aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2022-03-09 23:18:31 +0800
committercrupest <crupest@outlook.com>2022-03-09 23:18:31 +0800
commit268bec4cd0d562394c2c27d10a26be1264bc8648 (patch)
treeb8398c35e3b51aa3b91c75612bb46da0a0f2845f /src/common
parentdceef749139061fdac4946df77219f1cc8aa6483 (diff)
downloadcru-268bec4cd0d562394c2c27d10a26be1264bc8648.tar.gz
cru-268bec4cd0d562394c2c27d10a26be1264bc8648.tar.bz2
cru-268bec4cd0d562394c2c27d10a26be1264bc8648.zip
...
Diffstat (limited to 'src/common')
-rw-r--r--src/common/StringToNumberConverter.cpp15
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};