]> git.puffer.fish Git - matthieu/frr.git/commitdiff
2003-08-20 Yasuhiro Ohara <yasu@sfc.wide.ad.jp>
authorpaul <paul>
Thu, 21 Aug 2003 20:28:24 +0000 (20:28 +0000)
committerpaul <paul>
Thu, 21 Aug 2003 20:28:24 +0000 (20:28 +0000)
* command.c: Fix <cr> display problem for command line
  description.

lib/ChangeLog
lib/command.c

index 71fb42c36e18392c149c8813e5b421027fc543d6..550568647407d6fb9c10a5817d69a4012e46b83d 100644 (file)
@@ -1,3 +1,8 @@
+2003-08-20 Yasuhiro Ohara <yasu@sfc.wide.ad.jp>
+
+       * command.c: Fix <cr> display problem for command line
+         description
+
 2003-05-24 Anil Madhavapeddy
 
        * (sockunion.c): Incorrect bounds specified in sockunion_log()
index e8c9203f4cccf19114e78451925ff213fbf8b874..8c60fc4f05a7626641b532980d64b487f174c222 100644 (file)
@@ -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 = { "<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 = "<cr>";
                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 */