Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-7]: src Pull up following revision(s) (requested by sevan in tick...



details:   https://anonhg.NetBSD.org/src/rev/db05d5e8180e
branches:  netbsd-7
changeset: 799928:db05d5e8180e
user:      snj <snj%NetBSD.org@localhost>
date:      Tue Jul 05 19:03:31 2016 +0000

description:
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

diffstat:

 bin/cat/cat.c                 |  26 +++++++++-----------------
 distrib/sets/lists/tests/mi   |   4 +++-
 tests/bin/cat/Makefile        |   4 +++-
 tests/bin/cat/d_se_output.in  |   3 +++
 tests/bin/cat/d_se_output.out |   3 +++
 tests/bin/cat/t_cat.sh        |  14 +++++++++++++-
 6 files changed, 34 insertions(+), 20 deletions(-)

diffs (137 lines):

diff -r cb07a652d544 -r db05d5e8180e bin/cat/cat.c
--- a/bin/cat/cat.c     Fri Jul 01 07:50:06 2016 +0000
+++ b/bin/cat/cat.c     Tue Jul 05 19:03:31 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cat.c,v 1.54 2013/12/08 08:32:13 spz Exp $ */
+/* $NetBSD: cat.c,v 1.54.4.1 2016/07/05 19:03:31 snj Exp $     */
 
 /*
  * Copyright (c) 1989, 1993
@@ -44,7 +44,7 @@
 #if 0
 static char sccsid[] = "@(#)cat.c      8.2 (Berkeley) 4/27/95";
 #else
-__RCSID("$NetBSD: cat.c,v 1.54 2013/12/08 08:32:13 spz Exp $");
+__RCSID("$NetBSD: cat.c,v 1.54.4.1 2016/07/05 19:03:31 snj Exp $");
 #endif
 #endif /* not lint */
 
@@ -175,18 +175,16 @@
        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))
@@ -198,13 +196,7 @@
                                                        break;
                                        }
                                }
-                       } else if (nflag) {
-                               (void)fprintf(stdout, "%6d\t", ++line);
-                               if (ferror(stdout))
-                                       break;
                        }
-               }
-               gobble = 0;
                if (ch == '\n') {
                        if (eflag)
                                if (putchar('$') == EOF)
diff -r cb07a652d544 -r db05d5e8180e distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Fri Jul 01 07:50:06 2016 +0000
+++ b/distrib/sets/lists/tests/mi       Tue Jul 05 19:03:31 2016 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.584.2.3 2015/08/06 21:13:43 snj Exp $
+# $NetBSD: mi,v 1.584.2.4 2016/07/05 19:03:31 snj Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -801,6 +801,8 @@
 ./usr/tests/bin/cat/Kyuafile                   tests-bin-tests         atf,kyua
 ./usr/tests/bin/cat/d_align.in                 tests-bin-tests         atf
 ./usr/tests/bin/cat/d_align.out                        tests-bin-tests         atf
+./usr/tests/bin/cat/d_se_output.in             tests-bin-tests         atf
+./usr/tests/bin/cat/d_se_output.out            tests-bin-tests         atf
 ./usr/tests/bin/cat/t_cat                      tests-bin-tests         atf
 ./usr/tests/bin/cp                             tests-bin-tests
 ./usr/tests/bin/cp/Atffile                     tests-bin-tests         atf
diff -r cb07a652d544 -r db05d5e8180e tests/bin/cat/Makefile
--- a/tests/bin/cat/Makefile    Fri Jul 01 07:50:06 2016 +0000
+++ b/tests/bin/cat/Makefile    Tue Jul 05 19:03:31 2016 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.1 2012/03/27 08:16:33 jruoho Exp $
+# $NetBSD: Makefile,v 1.1.12.1 2016/07/05 19:03:31 snj Exp $
 
 .include <bsd.own.mk>
 
@@ -8,5 +8,7 @@
 FILESDIR=      ${TESTSDIR}
 FILES+=                d_align.in
 FILES+=                d_align.out
+FILES+=        d_se_output.in
+FILES+=        d_se_output.out
 
 .include <bsd.test.mk>
diff -r cb07a652d544 -r db05d5e8180e tests/bin/cat/d_se_output.in
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/bin/cat/d_se_output.in      Tue Jul 05 19:03:31 2016 +0000
@@ -0,0 +1,3 @@
+
+Of course it runs NetBSD
+
diff -r cb07a652d544 -r db05d5e8180e tests/bin/cat/d_se_output.out
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/bin/cat/d_se_output.out     Tue Jul 05 19:03:31 2016 +0000
@@ -0,0 +1,3 @@
+$
+Of course it runs NetBSD$
+$
diff -r cb07a652d544 -r db05d5e8180e tests/bin/cat/t_cat.sh
--- a/tests/bin/cat/t_cat.sh    Fri Jul 01 07:50:06 2016 +0000
+++ b/tests/bin/cat/t_cat.sh    Tue Jul 05 19:03:31 2016 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_cat.sh,v 1.2 2012/03/27 17:57:02 jruoho Exp $
+# $NetBSD: t_cat.sh,v 1.2.12.1 2016/07/05 19:03:31 snj Exp $
 #
 # Copyright (c) 2012 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -52,8 +52,20 @@
                -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
 }



Home | Main Index | Thread Index | Old Index