fix for NumberParser changes

This commit is contained in:
Guenter Obiltschnig 2015-09-09 14:26:26 +02:00
parent b083364a94
commit 468f2e029b

View File

@ -19,11 +19,13 @@
#include "Poco/Ascii.h" #include "Poco/Ascii.h"
#include "Poco/Token.h" #include "Poco/Token.h"
#include "Poco/UTF8Encoding.h" #include "Poco/UTF8Encoding.h"
#include "Poco/String.h"
#undef min #undef min
#undef max #undef max
#include <limits> #include <limits>
#include <clocale> #include <clocale>
#include <istream> #include <istream>
#include <iostream>
namespace Poco { namespace Poco {
@ -407,9 +409,11 @@ void Parser::parseBuffer()
case JSON_T_INTEGER: case JSON_T_INTEGER:
{ {
#if defined(POCO_HAVE_INT64) #if defined(POCO_HAVE_INT64)
std::string numStr(_parseBuffer.begin(), _parseBuffer.size());
try try
{ {
Int64 value = NumberParser::parse64(std::string(_parseBuffer.begin(), _parseBuffer.size())); Poco::trimInPlace(numStr);
Int64 value = NumberParser::parse64(numStr);
// if number is 32-bit, then handle as such // if number is 32-bit, then handle as such
if (value > std::numeric_limits<int>::max() if (value > std::numeric_limits<int>::max()
|| value < std::numeric_limits<int>::min() ) || value < std::numeric_limits<int>::min() )
@ -424,7 +428,7 @@ void Parser::parseBuffer()
// try to handle error as unsigned in case of overflow // try to handle error as unsigned in case of overflow
catch ( const SyntaxException& ) catch ( const SyntaxException& )
{ {
UInt64 value = NumberParser::parseUnsigned64(std::string(_parseBuffer.begin(), _parseBuffer.size())); UInt64 value = NumberParser::parseUnsigned64(numStr);
// if number is 32-bit, then handle as such // if number is 32-bit, then handle as such
if ( value > std::numeric_limits<unsigned>::max() ) if ( value > std::numeric_limits<unsigned>::max() )
{ {
@ -438,13 +442,13 @@ void Parser::parseBuffer()
#else #else
try try
{ {
int value = NumberParser::parse(std::string(_parseBuffer.begin(), _parseBuffer.size())); int value = NumberParser::parse(numStr);
_pHandler->value(value); _pHandler->value(value);
} }
// try to handle error as unsigned in case of overflow // try to handle error as unsigned in case of overflow
catch ( const SyntaxException& ) catch ( const SyntaxException& )
{ {
unsigned value = NumberParser::parseUnsigned(std::string(_parseBuffer.begin(), _parseBuffer.size())); unsigned value = NumberParser::parseUnsigned(numStr);
_pHandler->value(value); _pHandler->value(value);
} }
#endif #endif