Fixed a small bug where two line number directives next to each other wouldn't

be parsed properly (the second one would be treated as Modula-2 syntax).
This commit is contained in:
David Given 2016-08-13 12:21:16 +02:00
parent 8e869b56e7
commit dbf8332bf0

View file

@ -188,55 +188,57 @@ CheckForLineDirective()
register char *c = buf; register char *c = buf;
if (ch != '#') { for (;;) {
PushBack(); if (ch != '#') {
return; PushBack();
}
do { /*
* Skip to next digit
* Do not skip newlines
*/
ch = getch();
if (class(ch) == STNL || class(ch) == STEOI) {
LineNumber++;
error(s_error);
return; return;
} }
} while (class(ch) != STNUM); do { /*
while (class(ch) == STNUM) { * Skip to next digit
i = i*10 + (ch - '0'); * Do not skip newlines
ch = getch(); */
}
while (ch != '"' && class(ch) != STNL && class(ch) != STEOI)
ch = getch();
if (ch == '"') {
c = buf;
do {
ch = getch(); ch = getch();
if (c < &buf[IDFSIZE]) *c++ = ch;
if (class(ch) == STNL || class(ch) == STEOI) { if (class(ch) == STNL || class(ch) == STEOI) {
LineNumber++; LineNumber++;
error(s_error); error(s_error);
return; return;
} }
} while (ch != '"'); } while (class(ch) != STNUM);
*--c = '\0'; while (class(ch) == STNUM) {
do { i = i*10 + (ch - '0');
ch = getch(); ch = getch();
} while (class(ch) != STNL && class(ch) != STEOI);
/*
* Remember the file name
*/
if (class(ch) == STNL && strcmp(FileName,buf)) {
FileName = Salloc(buf,(unsigned) strlen(buf) + 1);
WorkingDir = getwdir(FileName);
} }
while (ch != '"' && class(ch) != STNL && class(ch) != STEOI)
ch = getch();
if (ch == '"') {
c = buf;
do {
ch = getch();
if (c < &buf[IDFSIZE]) *c++ = ch;
if (class(ch) == STNL || class(ch) == STEOI) {
LineNumber++;
error(s_error);
return;
}
} while (ch != '"');
*--c = '\0';
do {
ch = getch();
} while (class(ch) != STNL && class(ch) != STEOI);
/*
* Remember the file name
*/
if (class(ch) == STNL && strcmp(FileName,buf)) {
FileName = Salloc(buf,(unsigned) strlen(buf) + 1);
WorkingDir = getwdir(FileName);
}
}
if (class(ch) == STEOI) {
error(s_error);
return;
}
LineNumber = i;
} }
if (class(ch) == STEOI) {
error(s_error);
return;
}
LineNumber = i;
} }
STATIC STATIC