Fix problems with spaces in config files
This commit is contained in:
parent
457bd13492
commit
bef2d8714c
|
@ -232,8 +232,9 @@ int config_read(char *file) {
|
|||
char path_buffer[PATH_MAX];
|
||||
CONFIGELEMENT *pce;
|
||||
int handled;
|
||||
char *term;
|
||||
|
||||
buffer=(char*)malloc(MAX_LINE);
|
||||
buffer=(char*)malloc(MAX_LINE+1);
|
||||
if(!buffer)
|
||||
return -1;
|
||||
|
||||
|
@ -278,23 +279,31 @@ int config_read(char *file) {
|
|||
config.servername=strdup("mt-daapd " VERSION);
|
||||
|
||||
while(fgets(buffer,MAX_LINE,fin)) {
|
||||
if(*buffer != '#') {
|
||||
value=buffer;
|
||||
buffer[MAX_LINE] = '\0';
|
||||
|
||||
comment=strchr(buffer,'#');
|
||||
if(comment)
|
||||
*comment = '\0';
|
||||
|
||||
while(strlen(buffer) && (strchr("\n\r ",buffer[strlen(buffer)-1])))
|
||||
buffer[strlen(buffer)-1] = '\0';
|
||||
|
||||
term=buffer;
|
||||
|
||||
while((*term=='\t') || (*term==' '))
|
||||
term++;
|
||||
|
||||
value=term;
|
||||
|
||||
strsep(&value,"\t ");
|
||||
if(value) {
|
||||
while((*value==' ')||(*value=='\t'))
|
||||
if((value) && (term) && (strlen(term))) {
|
||||
while(strlen(value) && (strchr("\t ",*value)))
|
||||
value++;
|
||||
|
||||
comment=value;
|
||||
strsep(&comment,"#");
|
||||
|
||||
if(value[strlen(value)-1] == '\n')
|
||||
value[strlen(value)-1] = '\0';
|
||||
|
||||
pce=config_elements;
|
||||
handled=0;
|
||||
while((!handled) && (pce->config_element != -1)) {
|
||||
if((strcasecmp(buffer,pce->name)==0) && (pce->config_element)) {
|
||||
if((strcasecmp(term,pce->name)==0) && (pce->config_element)) {
|
||||
/* valid config directive */
|
||||
handled=1;
|
||||
pce->changed=1;
|
||||
|
@ -323,7 +332,6 @@ int config_read(char *file) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fclose(fin);
|
||||
free(buffer);
|
||||
|
|
Loading…
Reference in New Issue