mirror of https://github.com/acidanthera/audk.git
Enhance the string formatting function to take "%p" to print pointer.
'p' - arugment is VOID *; printed as hex number Example is : ASPrint (Buffer, 1024, "This is a %p\n", SystemTable); ASPrint (Buffer, 1024, "This is a %10p\n", SystemTable); git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5554 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
34a0bac475
commit
0f77dfb622
|
@ -573,6 +573,27 @@ Returns:
|
|||
//
|
||||
Format = GetFlagsAndWidth (Format, &Flags, &Width, &Marker);
|
||||
switch (*Format) {
|
||||
case 'p':
|
||||
//
|
||||
// Flag space, +, 0, L & l are invalid for type p.
|
||||
//
|
||||
Flags &= ~(PREFIX_BLANK| PREFIX_SIGN | LONG_TYPE);
|
||||
if (sizeof (VOID *) > 4) {
|
||||
Flags |= LONG_TYPE;
|
||||
Value = VA_ARG (Marker, UINT64);
|
||||
} else {
|
||||
Value = VA_ARG (Marker, UINTN);
|
||||
}
|
||||
Flags |= PREFIX_ZERO;
|
||||
|
||||
EfiValueToHexStr (TempBuffer, Value, Flags, Width);
|
||||
UnicodeStr = TempBuffer;
|
||||
|
||||
for ( ;(*UnicodeStr != '\0') && (Index < NumberOfCharacters - 1); UnicodeStr++) {
|
||||
Buffer[Index++] = *UnicodeStr;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'X':
|
||||
Flags |= PREFIX_ZERO;
|
||||
Width = sizeof (UINT64) * 2;
|
||||
|
|
|
@ -39,6 +39,7 @@ Abstract:
|
|||
Decimal number that represents width of print
|
||||
|
||||
type:
|
||||
'p' - arugment is VOID *; printed as hex number
|
||||
'X' - argument is a UINTN hex number, prefix '0'
|
||||
'x' - argument is a hex number
|
||||
'd' - argument is a decimal number
|
||||
|
@ -206,6 +207,27 @@ Returns:
|
|||
//
|
||||
Format = GetFlagsAndWidth (Format, &Flags, &Width, &Marker);
|
||||
switch (*Format) {
|
||||
case 'p':
|
||||
//
|
||||
// Flag space, +, 0, L & l are invalid for type p.
|
||||
//
|
||||
Flags &= ~(PREFIX_BLANK| PREFIX_SIGN | LONG_TYPE);
|
||||
if (sizeof (VOID *) > 4) {
|
||||
Flags |= LONG_TYPE;
|
||||
Value = VA_ARG (Marker, UINT64);
|
||||
} else {
|
||||
Value = VA_ARG (Marker, UINTN);
|
||||
}
|
||||
Flags |= PREFIX_ZERO;
|
||||
|
||||
EfiValueToHexStr (TempBuffer, Value, Flags, Width);
|
||||
UnicodeStr = TempBuffer;
|
||||
|
||||
for ( ;(*UnicodeStr != '\0') && (Index < NumberOfCharacters - 1); UnicodeStr++) {
|
||||
Buffer[Index++] = *UnicodeStr;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'X':
|
||||
Flags |= PREFIX_ZERO;
|
||||
Width = sizeof (UINT64) * 2;
|
||||
|
|
|
@ -39,6 +39,7 @@ Abstract:
|
|||
Decimal number that represents width of print
|
||||
|
||||
type:
|
||||
'p' - arugment is VOID *; printed as hex number
|
||||
'X' - argument is a UINTN hex number, prefix '0'
|
||||
'x' - argument is a hex number
|
||||
'd' - argument is a decimal number
|
||||
|
@ -220,6 +221,26 @@ Returns:
|
|||
//
|
||||
Format = GetFlagsAndWidth (Format, &Flags, &Width, &Marker);
|
||||
switch (*Format) {
|
||||
case 'p':
|
||||
//
|
||||
// Flag space, +, 0, L & l are invalid for type p.
|
||||
//
|
||||
Flags &= ~(PREFIX_BLANK| PREFIX_SIGN | LONG_TYPE);
|
||||
if (sizeof (VOID *) > 4) {
|
||||
Flags |= LONG_TYPE;
|
||||
Value = VA_ARG (Marker, UINT64);
|
||||
} else {
|
||||
Value = VA_ARG (Marker, UINTN);
|
||||
}
|
||||
Flags |= PREFIX_ZERO;
|
||||
|
||||
ValueTomHexStr (TempBuffer, Value, Flags, Width);
|
||||
AsciiStr = TempBuffer;
|
||||
|
||||
for (; (*AsciiStr != '\0') && (Index < BufferSize - 1); AsciiStr++) {
|
||||
Buffer[Index++] = *AsciiStr;
|
||||
}
|
||||
break;
|
||||
case 'X':
|
||||
Flags |= PREFIX_ZERO;
|
||||
Width = sizeof (UINT64) * 2;
|
||||
|
|
Loading…
Reference in New Issue