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:
Ben Harris
2023-03-22 16:06:18 +00:00
parent adf2a09829
commit 09c15f206e
12 changed files with 26 additions and 35 deletions

View File

@ -377,6 +377,8 @@ char *fgetline(FILE *fp);
char *bin2hex(const unsigned char *in, int inlen);
unsigned char *hex2bin(const char *in, int outlen);
bool getenv_bool(const char *name, bool dflt);
/* Mixes two colours in specified proportions. */
void colour_mix(const float src1[3], const float src2[3], float p,
float dst[3]);