changeset 20586:90d6a75210d6

(record_overlay_string): Totalize sizes assuming strings are converted to match buffer in multibyteness. (overlay_strings): Convert strings to match buffer in multibyteness.
author Richard M. Stallman <rms@gnu.org>
date Mon, 05 Jan 1998 17:15:53 +0000
parents 15deff6b2848
children eaf988c7e291
files src/buffer.c
diffstat 1 files changed, 37 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/buffer.c	Mon Jan 05 17:14:29 1998 +0000
+++ b/src/buffer.c	Mon Jan 05 17:15:53 1998 +0000
@@ -2186,6 +2186,8 @@
      Lisp_Object str, str2, pri;
      int size;
 {
+  int nbytes;
+
   if (ssl->used == ssl->size)
     {
       if (ssl->buf)
@@ -2200,9 +2202,29 @@
   ssl->buf[ssl->used].size = size;
   ssl->buf[ssl->used].priority = (INTEGERP (pri) ? XINT (pri) : 0);
   ssl->used++;
-  ssl->bytes += XSTRING (str)->size;
+
+  if (NILP (current_buffer->enable_multibyte_characters))
+    nbytes = XSTRING (str)->size;
+  else if (! STRING_MULTIBYTE (str))
+    nbytes = count_size_as_multibyte (XSTRING (str)->data,
+				      XSTRING (str)->size_byte);
+  else
+    nbytes = XSTRING (str)->size_byte;
+
+  ssl->bytes += nbytes;
+
   if (STRINGP (str2))
-    ssl->bytes += XSTRING (str2)->size;
+    {
+      if (NILP (current_buffer->enable_multibyte_characters))
+	nbytes = XSTRING (str2)->size;
+      else if (! STRING_MULTIBYTE (str2))
+	nbytes = count_size_as_multibyte (XSTRING (str2)->data,
+					  XSTRING (str2)->size_byte);
+      else
+	nbytes = XSTRING (str2)->size_byte;
+
+      ssl->bytes += nbytes;
+    }
 }
 
 /* Return the concatenation of the strings associated with overlays that
@@ -2225,6 +2247,7 @@
 {
   Lisp_Object ov, overlay, window, str;
   int startpos, endpos;
+  int multibyte = ! NILP (current_buffer->enable_multibyte_characters);
 
   overlay_heads.used = overlay_heads.bytes = 0;
   overlay_tails.used = overlay_tails.bytes = 0;
@@ -2308,20 +2331,26 @@
       p = overlay_str_buf;
       for (i = overlay_tails.used; --i >= 0;)
 	{
+	  int nbytes;
 	  tem = overlay_tails.buf[i].string;
-	  bcopy (XSTRING (tem)->data, p, XSTRING (tem)->size);
-	  p += XSTRING (tem)->size;
+	  nbytes = copy_text (XSTRING (tem)->data, p, XSTRING (tem)->size_byte,
+			      STRING_MULTIBYTE (tem), multibyte);
+	  p += nbytes;
 	}
       for (i = 0; i < overlay_heads.used; ++i)
 	{
+	  int nbytes;
 	  tem = overlay_heads.buf[i].string;
-	  bcopy (XSTRING (tem)->data, p, XSTRING (tem)->size);
-	  p += XSTRING (tem)->size;
+	  nbytes = copy_text (XSTRING (tem)->data, p, XSTRING (tem)->size_byte,
+			      STRING_MULTIBYTE (tem), multibyte);
+	  p += nbytes;
 	  tem = overlay_heads.buf[i].string2;
 	  if (STRINGP (tem))
 	    {
-	      bcopy (XSTRING (tem)->data, p, XSTRING (tem)->size);
-	      p += XSTRING (tem)->size;
+	      nbytes = copy_text (XSTRING (tem)->data, p,
+				  XSTRING (tem)->size_byte,
+				  STRING_MULTIBYTE (tem), multibyte);
+	      p += nbytes;
 	    }
 	}
       if (p != overlay_str_buf + total)