NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
bin/51250: A '$' is printed for blank lines when invoked with -se
>Number: 51250
>Category: bin
>Synopsis: A '$' is printed for blank lines when invoked with -se
>Confidential: no
>Severity: serious
>Priority: low
>Responsible: bin-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Jun 16 00:25:00 +0000 2016
>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)
Home |
Main Index |
Thread Index |
Old Index