summaryrefslogtreecommitdiffstats
path: root/tools/lvm.c
diff options
context:
space:
mode:
authorJoe Thornber <thornber@redhat.com>2001-12-17 17:18:47 +0000
committerJoe Thornber <thornber@redhat.com>2001-12-17 17:18:47 +0000
commit1cb025cede99cde85f4d7be6e83fe9008d41c197 (patch)
treecca21288bfa988691f49ef973740421992b87d02 /tools/lvm.c
parent9f23b355f73671769cbcc6585f652c27d24bae71 (diff)
downloadlvm2-1cb025cede99cde85f4d7be6e83fe9008d41c197.tar.gz
lvm2-1cb025cede99cde85f4d7be6e83fe9008d41c197.tar.xz
lvm2-1cb025cede99cde85f4d7be6e83fe9008d41c197.zip
o Shuffled completion functions around so we dont have to declare them
at the top of the file. o Changed completion_matches -> rl_completion_matches, and added some consts. This will probably break things on pre readline 4.2 systems.
Diffstat (limited to 'tools/lvm.c')
-rw-r--r--tools/lvm.c52
1 files changed, 25 insertions, 27 deletions
diff --git a/tools/lvm.c b/tools/lvm.c
index 6d8af557..ba51d36f 100644
--- a/tools/lvm.c
+++ b/tools/lvm.c
@@ -96,9 +96,6 @@ static int run_script(int argc, char **argv);
#ifdef READLINE_SUPPORT
static int shell(void);
-static char **lvm_completion(char *text, int start_pos, int end_pos);
-static char *list_cmds(char *text, int state);
-static char *list_args(char *text, int state);
#endif
static void display_help(void);
@@ -931,29 +928,8 @@ static int run_script(int argc, char **argv)
}
#ifdef READLINE_SUPPORT
-/* Custom completion function */
-static char **lvm_completion(char *text, int start_pos, int end_pos)
-{
- char **match_list = NULL;
- int p = 0;
-
- while (isspace((int) *(rl_line_buffer + p)))
- p++;
-
- /* First word should be one of our commands */
- if (start_pos == p)
- match_list = completion_matches(text, list_cmds);
- else if (*text == '-')
- match_list = completion_matches(text, list_args);
- /* else other args */
-
- /* No further completion */
- rl_attempted_completion_over = 1;
- return match_list;
-}
-
/* List matching commands */
-static char *list_cmds(char *text, int state)
+static char *_list_cmds(const char *text, int state)
{
static int i = 0;
static int len = 0;
@@ -972,7 +948,7 @@ static char *list_cmds(char *text, int state)
}
/* List matching arguments */
-static char *list_args(char *text, int state)
+static char *_list_args(const char *text, int state)
{
static int match_no = 0;
static int len = 0;
@@ -1041,13 +1017,35 @@ static char *list_args(char *text, int state)
return NULL;
}
+/* Custom completion function */
+static char **_completion(const char *text, int start_pos, int end_pos)
+{
+ char **match_list = NULL;
+ int p = 0;
+
+ while (isspace((int) *(rl_line_buffer + p)))
+ p++;
+
+ /* First word should be one of our commands */
+ if (start_pos == p)
+ match_list = rl_completion_matches(text, _list_cmds);
+
+ else if (*text == '-')
+ match_list = rl_completion_matches(text, _list_args);
+ /* else other args */
+
+ /* No further completion */
+ rl_attempted_completion_over = 1;
+ return match_list;
+}
+
static int shell(void)
{
int argc, ret;
char *input = NULL, *args[MAX_ARGS], **argv;
rl_readline_name = "lvm";
- rl_attempted_completion_function = (CPPFunction *) lvm_completion;
+ rl_attempted_completion_function = (CPPFunction *) _completion;
_interactive = 1;
while (1) {