changeset 67841:53d14610ec35

(lisp_string_width): Check multibyteness of STRING.
author Kenichi Handa <handa@m17n.org>
date Tue, 27 Dec 2005 05:47:21 +0000
parents 77e654cbed22
children 095b05723996
files src/charset.c
diffstat 1 files changed, 13 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/charset.c	Tue Dec 27 04:31:21 2005 +0000
+++ b/src/charset.c	Tue Dec 27 05:47:21 2005 +0000
@@ -1344,6 +1344,10 @@
 {
   int len = SCHARS (string);
   int len_byte = SBYTES (string);
+  /* This set multibyte to 0 even if STRING is multibyte when it
+     contains only ascii and eight-bit-graphic, but that's
+     intentional.  */
+  int multibyte = len < len_byte;
   const unsigned char *str = SDATA (string);
   int i = 0, i_byte = 0;
   int width = 0;
@@ -1366,8 +1370,12 @@
 	}
       else if (dp)
 	{
-	  int c = STRING_CHAR_AND_LENGTH (str + i_byte, len - i_byte, bytes);
+	  int c;
 
+	  if (multibyte)
+	    c = STRING_CHAR_AND_LENGTH (str + i_byte, len - i_byte, bytes);
+	  else
+	    c = str[i_byte], bytes = 1;
 	  chars = 1;
 	  val = DISP_CHAR_VECTOR (dp, c);
 	  if (VECTORP (val))
@@ -1378,7 +1386,10 @@
       else
 	{
 	  chars = 1;
-	  PARSE_MULTIBYTE_SEQ (str + i_byte, len_byte - i_byte, bytes);
+	  if (multibyte)
+	    PARSE_MULTIBYTE_SEQ (str + i_byte, len_byte - i_byte, bytes);
+	  else
+	    bytes = 1;
 	  thiswidth = ONE_BYTE_CHAR_WIDTH (str[i_byte]);
 	}