From a186b9a33ceb2f19184eed7ab97c91e902f42399 Mon Sep 17 00:00:00 2001 From: Frank Mori Hess Date: Mon, 28 Aug 2006 22:59:42 +0000 Subject: [PATCH] Fix parsing of floating point values in exponential notation, and numbers with a leading + or - sign (untested). --- lib/calib_lex.l | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/calib_lex.l b/lib/calib_lex.l index a3e9335..e3ac508 100644 --- a/lib/calib_lex.l +++ b/lib/calib_lex.l @@ -69,13 +69,10 @@ softcal_to_phys {return T_SOFTCAL_TO_PHYS;} softcal_from_phys {return T_SOFTCAL_FROM_PHYS;} => { return ( T_ASSIGN ); }; -(0[xX])?(00)?[0-9a-fA-F]+ {calib_lvalp->ival = strtol(calib_yyget_text(yyscanner), NULL, 0); +[+-]?(0[xX])?[0-9a-fA-F]+ {calib_lvalp->ival = strtol(calib_yyget_text(yyscanner), NULL, 0); return( T_NUMBER ); } -[0-9]+\.*[0-9]* { calib_lvalp->dval = strtod(calib_yyget_text(yyscanner), 0); - return( T_FLOAT ); } - -[0-9]*\.*[0-9]+ { calib_lvalp->dval = strtod(calib_yyget_text(yyscanner), 0); +[+-]?(([0-9]+\.?[0-9]*)|([0-9]*\.?[0-9]+))([eE][+-]?[0-9]+)? { calib_lvalp->dval = strtod(calib_yyget_text(yyscanner), 0); return( T_FLOAT ); } [ \t] -- 2.26.2