]> de.git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
this might fix some linenumbering, I hope
authorWolfgang Bumiller <blub@speed.at>
Tue, 15 Jan 2013 21:29:44 +0000 (22:29 +0100)
committerWolfgang Bumiller <blub@speed.at>
Tue, 15 Jan 2013 21:29:44 +0000 (22:29 +0100)
ftepp.c

diff --git a/ftepp.c b/ftepp.c
index 86bd741bcbd4094e789b2b2a6f9058caa70dd2ee..77818f8bbe1f2332796e802d7b21dbec8b45344c 100644 (file)
--- a/ftepp.c
+++ b/ftepp.c
@@ -634,7 +634,7 @@ static void ftepp_param_out(ftepp_t *ftepp, macroparam *param)
 }
 
 static bool ftepp_preprocess(ftepp_t *ftepp);
-static bool ftepp_macro_expand(ftepp_t *ftepp, ppmacro *macro, macroparam *params)
+static bool ftepp_macro_expand(ftepp_t *ftepp, ppmacro *macro, macroparam *params, bool resetline)
 {
     char     *old_string   = ftepp->output_string;
     lex_file *old_lexer    = ftepp->lex;
@@ -740,6 +740,11 @@ static bool ftepp_macro_expand(ftepp_t *ftepp, ppmacro *macro, macroparam *param
     vec_free(ftepp->lex->open_string);
     if (has_newlines)
         ftepp_recursion_footer(ftepp);
+    if (resetline) {
+        char lineno[128];
+        sprintf(lineno, "\n#pragma line(%lu)\n", old_lexer->sline);
+        ftepp_out(ftepp, lineno, false);
+    }
     old_string = ftepp->output_string;
 
 cleanup:
@@ -753,9 +758,10 @@ static bool ftepp_macro_call(ftepp_t *ftepp, ppmacro *macro)
     size_t     o;
     macroparam *params = NULL;
     bool        retval = true;
+    size_t      paramline;
 
     if (!macro->has_params) {
-        if (!ftepp_macro_expand(ftepp, macro, NULL))
+        if (!ftepp_macro_expand(ftepp, macro, NULL, false))
             return false;
         ftepp_next(ftepp);
         return true;
@@ -771,6 +777,7 @@ static bool ftepp_macro_call(ftepp_t *ftepp, ppmacro *macro)
     }
 
     ftepp_next(ftepp);
+    paramline = ftepp->lex->sline;
     if (!ftepp_macro_call_params(ftepp, &params))
         return false;
 
@@ -785,7 +792,7 @@ static bool ftepp_macro_call(ftepp_t *ftepp, ppmacro *macro)
         goto cleanup;
     }
 
-    if (!ftepp_macro_expand(ftepp, macro, params))
+    if (!ftepp_macro_expand(ftepp, macro, params, (paramline != ftepp->lex->sline)))
         retval = false;
     ftepp_next(ftepp);