diff options
author | crupest <crupest@outlook.com> | 2022-03-09 23:18:31 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-03-09 23:18:31 +0800 |
commit | 268bec4cd0d562394c2c27d10a26be1264bc8648 (patch) | |
tree | b8398c35e3b51aa3b91c75612bb46da0a0f2845f /src/common | |
parent | dceef749139061fdac4946df77219f1cc8aa6483 (diff) | |
download | cru-268bec4cd0d562394c2c27d10a26be1264bc8648.tar.gz cru-268bec4cd0d562394c2c27d10a26be1264bc8648.tar.bz2 cru-268bec4cd0d562394c2c27d10a26be1264bc8648.zip |
...
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/StringToNumberConverter.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/common/StringToNumberConverter.cpp b/src/common/StringToNumberConverter.cpp index 259e39b0..d77f7886 100644 --- a/src/common/StringToNumberConverter.cpp +++ b/src/common/StringToNumberConverter.cpp @@ -143,10 +143,21 @@ StringToIntegerConverterImplResult StringToIntegerConverterImpl::Parse( while (current != end && IsSpace(*current)) { current++; } + + if (current != end) { + if (processed_characters_count) { + *processed_characters_count = 0; + } + if (throw_on_error) { + throw Exception(u"There is trailing junk."); + } else { + return {false, 0}; + } + } } - if (current != end) { - throw Exception(u"There is trailing junk."); + if (processed_characters_count) { + *processed_characters_count = current - str; } return {negate, result}; |