Annotation of 3BSD/cmd/split.c, revision 1.1.1.1

1.1       root        1: #include <stdio.h>
                      2: 
                      3: unsigned count = 1000;
                      4: int    fnumber;
                      5: char   fname[100];
                      6: char   *ifil;
                      7: char   *ofil;
                      8: FILE   *is;
                      9: FILE   *os;
                     10: 
                     11: main(argc, argv)
                     12: char *argv[];
                     13: {
                     14:        register i, c, f;
                     15:        int iflg = 0;
                     16: 
                     17:        for(i=1; i<argc; i++)
                     18:                if(argv[i][0] == '-')
                     19:                        switch(argv[i][1]) {
                     20:                
                     21:                        case '\0':
                     22:                                iflg = 1;
                     23:                                continue;
                     24:                
                     25:                        case '0':
                     26:                        case '1':
                     27:                        case '2':
                     28:                        case '3':
                     29:                        case '4':
                     30:                        case '5':
                     31:                        case '6':
                     32:                        case '7':
                     33:                        case '8':
                     34:                        case '9':
                     35:                                count = atoi(argv[i]+1);
                     36:                                continue;
                     37:                        }
                     38:                else if(iflg)
                     39:                        ofil = argv[i];
                     40:                else {
                     41:                        ifil = argv[i];
                     42:                        iflg = 2;
                     43:                }
                     44:        if(iflg != 2)
                     45:                is = stdin;
                     46:        else
                     47:                if((is=fopen(ifil,"r")) == NULL) {
                     48:                        fprintf(stderr,"cannot open input\n");
                     49:                        exit(1);
                     50:                }
                     51:        if(ofil == 0)
                     52:                ofil = "x";
                     53: 
                     54: loop:
                     55:        f = 1;
                     56:        for(i=0; i<count; i++)
                     57:        do {
                     58:                c = getc(is);
                     59:                if(c == EOF) {
                     60:                        if(f == 0)
                     61:                                fclose(os);
                     62:                        exit(0);
                     63:                }
                     64:                if(f) {
                     65:                        for(f=0; ofil[f]; f++)
                     66:                                fname[f] = ofil[f];
                     67:                        fname[f++] = fnumber/26 + 'a';
                     68:                        fname[f++] = fnumber%26 + 'a';
                     69:                        fname[f] = '\0';
                     70:                        fnumber++;
                     71:                        if((os=fopen(fname,"w")) == NULL) {
                     72:                                fprintf(stderr,"Cannot create output\n");
                     73:                                exit(1);
                     74:                        }
                     75:                        f = 0;
                     76:                }
                     77:                putc(c, os);
                     78:        } while(c != '\n');
                     79:        fclose(os);
                     80:        goto loop;
                     81: }

unix.superglobalmegacorp.com

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