USE_OLDARGS update (1 of 2)

Files modified:
    include/tradstdc.h, sp_lev.h, system.h
    util/lev_main.c

Silence a bunch of warnings generated by recent gcc which weren't there
with whatever version I had when 3.6.0 was being readied for release.
For lev_main, there were two basic types:  not enough arguments in calls
to lc_pline, lc_warning, and lc_error (since we weren't passing dummy
arguments as is done for add_opvars), and conversion from 'int' or
narrower to 'char *' (from -Wint-to-pointer-cast, which either wasn't
there yet in the older gcc, or wasn't included in -Wall back then).
[Note that for any configuration decrepit enough to actually need
USE_OLDARGS, such conversions will either work fine or else nethack
simply won't be viable.]

src/pline.c generates a bunch of warnings (for USE_OLDARGS).  The fix
for that will be (2 of 2).

To test, instead of mucking about with CFLAGS or sys/unix/hints, I've
been temporarily adding unconditional
|#undef USE_STDARG
|#undef USE_VARARGS
|#define USE_OLDARGS
to the end of config1.h and then doing my normal build--which is why
-Wall (or possibly -W) is drawing -Wint-to-pointer-cast warnings.
This commit is contained in:
PatR
2017-08-02 18:23:42 -07:00
parent b4e4d70008
commit 64f284dd61
4 changed files with 100 additions and 80 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 lev_main.c $NHDT-Date: 1501461281 2017/07/31 00:34:41 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.46 $ */
/* NetHack 3.6 lev_main.c $NHDT-Date: 1501723418 2017/08/03 01:23:38 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.47 $ */
/* Copyright (c) 1989 by Jean-Christophe Collet */
/* NetHack may be freely redistributed. See license for details. */
@@ -281,7 +281,7 @@ char **argv;
}
fin = freopen(fname, "r", stdin);
if (!fin) {
lc_pline("Can't open \"%s\" for input.\n", fname);
lc_pline("Can't open \"%s\" for input.\n", VA_PASS1(fname));
perror(fname);
errors_encountered = TRUE;
} else {
@@ -644,56 +644,56 @@ VA_DECL2(sp_lev *, sp, const char *, fmt)
case 'i': /* integer */
{
struct opvar *ov = New(struct opvar);
set_opvar_int(ov, VA_NEXT(la, long) );
set_opvar_int(ov, VA_NEXT(la, long));
add_opcode(sp, SPO_PUSH, ov);
break;
}
case 'c': /* coordinate */
{
struct opvar *ov = New(struct opvar);
set_opvar_coord(ov, VA_NEXT(la, long) );
set_opvar_coord(ov, VA_NEXT(la, long));
add_opcode(sp, SPO_PUSH, ov);
break;
}
case 'r': /* region */
{
struct opvar *ov = New(struct opvar);
set_opvar_region(ov, VA_NEXT(la, long) );
set_opvar_region(ov, VA_NEXT(la, long));
add_opcode(sp, SPO_PUSH, ov);
break;
}
case 'm': /* mapchar */
{
struct opvar *ov = New(struct opvar);
set_opvar_mapchar(ov, VA_NEXT(la, long) );
set_opvar_mapchar(ov, VA_NEXT(la, long));
add_opcode(sp, SPO_PUSH, ov);
break;
}
case 'M': /* monster */
{
struct opvar *ov = New(struct opvar);
set_opvar_monst(ov, VA_NEXT(la, long) );
set_opvar_monst(ov, VA_NEXT(la, long));
add_opcode(sp, SPO_PUSH, ov);
break;
}
case 'O': /* object */
{
struct opvar *ov = New(struct opvar);
set_opvar_obj(ov, VA_NEXT(la, long) );
set_opvar_obj(ov, VA_NEXT(la, long));
add_opcode(sp, SPO_PUSH, ov);
break;
}
case 's': /* string */
{
struct opvar *ov = New(struct opvar);
set_opvar_str(ov, VA_NEXT(lp, const char *) );
set_opvar_str(ov, VA_NEXT(lp, const char *));
add_opcode(sp, SPO_PUSH, ov);
break;
}
case 'v': /* variable */
{
struct opvar *ov = New(struct opvar);
set_opvar_var(ov, VA_NEXT(lp, const char *) );
set_opvar_var(ov, VA_NEXT(lp, const char *));
add_opcode(sp, SPO_PUSH, ov);
break;
}
@@ -701,12 +701,13 @@ VA_DECL2(sp_lev *, sp, const char *, fmt)
{
long i = VA_NEXT(la, int);
if (i < 0 || i >= MAX_SP_OPCODES)
lc_pline("add_opvars: unknown opcode '%ld'.", i);
lc_pline("add_opvars: unknown opcode '%ld'.", VA_PASS1(i));
add_opcode(sp, i, NULL);
break;
}
default:
lc_pline("add_opvars: illegal format character '%c'.", *p);
lc_pline("add_opvars: illegal format character '%ld'.",
VA_PASS1((long) *p));
break;
}
}
@@ -774,7 +775,8 @@ char *name;
struct lc_funcdefs *f = New(struct lc_funcdefs);
if (!f) {
lc_error("Could not alloc function definition for '%s'.", name);
lc_error("Could not alloc function definition for '%s'.",
VA_PASS1(name));
return NULL;
}
f->next = NULL;
@@ -855,7 +857,8 @@ char *name;
struct lc_vardefs *f = New(struct lc_vardefs);
if (!f) {
lc_error("Could not alloc variable definition for '%s'.", name);
lc_error("Could not alloc variable definition for '%s'.",
VA_PASS1(name));
return NULL;
}
f->next = NULL;
@@ -874,7 +877,7 @@ struct lc_vardefs *fchain;
while (tmp) {
if (be_verbose && (tmp->n_used == 0))
lc_warning("Unused variable '%s'", tmp->name);
lc_warning("Unused variable '%s'", VA_PASS1(tmp->name));
nxt = tmp->next;
Free(tmp->name);
Free(tmp);
@@ -913,7 +916,7 @@ long spovar;
spovar &= ~SPOVAR_ARRAY;
switch (spovar) {
default:
lc_error("spovar2str(%ld)", spovar);
lc_error("spovar2str(%ld)", VA_PASS1(spovar));
break;
case SPOVAR_INT:
n = "integer";
@@ -969,9 +972,11 @@ long vartype;
if ((tmp = vardef_defined(vd, varname, 1)) != 0) {
if (tmp->var_type != vartype)
lc_error("Trying to use variable '%s' as %s, when it is %s.",
varname, spovar2str(vartype), spovar2str(tmp->var_type));
VA_PASS3(varname,
spovar2str(vartype),
spovar2str(tmp->var_type)));
} else
lc_error("Variable '%s' not defined.", varname);
lc_error("Variable '%s' not defined.", VA_PASS1(varname));
}
struct lc_vardefs *
@@ -985,7 +990,9 @@ long vartype;
if ((tmp = vardef_defined(vd, varname, 1)) != 0) {
if (tmp->var_type != vartype)
lc_error("Trying to redefine variable '%s' as %s, when it is %s.",
varname, spovar2str(vartype), spovar2str(tmp->var_type));
VA_PASS3(varname,
spovar2str(vartype),
spovar2str(tmp->var_type)));
} else {
tmp = vardef_new(vartype, varname);
tmp->next = vd;
@@ -1012,7 +1019,8 @@ int opcode;
case SPO_JGE:
return SPO_JL;
default:
lc_error("Cannot reverse comparison jmp opcode %d.", opcode);
lc_error("Cannot reverse comparison jmp opcode %ld.",
VA_PASS1((long) opcode));
return SPO_NULL;
}
}
@@ -1054,7 +1062,8 @@ struct opvar *ov;
tmpov->vardata.str[len] = '\0';
} break;
default: {
lc_error("Unknown opvar_clone value type (%d)!", ov->spovartyp);
lc_error("Unknown opvar_clone value type (%ld)!",
VA_PASS1((long) ov->spovartyp));
} /* default */
} /* switch */
return tmpov;
@@ -1083,9 +1092,10 @@ char *ldfname;
struct lc_funcdefs *f;
if (index(ldfname, '.'))
lc_error("Invalid dot ('.') in level name '%s'.", ldfname);
lc_error("Invalid dot ('.') in level name '%s'.", VA_PASS1(ldfname));
if ((int) strlen(ldfname) > 14)
lc_error("Level names limited to 14 characters ('%s').", ldfname);
lc_error("Level names limited to 14 characters ('%s').",
VA_PASS1(ldfname));
f = function_definitions;
while (f) {
f->n_called = 0;
@@ -1173,8 +1183,8 @@ char c;
if (!class || class == mons[i].mlet)
if (!case_insensitive_comp(s, mons[i].mname)) {
if (be_verbose)
lc_warning("Monster type \"%s\" matches \"%s\".", s,
mons[i].mname);
lc_warning("Monster type \"%s\" matches \"%s\".",
VA_PASS2(s, mons[i].mname));
return i;
}
return ERR;
@@ -1209,7 +1219,8 @@ char c; /* class */
objname = obj_descr[i].oc_name;
if (objname && !case_insensitive_comp(s, objname)) {
if (be_verbose)
lc_warning("Object type \"%s\" matches \"%s\".", s, objname);
lc_warning("Object type \"%s\" matches \"%s\".",
VA_PASS2(s, objname));
return i;
}
}
@@ -1318,14 +1329,14 @@ genericptr_t dat;
_opcode *tmp;
if ((opc < 0) || (opc >= MAX_SP_OPCODES))
lc_error("Unknown opcode '%d'", opc);
lc_error("Unknown opcode '%ld'", VA_PASS1((long) opc));
tmp = (_opcode *) alloc(sizeof(_opcode) * (nop + 1));
if (!tmp) { /* lint suppression */
/*NOTREACHED*/
#if 0
/* not possible; alloc() never returns Null */
lc_error("Could not alloc opcode space");
lc_error("%s", VA_PASS1("Could not alloc opcode space"));
#endif
return;
}
@@ -1396,9 +1407,9 @@ sp_lev *sp;
for (i = 0; i < len; i++)
if ((tmpmap[max_hig][i] = what_map_char(map[i]))
== INVALID_TYPE) {
lc_warning("Invalid character '%c' @ (%d, %d) - replacing "
"with stone",
map[i], max_hig, i);
lc_warning(
"Invalid character '%ld' @ (%ld, %ld) - replacing with stone",
VA_PASS3((long) map[i], (long) max_hig, (long) i));
tmpmap[max_hig][i] = STONE;
}
while (i < max_len)
@@ -1413,8 +1424,9 @@ sp_lev *sp;
max_y_map = max_hig - 1;
if (max_len > MAP_X_LIM || max_hig > MAP_Y_LIM) {
lc_error("Map too large at (%d x %d), max is (%d x %d)", max_len,
max_hig, MAP_X_LIM, MAP_Y_LIM);
lc_error("Map too large at (%ld x %ld), max is (%ld x %ld)",
VA_PASS4((long) max_len, (long) max_hig,
(long) MAP_X_LIM, (long) MAP_Y_LIM));
}
mbuf = (char *) alloc(((max_hig - 1) * max_len) + (max_len - 1) + 2);
@@ -1424,7 +1436,8 @@ sp_lev *sp;
mbuf[((max_hig - 1) * max_len) + (max_len - 1) + 1] = '\0';
add_opvars(sp, "siio", VA_PASS4(mbuf, max_hig, max_len, SPO_MAP));
add_opvars(sp, "siio", VA_PASS4(mbuf, (long) max_hig, (long) max_len,
SPO_MAP));
for (dy = 0; dy < max_hig; dy++)
Free(tmpmap[dy]);