]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - ftepp.c
include: guard the actual inclusion with ftepp->output_on so that include inside...
[xonotic/gmqcc.git] / ftepp.c
diff --git a/ftepp.c b/ftepp.c
index ce5dd8ac2e0044f1388c815e797478334bac97f7..2ce9f4734fc7abd50357f5ad01bb59e040ab8988 100644 (file)
--- a/ftepp.c
+++ b/ftepp.c
@@ -82,7 +82,7 @@ static uint32_t ftepp_predef_randval  = 0;
 char *ftepp_predef_date(lex_file *context) {
     struct tm *itime;
     time_t     rtime;
-    char      *value = mem_a(82);
+    char      *value = (char*)mem_a(82);
     /* 82 is enough for strftime but we also have " " in our string */
 
     (void)context;
@@ -100,7 +100,7 @@ char *ftepp_predef_date(lex_file *context) {
 char *ftepp_predef_time(lex_file *context) {
     struct tm *itime;
     time_t     rtime;
-    char      *value = mem_a(82);
+    char      *value = (char*)mem_a(82);
     /* 82 is enough for strftime but we also have " " in our string */
 
     (void)context;
@@ -1285,11 +1285,17 @@ static bool ftepp_directive_warning(ftepp_t *ftepp) {
             ftepp_next(ftepp);
         }
         vec_push(message, '\0');
-        store = ftepp_warn(ftepp, WARN_CPP, message);
+        if (ftepp->output_on)
+            store = ftepp_warn(ftepp, WARN_CPP, message);
+        else
+            store = false;
         vec_free(message);
         return store;
     }
 
+    if (!ftepp->output_on)
+        return false;
+
     unescape  (ftepp_tokval(ftepp), ftepp_tokval(ftepp));
     return ftepp_warn(ftepp, WARN_CPP, "#warning %s", ftepp_tokval(ftepp));
 }
@@ -1309,11 +1315,15 @@ static void ftepp_directive_error(ftepp_t *ftepp) {
             ftepp_next(ftepp);
         }
         vec_push(message, '\0');
-        ftepp_error(ftepp, message);
+        if (ftepp->output_on)
+            ftepp_error(ftepp, message);
         vec_free(message);
         return;
     }
 
+    if (!ftepp->output_on)
+        return;
+
     unescape  (ftepp_tokval(ftepp), ftepp_tokval(ftepp));
     ftepp_error(ftepp, "#error %s", ftepp_tokval(ftepp));
 }
@@ -1333,11 +1343,15 @@ static void ftepp_directive_message(ftepp_t *ftepp) {
             ftepp_next(ftepp);
         }
         vec_push(message, '\0');
-        con_cprintmsg(&ftepp->lex->tok.ctx, LVL_MSG, "message", message);
+        if (ftepp->output_on)
+            con_cprintmsg(&ftepp->lex->tok.ctx, LVL_MSG, "message", message);
         vec_free(message);
         return;
     }
 
+    if (!ftepp->output_on)
+        return;
+
     unescape     (ftepp_tokval(ftepp), ftepp_tokval(ftepp));
     con_cprintmsg(&ftepp->lex->tok.ctx, LVL_MSG, "message",  ftepp_tokval(ftepp));
 }
@@ -1365,6 +1379,11 @@ static bool ftepp_include(ftepp_t *ftepp)
         return false;
     }
 
+    if (!ftepp->output_on) {
+        ftepp_next(ftepp);
+        return true;
+    }
+
     ctx = ftepp_ctx(ftepp);
 
     unescape(ftepp_tokval(ftepp), ftepp_tokval(ftepp));