config: "line ends early" is now a fatal error
This commit is contained in:
parent
50f3806f15
commit
6e9a68711d
21
src/config.c
21
src/config.c
|
@ -25,7 +25,7 @@ config_t *
|
|||
parse_config(char *path)
|
||||
{
|
||||
FILE *fd;
|
||||
int res, state, line, ws, comment, err, i, col;
|
||||
int state, line, ws, comment, err, i, col;
|
||||
#define ST_FILENAME 0
|
||||
#define ST_EXT 1
|
||||
#define ST_START 2
|
||||
|
@ -58,11 +58,13 @@ parse_config(char *path)
|
|||
switch (ch) {
|
||||
case '\t':
|
||||
case ' ':
|
||||
if (comment)
|
||||
if (comment) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* only run on the first whitespace */
|
||||
if (!ws) {
|
||||
DPRINTF(("i = %d\n", i));
|
||||
i = 0;
|
||||
ws = 1;
|
||||
state++;
|
||||
|
@ -106,25 +108,30 @@ parse_config(char *path)
|
|||
err = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if (state != ST_OPTS) {
|
||||
PMSG("warn", "line ends early");
|
||||
PMSG("error", "line ends early");
|
||||
err = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
memset(cur->next, 0, sizeof(config_t));
|
||||
cur = cur->next;
|
||||
memset(cur, 0, sizeof(config_t));
|
||||
}
|
||||
|
||||
/* reset state for next line */
|
||||
state = ST_FILENAME;
|
||||
ws = col = i = comment = 0;
|
||||
ws = col = i = 0;
|
||||
comment = 0;
|
||||
line++;
|
||||
break;
|
||||
case '#':
|
||||
comment = 1;
|
||||
break;
|
||||
default:
|
||||
if (comment)
|
||||
if (comment) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ws = 0;
|
||||
|
||||
|
@ -136,6 +143,7 @@ parse_config(char *path)
|
|||
err = 1;
|
||||
} else {
|
||||
cur->filename[i] = toupper(ch);
|
||||
DPRINTF(("%c", cur->filename[i]));
|
||||
i++;
|
||||
}
|
||||
break;
|
||||
|
@ -145,6 +153,7 @@ parse_config(char *path)
|
|||
err = 1;
|
||||
} else {
|
||||
cur->ext[i] = toupper(ch);
|
||||
DPRINTF(("%c", cur->ext[i]));
|
||||
i++;
|
||||
}
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue