lib: Fix '?'-completion dereferences in vtysh

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
This commit is contained in:
Quentin Young 2016-10-01 01:03:24 +00:00
parent f66625df51
commit c3f24f0653

View File

@ -823,32 +823,25 @@ vtysh_rl_describe (void)
for (i = 0; i < vector_active (describe); i++) for (i = 0; i < vector_active (describe); i++)
if ((token = vector_slot (describe, i)) != NULL) if ((token = vector_slot (describe, i)) != NULL)
{ {
int len; if (token->text[0] == '\0')
continue;
if (token->arg[0] == '\0') int len = strlen (token->text);
continue;
len = strlen (token->arg); if (width < len)
if (token->arg[0] == '.') width = len;
len--;
if (width < len)
width = len;
} }
for (i = 0; i < vector_active (describe); i++) for (i = 0; i < vector_active (describe); i++)
if ((token = vector_slot (describe, i)) != NULL) if ((token = vector_slot (describe, i)) != NULL)
{ {
if (token->arg[0] == '\0')
continue;
if (! token->desc) if (! token->desc)
fprintf (stdout," %-s\n", fprintf (stdout," %-s\n",
token->arg[0] == '.' ? token->arg + 1 : token->arg); token->text);
else else
fprintf (stdout," %-*s %s\n", fprintf (stdout," %-*s %s\n",
width, width,
token->arg[0] == '.' ? token->arg + 1 : token->arg, token->text,
token->desc); token->desc);
} }