Mercurial > hg > xemacs-beta
comparison src/search.c @ 4901:7504864a986c
Don't use Boyer-Moore if repeated octets & case-insensitive search.
2010-01-30 Aidan Kehoe <kehoea@parhasard.net>
* search.c (search_buffer):
Don't use Boyer-Moore for case-insensitive search if the search
pattern contains repeated Ibytes and the corresponding character
has case information (or, equivalently, if one of its case
equivalents would contain repeated Ibytes).
| author | Aidan Kehoe <kehoea@parhasard.net> |
|---|---|
| date | Sat, 30 Jan 2010 22:25:39 +0000 |
| parents | 91a023144e72 |
| children | e91e3e353805 |
comparison
equal
deleted
inserted
replaced
| 4900:0eccfd4850d6 | 4901:7504864a986c |
|---|---|
| 1423 boyer_moore(). */ | 1423 boyer_moore(). */ |
| 1424 boyer_moore_ok = 0; | 1424 boyer_moore_ok = 0; |
| 1425 break; | 1425 break; |
| 1426 } | 1426 } |
| 1427 } | 1427 } |
| 1428 | |
| 1429 if (ichar_len (c) > 2) | |
| 1430 { | |
| 1431 /* Case-equivalence plus repeated octets throws off | |
| 1432 the construction of the stride table; avoid this. | |
| 1433 | |
| 1434 It should be possible to correct boyer_moore to | |
| 1435 behave correctly even in this case--it doesn't have | |
| 1436 problems with repeated octets when case conversion | |
| 1437 is not involved--but this is not a critical | |
| 1438 issue. */ | |
| 1439 Ibyte encoded[MAX_ICHAR_LEN]; | |
| 1440 Bytecount len = set_itext_ichar (encoded, c); | |
| 1441 int i, j; | |
| 1442 for (i = 0; i < len && boyer_moore_ok; ++i) | |
| 1443 { | |
| 1444 for (j = 0; i < len && boyer_moore_ok; ++j) | |
| 1445 { | |
| 1446 if (encoded[i] == encoded[j]) | |
| 1447 { | |
| 1448 boyer_moore_ok = 0; | |
| 1449 } | |
| 1450 } | |
| 1451 } | |
| 1452 | |
| 1453 if (0 == boyer_moore_ok) | |
| 1454 { | |
| 1455 break; | |
| 1456 } | |
| 1457 } | |
| 1458 | |
| 1428 } while (c != starting_c); | 1459 } while (c != starting_c); |
| 1429 | 1460 |
| 1430 if (!checked) | 1461 if (!checked) |
| 1431 { | 1462 { |
| 1432 #ifdef DEBUG_XEMACS | 1463 #ifdef DEBUG_XEMACS |
