diff options
Diffstat (limited to 'src/buffer.c')
| -rw-r--r-- | src/buffer.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/buffer.c b/src/buffer.c index 9879e8520bf..9fcae96e8b2 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -1683,12 +1683,22 @@ static int | |||
| 1683 | advance_to_char_boundary (byte_pos) | 1683 | advance_to_char_boundary (byte_pos) |
| 1684 | int byte_pos; | 1684 | int byte_pos; |
| 1685 | { | 1685 | { |
| 1686 | int c = FETCH_BYTE (byte_pos); | 1686 | int c; |
| 1687 | 1687 | ||
| 1688 | while (! CHAR_HEAD_P (c)) | 1688 | if (byte_pos == BEG) |
| 1689 | /* Beginning of buffer is always a character boundary. */ | ||
| 1690 | return 1; | ||
| 1691 | |||
| 1692 | c = FETCH_BYTE (byte_pos); | ||
| 1693 | if (! CHAR_HEAD_P (c)) | ||
| 1689 | { | 1694 | { |
| 1690 | byte_pos++; | 1695 | /* We should advance BYTE_POS only when C is a constituen of a |
| 1691 | c = FETCH_BYTE (byte_pos); | 1696 | multibyte sequence. */ |
| 1697 | DEC_POS (byte_pos); | ||
| 1698 | INC_POS (byte_pos); | ||
| 1699 | /* If C is a constituent of a multibyte sequence, BYTE_POS was | ||
| 1700 | surely advance to the correct character boundary. If C is | ||
| 1701 | not, BYTE_POS was unchanged. */ | ||
| 1692 | } | 1702 | } |
| 1693 | 1703 | ||
| 1694 | return byte_pos; | 1704 | return byte_pos; |