Fix parsing of floating point values in exponential notation, and numbers
authorFrank Mori Hess <fmhess@speakeasy.net>
Mon, 28 Aug 2006 22:59:42 +0000 (22:59 +0000)
committerFrank Mori Hess <fmhess@speakeasy.net>
Mon, 28 Aug 2006 22:59:42 +0000 (22:59 +0000)
with a leading + or - sign (untested).

lib/calib_lex.l

index a3e933545e5036661971361a514ff1048e954341..e3ac5085e0d1e8d8ea0669a6fc0459d1476f233d 100644 (file)
@@ -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]