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

Diff of /trunk/instrument-js.c

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

revision 92 by siliconforks, Wed May 7 04:21:22 2008 UTC revision 101 by siliconforks, Sat May 24 18:11:30 2008 UTC
# Line 72  Line 72 
72  }  }
73    
74  static void print_string(JSString * s, Stream * f) {  static void print_string(JSString * s, Stream * f) {
75    for (int i = 0; i < s->length; i++) {    for (size_t i = 0; i < s->length; i++) {
76      char c = s->chars[i];      char c = s->chars[i];
77      Stream_write_char(f, c);      Stream_write_char(f, c);
78    }    }
# Line 853  Line 853 
853    
854    /* copy the instrumented source code to the output */    /* copy the instrumented source code to the output */
855    Stream_write(output, instrumented->data, instrumented->length);    Stream_write(output, instrumented->data, instrumented->length);
856      Stream_write_char(output, '\n');
857    
858      /* copy the original source to the output */
859      size_t i = 0;
860      while (i < input_length) {
861        Stream_write_string(output, "// ");
862        size_t line_start = i;
863        while (i < input_length && base[i] != '\r' && base[i] != '\n') {
864          i++;
865        }
866    
867        size_t line_end = i;
868        if (i < input_length) {
869          if (base[i] == '\r') {
870            line_end = i;
871            i++;
872            if (i < input_length && base[i] == '\n') {
873              i++;
874            }
875          }
876          else if (base[i] == '\n') {
877            line_end = i;
878            i++;
879          }
880          else {
881            abort();
882          }
883        }
884    
885        char * line = js_DeflateString(context, base + line_start, line_end - line_start);
886        Stream_write_string(output, line);
887        Stream_write_char(output, '\n');
888        JS_free(context, line);
889      }
890    
891    Stream_delete(instrumented);    Stream_delete(instrumented);
892    

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

  ViewVC Help
Powered by ViewVC 1.1.24