diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-06-22 15:52:45 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-06-22 15:53:52 +0200 |
commit | 1277d583ef32c8931dc51635a4b6cd7a96f737ed (patch) | |
tree | a0b94b8691099519e948b479381bc554e1f6dabc /AK/PrintfImplementation.h | |
parent | 5980007e44698071fe71a7e412785b8d04471127 (diff) | |
download | serenity-1277d583ef32c8931dc51635a4b6cd7a96f737ed.zip |
printf: Oops, '-' is the left padding modifier, not ' '.
It's kinda funny how I can make a mistake like this in Serenity and then
get so used to it by spending lots of time using this API that I start to
believe that this is how printf() always worked..
Diffstat (limited to 'AK/PrintfImplementation.h')
-rw-r--r-- | AK/PrintfImplementation.h | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/AK/PrintfImplementation.h b/AK/PrintfImplementation.h index 091b5b4334..e6a9495a3d 100644 --- a/AK/PrintfImplementation.h +++ b/AK/PrintfImplementation.h @@ -196,7 +196,7 @@ template<typename PutChFunc> char* bufptr = buffer; for (p = fmt; *p; ++p) { - bool leftPad = false; + bool left_pad = false; bool zeroPad = false; unsigned fieldWidth = 0; unsigned long_qualifiers = 0; @@ -204,8 +204,8 @@ template<typename PutChFunc> if (*p == '%' && *(p + 1)) { one_more: ++p; - if (*p == ' ') { - leftPad = true; + if (*p == '-') { + left_pad = true; if (*(p + 1)) goto one_more; } @@ -233,19 +233,19 @@ template<typename PutChFunc> switch (*p) { case 's': { const char* sp = va_arg(ap, const char*); - ret += print_string(putch, bufptr, sp ? sp : "(null)", leftPad, fieldWidth); + ret += print_string(putch, bufptr, sp ? sp : "(null)", left_pad, fieldWidth); } break; case 'd': - ret += print_signed_number(putch, bufptr, va_arg(ap, int), leftPad, zeroPad, fieldWidth); + ret += print_signed_number(putch, bufptr, va_arg(ap, int), left_pad, zeroPad, fieldWidth); break; case 'u': - ret += print_number(putch, bufptr, va_arg(ap, dword), leftPad, zeroPad, fieldWidth); + ret += print_number(putch, bufptr, va_arg(ap, dword), left_pad, zeroPad, fieldWidth); break; case 'Q': - ret += print_qword(putch, bufptr, va_arg(ap, qword), leftPad, zeroPad, fieldWidth); + ret += print_qword(putch, bufptr, va_arg(ap, qword), left_pad, zeroPad, fieldWidth); break; case 'q': @@ -256,7 +256,7 @@ template<typename PutChFunc> case 'g': case 'f': // FIXME: Print as float! - ret += print_signed_qword(putch, bufptr, (qword)va_arg(ap, double), leftPad, zeroPad, fieldWidth); + ret += print_signed_qword(putch, bufptr, (qword)va_arg(ap, double), left_pad, zeroPad, fieldWidth); break; #endif @@ -265,7 +265,7 @@ template<typename PutChFunc> 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), left_pad, zeroPad, fieldWidth); break; case 'x': |