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