Merge pull request !38728 from harmony_zhangjian/master
This commit is contained in:
openharmony_ci 2024-07-25 11:20:47 +00:00 committed by Gitee
commit 43da35a5e2
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -77,7 +77,7 @@ void ReplaceHolder(std::string& originStr, const std::vector<std::string>& param
std::smatch matches;
bool shortHolderType = false;
bool firstMatch = true;
int searchTime = 0;
uint32_t searchTime = 0;
while (std::regex_search(start, end, matches, RESOURCE_APP_STRING_PLACEHOLDER)) {
std::string pos = matches[2];
std::string type = matches[4];
@ -92,16 +92,21 @@ void ReplaceHolder(std::string& originStr, const std::vector<std::string>& param
}
std::string replaceContentStr;
std::string::size_type index;
std::string::size_type index = 0;
if (shortHolderType) {
index = static_cast<std::string::size_type>(searchTime + containCount);
} else {
index = static_cast<std::string::size_type>(StringUtils::StringToInt(pos) - 1 + containCount);
int32_t indexTmp = StringUtils::StringToInt(pos) + static_cast<int32_t>(containCount) - 1;
if (indexTmp >= 0) {
index = static_cast<std::string::size_type>(indexTmp);
} else {
LOGE("indexTmp err:%{public}d", indexTmp);
}
}
if (static_cast<uint32_t>(index) < size) {
replaceContentStr = params[index];
} else {
LOGE("str size is error index = %{public}d size = %{public}d", static_cast<uint32_t>(index), size);
LOGE("index = %{public}d size = %{public}d", static_cast<uint32_t>(index), size);
}
originStr.replace(matches[0].first - originStr.begin(), matches[0].length(), replaceContentStr);
start = originStr.begin() + matches.prefix().length() + replaceContentStr.length();