From be193d27b5c2370badd9eb99a51af0a62e3862c9 Mon Sep 17 00:00:00 2001 From: "nethack.rankin" Date: Tue, 27 Sep 2005 04:35:57 +0000 Subject: [PATCH] more graphics option parsing The recent fix for OPTIONS=noDECgraphics,IBMgraphics would have been subject to lint complaints for some configurations. Declare the extra variable with the same conditional tests which control its use; somewhat messier, but lint free. My previous fix only solves this problem for the initial config file parsing. If you enable IBMgraphics (by any method), then interactively use the 'O' command to try to enable DECgrahpics and to _simultaneously_ disable IBMgraphics instead of letting it be overridden, you will end up with IBMgraphics on and DECgraphics off. That's because the menu entries are processed in order, and after it has acted upon the request to set DECgraphics on, the IBMgraphics flag will have been switched off; then when it acts upon the request to toggle IBMgraphics, that flag will end up being switched back on (switching DECgraphics back off in the process). This erroneous behavior was the same prior to last week's patch; I just hadn't noticed yet. It looks like we really do need to change {ASCII,DEC,IBM,MAC}graphics into a single compound option. --- src/options.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/options.c b/src/options.c index 059e37bd9..862c50d04 100644 --- a/src/options.c +++ b/src/options.c @@ -2309,9 +2309,16 @@ goodfruit: * options list */ for (i = 0; boolopt[i].name; i++) { - boolean was_set; - if (match_optname(opts, boolopt[i].name, 3, FALSE)) { +#if defined(TERMLIB) || defined(ASCIIGRAPH) || defined(MAC_GRAPHICS_ENV) + /* need to remember previous XXXgraphics setting + in order to prevent explicit "noXXXgraphics" from + overriding a preceding "YYYgraphics" request; + noXXXgraphics will reset to ordinary ASCII only + if/when XXXgraphics is currently in effect */ + boolean old_gfx = boolopt[i].addr && *boolopt[i].addr; +#endif + /* options that don't exist */ if (!boolopt[i].addr) { if (!initial && !negated) @@ -2325,7 +2332,6 @@ goodfruit: return; } - was_set = *(boolopt[i].addr); *(boolopt[i].addr) = !negated; /* 0 means boolean opts */ @@ -2351,21 +2357,21 @@ goodfruit: need_redraw = TRUE; # ifdef TERMLIB if ((boolopt[i].addr) == &iflags.DECgraphics) { - if (iflags.DECgraphics != was_set) + if (iflags.DECgraphics != old_gfx) switch_graphics(iflags.DECgraphics ? DEC_GRAPHICS : ASCII_GRAPHICS); } # endif # ifdef ASCIIGRAPH if ((boolopt[i].addr) == &iflags.IBMgraphics) { - if (iflags.IBMgraphics != was_set) + if (iflags.IBMgraphics != old_gfx) switch_graphics(!negated ? IBM_GRAPHICS : ASCII_GRAPHICS); } # endif # ifdef MAC_GRAPHICS_ENV if ((boolopt[i].addr) == &iflags.MACgraphics) { - if (iflags.MACgraphics != was_set) + if (iflags.MACgraphics != old_gfx) switch_graphics(iflags.MACgraphics ? MAC_GRAPHICS : ASCII_GRAPHICS); } -- 2.40.0