summaryrefslogtreecommitdiffstats
path: root/lib/command_lex.l
diff options
context:
space:
mode:
authorQuentin Young <qlyoung@cumulusnetworks.com>2016-08-09 19:37:01 +0200
committerQuentin Young <qlyoung@cumulusnetworks.com>2016-08-09 19:37:01 +0200
commit4427e9b3eeb6aaff3882dd1e96e14af62fa37ad4 (patch)
tree1cb9919bd6e5b661f8b6900b2510109319ec0e68 /lib/command_lex.l
parentlib: Code cleanup, formatting, & headers (diff)
downloadfrr-4427e9b3eeb6aaff3882dd1e96e14af62fa37ad4.tar.xz
frr-4427e9b3eeb6aaff3882dd1e96e14af62fa37ad4.zip
lib: Fix various minor bugs
- 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>
Diffstat (limited to 'lib/command_lex.l')
-rw-r--r--lib/command_lex.l14
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/command_lex.l b/lib/command_lex.l
index 920c03db8..b3276894f 100644
--- a/lib/command_lex.l
+++ b/lib/command_lex.l
@@ -25,7 +25,9 @@
%{
#include "command_parse.h"
-extern void set_buffer_string(const char *);
+extern void set_lexer_string (const char *);
+extern void cleanup_lexer (void);
+YY_BUFFER_STATE buffer;
%}
WORD (\-|\+)?[a-z\*][-+_a-zA-Z0-9\*]*
@@ -62,7 +64,13 @@ RANGE \({NUMBER}[ ]?\-[ ]?{NUMBER}\)
%%
void
-set_buffer_string(const char *string)
+set_lexer_string (const char *string)
{
- yy_scan_string(string);
+ buffer = yy_scan_string (XSTRDUP(MTYPE_TMP, string));
+}
+
+void
+cleanup_lexer ()
+{
+ yy_delete_buffer (buffer);
}