(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,26 +413,24 @@ static config_file_t *config_file_new_internal(
line = getaline(file);
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
if (!line)
{
free(list);
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)
free(list);
}