From d8ce7ea1badd51c0b9a6b23f84c576cdec57a806 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Mon, 3 Oct 2016 05:11:00 +0800 Subject: [PATCH] fix the issue of place find_str(#156) --- source/gui/place.cpp | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/source/gui/place.cpp b/source/gui/place.cpp index 739b80cf..ba7c6f9d 100644 --- a/source/gui/place.cpp +++ b/source/gui/place.cpp @@ -2727,17 +2727,26 @@ namespace nana std::size_t find_idstr(const std::string& text, const char* idstr, std::size_t off = 0) { const auto len = std::strlen(idstr); - auto pos = text.find(idstr, off); - if (text.npos == pos) - return text.npos; - if (pos && is_idchar(text[pos - 1])) - return text.npos; + while (true) + { + auto pos = text.find(idstr, off); + if (text.npos == pos) + return text.npos; - if ((pos + len < text.length()) && is_idchar(text[pos + len])) - return text.npos; + if (pos && is_idchar(text[pos - 1])) + { + off = pos + 1; + continue; + } - return pos; + if ((pos + len < text.length()) && is_idchar(text[pos + len])) + { + off = pos + 1; + continue; + } + return pos; + } } void update_div(std::string& div, const char* field, const char* attr, bool insertion)