Annotation of 40BSD/cmd/ssp.c, revision 1.1.1.1

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.