Annotation of 43BSD/ucb/what.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 1980 Regents of the University of California.
        !             3:  * All rights reserved.  The Berkeley software License Agreement
        !             4:  * specifies the terms and conditions for redistribution.
        !             5:  */
        !             6: 
        !             7: #ifndef lint
        !             8: char copyright[] =
        !             9: "@(#) Copyright (c) 1980 Regents of the University of California.\n\
        !            10:  All rights reserved.\n";
        !            11: #endif not lint
        !            12: 
        !            13: #ifndef lint
        !            14: static char sccsid[] = "@(#)what.c     5.1 (Berkeley) 5/31/85";
        !            15: #endif not lint
        !            16: 
        !            17: #include <stdio.h>
        !            18: 
        !            19: /*
        !            20:  * what
        !            21:  */
        !            22: 
        !            23: char   *infile = "Standard input";
        !            24: 
        !            25: main(argc, argv)
        !            26:        int argc;
        !            27:        char *argv[];
        !            28: {
        !            29: 
        !            30:        argc--, argv++;
        !            31:        do {
        !            32:                if (argc > 0) {
        !            33:                        if (freopen(argv[0], "r", stdin) == NULL) {
        !            34:                                perror(argv[0]);
        !            35:                                exit(1);
        !            36:                        }
        !            37:                        infile = argv[0];
        !            38:                        printf("%s\n", infile);
        !            39:                        argc--, argv++;
        !            40:                }
        !            41:                fseek(stdin, (long) 0, 0);
        !            42:                find();
        !            43:        } while (argc > 0);
        !            44:        exit(0);
        !            45: }
        !            46: 
        !            47: find()
        !            48: {
        !            49:        static char buf[BUFSIZ];
        !            50:        register char *cp;
        !            51:        register int c, cc;
        !            52:        register char *pat;
        !            53: 
        !            54: contin:
        !            55:        while ((c = getchar()) != EOF)
        !            56:                if (c == '@') {
        !            57:                        for (pat = "(#)"; *pat; pat++)
        !            58:                                if ((c = getchar()) != *pat)
        !            59:                                        goto contin;
        !            60:                        putchar('\t');
        !            61:                        while ((c = getchar()) != EOF && c && c != '"' &&
        !            62:                            c != '>' && c != '\n')
        !            63:                                putchar(c);
        !            64:                        putchar('\n');
        !            65:                }
        !            66: }

unix.superglobalmegacorp.com

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