NetBSD Problem Report #55891

From www@netbsd.org  Tue Dec 22 08:52:25 2020
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 497F11A921F
	for <gnats-bugs@gnats.NetBSD.org>; Tue, 22 Dec 2020 08:52:25 +0000 (UTC)
Message-Id: <20201222085224.58FB91A923A@mollari.NetBSD.org>
Date: Tue, 22 Dec 2020 08:52:24 +0000 (UTC)
From: a1415tk@aiit.ac.jp
Reply-To: a1415tk@aiit.ac.jp
To: gnats-bugs@NetBSD.org
Subject: /usr/bin/nl breaks POSIX compatibility
X-Send-Pr-Version: www-1.0

>Number:         55891
>Category:       bin
>Synopsis:       /usr/bin/nl breaks POSIX compatibility
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    ginsbach
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Dec 22 08:55:00 +0000 2020
>Closed-Date:    Wed Mar 03 17:05:38 +0000 2021
>Last-Modified:  Wed Mar 03 17:05:38 +0000 2021
>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:/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");

>Release-Note:

>Audit-Trail:
	Take ginsbach
Responsible-Changed-From-To: bin-bug-people->ginsbach
Responsible-Changed-By: ginsbach@NetBSD.org
Responsible-Changed-When: Thu, 31 Dec 2020 03:52:12 +0000
Responsible-Changed-Why:
ginsbach working on PR


From: Brian Ginsbach <ginsbach@netbsd.org>
To: gnats-bugs@netbsd.org
Cc: a1415tk@aiit.ac.jp
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 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:/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

From: "Brian Ginsbach" <ginsbach@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/55891 CVS commit: src/usr.bin/nl
Date: Thu, 31 Dec 2020 04:07:37 +0000

 Module Name:	src
 Committed By:	ginsbach
 Date:		Thu Dec 31 04:07:37 UTC 2020

 Modified Files:
 	src/usr.bin/nl: nl.c

 Log Message:
 PR/55891 supress displaying separator when numbers supressed

 Fix based on patch provided by Kobayashi Takashi. This brings nl(1) further
 in to POSIX compliance. Verified behavior with classic SysV nl(1) and GNU
 nl(1). There could still be edge cases here not specified by POSIX.


 To generate a diff of this commit:
 cvs rdiff -u -r1.14 -r1.15 src/usr.bin/nl/nl.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->feedback
State-Changed-By: ginsbach@NetBSD.org
State-Changed-When: Wed, 03 Feb 2021 21:17:22 +0000
State-Changed-Why:
Fix committed.


From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/55891 CVS commit: [netbsd-9] src/usr.bin/nl
Date: Wed, 10 Feb 2021 16:54:53 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Wed Feb 10 16:54:52 UTC 2021

 Modified Files:
 	src/usr.bin/nl [netbsd-9]: nl.c

 Log Message:
 Pull up following revision(s) (requested by ginsbach in ticket #1202):

 	usr.bin/nl/nl.c: revision 1.13
 	usr.bin/nl/nl.c: revision 1.14
 	usr.bin/nl/nl.c: revision 1.15

 nl(1): remove superfluous exit

 Remove exit(3) call missed when errors were converted to errx(3).

 nl: fix -d delim parsing for POSIX
 POSIX specifies it is possible to specify a one delimiter character.
 Fix the logic so that both one and two character delimiters are accepted.

 PR/55891 supress displaying separator when numbers supressed

 Fix based on patch provided by Kobayashi Takashi. This brings nl(1) further
 in to POSIX compliance. Verified behavior with classic SysV nl(1) and GNU
 nl(1). There could still be edge cases here not specified by POSIX.


 To generate a diff of this commit:
 cvs rdiff -u -r1.12 -r1.12.28.1 src/usr.bin/nl/nl.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/55891 CVS commit: [netbsd-8] src/usr.bin/nl
Date: Wed, 10 Feb 2021 16:56:52 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Wed Feb 10 16:56:52 UTC 2021

 Modified Files:
 	src/usr.bin/nl [netbsd-8]: nl.c

 Log Message:
 Pull up following revision(s) (requested by ginsbach in ticket #1651):

 	usr.bin/nl/nl.c: revision 1.13
 	usr.bin/nl/nl.c: revision 1.14
 	usr.bin/nl/nl.c: revision 1.15

 nl(1): remove superfluous exit

 Remove exit(3) call missed when errors were converted to errx(3).

 nl: fix -d delim parsing for POSIX
 POSIX specifies it is possible to specify a one delimiter character.
 Fix the logic so that both one and two character delimiters are accepted.

 PR/55891 supress displaying separator when numbers supressed

 Fix based on patch provided by Kobayashi Takashi. This brings nl(1) further
 in to POSIX compliance. Verified behavior with classic SysV nl(1) and GNU
 nl(1). There could still be edge cases here not specified by POSIX.


 To generate a diff of this commit:
 cvs rdiff -u -r1.12 -r1.12.18.1 src/usr.bin/nl/nl.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: feedback->closed
State-Changed-By: ginsbach@NetBSD.org
State-Changed-When: Wed, 03 Mar 2021 17:05:38 +0000
State-Changed-Why:
Bug is fixed. Feedback timeout from submitter.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.