summaryrefslogtreecommitdiff
path: root/AK/PrintfImplementation.h
AgeCommit message (Collapse)Author
2021-04-22Everything: Move to SPDX license identifiers in all files.Brian Gianforcaro
SPDX License Identifiers are a more compact / standardized way of representing file license information. See: https://spdx.dev/resources/use/#identifiers This was done with the `ambr` search and replace tool. ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-03-21AK+LibC: Make %p specifier Architecture IndependentHendiadyoin1
We were using u32 as a pointer representation and not FlatPtr
2021-02-08AK: Clean up includes around printf/vdbgprintfBen Wiederhake
2021-01-12LibC+Everywhere: Remove open_with_path_length() in favor of open()Andreas Kling
This API was a mostly gratuitous deviation from POSIX that gave up some portability in exchange for avoiding the occasional strlen(). I don't think that was actually achieving anything valuable, so let's just chill out and have the same open() API as everyone else. :^)
2020-12-25AK: Remove custom %w format string specifierAndreas Kling
This was a non-standard specifier alias for %04x. This patch replaces all uses of it with new-style formatting functions instead.
2020-12-25AK: Remove custom %b format string specifierAndreas Kling
This was a non-standard specifier alias for %02x. This patch replaces all uses of it with new-style formatting functions instead.
2020-11-05AK: printf was not accounting for plus sign with "%+d"Andreas Kling
We have to include the plus sign in the number of characters written, otherwise sprintf() will put the null terminator too early.
2020-10-08AK: Use new format functions.asynts
2020-10-02AK+Format: Do some housekeeping in the format implementation.asynts
2020-09-29AK+Format: Support all format specifiers for strings.asynts
The following is now possible: outf("{:.4}", "abcdef"); // abcd outf("{:*<8}", "abcdef"); // abcdef**
2020-09-26AK+Format: Add new integer to string backend.asynts
I put this into the <AK/PrintfImplementation.h> header in the hope that it could be re-used by the printf implementation. That would not be super trivial though, so I am not doing that now.
2020-09-21AK: Add format function like std::format or fmt::format.asynts
2020-09-12AK: Fix PrintfImplementation "%x" handling for u32AnotherTest
This also fixes an issue with the color input value being messed up. oops :P
2020-09-11AK: Generalise 'PrintfImplementation'AnotherTest
This makes PrintfImplementation usable with any sequence, provided that a 'next element' function can be written for it. Does not affect the behaviour of printf() and co.
2020-08-30AK: Make %llx work in printfNico Weber
2020-07-25AK: Fix print_doubleBen Wiederhake
Fixes #2776. This fixes, among other things, JSON serialization. The underlying bug was that 'print_double' defined fraction_length as a function argument with a default value, whereas printf_internal *always* provided a value, even if nothing was read. The 'use 6 by default' logic has been moved to printf_internal instead.
2020-06-06AK: Fix printf("%c", 0)Sergey Bugaev
It was me who has broken this, sorry ;(
2020-05-16Kernel: Absorb LibBareMetal back into the kernelAndreas Kling
This was supposed to be the foundation for some kind of pre-kernel environment, but nobody is working on it right now, so let's move everything back into the kernel and remove all the confusion.
2020-05-05AK: run clang-format on PrintfImplementation.hEmanuele Torre
2020-05-04AK: Rename variables with camelCase names in PrintfImplementation.h (#2095)Emanuele Torre
zeroPad => zero_pad leftPad => left_pad fieldWidth => field_width These were the only variables with names in camelCase. We were not consistent with the naming of these variables: some times we called them zeroPad, leftPad, fieldWidth; other times we called them zero_pad, left_pad, field_width. These inconsistencies made the code hard to read, so I changed their names to snake_case. Also rename width => field_width in AK::print_hex()
2020-04-30AK: Add ALWAYS_INLINE, NEVER_INLINE and FLATTEN macrosAndreas Kling
It's tedious to write (and look at) [[gnu::always_inline]] etc. :^)
2020-04-07AK: Allow %m.nf specifier for double/float in printf to set fraction withEmanuel Sprung
This patch adds the missing part for the printf of double values to specify the length of the fraction part. For GVariant, a default of %.2 is used.
2020-03-31AK: Print double numbers with printfEmanuel Sprung
This patchset allows double numbers to be printed with the printf function. The fraction will always be printed as 6 digit number. This can be improved :^)
2020-03-26AK: Use print_string() for %c formattingSergey Bugaev
Instead of simply outputting the character. This way, we get proper padding support and other niceties strings enjoy.
2020-02-19AK: Fix bug where "%s" with field width would print too many charactersAndreas Kling
I introduced this while implementing "%.*s", oops.
2020-02-19AK: Support "%.*s" in format stringsAndreas Kling
Work towards #623.
2020-02-09AK: Apply changes for the Bootstrapper environmentLiav A
2020-02-08AK: Make PrintfImplementation treat %lld as 64-bitAndreas Kling
2020-01-19AK: Support '+' qualifier in printf() to force sign for positive %d'sAndreas Kling
2020-01-18Meta: Add license header to source filesAndreas Kling
As suggested by Joshua, this commit adds the 2-clause BSD license as a comment block to the top of every source file. For the first pass, I've just added myself for simplicity. I encourage everyone to add themselves as copyright holders of any file they've added or modified in some significant way. If I've added myself in error somewhere, feel free to replace it with the appropriate copyright holder instead. Going forward, all new source files should include a license header.
2019-12-05AK: Implement %n printf specifierSergey Bugaev
This is a special specifier that does not output anything to the stream, but saves the number of already output chars to the provided pointer. This is apparently used by GNU Nano.
2019-11-04AK: Let's just log unimplemented printf() format stringsAndreas Kling
It's too dang frustrating that we actually crash whenever we hit some unimplemented printf specifier. Let's just log the whole format string and carry on as best we can.
2019-11-02AK: Handle '%llu' in printf() (unsigned 64-bit integer)Andreas Kling
I got a warning when using '%Q' since that's non-standard. This patch makes our printf family accept '%llu'.
2019-09-11printf: %w, %b, and %p should be zero-padded but not left-paddedAndreas Kling
This fixes the goofy issue with %p coming out as " 0x123" instead of "0x00000123".
2019-09-08AK: Pad %b and %w to two and four places in printfConrad Pankoff
2019-09-06AK: When printf assert on unsupported specifier, specify which one!Andreas Kling
We were asserting without saying why. That's a bit unhelpful. :^)
2019-09-03AK: Fix printf %x padding and %p lengthConrad Pankoff
2019-09-02AK: Abort on unknown printf formatting charactersConrad Pankoff
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-02AK: Support %i as an alias for %d in printfConrad Pankoff
2019-08-28AK: Make printf %x actually work properlyConrad Pankoff
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-18AK: The printf family was mixing up case and alternate form settingsAndreas Kling
2019-08-13AK: Support width/alt/caps/padding modifiers for %x in printfConrad Pankoff
2019-08-10printf: Support dynamic fill widthsSergey Bugaev
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-07-03AK: Rename the common integer typedefs to make it obvious what they are.Andreas Kling
These types can be picked up by including <AK/Types.h>: * u8, u16, u32, u64 (unsigned) * i8, i16, i32, i64 (signed)
2019-06-22printf: Support %zu (the 'z' is really just ignored.)Andreas Kling
2019-06-22printf: Oops, '-' is the left padding modifier, not ' '.Andreas Kling
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-18printf: Support printing negative values with %f or %g.Andreas Kling
2019-06-18printf: Treat %g as %f for now.Andreas Kling
2019-06-14AK: Massage it into building on my host system without breaking Serenity.Andreas Kling
2019-06-07AK: Rename printf.cpp to PrintfImplementation.h.Andreas Kling