Print the "$" symbol on blank lines when the -s and -e options are used

together.

Obtained from:	OpenBSD (millert, Denis Afonin)
This commit is contained in:
Tim J. Robbins 2002-06-13 14:05:26 +00:00
parent 99cc224074
commit bf5f0c446e

View File

@ -179,29 +179,23 @@ cook_cat(FILE *fp)
line = gobble = 0; line = gobble = 0;
for (prev = '\n'; (ch = getc(fp)) != EOF; prev = ch) { for (prev = '\n'; (ch = getc(fp)) != EOF; prev = ch) {
if (prev == '\n') { if (prev == '\n') {
if (ch == '\n') { if (sflag) {
if (sflag) { if (ch == '\n') {
if (!gobble && putchar(ch) == EOF) if (gobble)
break; continue;
gobble = 1; gobble = 1;
continue; } else
} gobble = 0;
if (nflag && !bflag) { }
fprintf(stdout, "%6d\t", ++line); if (nflag && (!bflag || ch != '\n')) {
if (ferror(stdout)) (void)fprintf(stdout, "%6d\t", ++line);
break;
}
} else if (nflag) {
fprintf(stdout, "%6d\t", ++line);
if (ferror(stdout)) if (ferror(stdout))
break; break;
} }
} }
gobble = 0;
if (ch == '\n') { if (ch == '\n') {
if (eflag) if (eflag && putchar('$') == EOF)
if (putchar('$') == EOF) break;
break;
} else if (ch == '\t') { } else if (ch == '\t') {
if (tflag) { if (tflag) {
if (putchar('^') == EOF || putchar('I') == EOF) if (putchar('^') == EOF || putchar('I') == EOF)