Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

printf: fix formatting for zero value when precision is zero#8351

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
nickorlow wants to merge2 commits intouutils:main
base:main
Choose a base branch
Loading
fromnickorlow:main

Conversation

nickorlow
Copy link

Fixes issue#7509

According to the C/C++ reference, "if both the value and precision are 0, the conversion results in no characters. "

This PR also includes code to handle the following exceptions:

  • If width isn't zero, the result should still be padded, but empty
  • If the alternate octal output is selected, a0 should be outputted
  • The positive sign should be printed if specified

@hz2
Copy link
Contributor

hz2 commentedJul 18, 2025

For clippy related issues, it may be helpful to run locally:

cargo clippy --all-targets --all-features -- -D warnings

@nickorlow
Copy link
Author

Ah, forgot to check lint. Thank you.

Comment on lines +454 to +456
ifletSome(prec) = precision{
if precasu64 > i32::MAXasu64{
returnErr(FormatError::InvalidPrecision(prec.to_string()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

based onpipeline, didn't like naming ofprec, try renaming

if precisionasu64 > i32::MAXasu64{
returnErr(FormatError::InvalidPrecision(precision.to_string()));
ifletSome(prec) = precision{
if precasu64 > i32::MAXasu64{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

based onpipeline, didn't like naming of prec, try renaming

@github-actionsGitHub Actions
Copy link

GNU testsuite comparison:

GNU test failed: tests/printf/printf. tests/printf/printf is passing on 'main'. Maybe you have to rebase?Skip an intermittent issue tests/misc/stdbuf (fails in this run but passes in the 'main' branch)Skip an intermittent issue tests/misc/tee (fails in this run but passes in the 'main' branch)Skip an intermittent issue tests/timeout/timeout (fails in this run but passes in the 'main' branch)

@nickorlow
Copy link
Author

nickorlow commentedJul 18, 2025
edited
Loading

Will look into failing tests + other lints I didn't pick up earlier

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@hz2hz2hz2 left review comments

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@nickorlow@hz2

[8]ページ先頭

©2009-2025 Movatter.jp