Skip to content

Commit

Permalink
more graphics option parsing
Browse files Browse the repository at this point in the history
     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.
  • Loading branch information
nethack.rankin committed Sep 27, 2005
1 parent fa7fd20 commit be193d2
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -2309,9 +2309,16 @@ boolean tinitial, tfrom_file;
* 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)
Expand All @@ -2325,7 +2332,6 @@ boolean tinitial, tfrom_file;
return;
}

was_set = *(boolopt[i].addr);
*(boolopt[i].addr) = !negated;

/* 0 means boolean opts */
Expand All @@ -2351,21 +2357,21 @@ boolean tinitial, tfrom_file;
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);
}
Expand Down

0 comments on commit be193d2

Please sign in to comment.