fixed two little bugs

This commit is contained in:
eck 1990-08-31 10:27:12 +00:00
parent 1cb247fa39
commit f614fc6dc3
2 changed files with 16 additions and 5 deletions

View file

@ -203,9 +203,20 @@ int to_endif;
on the same level. on the same level.
*/ */
id = findidf(tk.tk_str); id = findidf(tk.tk_str);
if (id == (struct idf *)0) {
/* invalid word seen after the '#' */
error("%s: unknown control", tk.tk_str);
}
free(tk.tk_str); free(tk.tk_str);
if (id == (struct idf *)0) continue;
switch(id->id_resmac) { switch(id->id_resmac) {
default: case K_DEFINE:
case K_ERROR:
case K_INCLUDE:
case K_LINE:
case K_PRAGMA:
case K_UNDEF:
case K_FILE:
SkipToNewLine(); SkipToNewLine();
break; break;
case K_IF: case K_IF:

View file

@ -215,10 +215,10 @@ preprocess(fn)
case STCHAR: case STCHAR:
{ {
register int stopc = c; register int stopc = c;
int escaped = 0; int escaped;
do { do {
escaped = 0;
echo(c); echo(c);
c = GetChar(); c = GetChar();
if (c == '\n') { if (c == '\n') {
@ -230,14 +230,14 @@ preprocess(fn)
flush((int)(op-_obuf)); flush((int)(op-_obuf));
return; return;
} }
if (!escaped && c == '\\') { if (c == '\\') {
echo(c); echo(c);
c = GetChar(); c = GetChar();
if (c == '\n') { if (c == '\n') {
++LineNumber; ++LineNumber;
lineno++; lineno++;
} else escaped = 1; } else escaped = 1;
} else escaped = 0; }
} while (escaped || c != stopc); } while (escaped || c != stopc);
echo(c); echo(c);
if (c == '\n') if (c == '\n')