summaryrefslogtreecommitdiffstats
path: root/cfg.c
Side-by-side diff
Diffstat (limited to 'cfg.c') (more/less context) (ignore whitespace changes)
-rw-r--r--cfg.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/cfg.c b/cfg.c
index 0c8dab2..1789325 100644
--- a/cfg.c
+++ b/cfg.c
@@ -73,7 +73,7 @@ load_cfg(const char *path, char **causep)
buf = NULL;
len = 0;
- line = 1;
+ line = 0;
while ((ch = getc(f)) != EOF) {
switch (ch) {
case '#':
@@ -98,17 +98,18 @@ load_cfg(const char *path, char **causep)
case EOF:
case ' ':
case '\t':
- if (len == 0)
- break;
- buf[len] = '\0';
-
- argv = xrealloc(argv, argc + 1, sizeof (char *));
- argv[argc++] = buf;
+ if (len != 0) {
+ buf[len] = '\0';
- buf = NULL;
- len = 0;
+ argv = xrealloc(
+ argv, argc + 1, sizeof (char *));
+ argv[argc++] = buf;
+
+ buf = NULL;
+ len = 0;
+ }
- if (ch != '\n' && ch != EOF)
+ if ((ch != '\n' && ch != EOF) || argc == 0)
break;
line++;
@@ -123,7 +124,7 @@ load_cfg(const char *path, char **causep)
ctx.print = cfg_print;
ctx.cmdclient = NULL;
- ctx.flags = CMD_KEY;
+ ctx.flags = 0;
cfg_cause = NULL;
cmd_exec(cmd, &ctx);