BSD 4_4 release
[unix-history] / usr / src / old / tbl / t1.c
/*-
* This module is believed to contain source code proprietary to AT&T.
* Use and redistribution is subject to the Berkeley Software License
* Agreement and your Software Agreement with AT&T (Western Electric).
*/
#ifndef lint
static char sccsid[] = "@(#)t1.c 4.5 (Berkeley) 4/18/91";
#endif /* not lint */
/* t1.c: main control and input switching */
#
# include "t..c"
#include <signal.h>
#include "pathnames.h"
# ifdef gcos
/* required by GCOS because file is passed to "tbl" by troff preprocessor */
# define _f1 _f
extern FILE *_f[];
# endif
# define ever (;;)
main(argc,argv)
char *argv[];
{
# ifdef unix
void badsig();
signal(SIGPIPE, badsig);
# endif
# ifdef gcos
if(!intss()) tabout = fopen("qq", "w"); /* default media code is type 5 */
# endif
exit(tbl(argc,argv));
}
tbl(argc,argv)
char *argv[];
{
char line[BUFSIZ];
/* required by GCOS because "stdout" is set by troff preprocessor */
tabin=stdin; tabout=stdout;
setinp(argc,argv);
while (gets1(line))
{
fprintf(tabout, "%s\n",line);
if (prefix(".TS", line))
tableput();
}
fclose(tabin);
return(0);
}
int sargc;
char **sargv;
setinp(argc,argv)
char **argv;
{
sargc = argc;
sargv = argv;
sargc--; sargv++;
if (sargc>0)
swapin();
}
swapin()
{
while (sargc>0 && **sargv=='-') /* Mem fault if no test on sargc */
{
if (sargc<=0) return(0);
if (match("-ms", *sargv))
{
*sargv = _PATH_MACROS;
break;
}
if (match("-mm", *sargv))
{
*sargv = _PATH_PYMACS;
break;
}
if (match("-TX", *sargv))
pr1403=1;
sargc--; sargv++;
}
if (sargc<=0) return(0);
# ifdef unix
/* file closing is done by GCOS troff preprocessor */
if (tabin!=stdin) fclose(tabin);
# endif
tabin = fopen(ifile= *sargv, "r");
iline=1;
# ifdef unix
/* file names are all put into f. by the GCOS troff preprocessor */
fprintf(tabout, ".ds f. %s\n",ifile);
# endif
if (tabin==NULL)
error("Can't open file");
sargc--;
sargv++;
return(1);
}
# ifdef unix
void
badsig()
{
signal(SIGPIPE, SIG_IGN);
exit(0);
}
# endif