kf zheng
a77848fb83
printf: Fix extra padding ( #6548 )
2024-07-13 10:19:01 +02:00
kf zheng
e6b6b2761b
printf: Check precision before writing into stdout ( #6511 )
...
* Add a new error type InvalidPrecision
* check if the precision is valid before writing to stdout when it is signedInt, unsigned, or float
* add tests for invalid precision check
* add tests for invalid precision check
* fix possible cross-platform issue that code failing to pass on some tests
* uucore/format: inline var in format string
---------
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
2024-07-01 15:15:32 +02:00
Ben Wiederhake
289346a4ba
printf+tests: remove unused spell-checker:disable
2024-04-30 18:28:20 +02:00
Dorian Péron
58ee0ce427
tests/printf: Verify the correct error behavior of printf when provided with '%0c' or '%0s'
2024-03-01 00:02:31 +01:00
Dorian Péron
42cde767d2
printf: Change get_char and write_padded to handle bytes instead of chars
2024-02-29 00:59:08 +01:00
Dorian Péron
5d74a6e002
tests/printf: Fix char_as_byte test, add char and string padding tests
2024-02-29 00:43:47 +01:00
Terts Diepraam
3126e5f8a1
printf: fix padding and prefixes for unsigned ints
2024-02-09 13:28:18 +01:00
Terts Diepraam
4dae902429
printf: pad octal numbers with zeros on the left
2024-02-09 13:28:18 +01:00
Sylvestre Ledru
4557821adf
Merge branch 'main' into fix-printf-hex-alternate-zero
2024-01-15 10:41:09 +01:00
Sudhakar Verma
2aa8a3502f
printf : no infinite loop
2024-01-12 16:08:47 +05:30
Sylvestre Ledru
edb77b8d59
Merge pull request #5827 from samueltardieu/issue-5826
...
printf: %c prints the first byte of its argument
2024-01-12 00:25:32 +01:00
Samuel Tardieu
47e908bc6c
printf: output of double-quote should not be escaped
...
This is obtained by escaping the sequence `\"` as `"`.
2024-01-10 19:17:42 +01:00
Samuel Tardieu
7d32e49fb9
printf: %c prints the first byte of its argument
2024-01-10 18:19:56 +01:00
Marras Antoine
3b884966ac
printf: added failing tests on alternative hex form
2024-01-10 16:55:03 +01:00
Samuel Tardieu
a85a792c88
format: use the new number parser and fix the error messages
...
The error messages are more compliant with GNU coreutils.
Also, floating hexadecimal numbers are now supported in
`printf`.
2024-01-10 14:34:43 +01:00
Samuel Tardieu
5dfeca9ff2
format: %c prints the first character of a string
2024-01-09 00:13:54 +01:00
Terts Diepraam
0822511fdc
test/printf: ignoring rounding up to 2
...
This is a limitation of the current implementation, which should ultimately use "long double" precision instead of f64.
2023-11-21 16:49:20 +01:00
Terts Diepraam
6d2698b802
Merge branch 'main' into printf-rewrite
2023-11-20 13:53:11 +01:00
Terts Diepraam
ce18e0ab97
printf: ignore hexadecimal floats test
...
This can be un-ignored when it is implemented
2023-11-17 14:47:41 +01:00
Terts Diepraam
fef84f7203
printf: add emoji character test
2023-11-17 14:47:08 +01:00
Terts Diepraam
955640aac8
printf: fix and test float formatting
2023-11-17 14:46:38 +01:00
ALXD
3cdb0966ae
printf: add a test for %x with invalid value
2023-11-15 17:51:43 +01:00
Zhuoxun Yang
fb414ed917
tests/printf: support %q
2023-11-09 10:18:27 +08:00
Sylvestre Ledru
bfca6bf70f
Add license headers on all files
2023-08-21 10:49:27 +02:00
Daniel Hofstetter
6988eb7ec6
tests: expand wildcard imports
2023-03-20 15:32:35 +01:00
Hanif Ariffin
2e60dce11a
printf: Default left-justify integer conversion to 1 width
...
When using left-justify with integer conversion (like `printf '%-o'`),
default the minimum width to 1.
Closes: https://github.com/uutils/coreutils/issues/3050
Signed-off-by: Hanif Ariffin <hanif.ariffin.4326@gmail.com>
2022-05-01 20:00:09 +02:00
Eli Youngs
a0bd88b51b
Add comments and an additional test
2022-03-20 00:44:09 -07:00
Eli Youngs
565af8237b
Fix formatting
2022-03-11 23:43:59 +01:00
Eli Youngs
e23219289a
Simplify test cases
2022-03-11 23:43:59 +01:00
Eli Youngs
2afa9cd1a0
printf - Update %g formatting to match GNU
2022-03-11 23:43:59 +01:00
Nick Donald
a74ffac19e
printf: fix printf sci notation round up
2022-03-07 07:01:21 +01:00
Eli Youngs
162f85773e
printf: Support leading zeroes with %0n formatting
2022-02-05 00:43:09 -08:00
Hanif Ariffin
793d3dd97c
test_printf: add test for additional escape (\c)
...
Using this escaped character will cause `printf` to stop generating characters.
For instance,
```rust
hbina@akarin ~/g/uutils (hbina-add-test-for-additional-escape)> cargo run --quiet -- printf "%s\c%s" a b
a⏎
```
Signed-off-by: Hanif Ariffin <hanif.ariffin.4326@gmail.com>
2022-02-04 18:47:23 +08:00
Roy Ivy III
3f35e0a421
refactor ~ cargo make format
2021-05-31 08:23:58 -05:00
Roy Ivy III
4e20dedf58
tests ~ refactor/polish spelling (comments, names, and exceptions)
2021-05-31 08:23:57 -05:00
Roy Ivy III
de0375f909
tests ~ reorganize tests
2020-06-01 18:30:04 -05:00