From 06aeeecb3fe2655fd5e4e12948b389873a79884b Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sat, 24 Nov 2012 11:36:15 -0800 Subject: cut: do not print extraneous delimiters in some unusual cases MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When printing output delimiters, and when a to-EOL range subsumes at least one other range, cut would mistakenly print delimiters for the subsumed range. This bug was probably introduced via commit v5.2.1-639-g847e066. * src/cut.c (set_fields): Ignore any range that is subsumed by a to-EOL range. Also, move two declarations down. * tests/misc/cut.pl: Add tests to exercise this. * NEWS (Bug fixes): Mention it. Reported by Marcel Böhme in http://bugs.gnu.org/12966 --- tests/misc/cut.pl | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests/misc/cut.pl') diff --git a/tests/misc/cut.pl b/tests/misc/cut.pl index cb4781a7d..27768ff29 100755 --- a/tests/misc/cut.pl +++ b/tests/misc/cut.pl @@ -166,6 +166,15 @@ my @Tests = ['overlapping-unbounded-1', '-b3-,2-', {IN=>"1234\n"}, {OUT=>"234\n"}], ['overlapping-unbounded-2', '-b2-,3-', {IN=>"1234\n"}, {OUT=>"234\n"}], + + # When printing output delimiters, and with one or more ranges subsumed + # by a to-EOL range, cut 8.20 and earlier would print extraneous delimiters. + ['EOL-subsumed-1', '--output-d=: -b2-,3,4-4,5', + {IN=>"123456\n"}, {OUT=>"23456\n"}], + ['EOL-subsumed-2', '--output-d=: -b3,4-4,5,2-', + {IN=>"123456\n"}, {OUT=>"23456\n"}], + ['EOL-subsumed-3', '--complement -b3,4-4,5,2-', + {IN=>"123456\n"}, {OUT=>"1\n"}], ); if ($mb_locale ne 'C') -- cgit v1.2.3-54-g00ecf