diff options
| -rw-r--r-- | src/ChangeLog | 5 | ||||
| -rw-r--r-- | src/search.c | 27 |
2 files changed, 17 insertions, 15 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 27c2b7246af..1ac89ec8561 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2009-11-22 Andreas Schwab <schwab@linux-m68k.org> | ||
| 2 | |||
| 3 | * search.c (simple_search): Avoid CHAR_TO_BYTE in inner loop when | ||
| 4 | searching backwards through multibyte buffer. | ||
| 5 | |||
| 1 | 2009-11-21 Jan Djärv <jan.h.d@swipnet.se> | 6 | 2009-11-21 Jan Djärv <jan.h.d@swipnet.se> |
| 2 | 7 | ||
| 3 | * xterm.c: #include xgselect.h. | 8 | * xterm.c: #include xgselect.h. |
diff --git a/src/search.c b/src/search.c index fd45d316a46..abbad764c3c 100644 --- a/src/search.c +++ b/src/search.c | |||
| @@ -1609,39 +1609,36 @@ simple_search (n, pat, len, len_byte, trt, pos, pos_byte, lim, lim_byte) | |||
| 1609 | while (1) | 1609 | while (1) |
| 1610 | { | 1610 | { |
| 1611 | /* Try matching at position POS. */ | 1611 | /* Try matching at position POS. */ |
| 1612 | EMACS_INT this_pos = pos - len; | 1612 | EMACS_INT this_pos = pos; |
| 1613 | EMACS_INT this_pos_byte; | 1613 | EMACS_INT this_pos_byte = pos_byte; |
| 1614 | int this_len = len; | 1614 | int this_len = len; |
| 1615 | unsigned char *p = pat; | 1615 | unsigned char *p = pat + len_byte; |
| 1616 | 1616 | ||
| 1617 | if (this_pos < lim || (pos_byte - len_byte) < lim_byte) | 1617 | if (this_pos - len < lim || (pos_byte - len_byte) < lim_byte) |
| 1618 | goto stop; | 1618 | goto stop; |
| 1619 | this_pos_byte = CHAR_TO_BYTE (this_pos); | ||
| 1620 | match_byte = pos_byte - this_pos_byte; | ||
| 1621 | 1619 | ||
| 1622 | while (this_len > 0) | 1620 | while (this_len > 0) |
| 1623 | { | 1621 | { |
| 1624 | int charlen, buf_charlen; | 1622 | int charlen; |
| 1625 | int pat_ch, buf_ch; | 1623 | int pat_ch, buf_ch; |
| 1626 | 1624 | ||
| 1627 | pat_ch = STRING_CHAR_AND_LENGTH (p, charlen); | 1625 | DEC_BOTH (this_pos, this_pos_byte); |
| 1628 | buf_ch = STRING_CHAR_AND_LENGTH (BYTE_POS_ADDR (this_pos_byte), | 1626 | PREV_CHAR_BOUNDARY (p, pat); |
| 1629 | buf_charlen); | 1627 | pat_ch = STRING_CHAR (p); |
| 1628 | buf_ch = STRING_CHAR (BYTE_POS_ADDR (this_pos_byte)); | ||
| 1630 | TRANSLATE (buf_ch, trt, buf_ch); | 1629 | TRANSLATE (buf_ch, trt, buf_ch); |
| 1631 | 1630 | ||
| 1632 | if (buf_ch != pat_ch) | 1631 | if (buf_ch != pat_ch) |
| 1633 | break; | 1632 | break; |
| 1634 | 1633 | ||
| 1635 | this_len--; | 1634 | this_len--; |
| 1636 | p += charlen; | ||
| 1637 | this_pos_byte += buf_charlen; | ||
| 1638 | this_pos++; | ||
| 1639 | } | 1635 | } |
| 1640 | 1636 | ||
| 1641 | if (this_len == 0) | 1637 | if (this_len == 0) |
| 1642 | { | 1638 | { |
| 1643 | pos -= len; | 1639 | match_byte = pos_byte - this_pos_byte; |
| 1644 | pos_byte -= match_byte; | 1640 | pos = this_pos; |
| 1641 | pos_byte = this_pos_byte; | ||
| 1645 | break; | 1642 | break; |
| 1646 | } | 1643 | } |
| 1647 | 1644 | ||