bug fixes: ifval must be an arith, not an int

This commit is contained in:
ceriel 1987-08-19 10:36:37 +00:00
parent d7b2998ebe
commit d35035fab8
8 changed files with 34 additions and 27 deletions

View file

@ -26,6 +26,7 @@ int AccDefined = 0; /* accept "defined(...)" */
int UnknownIdIsZero = 0; /* interpret unknown id as integer 0 */ int UnknownIdIsZero = 0; /* interpret unknown id as integer 0 */
char *string_token(); char *string_token();
char *strcpy();
PushLex() PushLex()
{ {
@ -192,7 +193,8 @@ go_on:
} }
case STCHAR: /* character constant */ case STCHAR: /* character constant */
{ {
register int val = 0, size = 0; register arith val = 0;
register int size = 0;
LoadChar(c); LoadChar(c);
if (c == '\'') if (c == '\'')
@ -216,7 +218,7 @@ go_on:
size++; size++;
LoadChar(c); LoadChar(c);
} }
if (size > sizeof(int)) if (size > sizeof(arith))
error("character constant too long"); error("character constant too long");
ptok->tk_val = val; ptok->tk_val = val;
return ptok->tk_symb = INTEGER; return ptok->tk_symb = INTEGER;
@ -226,7 +228,7 @@ go_on:
register char *np = &buf[1]; register char *np = &buf[1];
register int base = 10; register int base = 10;
register int vch; register int vch;
register int val = 0; register arith val = 0;
if (c == '0') { if (c == '0') {
*np++ = c; *np++ = c;
@ -319,6 +321,7 @@ string_token(nm, stop_char)
LoadChar(c); LoadChar(c);
} }
str[pos++] = '\0'; /* for filenames etc. */ str[pos++] = '\0'; /* for filenames etc. */
str = Srealloc(str, pos);
return str; return str;
} }

View file

@ -10,11 +10,13 @@
to it. to it.
*/ */
#include <em_arith.h>
/* the structure of a token: */ /* the structure of a token: */
struct token { struct token {
int tok_symb; /* the token itself */ int tok_symb; /* the token itself */
union { union {
int tok_val; /* numeric values */ arith tok_val; /* numeric values */
char *tok_str; /* string/filespecifier */ char *tok_str; /* string/filespecifier */
} tok_data; } tok_data;
}; };

View file

@ -6,9 +6,10 @@
/* EVALUATION OF BINARY OPERATORS */ /* EVALUATION OF BINARY OPERATORS */
#include "Lpars.h" #include "Lpars.h"
#include <em_arith.h>
ch7bin(pval, oper, val) ch7bin(pval, oper, val)
register int *pval, val; register arith *pval, val;
int oper; int oper;
{ {
switch (oper) { switch (oper) {

View file

@ -6,9 +6,10 @@
/* EVALUATION OF MONADIC OPERATORS */ /* EVALUATION OF MONADIC OPERATORS */
#include "Lpars.h" #include "Lpars.h"
#include <em_arith.h>
ch7mon(oper, pval) ch7mon(oper, pval)
register int *pval; register arith *pval;
{ {
switch (oper) { switch (oper) {
case '~': case '~':

View file

@ -6,7 +6,6 @@
/* PREPROCESSOR: CONTROLLINE INTERPRETER */ /* PREPROCESSOR: CONTROLLINE INTERPRETER */
#include "interface.h" #include "interface.h"
#include <em_arith.h>
#include "LLlex.h" #include "LLlex.h"
#include "Lpars.h" #include "Lpars.h"
#include "debug.h" #include "debug.h"
@ -258,7 +257,7 @@ do_include()
inctable[0] = WorkingDir; inctable[0] = WorkingDir;
if (filenm) { if (filenm) {
if (!InsertFile(filenm, &inctable[tok==FILESPECIFIER],&result)){ if (!InsertFile(filenm, &inctable[tok==FILESPECIFIER],&result)){
error("cannot find include file \"%s\"", filenm); fatal("cannot find include file \"%s\"", filenm);
} }
else { else {
WorkingDir = getwdir(result); WorkingDir = getwdir(result);
@ -645,13 +644,12 @@ get_text(formals, length)
text_size <<= 1); text_size <<= 1);
} }
else { else {
int sz = idp - id_buf; int sz = idp - id_buf + 1;
idp = id_buf; idp = id_buf;
while (pos + sz >= text_size) while (pos + sz >= text_size) text_size <<= 1;
text = Srealloc(text, text = Srealloc(text, text_size);
text_size <<= 1);
while (text[pos++] = *idp++) ; while (text[pos++] = *idp++) ;
pos--; pos--;
} }
@ -664,6 +662,7 @@ get_text(formals, length)
} }
} }
text[pos++] = '\0'; text[pos++] = '\0';
text = Srealloc(text, pos);
*length = pos - 1; *length = pos - 1;
return text; return text;
} }

View file

@ -10,8 +10,9 @@
{ {
#include "LLlex.h" #include "LLlex.h"
#include <em_arith.h>
extern int ifval; extern arith ifval;
} }
if_expression if_expression
@ -20,14 +21,14 @@ if_expression
; ;
/* 7.1 */ /* 7.1 */
primary(int *pval;) primary(arith *pval;)
: :
constant(pval) constant(pval)
| |
'(' expression(pval) ')' '(' expression(pval) ')'
; ;
unary(int *pval;) unary(arith *pval;)
{int oper;} {int oper;}
: :
unop(&oper) unop(&oper)
@ -37,8 +38,8 @@ unary(int *pval;)
primary(pval) primary(pval)
; ;
binary_expression(int maxrank; int *pval;) binary_expression(int maxrank; arith *pval;)
{int oper; int val1;} {int oper; arith val1;}
: :
unary(pval) unary(pval)
[%while (rank_of(DOT) <= maxrank) [%while (rank_of(DOT) <= maxrank)
@ -51,8 +52,8 @@ binary_expression(int maxrank; int *pval;)
; ;
/* 7.13 */ /* 7.13 */
conditional_expression(int *pval;) conditional_expression(arith *pval;)
{int val1 = 0, val2 = 0;} {arith val1 = 0, val2 = 0;}
: :
/* allow all binary operators */ /* allow all binary operators */
binary_expression(rank_of('?') - 1, pval) binary_expression(rank_of('?') - 1, pval)
@ -65,14 +66,14 @@ conditional_expression(int *pval;)
; ;
/* 7.14 */ /* 7.14 */
assignment_expression(int *pval;) assignment_expression(arith *pval;)
: :
conditional_expression(pval) conditional_expression(pval)
; ;
/* 7.15 */ /* 7.15 */
expression(int *pval;) expression(arith *pval;)
{int val1;} {arith val1;}
: :
assignment_expression(pval) assignment_expression(pval)
[ ',' [ ','
@ -119,11 +120,11 @@ binop(int *oper;) :
{*oper = DOT;} {*oper = DOT;}
; ;
constant(int *pval;) : constant(arith *pval;) :
INTEGER INTEGER
{*pval = dot.tk_val;} {*pval = dot.tk_val;}
; ;
constant_expression (int *pval;) : constant_expression (arith *pval;) :
assignment_expression(pval) assignment_expression(pval)
; ;

View file

@ -6,6 +6,7 @@
/* MAIN PROGRAM */ /* MAIN PROGRAM */
#include <alloc.h> #include <alloc.h>
#include <em_arith.h>
#include "file_info.h" #include "file_info.h"
#include "idfsize.h" #include "idfsize.h"
@ -14,7 +15,7 @@ extern char *getwdir();
extern int err_occurred; extern int err_occurred;
int idfsize = IDFSIZE; int idfsize = IDFSIZE;
int ifval; arith ifval;
char *prog_name; char *prog_name;

View file

@ -10,7 +10,6 @@
#include "textsize.h" /* UF */ #include "textsize.h" /* UF */
#include <alloc.h> #include <alloc.h>
#include <em_arith.h>
#include <assert.h> #include <assert.h>
#include "idf.h" #include "idf.h"
#include "input.h" #include "input.h"
@ -185,7 +184,7 @@ macro2buffer(idef, actpars, siztext)
} }
text[pos] = '\0'; text[pos] = '\0';
*siztext = pos; *siztext = pos;
return text; return Srealloc(text, pos+1);
} }
EXPORT EXPORT