X-Git-Url: https://git.xonotic.org/?p=xonotic%2Fgmqcc.git;a=blobdiff_plain;f=main.c;h=156a3f0c1af5c81c4c72d7ac70dc64087ea5c29c;hp=9a76706b06653412f017945dde44aa891ccdc06e;hb=0db41f4279a72ed05f93a047baae53a159e23511;hpb=fa14ca93d2b60f722d55c24214fde7ac84581ad0 diff --git a/main.c b/main.c index 9a76706..156a3f0 100644 --- a/main.c +++ b/main.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012, 2013 + * Copyright (C) 2012, 2013, 2014 * Dale Weiler * Wolfgang Bumiller * @@ -21,8 +21,6 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#include -#include #include #include @@ -87,6 +85,7 @@ static int usage(void) { " -Ono- disable specific optimization\n" " -Ohelp list optimizations\n"); con_out(" -force-crc=num force a specific checksum into the header\n"); + con_out(" -coverage add coverage support\n"); return -1; } @@ -282,6 +281,10 @@ static bool options_parse(int argc, char **argv) { con_color(0); continue; } + if (!strcmp(argv[0]+1, "coverage")) { + OPTS_OPTION_BOOL(OPTION_COVERAGE) = true; + continue; + } switch (argv[0][1]) { /* -h, show usage but exit with 0 */ @@ -531,7 +534,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 +562,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 +669,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 +694,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,8 +783,12 @@ 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);