Added ftepp predefs flag (ability to turn on/off predefs) disabled by default (even...
authorDale Weiler <killfieldengine@gmail.com>
Mon, 24 Dec 2012 00:21:55 +0000 (00:21 +0000)
committerDale Weiler <killfieldengine@gmail.com>
Mon, 24 Dec 2012 00:21:55 +0000 (00:21 +0000)
ftepp.c
main.c
opts.c
opts.def

diff --git a/ftepp.c b/ftepp.c
index 577cd6fe6241f79a21de5a1eb75e1c4fdb30af4a..e1ee582c634c722eac2a285a575b595f9788bb15 100644 (file)
--- a/ftepp.c
+++ b/ftepp.c
@@ -1391,14 +1391,16 @@ static bool ftepp_preprocess(ftepp_t *ftepp)
             case TOKEN_IDENT:
             case TOKEN_TYPENAME:
                 /* is it a predef? */
-                for (i = 0; i < sizeof(ftepp_predefs) / sizeof (*ftepp_predefs); i++) {
-                    if (!strcmp(ftepp_predefs[i].name, ftepp_tokval(ftepp))) {
-                        expand = ftepp_predefs[i].func(ftepp->lex);
-                        ftepp_out(ftepp, expand, false);
-                        ftepp_next(ftepp); /* skip */
-
-                        mem_d(expand); /* free memory */
-                        break;
+                if (OPTS_FLAG(FTEPP_PREDEFS)) {
+                    for (i = 0; i < sizeof(ftepp_predefs) / sizeof (*ftepp_predefs); i++) {
+                        if (!strcmp(ftepp_predefs[i].name, ftepp_tokval(ftepp))) {
+                            expand = ftepp_predefs[i].func(ftepp->lex);
+                            ftepp_out(ftepp, expand, false);
+                            ftepp_next(ftepp); /* skip */
+
+                            mem_d(expand); /* free memory */
+                            break;
+                        }
                     }
                 }
 
diff --git a/main.c b/main.c
index 838a26d3cc64301ae860966a68968906f1e36cb3..aa1e3a0d285a43e0b8497fd4bbe4f47d6608354d 100644 (file)
--- a/main.c
+++ b/main.c
@@ -261,6 +261,7 @@ static bool options_parse(int argc, char **argv) {
 
                 case 'E':
                     opts.pp_only = true;
+                    opts_set(opts.flags, FTEPP_PREDEFS, true); /* predefs on for -E */
                     break;
 
                 /* debug turns on -flno */
diff --git a/opts.c b/opts.c
index 4d7d9a08debaed3e9fa9d96dac23e973d0b7d907..c1b0e630783137d07288b921c68debfb50464ed3 100644 (file)
--- a/opts.c
+++ b/opts.c
@@ -57,6 +57,7 @@ static void opts_setdefault() {
     /* flags */
     opts_set(opts.flags, ADJUST_VECTOR_FIELDS,           true);
     opts_set(opts.flags, FTEPP,                          false);
+    opts_set(opts.flags, FTEPP_PREDEFS,                  false);
     opts_set(opts.flags, CORRECT_TERNARY,                true);
 }
 
index 2c68898dda5c0e951d6d38cc05b00b830eaa94f0..111700db60bd6330b327fb3257e04c4052a04ef3 100644 (file)
--- a/opts.def
+++ b/opts.def
@@ -31,6 +31,7 @@
     GMQCC_DEFINE_FLAG(DARKPLACES_STRING_TABLE_BUG)
     GMQCC_DEFINE_FLAG(ADJUST_VECTOR_FIELDS)
     GMQCC_DEFINE_FLAG(FTEPP)
+    GMQCC_DEFINE_FLAG(FTEPP_PREDEFS)
     GMQCC_DEFINE_FLAG(RELAXED_SWITCH)
     GMQCC_DEFINE_FLAG(SHORT_LOGIC)
     GMQCC_DEFINE_FLAG(PERL_LOGIC)
 #endif
 
 #ifdef GMQCC_TYPE_OPTIMIZATIONS
-    GMQCC_DEFINE_FLAG(PEEPHOLE,       1)
-    GMQCC_DEFINE_FLAG(LOCAL_TEMPS,    3)
-    GMQCC_DEFINE_FLAG(TAIL_RECURSION, 1)
-    GMQCC_DEFINE_FLAG(TAIL_CALLS,     2)
-    GMQCC_DEFINE_FLAG(OVERLAP_LOCALS, 3)
+    GMQCC_DEFINE_FLAG(PEEPHOLE,             1)
+    GMQCC_DEFINE_FLAG(LOCAL_TEMPS,          3)
+    GMQCC_DEFINE_FLAG(TAIL_RECURSION,       1)
+    GMQCC_DEFINE_FLAG(TAIL_CALLS,           2)
+    GMQCC_DEFINE_FLAG(OVERLAP_LOCALS,       3)
     GMQCC_DEFINE_FLAG(STRIP_CONSTANT_NAMES, 1)
 #endif