]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/BasePrintLib/PrintLibInternal.c
Remove some junk informatin.
[mirror_edk2.git] / MdePkg / Library / BasePrintLib / PrintLibInternal.c
index 06c220692e1ea6d88b147352a6128abca1948987..8f417fbf11489f4c9c18955b75706e087616c0e5 100644 (file)
@@ -92,7 +92,7 @@ BasePrintLibValueToString (
   Converts the decimal number specified by Value to a Null-terminated  \r
   string specified by Buffer containing at most Width characters.\r
   If Width is 0 then a width of  MAXIMUM_VALUE_CHARACTERS is assumed.\r
-  The total number of characters placed in Buffer is returned.\r
+  The number of characters in Buffer is returned not including the Null-terminator.\r
   If the conversion contains more than Width characters, then only the first\r
   Width characters are returned, and the total number of characters \r
   required to perform the conversion is returned.\r
@@ -117,10 +117,10 @@ BasePrintLibValueToString (
   @param  Flags     The bitmask of flags that specify left justification, zero pad,\r
                     and commas.\r
   @param  Value     The 64-bit signed value to convert to a string.\r
-  @param  Width            The maximum number of characters to place in Buffer.\r
+  @param  Width      The maximum number of characters to place in Buffer.\r
   @param  Increment Character increment in Buffer.\r
   \r
-  @return Total number of characters required to perform the conversion.\r
+  @return The number of characters in Buffer not including the Null-terminator.\r
 \r
 **/\r
 UINTN\r
@@ -158,6 +158,7 @@ BasePrintLibConvertValueToString (
   if (Value < 0) {\r
     Value = -Value;\r
     Buffer = BasePrintLibFillBuffer (Buffer, 1, '-', Increment);\r
+    Width--;\r
   }\r
 \r
   Count = BasePrintLibValueToString (ValueBuffer, Value, 10);\r
@@ -166,7 +167,10 @@ BasePrintLibConvertValueToString (
     Buffer = BasePrintLibFillBuffer (Buffer, Width - Count, '0', Increment);\r
   }\r
 \r
-  Digits = 3 - (Count % 3);\r
+  Digits = Count % 3;\r
+  if (Digits != 0) {\r
+    Digits = 3 - Digits;\r
+  }\r
   for (Index = 0; Index < Count; Index++) {\r
     Buffer = BasePrintLibFillBuffer (Buffer, 1, ValueBuffer[Count - Index], Increment);\r
     if ((Flags & COMMA_TYPE) != 0) {\r
@@ -180,7 +184,7 @@ BasePrintLibConvertValueToString (
     }\r
   }\r
 \r
-  Buffer = BasePrintLibFillBuffer (Buffer, 1, 0, Increment);\r
+  BasePrintLibFillBuffer (Buffer, 1, 0, Increment);\r
 \r
   return ((Buffer - OriginalBuffer) / Increment);\r
 }\r