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

Diff of /trunk/instrument.c

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

revision 95 by siliconforks, Wed May 7 22:50:00 2008 UTC revision 179 by siliconforks, Sun Sep 21 18:35:21 2008 UTC
# Line 17  Line 17 
17      51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.      51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */  */
19    
20    #include <config.h>
21    
22  #include "instrument.h"  #include "instrument.h"
23    
24  #include <assert.h>  #include <assert.h>
# Line 27  Line 29 
29  #include <sys/stat.h>  #include <sys/stat.h>
30  #include <sys/types.h>  #include <sys/types.h>
31    
32    #include "encoding.h"
33    #include "global.h"
34  #include "instrument-js.h"  #include "instrument-js.h"
35  #include "resource-manager.h"  #include "resource-manager.h"
36  #include "util.h"  #include "util.h"
# Line 50  Line 54 
54      return FILE_TYPE_HTML;      return FILE_TYPE_HTML;
55    }    }
56    else {    else {
57      return FILE_TYPE_UNKNOWN;      return FILE_TYPE_OTHER;
58    }    }
59  }  }
60    
# Line 81  Line 85 
85    if (instrumenting) {    if (instrumenting) {
86      enum FileType file_type = get_file_type(source_file);      enum FileType file_type = get_file_type(source_file);
87      switch (file_type) {      switch (file_type) {
88      case FILE_TYPE_UNKNOWN:      case FILE_TYPE_OTHER:
89      case FILE_TYPE_HTML:      case FILE_TYPE_HTML:
90        copy_file(source_file, destination_file);        copy_file(source_file, destination_file);
91        break;        break;
# Line 95  Line 99 
99    
100          Stream_write_file_contents(input_stream, input);          Stream_write_file_contents(input_stream, input);
101    
102          jscoverage_instrument_js(id, input_stream, output_stream);          size_t num_characters = input_stream->length;
103            uint16_t * characters = NULL;
104            int result = jscoverage_bytes_to_characters(jscoverage_encoding, input_stream->data, input_stream->length, &characters, &num_characters);
105            if (result == JSCOVERAGE_ERROR_ENCODING_NOT_SUPPORTED) {
106              fatal("encoding %s not supported", jscoverage_encoding);
107            }
108            else if (result == JSCOVERAGE_ERROR_INVALID_BYTE_SEQUENCE) {
109              fatal("error decoding %s in file %s", jscoverage_encoding, id);
110            }
111            jscoverage_instrument_js(id, characters, num_characters, output_stream);
112            free(characters);
113    
114          if (fwrite(output_stream->data, 1, output_stream->length, output) != output_stream->length) {          if (fwrite(output_stream->data, 1, output_stream->length, output) != output_stream->length) {
115            fatal("cannot write to file: %s", destination_file);            fatal("cannot write to file: %s", destination_file);
# Line 204  Line 218 
218    }    }
219    free_dir_list(list);    free_dir_list(list);
220  }  }
   
 void jscoverage_copy_resources(const char * destination_directory) {  
   copy_resource("jscoverage.html", destination_directory);  
   copy_resource("jscoverage.css", destination_directory);  
   copy_resource("jscoverage.js", destination_directory);  
   copy_resource("jscoverage-throbber.gif", destination_directory);  
   copy_resource("jscoverage-sh_main.js", destination_directory);  
   copy_resource("jscoverage-sh_javascript.js", destination_directory);  
   copy_resource("jscoverage-sh_nedit.css", destination_directory);  
 }  

Legend:
Removed from v.95  
changed lines
  Added in v.179

  ViewVC Help
Powered by ViewVC 1.1.24