NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: bin/55891: /usr/bin/nl breaks POSIX compatibility
The following reply was made to PR bin/55891; it has been noted by GNATS.
From: Brian Ginsbach <ginsbach%netbsd.org@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc: a1415tk%aiit.ac.jp@localhost
Subject: Re: bin/55891: /usr/bin/nl breaks POSIX compatibility
Date: Thu, 31 Dec 2020 03:58:20 +0000
On Tue, Dec 22, 2020 at 08:55:00AM +0000, a1415tk%aiit.ac.jp@localhost wrote:
> >Number: 55891
> >Category: bin
> >Synopsis: /usr/bin/nl breaks POSIX compatibility
> >Confidential: no
> >Severity: non-critical
> >Priority: medium
> >Responsible: bin-bug-people
> >State: open
> >Class: sw-bug
> >Submitter-Id: net
> >Arrival-Date: Tue Dec 22 08:55:00 +0000 2020
> >Originator: Kobayashi Takashi
> >Release: 9.1
> >Organization:
> AIIT
> >Environment:
> NetBSD localhost 9.1 NetBSD 9.1 (GENERIC) #0: Sun Oct 18 19:24:30 UTC 2020 mkrepro%mkrepro.NetBSD.org@localhost:/usr/src/sys/arch/amd64/compile/GENERIC amd64
>
> >Description:
> In POSIX, the "STDOUT" section of nl requires the following:
> > When line numbers are suppressed for a portion of the page; the <separator> is also suppressed.
>
> However, it is not actually suppressed.
> >How-To-Repeat:
> $ yes '' | head | nl -s@
> @
> @
> @
> @
> @
> @
> @
> @
> @
> @
>
> >Fix:
> Maybe...
>
> --- nl.c 2020-12-15 14:49:35.652652227 -0800
> +++ nl.new.c 2020-12-22 00:46:06.599251927 -0800
> @@ -331,13 +331,13 @@
> if (donumber) {
> consumed = snprintf(intbuffer, intbuffersize, format,
> width, line);
> - (void)printf("%s",
> - intbuffer + max(0, consumed - width));
> + (void)printf("%s%s",
> + intbuffer + max(0, consumed - width), sep);
> line += incr;
> } else {
> (void)printf("%*s", width, "");
> }
> - (void)printf("%s%s", sep, buffer);
> + (void)printf("%s", buffer);
>
> if (ferror(stdout))
> err(EXIT_FAILURE, "output error");
>
The above is close but oddly when the sep is suppressed the space it would
take is still emitted. This is both the historical SysV nl(1) behavior and
GNU nl(1) behavior.
--
Brian Ginsbach
ginsbach%netbsd.org@localhost
Home |
Main Index |
Thread Index |
Old Index