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("%#.5o", 06143), printf("%#.0o", 0) #53

Open
ledvinap opened this issue Apr 23, 2019 · 1 comment
Open

printf("%#.5o", 06143), printf("%#.0o", 0) #53

ledvinap opened this issue Apr 23, 2019 · 1 comment

Comments

@ledvinap
Copy link

In this case (and wider precision) octal zero should be included in padding instead of adding it

printf("%#.5o", 06143)
expected: 06143
got: 006143

printf("%#.6o", 06143)
expected: 006143
got: 0006143

another partially-related case is

sprintf("%#.0o", 0)
glibc: "0"
got: ""

ledvinap added a commit to ledvinap/printf that referenced this issue May 13, 2019
Handle 0x / 0b when width is equal to string size (issue mpaland#50):
printf("%#4x", 0x1234); -> "0x1234"

Do not print # prefix if it does not fit into PRINTF_NTOA_BUFFER_SIZE

%#<prec>o is implemented as in libc:
- printf("%#0o", 0); does output octal prefix ("0")

- printf("%#3o", 1); printf "001" - padding zero is used as octal
  prefix (issue mpaland#53)

Left padding and precision is handled correctly (issue mpaland#49):
- printf("%-10.6d", 1024); -> "001024    "
ledvinap added a commit to ledvinap/printf that referenced this issue May 13, 2019
Handle 0x / 0b when width is equal to string size (issue mpaland#50):
printf("%#4x", 0x1234); -> "0x1234"

Do not print # prefix if it does not fit into PRINTF_NTOA_BUFFER_SIZE

%#<prec>o is implemented as in libc:
- printf("%#0o", 0); does output octal prefix ("0")

- printf("%#3o", 1); printf "001" - padding zero is used as octal
  prefix (issue mpaland#53)

Left padding and precision is handled correctly (issue mpaland#49):
- printf("%-10.6d", 1024); -> "001024    "
@eyalroz
Copy link

eyalroz commented Aug 3, 2021

Should be fixed on my fork with 6a3ad44; see also #109.

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

No branches or pull requests

2 participants