|
|
@ -121,10 +121,9 @@ namespace plFormat_Private |
|
|
|
spec.fDigitClass = kDigitHexUpper; |
|
|
|
spec.fDigitClass = kDigitHexUpper; |
|
|
|
break; |
|
|
|
break; |
|
|
|
case '+': |
|
|
|
case '+': |
|
|
|
spec.fDigitClass = kDigitDecAlwaysSigned; |
|
|
|
spec.fAlwaysSigned = true; |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 'd': |
|
|
|
case 'd': |
|
|
|
if (spec.fDigitClass != kDigitDecAlwaysSigned) |
|
|
|
|
|
|
|
spec.fDigitClass = kDigitDec; |
|
|
|
spec.fDigitClass = kDigitDec; |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 'o': |
|
|
|
case 'o': |
|
|
@ -265,7 +264,7 @@ static void _formatDecimal(const plFormat_Private::FormatSpec &format, |
|
|
|
if (format_size == 0) |
|
|
|
if (format_size == 0) |
|
|
|
format_size = 1; |
|
|
|
format_size = 1; |
|
|
|
|
|
|
|
|
|
|
|
if (value < 0 || format.fDigitClass == plFormat_Private::kDigitDecAlwaysSigned) |
|
|
|
if (value < 0 || format.fAlwaysSigned) |
|
|
|
++format_size; |
|
|
|
++format_size; |
|
|
|
|
|
|
|
|
|
|
|
hsAssert(format_size < 24, "Format length too long"); |
|
|
|
hsAssert(format_size < 24, "Format length too long"); |
|
|
@ -275,7 +274,7 @@ static void _formatDecimal(const plFormat_Private::FormatSpec &format, |
|
|
|
|
|
|
|
|
|
|
|
if (value < 0) |
|
|
|
if (value < 0) |
|
|
|
buffer[0] = '-'; |
|
|
|
buffer[0] = '-'; |
|
|
|
else if (format.fDigitClass == plFormat_Private::kDigitDecAlwaysSigned) |
|
|
|
else if (format.fAlwaysSigned) |
|
|
|
buffer[0] = '+'; |
|
|
|
buffer[0] = '+'; |
|
|
|
|
|
|
|
|
|
|
|
_formatString(format, output, buffer, format_size, plFormat_Private::kAlignRight); |
|
|
|
_formatString(format, output, buffer, format_size, plFormat_Private::kAlignRight); |
|
|
@ -340,7 +339,6 @@ static void _formatChar(const plFormat_Private::FormatSpec &format, |
|
|
|
_formatNumeric<_utype>(format, output, value, 16, true); \
|
|
|
|
_formatNumeric<_utype>(format, output, value, 16, true); \
|
|
|
|
break; \
|
|
|
|
break; \
|
|
|
|
case plFormat_Private::kDigitDec: \
|
|
|
|
case plFormat_Private::kDigitDec: \
|
|
|
|
case plFormat_Private::kDigitDecAlwaysSigned: \
|
|
|
|
|
|
|
|
case plFormat_Private::kDigitDefault: \
|
|
|
|
case plFormat_Private::kDigitDefault: \
|
|
|
|
_formatDecimal<_stype>(format, output, value); \
|
|
|
|
_formatDecimal<_stype>(format, output, value); \
|
|
|
|
break; \
|
|
|
|
break; \
|
|
|
@ -369,7 +367,6 @@ static void _formatChar(const plFormat_Private::FormatSpec &format, |
|
|
|
_formatNumeric<_utype>(format, output, value, 16, true); \
|
|
|
|
_formatNumeric<_utype>(format, output, value, 16, true); \
|
|
|
|
break; \
|
|
|
|
break; \
|
|
|
|
case plFormat_Private::kDigitDec: \
|
|
|
|
case plFormat_Private::kDigitDec: \
|
|
|
|
case plFormat_Private::kDigitDecAlwaysSigned: \
|
|
|
|
|
|
|
|
case plFormat_Private::kDigitDefault: \
|
|
|
|
case plFormat_Private::kDigitDefault: \
|
|
|
|
_formatDecimal<_utype>(format, output, value); \
|
|
|
|
_formatDecimal<_utype>(format, output, value); \
|
|
|
|
break; \
|
|
|
|
break; \
|
|
|
@ -402,6 +399,10 @@ PL_FORMAT_IMPL(double) |
|
|
|
size_t end = 0; |
|
|
|
size_t end = 0; |
|
|
|
|
|
|
|
|
|
|
|
format_buffer[end++] = '%'; |
|
|
|
format_buffer[end++] = '%'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (format.fAlwaysSigned) |
|
|
|
|
|
|
|
format_buffer[end++] = '+'; |
|
|
|
|
|
|
|
|
|
|
|
if (format.fPrecision >= 0) { |
|
|
|
if (format.fPrecision >= 0) { |
|
|
|
int count = snprintf(format_buffer + end, arrsize(format_buffer) - end, |
|
|
|
int count = snprintf(format_buffer + end, arrsize(format_buffer) - end, |
|
|
|
".%d", format.fPrecision); |
|
|
|
".%d", format.fPrecision); |
|
|
@ -459,7 +460,6 @@ PL_FORMAT_IMPL(char) |
|
|
|
_formatNumeric<unsigned char>(format, output, value, 16, true); |
|
|
|
_formatNumeric<unsigned char>(format, output, value, 16, true); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case plFormat_Private::kDigitDec: |
|
|
|
case plFormat_Private::kDigitDec: |
|
|
|
case plFormat_Private::kDigitDecAlwaysSigned: |
|
|
|
|
|
|
|
_formatDecimal<signed char>(format, output, value); |
|
|
|
_formatDecimal<signed char>(format, output, value); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case plFormat_Private::kDigitChar: |
|
|
|
case plFormat_Private::kDigitChar: |
|
|
@ -488,7 +488,6 @@ PL_FORMAT_IMPL(wchar_t) |
|
|
|
_formatNumeric<uint32_t>(format, output, value, 16, true); |
|
|
|
_formatNumeric<uint32_t>(format, output, value, 16, true); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case plFormat_Private::kDigitDec: |
|
|
|
case plFormat_Private::kDigitDec: |
|
|
|
case plFormat_Private::kDigitDecAlwaysSigned: |
|
|
|
|
|
|
|
_formatDecimal<uint32_t>(format, output, value); |
|
|
|
_formatDecimal<uint32_t>(format, output, value); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case plFormat_Private::kDigitChar: |
|
|
|
case plFormat_Private::kDigitChar: |
|
|
|