(config_file.c) Cleanups

This commit is contained in:
twinaphex 2016-06-03 07:52:57 +02:00
parent a503db016e
commit d95c421ba9

View File

@ -117,7 +117,7 @@ static char *strip_comment(char *str)
{
/* Remove everything after comment.
* Keep #s inside string literals. */
char *strend = str + strlen(str);
char *string_end = str + strlen(str);
bool cut_comment = true;
while (!string_is_empty(str))
@ -125,10 +125,10 @@ static char *strip_comment(char *str)
char *comment = NULL;
char *literal = strchr(str, '\"');
if (!literal)
literal = strend;
literal = string_end;
comment = (char*)strchr(str, '#');
if (!comment)
comment = strend;
comment = string_end;
if (cut_comment && literal < comment)
{
@ -146,7 +146,7 @@ static char *strip_comment(char *str)
str = comment;
}
else
str = strend;
str = string_end;
}
return str;
@ -413,8 +413,12 @@ static config_file_t *config_file_new_internal(
line = getaline(file);
if (line)
if (!line)
{
free(list);
continue;
}
if (parse_line(conf, list, line))
{
if (conf->entries)
@ -426,12 +430,6 @@ static config_file_t *config_file_new_internal(
}
free(line);
}
else
{
free(list);
continue;
}
if (list != conf->tail)
free(list);