]> git.rm.cloudns.org Git - xonotic/gmqcc.git/commitdiff
Better handling of __VA_ARGS__ subscripting.
authorDale Weiler <killfieldengine@gmail.com>
Sun, 27 Jan 2013 21:27:50 +0000 (21:27 +0000)
committerDale Weiler <killfieldengine@gmail.com>
Sun, 27 Jan 2013 21:27:50 +0000 (21:27 +0000)
ftepp.c

diff --git a/ftepp.c b/ftepp.c
index b695edc24d03fae7f5b8df4f0fd27a6da9ae4fef..0fb7681c579314df26ea7aaa426d7d5eccf57860 100644 (file)
--- a/ftepp.c
+++ b/ftepp.c
@@ -408,13 +408,18 @@ static bool ftepp_define_body(ftepp_t *ftepp, ppmacro *macro)
 {
     pptoken *ptok;
     while (ftepp->token != TOKEN_EOL && ftepp->token < TOKEN_EOF) {
-        size_t index;
+        bool   subscript = false;
+        size_t index     = 0;
         if (macro->variadic && !strcmp(ftepp_tokval(ftepp), "__VA_ARGS__")) {
             /* remember the token */
-            if (ftepp_next(ftepp) == '#' &&
-                ftepp_next(ftepp) == '#' &&
-                ftepp_next(ftepp) == '[')
-            {
+            if (ftepp_next(ftepp) == '#') {
+                subscript = true;
+            }
+
+            if (subscript && ftepp_next(ftepp) != '#') {
+                ftepp_error(ftepp, "expected `##` in __VA_ARGS__ for subscripting");
+                return false;
+            } else if (subscript && ftepp_next(ftepp) == '[') {
                 if (ftepp_next(ftepp) != TOKEN_INTCONST) {
                     ftepp_error(ftepp, "expected index for __VA_ARGS__ subscript");
                     return false;