Subject: Re: bug#13080: [PATHC] improve error reporting

From: Pádraig Brady <[email-masked]>
Date: Wed, 05 Dec 2012 01:57:22 +0000

On 12/04/2012 03:32 PM, Alexandru Cojocaru wrote:
>>>From 8ecd92b3c11abc5cde184f0c511cd469190511af Mon Sep 17 00:00:00 2001
> From: Cojocaru Alexandru <[email-masked]>
> 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.