Debian Codegraph @

texk/web2c/cwebdir/comm-bs.ch

raw
1 Changes for code common to CTANGLE and CWEAVE, for MSDOS
2 and Borland C++ 3.1 using the following options (and perhaps others):
3
4 -mc -w-pro -Ff=5000 -Z- -O-p
5
6 The options -Z- and -O-p explicitly turn off optimizations that seem to be
7 dangerous for the style of code in the CWEB sources. (See makefile.bs.)
8
9 The main purpose of these changes is to support MSDOS with full-size arrays
10 by using "huge" pointers.
11
12 (This file contributed by Barry Schwartz, [email protected], 28 Jun 94;
13 revised 24 Jul 94.)
14
15 (Update attempt by Andreas Scherer, 31 Jan 2021. Good luck!)
16
17
18 @x Section 10.
19 @d ilk dummy.Ilk /* used by \.{CWEAVE} only */
20
21 @<Common code...@>=
22 typedef struct name_info {
23 char *byte_start; /* beginning of the name in |byte_mem| */
24 struct name_info *link;
25 union {
26 struct name_info *Rlink; /* right link in binary search tree for section
27 names */
28 eight_bits Ilk; /* used by identifiers in \.{CWEAVE} only */
29 } dummy;
30 void *equiv_or_xref; /* info corresponding to names */
31 } name_info; /* contains information about an identifier or section name */
32 typedef name_info *name_pointer; /* pointer into array of \&{name\_info}s */
33 typedef name_pointer *hash_pointer;
34 extern char byte_mem[]; /* characters of names */
35 extern char *byte_mem_end; /* end of |byte_mem| */
36 @y
37 @d ilk dummy.Ilk /* used by \.{CWEAVE} only */
38
39 @f huge extern
40
41 @<Common code...@>=
42 typedef struct name_info {
43 char huge* byte_start; /* beginning of the name in |byte_mem| */
44 struct name_info *link;
45 union {
46 struct name_info *Rlink; /* right link in binary search tree for section
47 names */
48 eight_bits Ilk; /* used by identifiers in \.{CWEAVE} only */
49 } dummy;
50 union {
51 void huge* equiv_member;
52 void huge* xref_member;
53 } ptr_union; /* info corresponding to names */
54 } name_info; /* contains information about an identifier or section name */
55 typedef name_info *name_pointer; /* pointer into array of \&{name\_info}s */
56 typedef name_pointer *hash_pointer;
57 extern char huge byte_mem[]; /* characters of names */
58 extern char huge* byte_mem_end; /* end of |byte_mem| */
59 @z
60
61
62 @x Section 36.
63 cur_file_name[l]='/'; /* \UNIX/ pathname separator */
64 @y
65 cur_file_name[l]='/'; /* A valid {\mc MSDOS} pathname separator */
66 @z
67
68
69 @x Section 44.
70 char *byte_ptr; /* first unused position in |byte_mem| */
71 @y
72 char huge* byte_ptr; /* first unused position in |byte_mem| */
73 @z
74
75
76 @x Section 45.
77 @ @<Init...@>=
78 name_dir->byte_start=byte_ptr=byte_mem; /* position zero in both arrays */
79 name_ptr=name_dir+1; /* |name_dir[0]| will be used only for error recovery */
80 name_ptr->byte_start=byte_mem; /* this makes name 0 of length zero */
81 @y
82 @ @<Init...@>=
83 name_dir->byte_start=byte_ptr=byte_mem; /* position zero in both arrays */
84 name_ptr=name_dir+1; /* |name_dir[0]| will be used only for error recovery */
85 name_ptr->byte_start=byte_mem; /* this makes name 0 of length zero */
86 byte_mem_end = byte_mem+max_bytes-1;
87 @z
88
89
90 @x Section 52.
91 void
92 print_section_name(
93 name_pointer p)
94 {
95 char *ss, *s = first_chunk(p);
96 @y
97 void
98 print_section_name(
99 name_pointer p)
100 {
101 char huge* ss, huge* s = first_chunk(p);
102 @z
103
104
105 @x Section 53.
106 void
107 sprint_section_name(
108 char *dest,
109 name_pointer p)
110 {
111 char *ss, *s = first_chunk(p);
112 @y
113 void
114 sprint_section_name(
115 char huge* dest,
116 name_pointer p)
117 {
118 char huge* ss, huge* s = first_chunk(p);
119 @z
120
121
122 @x Section 54.
123 void
124 print_prefix_name(
125 name_pointer p)
126 {
127 char *s = first_chunk(p);
128 @y
129 void
130 print_prefix_name(
131 name_pointer p)
132 {
133 char huge* s = first_chunk(p);
134 @z
135
136
137 @x Section 57.
138 static name_pointer
139 add_section_name( /* install a new node in the tree */
140 name_pointer par, /* parent of new node */
141 int c, /* right or left? */
142 char *first, /* first character of section name */
143 char *last, /* last character of section name, plus one */
144 bool ispref) /* are we adding a prefix or a full name? */
145 {
146 name_pointer p=name_ptr; /* new node */
147 char *s=first_chunk(p);
148 @y
149 static name_pointer
150 add_section_name( /* install a new node in the tree */
151 name_pointer par, /* parent of new node */
152 int c, /* right or left? */
153 char huge* first, /* first character of section name */
154 char huge* last, /* last character of section name, plus one */
155 bool ispref) /* are we adding a prefix or a full name? */
156 {
157 name_pointer p=name_ptr; /* new node */
158 char huge* s=first_chunk(p);
159 @z
160
161
162 @x Section 58.
163 static void
164 extend_section_name(
165 name_pointer p, /* name to be extended */
166 char *first, /* beginning of extension text */
167 char *last, /* one beyond end of extension text */
168 bool ispref) /* are we adding a prefix or a full name? */
169 {
170 char *s;
171 @y
172 static void
173 extend_section_name(
174 name_pointer p, /* name to be extended */
175 char huge* first, /* beginning of extension text */
176 char huge* last, /* one beyond end of extension text */
177 bool ispref) /* are we adding a prefix or a full name? */
178 {
179 char huge* s;
180 @z
181
182
183 @x Section 63.
184 static int section_name_cmp(
185 char **pfirst, /* pointer to beginning of comparison string */
186 size_t len, /* length of string */
187 name_pointer r) /* section name being compared */
188 {
189 char *first=*pfirst; /* beginning of comparison string */
190 name_pointer q=r+1; /* access to subsequent chunks */
191 char *ss, *s=first_chunk(r);
192 @y
193 static int section_name_cmp(
194 char huge** pfirst, /* pointer to beginning of comparison string */
195 size_t len, /* length of string */
196 name_pointer r) /* section name being compared */
197 {
198 char huge* first=*pfirst; /* beginning of comparison string */
199 name_pointer q=r+1; /* access to subsequent chunks */
200 char huge* ss, huge* s=first_chunk(r);
201 @z
202
203
204 @x Section 75.
205 An omitted change file argument means that |"/dev/null"| should be used,
206 @y
207 An omitted change file argument means that |"NUL"| should be used,
208 @z
209
210
211 @x Section 75.
212 strcpy(change_file_name,"/dev/null");
213 @y
214 strcpy(change_file_name,"NUL");
215 @z
216
217
218 @x Section 75.
219 else if (*s=='/') dot_pos=NULL,name_pos=++s;
220 @y
221 else if (*s == ':' || *s == '\\' || *s == '/')
222 dot_pos=NULL,name_pos=++s;
223 @z