]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - ftepp.c
Don't delete the ftepp prematurely
[xonotic/gmqcc.git] / ftepp.c
diff --git a/ftepp.c b/ftepp.c
index e677e74a49af7c48b6ea4ea7f09fef6aecd6dc58..b8fc9f4a5734eadd74e032a6de359f7126f5652e 100644 (file)
--- a/ftepp.c
+++ b/ftepp.c
@@ -77,7 +77,7 @@ static void ftepp_errorat(ftepp_t *ftepp, lex_ctx ctx, const char *fmt, ...)
     ftepp->errors++;
 
     va_start(ap, fmt);
-    con_vprintmsg(LVL_ERROR, ctx.file, ctx.line, "error", fmt, ap);
+    con_cvprintmsg((void*)&ctx, LVL_ERROR, "error", fmt, ap);
     va_end(ap);
 }
 
@@ -88,7 +88,7 @@ static void ftepp_error(ftepp_t *ftepp, const char *fmt, ...)
     ftepp->errors++;
 
     va_start(ap, fmt);
-    con_vprintmsg(LVL_ERROR, ftepp->lex->tok.ctx.file, ftepp->lex->tok.ctx.line, "error", fmt, ap);
+    con_cvprintmsg((void*)&ftepp->lex->tok.ctx, LVL_ERROR, "error", fmt, ap);
     va_end(ap);
 }
 
@@ -106,7 +106,7 @@ static bool GMQCC_WARN ftepp_warn(ftepp_t *ftepp, int warntype, const char *fmt,
     }
 
     va_start(ap, fmt);
-    con_vprintmsg(lvl, ftepp->lex->tok.ctx.file, ftepp->lex->tok.ctx.line, "error", fmt, ap);
+    con_cvprintmsg((void*)&ftepp->lex->tok.ctx, lvl, "error", fmt, ap);
     va_end(ap);
     return opts_werror;
 }
@@ -135,6 +135,8 @@ static void pptoken_delete(pptoken *self)
 static ppmacro *ppmacro_new(lex_ctx ctx, const char *name)
 {
     ppmacro *macro = (ppmacro*)mem_a(sizeof(ppmacro));
+    
+    (void)ctx;
     memset(macro, 0, sizeof(*macro));
     macro->name = util_strdup(name);
     return macro;
@@ -1233,10 +1235,8 @@ bool ftepp_preprocess_file(const char *filename)
         con_out("failed to open file \"%s\"\n", filename);
         return false;
     }
-    if (!ftepp_preprocess(ftepp)) {
-        ftepp_delete(ftepp);
+    if (!ftepp_preprocess(ftepp))
         return false;
-    }
     return ftepp_preprocess_done();
 }
 
@@ -1248,10 +1248,8 @@ bool ftepp_preprocess_string(const char *name, const char *str)
         con_out("failed to create lexer for string \"%s\"\n", name);
         return false;
     }
-    if (!ftepp_preprocess(ftepp)) {
-        ftepp_delete(ftepp);
+    if (!ftepp_preprocess(ftepp))
         return false;
-    }
     return ftepp_preprocess_done();
 }