summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1998-03-06 21:57:04 +0000
committerRichard M. Stallman <rms@gnu.org>1998-03-06 21:57:04 +0000
commitf8449323058067b822415b4821e2eb66effe0ecb (patch)
tree637dfa0b070fb7867f6848fff9205f9582ff2d6b /src
parente54daa22b060568e8d8e1b07eee3ed6905c3279c (diff)
downloademacs-f8449323058067b822415b4821e2eb66effe0ecb.tar.gz
(advance_to_char_boundary): Handle the case the code
0240..0377 is not a constituent of a multibyte sequence.
Diffstat (limited to 'src')
-rw-r--r--src/buffer.c18
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
advance_to_char_boundary (byte_pos)
int byte_pos;
{
- int c = FETCH_BYTE (byte_pos);
+ int c;
- while (! CHAR_HEAD_P (c))
+ if (byte_pos == BEG)
+ /* Beginning of buffer is always a character boundary. */
+ return 1;
+
+ c = FETCH_BYTE (byte_pos);
+ if (! CHAR_HEAD_P (c))
{
- byte_pos++;
- c = FETCH_BYTE (byte_pos);
+ /* We should advance BYTE_POS only when C is a constituen of a
+ multibyte sequence. */
+ DEC_POS (byte_pos);
+ INC_POS (byte_pos);
+ /* If C is a constituent of a multibyte sequence, BYTE_POS was
+ surely advance to the correct character boundary. If C is
+ not, BYTE_POS was unchanged. */
}
return byte_pos;