(config_file.c) Cleanups
This commit is contained in:
parent
a503db016e
commit
d95c421ba9
|
@ -117,7 +117,7 @@ static char *strip_comment(char *str)
|
||||||
{
|
{
|
||||||
/* Remove everything after comment.
|
/* Remove everything after comment.
|
||||||
* Keep #s inside string literals. */
|
* Keep #s inside string literals. */
|
||||||
char *strend = str + strlen(str);
|
char *string_end = str + strlen(str);
|
||||||
bool cut_comment = true;
|
bool cut_comment = true;
|
||||||
|
|
||||||
while (!string_is_empty(str))
|
while (!string_is_empty(str))
|
||||||
|
@ -125,10 +125,10 @@ static char *strip_comment(char *str)
|
||||||
char *comment = NULL;
|
char *comment = NULL;
|
||||||
char *literal = strchr(str, '\"');
|
char *literal = strchr(str, '\"');
|
||||||
if (!literal)
|
if (!literal)
|
||||||
literal = strend;
|
literal = string_end;
|
||||||
comment = (char*)strchr(str, '#');
|
comment = (char*)strchr(str, '#');
|
||||||
if (!comment)
|
if (!comment)
|
||||||
comment = strend;
|
comment = string_end;
|
||||||
|
|
||||||
if (cut_comment && literal < comment)
|
if (cut_comment && literal < comment)
|
||||||
{
|
{
|
||||||
|
@ -146,7 +146,7 @@ static char *strip_comment(char *str)
|
||||||
str = comment;
|
str = comment;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
str = strend;
|
str = string_end;
|
||||||
}
|
}
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
|
@ -413,26 +413,24 @@ static config_file_t *config_file_new_internal(
|
||||||
|
|
||||||
line = getaline(file);
|
line = getaline(file);
|
||||||
|
|
||||||
if (line)
|
if (!line)
|
||||||
{
|
|
||||||
if (parse_line(conf, list, line))
|
|
||||||
{
|
|
||||||
if (conf->entries)
|
|
||||||
conf->tail->next = list;
|
|
||||||
else
|
|
||||||
conf->entries = list;
|
|
||||||
|
|
||||||
conf->tail = list;
|
|
||||||
}
|
|
||||||
|
|
||||||
free(line);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
free(list);
|
free(list);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (parse_line(conf, list, line))
|
||||||
|
{
|
||||||
|
if (conf->entries)
|
||||||
|
conf->tail->next = list;
|
||||||
|
else
|
||||||
|
conf->entries = list;
|
||||||
|
|
||||||
|
conf->tail = list;
|
||||||
|
}
|
||||||
|
|
||||||
|
free(line);
|
||||||
|
|
||||||
if (list != conf->tail)
|
if (list != conf->tail)
|
||||||
free(list);
|
free(list);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue