Skip to content

Commit 69ec031

Browse files
committed
Find end of integer in the event there's no fractional part
1 parent 287aa2b commit 69ec031

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

include/boost/decimal/detail/locale_conversion.hpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,25 @@ inline int convert_pointer_pair_to_local_locale(char* first, char* last, const s
110110
}
111111
}
112112

113-
const auto int_end {decimal_pos != nullptr ? decimal_pos : last};
113+
// If there is no fractional part we still need to find where the end of the integer is
114+
// We've already inserted a null terminator for ourselves
115+
char* last_digit {start};
116+
if (decimal_pos == nullptr)
117+
{
118+
for (const char* p = start; p < last; ++p)
119+
{
120+
if (*p != '\0')
121+
{
122+
++last_digit;
123+
}
124+
else
125+
{
126+
break;
127+
}
128+
}
129+
}
130+
131+
const auto int_end {decimal_pos != nullptr ? decimal_pos : last_digit};
114132
const auto int_digits {static_cast<int>(int_end - start)};
115133

116134
// Calculate how many separators we need

0 commit comments

Comments
 (0)