-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
csplit: fix bug when --suppress-matched flag is active and positive/negative offset is present #7088
Conversation
…atched according to issue uutils#7052 and modified also test_up_to_match_negative_offset_option_suppress_matched
…d-matched flag is active
GNU testsuite comparison:
|
…atched according to issue uutils#7052 and modified also test_up_to_match_negative_offset_option_suppress_matched
…d-matched flag is active
2796cc1
to
c1b9509
Compare
GNU testsuite comparison:
|
src/uu/csplit/src/csplit.rs
Outdated
} else { | ||
// since offset_usize is for sure greater than 0 | ||
// the first element of the buffer should be removed and this | ||
// line inserted to be coherent with GNU implementation | ||
input_iter.add_line_to_buffer(ln, l); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A detail: I would swap the if
and else
blocks. It allows you to get rid of the !
in the condition for better readability.
…ils into csplit_suppressed_matched
Thanks, I have swapped the |
GNU testsuite comparison:
|
Thanks!
I don't remember what the error was then, sometimes it simply fails randomly :| |
I modified the test cases
test_up_to_match_offset_option_suppress_matched
according to the issue #7052 and also the testtest_up_to_match_negative_offset_option_suppress_matched
because the output was different with the GNU implementation.The code should fix the bug:
In case of positive offset: the code checks if the offset is greater than 0, so the last line should be skipped
In case of negative offset: when the regex is matched, the first element of the buffer should be deleted and the current line inserted.