diff options
author | Chris Robinson <[email protected]> | 2014-08-19 14:48:13 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2014-08-19 16:54:53 -0700 |
commit | e3d72ccd150679e92c9bf21518a2a6d164ea4a29 (patch) | |
tree | 37276404cbf7cf66d05d47f99c8a20ca9a27af7b /Alc | |
parent | 3c13e1e333e5a55185e19456df9dfbd1e80055d8 (diff) |
Support brace-enclosed environment variable names
This makes it possible to append alpha-numeric characters directly to an
environment variable value, e.g. ${FOO}bar will use "FOO" as the variable name
and keep the "bar" as-is, whereas $FOObar will take "FOObar" as the variable
name.
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/alcConfig.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Alc/alcConfig.c b/Alc/alcConfig.c index 55f647e7..a7d36a84 100644 --- a/Alc/alcConfig.c +++ b/Alc/alcConfig.c @@ -38,6 +38,7 @@ #include "alMain.h" #include "compat.h" +#include "bool.h" typedef struct ConfigEntry { @@ -137,13 +138,21 @@ static char *expdup(const char *str) } else { + bool hasbraces; char envname[1024]; size_t k = 0; + hasbraces = (*str == '{'); + if(hasbraces) str++; + while((isalnum(*str) || *str == '_') && k < sizeof(envname)-1) envname[k++] = *(str++); envname[k++] = '\0'; + if(hasbraces && *str != '}') + continue; + + if(hasbraces) str++; if((addstr=getenv(envname)) == NULL) continue; addstrlen = strlen(addstr); |