mirror of
https://github.com/tmate-io/tmate.git
synced 2024-12-25 16:19:02 +01:00
Sync OpenBSD patchset 649:
have_arg matches buf so it is no longer necessary, spotted by Tim van der Molen.
This commit is contained in:
parent
ecac081a55
commit
8dcb62cd87
20
cmd-string.c
20
cmd-string.c
@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-string.c,v 1.30 2010-02-02 23:53:36 tcunha Exp $ */
|
/* $Id: cmd-string.c,v 1.31 2010-02-26 13:27:38 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -61,7 +61,7 @@ int
|
|||||||
cmd_string_parse(const char *s, struct cmd_list **cmdlist, char **cause)
|
cmd_string_parse(const char *s, struct cmd_list **cmdlist, char **cause)
|
||||||
{
|
{
|
||||||
size_t p;
|
size_t p;
|
||||||
int ch, i, argc, rval, have_arg;
|
int ch, i, argc, rval;
|
||||||
char **argv, *buf, *t;
|
char **argv, *buf, *t;
|
||||||
const char *whitespace, *equals;
|
const char *whitespace, *equals;
|
||||||
size_t len;
|
size_t len;
|
||||||
@ -72,8 +72,6 @@ cmd_string_parse(const char *s, struct cmd_list **cmdlist, char **cause)
|
|||||||
buf = NULL;
|
buf = NULL;
|
||||||
len = 0;
|
len = 0;
|
||||||
|
|
||||||
have_arg = 0;
|
|
||||||
|
|
||||||
*cause = NULL;
|
*cause = NULL;
|
||||||
|
|
||||||
*cmdlist = NULL;
|
*cmdlist = NULL;
|
||||||
@ -90,8 +88,6 @@ cmd_string_parse(const char *s, struct cmd_list **cmdlist, char **cause)
|
|||||||
strlcpy(buf + len, t, strlen(t) + 1);
|
strlcpy(buf + len, t, strlen(t) + 1);
|
||||||
len += strlen(t);
|
len += strlen(t);
|
||||||
xfree(t);
|
xfree(t);
|
||||||
|
|
||||||
have_arg = 1;
|
|
||||||
break;
|
break;
|
||||||
case '"':
|
case '"':
|
||||||
if ((t = cmd_string_string(s, &p, '"', 1)) == NULL)
|
if ((t = cmd_string_string(s, &p, '"', 1)) == NULL)
|
||||||
@ -100,8 +96,6 @@ cmd_string_parse(const char *s, struct cmd_list **cmdlist, char **cause)
|
|||||||
strlcpy(buf + len, t, strlen(t) + 1);
|
strlcpy(buf + len, t, strlen(t) + 1);
|
||||||
len += strlen(t);
|
len += strlen(t);
|
||||||
xfree(t);
|
xfree(t);
|
||||||
|
|
||||||
have_arg = 1;
|
|
||||||
break;
|
break;
|
||||||
case '$':
|
case '$':
|
||||||
if ((t = cmd_string_variable(s, &p)) == NULL)
|
if ((t = cmd_string_variable(s, &p)) == NULL)
|
||||||
@ -110,8 +104,6 @@ cmd_string_parse(const char *s, struct cmd_list **cmdlist, char **cause)
|
|||||||
strlcpy(buf + len, t, strlen(t) + 1);
|
strlcpy(buf + len, t, strlen(t) + 1);
|
||||||
len += strlen(t);
|
len += strlen(t);
|
||||||
xfree(t);
|
xfree(t);
|
||||||
|
|
||||||
have_arg = 1;
|
|
||||||
break;
|
break;
|
||||||
case '#':
|
case '#':
|
||||||
/* Comment: discard rest of line. */
|
/* Comment: discard rest of line. */
|
||||||
@ -121,7 +113,7 @@ cmd_string_parse(const char *s, struct cmd_list **cmdlist, char **cause)
|
|||||||
case EOF:
|
case EOF:
|
||||||
case ' ':
|
case ' ':
|
||||||
case '\t':
|
case '\t':
|
||||||
if (have_arg) {
|
if (buf != NULL) {
|
||||||
buf = xrealloc(buf, 1, len + 1);
|
buf = xrealloc(buf, 1, len + 1);
|
||||||
buf[len] = '\0';
|
buf[len] = '\0';
|
||||||
|
|
||||||
@ -130,8 +122,6 @@ cmd_string_parse(const char *s, struct cmd_list **cmdlist, char **cause)
|
|||||||
|
|
||||||
buf = NULL;
|
buf = NULL;
|
||||||
len = 0;
|
len = 0;
|
||||||
|
|
||||||
have_arg = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ch != EOF)
|
if (ch != EOF)
|
||||||
@ -156,7 +146,7 @@ cmd_string_parse(const char *s, struct cmd_list **cmdlist, char **cause)
|
|||||||
rval = 0;
|
rval = 0;
|
||||||
goto out;
|
goto out;
|
||||||
case '~':
|
case '~':
|
||||||
if (have_arg == 0) {
|
if (buf == NULL) {
|
||||||
if ((t = cmd_string_expand_tilde(s, &p)) == NULL)
|
if ((t = cmd_string_expand_tilde(s, &p)) == NULL)
|
||||||
goto error;
|
goto error;
|
||||||
buf = xrealloc(buf, 1, len + strlen(t) + 1);
|
buf = xrealloc(buf, 1, len + strlen(t) + 1);
|
||||||
@ -172,8 +162,6 @@ cmd_string_parse(const char *s, struct cmd_list **cmdlist, char **cause)
|
|||||||
|
|
||||||
buf = xrealloc(buf, 1, len + 1);
|
buf = xrealloc(buf, 1, len + 1);
|
||||||
buf[len++] = ch;
|
buf[len++] = ch;
|
||||||
|
|
||||||
have_arg = 1;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user