History

CWEB - release 4.2, 2021-02-25.

This second service release wraps up the major code overhaul after CWEB 4.0.

Andreas Scherer committed 5 years ago

Commit 78e1eee1 parent 659f08423 files · +772 −810Browse files

Unified · Split

23 files
  1. Makefile +4 −1
  2. README.md +2 −2
  3. comm-mac.ch +2 −2
  4. comm-ql.ch +4 −4
  5. common.c +167 −171
  6. common.h +45 −45
  7. common.w +29 −33
  8. ctang-bs.ch +8 −8
  9. ctang-pc.ch +2 −2
  10. ctang-ql.ch +4 −4
  11. ctang-vms.ch +2 −2
  12. ctang-w32.ch +2 −2
  13. ctangle.c +216 −225
  14. ctangle.w +83 −92
  15. cweav-bs.ch +23 −23
  16. cweav-man.ch +1 −1
  17. cweav-pc.ch +2 −2
  18. cweav-ql.ch +4 −4
  19. cweav-vms.ch +2 −2
  20. cweav-w32.ch +2 −2
  21. cweave.w +151 −166
  22. cwebmac.tex +2 −2
  23. cwebman.tex +15 −15
Makefile+4−1
@@ -1,6 +1,6 @@
1# This file is part of CWEB.1# This file is part of CWEB.
2# It is distributed WITHOUT ANY WARRANTY, express or implied.2# It is distributed WITHOUT ANY WARRANTY, express or implied.
3# Version 4.1 --- February 20213# Version 4.2 --- February 2021
4 4
5# Copyright (C) 1987,1990,1993,2000 Silvio Levy and Donald E. Knuth5# Copyright (C) 1987,1990,1993,2000 Silvio Levy and Donald E. Knuth
6 6
@@ -63,8 +63,10 @@ RM= /bin/rm · 56 unmodified lines
63CP= /bin/cp63CP= /bin/cp
64 64
65# uncomment the second line if you use pdftex to bypass .dvi files65# uncomment the second line if you use pdftex to bypass .dvi files
66# uncomment the third line if you use xetex to bypass .dvi files
66PDFTEX = dvipdfm67PDFTEX = dvipdfm
67#PDFTEX = pdftex68#PDFTEX = pdftex
69#PDFTEX = xetex
68 70
69########## You shouldn't have to change anything after this point #######71########## You shouldn't have to change anything after this point #######
70 72
@@ -105,6 +107,7 @@ ALL = common.w ctangle.w cweave.w prod.w \ · 34 unmodified lines
105 case "$(PDFTEX)" in \107 case "$(PDFTEX)" in \
106 dvipdfm ) tex "\let\pdf+ \input $*"; dvipdfm $* ;; \108 dvipdfm ) tex "\let\pdf+ \input $*"; dvipdfm $* ;; \
107 pdftex ) pdftex $* ;; \109 pdftex ) pdftex $* ;; \
110 xetex ) xetex $* ;; \
108 esac111 esac
109 112
110all: ctangle cweave113all: ctangle cweave
README.md+2−2
@@ -1,4 +1,4 @@
1# cweb 4.11# cweb 4.2
2 2
3people have been accumulating several decades of experience with3people have been accumulating several decades of experience with
4[cweb](http://www-cs-faculty.stanford.edu/~uno/cweb.html), and we know that4[cweb](http://www-cs-faculty.stanford.edu/~uno/cweb.html), and we know that
@@ -16,7 +16,7 @@ in fact, now to be found in this cweb development project. · 11 unmodified lines
16besides for further development, this ‘project’ is used as an – obviously16besides for further development, this ‘project’ is used as an – obviously
17incomplete – repository of original release versions of levy/knuth17incomplete – repository of original release versions of levy/knuth
18[cweb](http://www-cs-faculty.stanford.edu/~uno/cweb.html). you can either18[cweb](http://www-cs-faculty.stanford.edu/~uno/cweb.html). you can either
19compile these sources directly or stick the recent version “cweb-4.1” into my19compile these sources directly or stick the recent version “cweb-4.2” into my
20[cwebbin](https://github.com/ascherer/cwebbin), which introduces convenient20[cwebbin](https://github.com/ascherer/cwebbin), which introduces convenient
21extensions and prepares cweb for inclusion in the “tex live” distribution.21extensions and prepares cweb for inclusion in the “tex live” distribution.
22 22
comm-mac.ch+2−2
@@ -4,9 +4,9 @@ No changes to CTANGLE or CWEAVE are needed. · 3 unmodified lines
4(Contributed 13 Oct 2000 by AndPio@aol.com; slightly edited by Don Knuth)4(Contributed 13 Oct 2000 by AndPio@aol.com; slightly edited by Don Knuth)
5 5
6@x in limbo, change the title page document to specify Mac version6@x in limbo, change the title page document to specify Mac version
7 \centerline{(Version 4.1)}7 \centerline{(Version 4.2)}
8@y8@y
9 \centerline{(Version 4.1 for MacOS)}9 \centerline{(Version 4.2 for MacOS)}
10@z10@z
11 11
12@x sections 23/24: Make input_ln accept \n, \r, \n\r, or \r\n as line endings12@x sections 23/24: Make input_ln accept \n, \r, \n\r, or \r\n as line endings
comm-ql.ch+4−4
@@ -10,24 +10,24 @@ ex <dev_>cc;'-v -h -c -=500000 -DCWEBINPUTS=flp2_ common_c' · 9 unmodified lines
10@x10@x
11\def\v{\char'174} % vertical (|) in typewriter font11\def\v{\char'174} % vertical (|) in typewriter font
12 12
13\def\title{Common code for CTANGLE and CWEAVE (Version 4.1)}13\def\title{Common code for CTANGLE and CWEAVE (Version 4.2)}
14\def\topofcontents{\null\vfill14\def\topofcontents{\null\vfill
15 \centerline{\titlefont Common code for {\ttitlefont CTANGLE} and15 \centerline{\titlefont Common code for {\ttitlefont CTANGLE} and
16 {\ttitlefont CWEAVE}}16 {\ttitlefont CWEAVE}}
17 \vskip 15pt17 \vskip 15pt
18 \centerline{(Version 4.1)}18 \centerline{(Version 4.2)}
19 \vfill}19 \vfill}
20\def\botofcontents{\vfill20\def\botofcontents{\vfill
21\noindent21\noindent
22@y22@y
23\def\v{\char'174} % vertical (|) in typewriter font23\def\v{\char'174} % vertical (|) in typewriter font
24 24
25\def\title{Common code for CTANGLE and CWEAVE (QL Version 4.1)}25\def\title{Common code for CTANGLE and CWEAVE (QL Version 4.2)}
26\def\topofcontents{\null\vfill26\def\topofcontents{\null\vfill
27 \centerline{\titlefont Common code for {\ttitlefont CTANGLE} and27 \centerline{\titlefont Common code for {\ttitlefont CTANGLE} and
28 {\ttitlefont CWEAVE}}28 {\ttitlefont CWEAVE}}
29 \vskip 15pt29 \vskip 15pt
30 \centerline{(Version 4.1)}30 \centerline{(Version 4.2)}
31 \vfill}31 \vfill}
32\def\botofcontents{\vfill32\def\botofcontents{\vfill
33\noindent33\noindent
common.c+167−171
@@ -41,6 +41,15 @@ · 40 unmodified lines
41#define xisupper(c) (isupper((eight_bits) c) &&((eight_bits) c<0200) ) 41#define xisupper(c) (isupper((eight_bits) c) &&((eight_bits) c<0200) )
42#define xisxdigit(c) (isxdigit((eight_bits) c) &&((eight_bits) c<0200) ) \42#define xisxdigit(c) (isxdigit((eight_bits) c) &&((eight_bits) c<0200) ) \
43 43
44#define max_include_depth 10 \
45
46#define max_file_name_length 1024
47#define cur_file file[include_depth]
48#define cur_file_name file_name[include_depth]
49#define cur_line line[include_depth]
50#define web_file file[0]
51#define web_file_name file_name[0] \
52
44#define length(c) (size_t) ((c+1) ->byte_start-(c) ->byte_start) 53#define length(c) (size_t) ((c+1) ->byte_start-(c) ->byte_start)
45#define print_id(c) term_write((c) ->byte_start,length((c) ) ) 54#define print_id(c) term_write((c) ->byte_start,length((c) ) )
46#define llink link55#define llink link
@@ -57,15 +66,6 @@ · 10 unmodified lines
57#define confusion(s) fatal("! This can't happen: ",s) \66#define confusion(s) fatal("! This can't happen: ",s) \
58 \67 \
59 68
60#define max_include_depth 10 \
61
62#define max_file_name_length 1024
63#define cur_file file[include_depth]
64#define cur_file_name file_name[include_depth]
65#define cur_line line[include_depth]
66#define web_file file[0]
67#define web_file_name file_name[0] \
68
69#define show_banner flags['b']69#define show_banner flags['b']
70#define show_progress flags['p']70#define show_progress flags['p']
71#define show_stats flags['s']71#define show_stats flags['s']
@@ -149,7 +149,31 @@ extern char*loc; · 77 unmodified lines
149extern char*limit;149extern char*limit;
150 150
151/*:5*//*6:*/151/*:5*//*6:*/
152#line 102 "common.h"152#line 105 "common.h"
153
154extern int include_depth;
155extern FILE*file[];
156extern FILE*change_file;
157extern char file_name[][max_file_name_length];
158
159extern char change_file_name[];
160extern int line[];
161extern int change_line;
162extern int change_depth;
163extern boolean input_has_ended;
164extern boolean changing;
165extern boolean web_file_open;
166
167/*:6*//*8:*/
168#line 125 "common.h"
169
170extern sixteen_bits section_count;
171extern boolean changed_section[];
172extern boolean change_pending;
173extern boolean print_where;
174
175/*:8*//*9:*/
176#line 139 "common.h"
153 177
154typedef struct name_info{178typedef struct name_info{
155char*byte_start;179char*byte_start;
@@ -173,44 +197,20 @@ extern name_pointer hash[]; · 17 unmodified lines
173extern hash_pointer hash_end;197extern hash_pointer hash_end;
174extern hash_pointer h;198extern hash_pointer h;
175 199
176/*:6*//*8:*/200/*:9*//*11:*/
177#line 146 "common.h"201#line 183 "common.h"
178 202
179extern int history;203extern int history;
180 204
181/*:8*//*10:*/205/*:11*//*13:*/
182#line 166 "common.h"206#line 199 "common.h"
183 207
184extern int include_depth;208extern int argc;
185extern FILE*file[];209extern char**argv;
186extern FILE*change_file;
187extern char C_file_name[];210extern char C_file_name[];
188extern char tex_file_name[];211extern char tex_file_name[];
189extern char idx_file_name[];212extern char idx_file_name[];
190extern char scn_file_name[];213extern char scn_file_name[];
191extern char file_name[][max_file_name_length];
192
193extern char change_file_name[];
194extern int line[];
195extern int change_line;
196extern int change_depth;
197extern boolean input_has_ended;
198extern boolean changing;
199extern boolean web_file_open;
200
201/*:10*//*12:*/
202#line 190 "common.h"
203
204extern sixteen_bits section_count;
205extern boolean changed_section[];
206extern boolean change_pending;
207extern boolean print_where;
208
209/*:12*//*13:*/
210#line 203 "common.h"
211
212extern int argc;
213extern char**argv;
214extern boolean flags[];214extern boolean flags[];
215 215
216/*:13*//*14:*/216/*:13*//*14:*/
@@ -232,10 +232,11 @@ boolean program; · 15 unmodified lines
232 232
233/*:18*//*19:*/233/*:18*//*19:*/
234#line 92 "common.w"234#line 92 "common.w"
235
235int phase;236int phase;
236 237
237/*:19*//*21:*/238/*:19*//*21:*/
238#line 129 "common.w"239#line 130 "common.w"
239 240
240char section_text[longest_name+1];241char section_text[longest_name+1];
241char*section_text_end= section_text+longest_name;242char*section_text_end= section_text+longest_name;
@@ -243,12 +244,12 @@ char*id_first; · 1 unmodified line
243char*id_loc;244char*id_loc;
244 245
245/*:21*//*22:*/246/*:21*//*22:*/
246#line 149 "common.w"247#line 150 "common.w"
247 248
248char buffer[long_buf_size];249char buffer[long_buf_size];
249char*buffer_end= buffer+buf_size-2;250char*buffer_end= buffer+buf_size-2;
250char*limit= buffer;
251char*loc= buffer;251char*loc= buffer;
252char*limit= buffer;
252 253
253/*:22*//*25:*/254/*:22*//*25:*/
254#line 194 "common.w"255#line 194 "common.w"
@@ -259,7 +260,7 @@ FILE*change_file; · 4 unmodified lines
259char file_name[max_include_depth][max_file_name_length];260char file_name[max_include_depth][max_file_name_length];
260 261
261char change_file_name[max_file_name_length];262char change_file_name[max_file_name_length];
262char alt_web_file_name[max_file_name_length];263static char alt_web_file_name[max_file_name_length];
263int line[max_include_depth];264int line[max_include_depth];
264int change_line;265int change_line;
265int change_depth;266int change_depth;
@@ -270,11 +271,11 @@ boolean web_file_open= false; · 4 unmodified lines
270/*:25*//*26:*/271/*:25*//*26:*/
271#line 220 "common.w"272#line 220 "common.w"
272 273
273char change_buffer[buf_size];274static char change_buffer[buf_size];
274char*change_limit;275static char*change_limit;
275 276
276/*:26*//*37:*/277/*:26*//*37:*/
277#line 401 "common.w"278#line 399 "common.w"
278 279
279sixteen_bits section_count;280sixteen_bits section_count;
280boolean changed_section[max_sections];281boolean changed_section[max_sections];
@@ -283,7 +284,7 @@ boolean change_pending; · 2 unmodified lines
283boolean print_where= false;284boolean print_where= false;
284 285
285/*:37*//*43:*/286/*:37*//*43:*/
286#line 598 "common.w"287#line 596 "common.w"
287 288
288char byte_mem[max_bytes];289char byte_mem[max_bytes];
289char*byte_mem_end= byte_mem+max_bytes-1;290char*byte_mem_end= byte_mem+max_bytes-1;
@@ -291,25 +292,25 @@ name_info name_dir[max_names]; · 1 unmodified line
291name_pointer name_dir_end= name_dir+max_names-1;292name_pointer name_dir_end= name_dir+max_names-1;
292 293
293/*:43*//*44:*/294/*:43*//*44:*/
294#line 609 "common.w"295#line 607 "common.w"
295 296
296name_pointer name_ptr;
297char*byte_ptr;297char*byte_ptr;
298name_pointer name_ptr;
298 299
299/*:44*//*46:*/300/*:44*//*46:*/
300#line 629 "common.w"301#line 627 "common.w"
301 302
302name_pointer hash[hash_size];303name_pointer hash[hash_size];
303hash_pointer hash_end= hash+hash_size-1;304hash_pointer hash_end= hash+hash_size-1;
304hash_pointer h;305hash_pointer h;
305 306
306/*:46*//*65:*/307/*:46*//*65:*/
307#line 1017 "common.w"308#line 1014 "common.w"
308 309
309int history= spotless;310int history= spotless;
310 311
311/*:65*//*73:*/312/*:65*//*73:*/
312#line 1138 "common.w"313#line 1135 "common.w"
313 314
314int argc;315int argc;
315char**argv;316char**argv;
@@ -320,7 +321,7 @@ char scn_file_name[max_file_name_length]; · 4 unmodified lines
320boolean flags[128];321boolean flags[128];
321 322
322/*:73*//*83:*/323/*:73*//*83:*/
323#line 1286 "common.w"324#line 1282 "common.w"
324 325
325FILE*C_file;326FILE*C_file;
326FILE*tex_file;327FILE*tex_file;
@@ -332,7 +333,14 @@ FILE*active_file; · 5 unmodified lines
332#line 70 "common.w"333#line 70 "common.w"
333 334
334/*7:*/335/*7:*/
335#line 125 "common.h"336#line 119 "common.h"
337
338extern boolean get_line(void);
339extern void check_complete(void);
340extern void reset_input(void);
341
342/*:7*//*10:*/
343#line 162 "common.h"
336 344
337extern boolean names_match(name_pointer,const char*,size_t,eight_bits);345extern boolean names_match(name_pointer,const char*,size_t,eight_bits);
338extern name_pointer id_lookup(const char*,const char*,char);346extern name_pointer id_lookup(const char*,const char*,char);
@@ -344,71 +352,59 @@ extern void print_prefix_name(name_pointer); · 5 unmodified lines
344extern void print_section_name(name_pointer);352extern void print_section_name(name_pointer);
345extern void sprint_section_name(char*,name_pointer);353extern void sprint_section_name(char*,name_pointer);
346 354
347/*:7*//*9:*/355/*:10*//*12:*/
348#line 149 "common.h"356#line 186 "common.h"
349 357
350extern int wrap_up(void);358extern int wrap_up(void);
351extern void err_print(const char*);359extern void err_print(const char*);
352extern void fatal(const char*,const char*);360extern void fatal(const char*,const char*);
353extern void overflow(const char*);361extern void overflow(const char*);
354 362
355/*:9*//*11:*/363/*:12*//*15:*/
356#line 184 "common.h"
357
358extern boolean get_line(void);
359extern void check_complete(void);
360extern void reset_input(void);
361
362/*:11*//*15:*/
363#line 223 "common.h"364#line 223 "common.h"
364 365
365extern void common_init(void);366extern void common_init(void);
366extern void print_stats(void);367extern void print_stats(void);
367 368
368/*:15*//*23:*/369/*:15*//*24:*/
369#line 159 "common.w"370#line 180 "common.w"
370
371static boolean input_ln(FILE*);371static boolean input_ln(FILE*);
372 372
373/*:23*//*27:*/373/*:24*//*28:*/
374#line 231 "common.w"374#line 241 "common.w"
375
376static void prime_the_change_buffer(void);375static void prime_the_change_buffer(void);
377 376
378/*:27*//*32:*/377/*:28*//*33:*/
379#line 303 "common.w"378#line 340 "common.w"
380
381static void check_change(void);379static void check_change(void);
382 380
383/*:32*//*55:*/381/*:33*//*55:*/
384#line 776 "common.w"382#line 774 "common.w"
385 383
386static int web_strcmp(char*,int,char*,int);384static int web_strcmp(char*,int,char*,int);
387static name_pointer add_section_name(name_pointer,int,char*,char*,int);385static name_pointer add_section_name(name_pointer,int,char*,char*,int);
388static void extend_section_name(name_pointer,char*,char*,int);386static void extend_section_name(name_pointer,char*,char*,int);
389 387
390/*:55*//*63:*/388/*:55*//*64:*/
391#line 972 "common.w"389#line 1002 "common.w"
392
393static int section_name_cmp(char**,int,name_pointer);390static int section_name_cmp(char**,int,name_pointer);
394 391
395/*:63*//*75:*/392/*:64*//*76:*/
396#line 1170 "common.w"393#line 1197 "common.w"
397
398static void scan_args(void);394static void scan_args(void);
399 395
400/*:75*/396/*:76*/
401#line 71 "common.w"397#line 71 "common.w"
402 398
403 399
404/*:1*//*20:*/400/*:1*//*20:*/
405#line 98 "common.w"401#line 99 "common.w"
406 402
407void403void
408common_init(void)404common_init(void)
409{405{
410/*45:*/406/*45:*/
411#line 613 "common.w"407#line 611 "common.w"
412 408
413name_dir->byte_start= byte_ptr= byte_mem;409name_dir->byte_start= byte_ptr= byte_mem;
414name_ptr= name_dir+1;410name_ptr= name_dir+1;
@@ -416,24 +412,24 @@ name_ptr->byte_start= byte_mem; · 1 unmodified line
416root= NULL;412root= NULL;
417 413
418/*:45*//*47:*/414/*:45*//*47:*/
419#line 636 "common.w"415#line 634 "common.w"
420 416
421for(h= hash;h<=hash_end;*h++= NULL);417for(h= hash;h<=hash_end;*h++= NULL);
422 418
423/*:47*/419/*:47*/
424#line 102 "common.w"420#line 103 "common.w"
425 421
426/*74:*/422/*74:*/
427#line 1151 "common.w"423#line 1148 "common.w"
428 424
429show_banner= show_happiness= show_progress= make_xrefs= true;425show_banner= show_happiness= show_progress= make_xrefs= true;
430show_stats= false;426show_stats= false;
431 427
432/*:74*/428/*:74*/
433#line 103 "common.w"429#line 104 "common.w"
434 430
435/*84:*/431/*84:*/
436#line 1293 "common.w"432#line 1289 "common.w"
437 433
438scan_args();434scan_args();
439if(program==ctangle){435if(program==ctangle){
@@ -447,12 +443,12 @@ fatal("! Cannot open output file ",tex_file_name); · 7 unmodified lines
447}443}
448 444
449/*:84*/445/*:84*/
450#line 104 "common.w"446#line 105 "common.w"
451 447
452}448}
453 449
454/*:20*//*24:*/450/*:20*//*23:*/
455#line 162 "common.w"451#line 160 "common.w"
456 452
457static boolean input_ln(453static boolean input_ln(
458FILE*fp)454FILE*fp)
@@ -473,15 +469,15 @@ if(c==EOF&&limit==buffer)return false; · 14 unmodified lines
473return true;469return true;
474}470}
475 471
476/*:24*//*28:*/472/*:23*//*27:*/
477#line 234 "common.w"473#line 231 "common.w"
478 474
479static void475static void
480prime_the_change_buffer(void)476prime_the_change_buffer(void)
481{477{
482change_limit= change_buffer;478change_limit= change_buffer;
483/*29:*/479/*29:*/
484#line 248 "common.w"480#line 247 "common.w"
485 481
486while(true){482while(true){
487change_line++;483change_line++;
@@ -498,10 +494,10 @@ err_print("! Missing @x in change file"); · 10 unmodified lines
498}494}
499 495
500/*:29*/496/*:29*/
501#line 239 "common.w"497#line 236 "common.w"
502 498
503/*30:*/499/*30:*/
504#line 265 "common.w"500#line 264 "common.w"
505 501
506do{502do{
507change_line++;503change_line++;
@@ -513,10 +509,10 @@ return; · 5 unmodified lines
513}while(limit==buffer);509}while(limit==buffer);
514 510
515/*:30*/511/*:30*/
516#line 240 "common.w"512#line 237 "common.w"
517 513
518/*31:*/514/*31:*/
519#line 275 "common.w"515#line 274 "common.w"
520 516
521{517{
522change_limit= change_buffer+(ptrdiff_t)(limit-buffer);518change_limit= change_buffer+(ptrdiff_t)(limit-buffer);
@@ -524,12 +520,12 @@ strncpy(change_buffer,buffer,(size_t)(limit-buffer+1)); · 1 unmodified line
524}520}
525 521
526/*:31*/522/*:31*/
527#line 241 "common.w"523#line 238 "common.w"
528 524
529}525}
530 526
531/*:28*//*33:*/527/*:27*//*32:*/
532#line 306 "common.w"528#line 302 "common.w"
533 529
534static void530static void
535check_change(void)531check_change(void)
@@ -552,7 +548,7 @@ return; · 16 unmodified lines
552if(limit> buffer+1&&buffer[0]=='@'){548if(limit> buffer+1&&buffer[0]=='@'){
553char xyz_code= xisupper(buffer[1])?tolower((eight_bits)buffer[1]):buffer[1];549char xyz_code= xisupper(buffer[1])?tolower((eight_bits)buffer[1]):buffer[1];
554/*34:*/550/*34:*/
555#line 344 "common.w"551#line 342 "common.w"
556 552
557if(xyz_code=='x'||xyz_code=='z'){553if(xyz_code=='x'||xyz_code=='z'){
558loc= buffer+2;err_print("! Where is the matching @y?");554loc= buffer+2;err_print("! Where is the matching @y?");
@@ -570,11 +566,11 @@ return; · 11 unmodified lines
570}566}
571 567
572/*:34*/568/*:34*/
573#line 328 "common.w"569#line 324 "common.w"
574 570
575}571}
576/*31:*/572/*31:*/
577#line 275 "common.w"573#line 274 "common.w"
578 574
579{575{
580change_limit= change_buffer+(ptrdiff_t)(limit-buffer);576change_limit= change_buffer+(ptrdiff_t)(limit-buffer);
@@ -582,7 +578,7 @@ strncpy(change_buffer,buffer,(size_t)(limit-buffer+1)); · 1 unmodified line
582}578}
583 579
584/*:31*/580/*:31*/
585#line 330 "common.w"581#line 326 "common.w"
586 582
587changing= false;cur_line++;583changing= false;cur_line++;
588while(!input_ln(cur_file)){584while(!input_ln(cur_file)){
@@ -597,15 +593,15 @@ if(lines_dont_match)n++; · 8 unmodified lines
597}593}
598}594}
599 595
600/*:33*//*35:*/596/*:32*//*35:*/
601#line 364 "common.w"597#line 362 "common.w"
602 598
603void599void
604reset_input(void)600reset_input(void)
605{601{
606limit= buffer;loc= buffer+1;buffer[0]= ' ';602limit= buffer;loc= buffer+1;buffer[0]= ' ';
607/*36:*/603/*36:*/
608#line 379 "common.w"604#line 377 "common.w"
609 605
610if((web_file= fopen(web_file_name,"r"))==NULL){606if((web_file= fopen(web_file_name,"r"))==NULL){
611strcpy(web_file_name,alt_web_file_name);607strcpy(web_file_name,alt_web_file_name);
@@ -619,7 +615,7 @@ if((change_file= fopen(change_file_name,"r"))==NULL) · 7 unmodified lines
619fatal("! Cannot open change file ",change_file_name);615fatal("! Cannot open change file ",change_file_name);
620 616
621/*:36*/617/*:36*/
622#line 369 "common.w"618#line 367 "common.w"
623 619
624include_depth= 0;cur_line= 0;change_line= 0;620include_depth= 0;cur_line= 0;change_line= 0;
625change_depth= include_depth;621change_depth= include_depth;
@@ -628,14 +624,14 @@ limit= buffer;loc= buffer+1;buffer[0]= ' ';input_has_ended= false; · 2 unmodified lines
628}624}
629 625
630/*:35*//*38:*/626/*:35*//*38:*/
631#line 408 "common.w"627#line 406 "common.w"
632 628
633boolean get_line(void)629boolean get_line(void)
634{630{
635restart:631restart:
636if(changing&&include_depth==change_depth)632if(changing&&include_depth==change_depth)
637/*41:*/633/*41:*/
638#line 516 "common.w"634#line 514 "common.w"
639{635{
640change_line++;636change_line++;
641if(!input_ln(change_file)){637if(!input_ln(change_file)){
@@ -666,11 +662,11 @@ prime_the_change_buffer();changing= !changing;print_where= true; · 24 unmodified lines
666}662}
667 663
668/*:41*/664/*:41*/
669#line 413 "common.w"665#line 411 "common.w"
670 666
671if(!changing||include_depth> change_depth){667if(!changing||include_depth> change_depth){
672/*40:*/668/*40:*/
673#line 499 "common.w"669#line 497 "common.w"
674{670{
675cur_line++;671cur_line++;
676while(!input_ln(cur_file)){672while(!input_ln(cur_file)){
@@ -689,7 +685,7 @@ if(change_limit> change_buffer)check_change(); · 12 unmodified lines
689}685}
690 686
691/*:40*/687/*:40*/
692#line 415 "common.w"688#line 413 "common.w"
693 689
694if(changing&&include_depth==change_depth)goto restart;690if(changing&&include_depth==change_depth)goto restart;
695}691}
@@ -710,7 +706,7 @@ goto restart; · 14 unmodified lines
710}706}
711include_depth++;707include_depth++;
712/*39:*/708/*39:*/
713#line 453 "common.w"709#line 451 "common.w"
714{710{
715char temp_file_name[max_file_name_length];711char temp_file_name[max_file_name_length];
716char*cur_file_name_end= cur_file_name+max_file_name_length-1;712char*cur_file_name_end= cur_file_name+max_file_name_length-1;
@@ -758,14 +754,14 @@ include_depth--;err_print("! Cannot open include file");goto restart; · 41 unmodified lines
758}754}
759 755
760/*:39*/756/*:39*/
761#line 434 "common.w"757#line 432 "common.w"
762 758
763}759}
764return true;760return true;
765}761}
766 762
767/*:38*//*42:*/763/*:38*//*42:*/
768#line 548 "common.w"764#line 546 "common.w"
769 765
770void766void
771check_complete(void){767check_complete(void){
@@ -779,7 +775,7 @@ err_print("! Change file entry did not match"); · 7 unmodified lines
779}775}
780 776
781/*:42*//*48:*/777/*:42*//*48:*/
782#line 641 "common.w"778#line 639 "common.w"
783 779
784name_pointer780name_pointer
785id_lookup(781id_lookup(
@@ -794,17 +790,17 @@ name_pointer p; · 8 unmodified lines
794if(last==NULL)for(last= first;*last!='\0';last++);790if(last==NULL)for(last= first;*last!='\0';last++);
795l= (int)(last-first);791l= (int)(last-first);
796/*49:*/792/*49:*/
797#line 664 "common.w"793#line 662 "common.w"
798 794
799h= (eight_bits)*i;795h= (eight_bits)*i;
800while(++i<last)h= (h+h+(int)((eight_bits)*i))%hash_size;796while(++i<last)h= (h+h+(int)((eight_bits)*i))%hash_size;
801 797
802 798
803/*:49*/799/*:49*/
804#line 654 "common.w"800#line 652 "common.w"
805 801
806/*50:*/802/*50:*/
807#line 672 "common.w"803#line 670 "common.w"
808 804
809p= hash[h];805p= hash[h];
810while(p&&!names_match(p,first,l,t))p= p->link;806while(p&&!names_match(p,first,l,t))p= p->link;
@@ -814,10 +810,10 @@ p->link= hash[h];hash[h]= p; · 3 unmodified lines
814}810}
815 811
816/*:50*/812/*:50*/
817#line 655 "common.w"813#line 653 "common.w"
818 814
819if(p==name_ptr)/*51:*/815if(p==name_ptr)/*51:*/
820#line 683 "common.w"816#line 681 "common.w"
821{817{
822if(byte_ptr+l> byte_mem_end)overflow("byte memory");818if(byte_ptr+l> byte_mem_end)overflow("byte memory");
823if(name_ptr>=name_dir_end)overflow("name");819if(name_ptr>=name_dir_end)overflow("name");
@@ -827,13 +823,13 @@ init_p(p,t); · 3 unmodified lines
827}823}
828 824
829/*:51*/825/*:51*/
830#line 656 "common.w"826#line 654 "common.w"
831 827
832return p;828return p;
833}829}
834 830
835/*:48*//*52:*/831/*:48*//*52:*/
836#line 715 "common.w"832#line 713 "common.w"
837 833
838void834void
839print_section_name(835print_section_name(
@@ -854,7 +850,7 @@ if(q)term_write("...",3); · 14 unmodified lines
854}850}
855 851
856/*:52*//*53:*/852/*:52*//*53:*/
857#line 734 "common.w"853#line 732 "common.w"
858 854
859void855void
860sprint_section_name(856sprint_section_name(
@@ -877,7 +873,7 @@ s= p->byte_start; · 16 unmodified lines
877}873}
878 874
879/*:53*//*54:*/875/*:53*//*54:*/
880#line 755 "common.w"876#line 753 "common.w"
881 877
882void878void
883print_prefix_name(879print_prefix_name(
@@ -890,7 +886,7 @@ if(s+l<(p+1)->byte_start)term_write("...",3); · 6 unmodified lines
890}886}
891 887
892/*:54*//*56:*/888/*:54*//*56:*/
893#line 781 "common.w"889#line 779 "common.w"
894 890
895static int web_strcmp(891static int web_strcmp(
896char*j,892char*j,
@@ -908,7 +904,7 @@ else return greater; · 11 unmodified lines
908}904}
909 905
910/*:56*//*57:*/906/*:56*//*57:*/
911#line 810 "common.w"907#line 808 "common.w"
912 908
913static name_pointer909static name_pointer
914add_section_name(910add_section_name(
@@ -939,7 +935,7 @@ return par==NULL?(root= p):c==less?(par->llink= p):(par->rlink= p); · 24 unmodified lines
939}935}
940 936
941/*:57*//*58:*/937/*:57*//*58:*/
942#line 839 "common.w"938#line 837 "common.w"
943 939
944static void940static void
945extend_section_name(941extend_section_name(
@@ -963,7 +959,7 @@ if(ispref)*(byte_ptr-1)= ' '; · 17 unmodified lines
963}959}
964 960
965/*:58*//*59:*/961/*:58*//*59:*/
966#line 867 "common.w"962#line 865 "common.w"
967 963
968name_pointer964name_pointer
969section_lookup(965section_lookup(
@@ -978,7 +974,7 @@ name_pointer par= NULL; · 8 unmodified lines
978 974
979int name_len= (int)(last-first)+1;975int name_len= (int)(last-first)+1;
980/*60:*/976/*60:*/
981#line 891 "common.w"977#line 889 "common.w"
982 978
983while(p){979while(p){
984c= web_strcmp(first,name_len,first_chunk(p),prefix_length(p));980c= web_strcmp(first,name_len,first_chunk(p),prefix_length(p));
@@ -1005,19 +1001,19 @@ p= q,q= NULL; · 20 unmodified lines
1005}1001}
1006 1002
1007/*:60*/1003/*:60*/
1008#line 881 "common.w"1004#line 879 "common.w"
1009 1005
1010/*61:*/1006/*61:*/
1011#line 916 "common.w"1007#line 914 "common.w"
1012 1008
1013if(r==NULL)1009if(r==NULL)
1014return add_section_name(par,c,first,last+1,ispref);1010return add_section_name(par,c,first,last+1,ispref);
1015 1011
1016/*:61*/1012/*:61*/
1017#line 882 "common.w"1013#line 880 "common.w"
1018 1014
1019/*62:*/1015/*62:*/
1020#line 924 "common.w"1016#line 922 "common.w"
1021 1017
1022switch(section_name_cmp(&first,name_len,r)){1018switch(section_name_cmp(&first,name_len,r)){
1023 1019
@@ -1051,12 +1047,12 @@ return r; · 27 unmodified lines
1051}1047}
1052 1048
1053/*:62*/1049/*:62*/
1054#line 883 "common.w"1050#line 881 "common.w"
1055 1051
1056}1052}
1057 1053
1058/*:59*//*64:*/1054/*:59*//*63:*/
1059#line 975 "common.w"1055#line 970 "common.w"
1060 1056
1061static int section_name_cmp(1057static int section_name_cmp(
1062char**pfirst,1058char**pfirst,
@@ -1089,8 +1085,8 @@ default:return c; · 26 unmodified lines
1089}1085}
1090}1086}
1091 1087
1092/*:64*//*66:*/1088/*:63*//*66:*/
1093#line 1027 "common.w"1089#line 1024 "common.w"
1094 1090
1095void1091void
1096err_print(1092err_print(
@@ -1099,7 +1095,7 @@ const char*s) · 2 unmodified lines
1099char*k,*l;1095char*k,*l;
1100printf(*s=='!'?"\n%s":"%s",s);1096printf(*s=='!'?"\n%s":"%s",s);
1101if(web_file_open)/*67:*/1097if(web_file_open)/*67:*/
1102#line 1047 "common.w"1098#line 1044 "common.w"
1103 1099
1104{if(changing&&include_depth==change_depth)1100{if(changing&&include_depth==change_depth)
1105printf(". (l. %d of change file)\n",change_line);1101printf(". (l. %d of change file)\n",change_line);
@@ -1119,20 +1115,20 @@ putchar(' '); · 13 unmodified lines
1119}1115}
1120 1116
1121/*:67*/1117/*:67*/
1122#line 1034 "common.w"1118#line 1031 "common.w"
1123 1119
1124update_terminal;mark_error;1120update_terminal;mark_error;
1125}1121}
1126 1122
1127/*:66*//*68:*/1123/*:66*//*68:*/
1128#line 1079 "common.w"1124#line 1076 "common.w"
1129 1125
1130int wrap_up(void){1126int wrap_up(void){
1131if(show_progress)new_line;1127if(show_progress)new_line;
1132if(show_stats)1128if(show_stats)
1133print_stats();1129print_stats();
1134/*69:*/1130/*69:*/
1135#line 1089 "common.w"1131#line 1086 "common.w"
1136 1132
1137switch(history){1133switch(history){
1138case spotless:if(show_happiness)puts("(No errors were found.)");break;1134case spotless:if(show_happiness)puts("(No errors were found.)");break;
@@ -1144,14 +1140,14 @@ case fatal_message:puts("(That was a fatal error, my friend.)"); · 5 unmodified lines
1144}1140}
1145 1141
1146/*:69*/1142/*:69*/
1147#line 1084 "common.w"1143#line 1081 "common.w"
1148 1144
1149if(history> harmless_message)return EXIT_FAILURE;1145if(history> harmless_message)return EXIT_FAILURE;
1150else return EXIT_SUCCESS;1146else return EXIT_SUCCESS;
1151}1147}
1152 1148
1153/*:68*//*70:*/1149/*:68*//*70:*/
1154#line 1105 "common.w"1150#line 1102 "common.w"
1155void1151void
1156fatal(1152fatal(
1157const char*s,const char*t)1153const char*s,const char*t)
@@ -1162,7 +1158,7 @@ history= fatal_message;exit(wrap_up()); · 4 unmodified lines
1162}1158}
1163 1159
1164/*:70*//*71:*/1160/*:70*//*71:*/
1165#line 1116 "common.w"1161#line 1113 "common.w"
1166void1162void
1167overflow(1163overflow(
1168const char*t)1164const char*t)
@@ -1171,8 +1167,8 @@ printf("\n! Sorry, %s capacity exceeded",t);fatal("",""); · 2 unmodified lines
1171}1167}
1172 1168
1173 1169
1174/*:71*//*76:*/1170/*:71*//*75:*/
1175#line 1173 "common.w"1171#line 1167 "common.w"
1176 1172
1177static void1173static void
1178scan_args(void)1174scan_args(void)
@@ -1186,7 +1182,7 @@ boolean found_web= false,found_change= false,found_out= false; · 7 unmodified lines
1186strcpy(change_file_name,"/dev/null");1182strcpy(change_file_name,"/dev/null");
1187while(--argc> 0){1183while(--argc> 0){
1188if((**(++argv)=='-'||**argv=='+')&&*(*argv+1))/*80:*/1184if((**(++argv)=='-'||**argv=='+')&&*(*argv+1))/*80:*/
1189#line 1262 "common.w"1185#line 1258 "common.w"
1190 1186
1191{1187{
1192for(dot_pos= *argv+1;*dot_pos> '\0';dot_pos++)1188for(dot_pos= *argv+1;*dot_pos> '\0';dot_pos++)
@@ -1194,7 +1190,7 @@ flags[(eight_bits)*dot_pos]= flag_change; · 1 unmodified line
1194}1190}
1195 1191
1196/*:80*/1192/*:80*/
1197#line 1185 "common.w"1193#line 1179 "common.w"
1198 1194
1199else{1195else{
1200s= name_pos= *argv;dot_pos= NULL;1196s= name_pos= *argv;dot_pos= NULL;
@@ -1204,17 +1200,17 @@ else if(*s=='/')dot_pos= NULL,name_pos= ++s; · 3 unmodified lines
1204else s++;1200else s++;
1205}1201}
1206if(!found_web)/*77:*/1202if(!found_web)/*77:*/
1207#line 1210 "common.w"1203#line 1206 "common.w"
1208 1204
1209{1205{
1210if(s-*argv> max_file_name_length-5)1206if(s-*argv> max_file_name_length-5)
1211/*82:*/1207/*82:*/
1212#line 1280 "common.w"1208#line 1276 "common.w"
1213fatal("! Filename too long\n",*argv);1209fatal("! Filename too long\n",*argv);
1214 1210
1215 1211
1216/*:82*/1212/*:82*/
1217#line 1213 "common.w"1213#line 1209 "common.w"
1218 1214
1219if(dot_pos==NULL)1215if(dot_pos==NULL)
1220sprintf(web_file_name,"%s.w",*argv);1216sprintf(web_file_name,"%s.w",*argv);
@@ -1231,21 +1227,21 @@ found_web= true; · 10 unmodified lines
1231}1227}
1232 1228
1233/*:77*/1229/*:77*/
1234#line 1194 "common.w"1230#line 1188 "common.w"
1235 1231
1236else if(!found_change)/*78:*/1232else if(!found_change)/*78:*/
1237#line 1228 "common.w"1233#line 1224 "common.w"
1238 1234
1239{1235{
1240if(strcmp(*argv,"-")!=0){1236if(strcmp(*argv,"-")!=0){
1241if(s-*argv> max_file_name_length-4)1237if(s-*argv> max_file_name_length-4)
1242/*82:*/1238/*82:*/
1243#line 1280 "common.w"1239#line 1276 "common.w"
1244fatal("! Filename too long\n",*argv);1240fatal("! Filename too long\n",*argv);
1245 1241
1246 1242
1247/*:82*/1243/*:82*/
1248#line 1232 "common.w"1244#line 1228 "common.w"
1249 1245
1250if(dot_pos==NULL)1246if(dot_pos==NULL)
1251sprintf(change_file_name,"%s.ch",*argv);1247sprintf(change_file_name,"%s.ch",*argv);
@@ -1255,20 +1251,20 @@ found_change= true; · 3 unmodified lines
1255}1251}
1256 1252
1257/*:78*/1253/*:78*/
1258#line 1195 "common.w"1254#line 1189 "common.w"
1259 1255
1260else if(!found_out)/*79:*/1256else if(!found_out)/*79:*/
1261#line 1240 "common.w"1257#line 1236 "common.w"
1262 1258
1263{1259{
1264if(s-*argv> max_file_name_length-5)1260if(s-*argv> max_file_name_length-5)
1265/*82:*/1261/*82:*/
1266#line 1280 "common.w"1262#line 1276 "common.w"
1267fatal("! Filename too long\n",*argv);1263fatal("! Filename too long\n",*argv);
1268 1264
1269 1265
1270/*:82*/1266/*:82*/
1271#line 1243 "common.w"1267#line 1239 "common.w"
1272 1268
1273if(dot_pos==NULL){1269if(dot_pos==NULL){
1274sprintf(tex_file_name,"%s.tex",*argv);1270sprintf(tex_file_name,"%s.tex",*argv);
@@ -1288,10 +1284,10 @@ found_out= true; · 13 unmodified lines
1288}1284}
1289 1285
1290/*:79*/1286/*:79*/
1291#line 1196 "common.w"1287#line 1190 "common.w"
1292 1288
1293else/*81:*/1289else/*81:*/
1294#line 1268 "common.w"1290#line 1264 "common.w"
1295 1291
1296{1292{
1297if(program==ctangle)1293if(program==ctangle)
@@ -1305,12 +1301,12 @@ else fatal( · 7 unmodified lines
1305}1301}
1306 1302
1307/*:81*/1303/*:81*/
1308#line 1197 "common.w"1304#line 1191 "common.w"
1309 1305
1310}1306}
1311}1307}
1312if(!found_web)/*81:*/1308if(!found_web)/*81:*/
1313#line 1268 "common.w"1309#line 1264 "common.w"
1314 1310
1315{1311{
1316if(program==ctangle)1312if(program==ctangle)
@@ -1324,8 +1320,8 @@ else fatal( · 7 unmodified lines
1324}1320}
1325 1321
1326/*:81*/1322/*:81*/
1327#line 1200 "common.w"1323#line 1194 "common.w"
1328 1324
1329}1325}
1330 1326
1331/*:76*/1327/*:75*/
common.h+45−45
@@ -2,7 +2,7 @@ · 1 unmodified line
2% This program by Silvio Levy and Donald E. Knuth2% This program by Silvio Levy and Donald E. Knuth
3% is based on a program by Knuth.3% is based on a program by Knuth.
4% It is distributed WITHOUT ANY WARRANTY, express or implied.4% It is distributed WITHOUT ANY WARRANTY, express or implied.
5% Version 4.1 --- February 2021 (works also with later versions)5% Version 4.2 --- February 2021 (works also with later versions)
6 6
7% Copyright (C) 1987,1990,1993 Silvio Levy and Donald E. Knuth7% Copyright (C) 1987,1990,1993 Silvio Levy and Donald E. Knuth
8 8
@@ -91,6 +91,43 @@ extern char *buffer_end; /* end of |buffer| */ · 82 unmodified lines
91extern char *loc; /* points to the next character to be read from the buffer */91extern char *loc; /* points to the next character to be read from the buffer */
92extern char *limit; /* points to the last character in the buffer */92extern char *limit; /* points to the last character in the buffer */
93 93
94@ Code related to file handling:
95@f line x /* make |line| an unreserved word */
96@d max_include_depth 10 /* maximum number of source files open
97 simultaneously, not counting the change file */
98@d max_file_name_length 1024
99@d cur_file file[include_depth] /* current file */
100@d cur_file_name file_name[include_depth] /* current file name */
101@d cur_line line[include_depth] /* number of current line in current file */
102@d web_file file[0] /* main source file */
103@d web_file_name file_name[0] /* main source file name */
104
105@<Common code...@>=
106extern int include_depth; /* current level of nesting */
107extern FILE *file[]; /* stack of non-change files */
108extern FILE *change_file; /* change file */
109extern char file_name[][max_file_name_length];
110 /* stack of non-change file names */
111extern char change_file_name[]; /* name of change file */
112extern int line[]; /* number of current line in the stacked files */
113extern int change_line; /* number of current line in change file */
114extern int change_depth; /* where \.{@@y} originated during a change */
115extern boolean input_has_ended; /* if there is no more input */
116extern boolean changing; /* if the current line is from |change_file| */
117extern boolean web_file_open; /* if the web file is being read */
118
119@ @<Predecl...@>=
120extern boolean get_line(void); /* inputs the next line */
121extern void check_complete(void); /* checks that all changes were picked up */
122extern void reset_input(void); /* initialize to read the web file and change file */
123
124@ Code related to section numbers:
125@<Common code...@>=
126extern sixteen_bits section_count; /* the current section number */
127extern boolean changed_section[]; /* is the section changed? */
128extern boolean change_pending; /* is a decision about change still unclear? */
129extern boolean print_where; /* tells \.{CTANGLE} to print line and file info */
130
94@ Code related to identifier and section name storage:131@ Code related to identifier and section name storage:
95@d length(c) (size_t)((c+1)->byte_start-(c)->byte_start) /* the length of a name */132@d length(c) (size_t)((c+1)->byte_start-(c)->byte_start) /* the length of a name */
96@d print_id(c) term_write((c)->byte_start,length((c))) /* print identifier */133@d print_id(c) term_write((c)->byte_start,length((c))) /* print identifier */
@@ -131,7 +168,7 @@ extern void init_node(name_pointer);@/ · 34 unmodified lines
131extern void init_p(name_pointer,eight_bits);@/168extern void init_p(name_pointer,eight_bits);@/
132extern void print_prefix_name(name_pointer);@/169extern void print_prefix_name(name_pointer);@/
133extern void print_section_name(name_pointer);@/170extern void print_section_name(name_pointer);@/
134extern void sprint_section_name(char *,name_pointer);@/171extern void sprint_section_name(char *,name_pointer);
135 172
136@ Code related to error handling:173@ Code related to error handling:
137@d spotless 0 /* |history| value for normal jobs */174@d spotless 0 /* |history| value for normal jobs */
@@ -152,47 +189,6 @@ extern void err_print(const char *); /* print error message and context */ · 14 unmodified lines
152extern void fatal(const char *,const char *); /* issue error message and die */189extern void fatal(const char *,const char *); /* issue error message and die */
153extern void overflow(const char *); /* succumb because a table has overflowed */190extern void overflow(const char *); /* succumb because a table has overflowed */
154 191
155@ Code related to file handling:
156@f line x /* make |line| an unreserved word */
157@d max_include_depth 10 /* maximum number of source files open
158 simultaneously, not counting the change file */
159@d max_file_name_length 1024
160@d cur_file file[include_depth] /* current file */
161@d cur_file_name file_name[include_depth] /* current file name */
162@d cur_line line[include_depth] /* number of current line in current file */
163@d web_file file[0] /* main source file */
164@d web_file_name file_name[0] /* main source file name */
165
166@<Common code...@>=
167extern int include_depth; /* current level of nesting */
168extern FILE *file[]; /* stack of non-change files */
169extern FILE *change_file; /* change file */
170extern char C_file_name[]; /* name of |C_file| */
171extern char tex_file_name[]; /* name of |tex_file| */
172extern char idx_file_name[]; /* name of |idx_file| */
173extern char scn_file_name[]; /* name of |scn_file| */
174extern char file_name[][max_file_name_length];
175 /* stack of non-change file names */
176extern char change_file_name[]; /* name of change file */
177extern int line[]; /* number of current line in the stacked files */
178extern int change_line; /* number of current line in change file */
179extern int change_depth; /* where \.{@@y} originated during a change */
180extern boolean input_has_ended; /* if there is no more input */
181extern boolean changing; /* if the current line is from |change_file| */
182extern boolean web_file_open; /* if the web file is being read */
183
184@ @<Predecl...@>=
185extern boolean get_line(void); /* inputs the next line */
186extern void check_complete(void); /* checks that all changes were picked up */
187extern void reset_input(void); /* initialize to read the web file and change file */
188
189@ Code related to section numbers:
190@<Common code...@>=
191extern sixteen_bits section_count; /* the current section number */
192extern boolean changed_section[]; /* is the section changed? */
193extern boolean change_pending; /* is a decision about change still unclear? */
194extern boolean print_where; /* tells \.{CTANGLE} to print line and file info */
195
196@ Code related to command line arguments:192@ Code related to command line arguments:
197@d show_banner flags['b'] /* should the banner line be printed? */193@d show_banner flags['b'] /* should the banner line be printed? */
198@d show_progress flags['p'] /* should progress reports be printed? */194@d show_progress flags['p'] /* should progress reports be printed? */
@@ -203,9 +199,13 @@ extern boolean print_where; /* tells \.{CTANGLE} to print line and file info */ · 4 unmodified lines
203@<Common code...@>=199@<Common code...@>=
204extern int argc; /* copy of |ac| parameter to |main| */200extern int argc; /* copy of |ac| parameter to |main| */
205extern char **argv; /* copy of |av| parameter to |main| */201extern char **argv; /* copy of |av| parameter to |main| */
202extern char C_file_name[]; /* name of |C_file| */
203extern char tex_file_name[]; /* name of |tex_file| */
204extern char idx_file_name[]; /* name of |idx_file| */
205extern char scn_file_name[]; /* name of |scn_file| */
206extern boolean flags[]; /* an option for each 7-bit code */206extern boolean flags[]; /* an option for each 7-bit code */
207 207
208@ Code relating to output:208@ Code related to output:
209@d update_terminal fflush(stdout) /* empty the terminal output buffer */209@d update_terminal fflush(stdout) /* empty the terminal output buffer */
210@d new_line putchar('\n') @d putxchar putchar210@d new_line putchar('\n') @d putxchar putchar
211@d term_write(a,b) fflush(stdout),fwrite(a,sizeof(char),b,stdout)211@d term_write(a,b) fflush(stdout),fwrite(a,sizeof(char),b,stdout)
@@ -222,7 +222,7 @@ extern FILE *active_file; /* currently active file for \.{CWEAVE} output */ · 10 unmodified lines
222@ The procedure that gets everything rolling:222@ The procedure that gets everything rolling:
223@<Predecl...@>=223@<Predecl...@>=
224extern void common_init(void);@/224extern void common_init(void);@/
225extern void print_stats(void);@/225extern void print_stats(void);
226 226
227@ The following parameters were sufficient in the original \.{WEB} to227@ The following parameters were sufficient in the original \.{WEB} to
228handle \TEX/, so they should be sufficient for most applications of228handle \TEX/, so they should be sufficient for most applications of
common.w+29−33
@@ -2,7 +2,7 @@ · 1 unmodified line
2% This program by Silvio Levy and Donald E. Knuth2% This program by Silvio Levy and Donald E. Knuth
3% is based on a program by Knuth.3% is based on a program by Knuth.
4% It is distributed WITHOUT ANY WARRANTY, express or implied.4% It is distributed WITHOUT ANY WARRANTY, express or implied.
5% Version 4.1 --- February 20215% Version 4.2 --- February 2021
6 6
7% Copyright (C) 1987,1990,1993,2000 Silvio Levy and Donald E. Knuth7% Copyright (C) 1987,1990,1993,2000 Silvio Levy and Donald E. Knuth
8 8
@@ -22,12 +22,12 @@ · 13 unmodified lines
22 22
23\def\v{\char'174} % vertical (|) in typewriter font23\def\v{\char'174} % vertical (|) in typewriter font
24 24
25\def\title{Common code for CTANGLE and CWEAVE (Version 4.1)}25\def\title{Common code for CTANGLE and CWEAVE (Version 4.2)}
26\def\topofcontents{\null\vfill26\def\topofcontents{\null\vfill
27 \centerline{\titlefont Common code for {\ttitlefont CTANGLE} and27 \centerline{\titlefont Common code for {\ttitlefont CTANGLE} and
28 {\ttitlefont CWEAVE}}28 {\ttitlefont CWEAVE}}
29 \vskip 15pt29 \vskip 15pt
30 \centerline{(Version 4.1)}30 \centerline{(Version 4.2)}
31 \vfill}31 \vfill}
32\def\botofcontents{\vfill32\def\botofcontents{\vfill
33\noindent33\noindent
@@ -68,7 +68,7 @@ The file begins with a few basic definitions. · 34 unmodified lines
68@h68@h
69@<Common code for \.{CWEAVE} and \.{CTANGLE}@>@/69@<Common code for \.{CWEAVE} and \.{CTANGLE}@>@/
70@<Global variables@>@/70@<Global variables@>@/
71@<Predeclaration of procedures@>@/71@<Predeclaration of procedures@>
72 72
73@ The details will be filled in due course. The interface of this module73@ The details will be filled in due course. The interface of this module
74is included first. It is also used by the main programs.74is included first. It is also used by the main programs.
@@ -89,7 +89,8 @@ produces the \TEX/ output file, and finally it sorts and outputs the index. · 14 unmodified lines
89Similarly, \.{CTANGLE} operates in two phases.89Similarly, \.{CTANGLE} operates in two phases.
90The global variable |phase| tells which phase we are in.90The global variable |phase| tells which phase we are in.
91 91
92@<Global var...@>= int phase; /* which phase are we in? */92@<Global var...@>=
93int phase; /* which phase are we in? */
93 94
94@ There's an initialization procedure that gets both \.{CTANGLE} and95@ There's an initialization procedure that gets both \.{CTANGLE} and
95\.{CWEAVE} off to a good start. We will fill in the details of this96\.{CWEAVE} off to a good start. We will fill in the details of this
@@ -149,17 +150,14 @@ some of \.{CWEB}'s routines use the fact that it is safe to refer to · 53 unmodified lines
149@<Global var...@>=150@<Global var...@>=
150char buffer[long_buf_size]; /* where each line of input goes */151char buffer[long_buf_size]; /* where each line of input goes */
151char *buffer_end=buffer+buf_size-2; /* end of |buffer| */152char *buffer_end=buffer+buf_size-2; /* end of |buffer| */
152char *limit=buffer; /* points to the last character in the buffer */
153char *loc=buffer; /* points to the next character to be read from the buffer */153char *loc=buffer; /* points to the next character to be read from the buffer */
154char *limit=buffer; /* points to the last character in the buffer */
154 155
155@ In the unlikely event that your standard I/O library does not156@ In the unlikely event that your standard I/O library does not
156support |feof|, |getc|, and |ungetc| you may have to change things here.157support |feof|, |getc|, and |ungetc| you may have to change things here.
157@^system dependencies@>158@^system dependencies@>
158 159
159@<Predecl...@>=160@c
160static boolean input_ln(FILE *);@/
161
162@ @c
163static boolean input_ln(@t\1\1@> /* copies a line into |buffer| or returns |false| */161static boolean input_ln(@t\1\1@> /* copies a line into |buffer| or returns |false| */
164FILE *fp@t\2\2@>) /* what file to read from */162FILE *fp@t\2\2@>) /* what file to read from */
165{163{
@@ -179,6 +177,8 @@ FILE *fp@t\2\2@>) /* what file to read from */ · 13 unmodified lines
179 return true;177 return true;
180}178}
181 179
180@ @<Predecl...@>=@+static boolean input_ln(FILE *);
181
182@ Now comes the problem of deciding which file to read from next.182@ Now comes the problem of deciding which file to read from next.
183Recall that the actual text that \.{CWEB} should process comes from two183Recall that the actual text that \.{CWEB} should process comes from two
184streams: a |web_file|, which can contain possibly nested include184streams: a |web_file|, which can contain possibly nested include
@@ -198,7 +198,7 @@ FILE *change_file; /* change file */ · 13 unmodified lines
198char file_name[max_include_depth][max_file_name_length];198char file_name[max_include_depth][max_file_name_length];
199 /* stack of non-change file names */199 /* stack of non-change file names */
200char change_file_name[max_file_name_length]; /* name of change file */200char change_file_name[max_file_name_length]; /* name of change file */
201char alt_web_file_name[max_file_name_length]; /* alternate name to try */201static char alt_web_file_name[max_file_name_length]; /* alternate name to try */
202int line[max_include_depth]; /* number of current line in the stacked files */202int line[max_include_depth]; /* number of current line in the stacked files */
203int change_line; /* number of current line in change file */203int change_line; /* number of current line in change file */
204int change_depth; /* where \.{@@y} originated during a change */204int change_depth; /* where \.{@@y} originated during a change */
@@ -218,8 +218,8 @@ Here's a shorthand expression for inequality between the two lines: · 13 unmodified lines
218 strncmp(buffer, change_buffer, (size_t)(limit-buffer)))218 strncmp(buffer, change_buffer, (size_t)(limit-buffer)))
219 219
220@<Global var...@>=220@<Global var...@>=
221char change_buffer[buf_size]; /* next line of |change_file| */221static char change_buffer[buf_size]; /* next line of |change_file| */
222char *change_limit; /* points to the last character in |change_buffer| */222static char *change_limit; /* points to the last character in |change_buffer| */
223 223
224@ Procedure |prime_the_change_buffer|224@ Procedure |prime_the_change_buffer|
225sets |change_buffer| in preparation for the next matching operation.225sets |change_buffer| in preparation for the next matching operation.
@@ -228,10 +228,7 @@ Since blank lines in the change file are not used for matching, we have · 2 unmodified lines
228the change file is exhausted. This procedure is called only when228the change file is exhausted. This procedure is called only when
229|changing| is |true|; hence error messages will be reported correctly.229|changing| is |true|; hence error messages will be reported correctly.
230 230
231@<Predecl...@>=231@c
232static void prime_the_change_buffer(void);@/
233
234@ @c
235static void232static void
236prime_the_change_buffer(void)233prime_the_change_buffer(void)
237{234{
@@ -241,6 +238,8 @@ prime_the_change_buffer(void) · 3 unmodified lines
241 @<Move |buffer| and |limit| to |change_buffer| and |change_limit|@>@;238 @<Move |buffer| and |limit| to |change_buffer| and |change_limit|@>@;
242}239}
243 240
241@ @<Predecl...@>=@+static void prime_the_change_buffer(void);
242
244@ While looking for a line that begins with \.{@@x} in the change file, we243@ While looking for a line that begins with \.{@@x} in the change file, we
245allow lines that begin with \.{@@}, as long as they don't begin with \.{@@y},244allow lines that begin with \.{@@}, as long as they don't begin with \.{@@y},
246\.{@@z}, or \.{@@i} (which would probably mean that the change file is fouled up).245\.{@@z}, or \.{@@i} (which would probably mean that the change file is fouled up).
@@ -289,7 +288,7 @@ prepares to read the next line from |change_file|. · 42 unmodified lines
289 288
290When a match is found, the current section is marked as changed unless289When a match is found, the current section is marked as changed unless
291the first line after the \.{@@x} and after the \.{@@y} both start with290the first line after the \.{@@x} and after the \.{@@y} both start with
292either |'@@*'| or |'@@ '| (possibly preceded by whitespace).291either `\.{@@*}' or `\.{@@\ }' (possibly preceded by whitespace).
293 292
294This procedure is called only when |buffer<limit|, i.e., when the293This procedure is called only when |buffer<limit|, i.e., when the
295current line is nonempty.294current line is nonempty.
@@ -300,10 +299,7 @@ current line is nonempty. · 4 unmodified lines
300 if (*loc=='@@' && (xisspace(*(loc+1)) || *(loc+1)=='*')) change_pending=b;299 if (*loc=='@@' && (xisspace(*(loc+1)) || *(loc+1)=='*')) change_pending=b;
301}300}
302 301
303@<Predecl...@>=302@c
304static void check_change(void);@/
305
306@ @c
307static void303static void
308check_change(void) /* switches to |change_file| if the buffers match */304check_change(void) /* switches to |change_file| if the buffers match */
309{305{
@@ -341,6 +337,8 @@ check_change(void) /* switches to |change_file| if the buffers match */ · 31 unmodified lines
341 }337 }
342}338}
343 339
340@ @<Predecl...@>=@+static void check_change(void);
341
344@ @<If the current line starts with \.{@@y}...@>=342@ @<If the current line starts with \.{@@y}...@>=
345if (xyz_code=='x' || xyz_code=='z') {343if (xyz_code=='x' || xyz_code=='z') {
346 loc=buffer+2; err_print("! Where is the matching @@y?");344 loc=buffer+2; err_print("! Where is the matching @@y?");
@@ -607,8 +605,8 @@ usually have |name_ptr->byte_start==byte_ptr|, and certainly · 260 unmodified lines
607we want to keep |name_ptr<=name_dir_end| and |byte_ptr<=byte_mem_end|.605we want to keep |name_ptr<=name_dir_end| and |byte_ptr<=byte_mem_end|.
608 606
609@<Global var...@>=607@<Global var...@>=
610name_pointer name_ptr; /* first unused position in |name_dir| */
611char *byte_ptr; /* first unused position in |byte_mem| */608char *byte_ptr; /* first unused position in |byte_mem| */
609name_pointer name_ptr; /* first unused position in |name_dir| */
612 610
613@ @<Init...@>=611@ @<Init...@>=
614name_dir->byte_start=byte_ptr=byte_mem; /* position zero in both arrays */612name_dir->byte_start=byte_ptr=byte_mem; /* position zero in both arrays */
@@ -776,7 +774,7 @@ are null-terminated, and we keep an eye open for prefixes and extensions. · 161 unmodified lines
776@<Predecl...@>=774@<Predecl...@>=
777static int web_strcmp(char *,int,char *,int);@/775static int web_strcmp(char *,int,char *,int);@/
778static name_pointer add_section_name(name_pointer,int,char *,char *,int);@/776static name_pointer add_section_name(name_pointer,int,char *,char *,int);@/
779static void extend_section_name(name_pointer,char *,char *,int);@/777static void extend_section_name(name_pointer,char *,char *,int);
780 778
781@ @c779@ @c
782static int web_strcmp(@t\1\1@> /* fuller comparison than |strcmp| */780static int web_strcmp(@t\1\1@> /* fuller comparison than |strcmp| */
@@ -969,10 +967,7 @@ us to regard \.{@@<foo...@@>} as an ``extension'' of itself. · 186 unmodified lines
969 967
970@d bad_extension 5968@d bad_extension 5
971 969
972@<Predec...@>=970@c
973static int section_name_cmp(char **,int,name_pointer);@/
974
975@ @c
976static int section_name_cmp(@t\1\1@>971static int section_name_cmp(@t\1\1@>
977char **pfirst, /* pointer to beginning of comparison string */972char **pfirst, /* pointer to beginning of comparison string */
978int len, /* length of string */973int len, /* length of string */
@@ -1004,6 +999,8 @@ name_pointer r@t\2\2@>) /* section name being compared */ · 25 unmodified lines
1004 }999 }
1005}1000}
1006 1001
1002@ @<Predec...@>=@+static int section_name_cmp(char **,int,name_pointer);
1003
1007@** Reporting errors to the user.1004@** Reporting errors to the user.
1008A global variable called |history| will contain one of four values1005A global variable called |history| will contain one of four values
1009at the end of every run: |spotless| means that no unusual messages were1006at the end of every run: |spotless| means that no unusual messages were
@@ -1150,7 +1147,7 @@ should be set before calling |common_init|. · 140 unmodified lines
1150 1147
1151@<Set the default options common to \.{CTANGLE} and \.{CWEAVE}@>=1148@<Set the default options common to \.{CTANGLE} and \.{CWEAVE}@>=
1152show_banner=show_happiness=show_progress=make_xrefs=true;@/1149show_banner=show_happiness=show_progress=make_xrefs=true;@/
1153show_stats=false;@/1150show_stats=false;
1154 1151
1155@ We now must look at the command line arguments and set the file names1152@ We now must look at the command line arguments and set the file names
1156accordingly. At least one file name must be present: the \.{CWEB}1153accordingly. At least one file name must be present: the \.{CWEB}
@@ -1167,10 +1164,7 @@ when no changes are desired. · 10 unmodified lines
1167 1164
1168If there's a third file name, it will be the output file.1165If there's a third file name, it will be the output file.
1169 1166
1170@<Pred...@>=1167@c
1171static void scan_args(void);@/
1172
1173@ @c
1174static void1168static void
1175scan_args(void)1169scan_args(void)
1176{1170{
@@ -1200,6 +1194,8 @@ scan_args(void) · 23 unmodified lines
1200 if (!found_web) @<Print usage error message and quit@>@;1194 if (!found_web) @<Print usage error message and quit@>@;
1201}1195}
1202 1196
1197@ @<Pred...@>=@+static void scan_args(void);
1198
1203@ We use all of |*argv| for the |web_file_name| if there is a |'.'| in it,1199@ We use all of |*argv| for the |web_file_name| if there is a |'.'| in it,
1204otherwise we add |".w"|. If this file can't be opened, we prepare an1200otherwise we add |".w"|. If this file can't be opened, we prepare an
1205|alt_web_file_name| by adding |"web"| after the dot.1201|alt_web_file_name| by adding |"web"| after the dot.
ctang-bs.ch+8−8
@@ -17,12 +17,12 @@ by using "huge" pointers. · 16 unmodified lines
17The ``banner line'' defined here should be changed whenever \.{CTANGLE}17The ``banner line'' defined here should be changed whenever \.{CTANGLE}
18is modified.18is modified.
19 19
20@d banner "This is CTANGLE (Version 4.1)"20@d banner "This is CTANGLE (Version 4.2)"
21@y21@y
22The ``banner line'' defined here should be changed whenever \.{CTANGLE}22The ``banner line'' defined here should be changed whenever \.{CTANGLE}
23is modified.23is modified.
24 24
25@d banner "This is CTANGLE (Version 4.1pc/big)"25@d banner "This is CTANGLE (Version 4.2pc/big)"
26@z26@z
27 27
28 28
@@ -141,13 +141,13 @@ typedef text *text_pointer; · 112 unmodified lines
141 141
142 142
143@x Section 17.143@x Section 17.
144eight_bits tok_mem[max_toks];144static eight_bits tok_mem[max_toks];
145eight_bits *tok_mem_end=tok_mem+max_toks-1;145static eight_bits *tok_mem_end=tok_mem+max_toks-1;
146eight_bits *tok_ptr; /* first unused position in |tok_mem| */146static eight_bits *tok_ptr; /* first unused position in |tok_mem| */
147@y147@y
148eight_bits huge tok_mem[max_toks];148static eight_bits huge tok_mem[max_toks];
149eight_bits huge* tok_mem_end;149static eight_bits huge* tok_mem_end;
150eight_bits huge* tok_ptr; /* first unused position in |tok_mem| */150static eight_bits huge* tok_ptr; /* first unused position in |tok_mem| */
151@z151@z
152 152
153 153
ctang-pc.ch+2−2
@@ -9,9 +9,9 @@ that allows >64K arrays. If you need lots of bytes and toks, try the · 8 unmodified lines
9alternate change files with -bs suffix instead of -pc.9alternate change files with -bs suffix instead of -pc.
10 10
11@x section 111@x section 1
12@d banner "This is CTANGLE (Version 4.1)"12@d banner "This is CTANGLE (Version 4.2)"
13@y13@y
14@d banner "This is CTANGLE (Version 4.1pc)"14@d banner "This is CTANGLE (Version 4.2pc)"
15@z15@z
16@x section 416@x section 4
17@d max_bytes 1000000 /* the number of bytes in identifiers,17@d max_bytes 1000000 /* the number of bytes in identifiers,
ctang-ql.ch+4−4
@@ -7,15 +7,15 @@ ex <dev_>cc;"-v -h -c -=500000 ctangle_c" · 6 unmodified lines
7 7
8 8
9@x9@x
10\def\title{CTANGLE (Version 4.1)}10\def\title{CTANGLE (Version 4.2)}
11@y11@y
12\def\title{CTANGLE (QL Version 4.1)}12\def\title{CTANGLE (QL Version 4.2)}
13@z13@z
14 14
15@x section 115@x section 1
16@d banner "This is CTANGLE (Version 4.1)"16@d banner "This is CTANGLE (Version 4.2)"
17@y17@y
18@d banner "This is CTANGLE (QL Version 4.1)"18@d banner "This is CTANGLE (QL Version 4.2)"
19@z19@z
20 20
21@x21@x
ctang-vms.ch+2−2
@@ -10,9 +10,9 @@ created: · 9 unmodified lines
10(these changes not necessary for initial bootstrapping)10(these changes not necessary for initial bootstrapping)
11 11
12@x section 1 (01-FEB-1992 ST)12@x section 1 (01-FEB-1992 ST)
13@d banner "This is CTANGLE (Version 4.1)"13@d banner "This is CTANGLE (Version 4.2)"
14@y14@y
15@d banner "This is CTANGLE (VAX/VMS Version 4.1)"15@d banner "This is CTANGLE (VAX/VMS Version 4.2)"
16@z16@z
17 17
18@x section 3 (01-FEB-1992 ST)18@x section 3 (01-FEB-1992 ST)
ctang-w32.ch+2−2
@@ -4,9 +4,9 @@ This is the change file for CWEB's CTANGLE under Win32 · 3 unmodified lines
4Changes necessary for compiling with Borland C/C++4Changes necessary for compiling with Borland C/C++
5 5
6@x section 16@x section 1
7@d banner "This is CTANGLE (Version 4.1)"7@d banner "This is CTANGLE (Version 4.2)"
8@y8@y
9@d banner "This is CTANGLE (Version 4.1win32)"9@d banner "This is CTANGLE (Version 4.2win32)"
10@z10@z
11 11
12@x12@x
ctangle.c+216−225
@@ -15,7 +15,7 @@ · 14 unmodified lines
15/*:4*/15/*:4*/
16#line 67 "ctangle.w"16#line 67 "ctangle.w"
17 17
18#define banner "This is CTANGLE (Version 4.1)" \18#define banner "This is CTANGLE (Version 4.2)" \
19 19
20#define ctangle false20#define ctangle false
21#define cweave true \21#define cweave true \
@@ -43,6 +43,15 @@ · 21 unmodified lines
43#define xisupper(c) (isupper((eight_bits) c) &&((eight_bits) c<0200) ) 43#define xisupper(c) (isupper((eight_bits) c) &&((eight_bits) c<0200) )
44#define xisxdigit(c) (isxdigit((eight_bits) c) &&((eight_bits) c<0200) ) \44#define xisxdigit(c) (isxdigit((eight_bits) c) &&((eight_bits) c<0200) ) \
45 45
46#define max_include_depth 10 \
47
48#define max_file_name_length 1024
49#define cur_file file[include_depth]
50#define cur_file_name file_name[include_depth]
51#define cur_line line[include_depth]
52#define web_file file[0]
53#define web_file_name file_name[0] \
54
46#define length(c) (size_t) ((c+1) ->byte_start-(c) ->byte_start) 55#define length(c) (size_t) ((c+1) ->byte_start-(c) ->byte_start)
47#define print_id(c) term_write((c) ->byte_start,length((c) ) ) 56#define print_id(c) term_write((c) ->byte_start,length((c) ) )
48#define llink link57#define llink link
@@ -59,15 +68,6 @@ · 10 unmodified lines
59#define confusion(s) fatal("! This can't happen: ",s) \68#define confusion(s) fatal("! This can't happen: ",s) \
60 \69 \
61 70
62#define max_include_depth 10 \
63
64#define max_file_name_length 1024
65#define cur_file file[include_depth]
66#define cur_file_name file_name[include_depth]
67#define cur_line line[include_depth]
68#define web_file file[0]
69#define web_file_name file_name[0] \
70
71#define show_banner flags['b']71#define show_banner flags['b']
72#define show_progress flags['p']72#define show_progress flags['p']
73#define show_stats flags['s']73#define show_stats flags['s']
@@ -171,7 +171,31 @@ extern char*loc; · 97 unmodified lines
171extern char*limit;171extern char*limit;
172 172
173/*:6*//*7:*/173/*:6*//*7:*/
174#line 102 "common.h"174#line 105 "common.h"
175
176extern int include_depth;
177extern FILE*file[];
178extern FILE*change_file;
179extern char file_name[][max_file_name_length];
180
181extern char change_file_name[];
182extern int line[];
183extern int change_line;
184extern int change_depth;
185extern boolean input_has_ended;
186extern boolean changing;
187extern boolean web_file_open;
188
189/*:7*//*9:*/
190#line 125 "common.h"
191
192extern sixteen_bits section_count;
193extern boolean changed_section[];
194extern boolean change_pending;
195extern boolean print_where;
196
197/*:9*//*10:*/
198#line 139 "common.h"
175 199
176typedef struct name_info{200typedef struct name_info{
177char*byte_start;201char*byte_start;
@@ -195,44 +219,20 @@ extern name_pointer hash[]; · 17 unmodified lines
195extern hash_pointer hash_end;219extern hash_pointer hash_end;
196extern hash_pointer h;220extern hash_pointer h;
197 221
198/*:7*//*9:*/222/*:10*//*12:*/
199#line 146 "common.h"223#line 183 "common.h"
200 224
201extern int history;225extern int history;
202 226
203/*:9*//*11:*/227/*:12*//*14:*/
204#line 166 "common.h"228#line 199 "common.h"
205 229
206extern int include_depth;230extern int argc;
207extern FILE*file[];231extern char**argv;
208extern FILE*change_file;
209extern char C_file_name[];232extern char C_file_name[];
210extern char tex_file_name[];233extern char tex_file_name[];
211extern char idx_file_name[];234extern char idx_file_name[];
212extern char scn_file_name[];235extern char scn_file_name[];
213extern char file_name[][max_file_name_length];
214
215extern char change_file_name[];
216extern int line[];
217extern int change_line;
218extern int change_depth;
219extern boolean input_has_ended;
220extern boolean changing;
221extern boolean web_file_open;
222
223/*:11*//*13:*/
224#line 190 "common.h"
225
226extern sixteen_bits section_count;
227extern boolean changed_section[];
228extern boolean change_pending;
229extern boolean print_where;
230
231/*:13*//*14:*/
232#line 203 "common.h"
233
234extern int argc;
235extern char**argv;
236extern boolean flags[];236extern boolean flags[];
237 237
238/*:14*//*15:*/238/*:14*//*15:*/
@@ -257,7 +257,7 @@ sixteen_bits text_link; · 18 unmodified lines
257typedef text*text_pointer;257typedef text*text_pointer;
258 258
259/*:19*//*31:*/259/*:19*//*31:*/
260#line 270 "ctangle.w"260#line 269 "ctangle.w"
261 261
262typedef struct{262typedef struct{
263eight_bits*end_field;263eight_bits*end_field;
@@ -274,83 +274,90 @@ typedef output_state*stack_pointer; · 10 unmodified lines
274/*20:*/274/*20:*/
275#line 129 "ctangle.w"275#line 129 "ctangle.w"
276 276
277text text_info[max_texts];277static text text_info[max_texts];
278text_pointer text_info_end= text_info+max_texts-1;278static text_pointer text_info_end= text_info+max_texts-1;
279text_pointer text_ptr;279static text_pointer text_ptr;
280eight_bits tok_mem[max_toks];280static eight_bits tok_mem[max_toks];
281eight_bits*tok_mem_end= tok_mem+max_toks-1;281static eight_bits*tok_mem_end= tok_mem+max_toks-1;
282eight_bits*tok_ptr;282static eight_bits*tok_ptr;
283 283
284/*:20*//*26:*/284/*:20*//*26:*/
285#line 198 "ctangle.w"285#line 198 "ctangle.w"
286 286
287text_pointer last_unnamed;287static text_pointer last_unnamed;
288 288
289/*:26*//*32:*/289/*:26*//*32:*/
290#line 286 "ctangle.w"290#line 285 "ctangle.w"
291 291
292output_state cur_state;292static output_state cur_state;
293 293
294output_state stack[stack_size+1];294static output_state stack[stack_size+1];
295stack_pointer stack_end= stack+stack_size;295static stack_pointer stack_end= stack+stack_size;
296stack_pointer stack_ptr;296static stack_pointer stack_ptr;
297 297
298/*:32*//*37:*/298/*:32*//*37:*/
299#line 362 "ctangle.w"299#line 361 "ctangle.w"
300 300
301int cur_val;301static int cur_val;
302 302
303/*:37*//*42:*/303/*:37*//*42:*/
304#line 454 "ctangle.w"304#line 452 "ctangle.w"
305 305
306eight_bits out_state;306static eight_bits out_state;
307boolean protect;307static boolean protect;
308 308
309/*:42*//*45:*/309/*:42*//*45:*/
310#line 486 "ctangle.w"310#line 483 "ctangle.w"
311 311
312name_pointer output_files[max_files];312static name_pointer output_files[max_files];
313name_pointer*cur_out_file,*end_output_files,*an_output_file;313static name_pointer*cur_out_file,*end_output_files,*an_output_file;
314char cur_section_name_char;314static char cur_section_name_char;
315char output_file_name[longest_name+1];315static char output_file_name[longest_name+1];
316 316
317/*:45*//*52:*/317/*:45*//*52:*/
318#line 586 "ctangle.w"318#line 582 "ctangle.w"
319 319
320boolean output_defs_seen= false;320static boolean output_defs_seen= false;
321 321
322/*:52*//*57:*/322/*:52*//*57:*/
323#line 695 "ctangle.w"323#line 691 "ctangle.w"
324 324
325char translit[128][translit_length];325static char translit[128][translit_length];
326 326
327/*:57*//*62:*/327/*:57*//*62:*/
328#line 774 "ctangle.w"328#line 770 "ctangle.w"
329 329
330eight_bits ccode[256];330static eight_bits ccode[256];
331 331
332/*:62*//*66:*/332/*:62*//*66:*/
333#line 834 "ctangle.w"333#line 830 "ctangle.w"
334 334
335boolean comment_continues= false;335static boolean comment_continues= false;
336 336
337/*:66*//*68:*/337/*:66*//*68:*/
338#line 873 "ctangle.w"338#line 869 "ctangle.w"
339 339
340name_pointer cur_section_name;340static name_pointer cur_section_name;
341boolean no_where;341static boolean no_where;
342 342
343/*:68*//*82:*/343/*:68*//*82:*/
344#line 1187 "ctangle.w"344#line 1182 "ctangle.w"
345 345
346text_pointer cur_text;346static text_pointer cur_text;
347eight_bits next_control;347static eight_bits next_control;
348 348
349/*:82*/349/*:82*/
350#line 71 "ctangle.w"350#line 71 "ctangle.w"
351 351
352/*8:*/352/*8:*/
353#line 125 "common.h"353#line 119 "common.h"
354
355extern boolean get_line(void);
356extern void check_complete(void);
357extern void reset_input(void);
358
359/*:8*//*11:*/
360#line 162 "common.h"
354 361
355extern boolean names_match(name_pointer,const char*,size_t,eight_bits);362extern boolean names_match(name_pointer,const char*,size_t,eight_bits);
356extern name_pointer id_lookup(const char*,const char*,char);363extern name_pointer id_lookup(const char*,const char*,char);
@@ -362,91 +369,75 @@ extern void print_prefix_name(name_pointer); · 5 unmodified lines
362extern void print_section_name(name_pointer);369extern void print_section_name(name_pointer);
363extern void sprint_section_name(char*,name_pointer);370extern void sprint_section_name(char*,name_pointer);
364 371
365/*:8*//*10:*/372/*:11*//*13:*/
366#line 149 "common.h"373#line 186 "common.h"
367 374
368extern int wrap_up(void);375extern int wrap_up(void);
369extern void err_print(const char*);376extern void err_print(const char*);
370extern void fatal(const char*,const char*);377extern void fatal(const char*,const char*);
371extern void overflow(const char*);378extern void overflow(const char*);
372 379
373/*:10*//*12:*/380/*:13*//*16:*/
374#line 184 "common.h"
375
376extern boolean get_line(void);
377extern void check_complete(void);
378extern void reset_input(void);
379
380/*:12*//*16:*/
381#line 223 "common.h"381#line 223 "common.h"
382 382
383extern void common_init(void);383extern void common_init(void);
384extern void print_stats(void);384extern void print_stats(void);
385 385
386/*:16*//*29:*/386/*:16*//*30:*/
387#line 231 "ctangle.w"387#line 241 "ctangle.w"
388
389static void store_two_bytes(sixteen_bits);388static void store_two_bytes(sixteen_bits);
390 389
391/*:29*//*34:*/390/*:30*//*35:*/
392#line 310 "ctangle.w"391#line 324 "ctangle.w"
393 392
394static void push_level(name_pointer);393static void push_level(name_pointer);
395static void pop_level(boolean);394static void pop_level(boolean);
396 395
397/*:34*//*38:*/396/*:35*//*39:*/
398#line 369 "ctangle.w"397#line 397 "ctangle.w"
399
400static void get_output(void);398static void get_output(void);
401 399
402/*:38*//*43:*/400/*:39*//*44:*/
403#line 462 "ctangle.w"401#line 473 "ctangle.w"
404
405static void flush_buffer(void);402static void flush_buffer(void);
406 403
407/*:43*//*48:*/404/*:44*//*49:*/
408#line 517 "ctangle.w"405#line 549 "ctangle.w"
409
410static void phase_two(void);406static void phase_two(void);
411 407
412/*:48*//*53:*/408/*:49*//*53:*/
413#line 589 "ctangle.w"409#line 585 "ctangle.w"
414 410
415static void output_defs(void);411static void output_defs(void);
416static void out_char(eight_bits);412static void out_char(eight_bits);
417 413
418/*:53*//*64:*/414/*:53*//*65:*/
419#line 798 "ctangle.w"415#line 810 "ctangle.w"
420 416
421static eight_bits skip_ahead(void);417static eight_bits skip_ahead(void);
422static boolean skip_comment(boolean);418static boolean skip_comment(boolean);
423 419
424/*:64*//*69:*/420/*:65*//*70:*/
425#line 885 "ctangle.w"421#line 924 "ctangle.w"
426
427static eight_bits get_next(void);422static eight_bits get_next(void);
428 423
429/*:69*//*83:*/424/*:70*//*84:*/
430#line 1191 "ctangle.w"425#line 1208 "ctangle.w"
431
432static void scan_repl(eight_bits);426static void scan_repl(eight_bits);
433 427
434/*:83*//*90:*/428/*:84*//*91:*/
435#line 1348 "ctangle.w"429#line 1379 "ctangle.w"
436
437static void scan_section(void);430static void scan_section(void);
438 431
439/*:90*//*98:*/432/*:91*//*99:*/
440#line 1455 "ctangle.w"433#line 1460 "ctangle.w"
441
442static void phase_one(void);434static void phase_one(void);
443 435
444/*:98*//*100:*/436/*:99*//*101:*/
445#line 1473 "ctangle.w"437#line 1494 "ctangle.w"
446
447static void skip_limbo(void);438static void skip_limbo(void);
448 439
449/*:100*/440/*:101*/
450#line 72 "ctangle.w"441#line 72 "ctangle.w"
451 442
452 443
@@ -476,12 +467,12 @@ init_node(name_dir); · 23 unmodified lines
476last_unnamed= text_info;text_info->text_link= 0;467last_unnamed= text_info;text_info->text_link= 0;
477 468
478/*:27*//*46:*/469/*:27*//*46:*/
479#line 496 "ctangle.w"470#line 493 "ctangle.w"
480 471
481cur_out_file= end_output_files= output_files+max_files;472cur_out_file= end_output_files= output_files+max_files;
482 473
483/*:46*//*58:*/474/*:46*//*58:*/
484#line 698 "ctangle.w"475#line 694 "ctangle.w"
485 476
486{477{
487int i;478int i;
@@ -489,7 +480,7 @@ for(i= 0;i<128;i++)sprintf(translit[i],"X%02X",(unsigned int)(128+i)); · 1 unmodified line
489}480}
490 481
491/*:58*//*63:*/482/*:58*//*63:*/
492#line 777 "ctangle.w"483#line 773 "ctangle.w"
493{484{
494int c;485int c;
495for(c= 0;c<256;c++)ccode[c]= ignore;486for(c= 0;c<256;c++)ccode[c]= ignore;
@@ -509,7 +500,7 @@ ccode['\'']= ord; · 13 unmodified lines
509}500}
510 501
511/*:63*//*78:*/502/*:63*//*78:*/
512#line 1108 "ctangle.w"503#line 1103 "ctangle.w"
513section_text[0]= ' ';504section_text[0]= ' ';
514 505
515/*:78*/506/*:78*/
@@ -547,10 +538,10 @@ node->equiv= (void*)text_info; · 31 unmodified lines
547void538void
548init_p(name_pointer p,eight_bits t){(void)p;(void)t;}539init_p(name_pointer p,eight_bits t){(void)p;(void)t;}
549 540
550/*:25*//*30:*/541/*:25*//*29:*/
551#line 234 "ctangle.w"542#line 231 "ctangle.w"
552 543
553void544static void
554store_two_bytes(545store_two_bytes(
555sixteen_bits x)546sixteen_bits x)
556{547{
@@ -559,8 +550,8 @@ if(tok_ptr+2> tok_mem_end)overflow("token"); · 2 unmodified lines
559*tok_ptr++= x&0377;550*tok_ptr++= x&0377;
560}551}
561 552
562/*:30*//*35:*/553/*:29*//*34:*/
563#line 314 "ctangle.w"554#line 309 "ctangle.w"
564 555
565static void556static void
566push_level(557push_level(
@@ -576,8 +567,8 @@ cur_section= 0; · 9 unmodified lines
576}567}
577}568}
578 569
579/*:35*//*36:*/570/*:34*//*36:*/
580#line 333 "ctangle.w"571#line 332 "ctangle.w"
581 572
582static void573static void
583pop_level(574pop_level(
@@ -592,8 +583,8 @@ stack_ptr--; · 8 unmodified lines
592if(stack_ptr> stack)cur_state= *stack_ptr;583if(stack_ptr> stack)cur_state= *stack_ptr;
593}584}
594 585
595/*:36*//*39:*/586/*:36*//*38:*/
596#line 372 "ctangle.w"587#line 368 "ctangle.w"
597 588
598static void589static void
599get_output(void)590get_output(void)
@@ -616,7 +607,7 @@ switch(a/024000){ · 16 unmodified lines
616case 0:cur_val= a;out_char(identifier);break;607case 0:cur_val= a;out_char(identifier);break;
617case 1:if(a==output_defs_flag)output_defs();608case 1:if(a==output_defs_flag)output_defs();
618else/*40:*/609else/*40:*/
619#line 404 "ctangle.w"610#line 402 "ctangle.w"
620 611
621{612{
622a-= 024000;613a-= 024000;
@@ -630,7 +621,7 @@ goto restart; · 7 unmodified lines
630}621}
631 622
632/*:40*/623/*:40*/
633#line 393 "ctangle.w"624#line 389 "ctangle.w"
634 625
635break;626break;
636default:cur_val= a-050000;if(cur_val> 0)cur_section= cur_val;627default:cur_val= a-050000;if(cur_val> 0)cur_section= cur_val;
@@ -639,8 +630,8 @@ out_char(section_number); · 2 unmodified lines
639}630}
640}631}
641 632
642/*:39*//*44:*/633/*:38*//*43:*/
643#line 465 "ctangle.w"634#line 460 "ctangle.w"
644 635
645static void636static void
646flush_buffer(void)637flush_buffer(void)
@@ -654,30 +645,30 @@ update_terminal; · 7 unmodified lines
654cur_line++;645cur_line++;
655}646}
656 647
657/*:44*//*49:*/648/*:43*//*48:*/
658#line 520 "ctangle.w"649#line 514 "ctangle.w"
659 650
660static void651static void
661phase_two(void){652phase_two(void){
662web_file_open= false;653web_file_open= false;
663cur_line= 1;654cur_line= 1;
664/*33:*/655/*33:*/
665#line 299 "ctangle.w"656#line 298 "ctangle.w"
666 657
667stack_ptr= stack+1;cur_name= name_dir;cur_repl= text_info->text_link+text_info;658stack_ptr= stack+1;cur_name= name_dir;cur_repl= text_info->text_link+text_info;
668cur_byte= cur_repl->tok_start;cur_end= (cur_repl+1)->tok_start;cur_section= 0;659cur_byte= cur_repl->tok_start;cur_end= (cur_repl+1)->tok_start;cur_section= 0;
669 660
670/*:33*/661/*:33*/
671#line 525 "ctangle.w"662#line 519 "ctangle.w"
672 663
673/*51:*/664/*51:*/
674#line 582 "ctangle.w"665#line 578 "ctangle.w"
675 666
676if(!output_defs_seen)667if(!output_defs_seen)
677output_defs();668output_defs();
678 669
679/*:51*/670/*:51*/
680#line 526 "ctangle.w"671#line 520 "ctangle.w"
681 672
682if(text_info->text_link==0&&cur_out_file==end_output_files){673if(text_info->text_link==0&&cur_out_file==end_output_files){
683fputs("\n! No program text was specified.",stdout);mark_harmless;674fputs("\n! No program text was specified.",stdout);mark_harmless;
@@ -700,7 +691,7 @@ if(text_info->text_link==0)goto writeloop; · 16 unmodified lines
700while(stack_ptr> stack)get_output();691while(stack_ptr> stack)get_output();
701flush_buffer();692flush_buffer();
702writeloop:/*50:*/693writeloop:/*50:*/
703#line 559 "ctangle.w"694#line 555 "ctangle.w"
704 695
705for(an_output_file= end_output_files;an_output_file> cur_out_file;){696for(an_output_file= end_output_files;an_output_file> cur_out_file;){
706an_output_file--;697an_output_file--;
@@ -721,7 +712,7 @@ flush_buffer(); · 14 unmodified lines
721}712}
722 713
723/*:50*/714/*:50*/
724#line 547 "ctangle.w"715#line 541 "ctangle.w"
725 716
726if(show_happiness){717if(show_happiness){
727if(show_progress)new_line;718if(show_progress)new_line;
@@ -730,8 +721,8 @@ fputs("Done.",stdout); · 2 unmodified lines
730}721}
731}722}
732 723
733/*:49*//*54:*/724/*:48*//*54:*/
734#line 593 "ctangle.w"725#line 589 "ctangle.w"
735 726
736static void727static void
737output_defs(void)728output_defs(void)
@@ -771,7 +762,7 @@ pop_level(false); · 33 unmodified lines
771}762}
772 763
773/*:54*//*55:*/764/*:54*//*55:*/
774#line 636 "ctangle.w"765#line 632 "ctangle.w"
775 766
776static void767static void
777out_char(768out_char(
@@ -784,7 +775,7 @@ case'\n':if(protect&&out_state!=verbatim)C_putc(' '); · 6 unmodified lines
784if(protect||out_state==verbatim)C_putc('\\');775if(protect||out_state==verbatim)C_putc('\\');
785flush_buffer();if(out_state!=verbatim)out_state= normal;break;776flush_buffer();if(out_state!=verbatim)out_state= normal;break;
786/*59:*/777/*59:*/
787#line 704 "ctangle.w"778#line 700 "ctangle.w"
788 779
789case identifier:780case identifier:
790if(out_state==num_or_id)C_putc(' ');781if(out_state==num_or_id)C_putc(' ');
@@ -799,10 +790,10 @@ j++; · 8 unmodified lines
799out_state= num_or_id;break;790out_state= num_or_id;break;
800 791
801/*:59*/792/*:59*/
802#line 647 "ctangle.w"793#line 643 "ctangle.w"
803 794
804/*60:*/795/*60:*/
805#line 717 "ctangle.w"796#line 713 "ctangle.w"
806 797
807case section_number:798case section_number:
808if(cur_val> 0)C_printf("/*%d:*/",cur_val);799if(cur_val> 0)C_printf("/*%d:*/",cur_val);
@@ -829,10 +820,10 @@ C_printf("%s","\"\n"); · 20 unmodified lines
829break;820break;
830 821
831/*:60*/822/*:60*/
832#line 648 "ctangle.w"823#line 644 "ctangle.w"
833 824
834/*56:*/825/*56:*/
835#line 666 "ctangle.w"826#line 662 "ctangle.w"
836 827
837case plus_plus:C_putc('+');C_putc('+');out_state= normal;break;828case plus_plus:C_putc('+');C_putc('+');out_state= normal;break;
838case minus_minus:C_putc('-');C_putc('-');out_state= normal;break;829case minus_minus:C_putc('-');C_putc('-');out_state= normal;break;
@@ -853,7 +844,7 @@ case minus_gt_ast:C_putc('-');C_putc('>');C_putc('*');out_state= normal; · 14 unmodified lines
853break;844break;
854 845
855/*:56*/846/*:56*/
856#line 649 "ctangle.w"847#line 645 "ctangle.w"
857 848
858case'=':case'>':C_putc(cur_char);C_putc(' ');849case'=':case'>':C_putc(cur_char);C_putc(' ');
859out_state= normal;break;850out_state= normal;break;
@@ -871,8 +862,8 @@ default:C_putc(cur_char);out_state= normal;break; · 11 unmodified lines
871}862}
872}863}
873 864
874/*:55*//*65:*/865/*:55*//*64:*/
875#line 802 "ctangle.w"866#line 794 "ctangle.w"
876 867
877static eight_bits868static eight_bits
878skip_ahead(void)869skip_ahead(void)
@@ -889,8 +880,8 @@ if(c!=ignore||*(loc-1)=='>')return c; · 10 unmodified lines
889}880}
890}881}
891 882
892/*:65*//*67:*/883/*:64*//*67:*/
893#line 837 "ctangle.w"884#line 833 "ctangle.w"
894 885
895static boolean skip_comment(886static boolean skip_comment(
896boolean is_long_comment)887boolean is_long_comment)
@@ -923,8 +914,8 @@ else loc++; · 26 unmodified lines
923}914}
924}915}
925 916
926/*:67*//*70:*/917/*:67*//*69:*/
927#line 888 "ctangle.w"918#line 881 "ctangle.w"
928 919
929static eight_bits920static eight_bits
930get_next(void)921get_next(void)
@@ -938,7 +929,7 @@ if(get_line()==false)return new_section; · 7 unmodified lines
938else if(print_where&&!no_where){929else if(print_where&&!no_where){
939print_where= false;930print_where= false;
940/*85:*/931/*85:*/
941#line 1220 "ctangle.w"932#line 1214 "ctangle.w"
942 933
943store_two_bytes(0150000);934store_two_bytes(0150000);
944if(changing&&include_depth==change_depth){935if(changing&&include_depth==change_depth){
@@ -953,7 +944,7 @@ id_loc= id_first+strlen(id_first); · 8 unmodified lines
953app_repl(a_l%0400);}944app_repl(a_l%0400);}
954 945
955/*:85*/946/*:85*/
956#line 900 "ctangle.w"947#line 893 "ctangle.w"
957 948
958}949}
959else return'\n';950else return'\n';
@@ -967,7 +958,7 @@ else continue; · 7 unmodified lines
967}958}
968loc++;959loc++;
969if(xisdigit(c)||c=='.')/*73:*/960if(xisdigit(c)||c=='.')/*73:*/
970#line 969 "ctangle.w"961#line 964 "ctangle.w"
971{962{
972id_first= loc-1;963id_first= loc-1;
973if(*id_first=='.'&&!xisdigit(*loc))goto mistake;964if(*id_first=='.'&&!xisdigit(*loc))goto mistake;
@@ -992,13 +983,13 @@ return constant; · 18 unmodified lines
992}983}
993 984
994/*:73*/985/*:73*/
995#line 912 "ctangle.w"986#line 905 "ctangle.w"
996 987
997else if(c=='\''||c=='"'988else if(c=='\''||c=='"'
998||((c=='L'||c=='u'||c=='U')&&(*loc=='\''||*loc=='"'))989||((c=='L'||c=='u'||c=='U')&&(*loc=='\''||*loc=='"'))
999||((c=='u'&&*loc=='8')&&(*(loc+1)=='\''||*(loc+1)=='"')))990||((c=='u'&&*loc=='8')&&(*(loc+1)=='\''||*(loc+1)=='"')))
1000/*74:*/991/*74:*/
1001#line 997 "ctangle.w"992#line 992 "ctangle.w"
1002{993{
1003char delim= c;994char delim= c;
1004id_first= section_text+1;995id_first= section_text+1;
@@ -1042,11 +1033,11 @@ return string; · 37 unmodified lines
1042}1033}
1043 1034
1044/*:74*/1035/*:74*/
1045#line 916 "ctangle.w"1036#line 909 "ctangle.w"
1046 1037
1047else if(isalpha(c)||isxalpha(c)||ishigh(c))1038else if(isalpha(c)||isxalpha(c)||ishigh(c))
1048/*72:*/1039/*72:*/
1049#line 962 "ctangle.w"1040#line 957 "ctangle.w"
1050{1041{
1051id_first= --loc;1042id_first= --loc;
1052while(isalpha((eight_bits)*++loc)||isdigit((eight_bits)*loc)1043while(isalpha((eight_bits)*++loc)||isdigit((eight_bits)*loc)
@@ -1055,10 +1046,10 @@ id_loc= loc;return identifier; · 2 unmodified lines
1055}1046}
1056 1047
1057/*:72*/1048/*:72*/
1058#line 918 "ctangle.w"1049#line 911 "ctangle.w"
1059 1050
1060else if(c=='@')/*75:*/1051else if(c=='@')/*75:*/
1061#line 1042 "ctangle.w"1052#line 1037 "ctangle.w"
1062{1053{
1063c= ccode[(eight_bits)*loc++];1054c= ccode[(eight_bits)*loc++];
1064switch(c){1055switch(c){
@@ -1074,11 +1065,11 @@ continue; · 9 unmodified lines
1074case section_name:1065case section_name:
1075cur_section_name_char= *(loc-1);1066cur_section_name_char= *(loc-1);
1076/*77:*/1067/*77:*/
1077#line 1090 "ctangle.w"1068#line 1085 "ctangle.w"
1078{1069{
1079char*k;1070char*k;
1080/*79:*/1071/*79:*/
1081#line 1110 "ctangle.w"1072#line 1105 "ctangle.w"
1082 1073
1083k= section_text;1074k= section_text;
1084while(true){1075while(true){
@@ -1089,7 +1080,7 @@ loc= buffer+1;break; · 4 unmodified lines
1089}1080}
1090c= *loc;1081c= *loc;
1091/*80:*/1082/*80:*/
1092#line 1134 "ctangle.w"1083#line 1129 "ctangle.w"
1093 1084
1094if(c=='@'){1085if(c=='@'){
1095c= *(loc+1);1086c= *(loc+1);
@@ -1108,7 +1099,7 @@ err_print("! Nesting of section names not allowed");break; · 12 unmodified lines
1108}1099}
1109 1100
1110/*:80*/1101/*:80*/
1111#line 1119 "ctangle.w"1102#line 1114 "ctangle.w"
1112 1103
1113loc++;if(k<section_text_end)k++;1104loc++;if(k<section_text_end)k++;
1114if(xisspace(c)){1105if(xisspace(c)){
@@ -1125,14 +1116,14 @@ printf("...");mark_harmless; · 10 unmodified lines
1125if(*k==' '&&k> section_text)k--;1116if(*k==' '&&k> section_text)k--;
1126 1117
1127/*:79*/1118/*:79*/
1128#line 1092 "ctangle.w"1119#line 1087 "ctangle.w"
1129 1120
1130if(k-section_text> 3&&strncmp(k-2,"...",3)==0)1121if(k-section_text> 3&&strncmp(k-2,"...",3)==0)
1131cur_section_name= section_lookup(section_text+1,k-3,1);1122cur_section_name= section_lookup(section_text+1,k-3,1);
1132else cur_section_name= section_lookup(section_text+1,k,0);1123else cur_section_name= section_lookup(section_text+1,k,0);
1133if(cur_section_name_char=='(')1124if(cur_section_name_char=='(')
1134/*47:*/1125/*47:*/
1135#line 500 "ctangle.w"1126#line 497 "ctangle.w"
1136 1127
1137{1128{
1138for(an_output_file= cur_out_file;1129for(an_output_file= cur_out_file;
@@ -1148,16 +1139,16 @@ overflow("output files"); · 9 unmodified lines
1148}1139}
1149 1140
1150/*:47*/1141/*:47*/
1151#line 1098 "ctangle.w"1142#line 1093 "ctangle.w"
1152 1143
1153return section_name;1144return section_name;
1154}1145}
1155 1146
1156/*:77*/1147/*:77*/
1157#line 1056 "ctangle.w"1148#line 1051 "ctangle.w"
1158 1149
1159case string:/*81:*/1150case string:/*81:*/
1160#line 1156 "ctangle.w"1151#line 1151 "ctangle.w"
1161{1152{
1162id_first= loc++;*(limit+1)= '@';*(limit+2)= '>';1153id_first= loc++;*(limit+1)= '@';*(limit+2)= '>';
1163while(*loc!='@'||*(loc+1)!='>')loc++;1154while(*loc!='@'||*(loc+1)!='>')loc++;
@@ -1168,10 +1159,10 @@ return string; · 4 unmodified lines
1168}1159}
1169 1160
1170/*:81*/1161/*:81*/
1171#line 1057 "ctangle.w"1162#line 1052 "ctangle.w"
1172 1163
1173case ord:/*76:*/1164case ord:/*76:*/
1174#line 1069 "ctangle.w"1165#line 1064 "ctangle.w"
1175 1166
1176id_first= loc;1167id_first= loc;
1177if(*loc=='\\'){1168if(*loc=='\\'){
@@ -1194,14 +1185,14 @@ loc++; · 16 unmodified lines
1194return ord;1185return ord;
1195 1186
1196/*:76*/1187/*:76*/
1197#line 1058 "ctangle.w"1188#line 1053 "ctangle.w"
1198 1189
1199default:return c;1190default:return c;
1200}1191}
1201}1192}
1202 1193
1203/*:75*/1194/*:75*/
1204#line 919 "ctangle.w"1195#line 912 "ctangle.w"
1205 1196
1206else if(xisspace(c)){1197else if(xisspace(c)){
1207if(!preprocessing||loc> limit)continue;1198if(!preprocessing||loc> limit)continue;
@@ -1210,7 +1201,7 @@ else return' '; · 2 unmodified lines
1210}1201}
1211else if(c=='#'&&loc==buffer+1)preprocessing= 1;1202else if(c=='#'&&loc==buffer+1)preprocessing= 1;
1212mistake:/*71:*/1203mistake:/*71:*/
1213#line 940 "ctangle.w"1204#line 935 "ctangle.w"
1214 1205
1215switch(c){1206switch(c){
1216case'+':if(*loc=='+')compress(plus_plus);break;1207case'+':if(*loc=='+')compress(plus_plus);break;
@@ -1234,14 +1225,14 @@ case'!':if(*loc=='=')compress(non_eq);break; · 17 unmodified lines
1234}1225}
1235 1226
1236/*:71*/1227/*:71*/
1237#line 926 "ctangle.w"1228#line 919 "ctangle.w"
1238 1229
1239return c;1230return c;
1240}1231}
1241}1232}
1242 1233
1243/*:70*//*84:*/1234/*:69*//*83:*/
1244#line 1194 "ctangle.w"1235#line 1186 "ctangle.w"
1245 1236
1246static void1237static void
1247scan_repl(1238scan_repl(
@@ -1249,7 +1240,7 @@ eight_bits t) · 1 unmodified line
1249{1240{
1250sixteen_bits a;1241sixteen_bits a;
1251if(t==section_name){/*85:*/1242if(t==section_name){/*85:*/
1252#line 1220 "ctangle.w"1243#line 1214 "ctangle.w"
1253 1244
1254store_two_bytes(0150000);1245store_two_bytes(0150000);
1255if(changing&&include_depth==change_depth){1246if(changing&&include_depth==change_depth){
@@ -1264,11 +1255,11 @@ id_loc= id_first+strlen(id_first); · 8 unmodified lines
1264app_repl(a_l%0400);}1255app_repl(a_l%0400);}
1265 1256
1266/*:85*/1257/*:85*/
1267#line 1200 "ctangle.w"1258#line 1192 "ctangle.w"
1268}1259}
1269while(true)switch(a= get_next()){1260while(true)switch(a= get_next()){
1270/*86:*/1261/*86:*/
1271#line 1233 "ctangle.w"1262#line 1227 "ctangle.w"
1272 1263
1273case identifier:a= id_lookup(id_first,id_loc,0)-name_dir;1264case identifier:a= id_lookup(id_first,id_loc,0)-name_dir;
1274app_repl((a/0400)+0200);1265app_repl((a/0400)+0200);
@@ -1276,7 +1267,7 @@ app_repl(a%0400);break; · 1 unmodified line
1276case section_name:if(t!=section_name)goto done;1267case section_name:if(t!=section_name)goto done;
1277else{1268else{
1278/*87:*/1269/*87:*/
1279#line 1266 "ctangle.w"1270#line 1260 "ctangle.w"
1280{1271{
1281char*try_loc= loc;1272char*try_loc= loc;
1282while(*try_loc==' '&&try_loc<limit)try_loc++;1273while(*try_loc==' '&&try_loc<limit)try_loc++;
@@ -1289,13 +1280,13 @@ if(*try_loc=='=')err_print("! Missing `@ ' before a named section"); · 6 unmodified lines
1289}1280}
1290 1281
1291/*:87*/1282/*:87*/
1292#line 1239 "ctangle.w"1283#line 1233 "ctangle.w"
1293 1284
1294a= cur_section_name-name_dir;1285a= cur_section_name-name_dir;
1295app_repl((a/0400)+0250);1286app_repl((a/0400)+0250);
1296app_repl(a%0400);1287app_repl(a%0400);
1297/*85:*/1288/*85:*/
1298#line 1220 "ctangle.w"1289#line 1214 "ctangle.w"
1299 1290
1300store_two_bytes(0150000);1291store_two_bytes(0150000);
1301if(changing&&include_depth==change_depth){1292if(changing&&include_depth==change_depth){
@@ -1310,7 +1301,7 @@ id_loc= id_first+strlen(id_first); · 8 unmodified lines
1310app_repl(a_l%0400);}1301app_repl(a_l%0400);}
1311 1302
1312/*:85*/1303/*:85*/
1313#line 1243 "ctangle.w"1304#line 1237 "ctangle.w"
1314break;1305break;
1315}1306}
1316case output_defs_code:if(t!=section_name)err_print("! Misplaced @h");1307case output_defs_code:if(t!=section_name)err_print("! Misplaced @h");
@@ -1321,7 +1312,7 @@ a= output_defs_flag; · 4 unmodified lines
1321app_repl((a/0400)+0200);1312app_repl((a/0400)+0200);
1322app_repl(a%0400);1313app_repl(a%0400);
1323/*85:*/1314/*85:*/
1324#line 1220 "ctangle.w"1315#line 1214 "ctangle.w"
1325 1316
1326store_two_bytes(0150000);1317store_two_bytes(0150000);
1327if(changing&&include_depth==change_depth){1318if(changing&&include_depth==change_depth){
@@ -1336,13 +1327,13 @@ id_loc= id_first+strlen(id_first); · 8 unmodified lines
1336app_repl(a_l%0400);}1327app_repl(a_l%0400);}
1337 1328
1338/*:85*/1329/*:85*/
1339#line 1252 "ctangle.w"1330#line 1246 "ctangle.w"
1340 1331
1341}1332}
1342break;1333break;
1343case constant:case string:1334case constant:case string:
1344/*88:*/1335/*88:*/
1345#line 1277 "ctangle.w"1336#line 1271 "ctangle.w"
1346 1337
1347app_repl(a);1338app_repl(a);
1348while(id_first<id_loc){1339while(id_first<id_loc){
@@ -1356,11 +1347,11 @@ app_repl(*id_first++); · 7 unmodified lines
1356app_repl(a);break;1347app_repl(a);break;
1357 1348
1358/*:88*/1349/*:88*/
1359#line 1256 "ctangle.w"1350#line 1250 "ctangle.w"
1360 1351
1361case ord:1352case ord:
1362/*89:*/1353/*89:*/
1363#line 1293 "ctangle.w"1354#line 1287 "ctangle.w"
1364{1355{
1365int c= (eight_bits)*id_first;1356int c= (eight_bits)*id_first;
1366if(c=='\\'){1357if(c=='\\'){
@@ -1411,7 +1402,7 @@ app_repl(constant); · 44 unmodified lines
1411break;1402break;
1412 1403
1413/*:89*/1404/*:89*/
1414#line 1258 "ctangle.w"1405#line 1252 "ctangle.w"
1415 1406
1416case definition:case format_code:case begin_C:if(t!=section_name)goto done;1407case definition:case format_code:case begin_C:if(t!=section_name)goto done;
1417else{1408else{
@@ -1421,7 +1412,7 @@ err_print("! @d, @f and @c are ignored in C text");continue; · 3 unmodified lines
1421case new_section:goto done;1412case new_section:goto done;
1422 1413
1423/*:86*/1414/*:86*/
1424#line 1205 "ctangle.w"1415#line 1197 "ctangle.w"
1425 1416
1426case')':app_repl(a);1417case')':app_repl(a);
1427if(t==macro)app_repl(' ');1418if(t==macro)app_repl(' ');
@@ -1433,8 +1424,8 @@ if(text_ptr> text_info_end)overflow("text"); · 5 unmodified lines
1433cur_text= text_ptr;(++text_ptr)->tok_start= tok_ptr;1424cur_text= text_ptr;(++text_ptr)->tok_start= tok_ptr;
1434}1425}
1435 1426
1436/*:84*//*91:*/1427/*:83*//*90:*/
1437#line 1355 "ctangle.w"1428#line 1346 "ctangle.w"
1438 1429
1439static void1430static void
1440scan_section(void)1431scan_section(void)
@@ -1449,7 +1440,7 @@ printf("*%d",section_count);update_terminal; · 8 unmodified lines
1449next_control= 0;1440next_control= 0;
1450while(true){1441while(true){
1451/*92:*/1442/*92:*/
1452#line 1394 "ctangle.w"1443#line 1387 "ctangle.w"
1453 1444
1454while(next_control<definition)1445while(next_control<definition)
1455 1446
@@ -1458,11 +1449,11 @@ loc-= 2;next_control= get_next(); · 2 unmodified lines
1458}1449}
1459 1450
1460/*:92*/1451/*:92*/
1461#line 1369 "ctangle.w"1452#line 1360 "ctangle.w"
1462 1453
1463if(next_control==definition){1454if(next_control==definition){
1464/*93:*/1455/*93:*/
1465#line 1401 "ctangle.w"1456#line 1394 "ctangle.w"
1466{1457{
1467while((next_control= get_next())=='\n');1458while((next_control= get_next())=='\n');
1468if(next_control!=identifier){1459if(next_control!=identifier){
@@ -1481,7 +1472,7 @@ cur_text->text_link= macro; · 12 unmodified lines
1481}1472}
1482 1473
1483/*:93*/1474/*:93*/
1484#line 1371 "ctangle.w"1475#line 1362 "ctangle.w"
1485 1476
1486continue;1477continue;
1487}1478}
@@ -1491,14 +1482,14 @@ p= name_dir;break; · 3 unmodified lines
1491if(next_control==section_name){1482if(next_control==section_name){
1492p= cur_section_name;1483p= cur_section_name;
1493/*94:*/1484/*94:*/
1494#line 1426 "ctangle.w"1485#line 1419 "ctangle.w"
1495 1486
1496while((next_control= get_next())=='+');1487while((next_control= get_next())=='+');
1497if(next_control!='='&&next_control!=eq_eq)1488if(next_control!='='&&next_control!=eq_eq)
1498continue;1489continue;
1499 1490
1500/*:94*/1491/*:94*/
1501#line 1379 "ctangle.w"1492#line 1370 "ctangle.w"
1502 1493
1503break;1494break;
1504}1495}
@@ -1506,20 +1497,20 @@ return; · 1 unmodified line
1506}1497}
1507no_where= print_where= false;1498no_where= print_where= false;
1508/*95:*/1499/*95:*/
1509#line 1431 "ctangle.w"1500#line 1424 "ctangle.w"
1510 1501
1511/*96:*/1502/*96:*/
1512#line 1436 "ctangle.w"1503#line 1429 "ctangle.w"
1513 1504
1514store_two_bytes((sixteen_bits)(0150000+section_count));1505store_two_bytes((sixteen_bits)(0150000+section_count));
1515 1506
1516 1507
1517/*:96*/1508/*:96*/
1518#line 1432 "ctangle.w"1509#line 1425 "ctangle.w"
1519 1510
1520scan_repl(section_name);1511scan_repl(section_name);
1521/*97:*/1512/*97:*/
1522#line 1440 "ctangle.w"1513#line 1433 "ctangle.w"
1523 1514
1524if(p==name_dir||p==0){1515if(p==name_dir||p==0){
1525(last_unnamed)->text_link= cur_text-text_info;last_unnamed= cur_text;1516(last_unnamed)->text_link= cur_text-text_info;last_unnamed= cur_text;
@@ -1536,16 +1527,16 @@ cur_text->text_link= section_flag; · 10 unmodified lines
1536 1527
1537 1528
1538/*:97*/1529/*:97*/
1539#line 1434 "ctangle.w"1530#line 1427 "ctangle.w"
1540 1531
1541 1532
1542/*:95*/1533/*:95*/
1543#line 1385 "ctangle.w"1534#line 1376 "ctangle.w"
1544 1535
1545}1536}
1546 1537
1547/*:91*//*99:*/1538/*:90*//*98:*/
1548#line 1458 "ctangle.w"1539#line 1448 "ctangle.w"
1549 1540
1550static void1541static void
1551phase_one(void){1542phase_one(void){
@@ -1558,8 +1549,8 @@ check_complete(); · 6 unmodified lines
1558phase= 2;1549phase= 2;
1559}1550}
1560 1551
1561/*:99*//*101:*/1552/*:98*//*100:*/
1562#line 1476 "ctangle.w"1553#line 1465 "ctangle.w"
1563 1554
1564static void1555static void
1565skip_limbo(void)1556skip_limbo(void)
@@ -1574,7 +1565,7 @@ c= *loc++; · 8 unmodified lines
1574if(ccode[(eight_bits)c]==new_section)break;1565if(ccode[(eight_bits)c]==new_section)break;
1575switch(ccode[(eight_bits)c]){1566switch(ccode[(eight_bits)c]){
1576case translit_code:/*102:*/1567case translit_code:/*102:*/
1577#line 1505 "ctangle.w"1568#line 1496 "ctangle.w"
1578 1569
1579while(xisspace(*loc)&&loc<limit)loc++;1570while(xisspace(*loc)&&loc<limit)loc++;
1580loc+= 3;1571loc+= 3;
@@ -1599,7 +1590,7 @@ translit[i-0200][loc-beg]= '\0'; · 18 unmodified lines
1599}1590}
1600 1591
1601/*:102*/1592/*:102*/
1602#line 1489 "ctangle.w"1593#line 1478 "ctangle.w"
1603break;1594break;
1604case format_code:case'@':break;1595case format_code:case'@':break;
1605case control_text:if(c=='q'||c=='Q'){1596case control_text:if(c=='q'||c=='Q'){
@@ -1616,8 +1607,8 @@ default:err_print("! Double @ should be used in limbo"); · 10 unmodified lines
1616}1607}
1617}1608}
1618 1609
1619/*:101*//*103:*/1610/*:100*//*103:*/
1620#line 1531 "ctangle.w"1611#line 1522 "ctangle.w"
1621 1612
1622void1613void
1623print_stats(void){1614print_stats(void){
ctangle.w+83−92
@@ -2,7 +2,7 @@ · 1 unmodified line
2% This program by Silvio Levy and Donald E. Knuth2% This program by Silvio Levy and Donald E. Knuth
3% is based on a program by Knuth.3% is based on a program by Knuth.
4% It is distributed WITHOUT ANY WARRANTY, express or implied.4% It is distributed WITHOUT ANY WARRANTY, express or implied.
5% Version 4.1 --- February 20215% Version 4.2 --- February 2021
6 6
7% Copyright (C) 1987,1990,1993,2000 Silvio Levy and Donald E. Knuth7% Copyright (C) 1987,1990,1993,2000 Silvio Levy and Donald E. Knuth
8 8
@@ -27,11 +27,11 @@ · 18 unmodified lines
27\mathchardef\RA="3221 % right arrow27\mathchardef\RA="3221 % right arrow
28\mathchardef\BA="3224 % double arrow28\mathchardef\BA="3224 % double arrow
29 29
30\def\title{CTANGLE (Version 4.1)}30\def\title{CTANGLE (Version 4.2)}
31\def\topofcontents{\null\vfill31\def\topofcontents{\null\vfill
32 \centerline{\titlefont The {\ttitlefont CTANGLE} processor}32 \centerline{\titlefont The {\ttitlefont CTANGLE} processor}
33 \vskip 15pt33 \vskip 15pt
34 \centerline{(Version 4.1)}34 \centerline{(Version 4.2)}
35 \vfill}35 \vfill}
36\def\botofcontents{\vfill36\def\botofcontents{\vfill
37\noindent37\noindent
@@ -61,15 +61,15 @@ Joachim Schrod, Lee Wittenberg, and others who have contributed improvements. · 23 unmodified lines
61The ``banner line'' defined here should be changed whenever \.{CTANGLE}61The ``banner line'' defined here should be changed whenever \.{CTANGLE}
62is modified.62is modified.
63 63
64@d banner "This is CTANGLE (Version 4.1)"64@d banner "This is CTANGLE (Version 4.2)"
65 65
66@c66@c
67@<Include files@>@/67@<Include files@>@/
68@h68@h
69@<Common code for \.{CWEAVE} and \.{CTANGLE}@>@/69@<Common code for \.{CWEAVE} and \.{CTANGLE}@>@/
70@<Typedef declarations@>@/70@<Typedef declarations@>@/
71@<Global variables@>@/71@<Private variables@>@/
72@<Predeclaration of procedures@>@/72@<Predeclaration of procedures@>
73 73
74@ \.{CTANGLE} has a fairly straightforward outline. It operates in74@ \.{CTANGLE} has a fairly straightforward outline. It operates in
75two phases: First it reads the source file, saving the \CEE/ code in75two phases: First it reads the source file, saving the \CEE/ code in
@@ -126,13 +126,13 @@ typedef struct { · 50 unmodified lines
126} text;126} text;
127typedef text *text_pointer;127typedef text *text_pointer;
128 128
129@ @<Glob...@>=129@ @<Private...@>=
130text text_info[max_texts];130static text text_info[max_texts];
131text_pointer text_info_end=text_info+max_texts-1;131static text_pointer text_info_end=text_info+max_texts-1;
132text_pointer text_ptr; /* first unused position in |text_info| */132static text_pointer text_ptr; /* first unused position in |text_info| */
133eight_bits tok_mem[max_toks];133static eight_bits tok_mem[max_toks];
134eight_bits *tok_mem_end=tok_mem+max_toks-1;134static eight_bits *tok_mem_end=tok_mem+max_toks-1;
135eight_bits *tok_ptr; /* first unused position in |tok_mem| */135static eight_bits *tok_ptr; /* first unused position in |tok_mem| */
136 136
137@ @<Set init...@>=137@ @<Set init...@>=
138text_info->tok_start=tok_ptr=tok_mem;138text_info->tok_start=tok_ptr=tok_mem;
@@ -195,8 +195,8 @@ The replacement text pointer for the first unnamed section appears in · 56 unmodified lines
195 195
196@d section_flag max_texts /* final |text_link| in section replacement texts */196@d section_flag max_texts /* final |text_link| in section replacement texts */
197 197
198@<Glob...@>=198@<Private...@>=
199text_pointer last_unnamed; /* most recent replacement text of unnamed section */199static text_pointer last_unnamed; /* most recent replacement text of unnamed section */
200 200
201@ @<Set init...@>= last_unnamed=text_info; text_info->text_link=0;201@ @<Set init...@>= last_unnamed=text_info; text_info->text_link=0;
202 202
@@ -228,11 +228,8 @@ construction or numerical constant. · 25 unmodified lines
228@ The following procedure is used to enter a two-byte value into228@ The following procedure is used to enter a two-byte value into
229|tok_mem| when a replacement text is being generated.229|tok_mem| when a replacement text is being generated.
230 230
231@<Predecl...@>=231@c
232static void store_two_bytes(sixteen_bits);@/232static void
233
234@ @c
235void
236store_two_bytes(233store_two_bytes(
237sixteen_bits x)234sixteen_bits x)
238{235{
@@ -241,6 +238,8 @@ sixteen_bits x) · 2 unmodified lines
241 *tok_ptr++=x&0377; /* store low byte */238 *tok_ptr++=x&0377; /* store low byte */
242}239}
243 240
241@ @<Predecl...@>=@+static void store_two_bytes(sixteen_bits);
242
244@** Stacks for output. The output process uses a stack to keep track243@** Stacks for output. The output process uses a stack to keep track
245of what is going on at different ``levels'' as the sections are being244of what is going on at different ``levels'' as the sections are being
246written out. Entries on this stack have five parts:245written out. Entries on this stack have five parts:
@@ -283,12 +282,12 @@ typedef output_state *stack_pointer; · 36 unmodified lines
283@d cur_repl cur_state.repl_field /* pointer to current replacement text */282@d cur_repl cur_state.repl_field /* pointer to current replacement text */
284@d cur_section cur_state.section_field /* current section number being expanded */283@d cur_section cur_state.section_field /* current section number being expanded */
285 284
286@<Global...@>=285@<Private...@>=
287output_state cur_state; /* |cur_end|, |cur_byte|, |cur_name|, |cur_repl|,286static output_state cur_state; /* |cur_end|, |cur_byte|, |cur_name|, |cur_repl|,
288 and |cur_section| */287 and |cur_section| */
289output_state stack[stack_size+1]; /* info for non-current levels */288static output_state stack[stack_size+1]; /* info for non-current levels */
290stack_pointer stack_end=stack+stack_size; /* end of |stack| */289static stack_pointer stack_end=stack+stack_size; /* end of |stack| */
291stack_pointer stack_ptr; /* first unused location in the output state stack */290static stack_pointer stack_ptr; /* first unused location in the output state stack */
292 291
293@ To get the output process started, we will perform the following292@ To get the output process started, we will perform the following
294initialization steps. We may assume that |text_info->text_link| is nonzero,293initialization steps. We may assume that |text_info->text_link| is nonzero,
@@ -307,11 +306,7 @@ the new one going. · 12 unmodified lines
307We assume that the \CEE/ compiler can copy structures.306We assume that the \CEE/ compiler can copy structures.
308@^system dependencies@>307@^system dependencies@>
309 308
310@<Predecl...@>=309@c
311static void push_level(name_pointer);@/
312static void pop_level(boolean);@/
313
314@ @c
315static void310static void
316push_level(@t\1\1@> /* suspends the current level */311push_level(@t\1\1@> /* suspends the current level */
317name_pointer p@t\2\2@>)312name_pointer p@t\2\2@>)
@@ -326,6 +321,10 @@ name_pointer p@t\2\2@>) · 8 unmodified lines
326 }321 }
327}322}
328 323
324@ @<Predecl...@>=
325static void push_level(name_pointer);@/
326static void pop_level(boolean);
327
329@ When we come to the end of a replacement text, the |pop_level| subroutine328@ When we come to the end of a replacement text, the |pop_level| subroutine
330does the right thing: It either moves to the continuation of this replacement329does the right thing: It either moves to the continuation of this replacement
331text or returns the state to the most recently stacked level.330text or returns the state to the most recently stacked level.
@@ -359,17 +358,14 @@ if the next output is an identifier, in which case · 27 unmodified lines
359@d section_number 0201 /* code returned by |get_output| for section numbers */358@d section_number 0201 /* code returned by |get_output| for section numbers */
360@d identifier 0202 /* code returned by |get_output| for identifiers */359@d identifier 0202 /* code returned by |get_output| for identifiers */
361 360
362@<Global...@>=361@<Private...@>=
363int cur_val; /* additional information corresponding to output token */362static int cur_val; /* additional information corresponding to output token */
364 363
365@ If |get_output| finds that no more output remains, it returns with364@ If |get_output| finds that no more output remains, it returns with
366|stack_ptr==stack|.365|stack_ptr==stack|.
367@^high-bit character handling@>366@^high-bit character handling@>
368 367
369@<Predecl...@>=368@c
370static void get_output(void);@/
371
372@ @c
373static void369static void
374get_output(void) /* sends next token to |out_char| */370get_output(void) /* sends next token to |out_char| */
375{371{
@@ -398,6 +394,8 @@ get_output(void) /* sends next token to |out_char| */ · 22 unmodified lines
398 }394 }
399}395}
400 396
397@ @<Predecl...@>=@+static void get_output(void);
398
401@ The user may have forgotten to give any \CEE/ text for a section name,399@ The user may have forgotten to give any \CEE/ text for a section name,
402or the \CEE/ text may have been associated with a different name by mistake.400or the \CEE/ text may have been associated with a different name by mistake.
403 401
@@ -451,18 +449,15 @@ are preceded by a `\.\\'. · 47 unmodified lines
451@d unbreakable 3 /* state associated with \.{@@\&} */449@d unbreakable 3 /* state associated with \.{@@\&} */
452@d verbatim 4 /* state in the middle of a string */450@d verbatim 4 /* state in the middle of a string */
453 451
454@<Global...@>=452@<Private...@>=
455eight_bits out_state; /* current status of partial output */453static eight_bits out_state; /* current status of partial output */
456boolean protect; /* should newline characters be quoted? */454static boolean protect; /* should newline characters be quoted? */
457 455
458@ Here is a routine that is invoked when we want to output the current line.456@ Here is a routine that is invoked when we want to output the current line.
459During the output process, |cur_line| equals the number of the next line457During the output process, |cur_line| equals the number of the next line
460to be output.458to be output.
461 459
462@<Predecl...@>=460@c
463static void flush_buffer(void);@/
464
465@ @c
466static void461static void
467flush_buffer(void) /* writes one line to output file */462flush_buffer(void) /* writes one line to output file */
468{463{
@@ -475,6 +470,8 @@ flush_buffer(void) /* writes one line to output file */ · 6 unmodified lines
475 cur_line++;470 cur_line++;
476}471}
477 472
473@ @<Predecl...@>=@+static void flush_buffer(void);
474
478@ Second, we have modified the original \.{TANGLE} so that it will write output475@ Second, we have modified the original \.{TANGLE} so that it will write output
479on multiple files.476on multiple files.
480If a section name is introduced in at least one place by \.{@@(}477If a section name is introduced in at least one place by \.{@@(}
@@ -483,11 +480,11 @@ All these special sections are saved on a stack, |output_files|. · 2 unmodified lines
483We write them out after we've done the unnamed section.480We write them out after we've done the unnamed section.
484 481
485@d max_files 256482@d max_files 256
486@<Glob...@>=483@<Private...@>=
487name_pointer output_files[max_files];484static name_pointer output_files[max_files];
488name_pointer *cur_out_file, *end_output_files, *an_output_file;485static name_pointer *cur_out_file, *end_output_files, *an_output_file;
489char cur_section_name_char; /* is it |'<'| or |'('| */486static char cur_section_name_char; /* is it |'<'| or |'('| */
490char output_file_name[longest_name+1]; /* name of the file */487static char output_file_name[longest_name+1]; /* name of the file */
491 488
492@ We make |end_output_files| point just beyond the end of489@ We make |end_output_files| point just beyond the end of
493|output_files|. The stack pointer490|output_files|. The stack pointer
@@ -514,10 +511,7 @@ complain we're out of room@>= · 20 unmodified lines
514@* The big output switch. Here then is the routine that does the511@* The big output switch. Here then is the routine that does the
515output.512output.
516 513
517@<Predecl...@>=514@c
518static void phase_two(void);@/
519
520@ @c
521static void515static void
522phase_two (void) {516phase_two (void) {
523 web_file_open=false;517 web_file_open=false;
@@ -552,6 +546,8 @@ writeloop: @<Write all the named output files@>@; · 28 unmodified lines
552 }546 }
553}547}
554 548
549@ @<Predecl...@>=@+static void phase_two(void);
550
555@ To write the named output files, we proceed as for the unnamed551@ To write the named output files, we proceed as for the unnamed
556section.552section.
557The only subtlety is that we have to open each one.553The only subtlety is that we have to open each one.
@@ -583,12 +579,12 @@ that refer to macros, preceded by the \.{\#define} preprocessor command. · 25 unmodified lines
583 if (!output_defs_seen)579 if (!output_defs_seen)
584 output_defs();580 output_defs();
585 581
586@ @<Glob...@>=582@ @<Private...@>=
587boolean output_defs_seen=false;583static boolean output_defs_seen=false;
588 584
589@ @<Predecl...@>=585@ @<Predecl...@>=
590static void output_defs(void);@/586static void output_defs(void);@/
591static void out_char(eight_bits);@/587static void out_char(eight_bits);
592 588
593@ @c589@ @c
594static void590static void
@@ -692,8 +688,8 @@ This makes debugging a lot less confusing. · 97 unmodified lines
692 688
693@d translit_length 10689@d translit_length 10
694 690
695@<Glo...@>=691@<Private...@>=
696char translit[128][translit_length];692static char translit[128][translit_length];
697 693
698@ @<Set init...@>=694@ @<Set init...@>=
699{695{
@@ -771,8 +767,8 @@ milestones. · 71 unmodified lines
771@d section_name 0311 /* control code for `\.{@@<}' */767@d section_name 0311 /* control code for `\.{@@<}' */
772@d new_section 0312 /* control code for `\.{@@\ }' and `\.{@@*}' */768@d new_section 0312 /* control code for `\.{@@\ }' and `\.{@@*}' */
773 769
774@<Global...@>=770@<Private...@>=
775eight_bits ccode[256]; /* meaning of a char following \.{@@} */771static eight_bits ccode[256]; /* meaning of a char following \.{@@} */
776 772
777@ @<Set ini...@>= {773@ @<Set ini...@>= {
778 int c; /* must be |int| so the |for| loop will end */774 int c; /* must be |int| so the |for| loop will end */
@@ -795,11 +791,7 @@ eight_bits ccode[256]; /* meaning of a char following \.{@@} */ · 16 unmodified lines
795@ The |skip_ahead| procedure reads through the input at fairly high speed791@ The |skip_ahead| procedure reads through the input at fairly high speed
796until finding the next non-ignorable control code, which it returns.792until finding the next non-ignorable control code, which it returns.
797 793
798@<Predecl...@>=794@c
799static eight_bits skip_ahead(void);@/
800static boolean skip_comment(boolean);@/
801
802@ @c
803static eight_bits795static eight_bits
804skip_ahead(void) /* skip to next control code */796skip_ahead(void) /* skip to next control code */
805{797{
@@ -815,6 +807,10 @@ skip_ahead(void) /* skip to next control code */ · 9 unmodified lines
815 }807 }
816}808}
817 809
810@ @<Predecl...@>=
811static eight_bits skip_ahead(void);@/
812static boolean skip_comment(boolean);
813
818@ The |skip_comment| procedure reads through the input at somewhat high814@ The |skip_comment| procedure reads through the input at somewhat high
819speed in order to pass over comments, which \.{CTANGLE} does not transmit815speed in order to pass over comments, which \.{CTANGLE} does not transmit
820to the output. If the comment is introduced by \.{/*}, |skip_comment|816to the output. If the comment is introduced by \.{/*}, |skip_comment|
@@ -831,8 +827,8 @@ the two types of comments. · 10 unmodified lines
831If |skip_comment| comes to the end of the section, it prints an error message.827If |skip_comment| comes to the end of the section, it prints an error message.
832No comment, long or short, is allowed to contain `\.{@@\ }' or `\.{@@*}'.828No comment, long or short, is allowed to contain `\.{@@\ }' or `\.{@@*}'.
833 829
834@<Global...@>=830@<Private...@>=
835boolean comment_continues=false; /* are we scanning a comment? */831static boolean comment_continues=false; /* are we scanning a comment? */
836 832
837@ @c833@ @c
838static boolean skip_comment(@t\1\1@> /* skips over comments */834static boolean skip_comment(@t\1\1@> /* skips over comments */
@@ -870,9 +866,9 @@ boolean is_long_comment@t\2\2@>) · 31 unmodified lines
870 866
871@d constant 03867@d constant 03
872 868
873@<Global...@>=869@<Private...@>=
874name_pointer cur_section_name; /* name of section just scanned */870static name_pointer cur_section_name; /* name of section just scanned */
875boolean no_where; /* suppress |print_where|? */871static boolean no_where; /* suppress |print_where|? */
876 872
877@ As one might expect, |get_next| consists mostly of a big switch873@ As one might expect, |get_next| consists mostly of a big switch
878that branches to the various special cases that can arise.874that branches to the various special cases that can arise.
@@ -882,10 +878,7 @@ that branches to the various special cases that can arise. · 3 unmodified lines
882@d ishigh(c) ((eight_bits)(c)>0177)878@d ishigh(c) ((eight_bits)(c)>0177)
883@^high-bit character handling@>879@^high-bit character handling@>
884 880
885@<Predecl...@>=881@c
886static eight_bits get_next(void);@/
887
888@ @c
889static eight_bits882static eight_bits
890get_next(void) /* produces the next input token */883get_next(void) /* produces the next input token */
891{884{
@@ -928,6 +921,8 @@ get_next(void) /* produces the next input token */ · 36 unmodified lines
928 }921 }
929}922}
930 923
924@ @<Predecl...@>=@+static eight_bits get_next(void);
925
931@ The following code assigns values to the combinations \.{++},926@ The following code assigns values to the combinations \.{++},
932\.{--}, \.{->}, \.{>=}, \.{<=}, \.{==}, \.{<<}, \.{>>}, \.{!=}, \.{||} and927\.{--}, \.{->}, \.{>=}, \.{<=}, \.{==}, \.{<<}, \.{>>}, \.{!=}, \.{||} and
933\.{\&\&}, and to the \CPLUSPLUS/928\.{\&\&}, and to the \CPLUSPLUS/
@@ -1184,12 +1179,9 @@ acted, |cur_text| will point to the replacement text just generated, and · 250 unmodified lines
1184@d macro 01179@d macro 0
1185@d app_repl(c) {if (tok_ptr==tok_mem_end) overflow("token"); *tok_ptr++=c;}1180@d app_repl(c) {if (tok_ptr==tok_mem_end) overflow("token"); *tok_ptr++=c;}
1186 1181
1187@<Global...@>=1182@<Private...@>=
1188text_pointer cur_text; /* replacement text formed by |scan_repl| */1183static text_pointer cur_text; /* replacement text formed by |scan_repl| */
1189eight_bits next_control;1184static eight_bits next_control;
1190
1191@ @<Predecl...@>=
1192static void scan_repl(eight_bits);@/
1193 1185
1194@ @c1186@ @c
1195static void1187static void
@@ -1213,6 +1205,8 @@ eight_bits t@t\2\2@>) · 17 unmodified lines
1213 cur_text=text_ptr; (++text_ptr)->tok_start=tok_ptr;1205 cur_text=text_ptr; (++text_ptr)->tok_start=tok_ptr;
1214}1206}
1215 1207
1208@ @<Predecl...@>=@+static void scan_repl(eight_bits);
1209
1216@ Here is the code for the line number: first a |sixteen_bits| equal1210@ Here is the code for the line number: first a |sixteen_bits| equal
1217to |0150000|; then the numeric line number; then a pointer to the1211to |0150000|; then the numeric line number; then a pointer to the
1218file name.1212file name.
@@ -1236,7 +1230,7 @@ case identifier: a=id_lookup(id_first,id_loc,0)-name_dir; · 17 unmodified lines
1236 app_repl(a % 0400); break;1230 app_repl(a % 0400); break;
1237case section_name: if (t!=section_name) goto done;1231case section_name: if (t!=section_name) goto done;
1238 else {1232 else {
1239 @<Was an `@@' missed here?@>@;1233 @<Was an `\.{@@}' missed here?@>@;
1240 a=cur_section_name-name_dir;1234 a=cur_section_name-name_dir;
1241 app_repl((a / 0400)+0250);1235 app_repl((a / 0400)+0250);
1242 app_repl(a % 0400);1236 app_repl(a % 0400);
@@ -1263,7 +1257,7 @@ case definition: case format_code: case begin_C: if (t!=section_name) goto done; · 20 unmodified lines
1263 }1257 }
1264case new_section: goto done;1258case new_section: goto done;
1265 1259
1266@ @<Was an `@@'...@>= {1260@ @<Was an `\.{@@}'...@>= {
1267 char *try_loc=loc;1261 char *try_loc=loc;
1268 while (*try_loc==' ' && try_loc<limit) try_loc++;1262 while (*try_loc==' ' && try_loc<limit) try_loc++;
1269 if (*try_loc=='+' && try_loc<limit) try_loc++;1263 if (*try_loc=='+' && try_loc<limit) try_loc++;
@@ -1345,10 +1339,7 @@ sensed in the input, and it proceeds until the end of that section. It · 75 unmodified lines
1345uses |section_count| to keep track of the current section number; with luck,1339uses |section_count| to keep track of the current section number; with luck,
1346\.{CWEAVE} and \.{CTANGLE} will both assign the same numbers to sections.1340\.{CWEAVE} and \.{CTANGLE} will both assign the same numbers to sections.
1347 1341
1348@<Predecl...@>=1342The body of |scan_section| is a loop where we look for control codes
1349static void scan_section(void);@/
1350
1351@ The body of |scan_section| is a loop where we look for control codes
1352that are significant to \.{CTANGLE}: those1343that are significant to \.{CTANGLE}: those
1353that delimit a definition, the \CEE/ part of a module, or a new module.1344that delimit a definition, the \CEE/ part of a module, or a new module.
1354 1345
@@ -1385,6 +1376,8 @@ scan_section(void) · 30 unmodified lines
1385 @<Scan the \CEE/ part of the current section@>@;1376 @<Scan the \CEE/ part of the current section@>@;
1386}1377}
1387 1378
1379@ @<Predecl...@>=@+static void scan_section(void);
1380
1388@ At the top of this loop, if |next_control==section_name|, the1381@ At the top of this loop, if |next_control==section_name|, the
1389section name has already been scanned (see |@<Get control code1382section name has already been scanned (see |@<Get control code
1390and...@>|). Thus, if we encounter |next_control==section_name| in the1383and...@>|). Thus, if we encounter |next_control==section_name| in the
@@ -1452,9 +1445,6 @@ else { · 61 unmodified lines
1452cur_text->text_link=section_flag;1445cur_text->text_link=section_flag;
1453 /* mark this replacement text as a nonmacro */1446 /* mark this replacement text as a nonmacro */
1454 1447
1455@ @<Predec...@>=
1456static void phase_one(void);@/
1457
1458@ @c1448@ @c
1459static void1449static void
1460phase_one(void) {1450phase_one(void) {
@@ -1467,13 +1457,12 @@ phase_one(void) { · 6 unmodified lines
1467 phase=2;1457 phase=2;
1468}1458}
1469 1459
1460@ @<Predec...@>=@+static void phase_one(void);
1461
1470@ Only a small subset of the control codes is legal in limbo, so limbo1462@ Only a small subset of the control codes is legal in limbo, so limbo
1471processing is straightforward.1463processing is straightforward.
1472 1464
1473@<Predecl...@>=1465@c
1474static void skip_limbo(void);@/
1475
1476@ @c
1477static void1466static void
1478skip_limbo(void)1467skip_limbo(void)
1479{1468{
@@ -1502,6 +1491,8 @@ skip_limbo(void) · 22 unmodified lines
1502 }1491 }
1503}1492}
1504 1493
1494@ @<Predecl...@>=@+static void skip_limbo(void);
1495
1505@ @<Read in transliteration of a character@>=1496@ @<Read in transliteration of a character@>=
1506 while(xisspace(*loc)&&loc<limit) loc++;1497 while(xisspace(*loc)&&loc<limit) loc++;
1507 loc+=3;1498 loc+=3;
cweav-bs.ch+23−23
@@ -20,12 +20,12 @@ This file contributed by Barry Schwartz, trashman@crud.mn.org, 28 Jun 94. · 19 unmodified lines
20The ``banner line'' defined here should be changed whenever \.{CWEAVE}20The ``banner line'' defined here should be changed whenever \.{CWEAVE}
21is modified.21is modified.
22 22
23@d banner "This is CWEAVE (Version 4.1)"23@d banner "This is CWEAVE (Version 4.2)"
24@y24@y
25The ``banner line'' defined here should be changed whenever \.{CWEAVE}25The ``banner line'' defined here should be changed whenever \.{CWEAVE}
26is modified.26is modified.
27 27
28@d banner "This is CWEAVE (Version 4.1pc/big)"28@d banner "This is CWEAVE (Version 4.2pc/big)"
29@z29@z
30 30
31 31
@@ -103,11 +103,11 @@ typedef xref_info huge* xref_pointer; · 71 unmodified lines
103 103
104 104
105@x Section 23.105@x Section 23.
106xref_info xmem[max_refs]; /* contains cross-reference information */106static xref_info xmem[max_refs]; /* contains cross-reference information */
107xref_pointer xmem_end = xmem+max_refs-1;107static xref_pointer xmem_end = xmem+max_refs-1;
108@y108@y
109xref_info huge xmem[max_refs]; /* contains cross-reference information */109static xref_info huge xmem[max_refs]; /* contains cross-reference information */
110xref_pointer xmem_end;110static xref_pointer xmem_end;
111@z111@z
112 112
113 113
@@ -129,21 +129,21 @@ xmem->num=0; /* sentinel value */ · 15 unmodified lines
129 129
130 130
131@x Section 30. (to please Borland's C++, version 4.02)131@x Section 30. (to please Borland's C++, version 4.02)
132token tok_mem[max_toks]; /* tokens */132static token tok_mem[max_toks]; /* tokens */
133token_pointer tok_mem_end = tok_mem+max_toks-1; /* end of |tok_mem| */133static token_pointer tok_mem_end = tok_mem+max_toks-1; /* end of |tok_mem| */
134token_pointer tok_ptr; /* first unused position in |tok_mem| */134static token_pointer tok_ptr; /* first unused position in |tok_mem| */
135token_pointer max_tok_ptr; /* largest value of |tok_ptr| */135static token_pointer max_tok_ptr; /* largest value of |tok_ptr| */
136token_pointer tok_start[max_texts]; /* directory into |tok_mem| */136static token_pointer tok_start[max_texts]; /* directory into |tok_mem| */
137text_pointer tok_start_end = tok_start+max_texts-1; /* end of |tok_start| */137static text_pointer tok_start_end = tok_start+max_texts-1; /* end of |tok_start| */
138text_pointer text_ptr; /* first unused position in |tok_start| */138static text_pointer text_ptr; /* first unused position in |tok_start| */
139@y139@y
140token tok_mem[max_toks]; /* tokens */140static token tok_mem[max_toks]; /* tokens */
141token_pointer tok_mem_end; /* end of |tok_mem| */141static token_pointer tok_mem_end; /* end of |tok_mem| */
142token_pointer tok_ptr; /* first unused position in |tok_mem| */142static token_pointer tok_ptr; /* first unused position in |tok_mem| */
143token_pointer max_tok_ptr; /* largest value of |tok_ptr| */143static token_pointer max_tok_ptr; /* largest value of |tok_ptr| */
144token_pointer tok_start[max_texts]; /* directory into |tok_mem| */144static token_pointer tok_start[max_texts]; /* directory into |tok_mem| */
145text_pointer tok_start_end; /* end of |tok_start| */145static text_pointer tok_start_end; /* end of |tok_start| */
146text_pointer text_ptr; /* first unused position in |tok_start| */146static text_pointer text_ptr; /* first unused position in |tok_start| */
147@z147@z
148 148
149@x Section 31. (goes with the previous change)149@x Section 31. (goes with the previous change)
@@ -212,9 +212,9 @@ max_tok_ptr=tok_mem+1; max_text_ptr=tok_start+1; · 62 unmodified lines
212 212
213 213
214@x Section 246.214@x Section 246.
215char *cur_byte; /* index into |byte_mem| */215static char *cur_byte; /* index into |byte_mem| */
216@y216@y
217char huge* cur_byte; /* index into |byte_mem| */217static char huge* cur_byte; /* index into |byte_mem| */
218@z218@z
219 219
220 220
cweav-man.ch+1−1
@@ -16,7 +16,7 @@ under the terms of a permission notice identical to this one. · 15 unmodified lines
16}16}
17@y17@y
18\def\botofcontents{\vfill\titlefalse}18\def\botofcontents{\vfill\titlefalse}
19\def\contentspagenumber{110}19\def\contentspagenumber{111}
20\def\title{APPENDIX F: CWEAVE}20\def\title{APPENDIX F: CWEAVE}
21\let\K=\leftarrow21\let\K=\leftarrow
22@z22@z
cweav-pc.ch+2−2
@@ -11,9 +11,9 @@ that allows >64K arrays. (If you need lots more bytes, try the alternate · 10 unmodified lines
11change files that have -bs in their name instead of -pc.)11change files that have -bs in their name instead of -pc.)
12 12
13@x section 113@x section 1
14@d banner "This is CWEAVE (Version 4.1)"14@d banner "This is CWEAVE (Version 4.2)"
15@y15@y
16@d banner "This is CWEAVE (Version 4.1pc)"16@d banner "This is CWEAVE (Version 4.2pc)"
17@z17@z
18 18
19@x section 419@x section 4
cweav-ql.ch+4−4
@@ -7,15 +7,15 @@ ex <dev_>cc;"-v -h -c =500000 cweave_c" · 6 unmodified lines
7 7
8 8
9@x9@x
10\def\title{CWEAVE (Version 4.1)}10\def\title{CWEAVE (Version 4.2)}
11@y11@y
12\def\title{CWEAVE (QL Version 4.1)}12\def\title{CWEAVE (QL Version 4.2)}
13@z13@z
14 14
15@x section 115@x section 1
16@d banner "This is CWEAVE (Version 4.1)"16@d banner "This is CWEAVE (Version 4.2)"
17@y17@y
18@d banner "This is CWEAVE (QL Version 4.1)"18@d banner "This is CWEAVE (QL Version 4.2)"
19@z19@z
20 20
21@x21@x
cweav-vms.ch+2−2
@@ -13,9 +13,9 @@ modified: · 12 unmodified lines
13(also modified by Don Knuth to keep version numbers uptodate)13(also modified by Don Knuth to keep version numbers uptodate)
14 14
15@x section 1 (01-FEB-1992 ST)15@x section 1 (01-FEB-1992 ST)
16@d banner "This is CWEAVE (Version 4.1)"16@d banner "This is CWEAVE (Version 4.2)"
17@y17@y
18@d banner "This is CWEAVE (VAX/VMS Version 4.1)"18@d banner "This is CWEAVE (VAX/VMS Version 4.2)"
19@z19@z
20 20
21@x section 3 (01-FEB-1992 ST)21@x section 3 (01-FEB-1992 ST)
cweav-w32.ch+2−2
@@ -2,9 +2,9 @@ This is the change file for CWEB's CWEAVE under Win32 · 1 unmodified line
2(Contributed by Fabrice Popineau, February 2002)2(Contributed by Fabrice Popineau, February 2002)
3 3
4@x section 14@x section 1
5@d banner "This is CWEAVE (Version 4.1)"5@d banner "This is CWEAVE (Version 4.2)"
6@y6@y
7@d banner "This is CWEAVE (Version 4.1win32)"7@d banner "This is CWEAVE (Version 4.2win32)"
8@z8@z
9 9
10@x10@x
cweave.w+151−166
@@ -2,7 +2,7 @@ · 1 unmodified line
2% This program by Silvio Levy and Donald E. Knuth2% This program by Silvio Levy and Donald E. Knuth
3% is based on a program by Knuth.3% is based on a program by Knuth.
4% It is distributed WITHOUT ANY WARRANTY, express or implied.4% It is distributed WITHOUT ANY WARRANTY, express or implied.
5% Version 4.1 --- February 20215% Version 4.2 --- February 2021
6 6
7% Copyright (C) 1987,1990,1993,2000 Silvio Levy and Donald E. Knuth7% Copyright (C) 1987,1990,1993,2000 Silvio Levy and Donald E. Knuth
8 8
@@ -32,11 +32,11 @@ · 23 unmodified lines
32\def\skipxTeX{\\{skip\_\TEX/}}32\def\skipxTeX{\\{skip\_\TEX/}}
33\def\copyxTeX{\\{copy\_\TEX/}}33\def\copyxTeX{\\{copy\_\TEX/}}
34 34
35\def\title{CWEAVE (Version 4.1)}35\def\title{CWEAVE (Version 4.2)}
36\def\topofcontents{\null\vfill36\def\topofcontents{\null\vfill
37 \centerline{\titlefont The {\ttitlefont CWEAVE} processor}37 \centerline{\titlefont The {\ttitlefont CWEAVE} processor}
38 \vskip 15pt38 \vskip 15pt
39 \centerline{(Version 4.1)}39 \centerline{(Version 4.2)}
40 \vfill}40 \vfill}
41\def\botofcontents{\vfill41\def\botofcontents{\vfill
42\noindent42\noindent
@@ -67,13 +67,13 @@ Crusius, and others who have contributed improvements. · 24 unmodified lines
67The ``banner line'' defined here should be changed whenever \.{CWEAVE}67The ``banner line'' defined here should be changed whenever \.{CWEAVE}
68is modified.68is modified.
69 69
70@d banner "This is CWEAVE (Version 4.1)"70@d banner "This is CWEAVE (Version 4.2)"
71 71
72@c @<Include files@>@/72@c @<Include files@>@/
73@h73@h
74@<Common code for \.{CWEAVE} and \.{CTANGLE}@>@/74@<Common code for \.{CWEAVE} and \.{CTANGLE}@>@/
75@<Typedef declarations@>@/75@<Typedef declarations@>@/
76@<Global variables@>@/76@<Private variables@>@/
77@<Predeclaration of procedures@>77@<Predeclaration of procedures@>
78 78
79@ \.{CWEAVE} has a fairly straightforward outline. It operates in79@ \.{CWEAVE} has a fairly straightforward outline. It operates in
@@ -99,6 +99,7 @@ char **av@t\2\2@>) /* argument values */ · 19 unmodified lines
99 phase_one(); /* read all the user's text and store the cross-references */99 phase_one(); /* read all the user's text and store the cross-references */
100 phase_two(); /* read all the text again and translate it to \TEX/ form */100 phase_two(); /* read all the text again and translate it to \TEX/ form */
101 phase_three(); /* output the cross-reference index */101 phase_three(); /* output the cross-reference index */
102 if (tracing==2 && !show_progress) new_line;
102 return wrap_up(); /* and exit gracefully */103 return wrap_up(); /* and exit gracefully */
103}104}
104 105
@@ -181,8 +182,8 @@ is the total number of sections that have started. Sections which have · 76 unmodified lines
181been altered by a change file entry have their |changed_section| flag182been altered by a change file entry have their |changed_section| flag
182turned on during the first phase.183turned on during the first phase.
183 184
184@<Global...@>=185@<Private...@>=
185boolean change_exists; /* has any section changed? */186static boolean change_exists; /* has any section changed? */
186 187
187@ The other large memory area in \.{CWEAVE} keeps the cross-reference data.188@ The other large memory area in \.{CWEAVE} keeps the cross-reference data.
188All uses of the name |p| are recorded in a linked list beginning at189All uses of the name |p| are recorded in a linked list beginning at
@@ -213,11 +214,11 @@ typedef struct xref_info { · 24 unmodified lines
213} xref_info;214} xref_info;
214typedef xref_info *xref_pointer;215typedef xref_info *xref_pointer;
215 216
216@ @<Global...@>=217@ @<Private...@>=
217xref_info xmem[max_refs]; /* contains cross-reference information */218static xref_info xmem[max_refs]; /* contains cross-reference information */
218xref_pointer xmem_end = xmem+max_refs-1;219static xref_pointer xmem_end = xmem+max_refs-1;
219xref_pointer xref_ptr; /* the largest occupied position in |xmem| */220static xref_pointer xref_ptr; /* the largest occupied position in |xmem| */
220sixteen_bits xref_switch,section_xref_switch; /* either zero or |def_flag| */221static sixteen_bits xref_switch,section_xref_switch; /* either zero or |def_flag| */
221 222
222@ A section that is used for multi-file output (with the \.{@@(} feature)223@ A section that is used for multi-file output (with the \.{@@(} feature)
223has a special first cross-reference whose |num| field is |file_flag|.224has a special first cross-reference whose |num| field is |file_flag|.
@@ -250,7 +251,7 @@ If one were careful, one could probably make more changes around section · 26 unmodified lines
250@<Predecl...@>=251@<Predecl...@>=
251static void new_xref(name_pointer);@/252static void new_xref(name_pointer);@/
252static void new_section_xref(name_pointer);@/253static void new_section_xref(name_pointer);@/
253static void set_file_flag(name_pointer);@/254static void set_file_flag(name_pointer);
254 255
255@ @c256@ @c
256static void257static void
@@ -332,15 +333,15 @@ that is unoccupied by replacement text is called |tok_ptr|, and the first · 75 unmodified lines
332unused location of |tok_start| is called |text_ptr|.333unused location of |tok_start| is called |text_ptr|.
333Thus, we usually have |*text_ptr==tok_ptr|.334Thus, we usually have |*text_ptr==tok_ptr|.
334 335
335@<Global...@>=336@<Private...@>=
336token tok_mem[max_toks]; /* tokens */337static token tok_mem[max_toks]; /* tokens */
337token_pointer tok_mem_end = tok_mem+max_toks-1; /* end of |tok_mem| */338static token_pointer tok_mem_end = tok_mem+max_toks-1; /* end of |tok_mem| */
338token_pointer tok_ptr; /* first unused position in |tok_mem| */339static token_pointer tok_ptr; /* first unused position in |tok_mem| */
339token_pointer max_tok_ptr; /* largest value of |tok_ptr| */340static token_pointer max_tok_ptr; /* largest value of |tok_ptr| */
340token_pointer tok_start[max_texts]; /* directory into |tok_mem| */341static token_pointer tok_start[max_texts]; /* directory into |tok_mem| */
341text_pointer tok_start_end = tok_start+max_texts-1; /* end of |tok_start| */342static text_pointer tok_start_end = tok_start+max_texts-1; /* end of |tok_start| */
342text_pointer text_ptr; /* first unused position in |tok_start| */343static text_pointer text_ptr; /* first unused position in |tok_start| */
343text_pointer max_text_ptr; /* largest value of |text_ptr| */344static text_pointer max_text_ptr; /* largest value of |text_ptr| */
344 345
345@ @<Set init...@>=346@ @<Set init...@>=
346tok_ptr=max_tok_ptr=tok_mem+1;@/347tok_ptr=max_tok_ptr=tok_mem+1;@/
@@ -382,8 +383,7 @@ name_pointer p) · 35 unmodified lines
382 p->xref=(void *)xref_ptr;383 p->xref=(void *)xref_ptr;
383}384}
384 385
385@ @<Predecl...@>=386@ @<Predecl...@>=@+static void update_node(name_pointer p);
386static void update_node(name_pointer p);@/
387 387
388@ We have to get \CEE/'s388@ We have to get \CEE/'s
389reserved words into the hash table, and the simplest way to do this is389reserved words into the hash table, and the simplest way to do this is
@@ -489,8 +489,7 @@ id_lookup("volatile",NULL,const_like); · 99 unmodified lines
489id_lookup("wchar_t",NULL,raw_int);489id_lookup("wchar_t",NULL,raw_int);
490id_lookup("while",NULL,for_like);490id_lookup("while",NULL,for_like);
491id_lookup("xor",NULL,alfop);491id_lookup("xor",NULL,alfop);
492id_lookup("xor_eq",NULL,alfop);492id_lookup("xor_eq",NULL,alfop);@+ res_wd_end=name_ptr;
493res_wd_end=name_ptr;
494id_lookup("TeX",NULL,custom);493id_lookup("TeX",NULL,custom);
495id_lookup("make_pair",NULL,func_template);494id_lookup("make_pair",NULL,func_template);
496 495
@@ -546,8 +545,8 @@ scanning routines. · 49 unmodified lines
546@ Control codes are converted to \.{CWEAVE}'s internal545@ Control codes are converted to \.{CWEAVE}'s internal
547representation by means of the table |ccode|.546representation by means of the table |ccode|.
548 547
549@<Global...@>=548@<Private...@>=
550eight_bits ccode[256]; /* meaning of a char following \.{@@} */549static eight_bits ccode[256]; /* meaning of a char following \.{@@} */
551 550
552@ @<Set ini...@>=551@ @<Set ini...@>=
553{int c; for (c=0; c<256; c++) ccode[c]=0;}552{int c; for (c=0; c<256; c++) ccode[c]=0;}
@@ -589,7 +588,7 @@ interpretation of identifiers. · 35 unmodified lines
589 588
590@<Predec...@>=589@<Predec...@>=
591static void skip_limbo(void);@/590static void skip_limbo(void);@/
592static eight_bits skip_TeX(void);@/591static eight_bits skip_TeX(void);
593 592
594@ @c593@ @c
595static void594static void
@@ -597,7 +596,7 @@ skip_limbo(void) { · 1 unmodified line
597 while(true) {596 while(true) {
598 if (loc>limit && get_line()==false) return;597 if (loc>limit && get_line()==false) return;
599 *(limit+1)='@@';598 *(limit+1)='@@';
600 while (*loc!='@@') loc++; /* look for '@@', then skip two chars */599 while (*loc!='@@') loc++; /* look for `\.{@@}', then skip two chars */
601 if (loc++ <=limit) { int c=ccode[(eight_bits)*loc++];600 if (loc++ <=limit) { int c=ccode[(eight_bits)*loc++];
602 if (c==new_section) return;601 if (c==new_section) return;
603 if (c==noop) skip_restricted();602 if (c==noop) skip_restricted();
@@ -666,9 +665,9 @@ it sets |xref_switch| to |def_flag| and goes on to the next token. · 62 unmodified lines
666@d string 0201 /* \CEE/ string */665@d string 0201 /* \CEE/ string */
667@d identifier 0202 /* \CEE/ identifier or reserved word */666@d identifier 0202 /* \CEE/ identifier or reserved word */
668 667
669@<Global...@>=668@<Private...@>=
670name_pointer cur_section; /* name of section just scanned */669static name_pointer cur_section; /* name of section just scanned */
671char cur_section_char; /* the character just before that name */670static char cur_section_char; /* the character just before that name */
672 671
673@ As one might expect, |get_next| consists mostly of a big switch672@ As one might expect, |get_next| consists mostly of a big switch
674that branches to the various special cases that can arise.673that branches to the various special cases that can arise.
@@ -680,10 +679,7 @@ compilers even allow the dollar sign. · 5 unmodified lines
680@d ishigh(c) ((eight_bits)(c)>0177)679@d ishigh(c) ((eight_bits)(c)>0177)
681@^high-bit character handling@>680@^high-bit character handling@>
682 681
683@<Predecl...@>=682@c
684static eight_bits get_next(void);@/
685
686@ @c
687static eight_bits683static eight_bits
688get_next(void) /* produces the next input token */684get_next(void) /* produces the next input token */
689{685{
@@ -708,6 +704,8 @@ get_next(void) /* produces the next input token */ · 18 unmodified lines
708 }704 }
709}705}
710 706
707@ @<Predecl...@>=@+static eight_bits get_next(void);
708
711@ Because preprocessor commands do not fit in with the rest of the syntax709@ Because preprocessor commands do not fit in with the rest of the syntax
712of \CEE/,710of \CEE/,
713we have to deal with them separately. One solution is to enclose such711we have to deal with them separately. One solution is to enclose such
@@ -721,8 +719,8 @@ for |ord|, since |get_next| changes |ord| into a string. · 7 unmodified lines
721@d left_preproc ord /* begins a preprocessor command */719@d left_preproc ord /* begins a preprocessor command */
722@d right_preproc 0217 /* ends a preprocessor command */720@d right_preproc 0217 /* ends a preprocessor command */
723 721
724@<Glob...@>=722@<Private...@>=
725boolean preprocessing=false; /* are we scanning a preprocessor command? */723static boolean preprocessing=false; /* are we scanning a preprocessor command? */
726 724
727@ @<Raise prep...@>= {725@ @<Raise prep...@>= {
728 preprocessing=true;726 preprocessing=true;
@@ -734,8 +732,8 @@ boolean preprocessing=false; /* are we scanning a preprocessor command? */ · 5 unmodified lines
734a file name in lines that start with \.{\#include}. We must treat this file732a file name in lines that start with \.{\#include}. We must treat this file
735name as a string.733name as a string.
736 734
737@<Glob...@>=735@<Private...@>=
738boolean sharp_include_line=false; /* are we scanning a |#include| line? */736static boolean sharp_include_line=false; /* are we scanning a \&{\#include} line? */
739 737
740@ @<Check if next token is |include|@>=738@ @<Check if next token is |include|@>=
741while (loc<=buffer_end-7 && xisspace(*loc)) loc++;739while (loc<=buffer_end-7 && xisspace(*loc)) loc++;
@@ -844,7 +842,7 @@ convention, but do not allow the string to be longer than |longest_name|. · 102 unmodified lines
844 if (delim=='u' && *loc=='8') { *++id_loc=*loc++; }842 if (delim=='u' && *loc=='8') { *++id_loc=*loc++; }
845 delim=*loc++; *++id_loc=delim;843 delim=*loc++; *++id_loc=delim;
846 }844 }
847 if (delim=='<') delim='>'; /* for file names in |#include| lines */845 if (delim=='<') delim='>'; /* for file names in \&{\#include} lines */
848 while (true) {846 while (true) {
849 if (loc>=limit) {847 if (loc>=limit) {
850 if(*(limit-1)!='\\') {848 if(*(limit-1)!='\\') {
@@ -960,10 +958,7 @@ if (c=='@@') { · 109 unmodified lines
960 958
961@ This function skips over a restricted context at relatively high speed.959@ This function skips over a restricted context at relatively high speed.
962 960
963@<Predecl...@>=961@c
964static void skip_restricted(void);@/
965
966@ @c
967static void962static void
968skip_restricted(void)963skip_restricted(void)
969{964{
@@ -983,6 +978,8 @@ false_alarm: · 13 unmodified lines
983 }978 }
984}979}
985 980
981@ @<Predecl...@>=@+static void skip_restricted(void);
982
986@ At the present point in the program we983@ At the present point in the program we
987have |*(loc-1)==verbatim|; we set |id_first| to the beginning984have |*(loc-1)==verbatim|; we set |id_first| to the beginning
988of the string itself, and |id_loc| to its ending-plus-one location in the985of the string itself, and |id_loc| to its ending-plus-one location in the
@@ -1007,16 +1004,13 @@ The global variable |next_control| often contains the most recent output of · 18 unmodified lines
1007|get_next|; in interesting cases, this will be the control code that1004|get_next|; in interesting cases, this will be the control code that
1008ended a section or part of a section.1005ended a section or part of a section.
1009 1006
1010@<Global...@>=1007@<Private...@>=
1011eight_bits next_control; /* control code waiting to be acting upon */1008static eight_bits next_control; /* control code waiting to be acting upon */
1012 1009
1013@ The overall processing strategy in phase one has the following1010@ The overall processing strategy in phase one has the following
1014straightforward outline.1011straightforward outline.
1015 1012
1016@<Predecl...@>=1013@c
1017static void phase_one(void);@/
1018
1019@ @c
1020static void1014static void
1021phase_one(void) {1015phase_one(void) {
1022 phase=1; reset_input(); section_count=0;1016 phase=1; reset_input(); section_count=0;
@@ -1029,6 +1023,8 @@ phase_one(void) { · 6 unmodified lines
1029 @<Print error messages about unused or undefined section names@>@;1023 @<Print error messages about unused or undefined section names@>@;
1030}1024}
1031 1025
1026@ @<Predecl...@>=@+static void phase_one(void);
1027
1032@ @<Store cross-reference data...@>=1028@ @<Store cross-reference data...@>=
1033{1029{
1034 if (++section_count==max_sections) overflow("section number");1030 if (++section_count==max_sections) overflow("section number");
@@ -1067,7 +1063,7 @@ as well as |normal==0|. · 32 unmodified lines
1067 1063
1068@<Predecl...@>=1064@<Predecl...@>=
1069static void C_xref(eight_bits);@/1065static void C_xref(eight_bits);@/
1070static void outer_xref(void);@/1066static void outer_xref(void);
1071 1067
1072@ @c1068@ @c
1073static void1069static void
@@ -1161,9 +1157,9 @@ entirely, even if it contains \pb\ constructions. · 87 unmodified lines
1161The variables |lhs| and |rhs| point to the respective identifiers involved1157The variables |lhs| and |rhs| point to the respective identifiers involved
1162in a format definition.1158in a format definition.
1163 1159
1164@<Global...@>=1160@<Private...@>=
1165name_pointer lhs, rhs; /* pointers to |byte_start| for format identifiers */1161static name_pointer lhs, rhs; /* pointers to |byte_start| for format identifiers */
1166name_pointer res_wd_end; /* pointer to the first nonreserved identifier */1162static name_pointer res_wd_end; /* pointer to the first nonreserved identifier */
1167 1163
1168@ When we get to the following code we have |next_control>=format_code|.1164@ When we get to the following code we have |next_control>=format_code|.
1169 1165
@@ -1245,18 +1241,15 @@ if (next_control<=section_name) { /* |begin_C| or |section_name| */ · 75 unmodified lines
1245section name was both defined and used. The variable |cur_xref| will point1241section name was both defined and used. The variable |cur_xref| will point
1246to cross-references for the current section name of interest.1242to cross-references for the current section name of interest.
1247 1243
1248@<Global...@>=1244@<Private...@>=
1249xref_pointer cur_xref; /* temporary cross-reference pointer */1245static xref_pointer cur_xref; /* temporary cross-reference pointer */
1250boolean an_output; /* did |file_flag| precede |cur_xref|? */1246static boolean an_output; /* did |file_flag| precede |cur_xref|? */
1251 1247
1252@ The following recursive procedure1248@ The following recursive procedure
1253walks through the tree of section names and prints out anomalies.1249walks through the tree of section names and prints out anomalies.
1254@^recursion@>1250@^recursion@>
1255 1251
1256@<Predecl...@>=1252@c
1257static void section_check(name_pointer);@/
1258
1259@ @c
1260static void1253static void
1261section_check(1254section_check(
1262name_pointer p) /* print anomalies in subtree |p| */1255name_pointer p) /* print anomalies in subtree |p| */
@@ -1281,6 +1274,8 @@ name_pointer p) /* print anomalies in subtree |p| */ · 18 unmodified lines
1281 }1274 }
1282}1275}
1283 1276
1277@ @<Predecl...@>=@+static void section_check(name_pointer);
1278
1284@ @<Print error messages about un...@>=section_check(root);1279@ @<Print error messages about un...@>=section_check(root);
1285 1280
1286@* Low-level output routines.1281@* Low-level output routines.
@@ -1289,11 +1284,11 @@ characters long, so we place it into an output buffer. During the output · 2 unmodified lines
1289process, |out_line| will hold the current line number of the line about to1284process, |out_line| will hold the current line number of the line about to
1290be output.1285be output.
1291 1286
1292@<Global...@>=1287@<Private...@>=
1293char out_buf[line_length+1]; /* assembled characters */1288static char out_buf[line_length+1]; /* assembled characters */
1294char *out_buf_end = out_buf+line_length; /* end of |out_buf| */1289static char *out_buf_end = out_buf+line_length; /* end of |out_buf| */
1295char *out_ptr; /* last character in |out_buf| */1290static char *out_ptr; /* last character in |out_buf| */
1296int out_line; /* number of next line to be output */1291static int out_line; /* number of next line to be output */
1297 1292
1298@ The |flush_buffer| routine empties the buffer up to a given breakpoint,1293@ The |flush_buffer| routine empties the buffer up to a given breakpoint,
1299and moves any remaining characters to the beginning of the next line.1294and moves any remaining characters to the beginning of the next line.
@@ -1314,7 +1309,7 @@ of commented-out text). · 14 unmodified lines
1314 1309
1315@<Predecl...@>=1310@<Predecl...@>=
1316static void flush_buffer(char *,boolean,boolean);@/1311static void flush_buffer(char *,boolean,boolean);@/
1317static void finish_line(void);@/1312static void finish_line(void);
1318 1313
1319@ @c1314@ @c
1320static void1315static void
@@ -1379,7 +1374,7 @@ A line break will occur at a space or after a single-nonletter · 58 unmodified lines
1379 1374
1380@<Predecl...@>=1375@<Predecl...@>=
1381static void out_str(const char *);@/1376static void out_str(const char *);@/
1382static void break_out(void);@/1377static void break_out(void);
1383 1378
1384@ @c1379@ @c
1385static void1380static void
@@ -1437,7 +1432,7 @@ the section is changed, we output `\.{\\*}' just after the number. · 51 unmodified lines
1437 1432
1438@<Predecl...@>=1433@<Predecl...@>=
1439static void out_section(sixteen_bits);@/1434static void out_section(sixteen_bits);@/
1440static void out_name(name_pointer,boolean);@/1435static void out_name(name_pointer,boolean);
1441 1436
1442@ @c1437@ @c
1443static void1438static void
@@ -1484,7 +1479,7 @@ The use of `\.{@@}' signs is severely restricted in such material: · 40 unmodified lines
1484@<Predecl...@>=1479@<Predecl...@>=
1485static void copy_limbo(void);@/1480static void copy_limbo(void);@/
1486static eight_bits copy_TeX(void);@/1481static eight_bits copy_TeX(void);@/
1487static int copy_comment(boolean,int);@/1482static int copy_comment(boolean,int);
1488 1483
1489@ @c1484@ @c
1490static void1485static void
@@ -1716,8 +1711,8 @@ same initial letter; these subscripts are assigned from left to right. · 225 unmodified lines
1716@d begin_arg 61 /* \.{@@[} */1711@d begin_arg 61 /* \.{@@[} */
1717@d end_arg 62 /* \.{@@]} */1712@d end_arg 62 /* \.{@@]} */
1718 1713
1719@<Glo...@>=1714@<Private...@>=
1720char cat_name[256][12];1715static char cat_name[256][12];
1721 1716
1722@ @<Set in...@>=1717@ @<Set in...@>=
1723{int c; for (c=0;c<256;c++) strcpy(cat_name[c],"UNKNOWN");}1718{int c; for (c=0;c<256;c++) strcpy(cat_name[c],"UNKNOWN");}
@@ -1783,10 +1778,7 @@ char cat_name[256][12]; · 59 unmodified lines
1783 1778
1784@ This code allows \.{CWEAVE} to display its parsing steps.1779@ This code allows \.{CWEAVE} to display its parsing steps.
1785 1780
1786@<Predecl...@>=1781@c
1787static void print_cat(eight_bits);@/
1788
1789@ @c
1790static void1782static void
1791print_cat(@t\1\1@> /* symbolic printout of a category */1783print_cat(@t\1\1@> /* symbolic printout of a category */
1792eight_bits c@t\2\2@>)1784eight_bits c@t\2\2@>)
@@ -1794,6 +1786,8 @@ eight_bits c@t\2\2@>) · 1 unmodified line
1794 fputs(cat_name[c],stdout);1786 fputs(cat_name[c],stdout);
1795}1787}
1796 1788
1789@ @<Predecl...@>=@+static void print_cat(eight_bits);
1790
1797@ The token lists for translated \TEX/ output contain some special control1791@ The token lists for translated \TEX/ output contain some special control
1798symbols as well as ordinary characters. These control symbols are1792symbols as well as ordinary characters. These control symbols are
1799interpreted by \.{CWEAVE} before they are written to the output file.1793interpreted by \.{CWEAVE} before they are written to the output file.
@@ -2104,15 +2098,15 @@ typedef scrap *scrap_pointer; · 304 unmodified lines
2104 2098
2105@ @d trans trans_plus.Trans /* translation texts of scraps */2099@ @d trans trans_plus.Trans /* translation texts of scraps */
2106 2100
2107@<Global...@>=2101@<Private...@>=
2108scrap scrap_info[max_scraps]; /* memory array for scraps */2102static scrap scrap_info[max_scraps]; /* memory array for scraps */
2109scrap_pointer scrap_info_end=scrap_info+max_scraps-1; /* end of |scrap_info| */2103static scrap_pointer scrap_info_end=scrap_info+max_scraps-1; /* end of |scrap_info| */
2110scrap_pointer scrap_base; /* beginning of the current scrap sequence */2104static scrap_pointer scrap_base; /* beginning of the current scrap sequence */
2111scrap_pointer scrap_ptr; /* ending of the current scrap sequence */2105static scrap_pointer scrap_ptr; /* ending of the current scrap sequence */
2112scrap_pointer max_scr_ptr; /* largest value assumed by |scrap_ptr| */2106static scrap_pointer max_scr_ptr; /* largest value assumed by |scrap_ptr| */
2113scrap_pointer pp; /* current position for reducing productions */2107static scrap_pointer pp; /* current position for reducing productions */
2114scrap_pointer lo_ptr; /* last scrap that has been examined */2108static scrap_pointer lo_ptr; /* last scrap that has been examined */
2115scrap_pointer hi_ptr; /* first scrap that has not been examined */2109static scrap_pointer hi_ptr; /* first scrap that has not been examined */
2116 2110
2117@ @<Set init...@>=2111@ @<Set init...@>=
2118scrap_base=scrap_info+1;2112scrap_base=scrap_info+1;
@@ -2141,10 +2135,7 @@ translated without line-break controls. · 22 unmodified lines
2141@d tok_flag 4*id_flag /* signifies a token list */2135@d tok_flag 4*id_flag /* signifies a token list */
2142@d inner_tok_flag 5*id_flag /* signifies a token list in `\pb' */2136@d inner_tok_flag 5*id_flag /* signifies a token list in `\pb' */
2143 2137
2144@<Predecl...@>=2138@c
2145static void print_text(text_pointer p);@/
2146
2147@ @c
2148static void2139static void
2149print_text(@t\1\1@> /* prints a token list for debugging; not used in |main| */2140print_text(@t\1\1@> /* prints a token list for debugging; not used in |main| */
2150text_pointer p@t\2\2@>)2141text_pointer p@t\2\2@>)
@@ -2169,6 +2160,8 @@ text_pointer p@t\2\2@>) · 18 unmodified lines
2169 update_terminal;2160 update_terminal;
2170}2161}
2171 2162
2163@ @<Predecl...@>=@+static void print_text(text_pointer p);
2164
2172@ @<Print token |r|...@>=2165@ @<Print token |r|...@>=
2173switch (r) {2166switch (r) {
2174 case math_rel: printf("\\mathrel{"@q}@>); break;2167 case math_rel: printf("\\mathrel{"@q}@>); break;
@@ -2265,13 +2258,13 @@ productions as they were listed earlier. · 90 unmodified lines
2265@d app(a) *(tok_ptr++)=(token)(a)2258@d app(a) *(tok_ptr++)=(token)(a)
2266@d app1(a) *(tok_ptr++)=(token)(tok_flag+(int)((a)->trans-tok_start))2259@d app1(a) *(tok_ptr++)=(token)(tok_flag+(int)((a)->trans-tok_start))
2267 2260
2268@<Global...@>=2261@<Private...@>=
2269int cur_mathness, init_mathness;2262static int cur_mathness, init_mathness;
2270 2263
2271@ @<Predecl...@>=2264@ @<Predecl...@>=
2272static void app_str(const char *);@/2265static void app_str(const char *);@/
2273static void big_app(token);@/2266static void big_app(token);@/
2274static void big_app1(scrap_pointer);@/2267static void big_app1(scrap_pointer);
2275 2268
2276@ @c2269@ @c
2277static void2270static void
@@ -2428,7 +2421,7 @@ more properly alpha\-betized, · 150 unmodified lines
2428static token_pointer find_first_ident(text_pointer);@/2421static token_pointer find_first_ident(text_pointer);@/
2429static void make_reserved(scrap_pointer);@/2422static void make_reserved(scrap_pointer);@/
2430static void make_underlined(scrap_pointer);@/2423static void make_underlined(scrap_pointer);@/
2431static void underline_xref(name_pointer);@/2424static void underline_xref(name_pointer);
2432 2425
2433@ @c2426@ @c
2434static token_pointer2427static token_pointer
@@ -3022,7 +3015,7 @@ too large, since it is assumed that this test was done beforehand. · 587 unmodified lines
3022 3015
3023@<Predecl...@>=3016@<Predecl...@>=
3024static void reduce(scrap_pointer,short,eight_bits,short,short);@/3017static void reduce(scrap_pointer,short,eight_bits,short,short);@/
3025static void squash(scrap_pointer,short,eight_bits,short,short);@/3018static void squash(scrap_pointer,short,eight_bits,short,short);
3026 3019
3027@ @c3020@ @c
3028static void3021static void
@@ -3114,8 +3107,8 @@ current stack categories will be printed out when |tracing| is set to 2; · 85 unmodified lines
3114a sequence of two or more irreducible scraps will be printed out when3107a sequence of two or more irreducible scraps will be printed out when
3115|tracing| is set to 1.3108|tracing| is set to 1.
3116 3109
3117@<Global...@>=3110@<Private...@>=
3118int tracing; /* can be used to show parsing details */3111static int tracing; /* can be used to show parsing details */
3119 3112
3120@ @<Print a snapsh...@>=3113@ @<Print a snapsh...@>=
3121{ scrap_pointer k_l; /* pointer into |scrap_info| */3114{ scrap_pointer k_l; /* pointer into |scrap_info| */
@@ -3146,10 +3139,7 @@ lists with up to six tokens without checking for overflow. Before calling · 24 unmodified lines
3146since |translate| might add a new text and a new scrap before it checks3139since |translate| might add a new text and a new scrap before it checks
3147for overflow.3140for overflow.
3148 3141
3149@<Predecl...@>=3142@c
3150static text_pointer translate(void);@/
3151
3152@ @c
3153static text_pointer3143static text_pointer
3154translate(void) /* converts a sequence of scraps */3144translate(void) /* converts a sequence of scraps */
3155{3145{
@@ -3161,6 +3151,8 @@ translate(void) /* converts a sequence of scraps */ · 5 unmodified lines
3161 @<Combine the irreducible scraps that remain@>@;3151 @<Combine the irreducible scraps that remain@>@;
3162}3152}
3163 3153
3154@ @<Predecl...@>=@+static text_pointer translate(void);
3155
3164@ If the initial sequence of scraps does not reduce to a single scrap,3156@ If the initial sequence of scraps does not reduce to a single scrap,
3165we concatenate the translations of all remaining scraps, separated by3157we concatenate the translations of all remaining scraps, separated by
3166blank spaces, with dollar signs surrounding the translations of scraps3158blank spaces, with dollar signs surrounding the translations of scraps
@@ -3214,10 +3206,7 @@ repeatedly to read \CEE/ text until encountering the next `\.{\v}' or · 47 unmodified lines
3214what it reads are appended into the |cat| and |trans| arrays, and |scrap_ptr|3206what it reads are appended into the |cat| and |trans| arrays, and |scrap_ptr|
3215is advanced.3207is advanced.
3216 3208
3217@<Predecl...@>=3209@c
3218static void C_parse(eight_bits);@/
3219
3220@ @c
3221static void3210static void
3222C_parse(@t\1\1@> /* creates scraps from \CEE/ tokens */3211C_parse(@t\1\1@> /* creates scraps from \CEE/ tokens */
3223 eight_bits spec_ctrl@t\2\2@>)3212 eight_bits spec_ctrl@t\2\2@>)
@@ -3231,6 +3220,8 @@ C_parse(@t\1\1@> /* creates scraps from \CEE/ tokens */ · 7 unmodified lines
3231 }3220 }
3232}3221}
3233 3222
3223@ @<Predecl...@>=@+static void C_parse(eight_bits);
3224
3234@ The following macro is used to append a scrap whose tokens have just3225@ The following macro is used to append a scrap whose tokens have just
3235been appended:3226been appended:
3236 3227
@@ -3452,7 +3443,7 @@ token list; it also builds a new scrap if |scrapping==true|. · 215 unmodified lines
3452@<Predec...@>=3443@<Predec...@>=
3453static void app_cur_id(boolean);@/3444static void app_cur_id(boolean);@/
3454static text_pointer C_translate(void);@/3445static text_pointer C_translate(void);@/
3455static void outer_parse(void);@/3446static void outer_parse(void);
3456 3447
3457@ @c3448@ @c
3458static void3449static void
@@ -3604,12 +3595,12 @@ typedef output_state *stack_pointer; · 145 unmodified lines
3604@d cur_mode cur_state.mode_field /* current mode of interpretation */3595@d cur_mode cur_state.mode_field /* current mode of interpretation */
3605@d init_stack stack_ptr=stack;cur_mode=outer /* initialize the stack */3596@d init_stack stack_ptr=stack;cur_mode=outer /* initialize the stack */
3606 3597
3607@<Global...@>=3598@<Private...@>=
3608output_state cur_state; /* |cur_end|, |cur_tok|, |cur_mode| */3599static output_state cur_state; /* |cur_end|, |cur_tok|, |cur_mode| */
3609output_state stack[stack_size]; /* info for non-current levels */3600static output_state stack[stack_size]; /* info for non-current levels */
3610stack_pointer stack_end=stack+stack_size-1; /* end of |stack| */3601static stack_pointer stack_end=stack+stack_size-1; /* end of |stack| */
3611stack_pointer stack_ptr; /* first unused location in the output state stack */3602static stack_pointer stack_ptr; /* first unused location in the output state stack */
3612stack_pointer max_stack_ptr; /* largest value assumed by |stack_ptr| */3603static stack_pointer max_stack_ptr; /* largest value assumed by |stack_ptr| */
3613 3604
3614@ @<Set init...@>=3605@ @<Set init...@>=
3615max_stack_ptr=stack;3606max_stack_ptr=stack;
@@ -3620,7 +3611,7 @@ The value of |cur_mode| is not changed. · 4 unmodified lines
3620 3611
3621@<Predecl...@>=3612@<Predecl...@>=
3622static void push_level(text_pointer);@/3613static void push_level(text_pointer);@/
3623static void pop_level(void);@/3614static void pop_level(void);
3624 3615
3625@ @c3616@ @c
3626static void3617static void
@@ -3658,8 +3649,8 @@ by a complex routine that might generate additional levels of output). · 31 unmodified lines
3658In these cases |cur_name| points to the identifier or section name in3649In these cases |cur_name| points to the identifier or section name in
3659question.3650question.
3660 3651
3661@<Global...@>=3652@<Private...@>=
3662name_pointer cur_name;3653static name_pointer cur_name;
3663 3654
3664@ @d res_word 0201 /* returned by |get_output| for reserved words */3655@ @d res_word 0201 /* returned by |get_output| for reserved words */
3665@d section_code 0200 /* returned by |get_output| for section names */3656@d section_code 0200 /* returned by |get_output| for section names */
@@ -3667,7 +3658,7 @@ name_pointer cur_name; · 1 unmodified line
3667@<Predecl...@>=3658@<Predecl...@>=
3668static eight_bits get_output(void);@/3659static eight_bits get_output(void);@/
3669static void output_C(void);@/3660static void output_C(void);@/
3670static void make_output(void);@/3661static void make_output(void);
3671 3662
3672@ @c3663@ @c
3673static eight_bits3664static eight_bits
@@ -3990,10 +3981,7 @@ is analogous to phase one, except that more work is involved because we must · 316 unmodified lines
3990actually output the \TEX/ material instead of merely looking at the3981actually output the \TEX/ material instead of merely looking at the
3991\.{CWEB} specifications.3982\.{CWEB} specifications.
3992 3983
3993@<Predecl...@>=3984@c
3994static void phase_two(void);@/
3995
3996@ @c
3997static void3985static void
3998phase_two(void) {3986phase_two(void) {
3999reset_input(); if (show_progress) fputs("\nWriting the output file...",stdout);3987reset_input(); if (show_progress) fputs("\nWriting the output file...",stdout);
@@ -4003,6 +3991,8 @@ finish_line(); flush_buffer(out_buf,false,false); /* insert a blank line, it loo · 3 unmodified lines
4003while (!input_has_ended) @<Translate the current section@>@;3991while (!input_has_ended) @<Translate the current section@>@;
4004}3992}
4005 3993
3994@ @<Predecl...@>=@+static void phase_two(void);
3995
4006@ The output file will contain the control sequence \.{\\Y} between non-null3996@ The output file will contain the control sequence \.{\\Y} between non-null
4007sections of a section, e.g., between the \TEX/ and definition parts if both3997sections of a section, e.g., between the \TEX/ and definition parts if both
4008are nonempty. This puts a little white space between the parts when they are3998are nonempty. This puts a little white space between the parts when they are
@@ -4017,14 +4007,14 @@ and `|emit_space_if_needed|' are able to handle the situation: · 8 unmodified lines
4017 space_checked=true;4007 space_checked=true;
4018@.\\Y@>4008@.\\Y@>
4019 4009
4020@<Global...@>=4010@<Private...@>=
4021int save_line; /* former value of |out_line| */4011static int save_line; /* former value of |out_line| */
4022char *save_place; /* former value of |out_ptr| */4012static char *save_place; /* former value of |out_ptr| */
4023int sec_depth; /* the integer, if any, following \.{@@*} */4013static int sec_depth; /* the integer, if any, following \.{@@*} */
4024boolean space_checked; /* have we done |emit_space_if_needed|? */4014static boolean space_checked; /* have we done |emit_space_if_needed|? */
4025boolean format_visible; /* should the next format declaration be output? */4015static boolean format_visible; /* should the next format declaration be output? */
4026boolean doing_format=false; /* are we outputting a format declaration? */4016static boolean doing_format=false; /* are we outputting a format declaration? */
4027boolean group_found=false; /* has a starred section occurred? */4017static boolean group_found=false; /* has a starred section occurred? */
4028 4018
4029@ @<Translate the current section@>= {4019@ @<Translate the current section@>= {
4030 section_count++;4020 section_count++;
@@ -4113,10 +4103,7 @@ takes place, so that the translation will normally end with \.{\\6} or · 82 unmodified lines
4113\.{\\7} (the \TEX/ macros for |force| and |big_force|). This \.{\\6} or4103\.{\\7} (the \TEX/ macros for |force| and |big_force|). This \.{\\6} or
4114\.{\\7} is replaced by the concluding \.{\\par} or by \.{\\Y\\par}.4104\.{\\7} is replaced by the concluding \.{\\par} or by \.{\\Y\\par}.
4115 4105
4116@<Predecl...@>=4106@c
4117static void finish_C(boolean);@/
4118
4119@ @c
4120static void4107static void
4121finish_C(@t\1\1@> /* finishes a definition or a \CEE/ part */4108finish_C(@t\1\1@> /* finishes a definition or a \CEE/ part */
4122 boolean visible@t\2\2@>) /* nonzero if we should produce \TeX\ output */4109 boolean visible@t\2\2@>) /* nonzero if we should produce \TeX\ output */
@@ -4145,6 +4132,8 @@ finish_C(@t\1\1@> /* finishes a definition or a \CEE/ part */ · 22 unmodified lines
4145 /* forget the tokens and the scraps */4132 /* forget the tokens and the scraps */
4146}4133}
4147 4134
4135@ @<Predecl...@>=@+static void finish_C(boolean);
4136
4148@ Keeping in line with the conventions of the \CEE/ preprocessor (and4137@ Keeping in line with the conventions of the \CEE/ preprocessor (and
4149otherwise contrary to the rules of \.{CWEB}) we distinguish here4138otherwise contrary to the rules of \.{CWEB}) we distinguish here
4150between the case that `\.(' immediately follows an identifier and the4139between the case that `\.(' immediately follows an identifier and the
@@ -4202,8 +4191,8 @@ it starts after we scan the matching `\.)'. · 51 unmodified lines
4202|next_control>=begin_C|. We will make the global variable |this_section|4191|next_control>=begin_C|. We will make the global variable |this_section|
4203point to the current section name, if it has a name.4192point to the current section name, if it has a name.
4204 4193
4205@<Global...@>=4194@<Private...@>=
4206name_pointer this_section; /* the current section name, or zero */4195static name_pointer this_section; /* the current section name, or zero */
4207 4196
4208@ @<Translate the \CEE/...@>=4197@ @<Translate the \CEE/...@>=
4209this_section=name_dir;4198this_section=name_dir;
@@ -4286,10 +4275,7 @@ leaves |cur_xref| pointing to the first element not printed. Typical outputs: · 76 unmodified lines
4286Note that the output of \.{CWEAVE} is not English-specific; users may4275Note that the output of \.{CWEAVE} is not English-specific; users may
4287supply new definitions for the macros \.{\\A}, \.{\\As}, etc.4276supply new definitions for the macros \.{\\A}, \.{\\As}, etc.
4288 4277
4289@<Predecl...@>=4278@c
4290static void footnote(sixteen_bits);@/
4291
4292@ @c
4293static void4279static void
4294footnote(@t\1\1@> /* outputs section cross-references */4280footnote(@t\1\1@> /* outputs section cross-references */
4295sixteen_bits flag@t\2\2@>)4281sixteen_bits flag@t\2\2@>)
@@ -4305,6 +4291,8 @@ sixteen_bits flag@t\2\2@>) · 9 unmodified lines
4305 out('.');4291 out('.');
4306}4292}
4307 4293
4294@ @<Predecl...@>=@+static void footnote(sixteen_bits);
4295
4308@ The following code distinguishes three cases, according as the number4296@ The following code distinguishes three cases, according as the number
4309of cross-references is one, two, or more than two. Variable |q| points4297of cross-references is one, two, or more than two. Variable |q| points
4310to the first cross-reference, and the last link is a zero.4298to the first cross-reference, and the last link is a zero.
@@ -4335,10 +4323,7 @@ If the user has set the |no_xref| flag (the \.{-x} option on the command line), · 24 unmodified lines
4335just finish off the page, omitting the index, section name list, and table of4323just finish off the page, omitting the index, section name list, and table of
4336contents.4324contents.
4337 4325
4338@<Predecl...@>=4326@c
4339static void phase_three(void);@/
4340
4341@ @c
4342static void4327static void
4343phase_three(void) {4328phase_three(void) {
4344if (no_xref) {4329if (no_xref) {
@@ -4386,11 +4371,13 @@ if (show_happiness) { · 41 unmodified lines
4386check_complete(); /* was all of the change file used? */4371check_complete(); /* was all of the change file used? */
4387}4372}
4388 4373
4374@ @<Predecl...@>=@+static void phase_three(void);
4375
4389@ Just before the index comes a list of all the changed sections, including4376@ Just before the index comes a list of all the changed sections, including
4390the index section itself.4377the index section itself.
4391 4378
4392@<Global...@>=4379@<Private...@>=
4393sixteen_bits k_section; /* runs through the sections */4380static sixteen_bits k_section; /* runs through the sections */
4394 4381
4395@ @<Tell about changed sections@>= {4382@ @<Tell about changed sections@>= {
4396 /* remember that the index is already marked as changed */4383 /* remember that the index is already marked as changed */
@@ -4415,10 +4402,10 @@ letters, since we want to have `$t<\\{TeX}<\&{to}$'.) The · 18 unmodified lines
4415list for character |c| begins at location |bucket[c]| and continues through4402list for character |c| begins at location |bucket[c]| and continues through
4416the |blink| array.4403the |blink| array.
4417 4404
4418@<Global...@>=4405@<Private...@>=
4419name_pointer bucket[256];4406static name_pointer bucket[256];
4420name_pointer next_name; /* successor of |cur_name| when sorting */4407static name_pointer next_name; /* successor of |cur_name| when sorting */
4421name_pointer blink[max_names]; /* links in the buckets */4408static name_pointer blink[max_names]; /* links in the buckets */
4422 4409
4423@ To begin the sorting, we go through all the hash lists and put each entry4410@ To begin the sorting, we go through all the hash lists and put each entry
4424having a nonempty cross-reference list into the proper bucket.4411having a nonempty cross-reference list into the proper bucket.
@@ -4458,11 +4445,11 @@ name_pointer Head; · 33 unmodified lines
4458@d sort_ptr scrap_ptr /* ditto */4445@d sort_ptr scrap_ptr /* ditto */
4459@d max_sorts max_scraps /* ditto */4446@d max_sorts max_scraps /* ditto */
4460 4447
4461@<Global...@>=4448@<Private...@>=
4462eight_bits cur_depth; /* depth of current buckets */4449static eight_bits cur_depth; /* depth of current buckets */
4463char *cur_byte; /* index into |byte_mem| */4450static char *cur_byte; /* index into |byte_mem| */
4464sixteen_bits cur_val; /* current cross-reference number */4451static sixteen_bits cur_val; /* current cross-reference number */
4465sort_pointer max_sort_ptr; /* largest value of |sort_ptr| */4452static sort_pointer max_sort_ptr; /* largest value of |sort_ptr| */
4466 4453
4467@ @<Set init...@>=4454@ @<Set init...@>=
4468max_sort_ptr=scrap_info;4455max_sort_ptr=scrap_info;
@@ -4470,8 +4457,8 @@ max_sort_ptr=scrap_info; · 1 unmodified line
4470@ The desired alphabetic order is specified by the |collate| array; namely,4457@ The desired alphabetic order is specified by the |collate| array; namely,
4471$|collate|[0]<|collate|[1]<\cdots<|collate|[100]$.4458$|collate|[0]<|collate|[1]<\cdots<|collate|[100]$.
4472 4459
4473@<Global...@>=4460@<Private...@>=
4474eight_bits collate[101+128]; /* collation order */4461static eight_bits collate[101+128]; /* collation order */
4475@^high-bit character handling@>4462@^high-bit character handling@>
4476 4463
4477@ We use the order $\hbox{null}<\.\ <\hbox{other characters}<{}$\.\_${}<4464@ We use the order $\hbox{null}<\.\ <\hbox{other characters}<{}$\.\_${}<
@@ -4530,10 +4517,7 @@ regarded as identical. · 52 unmodified lines
4530 4517
4531@d infinity 255 /* $\infty$ (approximately) */4518@d infinity 255 /* $\infty$ (approximately) */
4532 4519
4533@<Predecl...@>=4520@c
4534static void unbucket(eight_bits);@/
4535
4536@ @c
4537static void4521static void
4538unbucket(@t\1\1@> /* empties buckets having depth |d| */4522unbucket(@t\1\1@> /* empties buckets having depth |d| */
4539eight_bits d@t\2\2@>)4523eight_bits d@t\2\2@>)
@@ -4551,6 +4535,8 @@ eight_bits d@t\2\2@>) · 11 unmodified lines
4551 }4535 }
4552}4536}
4553 4537
4538@ @<Predecl...@>=@+static void unbucket(eight_bits);
4539
4554@ @<Sort and output...@>=4540@ @<Sort and output...@>=
4555sort_ptr=scrap_info; unbucket(1);4541sort_ptr=scrap_info; unbucket(1);
4556while (sort_ptr>scrap_info) {4542while (sort_ptr>scrap_info) {
@@ -4635,8 +4621,8 @@ out('.'); finish_line(); · 78 unmodified lines
4635@ List inversion is best thought of as popping elements off one stack and4621@ List inversion is best thought of as popping elements off one stack and
4636pushing them onto another. In this case |cur_xref| will be the head of4622pushing them onto another. In this case |cur_xref| will be the head of
4637the stack that we push things onto.4623the stack that we push things onto.
4638@<Global...@>=4624@<Private...@>=
4639xref_pointer next_xref, this_xref;4625static xref_pointer next_xref, this_xref;
4640 /* pointer variables for rearranging a list */4626 /* pointer variables for rearranging a list */
4641 4627
4642@ @<Invert the cross-reference list at |cur_name|, making |cur_xref| the head@>=4628@ @<Invert the cross-reference list at |cur_name|, making |cur_xref| the head@>=
@@ -4650,10 +4636,7 @@ do { · 7 unmodified lines
4650prints them.4636prints them.
4651@^recursion@>4637@^recursion@>
4652 4638
4653@<Predecl...@>=4639@c
4654static void section_print(name_pointer);@/
4655
4656@ @c
4657static void4640static void
4658section_print(@t\1\1@> /* print all section names in subtree |p| */4641section_print(@t\1\1@> /* print all section names in subtree |p| */
4659name_pointer p@t\2\2@>)4642name_pointer p@t\2\2@>)
@@ -4670,6 +4653,8 @@ name_pointer p@t\2\2@>) · 10 unmodified lines
4670 }4653 }
4671}4654}
4672 4655
4656@ @<Predecl...@>=@+static void section_print(name_pointer);
4657
4673@ @<Output all the section names@>=section_print(root);4658@ @<Output all the section names@>=section_print(root);
4674 4659
4675@ Because on some systems the difference between two pointers is a |ptrdiff_t|4660@ Because on some systems the difference between two pointers is a |ptrdiff_t|
cwebmac.tex+2−2
@@ -1,7 +1,7 @@
1% standard macros for CWEB listings (in addition to plain.tex)1% standard macros for CWEB listings (in addition to plain.tex)
2% Version 4.1 --- February 20212% Version 4.2 --- February 2021
3\ifx\renewenvironment\undefined\else\endinput\fi % LaTeX will use other macros3\ifx\renewenvironment\undefined\else\endinput\fi % LaTeX will use other macros
4\xdef\fmtversion{\fmtversion+CWEB4.1}4\xdef\fmtversion{\fmtversion+CWEB4.2}
5\chardef\cwebversion=4 \chardef\cwebrevision=15\chardef\cwebversion=4 \chardef\cwebrevision=1
6\newif\ifpdf6\newif\ifpdf
7\ifx\pdf+\pdftrue\fi7\ifx\pdf+\pdftrue\fi
cwebman.tex+15−15
@@ -36,7 +36,7 @@ · 35 unmodified lines
36 36
37\def\lheader{\mainfont\the\pageno\hfill\sc\runninghead\hfill}37\def\lheader{\mainfont\the\pageno\hfill\sc\runninghead\hfill}
38\def\rheader{\hfill\sc\runninghead\hfill\mainfont\the\pageno}38\def\rheader{\hfill\sc\runninghead\hfill\mainfont\the\pageno}
39\def\runninghead{{\tentt CWEB} USER MANUAL (VERSION 4.1)}39\def\runninghead{{\tentt CWEB} USER MANUAL (VERSION 4.2)}
40 40
41% This verbatim mode assumes that ! marks are !! in the text being copied.41% This verbatim mode assumes that ! marks are !! in the text being copied.
42\def\verbatim{\begingroup42\def\verbatim{\begingroup
@@ -50,7 +50,7 @@ · 7 unmodified lines
50\null\vfill50\null\vfill
51\centerline{\titlefont The {\ttitlefont CWEB} System of51\centerline{\titlefont The {\ttitlefont CWEB} System of
52 Structured Documentation}52 Structured Documentation}
53\vskip 18pt\centerline{(Version 4.1 --- February 2021)}53\vskip 18pt\centerline{(Version 4.2 --- February 2021)}
54\vskip 24pt54\vskip 24pt
55\centerline{\authorfont Donald E. Knuth and Silvio Levy}55\centerline{\authorfont Donald E. Knuth and Silvio Levy}
56\vfill56\vfill
@@ -398,15 +398,15 @@ $$\hbox{ If \\{pa} is declared as `\&{int} ${}{*}\\{pa}$', · 341 unmodified lines
398the assignment $\\{pa}\K{\AND}\|a[\T{0}]$ makes \\{pa}398the assignment $\\{pa}\K{\AND}\|a[\T{0}]$ makes \\{pa}
399point to the zeroth element of \|a.}$$399point to the zeroth element of \|a.}$$
400The \TEX/ text would look like this in your \.{CWEB} file:400The \TEX/ text would look like this in your \.{CWEB} file:
401$$\lpile{\.{If |pa| is declared as `|int *pa|', the}\cr401$$\lpile{\.{If |pa| is declared as `|int *pa|', the assignment}\cr
402\.{assignment |pa=\&a[0]| makes |pa| point402\.{|pa=\&a[0]| makes |pa| point to the zeroth element of |a|.}\cr}$$
403to the zeroth element of |a|.}\cr}$$403And \.{CWEAVE} translates this into something
404And \.{CWEAVE} translates this into something you are glad you didn't have404you are glad you didn't have to type:
405to type:405$$\lpile{\.{If \\PB\{\\\\\{pa\}\} is declared as `\\PB\{\\\&\{int\}
406$$\lpile{\.{If \\\\\{pa\} is declared as406 \$\{\}\{*\}\\\\\{pa\}\$\}', the}\cr
407 `\\\&\{int\} \$\{\}\{*\}\\\\\{pa\}\$',}\cr407\.{assignment \\PB\{\$\\\\\{pa\}\\K\{\\AND\}\\|a[\\T\{0\}]\$\}
408\.{the assignment \$\\\\\{pa\}\\K\{\\AND\}\\|a[\\T\{0\}]\$}\cr408 makes \\PB\{\\\\\{pa\}\} point}\cr
409\.{makes \\\\\{pa\} point to the zeroth element of \\|a.}\cr}$$409\.{to the zeroth element of \\PB\{\\|a\}.}\cr}$$
410Incidentally, the cross-reference index that \.{CWEAVE} would make, in410Incidentally, the cross-reference index that \.{CWEAVE} would make, in
411the presence of a comment like this, would include411the presence of a comment like this, would include
412the current section number as one of the index entries for \\{pa},412the current section number as one of the index entries for \\{pa},
@@ -1011,7 +1011,7 @@ part of a \.{struct}, even though \CEE/ does allow this. · 598 unmodified lines
1011 1011
1012\section Running the programs.1012\section Running the programs.
1013The \UNIX/ command line for \.{CTANGLE} is1013The \UNIX/ command line for \.{CTANGLE} is
1014$$\.{ctangle [options] web\_file[.w] [\{change\_file[.ch]|-\} [out\_file]]}$$1014$$\.{ctangle [options] webfile[.w] [\{changefile[.ch]|-\} [outfile[.c]]]}$$
1015and the same conventions apply to \.{CWEAVE}. If `\.-' or no change file is1015and the same conventions apply to \.{CWEAVE}. If `\.-' or no change file is
1016specified, the change file is null. The extensions \.{.w} and \.{.ch}1016specified, the change file is null. The extensions \.{.w} and \.{.ch}
1017are appended only if the given file names contain no dot. If the1017are appended only if the given file names contain no dot. If the
@@ -1042,7 +1042,7 @@ by default.) · 24 unmodified lines
1042 1042
1043\option e Enclose \CEE/ material formatted by \.{CWEAVE} in1043\option e Enclose \CEE/ material formatted by \.{CWEAVE} in
1044brackets \.{\\PB\{...\}}, so that special hooks can be used.1044brackets \.{\\PB\{...\}}, so that special hooks can be used.
1045(Off by default; has no effect on \.{CTANGLE}.)1045(On by default; has no effect on \.{CTANGLE}.)
1046 1046
1047\option f Force line breaks after each \CEE/ statement formatted1047\option f Force line breaks after each \CEE/ statement formatted
1048by \.{CWEAVE}. (On by default; \.{-f} saves paper but looks less \CEE/-like1048by \.{CWEAVE}. (On by default; \.{-f} saves paper but looks less \CEE/-like
@@ -1336,7 +1336,7 @@ strncpy(change_buffer,buffer,(size_t)(limit-buffer+1)); · 287 unmodified lines
1336\def\runninghead{APPENDIX A --- TRANSLATION BY {\tentt CWEAVE}}1336\def\runninghead{APPENDIX A --- TRANSLATION BY {\tentt CWEAVE}}
1337 1337
1338Here is the corresponding excerpt from \.{common.tex}.1338Here is the corresponding excerpt from \.{common.tex}.
1339(Code for section 31 omitted for space reasons.)1339(Code for section 31 is omitted for space reasons.)
1340 1340
1341\vskip6pt1341\vskip6pt
1342\begingroup \def\tt{\eighttt} \baselineskip9pt1342\begingroup \def\tt{\eighttt} \baselineskip9pt
@@ -1591,7 +1591,7 @@ $$\lpile{\.{\\def\\topofcontents\{\\null\\vfill}\cr · 248 unmodified lines
1591 \.{ { }\\titlefalse \% include headline on the contents page}\cr1591 \.{ { }\\titlefalse \% include headline on the contents page}\cr
1592 \.{ { }\\def\\rheader\{\\mainfont The \{\\tt CWEAVE\}{ }processor\\hfil\}}\cr1592 \.{ { }\\def\\rheader\{\\mainfont The \{\\tt CWEAVE\}{ }processor\\hfil\}}\cr
1593 \.{ { }\\centerline\{\\titlefont The \{\\ttitlefont CWEAVE\}{ }processor\}}\cr1593 \.{ { }\\centerline\{\\titlefont The \{\\ttitlefont CWEAVE\}{ }processor\}}\cr
1594 \.{ { }\\vskip 15pt \\centerline\{(Version 4.1)\}{ }\\vfill\}}\cr}$$1594 \.{ { }\\vskip 15pt \\centerline\{(Version 4.2)\}{ }\\vfill\}}\cr}$$
1595Redefining \.{\\rheader}, which is the headline for right-hand pages,1595Redefining \.{\\rheader}, which is the headline for right-hand pages,
1596suffices in this case to put the desired information at the top of the1596suffices in this case to put the desired information at the top of the
1597contents page.1597contents page.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t