Fixed small bug in replace_all.

Start_pos should of course be 0...

Signed-off-by: Victor Arvidsson <victarv@gmail.com>
This commit is contained in:
Victor Arvidsson 2024-10-24 07:26:12 +02:00 committed by Michael Keller
parent 6886c9ccf8
commit e58824e636

View file

@ -47,10 +47,10 @@ static std::string video_time(int secs)
return format_string_std("%d:%02d:%02d.000,", hours, mins, secs);
}
void replace_all(std::string& str, const std::string& old_value, const std::string& new_value) {
static void replace_all(std::string &str, const std::string &old_value, const std::string &new_value) {
if (old_value.empty())
return;
size_t start_pos = std::string::npos;
size_t start_pos = 0;
while ((start_pos = str.find(old_value, start_pos)) != std::string::npos) {
str.replace(start_pos, old_value.length(), new_value);
start_pos += new_value.length(); // In case 'new_value' contains 'old_value', like replacing 'x' with 'yx'