X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/f3c0d7a59d99c2a94c6b8822291f0e42be3773c9..HEAD:/icuSources/i18n/uregex.cpp diff --git a/icuSources/i18n/uregex.cpp b/icuSources/i18n/uregex.cpp index 0c26bdf6..7f41918c 100644 --- a/icuSources/i18n/uregex.cpp +++ b/icuSources/i18n/uregex.cpp @@ -767,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; } @@ -791,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; } @@ -1465,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(); @@ -1506,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; @@ -1652,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 (;;) {