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 */
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;
}

View file

@ -10,11 +10,13 @@
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;
};

View 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) {

View 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 '~':

View 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;
}

View 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)
;

View 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;

View 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