X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdePkg%2FLibrary%2FBasePrintLib%2FPrintLibInternal.c;h=72c05e4dc5dbd88c515e51826a4a43079884ced4;hp=3d2f2952f9ec73db12599ee917b180ab5f684384;hb=e1f414b6a7d8a0424e0e01f655b09a4612b4d0e8;hpb=b0537818290619c85993136877afae37492fe5e0 diff --git a/MdePkg/Library/BasePrintLib/PrintLibInternal.c b/MdePkg/Library/BasePrintLib/PrintLibInternal.c index 3d2f2952f9..72c05e4dc5 100644 --- a/MdePkg/Library/BasePrintLib/PrintLibInternal.c +++ b/MdePkg/Library/BasePrintLib/PrintLibInternal.c @@ -1,7 +1,7 @@ /** @file Print Library worker functions. - Copyright (c) 2006, Intel Corporation
+ Copyright (c) 2006 - 2007, 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 @@ -14,6 +14,11 @@ **/ +// +// Include common header file for this module. +// +#include "CommonHeader.h" + #include "PrintLibInternal.h" GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 mHexStr[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'}; @@ -105,11 +110,13 @@ BasePrintLibValueToString ( If Width is 0, PREFIX_ZERO is ignored in Flags. If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas are inserted every 3rd digit starting from the right. - If Value is < 0, then the fist character in Buffer is a '-'. + If HEX_RADIX is set in Flags, then the output buffer will be formatted in hexadecimal format. + If Value is < 0 and HEX_RADIX is not set in Flags, then the fist character in Buffer is a '-'. If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, then Buffer is padded with '0' characters so the combination of the optional '-' sign character, '0' characters, digit characters for Value, and the Null-terminator add up to Width characters. + If both COMMA_TYPE and HEX_RADIX are set in Flags, then ASSERT(). If Buffer is NULL, then ASSERT(). If unsupported bits are set in Flags, then ASSERT(). @@ -142,13 +149,19 @@ BasePrintLibConvertValueToString ( UINTN Count; UINTN Digits; UINTN Index; + UINTN Radix; ASSERT (Buffer != NULL); ASSERT (Width < MAXIMUM_VALUE_CHARACTERS); // // Make sure Flags can only contain supported bits. // - ASSERT ((Flags & ~(LEFT_JUSTIFY | COMMA_TYPE | PREFIX_ZERO)) == 0); + ASSERT ((Flags & ~(LEFT_JUSTIFY | COMMA_TYPE | PREFIX_ZERO | RADIX_HEX)) == 0); + + // + // If both COMMA_TYPE and HEX_RADIX are set, then ASSERT () + // + ASSERT (((Flags & COMMA_TYPE) != 0 && (Flags & RADIX_HEX) != 0) == FALSE); OriginalBuffer = Buffer; @@ -164,13 +177,14 @@ BasePrintLibConvertValueToString ( // EndBuffer = Buffer + Width * Increment; - if (Value < 0) { + if ((Value < 0) && ((Flags & RADIX_HEX) == 0)) { Value = -Value; Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, 1, '-', Increment); Width--; } - Count = BasePrintLibValueToString (ValueBuffer, Value, 10); + Radix = ((Flags & RADIX_HEX) == 0)? 10 : 16; + Count = BasePrintLibValueToString (ValueBuffer, Value, Radix); if ((Flags & PREFIX_ZERO) != 0) { Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, Width - Count, '0', Increment); @@ -197,3 +211,4 @@ BasePrintLibConvertValueToString ( return ((Buffer - OriginalBuffer) / Increment); } +