# HG changeset patch # User Richard M. Stallman # Date 889221424 0 # Node ID 6b0336de5fbe474c1d05e6d3d24857a47eec02dd # Parent 371ed7bdfd2bd36c0ab02d1cc6fb4654c1436a2c (advance_to_char_boundary): Handle the case the code 0240..0377 is not a constituent of a multibyte sequence. diff -r 371ed7bdfd2b -r 6b0336de5fbe src/buffer.c --- a/src/buffer.c Fri Mar 06 21:50:44 1998 +0000 +++ b/src/buffer.c Fri Mar 06 21:57:04 1998 +0000 @@ -1683,12 +1683,22 @@ advance_to_char_boundary (byte_pos) int byte_pos; { - int c = FETCH_BYTE (byte_pos); - - while (! CHAR_HEAD_P (c)) + int 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;