beta-0.89.2
[luatex.git] / source / texk / web2c / cwebdir / comm-bs.ch
blob26f79b160d1bb962e1d9bc6eddd5ce3b73100932
1 Changes for code common to CTANGLE and CWEAVE, for MSDOS
2 and Borland C++ 3.1 using the following options (and perhaps others):
4     -mc -w-pro -Ff=5000 -Z- -O-p
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.)
9 The main purpose of these changes is to support MSDOS with full-size arrays
10 by using "huge" pointers.
12 (This file contributed by Barry Schwartz, trashman@crud.mn.org, 28 Jun 94;
13  revised 24 Jul 94.)
16 @x Section 23.
17     cur_file_name[l]='/'; /* \UNIX/ pathname separator */
19     cur_file_name[l]='/'; /* A valid {\mc MSDOS} pathname separator */
23 @x Section 27.
24 @d max_names 4000 /* number of identifiers, strings, section names;
25   must be less than 10240 */
27 @<Definitions that...@>=
28 typedef 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 */
32 typedef name_info *name_pointer; /* pointer into array of |name_info|s */
33 char byte_mem[max_bytes]; /* characters of names */
34 char *byte_mem_end = byte_mem+max_bytes-1; /* end of |byte_mem| */
35 name_info name_dir[max_names]; /* information about names */
36 name_pointer name_dir_end = name_dir+max_names-1; /* end of |name_dir| */
38 @d max_names 4000 /* number of identifiers, strings, section names;
39   must be less than 10240 */
41 @f huge extern
43 @<Definitions that...@>=
44 typedef 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 */
48 typedef name_info *name_pointer; /* pointer into array of |name_info|s */
49 char huge byte_mem[max_bytes]; /* characters of names */
50 char huge* byte_mem_end; /* end of |byte_mem| */
51 name_info name_dir[max_names]; /* information about names */
52 name_pointer name_dir_end = name_dir+max_names-1;
56 @x Section 29.
57 char *byte_ptr; /* first unused position in |byte_mem| */
59 char huge* byte_ptr; /* first unused position in |byte_mem| */
63 @x Section 30.
64 @ @<Init...@>=
65 name_dir->byte_start=byte_ptr=byte_mem; /* position zero in both arrays */
66 name_ptr=name_dir+1; /* |name_dir[0]| will be used only for error recovery */
67 name_ptr->byte_start=byte_mem; /* this makes name 0 of length zero */
69 @ @<Init...@>=
70 name_dir->byte_start=byte_ptr=byte_mem; /* position zero in both arrays */
71 name_ptr=name_dir+1; /* |name_dir[0]| will be used only for error recovery */
72 name_ptr->byte_start=byte_mem; /* this makes name 0 of length zero */
73 byte_mem_end = byte_mem+max_bytes-1;
77 @x Section 42.
78 void
79 print_section_name(p)
80 name_pointer p;
82   char *ss, *s = first_chunk(p);
84 void
85 print_section_name(p)
86 name_pointer p;
88   char huge* ss, huge* s = first_chunk(p);
92 @x Section 43.
93 void
94 sprint_section_name(dest,p)
95   char*dest;
96   name_pointer p;
98   char *ss, *s = first_chunk(p);
100 void
101 sprint_section_name(dest,p)
102   char*dest;
103   name_pointer p;
105   char huge* ss, huge* s = first_chunk(p);
109 @x Section 44.
110 void
111 print_prefix_name(p)
112 name_pointer p;
114   char *s = first_chunk(p);
116 void
117 print_prefix_name(p)
118 name_pointer p;
120   char huge* s = first_chunk(p);
124 @x Section 47.
125 name_pointer
126 add_section_name(par,c,first,last,ispref) /* install a new node in the tree */
127 name_pointer par; /* parent of new node */
128 int c; /* right or left? */
129 char *first; /* first character of section name */
130 char *last; /* last character of section name, plus one */
131 int ispref; /* are we adding a prefix or a full name? */
133   name_pointer p=name_ptr; /* new node */
134   char *s=first_chunk(p);
136 name_pointer
137 add_section_name(par,c,first,last,ispref) /* install a new node in the tree */
138 name_pointer par; /* parent of new node */
139 int c; /* right or left? */
140 char *first; /* first character of section name */
141 char *last; /* last character of section name, plus one */
142 int ispref; /* are we adding a prefix or a full name? */
144   name_pointer p=name_ptr; /* new node */
145   char huge* s=first_chunk(p);
149 @x Section 48.
150 void
151 extend_section_name(p,first,last,ispref)
152 name_pointer p; /* name to be extended */
153 char *first; /* beginning of extension text */
154 char *last; /* one beyond end of extension text */
155 int ispref; /* are we adding a prefix or a full name? */
157   char *s;
159 void
160 extend_section_name(p,first,last,ispref)
161 name_pointer p; /* name to be extended */
162 char *first; /* beginning of extension text */
163 char *last; /* one beyond end of extension text */
164 int ispref; /* are we adding a prefix or a full name? */
166   char huge* s;
170 @x Section 54.
171 int section_name_cmp(pfirst,len,r)
172 char **pfirst; /* pointer to beginning of comparison string */
173 int len; /* length of string */
174 name_pointer r; /* section name being compared */
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);
180 int section_name_cmp(pfirst,len,r)
181 char **pfirst; /* pointer to beginning of comparison string */
182 int len; /* length of string */
183 name_pointer r; /* section name being compared */
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);
191 @x Section 55.
192 source files, respectively; here we just declare a common field
193 |equiv_or_xref| as a pointer to a |char|.
195 @<More elements of |name...@>=
196 char *equiv_or_xref; /* info corresponding to names */
198 source files, respectively.  Here we just declare a common field
199 |ptr_union| as a union of pointers to |char|, which happen to have
200 different addressing attributes.
202 @<More elements of |name...@>=
203 union {
204   char *equiv_member;
205   char huge* xref_member;
206 } ptr_union;  /* info corresponding to names */
210 @x Section 69.
211 An omitted change file argument means that |"/dev/null"| should be used,
213 An omitted change file argument means that |"NUL"| should be used,
217 @x Section 70.
218         else if (*s=='/') dot_pos=NULL,name_pos=++s;
220         else if (*s == ':' || *s == '\\' || *s == '/')
221           dot_pos=NULL,name_pos=++s;
225 @x Section 70.
226   if (found_change<=0) strcpy(change_file_name,"/dev/null");
228   if (found_change<=0) strcpy(change_file_name,"NUL");