From e3d72ccd150679e92c9bf21518a2a6d164ea4a29 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Tue, 19 Aug 2014 14:48:13 -0700 Subject: 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. --- Alc/alcConfig.c | 9 +++++++++ 1 file changed, 9 insertions(+) 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); -- cgit v1.2.3