diff options
| author | David Lamparter <equinox@diac24.net> | 2017-05-09 17:54:46 +0200 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-05-09 17:54:46 +0200 | 
| commit | feaa866a4c591dfd9bbe60463d1eeef10b7e206b (patch) | |
| tree | d02844e9cadb6dc2dda2afa251a7fb20d88c6b10 /lib | |
| parent | 76dfee9873c1d65c2cbbf6dfeb5ac2df87ca339b (diff) | |
| parent | dfe536f475a79e899cf2915a3ba602c92aee2263 (diff) | |
Merge pull request #469 from qlyoung/fix-list-perm-3.0
lib: fix 'list permutations' (3.0)
Diffstat (limited to 'lib')
| -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 993d6f9055..43b2c478a0 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));  }  | 
