diff options
author | Chris Robinson <[email protected]> | 2015-08-28 14:59:45 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2015-08-28 14:59:45 -0700 |
commit | 70c63dd576c240c16ce93c716f3bc28be2c085e0 (patch) | |
tree | 8edb5de7328e04ada6351ed99ab1a84a68a5f524 /Alc/alcConfig.c | |
parent | 8fe421cba12087746959501685272a075dcc7931 (diff) |
Allow '#' in config block names
Since some devices may have it appended.
Diffstat (limited to 'Alc/alcConfig.c')
-rw-r--r-- | Alc/alcConfig.c | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/Alc/alcConfig.c b/Alc/alcConfig.c index b318ecdf..c5d1055a 100644 --- a/Alc/alcConfig.c +++ b/Alc/alcConfig.c @@ -202,12 +202,8 @@ static void LoadConfigFromFile(FILE *f) char key[256] = ""; char value[256] = ""; - comment = strchr(buffer, '#'); - if(comment) *(comment++) = 0; - line = rstrip(lstrip(buffer)); - if(!line[0]) - continue; + if(!line[0]) continue; if(line[0] == '[') { @@ -215,10 +211,21 @@ static void LoadConfigFromFile(FILE *f) char *endsection; endsection = strchr(section, ']'); - if(!endsection || section == endsection || endsection[1] != 0) + if(!endsection || section == endsection) { - ERR("config parse error: bad line \"%s\"\n", line); - continue; + ERR("config parse error: bad line \"%s\"\n", line); + continue; + } + if(endsection[1] != 0) + { + char *end = endsection+1; + while(isspace(*end)) + ++end; + if(*end != 0 && *end != '#') + { + ERR("config parse error: bad line \"%s\"\n", line); + continue; + } } *endsection = 0; @@ -233,6 +240,10 @@ static void LoadConfigFromFile(FILE *f) continue; } + comment = strchr(line, '#'); + if(comment) *(comment++) = 0; + if(!line[0]) continue; + if(sscanf(line, "%255[^=] = \"%255[^\"]\"", key, value) == 2 || sscanf(line, "%255[^=] = '%255[^\']'", key, value) == 2 || sscanf(line, "%255[^=] = %255[^\n]", key, value) == 2) |