[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 5cf7b1ada9 1/2: ; * src/lread.c (invalid_radix_integer): Use a lo
From: |
Mattias Engdegård |
Subject: |
master 5cf7b1ada9 1/2: ; * src/lread.c (invalid_radix_integer): Use a local buffer. |
Date: |
Tue, 30 Aug 2022 10:51:20 -0400 (EDT) |
branch: master
commit 5cf7b1ada96c2e209580d086d15b1bbe5b345657
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>
; * src/lread.c (invalid_radix_integer): Use a local buffer.
---
src/lread.c | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
diff --git a/src/lread.c b/src/lread.c
index bb37606481..d64a4fad3a 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -2905,20 +2905,18 @@ digit_to_number (int character, int base)
return digit < base ? digit : -1;
}
-/* Size of the fixed-size buffer used during reading.
- It should be at least big enough for `invalid_radix_integer' but
- can usefully be much bigger than that. */
-enum { stackbufsize = 1024 };
-
static void
-invalid_radix_integer (EMACS_INT radix, char stackbuf[VLA_ELEMS
(stackbufsize)],
- Lisp_Object readcharfun)
+invalid_radix_integer (EMACS_INT radix, Lisp_Object readcharfun)
{
- int n = snprintf (stackbuf, stackbufsize, "integer, radix %"pI"d", radix);
- eassert (n < stackbufsize);
- invalid_syntax (stackbuf, readcharfun);
+ char buf[64];
+ int n = snprintf (buf, sizeof buf, "integer, radix %"pI"d", radix);
+ eassert (n < sizeof buf);
+ invalid_syntax (buf, readcharfun);
}
+/* Size of the fixed-size buffer used during reading. */
+enum { stackbufsize = 1024 };
+
/* Read an integer in radix RADIX using READCHARFUN to read
characters. RADIX must be in the interval [2..36]. Use STACKBUF
for temporary storage as needed. Value is the integer read.
@@ -2976,7 +2974,7 @@ read_integer (Lisp_Object readcharfun, int radix,
UNREAD (c);
if (valid != 1)
- invalid_radix_integer (radix, stackbuf, readcharfun);
+ invalid_radix_integer (radix, readcharfun);
*p = '\0';
return unbind_to (count, string_to_number (read_buffer, radix, NULL));
@@ -3989,7 +3987,7 @@ read0 (Lisp_Object readcharfun, bool locate_syms)
{
/* #NrDIGITS -- radix-N number */
if (n < 0 || n > 36)
- invalid_radix_integer (n, stackbuf, readcharfun);
+ invalid_radix_integer (n, readcharfun);
obj = read_integer (readcharfun, n, stackbuf);
break;
}