aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa1998-03-04 07:41:41 +0000
committerKenichi Handa1998-03-04 07:41:41 +0000
commite515b0a97ec150d54996700f9d6fffae5d1420f1 (patch)
tree354f2db3478a13b4aa542df69f8eadd06d985285 /src
parent4b5ce591343f51796b5844c770a27c21eaa16307 (diff)
downloademacs-e515b0a97ec150d54996700f9d6fffae5d1420f1.tar.gz
emacs-e515b0a97ec150d54996700f9d6fffae5d1420f1.zip
(strwidth): Make it work for invalid bytes sequence.
(Fstring_width): Give byte length of STR to strwidth.
Diffstat (limited to 'src')
-rw-r--r--src/charset.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/charset.c b/src/charset.c
index 6134f040663..7e9d1eab821 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -997,8 +997,8 @@ strwidth (str, len)
997 else 997 else
998 { 998 {
999 Lisp_Object disp; 999 Lisp_Object disp;
1000 int thiswidth; 1000 int thislen;
1001 int c = STRING_CHAR (str, endp - str); 1001 int c = STRING_CHAR_AND_LENGTH (str, endp - str, thislen);
1002 1002
1003 /* Get the way the display table would display it. */ 1003 /* Get the way the display table would display it. */
1004 if (dp) 1004 if (dp)
@@ -1007,12 +1007,11 @@ strwidth (str, len)
1007 disp = Qnil; 1007 disp = Qnil;
1008 1008
1009 if (VECTORP (disp)) 1009 if (VECTORP (disp))
1010 thiswidth = XVECTOR (disp)->size; 1010 width += XVECTOR (disp)->size;
1011 else 1011 else
1012 thiswidth = ONE_BYTE_CHAR_WIDTH (*str); 1012 width += ONE_BYTE_CHAR_WIDTH (*str);
1013 1013
1014 width += thiswidth; 1014 str += thislen;
1015 str += BYTES_BY_CHAR_HEAD (*str);
1016 } 1015 }
1017 } 1016 }
1018 return width; 1017 return width;
@@ -1030,7 +1029,7 @@ the following bytes is not checked.")
1030 Lisp_Object val; 1029 Lisp_Object val;
1031 1030
1032 CHECK_STRING (str, 0); 1031 CHECK_STRING (str, 0);
1033 XSETFASTINT (val, strwidth (XSTRING (str)->data, XSTRING (str)->size)); 1032 XSETFASTINT (val, strwidth (XSTRING (str)->data, XSTRING (str)->size_byte));
1034 return val; 1033 return val;
1035} 1034}
1036 1035