+2007-12-10 Darin Adler <darin@apple.com>
+
+ Reviewed by Sam Weinig.
+
+ - fix http://bugs.webkit.org/show_bug.cgi?id=16379
+ REGRESSION(r28525): Failures in http/tests/xmlhttprequest/response-encoding.html and
+ fast/dom/xmlhttprequest-html-response-encoding.html
+ and <rdar://problem/5640230> REGRESSION (306A4-ToT): Access violation in PCRE function
+ find_firstassertedchar
+
+ Test: fast/js/regexp-find-first-asserted.html
+
+ * pcre/pcre_compile.cpp:
+ (compileBracket): Take out unnecessary initialization of out parameters.
+ (branchFindFirstAssertedCharacter): Added. Broke out the half of the function that handles
+ a branch.
+ (bracketFindFirstAssertedCharacter): Renamed from find_firstassertedchar. Also removed the
+ options parameter -- the caller can handle the options.
+ (jsRegExpCompile): Changed call site to call the appropriate bracket or branch version of
+ the find_firstassertedchar function. Also put the REQ_IGNORE_CASE code here instead of
+ passing in the options.
+
2007-12-10 Geoffrey Garen <ggaren@apple.com>
Reviewed by Sam Weinig.
static bool compileBracket(int, int*, uschar**, const UChar**, const UChar*, ErrorCode*, int, int*, int*, CompileData&);
static bool bracketIsAnchored(const uschar* code);
static bool bracketNeedsLineStart(const uschar* code, unsigned captureMap, unsigned backrefMap);
+static int bracketFindFirstAssertedCharacter(const uschar* code, bool inassert);
/*************************************************
* Handle escapes *
while (true) {
/* Now compile the branch */
- int branchfirstbyte = REQ_UNSET;
- int branchreqbyte = REQ_UNSET;
+ int branchfirstbyte;
+ int branchreqbyte;
if (!compileBranch(options, brackets, &code, &ptr, patternEnd, errorcodeptr,
&branchfirstbyte, &branchreqbyte, cd)) {
*ptrptr = ptr;
Returns: -1 or the fixed first char
*/
-static int find_firstassertedchar(const uschar* code, int options, bool inassert)
+static int branchFindFirstAssertedCharacter(const uschar* code, bool inassert)
{
- int c = -1;
- do {
- const uschar* scode = firstSignificantOpCodeSkippingAssertions(code + 1 + LINK_SIZE);
- int op = *scode;
-
- if (op >= OP_BRA)
- op = OP_BRA;
-
- switch (op) {
- default:
+ const uschar* scode = firstSignificantOpCodeSkippingAssertions(code);
+ int op = *scode;
+
+ if (op >= OP_BRA)
+ op = OP_BRA;
+
+ switch (op) {
+ default:
+ return -1;
+
+ case OP_BRA:
+ case OP_ASSERT:
+ case OP_ONCE:
+ return bracketFindFirstAssertedCharacter(scode, op == OP_ASSERT);
+
+ case OP_EXACT:
+ scode += 2;
+ /* Fall through */
+
+ case OP_CHAR:
+ case OP_CHAR_IGNORING_CASE:
+ case OP_ASCII_CHAR:
+ case OP_ASCII_LETTER_IGNORING_CASE:
+ case OP_PLUS:
+ case OP_MINPLUS:
+ if (!inassert)
return -1;
-
- case OP_BRA:
- case OP_ASSERT:
- case OP_ONCE: {
- int d;
- if ((d = find_firstassertedchar(scode, options, op == OP_ASSERT)) < 0)
- return -1;
- if (c < 0)
- c = d;
- else if (c != d)
- return -1;
- break;
- }
-
- case OP_EXACT:
- scode += 2;
- /* Fall through */
-
- case OP_CHAR:
- case OP_CHAR_IGNORING_CASE:
- case OP_ASCII_CHAR:
- case OP_ASCII_LETTER_IGNORING_CASE:
- case OP_PLUS:
- case OP_MINPLUS:
- if (!inassert)
- return -1;
- if (c < 0) {
- c = scode[1];
- if (options & IgnoreCaseOption)
- c |= REQ_IGNORE_CASE;
- }
- else if (c != scode[1])
- return -1;
- break;
- }
+ return scode[1];
+ }
+}
+static int bracketFindFirstAssertedCharacter(const uschar* code, bool inassert)
+{
+ int c = -1;
+ do {
+ int d = branchFindFirstAssertedCharacter(code + 1 + LINK_SIZE, inassert);
+ if (d < 0)
+ return -1;
+ if (c < 0)
+ c = d;
+ else if (c != d)
+ return -1;
code += getOpcodeValueAtOffset(code, 1);
} while (*code == OP_ALT);
return c;
if (cd.needOuterBracket ? bracketIsAnchored(codeStart) : branchIsAnchored(codeStart))
re->options |= IsAnchoredOption;
else {
- if (firstbyte < 0)
- firstbyte = find_firstassertedchar(codeStart, re->options, false);
+ if (firstbyte < 0) {
+ firstbyte = (cd.needOuterBracket
+ ? bracketFindFirstAssertedCharacter(codeStart, false)
+ : branchFindFirstAssertedCharacter(codeStart, false))
+ | ((re->options & IgnoreCaseOption) ? REQ_IGNORE_CASE : 0);
+ }
if (firstbyte >= 0) {
int ch = firstbyte & 255;
if (ch < 127) {
+2007-12-10 Darin Adler <darin@apple.com>
+
+ Reviewed by Sam Weinig.
+
+ - test for http://bugs.webkit.org/show_bug.cgi?id=16379
+ REGRESSION(r28525): Failures in http/tests/xmlhttprequest/response-encoding.html and
+ fast/dom/xmlhttprequest-html-response-encoding.html
+ and <rdar://problem/5640230> REGRESSION (306A4-ToT): Access violation in PCRE function
+ find_firstassertedchar
+
+ * fast/js/regexp-find-first-asserted-expected.txt: Added.
+ * fast/js/regexp-find-first-asserted.html: Added.
+ * fast/js/resources/regexp-find-first-asserted.js: Added.
+
2007-12-10 Antti Koivisto <antti@apple.com>
Reviewed by Adele.