more vsnprintf
This commit is contained in:
+6
-22
@@ -145,8 +145,8 @@ VA_DECL(const char *, line)
|
|||||||
vlen = vsnprintf(pbuf, sizeof pbuf, line, VA_ARGS);
|
vlen = vsnprintf(pbuf, sizeof pbuf, line, VA_ARGS);
|
||||||
#if (NH_DEVEL_STATUS != NH_STATUS_RELEASED) && defined(DEBUG)
|
#if (NH_DEVEL_STATUS != NH_STATUS_RELEASED) && defined(DEBUG)
|
||||||
if (vlen >= (int) sizeof pbuf)
|
if (vlen >= (int) sizeof pbuf)
|
||||||
panic("pline", "truncation of buffer at %zu of %d bytes",
|
panic("%s: truncation of buffer at %zu of %d bytes",
|
||||||
sizeof pbuf, vlen);
|
"pline", sizeof pbuf, vlen);
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
Vsprintf(pbuf, line, VA_ARGS);
|
Vsprintf(pbuf, line, VA_ARGS);
|
||||||
@@ -459,20 +459,12 @@ void raw_printf
|
|||||||
VA_DECL(const char *, line)
|
VA_DECL(const char *, line)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#if !defined(NO_VSNPRINTF)
|
|
||||||
int vlen = 0;
|
|
||||||
#endif
|
|
||||||
char pbuf[BIGBUFSZ]; /* will be chopped down to BUFSZ-1 if longer */
|
char pbuf[BIGBUFSZ]; /* will be chopped down to BUFSZ-1 if longer */
|
||||||
/* Do NOT use VA_START and VA_END in here... see above */
|
/* Do NOT use VA_START and VA_END in here... see above */
|
||||||
|
|
||||||
if (index(line, '%')) {
|
if (index(line, '%')) {
|
||||||
#if !defined(NO_VSNPRINTF)
|
#if !defined(NO_VSNPRINTF)
|
||||||
vlen = vsnprintf(pbuf, sizeof pbuf, line, VA_ARGS);
|
(void) vsnprintf(pbuf, sizeof pbuf, line, VA_ARGS);
|
||||||
#if (NH_DEVEL_STATUS != NH_STATUS_RELEASED) && defined(DEBUG)
|
|
||||||
if (vlen >= (int) sizeof pbuf)
|
|
||||||
panic("raw_printf", "truncation of buffer at %zu of %d bytes",
|
|
||||||
sizeof pbuf, vlen);
|
|
||||||
#endif
|
|
||||||
#else
|
#else
|
||||||
Vsprintf(pbuf, line, VA_ARGS);
|
Vsprintf(pbuf, line, VA_ARGS);
|
||||||
#endif
|
#endif
|
||||||
@@ -497,9 +489,6 @@ VA_DECL(const char *, line)
|
|||||||
void impossible
|
void impossible
|
||||||
VA_DECL(const char *, s)
|
VA_DECL(const char *, s)
|
||||||
{
|
{
|
||||||
#if !defined(NO_VSNPRINTF)
|
|
||||||
int vlen = 0;
|
|
||||||
#endif
|
|
||||||
char pbuf[BIGBUFSZ]; /* will be chopped down to BUFSZ-1 if longer */
|
char pbuf[BIGBUFSZ]; /* will be chopped down to BUFSZ-1 if longer */
|
||||||
|
|
||||||
VA_START(s);
|
VA_START(s);
|
||||||
@@ -509,12 +498,7 @@ VA_DECL(const char *, s)
|
|||||||
|
|
||||||
program_state.in_impossible = 1;
|
program_state.in_impossible = 1;
|
||||||
#if !defined(NO_VSNPRINTF)
|
#if !defined(NO_VSNPRINTF)
|
||||||
vlen = vsnprintf(pbuf, sizeof pbuf, s, VA_ARGS);
|
(void) vsnprintf(pbuf, sizeof pbuf, s, VA_ARGS);
|
||||||
#if (NH_DEVEL_STATUS != NH_STATUS_RELEASED) && defined(DEBUG)
|
|
||||||
if (vlen >= (int) sizeof pbuf)
|
|
||||||
panic("impossible", "truncation of buffer at %zu of %d bytes",
|
|
||||||
sizeof pbuf, vlen);
|
|
||||||
#endif
|
|
||||||
#else
|
#else
|
||||||
Vsprintf(pbuf, s, VA_ARGS);
|
Vsprintf(pbuf, s, VA_ARGS);
|
||||||
#endif
|
#endif
|
||||||
@@ -619,8 +603,8 @@ VA_DECL(const char *, str)
|
|||||||
vlen = vsnprintf(buf, sizeof buf, str, VA_ARGS);
|
vlen = vsnprintf(buf, sizeof buf, str, VA_ARGS);
|
||||||
#if (NH_DEVEL_STATUS != NH_STATUS_RELEASED) && defined(DEBUG)
|
#if (NH_DEVEL_STATUS != NH_STATUS_RELEASED) && defined(DEBUG)
|
||||||
if (vlen >= (int) sizeof buf)
|
if (vlen >= (int) sizeof buf)
|
||||||
panic("config_error_add", "truncation of buffer at %zu of %d bytes",
|
panic("%s: truncation of buffer at %zu of %d bytes",
|
||||||
sizeof buf, vlen);
|
"config_error_add", sizeof buf, vlen);
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
Vsprintf(buf, str, VA_ARGS);
|
Vsprintf(buf, str, VA_ARGS);
|
||||||
|
|||||||
+2
-2
@@ -1155,7 +1155,7 @@ VA_DECL(const char *, s)
|
|||||||
if (iflags.window_inited)
|
if (iflags.window_inited)
|
||||||
end_screen();
|
end_screen();
|
||||||
buf[0] = '\n';
|
buf[0] = '\n';
|
||||||
(void) vsprintf(&buf[1], s, VA_ARGS);
|
(void) vsnprintf(&buf[1], sizeof buf - 1, s, VA_ARGS);
|
||||||
msmsg(buf);
|
msmsg(buf);
|
||||||
really_move_cursor();
|
really_move_cursor();
|
||||||
VA_END();
|
VA_END();
|
||||||
@@ -1973,7 +1973,7 @@ VA_DECL(const char *, fmt)
|
|||||||
char buf[ROWNO * COLNO]; /* worst case scenario */
|
char buf[ROWNO * COLNO]; /* worst case scenario */
|
||||||
VA_START(fmt);
|
VA_START(fmt);
|
||||||
VA_INIT(fmt, const char *);
|
VA_INIT(fmt, const char *);
|
||||||
Vsprintf(buf, fmt, VA_ARGS);
|
(void) vsnprintf(buf, sizeof buf, fmt, VA_ARGS);
|
||||||
if (redirect_stdout)
|
if (redirect_stdout)
|
||||||
fprintf(stdout, "%s", buf);
|
fprintf(stdout, "%s", buf);
|
||||||
else {
|
else {
|
||||||
|
|||||||
Reference in New Issue
Block a user