%d now represents signed decimal, %u represents unsigned decimal.

This patch changes the behavior of Print() slightly. %d is now signed decimal,
and %u (new) is unsigned decimal. Previously, although ValueToString supports
signed decimal printing, %d always read args as UINTxx.

Old behavior:
Print(L"%d\n", -4) -> "4294967292"

New behavior:
Print(L"%d\n, -4) -> "-4"
Print(L"%u\n", -4) -> "4294967292"

If you want to keep complete backwards compatibility you could leave %d alone
and make something else (probably shouldn't be %u to avoid confusion) be
signed decimal. But this way it agrees with the usual use of %d and %u.

Signed-off-by: Nathan Blythe <nblythe@lgsinnovations.com>
Signed-off-by: Nigel Croxon <nigel.croxon@hpe.com>
This commit is contained in:
Nigel Croxon 2016-03-25 10:28:02 -04:00
parent 9b0fe34e20
commit 1acb1d9dae

View file

@ -998,7 +998,8 @@ Routine Description:
s - unicode string
X - fixed 8 byte value in hex
x - hex value
d - value as decimal
d - value as signed decimal
u - value as unsigned decimal
c - Unicode char
t - EFI time structure
g - Pointer to GUID
@ -1144,15 +1145,24 @@ Returns:
GuidToString (Item.Item.pw, va_arg(ps->args, EFI_GUID *));
break;
case 'd':
case 'u':
Item.Item.pw = Item.Scratch;
ValueToString (
Item.Item.pw,
Item.Comma,
Item.Long ? va_arg(ps->args, UINT64) : va_arg(ps->args, UINT32)
);
break
;
break;
case 'd':
Item.Item.pw = Item.Scratch;
ValueToString (
Item.Item.pw,
Item.Comma,
Item.Long ? va_arg(ps->args, INT64) : va_arg(ps->args, INT32)
);
break;
case 't':
Item.Item.pw = Item.Scratch;
TimeToString (Item.Item.pw, va_arg(ps->args, EFI_TIME *));