]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: Allow optional whitespace in ranges
authorQuentin Young <qlyoung@cumulusnetworks.com>
Thu, 4 Aug 2016 16:39:15 +0000 (16:39 +0000)
committerQuentin Young <qlyoung@cumulusnetworks.com>
Thu, 4 Aug 2016 16:39:15 +0000 (16:39 +0000)
Makes ranges where both endpoints are negative
somewhat more readable. Also validate ranges.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
lib/command_lex.l
lib/command_parse.y

index 0a997de8df11f8b6f2dbd057969cef7b8ef2a83e..47723cbf9161c36b53fff94314f2355e77be13ec 100644 (file)
@@ -11,7 +11,7 @@ IPV6            X:X::X:X
 IPV6_PREFIX     X:X::X:X\/M
 VARIABLE        [A-Z][-_a-zA-Z:0-9]+
 NUMBER          [-|+]?[0-9]{1,20}
-RANGE           \({NUMBER}\-{NUMBER}\)
+RANGE           \({NUMBER}[ ]?\-[ ]?{NUMBER}\)
 
 /* yytext shall be a pointer */
 %pointer
index 9d7432ca40de924cbc0c57f67461d2f6a4db9e98..0ea87443467219436ff67dcb32d626c58247d20a 100644 (file)
@@ -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);
 }