[hackers] [scc] Add #elif || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Mon, 27 Jul 2015 17:09:31 +0200 (CEST)

commit aaf9dd81207b3944018233ca15f6befa871aaf0f
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Mon Jul 27 10:56:43 2015 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Mon Jul 27 10:56:43 2015 +0200

    Add #elif
    
    The implemetation of elif is really easy, it is a #else chained
    with a #if.

diff --git a/cc1/cc1.h b/cc1/cc1.h
index 8da3585..84982e2 100644
--- a/cc1/cc1.h
+++ b/cc1/cc1.h
_AT_@ -214,6 +214,7 @@ enum tokens {
         PRAGMA,
         ERROR,
         IFDEF,
+ ELIF,
         IFNDEF,
         UNDEF,
         ENDIF,
diff --git a/cc1/cpp.c b/cc1/cpp.c
index 9099840..7dab27e 100644
--- a/cc1/cpp.c
+++ b/cc1/cpp.c
_AT_@ -522,6 +522,13 @@ elseclause(void)
 }
 
 static void
+elif(void)
+{
+ elseclause();
+ ifclause(0, 0);
+}
+
+static void
 undef(void)
 {
         Symbol *sym;
_AT_@ -549,6 +556,7 @@ cpp(void)
                 {LINE, line},
                 {IFDEF, ifdef},
                 {IF, cppif},
+ {ELIF, elif},
                 {IFNDEF, ifndef},
                 {ELSE, elseclause},
                 {ENDIF, endif},
diff --git a/cc1/symbol.c b/cc1/symbol.c
index 8c86de2..0b672fb 100644
--- a/cc1/symbol.c
+++ b/cc1/symbol.c
_AT_@ -263,6 +263,7 @@ ikeywords(void)
                 {"line", LINE, LINE},
                 {"ifdef", IFDEF, IFDEF},
                 {"if", IF, IF},
+ {"elif", ELIF, ELIF},
                 {"else", ELSE, ELSE},
                 {"ifndef", IFNDEF, IFNDEF},
                 {"endif", ENDIF, ENDIF},
Received on Mon Jul 27 2015 - 17:09:31 CEST

This archive was generated by hypermail 2.3.0 : Mon Jul 27 2015 - 17:12:13 CEST