diff options
| author | Paul Eggert | 2011-05-20 21:33:23 -0700 |
|---|---|---|
| committer | Paul Eggert | 2011-05-20 21:33:23 -0700 |
| commit | de883a701d8f0db9595c6c459fdff9e3bb20bc83 (patch) | |
| tree | aba160bb28d92c3fbec56549e211bd1f705b273e /src/character.c | |
| parent | 1dcf791fefa6533a06f58a5d2d074f59f06ee9ae (diff) | |
| download | emacs-de883a701d8f0db9595c6c459fdff9e3bb20bc83.tar.gz emacs-de883a701d8f0db9595c6c459fdff9e3bb20bc83.zip | |
merge count_size_as_multibyte, parse_str_to_multibyte
* character.c, character.h (count_size_as_multibyte):
Renamed from parse_str_to_multibyte; all uses changed.
Check for integer overflow.
* insdel.c, lisp.h (count_size_as_multibyte): Remove,
since it's now a duplicate of the other. This is more of
a character than a buffer op, so better that it's in character.c.
* fns.c, print.c: Adjust to above changes.
Diffstat (limited to 'src/character.c')
| -rw-r--r-- | src/character.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/character.c b/src/character.c index b9595f97ec7..34e69da9cc5 100644 --- a/src/character.c +++ b/src/character.c | |||
| @@ -672,13 +672,18 @@ str_as_multibyte (unsigned char *str, EMACS_INT len, EMACS_INT nbytes, | |||
| 672 | `str_to_multibyte'. */ | 672 | `str_to_multibyte'. */ |
| 673 | 673 | ||
| 674 | EMACS_INT | 674 | EMACS_INT |
| 675 | parse_str_to_multibyte (const unsigned char *str, EMACS_INT len) | 675 | count_size_as_multibyte (const unsigned char *str, EMACS_INT len) |
| 676 | { | 676 | { |
| 677 | const unsigned char *endp = str + len; | 677 | const unsigned char *endp = str + len; |
| 678 | EMACS_INT bytes; | 678 | EMACS_INT bytes; |
| 679 | 679 | ||
| 680 | for (bytes = 0; str < endp; str++) | 680 | for (bytes = 0; str < endp; str++) |
| 681 | bytes += (*str < 0x80) ? 1 : 2; | 681 | { |
| 682 | int n = *str < 0x80 ? 1 : 2; | ||
| 683 | if (INT_ADD_OVERFLOW (bytes, n)) | ||
| 684 | string_overflow (); | ||
| 685 | bytes += n; | ||
| 686 | } | ||
| 682 | return bytes; | 687 | return bytes; |
| 683 | } | 688 | } |
| 684 | 689 | ||