mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
AK: printf() should support %#x and %#o.
This commit is contained in:
parent
f2773e05e5
commit
e2a24e5746
Notes:
sideshowbarker
2024-07-19 14:56:18 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/e2a24e57463
1 changed files with 17 additions and 1 deletions
|
@ -193,6 +193,7 @@ template<typename PutChFunc>
|
|||
bool zeroPad = false;
|
||||
unsigned fieldWidth = 0;
|
||||
unsigned long_qualifiers = 0;
|
||||
bool alternate_form = 0;
|
||||
if (*p == '%' && *(p + 1)) {
|
||||
one_more:
|
||||
++p;
|
||||
|
@ -214,6 +215,12 @@ one_more:
|
|||
}
|
||||
if (*p == 'l') {
|
||||
++long_qualifiers;
|
||||
if (*(p + 1))
|
||||
goto one_more;
|
||||
}
|
||||
if (*p == '#') {
|
||||
alternate_form = true;
|
||||
if (*(p + 1))
|
||||
goto one_more;
|
||||
}
|
||||
switch( *p )
|
||||
|
@ -247,10 +254,19 @@ one_more:
|
|||
break;
|
||||
|
||||
case 'o':
|
||||
if (alternate_form) {
|
||||
putch(bufptr, '0');
|
||||
++ret;
|
||||
}
|
||||
ret += print_octal_number(putch, bufptr, va_arg(ap, dword), leftPad, zeroPad, fieldWidth);
|
||||
break;
|
||||
|
||||
case 'x':
|
||||
if (alternate_form) {
|
||||
putch(bufptr, '0');
|
||||
putch(bufptr, 'x');
|
||||
ret += 2;
|
||||
}
|
||||
ret += print_hex(putch, bufptr, va_arg(ap, dword), 8);
|
||||
break;
|
||||
|
||||
|
|
Loading…
Reference in a new issue