Added some %persistents, improved behaviour of preprocessor, and other
minor mods
This commit is contained in:
parent
c483664bb1
commit
1b08effa77
|
@ -321,7 +321,7 @@ firstline:
|
|||
while (ch != '\'') {
|
||||
if (ch == '\n') {
|
||||
lexerror("newline in character constant");
|
||||
LineNumber++;
|
||||
PushBack();
|
||||
break;
|
||||
}
|
||||
if (ch == '\\') {
|
||||
|
@ -522,7 +522,7 @@ string_token(nm, stop_char, plen)
|
|||
while (ch != stop_char) {
|
||||
if (ch == '\n') {
|
||||
lexerror("newline in %s", nm);
|
||||
LineNumber++;
|
||||
PushBack();
|
||||
break;
|
||||
}
|
||||
if (ch == EOI) {
|
||||
|
|
|
@ -291,7 +291,7 @@ arrayer(arith *sizep;)
|
|||
|
||||
formal_list (struct formal **fmp;)
|
||||
:
|
||||
formal(fmp) [ ',' formal(fmp) ]*
|
||||
formal(fmp) [ %persistent ',' formal(fmp) ]*
|
||||
;
|
||||
|
||||
formal(struct formal **fmp;)
|
||||
|
|
|
@ -167,12 +167,18 @@ skip_block(to_endif)
|
|||
on the same level.
|
||||
*/
|
||||
switch(tk.tk_idf->id_resmac) {
|
||||
default:
|
||||
SkipRestOfLine();
|
||||
break;
|
||||
case K_IF:
|
||||
case K_IFDEF:
|
||||
case K_IFNDEF:
|
||||
push_if();
|
||||
SkipRestOfLine();
|
||||
break;
|
||||
case K_ELIF:
|
||||
if (ifstack[nestlevel])
|
||||
lexwarning("#elif without corresponding #if");
|
||||
if (! to_endif && nestlevel == skiplevel) {
|
||||
nestlevel--;
|
||||
push_if();
|
||||
|
@ -181,12 +187,15 @@ skip_block(to_endif)
|
|||
return;
|
||||
}
|
||||
}
|
||||
else SkipRestOfLine();
|
||||
break;
|
||||
case K_ELSE:
|
||||
if (ifstack[nestlevel])
|
||||
lexwarning("#else without corresponding #if");
|
||||
SkipRestOfLine();
|
||||
if (! to_endif) {
|
||||
++(ifstack[nestlevel]);
|
||||
if (nestlevel == skiplevel) {
|
||||
SkipRestOfLine();
|
||||
NoUnstack--;
|
||||
return;
|
||||
}
|
||||
|
@ -194,8 +203,8 @@ skip_block(to_endif)
|
|||
break;
|
||||
case K_ENDIF:
|
||||
ASSERT(nestlevel > nestlow);
|
||||
if (nestlevel == skiplevel) {
|
||||
SkipRestOfLine();
|
||||
if (nestlevel == skiplevel) {
|
||||
nestlevel--;
|
||||
NoUnstack--;
|
||||
return;
|
||||
|
|
|
@ -72,7 +72,8 @@ parameter_list(struct expr **expp;)
|
|||
:
|
||||
assignment_expression(expp)
|
||||
{any2opnd(expp, PARCOMMA);}
|
||||
[ ','
|
||||
[ %persistent
|
||||
','
|
||||
assignment_expression(&e1)
|
||||
{any2opnd(&e1, PARCOMMA);}
|
||||
{ch7bin(expp, PARCOMMA, e1);}
|
||||
|
|
|
@ -557,8 +557,8 @@ ch_array(tpp, ex)
|
|||
struct expr *ex;
|
||||
{
|
||||
register struct type *tp = *tpp;
|
||||
register arith length = ex->SG_LEN;
|
||||
char *s;
|
||||
register int length = ex->SG_LEN, i;
|
||||
register char *to, *from, *s;
|
||||
|
||||
ASSERT(ex->ex_class == String);
|
||||
if (tp->tp_size == (arith)-1) {
|
||||
|
@ -575,10 +575,14 @@ ch_array(tpp, ex)
|
|||
}
|
||||
/* throw out the characters of the already prepared string */
|
||||
s = Malloc((unsigned) (length));
|
||||
clear(s, (int) (length));
|
||||
strncpy(s, ex->SG_VALUE, (int) length);
|
||||
clear(s, length);
|
||||
i = length <= ex->SG_LEN ? length : ex->SG_LEN;
|
||||
to = s; from = ex->SG_VALUE;
|
||||
while(--i >= 0) {
|
||||
*to++ = *from++;
|
||||
}
|
||||
free(ex->SG_VALUE);
|
||||
str_cst(s, (int) (length));
|
||||
str_cst(s, length);
|
||||
free(s);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue