X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdePkg%2FLibrary%2FBasePrintLib%2FPrintLibInternal.c;h=8f417fbf11489f4c9c18955b75706e087616c0e5;hb=cf93f221c66e7ff5870d7ce6386608d0b7cf741c;hp=06c220692e1ea6d88b147352a6128abca1948987;hpb=8960cdebac8c75f13f1cb6afa932f0ae323a138b;p=mirror_edk2.git diff --git a/MdePkg/Library/BasePrintLib/PrintLibInternal.c b/MdePkg/Library/BasePrintLib/PrintLibInternal.c index 06c220692e..8f417fbf11 100644 --- a/MdePkg/Library/BasePrintLib/PrintLibInternal.c +++ b/MdePkg/Library/BasePrintLib/PrintLibInternal.c @@ -92,7 +92,7 @@ BasePrintLibValueToString ( Converts the decimal number specified by Value to a Null-terminated string specified by Buffer containing at most Width characters. If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed. - The total number of characters placed in Buffer is returned. + The number of characters in Buffer is returned not including the Null-terminator. If the conversion contains more than Width characters, then only the first Width characters are returned, and the total number of characters required to perform the conversion is returned. @@ -117,10 +117,10 @@ BasePrintLibValueToString ( @param Flags The bitmask of flags that specify left justification, zero pad, and commas. @param Value The 64-bit signed value to convert to a string. - @param Width The maximum number of characters to place in Buffer. + @param Width The maximum number of characters to place in Buffer. @param Increment Character increment in Buffer. - @return Total number of characters required to perform the conversion. + @return The number of characters in Buffer not including the Null-terminator. **/ UINTN @@ -158,6 +158,7 @@ BasePrintLibConvertValueToString ( if (Value < 0) { Value = -Value; Buffer = BasePrintLibFillBuffer (Buffer, 1, '-', Increment); + Width--; } Count = BasePrintLibValueToString (ValueBuffer, Value, 10); @@ -166,7 +167,10 @@ BasePrintLibConvertValueToString ( Buffer = BasePrintLibFillBuffer (Buffer, Width - Count, '0', Increment); } - Digits = 3 - (Count % 3); + Digits = Count % 3; + if (Digits != 0) { + Digits = 3 - Digits; + } for (Index = 0; Index < Count; Index++) { Buffer = BasePrintLibFillBuffer (Buffer, 1, ValueBuffer[Count - Index], Increment); if ((Flags & COMMA_TYPE) != 0) { @@ -180,7 +184,7 @@ BasePrintLibConvertValueToString ( } } - Buffer = BasePrintLibFillBuffer (Buffer, 1, 0, Increment); + BasePrintLibFillBuffer (Buffer, 1, 0, Increment); return ((Buffer - OriginalBuffer) / Increment); }