changeset 20188:d4ad4463384d

(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.
author Kenichi Handa <handa@m17n.org>
date Mon, 27 Oct 1997 04:34:26 +0000
parents 0ee26e03e911
children 16f5b56c2f68
files src/charset.c
diffstat 1 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/charset.c	Mon Oct 27 03:53:24 1997 +0000
+++ b/src/charset.c	Mon Oct 27 04:34:26 1997 +0000
@@ -945,6 +945,9 @@
 
   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 @@
   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 @@
 
   while (1)
     {
-      if (p == endp)
+      if (p >= endp)
 	{
-	  if (stop == to)
+	  if (stop >= to)
 	    break;
 
 	  p = POS_ADDR (stop);