Minor improvements to make_formatted_string.

* alloc.c (make_formatted_string): Prefer int to ptrdiff_t
where int is good enough, as vsprintf returns an int.
* lisp.h (make_formatted_string): Add ATTRIBUTE_FORMAT_PRINTF.
This commit is contained in:
Paul Eggert 2012-07-09 09:06:19 -07:00
parent 52331d2c41
commit 26bccfaebf
3 changed files with 10 additions and 2 deletions

View file

@ -1,3 +1,10 @@
2012-07-09 Paul Eggert <eggert@cs.ucla.edu>
Minor improvements to make_formatted_string.
* alloc.c (make_formatted_string): Prefer int to ptrdiff_t
where int is good enough, as vsprintf returns an int.
* lisp.h (make_formatted_string): Add ATTRIBUTE_FORMAT_PRINTF.
2012-07-09 Dmitry Antipov <dmantipov@yandex.ru>
Use make_formatted_string to avoid double length calculation.

View file

@ -2524,7 +2524,7 @@ Lisp_Object
make_formatted_string (char *buf, const char *format, ...)
{
va_list ap;
ptrdiff_t length;
int length;
va_start (ap, format);
length = vsprintf (buf, format, ap);

View file

@ -2611,7 +2611,8 @@ extern Lisp_Object list5 (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object,
extern Lisp_Object allocate_misc (void);
extern _Noreturn void string_overflow (void);
extern Lisp_Object make_string (const char *, ptrdiff_t);
extern Lisp_Object make_formatted_string (char *, const char *, ...);
extern Lisp_Object make_formatted_string (char *, const char *, ...)
ATTRIBUTE_FORMAT_PRINTF (2, 3);
extern Lisp_Object make_unibyte_string (const char *, ptrdiff_t);
extern Lisp_Object make_multibyte_string (const char *, ptrdiff_t, ptrdiff_t);
extern Lisp_Object make_event_array (int, Lisp_Object *);