]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - ftepp.c
Rewrote memory tracking, now prints highest water mark (most used memory at a given...
[xonotic/gmqcc.git] / ftepp.c
diff --git a/ftepp.c b/ftepp.c
index a1b5f07e9a446321966707dde62f08b068b9efa4..87be73881c4ecbd10f0a29b562df00b1e4fada67 100644 (file)
--- a/ftepp.c
+++ b/ftepp.c
@@ -394,6 +394,7 @@ static bool ftepp_define_params(ftepp_t *ftepp, ppmacro *macro)
             return false;
         }
     } while (ftepp->token == ',');
+
     if (ftepp->token != ')') {
         ftepp_error(ftepp, "expected closing paren after macro parameter list");
         return false;
@@ -422,7 +423,7 @@ static bool ftepp_define_body(ftepp_t *ftepp, ppmacro *macro)
                         return false;
                     }
 
-                    index = atoi(ftepp_tokval(ftepp));
+                    index = (int)strtol(ftepp_tokval(ftepp), NULL, 10);
 
                     if (ftepp_next(ftepp) != ']') {
                         ftepp_error(ftepp, "expected `]` in __VA_ARGS__ subscript");
@@ -492,22 +493,28 @@ static bool ftepp_define(ftepp_t *ftepp)
             break;
         default:
             ftepp_error(ftepp, "expected macro name");
-            goto cleanup_false;
+            return false;
     }
 
     (void)ftepp_next(ftepp);
 
     if (ftepp->token == '(') {
         macro->has_params = true;
-        if (!ftepp_define_params(ftepp, macro))
-            goto cleanup_false;
+        if (!ftepp_define_params(ftepp, macro)) {
+            ppmacro_delete(macro);
+            return false;
+        }
     }
 
-    if (!ftepp_skipspace(ftepp))
-        goto cleanup_false;
+    if (!ftepp_skipspace(ftepp)) {
+        ppmacro_delete(macro);
+        return false;
+    }
 
-    if (!ftepp_define_body(ftepp, macro))
-        goto cleanup_false;
+    if (!ftepp_define_body(ftepp, macro)) {
+        ppmacro_delete(macro);
+        return false;
+    }
 
     if (ftepp->output_on)
         vec_push(ftepp->macros, macro);
@@ -518,10 +525,6 @@ static bool ftepp_define(ftepp_t *ftepp)
     for (; l < ftepp_ctx(ftepp).line; ++l)
         ftepp_out(ftepp, "\n", true);
     return true;
-
-cleanup_false:
-    if (macro) ppmacro_delete(macro);
-    return false;
 }
 
 /**