csplit: create final empty file with --suppress-matched to match GNU (fixes #7286)#8655
Merged
cakebaker merged 1 commit intouutils:mainfrom Sep 18, 2025
Conversation
…ixes uutils#7286) Problem - With , uutils csplit failed to create the final empty output file when the last split point consumed the trailing input. - GNU csplit always creates a final segment after processing patterns; with , that empty final segment is elided. - This broke the GNU test (tests/csplit/csplit-suppress-matched.pl) and the scenario: Root cause - Final-file creation was conditional on there being remaining input after pattern processing. If none remained, no final file was created, contrary to GNU semantics. Fix (minimal, targeted) - In , after : - If there is remaining input, always create a final split and copy the remainder, then finish. - Else, if all patterns were integer-based and is set, create a final (possibly empty) split and finish; elides it when is set. Tests (Rust integration) - Added two Rust tests under to lock down GNU-compatible behavior: - (expects sizes 2,2,2,0 and a final empty ) - (final empty file is correctly elided) Verification - All tests pass locally. The originally reported case now matches GNU. Relation to PR uutils#7806 - uutils#7806 proposes a broader refactor to fix multiple issues, but remains a draft and notes remaining GNU suppress-matched differences. - This PR provides a small, reviewable fix specifically for uutils#7286, plus precise integration tests to safeguard behavior. Fixes uutils#7286
|
GNU testsuite comparison: |
Contributor
Kudos, 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.
csplit: create final empty file with --suppress-matched to match GNU (fixes #7286)
Problem
Root cause
Fix (minimal, targeted)
Tests (Rust integration)
Verification
Relation to PR #7806
Fixes #7286