Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

printf: floating point conversion flags not supported or incorrect #2774

Open
jfinkels opened this issue Dec 16, 2021 · 1 comment
Open

printf: floating point conversion flags not supported or incorrect #2774

jfinkels opened this issue Dec 16, 2021 · 1 comment

Comments

@jfinkels
Copy link
Collaborator

Floating point conversion flags are defined here: https://www.gnu.org/software/libc/manual/html_node/Floating_002dPoint-Conversions.html

Here are a few failing test cases:

Flag to always include a plus or minus sign:

$ printf "%+3.0f\n" 0
 +0
$ ./target/debug/coreutils printf "%+3.0f\n" 0
printf: %+: invalid conversion specification

Flag to pad the field with spaces:

$ printf "% 3.0f\n" 1
  1
$ ./target/debug/coreutils printf "% 3.0f\n" 1
printf: % : invalid conversion specification

Flag to pad the field with zeros instead of spaces:

$ printf "%03.0f\n" 0
000
$ ./target/debug/coreutils printf "%03.0f\n" 0
  0

Combining the + and 0 flags:

$ printf "%0+3.0f\n" 0
+00
$ ./target/debug/coreutils printf "%0+3.0f\n" 0
printf: %0+: invalid conversion specification

Combining the and - flags:

$ printf "% -3.0f\n" 1
 1
$ ./target/debug/coreutils printf "% -3.0f\n" 1
printf: % : invalid conversion specification

Discovered this while investigating #2616.

@stale
Copy link

stale bot commented Jan 13, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants