]> thyrsus.com Git - cupl.git/commitdiff
Port to modern ANSI C.
authorEric S. Raymond <esr@thyrsus.com>
Wed, 13 Oct 2010 10:40:41 +0000 (06:40 -0400)
committerEric S. Raymond <esr@thyrsus.com>
Wed, 13 Oct 2010 10:40:41 +0000 (06:40 -0400)
cupl.l
cupl.y
execute.c
interpret.c
monitor.c

diff --git a/cupl.l b/cupl.l
index c455096a3c4b4a8733dbaeff8ec496dd321a2251..cabafab4f7dbda31e0c847ac98182269fb967d4f 100644 (file)
--- a/cupl.l
+++ b/cupl.l
@@ -148,7 +148,7 @@ static node *intern_identifier(char *str)
 
 #ifdef PARSEDEBUG
        if (verbose >= DEBUG_ALLOCATE)
-           (void) printf("intern: %9x                        (IDENTIFIER: %s)\n",
+           (void) printf("intern: %p                        (IDENTIFIER: %s)\n",
                  new, str);
 #endif /* PARSEDEBUG */
 
@@ -172,7 +172,7 @@ static node *intern_number(char *str)
 
 #ifdef PARSEDEBUG
     if (verbose >= DEBUG_ALLOCATE)
-       (void) printf("intern: %9x                        (NUMBER: %f)\n", new, numval);
+       (void) printf("intern: %p                        (NUMBER: %f)\n", new, numval);
 #endif /* PARSEDEBUG */
     return(new);
 }
@@ -195,7 +195,7 @@ static node *intern_string(char *str)
 
 #ifdef PARSEDEBUG
     if (verbose >= DEBUG_ALLOCATE)
-       (void) printf("intern: %9x                        (STRING: '%s')\n",
+       (void) printf("intern: %p                        (STRING: '%s')\n",
                      new, new->u.string);
 #endif /* PARSEDEBUG */
 
diff --git a/cupl.y b/cupl.y
index 4b999eef1b0f0c946d984a05b40d462c6c96a489..7b5598b69b8d7ed50b139182277b44b540dd6309 100644 (file)
--- a/cupl.y
+++ b/cupl.y
@@ -23,6 +23,7 @@ author first.
 #include <stdio.h>
 #include <string.h>
 #include <setjmp.h>
+#include <stdlib.h>
 
 #ifdef PARSEDEBUG
 static int statement_count;
@@ -45,7 +46,7 @@ int yydebug;
 /* keywords */
 %token ABS ALL ALLOCATE AND ATAN BLOCK BY COMMENT COS DEC DET DOT ELSE END EXP
 %token FLOOR FOR GE GO GT IDN IF INC INV LE LET LN LOG LT MAX MIN NE OR PERFORM
-%token POSMAX POSMIN RAND READ SGM SIN SQRT STOP THEN TIMES TITLE TO TRC TRN
+%token POSMAX POSMIN RAND READ SGM SIN SQRT STOP THEN TIMES TO TRC TRN
 %token UNTIL WATCH WHILE WRITE DATA
 
 %token <node> POWER
@@ -309,7 +310,7 @@ node        *left, *right;  /* child nodes */
 
 #ifdef PARSEDEBUG
     if (verbose >= DEBUG_ALLOCATE)
-       (void) printf("cons:   %9x -> %9x %9x (%s)\n",
+       (void) printf("cons:   %p -> %p %p (%s)\n",
                      new, left, right, tokdump(op));
 #endif /* PARSEDEBUG */
 
index 74401e24b0befc57f9f08e77e68d3096f641184a..8666feaa2f7c47b0c59acfb9b0f5a2235de3cdc1 100644 (file)
--- a/execute.c
+++ b/execute.c
@@ -126,7 +126,7 @@ static void display_return(node *tree, node *left, node *right, value v)
 {
     if (verbose >= DEBUG_EXECUTE)
     {
-       (void) printf("eval returns: %x (%-10s of %9x, %9x) ",
+       (void) printf("eval returns: %p (%-10s of %p, %p) ",
                      tree, tokdump(tree->type), left, right);
 
        if (RELATION(tree->type))
@@ -141,7 +141,7 @@ static void display_return(node *tree, node *left, node *right, value v)
 static void cupl_assign(node *to, value from)
 /* assign result of the expression at the cdr to the identifier at the cdr */
 {
-    static value cupl_eval(node *);
+    value cupl_eval(node *tree);
 
     deallocate_value(&(to->syminf->value));
     to->syminf->value = from;
@@ -152,7 +152,7 @@ static void cupl_assign(node *to, value from)
     }
 }
 
-static value cupl_eval(node *tree)
+value cupl_eval(node *tree)
 /* recursively evaluate a CUPL parse tree */
 {
     node *pc;  /* pointer to statement being evaluated */
@@ -164,7 +164,7 @@ static value cupl_eval(node *tree)
     int                n;
 
     if (verbose >= DEBUG_EXECUTE)
-       (void) printf("eval begins:  %x (%-10s of %9x, %9x)\n",
+       (void) printf("eval begins:  %p (%-10s of %p, %p)\n",
                      tree, tokdump(tree->type), tree->car, tree->cdr);
 
     switch(tree->type)
@@ -569,7 +569,7 @@ static value cupl_eval(node *tree)
        for (pc = tree->car; pc; pc = next)
        {
            if (verbose >= DEBUG_EXECUTE)
-               (void) printf("statement %2d: %x (%-10s of %9x, %9x)\n",
+               (void) printf("statement %2d: %p (%-10s of %p, %p)\n",
                      pc->number, pc, tokdump(pc->type), pc->car, pc->cdr);
 
            switch (pc->car->type)
index ef0880bbbb45893b78eea559114d426330cfbf95..872eb5c695397df81cfb910f708941683b0eb2c2 100644 (file)
@@ -17,6 +17,7 @@ differently if we get a compiler back end.
 *****************************************************************************/
 /*LINTLIBRARY*/
 #include <stdio.h>
+#include <stdlib.h>
 #include "cupl.h"
 #include "tokens.h"
 
@@ -86,7 +87,7 @@ static void prettyprint(node *tree, int indent)
            (void) printf("%-20s", tokdump(tree->type));
 
        if (verbose >= DEBUG_EXECUTE)
-           (void) printf("                          (%x -> %x, %x)",
+           (void) printf("                          (%p -> %p, %p)",
                          tree,
                          tree->car,
                          tree->cdr);
index 343eb5c9efd9a025cdbe7c95a3e516240b9c46fa..762dfcfd132d4c37c3f45cccfc26e5b81e89820f 100644 (file)
--- a/monitor.c
+++ b/monitor.c
@@ -63,6 +63,7 @@ library.
 #include <stdlib.h>
 #include <stdarg.h>
 #include <math.h>
+#include <string.h>
 #include "cupl.h"
 
 #define max(x, y)      ((x) > (y) ? (x) : (y))