diff options
| author | Donald Sharp <sharpd@cumulusnetworks.com> | 2017-01-25 07:49:21 -0500 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-01-25 07:49:21 -0500 | 
| commit | d2ce19c9b5e2a707dd5620dc6bb3cb8562a06261 (patch) | |
| tree | e2633fa53dfdaa08c4d4eb59bcec754225de280f /lib/command_match.c | |
| parent | 9ffaae7a4f175db9f2ad907d2f423c24277bbf70 (diff) | |
| parent | 8fd8881c2951f166ca55095e0c01a9820a714e08 (diff) | |
Merge pull request #105 from opensourcerouting/cli_merge_step_prep
Prepare for split-off cli parser "merge" step
Diffstat (limited to 'lib/command_match.c')
| -rw-r--r-- | lib/command_match.c | 36 | 
1 files changed, 17 insertions, 19 deletions
diff --git a/lib/command_match.c b/lib/command_match.c index aa58313134..bbd9cd091d 100644 --- a/lib/command_match.c +++ b/lib/command_match.c @@ -458,7 +458,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 @@ -489,26 +489,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++;          }      }  | 
