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

Diff of /trunk/instrument.c

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

revision 2 by siliconforks, Wed Aug 1 13:51:53 2007 UTC revision 92 by siliconforks, Wed May 7 04:21:22 2008 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 siliconforks.com      Copyright (C) 2007, 2008 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 81  Line 81 
81    
82    fprintf(output, "<html><head><title>%s</title>\n", relative_path);    fprintf(output, "<html><head><title>%s</title>\n", relative_path);
83    fprintf(output, "<link rel=\"stylesheet\" type='text/css' href='%sjscoverage.css'>\n", relative_path_to_ancestor);    fprintf(output, "<link rel=\"stylesheet\" type='text/css' href='%sjscoverage.css'>\n", relative_path_to_ancestor);
84    fprintf(output, "<link rel=\"stylesheet\" type='text/css' href='%ssh_nedit.css'>\n", relative_path_to_ancestor);    fprintf(output, "<link rel=\"stylesheet\" type='text/css' href='%sjscoverage-sh_nedit.css'>\n", relative_path_to_ancestor);
85    fprintf(output, "<script src=\"%sjscoverage.js\"></script>\n", relative_path_to_ancestor);    fprintf(output, "<script src=\"%sjscoverage.js\"></script>\n", relative_path_to_ancestor);
86    fprintf(output, "<script src=\"%ssh_main.min.js\"></script>\n", relative_path_to_ancestor);    fprintf(output, "<script src=\"%sjscoverage-sh_main.js\"></script>\n", relative_path_to_ancestor);
87    fprintf(output, "<script src=\"%ssh_javascript.min.js\"></script>\n", relative_path_to_ancestor);    fprintf(output, "<script src=\"%sjscoverage-sh_javascript.js\"></script>\n", relative_path_to_ancestor);
88    fprintf(output, "<script>\n");    fprintf(output, "<script>\n");
89    fprintf(output, "var gCurrentFile = \"%s\";\n", relative_path);    fprintf(output, "var gCurrentFile = \"%s\";\n", relative_path);
90    fprintf(output, "</script>\n");    fprintf(output, "</script>\n");
# Line 162  Line 162 
162        copy_file(source_file, destination_file);        copy_file(source_file, destination_file);
163        break;        break;
164      case FILE_TYPE_JS:      case FILE_TYPE_JS:
       highlight_file(source_file, destination_file, id);  
165        {        {
166          FILE * input = xfopen(source_file, "r");          FILE * input = xfopen(source_file, "r");
167          FILE * output = xfopen(destination_file, "w");          FILE * output = xfopen(destination_file, "w");
168          jscoverage_instrument_js(id, input, output);  
169            Stream * input_stream = Stream_new(0);
170            Stream * output_stream = Stream_new(0);
171    
172            Stream_write_file_contents(input_stream, input);
173    
174            jscoverage_instrument_js(id, input_stream, output_stream);
175    
176            if (fwrite(output_stream->data, 1, output_stream->length, output) != output_stream->length) {
177              fatal("cannot write to file: %s", destination_file);
178            }
179    
180            Stream_delete(input_stream);
181            Stream_delete(output_stream);
182    
183          fclose(input);          fclose(input);
184          fclose(output);          fclose(output);
185        }        }
186          highlight_file(source_file, destination_file, id);
187        break;        break;
188      }      }
189    }    }
# Line 225  Line 239 
239      fatal("cannot stat directory: %s", destination);      fatal("cannot stat directory: %s", destination);
240    }    }
241    
242      /* copy the resources */
243      jscoverage_copy_resources(destination);
244    
245    /* finally: copy the directory */    /* finally: copy the directory */
246    struct DirListEntry * list = make_recursive_dir_list(source);    struct DirListEntry * list = make_recursive_dir_list(source);
247    for (struct DirListEntry * p = list; p != NULL; p = p->next) {    for (struct DirListEntry * p = list; p != NULL; p = p->next) {
# Line 270  Line 287 
287    copy_resource("jscoverage.css", destination_directory);    copy_resource("jscoverage.css", destination_directory);
288    copy_resource("jscoverage.js", destination_directory);    copy_resource("jscoverage.js", destination_directory);
289    copy_resource("jscoverage-throbber.gif", destination_directory);    copy_resource("jscoverage-throbber.gif", destination_directory);
290    copy_resource("sh_main.min.js", destination_directory);    copy_resource("jscoverage-sh_main.js", destination_directory);
291    copy_resource("sh_javascript.min.js", destination_directory);    copy_resource("jscoverage-sh_javascript.js", destination_directory);
292    copy_resource("sh_nedit.css", destination_directory);    copy_resource("jscoverage-sh_nedit.css", destination_directory);
293  }  }

Legend:
Removed from v.2  
changed lines
  Added in v.92

  ViewVC Help
Powered by ViewVC 1.1.24