summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2020-07-14 12:20:06 -0400
committerJakob Kaivo <jkk@ung.org>2020-07-14 12:20:06 -0400
commit75f16e09b7cdc6f7323bc095c4401c9e5baae065 (patch)
treee95c032cc227d93a81384ccdd2f525a5ae8da0b7
parentfda3ed8bb7bcce4cbac96c8e3280e40a6b4d89d2 (diff)
carry newline compression between files
-rw-r--r--more.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/more.c b/more.c
index a27f740..d546b9b 100644
--- a/more.c
+++ b/more.c
@@ -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;
}