forked from Imagelibrary/binutils-gdb
* defs.h (xsnprintf): New prototype.
* utils.c (xsnprintf): New function.
This commit is contained in:
@@ -1,5 +1,8 @@
|
|||||||
2005-03-17 Mark Kettenis <kettenis@gnu.org>
|
2005-03-17 Mark Kettenis <kettenis@gnu.org>
|
||||||
|
|
||||||
|
* defs.h (xsnprintf): New prototype.
|
||||||
|
* utils.c (xsnprintf): New function.
|
||||||
|
|
||||||
* corelow.c (get_core_register_section): Replace usage of sprintf
|
* corelow.c (get_core_register_section): Replace usage of sprintf
|
||||||
and strcpy with xstrprintf and xstrdup.
|
and strcpy with xstrprintf and xstrdup.
|
||||||
|
|
||||||
|
|||||||
@@ -879,6 +879,10 @@ extern void xvasprintf (char **ret, const char *format, va_list ap);
|
|||||||
extern char *xstrprintf (const char *format, ...) ATTR_FORMAT (printf, 1, 2);
|
extern char *xstrprintf (const char *format, ...) ATTR_FORMAT (printf, 1, 2);
|
||||||
extern char *xstrvprintf (const char *format, va_list ap);
|
extern char *xstrvprintf (const char *format, va_list ap);
|
||||||
|
|
||||||
|
/* Like snprintf, but throw an error if the output buffer is too small. */
|
||||||
|
extern int xsnprintf (char *str, size_t size, const char *format, ...)
|
||||||
|
ATTR_FORMAT (printf, 3, 4);
|
||||||
|
|
||||||
extern int parse_escape (char **);
|
extern int parse_escape (char **);
|
||||||
|
|
||||||
/* Message to be printed before the error message, when an error occurs. */
|
/* Message to be printed before the error message, when an error occurs. */
|
||||||
|
|||||||
14
gdb/utils.c
14
gdb/utils.c
@@ -1079,6 +1079,20 @@ xstrvprintf (const char *format, va_list ap)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
xsnprintf (char *str, size_t size, const char *format, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
va_start (args, format);
|
||||||
|
ret = vsnprintf (str, size, format, args);
|
||||||
|
gdb_assert (ret < size);
|
||||||
|
va_end (args);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/* My replacement for the read system call.
|
/* My replacement for the read system call.
|
||||||
Used like `read' but keeps going if `read' returns too soon. */
|
Used like `read' but keeps going if `read' returns too soon. */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user