1
0
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-18 19:29:09 +00:00

Properly handle zero

This commit is contained in:
2014-05-15 23:31:32 -07:00
parent 2048b641d3
commit 1baefdd0f2

View File

@ -190,6 +190,11 @@ namespace plFormat_Private
template <typename _IType, size_t bits>
void _IFormatNumeric_Impl(char *output_end, _IType value, int radix, bool upperCase = false)
{
if (value == 0) {
*(output_end - 1) = '0';
return;
}
while (value)
{
int digit = (value % radix);
@ -218,6 +223,9 @@ static plStringBuffer<char> _formatNumeric(const plFormat_Private::FormatSpec &f
temp /= radix;
}
if (max == 0)
max = 1;
plStringBuffer<char> buffer;
if (format.fPrecisionLeft > max) {
char *output = buffer.CreateWritableBuffer(format.fPrecisionLeft);
@ -252,6 +260,9 @@ static plStringBuffer<char> _formatDecimal(const plFormat_Private::FormatSpec &f
temp /= 10;
}
if (max == 0)
max = 1;
if (value < 0 || format.fDigitClass == plFormat_Private::kDigitDecAlwaysSigned)
++max;