Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/uu/od/src/od.rs
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ fn extract_strings_from_input(
match radix {
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}"),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

could this reuse InputOffset::format_byte_offset instead? it would avoid the two copies drifting again

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@sylvestre Good idea. I did that in a follow-up PR: #15648

Radix::Octal => writeln!(writer, "{offset:07o} {string_content}"),
}
};
Expand Down
8 changes: 8 additions & 0 deletions tests/by-util/test_od.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1404,6 +1404,14 @@ fn test_od_strings_option() {
.succeeds()
.stdout_is("0000001 hello\n0000007 world\n");

// Hexadecimal offsets use 6 digits, as in the normal dump
new_ucmd!()
.arg("-Ax")
.arg("-S3")
.pipe_in(b"\x01hello\x00world\x00ab\x00")
.succeeds()
.stdout_is("000001 hello\n000007 world\n");

// Test with -S10 to show only strings with minimum length
new_ucmd!()
.arg("-S10")
Expand Down
Loading