Fixing bug 225926 : patch from Roger Lawrence

This commit is contained in:
igor%mir2.org 2003-12-07 15:35:40 +00:00
Родитель ae361d0e90
Коммит 21f15557ab
1 изменённых файлов: 20 добавлений и 15 удалений

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

@ -1022,10 +1022,19 @@ System.out.println();
break; break;
case '*': case '*':
case '+': case '+':
case '}':
case '?': case '?':
reportError("msg.bad.quant", String.valueOf(src[state.cp - 1])); reportError("msg.bad.quant", String.valueOf(src[state.cp - 1]));
return false; return false;
case '{':
/* Treat left-curly in a non-quantifier context as an error only
* if it's followed immediately by a decimal digit.
* This is an Perl extension.
*/
if ((state.cp != state.cpend) && isDigit(src[state.cp])) {
reportError("msg.bad.quant", String.valueOf(src[state.cp - 1]));
return false;
}
// fall thru...
default: default:
state.result = new RENode(REOP_FLAT); state.result = new RENode(REOP_FLAT);
state.result.chr = c; state.result.chr = c;
@ -1069,19 +1078,21 @@ System.out.println();
int max = -1; int max = -1;
int errIndex = state.cp++; int errIndex = state.cp++;
state.result = new RENode(REOP_QUANT);
c = src[state.cp]; c = src[state.cp];
if (isDigit(c)) { if (isDigit(c)) {
++state.cp; ++state.cp;
min = getDecimalValue(c, state); min = getDecimalValue(c, state);
c = src[state.cp]; c = src[state.cp];
} else {
/* For Perl etc. compatibility, if a curly is not
* followed by a proper digit, back off from it
* being a quantifier, and chew it up as a literal
* atom next time instead.
*/
--state.cp;
return true;
} }
else { state.result = new RENode(REOP_QUANT);
reportError("msg.bad.quant",
String.valueOf(src[state.cp]));
return false;
}
if ((min >> 16) != 0) { if ((min >> 16) != 0) {
reportError("msg.overlarge.max", reportError("msg.overlarge.max",
String.valueOf(src[state.cp])); String.valueOf(src[state.cp]));
@ -1109,14 +1120,8 @@ System.out.println();
String.valueOf(src[state.cp])); String.valueOf(src[state.cp]));
return false; return false;
} }
} } else {
else {
max = min; max = min;
if (max == 0) {
reportError("msg.zero.quant",
String.valueOf(src[state.cp]));
return false;
}
} }
state.result.min = min; state.result.min = min;
state.result.max = max; state.result.max = max;