option fixes and missing prototypes

I added -Wmissing-prototypes to my CFLAGS and got a bunch of warnings.
This fixes the core ones (there are more for X11 that I haven't looked
at yet).  While fixing these, I discovered a few option processing
issues:  the non-Amiga 'altmeta' should be settable while the game is
in progress (not sure about the Amiga variation so left that as-is),
'altmeta' and 'menucolor' are booleans so shouldn't have had optfn_XXX
functions; 'MACgraphics' and 'subkeyvalue' were conditionally defined
differently in options.c than in optlist.h.
This commit is contained in:
PatR
2020-04-22 13:39:38 -07:00
parent f9f423b385
commit 0ae84411a0
6 changed files with 22 additions and 96 deletions

View File

@@ -2749,8 +2749,10 @@ E void NDECL(port_help);
#endif
E void FDECL(sethanguphandler, (void (*)(int)));
E boolean NDECL(authorize_wizard_mode);
E void FDECL(append_slash, (char *));
E boolean FDECL(check_user_string, (char *));
E char *NDECL(get_login_name);
E unsigned long NDECL(sys_random_seed);
#endif /* UNIX */
/* ### unixtty.c ### */

View File

@@ -69,7 +69,7 @@ pfx_##a,
al, z, #a, Off, h, 0 },
#endif
/* B:nm, ln, opt_*, setwhere?, on?, negat?, val?, dup?, hndlr? Alias, boolptr */
/* B:nm, ln, opt_*, setwhere?, on?, negat?, val?, dup?, hndlr? Alias, bool_p */
/* C:nm, ln, opt_*, setwhere?, negateok?, valok?, dupok?, hndlr? Alias, desc */
/* P:pfx, ln, opt_*, setwhere?, negateok?, valok?, dupok?, hndlr? Alias, desc*/
@@ -88,7 +88,7 @@ pfx_##a,
&sysflags.altmeta)
#else
#ifdef ALTMETA
NHOPTB(altmeta, 0, opt_out, set_in_config, Off, No, No, No, NoAlias,
NHOPTB(altmeta, 0, opt_out, set_in_game, Off, No, No, No, NoAlias,
&iflags.altmeta)
#else
NHOPTB(altmeta, 0, opt_out, set_in_config, Off, No, No, No, NoAlias,
@@ -248,11 +248,9 @@ pfx_##a,
&flags.lit_corridor)
NHOPTB(lootabc, 0, opt_in, set_in_game, Off, Yes, No, No, NoAlias,
&flags.lootabc)
#ifdef BACKWARD_COMPAT
#ifdef MAC_GRAPHICS_ENV
#if defined(BACKWARD_COMPAT) && defined(MAC_GRAPHICS_ENV)
NHOPTC(Macgraphics, 70, opt_in, set_in_config, No, Yes, No, No, NoAlias,
"load MACGraphics display symbols")
#endif
#endif
NHOPTB(mail, 0, opt_out, set_in_game, On, Yes, No, No, NoAlias,
&flags.biff)

View File

@@ -3236,6 +3236,8 @@ struct permonst _mons2[] = {
#ifndef SPLITMON_1
void NDECL(monst_globals_init); /* in hack.h but we're using config.h */
struct permonst mons[SIZE(mons_init)];
void

View File

@@ -1170,6 +1170,8 @@ OBJECT(OBJ(None, None),
/* clang-format on */
/* *INDENT-ON* */
void NDECL(objects_globals_init); /* in hack.h but we're using config.h */
struct objdescr obj_descr[SIZE(obj_descr_init)];
struct objclass objects[SIZE(obj_init)];

View File

@@ -672,40 +672,6 @@ char *op UNUSED;
return optn_ok;
}
int
optfn_altmeta(optidx, req, negated, opts, op)
int optidx UNUSED;
int req;
boolean negated UNUSED;
char *opts;
char *op UNUSED;
{
if (req == do_init) {
return optn_ok;
}
if (req == do_set) {
/* Amiga altmeta causes Alt+key to be converted into Meta+key by
low level nethack code; on by default, can be toggled off if
Alt+key is needed for some ASCII chars on non-ASCII keyboard */
/* non-Amiga altmeta causes nethack's top level command loop to treat
two character sequence "ESC c" as M-c, for terminals or emulators
which send "ESC c" when Alt+c is pressed; off by default, enabling
this can potentially make trouble if user types ESC when nethack
is honoring this conversion request (primarily after starting a
count prefix prior to a command and then deciding to cancel it) */
return optn_ok;
}
if (req == get_val) {
if (!opts)
return optn_err;
opts[0] = '\0';
return optn_err;
}
return optn_ok;
}
int
optfn_boulder(optidx, req, negated, opts, op)
int optidx UNUSED;
@@ -1467,23 +1433,15 @@ char *op UNUSED;
return optn_ok;
}
#if defined(BACKWARD_COMPAT) && defined(MAC_GRAPHICS_ENV)
int
optfn_MACgraphics(optidx, req, negated, opts, op)
#if defined(MAC_GRAPHICS_ENV) && defined(BACKWARD_COMPAT)
int optidx;
int req;
boolean negated;
char *opts;
char *op;
#else
int optidx UNUSED;
int req;
boolean negated UNUSED;
char *opts UNUSED;
char *op UNUSED;
#endif
{
#if defined(MAC_GRAPHICS_ENV) && defined(BACKWARD_COMPAT)
boolean badflag = FALSE;
if (req == do_init) {
@@ -1518,20 +1476,9 @@ char *op UNUSED;
opts[0] = '\0';
return optn_ok;
}
#else
if (req == do_set) {
config_error_add("'%s' %s; use 'symset:%s' instead",
allopt[optidx].name,
#ifdef MAC_GRAPHICS_ENV /* implies BACKWARD_COMPAT is not defined */
"no longer supported",
#else
"is not supported",
#endif
allopt[optidx].name);
}
#endif
return optn_ok;
}
#endif /* BACKWARD_COMPAT && MAC_GRAPHICS_ENV */
int
optfn_map_mode(optidx, req, negated, opts, op)
@@ -1951,36 +1898,6 @@ char *op UNUSED;
return optn_ok;
}
int
optfn_menucolor(optidx, req, negated, opts, op)
int optidx;
int req;
boolean negated UNUSED;
char *opts;
char *op;
{
if (req == do_init) {
return optn_ok;
}
if (req == do_set) {
/* menucolor:"regex_string"=color */
if ((op = string_for_env_opt(allopt[optidx].name, opts, FALSE))
!= empty_optstr) {
if (!add_menu_coloring(op))
return optn_err;
} else
return optn_err;
return optn_ok;
}
if (req == get_val) {
if (!opts)
return optn_err;
opts[0] = '\0';
return optn_ok;
}
return optn_ok;
}
int
optfn_menuinvertmode(optidx, req, negated, opts, op)
int optidx;
@@ -3468,6 +3385,7 @@ char *op;
return optn_ok;
}
#ifdef WIN32
int
optfn_subkeyvalue(optidx, req, negated, opts, op)
int optidx UNUSED;
@@ -3480,12 +3398,10 @@ char *op UNUSED;
return optn_ok;
}
if (req == do_set) {
#if defined(WIN32)
if (op == empty_optstr)
return optn_err;
#ifdef TTY_GRAPHICS
map_subkeyvalue(op);
#endif
#endif
return optn_ok;
}
@@ -3497,6 +3413,7 @@ char *op UNUSED;
}
return optn_ok;
}
#endif /* WIN32 */
int
optfn_suppress_alert(optidx, req, negated, opts, op)

View File

@@ -23,6 +23,7 @@ typedef void FDECL((*select_iter_func), (int, int, genericptr));
extern void FDECL(mkmap, (lev_init *));
static boolean FDECL(match_maptyps, (XCHAR_P, XCHAR_P));
static void NDECL(solidify_map);
static void FDECL(lvlfill_maze_grid, (int, int, int, int, SCHAR_P));
static void FDECL(lvlfill_solid, (SCHAR_P, SCHAR_P));
@@ -91,9 +92,11 @@ static void NDECL(spo_end_moninvent);
static void NDECL(spo_pop_container);
static int FDECL(l_create_stairway, (lua_State *, BOOLEAN_P));
static void FDECL(spo_endroom, (struct sp_coder *));
static void FDECL(l_table_getset_feature_flag, (lua_State *, int, int, const char *, int));
static void FDECL(l_table_getset_feature_flag, (lua_State *, int, int,
const char *, int));
static void FDECL(sel_set_lit, (int, int, genericptr_t));
static void FDECL(selection_iterate, (struct selectionvar *, select_iter_func, genericptr_t));
static void FDECL(selection_iterate, (struct selectionvar *, select_iter_func,
genericptr_t));
static void FDECL(sel_set_ter, (int, int, genericptr_t));
static void FDECL(sel_set_door, (int, int, genericptr_t));
static void FDECL(sel_set_feature, (int, int, genericptr_t));
@@ -105,6 +108,8 @@ static int FDECL(get_table_region, (lua_State *, const char *,
static void FDECL(set_wallprop_in_selection, (lua_State *, int));
static int FDECL(floodfillchk_match_under, (int, int));
static int FDECL(floodfillchk_match_accessible, (int, int));
static boolean FDECL(sel_flood_havepoint, (int, int, xchar *, xchar *, int));
static long FDECL(line_dist_coord, (long, long, long, long, long, long));
static void FDECL(l_push_wid_hei_table, (lua_State *, int, int));
static int FDECL(get_table_align, (lua_State *));
static int FDECL(get_table_monclass, (lua_State *));
@@ -195,7 +200,7 @@ static struct monst *invent_carrying_monster = (struct monst *) 0;
/* Does typ match with levl[][].typ, considering special types
MATCH_WALL and MAX_TYPE (aka transparency)? */
boolean
static boolean
match_maptyps(typ, levltyp)
xchar typ, levltyp;
{
@@ -4684,7 +4689,7 @@ int xc, yc, a, b, filled;
}
/* distance from line segment (x1,y1, x2,y2) to point (x3,y3) */
long
static long
line_dist_coord(x1, y1, x2, y2, x3, y3)
long x1, y1, x2, y2, x3, y3;
{