summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorQuentin Young <qlyoung@cumulusnetworks.com>2017-05-05 00:46:46 +0200
committerQuentin Young <qlyoung@cumulusnetworks.com>2017-05-05 02:18:14 +0200
commitdfe536f475a79e899cf2915a3ba602c92aee2263 (patch)
treed22fd5ec202d5e21fe87c017d8872304a8be523d /lib
parentMerge pull request #427 from opensourcerouting/zebra-ifdel-fix (diff)
downloadfrr-dfe536f475a79e899cf2915a3ba602c92aee2263.tar.xz
frr-dfe536f475a79e899cf2915a3ba602c92aee2263.zip
lib: fix 'list permutations'
Cyclic graphs ftw Also remove graph pretty printer from permutations.c 'cause it's not really needed anymore Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/command.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/command.c b/lib/command.c
index 993d6f905..43b2c478a 100644
--- a/lib/command.c
+++ b/lib/command.c
@@ -1584,6 +1584,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++)
@@ -1595,8 +1599,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))
{
@@ -1609,7 +1611,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));
}