Remove NO_VSNPRINTF

Affects only ancient VMS where vsnprintf wasn't available.
This commit is contained in:
Pasi Kallinen
2023-01-06 15:53:06 +02:00
parent 18fa85c681
commit 030fc0036a
8 changed files with 2 additions and 46 deletions
+1
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 less obtrusive in unixconf.h
remove the per dungeon level door limit remove the per dungeon level door limit
remove various '#if LINT' hacks used to suppress warnings from pre-ANSI 'lint' remove various '#if LINT' hacks used to suppress warnings from pre-ANSI 'lint'
VMS: removed NO_VSNPRINTF conditional code
-5
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 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. * The remainder of the file should not need to be changed.
*/ */
-4
View File
@@ -656,11 +656,7 @@ panic VA_DECL(const char *, str)
{ {
char buf[BUFSZ]; char buf[BUFSZ];
#if !defined(NO_VSNPRINTF)
(void) vsnprintf(buf, sizeof buf, str, VA_ARGS); (void) vsnprintf(buf, sizeof buf, str, VA_ARGS);
#else
Vsprintf(buf, str, VA_ARGS);
#endif
raw_print(buf); raw_print(buf);
paniclog("panic", buf); paniclog("panic", buf);
} }
-4
View File
@@ -1337,11 +1337,7 @@ nh_snprintf(
int n; int n;
va_start(ap, fmt); va_start(ap, fmt);
#ifdef NO_VSNPRINTF
n = vsprintf(str, fmt, ap);
#else
n = vsnprintf(str, size, fmt, ap); n = vsnprintf(str, size, fmt, ap);
#endif
va_end(ap); va_end(ap);
if (n < 0 || (size_t) n >= size) { /* is there a problem? */ if (n < 0 || (size_t) n >= size) { /* is there a problem? */
impossible("snprintf %s: func %s, file line %d", impossible("snprintf %s: func %s, file line %d",
-4
View File
@@ -283,11 +283,7 @@ nh_snprintf(const char *func UNUSED, int line UNUSED, char *str, size_t size,
int n; int n;
va_start(ap, fmt); va_start(ap, fmt);
#ifdef NO_VSNPRINTF
n = vsprintf(str, fmt, ap);
#else
n = vsnprintf(str, size, fmt, ap); n = vsnprintf(str, size, fmt, ap);
#endif
va_end(ap); va_end(ap);
if (n < 0 || (size_t)n >= size) { /* is there a problem? */ if (n < 0 || (size_t)n >= size) { /* is there a problem? */
-20
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 */ char pbuf[BIGBUFSZ]; /* will get chopped down to BUFSZ-1 if longer */
int ln; int ln;
int msgtyp; int msgtyp;
#if !defined(NO_VSNPRINTF)
int vlen = 0; int vlen = 0;
#endif
boolean no_repeat; boolean no_repeat;
if (!line || !*line) if (!line || !*line)
@@ -114,7 +112,6 @@ vpline(const char *line, va_list the_args)
return; return;
if (strchr(line, '%')) { if (strchr(line, '%')) {
#if !defined(NO_VSNPRINTF)
vlen = vsnprintf(pbuf, sizeof(pbuf), line, the_args); vlen = vsnprintf(pbuf, sizeof(pbuf), line, the_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)
@@ -122,9 +119,6 @@ vpline(const char *line, va_list the_args)
"pline", sizeof pbuf, vlen); "pline", sizeof pbuf, vlen);
#else #else
nhUse(vlen); nhUse(vlen);
#endif
#else
Vsprintf(pbuf, line, the_args);
#endif #endif
line = pbuf; 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 */ char pbuf[BIGBUFSZ]; /* will be chopped down to BUFSZ-1 if longer */
if (strchr(line, '%')) { if (strchr(line, '%')) {
#if !defined(NO_VSNPRINTF)
(void) vsnprintf(pbuf, sizeof(pbuf), line, the_args); (void) vsnprintf(pbuf, sizeof(pbuf), line, the_args);
#else
Vsprintf(pbuf, line, the_args);
#endif
line = pbuf; line = pbuf;
} }
if ((int) strlen(line) > BUFSZ - 1) { if ((int) strlen(line) > BUFSZ - 1) {
@@ -508,11 +498,7 @@ impossible(const char *s, ...)
panic("impossible called impossible"); panic("impossible called impossible");
gp.program_state.in_impossible = 1; gp.program_state.in_impossible = 1;
#if !defined(NO_VSNPRINTF)
(void) vsnprintf(pbuf, sizeof(pbuf), s, the_args); (void) vsnprintf(pbuf, sizeof(pbuf), s, the_args);
#else
Vsprintf(pbuf, s, the_args);
#endif
va_end(the_args); va_end(the_args);
pbuf[BUFSZ - 1] = '\0'; /* sanity */ pbuf[BUFSZ - 1] = '\0'; /* sanity */
paniclog("impossible", pbuf); paniclog("impossible", pbuf);
@@ -609,12 +595,9 @@ config_error_add(const char *str, ...)
static void static void
vconfig_error_add(const char *str, va_list the_args) vconfig_error_add(const char *str, va_list the_args)
{ /* start of vconf...() or of nested block in USE_OLDARG's conf...() */ { /* start of vconf...() or of nested block in USE_OLDARG's conf...() */
#if !defined(NO_VSNPRINTF)
int vlen = 0; int vlen = 0;
#endif
char buf[BIGBUFSZ]; /* will be chopped down to BUFSZ-1 if longer */ char buf[BIGBUFSZ]; /* will be chopped down to BUFSZ-1 if longer */
#if !defined(NO_VSNPRINTF)
vlen = vsnprintf(buf, sizeof buf, str, the_args); vlen = vsnprintf(buf, sizeof buf, str, the_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)
@@ -622,9 +605,6 @@ vconfig_error_add(const char *str, va_list the_args)
"config_error_add", sizeof buf, vlen); "config_error_add", sizeof buf, vlen);
#else #else
nhUse(vlen); nhUse(vlen);
#endif
#else
Vsprintf(buf, str, the_args);
#endif #endif
buf[BUFSZ - 1] = '\0'; buf[BUFSZ - 1] = '\0';
config_erradd(buf); config_erradd(buf);
+1 -5
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 work with 3.7.0. The scoreboard file (RECORD) from 3.6.x or 3.4.x or
3.3.x will work. 3.3.x will work.
2. If pline.c fails to compile, edit vmsconf.h and uncomment 2. Ancient C libs will not work; vsnprintf is required.
#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.)
3. To specify user-preference options in your environment, define the 3. To specify user-preference options in your environment, define the
logical name NETHACKOPTIONS to have the value of a quoted string logical name NETHACKOPTIONS to have the value of a quoted string
-4
View File
@@ -1561,11 +1561,7 @@ nh_snprintf(
int n; int n;
va_start(ap, fmt); va_start(ap, fmt);
#ifdef NO_VSNPRINTF
n = vsprintf(str, fmt, ap);
#else
n = vsnprintf(str, size, fmt, ap); n = vsnprintf(str, size, fmt, ap);
#endif
va_end(ap); va_end(ap);
if (n < 0 || (size_t) n >= size) { /* is there a problem? */ if (n < 0 || (size_t) n >= size) { /* is there a problem? */