Do not search for empty string

This commit is contained in:
Juergen Spitzmueller 2012-09-17 09:32:47 +02:00
parent e8a01d099a
commit ec078bd29d

View File

@ -1044,7 +1044,7 @@ int iterateLine(string const token, regex const reg, string const closing,
// result = -1 means we did not find a fragment! // result = -1 means we did not find a fragment!
int result = -1; int result = -1;
int last_match_pos = -1; int last_match_pos = -1;
if (token.find(last_match) != string::npos) if (!last_match.empty() && token.find(last_match) != string::npos)
last_match_pos = int(token.find(last_match)); last_match_pos = int(token.find(last_match));
if (fragment) { if (fragment) {
if (last_match_pos > fragment_pos) if (last_match_pos > fragment_pos)
@ -1054,6 +1054,7 @@ int iterateLine(string const token, regex const reg, string const closing,
} else } else
if (last_match_pos < fragment_pos) if (last_match_pos < fragment_pos)
result = fragment_pos; result = fragment_pos;
return result; return result;
} }