mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-20 15:41:30 -07:00
New shared function, getenv_bool()
This provides a standard way to get a boolean from an environment variable. It treats the variable as true iff its value begins with 'y' or 'Y', like most of the current implementations. The function takes a default value which it returns if the environment variable is undefined. This replaces the various ad-hoc tests of environment variable scattered around and mostly doesn't change their behaviour. The exceptions are TOWERS_2D in Towers and DEBUG_PUZZLES in the Windows front end. Both of those were treated as true if they were defined at all, but now follow the same rules as other boolean environment variables.
This commit is contained in:
6
range.c
6
range.c
@ -1324,10 +1324,8 @@ static char *interpret_move(const game_state *state, game_ui *ui,
|
||||
*/
|
||||
{
|
||||
static int swap_buttons = -1;
|
||||
if (swap_buttons < 0) {
|
||||
char *env = getenv("RANGE_SWAP_BUTTONS");
|
||||
swap_buttons = (env && (env[0] == 'y' || env[0] == 'Y'));
|
||||
}
|
||||
if (swap_buttons < 0)
|
||||
swap_buttons = getenv_bool("RANGE_SWAP_BUTTONS", false);
|
||||
if (swap_buttons) {
|
||||
if (button == LEFT_BUTTON)
|
||||
button = RIGHT_BUTTON;
|
||||
|
Reference in New Issue
Block a user