Annotation of 43BSD/usr.bin/tbl/t1.c, revision 1.1

1.1     ! root        1: #ifndef lint
        !             2: static char sccsid[] = "@(#)t1.c       4.2 8/11/83";
        !             3: #endif
        !             4: 
        !             5:  /* t1.c: main control and input switching */
        !             6: #
        !             7: # include "t..c"
        !             8: #include <signal.h>
        !             9: # ifdef gcos
        !            10: /* required by GCOS because file is passed to "tbl" by troff preprocessor */
        !            11: # define _f1 _f
        !            12: extern FILE *_f[];
        !            13: # endif
        !            14: 
        !            15: # ifdef unix
        !            16: # define MACROS "/usr/lib/tmac.s"
        !            17: # define PYMACS "/usr/lib/tmac.m"
        !            18: # endif
        !            19: 
        !            20: # ifdef gcos
        !            21: # define MACROS "cc/troff/smac"
        !            22: # define PYMACS "cc/troff/mmac"
        !            23: # endif
        !            24: 
        !            25: # define ever (;;)
        !            26: 
        !            27: main(argc,argv)
        !            28:        char *argv[];
        !            29: {
        !            30: # ifdef unix
        !            31: int badsig();
        !            32: signal(SIGPIPE, badsig);
        !            33: # endif
        !            34: # ifdef gcos
        !            35: if(!intss()) tabout = fopen("qq", "w"); /* default media code is type 5 */
        !            36: # endif
        !            37: exit(tbl(argc,argv));
        !            38: }
        !            39: 
        !            40: 
        !            41: tbl(argc,argv)
        !            42:        char *argv[];
        !            43: {
        !            44: char line[BUFSIZ];
        !            45: /* required by GCOS because "stdout" is set by troff preprocessor */
        !            46: tabin=stdin; tabout=stdout;
        !            47: setinp(argc,argv);
        !            48: while (gets1(line))
        !            49:        {
        !            50:        fprintf(tabout, "%s\n",line);
        !            51:        if (prefix(".TS", line))
        !            52:                tableput();
        !            53:        }
        !            54: fclose(tabin);
        !            55: return(0);
        !            56: }
        !            57: int sargc;
        !            58: char **sargv;
        !            59: setinp(argc,argv)
        !            60:        char **argv;
        !            61: {
        !            62:        sargc = argc;
        !            63:        sargv = argv;
        !            64:        sargc--; sargv++;
        !            65:        if (sargc>0)
        !            66:                swapin();
        !            67: }
        !            68: swapin()
        !            69: {
        !            70:        while (sargc>0 && **sargv=='-') /* Mem fault if no test on sargc */
        !            71:                {
        !            72:                if (sargc<=0) return(0);
        !            73:                if (match("-ms", *sargv))
        !            74:                        {
        !            75:                        *sargv = MACROS;
        !            76:                        break;
        !            77:                        }
        !            78:                if (match("-mm", *sargv))
        !            79:                        {
        !            80:                        *sargv = PYMACS;
        !            81:                        break;
        !            82:                        }
        !            83:                if (match("-TX", *sargv))
        !            84:                        pr1403=1;
        !            85:                sargc--; sargv++;
        !            86:                }
        !            87:        if (sargc<=0) return(0);
        !            88: # ifdef unix
        !            89: /* file closing is done by GCOS troff preprocessor */
        !            90:        if (tabin!=stdin) fclose(tabin);
        !            91: # endif
        !            92:        tabin = fopen(ifile= *sargv, "r");
        !            93:        iline=1;
        !            94: # ifdef unix
        !            95: /* file names are all put into f. by the GCOS troff preprocessor */
        !            96:        fprintf(tabout, ".ds f. %s\n",ifile);
        !            97: # endif
        !            98:        if (tabin==NULL)
        !            99:                error("Can't open file");
        !           100:        sargc--;
        !           101:        sargv++;
        !           102:        return(1);
        !           103: }
        !           104: # ifdef unix
        !           105: badsig()
        !           106: {
        !           107: signal(SIGPIPE, SIG_IGN);
        !           108:  exit(0);
        !           109: }
        !           110: # endif

unix.superglobalmegacorp.com

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