Handle "" properly.

This commit is contained in:
Nicholas Marriott 2009-02-08 16:38:19 +00:00
parent b235815831
commit dd1ebf1b9d
2 changed files with 18 additions and 4 deletions

View File

@ -1,5 +1,7 @@
08 February 2009
* Don't treat empty arguments ("") differently when parsing configuration
file/command prompt rather than command line.
* tmux 0.7 released.
03 February 2009
@ -1083,7 +1085,7 @@
(including mutt, emacs). No status bar yet and no key remapping or other
customisation.
$Id: CHANGES,v 1.248 2009-02-08 14:11:37 nicm Exp $
$Id: CHANGES,v 1.249 2009-02-08 16:38:19 nicm Exp $
LocalWords: showw utf UTF fulvio ciriaco joshe OSC APC gettime abc DEF OA clr
LocalWords: rivo nurges lscm Erdely eol smysession mysession ek dstname RB ms

View File

@ -1,4 +1,4 @@
/* $Id: cmd-string.c,v 1.11 2009-01-18 14:40:48 nicm Exp $ */
/* $Id: cmd-string.c,v 1.12 2009-02-08 16:38:19 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@ -56,7 +56,7 @@ int
cmd_string_parse(const char *s, struct cmd_list **cmdlist, char **cause)
{
size_t p;
int ch, argc, rval;
int ch, argc, rval, have_arg;
char **argv, *buf, *t, *u;
size_t len;
@ -77,6 +77,8 @@ cmd_string_parse(const char *s, struct cmd_list **cmdlist, char **cause)
buf = NULL;
len = 0;
have_arg = 0;
*cause = NULL;
*cmdlist = NULL;
@ -92,6 +94,8 @@ cmd_string_parse(const char *s, struct cmd_list **cmdlist, char **cause)
buf = xrealloc(buf, 1, len + strlen(t) + 1);
strlcpy(buf + len, t, strlen(t) + 1);
len += strlen(t);
have_arg = 1;
break;
case '"':
if ((t = cmd_string_string(s, &p, '"', 1)) == NULL)
@ -99,6 +103,8 @@ cmd_string_parse(const char *s, struct cmd_list **cmdlist, char **cause)
buf = xrealloc(buf, 1, len + strlen(t) + 1);
strlcpy(buf + len, t, strlen(t) + 1);
len += strlen(t);
have_arg = 1;
break;
case '$':
if ((t = cmd_string_variable(s, &p)) == NULL)
@ -106,6 +112,8 @@ cmd_string_parse(const char *s, struct cmd_list **cmdlist, char **cause)
buf = xrealloc(buf, 1, len + strlen(t) + 1);
strlcpy(buf + len, t, strlen(t) + 1);
len += strlen(t);
have_arg = 1;
break;
case '#':
/* Comment: discard rest of line. */
@ -115,7 +123,7 @@ cmd_string_parse(const char *s, struct cmd_list **cmdlist, char **cause)
case EOF:
case ' ':
case '\t':
if (len != 0) {
if (have_arg) {
buf = xrealloc(buf, 1, len + 1);
buf[len] = '\0';
@ -124,6 +132,8 @@ cmd_string_parse(const char *s, struct cmd_list **cmdlist, char **cause)
buf = NULL;
len = 0;
have_arg = 0;
}
if (ch != EOF)
@ -143,6 +153,8 @@ cmd_string_parse(const char *s, struct cmd_list **cmdlist, char **cause)
buf = xrealloc(buf, 1, len + 1);
buf[len++] = ch;
have_arg = 1;
break;
}
}