projects
/
unix-history
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
tags
|
clone url
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
do -s processing, even if output not a tty
[unix-history]
/
usr
/
src
/
usr.bin
/
more
/
main.c
diff --git
a/usr/src/usr.bin/more/main.c
b/usr/src/usr.bin/more/main.c
index
5259232
..
edaa238
100644
(file)
--- a/
usr/src/usr.bin/more/main.c
+++ b/
usr/src/usr.bin/more/main.c
@@
-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();
}