6635133: Exception thrown when using a Unicode escape

Update regex engine to handle unicode escape correctly in character class

Reviewed-by: okutsu
This commit is contained in:
Xueming Shen 2008-04-14 21:45:45 -07:00
parent 6c33c4e721
commit f935457fef

@ -2844,7 +2844,15 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
/**
* Utility method for parsing unicode escape sequences.
*/
private int u() {
private int cursor() {
return cursor;
}
private void setcursor(int pos) {
cursor = pos;
}
private int uxxxx() {
int n = 0;
for (int i = 0; i < 4; i++) {
int ch = read();
@ -2856,6 +2864,20 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
return n;
}
private int u() {
int n = uxxxx();
if (Character.isHighSurrogate((char)n)) {
int cur = cursor();
if (read() == '\\' && read() == 'u') {
int n2 = uxxxx();
if (Character.isLowSurrogate((char)n2))
return Character.toCodePoint((char)n, (char)n2);
}
setcursor(cur);
}
return n;
}
//
// Utility methods for code point support
//