X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/a0b4f637ba1a6c3c5651b61a69303b029bacf7d3..2ca993e82fb37b597a3c73ecd1586a139a6579c5:/icuSources/i18n/regexcmp.cpp diff --git a/icuSources/i18n/regexcmp.cpp b/icuSources/i18n/regexcmp.cpp index e518e84c..be832337 100644 --- a/icuSources/i18n/regexcmp.cpp +++ b/icuSources/i18n/regexcmp.cpp @@ -1,7 +1,7 @@ // // file: regexcmp.cpp // -// Copyright (C) 2002-2015 International Business Machines Corporation and others. +// Copyright (C) 2002-2016 International Business Machines Corporation and others. // All Rights Reserved. // // This file contains the ICU regular expression compiler, which is responsible @@ -71,6 +71,7 @@ RegexCompile::RegexCompile(RegexPattern *rxp, UErrorCode &status) : fMatchOpenParen = -1; fMatchCloseParen = -1; fCaptureName = NULL; + fLastSetLiteral = U_SENTINEL; if (U_SUCCESS(status) && U_FAILURE(rxp->fDeferredStatus)) { status = rxp->fDeferredStatus; @@ -1757,7 +1758,7 @@ UBool RegexCompile::doParseActions(int32_t action) // and ICU UnicodeSet behavior. { UChar32 c = scanNamedChar(); - if (U_SUCCESS(*fStatus) && fLastSetLiteral > c) { + if (U_SUCCESS(*fStatus) && (fLastSetLiteral == U_SENTINEL || fLastSetLiteral > c)) { error(U_REGEX_INVALID_RANGE); } UnicodeSet *s = (UnicodeSet *)fSetStack.peek(); @@ -1826,7 +1827,8 @@ UBool RegexCompile::doParseActions(int32_t action) // Lower Limit > Upper limit being an error matches both Java // and ICU UnicodeSet behavior. { - if (fLastSetLiteral > fC.fChar) { + + if (fLastSetLiteral == U_SENTINEL || fLastSetLiteral > fC.fChar) { error(U_REGEX_INVALID_RANGE); } UnicodeSet *s = (UnicodeSet *)fSetStack.peek(); @@ -2894,6 +2896,7 @@ void RegexCompile::matchStartType() { case URX_JMPX: loc++; // Except for extra operand on URX_JMPX, same as URX_JMP. + U_FALLTHROUGH; case URX_JMP: { int32_t jmpDest = URX_VAL(op); @@ -3256,6 +3259,7 @@ int32_t RegexCompile::minMatchLength(int32_t start, int32_t end) { case URX_JMPX: loc++; // URX_JMPX has an extra operand, ignored here, // otherwise processed identically to URX_JMP. + U_FALLTHROUGH; case URX_JMP: { int32_t jmpDest = URX_VAL(op);