From: ceriel Date: Wed, 19 Aug 1987 10:36:37 +0000 (+0000) Subject: bug fixes: ifval must be an arith, not an int X-Git-Tag: release-5-5~3884 X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=d35035fab8508b3ddae078e5922caf7b2d682aa3;p=ack.git bug fixes: ifval must be an arith, not an int --- diff --git a/util/cpp/LLlex.c b/util/cpp/LLlex.c index 8df9a28ef..d188cfbea 100644 --- a/util/cpp/LLlex.c +++ b/util/cpp/LLlex.c @@ -26,6 +26,7 @@ int AccDefined = 0; /* accept "defined(...)" */ int UnknownIdIsZero = 0; /* interpret unknown id as integer 0 */ char *string_token(); +char *strcpy(); PushLex() { @@ -192,7 +193,8 @@ go_on: } case STCHAR: /* character constant */ { - register int val = 0, size = 0; + register arith val = 0; + register int size = 0; LoadChar(c); if (c == '\'') @@ -216,7 +218,7 @@ go_on: size++; LoadChar(c); } - if (size > sizeof(int)) + if (size > sizeof(arith)) error("character constant too long"); ptok->tk_val = val; return ptok->tk_symb = INTEGER; @@ -226,7 +228,7 @@ go_on: register char *np = &buf[1]; register int base = 10; register int vch; - register int val = 0; + register arith val = 0; if (c == '0') { *np++ = c; @@ -319,6 +321,7 @@ string_token(nm, stop_char) LoadChar(c); } str[pos++] = '\0'; /* for filenames etc. */ + str = Srealloc(str, pos); return str; } diff --git a/util/cpp/LLlex.h b/util/cpp/LLlex.h index 280567753..cbdb188f3 100644 --- a/util/cpp/LLlex.h +++ b/util/cpp/LLlex.h @@ -10,11 +10,13 @@ to it. */ +#include + /* the structure of a token: */ struct token { int tok_symb; /* the token itself */ union { - int tok_val; /* numeric values */ + arith tok_val; /* numeric values */ char *tok_str; /* string/filespecifier */ } tok_data; }; diff --git a/util/cpp/ch7bin.c b/util/cpp/ch7bin.c index 3eb397b6a..2400567e0 100644 --- a/util/cpp/ch7bin.c +++ b/util/cpp/ch7bin.c @@ -6,9 +6,10 @@ /* EVALUATION OF BINARY OPERATORS */ #include "Lpars.h" +#include ch7bin(pval, oper, val) - register int *pval, val; + register arith *pval, val; int oper; { switch (oper) { diff --git a/util/cpp/ch7mon.c b/util/cpp/ch7mon.c index 1bb38b703..1cb742499 100644 --- a/util/cpp/ch7mon.c +++ b/util/cpp/ch7mon.c @@ -6,9 +6,10 @@ /* EVALUATION OF MONADIC OPERATORS */ #include "Lpars.h" +#include ch7mon(oper, pval) - register int *pval; + register arith *pval; { switch (oper) { case '~': diff --git a/util/cpp/domacro.c b/util/cpp/domacro.c index d58706be5..665233e2f 100644 --- a/util/cpp/domacro.c +++ b/util/cpp/domacro.c @@ -6,7 +6,6 @@ /* PREPROCESSOR: CONTROLLINE INTERPRETER */ #include "interface.h" -#include #include "LLlex.h" #include "Lpars.h" #include "debug.h" @@ -258,7 +257,7 @@ do_include() inctable[0] = WorkingDir; if (filenm) { if (!InsertFile(filenm, &inctable[tok==FILESPECIFIER],&result)){ - error("cannot find include file \"%s\"", filenm); + fatal("cannot find include file \"%s\"", filenm); } else { WorkingDir = getwdir(result); @@ -645,13 +644,12 @@ get_text(formals, length) text_size <<= 1); } else { - int sz = idp - id_buf; + int sz = idp - id_buf + 1; idp = id_buf; - while (pos + sz >= text_size) - text = Srealloc(text, - text_size <<= 1); + while (pos + sz >= text_size) text_size <<= 1; + text = Srealloc(text, text_size); while (text[pos++] = *idp++) ; pos--; } @@ -664,6 +662,7 @@ get_text(formals, length) } } text[pos++] = '\0'; + text = Srealloc(text, pos); *length = pos - 1; return text; } diff --git a/util/cpp/expression.g b/util/cpp/expression.g index fde3225ca..d12e6aa6d 100644 --- a/util/cpp/expression.g +++ b/util/cpp/expression.g @@ -10,8 +10,9 @@ { #include "LLlex.h" +#include -extern int ifval; +extern arith ifval; } if_expression @@ -20,14 +21,14 @@ if_expression ; /* 7.1 */ -primary(int *pval;) +primary(arith *pval;) : constant(pval) | '(' expression(pval) ')' ; -unary(int *pval;) +unary(arith *pval;) {int oper;} : unop(&oper) @@ -37,8 +38,8 @@ unary(int *pval;) primary(pval) ; -binary_expression(int maxrank; int *pval;) - {int oper; int val1;} +binary_expression(int maxrank; arith *pval;) + {int oper; arith val1;} : unary(pval) [%while (rank_of(DOT) <= maxrank) @@ -51,8 +52,8 @@ binary_expression(int maxrank; int *pval;) ; /* 7.13 */ -conditional_expression(int *pval;) - {int val1 = 0, val2 = 0;} +conditional_expression(arith *pval;) + {arith val1 = 0, val2 = 0;} : /* allow all binary operators */ binary_expression(rank_of('?') - 1, pval) @@ -65,14 +66,14 @@ conditional_expression(int *pval;) ; /* 7.14 */ -assignment_expression(int *pval;) +assignment_expression(arith *pval;) : conditional_expression(pval) ; /* 7.15 */ -expression(int *pval;) - {int val1;} +expression(arith *pval;) + {arith val1;} : assignment_expression(pval) [ ',' @@ -119,11 +120,11 @@ binop(int *oper;) : {*oper = DOT;} ; -constant(int *pval;) : +constant(arith *pval;) : INTEGER {*pval = dot.tk_val;} ; -constant_expression (int *pval;) : +constant_expression (arith *pval;) : assignment_expression(pval) ; diff --git a/util/cpp/main.c b/util/cpp/main.c index 11c1edc54..ac04bca59 100644 --- a/util/cpp/main.c +++ b/util/cpp/main.c @@ -6,6 +6,7 @@ /* MAIN PROGRAM */ #include +#include #include "file_info.h" #include "idfsize.h" @@ -14,7 +15,7 @@ extern char *getwdir(); extern int err_occurred; int idfsize = IDFSIZE; -int ifval; +arith ifval; char *prog_name; diff --git a/util/cpp/replace.c b/util/cpp/replace.c index ce5941c85..8aa4f4ea5 100644 --- a/util/cpp/replace.c +++ b/util/cpp/replace.c @@ -10,7 +10,6 @@ #include "textsize.h" /* UF */ #include -#include #include #include "idf.h" #include "input.h" @@ -185,7 +184,7 @@ macro2buffer(idef, actpars, siztext) } text[pos] = '\0'; *siztext = pos; - return text; + return Srealloc(text, pos+1); } EXPORT