X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdePkg%2FLibrary%2FBasePrintLib%2FPrintLibInternal.c;h=e1e8c08c5519b57f3af7cd47b14758904867582e;hp=72c05e4dc5dbd88c515e51826a4a43079884ced4;hb=1efcc4ae46f52e3845923ffbab68426e068709d2;hpb=e1f414b6a7d8a0424e0e01f655b09a4612b4d0e8 diff --git a/MdePkg/Library/BasePrintLib/PrintLibInternal.c b/MdePkg/Library/BasePrintLib/PrintLibInternal.c index 72c05e4dc5..e1e8c08c55 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 @@ -10,14 +10,10 @@ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - Module Name: PrintLibInternal.c - **/ -// -// Include common header file for this module. -// -#include "CommonHeader.h" + + #include "PrintLibInternal.h" @@ -36,16 +32,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; @@ -71,7 +67,6 @@ BasePrintLibFillBuffer ( **/ UINTN -EFIAPI BasePrintLibValueToString ( IN OUT CHAR8 *Buffer, IN INT64 Value, @@ -91,6 +86,10 @@ BasePrintLibValueToString ( *(Buffer++) = mHexStr[Remainder]; Digits++; } while (Value != 0); + + // + // the length of Buffer string converted from Value + // return Digits; } @@ -151,6 +150,9 @@ BasePrintLibConvertValueToString ( UINTN Index; UINTN Radix; + // + // Make sure Buffer is not NULL and Width < MAXIMUM + // ASSERT (Buffer != NULL); ASSERT (Width < MAXIMUM_VALUE_CHARACTERS); // @@ -164,11 +166,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; } @@ -176,20 +183,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; @@ -206,7 +225,10 @@ BasePrintLibConvertValueToString ( } } } - + + // + // Print Null-terminator + // BasePrintLibFillBuffer (Buffer, EndBuffer + Increment, 1, 0, Increment); return ((Buffer - OriginalBuffer) / Increment);