diff src/buffer.c @ 88354:8a0cda2f3c85

Include "character.h" instead of "charset.h", don't include "coding.h". (Fset_buffer_multibyte): Adjuted for UTF-8.
author Kenichi Handa <handa@m17n.org>
date Fri, 01 Mar 2002 01:07:51 +0000
parents 7c5115d286df
children 4e78ee207f40
line wrap: on
line diff
--- a/src/buffer.c	Fri Mar 01 01:06:56 2002 +0000
+++ b/src/buffer.c	Fri Mar 01 01:07:51 2002 +0000
@@ -45,7 +45,7 @@
 #include "window.h"
 #include "commands.h"
 #include "buffer.h"
-#include "charset.h"
+#include "character.h"
 #include "region-cache.h"
 #include "indent.h"
 #include "blockinput.h"
@@ -2085,9 +2085,9 @@
 	      p = GAP_END_ADDR;
 	      stop = Z;
 	    }
-	  if (MULTIBYTE_STR_AS_UNIBYTE_P (p, bytes))
-	    p += bytes, pos += bytes;
-	  else
+	  if (ASCII_BYTE_P (*p))
+	    p++, pos++;
+	  else if (CHAR_BYTE8_HEAD_P (*p))
 	    {
 	      c = STRING_CHAR (p, stop - pos);
 	      /* Delete all bytes for this 8-bit character but the
@@ -2104,6 +2104,11 @@
 		zv -= bytes;
 	      stop = Z;
 	    }
+	  else
+	    {
+	      bytes = BYTES_BY_CHAR_HEAD (*p);
+	      p += bytes, pos += bytes;
+	    }
 	}
       if (narrowed)
 	Fnarrow_to_region (make_number (begv), make_number (zv));
@@ -2112,11 +2117,11 @@
     {
       int pt = PT;
       int pos, stop;
-      unsigned char *p;
+      unsigned char *p, *pend;
 
       /* Be sure not to have a multibyte sequence striding over the GAP.
-	 Ex: We change this: "...abc\201 _GAP_ \241def..."
-	     to: "...abc _GAP_ \201\241def..."  */
+	 Ex: We change this: "...abc\302 _GAP_ \241def..."
+	     to: "...abc _GAP_ \302\241def..."  */
 
       if (GPT_BYTE > 1 && GPT_BYTE < Z_BYTE
 	  && ! CHAR_HEAD_P (*(GAP_END_ADDR)))
@@ -2137,6 +2142,7 @@
       pos = BEG;
       stop = GPT;
       p = BEG_ADDR;
+      pend = GPT_ADDR;
       while (1)
 	{
 	  int bytes;
@@ -2146,10 +2152,11 @@
 	      if (pos == Z)
 		break;
 	      p = GAP_END_ADDR;
+	      pend = Z_ADDR;
 	      stop = Z;
 	    }
 	      
-	  if (UNIBYTE_STR_AS_MULTIBYTE_P (p, stop - pos, bytes))
+	  if ((bytes = MULTIBYTE_LENGTH (p, pend)) > 0)
 	    p += bytes, pos += bytes;
 	  else
 	    {
@@ -4261,8 +4268,6 @@
 #include <fcntl.h>
 #endif
 
-#include "coding.h"
-
 
 /* Memory is allocated in regions which are mapped using mmap(2).
    The current implementation lets the system select mapped