зеркало из https://github.com/mozilla/gecko-dev.git
Additional regexp DoReplace diagnostics. (r=dmandelin, a=blocker, b=605754)
--HG-- extra : rebase_source : 4df11ffca07b3410c479c887daf3fc4207d6395c
This commit is contained in:
Родитель
d6b3b76cf6
Коммит
83291e1e5a
|
@ -2369,10 +2369,24 @@ struct JSContext
|
|||
DOLLAR_AMP,
|
||||
DOLLAR_PLUS,
|
||||
DOLLAR_TICK,
|
||||
DOLLAR_QUOT
|
||||
DOLLAR_QUOT,
|
||||
DOLLAR_EMPTY,
|
||||
DOLLAR_1,
|
||||
DOLLAR_2,
|
||||
DOLLAR_3,
|
||||
DOLLAR_4,
|
||||
DOLLAR_5,
|
||||
DOLLAR_OTHER
|
||||
};
|
||||
#ifdef XP_WIN
|
||||
volatile DollarPath *dollarPath;
|
||||
volatile JSSubString *sub;
|
||||
volatile jschar *blackBox;
|
||||
volatile jschar **repstrChars;
|
||||
volatile jschar **repstrDollar;
|
||||
volatile jschar **repstrDollarEnd;
|
||||
volatile size_t *peekLen;
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -2020,6 +2020,16 @@ InterpretDollar(JSContext *cx, RegExpStatics *res, jschar *dp, jschar *ep, Repla
|
|||
*skip = cp - dp;
|
||||
|
||||
JS_CRASH_UNLESS(num <= res->parenCount());
|
||||
|
||||
switch (num) {
|
||||
case 1: *path = JSContext::DOLLAR_1; break;
|
||||
case 2: *path = JSContext::DOLLAR_2; break;
|
||||
case 3: *path = JSContext::DOLLAR_3; break;
|
||||
case 4: *path = JSContext::DOLLAR_4; break;
|
||||
case 5: *path = JSContext::DOLLAR_5; break;
|
||||
default: *path = JSContext::DOLLAR_OTHER;
|
||||
}
|
||||
|
||||
/*
|
||||
* Note: we index to get the paren with the (1-indexed) pair
|
||||
* number, as opposed to a (0-indexed) paren number.
|
||||
|
@ -2185,9 +2195,11 @@ DoReplace(JSContext *cx, RegExpStatics *res, ReplaceData &rdata, jschar *chars)
|
|||
jschar *cp;
|
||||
jschar *bp = cp = repstr->chars();
|
||||
volatile JSContext::DollarPath path;
|
||||
#ifdef XP_WIN
|
||||
cx->dollarPath = &path;
|
||||
jschar sourceBuf[128];
|
||||
cx->blackBox = sourceBuf;
|
||||
#endif
|
||||
|
||||
for (jschar *dp = rdata.dollar, *ep = rdata.dollarEnd; dp; dp = js_strchr_limit(dp, '$', ep)) {
|
||||
size_t len = dp - cp;
|
||||
|
@ -2198,11 +2210,24 @@ DoReplace(JSContext *cx, RegExpStatics *res, ReplaceData &rdata, jschar *chars)
|
|||
JSSubString sub;
|
||||
size_t skip;
|
||||
if (InterpretDollar(cx, res, dp, ep, rdata, &sub, &skip, &path)) {
|
||||
#ifdef XP_WIN
|
||||
if (((size_t(sub.chars) & 0xfffffU) + sub.length) > 0x100000U) {
|
||||
/* Going to cross a 0xffffe address, so take a gander at the replace value. */
|
||||
size_t peekLen = JS_MIN(rdata.dollarEnd - rdata.dollar, 128);
|
||||
js_strncpy(sourceBuf, rdata.dollar, peekLen);
|
||||
volatile JSSubString vsub = sub;
|
||||
volatile jschar *repstrChars = rdata.repstr->chars();
|
||||
volatile jschar *repstrDollar = rdata.dollar;
|
||||
volatile jschar *repstrDollarEnd = rdata.dollarEnd;
|
||||
cx->sub = &vsub;
|
||||
cx->repstrChars = &repstrChars;
|
||||
cx->repstrDollar = &repstrDollar;
|
||||
cx->repstrDollarEnd = &repstrDollarEnd;
|
||||
ptrdiff_t dollarDistance = rdata.dollarEnd - rdata.dollar;
|
||||
JS_CRASH_UNLESS(dollarDistance >= 0);
|
||||
volatile size_t peekLen = JS_MIN(rdata.repstr->length(), 128);
|
||||
cx->peekLen = &peekLen;
|
||||
js_strncpy(sourceBuf, rdata.repstr->chars(), peekLen);
|
||||
}
|
||||
#endif
|
||||
|
||||
len = sub.length;
|
||||
js_strncpy(chars, sub.chars, len);
|
||||
|
|
|
@ -994,7 +994,7 @@ class RegexGenerator : private MacroAssembler {
|
|||
parenthesesState.linkAlternativeBacktracks(this);
|
||||
if (term.invertOrCapture) {
|
||||
store32(Imm32(-1), Address(output, (term.parentheses.subpatternId << 1) * sizeof(int)));
|
||||
#if DEBUG
|
||||
#if 0
|
||||
store32(Imm32(-1), Address(output, ((term.parentheses.subpatternId << 1) + 1) * sizeof(int)));
|
||||
#endif
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче