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. --- loopy.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'loopy.c') diff --git a/loopy.c b/loopy.c index 0a22e6a..c627f2b 100644 --- a/loopy.c +++ b/loopy.c @@ -3292,11 +3292,8 @@ static void game_redraw_line(drawing *dr, game_drawstate *ds, if (line_colour == COL_FAINT) { static int draw_faint_lines = -1; - if (draw_faint_lines < 0) { - char *env = getenv("LOOPY_FAINT_LINES"); - draw_faint_lines = (!env || (env[0] == 'y' || - env[0] == 'Y')); - } + if (draw_faint_lines < 0) + draw_faint_lines = getenv_bool("LOOPY_FAINT_LINES", true); if (draw_faint_lines) draw_line(dr, x1, y1, x2, y2, line_colour); } else { -- cgit v1.1