SVN commit 1215994 by trueg: Better detection for number literals M +15 -10 queryparser.cpp --- trunk/KDE/kdelibs/nepomuk/query/queryparser.cpp #1215993:1215994 @@ -1,6 +1,6 @@ /* This file is part of the Nepomuk KDE project. - Copyright (C) 2007-2010 Sebastian Trueg + Copyright (C) 2007-2011 Sebastian Trueg This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -99,21 +99,26 @@ } Soprano::LiteralValue createLiteral( const QString& s, bool globbing ) { + // 1. check if it is a number + QString clearString(s); + clearString.remove(QLatin1Char('\'')); + clearString.remove(QLatin1Char('"')); + bool b = false; + int i = clearString.toInt( &b ); + if ( b ) + return Soprano::LiteralValue( i ); + double d = clearString.toDouble( &b ); + if ( b ) + return Soprano::LiteralValue( d ); + + // 2. no number - continue with the original string + // no globbing if we have quotes or if there already is a wildcard if ( s[0] == QLatin1Char('\'') || s[0] == QLatin1Char('\"') ) { return s; } - // at this point we should have a string without spaces in it - bool b = false; - int i = s.toInt( &b ); - if ( b ) - return Soprano::LiteralValue( i ); - double d = s.toDouble( &b ); - if ( b ) - return Soprano::LiteralValue( d ); - // // we can only do query term globbing for strings longer than 3 chars //