[webkit-changes] cvs commit: JavaScriptCore/tests/mozilla/ecma/Array 15.4.5.1-1.js

John sullivan at opensource.apple.com
Mon Oct 24 14:22:22 PDT 2005


sullivan    05/10/24 14:22:21

  Modified:    .        ChangeLog
               kjs      lexer.cpp
               tests/mozilla/ecma/Array 15.4.5.1-1.js
  Log:
          Reviewed by Darin Adler. Code changes by Alexey Proskuryakov.
  
          - fixed http://bugzilla.opendarwin.org/show_bug.cgi?id=4931
          Unicode format characters (Cf) should be removed from JavaScript source
  
          * kjs/lexer.cpp:
          include <unicode/uchar.h>
          (Lexer::Lexer):
          use KJS::UChar instead of UChar to avoid ambiguity caused by new include
          (Lexer::setCode):
          ditto; also, use shift(4) to skip first 4 chars to take advantage of new
          logic there.
          (Lexer::shift):
          skip chars of type U_FORMAT_CHAR
          (Lexer::convertUnicode):
          use KJS::UChar instead of UChar to avoid ambiguity caused by new include
          (Lexer::record16):
          ditto
          (Lexer::makeIdentifier):
          ditto
          (Lexer::makeUString):
          ditto
  
          * tests/mozilla/ecma/Array/15.4.5.1-1.js:
          updated to skip soft hyphens
  
  Revision  Changes    Path
  1.870     +28 -0     JavaScriptCore/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/JavaScriptCore/ChangeLog,v
  retrieving revision 1.869
  retrieving revision 1.870
  diff -u -r1.869 -r1.870
  --- ChangeLog	24 Oct 2005 20:45:54 -0000	1.869
  +++ ChangeLog	24 Oct 2005 21:22:19 -0000	1.870
  @@ -1,5 +1,33 @@
   2005-10-24  John Sullivan  <sullivan at apple.com>
   
  +        Reviewed by Darin Adler. Code changes by Alexey Proskuryakov.
  +        
  +        - fixed http://bugzilla.opendarwin.org/show_bug.cgi?id=4931
  +        Unicode format characters (Cf) should be removed from JavaScript source
  +
  +        * kjs/lexer.cpp:
  +        include <unicode/uchar.h>
  +        (Lexer::Lexer):
  +        use KJS::UChar instead of UChar to avoid ambiguity caused by new include
  +        (Lexer::setCode):
  +        ditto; also, use shift(4) to skip first 4 chars to take advantage of new
  +        logic there.
  +        (Lexer::shift):
  +        skip chars of type U_FORMAT_CHAR
  +        (Lexer::convertUnicode):
  +        use KJS::UChar instead of UChar to avoid ambiguity caused by new include
  +        (Lexer::record16):
  +        ditto
  +        (Lexer::makeIdentifier):
  +        ditto
  +        (Lexer::makeUString):
  +        ditto
  +        
  +        * tests/mozilla/ecma/Array/15.4.5.1-1.js:
  +        updated to skip soft hyphens
  +
  +2005-10-24  John Sullivan  <sullivan at apple.com>
  +
           Reviewed by Darin Adler. Code changes by George Staikos/Geoff Garen.
           
           - fixed http://bugzilla.opendarwin.org/show_bug.cgi?id=4142
  
  
  
  1.22      +18 -15    JavaScriptCore/kjs/lexer.cpp
  
  Index: lexer.cpp
  ===================================================================
  RCS file: /cvs/root/JavaScriptCore/kjs/lexer.cpp,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- lexer.cpp	3 Oct 2005 21:11:49 -0000	1.21
  +++ lexer.cpp	24 Oct 2005 21:22:21 -0000	1.22
  @@ -39,6 +39,7 @@
   #include "identifier.h"
   #include "lookup.h"
   #include "internal.h"
  +#include <unicode/uchar.h>
   
   // we can't specify the namespace in yacc's C output, so do it here
   using namespace KJS;
  @@ -73,7 +74,7 @@
   {
     // allocate space for read buffers
     buffer8 = new char[size8];
  -  buffer16 = new UChar[size16];
  +  buffer16 = new KJS::UChar[size16];
     currLexer = this;
   }
   
  @@ -101,7 +102,7 @@
   }
   #endif
   
  -void Lexer::setCode(const UString &sourceURL, int startingLineNumber, const UChar *c, unsigned int len)
  +void Lexer::setCode(const UString &sourceURL, int startingLineNumber, const KJS::UChar *c, unsigned int len)
   {
     yylineno = 1 + startingLineNumber;
     m_sourceURL = sourceURL;
  @@ -121,20 +122,22 @@
   #endif
   
     // read first characters
  -  current = (length > 0) ? code[0].uc : 0;
  -  next1 = (length > 1) ? code[1].uc : 0;
  -  next2 = (length > 2) ? code[2].uc : 0;
  -  next3 = (length > 3) ? code[3].uc : 0;
  +  shift(4);
   }
   
   void Lexer::shift(unsigned int p)
   {
     while (p--) {
  -    pos++;
       current = next1;
       next1 = next2;
       next2 = next3;
  -    next3 = (pos + 3 < length) ? code[pos+3].uc : 0;
  +    do {
  +      if (pos >= length) {
  +	next3 = 0;
  +	break;
  +      }
  +      next3 = code[pos++].uc;
  +    } while (u_charType(next3) == U_FORMAT_CHAR);
     }
   }
   
  @@ -751,10 +754,10 @@
     return ((convertHex(c1) << 4) + convertHex(c2));
   }
   
  -UChar Lexer::convertUnicode(unsigned short c1, unsigned short c2,
  +KJS::UChar Lexer::convertUnicode(unsigned short c1, unsigned short c2,
                                        unsigned short c3, unsigned short c4)
   {
  -  return UChar((convertHex(c1) << 4) + convertHex(c2),
  +  return KJS::UChar((convertHex(c1) << 4) + convertHex(c2),
                  (convertHex(c3) << 4) + convertHex(c4));
   }
   
  @@ -774,12 +777,12 @@
     buffer8[pos8++] = (char) c;
   }
   
  -void Lexer::record16(UChar c)
  +void Lexer::record16(KJS::UChar c)
   {
     // enlarge buffer if full
     if (pos16 >= size16 - 1) {
  -    UChar *tmp = new UChar[2 * size16];
  -    memcpy(tmp, buffer16, size16 * sizeof(UChar));
  +    KJS::UChar *tmp = new KJS::UChar[2 * size16];
  +    memcpy(tmp, buffer16, size16 * sizeof(KJS::UChar));
       delete [] buffer16;
       buffer16 = tmp;
       size16 *= 2;
  @@ -851,7 +854,7 @@
   const int initialCapacity = 64;
   const int growthFactor = 2;
   
  -Identifier *Lexer::makeIdentifier(UChar *buffer, unsigned int pos)
  +Identifier *Lexer::makeIdentifier(KJS::UChar *buffer, unsigned int pos)
   {
     if (numIdentifiers == identifiersCapacity) {
       identifiersCapacity = (identifiersCapacity == 0) ? initialCapacity : identifiersCapacity *growthFactor;
  @@ -863,7 +866,7 @@
     return identifier;
   }
    
  -UString *Lexer::makeUString(UChar *buffer, unsigned int pos)
  +UString *Lexer::makeUString(KJS::UChar *buffer, unsigned int pos)
   {
     if (numStrings == stringsCapacity) {
       stringsCapacity = (stringsCapacity == 0) ? initialCapacity : stringsCapacity *growthFactor;
  
  
  
  1.2       +4 -2      JavaScriptCore/tests/mozilla/ecma/Array/15.4.5.1-1.js
  
  Index: 15.4.5.1-1.js
  ===================================================================
  RCS file: /cvs/root/JavaScriptCore/tests/mozilla/ecma/Array/15.4.5.1-1.js,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- 15.4.5.1-1.js	13 Oct 2003 02:05:28 -0000	1.1
  +++ 15.4.5.1-1.js	24 Oct 2005 21:22:21 -0000	1.2
  @@ -104,7 +104,9 @@
   
   
       for ( var i = 0X0020, TEST_STRING = "var A = new Array( " ; i < 0x00ff; i++ ) {
  -        TEST_STRING += "\'\\"+ String.fromCharCode( i ) +"\'";
  +        if (i == 0xAD) // Must skip over soft hyphen, because it's a Cf character and can't be parsed.
  +            i++;
  +        TEST_STRING += "'\\"+ String.fromCharCode( i ) +"'";
           if ( i < 0x00FF - 1   ) {
               TEST_STRING += ",";
           } else {
  @@ -112,7 +114,7 @@
           }
       }
   
  -    var LENGTH = 0x00ff - 0x0020;
  +    var LENGTH = 0x00ff - 0x0020 - 1;
   
       array[item++] = new TestCase(   SECTION,
                                       TEST_STRING +" A[150] = 'hello'; A[150]",
  
  
  



More information about the webkit-changes mailing list