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

Annotation of /trunk/jscoverage.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 454 - (hide annotations)
Mon Sep 7 17:39:47 2009 UTC (9 years, 1 month ago) by siliconforks
File MIME type: text/plain
File size: 4325 byte(s)
Remove commented-out code.
1 siliconforks 2 /*
2 siliconforks 382 jscoverage.c - main routine for `jscoverage' program
3 siliconforks 427 Copyright (C) 2007, 2008, 2009 siliconforks.com
4 siliconforks 2
5     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
7     the Free Software Foundation; either version 2 of the License, or
8     (at your option) any later version.
9    
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13     GNU General Public License for more details.
14    
15     You should have received a copy of the GNU General Public License along
16     with this program; if not, write to the Free Software Foundation, Inc.,
17     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18     */
19    
20 siliconforks 88 #include <config.h>
21    
22 siliconforks 2 #include <stdio.h>
23     #include <stdlib.h>
24     #include <string.h>
25    
26 siliconforks 174 #include "global.h"
27 siliconforks 2 #include "instrument.h"
28     #include "instrument-js.h"
29     #include "resource-manager.h"
30     #include "util.h"
31    
32 siliconforks 174 const char * jscoverage_encoding = "ISO-8859-1";
33 siliconforks 179 bool jscoverage_highlight = true;
34 siliconforks 174
35 siliconforks 2 int main(int argc, char ** argv) {
36     int verbose = 0;
37    
38     program = "jscoverage";
39    
40     char * source = NULL;
41     char * destination = NULL;
42    
43 siliconforks 107 char ** no_instrument = xnew(char *, argc - 1);
44 siliconforks 2 int num_no_instrument = 0;
45    
46 siliconforks 107 char ** exclude = xnew(char *, argc - 1);
47 siliconforks 2 int num_exclude = 0;
48    
49     for (int i = 1; i < argc; i++) {
50     if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) {
51 siliconforks 385 copy_resource_to_stream("jscoverage-help.txt", stdout);
52 siliconforks 2 exit(EXIT_SUCCESS);
53     }
54     else if (strcmp(argv[i], "-V") == 0 || strcmp(argv[i], "--version") == 0) {
55 siliconforks 311 version();
56 siliconforks 2 }
57     else if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--verbose") == 0) {
58     verbose = 1;
59     }
60 siliconforks 179 else if (strcmp(argv[i], "--no-highlight") == 0) {
61     jscoverage_highlight = false;
62     }
63 siliconforks 361 else if (strcmp(argv[i], "--mozilla") == 0) {
64 siliconforks 431 jscoverage_mode = JSCOVERAGE_MOZILLA;
65 siliconforks 361 jscoverage_set_js_version("180");
66     }
67 siliconforks 431 else if (strcmp(argv[i], "--no-browser") == 0) {
68     jscoverage_mode = JSCOVERAGE_NO_BROWSER;
69     }
70 siliconforks 2 else if (strcmp(argv[i], "--no-instrument") == 0) {
71     i++;
72     if (i == argc) {
73 siliconforks 191 fatal_command_line("--no-instrument: option requires an argument");
74 siliconforks 2 }
75     no_instrument[num_no_instrument] = argv[i];
76     num_no_instrument++;
77     }
78     else if (strncmp(argv[i], "--no-instrument=", 16) == 0) {
79     no_instrument[num_no_instrument] = argv[i] + 16;
80     num_no_instrument++;
81     }
82     else if (strcmp(argv[i], "--exclude") == 0) {
83     i++;
84     if (i == argc) {
85 siliconforks 191 fatal_command_line("--exclude: option requires an argument");
86 siliconforks 2 }
87     exclude[num_exclude] = argv[i];
88     num_exclude++;
89     }
90     else if (strncmp(argv[i], "--exclude=", 10) == 0) {
91     exclude[num_exclude] = argv[i] + 10;
92     num_exclude++;
93     }
94 siliconforks 174 else if (strcmp(argv[i], "--encoding") == 0) {
95     i++;
96     if (i == argc) {
97 siliconforks 191 fatal_command_line("--encoding: option requires an argument");
98 siliconforks 174 }
99     jscoverage_encoding = argv[i];
100     }
101     else if (strncmp(argv[i], "--encoding=", 11) == 0) {
102     jscoverage_encoding = argv[i] + 11;
103     }
104 siliconforks 339 else if (strcmp(argv[i], "--js-version") == 0) {
105     i++;
106     if (i == argc) {
107     fatal_command_line("--js-version: option requires an argument");
108     }
109     jscoverage_set_js_version(argv[i]);
110     }
111     else if (strncmp(argv[i], "--js-version=", 13) == 0) {
112     jscoverage_set_js_version(argv[i] + 13);
113     }
114 siliconforks 2 else if (strncmp(argv[i], "-", 1) == 0) {
115 siliconforks 191 fatal_command_line("unrecognized option `%s'", argv[i]);
116 siliconforks 2 }
117     else if (source == NULL) {
118     source = argv[i];
119     }
120     else if (destination == NULL) {
121     destination = argv[i];
122     }
123     else {
124 siliconforks 191 fatal_command_line("too many arguments");
125 siliconforks 2 }
126     }
127    
128     if (source == NULL || destination == NULL) {
129 siliconforks 191 fatal_command_line("missing argument");
130 siliconforks 2 }
131    
132     source = make_canonical_path(source);
133     destination = make_canonical_path(destination);
134    
135     jscoverage_init();
136     jscoverage_instrument(source, destination, verbose, exclude, num_exclude, no_instrument, num_no_instrument);
137     jscoverage_cleanup();
138    
139     free(source);
140     free(destination);
141     free(exclude);
142     free(no_instrument);
143    
144     exit(EXIT_SUCCESS);
145     }

  ViewVC Help
Powered by ViewVC 1.1.24