do -s processing, even if output not a tty
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Mon, 28 Nov 1988 10:28:18 +0000 (02:28 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Mon, 28 Nov 1988 10:28:18 +0000 (02:28 -0800)
SCCS-vsn: usr.bin/more/main.c 5.10

usr/src/usr.bin/more/main.c

index 5259232..edaa238 100644 (file)
@@ -25,7 +25,7 @@ char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)main.c     5.9 (Berkeley) %G%";
+static char sccsid[] = "@(#)main.c     5.10 (Berkeley) %G%";
 #endif /* not lint */
 
 /*
 #endif /* not lint */
 
 /*
@@ -200,15 +200,28 @@ prev_file(n)
 }
 
 /*
 }
 
 /*
- * Copy a file directly to standard output.
- * Used if standard output is not a tty.
+ * copy a file directly to standard output; used if stdout is not a tty.
+ * the only processing is to squeeze multiple blank input lines.
  */
 static
 cat_file()
 {
  */
 static
 cat_file()
 {
-       register int c;
+       extern int squeeze;
+       register int c, empty;
 
 
-       while ((c = ch_forw_get()) != EOI)
+       if (squeeze) {
+               empty = 0;
+               while ((c = ch_forw_get()) != EOI)
+                       if (c != '\n') {
+                               putchr(c);
+                               empty = 0;
+                       }
+                       else if (empty < 2) {
+                               putchr(c);
+                               ++empty;
+                       }
+       }
+       else while ((c = ch_forw_get()) != EOI)
                putchr(c);
        flush();
 }
                putchr(c);
        flush();
 }