diff options
| author | Jean-Baptiste Queru <jbq@google.com> | 2009-11-15 12:06:13 -0800 |
|---|---|---|
| committer | Jean-Baptiste Queru <jbq@google.com> | 2009-11-15 12:06:16 -0800 |
| commit | 19b276ff1f54bed5c687bef385cb6d8c33332d56 (patch) | |
| tree | 3f24d37c741607a2f8d4b8ba40d723047bc74456 /JavaScriptCore/pcre | |
| parent | a2acdcdf0059d9926f5b53c6824fe16371dd04f2 (diff) | |
| parent | ca654d632f783143435336ddc4381fbda6340a65 (diff) | |
| download | external_webkit-19b276ff1f54bed5c687bef385cb6d8c33332d56.zip external_webkit-19b276ff1f54bed5c687bef385cb6d8c33332d56.tar.gz external_webkit-19b276ff1f54bed5c687bef385cb6d8c33332d56.tar.bz2 | |
merge from eclair
Diffstat (limited to 'JavaScriptCore/pcre')
| -rwxr-xr-x | JavaScriptCore/pcre/dftables | 2 | ||||
| -rw-r--r-- | JavaScriptCore/pcre/pcre_compile.cpp | 2 | ||||
| -rw-r--r-- | JavaScriptCore/pcre/pcre_exec.cpp | 11 | ||||
| -rw-r--r-- | JavaScriptCore/pcre/pcre_internal.h | 36 |
4 files changed, 42 insertions, 9 deletions
diff --git a/JavaScriptCore/pcre/dftables b/JavaScriptCore/pcre/dftables index de2f5bb..8a2d140 100755 --- a/JavaScriptCore/pcre/dftables +++ b/JavaScriptCore/pcre/dftables @@ -244,7 +244,7 @@ sub readHeaderValues() my ($fh, $tempFile) = tempfile( basename($0) . "-XXXXXXXX", - DIR => ($ENV{'TMPDIR'} || "/tmp"), + DIR => File::Spec->tmpdir, SUFFIX => ".in", UNLINK => 0, ); diff --git a/JavaScriptCore/pcre/pcre_compile.cpp b/JavaScriptCore/pcre/pcre_compile.cpp index 18c54ff..2bedca6 100644 --- a/JavaScriptCore/pcre/pcre_compile.cpp +++ b/JavaScriptCore/pcre/pcre_compile.cpp @@ -2216,7 +2216,7 @@ static int calculateCompiledPatternLength(const UChar* pattern, int patternLengt int d = -1; if (safelyCheckNextChar(ptr, patternEnd, '-')) { - UChar const *hyptr = ptr++; + const UChar* hyptr = ptr++; if (safelyCheckNextChar(ptr, patternEnd, '\\')) { ptr++; d = checkEscape(&ptr, patternEnd, &errorcode, cd.numCapturingBrackets, true); diff --git a/JavaScriptCore/pcre/pcre_exec.cpp b/JavaScriptCore/pcre/pcre_exec.cpp index 34e2786..16619d4 100644 --- a/JavaScriptCore/pcre/pcre_exec.cpp +++ b/JavaScriptCore/pcre/pcre_exec.cpp @@ -50,13 +50,13 @@ the JavaScript specification. There are also some supporting functions. */ #include <wtf/Vector.h> #if REGEXP_HISTOGRAM -#include <parser/DateMath.h> +#include <wtf/DateMath.h> #include <runtime/UString.h> #endif using namespace WTF; -#ifdef __GNUC__ +#if COMPILER(GCC) #define USE_COMPUTED_GOTO_FOR_MATCH_RECURSION //#define USE_COMPUTED_GOTO_FOR_MATCH_OPCODE_LOOP #endif @@ -112,7 +112,7 @@ struct BracketChainNode { const UChar* bracketStart; }; -struct MatchFrame { +struct MatchFrame : FastAllocBase { ReturnLocation returnLocation; struct MatchFrame* previousFrame; @@ -175,7 +175,7 @@ reqByte match. */ /* The below limit restricts the number of "recursive" match calls in order to avoid spending exponential time on complex regular expressions. */ -static const unsigned matchLimit = 100000; +static const unsigned matchLimit = 1000000; #ifdef DEBUG /************************************************* @@ -447,6 +447,7 @@ static int match(const UChar* subjectPtr, const unsigned char* instructionPtr, i int min; bool minimize = false; /* Initialization not really needed, but some compilers think so. */ unsigned remainingMatchCount = matchLimit; + int othercase; /* Declare here to avoid errors during jumps */ MatchStack stack; @@ -1186,7 +1187,7 @@ RECURSE: stack.currentFrame->args.instructionPtr += stack.currentFrame->locals.length; if (stack.currentFrame->locals.fc <= 0xFFFF) { - int othercase = md.ignoreCase ? jsc_pcre_ucp_othercase(stack.currentFrame->locals.fc) : -1; + 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 2916765..0016bb5 100644 --- a/JavaScriptCore/pcre/pcre_internal.h +++ b/JavaScriptCore/pcre/pcre_internal.h @@ -85,7 +85,7 @@ total length. */ offsets within the compiled regex. The default is 2, which allows for compiled patterns up to 64K long. */ -#define LINK_SIZE 2 +#define LINK_SIZE 3 /* Define DEBUG to get debugging output on stdout. */ @@ -124,28 +124,60 @@ static inline void put2ByteValue(unsigned char* opcodePtr, int value) opcodePtr[1] = value; } +static inline void put3ByteValue(unsigned char* opcodePtr, int value) +{ + ASSERT(value >= 0 && value <= 0xFFFFFF); + opcodePtr[0] = value >> 16; + opcodePtr[1] = value >> 8; + opcodePtr[2] = value; +} + static inline int get2ByteValue(const unsigned char* opcodePtr) { return (opcodePtr[0] << 8) | opcodePtr[1]; } +static inline int get3ByteValue(const unsigned char* opcodePtr) +{ + return (opcodePtr[0] << 16) | (opcodePtr[1] << 8) | opcodePtr[2]; +} + static inline void put2ByteValueAndAdvance(unsigned char*& opcodePtr, int value) { put2ByteValue(opcodePtr, value); opcodePtr += 2; } +static inline void put3ByteValueAndAdvance(unsigned char*& opcodePtr, int value) +{ + put3ByteValue(opcodePtr, value); + opcodePtr += 3; +} + static inline void putLinkValueAllowZero(unsigned char* opcodePtr, int value) { +#if LINK_SIZE == 3 + put3ByteValue(opcodePtr, value); +#elif LINK_SIZE == 2 put2ByteValue(opcodePtr, value); +#else +# error LINK_SIZE not supported. +#endif } static inline int getLinkValueAllowZero(const unsigned char* opcodePtr) { +#if LINK_SIZE == 3 + return get3ByteValue(opcodePtr); +#elif LINK_SIZE == 2 return get2ByteValue(opcodePtr); +#else +# error LINK_SIZE not supported. +#endif } -#define MAX_PATTERN_SIZE (1 << 16) +#define MAX_PATTERN_SIZE 1024 * 1024 // Derived by empirical testing of compile time in PCRE and WREC. +COMPILE_ASSERT(MAX_PATTERN_SIZE < (1 << (8 * LINK_SIZE)), pcre_max_pattern_fits_in_bytecode); static inline void putLinkValue(unsigned char* opcodePtr, int value) { |
