diff options
-rw-r--r-- | lib/command.c | 7 | ||||
-rw-r--r-- | lib/command.h | 2 | ||||
-rw-r--r-- | lib/vty.c | 2 | ||||
-rw-r--r-- | vtysh/vtysh.c | 2 |
4 files changed, 6 insertions, 7 deletions
diff --git a/lib/command.c b/lib/command.c index 454f0957c..6d304fc12 100644 --- a/lib/command.c +++ b/lib/command.c @@ -718,13 +718,12 @@ cmd_variable_complete (struct cmd_token *token, const char *arg, vector comps) #define AUTOCOMP_INDENT 5 char * -cmd_variable_comp2str(vector comps, unsigned short cols, const char nl[]) +cmd_variable_comp2str(vector comps, unsigned short cols) { size_t bsz = 16; char *buf = XCALLOC(MTYPE_TMP, bsz); int lc = AUTOCOMP_INDENT; size_t cs = AUTOCOMP_INDENT; - size_t nllen = strlen(nl); size_t itemlen; snprintf(buf, bsz, "%*s", AUTOCOMP_INDENT, ""); for (size_t j = 0; j < vector_active (comps); j++) @@ -732,12 +731,12 @@ cmd_variable_comp2str(vector comps, unsigned short cols, const char nl[]) char *item = vector_slot (comps, j); itemlen = strlen(item); - if (cs + itemlen + nllen + AUTOCOMP_INDENT + 2 >= bsz) + if (cs + itemlen + AUTOCOMP_INDENT + 3 >= bsz) buf = XREALLOC(MTYPE_TMP, buf, (bsz *= 2)); if (lc + itemlen + 1 >= cols) { - cs += snprintf(&buf[cs], bsz - cs, "%s%*s", nl, AUTOCOMP_INDENT, ""); + cs += snprintf(&buf[cs], bsz - cs, "\n%*s", AUTOCOMP_INDENT, ""); lc = AUTOCOMP_INDENT; } diff --git a/lib/command.h b/lib/command.h index f712407b7..5bde83001 100644 --- a/lib/command.h +++ b/lib/command.h @@ -406,6 +406,6 @@ struct cmd_variable_handler { extern void cmd_variable_complete (struct cmd_token *token, const char *arg, vector comps); extern void cmd_variable_handler_register (const struct cmd_variable_handler *cvh); -extern char *cmd_variable_comp2str (vector comps, unsigned short cols, const char nl[]); +extern char *cmd_variable_comp2str (vector comps, unsigned short cols); #endif /* _ZEBRA_COMMAND_H */ @@ -1118,7 +1118,7 @@ vty_describe_command (struct vty *vty) if (vector_active (varcomps) > 0) { - char *ac = cmd_variable_comp2str(varcomps, vty->width, "\n"); + char *ac = cmd_variable_comp2str(varcomps, vty->width); vty_out(vty, "%s\n", ac); XFREE(MTYPE_TMP, ac); } diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index 5f89afdd0..e4bf5b257 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -816,7 +816,7 @@ vtysh_rl_describe (void) int rows, cols; rl_get_screen_size(&rows, &cols); - char *ac = cmd_variable_comp2str(varcomps, cols, "\n"); + char *ac = cmd_variable_comp2str(varcomps, cols); fprintf(stdout, "%s\n", ac); XFREE(MTYPE_TMP, ac); } |