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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
include <error.h>
include <ctype.h>
include <ctotok.h>
define SZ_LBUF 1024
define MAX_TAGS 8192
define SZ_SBUF 256000
define TAGSFILE "tags"
# TG_COMPARE -- String compare of two tags.
int procedure tg_compare (s1, s2)
int s1 # t_sort index of string 1
int s2 # t_sort index of string 2
int ntags
pointer tg_op
pointer tg_sbuf
pointer tg_tag[MAX_TAGS]
pointer tg_file[MAX_TAGS]
pointer tg_lnum[MAX_TAGS]
pointer tg_lbuf[MAX_TAGS]
int tg_sort[MAX_TAGS]
common /tagcom/ ntags, tg_op, tg_sbuf, tg_tag, tg_file, tg_lnum, tg_lbuf,
tg_sort
int strncmp()
begin
return (strncmp (Memc[tg_tag[s1]], Memc[tg_tag[s2]], ARB))
end
# TG_PUTSTR -- Add a string to the string buffer and return a pointer to
# the beginning of the string.
pointer procedure tg_putstr (str)
char str[ARB] # string to be appended
int nchars
pointer newstr
int strlen()
int ntags
pointer tg_op
pointer tg_sbuf
pointer tg_tag[MAX_TAGS]
pointer tg_file[MAX_TAGS]
pointer tg_lnum[MAX_TAGS]
pointer tg_lbuf[MAX_TAGS]
int tg_sort[MAX_TAGS]
common /tagcom/ ntags, tg_op, tg_sbuf, tg_tag, tg_file, tg_lnum, tg_lbuf,
tg_sort
begin
nchars = strlen (str)
newstr = tg_op
if (tg_op - tg_sbuf + nchars >= SZ_SBUF)
call error (2, "out of string buffer space")
call strcpy (str, Memc[newstr], nchars)
tg_op = tg_op + nchars + 1
return (newstr)
end
# TG_GETLONGLINE -- Get a long line, i.e., a logical line possibly spanning
# several physical lines with the newlines escaped at the ends. Skip
# comment lines and .help sections.
int procedure tg_getlongline (fd, obuf, maxch, linenum)
int fd # input file
char obuf[ARB] # output buffer
int maxch
int linenum
int op, status
int getline(), strncmp()
begin
op = 1
while (maxch - op + 1 >= SZ_LINE) {
# Get next non-comment line.
repeat {
status = getline (fd, obuf[op])
linenum = linenum + 1
if (status == EOF) {
break
} else if (obuf[op] == '#') {
next
} else if (obuf[op] == '.') {
# Skip help sections.
if (strncmp (obuf[op], ".help", 5) == 0) {
repeat {
status = getline (fd, obuf[op])
linenum = linenum + 1
if (status == EOF)
break
if (strncmp (obuf[op], ".endhelp", 8) == 0)
break
}
} else
break
} else
break
}
if (status == EOF) {
if (op == 1)
return (EOF)
else
return (op - 1)
} else
op = op + status
if (obuf[op-2] == '\\' && obuf[op-1] == '\n')
op = op - 2
else
break
}
return (op - 1)
end
|