summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorragge <ragge>2009-08-04 19:23:44 +0000
committerragge <ragge>2009-08-04 19:23:44 +0000
commit3767af5a859910f75db5820f6480b65245391aad (patch)
treef4d3cd383a4da25dc86031b958b385b3136e4afa
parent770591808f64022dbef51f9026c03b283c409b80 (diff)
Always print out a \n after a directive that turned false, to avoid
indented # line directives to cc. Fixes Jira#PCC-66.
-rw-r--r--token.c45
1 files changed, 30 insertions, 15 deletions
diff --git a/token.c b/token.c
index 8bee165..69e380c 100644
--- a/token.c
+++ b/token.c
@@ -880,16 +880,22 @@ elsestmt(void)
}
static void
+skpln(void)
+{
+ /* just ignore the rest of the line */
+ while (inch() != '\n')
+ ;
+ unch('\n');
+ flslvl++;
+}
+
+static void
ifdefstmt(void)
{
int t;
if (flslvl) {
- /* just ignore the rest of the line */
- while (inch() != '\n')
- ;
- unch('\n');
- flslvl++;
+ skpln();
return;
}
do
@@ -897,10 +903,11 @@ ifdefstmt(void)
while (t == WSPACE);
if (t != IDENT)
error("bad ifdef");
- if (flslvl == 0 && lookup((usch *)yytext, FIND) != 0)
- trulvl++;
- else
+ if (lookup((usch *)yytext, FIND) == 0) {
+ putch('\n');
flslvl++;
+ } else
+ trulvl++;
chknl(0);
}
@@ -909,15 +916,20 @@ ifndefstmt(void)
{
int t;
+ if (flslvl) {
+ skpln();
+ return;
+ }
do
t = sloscan();
while (t == WSPACE);
if (t != IDENT)
error("bad ifndef");
- if (flslvl == 0 && lookup((usch *)yytext, FIND) == 0)
- trulvl++;
- else
+ if (lookup((usch *)yytext, FIND) != 0) {
+ putch('\n');
flslvl++;
+ } else
+ trulvl++;
chknl(0);
}
@@ -942,10 +954,11 @@ static void
ifstmt(void)
{
if (flslvl == 0) {
- if (yyparse())
- ++trulvl;
- else
+ if (yyparse() == 0) {
+ putch('\n');
++flslvl;
+ } else
+ ++trulvl;
} else
++flslvl;
}
@@ -964,8 +977,10 @@ elifstmt(void)
if (yyparse()) {
++trulvl;
prtline();
- } else
+ } else {
+ putch('\n');
++flslvl;
+ }
}
} else if (trulvl) {
++flslvl;