summaryrefslogtreecommitdiff
path: root/AK/PrintfImplementation.h
AgeCommit message (Collapse)Author
2023-01-21Everywhere: Remove string.h include from AK/Traits.h and resolve falloutAndrew Kaster
A lot of places were relying on AK/Traits.h to give it strnlen, memcmp, memcpy and other related declarations. In the quest to remove inclusion of LibC headers from Kernel files, deal with all the fallout of this included-everywhere header including less things.
2023-01-19AK: Don't write trailing zeros with %gPeter Elliott
2022-12-03Everywhere: Run clang-formatLinus Groh
2022-10-10Everywhere: Replace uses of __serenity__ with AK_OS_SERENITYAndrew Kaster
Now that we have OS macros for essentially every supported OS, let's try to use them everywhere.
2022-09-30AK: Fix a comment typoNico Weber
2022-09-29Lagom: Fix printf implementation on win32Diego Iastrubni
It seems that Filip has already done the hard work, and found out the implementation different between unix* and windows. Borrowed from: https://github.com/SerenityOS/serenity/compare/master...filiphsps:serenity:dev-win32#diff-e3209c9a434a102d0d9459e31e33ddb729dff925b95f41b9d1e56c1e7f88c487R466 Co-authored-by: Filiph Sandström <filiph.sandstrom@filfatstudios.com>
2022-04-23AK: Make sure we don't include Math.h or math.h from KERNELAndrew Kaster
2022-04-14AK: Differ between long and long long formatsTim Schumacher
2022-04-14AK: Deduplicate formatting hexadecimal valuesTim Schumacher
Both calls essentially only differ in one boolean, which dictates whether to print the value in uppercase or lowercase. Move the long function call into a new function and pass in the "uppercase" boolean seperately to avoid having to write everything twice.
2022-04-14AK: Merge print_i64 into print_signed_numberTim Schumacher
Those functions only differ by the input type of `number`. No other wrapper does this, as they rely on adjusting the type of the argument on the caller side instead. Avoid specializing too much by just doing the same for signed numbers.
2022-04-01Everywhere: Run clang-formatIdan Horowitz
2022-03-30AK: Allow printing wide characters using %ls modifiersafarp
2022-03-12AK: Properly parse unimplemented format length specifiersTim Schumacher
This keeps us from stopping early and not rendering the argument at all.
2022-03-02AK: Print NaN and infinite numbers in PrintfImplementationPeter Ross
2022-02-28AK: Correctly process precision modifiers in printfTimur Sultanov
2021-12-21LibC+AK: Implement all sorts of wprintf variantsAli Mohammad Pur
2021-12-07AK: Zero-pad automatically if formatting with precisionTim Schumacher
2021-11-14AK: Swallow 'L' format specifier until it is properly implementedBrian Gianforcaro
Previously if code attempted to use the format specifier somewhere (Ex: "%#4.3Lg"), the specifier would get dropped and we would just print "g" instead of any value. Now at least we print a value.
2021-05-30AK: Honor variable precision argument when formattingTim Schumacher
printf didn't check whether the additional integer variable belongs to the field width specifier or to the precision specifier, and always applied it to the field width instead. Implement the case distinction that we already use in literal width and precision specifiers for the variable version as well so that they are correctly attributed.
2021-05-18AK/PrintfImplementation: Change static constexpr array to function localLenny Maiorani
Problem: - Static variables take memory and can be subject to less optimization. - This static variable is only used in 1 place. Solution: - Move the variable into the function and make it non-static.
2021-05-06AK: Implement printf fraction length specification for stringsAnotherTest
This adds support for '%.20s' and friends :^)
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