Skip to content

base32/base64/basenc: accept a -w value starting with - to match GNU - #14084

Open
AlejandroCoronadoN wants to merge 1 commit into
uutils:mainfrom
AlejandroCoronadoN:base-wrap-hyphen-value
Open

base32/base64/basenc: accept a -w value starting with - to match GNU#14084
AlejandroCoronadoN wants to merge 1 commit into
uutils:mainfrom
AlejandroCoronadoN:base-wrap-hyphen-value

Conversation

@AlejandroCoronadoN

Copy link
Copy Markdown
Contributor

base64 -w -5 (and any -w value that starts with -, e.g. -w -d) was rejected by the argument parser with unexpected argument '-5' found, while GNU takes the token after -w as the wrap size and reports invalid wrap size:

$ printf abc | base64 -w -5
error: unexpected argument '-5' found
$ printf abc | gbase64 -w -5
gbase64: invalid wrap size: '-5'

Adding allow_hyphen_values(true) to the -w/--wrap argument lets the value reach the existing wrap-size parser, which already emits the GNU-matching message. Verified against GNU for -w -5, -w -d, -w -x (all invalid wrap size), with valid values (-w 5, -w0, --wrap=5) and decoding unchanged. The shared base_common.rs covers base32, base64 and basenc.

@codspeed-hq

codspeed-hq Bot commented Aug 22, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 3.7%

⚠️ 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

⚡ 2 improved benchmarks
✅ 355 untouched benchmarks
⏩ 50 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation cksum_crc32b 39.7 ms 38.1 ms +4.19%
Simulation cksum_sysv 68.4 ms 66.3 ms +3.22%

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:base-wrap-hyphen-value (48e182d) with main (36947fc)

Open in CodSpeed

Footnotes

  1. 50 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.

@github-actions

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/tail/pid-pipe (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/cut/bounded-memory (passes in this run but fails in the 'main' branch)

.short('w')
.long(options::WRAP)
.value_name("COLS")
// GNU takes the token after -w as the wrap size even when it starts with '-'.

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.

Suggested change
// GNU takes the token after -w as the wrap size even when it starts with '-'.

Comment is unnecessary if you added test.

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.

2 participants