config handles comments better

This commit is contained in:
taiyu 2015-08-18 02:48:56 -07:00
parent 2f8a239248
commit e9c3a9016f
2 changed files with 2 additions and 2 deletions

View File

@ -188,8 +188,8 @@ bool read_config(FILE *file, bool is_active) {
while (!feof(file)) { while (!feof(file)) {
int _; int _;
char *line = read_line(file); char *line = read_line(file);
line = strip_whitespace(line, &_);
line = strip_comments(line); line = strip_comments(line);
line = strip_whitespace(line, &_);
if (!line[0]) { if (!line[0]) {
goto _continue; goto _continue;
} }

View File

@ -40,7 +40,7 @@ char *strip_comments(char *str) {
} else if (str[i] == '\'' && !in_string) { } else if (str[i] == '\'' && !in_string) {
in_character = !in_character; in_character = !in_character;
} else if (!in_character && !in_string) { } else if (!in_character && !in_string) {
if (str[i] == '#' && i == 0) { if (str[i] == '#') {
str[i] = '\0'; str[i] = '\0';
break; break;
} }