/[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 174 by siliconforks, Sat Sep 20 23:27:14 2008 UTC revision 176 by siliconforks, Sat Sep 20 23:29:42 2008 UTC
# Line 887  Line 887 
887    file_id = id;    file_id = id;
888    
889    /* scan the javascript */    /* scan the javascript */
890    size_t input_length = input->length;    size_t num_characters = input->length;
891    jschar * base = NULL;    jschar * base = NULL;
892    int result = jscoverage_bytes_to_characters(encoding, input->data, input->length, &base, &input_length);    int result = jscoverage_bytes_to_characters(encoding, input->data, input->length, &base, &num_characters);
893    if (result == JSCOVERAGE_ERROR_ENCODING_NOT_SUPPORTED) {    if (result == JSCOVERAGE_ERROR_ENCODING_NOT_SUPPORTED) {
894      fatal("encoding %s not supported in file %s", encoding, id);      fatal("encoding %s not supported in file %s", encoding, id);
895    }    }
896    else if (result == JSCOVERAGE_ERROR_INVALID_BYTE_SEQUENCE) {    else if (result == JSCOVERAGE_ERROR_INVALID_BYTE_SEQUENCE) {
897      fatal("error decoding %s in file %s", encoding, id);      fatal("error decoding %s in file %s", encoding, id);
898    }    }
899    JSTokenStream * token_stream = js_NewTokenStream(context, base, input_length, NULL, 1, NULL);    JSTokenStream * token_stream = js_NewTokenStream(context, base, num_characters, NULL, 1, NULL);
900    if (token_stream == NULL) {    if (token_stream == NULL) {
901      fatal("cannot create token stream from file: %s", file_id);      fatal("cannot create token stream from file: %s", file_id);
902    }    }
# Line 945  Line 945 
945    bool has_conditionals = false;    bool has_conditionals = false;
946    size_t line_number = 0;    size_t line_number = 0;
947    size_t i = 0;    size_t i = 0;
948    while (i < input_length) {    while (i < num_characters) {
949      line_number++;      line_number++;
950      size_t line_start = i;      size_t line_start = i;
951      while (i < input_length && base[i] != '\r' && base[i] != '\n') {      while (i < num_characters && base[i] != '\r' && base[i] != '\n') {
952        i++;        i++;
953      }      }
954      size_t line_end = i;      size_t line_end = i;
955      if (i < input_length) {      if (i < num_characters) {
956        if (base[i] == '\r') {        if (base[i] == '\r') {
957          line_end = i;          line_end = i;
958          i++;          i++;
959          if (i < input_length && base[i] == '\n') {          if (i < num_characters && base[i] == '\n') {
960            i++;            i++;
961          }          }
962        }        }
# Line 986  Line 986 
986    
987    /* copy the original source to the output */    /* copy the original source to the output */
988    i = 0;    i = 0;
989    while (i < input_length) {    while (i < num_characters) {
990      Stream_write_string(output, "// ");      Stream_write_string(output, "// ");
991      size_t line_start = i;      size_t line_start = i;
992      while (i < input_length && base[i] != '\r' && base[i] != '\n') {      while (i < num_characters && base[i] != '\r' && base[i] != '\n') {
993        i++;        i++;
994      }      }
995    
996      size_t line_end = i;      size_t line_end = i;
997      if (i < input_length) {      if (i < num_characters) {
998        if (base[i] == '\r') {        if (base[i] == '\r') {
999          line_end = i;          line_end = i;
1000          i++;          i++;
1001          if (i < input_length && base[i] == '\n') {          if (i < num_characters && base[i] == '\n') {
1002            i++;            i++;
1003          }          }
1004        }        }

Legend:
Removed from v.174  
changed lines
  Added in v.176

  ViewVC Help
Powered by ViewVC 1.1.24