X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Flyxfind.cpp;h=57a25e929f38ee911c0c27e4389a4eb0af680db0;hb=91d8a3982d4acd9118217b4d30a5500e3bbd178e;hp=955ffc4a3b6323ca06655db745b5b003699ce5c1;hpb=ee251c626cd9ab59a12b9024304e01deee464acb;p=lyx.git diff --git a/src/lyxfind.cpp b/src/lyxfind.cpp index 955ffc4a3b..57a25e929f 100644 --- a/src/lyxfind.cpp +++ b/src/lyxfind.cpp @@ -957,23 +957,7 @@ int MatchStringAdv::findAux(DocIterator const & cur, int len, bool at_begin) con LYXERR(Debug::FIND, "Matching against '" << lyx::to_utf8(docstr) << "'"); LYXERR(Debug::FIND, "After normalization: '" << str << "'"); - if (!use_regexp) { - LYXERR(Debug::FIND, "Searching in normal mode: par_as_string='" - << par_as_string << "', str='" << str << "'"); - LYXERR(Debug::FIND, "Searching in normal mode: lead_as_string='" - << lead_as_string << "', par_as_string_nolead='" - << par_as_string_nolead << "'"); - if (at_begin) { - LYXERR(Debug::FIND, "size=" << par_as_string.size() - << ", substr='" << str.substr(0, par_as_string.size()) << "'"); - if (str.substr(0, par_as_string.size()) == par_as_string) - return par_as_string.size(); - } else { - size_t pos = str.find(par_as_string_nolead); - if (pos != string::npos) - return par_as_string.size(); - } - } else { + if (use_regexp) { LYXERR(Debug::FIND, "Searching in regexp mode: at_begin=" << at_begin); regex const & p_regexp = at_begin ? regexp : regexp2; sregex_iterator re_it(str.begin(), str.end(), p_regexp); @@ -994,8 +978,26 @@ int MatchStringAdv::findAux(DocIterator const & cur, int len, bool at_begin) con // due to close wildcards added at end of regexp if (close_wildcards == 0) return m[0].second - m[0].first; - else - return m[m.size() - close_wildcards].first - m[0].first; + + return m[m.size() - close_wildcards].first - m[0].first; + } + + // else !use_regexp: but all code paths above return + LYXERR(Debug::FIND, "Searching in normal mode: par_as_string='" + << par_as_string << "', str='" << str << "'"); + LYXERR(Debug::FIND, "Searching in normal mode: lead_as_string='" + << lead_as_string << "', par_as_string_nolead='" + << par_as_string_nolead << "'"); + + if (at_begin) { + LYXERR(Debug::FIND, "size=" << par_as_string.size() + << ", substr='" << str.substr(0, par_as_string.size()) << "'"); + if (str.substr(0, par_as_string.size()) == par_as_string) + return par_as_string.size(); + } else { + size_t pos = str.find(par_as_string_nolead); + if (pos != string::npos) + return par_as_string.size(); } return 0; }