fix the issue of place find_str(#156)

This commit is contained in:
Jinhao
2016-10-03 05:11:00 +08:00
parent 830839ae27
commit d8ce7ea1ba

View File

@@ -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)