]> git.rm.cloudns.org Git - xonotic/gmqcc.git/commitdiff
Fix some bugs
authorDale Weiler <killfieldengine@gmail.com>
Mon, 17 Jun 2013 20:11:37 +0000 (20:11 +0000)
committerDale Weiler <killfieldengine@gmail.com>
Mon, 17 Jun 2013 20:11:37 +0000 (20:11 +0000)
main.c
opts.def
parser.c

diff --git a/main.c b/main.c
index 37638e92ae4fb8b0202116f596d48e3d1d27e127..3dac2e1973cfe1bfe0a17b7359ba6e3549b515b7 100644 (file)
--- a/main.c
+++ b/main.c
@@ -662,9 +662,10 @@ int main(int argc, char **argv) {
     }
 
     if (!vec_size(items)) {
-        FILE *src;
-        char *line;
+        FILE  *src;
+        char  *line    = NULL;
         size_t linelen = 0;
+        bool   hasline = false;
 
         progs_src = true;
 
@@ -675,28 +676,23 @@ int main(int argc, char **argv) {
             goto cleanup;
         }
 
-        line = NULL;
-        if (!progs_nextline(&line, &linelen, src) || !line[0]) {
-            con_err("illformatted progs.src file: expected output filename in first line\n");
-            retval = 1;
-            goto srcdone;
-        }
-
-        if (!opts_output_wasset) {
-            OPTS_OPTION_STR(OPTION_OUTPUT) = util_strdup(line);
-            opts_output_free = true;
-        }
-
         while (progs_nextline(&line, &linelen, src)) {
             argitem item;
+
             if (!line[0] || (line[0] == '/' && line[1] == '/'))
                 continue;
-            item.filename = util_strdup(line);
-            item.type     = TYPE_QC;
-            vec_push(items, item);
+                
+            if (hasline) {
+                item.filename = util_strdup(line);
+                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;
+                hasline                        = true;
+            }
         }
 
-srcdone:
         fs_file_close(src);
         mem_d(line);
     }
index 77a4094115b3535e2090f5f62bf028a2288fe834..071b11a951373978388a5f967d4bb65b157408dd 100644 (file)
--- a/opts.def
+++ b/opts.def
@@ -89,6 +89,7 @@
     GMQCC_DEFINE_FLAG(DIFFERENT_ATTRIBUTES)
     GMQCC_DEFINE_FLAG(DEPRECATED)
     GMQCC_DEFINE_FLAG(PARENTHESIS)
+    GMQCC_DEFINE_FLAG(BREAKDEF)
 #endif
 
 #ifdef GMQCC_TYPE_OPTIMIZATIONS
index 2a0e7b796ca27775f6579351c23a53f5dd950d15..f8805e24f43c0d481560d1cb9a8b18d7c734e981 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -5694,8 +5694,16 @@ skipvar:
 
         if (parser->tok != '{' || var->expression.vtype != TYPE_FUNCTION) {
             if (parser->tok != '=') {
-                parseerror(parser, "missing semicolon or initializer, got: `%s`", parser_tokval(parser));
-                break;
+                if (!strcmp(parser_tokval(parser), "break")) {
+                    if (!parser_next(parser)) {
+                        parseerror(parser, "error parsing break definition");
+                        break;
+                    }
+                    (void)!!parsewarning(parser, WARN_BREAKDEF, "break definition ignored (suggest removing it)");
+                } else {
+                    parseerror(parser, "missing semicolon or initializer, got: `%s`", parser_tokval(parser));
+                    break;
+                }
             }
 
             if (!parser_next(parser)) {