fmt: measure -w in UTF-8 bytes to match GNU - #13651
Merged
Merged
Conversation
GNU fmt (through 9.11) is not multibyte-aware and counts line length from pointer differences, not Unicode display columns. Switch uutils fmt to the same byte-oriented width so CJK wrapping matches GNU. Revisit when GNU moves to display-column width. Fixes uutils#10095 Co-authored-by: Cursor <cursoragent@cursor.com>
Merging this PR will degrade performance by 4.28%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | Simulation | du_summarize_balanced_tree[(5, 4, 10)] |
15.7 ms | 16.5 ms | -4.3% |
| ❌ | Simulation | du_max_depth_balanced_tree[(6, 4, 10)] |
60.9 ms | 63.6 ms | -4.27% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing sankalpsthakur:fix/fmt-gnu-width-10095 (875fac9) with main (0cb3473)
Footnotes
-
46 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. ↩
|
GNU testsuite comparison: |
Collaborator
|
Thanks ! |
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.
Summary
GNU
fmt(verified against 9.11) measures-w/--widthin UTF-8 bytes, not Unicode display columns. uutils was usingunicode-width, so CJK examples from #10095 wrapped differently.This switches
char_width/ word length accounting inparasplit.rsto UTF-8 byte length and adds regression tests for the issue’s multibyte cases.Intentionally not reopening #12623’s
width-1/ newline-budget approach (closed as stale vs GNU 9.10+).When GNU grows true multibyte/display-column width support, this should be revisited.
Validation
Compared local binary output to GNU 9.11 on the #10095 examples.
Fixes #10095
AI/LLM disclosure
Made with Cursor