aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenichi Handa2005-12-27 05:47:21 +0000
committerKenichi Handa2005-12-27 05:47:21 +0000
commit212cc638bdc8e0560ea6945b306f150ad9f562e7 (patch)
tree872ab6f30748749fa15c0eab16cbd371f5ddf46d
parentc0b457636e9a18775121223d04bbea36cf14454d (diff)
downloademacs-212cc638bdc8e0560ea6945b306f150ad9f562e7.tar.gz
emacs-212cc638bdc8e0560ea6945b306f150ad9f562e7.zip
(lisp_string_width): Check multibyteness of STRING.
-rw-r--r--src/charset.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/charset.c b/src/charset.c
index 2c985b14dbc..fb9804c0306 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -1344,6 +1344,10 @@ lisp_string_width (string, precision, nchars, nbytes)
1344{ 1344{
1345 int len = SCHARS (string); 1345 int len = SCHARS (string);
1346 int len_byte = SBYTES (string); 1346 int len_byte = SBYTES (string);
1347 /* This set multibyte to 0 even if STRING is multibyte when it
1348 contains only ascii and eight-bit-graphic, but that's
1349 intentional. */
1350 int multibyte = len < len_byte;
1347 const unsigned char *str = SDATA (string); 1351 const unsigned char *str = SDATA (string);
1348 int i = 0, i_byte = 0; 1352 int i = 0, i_byte = 0;
1349 int width = 0; 1353 int width = 0;
@@ -1366,8 +1370,12 @@ lisp_string_width (string, precision, nchars, nbytes)
1366 } 1370 }
1367 else if (dp) 1371 else if (dp)
1368 { 1372 {
1369 int c = STRING_CHAR_AND_LENGTH (str + i_byte, len - i_byte, bytes); 1373 int c;
1370 1374
1375 if (multibyte)
1376 c = STRING_CHAR_AND_LENGTH (str + i_byte, len - i_byte, bytes);
1377 else
1378 c = str[i_byte], bytes = 1;
1371 chars = 1; 1379 chars = 1;
1372 val = DISP_CHAR_VECTOR (dp, c); 1380 val = DISP_CHAR_VECTOR (dp, c);
1373 if (VECTORP (val)) 1381 if (VECTORP (val))
@@ -1378,7 +1386,10 @@ lisp_string_width (string, precision, nchars, nbytes)
1378 else 1386 else
1379 { 1387 {
1380 chars = 1; 1388 chars = 1;
1381 PARSE_MULTIBYTE_SEQ (str + i_byte, len_byte - i_byte, bytes); 1389 if (multibyte)
1390 PARSE_MULTIBYTE_SEQ (str + i_byte, len_byte - i_byte, bytes);
1391 else
1392 bytes = 1;
1382 thiswidth = ONE_BYTE_CHAR_WIDTH (str[i_byte]); 1393 thiswidth = ONE_BYTE_CHAR_WIDTH (str[i_byte]);
1383 } 1394 }
1384 1395