diff options
author | Jakob Kaivo <jkk@ung.org> | 2020-07-14 12:20:06 -0400 |
---|---|---|
committer | Jakob Kaivo <jkk@ung.org> | 2020-07-14 12:20:06 -0400 |
commit | 75f16e09b7cdc6f7323bc095c4401c9e5baae065 (patch) | |
tree | e95c032cc227d93a81384ccdd2f525a5ae8da0b7 | |
parent | fda3ed8bb7bcce4cbac96c8e3280e40a6b4d89d2 (diff) |
carry newline compression between files
-rw-r--r-- | more.c | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -375,14 +375,18 @@ static void cat_loop(FILE *f) static void compress_loop(FILE *f) { + static int nl = 0; int c = 0; - int nl = 0; + while ((c = fgetc(f)) != EOF) { if (c == '\n') { - if (nl) { + if (nl == 2) { continue; + } else if (nl == 1) { + nl = 2; + } else { + nl = 1; } - nl = 1; } else { nl = 0; } |