GNU bug report logs -
#13080
[PATHC] improve error reporting
Previous Next
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 13080 in the body.
You can then email your comments to 13080 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-coreutils <at> gnu.org
:
bug#13080
; Package
coreutils
.
(Tue, 04 Dec 2012 16:48:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
"Alexandru Cojocaru" <cojocaru_alexandru <at> gmx.com>
:
New bug report received and forwarded. Copy sent to
bug-coreutils <at> gnu.org
.
(Tue, 04 Dec 2012 16:48:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
From 8ecd92b3c11abc5cde184f0c511cd469190511af Mon Sep 17 00:00:00 2001
From: Cojocaru Alexandru <xojoc <at> gmx.com>
Date: Tue, 4 Dec 2012 16:08:42 +0100
Subject: [PATCH] cut: improve error reporting
* src/cut.c (main): Report error on `-d '' -b1'
* src/cut.c (set_fields): Change the error message when
the given list is invalid.
---
src/cut.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/cut.c b/src/cut.c
index 4219d24..d55da51 100644
--- a/src/cut.c
+++ b/src/cut.c
@@ -365,7 +365,7 @@ set_fields (const char *fieldstr)
in_digits = false;
/* Starting a range. */
if (dash_found)
- FATAL_ERROR (_("invalid byte or field list"));
+ FATAL_ERROR (_("invalid byte, character or field list"));
dash_found = true;
fieldstr++;
@@ -491,7 +491,7 @@ set_fields (const char *fieldstr)
fieldstr++;
}
else
- FATAL_ERROR (_("invalid byte or field list"));
+ FATAL_ERROR (_("invalid byte, character or field list"));
}
max_range_endpoint = 0;
@@ -781,7 +781,7 @@ main (int argc, char **argv)
/* By default, all non-delimited lines are printed. */
suppress_non_delimited = false;
- delim = '\0';
+ delim = 0x7F + 1;
have_read_stdin = false;
while ((optc = getopt_long (argc, argv, "b:c:d:f:ns", longopts, NULL)) != -1)
@@ -846,7 +846,7 @@ main (int argc, char **argv)
if (operating_mode == undefined_mode)
FATAL_ERROR (_("you must specify a list of bytes, characters, or fields"));
- if (delim != '\0' && operating_mode != field_mode)
+ if (delim != 0x7F + 1 && operating_mode != field_mode)
FATAL_ERROR (_("an input delimiter may be specified only\
when operating on fields"));
--
1.8.0.1
Reply sent
to
Pádraig Brady <P <at> draigBrady.com>
:
You have taken responsibility.
(Wed, 05 Dec 2012 01:58:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
"Alexandru Cojocaru" <cojocaru_alexandru <at> gmx.com>
:
bug acknowledged by developer.
(Wed, 05 Dec 2012 01:58:02 GMT)
Full text and
rfc822 format available.
Message #10 received at 13080-done <at> debbugs.gnu.org (full text, mbox):
On 12/04/2012 03:32 PM, Alexandru Cojocaru wrote:
>>From 8ecd92b3c11abc5cde184f0c511cd469190511af Mon Sep 17 00:00:00 2001
> From: Cojocaru Alexandru <xojoc <at> gmx.com>
> Date: Tue, 4 Dec 2012 16:08:42 +0100
> Subject: [PATCH] cut: improve error reporting
>
> * src/cut.c (main): Report error on `-d '' -b1'
>
> * src/cut.c (set_fields): Change the error message when
> the given list is invalid.
> ---
> src/cut.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/src/cut.c b/src/cut.c
> index 4219d24..d55da51 100644
> --- a/src/cut.c
> +++ b/src/cut.c
> @@ -365,7 +365,7 @@ set_fields (const char *fieldstr)
> in_digits = false;
> /* Starting a range. */
> if (dash_found)
> - FATAL_ERROR (_("invalid byte or field list"));
> + FATAL_ERROR (_("invalid byte, character or field list"));
> dash_found = true;
> fieldstr++;
>
> @@ -491,7 +491,7 @@ set_fields (const char *fieldstr)
> fieldstr++;
> }
> else
> - FATAL_ERROR (_("invalid byte or field list"));
> + FATAL_ERROR (_("invalid byte, character or field list"));
> }
>
> max_range_endpoint = 0;
The above is fine.
> @@ -781,7 +781,7 @@ main (int argc, char **argv)
> /* By default, all non-delimited lines are printed. */
> suppress_non_delimited = false;
>
> - delim = '\0';
> + delim = 0x7F + 1;
> have_read_stdin = false;
>
> while ((optc = getopt_long (argc, argv, "b:c:d:f:ns", longopts, NULL)) != -1)
> @@ -846,7 +846,7 @@ main (int argc, char **argv)
> if (operating_mode == undefined_mode)
> FATAL_ERROR (_("you must specify a list of bytes, characters, or fields"));
>
> - if (delim != '\0' && operating_mode != field_mode)
> + if (delim != 0x7F + 1 && operating_mode != field_mode)
> FATAL_ERROR (_("an input delimiter may be specified only\
> when operating on fields"));
Keying on 0x80 doesn't seem right.
I'll apply this hunk instead in your name.
Please confirm.
diff --git a/src/cut.c b/src/cut.c
index 4219d24..f2e63dc 100644
--- a/src/cut.c
+++ b/src/cut.c
@@ -846,7 +846,7 @@ main (int argc, char **argv)
if (operating_mode == undefined_mode)
FATAL_ERROR (_("you must specify a list of bytes, characters, or fields"));
- if (delim != '\0' && operating_mode != field_mode)
+ if (delim_specified && operating_mode != field_mode)
FATAL_ERROR (_("an input delimiter may be specified only\
when operating on fields"));
thanks,
Pádraig.
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#13080
; Package
coreutils
.
(Wed, 05 Dec 2012 13:56:07 GMT)
Full text and
rfc822 format available.
Message #13 received at 13080 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On 12/05/2012 01:57 AM, Pádraig Brady wrote:
> Keying on 0x80 doesn't seem right.
> I'll apply this hunk instead in your name.
> Please confirm.
>
> diff --git a/src/cut.c b/src/cut.c
> index 4219d24..f2e63dc 100644
> --- a/src/cut.c
> +++ b/src/cut.c
> @@ -846,7 +846,7 @@ main (int argc, char **argv)
> if (operating_mode == undefined_mode)
> FATAL_ERROR (_("you must specify a list of bytes, characters, or fields"));
>
> - if (delim != '\0' && operating_mode != field_mode)
> + if (delim_specified && operating_mode != field_mode)
> FATAL_ERROR (_("an input delimiter may be specified only\
> when operating on fields"));
I got confirmation of the adjustment privately,
so I'm going to push the attached two patches,
which augment/adjust the cut test accordingly.
thanks,
Pádraig.
[cut-d-nul.diff (text/x-patch, attachment)]
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#13080
; Package
coreutils
.
(Wed, 05 Dec 2012 14:31:03 GMT)
Full text and
rfc822 format available.
Message #16 received at 13080 <at> debbugs.gnu.org (full text, mbox):
On 12/05/2012 01:55 PM, Pádraig Brady wrote:
> On 12/05/2012 01:57 AM, Pádraig Brady wrote:
>
>> Keying on 0x80 doesn't seem right.
>> I'll apply this hunk instead in your name.
>> Please confirm.
>>
>> diff --git a/src/cut.c b/src/cut.c
>> index 4219d24..f2e63dc 100644
>> --- a/src/cut.c
>> +++ b/src/cut.c
>> @@ -846,7 +846,7 @@ main (int argc, char **argv)
>> if (operating_mode == undefined_mode)
>> FATAL_ERROR (_("you must specify a list of bytes, characters, or fields"));
>>
>> - if (delim != '\0' && operating_mode != field_mode)
>> + if (delim_specified && operating_mode != field_mode)
>> FATAL_ERROR (_("an input delimiter may be specified only\
>> when operating on fields"));
>
> I got confirmation of the adjustment privately,
> so I'm going to push the attached two patches,
> which augment/adjust the cut test accordingly.
The previous mail omitted the following patch.
sorry,
Pádraig.
From b95a20224e40dd5e2d9eb3f0611e1db51b6f4e04 Mon Sep 17 00:00:00 2001
From: Cojocaru Alexandru <xojoc <at> gmx.com>
Date: Wed, 5 Dec 2012 13:13:51 +0000
Subject: [PATCH 1/2] cut: improve error reporting
* src/cut.c (main): Treat a NUL delimiter (-d '') consistently
with non NUL delimiters, and disallow such a delimiter option,
unless a field is also specified.
(set_fields): Provide a more accurate error message when
a given list is invalid.
* tests/misc/cut.pl: Add a test case.
---
src/cut.c | 6 +++---
tests/misc/cut.pl | 7 +++++++
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/src/cut.c b/src/cut.c
index 4219d24..dc83072 100644
--- a/src/cut.c
+++ b/src/cut.c
@@ -365,7 +365,7 @@ set_fields (const char *fieldstr)
in_digits = false;
/* Starting a range. */
if (dash_found)
- FATAL_ERROR (_("invalid byte or field list"));
+ FATAL_ERROR (_("invalid byte, character or field list"));
dash_found = true;
fieldstr++;
@@ -491,7 +491,7 @@ set_fields (const char *fieldstr)
fieldstr++;
}
else
- FATAL_ERROR (_("invalid byte or field list"));
+ FATAL_ERROR (_("invalid byte, character or field list"));
}
max_range_endpoint = 0;
@@ -846,7 +846,7 @@ main (int argc, char **argv)
if (operating_mode == undefined_mode)
FATAL_ERROR (_("you must specify a list of bytes, characters, or fields"));
- if (delim != '\0' && operating_mode != field_mode)
+ if (delim_specified && operating_mode != field_mode)
FATAL_ERROR (_("an input delimiter may be specified only\
when operating on fields"));
diff --git a/tests/misc/cut.pl b/tests/misc/cut.pl
index 27768ff..aff0cbe 100755
--- a/tests/misc/cut.pl
+++ b/tests/misc/cut.pl
@@ -32,6 +32,8 @@ my $try = "Try '$prog --help' for more information.\n";
my $from_1 = "$prog: fields and positions are numbered from 1\n$try";
my $inval = "$prog: invalid byte or field list\n$try";
my $no_endpoint = "$prog: invalid range with no endpoint: -\n$try";
+my $nofield = "$prog: an input delimiter may be specified only when " .
+ "operating on fields\n$try";
my @Tests =
(
@@ -118,6 +120,11 @@ my @Tests =
['multichar-od', qw(-d: --out=_._), '-f2,3', {IN=>"a:b:c\n"},
{OUT=>"b_._c\n"}],
+ # Ensure delim is not allowed without a field
+ # Prior to 8.21, a NUL delim was allowed without a field
+ ['delim-no-field1', qw(-d ''), '-b1', {EXIT=>1}, {ERR=>$nofield}],
+ ['delim-no-field2', qw(-d:), '-b1', {EXIT=>1}, {ERR=>$nofield}],
+
# Prior to 1.22i, you couldn't use a delimiter that would sign-extend.
['8bit-delim', '-d', "\255", '--out=_', '-f2,3', {IN=>"a\255b\255c\n"},
{OUT=>"b_c\n"}],
--
1.7.6.4
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Thu, 03 Jan 2013 12:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 12 years and 228 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.