Subject: bin/32759: Output of cat -s -n is wrong
To: None <gnats-admin@netbsd.org, netbsd-bugs@netbsd.org>
From: None <uhel@gmx.net>
List: netbsd-bugs
Date: 02/06/2006 23:25:00
>Number: 32759
>Category: bin
>Synopsis: Output of cat -s -n is wrong
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Feb 06 23:25:00 +0000 2006
>Originator: Ulrich Heilmann
>Release: 2.0
>Organization:
>Environment:
>Description:
man 1 cat:
.....
-n Number the output lines, starting at 1.
-b Implies the -n option but doesn't number blank lines.
-s Squeeze multiple adjacent empty lines, causing the output to be single spaced.
cat -s -n doesn't number all output lines, it behaves like cat -s -b.
Testet on NetBSD 2.0 & 3.0
>How-To-Repeat:
>Fix:
diff -u
--- /data2/NetBSD/NBSD3/release/src/bin/cat/cat.c 2006-02-01 00:22:45.000000000 +0100
+++ cat.c 2006-02-07 00:11:17.000000000 +0100
@@ -173,7 +173,9 @@
if (prev == '\n') {
if (ch == '\n') {
if (sflag) {
- if (!gobble && putchar(ch) == EOF)
+ if (!gobble && !bflag)
+ (void)fprintf(stdout, "%6d\t\n", ++line) ;
+ else if (!gobble && putchar(ch) == EOF)
break;
gobble = 1;
continue;