Commit | Line | Data |
---|---|---|
45964d3d BJ |
1 | #include <stdio.h> |
2 | /* | |
3 | * ssp - single space output | |
4 | * | |
5 | * Bill Joy UCB August 25, 1977 | |
6 | * | |
7 | * Compress multiple empty lines to a single empty line. | |
8 | * Option - compresses to nothing. | |
9 | */ | |
10 | ||
11 | char poof, hadsome; | |
12 | ||
13 | int ibuf[256]; | |
14 | ||
15 | ||
16 | main(argc, argv) | |
17 | int argc; | |
18 | char *argv[]; | |
19 | { | |
20 | register int c; | |
21 | FILE *f; | |
22 | ||
23 | argc--, argv++; | |
24 | do { | |
25 | while (argc > 0 && argv[0][0] == '-') { | |
26 | poof = 1; | |
27 | argc--, argv++; | |
28 | } | |
29 | f = stdin; | |
30 | if (argc > 0) { | |
31 | if ((f=fopen(argv[0], "r")) == NULL) { | |
32 | fflush(f); | |
33 | perror(argv[0]); | |
34 | exit(1); | |
35 | } | |
36 | argc--, argv++; | |
37 | } | |
38 | for (;;) { | |
39 | c = getc(f); | |
40 | if (c == -1) | |
41 | break; | |
42 | if (c != '\n') { | |
43 | hadsome = 1; | |
44 | putchar(c); | |
45 | continue; | |
46 | } | |
47 | /* | |
48 | * Eat em up | |
49 | */ | |
50 | if (hadsome) | |
51 | putchar('\n'); | |
52 | c = getc(f); | |
53 | if (c == -1) | |
54 | break; | |
55 | if (c != '\n') { | |
56 | putchar(c); | |
57 | hadsome = 1; | |
58 | continue; | |
59 | } | |
60 | do | |
61 | c = getc(f); | |
62 | while (c == '\n'); | |
63 | if (!poof && hadsome) | |
64 | putchar('\n'); | |
65 | if (c == -1) | |
66 | break; | |
67 | putchar(c); | |
68 | hadsome = 1; | |
69 | } | |
70 | } while (argc > 0); | |
71 | } |