summaryrefslogtreecommitdiff
path: root/lib/command_parse.y
diff options
context:
space:
mode:
authorQuentin Young <qlyoung@cumulusnetworks.com>2016-08-04 16:39:15 +0000
committerQuentin Young <qlyoung@cumulusnetworks.com>2016-08-04 16:39:15 +0000
commitef955a80a635f5fb821a640f7e1d7aaac8ec5e5e (patch)
tree8320bcdb4b0f2ef96dac5925e4206135cb24a75f /lib/command_parse.y
parent5a8bbed0b1e9b22526fd23946593f47487709497 (diff)
lib: Allow optional whitespace in ranges
Makes ranges where both endpoints are negative somewhat more readable. Also validate ranges. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Diffstat (limited to 'lib/command_parse.y')
-rw-r--r--lib/command_parse.y6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/command_parse.y b/lib/command_parse.y
index 9d7432ca40..0ea8744346 100644
--- a/lib/command_parse.y
+++ b/lib/command_parse.y
@@ -206,7 +206,11 @@ placeholder_token:
// get the numbers out
$$->min = strtoimax( yylval.string+1, &yylval.string, 10 );
- $$->max = strtoimax( yylval.string+1, &yylval.string, 10 );
+ strsep (&yylval.string, "-");
+ $$->max = strtoimax( yylval.string, &yylval.string, 10 );
+
+ // validate range
+ if ($$->min >= $$->max) yyerror("Invalid range.");
free ($1);
}