diff options
author | tjr <tjr@FreeBSD.org> | 2002-06-13 14:05:26 +0000 |
---|---|---|
committer | tjr <tjr@FreeBSD.org> | 2002-06-13 14:05:26 +0000 |
commit | 2f568aeb91d6d5f3b370b9b641b5a64a3466d1bd (patch) | |
tree | 5b9c079223f2bc10fc151ffb4841f3467a8b2f11 /bin | |
parent | dea54737474f1e4d39edbdd08862e39751a2bd7a (diff) | |
download | FreeBSD-src-2f568aeb91d6d5f3b370b9b641b5a64a3466d1bd.zip FreeBSD-src-2f568aeb91d6d5f3b370b9b641b5a64a3466d1bd.tar.gz |
Print the "$" symbol on blank lines when the -s and -e options are used
together.
Obtained from: OpenBSD (millert, Denis Afonin)
Diffstat (limited to 'bin')
-rw-r--r-- | bin/cat/cat.c | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/bin/cat/cat.c b/bin/cat/cat.c index 2186946..2648a7d 100644 --- a/bin/cat/cat.c +++ b/bin/cat/cat.c @@ -179,29 +179,23 @@ cook_cat(FILE *fp) line = gobble = 0; for (prev = '\n'; (ch = getc(fp)) != EOF; prev = ch) { if (prev == '\n') { - if (ch == '\n') { - if (sflag) { - if (!gobble && putchar(ch) == EOF) - break; + if (sflag) { + if (ch == '\n') { + if (gobble) + continue; gobble = 1; - continue; - } - if (nflag && !bflag) { - fprintf(stdout, "%6d\t", ++line); - if (ferror(stdout)) - break; - } - } else if (nflag) { - fprintf(stdout, "%6d\t", ++line); + } else + gobble = 0; + } + if (nflag && (!bflag || ch != '\n')) { + (void)fprintf(stdout, "%6d\t", ++line); if (ferror(stdout)) break; } } - gobble = 0; if (ch == '\n') { - if (eflag) - if (putchar('$') == EOF) - break; + if (eflag && putchar('$') == EOF) + break; } else if (ch == '\t') { if (tflag) { if (putchar('^') == EOF || putchar('I') == EOF) |