[hackers] [scc] Simplify conditional compilation || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Thu, 13 Aug 2015 20:02:11 +0200 (CEST)

commit dfb4776b82942448a8daa298b2ba280117f4ddce
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Thu Aug 13 17:23:35 2015 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Thu Aug 13 17:23:35 2015 +0200

    Simplify conditional compilation

diff --git a/cc1/cpp.c b/cc1/cpp.c
index a645809..49f246e 100644
--- a/cc1/cpp.c
+++ b/cc1/cpp.c
_AT_@ -484,7 +484,10 @@ ifclause(int negate, int isifdef)
 
         if (cppctx == NR_COND-1)
                 error("too much nesting levels of conditional inclusion");
+
         n = cppctx++;
+ setnamespace(NS_CPP);
+ next();
 
         if (isifdef) {
                 if (yytoken != IDEN) {
_AT_@ -515,39 +518,23 @@ ifclause(int negate, int isifdef)
 static void
 cppif(void)
 {
- setnamespace(NS_CPP);
         disexpand = 0;
- next();
         ifclause(0, 0);
 }
 
 static void
 ifdef(void)
 {
- setnamespace(NS_CPP);
- next();
         ifclause(0, 1);
 }
 
 static void
 ifndef(void)
 {
- setnamespace(NS_CPP);
- next();
         ifclause(1, 1);
 }
 
 static void
-endif(void)
-{
- if (cppctx == 0)
- error("#endif without #if");
- if (!ifstatus[--cppctx])
- --cppoff;
- next();
-}
-
-static void
 elseclause(void)
 {
         int status;
_AT_@ -557,16 +544,30 @@ elseclause(void)
 
         status = (ifstatus[cppctx-1] ^= 1);
         cppoff += (status) ? -1 : 1;
+}
+
+static void
+cppelse(void)
+{
+ elseclause();
         next();
 }
 
 static void
 elif(void)
 {
- setnamespace(NS_CPP);
- disexpand = 0;
         elseclause();
- ifclause(0, 0);
+ cppif();
+}
+
+static void
+endif(void)
+{
+ if (cppctx == 0)
+ error("#endif without #if");
+ if (!ifstatus[--cppctx])
+ --cppoff;
+ next();
 }
 
 static void
_AT_@ -599,7 +600,7 @@ cpp(void)
                 {IF, cppif},
                 {ELIF, elif},
                 {IFNDEF, ifndef},
- {ELSE, elseclause},
+ {ELSE, cppelse},
                 {ENDIF, endif},
                 {UNDEF, undef},
                 {PRAGMA, pragma},
Received on Thu Aug 13 2015 - 20:02:11 CEST

This archive was generated by hypermail 2.3.0 : Thu Aug 13 2015 - 20:12:25 CEST