Changeset 10800 in webkit


Ignore:
Timestamp:
Oct 8, 2005 9:45:29 PM (19 years ago)
Author:
darin
Message:

JavaScriptCore:

Reviewed by Geoff.
Tweaked and landed by Darin.

  • kjs/date_object.cpp: (KJS::skipSpacesAndComments): Take a pointer, and advance it past spaces, and also past anything enclosed in parentheses. (KJS::KRFCDate_parseDate): Use skipSpacesAndComments wherever we formerly had code to skip spaces.

LayoutTests:

  • fast/js/date-parse-comments-test-expected.txt: Added.
  • fast/js/date-parse-comments-test.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r10798 r10800  
     12005-10-08  Mitz Pettel  <opendarwin.org@mitzpettel.com>
     2
     3        Reviewed by Geoff.
     4        Tweaked and landed by Darin.
     5
     6        - fixed http://bugzilla.opendarwin.org/show_bug.cgi?id=5266
     7          Support parenthesized comments in Date.parse()
     8
     9        * kjs/date_object.cpp:
     10        (KJS::skipSpacesAndComments): Take a pointer, and advance it past spaces,
     11        and also past anything enclosed in parentheses.
     12        (KJS::KRFCDate_parseDate): Use skipSpacesAndComments wherever we formerly had
     13        code to skip spaces.
     14
    1152005-10-08  Justin Haygood  <justin@xiondigital.net>
    216
  • trunk/JavaScriptCore/kjs/date_object.cpp

    r10713 r10800  
    10321032}
    10331033
     1034inline static void skipSpacesAndComments(const char *&s)
     1035{
     1036    int nesting = 0;
     1037    char ch;
     1038    while ((ch = *s)) {
     1039        if (!isspace(ch)) {
     1040            if (ch == '(')
     1041                nesting++;
     1042            else if (ch == ')' && nesting > 0)
     1043                nesting--;
     1044            else if (nesting == 0)
     1045                break;
     1046        }
     1047        s++;
     1048    }
     1049}
     1050
    10341051// returns 0-11 (Jan-Dec); -1 on failure
    10351052static int findMonth(const char *monthStr)
     
    10841101     
    10851102     // Skip leading space
    1086      while(isspace(*dateString))
    1087         dateString++;
     1103     skipSpacesAndComments(dateString);
    10881104
    10891105     const char *wordStart = dateString;
    10901106     // Check contents of first words if not number
    1091      while(*dateString && !isdigit(*dateString))
    1092      {
    1093         if ( isspace(*dateString) && dateString - wordStart >= 3 )
    1094         {
    1095           month = findMonth(wordStart);
    1096           while(isspace(*dateString))
    1097              dateString++;
    1098           wordStart = dateString;
     1107     while (*dateString && !isdigit(*dateString)) {
     1108        if (isspace(*dateString) || *dateString == '(') {
     1109           if (dateString - wordStart >= 3)
     1110              month = findMonth(wordStart);
     1111           skipSpacesAndComments(dateString);
     1112           wordStart = dateString;
    10991113        }
    11001114        else
     
    11071121     }
    11081122
    1109      while(isspace(*dateString))
    1110         dateString++;
     1123     skipSpacesAndComments(dateString);
    11111124
    11121125     if (!*dateString)
     
    11631176         dateString++;
    11641177
    1165        while(isspace(*dateString))
    1166          dateString++;
     1178       skipSpacesAndComments(dateString);
    11671179
    11681180       if (*dateString == ',')
     
    11751187           return invalidDate;
    11761188
    1177          while(*dateString && (*dateString != '-') && !isspace(*dateString))
     1189         while (*dateString && (*dateString != '-') && !isspace(*dateString))
    11781190           dateString++;
    11791191
     
    12071219           else
    12081220               return invalidDate;
    1209         } else // in the normal case (we parsed the year), advance to the next number
     1221        } else {
     1222            // in the normal case (we parsed the year), advance to the next number
    12101223            dateString = ++newPosStr;
     1224            skipSpacesAndComments(dateString);
     1225        }
    12111226
    12121227        hour = strtol(dateString, &newPosStr, 10);
     
    12551270          }
    12561271
    1257           while(isspace(*dateString))
    1258             dateString++;
     1272          skipSpacesAndComments(dateString);
    12591273
    12601274          if (strncasecmp(dateString, "AM", 2) == 0) {
     
    12641278              hour = 0;
    12651279            dateString += 2;
    1266             while (isspace(*dateString))
    1267               dateString++;
     1280            skipSpacesAndComments(dateString);
    12681281          } else if (strncasecmp(dateString, "PM", 2) == 0) {
    12691282            if (hour > 12)
     
    12721285              hour += 12;
    12731286            dateString += 2;
    1274             while (isspace(*dateString))
    1275               dateString++;
     1287            skipSpacesAndComments(dateString);
    12761288          }
    12771289        }
     
    12891301       }
    12901302
    1291        while (isspace(*dateString))
    1292          ++dateString;
     1303       skipSpacesAndComments(dateString);
    12931304
    12941305       if (strncasecmp(dateString, "GMT", 3) == 0) {
     
    13281339     }
    13291340
    1330      while(isspace(*dateString))
    1331         dateString++;
     1341     skipSpacesAndComments(dateString);
    13321342
    13331343     if ( *dateString && year == -1 ) {
     
    13381348     }
    13391349     
    1340      while (isspace(*dateString))
    1341        dateString++;
     1350     skipSpacesAndComments(dateString);
    13421351     
    13431352     // Trailing garbage
  • trunk/LayoutTests/ChangeLog

    r10799 r10800  
     12005-10-08  Mitz Pettel  <opendarwin.org@mitzpettel.com>
     2
     3        - added a test for http://bugzilla.opendarwin.org/show_bug.cgi?id=5266
     4          Support parenthesized comments in Date.parse()
     5
     6        * fast/js/date-parse-comments-test-expected.txt: Added.
     7        * fast/js/date-parse-comments-test.html: Added.
     8
    192005-10-08  Alexey Proskuryakov  <ap@nypop.com>
    210
Note: See TracChangeset for help on using the changeset viewer.