]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/BasePrintLib/PrintLib.c
DebugLib:
[mirror_edk2.git] / MdePkg / Library / BasePrintLib / PrintLib.c
index 1484d891b63f284ba6df8e31f620ea5d8822208c..d33f49d3882aa32f08541cd361e2176ef162e6cc 100644 (file)
@@ -57,17 +57,17 @@ STATIC CONST CHAR8 *StatusString [] = {
 \r
   VSPrint function to process format and place the results in Buffer. Since a \r
   VA_LIST is used this rountine allows the nesting of Vararg routines. Thus \r
-  this is the main print working routine\r
+  this is the main print working routine.\r
 \r
   @param  Buffer      Character buffer to print the results of the parsing\r
                       of Format into.\r
   @param  BufferSize  Maximum number of characters to put into buffer.\r
   @param  Flags       Intial flags value.\r
-                      Can only have FORMAT_UNICODE and OUTPUT_UNICODE set\r
+                      Can only have FORMAT_UNICODE and OUTPUT_UNICODE set.\r
   @param  Format      Null-terminated format string.\r
   @param  Marker      Vararg list consumed by processing Format.\r
 \r
-  @return Number of characters printed.\r
+  @return Number of characters printed not including the Null-terminator.\r
 \r
 **/\r
 UINTN\r
@@ -127,8 +127,8 @@ BasePrintLibVSPrint (
     FormatMask = 0xffff;\r
   } else {\r
     //\r
-    // Make sure format string cannot contain more than PcdMaximumUnicodeStringLength\r
-    // Ascii characters if PcdMaximumUnicodeStringLength is not zero. \r
+    // Make sure format string cannot contain more than PcdMaximumAsciiStringLength\r
+    // Ascii characters if PcdMaximumAsciiStringLength is not zero. \r
     //\r
     ASSERT (AsciiStrSize (Format) != 0);\r
     BytesPerFormatCharacter = 1;\r
@@ -506,7 +506,7 @@ BasePrintLibVSPrint (
     // Output the Prefix character if it is present\r
     //\r
     Index = 0;\r
-    if (Prefix) {\r
+    if (Prefix != 0) {\r
       Index++;\r
     }\r
 \r
@@ -557,18 +557,17 @@ BasePrintLibVSPrint (
   //\r
   // Null terminate the Unicode or ASCII string\r
   //\r
-  Buffer = BasePrintLibFillBuffer (Buffer, 1, 0, BytesPerOutputCharacter);\r
+  BasePrintLibFillBuffer (Buffer, 1, 0, BytesPerOutputCharacter);\r
   //\r
   // Make sure output buffer cannot contain more than PcdMaximumUnicodeStringLength\r
   // Unicode characters if PcdMaximumUnicodeStringLength is not zero. \r
   //\r
   ASSERT ((((Flags & OUTPUT_UNICODE) == 0)) || (StrSize ((CHAR16 *) OriginalBuffer) != 0));\r
   //\r
-  // Make sure output buffer cannot contain more than PcdMaximumUnicodeStringLength\r
-  // Ascii characters if PcdMaximumUnicodeStringLength is not zero. \r
+  // Make sure output buffer cannot contain more than PcdMaximumAsciiStringLength\r
+  // ASCII characters if PcdMaximumAsciiStringLength is not zero. \r
   //\r
   ASSERT ((((Flags & OUTPUT_UNICODE) != 0)) || (AsciiStrSize (OriginalBuffer) != 0));\r
-   \r
 \r
   return ((Buffer - OriginalBuffer) / BytesPerOutputCharacter);\r
 }\r
@@ -579,7 +578,7 @@ BasePrintLibVSPrint (
 \r
   VSPrint function to process format and place the results in Buffer. Since a \r
   VA_LIST is used this rountine allows the nesting of Vararg routines. Thus \r
-  this is the main print working routine\r
+  this is the main print working routine.\r
 \r
   @param  Buffer        Character buffer to print the results of the parsing\r
                         of Format into.\r
@@ -589,7 +588,7 @@ BasePrintLibVSPrint (
                         Can only have FORMAT_UNICODE and OUTPUT_UNICODE set\r
   @param  FormatString  Null-terminated format string.\r
 \r
-  @return Number of characters printed.\r
+  @return Number of characters printed not including the Null-terminator.\r
 \r
 **/\r
 UINTN\r
@@ -616,23 +615,27 @@ BasePrintLibSPrint (
   The Unicode string is produced by parsing the format string specified by FormatString.  \r
   Arguments are pulled from the variable argument list specified by Marker based on the \r
   contents of the format string.  \r
-  The length of the produced output buffer is returned.\r
-  If BufferSize is 0, then no output buffer is produced and 0 is returned.\r
+  The number of Unicode characters in the produced output buffer is returned not including\r
+  the Null-terminator.\r
+  If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.\r
 \r
-  If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT().\r
-  If BufferSize is not 0 and FormatString is NULL, then ASSERT().\r
+  If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().\r
+  If BufferSize > 1 and FormatString is NULL, then ASSERT().\r
   If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than \r
-  PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r
+  PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then\r
+  ASSERT().\r
   If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r
-  contains more than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r
+  contains more than PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  Null-terminator, then ASSERT().\r
 \r
-  @param  StartOfBuffer   APointer to the output buffer for the produced Null-terminated \r
+  @param  StartOfBuffer   A pointer to the output buffer for the produced Null-terminated \r
                           Unicode string.\r
   @param  BufferSize      The size, in bytes, of the output buffer specified by StartOfBuffer.\r
   @param  FormatString    Null-terminated Unicode format string.\r
   @param  Marker          VA_LIST marker for the variable argument list.\r
   \r
-  @return return Length of the produced output buffer.\r
+  @return The number of Unicode characters in the produced output buffer not including the\r
+          Null-terminator.\r
 \r
 **/\r
 UINTN\r
@@ -655,22 +658,26 @@ UnicodeVSPrint (
   and BufferSize.\r
   The Unicode string is produced by parsing the format string specified by FormatString.\r
   Arguments are pulled from the variable argument list based on the contents of the format string.\r
-  The length of the produced output buffer is returned.  \r
-  If BufferSize is 0, then no output buffer is produced and 0 is returned.\r
+  The number of Unicode characters in the produced output buffer is returned not including\r
+  the Null-terminator.\r
+  If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.\r
 \r
-  If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT().\r
-  If BufferSize is not 0 and FormatString is NULL, then ASSERT().\r
+  If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().\r
+  If BufferSize > 1 and FormatString is NULL, then ASSERT().\r
   If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than \r
-  PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r
+  PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then\r
+  ASSERT().\r
   If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r
-  contains more than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r
+  contains more than PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  Null-terminator, then ASSERT().\r
 \r
-  @param  StartOfBuffer   APointer to the output buffer for the produced Null-terminated \r
+  @param  StartOfBuffer   A pointer to the output buffer for the produced Null-terminated \r
                           Unicode string.\r
   @param  BufferSize      The size, in bytes, of the output buffer specified by StartOfBuffer.\r
   @param  FormatString    Null-terminated Unicode format string.\r
   \r
-  @return Length of the produced output buffer.\r
+  @return The number of Unicode characters in the produced output buffer not including the\r
+          Null-terminator.\r
 \r
 **/\r
 UINTN\r
@@ -697,23 +704,27 @@ UnicodeSPrint (
   The Unicode string is produced by parsing the format string specified by FormatString.\r
   Arguments are pulled from the variable argument list specified by Marker based on the \r
   contents of the format string.\r
-  The length of the produced output buffer is returned.\r
-  If BufferSize is 0, then no output buffer is produced and 0 is returned.\r
-\r
-  If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT().\r
-  If BufferSize is not 0 and FormatString is NULL, then ASSERT().\r
-  If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than \r
-  PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r
+  The number of Unicode characters in the produced output buffer is returned not including\r
+  the Null-terminator.\r
+  If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.\r
+\r
+  If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().\r
+  If BufferSize > 1 and FormatString is NULL, then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than\r
+  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then\r
+  ASSERT().\r
   If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r
-  contains more than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r
+  contains more than PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  Null-terminator, then ASSERT().\r
 \r
-  @param  StartOfBuffer   APointer to the output buffer for the produced Null-terminated \r
+  @param  StartOfBuffer   A pointer to the output buffer for the produced Null-terminated \r
                           Unicode string.\r
   @param  BufferSize      The size, in bytes, of the output buffer specified by StartOfBuffer.\r
   @param  FormatString    Null-terminated Unicode format string.\r
   @param  Marker          VA_LIST marker for the variable argument list.\r
   \r
-  @return Length of the produced output buffer.\r
+  @return The number of Unicode characters in the produced output buffer not including the\r
+          Null-terminator.\r
 \r
 **/\r
 UINTN\r
@@ -737,22 +748,26 @@ UnicodeVSPrintAsciiFormat (
   The Unicode string is produced by parsing the format string specified by FormatString.\r
   Arguments are pulled from the variable argument list based on the contents of the \r
   format string.\r
-  The length of the produced output buffer is returned.\r
-  If BufferSize is 0, then no output buffer is produced and 0 is returned.\r
-\r
-  If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT().\r
-  If BufferSize is not 0 and FormatString is NULL, then ASSERT().\r
-  If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than \r
-  PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r
+  The number of Unicode characters in the produced output buffer is returned not including\r
+  the Null-terminator.\r
+  If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.\r
+\r
+  If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().\r
+  If BufferSize > 1 and FormatString is NULL, then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than\r
+  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then\r
+  ASSERT().\r
   If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r
-  contains more than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r
+  contains more than PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  Null-terminator, then ASSERT().\r
 \r
-  @param  StartOfBuffer   APointer to the output buffer for the produced Null-terminated \r
+  @param  StartOfBuffer   A pointer to the output buffer for the produced Null-terminated \r
                           Unicode string.\r
   @param  BufferSize      The size, in bytes, of the output buffer specified by StartOfBuffer.\r
   @param  FormatString    Null-terminated Unicode format string.\r
   \r
-  @return Length of the produced output buffer.\r
+  @return The number of Unicode characters in the produced output buffer not including the\r
+          Null-terminator.\r
 \r
 **/\r
 UINTN\r
@@ -779,23 +794,27 @@ UnicodeSPrintAsciiFormat (
   The ASCII string is produced by parsing the format string specified by FormatString.\r
   Arguments are pulled from the variable argument list specified by Marker based on \r
   the contents of the format string.\r
-  The length of the produced output buffer is returned.\r
+  The number of ASCII characters in the produced output buffer is returned not including\r
+  the Null-terminator.\r
   If BufferSize is 0, then no output buffer is produced and 0 is returned.\r
 \r
-  If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT().\r
-  If BufferSize is not 0 and FormatString is NULL, then ASSERT().\r
-  If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than \r
-  PcdMaximumUnicodeStringLength ASCII characters, then ASSERT().\r
-  If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r
-  contains more than PcdMaximumUnicodeStringLength ASCII characters, then ASSERT().\r
+  If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().\r
+  If BufferSize > 0 and FormatString is NULL, then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than\r
+  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then\r
+  ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string\r
+  contains more than PcdMaximumAsciiStringLength ASCII characters not including the\r
+  Null-terminator, then ASSERT().\r
 \r
-  @param  StartOfBuffer   APointer to the output buffer for the produced Null-terminated \r
+  @param  StartOfBuffer   A pointer to the output buffer for the produced Null-terminated \r
                           ASCII string.\r
   @param  BufferSize      The size, in bytes, of the output buffer specified by StartOfBuffer.\r
   @param  FormatString    Null-terminated Unicode format string.\r
   @param  Marker          VA_LIST marker for the variable argument list.\r
   \r
-  @return Length of the produced output buffer.\r
+  @return The number of ASCII characters in the produced output buffer not including the\r
+          Null-terminator.\r
 \r
 **/\r
 UINTN\r
@@ -819,22 +838,26 @@ AsciiVSPrint (
   The ASCII string is produced by parsing the format string specified by FormatString.\r
   Arguments are pulled from the variable argument list based on the contents of the \r
   format string.\r
-  The length of the produced output buffer is returned.\r
+  The number of ASCII characters in the produced output buffer is returned not including\r
+  the Null-terminator.\r
   If BufferSize is 0, then no output buffer is produced and 0 is returned.\r
 \r
-  If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT().\r
-  If BufferSize is not 0 and FormatString is NULL, then ASSERT().\r
-  If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than \r
-  PcdMaximumUnicodeStringLength ASCII characters, then ASSERT().\r
-  If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r
-  contains more than PcdMaximumUnicodeStringLength ASCII characters, then ASSERT().\r
+  If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().\r
+  If BufferSize > 0 and FormatString is NULL, then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than\r
+  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then\r
+  ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string\r
+  contains more than PcdMaximumAsciiStringLength ASCII characters not including the\r
+  Null-terminator, then ASSERT().\r
 \r
-  @param  StartOfBuffer   APointer to the output buffer for the produced Null-terminated \r
+  @param  StartOfBuffer   A pointer to the output buffer for the produced Null-terminated \r
                           ASCII string.\r
   @param  BufferSize      The size, in bytes, of the output buffer specified by StartOfBuffer.\r
   @param  FormatString    Null-terminated Unicode format string.\r
   \r
-  @return Length of the produced output buffer.\r
+  @return The number of ASCII characters in the produced output buffer not including the\r
+          Null-terminator.\r
 \r
 **/\r
 UINTN\r
@@ -861,23 +884,27 @@ AsciiSPrint (
   The ASCII string is produced by parsing the format string specified by FormatString.\r
   Arguments are pulled from the variable argument list specified by Marker based on \r
   the contents of the format string.\r
-  The length of the produced output buffer is returned.\r
+  The number of ASCII characters in the produced output buffer is returned not including\r
+  the Null-terminator.\r
   If BufferSize is 0, then no output buffer is produced and 0 is returned.\r
 \r
-  If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT().\r
-  If BufferSize is not 0 and FormatString is NULL, then ASSERT().\r
-  If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than \r
-  PcdMaximumUnicodeStringLength ASCII characters, then ASSERT().\r
-  If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r
-  contains more than PcdMaximumUnicodeStringLength ASCII characters, then ASSERT().\r
+  If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().\r
+  If BufferSize > 0 and FormatString is NULL, then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than\r
+  PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then\r
+  ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string\r
+  contains more than PcdMaximumAsciiStringLength ASCII characters not including the\r
+  Null-terminator, then ASSERT().\r
 \r
-  @param  StartOfBuffer   APointer to the output buffer for the produced Null-terminated \r
+  @param  StartOfBuffer   A pointer to the output buffer for the produced Null-terminated \r
                           ASCII string.\r
   @param  BufferSize      The size, in bytes, of the output buffer specified by StartOfBuffer.\r
   @param  FormatString    Null-terminated Unicode format string.\r
   @param  Marker          VA_LIST marker for the variable argument list.\r
   \r
-  @return Length of the produced output buffer.\r
+  @return The number of ASCII characters in the produced output buffer not including the\r
+          Null-terminator.\r
 \r
 **/\r
 UINTN\r
@@ -901,22 +928,26 @@ AsciiVSPrintUnicodeFormat (
   The ASCII string is produced by parsing the format string specified by FormatString.\r
   Arguments are pulled from the variable argument list based on the contents of the \r
   format string.\r
-  The length of the produced output buffer is returned.\r
+  The number of ASCII characters in the produced output buffer is returned not including\r
+  the Null-terminator.\r
   If BufferSize is 0, then no output buffer is produced and 0 is returned.\r
 \r
-  If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT().\r
-  If BufferSize is not 0 and FormatString is NULL, then ASSERT().\r
-  If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than \r
-  PcdMaximumUnicodeStringLength ASCII characters, then ASSERT().\r
-  If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r
-  contains more than PcdMaximumUnicodeStringLength ASCII characters, then ASSERT().\r
+  If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().\r
+  If BufferSize > 0 and FormatString is NULL, then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than\r
+  PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then\r
+  ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string\r
+  contains more than PcdMaximumAsciiStringLength ASCII characters not including the\r
+  Null-terminator, then ASSERT().\r
 \r
-  @param  StartOfBuffer   APointer to the output buffer for the produced Null-terminated \r
+  @param  StartOfBuffer   A pointer to the output buffer for the produced Null-terminated \r
                           ASCII string.\r
   @param  BufferSize      The size, in bytes, of the output buffer specified by StartOfBuffer.\r
   @param  FormatString    Null-terminated Unicode format string.\r
   \r
-  @return Length of the produced output buffer.\r
+  @return The number of ASCII characters in the produced output buffer not including the\r
+          Null-terminator.\r
 \r
 **/\r
 UINTN\r
@@ -940,7 +971,7 @@ AsciiSPrintUnicodeFormat (
   Converts the decimal number specified by Value to a Null-terminated Unicode \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 Unicode 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
@@ -964,9 +995,9 @@ AsciiSPrintUnicodeFormat (
                   Unicode string.\r
   @param  Flags   The bitmask of flags that specify left justification, zero pad, and commas.\r
   @param  Value   The 64-bit signed value to convert to a string.\r
-  @param  Width    The maximum number of Unicode characters to place in Buffer.\r
+  @param  Width   The maximum number of Unicode characters to place in Buffer.\r
   \r
-  @return Total number of characters required to perform the conversion.\r
+  @return The number of Unicode characters in Buffer not including the Null-terminator.\r
 \r
 **/\r
 UINTN\r
@@ -987,7 +1018,7 @@ UnicodeValueToString (
   Converts the decimal number specified by Value to a Null-terminated ASCII string \r
   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 ASCII characters in Buffer is returned not including the Null-terminator.\r
   If the conversion contains more than Width characters, then only the first Width\r
   characters are returned, and the total number of characters required to perform\r
   the conversion is returned.\r
@@ -1011,9 +1042,9 @@ UnicodeValueToString (
                   ASCII string.\r
   @param  Flags   The bitmask of flags that specify left justification, zero pad, and commas.\r
   @param  Value   The 64-bit signed value to convert to a string.\r
-  @param  Width    The maximum number of ASCII characters to place in Buffer.\r
+  @param  Width   The maximum number of ASCII characters to place in Buffer.\r
   \r
-  @return Total number of characters required to perform the conversion.\r
+  @return The number of ASCII characters in Buffer not including the Null-terminator.\r
 \r
 **/\r
 UINTN\r