bug fixes: ifval must be an arith, not an int
authorceriel <none@none>
Wed, 19 Aug 1987 10:36:37 +0000 (10:36 +0000)
committerceriel <none@none>
Wed, 19 Aug 1987 10:36:37 +0000 (10:36 +0000)
util/cpp/LLlex.c
util/cpp/LLlex.h
util/cpp/ch7bin.c
util/cpp/ch7mon.c
util/cpp/domacro.c
util/cpp/expression.g
util/cpp/main.c
util/cpp/replace.c

index 8df9a28..d188cfb 100644 (file)
@@ -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;
 }
 
index 2805677..cbdb188 100644 (file)
        to it.
 */
 
+#include <em_arith.h>
+
 /* 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;
 };
index 3eb397b..2400567 100644 (file)
@@ -6,9 +6,10 @@
 /* EVALUATION OF BINARY OPERATORS */
 
 #include       "Lpars.h"
+#include       <em_arith.h>
 
 ch7bin(pval, oper, val)
-       register int *pval, val;
+       register arith *pval, val;
        int oper;
 {
        switch (oper)   {
index 1bb38b7..1cb7424 100644 (file)
@@ -6,9 +6,10 @@
 /* EVALUATION OF MONADIC OPERATORS */
 
 #include       "Lpars.h"
+#include       <em_arith.h>
 
 ch7mon(oper, pval)
-       register int *pval;
+       register arith *pval;
 {
        switch (oper)   {
        case '~':
index d58706b..665233e 100644 (file)
@@ -6,7 +6,6 @@
 /* PREPROCESSOR: CONTROLLINE INTERPRETER */
 
 #include       "interface.h"
-#include       <em_arith.h>
 #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;
 }
index fde3225..d12e6aa 100644 (file)
@@ -10,8 +10,9 @@
 
 {
 #include       "LLlex.h"
+#include       <em_arith.h>
 
-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)
 ;
index 11c1edc..ac04bca 100644 (file)
@@ -6,6 +6,7 @@
 /* MAIN PROGRAM */
 
 #include <alloc.h>
+#include <em_arith.h>
 #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;
 
index ce5941c..8aa4f4e 100644 (file)
@@ -10,7 +10,6 @@
 #include       "textsize.h"    /* UF */
 
 #include       <alloc.h>
-#include       <em_arith.h>
 #include       <assert.h>
 #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