X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/b331163bffd790ced0e88b73f44f86d49ccc48a5..HEAD:/icuSources/i18n/uregex.cpp diff --git a/icuSources/i18n/uregex.cpp b/icuSources/i18n/uregex.cpp index 99e94283..7f41918c 100644 --- a/icuSources/i18n/uregex.cpp +++ b/icuSources/i18n/uregex.cpp @@ -1,3 +1,5 @@ +// © 2016 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html /* ******************************************************************************* * Copyright (C) 2004-2015, International Business Machines @@ -765,7 +767,7 @@ uregex_start64(URegularExpression *regexp2, if (validateRE(regexp, TRUE, status) == FALSE) { return 0; } - int32_t result = regexp->fMatcher->start(groupNum, *status); + int64_t result = regexp->fMatcher->start64(groupNum, *status); return result; } @@ -789,7 +791,7 @@ uregex_end64(URegularExpression *regexp2, if (validateRE(regexp, TRUE, status) == FALSE) { return 0; } - int32_t result = regexp->fMatcher->end(groupNum, *status); + int64_t result = regexp->fMatcher->end64(groupNum, *status); return result; } @@ -1463,8 +1465,10 @@ int32_t RegexCImpl::appendReplacement(RegularExpression *regexp, int32_t groupNum = 0; U_ASSERT(c == DOLLARSIGN); - UChar32 c32; - U16_GET(replacementText, 0, replIdx, replacementLength, c32); + UChar32 c32 = -1; + if (replIdx < replacementLength) { + U16_GET(replacementText, 0, replIdx, replacementLength, c32); + } if (u_isdigit(c32)) { int32_t numDigits = 0; int32_t numCaptureGroups = m->fPattern->fGroupMap->size(); @@ -1504,7 +1508,8 @@ int32_t RegexCImpl::appendReplacement(RegularExpression *regexp, (c32 >= 0x31 && c32 <= 0x39)) { // 0..9 groupName.append(c32); } else if (c32 == RIGHTBRACKET) { - groupNum = uhash_geti(regexp->fPat->fNamedCaptureMap, &groupName); + groupNum = regexp->fPat->fNamedCaptureMap ? + uhash_geti(regexp->fPat->fNamedCaptureMap, &groupName) : 0; if (groupNum == 0) { // Name not defined by pattern. *status = U_REGEX_INVALID_CAPTURE_GROUP_NAME; @@ -1650,8 +1655,8 @@ int32_t RegexCImpl::appendTail(RegularExpression *regexp, } else if (UTEXT_USES_U16(m->fInputText)) { srcIdx = (int32_t)nativeIdx; } else { - UErrorCode status = U_ZERO_ERROR; - srcIdx = utext_extract(m->fInputText, 0, nativeIdx, NULL, 0, &status); + UErrorCode newStatus = U_ZERO_ERROR; + srcIdx = utext_extract(m->fInputText, 0, nativeIdx, NULL, 0, &newStatus); } for (;;) {