ICU-3089 disallow unquoted specials in suffix

X-SVN-Rev: 14555
This commit is contained in:
Alan Liu 2004-02-20 19:38:59 +00:00
parent 0982a30439
commit d0393ac474

View File

@ -3018,46 +3018,23 @@ DecimalFormat::applyPattern(const UnicodeString& pattern,
// Process the prefix / suffix characters // Process the prefix / suffix characters
// Process unquoted characters seen in prefix or suffix // Process unquoted characters seen in prefix or suffix
// subpart. // subpart.
if (pattern.compare(pos, digitLen, digit) == 0) {
// Any of these characters implicitly begins the // Several syntax characters implicitly begins the
// next subpart if we are in the prefix // next subpart if we are in the prefix; otherwise
// they are illegal if unquoted.
if (!pattern.compare(pos, digitLen, digit) ||
!pattern.compare(pos, groupSepLen, groupingSeparator) ||
!pattern.compare(pos, decimalSepLen, decimalSeparator) ||
(ch >= zeroDigit && ch <= nineDigit)) {
if (subpart == 1) { // prefix subpart if (subpart == 1) { // prefix subpart
subpart = 0; // pattern proper subpart subpart = 0; // pattern proper subpart
sub0Start = pos; // Reprocess this character sub0Start = pos; // Reprocess this character
continue; continue;
} else {
status = U_UNQUOTED_SPECIAL;
syntaxError(pattern,pos,parseError);
return;
} }
pos += digitLen;
// Fall through to append(ch)
} else if (pattern.compare(pos, groupSepLen, groupingSeparator) == 0) {
// Any of these characters implicitly begins the
// next subpart if we are in the prefix
if (subpart == 1) { // prefix subpart
subpart = 0; // pattern proper subpart
sub0Start = pos; // Reprocess this character
continue;
}
pos += groupSepLen;
// Fall through to append(ch)
} else if (pattern.compare(pos, decimalSepLen, decimalSeparator) == 0) {
// Any of these characters implicitly begins the
// next subpart if we are in the prefix
if (subpart == 1) { // prefix subpart
subpart = 0; // pattern proper subpart
sub0Start = pos; // Reprocess this character
continue;
}
pos += decimalSepLen;
// Fall through to append(ch)
} else if (ch >= zeroDigit && ch <= nineDigit) {
// Any of these characters implicitly begins the
// next subpart if we are in the prefix
if (subpart == 1) { // prefix subpart
subpart = 0; // pattern proper subpart
sub0Start = pos; // Reprocess this character
continue;
}
pos++;
// Fall through to append(ch)
} else if (ch == kCurrencySign) { } else if (ch == kCurrencySign) {
// Use lookahead to determine if the currency sign is // Use lookahead to determine if the currency sign is
// doubled or not. // doubled or not.