%empty was added in bison 2.7.1, which seems to not be available on some
of the BSDs by default.
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Fix a few memory issues:
* Not freeing tab-completions upon input match failure
* Invalid write when null-terminating tab-completions
* Not freeing argv[] itself in additinon to elements
* Use XFREE() instead of free() as appropriate
* Not freeing final token of an [option] during parsing
Make a few minor changes to CLI internals:
* Improve documentation on matching & completion functions
* Only make one copy of cmd_token's when building argv,
instead of three
* Don't make a copy of the matching cmd_element
Make one major(ish) change to CLI internals:
* Change all pointers to struct cmd_element to const
Code outside of the core CLI units should never have an
occasion to modify the internal state of the command system.
Doing so could easily amount to having a CLI interface that
changes during runtime, and could conceivably lead to security
issues. Explicitly disallowing this removes any chance of
confusion.
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Each token now knows whether it is part of a hidden
or deprecated command. Command completion logic hides
such tokens when generating completions. Command
matching logic works as before and will still match on
hidden and deprecated commands.
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Shotgun commit:
* Remove shim sources from Makefile.am
* Move new types to command.c / command.h
* Rewrite command.c / command.h
* Refactor shim types to real types in matcher
and parser
* Initial refactor pass on vty.c
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Selectors may be nested inside options [<like|so>].
Removed the ability to make multipart options [like|so].
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Comparing the wrong nodes led to duplication during
graph construction, fixed. Also update graph pretty
print to use new graph struct.
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
- cmd_make_strvec returns null pointer if str
begins with a '#'
- disallow options nested options
- NULL out state variable in parser
- flip backwards comparison
- fix memory leak in lexer
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Gnu-style code, add copyright headers, cleanup some
random style issues, shuffle around code into
relevant units, add docs.
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Makes ranges where both endpoints are negative
somewhat more readable. Also validate ranges.
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Variables now allow strings beginning with numbers
to match, ranges and numbers are now long long to
fix OOB parses resulting in integer wraparounds.
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
When building argv for matched command, only the
last node was being copied to argv; the rest were
added by reference. Additionally the regex for
certain tokens was too restrictive and disallowed
characters allowed by the old parser; these have
been reinstated.
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Various memory leaks have been fixed and the quagga
memory macros are in use. Also consolidated the argv
and matching code into one graph traversal.
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Queries may be run against DFA's to find matching
cmd_element, and argument lists may be constructed.
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Introduce new node type, END_GN, and remove
is_leaf flags. Reorganize command_match.c & remove
internal functions from command_match.h. Start
rewriting command.h in command_new.h with changes
for new backend.
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>