Remove NO_VSNPRINTF

Affects only ancient VMS where vsnprintf wasn't available.
This commit is contained in:
Pasi Kallinen
2023-01-06 15:53:03 +02:00
parent 18fa85c681
commit 030fc0036a
8 changed files with 2 additions and 46 deletions

View File

@@ -2214,4 +2214,5 @@ replace some old 'time_t' hackery in system.h and hacklib.c with something
less obtrusive in unixconf.h
remove the per dungeon level door limit
remove various '#if LINT' hacks used to suppress warnings from pre-ANSI 'lint'
VMS: removed NO_VSNPRINTF conditional code

View File

@@ -168,11 +168,6 @@ PANICTRACE_GDB=2 #at conclusion of panic, show a call traceback and then
#define FCMASK 0660 /* file creation mask */
/*
*
*/
#define NO_VSNPRINTF /* Avoid vsnprintf, use less-safe vsprintf instead. */
/*
* The remainder of the file should not need to be changed.
*/

View File

@@ -656,11 +656,7 @@ panic VA_DECL(const char *, str)
{
char buf[BUFSZ];
#if !defined(NO_VSNPRINTF)
(void) vsnprintf(buf, sizeof buf, str, VA_ARGS);
#else
Vsprintf(buf, str, VA_ARGS);
#endif
raw_print(buf);
paniclog("panic", buf);
}

View File

@@ -1337,11 +1337,7 @@ nh_snprintf(
int n;
va_start(ap, fmt);
#ifdef NO_VSNPRINTF
n = vsprintf(str, fmt, ap);
#else
n = vsnprintf(str, size, fmt, ap);
#endif
va_end(ap);
if (n < 0 || (size_t) n >= size) { /* is there a problem? */
impossible("snprintf %s: func %s, file line %d",

View File

@@ -283,11 +283,7 @@ nh_snprintf(const char *func UNUSED, int line UNUSED, char *str, size_t size,
int n;
va_start(ap, fmt);
#ifdef NO_VSNPRINTF
n = vsprintf(str, fmt, ap);
#else
n = vsnprintf(str, size, fmt, ap);
#endif
va_end(ap);
if (n < 0 || (size_t)n >= size) { /* is there a problem? */

View File

@@ -99,9 +99,7 @@ vpline(const char *line, va_list the_args)
char pbuf[BIGBUFSZ]; /* will get chopped down to BUFSZ-1 if longer */
int ln;
int msgtyp;
#if !defined(NO_VSNPRINTF)
int vlen = 0;
#endif
boolean no_repeat;
if (!line || !*line)
@@ -114,7 +112,6 @@ vpline(const char *line, va_list the_args)
return;
if (strchr(line, '%')) {
#if !defined(NO_VSNPRINTF)
vlen = vsnprintf(pbuf, sizeof(pbuf), line, the_args);
#if (NH_DEVEL_STATUS != NH_STATUS_RELEASED) && defined(DEBUG)
if (vlen >= (int) sizeof pbuf)
@@ -122,9 +119,6 @@ vpline(const char *line, va_list the_args)
"pline", sizeof pbuf, vlen);
#else
nhUse(vlen);
#endif
#else
Vsprintf(pbuf, line, the_args);
#endif
line = pbuf;
}
@@ -476,11 +470,7 @@ vraw_printf(const char *line, va_list the_args)
char pbuf[BIGBUFSZ]; /* will be chopped down to BUFSZ-1 if longer */
if (strchr(line, '%')) {
#if !defined(NO_VSNPRINTF)
(void) vsnprintf(pbuf, sizeof(pbuf), line, the_args);
#else
Vsprintf(pbuf, line, the_args);
#endif
line = pbuf;
}
if ((int) strlen(line) > BUFSZ - 1) {
@@ -508,11 +498,7 @@ impossible(const char *s, ...)
panic("impossible called impossible");
gp.program_state.in_impossible = 1;
#if !defined(NO_VSNPRINTF)
(void) vsnprintf(pbuf, sizeof(pbuf), s, the_args);
#else
Vsprintf(pbuf, s, the_args);
#endif
va_end(the_args);
pbuf[BUFSZ - 1] = '\0'; /* sanity */
paniclog("impossible", pbuf);
@@ -609,12 +595,9 @@ config_error_add(const char *str, ...)
static void
vconfig_error_add(const char *str, va_list the_args)
{ /* start of vconf...() or of nested block in USE_OLDARG's conf...() */
#if !defined(NO_VSNPRINTF)
int vlen = 0;
#endif
char buf[BIGBUFSZ]; /* will be chopped down to BUFSZ-1 if longer */
#if !defined(NO_VSNPRINTF)
vlen = vsnprintf(buf, sizeof buf, str, the_args);
#if (NH_DEVEL_STATUS != NH_STATUS_RELEASED) && defined(DEBUG)
if (vlen >= (int) sizeof buf)
@@ -622,9 +605,6 @@ vconfig_error_add(const char *str, va_list the_args)
"config_error_add", sizeof buf, vlen);
#else
nhUse(vlen);
#endif
#else
Vsprintf(buf, str, the_args);
#endif
buf[BUFSZ - 1] = '\0';
config_erradd(buf);

View File

@@ -151,11 +151,7 @@ Notes:
work with 3.7.0. The scoreboard file (RECORD) from 3.6.x or 3.4.x or
3.3.x will work.
2. If pline.c fails to compile, edit vmsconf.h and uncomment
#define NO_VSNPRINTF
to avoid calling a C library routine that wasn't available on older
versions of VMS. (Note: in the distributed sources, this has already
been uncommented.)
2. Ancient C libs will not work; vsnprintf is required.
3. To specify user-preference options in your environment, define the
logical name NETHACKOPTIONS to have the value of a quoted string

View File

@@ -1561,11 +1561,7 @@ nh_snprintf(
int n;
va_start(ap, fmt);
#ifdef NO_VSNPRINTF
n = vsprintf(str, fmt, ap);
#else
n = vsnprintf(str, size, fmt, ap);
#endif
va_end(ap);
if (n < 0 || (size_t) n >= size) { /* is there a problem? */