From: Dale Weiler Date: Mon, 17 Jun 2013 20:11:37 +0000 (+0000) Subject: Fix some bugs X-Git-Tag: v0.3.0~105^2~2 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=23cb7f4e096e5cf6e08636a808820d480079db96;p=xonotic%2Fgmqcc.git Fix some bugs --- diff --git a/main.c b/main.c index 37638e9..3dac2e1 100644 --- 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); } diff --git a/opts.def b/opts.def index 77a4094..071b11a 100644 --- 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 diff --git a/parser.c b/parser.c index 2a0e7b7..f8805e2 100644 --- 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)) {