[sr-dev] git:alexh/master: core: allow negative decimal numbers in configuration file parser

Andrei Pelinescu-Onciul andrei at iptel.org
Fri Sep 2 15:15:55 CEST 2011


On Aug 08, 2011 at 11:11, Alex Hermann <alex at speakup.nl> wrote:
> Module: sip-router
> Branch: alexh/master
> Commit: 99f314429cea4341240836e9c9d62c38176eae12
> URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=99f314429cea4341240836e9c9d62c38176eae12
> 
> Author: Alex Hermann <alex at speakup.nl>
> Committer: Alex Hermann <alex at speakup.nl>
> Date:   Fri Aug  5 15:32:14 2011 +0200
> 
> core: allow negative decimal numbers in configuration file parser


You should use intno for that (defined inside cfg.y).
The problem with adding '-' to DECNUMBER is that in most of cfg.y the
assumption is that NUMBER is >= 0 and it will also probably interfere
with subtraction ( e.g. $a - 1 will be parsed as $a (-1) => error).

Andrei

> 
> ---
> 
>  cfg.lex |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/cfg.lex b/cfg.lex
> index ff35a8a..ecf92db 100644
> --- a/cfg.lex
> +++ b/cfg.lex
> @@ -525,7 +525,7 @@ NUM_ID		{ALPHANUM}+
>  HEX			[0-9a-fA-F]
>  HEXNUMBER	0x{HEX}+
>  OCTNUMBER	0[0-7]+
> -DECNUMBER       0|([1-9]{DIGIT}*)
> +DECNUMBER       0|(-?[1-9]{DIGIT}*)
>  BINNUMBER       [0-1]+b
>  HEX4		{HEX}{1,4}
>  IPV6ADDR	({HEX4}":"){7}{HEX4}|({HEX4}":"){1,7}(":"{HEX4}){1,7}|":"(":"{HEX4}){1,7}|({HEX4}":"){1,7}":"|"::"
> 
> 
> _______________________________________________
> sr-dev mailing list
> sr-dev at lists.sip-router.org
> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev



More information about the sr-dev mailing list