diff options
| author | Eli Zaretskii | 2011-04-23 13:33:28 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2011-04-23 13:33:28 +0300 |
| commit | e6c3da2065ac72cc4e1a2bef22d367cd75401892 (patch) | |
| tree | 1f6fcbee1e12f63096d2221a89f5436b831862a9 /src/xdisp.c | |
| parent | 4ffd0d6b569d252e4e807d4e9c9d6a5bd5b08640 (diff) | |
| download | emacs-e6c3da2065ac72cc4e1a2bef22d367cd75401892.tar.gz emacs-e6c3da2065ac72cc4e1a2bef22d367cd75401892.zip | |
Fix doprnt so it could be used safely in `verror'. (Bug#8435)
src/doprnt.c: Include limits.h.
(SIZE_MAX): New macro.
(doprnt): Return a size_t value. 2nd arg is now size_t. Many
local variables are now size_t instead of int or unsigned.
Improve overflow protection. Support `l' modifier for integer
conversions. Support %l conversion. Don't assume an EMACS_INT
argument for integer conversions and for %c.
src/lisp.h (doprnt): Restore prototype.
src/makefile.w32-in ($(BLD)/callint.$(O)): Depend on
$(SRC)/character.h.
src/Makefile.in (base_obj): Add back doprnt.o.
src/deps.mk (doprnt.o): Add back prerequisites.
(callint.o): Depend on character.h.
src/eval.c (internal_lisp_condition_case): Include the handler
representation in the error message.
(verror): Call doprnt instead of vsnprintf. Fix an off-by-one bug
when breaking from the loop.
src/xdisp.c (vmessage): Call doprnt instead of vsnprintf.
src/callint.c (Fcall_interactively): When displaying error message
about invalid control letter, pass the character's codepoint, not
a pointer to its multibyte form. Improve display of the character
in octal and display also its hex code.
src/character.c (char_string): Use %x to display the (unsigned)
codepoint of an invalid character, to avoid displaying a bogus
negative value.
src/font.c (check_otf_features): Pass SDATA of SYMBOL_NAME to
`error', not SYMBOL_NAME itself.
src/coding.c (Fencode_sjis_char, Fencode_big5_char): Use %c for
character arguments to `error'.
src/charset.c (check_iso_charset_parameter): Fix incorrect argument
to `error' in error message about FINAL_CHAR argument. Make sure
FINAL_CHAR is a character, and use %c when it is passed as
argument to `error'.
Diffstat (limited to 'src/xdisp.c')
| -rw-r--r-- | src/xdisp.c | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/src/xdisp.c b/src/xdisp.c index 19fef35fce8..91d1b6ea2e3 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -8373,22 +8373,10 @@ vmessage (const char *m, va_list ap) | |||
| 8373 | { | 8373 | { |
| 8374 | if (m) | 8374 | if (m) |
| 8375 | { | 8375 | { |
| 8376 | char *buf = FRAME_MESSAGE_BUF (f); | 8376 | size_t len; |
| 8377 | size_t bufsize = FRAME_MESSAGE_BUF_SIZE (f); | ||
| 8378 | int len; | ||
| 8379 | 8377 | ||
| 8380 | memset (buf, 0, bufsize); | 8378 | len = doprnt (FRAME_MESSAGE_BUF (f), |
| 8381 | len = vsnprintf (buf, bufsize, m, ap); | 8379 | FRAME_MESSAGE_BUF_SIZE (f), m, (char *)0, ap); |
| 8382 | |||
| 8383 | /* Do any truncation at a character boundary. */ | ||
| 8384 | if (! (0 <= len && len < bufsize)) | ||
| 8385 | { | ||
| 8386 | char *end = memchr (buf, 0, bufsize); | ||
| 8387 | for (len = end ? end - buf : bufsize; | ||
| 8388 | len && ! CHAR_HEAD_P (buf[len - 1]); | ||
| 8389 | len--) | ||
| 8390 | continue; | ||
| 8391 | } | ||
| 8392 | 8380 | ||
| 8393 | message2 (FRAME_MESSAGE_BUF (f), len, 0); | 8381 | message2 (FRAME_MESSAGE_BUF (f), len, 0); |
| 8394 | } | 8382 | } |