diff options
| author | Quentin Young <qlyoung@users.noreply.github.com> | 2021-09-09 12:22:53 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-09-09 12:22:53 -0400 |
| commit | 32acb4a7adc4e7fcd72b36a124e8ec3929d79e10 (patch) | |
| tree | 59036d4eb3c66e713097fac4308da117011c37d4 /tools | |
| parent | f334c88ed9675eab624728ecd6eaaff3a9b41255 (diff) | |
| parent | 3be280bb8c48de8bb71ad8b193a83a0b4eec4b62 (diff) | |
Merge pull request #9497 from opensourcerouting/cli-better-no
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/permutations.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tools/permutations.c b/tools/permutations.c index f51d4a4ec9..b280cc15b1 100644 --- a/tools/permutations.c +++ b/tools/permutations.c @@ -61,9 +61,22 @@ void permute(struct graph_node *start) struct cmd_token *stok = start->data; struct graph_node *gnn; struct listnode *ln; + bool is_neg = false; // recursive dfs listnode_add(position, start); + + for (ALL_LIST_ELEMENTS_RO(position, ln, gnn)) { + struct cmd_token *tok = gnn->data; + + if (tok->type == WORD_TKN && !strcmp(tok->text, "no")) { + is_neg = true; + break; + } + if (tok->type < SPECIAL_TKN) + break; + } + for (unsigned int i = 0; i < vector_active(start->to); i++) { struct graph_node *gn = vector_slot(start->to, i); struct cmd_token *tok = gn->data; @@ -82,6 +95,9 @@ void permute(struct graph_node *start) fprintf(stdout, "\n"); } else { bool skip = false; + + if (tok->type == NEG_ONLY_TKN && !is_neg) + continue; if (stok->type == FORK_TKN && tok->type != FORK_TKN) for (ALL_LIST_ELEMENTS_RO(position, ln, gnn)) if (gnn == gn) { |
