summaryrefslogtreecommitdiffstats
path: root/lib/command_match.c
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@opensourcerouting.org>2016-12-16 22:30:36 +0100
committerDavid Lamparter <equinox@opensourcerouting.org>2017-01-23 21:52:43 +0100
commit0bf5b1cbe3812e748d459fa4c4fb6596e072e7bd (patch)
tree192e6f292edc83b74016c74547a3cd76101710b2 /lib/command_match.c
parentlib: parser: free Mr. T (diff)
downloadfrr-0bf5b1cbe3812e748d459fa4c4fb6596e072e7bd.tar.xz
frr-0bf5b1cbe3812e748d459fa4c4fb6596e072e7bd.zip
lib: parser: simplify OPTION_TKN & SELECTOR_TKN
These are functionally identical as "fork" tokens. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'lib/command_match.c')
-rw-r--r--lib/command_match.c36
1 files changed, 17 insertions, 19 deletions
diff --git a/lib/command_match.c b/lib/command_match.c
index d22856324..c3eec53bb 100644
--- a/lib/command_match.c
+++ b/lib/command_match.c
@@ -459,7 +459,7 @@ command_complete (struct graph *graph,
/**
* Adds all children that are reachable by one parser hop to the given list.
- * NUL_TKN, SELECTOR_TKN, and OPTION_TKN nodes are treated as transparent.
+ * special tokens except END_TKN are treated as transparent.
*
* @param[in] list to add the nexthops to
* @param[in] node to start calculating nexthops from
@@ -490,26 +490,24 @@ add_nexthops (struct list *list, struct graph_node *node,
if (j != stackpos)
continue;
}
- switch (token->type)
+ if (token->type >= SPECIAL_TKN && token->type != END_TKN)
{
- case OPTION_TKN:
- case SELECTOR_TKN:
- case NUL_TKN:
- added += add_nexthops (list, child, stack, stackpos);
- break;
- default:
- if (stack)
- {
- nextstack = XMALLOC (MTYPE_CMD_MATCHSTACK,
- (stackpos + 1) * sizeof(struct graph_node *));
- nextstack[0] = child;
- memcpy(nextstack + 1, stack, stackpos * sizeof(struct graph_node *));
+ added += add_nexthops (list, child, stack, stackpos);
+ }
+ else
+ {
+ if (stack)
+ {
+ nextstack = XMALLOC (MTYPE_CMD_MATCHSTACK,
+ (stackpos + 1) * sizeof(struct graph_node *));
+ nextstack[0] = child;
+ memcpy(nextstack + 1, stack, stackpos * sizeof(struct graph_node *));
- listnode_add (list, nextstack);
- }
- else
- listnode_add (list, child);
- added++;
+ listnode_add (list, nextstack);
+ }
+ else
+ listnode_add (list, child);
+ added++;
}
}