diff options
| author | Paul Eggert | 2011-05-15 18:11:54 -0700 |
|---|---|---|
| committer | Paul Eggert | 2011-05-15 18:11:54 -0700 |
| commit | cb93f9bef01e95b17b3d7b8786c103505355d98c (patch) | |
| tree | b144c1445fa517c0f076e1fdbbab22ed5bae1c78 /src | |
| parent | d3cdcd1446538e4608b0d2dc31e6c8bd97bd9c5c (diff) | |
| download | emacs-cb93f9bef01e95b17b3d7b8786c103505355d98c.tar.gz emacs-cb93f9bef01e95b17b3d7b8786c103505355d98c.zip | |
* alloc.c (string_overflow): New function.
(Fmake_string): Use it. This doesn't change behavior, but saves
a few bytes and will simplify future changes.
* character.c (string_escape_byte8): Likewise.
* lisp.h (string_overflow): New decl.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 8 | ||||
| -rw-r--r-- | src/alloc.c | 7 | ||||
| -rw-r--r-- | src/character.c | 4 | ||||
| -rw-r--r-- | src/lisp.h | 1 |
4 files changed, 17 insertions, 3 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 89c58eeb5a4..178ebf78932 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,11 @@ | |||
| 1 | 2011-05-16 Paul Eggert <eggert@cs.ucla.edu> | ||
| 2 | |||
| 3 | * alloc.c (string_overflow): New function. | ||
| 4 | (Fmake_string): Use it. This doesn't change behavior, but saves | ||
| 5 | a few bytes and will simplify future changes. | ||
| 6 | * character.c (string_escape_byte8): Likewise. | ||
| 7 | * lisp.h (string_overflow): New decl. | ||
| 8 | |||
| 1 | 2011-05-15 Paul Eggert <eggert@cs.ucla.edu> | 9 | 2011-05-15 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 10 | ||
| 3 | Fixups, following up to the user-interface timestamp change. | 11 | Fixups, following up to the user-interface timestamp change. |
diff --git a/src/alloc.c b/src/alloc.c index 0bce83bfae7..71ab54bcab5 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -2174,6 +2174,11 @@ compact_small_strings (void) | |||
| 2174 | current_sblock = tb; | 2174 | current_sblock = tb; |
| 2175 | } | 2175 | } |
| 2176 | 2176 | ||
| 2177 | void | ||
| 2178 | string_overflow (void) | ||
| 2179 | { | ||
| 2180 | error ("Maximum string size exceeded"); | ||
| 2181 | } | ||
| 2177 | 2182 | ||
| 2178 | DEFUN ("make-string", Fmake_string, Smake_string, 2, 2, 0, | 2183 | DEFUN ("make-string", Fmake_string, Smake_string, 2, 2, 0, |
| 2179 | doc: /* Return a newly created string of length LENGTH, with INIT in each element. | 2184 | doc: /* Return a newly created string of length LENGTH, with INIT in each element. |
| @@ -2206,7 +2211,7 @@ INIT must be an integer that represents a character. */) | |||
| 2206 | EMACS_INT string_len = XINT (length); | 2211 | EMACS_INT string_len = XINT (length); |
| 2207 | 2212 | ||
| 2208 | if (string_len > MOST_POSITIVE_FIXNUM / len) | 2213 | if (string_len > MOST_POSITIVE_FIXNUM / len) |
| 2209 | error ("Maximum string size exceeded"); | 2214 | string_overflow (); |
| 2210 | nbytes = len * string_len; | 2215 | nbytes = len * string_len; |
| 2211 | val = make_uninit_multibyte_string (string_len, nbytes); | 2216 | val = make_uninit_multibyte_string (string_len, nbytes); |
| 2212 | p = SDATA (val); | 2217 | p = SDATA (val); |
diff --git a/src/character.c b/src/character.c index 64ea2625abb..6a8b86d5d87 100644 --- a/src/character.c +++ b/src/character.c | |||
| @@ -823,7 +823,7 @@ string_escape_byte8 (Lisp_Object string) | |||
| 823 | { | 823 | { |
| 824 | if ((MOST_POSITIVE_FIXNUM - nchars) / 3 < byte8_count | 824 | if ((MOST_POSITIVE_FIXNUM - nchars) / 3 < byte8_count |
| 825 | || (MOST_POSITIVE_FIXNUM - nbytes) / 2 < byte8_count) | 825 | || (MOST_POSITIVE_FIXNUM - nbytes) / 2 < byte8_count) |
| 826 | error ("Maximum string size exceeded"); | 826 | string_overflow (); |
| 827 | 827 | ||
| 828 | /* Convert 2-byte sequence of byte8 chars to 4-byte octal. */ | 828 | /* Convert 2-byte sequence of byte8 chars to 4-byte octal. */ |
| 829 | val = make_uninit_multibyte_string (nchars + byte8_count * 3, | 829 | val = make_uninit_multibyte_string (nchars + byte8_count * 3, |
| @@ -832,7 +832,7 @@ string_escape_byte8 (Lisp_Object string) | |||
| 832 | else | 832 | else |
| 833 | { | 833 | { |
| 834 | if ((MOST_POSITIVE_FIXNUM - nchars) / 3 < byte8_count) | 834 | if ((MOST_POSITIVE_FIXNUM - nchars) / 3 < byte8_count) |
| 835 | error ("Maximum string size exceeded"); | 835 | string_overflow (); |
| 836 | /* Convert 1-byte sequence of byte8 chars to 4-byte octal. */ | 836 | /* Convert 1-byte sequence of byte8 chars to 4-byte octal. */ |
| 837 | val = make_uninit_string (nbytes + byte8_count * 3); | 837 | val = make_uninit_string (nbytes + byte8_count * 3); |
| 838 | } | 838 | } |
diff --git a/src/lisp.h b/src/lisp.h index 2342ea2bdbe..b6bf2bdb502 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -2710,6 +2710,7 @@ EXFUN (Fmake_vector, 2); | |||
| 2710 | EXFUN (Fvector, MANY); | 2710 | EXFUN (Fvector, MANY); |
| 2711 | EXFUN (Fmake_symbol, 1); | 2711 | EXFUN (Fmake_symbol, 1); |
| 2712 | EXFUN (Fmake_marker, 0); | 2712 | EXFUN (Fmake_marker, 0); |
| 2713 | extern void string_overflow (void) NO_RETURN; | ||
| 2713 | EXFUN (Fmake_string, 2); | 2714 | EXFUN (Fmake_string, 2); |
| 2714 | extern Lisp_Object build_string (const char *); | 2715 | extern Lisp_Object build_string (const char *); |
| 2715 | extern Lisp_Object make_string (const char *, EMACS_INT); | 2716 | extern Lisp_Object make_string (const char *, EMACS_INT); |