]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
ftepp_out can now output to a string buffer
authorWolfgang (Blub) Bumiller <blub@speed.at>
Fri, 16 Nov 2012 21:06:07 +0000 (22:06 +0100)
committerWolfgang (Blub) Bumiller <blub@speed.at>
Fri, 16 Nov 2012 21:06:07 +0000 (22:06 +0100)
ftepp.c

diff --git a/ftepp.c b/ftepp.c
index 9cd2903aaf985c56be297cf3733f3624f3bca7f7..e1a8e300562498f9238f4c46fd5ce414b4e27a5c 100644 (file)
--- a/ftepp.c
+++ b/ftepp.c
@@ -61,6 +61,9 @@ typedef struct {
     bool         output_on;
     ppcondition *conditions;
     ppmacro    **macros;
+
+    bool         output_string;
+    char        *output;
 } ftepp_t;
 
 #define ftepp_tokval(f) ((f)->lex->tok.value)
@@ -154,7 +157,15 @@ static void ftepp_out(ftepp_t *ftepp, const char *str, bool ignore_cond)
 {
     if (ignore_cond || ftepp->output_on)
     {
-        printf("%s", str);
+        size_t len;
+        char  *data;
+        if (!ftepp->output_string) {
+            printf("%s", str);
+            return;
+        }
+        len = strlen(str);
+        data = vec_add(ftepp->output, len);
+        memcpy(data, str, len);
     }
 }