}
/* Change the state of a flag, and return it's original value, or return
- FLAG_ERROR if there is no flag called NAME. ON_OR_OFF should be one
- of FLAG_ON or FLAG_OFF. */
+ FLAG_ERROR if there is no flag FLAG. ON_OR_OFF must be either
+ FLAG_ON or FLAG_OFF. */
int
change_flag (flag, on_or_off)
int flag;
return (FLAG_ERROR);
#endif /* RESTRICTED_SHELL */
- if (value == (int *)FLAG_UNKNOWN)
+ if ((value == (int *)FLAG_UNKNOWN) || (on_or_off != FLAG_ON && on_or_off != FLAG_OFF))
return (FLAG_ERROR);
old_value = *value;
- if (on_or_off == FLAG_ON)
- *value = 1;
- else if (on_or_off == FLAG_OFF)
- *value = 0;
- else
- return (FLAG_ERROR);
+ *value = (on_or_off == FLAG_ON) ? 1 : 0;
/* Special cases for a few flags. */
switch (flag)