Skip to content

od: report current offset for empty strings with --strings=0 - #16157

Merged
cakebaker merged 1 commit into
uutils:mainfrom
huuan26:fix/od-strings-empty-offset-16134
Nov 3, 2026
Merged

cakebaker merged 1 commit into
uutils:mainfrom
huuan26:fix/od-strings-empty-offset-16134

Conversation

@huuan26

@huuan26 huuan26 commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Fixes #16134

Summary

When using \od --strings=0, empty strings (such as consecutive \0\ bytes) were printed with a stale \string_start_offset\ (or 0) because \string_start_offset\ is only recorded when a printable character is encountered.

This PR updates \extract_strings_from_input\ so that when \current_string.is_empty(), \current_offset\ is used as the starting offset for the null-terminated empty string, matching GNU \od\ behavior.

Verification

Added test cases in \ ests/by-util/test_od.rs\ covering:

  • Mixed strings and empty strings with --strings=0 -Ad\
  • Consecutive NUL bytes with -S0 -Ad\
  • Skipped bytes with -j4\ and --strings=0
    All tests pass.

@cakebaker
cakebaker force-pushed the fix/od-strings-empty-offset-16134 branch from 423cfad to 20e09d9 Compare November 3, 2026 08:23
@cakebaker
cakebaker merged commit cab3e66 into uutils:main Nov 3, 2026
99 checks passed
@cakebaker

Copy link
Copy Markdown
Contributor

Thanks for your PR!

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.

od: --strings=0 reports stale offsets for empty strings

2 participants