summaryrefslogtreecommitdiff
path: root/MdePkg/Library/BasePrintLib/PrintLibInternal.c
diff options
context:
space:
mode:
authorlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2008-07-15 11:12:43 +0000
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2008-07-15 11:12:43 +0000
commiteceb3a4cb9b97d331ba91ea0a930465c05e8e20b (patch)
tree2f30cbf356491a3bea738c3facb2c37d056ffd66 /MdePkg/Library/BasePrintLib/PrintLibInternal.c
parent329d3f3d01b5470a2311ada36e36664519eb3447 (diff)
downloadedk2-platforms-eceb3a4cb9b97d331ba91ea0a930465c05e8e20b.tar.xz
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
Diffstat (limited to 'MdePkg/Library/BasePrintLib/PrintLibInternal.c')
-rw-r--r--MdePkg/Library/BasePrintLib/PrintLibInternal.c58
1 files changed, 42 insertions, 16 deletions
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<BR>
+ Copyright (c) 2006 - 2008, Intel Corporation<BR>
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);