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