]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - main.c
fold_binary now used instead of ast_binary_new, which calls fold_superfluous
[xonotic/gmqcc.git] / main.c
diff --git a/main.c b/main.c
index fa245a936800d8f6ec72af07080179703ca5f5e3..78293d6d7615a3682a6153ff6b221381e5dc44cf 100644 (file)
--- a/main.c
+++ b/main.c
@@ -21,8 +21,6 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
  */
-#include <time.h>
-#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
@@ -531,7 +529,7 @@ static bool options_parse(int argc, char **argv) {
 }
 
 /* returns the line number, or -1 on error */
-static bool progs_nextline(char **out, size_t *alen,FILE *src) {
+static bool progs_nextline(char **out, size_t *alen, fs_file_t *src) {
     int    len;
     char  *line;
     char  *start;
@@ -559,10 +557,9 @@ static bool progs_nextline(char **out, size_t *alen,FILE *src) {
 int main(int argc, char **argv) {
     size_t          itr;
     int             retval           = 0;
-    bool            opts_output_free = false;
     bool            operators_free   = false;
     bool            progs_src        = false;
-    FILE            *outfile         = NULL;
+    fs_file_t       *outfile         = NULL;
     struct parser_s *parser          = NULL;
     struct ftepp_s  *ftepp           = NULL;
 
@@ -667,10 +664,10 @@ int main(int argc, char **argv) {
     }
 
     if (!vec_size(items)) {
-        FILE  *src;
-        char  *line    = NULL;
-        size_t linelen = 0;
-        bool   hasline = false;
+        fs_file_t *src;
+        char      *line    = NULL;
+        size_t     linelen = 0;
+        bool       hasline = false;
 
         progs_src = true;
 
@@ -692,8 +689,7 @@ int main(int argc, char **argv) {
                 item.type     = TYPE_QC;
                 vec_push(items, item);
             } else if (!opts_output_wasset) {
-                OPTS_OPTION_STR(OPTION_OUTPUT) = util_strdup(line);
-                opts_output_free               = true;
+                OPTS_OPTION_DUP(OPTION_OUTPUT) = util_strdup(line);
                 hasline                        = true;
             }
         }
@@ -782,13 +778,19 @@ cleanup:
 
     if (!OPTS_OPTION_BOOL(OPTION_PP_ONLY))
         if(parser) parser_cleanup(parser);
-    if (opts_output_free)
-        mem_d(OPTS_OPTION_STR(OPTION_OUTPUT));
+
+    /* free allocated option strings */
+    for (itr = 0; itr < OPTION_COUNT; itr++)
+        if (OPTS_OPTION_DUPED(itr))
+            mem_d(OPTS_OPTION_STR(itr));
+
     if (operators_free)
         mem_d((void*)operators);
 
     lex_cleanup();
     stat_info();
 
+    if (!retval && compile_errors)
+        retval = 1;
     return retval;
 }