/[jscoverage]/trunk/jscoverage.c
ViewVC logotype

Diff of /trunk/jscoverage.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

trunk/main.c revision 88 by siliconforks, Mon May 5 20:08:25 2008 UTC trunk/jscoverage.c revision 431 by siliconforks, Wed Feb 18 18:24:51 2009 UTC
# Line 1  Line 1 
1  /*  /*
2      main.c - JSCoverage main routine      jscoverage.c - main routine for `jscoverage' program
3      Copyright (C) 2007, 2008 siliconforks.com      Copyright (C) 2007, 2008, 2009 siliconforks.com
4    
5      This program is free software; you can redistribute it and/or modify      This program is free software; you can redistribute it and/or modify
6      it under the terms of the GNU General Public License as published by      it under the terms of the GNU General Public License as published by
# Line 23  Line 23 
23  #include <stdlib.h>  #include <stdlib.h>
24  #include <string.h>  #include <string.h>
25    
26    #include "global.h"
27  #include "instrument.h"  #include "instrument.h"
28  #include "instrument-js.h"  #include "instrument-js.h"
29  #include "resource-manager.h"  #include "resource-manager.h"
30  #include "util.h"  #include "util.h"
31    
32    const char * jscoverage_encoding = "ISO-8859-1";
33    bool jscoverage_highlight = true;
34    
35  int main(int argc, char ** argv) {  int main(int argc, char ** argv) {
36    int verbose = 0;    int verbose = 0;
37    
# Line 37  Line 41 
41    char * source = NULL;    char * source = NULL;
42    char * destination = NULL;    char * destination = NULL;
43    
44    char ** no_instrument = xmalloc((argc - 1) * sizeof(char *));    char ** no_instrument = xnew(char *, argc - 1);
45    int num_no_instrument = 0;    int num_no_instrument = 0;
46    
47    char ** exclude = xmalloc((argc - 1) * sizeof(char *));    char ** exclude = xnew(char *, argc - 1);
48    int num_exclude = 0;    int num_exclude = 0;
49    
50    for (int i = 1; i < argc; i++) {    for (int i = 1; i < argc; i++) {
51      if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) {      if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) {
52        copy_resource_to_stream("help.txt", stdout);        copy_resource_to_stream("jscoverage-help.txt", stdout);
53        exit(EXIT_SUCCESS);        exit(EXIT_SUCCESS);
54      }      }
55      else if (strcmp(argv[i], "-V") == 0 || strcmp(argv[i], "--version") == 0) {      else if (strcmp(argv[i], "-V") == 0 || strcmp(argv[i], "--version") == 0) {
56        printf("jscoverage %s\n", VERSION);        version();
       exit(EXIT_SUCCESS);  
57      }      }
58      else if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--verbose") == 0) {      else if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--verbose") == 0) {
59        verbose = 1;        verbose = 1;
60      }      }
61        else if (strcmp(argv[i], "--no-highlight") == 0) {
62          jscoverage_highlight = false;
63        }
64        else if (strcmp(argv[i], "--mozilla") == 0) {
65          jscoverage_mode = JSCOVERAGE_MOZILLA;
66          jscoverage_set_js_version("180");
67        }
68        else if (strcmp(argv[i], "--no-browser") == 0) {
69          jscoverage_mode = JSCOVERAGE_NO_BROWSER;
70        }
71      else if (strcmp(argv[i], "--no-instrument") == 0) {      else if (strcmp(argv[i], "--no-instrument") == 0) {
72        i++;        i++;
73        if (i == argc) {        if (i == argc) {
74          fatal("--no-instrument: option requires an argument");          fatal_command_line("--no-instrument: option requires an argument");
75        }        }
76        no_instrument[num_no_instrument] = argv[i];        no_instrument[num_no_instrument] = argv[i];
77        num_no_instrument++;        num_no_instrument++;
# Line 70  Line 83 
83      else if (strcmp(argv[i], "--exclude") == 0) {      else if (strcmp(argv[i], "--exclude") == 0) {
84        i++;        i++;
85        if (i == argc) {        if (i == argc) {
86          fatal("--exclude: option requires an argument");          fatal_command_line("--exclude: option requires an argument");
87        }        }
88        exclude[num_exclude] = argv[i];        exclude[num_exclude] = argv[i];
89        num_exclude++;        num_exclude++;
# Line 79  Line 92 
92        exclude[num_exclude] = argv[i] + 10;        exclude[num_exclude] = argv[i] + 10;
93        num_exclude++;        num_exclude++;
94      }      }
95        else if (strcmp(argv[i], "--encoding") == 0) {
96          i++;
97          if (i == argc) {
98            fatal_command_line("--encoding: option requires an argument");
99          }
100          jscoverage_encoding = argv[i];
101        }
102        else if (strncmp(argv[i], "--encoding=", 11) == 0) {
103          jscoverage_encoding = argv[i] + 11;
104        }
105        else if (strcmp(argv[i], "--js-version") == 0) {
106          i++;
107          if (i == argc) {
108            fatal_command_line("--js-version: option requires an argument");
109          }
110          jscoverage_set_js_version(argv[i]);
111        }
112        else if (strncmp(argv[i], "--js-version=", 13) == 0) {
113          jscoverage_set_js_version(argv[i] + 13);
114        }
115      else if (strncmp(argv[i], "-", 1) == 0) {      else if (strncmp(argv[i], "-", 1) == 0) {
116        fatal("unrecognized option `%s'", argv[i]);        fatal_command_line("unrecognized option `%s'", argv[i]);
117      }      }
118      else if (source == NULL) {      else if (source == NULL) {
119        source = argv[i];        source = argv[i];
# Line 89  Line 122 
122        destination = argv[i];        destination = argv[i];
123      }      }
124      else {      else {
125        fatal("too many arguments");        fatal_command_line("too many arguments");
126      }      }
127    }    }
128    
129    if (source == NULL || destination == NULL) {    if (source == NULL || destination == NULL) {
130      fatal("missing argument");      fatal_command_line("missing argument");
131    }    }
132    
133    source = make_canonical_path(source);    source = make_canonical_path(source);

Legend:
Removed from v.88  
changed lines
  Added in v.431

  ViewVC Help
Powered by ViewVC 1.1.24