Fixed whitespace testing. Fixed bug 122167 - $nn handling in replace.

This commit is contained in:
rogerl%netscape.com 2002-06-22 19:38:02 +00:00
Родитель a77335669a
Коммит a270823871
2 изменённых файлов: 21 добавлений и 6 удалений

Просмотреть файл

@ -384,6 +384,15 @@ System.out.println();
return TokenStream.isJSLineTerminator(c);
}
private boolean isREWhiteSpace(int c) {
return (c == '\u0020' || c == '\u0009'
|| c == '\n' || c == '\r'
|| c == 0x2028 || c == 0x2029
|| c == '\u000C' || c == '\u000B'
|| c == '\u00A0'
|| Character.getType((char)c) == Character.SPACE_SEPARATOR);
}
/*
*
@ -1693,12 +1702,12 @@ System.out.println();
continue;
case 's':
for (i = (int)(charSet.length); i >= 0; i--)
if (Character.isSpaceChar((char)i))
if (isREWhiteSpace(i))
addCharacterToCharSet(charSet, (char)(i));
continue;
case 'S':
for (i = (int)(charSet.length); i >= 0; i--)
if (!Character.isSpaceChar((char)i))
if (!isREWhiteSpace(i))
addCharacterToCharSet(charSet, (char)(i));
continue;
case 'w':
@ -1960,7 +1969,7 @@ System.out.println("Testing at " + x.cp + ", op = " + op);
break;
case REOP_SPACE:
if (x.cp != gData.cpend
&& Character.isSpaceChar(gData.cpbegin[x.cp])) {
&& isREWhiteSpace(gData.cpbegin[x.cp])) {
result = x;
result.cp++;
}
@ -1969,7 +1978,7 @@ System.out.println("Testing at " + x.cp + ", op = " + op);
break;
case REOP_NONSPACE:
if (x.cp != gData.cpend
&& !Character.isSpaceChar(gData.cpbegin[x.cp])) {
&& !isREWhiteSpace(gData.cpbegin[x.cp])) {
result = x;
result.cp++;
}

Просмотреть файл

@ -416,13 +416,19 @@ class ReplaceData extends GlobData {
}
}
else { /* ECMA 3, 1-9 or 01-99 */
int parenCount = res.parens.size();
num = NativeRegExp.unDigit(dc);
if (num > parenCount)
return null;
cp = dp + 2;
if ((dp + 2) < da.length) {
dc = da[dp + 2];
if (NativeRegExp.isDigit(dc)) {
num = 10 * num + NativeRegExp.unDigit(dc);
cp++;
tmp = 10 * num + NativeRegExp.unDigit(dc);
if (tmp <= parenCount) {
cp++;
num = tmp;
}
}
}
if (num == 0) return null; /* $0 or $00 is not valid */