]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
moving ftepp_delete out of ftepp_preprocess so that it can actually be called recursively
authorWolfgang (Blub) Bumiller <blub@speed.at>
Fri, 16 Nov 2012 21:07:53 +0000 (22:07 +0100)
committerWolfgang (Blub) Bumiller <blub@speed.at>
Fri, 16 Nov 2012 21:07:53 +0000 (22:07 +0100)
ftepp.c

diff --git a/ftepp.c b/ftepp.c
index e1a8e300562498f9238f4c46fd5ce414b4e27a5c..d4cf76176f721e08e5d8dbb80fc35e80a88abec3 100644 (file)
--- a/ftepp.c
+++ b/ftepp.c
@@ -827,7 +827,6 @@ static bool ftepp_preprocess(ftepp_t *ftepp)
     } while (!ftepp->errors && ftepp->token < TOKEN_EOF);
 
     newline = ftepp->token == TOKEN_EOF;
-    ftepp_delete(ftepp);
     return newline;
 }
 
@@ -839,7 +838,12 @@ bool ftepp_preprocess_file(const char *filename)
         con_out("failed to open file \"%s\"\n", filename);
         return false;
     }
-    return ftepp_preprocess(ftepp);
+    if (!ftepp_preprocess(ftepp)) {
+        ftepp_delete(ftepp);
+        return false;
+    }
+    ftepp_delete(ftepp);
+    return true;
 }
 
 bool ftepp_preprocess_string(const char *name, const char *str)
@@ -850,5 +854,10 @@ bool ftepp_preprocess_string(const char *name, const char *str)
         con_out("failed to create lexer for string \"%s\"\n", name);
         return false;
     }
-    return ftepp_preprocess(ftepp);
+    if (!ftepp_preprocess(ftepp)) {
+        ftepp_delete(ftepp);
+        return false;
+    }
+    ftepp_delete(ftepp);
+    return true;
 }