Mercurial > hg > xemacs-beta
diff src/search.c @ 4421:69b803c646cd
Fail searches immediately if searching for non-representable characters.
2008-02-11 Aidan Kehoe <kehoea@parhasard.net>
* search.c (search_buffer):
In the event that a character is not representable in the buffer,
fail immediately. Prevents an assertion failure in the code to
deal with whether Boyer-Moore search can be used for such
characters.
2008-02-11 Aidan Kehoe <kehoea@parhasard.net>
* automated/case-tests.el (Assert):
New test case; thank you Michael Sperber.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Mon, 11 Feb 2008 22:34:51 +0100 |
parents | df576f30c1d8 |
children | 91a023144e72 19a72041c5ed |
line wrap: on
line diff
--- a/src/search.c Thu Feb 07 10:03:49 2008 +0100 +++ b/src/search.c Mon Feb 11 22:34:51 2008 +0100 @@ -1385,7 +1385,7 @@ && (translated != c || inverse != c)) { Ichar starting_c = c; - int charset_base_code; + int charset_base_code, checked = 0; do { @@ -1399,6 +1399,8 @@ if (c > 0xFF && nothing_greater_than_0xff) continue; + checked = 1; + if (-1 == charset_base) /* No charset yet specified. */ { /* Keep track of which charset and character set row @@ -1425,6 +1427,23 @@ } } while (c != starting_c); + if (!checked) + { +#ifdef DEBUG_XEMACS + if (debug_xemacs_searches) + { + Lisp_Symbol *sym = XSYMBOL (Qsearch_algorithm_used); + sym->value = Qnil; + } +#endif + /* The "continue" clauses were used above, for every + translation of the character. As such, this character + is not to be found in the buffer and neither is the + string as a whole. Return immediately; also avoid + triggering the assertion a few lines down. */ + return n > 0 ? -n : n; + } + if (boyer_moore_ok && charset_base != -1 && charset_base != (translated & ~ICHAR_FIELD3_MASK)) {