summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorragge <ragge>2009-03-09 20:20:39 +0000
committerragge <ragge>2009-03-09 20:20:39 +0000
commit0ae485bf28d5b29d63757a3480af74900ad43607 (patch)
treea69e4e82271891fd93fca0e71664e3a57bf54ed1
parenta592b2884b2c7022d17cf8bae791bdfd09915d84 (diff)
Fix a few \n bugs.
-rw-r--r--token.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/token.c b/token.c
index 89f2cf4..9ba2aeb 100644
--- a/token.c
+++ b/token.c
@@ -100,11 +100,12 @@ yylex()
zagain:
yyp = 0;
-again:
yytext[yyp++] = ch = inch();
owasnl = wasnl;
wasnl = 0;
switch (ch) {
+ case -1:
+ return 0;
case '\n':
os = YYSTATE;
@@ -185,6 +186,7 @@ ppnum: for (;;) {
}
break;
}
+ unput(ch);
yytext[yyp] = 0;
if (mixed == 0) {
@@ -254,7 +256,7 @@ b1: unput(ch);
} else {
extern int inmac;
- while ((ch = input()) == ' ' || ch == '\t')
+contr: while ((ch = input()) == ' ' || ch == '\t')
;
unch(ch);
if (inmac)
@@ -321,8 +323,11 @@ b1: unput(ch);
goto any;
case '#':
- if (state != DEF)
+ if (state != DEF) {
+ if (owasnl)
+ goto contr;
goto any;
+ }
if ((ch = input()) == '#') {
yytext[yyp++] = ch;
ch = CONCAT;
@@ -406,10 +411,12 @@ b1: unput(ch);
/* Special hacks */
for (;;) { /* get chars */
ch = input();
- if (isalpha(ch) || isdigit(ch) || ch == '_')
+ if (isalpha(ch) || isdigit(ch) || ch == '_') {
yytext[yyp++] = ch;
- else
+ } else {
+ unput(ch);
break;
+ }
}
yytext[yyp] = 0; /* need already string */
@@ -511,7 +518,7 @@ b1: unput(ch);
} else
putstr((usch *)yytext);
xx:
- goto again;
+ goto zagain;
}
default:
@@ -546,7 +553,7 @@ b1: unput(ch);
break;
} /* endcase */
- goto again;
+ goto zagain;
yyret:
yytext[yyp] = 0;