Skip to content

printf: extra spaces if padding number is not next to % #6519

@Kev1n8

Description

@Kev1n8

Cases:

printf "% -3.0f" 1
 1 %
cargo run printf "% -3.0f" 1
 1  %(extra spaces here)
cargo run printf '%-3.0f' 1`
1  %

printf "% 3.0d" 1
 1 %
cargo run printf "% 3.0d" 1
 1  %(extra spaces here)

However, if the number is negative, the space will be filled with -, then there's no extra padding:

cargo run printf "% -3.0f" -1
-1 %

related issue: #2774

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions