1 % Kpathsea changes for CWEB by Wlodek Bzyl and Olaf Weber
2 % Copyright 2002 Wlodek Bzyl and Olaf Weber
3 % This file is in the Public Domain.
6 \def\title{CTANGLE (Version 3.64)}
7 \def\topofcontents{\null\vfill
8 \centerline{\titlefont The {\ttitlefont CTANGLE} processor}
10 \centerline{(Version 3.64)}
13 \def\title{CTANGLE (Version 3.64k)}
14 \def\topofcontents{\null\vfill
15 \centerline{\titlefont The {\ttitlefont CTANGLE} processor}
17 \centerline{(Version 3.64k)}
21 This change can not be applied when `tie' is used
22 (TOC file can not be typeset).
27 %\let\maybe=\iffalse % print only sections that change
34 The ``banner line'' defined here should be changed whenever \.{CTANGLE}
37 @d banner "This is CTANGLE (Version 3.64)\n"
39 The ``banner line'' defined here should be changed whenever \.{CTANGLE}
42 @d banner "This is CTANGLE, Version 3.64"
49 @ We predeclare several standard system functions here instead of including
50 their system header files, because the names of the header files are not as
51 standard as the names of the functions. (For example, some \CEE/ environments
52 have \.{<string.h>} where others have \.{<strings.h>}.)
55 extern int strlen(); /* length of string */
56 extern int strcmp(); /* compare strings lexicographically */
57 extern char* strcpy(); /* copy one string to another */
58 extern int strncmp(); /* compare up to $n$ string characters */
59 extern char* strncpy(); /* copy up to $n$ string characters */
70 int main (int ac, char **av)
73 @x l.100 - Add Web2C version to banner.
74 if (show_banner) printf(banner); /* print a ``banner line'' */
77 printf("%s%s\n", banner, versionstring); /* print a ``banner line'' */
82 @d max_bytes 90000 /* the number of bytes in identifiers,
84 @d max_bytes 1000000 /* the number of bytes in identifiers,
88 @d max_toks 270000 /* number of bytes in compressed \CEE/ code */
89 @d max_names 4000 /* number of identifiers, strings, section names;
91 @d max_toks 1000000 /* number of bytes in compressed \CEE/ code */
92 @d max_names 10239 /* number of identifiers, strings, section names;
96 @d max_texts 2500 /* number of replacement texts, must be less than 10240 */
97 @d hash_size 353 /* should be prime; used in |"common.w"| */
99 @d max_texts 10239 /* number of replacement texts, must be less than 10240 */
100 @d hash_size 8501 /* should be prime; used in |"common.w"| */
104 @d buf_size 100 /* for \.{CWEAVE} and \.{CTANGLE} */
106 @d buf_size 1000 /* for \.{CWEAVE} and \.{CTANGLE} */
111 @x common.h l.30 - boolean comes from kpathsea.
112 typedef short boolean;
121 #include <kpathsea/kpathsea.h>
126 @d xisalpha(c) (isalpha(c)&&((eight_bits)c<0200))
127 @d xisdigit(c) (isdigit(c)&&((eight_bits)c<0200))
128 @d xisspace(c) (isspace(c)&&((eight_bits)c<0200))
129 @d xislower(c) (islower(c)&&((eight_bits)c<0200))
130 @d xisupper(c) (isupper(c)&&((eight_bits)c<0200))
131 @d xisxdigit(c) (isxdigit(c)&&((eight_bits)c<0200))
133 @d xisalpha(c) (isalpha((eight_bits)c)&&((eight_bits)c<0200))
134 @d xisdigit(c) (isdigit((eight_bits)c)&&((eight_bits)c<0200))
135 @d xisspace(c) (isspace((eight_bits)c)&&((eight_bits)c<0200))
136 @d xislower(c) (islower((eight_bits)c)&&((eight_bits)c<0200))
137 @d xisupper(c) (isupper((eight_bits)c)&&((eight_bits)c<0200))
138 @d xisxdigit(c) (isxdigit((eight_bits)c)&&((eight_bits)c<0200))
143 @x common.h l.109 - protos now all in cweb.h.
144 extern name_pointer id_lookup(); /* looks up a string in the identifier table */
145 extern name_pointer section_lookup(); /* finds section name */
146 extern void print_section_name(), sprint_section_name();
153 @x common.h l.123 - explicit types, protos now all in cweb.h.
154 extern history; /* indicates how bad this run was */
155 extern err_print(); /* print error message and context */
156 extern wrap_up(); /* indicate |history| and exit */
157 extern void fatal(); /* issue error message and die */
158 extern void overflow(); /* succumb because a table has overflowed */
160 extern int history; /* indicates how bad this run was */
165 @x common.h l.131 - max_file_name_length is way too small.
166 @d max_file_name_length 60
168 @d max_file_name_length 1024
171 @x common.h l.138 - explicit types.
172 extern include_depth; /* current level of nesting */
174 extern int include_depth; /* current level of nesting */
177 @x common.h l.148 - explicit types.
178 extern line[]; /* number of current line in the stacked files */
179 extern change_line; /* number of current line in change file */
181 extern int line[]; /* number of current line in the stacked files */
182 extern int change_line; /* number of current line in change file */
185 @x common.h l.153 - protos now all in cweb.h.
186 extern reset_input(); /* initialize to read the web file and change file */
187 extern get_line(); /* inputs the next line */
188 extern check_complete(); /* checks that all changes were picked up */
194 @x common.h l.192 - protos now all in cweb.h.
195 extern void common_init();
202 int names_match(p,first,l)
203 name_pointer p; /* points to the proposed match */
204 char *first; /* position of first character of string */
205 int l; /* length of identifier */
207 int names_match (name_pointer p, const char *first, int l, char t)
216 init_node (name_pointer node)
222 init_p (name_pointer p, char t) {}
233 store_two_bytes (sixteen_bits x)
240 push_level(p) /* suspends the current level */
244 push_level (name_pointer p) /* suspends the current level */
251 pop_level(flag) /* do this when |cur_byte| reaches |cur_end| */
252 int flag; /* |flag==0| means we are in |output_defs| */
255 pop_level (int flag) /* do this when |cur_byte| reaches |cur_end| */
262 get_output() /* sends next token to |out_char| */
265 get_output (void) /* sends next token to |out_char| */
272 flush_buffer() /* writes one line to output file */
275 flush_buffer (void) /* writes one line to output file */
283 static void phase_two (void);
298 @x l.577 Use binary mode for output files
299 C_file=fopen(output_file_name,"w");
301 C_file=fopen(output_file_name,"wb");
309 static void output_defs (void);
325 static void out_char();
327 static void out_char (eight_bits);
336 out_char (eight_bits cur_char)
343 skip_ahead() /* skip to next control code */
346 skip_ahead (void) /* skip to next control code */
352 int skip_comment(is_long_comment) /* skips over comments */
353 boolean is_long_comment;
356 skip_comment (boolean is_long_comment) /* skips over comments */
361 @x l.889 - add declaration of versionstring.
362 #include <ctype.h> /* definition of |isalpha|, |isdigit| and so on */
370 get_next() /* produces the next input token */
373 get_next (void) /* produces the next input token */
379 else if (*loc=='>') if (*(loc+1)=='*') {loc++; compress(minus_gt_ast);}
380 else compress(minus_gt); break;
382 else if (*loc=='>') {if (*(loc+1)=='*') {loc++; compress(minus_gt_ast);}
383 else compress(minus_gt);} break;
387 while (isalpha(*++loc) || isdigit(*loc) || isxalpha(*loc) || ishigh(*loc));
389 while (isalpha((unsigned char)*++loc) || isdigit((unsigned char)*loc) || isxalpha(*loc) || ishigh(*loc));
396 scan_repl(t) /* creates a replacement text */
400 scan_repl (eight_bits t) /* creates a replacement text */
405 @x l.1232 -- rename local var, not to shadow previous local
406 {int a=id_lookup(id_first,id_loc,0)-name_dir; app_repl((a / 0400)+0200);
409 {int a_l=id_lookup(id_first,id_loc,0)-name_dir; app_repl((a_l / 0400)+0200);
410 app_repl(a_l % 0400);}
416 c=toupper(*id_first)-'A'+10;
418 c=toupper((unsigned char)*id_first)-'A'+10;
421 c=16*c+toupper(*id_first)-'A'+10;
423 c=16*c+toupper((unsigned char)*id_first)-'A'+10;
441 static void phase_one (void);
459 static void skip_limbo (void);