Skip to content

unexpand: accept a blank as a tab-list separator like GNU - #14057

Open
AlejandroCoronadoN wants to merge 2 commits into
uutils:mainfrom
AlejandroCoronadoN:unexpand-space-tab-separator
Open

unexpand: accept a blank as a tab-list separator like GNU#14057
AlejandroCoronadoN wants to merge 2 commits into
uutils:mainfrom
AlejandroCoronadoN:unexpand-space-tab-separator

Conversation

@AlejandroCoronadoN

Copy link
Copy Markdown
Contributor

GNU unexpand accepts both a comma and a blank between tab stops in -t/--tabs, so unexpand -t '2 3' behaves like unexpand -t '2,3'. uutils only splits on a comma, so the space form is rejected:

$ printf '  a   b\n' | unexpand -t '2 3' -a
unexpand: tab size contains invalid character(s): ' 3'

uutils' own expand already accepts both separators via an is_space_or_comma helper; only unexpand was inconsistent. This splits the tab list on a space or a comma too, mirroring expand. Verified byte for byte against GNU unexpand in the C locale for '2 3', ' 2 3', '2 3', '2, 3' and '1 4 7'; invalid values like -t x still error as before.

@codspeed-hq

codspeed-hq Bot commented Aug 21, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 3.44%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 1 improved benchmark
✅ 177 untouched benchmarks
⏩ 229 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation du_wide_tree[(5000, 500)] 20.2 ms 19.6 ms +3.44%

Tip

Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.


Comparing AlejandroCoronadoN:unexpand-space-tab-separator (148fd58) with main (a9b64fc)2

Open in CodSpeed

Footnotes

  1. 229 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on main (71ebb92) during the generation of this report, so a9b64fc was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@github-actions

github-actions Bot commented Aug 21, 2026

Copy link
Copy Markdown

GNU testsuite comparison:

GNU test failed: tests/tail/truncate. tests/tail/truncate is passing on 'main'. Maybe you have to rebase?
Skip an intermittent issue tests/pr/bounded-memory (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/date/date-locale-hour (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/tail/tail-n0f (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/dd/misc is no longer failing!
Note: The gnu test tests/seq/seq-epipe is now being skipped but was previously passing.
Congrats! The gnu test tests/tail/pipe-f is now passing!

Comment thread src/uu/unexpand/src/unexpand.rs Outdated
}

/// Decide whether the character is either a space or a comma.
fn is_space_or_comma(c: char) -> bool {

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.

Not a useful function. Please remove it and write code directly.

@AlejandroCoronadoN
AlejandroCoronadoN force-pushed the unexpand-space-tab-separator branch from 2a16155 to 80248df Compare August 21, 2026 09:41
@AlejandroCoronadoN

Copy link
Copy Markdown
Contributor Author

Good point, removed the helper and inlined it as s.split([' ', ',']). Thanks for the review!

@sylvestre

Copy link
Copy Markdown
Contributor

GNU splits on blank, so a literal TAB is a valid separator too - s.split([' ', '\t', ',']). expand's is_space_or_comma has the same gap; worth fixing both here.

@AlejandroCoronadoN
AlejandroCoronadoN force-pushed the unexpand-space-tab-separator branch from 80248df to 7c49a86 Compare August 21, 2026 21:40
@AlejandroCoronadoN

Copy link
Copy Markdown
Contributor Author

Good catch, added the tab so the split is now s.split([' ', '\t', ',']). Verified against GNU unexpand with a tab separator. Thanks!

@codspeed-hq

codspeed-hq Bot commented Aug 24, 2026

Copy link
Copy Markdown

Unable to generate the performance report

There was an internal error while processing the run's data. We're working on fixing the issue. Feel free to contact us on Discord or at support@codspeed.io if the issue persists.

@sylvestre
sylvestre enabled auto-merge (squash) August 26, 2026 11:27
hubot pushed a commit to coreutils/coreutils that referenced this pull request Aug 26, 2026
parse_tab_stops accepts a comma or any blank as a separator, but the
tests only ever used a comma or a space, so a tab separator was
untested.  unexpand had no coverage of multi-stop lists at all.
Missing case identified here:
uutils/coreutils#14057

* tests/expand/expand.pl (t4a): New test, using tabs as separators.
* tests/unexpand/unexpand.pl (tabs-3, tabs-4, tabs-5, tabs-6): New
tests, for comma-, space- and tab-separated lists and for a leading
separator.

Link: #332
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.

3 participants