diff options
| author | Joakim Verona | 2012-02-05 14:40:28 +0100 |
|---|---|---|
| committer | Joakim Verona | 2012-02-05 14:40:28 +0100 |
| commit | 8c5c7f5afa968d06efb6788cf680d5463c389d85 (patch) | |
| tree | a70876b87a7dbdcb936524880492f8fdc661fab0 /src/character.c | |
| parent | fbdce5fed745bc78911980466d9374d1101487fc (diff) | |
| parent | 1ff980ae49715eb372acff8a193e36497a7665c4 (diff) | |
| download | emacs-8c5c7f5afa968d06efb6788cf680d5463c389d85.tar.gz emacs-8c5c7f5afa968d06efb6788cf680d5463c389d85.zip | |
ustream
Diffstat (limited to 'src/character.c')
| -rw-r--r-- | src/character.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/src/character.c b/src/character.c index 593fbcece0b..82bc2bfef4e 100644 --- a/src/character.c +++ b/src/character.c | |||
| @@ -311,10 +311,10 @@ If the multibyte character does not represent a byte, return -1. */) | |||
| 311 | 311 | ||
| 312 | /* Return width (columns) of C considering the buffer display table DP. */ | 312 | /* Return width (columns) of C considering the buffer display table DP. */ |
| 313 | 313 | ||
| 314 | static int | 314 | static EMACS_INT |
| 315 | char_width (int c, struct Lisp_Char_Table *dp) | 315 | char_width (int c, struct Lisp_Char_Table *dp) |
| 316 | { | 316 | { |
| 317 | int width = CHAR_WIDTH (c); | 317 | EMACS_INT width = CHAR_WIDTH (c); |
| 318 | 318 | ||
| 319 | if (dp) | 319 | if (dp) |
| 320 | { | 320 | { |
| @@ -326,7 +326,12 @@ char_width (int c, struct Lisp_Char_Table *dp) | |||
| 326 | { | 326 | { |
| 327 | ch = AREF (disp, i); | 327 | ch = AREF (disp, i); |
| 328 | if (CHARACTERP (ch)) | 328 | if (CHARACTERP (ch)) |
| 329 | width += CHAR_WIDTH (XFASTINT (ch)); | 329 | { |
| 330 | int w = CHAR_WIDTH (XFASTINT (ch)); | ||
| 331 | if (INT_ADD_OVERFLOW (width, w)) | ||
| 332 | string_overflow (); | ||
| 333 | width += w; | ||
| 334 | } | ||
| 330 | } | 335 | } |
| 331 | } | 336 | } |
| 332 | return width; | 337 | return width; |
| @@ -340,7 +345,8 @@ Tab is taken to occupy `tab-width' columns. | |||
| 340 | usage: (char-width CHAR) */) | 345 | usage: (char-width CHAR) */) |
| 341 | (Lisp_Object ch) | 346 | (Lisp_Object ch) |
| 342 | { | 347 | { |
| 343 | int c, width; | 348 | int c; |
| 349 | EMACS_INT width; | ||
| 344 | 350 | ||
| 345 | CHECK_CHARACTER (ch); | 351 | CHECK_CHARACTER (ch); |
| 346 | c = XINT (ch); | 352 | c = XINT (ch); |
| @@ -367,10 +373,14 @@ c_string_width (const unsigned char *str, EMACS_INT len, int precision, | |||
| 367 | { | 373 | { |
| 368 | int bytes; | 374 | int bytes; |
| 369 | int c = STRING_CHAR_AND_LENGTH (str + i_byte, bytes); | 375 | int c = STRING_CHAR_AND_LENGTH (str + i_byte, bytes); |
| 370 | int thiswidth = char_width (c, dp); | 376 | EMACS_INT thiswidth = char_width (c, dp); |
| 371 | 377 | ||
| 372 | if (precision > 0 | 378 | if (precision <= 0) |
| 373 | && (width + thiswidth > precision)) | 379 | { |
| 380 | if (INT_ADD_OVERFLOW (width, thiswidth)) | ||
| 381 | string_overflow (); | ||
| 382 | } | ||
| 383 | else if (precision - width < thiswidth) | ||
| 374 | { | 384 | { |
| 375 | *nchars = i; | 385 | *nchars = i; |
| 376 | *nbytes = i_byte; | 386 | *nbytes = i_byte; |