- if (nwsp || !(f & f_newline)) {
- if (flags & F_VERBOSE)
- fprintf(stderr, "%s:%u: file ends in mid-line\n", name, nl);
- status = BADNESS;
- if (fout) putc('\n', fout);
+ if (!(f & f_begin)) {
+ if (!(f & f_newline)) {
+ if (flags & F_VERBOSE)
+ fprintf(stderr, "%s:%u: file ends in mid-line\n", name, nl);
+ status = BADNESS;
+ nnl = 1;
+ } else if (nnl > 1) {
+ if (flags & F_TBLANK) {
+ if (flags & F_VERBOSE) {
+ fprintf(stderr, "%s:%u: file has trailing blank lines\n",
+ name, nl - nnl + 1);
+ }
+ status = BADNESS;
+ nnl = 1;
+ }
+ }
+ if (fout) while (nnl--) putc('\n', fout); else nnl = 0;