-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
numfmt: add --zero-terminated option #7686
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: add --zero-terminated option #7686
Conversation
&prefix[1..] | ||
} else { | ||
prefix | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably just some implementation detail, but one of the GNU compatibility tests depends on this behavior. As per the guidelines, I haven't examined the GNU implementation for numfmt
, but here are some manual tests I did for compatibility:
$ printf "A\nB 1001 C\x00D E\n2002 F\x00" | ./src/numfmt -z --field=3 --to=si | cat --show-all # official test
A B 1.1k C^@D E 2.1k F^@⏎
$ printf "A \nB 1001 C\x00D E\n2002 F\x00" | ./src/numfmt -z --field=3 --to=si | cat --show-all
A $
B 1.1k C^@D E 2.1k F^@⏎
$ printf "A\n B 1001 C\x00D E\n2002 F\x00" | ./src/numfmt -z --field=3 --to=si | cat --show-all
A B 1.1k C^@D E 2.1k F^@⏎
The above output is from the GNU version of numfmt
, but it's identical to the uutils version output (with this patch of course).
GNU testsuite comparison:
|
There is some compilation error:
|
ea20122
to
81911f9
Compare
GNU testsuite comparison:
|
@cakebaker Thanks, this should be fixed now. I'm new to this project and didn't realize there are tests within CI is passing now except for what looks like an unrelated test for
Unfortunately it doesn't look like I have permission to rerun it, unless I'm missing something. So I'll have to wait until a maintainer can rerun it to verify. (I could push an empty commit, but don't want to pollute the commit log just for this.) |
Thanks! |
This partially fixes #1280. With this patch, the GNU compatibility tests for
numfmt --zero-terminated
pass:One thing to note is that this patch does an
unwrap
onString::from_utf8
becauseBufRead.split(0)
results inVec<u8>
instead ofString
. This isn't a regression though because the rest of the program already assumes input can be put intoString
. Here's an example from themain
branch:I don't see a bug report for that so I'm happy to file one. I just didn't want to do more than one thing in this PR.