From 86e3511500ac92d6449e0b3ec662cc10ecfd425a Mon Sep 17 00:00:00 2001 From: Iwan Kawrakow Date: Sun, 27 Aug 2023 16:43:50 +0300 Subject: [PATCH] Fixit: it was missing the piece after the last found occurence --- llama.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/llama.cpp b/llama.cpp index fe6501de6..dbbd4acd8 100644 --- a/llama.cpp +++ b/llama.cpp @@ -117,7 +117,10 @@ void replace_all(std::string & s, const std::string & search, const std::string std::string result; for (size_t pos = 0; ; pos += search.length()) { auto new_pos = s.find(search, pos); - if (new_pos == std::string::npos) break; + if (new_pos == std::string::npos) { + result += s.substr(pos, s.size() - pos); + break; + } result += s.substr(pos, new_pos - pos) + replace; pos = new_pos; }