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

Diff of /trunk/instrument.c

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

revision 361 by siliconforks, Sun Oct 26 05:28:03 2008 UTC revision 444 by siliconforks, Sun Jul 26 17:09:09 2009 UTC
# Line 1  Line 1 
1  /*  /*
2      instrument.c - file and directory instrumentation routines      instrument.c - file and directory instrumentation routines
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 99  Line 99 
99    
100          Stream_write_file_contents(input_stream, input);          Stream_write_file_contents(input_stream, input);
101    
102            /*
103            Check if the source file looks like an instrumented JavaScript file.
104            */
105            if (input_stream->length >= JSCOVERAGE_INSTRUMENTED_HEADER_LENGTH &&
106                memcmp(input_stream->data, JSCOVERAGE_INSTRUMENTED_HEADER, JSCOVERAGE_INSTRUMENTED_HEADER_LENGTH) == 0) {
107              fatal_command_line("file %s in the source directory appears to be already instrumented", id);
108            }
109    
110          size_t num_characters = input_stream->length;          size_t num_characters = input_stream->length;
111          uint16_t * characters = NULL;          uint16_t * characters = NULL;
112          int result = jscoverage_bytes_to_characters(jscoverage_encoding, input_stream->data, input_stream->length, &characters, &num_characters);          int result = jscoverage_bytes_to_characters(jscoverage_encoding, input_stream->data, input_stream->length, &characters, &num_characters);
# Line 163  Line 171 
171      }      }
172      if (! directory_is_empty(destination)) {      if (! directory_is_empty(destination)) {
173        char * expected_file = NULL;        char * expected_file = NULL;
174        if (jscoverage_mozilla) {        if (jscoverage_mode == JSCOVERAGE_MOZILLA) {
175          char * modules_directory = make_path(destination, "modules");          char * modules_directory = make_path(destination, "modules");
176          expected_file = make_path(modules_directory, "jscoverage.jsm");          expected_file = make_path(modules_directory, "jscoverage.jsm");
177          free(modules_directory);          free(modules_directory);
# Line 184  Line 192 
192      fatal("cannot stat directory: %s", destination);      fatal("cannot stat directory: %s", destination);
193    }    }
194    
195      /* copy the resources */
196      if (jscoverage_mode == JSCOVERAGE_MOZILLA) {
197        char * chrome_directory = make_path(destination, "chrome");
198        char * jscoverage_chrome_directory = make_path(chrome_directory, "jscoverage");
199        mkdirs(jscoverage_chrome_directory);
200        copy_resource("jscoverage.manifest", chrome_directory);
201        copy_resource("jscoverage.html", jscoverage_chrome_directory);
202        copy_resource("jscoverage.css", jscoverage_chrome_directory);
203        copy_resource("jscoverage.js", jscoverage_chrome_directory);
204        copy_resource("jscoverage-throbber.gif", jscoverage_chrome_directory);
205        copy_resource("jscoverage-highlight.css", jscoverage_chrome_directory);
206        copy_resource("jscoverage.xul", jscoverage_chrome_directory);
207        copy_resource("jscoverage-overlay.js", jscoverage_chrome_directory);
208        free(jscoverage_chrome_directory);
209        free(chrome_directory);
210    
211        char * modules_directory = make_path(destination, "modules");
212        mkdirs(modules_directory);
213        copy_resource("jscoverage.jsm", modules_directory);
214        free(modules_directory);
215      }
216      else {
217        jscoverage_copy_resources(destination);
218      }
219    
220    /* finally: copy the directory */    /* finally: copy the directory */
221    struct DirListEntry * list = make_recursive_dir_list(source);    struct DirListEntry * list = make_recursive_dir_list(source);
222    for (struct DirListEntry * p = list; p != NULL; p = p->next) {    for (struct DirListEntry * p = list; p != NULL; p = p->next) {
# Line 222  Line 255 
255      free(d);      free(d);
256    }    }
257    
   /* copy the resources */  
   if (jscoverage_mozilla) {  
     char * chrome_directory = make_path(destination, "chrome");  
     char * jscoverage_chrome_directory = make_path(chrome_directory, "jscoverage");  
     mkdir_if_necessary(jscoverage_chrome_directory);  
     copy_resource("jscoverage.manifest", chrome_directory);  
     copy_resource("jscoverage.html", jscoverage_chrome_directory);  
     copy_resource("jscoverage.css", jscoverage_chrome_directory);  
     copy_resource("jscoverage.js", jscoverage_chrome_directory);  
     copy_resource("jscoverage-throbber.gif", jscoverage_chrome_directory);  
     copy_resource("jscoverage-highlight.css", jscoverage_chrome_directory);  
     copy_resource("jscoverage.xul", jscoverage_chrome_directory);  
     copy_resource("jscoverage-overlay.js", jscoverage_chrome_directory);  
     free(jscoverage_chrome_directory);  
     free(chrome_directory);  
   
     char * modules_directory = make_path(destination, "modules");  
     copy_resource("jscoverage.jsm", modules_directory);  
     free(modules_directory);  
   }  
   else {  
     jscoverage_copy_resources(destination);  
   }  
   
258    free_dir_list(list);    free_dir_list(list);
259  }  }

Legend:
Removed from v.361  
changed lines
  Added in v.444

  ViewVC Help
Powered by ViewVC 1.1.24