--- trunk/main.c 2007/11/22 01:50:33 69 +++ trunk/main.c 2008/10/13 17:51:29 311 @@ -1,6 +1,6 @@ /* main.c - JSCoverage main routine - Copyright (C) 2007 siliconforks.com + Copyright (C) 2007, 2008 siliconforks.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,15 +17,21 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include + #include #include #include +#include "global.h" #include "instrument.h" #include "instrument-js.h" #include "resource-manager.h" #include "util.h" +const char * jscoverage_encoding = "ISO-8859-1"; +bool jscoverage_highlight = true; + int main(int argc, char ** argv) { int verbose = 0; @@ -35,10 +41,10 @@ char * source = NULL; char * destination = NULL; - char ** no_instrument = xmalloc((argc - 1) * sizeof(char *)); + char ** no_instrument = xnew(char *, argc - 1); int num_no_instrument = 0; - char ** exclude = xmalloc((argc - 1) * sizeof(char *)); + char ** exclude = xnew(char *, argc - 1); int num_exclude = 0; for (int i = 1; i < argc; i++) { @@ -47,16 +53,18 @@ exit(EXIT_SUCCESS); } else if (strcmp(argv[i], "-V") == 0 || strcmp(argv[i], "--version") == 0) { - printf("jscoverage %s\n", VERSION); - exit(EXIT_SUCCESS); + version(); } else if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--verbose") == 0) { verbose = 1; } + else if (strcmp(argv[i], "--no-highlight") == 0) { + jscoverage_highlight = false; + } else if (strcmp(argv[i], "--no-instrument") == 0) { i++; if (i == argc) { - fatal("--no-instrument: option requires an argument"); + fatal_command_line("--no-instrument: option requires an argument"); } no_instrument[num_no_instrument] = argv[i]; num_no_instrument++; @@ -68,7 +76,7 @@ else if (strcmp(argv[i], "--exclude") == 0) { i++; if (i == argc) { - fatal("--exclude: option requires an argument"); + fatal_command_line("--exclude: option requires an argument"); } exclude[num_exclude] = argv[i]; num_exclude++; @@ -77,8 +85,18 @@ exclude[num_exclude] = argv[i] + 10; num_exclude++; } + else if (strcmp(argv[i], "--encoding") == 0) { + i++; + if (i == argc) { + fatal_command_line("--encoding: option requires an argument"); + } + jscoverage_encoding = argv[i]; + } + else if (strncmp(argv[i], "--encoding=", 11) == 0) { + jscoverage_encoding = argv[i] + 11; + } else if (strncmp(argv[i], "-", 1) == 0) { - fatal("unrecognized option `%s'", argv[i]); + fatal_command_line("unrecognized option `%s'", argv[i]); } else if (source == NULL) { source = argv[i]; @@ -87,12 +105,12 @@ destination = argv[i]; } else { - fatal("too many arguments"); + fatal_command_line("too many arguments"); } } if (source == NULL || destination == NULL) { - fatal("missing argument"); + fatal_command_line("missing argument"); } source = make_canonical_path(source);