changeset 107319:7a74731f53f0

Fix handling of the multibyte form of raw-bytes in unibyte->multibyte conversion.
author Kenichi Handa <handa@m17n.org>
date Tue, 02 Mar 2010 13:55:33 +0900
parents 994a9686476c (current diff) 72a86cbe50bc (diff)
children d2bfe26756ed
files
diffstat 2 files changed, 16 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Mon Mar 01 19:47:19 2010 -0800
+++ b/src/ChangeLog	Tue Mar 02 13:55:33 2010 +0900
@@ -1,5 +1,9 @@
 2010-03-02  Kenichi Handa  <handa@m17n.org>
 
+	* character.c (parse_str_as_multibyte): Fix handling of the
+	multibyte form of raw-bytes.
+	(str_as_multibyte): Likewise.
+
 	* buffer.c (Fset_buffer_multibyte): Fix handling of the multibyte
 	form of raw-bytes.
 
--- a/src/character.c	Mon Mar 01 19:47:19 2010 -0800
+++ b/src/character.c	Tue Mar 02 13:55:33 2010 +0900
@@ -630,7 +630,8 @@
       const unsigned char *adjusted_endp = endp - MAX_MULTIBYTE_LENGTH;
       while (str < adjusted_endp)
 	{
-	  if ((n = MULTIBYTE_LENGTH_NO_CHECK (str)) > 0)
+	  if (! CHAR_BYTE8_HEAD_P (*str)
+	      && (n = MULTIBYTE_LENGTH_NO_CHECK (str)) > 0)
 	    str += n, bytes += n;
 	  else
 	    str++, bytes += 2;
@@ -639,7 +640,8 @@
     }
   while (str < endp)
     {
-      if ((n = MULTIBYTE_LENGTH (str, endp)) > 0)
+      if (! CHAR_BYTE8_HEAD_P (*str)
+	  && (n = MULTIBYTE_LENGTH (str, endp)) > 0)
 	str += n, bytes += n;
       else
 	str++, bytes += 2;
@@ -673,10 +675,13 @@
     {
       unsigned char *adjusted_endp = endp - MAX_MULTIBYTE_LENGTH;
       while (p < adjusted_endp
+	     && ! CHAR_BYTE8_HEAD_P (*p)
 	     && (n = MULTIBYTE_LENGTH_NO_CHECK (p)) > 0)
 	p += n, chars++;
     }
-  while ((n = MULTIBYTE_LENGTH (p, endp)) > 0)
+  while (p < endp
+	 && ! CHAR_BYTE8_HEAD_P (*p)
+	 && (n = MULTIBYTE_LENGTH (p, endp)) > 0)
     p += n, chars++;
   if (nchars)
     *nchars = chars;
@@ -694,7 +699,8 @@
       unsigned char *adjusted_endp = endp - MAX_MULTIBYTE_LENGTH;
       while (p < adjusted_endp)
 	{
-	  if ((n = MULTIBYTE_LENGTH_NO_CHECK (p)) > 0)
+	  if (! CHAR_BYTE8_HEAD_P (*p)
+	      && (n = MULTIBYTE_LENGTH_NO_CHECK (p)) > 0)
 	    {
 	      while (n--)
 		*to++ = *p++;
@@ -710,7 +716,8 @@
     }
   while (p < endp)
     {
-      if ((n = MULTIBYTE_LENGTH (p, endp)) > 0)
+      if (! CHAR_BYTE8_HEAD_P (*p)
+	  && (n = MULTIBYTE_LENGTH (p, endp)) > 0)
 	{
 	  while (n--)
 	    *to++ = *p++;