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

numfmt: implement --format #3751

Merged
merged 1 commit into from
Jul 29, 2022
Merged

numfmt: implement --format #3751

merged 1 commit into from
Jul 29, 2022

Conversation

cakebaker
Copy link
Contributor

This PR implements --format:

Use printf-style floating FORMAT string. The format string must contain one ‘%f’ directive, optionally with ‘'’, ‘-’, ‘0’, width or precision modifiers. The ‘'’ modifier will enable --grouping, the ‘-’ modifier will enable left-aligned --padding and the width modifier will enable right-aligned --padding. The ‘0’ width modifier (without the ‘-’ modifier) will generate leading zeros on the number, up to the specified width.

While the parsing of the format string is fully implemented, the handling of the ' modifier (grouping) is not implemented and hence has no effect on the output.

This PR makes all precision, fmt, and fmt-err (with the exception of fmt-err-9 and fmt-err-11) tests in https://github.com/coreutils/coreutils/blob/master/tests/misc/numfmt.pl pass.

@sylvestre
Copy link
Contributor

Impressive work.
Do you know if the code could be useful in other coreutils binaries?

@cakebaker
Copy link
Contributor Author

I don't know, the code is probably too specific to numfmt.

@sylvestre sylvestre merged commit 38679f1 into uutils:main Jul 29, 2022
@sylvestre
Copy link
Contributor

OK merci :)

@cakebaker cakebaker deleted the numfmt_format branch July 30, 2022 05:24
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

Successfully merging this pull request may close these issues.

2 participants