diff options
author | Jakob Kaivo <jkk@ung.org> | 2020-07-14 14:34:21 -0400 |
---|---|---|
committer | Jakob Kaivo <jkk@ung.org> | 2020-07-14 14:34:21 -0400 |
commit | ea8d0dfcd29f9f014bbd7f8c1065d8d949b89658 (patch) | |
tree | e4b532479122dd2c23383001c8694446c2d01dae | |
parent | 5998db47316af2c9cd7dbe6f9d62420de1726d6d (diff) |
only test for blank line compression once
-rw-r--r-- | more.c | 12 |
1 files changed, 5 insertions, 7 deletions
@@ -381,7 +381,7 @@ static void compress_loop(FILE *f) } } -static int more_cat(const char *path, int compressempty) +static int more_cat(const char *path, void (*loop)(FILE *)) { FILE *f = stdin; if (path != NULL && strcmp(path, "-") != 0) { @@ -392,11 +392,7 @@ static int more_cat(const char *path, int compressempty) } } - if (compressempty) { - compress_loop(f); - } else { - cat_loop(f); - } + loop(f); if (f != stdin) { fclose(f); @@ -460,13 +456,15 @@ int main(int argc, char *argv[]) if (!isatty(STDOUT_FILENO)) { int ret = 0; + void (*loop)(FILE*) = compressempty ? compress_loop : cat_loop; do { - ret |= more_cat(argv[optind++], compressempty); + ret |= more_cat(argv[optind++], loop); } while (optind < argc); return ret; } openrawtty(); + global.lines--; if (optind >= argc) { |