Annotation of coherent/d/bin/bc/main.c, revision 1.1

1.1     ! root        1: #include <stdio.h>
        !             2: #include <path.h>
        !             3: #include "bc.h"
        !             4: 
        !             5: #define LIBNAME "lib.b"
        !             6: 
        !             7: main(argc, argv)
        !             8: register int   argc;
        !             9: register char  *argv[];
        !            10: {
        !            11:        register FILE   *fp;
        !            12: 
        !            13:        init();
        !            14:        ++argv;
        !            15:        if (--argc > 0 && **argv == '-')
        !            16:                if (strcmp(*argv, "-l") == 0
        !            17:                 || strcmp(*argv, "-L") == 0) {
        !            18:                        static char lib[] = LIBNAME;
        !            19:                        register char *lp;
        !            20:                        extern char *getenv();
        !            21:                        lp = (lp=getenv("LIBPATH")) ? lp : DEFLIBPATH;
        !            22:                        if ((lp = path(lp, lib, AREAD)) == 0
        !            23:                         || (fp = fopen(lp, "r")) == 0)
        !            24:                                die("Can't find %s", lib);
        !            25:                        scan(fp, lib, 1);
        !            26:                        --argc;
        !            27:                        ++argv;
        !            28:                } else
        !            29:                        usage();
        !            30:        while (--argc >= 0) {
        !            31:                fp = fopen(*argv, "r");
        !            32:                if (fp == NULL)
        !            33:                        die("Can't open %s", *argv);
        !            34:                scan(fp, *argv, 1);
        !            35:                ++argv;
        !            36:        }
        !            37:        scan(stdin, NULL, 0);
        !            38:        return (0);
        !            39: }
        !            40: 
        !            41: scan(fp, fnm, lno)
        !            42: FILE   *fp;
        !            43: char   *fnm;
        !            44: int    lno;
        !            45: {
        !            46:        infile = fp;
        !            47:        infnam = fnm;
        !            48:        inline = lno;
        !            49:        yyparse();
        !            50:        fclose(fp);
        !            51: }
        !            52: 
        !            53: die(str)
        !            54: char   *str;
        !            55: {
        !            56:        fprintf(stderr, "bc: %r\n", &str);
        !            57:        exit(1);
        !            58: }
        !            59: 
        !            60: usage()
        !            61: {
        !            62:        fprintf(stderr, "Usage: bc [-l] file ... file\n");
        !            63:        exit(1);
        !            64: }

unix.superglobalmegacorp.com

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