summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorragge <ragge>2010-04-18 16:42:32 +0000
committerragge <ragge>2010-04-18 16:42:32 +0000
commitf80f6bd52cbd0e57206c489bbafc55184b4d9747 (patch)
tree765e5efa49c57d5a046e3cb72e6c91e59ca262bc
parentc10cac8b4bad4f9f3afb414b94209bf32c08426b (diff)
Discard comments in yylex() so that -C works even with comments in
#if directives. Supposes to fix Jira#PCC-126 by Iain Hibbert.
-rw-r--r--token.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/token.c b/token.c
index 190478d..05557f2 100644
--- a/token.c
+++ b/token.c
@@ -109,7 +109,7 @@ static char spechr[256] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, C_2, C_SPEC, 0, 0, 0, C_2, C_SPEC,
- 0, 0, 0, C_2, 0, C_2, 0, C_SPEC,
+ 0, 0, 0, C_2, 0, C_2, 0, C_SPEC|C_2,
C_I, C_I, C_I, C_I, C_I, C_I, C_I, C_I,
C_I, C_I, 0, 0, C_2, C_2, C_2, C_SPEC,
@@ -399,8 +399,10 @@ chlit:
int c, wrn;
extern int readmac;
- if (Cflag && !flslvl && readmac)
+ if (Cflag && !flslvl && readmac) {
+ unch(ch);
return CMNT;
+ }
wrn = 0;
more: while ((c = inch()) && c != '*') {
@@ -538,6 +540,20 @@ yylex()
badop("");
break;
+ case '/':
+ if (Cflag == 0 || c2 != '*')
+ break;
+ /* Found comment that need to be skipped */
+ for (;;) {
+ ch = inpch();
+ c1: if (ch != '*')
+ continue;
+ if ((ch = inpch()) == '/')
+ break;
+ goto c1;
+ }
+ return yylex();
+
case NUMBER:
if (yytext[0] == '\'') {
yylval.node.op = NUMBER;