aboutsummaryrefslogtreecommitdiff
path: root/cmd.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2009-01-06 17:04:56 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2009-01-06 17:04:56 +0000
commit4af8db90e825a2e6dd7034ec88fd6f856bf83e9e (patch)
tree2d16baaefd6306329f94c267ae0b39ca022e2d9e /cmd.c
parent9cddd796ffef383893b5fd4e228f4d18673a77bd (diff)
downloadrtmux-4af8db90e825a2e6dd7034ec88fd6f856bf83e9e.tar.gz
rtmux-4af8db90e825a2e6dd7034ec88fd6f856bf83e9e.tar.bz2
rtmux-4af8db90e825a2e6dd7034ec88fd6f856bf83e9e.zip
Complete option names as well.
Diffstat (limited to 'cmd.c')
-rw-r--r--cmd.c53
1 files changed, 1 insertions, 52 deletions
diff --git a/cmd.c b/cmd.c
index 4f4cf631..d9d46a40 100644
--- a/cmd.c
+++ b/cmd.c
@@ -1,4 +1,4 @@
-/* $Id: cmd.c,v 1.67 2008-12-15 21:21:56 nicm Exp $ */
+/* $Id: cmd.c,v 1.68 2009-01-06 17:04:56 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -74,57 +74,6 @@ const struct cmd_entry *cmd_table[] = {
NULL
};
-char *
-cmd_complete(const char *s)
-{
- const struct cmd_entry **entryp;
- ARRAY_DECL(, const char *) list;
- char *prefix, *s2;
- u_int i;
- size_t j;
-
- if (*s == '\0')
- return (xstrdup(s));
-
- /* First, build a list of all the possible matches. */
- ARRAY_INIT(&list);
- for (entryp = cmd_table; *entryp != NULL; entryp++) {
- if (strncmp((*entryp)->name, s, strlen(s)) != 0)
- continue;
- ARRAY_ADD(&list, (*entryp)->name);
- }
-
- /* If none, bail now with the original string. */
- if (ARRAY_LENGTH(&list) == 0) {
- ARRAY_FREE(&list);
- return (xstrdup(s));
- }
-
- /* If an exact match, return it, with a trailing space. */
- if (ARRAY_LENGTH(&list) == 1) {
- xasprintf(&s2, "%s ", ARRAY_FIRST(&list));
- ARRAY_FREE(&list);
- return (s2);
- }
-
- /* Now loop through the list and find the longest common prefix. */
- prefix = xstrdup(ARRAY_FIRST(&list));
- for (i = 1; i < ARRAY_LENGTH(&list); i++) {
- s = ARRAY_ITEM(&list, i);
-
- j = strlen(s);
- if (j > strlen(prefix))
- j = strlen(prefix);
- for (; j > 0; j--) {
- if (prefix[j - 1] != s[j - 1])
- prefix[j - 1] = '\0';
- }
- }
-
- ARRAY_FREE(&list);
- return (prefix);
-}
-
struct cmd *
cmd_parse(int argc, char **argv, char **cause)
{