diff options
Diffstat (limited to 'lib/command.c')
| -rw-r--r-- | lib/command.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/command.c b/lib/command.c index ba1e0bcec3..11c9a0968b 100644 --- a/lib/command.c +++ b/lib/command.c @@ -1592,6 +1592,10 @@ permute (struct graph_node *start, struct vty *vty) static struct list *position = NULL; if (!position) position = list_new (); + struct cmd_token *stok = start->data; + struct graph_node *gnn; + struct listnode *ln; + // recursive dfs listnode_add (position, start); for (unsigned int i = 0; i < vector_active (start->to); i++) @@ -1603,8 +1607,6 @@ permute (struct graph_node *start, struct vty *vty) continue; else if (tok->type == END_TKN || gn == start) { - struct graph_node *gnn; - struct listnode *ln; vty_out (vty, " "); for (ALL_LIST_ELEMENTS_RO (position,ln,gnn)) { @@ -1617,7 +1619,15 @@ permute (struct graph_node *start, struct vty *vty) vty_out (vty, VTY_NEWLINE); } else - permute (gn, vty); + { + bool skip = false; + if (stok->type == FORK_TKN && tok->type != FORK_TKN) + for (ALL_LIST_ELEMENTS_RO (position, ln, gnn)) + if (gnn == gn && (skip = true)) + break; + if (!skip) + permute (gn, vty); + } } list_delete_node (position, listtail(position)); } |
