Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Foundation/include/Poco/NumericString.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ template <typename I>
const char* start = begin;
if (*start == '+') ++start;
if (start >= end) return false; // reject bare sign without digits
if (start != begin && *start == '-') return false; // reject a sign after '+'

// Try std::from_chars -- handles sign, overflow, and all bases.
const auto [ptr, ec] = std::from_chars(start, end, outResult, base);
Expand Down
6 changes: 6 additions & 0 deletions Foundation/testsuite/src/NumberParserTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,12 @@ void NumberParserTest::testParseError()
failmsg("must throw SyntaxException");
} catch (SyntaxException&) { }

try
{
(void) NumberParser::parse("+-123");
failmsg("must throw SyntaxException");
} catch (SyntaxException&) { }

try
{
(void) NumberParser::parseUnsigned("-123");
Expand Down
2 changes: 2 additions & 0 deletions Foundation/testsuite/src/StringTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ class StringTest: public CppUnit::TestCase

assertFalse (Poco::strToInt("1,000", result, 0x10));
assertFalse (Poco::strToInt("ABCDEFG", result, 0x10));
assertFalse (Poco::strToInt("+-123", result, 10));
assertFalse (Poco::strToInt("+-123", result, 0x10));
}

template <typename Larger, typename Smaller>
Expand Down
Loading