Commit graph

13 commits

Author SHA1 Message Date
Conrad Pankoff 40daefd3dc AK: Abort on unknown printf formatting characters
Right now if we encounter an unknown character, printf (and its related
functions) fail in a really bad way, where they forget to pull things off
the stack. This usually leads to a crash somewhere else, which is hard to
debug.

This patch makes printf abort as soon as it encounters a formatting
character that it can't handle. This is not the optimal solution, but it
is an improvement for debugging.
2019-09-02 08:29:21 +02:00
Conrad Pankoff a92939b766 AK: Support %i as an alias for %d in printf 2019-09-02 08:28:31 +02:00
Conrad Pankoff 970e0147f7 AK: Make printf %x actually work properly
When printing hex numbers, we were printing the wrong thing sometimes. This
was because we were dividing the digit to print by 15 instead of 16. Also,
dividing by 16 is the same as shifting four bits to the right, which is a
bit closer to our actual intention in this case, so let's use a shift
instead.
2019-08-28 06:43:04 +02:00
Andreas Kling 5465795dc3 AK: The printf family was mixing up case and alternate form settings 2019-08-18 16:14:21 +02:00
Conrad Pankoff 06743932b8 AK: Support width/alt/caps/padding modifiers for %x in printf 2019-08-13 18:15:58 +02:00
Sergey Bugaev 79f867238a printf: Support dynamic fill widths
The printf formatting mini-language actually allows you
to pass a '*' character in place of the fill width specification,
in which case it eats one of the passed in arguments and uses it
as width, so implement that.
2019-08-10 08:46:22 +02:00
Andreas Kling 27f699ef0c AK: Rename the common integer typedefs to make it obvious what they are.
These types can be picked up by including <AK/Types.h>:

* u8, u16, u32, u64 (unsigned)
* i8, i16, i32, i64 (signed)
2019-07-03 21:20:13 +02:00
Andreas Kling 3ed17b0792 printf: Support %zu (the 'z' is really just ignored.) 2019-06-22 16:30:32 +02:00
Andreas Kling 1277d583ef 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..
2019-06-22 15:53:52 +02:00
Andreas Kling 9149a519f5 printf: Support printing negative values with %f or %g. 2019-06-18 14:47:52 +02:00
Andreas Kling 9f7c11710f printf: Treat %g as %f for now. 2019-06-18 09:46:39 +02:00
Andreas Kling 255c7562ba AK: Massage it into building on my host system without breaking Serenity. 2019-06-14 06:43:56 +02:00
Andreas Kling 98eeb8f22d AK: Rename printf.cpp to PrintfImplementation.h. 2019-06-07 11:41:11 +02:00
Renamed from AK/printf.cpp (Browse further)