GNU bug report logs - #12966
cut: Problems with overlapping, open-ended ranges

Previous Next

Package: coreutils;

Reported by: "Marcel Böhme" <hawkie <at> web.de>

Date: Fri, 23 Nov 2012 08:14:01 UTC

Severity: normal

Done: Jim Meyering <jim <at> meyering.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 12966 in the body.
You can then email your comments to 12966 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-coreutils <at> gnu.org:
bug#12966; Package coreutils. (Fri, 23 Nov 2012 08:14:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to "Marcel Böhme" <hawkie <at> web.de>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Fri, 23 Nov 2012 08:14:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: "Marcel Böhme" <hawkie <at> web.de>
To: bug-coreutils <at> gnu.org
Subject: cut: Problems with overlapping, open-ended ranges
Date: Fri, 23 Nov 2012 09:11:46 +0100 (CET)
[Message part 1 (text/html, inline)]

Information forwarded to bug-coreutils <at> gnu.org:
bug#12966; Package coreutils. (Sat, 24 Nov 2012 07:14:02 GMT) Full text and rfc822 format available.

Message #8 received at 12966 <at> debbugs.gnu.org (full text, mbox):

From: Jim Meyering <jim <at> meyering.net>
To: Marcel Böhme <hawkie <at> web.de>
Cc: 12966 <at> debbugs.gnu.org
Subject: Re: bug#12966: cut: Problems with overlapping, open-ended ranges
Date: Sat, 24 Nov 2012 08:11:34 +0100
Marcel Böhme wrote:
>    I found two (semantically related) bugs. One seems to originate in the
>    first version. For research purposes, I would appreciate if you could
>    confirm that the second was introduced with Coreutils 5.3.0.
>    1) The following bug seems to exists "since the beginning".
>    $echo 1234567890 | ./cut -b 2-,3,4-4,5,9-
>    3590
>    $echo 1234567890 | ./cut -b 2-,3,4-4,5,9-10
>    234567890
>    $echo 1234567890 | ./cut -b 2-10,3,4-4,5,9-
>    234567890

Thank you for the reports!  That is definitely a bug.
Here's a proposed fix:
[I'll look at the other one tomorrow if no one
gets to it first. ]

From 99084373fb7a12888234958ff0961643cf029dae Mon Sep 17 00:00:00 2001
From: Jim Meyering <jim <at> meyering.net>
Date: Fri, 23 Nov 2012 23:09:10 -0800
Subject: [PATCH] cut: interpret "-b3-,2-" like "-b2-", not like "-b3-"
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* src/cut.c (set_fields): When two right-open-ended ranges are
specified, don't blindly let the latter one take precedence over
the former.  Instead, use the union of the ranges.
* tests/misc/cut.pl: Add test to exercise this.
* THANKS.in: Attribute.
* NEWS (Bug fixes): Mention it.
Reported by Marcel Böhme in http://bugs.gnu.org/12966
---
 NEWS              | 4 ++++
 THANKS.in         | 1 +
 src/cut.c         | 6 ++++--
 tests/misc/cut.pl | 3 +++
 4 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/NEWS b/NEWS
index 15fddd4..284525e 100644
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,10 @@ GNU coreutils NEWS                                    -*- outline -*-
   Instead, cut now fails and emits an appropriate diagnostic.
   [This bug was present in "the beginning".]

+  cut now handles overlapping right-open-ended ranges properly.  Before,
+  it would interpret "-b3-,2-" like "-b3-".  Now it's treated like "-b2-".
+  [This bug was present in "the beginning".]
+
   install -m M SOURCE DEST no longer has a race condition where DEST's
   permissions are temporarily derived from SOURCE instead of from M.

diff --git a/THANKS.in b/THANKS.in
index 016a41e..3080cd3 100644
--- a/THANKS.in
+++ b/THANKS.in
@@ -367,6 +367,7 @@ Marc Haber                          mh+debian-bugs <at> zugschlus.de
 Marc Mengel                         mengel <at> fnal.gov
 Marc Lehman                         schmorp <at> schmorp.de
 Marc Olzheim                        marcolz <at> stack.nl
+Marcel Böhme                        hawkie <at> web.de
 Marco Franzen                       Marco.Franzen <at> Thyron.com
 Marcus Brinkmann                    http://www.marcus-brinkmann.de
 Marcus Daniels                      marcus <at> ee.pdx.edu
diff --git a/src/cut.c b/src/cut.c
index 2a57148..b464840 100644
--- a/src/cut.c
+++ b/src/cut.c
@@ -391,8 +391,10 @@ set_fields (const char *fieldstr)
                  In any case, 'initial' contains the start of the range. */
               if (!rhs_specified)
                 {
-                  /* 'n-'.  From 'initial' to end of line. */
-                  eol_range_start = initial;
+                  /* 'n-'.  From 'initial' to end of line.  If we've already
+                     seen an M- range, ignore subsequent N- unless N < M.  */
+                  if (eol_range_start == 0 || initial < eol_range_start)
+                    eol_range_start = initial;
                   field_found = true;
                 }
               else
diff --git a/tests/misc/cut.pl b/tests/misc/cut.pl
index cd56555..cb4781a 100755
--- a/tests/misc/cut.pl
+++ b/tests/misc/cut.pl
@@ -163,6 +163,9 @@ my @Tests =
   ['big-unbounded-b', '--output-d=:', '-b1234567890-', {IN=>''}, {OUT=>''}],
   ['big-unbounded-c', '--output-d=:', '-c1234567890-', {IN=>''}, {OUT=>''}],
   ['big-unbounded-f', '--output-d=:', '-f1234567890-', {IN=>''}, {OUT=>''}],
+
+  ['overlapping-unbounded-1', '-b3-,2-', {IN=>"1234\n"}, {OUT=>"234\n"}],
+  ['overlapping-unbounded-2', '-b2-,3-', {IN=>"1234\n"}, {OUT=>"234\n"}],
  );

 if ($mb_locale ne 'C')
--
1.8.0.251.g3a189da




Information forwarded to bug-coreutils <at> gnu.org:
bug#12966; Package coreutils. (Sat, 24 Nov 2012 08:46:02 GMT) Full text and rfc822 format available.

Message #11 received at 12966 <at> debbugs.gnu.org (full text, mbox):

From: Marcel Boehme <hawkie <at> web.de>
To: Jim Meyering <jim <at> meyering.net>
Cc: "12966 <at> debbugs.gnu.org" <12966 <at> debbugs.gnu.org>
Subject: Re: bug#12966: cut: Problems with overlapping, open-ended ranges
Date: Sat, 24 Nov 2012 16:45:39 +0800
Dear Mr. Meyering,

If adding me to THANKS, could you kindly point to: http://www.comp.nus.edu.sg/~mboehme instead of my (spam) email address?

Thank you very much indeed! Great work!

Best regards,
Marcel



On 24 Nov, 2012, at 3:11 PM, Jim Meyering <jim <at> meyering.net> wrote:

> Marcel Böhme wrote:
>>   I found two (semantically related) bugs. One seems to originate in the
>>   first version. For research purposes, I would appreciate if you could
>>   confirm that the second was introduced with Coreutils 5.3.0.
>>   1) The following bug seems to exists "since the beginning".
>>   $echo 1234567890 | ./cut -b 2-,3,4-4,5,9-
>>   3590
>>   $echo 1234567890 | ./cut -b 2-,3,4-4,5,9-10
>>   234567890
>>   $echo 1234567890 | ./cut -b 2-10,3,4-4,5,9-
>>   234567890
> 
> Thank you for the reports!  That is definitely a bug.
> Here's a proposed fix:
> [I'll look at the other one tomorrow if no one
> gets to it first. ]
> 
> From 99084373fb7a12888234958ff0961643cf029dae Mon Sep 17 00:00:00 2001
> From: Jim Meyering <jim <at> meyering.net>
> Date: Fri, 23 Nov 2012 23:09:10 -0800
> Subject: [PATCH] cut: interpret "-b3-,2-" like "-b2-", not like "-b3-"
> MIME-Version: 1.0
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: 8bit
> 
> * src/cut.c (set_fields): When two right-open-ended ranges are
> specified, don't blindly let the latter one take precedence over
> the former.  Instead, use the union of the ranges.
> * tests/misc/cut.pl: Add test to exercise this.
> * THANKS.in: Attribute.
> * NEWS (Bug fixes): Mention it.
> Reported by Marcel Böhme in http://bugs.gnu.org/12966
> ---
> NEWS              | 4 ++++
> THANKS.in         | 1 +
> src/cut.c         | 6 ++++--
> tests/misc/cut.pl | 3 +++
> 4 files changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/NEWS b/NEWS
> index 15fddd4..284525e 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -14,6 +14,10 @@ GNU coreutils NEWS                                    -*- outline -*-
>   Instead, cut now fails and emits an appropriate diagnostic.
>   [This bug was present in "the beginning".]
> 
> +  cut now handles overlapping right-open-ended ranges properly.  Before,
> +  it would interpret "-b3-,2-" like "-b3-".  Now it's treated like "-b2-".
> +  [This bug was present in "the beginning".]
> +
>   install -m M SOURCE DEST no longer has a race condition where DEST's
>   permissions are temporarily derived from SOURCE instead of from M.
> 
> diff --git a/THANKS.in b/THANKS.in
> index 016a41e..3080cd3 100644
> --- a/THANKS.in
> +++ b/THANKS.in
> @@ -367,6 +367,7 @@ Marc Haber                          mh+debian-bugs <at> zugschlus.de
> Marc Mengel                         mengel <at> fnal.gov
> Marc Lehman                         schmorp <at> schmorp.de
> Marc Olzheim                        marcolz <at> stack.nl
> +Marcel Böhme                        hawkie <at> web.de
> Marco Franzen                       Marco.Franzen <at> Thyron.com
> Marcus Brinkmann                    http://www.marcus-brinkmann.de
> Marcus Daniels                      marcus <at> ee.pdx.edu
> diff --git a/src/cut.c b/src/cut.c
> index 2a57148..b464840 100644
> --- a/src/cut.c
> +++ b/src/cut.c
> @@ -391,8 +391,10 @@ set_fields (const char *fieldstr)
>                  In any case, 'initial' contains the start of the range. */
>               if (!rhs_specified)
>                 {
> -                  /* 'n-'.  From 'initial' to end of line. */
> -                  eol_range_start = initial;
> +                  /* 'n-'.  From 'initial' to end of line.  If we've already
> +                     seen an M- range, ignore subsequent N- unless N < M.  */
> +                  if (eol_range_start == 0 || initial < eol_range_start)
> +                    eol_range_start = initial;
>                   field_found = true;
>                 }
>               else
> diff --git a/tests/misc/cut.pl b/tests/misc/cut.pl
> index cd56555..cb4781a 100755
> --- a/tests/misc/cut.pl
> +++ b/tests/misc/cut.pl
> @@ -163,6 +163,9 @@ my @Tests =
>   ['big-unbounded-b', '--output-d=:', '-b1234567890-', {IN=>''}, {OUT=>''}],
>   ['big-unbounded-c', '--output-d=:', '-c1234567890-', {IN=>''}, {OUT=>''}],
>   ['big-unbounded-f', '--output-d=:', '-f1234567890-', {IN=>''}, {OUT=>''}],
> +
> +  ['overlapping-unbounded-1', '-b3-,2-', {IN=>"1234\n"}, {OUT=>"234\n"}],
> +  ['overlapping-unbounded-2', '-b2-,3-', {IN=>"1234\n"}, {OUT=>"234\n"}],
>  );
> 
> if ($mb_locale ne 'C')
> --
> 1.8.0.251.g3a189da




Information forwarded to bug-coreutils <at> gnu.org:
bug#12966; Package coreutils. (Sat, 24 Nov 2012 12:18:01 GMT) Full text and rfc822 format available.

Message #14 received at 12966 <at> debbugs.gnu.org (full text, mbox):

From: Bernhard Voelker <mail <at> bernhard-voelker.de>
To: Jim Meyering <jim <at> meyering.net>
Cc: 12966 <at> debbugs.gnu.org, Marcel Böhme <hawkie <at> web.de>
Subject: Re: bug#12966: cut: Problems with overlapping, open-ended ranges
Date: Sat, 24 Nov 2012 13:15:31 +0100
On 11/24/2012 08:11 AM, Jim Meyering wrote:

> Subject: [PATCH] cut: interpret "-b3-,2-" like "-b2-", not like "-b3-"

Isn't it the other way round? I.e. "-b3-,2-" has already been working
correctly.

- Subject: [PATCH] cut: interpret "-b3-,2-" like "-b2-", not like "-b3-"
+ Subject: [PATCH] cut: interpret "-b2-,3-" like "-b2-", not like "-b3-"


> diff --git a/NEWS b/NEWS
> index 15fddd4..284525e 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -14,6 +14,10 @@ GNU coreutils NEWS                                    -*- outline -*-
>    Instead, cut now fails and emits an appropriate diagnostic.
>    [This bug was present in "the beginning".]
> 
> +  cut now handles overlapping right-open-ended ranges properly.  Before,
> +  it would interpret "-b3-,2-" like "-b3-".  Now it's treated like "-b2-".
> +  [This bug was present in "the beginning".]
> +

Likewise.


> diff --git a/THANKS.in b/THANKS.in
> index 016a41e..3080cd3 100644
> --- a/THANKS.in
> +++ b/THANKS.in
> @@ -367,6 +367,7 @@ Marc Haber                          mh+debian-bugs <at> zugschlus.de
>  Marc Mengel                         mengel <at> fnal.gov
>  Marc Lehman                         schmorp <at> schmorp.de
>  Marc Olzheim                        marcolz <at> stack.nl
> +Marcel Böhme                        hawkie <at> web.de
>  Marco Franzen                       Marco.Franzen <at> Thyron.com
>  Marcus Brinkmann                    http://www.marcus-brinkmann.de
>  Marcus Daniels                      marcus <at> ee.pdx.edu

That change will conflict with Padraig's pending patch for
http://bugs.gnu.org/12959.

Otherwise, the patch looks good.

BTW: interestingly, the i18n patch of openSuSE downstream
already had such a fix included for ages (line 215):
https://build.opensuse.org/package/view_file?file=coreutils-i18n.patch&package=coreutils&project=Base%3ASystem

Have a nice day,
Berny




Information forwarded to bug-coreutils <at> gnu.org:
bug#12966; Package coreutils. (Sat, 24 Nov 2012 16:50:02 GMT) Full text and rfc822 format available.

Message #17 received at 12966 <at> debbugs.gnu.org (full text, mbox):

From: Jim Meyering <jim <at> meyering.net>
To: Marcel Boehme <hawkie <at> web.de>
Cc: "12966 <at> debbugs.gnu.org" <12966 <at> debbugs.gnu.org>
Subject: Re: bug#12966: cut: Problems with overlapping, open-ended ranges
Date: Sat, 24 Nov 2012 17:48:10 +0100
Marcel Boehme wrote:
> If adding me to THANKS, could you kindly point to:
> http://www.comp.nus.edu.sg/~mboehme instead of my (spam) email
> address?

Pádraig already listed your name and URL for your seq report,
so the addition (with your email address) in my change-set can simply
be removed.

> Thank you very much indeed! Great work!

Thank you for finding/reporting all of those bugs.




Information forwarded to bug-coreutils <at> gnu.org:
bug#12966; Package coreutils. (Sat, 24 Nov 2012 17:03:02 GMT) Full text and rfc822 format available.

Message #20 received at 12966 <at> debbugs.gnu.org (full text, mbox):

From: Jim Meyering <jim <at> meyering.net>
To: Bernhard Voelker <mail <at> bernhard-voelker.de>
Cc: 12966 <at> debbugs.gnu.org, Marcel Böhme <hawkie <at> web.de>
Subject: Re: bug#12966: cut: Problems with overlapping, open-ended ranges
Date: Sat, 24 Nov 2012 18:01:17 +0100
Bernhard Voelker wrote:

> On 11/24/2012 08:11 AM, Jim Meyering wrote:
>
>> Subject: [PATCH] cut: interpret "-b3-,2-" like "-b2-", not like "-b3-"
>
> Isn't it the other way round? I.e. "-b3-,2-" has already been working
> correctly.
>
> - Subject: [PATCH] cut: interpret "-b3-,2-" like "-b2-", not like "-b3-"
> + Subject: [PATCH] cut: interpret "-b2-,3-" like "-b2-", not like "-b3-"

It most definitely is.
Good catch.  I've dropped the double quotes, too.
They were useful in an earlier version that had a space after each -b,
but now they add useless clutter.

>> diff --git a/NEWS b/NEWS
>> index 15fddd4..284525e 100644
>> --- a/NEWS
>> +++ b/NEWS
>> @@ -14,6 +14,10 @@ GNU coreutils NEWS -*- outline -*-
>>    Instead, cut now fails and emits an appropriate diagnostic.
>>    [This bug was present in "the beginning".]
>>
>> +  cut now handles overlapping right-open-ended ranges properly.  Before,
>> +  it would interpret "-b3-,2-" like "-b3-".  Now it's treated like "-b2-".
>> +  [This bug was present in "the beginning".]
>> +
>
> Likewise.

Yep.

>> diff --git a/THANKS.in b/THANKS.in
>> index 016a41e..3080cd3 100644
>> --- a/THANKS.in
>> +++ b/THANKS.in
>> @@ -367,6 +367,7 @@ Marc Haber mh+debian-bugs <at> zugschlus.de
>>  Marc Mengel                         mengel <at> fnal.gov
>>  Marc Lehman                         schmorp <at> schmorp.de
>>  Marc Olzheim                        marcolz <at> stack.nl
>> +Marcel Böhme                        hawkie <at> web.de
>>  Marco Franzen                       Marco.Franzen <at> Thyron.com
>>  Marcus Brinkmann                    http://www.marcus-brinkmann.de
>>  Marcus Daniels                      marcus <at> ee.pdx.edu
>
> That change will conflict with Padraig's pending patch for
> http://bugs.gnu.org/12959.

Yes.  Now that he's pushed that, I've simply removed the above
delta from my change set.

> Otherwise, the patch looks good.

Thanks for the review.

> BTW: interestingly, the i18n patch of openSuSE downstream
> already had such a fix included for ages (line 215):
> https://build.opensuse.org/package/view_file?file=coreutils-i18n.patch&package=coreutils&project=Base%3ASystem

Oh.  I wish that whoever fixed that had let us know.
For reference, here's the actual patch:

               if (!rhs_specified)
                 {
                   /* 'n-'.  From 'initial' to end of line. */
-                  eol_range_start = initial;
+                  if (eol_range_start == 0 ||
+                      (eol_range_start != 0 && eol_range_start > initial))
+                    eol_range_start = initial;
                   field_found = true;
                 }

BTW, I'll bet there's a static analysis tool that would
warn about its redundant test, "eol_range_start != 0"




Information forwarded to bug-coreutils <at> gnu.org:
bug#12966; Package coreutils. (Sat, 24 Nov 2012 19:43:02 GMT) Full text and rfc822 format available.

Message #23 received at 12966 <at> debbugs.gnu.org (full text, mbox):

From: Jim Meyering <jim <at> meyering.net>
To: Marcel Böhme <hawkie <at> web.de>
Cc: 12966 <at> debbugs.gnu.org
Subject: Re: bug#12966: cut: Problems with overlapping, open-ended ranges
Date: Sat, 24 Nov 2012 20:40:21 +0100
Marcel Böhme wrote:
>    I found two (semantically related) bugs. One seems to originate in the
>    first version. For research purposes, I would appreciate if you could
>    confirm that the second was introduced with Coreutils 5.3.0.
>    1) The following bug seems to exists "since the beginning".

As you saw, I've posted a patch for that separately.

>    2) Can you kindly confirm that the following bug has been introduced
>    with Coreutils 5.3.0, particularly commit
>    http://git.savannah.gnu.org/gitweb/?p=coreutils.git;a=commit;h=7380cf79
>    2aa35b9328519c5f374036d5260704cb ?
>    $echo 1234567890 | ./cut -b 2-,3,4-4,5 --output-delimiter="."
>    2.34.567890
>    $echo 1234567890 | ./cut -b 2-10,3,4-4,5 --output-delimiter="."
>    234567890

Yes, that's another bug.
Thanks again.  Here's a proposed patch:

From 7fce8c5bd9a916b65895b159caa6632b076fc634 Mon Sep 17 00:00:00 2001
From: Jim Meyering <jim <at> meyering.net>
Date: Sat, 24 Nov 2012 11:36:15 -0800
Subject: [PATCH] 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 test to exercise this.
* NEWS (Bug fixes): Mention it.
Reported by Marcel Böhme in http://bugs.gnu.org/12966
---
 NEWS              | 4 ++++
 src/cut.c         | 9 +++++----
 tests/misc/cut.pl | 9 +++++++++
 3 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/NEWS b/NEWS
index c46be61..9d0f2cf 100644
--- a/NEWS
+++ b/NEWS
@@ -18,6 +18,10 @@ GNU coreutils NEWS                                    -*- outline -*-
   it would interpret "-b2-,3-" like "-b3-".  Now it's treated like "-b2-".
   [This bug was present in "the beginning".]

+  cut no longer prints extraneous delimiters when a to-EOL range subsumes
+  another range.  Before, "echo 123|cut --output-delim=: -b2-,3" would print
+  "2:3".  Now it prints "23".  [bug introduced in 5.3.0]
+
   install -m M SOURCE DEST no longer has a race condition where DEST's
   permissions are temporarily derived from SOURCE instead of from M.

diff --git a/src/cut.c b/src/cut.c
index b464840..4219d24 100644
--- a/src/cut.c
+++ b/src/cut.c
@@ -514,17 +514,18 @@ set_fields (const char *fieldstr)
   /* Set the array entries corresponding to integers in the ranges of RP.  */
   for (i = 0; i < n_rp; i++)
     {
-      size_t j;
-      size_t rsi_candidate;
+      /* Ignore any range that is subsumed by the to-EOL range.  */
+      if (eol_range_start && eol_range_start <= rp[i].lo)
+        continue;

       /* Record the range-start indices, i.e., record each start
          index that is not part of any other (lo..hi] range.  */
-      rsi_candidate = complement ? rp[i].hi + 1 : rp[i].lo;
+      size_t rsi_candidate = complement ? rp[i].hi + 1 : rp[i].lo;
       if (output_delimiter_specified
           && !is_printable_field (rsi_candidate))
         mark_range_start (rsi_candidate);

-      for (j = rp[i].lo; j <= rp[i].hi; j++)
+      for (size_t j = rp[i].lo; j <= rp[i].hi; j++)
         mark_printable_field (j);
     }

diff --git a/tests/misc/cut.pl b/tests/misc/cut.pl
index cb4781a..27768ff 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')
--
1.8.0.273.g2d242fb




Information forwarded to bug-coreutils <at> gnu.org:
bug#12966; Package coreutils. (Sun, 25 Nov 2012 12:08:01 GMT) Full text and rfc822 format available.

Message #26 received at 12966 <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
To: Jim Meyering <jim <at> meyering.net>
Cc: 12966 <at> debbugs.gnu.org, Marcel Böhme <hawkie <at> web.de>
Subject: Re: bug#12966: cut: Problems with overlapping, open-ended ranges
Date: Sun, 25 Nov 2012 12:05:28 +0000
On 11/24/2012 07:40 PM, Jim Meyering wrote:

> diff --git a/src/cut.c b/src/cut.c
> index b464840..4219d24 100644
> --- a/src/cut.c
> +++ b/src/cut.c
> @@ -514,17 +514,18 @@ set_fields (const char *fieldstr)
>     /* Set the array entries corresponding to integers in the ranges of RP.  */
>     for (i = 0; i < n_rp; i++)
>       {
> -      size_t j;
> -      size_t rsi_candidate;
> +      /* Ignore any range that is subsumed by the to-EOL range.  */
> +      if (eol_range_start && eol_range_start <= rp[i].lo)
> +        continue;

looks good.

thanks,
Pádraig.




Reply sent to Jim Meyering <jim <at> meyering.net>:
You have taken responsibility. (Sun, 25 Nov 2012 15:53:02 GMT) Full text and rfc822 format available.

Notification sent to "Marcel Böhme" <hawkie <at> web.de>:
bug acknowledged by developer. (Sun, 25 Nov 2012 15:53:02 GMT) Full text and rfc822 format available.

Message #31 received at 12966-done <at> debbugs.gnu.org (full text, mbox):

From: Jim Meyering <jim <at> meyering.net>
To: Pádraig Brady <P <at> draigBrady.com>
Cc: 12966-done <at> debbugs.gnu.org, Marcel Böhme <hawkie <at> web.de>
Subject: Re: bug#12966: cut: Problems with overlapping, open-ended ranges
Date: Sun, 25 Nov 2012 16:50:35 +0100
Pádraig Brady wrote:
> On 11/24/2012 07:40 PM, Jim Meyering wrote:
>
>> diff --git a/src/cut.c b/src/cut.c
>> index b464840..4219d24 100644
>> --- a/src/cut.c
>> +++ b/src/cut.c
>> @@ -514,17 +514,18 @@ set_fields (const char *fieldstr)
>>     /* Set the array entries corresponding to integers in the ranges of RP.  */
>>     for (i = 0; i < n_rp; i++)
>>       {
>> -      size_t j;
>> -      size_t rsi_candidate;
>> +      /* Ignore any range that is subsumed by the to-EOL range.  */
>> +      if (eol_range_start && eol_range_start <= rp[i].lo)
>> +        continue;
>
> looks good.

Pushed (and marked "done").
Thanks for the review.




Information forwarded to bug-coreutils <at> gnu.org:
bug#12966; Package coreutils. (Wed, 28 Nov 2012 18:10:02 GMT) Full text and rfc822 format available.

Message #34 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Philipp Thomas <pth <at> suse.de>
To: bug-coreutils <at> gnu.org
Subject: Re: bug#12966: cut: Problems with overlapping, open-ended ranges
Date: Wed, 28 Nov 2012 19:06:41 +0100
* Jim Meyering (jim <at> meyering.net) [20121124 18:02]:

> Oh.  I wish that whoever fixed that had let us know.

I don't know who originated the i18n patch, but I took a newer version from
ArchLinux because their maintainer had already adapted the rather huge patch
to the then current coreutils version. That saved me lots of work as the
patch is neccessarily rather intrusive.

Philipp




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 27 Dec 2012 12:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 11 years and 122 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.