From 54aba54c10d7cc98023a49e3a8a3509cbd358867 Mon Sep 17 00:00:00 2001 From: paul Date: Thu, 21 Aug 2003 20:28:24 +0000 Subject: 2003-08-20 Yasuhiro Ohara * command.c: Fix display problem for command line description. --- lib/ChangeLog | 5 +++++ lib/command.c | 24 ++++++++++++++---------- 2 files changed, 19 insertions(+), 10 deletions(-) (limited to 'lib') diff --git a/lib/ChangeLog b/lib/ChangeLog index 71fb42c3..55056864 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,8 @@ +2003-08-20 Yasuhiro Ohara + + * command.c: Fix display problem for command line + description + 2003-05-24 Anil Madhavapeddy * (sockunion.c): Incorrect bounds specified in sockunion_log() diff --git a/lib/command.c b/lib/command.c index e8c9203f..8c60fc4f 100644 --- a/lib/command.c +++ b/lib/command.c @@ -1529,6 +1529,9 @@ cmd_describe_command_real (vector vline, struct vty *vty, int *status) vector matchvec; struct cmd_element *cmd_element; int index; + int ret; + enum match_type match; + char *command; static struct desc desc_cr = { "", "" }; /* Set index. */ @@ -1541,14 +1544,10 @@ cmd_describe_command_real (vector vline, struct vty *vty, int *status) matchvec = vector_init (INIT_MATCHVEC_SIZE); /* Filter commands. */ + /* Only words precedes current word will be checked in this loop. */ for (i = 0; i < index; i++) { - enum match_type match; - char *command; - int ret; - command = vector_slot (vline, i); - match = cmd_filter_by_completion (command, cmd_vector, i); if (match == vararg_match) @@ -1570,7 +1569,6 @@ cmd_describe_command_real (vector vline, struct vty *vty, int *status) } vector_set (matchvec, &desc_cr); - vector_free (cmd_vector); return matchvec; @@ -1593,6 +1591,11 @@ cmd_describe_command_real (vector vline, struct vty *vty, int *status) /* Prepare match vector */ /* matchvec = vector_init (INIT_MATCHVEC_SIZE); */ + /* Make sure that cmd_vector is filtered based on current word */ + command = vector_slot (vline, index); + if (command) + match = cmd_filter_by_completion (command, cmd_vector, index); + /* Make description vector. */ for (i = 0; i < vector_max (cmd_vector); i++) if ((cmd_element = vector_slot (cmd_vector, i)) != NULL) @@ -1600,12 +1603,13 @@ cmd_describe_command_real (vector vline, struct vty *vty, int *status) char *string = NULL; vector strvec = cmd_element->strvec; - if (index > vector_max (strvec)) + /* if command is NULL, index may be equal to vector_max */ + if (command && index >= vector_max (strvec)) vector_slot (cmd_vector, i) = NULL; else { - /* Check is command is completed. */ - if (index == vector_max (strvec)) + /* Check if command is completed. */ + if (command == NULL && index == vector_max (strvec)) { string = ""; if (! desc_unique_string (matchvec, string)) @@ -1620,7 +1624,7 @@ cmd_describe_command_real (vector vline, struct vty *vty, int *status) for (j = 0; j < vector_max (descvec); j++) { desc = vector_slot (descvec, j); - string = cmd_entry_function_desc (vector_slot (vline, index), desc->cmd); + string = cmd_entry_function_desc (command, desc->cmd); if (string) { /* Uniqueness check */ -- cgit v1.2.1