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.
Modified files: Index: src/bin/cat/cat.c diff -u src/bin/cat/cat.c:1.56 src/bin/cat/cat.c:1.57 --- src/bin/cat/cat.c:1.56 Thu Jun 16 00:45:37 2016 +++ src/bin/cat/cat.c Thu Jun 16 00:52:37 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: cat.c,v 1.56 2016/06/16 00:45:37 sevan Exp $ */ +/* $NetBSD: cat.c,v 1.57 2016/06/16 00:52:37 sevan Exp $ */ /* * Copyright (c) 1989, 1993 @@ -44,7 +44,7 @@ __COPYRIGHT( #if 0 static char sccsid[] = "@(#)cat.c 8.2 (Berkeley) 4/27/95"; #else -__RCSID("$NetBSD: cat.c,v 1.56 2016/06/16 00:45:37 sevan Exp $"); +__RCSID("$NetBSD: cat.c,v 1.57 2016/06/16 00:52:37 sevan Exp $"); #endif #endif /* not lint */ @@ -175,18 +175,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)) @@ -198,13 +196,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)