mirror of
https://git.savannah.gnu.org/git/grub.git
synced 2026-10-25 00:29:23 +00:00
kern/misc: Support octal printf format code
Also add parenthesis to nested ternary operator to improve clarity. Signed-off-by: Glenn Washburn <development@efficientek.com> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
1 parent
fb1f897373
commit
9ea4bf08e2
1 file changed
+11
-2
+11
-2
@@ -666,7 +666,7 @@ grub_divmod64 (grub_uint64_t n, grub_uint64_t d, grub_uint64_t *r)
|
|||||||
static inline char *
|
static inline char *
|
||||||
grub_lltoa (char *str, int c, unsigned long long n)
|
grub_lltoa (char *str, int c, unsigned long long n)
|
||||||
{
|
{
|
||||||
unsigned base = ((c == 'x') || (c == 'X')) ? 16 : 10;
|
unsigned base = ((c == 'x') || (c == 'X')) ? 16 : ((c == 'o') ? 8 : 10);
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
if ((long long) n < 0 && c == 'd')
|
if ((long long) n < 0 && c == 'd')
|
||||||
@@ -681,9 +681,15 @@ grub_lltoa (char *str, int c, unsigned long long n)
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
unsigned d = (unsigned) (n & 0xf);
|
unsigned d = (unsigned) (n & 0xf);
|
||||||
*p++ = (d > 9) ? d + ((c == 'x') ? 'a' : 'A') - 10 : d + '0';
|
*p++ = (d > 9) ? (d + ((c == 'x') ? 'a' : 'A') - 10) : d + '0';
|
||||||
}
|
}
|
||||||
while (n >>= 4);
|
while (n >>= 4);
|
||||||
|
else if (base == 8)
|
||||||
|
do
|
||||||
|
{
|
||||||
|
*p++ = ((unsigned) (n & 0x7)) + '0';
|
||||||
|
}
|
||||||
|
while (n >>= 3);
|
||||||
else
|
else
|
||||||
/* BASE == 10 */
|
/* BASE == 10 */
|
||||||
do
|
do
|
||||||
@@ -782,6 +788,7 @@ parse_printf_arg_fmt (const char *fmt0, struct printf_args *args,
|
|||||||
case 'X':
|
case 'X':
|
||||||
case 'u':
|
case 'u':
|
||||||
case 'd':
|
case 'd':
|
||||||
|
case 'o':
|
||||||
case 'c':
|
case 'c':
|
||||||
case 'C':
|
case 'C':
|
||||||
case 's':
|
case 's':
|
||||||
@@ -880,6 +887,7 @@ parse_printf_arg_fmt (const char *fmt0, struct printf_args *args,
|
|||||||
{
|
{
|
||||||
case 'x':
|
case 'x':
|
||||||
case 'X':
|
case 'X':
|
||||||
|
case 'o':
|
||||||
case 'u':
|
case 'u':
|
||||||
args->ptr[curn].type = UNSIGNED_INT + longfmt;
|
args->ptr[curn].type = UNSIGNED_INT + longfmt;
|
||||||
break;
|
break;
|
||||||
@@ -1089,6 +1097,7 @@ grub_vsnprintf_real (char *str, grub_size_t max_len, const char *fmt0,
|
|||||||
case 'X':
|
case 'X':
|
||||||
case 'u':
|
case 'u':
|
||||||
case 'd':
|
case 'd':
|
||||||
|
case 'o':
|
||||||
write_number (str, &count, max_len, format1, rightfill, zerofill, c, curarg);
|
write_number (str, &count, max_len, format1, rightfill, zerofill, c, curarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user