mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:47:36 +00:00
AK: printf() should support %#x and %#o.
This commit is contained in:
parent
f2773e05e5
commit
e2a24e5746
1 changed files with 17 additions and 1 deletions
|
@ -193,6 +193,7 @@ template<typename PutChFunc>
|
||||||
bool zeroPad = false;
|
bool zeroPad = false;
|
||||||
unsigned fieldWidth = 0;
|
unsigned fieldWidth = 0;
|
||||||
unsigned long_qualifiers = 0;
|
unsigned long_qualifiers = 0;
|
||||||
|
bool alternate_form = 0;
|
||||||
if (*p == '%' && *(p + 1)) {
|
if (*p == '%' && *(p + 1)) {
|
||||||
one_more:
|
one_more:
|
||||||
++p;
|
++p;
|
||||||
|
@ -214,7 +215,13 @@ one_more:
|
||||||
}
|
}
|
||||||
if (*p == 'l') {
|
if (*p == 'l') {
|
||||||
++long_qualifiers;
|
++long_qualifiers;
|
||||||
goto one_more;
|
if (*(p + 1))
|
||||||
|
goto one_more;
|
||||||
|
}
|
||||||
|
if (*p == '#') {
|
||||||
|
alternate_form = true;
|
||||||
|
if (*(p + 1))
|
||||||
|
goto one_more;
|
||||||
}
|
}
|
||||||
switch( *p )
|
switch( *p )
|
||||||
{
|
{
|
||||||
|
@ -247,10 +254,19 @@ one_more:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'o':
|
case 'o':
|
||||||
|
if (alternate_form) {
|
||||||
|
putch(bufptr, '0');
|
||||||
|
++ret;
|
||||||
|
}
|
||||||
ret += print_octal_number(putch, bufptr, va_arg(ap, dword), leftPad, zeroPad, fieldWidth);
|
ret += print_octal_number(putch, bufptr, va_arg(ap, dword), leftPad, zeroPad, fieldWidth);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'x':
|
case 'x':
|
||||||
|
if (alternate_form) {
|
||||||
|
putch(bufptr, '0');
|
||||||
|
putch(bufptr, 'x');
|
||||||
|
ret += 2;
|
||||||
|
}
|
||||||
ret += print_hex(putch, bufptr, va_arg(ap, dword), 8);
|
ret += print_hex(putch, bufptr, va_arg(ap, dword), 8);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue