Skip to content
Permalink
Browse files

fix interpretation of numeric constants in scientic notation (fixes #…

  • Loading branch information
jef-n committed Oct 22, 2014
1 parent 99c5c10 commit d833c22b46acee450d6617621c01c156437dcf59
Showing with 7 additions and 4 deletions.
  1. +4 −4 src/core/qgsexpressionlexer.ll
  2. +3 −0 tests/src/core/testqgsexpression.cpp
@@ -110,7 +110,7 @@ column_ref_quoted "\""{col_str_char}*"\""
dig [0-9]
num_int {dig}+
num_float {dig}*\.{dig}+([eE][-+]?{dig}+)?
num_float {dig}*(\.{dig}+([eE][-+]?{dig}+)?|[eE][-+]?{dig}+)
str_char ('')|(\\.)|[^'\\]
string "'"{str_char}*"'"
@@ -159,14 +159,14 @@ string "'"{str_char}*"'"
"," { return COMMA; }
{num_float} { yylval->numberFloat = cLocale.toDouble( QString::fromAscii(yytext) ); return NUMBER_FLOAT; }
{num_float} { yylval->numberFloat = cLocale.toDouble( QString::fromAscii(yytext) ); return NUMBER_FLOAT; }
{num_int} {
bool ok;
yylval->numberInt = cLocale.toInt( QString::fromAscii(yytext), &ok, 10 );
yylval->numberInt = cLocale.toInt( QString::fromAscii(yytext), &ok, 10 );
if( ok )
return NUMBER_INT;
yylval->numberFloat = cLocale.toDouble( QString::fromAscii(yytext), &ok );
yylval->numberFloat = cLocale.toDouble( QString::fromAscii(yytext), &ok );
if( ok )
return NUMBER_FLOAT;
@@ -148,6 +148,9 @@ class TestQgsExpression: public QObject
QTest::newRow( "literal int" ) << "123" << false << QVariant( 123 );
QTest::newRow( "literal double" ) << "1.2" << false << QVariant( 1.2 );
QTest::newRow( "literal text" ) << "'hello'" << false << QVariant( "hello" );
QTest::newRow( "literal double" ) << ".000001" << false << QVariant( 0.000001 );
QTest::newRow( "literal double" ) << "1.0e-6" << false << QVariant( 0.000001 );
QTest::newRow( "literal double" ) << "1e-6" << false << QVariant( 0.000001 );

// unary minus
QTest::newRow( "unary minus double" ) << "-1.3" << false << QVariant( -1.3 );

0 comments on commit d833c22

Please sign in to comment.
You can’t perform that action at this time.