# HG changeset patch # User Kenichi Handa # Date 905175555 0 # Node ID a4e6887571095089a7467bb47eb0be2ab694a7d3 # Parent 750deb2c6c0b993d791821a0834252fe568b43e1 (count_combining_after): Check also preceding bytes at POS if all characters in STRING are not character head. diff -r 750deb2c6c0b -r a4e688757109 src/insdel.c --- a/src/insdel.c Mon Sep 07 13:39:15 1998 +0000 +++ b/src/insdel.c Mon Sep 07 13:39:15 1998 +0000 @@ -950,11 +950,23 @@ if (length == 0 || ASCII_BYTE_P (string[length - 1])) return 0; i = length - 1; - while (i > 0 && ! CHAR_HEAD_P (string[i])) + while (i >= 0 && ! CHAR_HEAD_P (string[i])) { i--; } - if (! BASE_LEADING_CODE_P (string[i])) + if (i < 0) + { + /* All characters in `string' are not character head. + We must check also preceding bytes at POS. + We are sure that the gap is at POS. */ + string = BEG_ADDR; + i = pos_byte - 2; + while (i >= 0 && ! CHAR_HEAD_P (string[i])) + i--; + if (i < 0 || !BASE_LEADING_CODE_P (string[i])) + return 0; + } + else if (!BASE_LEADING_CODE_P (string[i])) return 0; if (pos == ZV)