/[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 245 by siliconforks, Sun Oct 5 18:05:12 2008 UTC revision 246 by siliconforks, Sun Oct 5 18:05:42 2008 UTC
# Line 88  Line 88 
88    JS_DestroyRuntime(runtime);    JS_DestroyRuntime(runtime);
89  }  }
90    
91    static void print_javascript(const jschar * characters, size_t num_characters, Stream * f) {
92      for (size_t i = 0; i < num_characters; i++) {
93        jschar c = characters[i];
94        /*
95        XXX does not handle no-break space, other unicode "space separator"
96        */
97        switch (c) {
98        case 0x9:
99        case 0xB:
100        case 0xC:
101          Stream_write_char(f, c);
102          break;
103        default:
104          if (32 <= c && c <= 126) {
105            Stream_write_char(f, c);
106          }
107          else {
108            Stream_printf(f, "\\u%04x", c);
109          }
110          break;
111        }
112      }
113    }
114    
115  static void print_string(JSString * s, Stream * f) {  static void print_string(JSString * s, Stream * f) {
116    size_t length = JSSTRING_LENGTH(s);    size_t length = JSSTRING_LENGTH(s);
117    jschar * characters = JSSTRING_CHARS(s);    jschar * characters = JSSTRING_CHARS(s);
# Line 1090  Line 1114 
1114    /* conditionals */    /* conditionals */
1115    for (struct IfDirective * if_directive = if_directives; if_directive != NULL; if_directive = if_directive->next) {    for (struct IfDirective * if_directive = if_directives; if_directive != NULL; if_directive = if_directive->next) {
1116      Stream_write_string(output, "if (!(");      Stream_write_string(output, "if (!(");
1117      for (const jschar * p = if_directive->condition_start; p < if_directive->condition_end; p++) {      print_javascript(if_directive->condition_start, if_directive->condition_end - if_directive->condition_start, output);
       jschar c = *p;  
       if (c == '\t' || (32 <= c && c <= 126)) {  
         Stream_write_char(output, c);  
       }  
       else {  
         Stream_printf(output, "\\u%04x", c);  
       }  
     }  
1118      Stream_write_string(output, ")) {\n");      Stream_write_string(output, ")) {\n");
1119      Stream_printf(output, "  _$jscoverage['%s'].conditionals[%d] = %d;\n", file_id, if_directive->start_line, if_directive->end_line);      Stream_printf(output, "  _$jscoverage['%s'].conditionals[%d] = %d;\n", file_id, if_directive->start_line, if_directive->end_line);
1120      Stream_write_string(output, "}\n");      Stream_write_string(output, "}\n");

Legend:
Removed from v.245  
changed lines
  Added in v.246

  ViewVC Help
Powered by ViewVC 1.1.24