diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2008-06-14 08:11:17 +0000 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2008-06-14 08:11:17 +0000 |
commit | 0bfd7a502309d329bcd0a41353b07ca6c5c5cafa (patch) | |
tree | a2404caccbab52066899288d691f2c06ceabdac7 | |
parent | ea80307acb957a3b0d24d23cf6da93503ef05bb9 (diff) | |
download | rtmux-0bfd7a502309d329bcd0a41353b07ca6c5c5cafa.tar.gz rtmux-0bfd7a502309d329bcd0a41353b07ca6c5c5cafa.tar.bz2 rtmux-0bfd7a502309d329bcd0a41353b07ca6c5c5cafa.zip |
Don't die on empty strings.
-rw-r--r-- | CHANGES | 6 | ||||
-rw-r--r-- | cfg.c | 26 |
2 files changed, 18 insertions, 14 deletions
@@ -1,3 +1,7 @@ +14 June 2008 + +* Don't die on empty strings in config file, reported by Will Maier. + 08 June 2008 * Set socket mode +x if any sessions are attached and -x if not. @@ -460,4 +464,4 @@ (including mutt, emacs). No status bar yet and no key remapping or other customisation. -$Id: CHANGES,v 1.117 2008-06-08 19:49:04 nicm Exp $ +$Id: CHANGES,v 1.118 2008-06-14 08:11:16 nicm Exp $ @@ -1,4 +1,4 @@ -/* $Id: cfg.c,v 1.6 2008-06-02 22:16:27 nicm Exp $ */ +/* $Id: cfg.c,v 1.7 2008-06-14 08:11:17 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> @@ -99,36 +99,36 @@ load_cfg(const char *path, char **causep) case '\t': if (len != 0) { buf[len] = '\0'; - + argv = xrealloc( argv, argc + 1, sizeof (char *)); argv[argc++] = buf; - + buf = NULL; len = 0; - } + } if (ch != '\n' && ch != EOF) break; line++; if (argc == 0) break; - + if ((cmd = cmd_parse(argc, argv, &cause)) == NULL) goto error; ctx.msgdata = NULL; ctx.cursession = NULL; ctx.curclient = NULL; - + ctx.error = cfg_error; ctx.print = cfg_print; - + ctx.cmdclient = NULL; ctx.flags = 0; - + cfg_cause = NULL; - cmd_exec(cmd, &ctx); + cmd_exec(cmd, &ctx); cmd_free(cmd); if (cfg_cause != NULL) { cause = cfg_cause; @@ -142,7 +142,7 @@ load_cfg(const char *path, char **causep) default: if (len >= SIZE_MAX - 2) goto error; - + buf = xrealloc(buf, 1, len + 1); buf[len++] = ch; break; @@ -163,7 +163,7 @@ error: if (cause == NULL) xasprintf(causep, "%s: error at line %u", path, line); - else + else xasprintf(causep, "%s: %s at line %u", path, cause, line); return (1); } @@ -175,7 +175,7 @@ cfg_string(FILE *f, char endch, int esc) char *buf; size_t len; - buf = NULL; + buf = xmalloc(1); len = 0; while ((ch = getc(f)) != endch) { @@ -211,6 +211,6 @@ cfg_string(FILE *f, char endch, int esc) buf[len++] = ch; } - buf[len] = '\0'; + buf[len] = '\0'; return (buf); } |