have string_for_opt() return the value string or empty_optstr to
provide some level of crash protection if some future added option
processing misbehaves. Callers of string_for_opt() and
string_for_env_opt() should always check for a match to empty_optstr.
This commit is contained in:
nhmall
2020-01-13 14:54:48 -05:00
parent bb715bc824
commit 5b0f3ae7bf
2 changed files with 21153 additions and 86 deletions

21045
src/nhdat364 Normal file

File diff suppressed because one or more lines are too long

View File

@@ -42,6 +42,8 @@ enum window_option_types {
#define PILE_LIMIT_DFLT 5
static char empty_optstr[] = {0};
/*
* NOTE: If you add (or delete) an option, please update the short
* options help (option_help()), the long options help (dat/opthelp),
@@ -1067,7 +1069,7 @@ boolean val_optional;
if (!colon || !*++colon) {
if (!val_optional)
config_error_add("Missing parameter for '%s'", opts);
return (char *) 0;
return empty_optstr;
}
return colon;
}
@@ -1080,7 +1082,7 @@ boolean val_optional;
{
if (!initial) {
rejectoption(optname);
return (char *) 0;
return empty_optstr;
}
return string_for_opt(opts, val_optional);
}
@@ -1159,7 +1161,7 @@ const char *optype;
uchar translate[WARNCOUNT];
int length, i;
if (!(opts = string_for_env_opt(optype, opts, FALSE)))
if ((opts = string_for_env_opt(optype, opts, FALSE)) == empty_optstr)
return FALSE;
escapes(opts, opts);
@@ -1953,7 +1955,8 @@ char **opp;
if (negated) {
bad_negation(fullname, FALSE);
} else if ((op = string_for_env_opt(fullname, opts, FALSE)) != 0) {
} else if ((op = string_for_env_opt(fullname, opts, FALSE))
!= empty_optstr) {
boolean val_negated = FALSE;
while ((*op == '!') || !strncmpi(op, "no", 2)) {
@@ -2150,7 +2153,8 @@ boolean tinitial, tfrom_file;
if (match_optname(opts, fullname, 3, TRUE)) {
if (duplicate)
complain_about_duplicate(opts, 1);
if ((op = string_for_env_opt(fullname, opts, negated)) != 0) {
if ((op = string_for_env_opt(fullname, opts, negated))
!= empty_optstr) {
if (negated) {
bad_negation(fullname, TRUE);
return FALSE;
@@ -2192,7 +2196,8 @@ boolean tinitial, tfrom_file;
if (negated) {
bad_negation(fullname, FALSE);
return FALSE;
} else if ((op = string_for_env_opt(fullname, opts, FALSE)) != 0) {
} else if ((op = string_for_env_opt(fullname, opts, FALSE))
!= empty_optstr) {
nmcpy(catname, op, PL_PSIZ);
} else
return FALSE;
@@ -2207,7 +2212,8 @@ boolean tinitial, tfrom_file;
if (negated) {
bad_negation(fullname, FALSE);
return FALSE;
} else if ((op = string_for_env_opt(fullname, opts, FALSE)) != 0) {
} else if ((op = string_for_env_opt(fullname, opts, FALSE))
!= empty_optstr) {
nmcpy(dogname, op, PL_PSIZ);
} else
return FALSE;
@@ -2222,7 +2228,8 @@ boolean tinitial, tfrom_file;
if (negated) {
bad_negation(fullname, FALSE);
return FALSE;
} else if ((op = string_for_env_opt(fullname, opts, FALSE)) != 0) {
} else if ((op = string_for_env_opt(fullname, opts, FALSE))
!= empty_optstr) {
nmcpy(horsename, op, PL_PSIZ);
} else
return FALSE;
@@ -2237,7 +2244,7 @@ boolean tinitial, tfrom_file;
if (duplicate)
complain_about_duplicate(opts, 1);
op = string_for_opt(opts, (compat || !initial));
if (!op) {
if (op == empty_optstr) {
if (compat || negated || initial) {
/* for backwards compatibility, "mouse_support" without a
value is a synonym for mouse_support:1 */
@@ -2266,7 +2273,7 @@ boolean tinitial, tfrom_file;
if (duplicate)
complain_about_duplicate(opts, 1);
op = string_for_opt(opts, (compat || !initial));
if (!op) {
if (op == empty_optstr) {
if (compat || negated || initial) {
/* for backwards compatibility, "number_pad" without a
value is a synonym for number_pad:1 */
@@ -2309,7 +2316,7 @@ boolean tinitial, tfrom_file;
if (negated) {
bad_negation(fullname, FALSE);
return FALSE;
} else if ((op = string_for_opt(opts, FALSE)) != 0) {
} else if ((op = string_for_opt(opts, FALSE)) != empty_optstr) {
symset[ROGUESET].name = dupstr(op);
if (!read_sym_file(ROGUESET)) {
clear_symsetentry(ROGUESET, TRUE);
@@ -2334,7 +2341,7 @@ boolean tinitial, tfrom_file;
if (negated) {
bad_negation(fullname, FALSE);
return FALSE;
} else if ((op = string_for_opt(opts, FALSE)) != 0) {
} else if ((op = string_for_opt(opts, FALSE)) != empty_optstr) {
symset[PRIMARY].name = dupstr(op);
if (!read_sym_file(PRIMARY)) {
clear_symsetentry(PRIMARY, TRUE);
@@ -2357,7 +2364,7 @@ boolean tinitial, tfrom_file;
complain_about_duplicate(opts, 1);
if (negated) {
flags.runmode = RUN_TPORT;
} else if ((op = string_for_opt(opts, FALSE)) != 0) {
} else if ((op = string_for_opt(opts, FALSE)) != empty_optstr) {
if (!strncmpi(op, "teleport", strlen(op)))
flags.runmode = RUN_TPORT;
else if (!strncmpi(op, "run", strlen(op)))
@@ -2381,7 +2388,8 @@ boolean tinitial, tfrom_file;
if (negated) {
bad_negation(fullname, FALSE);
return FALSE;
} else if ((op = string_for_env_opt(fullname, opts, FALSE)) != 0) {
} else if ((op = string_for_env_opt(fullname, opts, FALSE))
!= empty_optstr) {
if (!add_menu_coloring(op))
return FALSE;
} else
@@ -2394,7 +2402,8 @@ boolean tinitial, tfrom_file;
if (duplicate)
complain_about_duplicate(opts, 1);
op = string_for_env_opt(fullname, opts, negated);
if ((negated && !op) || (!negated && op)) {
if ((negated && op == empty_optstr)
|| (!negated && op != empty_optstr)) {
iflags.msg_history = negated ? 0 : atoi(op);
} else if (negated) {
bad_negation(fullname, TRUE);
@@ -2412,7 +2421,7 @@ boolean tinitial, tfrom_file;
if (duplicate)
complain_about_duplicate(opts, 1);
if (!(op = string_for_opt(opts, TRUE))) {
if ((op = string_for_opt(opts, TRUE)) == empty_optstr) {
tmp = negated ? 's' : 'f';
} else {
if (negated) {
@@ -2481,7 +2490,7 @@ boolean tinitial, tfrom_file;
if (duplicate)
complain_about_duplicate(opts, 1);
if (opttype > 0 && !negated
&& (op = string_for_opt(opts, FALSE)) != 0) {
&& (op = string_for_opt(opts, FALSE)) != empty_optstr) {
switch (opttype) {
case MAP_OPTION:
iflags.wc_fontsiz_map = atoi(op);
@@ -2505,7 +2514,7 @@ boolean tinitial, tfrom_file;
config_error_add("Unknown %s parameter '%s'", fullname, opts);
return FALSE;
}
if (opttype > 0 && (op = string_for_opt(opts, FALSE)) != 0) {
if (opttype > 0 && (op = string_for_opt(opts, FALSE)) != empty_optstr) {
wc_set_font_name(opttype, op);
#ifdef MAC
set_font_name(opttype, op);
@@ -2550,12 +2559,12 @@ boolean tinitial, tfrom_file;
}
#ifdef WIN32
op = string_for_opt(opts, TRUE);
if (!alternative_palette(op)) {
if (op == empty_optstr || !alternative_palette(op)) {
config_error_add("Error in palette parameter '%s'", op);
return FALSE;
}
#else
if ((op = string_for_opt(opts, FALSE)) != (char *) 0) {
if ((op = string_for_opt(opts, FALSE)) != empty_optstr) {
char *pt = op;
int cnt, tmp, reverse;
long rgb;
@@ -2611,14 +2620,14 @@ boolean tinitial, tfrom_file;
complain_about_duplicate(opts, 1);
op = string_for_opt(opts, negated || !initial);
if (negated) {
if (op) {
if (op != empty_optstr) {
bad_negation("fruit", TRUE);
return FALSE;
}
op = &empty_str;
op = empty_optstr;
goto goodfruit;
}
if (!op)
if (op == empty_optstr)
return FALSE;
/* stripped leading and trailing spaces, condensed internal ones in 3.6.2 */
mungspaces(op);
@@ -2669,7 +2678,8 @@ boolean tinitial, tfrom_file;
if (negated) {
iflags.getpos_coords = GPCOORDS_NONE;
return retval;
} else if ((op = string_for_env_opt(fullname, opts, FALSE)) != 0) {
} else if ((op = string_for_env_opt(fullname, opts, FALSE))
!= empty_optstr) {
static char gpcoords[] = { GPCOORDS_NONE, GPCOORDS_COMPASS,
GPCOORDS_COMFULL, GPCOORDS_MAP,
GPCOORDS_SCREEN, '\0' };
@@ -2693,7 +2703,8 @@ boolean tinitial, tfrom_file;
if (negated) {
iflags.getloc_filter = GFILTER_NONE;
return retval;
} else if ((op = string_for_env_opt(fullname, opts, FALSE)) != 0) {
} else if ((op = string_for_env_opt(fullname, opts, FALSE))
!= empty_optstr) {
char c = lowc(*op);
switch (c) {
@@ -2739,9 +2750,10 @@ boolean tinitial, tfrom_file;
bad_negation(fullname, FALSE);
return FALSE;
}
/* if (!(opts = string_for_env_opt(fullname, opts, FALSE)))
/* if ((opts = string_for_env_opt(fullname, opts, FALSE))
== empty_optstr)
*/
if (!(opts = string_for_opt(opts, FALSE)))
if ((opts = string_for_opt(opts, FALSE)) == empty_optstr)
return FALSE;
escapes(opts, opts);
/* note: dummy monclass #0 has symbol value '\0'; we allow that--
@@ -2790,7 +2802,8 @@ boolean tinitial, tfrom_file;
if (negated) {
bad_negation(fullname, FALSE);
return FALSE;
} else if ((op = string_for_env_opt(fullname, opts, FALSE)) != 0) {
} else if ((op = string_for_env_opt(fullname, opts, FALSE))
!= empty_optstr) {
nmcpy(plname, op, PL_NSIZ);
} else
return FALSE;
@@ -2805,7 +2818,7 @@ boolean tinitial, tfrom_file;
if (negated) {
bad_negation(fullname, FALSE);
return FALSE;
} else if ((op = string_for_opt(opts, negated)) != 0) {
} else if ((op = string_for_opt(opts, negated)) != empty_optstr) {
#if defined(WIN32) && defined(TTY_GRAPHICS)
set_altkeyhandler(op);
#endif
@@ -2819,7 +2832,7 @@ boolean tinitial, tfrom_file;
fullname = "align_status";
if (match_optname(opts, fullname, sizeof "align_status" - 1, TRUE)) {
op = string_for_opt(opts, negated);
if (op && !negated) {
if ((op != empty_optstr) && !negated) {
if (!strncmpi(op, "left", sizeof "left" - 1))
iflags.wc_align_status = ALIGN_LEFT;
else if (!strncmpi(op, "top", sizeof "top" - 1))
@@ -2846,7 +2859,7 @@ boolean tinitial, tfrom_file;
if (duplicate)
complain_about_duplicate(opts, 1);
op = string_for_opt(opts, negated);
if (op && !negated) {
if ((op != empty_optstr) && !negated) {
if (!strncmpi(op, "left", sizeof "left" - 1))
iflags.wc_align_message = ALIGN_LEFT;
else if (!strncmpi(op, "top", sizeof "top" - 1))
@@ -2874,7 +2887,7 @@ boolean tinitial, tfrom_file;
if (negated) {
bad_negation(fullname, FALSE);
return FALSE;
} else if (!(op = string_for_opt(opts, FALSE)))
} else if ((op = string_for_opt(opts, FALSE)) == empty_optstr)
return FALSE;
if (!change_inv_order(op))
@@ -2893,7 +2906,7 @@ boolean tinitial, tfrom_file;
flags.paranoia_bits = 0; /* clear all */
if (negated) {
flags.paranoia_bits = 0; /* [now redundant...] */
} else if ((op = string_for_opt(opts, TRUE)) != 0) {
} else if ((op = string_for_opt(opts, TRUE)) != empty_optstr) {
char *pp, buf[BUFSZ];
strncpy(buf, op, sizeof buf - 1);
@@ -2959,7 +2972,8 @@ boolean tinitial, tfrom_file;
if (negated) {
bad_negation(fullname, FALSE);
return FALSE;
} else if ((op = string_for_env_opt(fullname, opts, FALSE)) != 0) {
} else if ((op = string_for_env_opt(fullname, opts, FALSE))
!= empty_optstr) {
switch (lowc(*op)) {
case 'u': /* Unencumbered */
flags.pickup_burden = UNENCUMBERED;
@@ -3002,7 +3016,7 @@ boolean tinitial, tfrom_file;
oc_to_str(flags.pickup_types, tbuf);
flags.pickup_types[0] = '\0'; /* all */
op = string_for_opt(opts, (compat || !initial));
if (!op) {
if (op == empty_optstr) {
if (compat || negated || initial) {
/* for backwards compatibility, "pickup" without a
value is a synonym for autopickup of all types
@@ -3074,12 +3088,12 @@ boolean tinitial, tfrom_file;
if (duplicate)
complain_about_duplicate(opts, 1);
op = string_for_opt(opts, negated);
if ((negated && !op) || (!negated && op))
if ((negated && op == empty_optstr) || (!negated && op != empty_optstr))
flags.pile_limit = negated ? 0 : atoi(op);
else if (negated) {
bad_negation(fullname, TRUE);
return FALSE;
} else /* !op */
} else /* op == empty_optstr */
flags.pile_limit = PILE_LIMIT_DFLT;
/* sanity check */
if (flags.pile_limit < 0)
@@ -3097,7 +3111,7 @@ boolean tinitial, tfrom_file;
if (duplicate || negated)
return FALSE;
op = string_for_opt(opts, FALSE);
if (!op)
if (op == empty_optstr)
return FALSE;
if (!strncmpi(op, "normal", 6) || !strcmpi(op, "play")) {
wizard = discover = FALSE;
@@ -3120,7 +3134,7 @@ boolean tinitial, tfrom_file;
if (duplicate)
complain_about_duplicate(opts, 1);
op = string_for_opt(opts, negated);
if (op && !negated) {
if (op != empty_optstr && !negated) {
if (!strncmpi(op, "dialog", sizeof "dialog" - 1)) {
iflags.wc_player_selection = VIA_DIALOG;
} else if (!strncmpi(op, "prompt", sizeof "prompt" - 1)) {
@@ -3167,14 +3181,14 @@ boolean tinitial, tfrom_file;
if (duplicate)
complain_about_duplicate(opts, 1);
op = string_for_opt(opts, TRUE);
if (op && negated) {
if (op != empty_optstr && negated) {
bad_negation(fullname, TRUE);
return FALSE;
}
/* "disclose" without a value means "all with prompting"
and negated means "none without prompting" */
if (!op || !strcmpi(op, "all") || !strcmpi(op, "none")) {
if (op && !strcmpi(op, "none"))
if (op == empty_optstr || !strcmpi(op, "all") || !strcmpi(op, "none")) {
if (op != empty_optstr && !strcmpi(op, "none"))
negated = TRUE;
for (num = 0; num < NUM_DISCLOSURE_OPTIONS; num++)
flags.end_disclose[num] = negated
@@ -3239,7 +3253,7 @@ boolean tinitial, tfrom_file;
bad_negation(fullname, FALSE);
return FALSE;
}
if (!(op = string_for_opt(opts, FALSE)))
if ((op = string_for_opt(opts, FALSE)) == empty_optstr)
return FALSE;
while (*op) {
@@ -3288,7 +3302,7 @@ boolean tinitial, tfrom_file;
fullname = "sortloot";
if (match_optname(opts, fullname, 4, TRUE)) {
op = string_for_env_opt(fullname, opts, FALSE);
if (op) {
if (op != empty_optstr) {
char c = lowc(*op);
switch (c) {
@@ -3314,7 +3328,7 @@ boolean tinitial, tfrom_file;
if (negated) {
bad_negation(fullname, FALSE);
return FALSE;
} else if (op)
} else if (op != empty_optstr)
(void) feature_alert_opts(op, fullname);
return retval;
}
@@ -3329,7 +3343,8 @@ boolean tinitial, tfrom_file;
if (negated) {
bad_negation(fullname, FALSE);
return FALSE;
} else if (!(opts = string_for_env_opt(fullname, opts, FALSE))) {
} else if ((opts = string_for_env_opt(fullname, opts, FALSE))
== empty_optstr) {
return FALSE;
}
if (!assign_videocolors(opts)) {
@@ -3346,7 +3361,8 @@ boolean tinitial, tfrom_file;
if (negated) {
bad_negation(fullname, FALSE);
return FALSE;
} else if (!(opts = string_for_env_opt(fullname, opts, FALSE))) {
} else if ((opts = string_for_env_opt(fullname, opts, FALSE))
== empty_optstr) {
return FALSE;
}
if (!assign_videoshades(opts)) {
@@ -3367,7 +3383,8 @@ boolean tinitial, tfrom_file;
if (negated) {
bad_negation(fullname, FALSE);
return FALSE;
} else if (!(opts = string_for_env_opt(fullname, opts, FALSE))) {
} else if ((opts = string_for_env_opt(fullname, opts, FALSE))
== empty_optstr) {
return FALSE;
}
if (!assign_video(opts)) {
@@ -3385,7 +3402,8 @@ boolean tinitial, tfrom_file;
if (negated) {
bad_negation(fullname, FALSE);
return FALSE;
} else if (!(opts = string_for_env_opt(fullname, opts, FALSE))) {
} else if ((opts = string_for_env_opt(fullname, opts, FALSE))
== empty_optstr) {
return FALSE;
}
if (!assign_soundcard(opts)) {
@@ -3407,7 +3425,7 @@ boolean tinitial, tfrom_file;
if (duplicate)
complain_about_duplicate(opts, 1);
op = string_for_opt(opts, negated);
if (op && !negated) {
if (op != empty_optstr && !negated) {
if (!strcmpi(op, "tiles"))
iflags.wc_map_mode = MAP_MODE_TILES;
else if (!strncmpi(op, "ascii4x6", sizeof "ascii4x6" - 1))
@@ -3455,7 +3473,7 @@ boolean tinitial, tfrom_file;
if (duplicate)
complain_about_duplicate(opts, 1);
op = string_for_opt(opts, negated);
if ((negated && !op) || (!negated && op)) {
if ((negated && op == empty_optstr) || (!negated && op != empty_optstr)) {
iflags.wc_scroll_amount = negated ? 1 : atoi(op);
} else if (negated) {
bad_negation(fullname, TRUE);
@@ -3471,7 +3489,7 @@ boolean tinitial, tfrom_file;
if (duplicate)
complain_about_duplicate(opts, 1);
op = string_for_opt(opts, negated);
if ((negated && !op) || (!negated && op)) {
if ((negated && op == empty_optstr) || (!negated && op != empty_optstr)) {
iflags.wc_scroll_margin = negated ? 5 : atoi(op);
} else if (negated) {
bad_negation(fullname, TRUE);
@@ -3489,7 +3507,7 @@ boolean tinitial, tfrom_file;
#if defined(WIN32)
} else {
op = string_for_opt(opts, 0);
if (!op)
if (op == empty_optstr)
return FALSE;
#ifdef TTY_GRAPHICS
map_subkeyvalue(op);
@@ -3506,7 +3524,7 @@ boolean tinitial, tfrom_file;
if (duplicate)
complain_about_duplicate(opts, 1);
op = string_for_opt(opts, negated);
if ((negated && !op) || (!negated && op)) {
if ((negated && op == empty_optstr) || (!negated && op != empty_optstr)) {
iflags.wc_tile_width = negated ? 0 : atoi(op);
} else if (negated) {
bad_negation(fullname, TRUE);
@@ -3520,7 +3538,7 @@ boolean tinitial, tfrom_file;
if (match_optname(opts, fullname, sizeof "tile_file" - 1, TRUE)) {
if (duplicate)
complain_about_duplicate(opts, 1);
if ((op = string_for_opt(opts, FALSE)) != 0) {
if ((op = string_for_opt(opts, FALSE)) != empty_optstr) {
if (iflags.wc_tile_file)
free(iflags.wc_tile_file);
iflags.wc_tile_file = dupstr(op);
@@ -3535,7 +3553,7 @@ boolean tinitial, tfrom_file;
if (duplicate)
complain_about_duplicate(opts, 1);
op = string_for_opt(opts, negated);
if ((negated && !op) || (!negated && op)) {
if ((negated && op == empty_optstr) || (!negated && op != empty_optstr)) {
iflags.wc_tile_height = negated ? 0 : atoi(op);
} else if (negated) {
bad_negation(fullname, TRUE);
@@ -3551,7 +3569,7 @@ boolean tinitial, tfrom_file;
if (duplicate)
complain_about_duplicate(opts, 1);
op = string_for_opt(opts, negated);
if ((negated && !op) || (!negated && op)) {
if ((negated && op == empty_optstr) || (!negated && op != empty_optstr)) {
iflags.wc_vary_msgcount = negated ? 0 : atoi(op);
} else if (negated) {
bad_negation(fullname, TRUE);
@@ -3582,7 +3600,8 @@ boolean tinitial, tfrom_file;
if (negated) {
bad_negation(fullname, FALSE);
return FALSE;
} else if ((op = string_for_env_opt(fullname, opts, FALSE)) != 0) {
} else if ((op = string_for_env_opt(fullname, opts, FALSE))
!= empty_optstr) {
if (!iflags.windowtype_deferred) {
char buf[WINTYPELEN];
@@ -3602,7 +3621,8 @@ boolean tinitial, tfrom_file;
if (negated) {
bad_negation(fullname, FALSE);
return FALSE;
} else if ((op = string_for_env_opt(fullname, opts, FALSE)) != 0) {
} else if ((op = string_for_env_opt(fullname, opts, FALSE))
!= empty_optstr) {
char buf[WINTYPELEN];
nmcpy(buf, op, WINTYPELEN);
@@ -3621,7 +3641,7 @@ boolean tinitial, tfrom_file;
if (match_optname(opts, fullname, 7, TRUE)) {
if (duplicate)
complain_about_duplicate(opts, 1);
if ((op = string_for_opt(opts, FALSE)) != 0) {
if ((op = string_for_opt(opts, FALSE)) != empty_optstr) {
if (!wc_set_window_colors(op)) {
config_error_add("Could not set %s '%s'", fullname, op);
return FALSE;
@@ -3644,22 +3664,23 @@ boolean tinitial, tfrom_file;
|| (fullname = "term_rows", match_optname(opts, fullname, 8, TRUE))) {
long ltmp;
op = string_for_opt(opts, negated);
ltmp = atol(op);
if (negated) {
bad_negation(fullname, FALSE);
retval = FALSE;
if ((op = string_for_opt(opts, negated)) != empty_optstr) {
ltmp = atol(op);
if (negated) {
bad_negation(fullname, FALSE);
retval = FALSE;
/* this just checks atol() sanity, not logical window size sanity */
} else if (ltmp <= 0L || ltmp >= (long) LARGEST_INT) {
config_error_add("Invalid %s: %ld", fullname, ltmp);
retval = FALSE;
/* this just checks atol() sanity, not logical window size sanity */
} else if (ltmp <= 0L || ltmp >= (long) LARGEST_INT) {
config_error_add("Invalid %s: %ld", fullname, ltmp);
retval = FALSE;
} else {
if (!strcmp(fullname, "term_rows"))
iflags.wc2_term_rows = (int) ltmp;
else /* !strcmp(fullname, "term_cols") */
iflags.wc2_term_cols = (int) ltmp;
} else {
if (!strcmp(fullname, "term_rows"))
iflags.wc2_term_rows = (int) ltmp;
else /* !strcmp(fullname, "term_cols") */
iflags.wc2_term_cols = (int) ltmp;
}
}
return retval;
}
@@ -3669,10 +3690,10 @@ boolean tinitial, tfrom_file;
fullname = "petattr";
if (match_optname(opts, fullname, sizeof "petattr" - 1, TRUE)) {
op = string_for_opt(opts, negated);
if (op && negated) {
if (op != empty_optstr && negated) {
bad_negation(fullname, TRUE);
retval = FALSE;
} else if (op) {
} else if (op != empty_optstr) {
#ifdef CURSES_GRAPHICS
int itmp = curses_read_attrs(op);
@@ -3703,7 +3724,7 @@ boolean tinitial, tfrom_file;
fullname = "windowborders";
if (match_optname(opts, fullname, 10, TRUE)) {
op = string_for_opt(opts, negated);
if (negated && op) {
if (negated && op != empty_optstr) {
bad_negation(fullname, TRUE);
retval = FALSE;
} else {
@@ -3711,7 +3732,7 @@ boolean tinitial, tfrom_file;
if (negated)
itmp = 0; /* Off */
else if (!op)
else if (op == empty_optstr)
itmp = 1; /* On */
else /* Value supplied; expect 0 (off), 1 (on), or 2 (auto) */
itmp = atoi(op);
@@ -3739,7 +3760,7 @@ boolean tinitial, tfrom_file;
bad_negation(fullname, TRUE);
itmp = 2;
retval = FALSE;
} else if (op) {
} else if (op != empty_optstr) {
itmp = atoi(op);
}
if (itmp < 2 || itmp > 3) {
@@ -3761,7 +3782,7 @@ boolean tinitial, tfrom_file;
if (duplicate)
complain_about_duplicate(opts, 1);
if (!(op = string_for_opt(opts, !val_required))) {
if ((op = string_for_opt(opts, !val_required)) == empty_optstr) {
if (val_required)
return FALSE; /* string_for_opt gave feedback */
tmp = negated ? 'n' : 'f';
@@ -3802,7 +3823,8 @@ boolean tinitial, tfrom_file;
if (negated) {
bad_negation(fullname, FALSE);
return FALSE;
} else if (!(opts = string_for_env_opt(fullname, opts, FALSE))) {
} else if ((opts = string_for_env_opt(fullname, opts, FALSE))
== empty_optstr) {
return FALSE;
}
tmpattr = match_str2attr(opts, TRUE);
@@ -3822,7 +3844,7 @@ boolean tinitial, tfrom_file;
if (negated) {
bad_negation(fullname, FALSE);
return FALSE;
} else if ((op = string_for_opt(opts, FALSE)) != 0) {
} else if ((op = string_for_opt(opts, FALSE)) != empty_optstr) {
char c, op_buf[BUFSZ];
escapes(op, op_buf);
@@ -3844,10 +3866,10 @@ boolean tinitial, tfrom_file;
if (duplicate)
complain_about_duplicate(opts, 1);
op = string_for_opt(opts, TRUE);
if (op && negated) {
if (op != empty_optstr && negated) {
clear_status_hilites();
return retval;
} else if (!op) {
} else if (op == empty_optstr) {
config_error_add("Value is mandatory for hilite_status");
return FALSE;
}
@@ -3868,7 +3890,7 @@ boolean tinitial, tfrom_file;
iflags.hilite_delta = 0L;
} else {
op = string_for_opt(opts, TRUE);
iflags.hilite_delta = (!op || !*op) ? 3L : atol(op);
iflags.hilite_delta = (op == empty_optstr || !*op) ? 3L : atol(op);
if (iflags.hilite_delta < 0L)
iflags.hilite_delta = 1L;
}
@@ -4013,7 +4035,7 @@ boolean tinitial, tfrom_file;
}
op = string_for_opt(opts, TRUE);
if (op) {
if (op != empty_optstr) {
if (negated) {
config_error_add(
"Negated boolean '%s' should not have a parameter",