Repository navigation
od: print 6-digit hex offsets with -S, like the normal dump - #15625
Merged
Merged
Conversation
sylvestre
reviewed
Oct 22, 2026
| Radix::NoPrefix => writeln!(writer, "{string_content}"), | ||
| Radix::Decimal => writeln!(writer, "{offset:07} {string_content}"), | ||
| Radix::Hexadecimal => writeln!(writer, "{offset:07x} {string_content}"), | ||
| Radix::Hexadecimal => writeln!(writer, "{offset:06x} {string_content}"), |
Contributor
There was a problem hiding this comment.
could this reuse InputOffset::format_byte_offset instead? it would avoid the two copies drifting again
Contributor
Author
There was a problem hiding this comment.
@sylvestre Good idea. I did that in a follow-up PR: #15648
Contributor
|
Thanks for your PR |
sylvestre
pushed a commit
that referenced
this pull request
Oct 24, 2026
Follow-up to #15625: the strings mode had its own copy of the offset formats. InputOffset now implements Display, format_byte_offset uses it, and -S writes the offset through it without an extra allocation.
hubot
pushed a commit
to coreutils/coreutils
that referenced
this pull request
Oct 24, 2026
* tests/od/od.pl (@tests): Add test cases for -S with -Ax, -Ad and -Ao, ensuring hexadecimal offsets use 6 digits as in the normal dump. uutils/coreutils#15625 Link: #393
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #15592
With
-S/--stringsand-Ax,odzero-padded the offsets to 7 hex digits. GNU od uses 6, and so does uutils od's own normal dump with-Ax(InputOffsetformats hex as{:06x}). Decimal and octal offsets stay at 7 digits, which already matches GNU.I added a
-Ax -S3case totest_od_strings_option. It fails without the change, and alltest_odtests pass. I also compared-Soutput with GNUodon a 20 MB file of short NUL-separated ASCII strings, for-Ax,-Ad,-Aoand-An(with and without-j), so offsets past 6 hex digits are covered too. The output is identical.I used an AI assistant to help draft parts of the code and tests; I reviewed the changes and ran the tests myself.