Mercurial > hg > xemacs-beta
comparison 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 |
comparison
equal
deleted
inserted
replaced
4419:eb82fbb675ea | 4421:69b803c646cd |
---|---|
1383 /* Only do the Boyer-Moore check for characters needing | 1383 /* Only do the Boyer-Moore check for characters needing |
1384 translation. */ | 1384 translation. */ |
1385 && (translated != c || inverse != c)) | 1385 && (translated != c || inverse != c)) |
1386 { | 1386 { |
1387 Ichar starting_c = c; | 1387 Ichar starting_c = c; |
1388 int charset_base_code; | 1388 int charset_base_code, checked = 0; |
1389 | 1389 |
1390 do | 1390 do |
1391 { | 1391 { |
1392 c = TRANSLATE (inverse_trt, c); | 1392 c = TRANSLATE (inverse_trt, c); |
1393 | 1393 |
1396 if (c > 0x7F && entirely_one_byte_p) | 1396 if (c > 0x7F && entirely_one_byte_p) |
1397 continue; | 1397 continue; |
1398 | 1398 |
1399 if (c > 0xFF && nothing_greater_than_0xff) | 1399 if (c > 0xFF && nothing_greater_than_0xff) |
1400 continue; | 1400 continue; |
1401 | |
1402 checked = 1; | |
1401 | 1403 |
1402 if (-1 == charset_base) /* No charset yet specified. */ | 1404 if (-1 == charset_base) /* No charset yet specified. */ |
1403 { | 1405 { |
1404 /* Keep track of which charset and character set row | 1406 /* Keep track of which charset and character set row |
1405 contains the characters that need translation. | 1407 contains the characters that need translation. |
1422 boyer_moore_ok = 0; | 1424 boyer_moore_ok = 0; |
1423 break; | 1425 break; |
1424 } | 1426 } |
1425 } | 1427 } |
1426 } while (c != starting_c); | 1428 } while (c != starting_c); |
1429 | |
1430 if (!checked) | |
1431 { | |
1432 #ifdef DEBUG_XEMACS | |
1433 if (debug_xemacs_searches) | |
1434 { | |
1435 Lisp_Symbol *sym = XSYMBOL (Qsearch_algorithm_used); | |
1436 sym->value = Qnil; | |
1437 } | |
1438 #endif | |
1439 /* The "continue" clauses were used above, for every | |
1440 translation of the character. As such, this character | |
1441 is not to be found in the buffer and neither is the | |
1442 string as a whole. Return immediately; also avoid | |
1443 triggering the assertion a few lines down. */ | |
1444 return n > 0 ? -n : n; | |
1445 } | |
1427 | 1446 |
1428 if (boyer_moore_ok && charset_base != -1 && | 1447 if (boyer_moore_ok && charset_base != -1 && |
1429 charset_base != (translated & ~ICHAR_FIELD3_MASK)) | 1448 charset_base != (translated & ~ICHAR_FIELD3_MASK)) |
1430 { | 1449 { |
1431 /* In the rare event that the CANON entry for this | 1450 /* In the rare event that the CANON entry for this |