summaryrefslogtreecommitdiffstats
path: root/JavaScriptCore/pcre
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-03-05 14:34:32 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2009-03-05 14:34:32 -0800
commit635860845790a19bf50bbc51ba8fb66a96dde068 (patch)
treeef6ad9ff73a5b57f65249d4232a202fa77e6a140 /JavaScriptCore/pcre
parent8e35f3cfc7fba1d1c829dc557ebad6409cbe16a2 (diff)
downloadexternal_webkit-635860845790a19bf50bbc51ba8fb66a96dde068.zip
external_webkit-635860845790a19bf50bbc51ba8fb66a96dde068.tar.gz
external_webkit-635860845790a19bf50bbc51ba8fb66a96dde068.tar.bz2
auto import from //depot/cupcake/@136594
Diffstat (limited to 'JavaScriptCore/pcre')
-rwxr-xr-xJavaScriptCore/pcre/dftables4
-rw-r--r--JavaScriptCore/pcre/pcre.pri2
-rw-r--r--JavaScriptCore/pcre/pcre_compile.cpp59
-rw-r--r--JavaScriptCore/pcre/pcre_exec.cpp22
-rw-r--r--JavaScriptCore/pcre/pcre_internal.h26
-rw-r--r--JavaScriptCore/pcre/pcre_tables.cpp10
-rw-r--r--JavaScriptCore/pcre/pcre_ucp_searchfuncs.cpp4
-rw-r--r--JavaScriptCore/pcre/pcre_xclass.cpp8
8 files changed, 78 insertions, 57 deletions
diff --git a/JavaScriptCore/pcre/dftables b/JavaScriptCore/pcre/dftables
index 9268f19..de2f5bb 100755
--- a/JavaScriptCore/pcre/dftables
+++ b/JavaScriptCore/pcre/dftables
@@ -8,7 +8,7 @@
#
# Originally written by Philip Hazel
# Copyright (c) 1997-2006 University of Cambridge
-# Copyright (C) 2002, 2004, 2006, 2007, 2008 Apple Inc. All rights reserved.
+# Copyright (C) 2002, 2004, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
#
# -----------------------------------------------------------------------------
# Redistribution and use in source and binary forms, with or without
@@ -84,7 +84,7 @@ printf(OUT
"This file contains the default tables for characters with codes less than\n" .
"128 (ASCII characters). These tables are used when no external tables are\n" .
"passed to PCRE. */\n\n" .
- "const unsigned char kjs_pcre_default_tables[%d] = {\n\n" .
+ "const unsigned char jsc_pcre_default_tables[%d] = {\n\n" .
"/* This table is a lower casing table. */\n\n", $pcre_internal{tables_length});
if ($pcre_internal{lcc_offset} != 0) {
diff --git a/JavaScriptCore/pcre/pcre.pri b/JavaScriptCore/pcre/pcre.pri
index ec5c0d5..c33c67c 100644
--- a/JavaScriptCore/pcre/pcre.pri
+++ b/JavaScriptCore/pcre/pcre.pri
@@ -1,6 +1,6 @@
# Perl Compatible Regular Expressions - Qt4 build info
VPATH += $$PWD
-INCLUDEPATH += $$PWD $$OUTPUT_DIR/JavaScriptCore/kjs/tmp
+INCLUDEPATH += $$PWD $$OUTPUT_DIR/JavaScriptCore/tmp
DEPENDPATH += $$PWD
isEmpty(GENERATED_SOURCES_DIR):GENERATED_SOURCES_DIR = tmp
diff --git a/JavaScriptCore/pcre/pcre_compile.cpp b/JavaScriptCore/pcre/pcre_compile.cpp
index fdd90af..18c54ff 100644
--- a/JavaScriptCore/pcre/pcre_compile.cpp
+++ b/JavaScriptCore/pcre/pcre_compile.cpp
@@ -6,7 +6,7 @@ needed by JavaScriptCore and the rest of WebKit.
Originally written by Philip Hazel
Copyright (c) 1997-2006 University of Cambridge
- Copyright (C) 2002, 2004, 2006, 2007 Apple Inc. All rights reserved.
+ Copyright (C) 2002, 2004, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
Copyright (C) 2007 Eric Seidel <eric@webkit.org>
-----------------------------------------------------------------------------
@@ -236,8 +236,11 @@ static int checkEscape(const UChar** ptrPtr, const UChar* patternEnd, ErrorCode*
/* Handle an octal number following \. If the first digit is 8 or 9,
this is not octal. */
- if ((c = *ptr) >= '8')
+ if ((c = *ptr) >= '8') {
+ c = '\\';
+ ptr -= 1;
break;
+ }
/* \0 always starts an octal number, but we may drop through to here with a
larger first octal digit. */
@@ -298,8 +301,17 @@ static int checkEscape(const UChar** ptrPtr, const UChar* patternEnd, ErrorCode*
*errorCodePtr = ERR2;
return 0;
}
- c = *ptr;
+ c = *ptr;
+
+ /* To match Firefox, inside a character class, we also accept
+ numbers and '_' as control characters */
+ if ((!isClass && !isASCIIAlpha(c)) || (!isASCIIAlphanumeric(c) && c != '_')) {
+ c = '\\';
+ ptr -= 2;
+ break;
+ }
+
/* A letter is upper-cased; then the 0x40 bit is flipped. This coding
is ASCII-specific, but then the whole concept of \cx is ASCII-specific. */
c = toASCIIUpper(c) ^ 0x40;
@@ -477,7 +489,7 @@ static bool getOthercaseRange(int* cptr, int d, int* ocptr, int* odptr)
int c, othercase = 0;
for (c = *cptr; c <= d; c++) {
- if ((othercase = kjs_pcre_ucp_othercase(c)) >= 0)
+ if ((othercase = jsc_pcre_ucp_othercase(c)) >= 0)
break;
}
@@ -488,7 +500,7 @@ static bool getOthercaseRange(int* cptr, int d, int* ocptr, int* odptr)
int next = othercase + 1;
for (++c; c <= d; c++) {
- if (kjs_pcre_ucp_othercase(c) != next)
+ if (jsc_pcre_ucp_othercase(c) != next)
break;
next++;
}
@@ -516,15 +528,15 @@ static bool getOthercaseRange(int* cptr, int d, int* ocptr, int* odptr)
static int encodeUTF8(int cvalue, unsigned char *buffer)
{
int i;
- for (i = 0; i < kjs_pcre_utf8_table1_size; i++)
- if (cvalue <= kjs_pcre_utf8_table1[i])
+ for (i = 0; i < jsc_pcre_utf8_table1_size; i++)
+ if (cvalue <= jsc_pcre_utf8_table1[i])
break;
buffer += i;
for (int j = i; j > 0; j--) {
*buffer-- = 0x80 | (cvalue & 0x3f);
cvalue >>= 6;
}
- *buffer = kjs_pcre_utf8_table2[i] | cvalue;
+ *buffer = jsc_pcre_utf8_table2[i] | cvalue;
return i + 1;
}
@@ -900,7 +912,7 @@ compileBranch(int options, int* brackets, unsigned char** codePtr,
if (options & IgnoreCaseOption) {
int othercase;
- if ((othercase = kjs_pcre_ucp_othercase(c)) >= 0) {
+ if ((othercase = jsc_pcre_ucp_othercase(c)) >= 0) {
*class_utf8data++ = XCL_SINGLE;
class_utf8data += encodeUTF8(othercase, class_utf8data);
}
@@ -1402,6 +1414,15 @@ compileBranch(int options, int* brackets, unsigned char** codePtr,
code[-ketoffset] = OP_KETRMAX + repeatType;
}
+ // A quantifier after an assertion is mostly meaningless, but it
+ // can nullify the assertion if it has a 0 minimum.
+ else if (*previous == OP_ASSERT || *previous == OP_ASSERT_NOT) {
+ if (repeatMin == 0) {
+ code = previous;
+ goto END_REPEAT;
+ }
+ }
+
/* Else there's some kind of shambles */
else {
@@ -1468,12 +1489,12 @@ compileBranch(int options, int* brackets, unsigned char** codePtr,
bravalue = OP_BRA + *brackets;
}
- /* Process nested bracketed re. Assertions may not be repeated, but other
- kinds can be. We copy code into a non-variable in order to be able
- to pass its address because some compilers complain otherwise. Pass in a
- new setting for the ims options if they have changed. */
+ /* Process nested bracketed re. We copy code into a non-variable
+ in order to be able to pass its address because some compilers
+ complain otherwise. Pass in a new setting for the ims options
+ if they have changed. */
- previous = (bravalue >= OP_BRAZERO) ? code : 0;
+ previous = code;
*code = bravalue;
tempcode = code;
tempreqvary = cd.reqVaryOpt; /* Save value before bracket */
@@ -2041,8 +2062,8 @@ static int calculateCompiledPatternLength(const UChar* pattern, int patternLengt
if (c > 127) {
int i;
- for (i = 0; i < kjs_pcre_utf8_table1_size; i++)
- if (c <= kjs_pcre_utf8_table1[i]) break;
+ for (i = 0; i < jsc_pcre_utf8_table1_size; i++)
+ if (c <= jsc_pcre_utf8_table1[i]) break;
length += i;
lastitemlength += i;
}
@@ -2495,8 +2516,8 @@ static int calculateCompiledPatternLength(const UChar* pattern, int patternLengt
if (c > 127) {
int i;
- for (i = 0; i < kjs_pcre_utf8_table1_size; i++)
- if (c <= kjs_pcre_utf8_table1[i])
+ for (i = 0; i < jsc_pcre_utf8_table1_size; i++)
+ if (c <= jsc_pcre_utf8_table1[i])
break;
length += i;
lastitemlength += i;
@@ -2586,7 +2607,7 @@ JSRegExp* jsRegExpCompile(const UChar* pattern, int patternLength,
const UChar* ptr = (const UChar*)pattern;
const UChar* patternEnd = pattern + patternLength;
- unsigned char* code = (unsigned char*)codeStart;
+ unsigned char* code = const_cast<unsigned char*>(codeStart);
int firstByte, reqByte;
int bracketCount = 0;
if (!cd.needOuterBracket)
diff --git a/JavaScriptCore/pcre/pcre_exec.cpp b/JavaScriptCore/pcre/pcre_exec.cpp
index 36d81e2..34e2786 100644
--- a/JavaScriptCore/pcre/pcre_exec.cpp
+++ b/JavaScriptCore/pcre/pcre_exec.cpp
@@ -6,7 +6,7 @@ needed by JavaScriptCore and the rest of WebKit.
Originally written by Philip Hazel
Copyright (c) 1997-2006 University of Cambridge
- Copyright (C) 2002, 2004, 2006, 2007 Apple Inc. All rights reserved.
+ Copyright (C) 2002, 2004, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
Copyright (C) 2007 Eric Seidel <eric@webkit.org>
-----------------------------------------------------------------------------
@@ -50,8 +50,8 @@ the JavaScript specification. There are also some supporting functions. */
#include <wtf/Vector.h>
#if REGEXP_HISTOGRAM
-#include <kjs/DateMath.h>
-#include <kjs/ustring.h>
+#include <parser/DateMath.h>
+#include <runtime/UString.h>
#endif
using namespace WTF;
@@ -250,7 +250,7 @@ static bool matchRef(int offset, const UChar* subjectPtr, int length, const Matc
if (md.ignoreCase) {
while (length-- > 0) {
UChar c = *p++;
- int othercase = kjs_pcre_ucp_othercase(c);
+ int othercase = jsc_pcre_ucp_othercase(c);
UChar d = *subjectPtr++;
if (c != d && othercase != d)
return false;
@@ -403,9 +403,9 @@ static inline void getUTF8CharAndIncrementLength(int& c, const unsigned char* su
{
c = *subjectPtr;
if ((c & 0xc0) == 0xc0) {
- int gcaa = kjs_pcre_utf8_table4[c & 0x3f]; /* Number of additional bytes */
+ int gcaa = jsc_pcre_utf8_table4[c & 0x3f]; /* Number of additional bytes */
int gcss = 6 * gcaa;
- c = (c & kjs_pcre_utf8_table3[gcaa]) << gcss;
+ c = (c & jsc_pcre_utf8_table3[gcaa]) << gcss;
for (int gcii = 1; gcii <= gcaa; gcii++) {
gcss -= 6;
c |= (subjectPtr[gcii] & 0x3f) << gcss;
@@ -1048,7 +1048,7 @@ RECURSE:
if (stack.currentFrame->args.subjectPtr >= md.endSubject)
RRETURN_NO_MATCH;
int c = *stack.currentFrame->args.subjectPtr++;
- if (!kjs_pcre_xclass(c, stack.currentFrame->locals.data))
+ if (!jsc_pcre_xclass(c, stack.currentFrame->locals.data))
RRETURN_NO_MATCH;
}
@@ -1069,7 +1069,7 @@ RECURSE:
if (stack.currentFrame->locals.fi >= stack.currentFrame->locals.max || stack.currentFrame->args.subjectPtr >= md.endSubject)
RRETURN;
int c = *stack.currentFrame->args.subjectPtr++;
- if (!kjs_pcre_xclass(c, stack.currentFrame->locals.data))
+ if (!jsc_pcre_xclass(c, stack.currentFrame->locals.data))
RRETURN;
}
/* Control never reaches here */
@@ -1083,7 +1083,7 @@ RECURSE:
if (stack.currentFrame->args.subjectPtr >= md.endSubject)
break;
int c = *stack.currentFrame->args.subjectPtr;
- if (!kjs_pcre_xclass(c, stack.currentFrame->locals.data))
+ if (!jsc_pcre_xclass(c, stack.currentFrame->locals.data))
break;
++stack.currentFrame->args.subjectPtr;
}
@@ -1122,7 +1122,7 @@ RECURSE:
if (stack.currentFrame->args.subjectPtr >= md.endSubject)
RRETURN_NO_MATCH;
int dc = *stack.currentFrame->args.subjectPtr++;
- if (stack.currentFrame->locals.fc != dc && kjs_pcre_ucp_othercase(stack.currentFrame->locals.fc) != dc)
+ if (stack.currentFrame->locals.fc != dc && jsc_pcre_ucp_othercase(stack.currentFrame->locals.fc) != dc)
RRETURN_NO_MATCH;
NEXT_OPCODE;
}
@@ -1186,7 +1186,7 @@ RECURSE:
stack.currentFrame->args.instructionPtr += stack.currentFrame->locals.length;
if (stack.currentFrame->locals.fc <= 0xFFFF) {
- int othercase = md.ignoreCase ? kjs_pcre_ucp_othercase(stack.currentFrame->locals.fc) : -1;
+ int othercase = md.ignoreCase ? jsc_pcre_ucp_othercase(stack.currentFrame->locals.fc) : -1;
for (int i = 1; i <= min; i++) {
if (*stack.currentFrame->args.subjectPtr != stack.currentFrame->locals.fc && *stack.currentFrame->args.subjectPtr != othercase)
diff --git a/JavaScriptCore/pcre/pcre_internal.h b/JavaScriptCore/pcre/pcre_internal.h
index 06c3e9d..2916765 100644
--- a/JavaScriptCore/pcre/pcre_internal.h
+++ b/JavaScriptCore/pcre/pcre_internal.h
@@ -6,7 +6,7 @@ needed by JavaScriptCore and the rest of WebKit.
Originally written by Philip Hazel
Copyright (c) 1997-2006 University of Cambridge
- Copyright (C) 2002, 2004, 2006, 2007 Apple Inc. All rights reserved.
+ Copyright (C) 2002, 2004, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
@@ -340,36 +340,36 @@ struct JSRegExp {
but are not part of the PCRE public API. The data for these tables is in the
pcre_tables.c module. */
-#define kjs_pcre_utf8_table1_size 6
+#define jsc_pcre_utf8_table1_size 6
-extern const int kjs_pcre_utf8_table1[6];
-extern const int kjs_pcre_utf8_table2[6];
-extern const int kjs_pcre_utf8_table3[6];
-extern const unsigned char kjs_pcre_utf8_table4[0x40];
+extern const int jsc_pcre_utf8_table1[6];
+extern const int jsc_pcre_utf8_table2[6];
+extern const int jsc_pcre_utf8_table3[6];
+extern const unsigned char jsc_pcre_utf8_table4[0x40];
-extern const unsigned char kjs_pcre_default_tables[tables_length];
+extern const unsigned char jsc_pcre_default_tables[tables_length];
static inline unsigned char toLowerCase(unsigned char c)
{
- static const unsigned char* lowerCaseChars = kjs_pcre_default_tables + lcc_offset;
+ static const unsigned char* lowerCaseChars = jsc_pcre_default_tables + lcc_offset;
return lowerCaseChars[c];
}
static inline unsigned char flipCase(unsigned char c)
{
- static const unsigned char* flippedCaseChars = kjs_pcre_default_tables + fcc_offset;
+ static const unsigned char* flippedCaseChars = jsc_pcre_default_tables + fcc_offset;
return flippedCaseChars[c];
}
static inline unsigned char classBitmapForChar(unsigned char c)
{
- static const unsigned char* charClassBitmaps = kjs_pcre_default_tables + cbits_offset;
+ static const unsigned char* charClassBitmaps = jsc_pcre_default_tables + cbits_offset;
return charClassBitmaps[c];
}
static inline unsigned char charTypeForChar(unsigned char c)
{
- const unsigned char* charTypeMap = kjs_pcre_default_tables + ctypes_offset;
+ const unsigned char* charTypeMap = jsc_pcre_default_tables + ctypes_offset;
return charTypeMap[c];
}
@@ -413,8 +413,8 @@ static inline void advanceToEndOfBracket(const unsigned char*& opcodePtr)
that one of the source files. They have to have external linkage, but
but are not part of the public API and so not exported from the library. */
-extern int kjs_pcre_ucp_othercase(unsigned);
-extern bool kjs_pcre_xclass(int, const unsigned char*);
+extern int jsc_pcre_ucp_othercase(unsigned);
+extern bool jsc_pcre_xclass(int, const unsigned char*);
#endif
diff --git a/JavaScriptCore/pcre/pcre_tables.cpp b/JavaScriptCore/pcre/pcre_tables.cpp
index d306233..8696879 100644
--- a/JavaScriptCore/pcre/pcre_tables.cpp
+++ b/JavaScriptCore/pcre/pcre_tables.cpp
@@ -6,7 +6,7 @@ needed by JavaScriptCore and the rest of WebKit.
Originally written by Philip Hazel
Copyright (c) 1997-2006 University of Cambridge
- Copyright (C) 2002, 2004, 2006, 2007 Apple Inc. All rights reserved.
+ Copyright (C) 2002, 2004, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
@@ -50,20 +50,20 @@ PCRE code modules. */
/* These are the breakpoints for different numbers of bytes in a UTF-8
character. */
-const int kjs_pcre_utf8_table1[6] =
+const int jsc_pcre_utf8_table1[6] =
{ 0x7f, 0x7ff, 0xffff, 0x1fffff, 0x3ffffff, 0x7fffffff};
/* These are the indicator bits and the mask for the data bits to set in the
first byte of a character, indexed by the number of additional bytes. */
-const int kjs_pcre_utf8_table2[6] = { 0, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc};
-const int kjs_pcre_utf8_table3[6] = { 0xff, 0x1f, 0x0f, 0x07, 0x03, 0x01};
+const int jsc_pcre_utf8_table2[6] = { 0, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc};
+const int jsc_pcre_utf8_table3[6] = { 0xff, 0x1f, 0x0f, 0x07, 0x03, 0x01};
/* Table of the number of extra characters, indexed by the first character
masked with 0x3f. The highest number for a valid UTF-8 character is in fact
0x3d. */
-const unsigned char kjs_pcre_utf8_table4[0x40] = {
+const unsigned char jsc_pcre_utf8_table4[0x40] = {
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
diff --git a/JavaScriptCore/pcre/pcre_ucp_searchfuncs.cpp b/JavaScriptCore/pcre/pcre_ucp_searchfuncs.cpp
index 6e1d0e4..5592865 100644
--- a/JavaScriptCore/pcre/pcre_ucp_searchfuncs.cpp
+++ b/JavaScriptCore/pcre/pcre_ucp_searchfuncs.cpp
@@ -6,7 +6,7 @@ needed by JavaScriptCore and the rest of WebKit.
Originally written by Philip Hazel
Copyright (c) 1997-2006 University of Cambridge
- Copyright (C) 2002, 2004, 2006, 2007 Apple Inc. All rights reserved.
+ Copyright (C) 2002, 2004, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
@@ -60,7 +60,7 @@ Arguments:
Returns: the other case or -1 if none
*/
-int kjs_pcre_ucp_othercase(unsigned c)
+int jsc_pcre_ucp_othercase(unsigned c)
{
int bot = 0;
int top = sizeof(ucp_table) / sizeof(cnode);
diff --git a/JavaScriptCore/pcre/pcre_xclass.cpp b/JavaScriptCore/pcre/pcre_xclass.cpp
index 2fb36d7..a32edd4 100644
--- a/JavaScriptCore/pcre/pcre_xclass.cpp
+++ b/JavaScriptCore/pcre/pcre_xclass.cpp
@@ -6,7 +6,7 @@ needed by JavaScriptCore and the rest of WebKit.
Originally written by Philip Hazel
Copyright (c) 1997-2006 University of Cambridge
- Copyright (C) 2002, 2004, 2006, 2007 Apple Inc. All rights reserved.
+ Copyright (C) 2002, 2004, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
@@ -64,9 +64,9 @@ static inline void getUTF8CharAndAdvancePointer(int& c, const unsigned char*& su
{
c = *subjectPtr++;
if ((c & 0xc0) == 0xc0) {
- int gcaa = kjs_pcre_utf8_table4[c & 0x3f]; /* Number of additional bytes */
+ int gcaa = jsc_pcre_utf8_table4[c & 0x3f]; /* Number of additional bytes */
int gcss = 6 * gcaa;
- c = (c & kjs_pcre_utf8_table3[gcaa]) << gcss;
+ c = (c & jsc_pcre_utf8_table3[gcaa]) << gcss;
while (gcaa-- > 0) {
gcss -= 6;
c |= (*subjectPtr++ & 0x3f) << gcss;
@@ -74,7 +74,7 @@ static inline void getUTF8CharAndAdvancePointer(int& c, const unsigned char*& su
}
}
-bool kjs_pcre_xclass(int c, const unsigned char* data)
+bool jsc_pcre_xclass(int c, const unsigned char* data)
{
bool negated = (*data & XCL_NOT);