Age | Commit message (Collapse) | Author |
|
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.
|
|
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.
|
|
This adds support for '%.20s' and friends :^)
|
|
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 *
|
|
We were using u32 as a pointer representation and not FlatPtr
|
|
|
|
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. :^)
|
|
This was a non-standard specifier alias for %04x. This patch replaces
all uses of it with new-style formatting functions instead.
|
|
This was a non-standard specifier alias for %02x. This patch replaces
all uses of it with new-style formatting functions instead.
|
|
We have to include the plus sign in the number of characters written,
otherwise sprintf() will put the null terminator too early.
|
|
|
|
|
|
The following is now possible:
outf("{:.4}", "abcdef"); // abcd
outf("{:*<8}", "abcdef"); // abcdef**
|
|
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.
|
|
|
|
This also fixes an issue with the color input value being messed up.
oops :P
|
|
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.
|
|
|
|
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.
|
|
It was me who has broken this, sorry ;(
|
|
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.
|
|
|
|
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()
|
|
It's tedious to write (and look at) [[gnu::always_inline]] etc. :^)
|
|
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.
|
|
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 :^)
|
|
Instead of simply outputting the character. This way, we get proper padding
support and other niceties strings enjoy.
|
|
I introduced this while implementing "%.*s", oops.
|
|
Work towards #623.
|
|
|
|
|
|
|
|
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.
|
|
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.
|
|
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.
|
|
I got a warning when using '%Q' since that's non-standard. This patch
makes our printf family accept '%llu'.
|
|
This fixes the goofy issue with %p coming out as " 0x123" instead
of "0x00000123".
|
|
|
|
We were asserting without saying why. That's a bit unhelpful. :^)
|
|
|
|
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.
|
|
|
|
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.
|
|
|
|
|
|
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.
|
|
These types can be picked up by including <AK/Types.h>:
* u8, u16, u32, u64 (unsigned)
* i8, i16, i32, i64 (signed)
|
|
|
|
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..
|
|
|