NetBSD Problem Report #51250
From www@NetBSD.org Thu Jun 16 00:21:35 2016
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 "Postmaster NetBSD.org" (verified OK))
by mollari.NetBSD.org (Postfix) with ESMTPS id 1FE417A474
for <gnats-bugs@gnats.NetBSD.org>; Thu, 16 Jun 2016 00:21:35 +0000 (UTC)
Message-Id: <20160616002133.D80A57AAB1@mollari.NetBSD.org>
Date: Thu, 16 Jun 2016 00:21:33 +0000 (UTC)
From: venture37@geeklan.co.uk
Reply-To: venture37@geeklan.co.uk
To: gnats-bugs@NetBSD.org
Subject: A '$' is printed for blank lines when invoked with -se
X-Send-Pr-Version: www-1.0
>Number: 51250
>Category: bin
>Synopsis: A '$' is printed for blank lines when invoked with -se
>Confidential: no
>Severity: serious
>Priority: low
>Responsible: sevan
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Jun 16 00:25:00 +0000 2016
>Closed-Date: Thu Jun 16 11:55:44 +0000 2016
>Last-Modified: Sat Mar 25 17:45:00 +0000 2017
>Originator: Sevan Janiyan
>Release: Netbsd-head
>Organization:
Venture 37 Ltd
>Environment:
NetBSD 7.99.26 NetBSD 7.99.26 (GENERIC) #0: Sat Apr 2 19:23:46 UTC 2016 /usr/obj/sys/arch/amd64/compile/GENERIC amd64
>Description:
When 'cat -se' is used, a '$' is not printed for blank lines
>How-To-Repeat:
invoke cat with -se on a file containing empty lines. observe missing $ on those lines.
>Fix:
Obtained from OpenBSD r1.13 of src/bin/cat/cat.c
Index: cat.c
===================================================================
RCS file: /cvsroot/src/bin/cat/cat.c,v
retrieving revision 1.55
diff -u -p -u -r1.55 cat.c
--- cat.c 25 Jul 2015 16:17:01 -0000 1.55
+++ cat.c 3 Jun 2016 01:17:35 -0000
@@ -174,18 +174,16 @@ cook_buf(FILE *fp)
line = gobble = 0;
for (prev = '\n'; (ch = getc(fp)) != EOF; prev = ch) {
if (prev == '\n') {
- if (ch == '\n') {
- if (sflag) {
- if (!gobble && nflag && !bflag)
- (void)fprintf(stdout,
- "%6d\t\n", ++line);
- else if (!gobble && putchar(ch) == EOF)
- break;
+ if (sflag) {
+ if (ch == '\n') {
+ if (gobble)
+ continue;
gobble = 1;
- continue;
+ } else
+ gobble = 0;
}
if (nflag) {
- if (!bflag) {
+ if (!bflag || ch != '\n') {
(void)fprintf(stdout,
"%6d\t", ++line);
if (ferror(stdout))
@@ -197,13 +195,7 @@ cook_buf(FILE *fp)
break;
}
}
- } else if (nflag) {
- (void)fprintf(stdout, "%6d\t", ++line);
- if (ferror(stdout))
- break;
}
- }
- gobble = 0;
if (ch == '\n') {
if (eflag)
if (putchar('$') == EOF)
>Release-Note:
>Audit-Trail:
From: Sevan Janiyan <venture37@geeklan.co.uk>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: bin/51250: A '$' is printed for blank lines when invoked with -se
Date: Thu, 16 Jun 2016 01:35:06 +0100
This is a multi-part message in MIME format.
--------------EFDB8D92D6D9C8336CE4479F
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Following on from thread on tech-userlevel, include a unit test.
[1] http://mail-index.netbsd.org/tech-userlevel/2016/06/03/msg010085.html
--------------EFDB8D92D6D9C8336CE4479F
Content-Type: text/plain; charset=UTF-8;
name="pr-bin-51250.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="pr-bin-51250.txt"
Index: tests/bin/cat/Makefile
===================================================================
RCS file: /cvsroot/src/tests/bin/cat/Makefile,v
retrieving revision 1.1
diff -u -p -u -r1.1 Makefile
--- tests/bin/cat/Makefile 27 Mar 2012 08:16:33 -0000 1.1
+++ tests/bin/cat/Makefile 16 Jun 2016 00:29:24 -0000
@@ -8,5 +8,7 @@ TESTS_SH= t_cat
FILESDIR= ${TESTSDIR}
FILES+= d_align.in
FILES+= d_align.out
+FILES+= d_se_output.in
+FILES+= d_se_output.out
.include <bsd.test.mk>
Index: tests/bin/cat/d_se_output.in
===================================================================
RCS file: tests/bin/cat/d_se_output.in
diff -N tests/bin/cat/d_se_output.in
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/bin/cat/d_se_output.in 16 Jun 2016 00:29:24 -0000
@@ -0,0 +1,3 @@
+
+Of course it runs NetBSD
+
Index: tests/bin/cat/d_se_output.out
===================================================================
RCS file: tests/bin/cat/d_se_output.out
diff -N tests/bin/cat/d_se_output.out
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/bin/cat/d_se_output.out 16 Jun 2016 00:29:24 -0000
@@ -0,0 +1,3 @@
+$
+Of course it runs NetBSD$
+$
Index: tests/bin/cat/t_cat.sh
===================================================================
RCS file: /cvsroot/src/tests/bin/cat/t_cat.sh,v
retrieving revision 1.2
diff -u -p -u -r1.2 t_cat.sh
--- tests/bin/cat/t_cat.sh 27 Mar 2012 17:57:02 -0000 1.2
+++ tests/bin/cat/t_cat.sh 16 Jun 2016 00:29:24 -0000
@@ -52,8 +52,20 @@ nonexistent_body() {
-x "cat /some/name/that/does/not/exist"
}
+atf_test_case se_output
+se_output_head() {
+ atf_set "descr" "Test that cat(1) prints a $ sign " \
+ "on blank lines with options '-se' (PR bin/51250)"
+}
+
+se_output_body() {
+ atf_check -s ignore -o file:$(atf_get_srcdir)/d_se_output.out \
+ -x "cat -se $(atf_get_srcdir)/d_se_output.in"
+}
+
atf_init_test_cases()
{
atf_add_test_case align
atf_add_test_case nonexistent
+ atf_add_test_case se_output
}
--------------EFDB8D92D6D9C8336CE4479F--
From: "Sevan Janiyan" <sevan@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/51250 CVS commit: src/bin/cat
Date: Thu, 16 Jun 2016 00:52:38 +0000
Module Name: src
Committed By: sevan
Date: Thu Jun 16 00:52:37 UTC 2016
Modified Files:
src/bin/cat: cat.c
Log Message:
When invoked with -se, print a '$' on blank lines
Obtained from OpenBSD r1.13 of src/bin/cat/cat.c
Closes PR bin/51250
Reviewed by Christos@
To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/bin/cat/cat.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Sevan Janiyan" <sevan@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/51250 CVS commit: src/tests/bin/cat
Date: Thu, 16 Jun 2016 01:04:58 +0000
Module Name: src
Committed By: sevan
Date: Thu Jun 16 01:04:58 UTC 2016
Modified Files:
src/tests/bin/cat: Makefile t_cat.sh
Added Files:
src/tests/bin/cat: d_se_output.in d_se_output.out
Log Message:
Add a unit test for PR bin/51250 called se_output. se_output checks the output of cat
when invoked with '-se', to ensure that a '$' is printed on blank lines.
To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/bin/cat/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/bin/cat/d_se_output.in \
src/tests/bin/cat/d_se_output.out
cvs rdiff -u -r1.2 -r1.3 src/tests/bin/cat/t_cat.sh
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Responsible-Changed-From-To: bin-bug-people->sevan
Responsible-Changed-By: sevan@NetBSD.org
Responsible-Changed-When: Thu, 16 Jun 2016 11:55:44 +0000
Responsible-Changed-Why:
taking as I handled it
State-Changed-From-To: open->closed
State-Changed-By: sevan@NetBSD.org
State-Changed-When: Thu, 16 Jun 2016 11:55:44 +0000
State-Changed-Why:
Committed
From: "Soren Jacobsen" <snj@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/51250 CVS commit: [netbsd-7] src
Date: Tue, 5 Jul 2016 19:03:31 +0000
Module Name: src
Committed By: snj
Date: Tue Jul 5 19:03:31 UTC 2016
Modified Files:
src/bin/cat [netbsd-7]: cat.c
src/distrib/sets/lists/tests [netbsd-7]: mi
src/tests/bin/cat [netbsd-7]: Makefile t_cat.sh
Added Files:
src/tests/bin/cat [netbsd-7]: d_se_output.in d_se_output.out
Log Message:
Pull up following revision(s) (requested by sevan in ticket #1182):
bin/cat/cat.c: revision 1.57
distrib/sets/lists/tests/mi: revision 1.675
tests/bin/cat/Makefile: revision 1.2
tests/bin/cat/d_se_output.in: revision 1.1
tests/bin/cat/d_se_output.out: revision 1.1
tests/bin/cat/t_cat.sh: revision 1.3
When invoked with -se, print a '$' on blank lines
Obtained from OpenBSD r1.13 of src/bin/cat/cat.c
Closes PR bin/51250
Reviewed by Christos@
--
Add a unit test for PR bin/51250 called se_output. se_output checks
the output of cat when invoked with '-se', to ensure that a '$' is
printed on blank lines.
--
Add input/output files for new test case - fix build
To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.54.4.1 src/bin/cat/cat.c
cvs rdiff -u -r1.584.2.3 -r1.584.2.4 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.1 -r1.1.12.1 src/tests/bin/cat/Makefile
cvs rdiff -u -r0 -r1.1.2.2 src/tests/bin/cat/d_se_output.in \
src/tests/bin/cat/d_se_output.out
cvs rdiff -u -r1.2 -r1.2.12.1 src/tests/bin/cat/t_cat.sh
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Soren Jacobsen" <snj@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/51250 CVS commit: [netbsd-6] src/bin/cat
Date: Sat, 25 Mar 2017 17:41:49 +0000
Module Name: src
Committed By: snj
Date: Sat Mar 25 17:41:48 UTC 2017
Modified Files:
src/bin/cat [netbsd-6]: cat.c
Log Message:
Pull up following revision(s) (requested by sevan in ticket #1387):
bin/cat/cat.c: revision 1.57
When invoked with -se, print a '$' on blank lines
Obtained from OpenBSD r1.13 of src/bin/cat/cat.c
Closes PR bin/51250
Reviewed by Christos@
To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.47.20.1 src/bin/cat/cat.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.