mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 19:04:59 +00:00
AK: Use an enum instead of a bool for String::replace(all_occurences)
This commit has no behavior changes. In particular, this does not fix any of the wrong uses of the previous default parameter (which used to be 'false', meaning "only replace the first occurence in the string"). It simply replaces the default uses by String::replace(..., ReplaceMode::FirstOnly), leaving them incorrect.
This commit is contained in:
parent
b2454888e8
commit
7ceeb74535
47 changed files with 108 additions and 102 deletions
|
@ -340,7 +340,7 @@ static String parse_identifiers(String pattern, StringView replacement, UnicodeL
|
|||
utf8_pattern = utf8_pattern.substring_view(*start_index, *end_index - *start_index);
|
||||
utf8_pattern = utf8_pattern.trim(whitespace);
|
||||
|
||||
auto identifier = utf8_pattern.as_string().replace("'.'"sv, "."sv);
|
||||
auto identifier = utf8_pattern.as_string().replace("'.'"sv, "."sv, ReplaceMode::FirstOnly);
|
||||
auto identifier_index = locale_data.unique_strings.ensure(move(identifier));
|
||||
size_t replacement_index = 0;
|
||||
|
||||
|
@ -379,7 +379,7 @@ static void parse_number_pattern(Vector<String> patterns, UnicodeLocaleData& loc
|
|||
};
|
||||
|
||||
for (auto const& replacement : replacements)
|
||||
pattern = pattern.replace(replacement.key, replacement.value, true);
|
||||
pattern = pattern.replace(replacement.key, replacement.value, ReplaceMode::All);
|
||||
|
||||
if (auto start_number_index = pattern.find_any_of("#0"sv, String::SearchDirection::Forward); start_number_index.has_value()) {
|
||||
auto end_number_index = *start_number_index + 1;
|
||||
|
@ -415,7 +415,7 @@ static void parse_number_pattern(Vector<String> patterns, UnicodeLocaleData& loc
|
|||
// This is specifically handled here rather than in the replacements HashMap above so
|
||||
// that we do not errantly replace zeroes in number patterns.
|
||||
if (pattern.contains(*replacements.get("E"sv)))
|
||||
pattern = pattern.replace("0"sv, "{scientificExponent}"sv);
|
||||
pattern = pattern.replace("0"sv, "{scientificExponent}"sv, ReplaceMode::FirstOnly);
|
||||
}
|
||||
|
||||
if (type == NumberFormatType::Compact)
|
||||
|
@ -677,11 +677,11 @@ static ErrorOr<void> parse_units(String locale_units_path, UnicodeLocaleData& lo
|
|||
auto plurality = unit_key.substring_view(unit_pattern_prefix.length());
|
||||
format.plurality = NumberFormat::plurality_from_string(plurality);
|
||||
|
||||
auto zero_format = pattern_value.as_string().replace("{0}"sv, "{number}"sv);
|
||||
auto zero_format = pattern_value.as_string().replace("{0}"sv, "{number}"sv, ReplaceMode::FirstOnly);
|
||||
zero_format = parse_identifiers(zero_format, "unitIdentifier"sv, locale_data, format);
|
||||
|
||||
format.positive_format_index = locale_data.unique_strings.ensure(zero_format.replace("{number}"sv, "{plusSign}{number}"sv));
|
||||
format.negative_format_index = locale_data.unique_strings.ensure(zero_format.replace("{number}"sv, "{minusSign}{number}"sv));
|
||||
format.positive_format_index = locale_data.unique_strings.ensure(zero_format.replace("{number}"sv, "{plusSign}{number}"sv, ReplaceMode::FirstOnly));
|
||||
format.negative_format_index = locale_data.unique_strings.ensure(zero_format.replace("{number}"sv, "{minusSign}{number}"sv, ReplaceMode::FirstOnly));
|
||||
format.zero_format_index = locale_data.unique_strings.ensure(move(zero_format));
|
||||
|
||||
formats.append(locale_data.unique_formats.ensure(move(format)));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue