From 9036eb4502cc763993b219fcb74b546a2b5ab999 Mon Sep 17 00:00:00 2001 From: Kenichi Handa Date: Mon, 27 Oct 1997 04:34:26 +0000 Subject: [PATCH] (Fchars_in_string): Pay attention to enable-multibyte-characters. (Fchars_in_region): Likewise. Avoid error when the region ends in the middle of a multibyte character. --- src/charset.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/charset.c b/src/charset.c index 7d8716e134e..56dc15e78da 100644 --- a/src/charset.c +++ b/src/charset.c @@ -945,6 +945,9 @@ character.") CHECK_STRING (str, 0); + if (NILP (current_buffer->enable_multibyte_characters)) + return make_number (XSTRING (str)->size); + p = XSTRING (str)->data; endp = p + XSTRING (str)->size; chars = 0; while (p < endp) @@ -982,6 +985,9 @@ may be more than the number of characters.") to = max (XFASTINT (beg), XFASTINT (end)); p = POS_ADDR (from); + if (NILP (current_buffer->enable_multibyte_characters)) + return make_number (to - from); + if (from < GPT && GPT <= to) { stop = GPT; @@ -995,9 +1001,9 @@ may be more than the number of characters.") while (1) { - if (p == endp) + if (p >= endp) { - if (stop == to) + if (stop >= to) break; p = POS_ADDR (stop); -- 2.39.2