Subversion Repositories planix.SVN

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
/* t1.c: main control and input switching */
2
#
3
# include "t.h"
4
 
5
# define MACROS "/sys/lib/tmac/tmac.s"
6
# define PYMACS "/sys/lib/tmac/tmac.m"
7
 
8
 
9
# define ever (;;)
10
 
11
void
12
main(int argc, char *argv[])
13
{
14
	exits(tbl(argc, argv)? "error" : 0);
15
}
16
 
17
 
18
int
19
tbl(int argc, char *argv[])
20
{
21
	char	line[5120];
22
	/*int x;*/
23
	/*x=malloc((char *)0);	uncomment when allocation breaks*/
24
	Binit(&tabout, 1, OWRITE);
25
	setinp(argc, argv);
26
	while (gets1(line, sizeof(line))) {
27
		Bprint(&tabout, "%s\n", line);
28
		if (prefix(".TS", line))
29
			tableput();
30
	}
31
	Bterm(tabin);
32
	return(0);
33
}
34
 
35
 
36
int	sargc;
37
char	**sargv;
38
 
39
void
40
setinp(int argc, char **argv)
41
{
42
	sargc = argc;
43
	sargv = argv;
44
	sargc--; 
45
	sargv++;
46
	if (sargc == 0 || swapin() == 0) {
47
		tabin = (Biobuf*)getcore(sizeof(Biobuf), 1);
48
		Binit(tabin, 0, OREAD);
49
	}
50
}
51
 
52
 
53
int
54
swapin(void)
55
{
56
	char	*name;
57
	while (sargc > 0 && **sargv == '-') {
58
		if (match("-ms", *sargv)) {
59
			*sargv = MACROS;
60
			break;
61
		}
62
		if (match("-mm", *sargv)) {
63
			*sargv = PYMACS;
64
			break;
65
		}
66
		if (match("-TX", *sargv))
67
			pr1403 = 1;
68
		if (match("-", *sargv))
69
			break;
70
		sargc--; 
71
		sargv++;
72
	}
73
	if (sargc <= 0) 
74
		return(0);
75
	/* file closing is done by GCOS troff preprocessor */
76
	if(tabin)
77
		Bterm(tabin);
78
	ifile = *sargv;
79
	name = ifile;
80
	if (match(ifile, "-")) {
81
		tabin = (Biobuf*)getcore(sizeof(Biobuf), 1);
82
		Binit(tabin, 0, OREAD);
83
	} else
84
		tabin = Bopen(ifile, OREAD);
85
	iline = 1;
86
	Bprint(&tabout, ".ds f. %s\n", ifile);
87
	Bprint(&tabout, ".lf %d %s\n", iline, name);
88
	if (tabin == 0)
89
		error("Can't open file");
90
	sargc--;
91
	sargv++;
92
	return(1);
93
}