mirror of
https://github.com/pocoproject/poco.git
synced 2024-12-13 18:45:10 +01:00
fix for NumberParser changes
This commit is contained in:
parent
b083364a94
commit
468f2e029b
@ -19,11 +19,13 @@
|
||||
#include "Poco/Ascii.h"
|
||||
#include "Poco/Token.h"
|
||||
#include "Poco/UTF8Encoding.h"
|
||||
#include "Poco/String.h"
|
||||
#undef min
|
||||
#undef max
|
||||
#include <limits>
|
||||
#include <clocale>
|
||||
#include <istream>
|
||||
#include <iostream>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
@ -407,9 +409,11 @@ void Parser::parseBuffer()
|
||||
case JSON_T_INTEGER:
|
||||
{
|
||||
#if defined(POCO_HAVE_INT64)
|
||||
std::string numStr(_parseBuffer.begin(), _parseBuffer.size());
|
||||
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 (value > std::numeric_limits<int>::max()
|
||||
|| value < std::numeric_limits<int>::min() )
|
||||
@ -424,7 +428,7 @@ void Parser::parseBuffer()
|
||||
// try to handle error as unsigned in case of overflow
|
||||
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 ( value > std::numeric_limits<unsigned>::max() )
|
||||
{
|
||||
@ -438,13 +442,13 @@ void Parser::parseBuffer()
|
||||
#else
|
||||
try
|
||||
{
|
||||
int value = NumberParser::parse(std::string(_parseBuffer.begin(), _parseBuffer.size()));
|
||||
int value = NumberParser::parse(numStr);
|
||||
_pHandler->value(value);
|
||||
}
|
||||
// try to handle error as unsigned in case of overflow
|
||||
catch ( const SyntaxException& )
|
||||
{
|
||||
unsigned value = NumberParser::parseUnsigned(std::string(_parseBuffer.begin(), _parseBuffer.size()));
|
||||
unsigned value = NumberParser::parseUnsigned(numStr);
|
||||
_pHandler->value(value);
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user