From: Eric S. Raymond Date: Wed, 13 Oct 2010 10:40:41 +0000 (-0400) Subject: Port to modern ANSI C. X-Git-Tag: 1.7~3 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=0f1213d08574d51e5ebf1533d5b12ae8c88f9b20;p=cupl.git Port to modern ANSI C. --- diff --git a/cupl.l b/cupl.l index c455096..cabafab 100644 --- 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 4b999ee..7b5598b 100644 --- a/cupl.y +++ b/cupl.y @@ -23,6 +23,7 @@ author first. #include #include #include +#include #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 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 */ diff --git a/execute.c b/execute.c index 74401e2..8666fea 100644 --- 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) diff --git a/interpret.c b/interpret.c index ef0880b..872eb5c 100644 --- a/interpret.c +++ b/interpret.c @@ -17,6 +17,7 @@ differently if we get a compiler back end. *****************************************************************************/ /*LINTLIBRARY*/ #include +#include #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); diff --git a/monitor.c b/monitor.c index 343eb5c..762dfcf 100644 --- a/monitor.c +++ b/monitor.c @@ -63,6 +63,7 @@ library. #include #include #include +#include #include "cupl.h" #define max(x, y) ((x) > (y) ? (x) : (y))