fmt: restore GNU compatibility for tests/fmt/width#11073
Merged
cakebaker merged 1 commit intouutils:mainfrom Feb 24, 2026
Merged
fmt: restore GNU compatibility for tests/fmt/width#11073cakebaker merged 1 commit intouutils:mainfrom
cakebaker merged 1 commit intouutils:mainfrom
Conversation
76f1edc to
17733ee
Compare
Align fmt line-breaking with GNU coreutils 9.10 for the tests/fmt/width case. The -w 7 input "aa bb cc dd ee" now breaks as: aa bb cc dd ee Update Knuth-Plass scoring to keep finite penalties, evaluate break-before candidates, and apply orphan penalties. Add a regression test for -w 7 and -w 8 behavior.
17733ee to
04015af
Compare
Contributor
|
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.
This PR fixes fmt line wrapping to match GNU coreutils behavior for tests/fmt/width. In particular,
fmt -w 7foraa bb cc dd eenow producesaa,bb cc,dd ee, which matches GNU.The change updates Knuth-Plass scoring to avoid dropping valid short-line candidates, evaluates break-before and break-after candidates independently, and applies orphan-style penalties for sentence-final placement. It also adds a regression test covering both
-w 7and-w 8.Specifically, for input
aa bb cc dd ee,fmt -w 7now produces:Before
After (GNU-compatible)