Author: tommaso Date: Sun Jun 12 02:12:26 2011 New Revision: 39016 URL: http://www.lyx.org/trac/changeset/39016
Log: Now backslash-prefixed regexps like "\s", "\d", etc., are all understood by Advanced F&R. Fixing issue 4 reported at: http://permalink.gmane.org/gmane.editors.lyx.devel/136992 Added: lyx-devel/trunk/development/autotests/findadv-18-in.txt Modified: lyx-devel/trunk/src/lyxfind.cpp Added: lyx-devel/trunk/development/autotests/findadv-18-in.txt ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ lyx-devel/trunk/development/autotests/findadv-18-in.txt Sun Jun 12 02:12:26 2011 (r39016) @@ -0,0 +1,10 @@ +# Searching for regexp with e.g. \[Backspace]\[Backspace]s finds blanks + +Lang it_IT.utf8 +TestBegin test.lyx -dbg find > lyx-log.txt 2>&1 +KK: a b c\C\[Home] +KK: \Cs +KK: \CF +KK: \Axregexp-mode\[Return]\\\\s\[Return] +TestEnd +Assert pcregrep -M 'Putting selection at .*idx: 0 par: 0 pos: 1\n with len: 1' lyx-log.txt Modified: lyx-devel/trunk/src/lyxfind.cpp ============================================================================== --- lyx-devel/trunk/src/lyxfind.cpp Sun Jun 12 01:21:14 2011 (r39015) +++ lyx-devel/trunk/src/lyxfind.cpp Sun Jun 12 02:12:26 2011 (r39016) @@ -518,6 +518,7 @@ escape_map.push_back(pair<string, string>("{[}", "[")); escape_map.push_back(pair<string, string>("\\$", "$")); escape_map.push_back(pair<string, string>("\\backslash{}", "\\")); + escape_map.push_back(pair<string, string>("\\backslash ", "\\")); escape_map.push_back(pair<string, string>("\\backslash", "\\")); escape_map.push_back(pair<string, string>("\\sim ", "~")); escape_map.push_back(pair<string, string>("\\^", "^")); @@ -567,7 +568,8 @@ return s.size(); } -/// Within \regexp{} apply get_regex_escapes(), while outside apply get_lyx_unescapes(). +/// Within \regexp{} apply get_lyx_unescapes() only (i.e., preserve regexp semantics of the string), +/// while outside apply get_lyx_unescapes()+get_regexp_escapes(). string escape_for_regex(string s) { size_t pos = 0; @@ -577,9 +579,9 @@ new_pos = s.size(); LYXERR(Debug::FIND, "new_pos: " << new_pos); string t = apply_escapes(s.substr(pos, new_pos - pos), get_lyx_unescapes()); - LYXERR(Debug::FIND, "t : " << t); + LYXERR(Debug::FIND, "t [lyx]: " << t); t = apply_escapes(t, get_regexp_escapes()); - LYXERR(Debug::FIND, "t : " << t); + LYXERR(Debug::FIND, "t [rxp]: " << t); s.replace(pos, new_pos - pos, t); new_pos = pos + t.size(); LYXERR(Debug::FIND, "Regexp after escaping: " << s);
