unexpand:fix unexpand /dev/zero panic#10712
Open
mattsu2020 wants to merge 5 commits intouutils:mainfrom
Open
Conversation
Simplified conditional expressions using ternary operators for better readability and improved code formatting by reorganizing multi-line function calls with proper indentation.
…d security Updated multiple dependency versions across the project including: - cc from 1.2.52 to 1.2.55 - find-msvc-tools from 0.1.7 to 0.1.9 - flate2 from 1.1.8 to 1.1.9 - iana-time-zone from 0.1.64 to 0.1.65 - libm from 0.2.15 to 0.2.16 - notify-types from 2.0.0 to 2.1.0 - portable-atomic from 1.13.0 to 1.13.1 - portable-atomic-util from 0.2.4 to 0.2.5 - regex-automata from 0.4.13 to 0.4.14 - regex-lite from 0.1.8 to 0.1.9 - windows-sys from 0.59.0 to 0.61.2 - zerocopy from 0.8.33 to 0.8.38 These updates provide bug fixes, performance improvements, and security enhancements.
Simplify the conditional return statement in `utf8_incomplete_tail` using `usize::from()` for cleaner code. Also restructure the control flow in `unexpand_chunk` to eliminate unnecessary else block and improve readability by moving the write operation outside the conditional.
…acter The unexpand utility was incorrectly skipping tab conversion after encountering an initial non-space character, even when the current column position matched the starting column. This caused inconsistent behavior where tabs were not converted to spaces as expected. The fix adds a check for `state.col == state.scol` to ensure conversion only skips when both conditions are met: the initial non-space character is found AND we're at the
CodSpeed Performance ReportMerging this PR will improve performance by ×4.5Comparing Summary
Performance Changes
Footnotes
|
|
GNU testsuite comparison: |
Contributor
|
one more time ... |
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
This PR enhances the unexpand utility to improve compatibility with GNU coreutils and ensure more predictable behavior.
Motivation
While testing unexpand, I identified discrepancies in behavior compared to GNU coreutils, particularly in handling whitespace and tab conversion. This change aims to reduce those differences and improve overall reliability.
Changes
Refactored the unexpand logic to align more closely with GNU coreutils behavior.
Improved error handling by returning Result types instead of panicking, enhancing robustness.
Added and updated tests to cover the modified behavior and prevent regressions.
Compatibility
The goal of this change is to match GNU coreutils behavior as closely as possible without introducing breaking changes.
Testing
Added unit and integration tests.
Verified behavior against GNU coreutils.
Confirmed no regressions in existing tests.
related
#10698