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