From cb93f9bef01e95b17b3d7b8786c103505355d98c Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 15 May 2011 18:11:54 -0700 Subject: [PATCH] * 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. --- src/ChangeLog | 8 ++++++++ src/alloc.c | 7 ++++++- src/character.c | 4 ++-- 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 @@ +2011-05-16 Paul Eggert + + * 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. + 2011-05-15 Paul Eggert 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) current_sblock = tb; } +void +string_overflow (void) +{ + error ("Maximum string size exceeded"); +} DEFUN ("make-string", Fmake_string, Smake_string, 2, 2, 0, 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. */) EMACS_INT string_len = XINT (length); if (string_len > MOST_POSITIVE_FIXNUM / len) - error ("Maximum string size exceeded"); + string_overflow (); nbytes = len * string_len; val = make_uninit_multibyte_string (string_len, nbytes); 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) { if ((MOST_POSITIVE_FIXNUM - nchars) / 3 < byte8_count || (MOST_POSITIVE_FIXNUM - nbytes) / 2 < byte8_count) - error ("Maximum string size exceeded"); + string_overflow (); /* Convert 2-byte sequence of byte8 chars to 4-byte octal. */ val = make_uninit_multibyte_string (nchars + byte8_count * 3, @@ -832,7 +832,7 @@ string_escape_byte8 (Lisp_Object string) else { if ((MOST_POSITIVE_FIXNUM - nchars) / 3 < byte8_count) - error ("Maximum string size exceeded"); + string_overflow (); /* Convert 1-byte sequence of byte8 chars to 4-byte octal. */ val = make_uninit_string (nbytes + byte8_count * 3); } 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); EXFUN (Fvector, MANY); EXFUN (Fmake_symbol, 1); EXFUN (Fmake_marker, 0); +extern void string_overflow (void) NO_RETURN; EXFUN (Fmake_string, 2); extern Lisp_Object build_string (const char *); extern Lisp_Object make_string (const char *, EMACS_INT); -- 2.39.2