ref: b5bfdc4046312756d217fade2fb7ec63de568ff0
parent: 1a3a60b609e8a20d0ea2290027827f45384a0d97
author: Ori Bernstein <[email protected]>
date: Sat Nov 26 09:12:32 EST 2011
Fix nested comments. We had some parsing bugs. Fixed.
--- a/parse/tok.c
+++ b/parse/tok.c
@@ -88,26 +88,27 @@
while (1) {
c = next();
switch (c) {
+ /* enter level of nesting */
case '/':
- if (peekn(1) == '*')
+ if (match('*'))
depth++;
break;
+ /* leave level of nesting */
case '*':
- if (peekn(1) == '/')
+ if (match('/'))
depth--;
- if (depth == 0)
- goto done;
break;
+ /* have to keep line numbers synced */
case '\n':
line++;
break;
- case EOF:
+ case '\0':
fatal(line, "File ended within comment starting at line %d", startln);
break;
}
+ if (depth == 0)
+ break;
}
-done:
- return;
}
void eatspace()