From eceb3a4cb9b97d331ba91ea0a930465c05e8e20b Mon Sep 17 00:00:00 2001 From: lgao4 Date: Tue, 15 Jul 2008 11:12:43 +0000 Subject: Code scrub for the Debug library, PostCode library, Print library, and ExtractGuidedSection library. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5478 6f19259b-4bc3-4df7-8a09-765794883524 --- MdePkg/Library/BasePrintLib/BasePrintLib.inf | 4 +- MdePkg/Library/BasePrintLib/PrintLib.c | 30 +++++++------ MdePkg/Library/BasePrintLib/PrintLibInternal.c | 58 +++++++++++++++++++------- MdePkg/Library/BasePrintLib/PrintLibInternal.h | 26 ++++++------ 4 files changed, 74 insertions(+), 44 deletions(-) (limited to 'MdePkg/Library/BasePrintLib') diff --git a/MdePkg/Library/BasePrintLib/BasePrintLib.inf b/MdePkg/Library/BasePrintLib/BasePrintLib.inf index 0a03cd71cf..1f3844b384 100644 --- a/MdePkg/Library/BasePrintLib/BasePrintLib.inf +++ b/MdePkg/Library/BasePrintLib/BasePrintLib.inf @@ -1,8 +1,8 @@ #/** @file # Component description file for Base Print Library. # -# Print Library implementation. -# Copyright (c) 2007, Intel Corporation. +# Base Print Library instance implementation. +# Copyright (c) 2007 - 2008, Intel Corporation. # # All rights reserved. This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License diff --git a/MdePkg/Library/BasePrintLib/PrintLib.c b/MdePkg/Library/BasePrintLib/PrintLib.c index 548ec5490f..c2f1b5119c 100644 --- a/MdePkg/Library/BasePrintLib/PrintLib.c +++ b/MdePkg/Library/BasePrintLib/PrintLib.c @@ -1,7 +1,7 @@ /** @file - Print Library. + Base Print Library instance implementation. - Copyright (c) 2006 - 2007, Intel Corporation
+ Copyright (c) 2006 - 2008, Intel Corporation
All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -23,7 +23,7 @@ #define ERROR_STATUS_NUMBER 24 #define ASSERT_UNICODE_BUFFER(Buffer) ASSERT ((((UINTN) (Buffer)) & 0x01) == 0) -GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 *StatusString [] = { +GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 *gStatusString[] = { "Success", // RETURN_SUCCESS = 0 "Warning Unknown Glyph", // RETURN_WARN_UNKNOWN_GLYPH = 1 "Warning Delete Failure", // RETURN_WARN_DELETE_FAILURE = 2 @@ -424,12 +424,12 @@ BasePrintLibVSPrint ( // Index = Status & ~MAX_BIT; if (Index > 0 && Index <= ERROR_STATUS_NUMBER) { - ArgumentString = StatusString [Index + WARNING_STATUS_NUMBER]; + ArgumentString = gStatusString [Index + WARNING_STATUS_NUMBER]; } } else { Index = Status; if (Index <= WARNING_STATUS_NUMBER) { - ArgumentString = StatusString [Index]; + ArgumentString = gStatusString [Index]; } } if (ArgumentString == ValueBuffer) { @@ -583,13 +583,14 @@ BasePrintLibVSPrint ( VA_LIST is used this rountine allows the nesting of Vararg routines. Thus this is the main print working routine. - @param Buffer Character buffer to print the results of the parsing + @param StartOfBuffer Character buffer to print the results of the parsing of Format into. @param BufferSize Maximum number of characters to put into buffer. Zero means no limit. @param Flags Intial flags value. Can only have FORMAT_UNICODE and OUTPUT_UNICODE set @param FormatString Null-terminated format string. + @param ... The variable argument list. @return Number of characters printed not including the Null-terminator. @@ -684,7 +685,7 @@ UnicodeVSPrint ( Unicode string. @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. @param FormatString Null-terminated Unicode format string. - + @param ... The variable argument list. @return The number of Unicode characters in the produced output buffer not including the Null-terminator. @@ -730,7 +731,7 @@ UnicodeSPrint ( @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated Unicode string. @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. - @param FormatString Null-terminated Unicode format string. + @param FormatString Null-terminated ASCII format string. @param Marker VA_LIST marker for the variable argument list. @return The number of Unicode characters in the produced output buffer not including the @@ -776,7 +777,8 @@ UnicodeVSPrintAsciiFormat ( @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated Unicode string. @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. - @param FormatString Null-terminated Unicode format string. + @param FormatString Null-terminated ASCII format string. + @param ... The variable argument list. @return The number of Unicode characters in the produced output buffer not including the Null-terminator. @@ -876,7 +878,7 @@ UnicodeValueToString ( @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated ASCII string. @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. - @param FormatString Null-terminated Unicode format string. + @param FormatString Null-terminated ASCII format string. @param Marker VA_LIST marker for the variable argument list. @return The number of ASCII characters in the produced output buffer not including the @@ -920,7 +922,8 @@ AsciiVSPrint ( @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated ASCII string. @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. - @param FormatString Null-terminated Unicode format string. + @param FormatString Null-terminated ASCII format string. + @param ... The variable argument list. @return The number of ASCII characters in the produced output buffer not including the Null-terminator. @@ -943,7 +946,7 @@ AsciiSPrint ( /** Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated - ASCII format string and a VA_LIST argument list. + Unicode format string and a VA_LIST argument list. Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer and BufferSize. @@ -989,7 +992,7 @@ AsciiVSPrintUnicodeFormat ( /** Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated - ASCII format string and variable argument list. + Unicode format string and variable argument list. Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer and BufferSize. @@ -1014,6 +1017,7 @@ AsciiVSPrintUnicodeFormat ( ASCII string. @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. @param FormatString Null-terminated Unicode format string. + @param ... The variable argument list. @return The number of ASCII characters in the produced output buffer not including the Null-terminator. diff --git a/MdePkg/Library/BasePrintLib/PrintLibInternal.c b/MdePkg/Library/BasePrintLib/PrintLibInternal.c index 4a9b15fec1..572819e041 100644 --- a/MdePkg/Library/BasePrintLib/PrintLibInternal.c +++ b/MdePkg/Library/BasePrintLib/PrintLibInternal.c @@ -1,7 +1,7 @@ /** @file - Print Library worker functions. + Print Library internal worker functions. - Copyright (c) 2006 - 2007, Intel Corporation
+ Copyright (c) 2006 - 2008, Intel Corporation
All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -34,16 +34,16 @@ GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 mHexStr[] = {'0','1','2','3','4','5',' @param Character Character to be placed into Buffer. @param Increment Character increment in Buffer. - @return Number of characters printed. + @return Buffer Buffer filled with the input Character. **/ CHAR8 * BasePrintLibFillBuffer ( - CHAR8 *Buffer, - CHAR8 *EndBuffer, - INTN Length, - UINTN Character, - INTN Increment + OUT CHAR8 *Buffer, + IN CHAR8 *EndBuffer, + IN INTN Length, + IN UINTN Character, + IN INTN Increment ) { INTN Index; @@ -69,7 +69,6 @@ BasePrintLibFillBuffer ( **/ UINTN -EFIAPI BasePrintLibValueToString ( IN OUT CHAR8 *Buffer, IN INT64 Value, @@ -89,6 +88,10 @@ BasePrintLibValueToString ( *(Buffer++) = mHexStr[Remainder]; Digits++; } while (Value != 0); + + // + // the length of Buffer string converted from Value + // return Digits; } @@ -149,6 +152,9 @@ BasePrintLibConvertValueToString ( UINTN Index; UINTN Radix; + // + // Make sure Buffer is not NULL and Width < MAXIMUM + // ASSERT (Buffer != NULL); ASSERT (Width < MAXIMUM_VALUE_CHARACTERS); // @@ -162,11 +168,16 @@ BasePrintLibConvertValueToString ( ASSERT (((Flags & COMMA_TYPE) != 0 && (Flags & RADIX_HEX) != 0) == FALSE); OriginalBuffer = Buffer; - + + // + // Width is 0 or COMMA_TYPE is set, PREFIX_ZERO is ignored. + // if (Width == 0 || (Flags & COMMA_TYPE) != 0) { Flags &= (~PREFIX_ZERO); } - + // + // If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed. + // if (Width == 0) { Width = MAXIMUM_VALUE_CHARACTERS - 1; } @@ -174,20 +185,32 @@ BasePrintLibConvertValueToString ( // Set the tag for the end of the input Buffer. // EndBuffer = Buffer + Width * Increment; - + + // + // Convert decimal negative + // if ((Value < 0) && ((Flags & RADIX_HEX) == 0)) { Value = -Value; Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, 1, '-', Increment); Width--; } - + + // + // Count the length of the value string. + // Radix = ((Flags & RADIX_HEX) == 0)? 10 : 16; Count = BasePrintLibValueToString (ValueBuffer, Value, Radix); - + + // + // Append Zero + // if ((Flags & PREFIX_ZERO) != 0) { Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, Width - Count, '0', Increment); } - + + // + // Print Comma type for every 3 characters + // Digits = Count % 3; if (Digits != 0) { Digits = 3 - Digits; @@ -204,7 +227,10 @@ BasePrintLibConvertValueToString ( } } } - + + // + // Print Null-terminator + // BasePrintLibFillBuffer (Buffer, EndBuffer + Increment, 1, 0, Increment); return ((Buffer - OriginalBuffer) / Increment); diff --git a/MdePkg/Library/BasePrintLib/PrintLibInternal.h b/MdePkg/Library/BasePrintLib/PrintLibInternal.h index 62e51838e3..704842a716 100644 --- a/MdePkg/Library/BasePrintLib/PrintLibInternal.h +++ b/MdePkg/Library/BasePrintLib/PrintLibInternal.h @@ -1,7 +1,7 @@ /** @file - Print Library Internal Functions. + Base Print Library instance Internal Functions definition. - Copyright (c) 2006 - 2007, Intel Corporation + Copyright (c) 2006 - 2008, Intel Corporation All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -12,8 +12,8 @@ **/ -#ifndef __PRINT_LIB_INTERNAL_H -#define __PRINT_LIB_INTERNAL_H +#ifndef __PRINT_LIB_INTERNAL_H__ +#define __PRINT_LIB_INTERNAL_H__ #include #include @@ -91,20 +91,21 @@ BasePrintLibVSPrint ( VA_LIST is used this rountine allows the nesting of Vararg routines. Thus this is the main print working routine - @param Buffer Character buffer to print the results of the parsing + @param StartOfBuffer Character buffer to print the results of the parsing of Format into. @param BufferSize Maximum number of characters to put into buffer. Zero means no limit. @param Flags Intial flags value. Can only have FORMAT_UNICODE and OUTPUT_UNICODE set @param FormatString Null-terminated format string. + @param ... The variable argument list. @return Number of characters printed. **/ UINTN BasePrintLibSPrint ( - OUT CHAR8 *Buffer, + OUT CHAR8 *StartOfBuffer, IN UINTN BufferSize, IN UINTN Flags, IN CONST CHAR8 *FormatString, @@ -123,16 +124,16 @@ BasePrintLibSPrint ( @param Character Character to be placed into Buffer. @param Increment Character increment in Buffer. - @return Number of characters printed. + @return Buffer Buffer filled with the input Character. **/ CHAR8 * BasePrintLibFillBuffer ( - CHAR8 *Buffer, - CHAR8 *EndBuffer, - INTN Length, - UINTN Character, - INTN Increment + OUT CHAR8 *Buffer, + IN CHAR8 *EndBuffer, + IN INTN Length, + IN UINTN Character, + IN INTN Increment ); /** @@ -148,7 +149,6 @@ BasePrintLibFillBuffer ( **/ UINTN -EFIAPI BasePrintLibValueToString ( IN OUT CHAR8 *Buffer, IN INT64 Value, -- cgit v1.2.3