From 09c15f206edac18bd2158c189c821b9ba85d3939 Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Wed, 22 Mar 2023 16:06:18 +0000 Subject: 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. --- windows.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'windows.c') diff --git a/windows.c b/windows.c index 7287478..5735850 100644 --- a/windows.c +++ b/windows.c @@ -104,7 +104,7 @@ void debug_printf(const char *fmt, ...) static int debugging = -1; if (debugging == -1) - debugging = getenv("DEBUG_PUZZLES") ? 1 : 0; + debugging = getenv_bool("DEBUG_PUZZLES", false); if (debugging) { va_start(ap, fmt); -- cgit v1.1