summaryrefslogtreecommitdiffstats
path: root/cmd-list.c
authorRaghavendra D Prabhu <[email protected]>2011-01-23 11:59:16 (GMT)
committer Raghavendra D Prabhu <[email protected]>2011-01-23 11:59:16 (GMT)
commit0426ab2b383afd38af7274759c3a8d017bc88f00 (patch) (side-by-side diff)
tree2cc4bf1da4062c9ef91f2e94a9625f2423f57102 /cmd-list.c
parent4e4aed43dc2b40b36f1b31cd3af9f874b78fa454 (diff)
parentb67bfd382d3401de572bb3487b1af3382a9cbeda (diff)
downloadtmux-old-master.zip
tmux-old-master.tar.gz
tmux-old-master.tar.bz2
merged new changesmaster
Diffstat (limited to 'cmd-list.c') (more/less context) (ignore whitespace changes)
-rw-r--r--cmd-list.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/cmd-list.c b/cmd-list.c
index c1ebd86..ec70ed2 100644
--- a/cmd-list.c
+++ b/cmd-list.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-list.c,v 1.9 2010/07/02 02:43:01 tcunha Exp $ */
+/* $Id: cmd-list.c,v 1.10 2010/12/06 21:48:56 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <[email protected]>
@@ -29,7 +29,9 @@ cmd_list_parse(int argc, char **argv, char **cause)
struct cmd *cmd;
int i, lastsplit;
size_t arglen, new_argc;
- char **new_argv;
+ char **copy_argv, **new_argv;
+
+ copy_argv = cmd_copy_argv(argc, argv);
cmdlist = xmalloc(sizeof *cmdlist);
cmdlist->references = 1;
@@ -37,18 +39,18 @@ cmd_list_parse(int argc, char **argv, char **cause)
lastsplit = 0;
for (i = 0; i < argc; i++) {
- arglen = strlen(argv[i]);
- if (arglen == 0 || argv[i][arglen - 1] != ';')
+ arglen = strlen(copy_argv[i]);
+ if (arglen == 0 || copy_argv[i][arglen - 1] != ';')
continue;
- argv[i][arglen - 1] = '\0';
+ copy_argv[i][arglen - 1] = '\0';
- if (arglen > 1 && argv[i][arglen - 2] == '\\') {
- argv[i][arglen - 2] = ';';
+ if (arglen > 1 && copy_argv[i][arglen - 2] == '\\') {
+ copy_argv[i][arglen - 2] = ';';
continue;
}
new_argc = i - lastsplit;
- new_argv = argv + lastsplit;
+ new_argv = copy_argv + lastsplit;
if (arglen != 1)
new_argc++;
@@ -61,16 +63,18 @@ cmd_list_parse(int argc, char **argv, char **cause)
}
if (lastsplit != argc) {
- cmd = cmd_parse(argc - lastsplit, argv + lastsplit, cause);
+ cmd = cmd_parse(argc - lastsplit, copy_argv + lastsplit, cause);
if (cmd == NULL)
goto bad;
TAILQ_INSERT_TAIL(&cmdlist->list, cmd, qentry);
}
+ cmd_free_argv(argc, copy_argv);
return (cmdlist);
bad:
cmd_list_free(cmdlist);
+ cmd_free_argv(argc, copy_argv);
return (NULL);
}