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 @@
11 # This file is part of CWEB.
22 # It is distributed WITHOUT ANY WARRANTY, express or implied.
3−# Version 4.1 --- February 2021
3+# Version 4.2 --- February 2021
44
55 # Copyright (C) 1987,1990,1993,2000 Silvio Levy and Donald E. Knuth
66
@@ -63,8 +63,10 @@ RM= /bin/rm · 56 unmodified lines
6363 CP= /bin/cp
6464
6565 # 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
6667 PDFTEX = dvipdfm
6768 #PDFTEX = pdftex
69+#PDFTEX = xetex
6870
6971 ########## You shouldn't have to change anything after this point #######
7072
@@ -105,6 +107,7 @@ ALL = common.w ctangle.w cweave.w prod.w \ · 34 unmodified lines
105107 case "$(PDFTEX)" in \
106108 dvipdfm ) tex "\let\pdf+ \input $*"; dvipdfm $* ;; \
107109 pdftex ) pdftex $* ;; \
110+ xetex ) xetex $* ;; \
108111 esac
109112
110113 all: ctangle cweave
README.md+2−2
@@ -1,4 +1,4 @@
1−# cweb 4.1
1+# cweb 4.2
22
33 people have been accumulating several decades of experience with
44 [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
1616 besides for further development, this ‘project’ is used as an – obviously
1717 incomplete – repository of original release versions of levy/knuth
1818 [cweb](http://www-cs-faculty.stanford.edu/~uno/cweb.html). you can either
19−compile these sources directly or stick the recent version “cweb-4.1” into my
19+compile these sources directly or stick the recent version “cweb-4.2” into my
2020 [cwebbin](https://github.com/ascherer/cwebbin), which introduces convenient
2121 extensions and prepares cweb for inclusion in the “tex live” distribution.
2222
comm-mac.ch+2−2
@@ -4,9 +4,9 @@ No changes to CTANGLE or CWEAVE are needed. · 3 unmodified lines
44 (Contributed 13 Oct 2000 by AndPio@aol.com; slightly edited by Don Knuth)
55
66 @x in limbo, change the title page document to specify Mac version
7− \centerline{(Version 4.1)}
7+ \centerline{(Version 4.2)}
88 @y
9− \centerline{(Version 4.1 for MacOS)}
9+ \centerline{(Version 4.2 for MacOS)}
1010 @z
1111
1212 @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
1010 @x
1111 \def\v{\char'174} % vertical (|) in typewriter font
1212
13−\def\title{Common code for CTANGLE and CWEAVE (Version 4.1)}
13+\def\title{Common code for CTANGLE and CWEAVE (Version 4.2)}
1414 \def\topofcontents{\null\vfill
1515 \centerline{\titlefont Common code for {\ttitlefont CTANGLE} and
1616 {\ttitlefont CWEAVE}}
1717 \vskip 15pt
18− \centerline{(Version 4.1)}
18+ \centerline{(Version 4.2)}
1919 \vfill}
2020 \def\botofcontents{\vfill
2121 \noindent
2222 @y
2323 \def\v{\char'174} % vertical (|) in typewriter font
2424
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)}
2626 \def\topofcontents{\null\vfill
2727 \centerline{\titlefont Common code for {\ttitlefont CTANGLE} and
2828 {\ttitlefont CWEAVE}}
2929 \vskip 15pt
30− \centerline{(Version 4.1)}
30+ \centerline{(Version 4.2)}
3131 \vfill}
3232 \def\botofcontents{\vfill
3333 \noindent
common.c+167−171
@@ -41,6 +41,15 @@ · 40 unmodified lines
4141 #define xisupper(c) (isupper((eight_bits) c) &&((eight_bits) c<0200) )
4242 #define xisxdigit(c) (isxdigit((eight_bits) c) &&((eight_bits) c<0200) ) \
4343
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+
4453 #define length(c) (size_t) ((c+1) ->byte_start-(c) ->byte_start)
4554 #define print_id(c) term_write((c) ->byte_start,length((c) ) )
4655 #define llink link
@@ -57,15 +66,6 @@ · 10 unmodified lines
5766 #define confusion(s) fatal("! This can't happen: ",s) \
5867 \
5968
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−
6969 #define show_banner flags['b']
7070 #define show_progress flags['p']
7171 #define show_stats flags['s']
@@ -149,7 +149,31 @@ extern char*loc; · 77 unmodified lines
149149 extern char*limit;
150150
151151 /*:5*//*6:*/
152−#line 102 "common.h"
152+#line 105 "common.h"
153+
154+extern int include_depth;
155+extern FILE*file[];
156+extern FILE*change_file;
157+extern char file_name[][max_file_name_length];
158+
159+extern char change_file_name[];
160+extern int line[];
161+extern int change_line;
162+extern int change_depth;
163+extern boolean input_has_ended;
164+extern boolean changing;
165+extern boolean web_file_open;
166+
167+/*:6*//*8:*/
168+#line 125 "common.h"
169+
170+extern sixteen_bits section_count;
171+extern boolean changed_section[];
172+extern boolean change_pending;
173+extern boolean print_where;
174+
175+/*:8*//*9:*/
176+#line 139 "common.h"
153177
154178 typedef struct name_info{
155179 char*byte_start;
@@ -173,44 +197,20 @@ extern name_pointer hash[]; · 17 unmodified lines
173197 extern hash_pointer hash_end;
174198 extern hash_pointer h;
175199
176−/*:6*//*8:*/
177−#line 146 "common.h"
200+/*:9*//*11:*/
201+#line 183 "common.h"
178202
179203 extern int history;
180204
181−/*:8*//*10:*/
182−#line 166 "common.h"
205+/*:11*//*13:*/
206+#line 199 "common.h"
183207
184−extern int include_depth;
185−extern FILE*file[];
186−extern FILE*change_file;
208+extern int argc;
209+extern char**argv;
187210 extern char C_file_name[];
188211 extern char tex_file_name[];
189212 extern char idx_file_name[];
190213 extern char scn_file_name[];
191−extern char file_name[][max_file_name_length];
192−
193−extern char change_file_name[];
194−extern int line[];
195−extern int change_line;
196−extern int change_depth;
197−extern boolean input_has_ended;
198−extern boolean changing;
199−extern boolean web_file_open;
200−
201−/*:10*//*12:*/
202−#line 190 "common.h"
203−
204−extern sixteen_bits section_count;
205−extern boolean changed_section[];
206−extern boolean change_pending;
207−extern boolean print_where;
208−
209−/*:12*//*13:*/
210−#line 203 "common.h"
211−
212−extern int argc;
213−extern char**argv;
214214 extern boolean flags[];
215215
216216 /*:13*//*14:*/
@@ -232,10 +232,11 @@ boolean program; · 15 unmodified lines
232232
233233 /*:18*//*19:*/
234234 #line 92 "common.w"
235+
235236 int phase;
236237
237238 /*:19*//*21:*/
238−#line 129 "common.w"
239+#line 130 "common.w"
239240
240241 char section_text[longest_name+1];
241242 char*section_text_end= section_text+longest_name;
@@ -243,12 +244,12 @@ char*id_first; · 1 unmodified line
243244 char*id_loc;
244245
245246 /*:21*//*22:*/
246−#line 149 "common.w"
247+#line 150 "common.w"
247248
248249 char buffer[long_buf_size];
249250 char*buffer_end= buffer+buf_size-2;
250−char*limit= buffer;
251251 char*loc= buffer;
252+char*limit= buffer;
252253
253254 /*:22*//*25:*/
254255 #line 194 "common.w"
@@ -259,7 +260,7 @@ FILE*change_file; · 4 unmodified lines
259260 char file_name[max_include_depth][max_file_name_length];
260261
261262 char change_file_name[max_file_name_length];
262−char alt_web_file_name[max_file_name_length];
263+static char alt_web_file_name[max_file_name_length];
263264 int line[max_include_depth];
264265 int change_line;
265266 int change_depth;
@@ -270,11 +271,11 @@ boolean web_file_open= false; · 4 unmodified lines
270271 /*:25*//*26:*/
271272 #line 220 "common.w"
272273
273−char change_buffer[buf_size];
274−char*change_limit;
274+static char change_buffer[buf_size];
275+static char*change_limit;
275276
276277 /*:26*//*37:*/
277−#line 401 "common.w"
278+#line 399 "common.w"
278279
279280 sixteen_bits section_count;
280281 boolean changed_section[max_sections];
@@ -283,7 +284,7 @@ boolean change_pending; · 2 unmodified lines
283284 boolean print_where= false;
284285
285286 /*:37*//*43:*/
286−#line 598 "common.w"
287+#line 596 "common.w"
287288
288289 char byte_mem[max_bytes];
289290 char*byte_mem_end= byte_mem+max_bytes-1;
@@ -291,25 +292,25 @@ name_info name_dir[max_names]; · 1 unmodified line
291292 name_pointer name_dir_end= name_dir+max_names-1;
292293
293294 /*:43*//*44:*/
294−#line 609 "common.w"
295+#line 607 "common.w"
295296
296−name_pointer name_ptr;
297297 char*byte_ptr;
298+name_pointer name_ptr;
298299
299300 /*:44*//*46:*/
300−#line 629 "common.w"
301+#line 627 "common.w"
301302
302303 name_pointer hash[hash_size];
303304 hash_pointer hash_end= hash+hash_size-1;
304305 hash_pointer h;
305306
306307 /*:46*//*65:*/
307−#line 1017 "common.w"
308+#line 1014 "common.w"
308309
309310 int history= spotless;
310311
311312 /*:65*//*73:*/
312−#line 1138 "common.w"
313+#line 1135 "common.w"
313314
314315 int argc;
315316 char**argv;
@@ -320,7 +321,7 @@ char scn_file_name[max_file_name_length]; · 4 unmodified lines
320321 boolean flags[128];
321322
322323 /*:73*//*83:*/
323−#line 1286 "common.w"
324+#line 1282 "common.w"
324325
325326 FILE*C_file;
326327 FILE*tex_file;
@@ -332,7 +333,14 @@ FILE*active_file; · 5 unmodified lines
332333 #line 70 "common.w"
333334
334335 /*7:*/
335−#line 125 "common.h"
336+#line 119 "common.h"
337+
338+extern boolean get_line(void);
339+extern void check_complete(void);
340+extern void reset_input(void);
341+
342+/*:7*//*10:*/
343+#line 162 "common.h"
336344
337345 extern boolean names_match(name_pointer,const char*,size_t,eight_bits);
338346 extern name_pointer id_lookup(const char*,const char*,char);
@@ -344,71 +352,59 @@ extern void print_prefix_name(name_pointer); · 5 unmodified lines
344352 extern void print_section_name(name_pointer);
345353 extern void sprint_section_name(char*,name_pointer);
346354
347−/*:7*//*9:*/
348−#line 149 "common.h"
355+/*:10*//*12:*/
356+#line 186 "common.h"
349357
350358 extern int wrap_up(void);
351359 extern void err_print(const char*);
352360 extern void fatal(const char*,const char*);
353361 extern void overflow(const char*);
354362
355−/*:9*//*11:*/
356−#line 184 "common.h"
357−
358−extern boolean get_line(void);
359−extern void check_complete(void);
360−extern void reset_input(void);
361−
362−/*:11*//*15:*/
363+/*:12*//*15:*/
363364 #line 223 "common.h"
364365
365366 extern void common_init(void);
366367 extern void print_stats(void);
367368
368−/*:15*//*23:*/
369−#line 159 "common.w"
370−
369+/*:15*//*24:*/
370+#line 180 "common.w"
371371 static boolean input_ln(FILE*);
372372
373−/*:23*//*27:*/
374−#line 231 "common.w"
375−
373+/*:24*//*28:*/
374+#line 241 "common.w"
376375 static void prime_the_change_buffer(void);
377376
378−/*:27*//*32:*/
379−#line 303 "common.w"
380−
377+/*:28*//*33:*/
378+#line 340 "common.w"
381379 static void check_change(void);
382380
383−/*:32*//*55:*/
384−#line 776 "common.w"
381+/*:33*//*55:*/
382+#line 774 "common.w"
385383
386384 static int web_strcmp(char*,int,char*,int);
387385 static name_pointer add_section_name(name_pointer,int,char*,char*,int);
388386 static void extend_section_name(name_pointer,char*,char*,int);
389387
390−/*:55*//*63:*/
391−#line 972 "common.w"
392−
388+/*:55*//*64:*/
389+#line 1002 "common.w"
393390 static int section_name_cmp(char**,int,name_pointer);
394391
395−/*:63*//*75:*/
396−#line 1170 "common.w"
397−
392+/*:64*//*76:*/
393+#line 1197 "common.w"
398394 static void scan_args(void);
399395
400−/*:75*/
396+/*:76*/
401397 #line 71 "common.w"
402398
403399
404400 /*:1*//*20:*/
405−#line 98 "common.w"
401+#line 99 "common.w"
406402
407403 void
408404 common_init(void)
409405 {
410406 /*45:*/
411−#line 613 "common.w"
407+#line 611 "common.w"
412408
413409 name_dir->byte_start= byte_ptr= byte_mem;
414410 name_ptr= name_dir+1;
@@ -416,24 +412,24 @@ name_ptr->byte_start= byte_mem; · 1 unmodified line
416412 root= NULL;
417413
418414 /*:45*//*47:*/
419−#line 636 "common.w"
415+#line 634 "common.w"
420416
421417 for(h= hash;h<=hash_end;*h++= NULL);
422418
423419 /*:47*/
424−#line 102 "common.w"
420+#line 103 "common.w"
425421
426422 /*74:*/
427−#line 1151 "common.w"
423+#line 1148 "common.w"
428424
429425 show_banner= show_happiness= show_progress= make_xrefs= true;
430426 show_stats= false;
431427
432428 /*:74*/
433−#line 103 "common.w"
429+#line 104 "common.w"
434430
435431 /*84:*/
436−#line 1293 "common.w"
432+#line 1289 "common.w"
437433
438434 scan_args();
439435 if(program==ctangle){
@@ -447,12 +443,12 @@ fatal("! Cannot open output file ",tex_file_name); · 7 unmodified lines
447443 }
448444
449445 /*:84*/
450−#line 104 "common.w"
446+#line 105 "common.w"
451447
452448 }
453449
454−/*:20*//*24:*/
455−#line 162 "common.w"
450+/*:20*//*23:*/
451+#line 160 "common.w"
456452
457453 static boolean input_ln(
458454 FILE*fp)
@@ -473,15 +469,15 @@ if(c==EOF&&limit==buffer)return false; · 14 unmodified lines
473469 return true;
474470 }
475471
476−/*:24*//*28:*/
477−#line 234 "common.w"
472+/*:23*//*27:*/
473+#line 231 "common.w"
478474
479475 static void
480476 prime_the_change_buffer(void)
481477 {
482478 change_limit= change_buffer;
483479 /*29:*/
484−#line 248 "common.w"
480+#line 247 "common.w"
485481
486482 while(true){
487483 change_line++;
@@ -498,10 +494,10 @@ err_print("! Missing @x in change file"); · 10 unmodified lines
498494 }
499495
500496 /*:29*/
501−#line 239 "common.w"
497+#line 236 "common.w"
502498
503499 /*30:*/
504−#line 265 "common.w"
500+#line 264 "common.w"
505501
506502 do{
507503 change_line++;
@@ -513,10 +509,10 @@ return; · 5 unmodified lines
513509 }while(limit==buffer);
514510
515511 /*:30*/
516−#line 240 "common.w"
512+#line 237 "common.w"
517513
518514 /*31:*/
519−#line 275 "common.w"
515+#line 274 "common.w"
520516
521517 {
522518 change_limit= change_buffer+(ptrdiff_t)(limit-buffer);
@@ -524,12 +520,12 @@ strncpy(change_buffer,buffer,(size_t)(limit-buffer+1)); · 1 unmodified line
524520 }
525521
526522 /*:31*/
527−#line 241 "common.w"
523+#line 238 "common.w"
528524
529525 }
530526
531−/*:28*//*33:*/
532−#line 306 "common.w"
527+/*:27*//*32:*/
528+#line 302 "common.w"
533529
534530 static void
535531 check_change(void)
@@ -552,7 +548,7 @@ return; · 16 unmodified lines
552548 if(limit> buffer+1&&buffer[0]=='@'){
553549 char xyz_code= xisupper(buffer[1])?tolower((eight_bits)buffer[1]):buffer[1];
554550 /*34:*/
555−#line 344 "common.w"
551+#line 342 "common.w"
556552
557553 if(xyz_code=='x'||xyz_code=='z'){
558554 loc= buffer+2;err_print("! Where is the matching @y?");
@@ -570,11 +566,11 @@ return; · 11 unmodified lines
570566 }
571567
572568 /*:34*/
573−#line 328 "common.w"
569+#line 324 "common.w"
574570
575571 }
576572 /*31:*/
577−#line 275 "common.w"
573+#line 274 "common.w"
578574
579575 {
580576 change_limit= change_buffer+(ptrdiff_t)(limit-buffer);
@@ -582,7 +578,7 @@ strncpy(change_buffer,buffer,(size_t)(limit-buffer+1)); · 1 unmodified line
582578 }
583579
584580 /*:31*/
585−#line 330 "common.w"
581+#line 326 "common.w"
586582
587583 changing= false;cur_line++;
588584 while(!input_ln(cur_file)){
@@ -597,15 +593,15 @@ if(lines_dont_match)n++; · 8 unmodified lines
597593 }
598594 }
599595
600−/*:33*//*35:*/
601−#line 364 "common.w"
596+/*:32*//*35:*/
597+#line 362 "common.w"
602598
603599 void
604600 reset_input(void)
605601 {
606602 limit= buffer;loc= buffer+1;buffer[0]= ' ';
607603 /*36:*/
608−#line 379 "common.w"
604+#line 377 "common.w"
609605
610606 if((web_file= fopen(web_file_name,"r"))==NULL){
611607 strcpy(web_file_name,alt_web_file_name);
@@ -619,7 +615,7 @@ if((change_file= fopen(change_file_name,"r"))==NULL) · 7 unmodified lines
619615 fatal("! Cannot open change file ",change_file_name);
620616
621617 /*:36*/
622−#line 369 "common.w"
618+#line 367 "common.w"
623619
624620 include_depth= 0;cur_line= 0;change_line= 0;
625621 change_depth= include_depth;
@@ -628,14 +624,14 @@ limit= buffer;loc= buffer+1;buffer[0]= ' ';input_has_ended= false; · 2 unmodified lines
628624 }
629625
630626 /*:35*//*38:*/
631−#line 408 "common.w"
627+#line 406 "common.w"
632628
633629 boolean get_line(void)
634630 {
635631 restart:
636632 if(changing&&include_depth==change_depth)
637633 /*41:*/
638−#line 516 "common.w"
634+#line 514 "common.w"
639635 {
640636 change_line++;
641637 if(!input_ln(change_file)){
@@ -666,11 +662,11 @@ prime_the_change_buffer();changing= !changing;print_where= true; · 24 unmodified lines
666662 }
667663
668664 /*:41*/
669−#line 413 "common.w"
665+#line 411 "common.w"
670666
671667 if(!changing||include_depth> change_depth){
672668 /*40:*/
673−#line 499 "common.w"
669+#line 497 "common.w"
674670 {
675671 cur_line++;
676672 while(!input_ln(cur_file)){
@@ -689,7 +685,7 @@ if(change_limit> change_buffer)check_change(); · 12 unmodified lines
689685 }
690686
691687 /*:40*/
692−#line 415 "common.w"
688+#line 413 "common.w"
693689
694690 if(changing&&include_depth==change_depth)goto restart;
695691 }
@@ -710,7 +706,7 @@ goto restart; · 14 unmodified lines
710706 }
711707 include_depth++;
712708 /*39:*/
713−#line 453 "common.w"
709+#line 451 "common.w"
714710 {
715711 char temp_file_name[max_file_name_length];
716712 char*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
758754 }
759755
760756 /*:39*/
761−#line 434 "common.w"
757+#line 432 "common.w"
762758
763759 }
764760 return true;
765761 }
766762
767763 /*:38*//*42:*/
768−#line 548 "common.w"
764+#line 546 "common.w"
769765
770766 void
771767 check_complete(void){
@@ -779,7 +775,7 @@ err_print("! Change file entry did not match"); · 7 unmodified lines
779775 }
780776
781777 /*:42*//*48:*/
782−#line 641 "common.w"
778+#line 639 "common.w"
783779
784780 name_pointer
785781 id_lookup(
@@ -794,17 +790,17 @@ name_pointer p; · 8 unmodified lines
794790 if(last==NULL)for(last= first;*last!='\0';last++);
795791 l= (int)(last-first);
796792 /*49:*/
797−#line 664 "common.w"
793+#line 662 "common.w"
798794
799795 h= (eight_bits)*i;
800796 while(++i<last)h= (h+h+(int)((eight_bits)*i))%hash_size;
801797
802798
803799 /*:49*/
804−#line 654 "common.w"
800+#line 652 "common.w"
805801
806802 /*50:*/
807−#line 672 "common.w"
803+#line 670 "common.w"
808804
809805 p= hash[h];
810806 while(p&&!names_match(p,first,l,t))p= p->link;
@@ -814,10 +810,10 @@ p->link= hash[h];hash[h]= p; · 3 unmodified lines
814810 }
815811
816812 /*:50*/
817−#line 655 "common.w"
813+#line 653 "common.w"
818814
819815 if(p==name_ptr)/*51:*/
820−#line 683 "common.w"
816+#line 681 "common.w"
821817 {
822818 if(byte_ptr+l> byte_mem_end)overflow("byte memory");
823819 if(name_ptr>=name_dir_end)overflow("name");
@@ -827,13 +823,13 @@ init_p(p,t); · 3 unmodified lines
827823 }
828824
829825 /*:51*/
830−#line 656 "common.w"
826+#line 654 "common.w"
831827
832828 return p;
833829 }
834830
835831 /*:48*//*52:*/
836−#line 715 "common.w"
832+#line 713 "common.w"
837833
838834 void
839835 print_section_name(
@@ -854,7 +850,7 @@ if(q)term_write("...",3); · 14 unmodified lines
854850 }
855851
856852 /*:52*//*53:*/
857−#line 734 "common.w"
853+#line 732 "common.w"
858854
859855 void
860856 sprint_section_name(
@@ -877,7 +873,7 @@ s= p->byte_start; · 16 unmodified lines
877873 }
878874
879875 /*:53*//*54:*/
880−#line 755 "common.w"
876+#line 753 "common.w"
881877
882878 void
883879 print_prefix_name(
@@ -890,7 +886,7 @@ if(s+l<(p+1)->byte_start)term_write("...",3); · 6 unmodified lines
890886 }
891887
892888 /*:54*//*56:*/
893−#line 781 "common.w"
889+#line 779 "common.w"
894890
895891 static int web_strcmp(
896892 char*j,
@@ -908,7 +904,7 @@ else return greater; · 11 unmodified lines
908904 }
909905
910906 /*:56*//*57:*/
911−#line 810 "common.w"
907+#line 808 "common.w"
912908
913909 static name_pointer
914910 add_section_name(
@@ -939,7 +935,7 @@ return par==NULL?(root= p):c==less?(par->llink= p):(par->rlink= p); · 24 unmodified lines
939935 }
940936
941937 /*:57*//*58:*/
942−#line 839 "common.w"
938+#line 837 "common.w"
943939
944940 static void
945941 extend_section_name(
@@ -963,7 +959,7 @@ if(ispref)*(byte_ptr-1)= ' '; · 17 unmodified lines
963959 }
964960
965961 /*:58*//*59:*/
966−#line 867 "common.w"
962+#line 865 "common.w"
967963
968964 name_pointer
969965 section_lookup(
@@ -978,7 +974,7 @@ name_pointer par= NULL; · 8 unmodified lines
978974
979975 int name_len= (int)(last-first)+1;
980976 /*60:*/
981−#line 891 "common.w"
977+#line 889 "common.w"
982978
983979 while(p){
984980 c= web_strcmp(first,name_len,first_chunk(p),prefix_length(p));
@@ -1005,19 +1001,19 @@ p= q,q= NULL; · 20 unmodified lines
10051001 }
10061002
10071003 /*:60*/
1008−#line 881 "common.w"
1004+#line 879 "common.w"
10091005
10101006 /*61:*/
1011−#line 916 "common.w"
1007+#line 914 "common.w"
10121008
10131009 if(r==NULL)
10141010 return add_section_name(par,c,first,last+1,ispref);
10151011
10161012 /*:61*/
1017−#line 882 "common.w"
1013+#line 880 "common.w"
10181014
10191015 /*62:*/
1020−#line 924 "common.w"
1016+#line 922 "common.w"
10211017
10221018 switch(section_name_cmp(&first,name_len,r)){
10231019
@@ -1051,12 +1047,12 @@ return r; · 27 unmodified lines
10511047 }
10521048
10531049 /*:62*/
1054−#line 883 "common.w"
1050+#line 881 "common.w"
10551051
10561052 }
10571053
1058−/*:59*//*64:*/
1059−#line 975 "common.w"
1054+/*:59*//*63:*/
1055+#line 970 "common.w"
10601056
10611057 static int section_name_cmp(
10621058 char**pfirst,
@@ -1089,8 +1085,8 @@ default:return c; · 26 unmodified lines
10891085 }
10901086 }
10911087
1092−/*:64*//*66:*/
1093−#line 1027 "common.w"
1088+/*:63*//*66:*/
1089+#line 1024 "common.w"
10941090
10951091 void
10961092 err_print(
@@ -1099,7 +1095,7 @@ const char*s) · 2 unmodified lines
10991095 char*k,*l;
11001096 printf(*s=='!'?"\n%s":"%s",s);
11011097 if(web_file_open)/*67:*/
1102−#line 1047 "common.w"
1098+#line 1044 "common.w"
11031099
11041100 {if(changing&&include_depth==change_depth)
11051101 printf(". (l. %d of change file)\n",change_line);
@@ -1119,20 +1115,20 @@ putchar(' '); · 13 unmodified lines
11191115 }
11201116
11211117 /*:67*/
1122−#line 1034 "common.w"
1118+#line 1031 "common.w"
11231119
11241120 update_terminal;mark_error;
11251121 }
11261122
11271123 /*:66*//*68:*/
1128−#line 1079 "common.w"
1124+#line 1076 "common.w"
11291125
11301126 int wrap_up(void){
11311127 if(show_progress)new_line;
11321128 if(show_stats)
11331129 print_stats();
11341130 /*69:*/
1135−#line 1089 "common.w"
1131+#line 1086 "common.w"
11361132
11371133 switch(history){
11381134 case 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
11441140 }
11451141
11461142 /*:69*/
1147−#line 1084 "common.w"
1143+#line 1081 "common.w"
11481144
11491145 if(history> harmless_message)return EXIT_FAILURE;
11501146 else return EXIT_SUCCESS;
11511147 }
11521148
11531149 /*:68*//*70:*/
1154−#line 1105 "common.w"
1150+#line 1102 "common.w"
11551151 void
11561152 fatal(
11571153 const char*s,const char*t)
@@ -1162,7 +1158,7 @@ history= fatal_message;exit(wrap_up()); · 4 unmodified lines
11621158 }
11631159
11641160 /*:70*//*71:*/
1165−#line 1116 "common.w"
1161+#line 1113 "common.w"
11661162 void
11671163 overflow(
11681164 const char*t)
@@ -1171,8 +1167,8 @@ printf("\n! Sorry, %s capacity exceeded",t);fatal("",""); · 2 unmodified lines
11711167 }
11721168
11731169
1174−/*:71*//*76:*/
1175−#line 1173 "common.w"
1170+/*:71*//*75:*/
1171+#line 1167 "common.w"
11761172
11771173 static void
11781174 scan_args(void)
@@ -1186,7 +1182,7 @@ boolean found_web= false,found_change= false,found_out= false; · 7 unmodified lines
11861182 strcpy(change_file_name,"/dev/null");
11871183 while(--argc> 0){
11881184 if((**(++argv)=='-'||**argv=='+')&&*(*argv+1))/*80:*/
1189−#line 1262 "common.w"
1185+#line 1258 "common.w"
11901186
11911187 {
11921188 for(dot_pos= *argv+1;*dot_pos> '\0';dot_pos++)
@@ -1194,7 +1190,7 @@ flags[(eight_bits)*dot_pos]= flag_change; · 1 unmodified line
11941190 }
11951191
11961192 /*:80*/
1197−#line 1185 "common.w"
1193+#line 1179 "common.w"
11981194
11991195 else{
12001196 s= name_pos= *argv;dot_pos= NULL;
@@ -1204,17 +1200,17 @@ else if(*s=='/')dot_pos= NULL,name_pos= ++s; · 3 unmodified lines
12041200 else s++;
12051201 }
12061202 if(!found_web)/*77:*/
1207−#line 1210 "common.w"
1203+#line 1206 "common.w"
12081204
12091205 {
12101206 if(s-*argv> max_file_name_length-5)
12111207 /*82:*/
1212−#line 1280 "common.w"
1208+#line 1276 "common.w"
12131209 fatal("! Filename too long\n",*argv);
12141210
12151211
12161212 /*:82*/
1217−#line 1213 "common.w"
1213+#line 1209 "common.w"
12181214
12191215 if(dot_pos==NULL)
12201216 sprintf(web_file_name,"%s.w",*argv);
@@ -1231,21 +1227,21 @@ found_web= true; · 10 unmodified lines
12311227 }
12321228
12331229 /*:77*/
1234−#line 1194 "common.w"
1230+#line 1188 "common.w"
12351231
12361232 else if(!found_change)/*78:*/
1237−#line 1228 "common.w"
1233+#line 1224 "common.w"
12381234
12391235 {
12401236 if(strcmp(*argv,"-")!=0){
12411237 if(s-*argv> max_file_name_length-4)
12421238 /*82:*/
1243−#line 1280 "common.w"
1239+#line 1276 "common.w"
12441240 fatal("! Filename too long\n",*argv);
12451241
12461242
12471243 /*:82*/
1248−#line 1232 "common.w"
1244+#line 1228 "common.w"
12491245
12501246 if(dot_pos==NULL)
12511247 sprintf(change_file_name,"%s.ch",*argv);
@@ -1255,20 +1251,20 @@ found_change= true; · 3 unmodified lines
12551251 }
12561252
12571253 /*:78*/
1258−#line 1195 "common.w"
1254+#line 1189 "common.w"
12591255
12601256 else if(!found_out)/*79:*/
1261−#line 1240 "common.w"
1257+#line 1236 "common.w"
12621258
12631259 {
12641260 if(s-*argv> max_file_name_length-5)
12651261 /*82:*/
1266−#line 1280 "common.w"
1262+#line 1276 "common.w"
12671263 fatal("! Filename too long\n",*argv);
12681264
12691265
12701266 /*:82*/
1271−#line 1243 "common.w"
1267+#line 1239 "common.w"
12721268
12731269 if(dot_pos==NULL){
12741270 sprintf(tex_file_name,"%s.tex",*argv);
@@ -1288,10 +1284,10 @@ found_out= true; · 13 unmodified lines
12881284 }
12891285
12901286 /*:79*/
1291−#line 1196 "common.w"
1287+#line 1190 "common.w"
12921288
12931289 else/*81:*/
1294−#line 1268 "common.w"
1290+#line 1264 "common.w"
12951291
12961292 {
12971293 if(program==ctangle)
@@ -1305,12 +1301,12 @@ else fatal( · 7 unmodified lines
13051301 }
13061302
13071303 /*:81*/
1308−#line 1197 "common.w"
1304+#line 1191 "common.w"
13091305
13101306 }
13111307 }
13121308 if(!found_web)/*81:*/
1313−#line 1268 "common.w"
1309+#line 1264 "common.w"
13141310
13151311 {
13161312 if(program==ctangle)
@@ -1324,8 +1320,8 @@ else fatal( · 7 unmodified lines
13241320 }
13251321
13261322 /*:81*/
1327−#line 1200 "common.w"
1323+#line 1194 "common.w"
13281324
13291325 }
13301326
1331−/*:76*/
1327+/*:75*/
common.h+45−45
@@ -2,7 +2,7 @@ · 1 unmodified line
22 % This program by Silvio Levy and Donald E. Knuth
33 % is based on a program by Knuth.
44 % 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)
66
77 % Copyright (C) 1987,1990,1993 Silvio Levy and Donald E. Knuth
88
@@ -91,6 +91,43 @@ extern char *buffer_end; /* end of |buffer| */ · 82 unmodified lines
9191 extern char *loc; /* points to the next character to be read from the buffer */
9292 extern char *limit; /* points to the last character in the buffer */
9393
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...@>=
106+extern int include_depth; /* current level of nesting */
107+extern FILE *file[]; /* stack of non-change files */
108+extern FILE *change_file; /* change file */
109+extern char file_name[][max_file_name_length];
110+ /* stack of non-change file names */
111+extern char change_file_name[]; /* name of change file */
112+extern int line[]; /* number of current line in the stacked files */
113+extern int change_line; /* number of current line in change file */
114+extern int change_depth; /* where \.{@@y} originated during a change */
115+extern boolean input_has_ended; /* if there is no more input */
116+extern boolean changing; /* if the current line is from |change_file| */
117+extern boolean web_file_open; /* if the web file is being read */
118+
119+@ @<Predecl...@>=
120+extern boolean get_line(void); /* inputs the next line */
121+extern void check_complete(void); /* checks that all changes were picked up */
122+extern void reset_input(void); /* initialize to read the web file and change file */
123+
124+@ Code related to section numbers:
125+@<Common code...@>=
126+extern sixteen_bits section_count; /* the current section number */
127+extern boolean changed_section[]; /* is the section changed? */
128+extern boolean change_pending; /* is a decision about change still unclear? */
129+extern boolean print_where; /* tells \.{CTANGLE} to print line and file info */
130+
94131 @ Code related to identifier and section name storage:
95132 @d length(c) (size_t)((c+1)->byte_start-(c)->byte_start) /* the length of a name */
96133 @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
131168 extern void init_p(name_pointer,eight_bits);@/
132169 extern void print_prefix_name(name_pointer);@/
133170 extern void print_section_name(name_pointer);@/
134−extern void sprint_section_name(char *,name_pointer);@/
171+extern void sprint_section_name(char *,name_pointer);
135172
136173 @ Code related to error handling:
137174 @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
152189 extern void fatal(const char *,const char *); /* issue error message and die */
153190 extern void overflow(const char *); /* succumb because a table has overflowed */
154191
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...@>=
167−extern int include_depth; /* current level of nesting */
168−extern FILE *file[]; /* stack of non-change files */
169−extern FILE *change_file; /* change file */
170−extern char C_file_name[]; /* name of |C_file| */
171−extern char tex_file_name[]; /* name of |tex_file| */
172−extern char idx_file_name[]; /* name of |idx_file| */
173−extern char scn_file_name[]; /* name of |scn_file| */
174−extern char file_name[][max_file_name_length];
175− /* stack of non-change file names */
176−extern char change_file_name[]; /* name of change file */
177−extern int line[]; /* number of current line in the stacked files */
178−extern int change_line; /* number of current line in change file */
179−extern int change_depth; /* where \.{@@y} originated during a change */
180−extern boolean input_has_ended; /* if there is no more input */
181−extern boolean changing; /* if the current line is from |change_file| */
182−extern boolean web_file_open; /* if the web file is being read */
183−
184−@ @<Predecl...@>=
185−extern boolean get_line(void); /* inputs the next line */
186−extern void check_complete(void); /* checks that all changes were picked up */
187−extern void reset_input(void); /* initialize to read the web file and change file */
188−
189−@ Code related to section numbers:
190−@<Common code...@>=
191−extern sixteen_bits section_count; /* the current section number */
192−extern boolean changed_section[]; /* is the section changed? */
193−extern boolean change_pending; /* is a decision about change still unclear? */
194−extern boolean print_where; /* tells \.{CTANGLE} to print line and file info */
195−
196192 @ Code related to command line arguments:
197193 @d show_banner flags['b'] /* should the banner line be printed? */
198194 @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
203199 @<Common code...@>=
204200 extern int argc; /* copy of |ac| parameter to |main| */
205201 extern char **argv; /* copy of |av| parameter to |main| */
202+extern char C_file_name[]; /* name of |C_file| */
203+extern char tex_file_name[]; /* name of |tex_file| */
204+extern char idx_file_name[]; /* name of |idx_file| */
205+extern char scn_file_name[]; /* name of |scn_file| */
206206 extern boolean flags[]; /* an option for each 7-bit code */
207207
208−@ Code relating to output:
208+@ Code related to output:
209209 @d update_terminal fflush(stdout) /* empty the terminal output buffer */
210210 @d new_line putchar('\n') @d putxchar putchar
211211 @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
222222 @ The procedure that gets everything rolling:
223223 @<Predecl...@>=
224224 extern void common_init(void);@/
225−extern void print_stats(void);@/
225+extern void print_stats(void);
226226
227227 @ The following parameters were sufficient in the original \.{WEB} to
228228 handle \TEX/, so they should be sufficient for most applications of
common.w+29−33
@@ -2,7 +2,7 @@ · 1 unmodified line
22 % This program by Silvio Levy and Donald E. Knuth
33 % is based on a program by Knuth.
44 % It is distributed WITHOUT ANY WARRANTY, express or implied.
5−% Version 4.1 --- February 2021
5+% Version 4.2 --- February 2021
66
77 % Copyright (C) 1987,1990,1993,2000 Silvio Levy and Donald E. Knuth
88
@@ -22,12 +22,12 @@ · 13 unmodified lines
2222
2323 \def\v{\char'174} % vertical (|) in typewriter font
2424
25−\def\title{Common code for CTANGLE and CWEAVE (Version 4.1)}
25+\def\title{Common code for CTANGLE and CWEAVE (Version 4.2)}
2626 \def\topofcontents{\null\vfill
2727 \centerline{\titlefont Common code for {\ttitlefont CTANGLE} and
2828 {\ttitlefont CWEAVE}}
2929 \vskip 15pt
30− \centerline{(Version 4.1)}
30+ \centerline{(Version 4.2)}
3131 \vfill}
3232 \def\botofcontents{\vfill
3333 \noindent
@@ -68,7 +68,7 @@ The file begins with a few basic definitions. · 34 unmodified lines
6868 @h
6969 @<Common code for \.{CWEAVE} and \.{CTANGLE}@>@/
7070 @<Global variables@>@/
71−@<Predeclaration of procedures@>@/
71+@<Predeclaration of procedures@>
7272
7373 @ The details will be filled in due course. The interface of this module
7474 is 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
8989 Similarly, \.{CTANGLE} operates in two phases.
9090 The global variable |phase| tells which phase we are in.
9191
92−@<Global var...@>= int phase; /* which phase are we in? */
92+@<Global var...@>=
93+int phase; /* which phase are we in? */
9394
9495 @ There's an initialization procedure that gets both \.{CTANGLE} and
9596 \.{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
149150 @<Global var...@>=
150151 char buffer[long_buf_size]; /* where each line of input goes */
151152 char *buffer_end=buffer+buf_size-2; /* end of |buffer| */
152−char *limit=buffer; /* points to the last character in the buffer */
153153 char *loc=buffer; /* points to the next character to be read from the buffer */
154+char *limit=buffer; /* points to the last character in the buffer */
154155
155156 @ In the unlikely event that your standard I/O library does not
156157 support |feof|, |getc|, and |ungetc| you may have to change things here.
157158 @^system dependencies@>
158159
159−@<Predecl...@>=
160−static boolean input_ln(FILE *);@/
161−
162−@ @c
160+@c
163161 static boolean input_ln(@t\1\1@> /* copies a line into |buffer| or returns |false| */
164162 FILE *fp@t\2\2@>) /* what file to read from */
165163 {
@@ -179,6 +177,8 @@ FILE *fp@t\2\2@>) /* what file to read from */ · 13 unmodified lines
179177 return true;
180178 }
181179
180+@ @<Predecl...@>=@+static boolean input_ln(FILE *);
181+
182182 @ Now comes the problem of deciding which file to read from next.
183183 Recall that the actual text that \.{CWEB} should process comes from two
184184 streams: a |web_file|, which can contain possibly nested include
@@ -198,7 +198,7 @@ FILE *change_file; /* change file */ · 13 unmodified lines
198198 char file_name[max_include_depth][max_file_name_length];
199199 /* stack of non-change file names */
200200 char change_file_name[max_file_name_length]; /* name of change file */
201−char alt_web_file_name[max_file_name_length]; /* alternate name to try */
201+static char alt_web_file_name[max_file_name_length]; /* alternate name to try */
202202 int line[max_include_depth]; /* number of current line in the stacked files */
203203 int change_line; /* number of current line in change file */
204204 int 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
218218 strncmp(buffer, change_buffer, (size_t)(limit-buffer)))
219219
220220 @<Global var...@>=
221−char change_buffer[buf_size]; /* next line of |change_file| */
222−char *change_limit; /* points to the last character in |change_buffer| */
221+static char change_buffer[buf_size]; /* next line of |change_file| */
222+static char *change_limit; /* points to the last character in |change_buffer| */
223223
224224 @ Procedure |prime_the_change_buffer|
225225 sets |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
228228 the change file is exhausted. This procedure is called only when
229229 |changing| is |true|; hence error messages will be reported correctly.
230230
231−@<Predecl...@>=
232−static void prime_the_change_buffer(void);@/
233−
234−@ @c
231+@c
235232 static void
236233 prime_the_change_buffer(void)
237234 {
@@ -241,6 +238,8 @@ prime_the_change_buffer(void) · 3 unmodified lines
241238 @<Move |buffer| and |limit| to |change_buffer| and |change_limit|@>@;
242239 }
243240
241+@ @<Predecl...@>=@+static void prime_the_change_buffer(void);
242+
244243 @ While looking for a line that begins with \.{@@x} in the change file, we
245244 allow lines that begin with \.{@@}, as long as they don't begin with \.{@@y},
246245 \.{@@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
289288
290289 When a match is found, the current section is marked as changed unless
291290 the first line after the \.{@@x} and after the \.{@@y} both start with
292−either |'@@*'| or |'@@ '| (possibly preceded by whitespace).
291+either `\.{@@*}' or `\.{@@\ }' (possibly preceded by whitespace).
293292
294293 This procedure is called only when |buffer<limit|, i.e., when the
295294 current line is nonempty.
@@ -300,10 +299,7 @@ current line is nonempty. · 4 unmodified lines
300299 if (*loc=='@@' && (xisspace(*(loc+1)) || *(loc+1)=='*')) change_pending=b;
301300 }
302301
303−@<Predecl...@>=
304−static void check_change(void);@/
305−
306−@ @c
302+@c
307303 static void
308304 check_change(void) /* switches to |change_file| if the buffers match */
309305 {
@@ -341,6 +337,8 @@ check_change(void) /* switches to |change_file| if the buffers match */ · 31 unmodified lines
341337 }
342338 }
343339
340+@ @<Predecl...@>=@+static void check_change(void);
341+
344342 @ @<If the current line starts with \.{@@y}...@>=
345343 if (xyz_code=='x' || xyz_code=='z') {
346344 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
607605 we want to keep |name_ptr<=name_dir_end| and |byte_ptr<=byte_mem_end|.
608606
609607 @<Global var...@>=
610−name_pointer name_ptr; /* first unused position in |name_dir| */
611608 char *byte_ptr; /* first unused position in |byte_mem| */
609+name_pointer name_ptr; /* first unused position in |name_dir| */
612610
613611 @ @<Init...@>=
614612 name_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
776774 @<Predecl...@>=
777775 static int web_strcmp(char *,int,char *,int);@/
778776 static name_pointer add_section_name(name_pointer,int,char *,char *,int);@/
779−static void extend_section_name(name_pointer,char *,char *,int);@/
777+static void extend_section_name(name_pointer,char *,char *,int);
780778
781779 @ @c
782780 static 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
969967
970968 @d bad_extension 5
971969
972−@<Predec...@>=
973−static int section_name_cmp(char **,int,name_pointer);@/
974−
975−@ @c
970+@c
976971 static int section_name_cmp(@t\1\1@>
977972 char **pfirst, /* pointer to beginning of comparison string */
978973 int len, /* length of string */
@@ -1004,6 +999,8 @@ name_pointer r@t\2\2@>) /* section name being compared */ · 25 unmodified lines
1004999 }
10051000 }
10061001
1002+@ @<Predec...@>=@+static int section_name_cmp(char **,int,name_pointer);
1003+
10071004 @** Reporting errors to the user.
10081005 A global variable called |history| will contain one of four values
10091006 at 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
11501147
11511148 @<Set the default options common to \.{CTANGLE} and \.{CWEAVE}@>=
11521149 show_banner=show_happiness=show_progress=make_xrefs=true;@/
1153−show_stats=false;@/
1150+show_stats=false;
11541151
11551152 @ We now must look at the command line arguments and set the file names
11561153 accordingly. At least one file name must be present: the \.{CWEB}
@@ -1167,10 +1164,7 @@ when no changes are desired. · 10 unmodified lines
11671164
11681165 If there's a third file name, it will be the output file.
11691166
1170−@<Pred...@>=
1171−static void scan_args(void);@/
1172−
1173−@ @c
1167+@c
11741168 static void
11751169 scan_args(void)
11761170 {
@@ -1200,6 +1194,8 @@ scan_args(void) · 23 unmodified lines
12001194 if (!found_web) @<Print usage error message and quit@>@;
12011195 }
12021196
1197+@ @<Pred...@>=@+static void scan_args(void);
1198+
12031199 @ We use all of |*argv| for the |web_file_name| if there is a |'.'| in it,
12041200 otherwise we add |".w"|. If this file can't be opened, we prepare an
12051201 |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
1717 The ``banner line'' defined here should be changed whenever \.{CTANGLE}
1818 is modified.
1919
20−@d banner "This is CTANGLE (Version 4.1)"
20+@d banner "This is CTANGLE (Version 4.2)"
2121 @y
2222 The ``banner line'' defined here should be changed whenever \.{CTANGLE}
2323 is modified.
2424
25−@d banner "This is CTANGLE (Version 4.1pc/big)"
25+@d banner "This is CTANGLE (Version 4.2pc/big)"
2626 @z
2727
2828
@@ -141,13 +141,13 @@ typedef text *text_pointer; · 112 unmodified lines
141141
142142
143143 @x Section 17.
144−eight_bits tok_mem[max_toks];
145−eight_bits *tok_mem_end=tok_mem+max_toks-1;
146−eight_bits *tok_ptr; /* first unused position in |tok_mem| */
144+static eight_bits tok_mem[max_toks];
145+static eight_bits *tok_mem_end=tok_mem+max_toks-1;
146+static eight_bits *tok_ptr; /* first unused position in |tok_mem| */
147147 @y
148−eight_bits huge tok_mem[max_toks];
149−eight_bits huge* tok_mem_end;
150−eight_bits huge* tok_ptr; /* first unused position in |tok_mem| */
148+static eight_bits huge tok_mem[max_toks];
149+static eight_bits huge* tok_mem_end;
150+static eight_bits huge* tok_ptr; /* first unused position in |tok_mem| */
151151 @z
152152
153153
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
99 alternate change files with -bs suffix instead of -pc.
1010
1111 @x section 1
12−@d banner "This is CTANGLE (Version 4.1)"
12+@d banner "This is CTANGLE (Version 4.2)"
1313 @y
14−@d banner "This is CTANGLE (Version 4.1pc)"
14+@d banner "This is CTANGLE (Version 4.2pc)"
1515 @z
1616 @x section 4
1717 @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
77
88
99 @x
10−\def\title{CTANGLE (Version 4.1)}
10+\def\title{CTANGLE (Version 4.2)}
1111 @y
12−\def\title{CTANGLE (QL Version 4.1)}
12+\def\title{CTANGLE (QL Version 4.2)}
1313 @z
1414
1515 @x section 1
16−@d banner "This is CTANGLE (Version 4.1)"
16+@d banner "This is CTANGLE (Version 4.2)"
1717 @y
18−@d banner "This is CTANGLE (QL Version 4.1)"
18+@d banner "This is CTANGLE (QL Version 4.2)"
1919 @z
2020
2121 @x
ctang-vms.ch+2−2
@@ -10,9 +10,9 @@ created: · 9 unmodified lines
1010 (these changes not necessary for initial bootstrapping)
1111
1212 @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)"
1414 @y
15−@d banner "This is CTANGLE (VAX/VMS Version 4.1)"
15+@d banner "This is CTANGLE (VAX/VMS Version 4.2)"
1616 @z
1717
1818 @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
44 Changes necessary for compiling with Borland C/C++
55
66 @x section 1
7−@d banner "This is CTANGLE (Version 4.1)"
7+@d banner "This is CTANGLE (Version 4.2)"
88 @y
9−@d banner "This is CTANGLE (Version 4.1win32)"
9+@d banner "This is CTANGLE (Version 4.2win32)"
1010 @z
1111
1212 @x
ctangle.c+216−225
@@ -15,7 +15,7 @@ · 14 unmodified lines
1515 /*:4*/
1616 #line 67 "ctangle.w"
1717
18−#define banner "This is CTANGLE (Version 4.1)" \
18+#define banner "This is CTANGLE (Version 4.2)" \
1919
2020 #define ctangle false
2121 #define cweave true \
@@ -43,6 +43,15 @@ · 21 unmodified lines
4343 #define xisupper(c) (isupper((eight_bits) c) &&((eight_bits) c<0200) )
4444 #define xisxdigit(c) (isxdigit((eight_bits) c) &&((eight_bits) c<0200) ) \
4545
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+
4655 #define length(c) (size_t) ((c+1) ->byte_start-(c) ->byte_start)
4756 #define print_id(c) term_write((c) ->byte_start,length((c) ) )
4857 #define llink link
@@ -59,15 +68,6 @@ · 10 unmodified lines
5968 #define confusion(s) fatal("! This can't happen: ",s) \
6069 \
6170
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−
7171 #define show_banner flags['b']
7272 #define show_progress flags['p']
7373 #define show_stats flags['s']
@@ -171,7 +171,31 @@ extern char*loc; · 97 unmodified lines
171171 extern char*limit;
172172
173173 /*:6*//*7:*/
174−#line 102 "common.h"
174+#line 105 "common.h"
175+
176+extern int include_depth;
177+extern FILE*file[];
178+extern FILE*change_file;
179+extern char file_name[][max_file_name_length];
180+
181+extern char change_file_name[];
182+extern int line[];
183+extern int change_line;
184+extern int change_depth;
185+extern boolean input_has_ended;
186+extern boolean changing;
187+extern boolean web_file_open;
188+
189+/*:7*//*9:*/
190+#line 125 "common.h"
191+
192+extern sixteen_bits section_count;
193+extern boolean changed_section[];
194+extern boolean change_pending;
195+extern boolean print_where;
196+
197+/*:9*//*10:*/
198+#line 139 "common.h"
175199
176200 typedef struct name_info{
177201 char*byte_start;
@@ -195,44 +219,20 @@ extern name_pointer hash[]; · 17 unmodified lines
195219 extern hash_pointer hash_end;
196220 extern hash_pointer h;
197221
198−/*:7*//*9:*/
199−#line 146 "common.h"
222+/*:10*//*12:*/
223+#line 183 "common.h"
200224
201225 extern int history;
202226
203−/*:9*//*11:*/
204−#line 166 "common.h"
227+/*:12*//*14:*/
228+#line 199 "common.h"
205229
206−extern int include_depth;
207−extern FILE*file[];
208−extern FILE*change_file;
230+extern int argc;
231+extern char**argv;
209232 extern char C_file_name[];
210233 extern char tex_file_name[];
211234 extern char idx_file_name[];
212235 extern char scn_file_name[];
213−extern char file_name[][max_file_name_length];
214−
215−extern char change_file_name[];
216−extern int line[];
217−extern int change_line;
218−extern int change_depth;
219−extern boolean input_has_ended;
220−extern boolean changing;
221−extern boolean web_file_open;
222−
223−/*:11*//*13:*/
224−#line 190 "common.h"
225−
226−extern sixteen_bits section_count;
227−extern boolean changed_section[];
228−extern boolean change_pending;
229−extern boolean print_where;
230−
231−/*:13*//*14:*/
232−#line 203 "common.h"
233−
234−extern int argc;
235−extern char**argv;
236236 extern boolean flags[];
237237
238238 /*:14*//*15:*/
@@ -257,7 +257,7 @@ sixteen_bits text_link; · 18 unmodified lines
257257 typedef text*text_pointer;
258258
259259 /*:19*//*31:*/
260−#line 270 "ctangle.w"
260+#line 269 "ctangle.w"
261261
262262 typedef struct{
263263 eight_bits*end_field;
@@ -274,83 +274,90 @@ typedef output_state*stack_pointer; · 10 unmodified lines
274274 /*20:*/
275275 #line 129 "ctangle.w"
276276
277−text text_info[max_texts];
278−text_pointer text_info_end= text_info+max_texts-1;
279−text_pointer text_ptr;
280−eight_bits tok_mem[max_toks];
281−eight_bits*tok_mem_end= tok_mem+max_toks-1;
282−eight_bits*tok_ptr;
277+static text text_info[max_texts];
278+static text_pointer text_info_end= text_info+max_texts-1;
279+static text_pointer text_ptr;
280+static eight_bits tok_mem[max_toks];
281+static eight_bits*tok_mem_end= tok_mem+max_toks-1;
282+static eight_bits*tok_ptr;
283283
284284 /*:20*//*26:*/
285285 #line 198 "ctangle.w"
286286
287−text_pointer last_unnamed;
287+static text_pointer last_unnamed;
288288
289289 /*:26*//*32:*/
290−#line 286 "ctangle.w"
290+#line 285 "ctangle.w"
291291
292−output_state cur_state;
292+static output_state cur_state;
293293
294−output_state stack[stack_size+1];
295−stack_pointer stack_end= stack+stack_size;
296−stack_pointer stack_ptr;
294+static output_state stack[stack_size+1];
295+static stack_pointer stack_end= stack+stack_size;
296+static stack_pointer stack_ptr;
297297
298298 /*:32*//*37:*/
299−#line 362 "ctangle.w"
299+#line 361 "ctangle.w"
300300
301−int cur_val;
301+static int cur_val;
302302
303303 /*:37*//*42:*/
304−#line 454 "ctangle.w"
304+#line 452 "ctangle.w"
305305
306−eight_bits out_state;
307−boolean protect;
306+static eight_bits out_state;
307+static boolean protect;
308308
309309 /*:42*//*45:*/
310−#line 486 "ctangle.w"
310+#line 483 "ctangle.w"
311311
312−name_pointer output_files[max_files];
313−name_pointer*cur_out_file,*end_output_files,*an_output_file;
314−char cur_section_name_char;
315−char output_file_name[longest_name+1];
312+static name_pointer output_files[max_files];
313+static name_pointer*cur_out_file,*end_output_files,*an_output_file;
314+static char cur_section_name_char;
315+static char output_file_name[longest_name+1];
316316
317317 /*:45*//*52:*/
318−#line 586 "ctangle.w"
318+#line 582 "ctangle.w"
319319
320−boolean output_defs_seen= false;
320+static boolean output_defs_seen= false;
321321
322322 /*:52*//*57:*/
323−#line 695 "ctangle.w"
323+#line 691 "ctangle.w"
324324
325−char translit[128][translit_length];
325+static char translit[128][translit_length];
326326
327327 /*:57*//*62:*/
328−#line 774 "ctangle.w"
328+#line 770 "ctangle.w"
329329
330−eight_bits ccode[256];
330+static eight_bits ccode[256];
331331
332332 /*:62*//*66:*/
333−#line 834 "ctangle.w"
333+#line 830 "ctangle.w"
334334
335−boolean comment_continues= false;
335+static boolean comment_continues= false;
336336
337337 /*:66*//*68:*/
338−#line 873 "ctangle.w"
338+#line 869 "ctangle.w"
339339
340−name_pointer cur_section_name;
341−boolean no_where;
340+static name_pointer cur_section_name;
341+static boolean no_where;
342342
343343 /*:68*//*82:*/
344−#line 1187 "ctangle.w"
344+#line 1182 "ctangle.w"
345345
346−text_pointer cur_text;
347−eight_bits next_control;
346+static text_pointer cur_text;
347+static eight_bits next_control;
348348
349349 /*:82*/
350350 #line 71 "ctangle.w"
351351
352352 /*8:*/
353−#line 125 "common.h"
353+#line 119 "common.h"
354+
355+extern boolean get_line(void);
356+extern void check_complete(void);
357+extern void reset_input(void);
358+
359+/*:8*//*11:*/
360+#line 162 "common.h"
354361
355362 extern boolean names_match(name_pointer,const char*,size_t,eight_bits);
356363 extern name_pointer id_lookup(const char*,const char*,char);
@@ -362,91 +369,75 @@ extern void print_prefix_name(name_pointer); · 5 unmodified lines
362369 extern void print_section_name(name_pointer);
363370 extern void sprint_section_name(char*,name_pointer);
364371
365−/*:8*//*10:*/
366−#line 149 "common.h"
372+/*:11*//*13:*/
373+#line 186 "common.h"
367374
368375 extern int wrap_up(void);
369376 extern void err_print(const char*);
370377 extern void fatal(const char*,const char*);
371378 extern void overflow(const char*);
372379
373−/*:10*//*12:*/
374−#line 184 "common.h"
375−
376−extern boolean get_line(void);
377−extern void check_complete(void);
378−extern void reset_input(void);
379−
380−/*:12*//*16:*/
380+/*:13*//*16:*/
381381 #line 223 "common.h"
382382
383383 extern void common_init(void);
384384 extern void print_stats(void);
385385
386−/*:16*//*29:*/
387−#line 231 "ctangle.w"
388−
386+/*:16*//*30:*/
387+#line 241 "ctangle.w"
389388 static void store_two_bytes(sixteen_bits);
390389
391−/*:29*//*34:*/
392−#line 310 "ctangle.w"
390+/*:30*//*35:*/
391+#line 324 "ctangle.w"
393392
394393 static void push_level(name_pointer);
395394 static void pop_level(boolean);
396395
397−/*:34*//*38:*/
398−#line 369 "ctangle.w"
399−
396+/*:35*//*39:*/
397+#line 397 "ctangle.w"
400398 static void get_output(void);
401399
402−/*:38*//*43:*/
403−#line 462 "ctangle.w"
404−
400+/*:39*//*44:*/
401+#line 473 "ctangle.w"
405402 static void flush_buffer(void);
406403
407−/*:43*//*48:*/
408−#line 517 "ctangle.w"
409−
404+/*:44*//*49:*/
405+#line 549 "ctangle.w"
410406 static void phase_two(void);
411407
412−/*:48*//*53:*/
413−#line 589 "ctangle.w"
408+/*:49*//*53:*/
409+#line 585 "ctangle.w"
414410
415411 static void output_defs(void);
416412 static void out_char(eight_bits);
417413
418−/*:53*//*64:*/
419−#line 798 "ctangle.w"
414+/*:53*//*65:*/
415+#line 810 "ctangle.w"
420416
421417 static eight_bits skip_ahead(void);
422418 static boolean skip_comment(boolean);
423419
424−/*:64*//*69:*/
425−#line 885 "ctangle.w"
426−
420+/*:65*//*70:*/
421+#line 924 "ctangle.w"
427422 static eight_bits get_next(void);
428423
429−/*:69*//*83:*/
430−#line 1191 "ctangle.w"
431−
424+/*:70*//*84:*/
425+#line 1208 "ctangle.w"
432426 static void scan_repl(eight_bits);
433427
434−/*:83*//*90:*/
435−#line 1348 "ctangle.w"
436−
428+/*:84*//*91:*/
429+#line 1379 "ctangle.w"
437430 static void scan_section(void);
438431
439−/*:90*//*98:*/
440−#line 1455 "ctangle.w"
441−
432+/*:91*//*99:*/
433+#line 1460 "ctangle.w"
442434 static void phase_one(void);
443435
444−/*:98*//*100:*/
445−#line 1473 "ctangle.w"
446−
436+/*:99*//*101:*/
437+#line 1494 "ctangle.w"
447438 static void skip_limbo(void);
448439
449−/*:100*/
440+/*:101*/
450441 #line 72 "ctangle.w"
451442
452443
@@ -476,12 +467,12 @@ init_node(name_dir); · 23 unmodified lines
476467 last_unnamed= text_info;text_info->text_link= 0;
477468
478469 /*:27*//*46:*/
479−#line 496 "ctangle.w"
470+#line 493 "ctangle.w"
480471
481472 cur_out_file= end_output_files= output_files+max_files;
482473
483474 /*:46*//*58:*/
484−#line 698 "ctangle.w"
475+#line 694 "ctangle.w"
485476
486477 {
487478 int i;
@@ -489,7 +480,7 @@ for(i= 0;i<128;i++)sprintf(translit[i],"X%02X",(unsigned int)(128+i)); · 1 unmodified line
489480 }
490481
491482 /*:58*//*63:*/
492−#line 777 "ctangle.w"
483+#line 773 "ctangle.w"
493484 {
494485 int c;
495486 for(c= 0;c<256;c++)ccode[c]= ignore;
@@ -509,7 +500,7 @@ ccode['\'']= ord; · 13 unmodified lines
509500 }
510501
511502 /*:63*//*78:*/
512−#line 1108 "ctangle.w"
503+#line 1103 "ctangle.w"
513504 section_text[0]= ' ';
514505
515506 /*:78*/
@@ -547,10 +538,10 @@ node->equiv= (void*)text_info; · 31 unmodified lines
547538 void
548539 init_p(name_pointer p,eight_bits t){(void)p;(void)t;}
549540
550−/*:25*//*30:*/
551−#line 234 "ctangle.w"
541+/*:25*//*29:*/
542+#line 231 "ctangle.w"
552543
553−void
544+static void
554545 store_two_bytes(
555546 sixteen_bits x)
556547 {
@@ -559,8 +550,8 @@ if(tok_ptr+2> tok_mem_end)overflow("token"); · 2 unmodified lines
559550 *tok_ptr++= x&0377;
560551 }
561552
562−/*:30*//*35:*/
563−#line 314 "ctangle.w"
553+/*:29*//*34:*/
554+#line 309 "ctangle.w"
564555
565556 static void
566557 push_level(
@@ -576,8 +567,8 @@ cur_section= 0; · 9 unmodified lines
576567 }
577568 }
578569
579−/*:35*//*36:*/
580−#line 333 "ctangle.w"
570+/*:34*//*36:*/
571+#line 332 "ctangle.w"
581572
582573 static void
583574 pop_level(
@@ -592,8 +583,8 @@ stack_ptr--; · 8 unmodified lines
592583 if(stack_ptr> stack)cur_state= *stack_ptr;
593584 }
594585
595−/*:36*//*39:*/
596−#line 372 "ctangle.w"
586+/*:36*//*38:*/
587+#line 368 "ctangle.w"
597588
598589 static void
599590 get_output(void)
@@ -616,7 +607,7 @@ switch(a/024000){ · 16 unmodified lines
616607 case 0:cur_val= a;out_char(identifier);break;
617608 case 1:if(a==output_defs_flag)output_defs();
618609 else/*40:*/
619−#line 404 "ctangle.w"
610+#line 402 "ctangle.w"
620611
621612 {
622613 a-= 024000;
@@ -630,7 +621,7 @@ goto restart; · 7 unmodified lines
630621 }
631622
632623 /*:40*/
633−#line 393 "ctangle.w"
624+#line 389 "ctangle.w"
634625
635626 break;
636627 default:cur_val= a-050000;if(cur_val> 0)cur_section= cur_val;
@@ -639,8 +630,8 @@ out_char(section_number); · 2 unmodified lines
639630 }
640631 }
641632
642−/*:39*//*44:*/
643−#line 465 "ctangle.w"
633+/*:38*//*43:*/
634+#line 460 "ctangle.w"
644635
645636 static void
646637 flush_buffer(void)
@@ -654,30 +645,30 @@ update_terminal; · 7 unmodified lines
654645 cur_line++;
655646 }
656647
657−/*:44*//*49:*/
658−#line 520 "ctangle.w"
648+/*:43*//*48:*/
649+#line 514 "ctangle.w"
659650
660651 static void
661652 phase_two(void){
662653 web_file_open= false;
663654 cur_line= 1;
664655 /*33:*/
665−#line 299 "ctangle.w"
656+#line 298 "ctangle.w"
666657
667658 stack_ptr= stack+1;cur_name= name_dir;cur_repl= text_info->text_link+text_info;
668659 cur_byte= cur_repl->tok_start;cur_end= (cur_repl+1)->tok_start;cur_section= 0;
669660
670661 /*:33*/
671−#line 525 "ctangle.w"
662+#line 519 "ctangle.w"
672663
673664 /*51:*/
674−#line 582 "ctangle.w"
665+#line 578 "ctangle.w"
675666
676667 if(!output_defs_seen)
677668 output_defs();
678669
679670 /*:51*/
680−#line 526 "ctangle.w"
671+#line 520 "ctangle.w"
681672
682673 if(text_info->text_link==0&&cur_out_file==end_output_files){
683674 fputs("\n! No program text was specified.",stdout);mark_harmless;
@@ -700,7 +691,7 @@ if(text_info->text_link==0)goto writeloop; · 16 unmodified lines
700691 while(stack_ptr> stack)get_output();
701692 flush_buffer();
702693 writeloop:/*50:*/
703−#line 559 "ctangle.w"
694+#line 555 "ctangle.w"
704695
705696 for(an_output_file= end_output_files;an_output_file> cur_out_file;){
706697 an_output_file--;
@@ -721,7 +712,7 @@ flush_buffer(); · 14 unmodified lines
721712 }
722713
723714 /*:50*/
724−#line 547 "ctangle.w"
715+#line 541 "ctangle.w"
725716
726717 if(show_happiness){
727718 if(show_progress)new_line;
@@ -730,8 +721,8 @@ fputs("Done.",stdout); · 2 unmodified lines
730721 }
731722 }
732723
733−/*:49*//*54:*/
734−#line 593 "ctangle.w"
724+/*:48*//*54:*/
725+#line 589 "ctangle.w"
735726
736727 static void
737728 output_defs(void)
@@ -771,7 +762,7 @@ pop_level(false); · 33 unmodified lines
771762 }
772763
773764 /*:54*//*55:*/
774−#line 636 "ctangle.w"
765+#line 632 "ctangle.w"
775766
776767 static void
777768 out_char(
@@ -784,7 +775,7 @@ case'\n':if(protect&&out_state!=verbatim)C_putc(' '); · 6 unmodified lines
784775 if(protect||out_state==verbatim)C_putc('\\');
785776 flush_buffer();if(out_state!=verbatim)out_state= normal;break;
786777 /*59:*/
787−#line 704 "ctangle.w"
778+#line 700 "ctangle.w"
788779
789780 case identifier:
790781 if(out_state==num_or_id)C_putc(' ');
@@ -799,10 +790,10 @@ j++; · 8 unmodified lines
799790 out_state= num_or_id;break;
800791
801792 /*:59*/
802−#line 647 "ctangle.w"
793+#line 643 "ctangle.w"
803794
804795 /*60:*/
805−#line 717 "ctangle.w"
796+#line 713 "ctangle.w"
806797
807798 case section_number:
808799 if(cur_val> 0)C_printf("/*%d:*/",cur_val);
@@ -829,10 +820,10 @@ C_printf("%s","\"\n"); · 20 unmodified lines
829820 break;
830821
831822 /*:60*/
832−#line 648 "ctangle.w"
823+#line 644 "ctangle.w"
833824
834825 /*56:*/
835−#line 666 "ctangle.w"
826+#line 662 "ctangle.w"
836827
837828 case plus_plus:C_putc('+');C_putc('+');out_state= normal;break;
838829 case 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
853844 break;
854845
855846 /*:56*/
856−#line 649 "ctangle.w"
847+#line 645 "ctangle.w"
857848
858849 case'=':case'>':C_putc(cur_char);C_putc(' ');
859850 out_state= normal;break;
@@ -871,8 +862,8 @@ default:C_putc(cur_char);out_state= normal;break; · 11 unmodified lines
871862 }
872863 }
873864
874−/*:55*//*65:*/
875−#line 802 "ctangle.w"
865+/*:55*//*64:*/
866+#line 794 "ctangle.w"
876867
877868 static eight_bits
878869 skip_ahead(void)
@@ -889,8 +880,8 @@ if(c!=ignore||*(loc-1)=='>')return c; · 10 unmodified lines
889880 }
890881 }
891882
892−/*:65*//*67:*/
893−#line 837 "ctangle.w"
883+/*:64*//*67:*/
884+#line 833 "ctangle.w"
894885
895886 static boolean skip_comment(
896887 boolean is_long_comment)
@@ -923,8 +914,8 @@ else loc++; · 26 unmodified lines
923914 }
924915 }
925916
926−/*:67*//*70:*/
927−#line 888 "ctangle.w"
917+/*:67*//*69:*/
918+#line 881 "ctangle.w"
928919
929920 static eight_bits
930921 get_next(void)
@@ -938,7 +929,7 @@ if(get_line()==false)return new_section; · 7 unmodified lines
938929 else if(print_where&&!no_where){
939930 print_where= false;
940931 /*85:*/
941−#line 1220 "ctangle.w"
932+#line 1214 "ctangle.w"
942933
943934 store_two_bytes(0150000);
944935 if(changing&&include_depth==change_depth){
@@ -953,7 +944,7 @@ id_loc= id_first+strlen(id_first); · 8 unmodified lines
953944 app_repl(a_l%0400);}
954945
955946 /*:85*/
956−#line 900 "ctangle.w"
947+#line 893 "ctangle.w"
957948
958949 }
959950 else return'\n';
@@ -967,7 +958,7 @@ else continue; · 7 unmodified lines
967958 }
968959 loc++;
969960 if(xisdigit(c)||c=='.')/*73:*/
970−#line 969 "ctangle.w"
961+#line 964 "ctangle.w"
971962 {
972963 id_first= loc-1;
973964 if(*id_first=='.'&&!xisdigit(*loc))goto mistake;
@@ -992,13 +983,13 @@ return constant; · 18 unmodified lines
992983 }
993984
994985 /*:73*/
995−#line 912 "ctangle.w"
986+#line 905 "ctangle.w"
996987
997988 else if(c=='\''||c=='"'
998989 ||((c=='L'||c=='u'||c=='U')&&(*loc=='\''||*loc=='"'))
999990 ||((c=='u'&&*loc=='8')&&(*(loc+1)=='\''||*(loc+1)=='"')))
1000991 /*74:*/
1001−#line 997 "ctangle.w"
992+#line 992 "ctangle.w"
1002993 {
1003994 char delim= c;
1004995 id_first= section_text+1;
@@ -1042,11 +1033,11 @@ return string; · 37 unmodified lines
10421033 }
10431034
10441035 /*:74*/
1045−#line 916 "ctangle.w"
1036+#line 909 "ctangle.w"
10461037
10471038 else if(isalpha(c)||isxalpha(c)||ishigh(c))
10481039 /*72:*/
1049−#line 962 "ctangle.w"
1040+#line 957 "ctangle.w"
10501041 {
10511042 id_first= --loc;
10521043 while(isalpha((eight_bits)*++loc)||isdigit((eight_bits)*loc)
@@ -1055,10 +1046,10 @@ id_loc= loc;return identifier; · 2 unmodified lines
10551046 }
10561047
10571048 /*:72*/
1058−#line 918 "ctangle.w"
1049+#line 911 "ctangle.w"
10591050
10601051 else if(c=='@')/*75:*/
1061−#line 1042 "ctangle.w"
1052+#line 1037 "ctangle.w"
10621053 {
10631054 c= ccode[(eight_bits)*loc++];
10641055 switch(c){
@@ -1074,11 +1065,11 @@ continue; · 9 unmodified lines
10741065 case section_name:
10751066 cur_section_name_char= *(loc-1);
10761067 /*77:*/
1077−#line 1090 "ctangle.w"
1068+#line 1085 "ctangle.w"
10781069 {
10791070 char*k;
10801071 /*79:*/
1081−#line 1110 "ctangle.w"
1072+#line 1105 "ctangle.w"
10821073
10831074 k= section_text;
10841075 while(true){
@@ -1089,7 +1080,7 @@ loc= buffer+1;break; · 4 unmodified lines
10891080 }
10901081 c= *loc;
10911082 /*80:*/
1092−#line 1134 "ctangle.w"
1083+#line 1129 "ctangle.w"
10931084
10941085 if(c=='@'){
10951086 c= *(loc+1);
@@ -1108,7 +1099,7 @@ err_print("! Nesting of section names not allowed");break; · 12 unmodified lines
11081099 }
11091100
11101101 /*:80*/
1111−#line 1119 "ctangle.w"
1102+#line 1114 "ctangle.w"
11121103
11131104 loc++;if(k<section_text_end)k++;
11141105 if(xisspace(c)){
@@ -1125,14 +1116,14 @@ printf("...");mark_harmless; · 10 unmodified lines
11251116 if(*k==' '&&k> section_text)k--;
11261117
11271118 /*:79*/
1128−#line 1092 "ctangle.w"
1119+#line 1087 "ctangle.w"
11291120
11301121 if(k-section_text> 3&&strncmp(k-2,"...",3)==0)
11311122 cur_section_name= section_lookup(section_text+1,k-3,1);
11321123 else cur_section_name= section_lookup(section_text+1,k,0);
11331124 if(cur_section_name_char=='(')
11341125 /*47:*/
1135−#line 500 "ctangle.w"
1126+#line 497 "ctangle.w"
11361127
11371128 {
11381129 for(an_output_file= cur_out_file;
@@ -1148,16 +1139,16 @@ overflow("output files"); · 9 unmodified lines
11481139 }
11491140
11501141 /*:47*/
1151−#line 1098 "ctangle.w"
1142+#line 1093 "ctangle.w"
11521143
11531144 return section_name;
11541145 }
11551146
11561147 /*:77*/
1157−#line 1056 "ctangle.w"
1148+#line 1051 "ctangle.w"
11581149
11591150 case string:/*81:*/
1160−#line 1156 "ctangle.w"
1151+#line 1151 "ctangle.w"
11611152 {
11621153 id_first= loc++;*(limit+1)= '@';*(limit+2)= '>';
11631154 while(*loc!='@'||*(loc+1)!='>')loc++;
@@ -1168,10 +1159,10 @@ return string; · 4 unmodified lines
11681159 }
11691160
11701161 /*:81*/
1171−#line 1057 "ctangle.w"
1162+#line 1052 "ctangle.w"
11721163
11731164 case ord:/*76:*/
1174−#line 1069 "ctangle.w"
1165+#line 1064 "ctangle.w"
11751166
11761167 id_first= loc;
11771168 if(*loc=='\\'){
@@ -1194,14 +1185,14 @@ loc++; · 16 unmodified lines
11941185 return ord;
11951186
11961187 /*:76*/
1197−#line 1058 "ctangle.w"
1188+#line 1053 "ctangle.w"
11981189
11991190 default:return c;
12001191 }
12011192 }
12021193
12031194 /*:75*/
1204−#line 919 "ctangle.w"
1195+#line 912 "ctangle.w"
12051196
12061197 else if(xisspace(c)){
12071198 if(!preprocessing||loc> limit)continue;
@@ -1210,7 +1201,7 @@ else return' '; · 2 unmodified lines
12101201 }
12111202 else if(c=='#'&&loc==buffer+1)preprocessing= 1;
12121203 mistake:/*71:*/
1213−#line 940 "ctangle.w"
1204+#line 935 "ctangle.w"
12141205
12151206 switch(c){
12161207 case'+':if(*loc=='+')compress(plus_plus);break;
@@ -1234,14 +1225,14 @@ case'!':if(*loc=='=')compress(non_eq);break; · 17 unmodified lines
12341225 }
12351226
12361227 /*:71*/
1237−#line 926 "ctangle.w"
1228+#line 919 "ctangle.w"
12381229
12391230 return c;
12401231 }
12411232 }
12421233
1243−/*:70*//*84:*/
1244−#line 1194 "ctangle.w"
1234+/*:69*//*83:*/
1235+#line 1186 "ctangle.w"
12451236
12461237 static void
12471238 scan_repl(
@@ -1249,7 +1240,7 @@ eight_bits t) · 1 unmodified line
12491240 {
12501241 sixteen_bits a;
12511242 if(t==section_name){/*85:*/
1252−#line 1220 "ctangle.w"
1243+#line 1214 "ctangle.w"
12531244
12541245 store_two_bytes(0150000);
12551246 if(changing&&include_depth==change_depth){
@@ -1264,11 +1255,11 @@ id_loc= id_first+strlen(id_first); · 8 unmodified lines
12641255 app_repl(a_l%0400);}
12651256
12661257 /*:85*/
1267−#line 1200 "ctangle.w"
1258+#line 1192 "ctangle.w"
12681259 }
12691260 while(true)switch(a= get_next()){
12701261 /*86:*/
1271−#line 1233 "ctangle.w"
1262+#line 1227 "ctangle.w"
12721263
12731264 case identifier:a= id_lookup(id_first,id_loc,0)-name_dir;
12741265 app_repl((a/0400)+0200);
@@ -1276,7 +1267,7 @@ app_repl(a%0400);break; · 1 unmodified line
12761267 case section_name:if(t!=section_name)goto done;
12771268 else{
12781269 /*87:*/
1279−#line 1266 "ctangle.w"
1270+#line 1260 "ctangle.w"
12801271 {
12811272 char*try_loc= loc;
12821273 while(*try_loc==' '&&try_loc<limit)try_loc++;
@@ -1289,13 +1280,13 @@ if(*try_loc=='=')err_print("! Missing `@ ' before a named section"); · 6 unmodified lines
12891280 }
12901281
12911282 /*:87*/
1292−#line 1239 "ctangle.w"
1283+#line 1233 "ctangle.w"
12931284
12941285 a= cur_section_name-name_dir;
12951286 app_repl((a/0400)+0250);
12961287 app_repl(a%0400);
12971288 /*85:*/
1298−#line 1220 "ctangle.w"
1289+#line 1214 "ctangle.w"
12991290
13001291 store_two_bytes(0150000);
13011292 if(changing&&include_depth==change_depth){
@@ -1310,7 +1301,7 @@ id_loc= id_first+strlen(id_first); · 8 unmodified lines
13101301 app_repl(a_l%0400);}
13111302
13121303 /*:85*/
1313−#line 1243 "ctangle.w"
1304+#line 1237 "ctangle.w"
13141305 break;
13151306 }
13161307 case output_defs_code:if(t!=section_name)err_print("! Misplaced @h");
@@ -1321,7 +1312,7 @@ a= output_defs_flag; · 4 unmodified lines
13211312 app_repl((a/0400)+0200);
13221313 app_repl(a%0400);
13231314 /*85:*/
1324−#line 1220 "ctangle.w"
1315+#line 1214 "ctangle.w"
13251316
13261317 store_two_bytes(0150000);
13271318 if(changing&&include_depth==change_depth){
@@ -1336,13 +1327,13 @@ id_loc= id_first+strlen(id_first); · 8 unmodified lines
13361327 app_repl(a_l%0400);}
13371328
13381329 /*:85*/
1339−#line 1252 "ctangle.w"
1330+#line 1246 "ctangle.w"
13401331
13411332 }
13421333 break;
13431334 case constant:case string:
13441335 /*88:*/
1345−#line 1277 "ctangle.w"
1336+#line 1271 "ctangle.w"
13461337
13471338 app_repl(a);
13481339 while(id_first<id_loc){
@@ -1356,11 +1347,11 @@ app_repl(*id_first++); · 7 unmodified lines
13561347 app_repl(a);break;
13571348
13581349 /*:88*/
1359−#line 1256 "ctangle.w"
1350+#line 1250 "ctangle.w"
13601351
13611352 case ord:
13621353 /*89:*/
1363−#line 1293 "ctangle.w"
1354+#line 1287 "ctangle.w"
13641355 {
13651356 int c= (eight_bits)*id_first;
13661357 if(c=='\\'){
@@ -1411,7 +1402,7 @@ app_repl(constant); · 44 unmodified lines
14111402 break;
14121403
14131404 /*:89*/
1414−#line 1258 "ctangle.w"
1405+#line 1252 "ctangle.w"
14151406
14161407 case definition:case format_code:case begin_C:if(t!=section_name)goto done;
14171408 else{
@@ -1421,7 +1412,7 @@ err_print("! @d, @f and @c are ignored in C text");continue; · 3 unmodified lines
14211412 case new_section:goto done;
14221413
14231414 /*:86*/
1424−#line 1205 "ctangle.w"
1415+#line 1197 "ctangle.w"
14251416
14261417 case')':app_repl(a);
14271418 if(t==macro)app_repl(' ');
@@ -1433,8 +1424,8 @@ if(text_ptr> text_info_end)overflow("text"); · 5 unmodified lines
14331424 cur_text= text_ptr;(++text_ptr)->tok_start= tok_ptr;
14341425 }
14351426
1436−/*:84*//*91:*/
1437−#line 1355 "ctangle.w"
1427+/*:83*//*90:*/
1428+#line 1346 "ctangle.w"
14381429
14391430 static void
14401431 scan_section(void)
@@ -1449,7 +1440,7 @@ printf("*%d",section_count);update_terminal; · 8 unmodified lines
14491440 next_control= 0;
14501441 while(true){
14511442 /*92:*/
1452−#line 1394 "ctangle.w"
1443+#line 1387 "ctangle.w"
14531444
14541445 while(next_control<definition)
14551446
@@ -1458,11 +1449,11 @@ loc-= 2;next_control= get_next(); · 2 unmodified lines
14581449 }
14591450
14601451 /*:92*/
1461−#line 1369 "ctangle.w"
1452+#line 1360 "ctangle.w"
14621453
14631454 if(next_control==definition){
14641455 /*93:*/
1465−#line 1401 "ctangle.w"
1456+#line 1394 "ctangle.w"
14661457 {
14671458 while((next_control= get_next())=='\n');
14681459 if(next_control!=identifier){
@@ -1481,7 +1472,7 @@ cur_text->text_link= macro; · 12 unmodified lines
14811472 }
14821473
14831474 /*:93*/
1484−#line 1371 "ctangle.w"
1475+#line 1362 "ctangle.w"
14851476
14861477 continue;
14871478 }
@@ -1491,14 +1482,14 @@ p= name_dir;break; · 3 unmodified lines
14911482 if(next_control==section_name){
14921483 p= cur_section_name;
14931484 /*94:*/
1494−#line 1426 "ctangle.w"
1485+#line 1419 "ctangle.w"
14951486
14961487 while((next_control= get_next())=='+');
14971488 if(next_control!='='&&next_control!=eq_eq)
14981489 continue;
14991490
15001491 /*:94*/
1501−#line 1379 "ctangle.w"
1492+#line 1370 "ctangle.w"
15021493
15031494 break;
15041495 }
@@ -1506,20 +1497,20 @@ return; · 1 unmodified line
15061497 }
15071498 no_where= print_where= false;
15081499 /*95:*/
1509−#line 1431 "ctangle.w"
1500+#line 1424 "ctangle.w"
15101501
15111502 /*96:*/
1512−#line 1436 "ctangle.w"
1503+#line 1429 "ctangle.w"
15131504
15141505 store_two_bytes((sixteen_bits)(0150000+section_count));
15151506
15161507
15171508 /*:96*/
1518−#line 1432 "ctangle.w"
1509+#line 1425 "ctangle.w"
15191510
15201511 scan_repl(section_name);
15211512 /*97:*/
1522−#line 1440 "ctangle.w"
1513+#line 1433 "ctangle.w"
15231514
15241515 if(p==name_dir||p==0){
15251516 (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
15361527
15371528
15381529 /*:97*/
1539−#line 1434 "ctangle.w"
1530+#line 1427 "ctangle.w"
15401531
15411532
15421533 /*:95*/
1543−#line 1385 "ctangle.w"
1534+#line 1376 "ctangle.w"
15441535
15451536 }
15461537
1547−/*:91*//*99:*/
1548−#line 1458 "ctangle.w"
1538+/*:90*//*98:*/
1539+#line 1448 "ctangle.w"
15491540
15501541 static void
15511542 phase_one(void){
@@ -1558,8 +1549,8 @@ check_complete(); · 6 unmodified lines
15581549 phase= 2;
15591550 }
15601551
1561−/*:99*//*101:*/
1562−#line 1476 "ctangle.w"
1552+/*:98*//*100:*/
1553+#line 1465 "ctangle.w"
15631554
15641555 static void
15651556 skip_limbo(void)
@@ -1574,7 +1565,7 @@ c= *loc++; · 8 unmodified lines
15741565 if(ccode[(eight_bits)c]==new_section)break;
15751566 switch(ccode[(eight_bits)c]){
15761567 case translit_code:/*102:*/
1577−#line 1505 "ctangle.w"
1568+#line 1496 "ctangle.w"
15781569
15791570 while(xisspace(*loc)&&loc<limit)loc++;
15801571 loc+= 3;
@@ -1599,7 +1590,7 @@ translit[i-0200][loc-beg]= '\0'; · 18 unmodified lines
15991590 }
16001591
16011592 /*:102*/
1602−#line 1489 "ctangle.w"
1593+#line 1478 "ctangle.w"
16031594 break;
16041595 case format_code:case'@':break;
16051596 case control_text:if(c=='q'||c=='Q'){
@@ -1616,8 +1607,8 @@ default:err_print("! Double @ should be used in limbo"); · 10 unmodified lines
16161607 }
16171608 }
16181609
1619−/*:101*//*103:*/
1620−#line 1531 "ctangle.w"
1610+/*:100*//*103:*/
1611+#line 1522 "ctangle.w"
16211612
16221613 void
16231614 print_stats(void){
ctangle.w+83−92
@@ -2,7 +2,7 @@ · 1 unmodified line
22 % This program by Silvio Levy and Donald E. Knuth
33 % is based on a program by Knuth.
44 % It is distributed WITHOUT ANY WARRANTY, express or implied.
5−% Version 4.1 --- February 2021
5+% Version 4.2 --- February 2021
66
77 % Copyright (C) 1987,1990,1993,2000 Silvio Levy and Donald E. Knuth
88
@@ -27,11 +27,11 @@ · 18 unmodified lines
2727 \mathchardef\RA="3221 % right arrow
2828 \mathchardef\BA="3224 % double arrow
2929
30−\def\title{CTANGLE (Version 4.1)}
30+\def\title{CTANGLE (Version 4.2)}
3131 \def\topofcontents{\null\vfill
3232 \centerline{\titlefont The {\ttitlefont CTANGLE} processor}
3333 \vskip 15pt
34− \centerline{(Version 4.1)}
34+ \centerline{(Version 4.2)}
3535 \vfill}
3636 \def\botofcontents{\vfill
3737 \noindent
@@ -61,15 +61,15 @@ Joachim Schrod, Lee Wittenberg, and others who have contributed improvements. · 23 unmodified lines
6161 The ``banner line'' defined here should be changed whenever \.{CTANGLE}
6262 is modified.
6363
64−@d banner "This is CTANGLE (Version 4.1)"
64+@d banner "This is CTANGLE (Version 4.2)"
6565
6666 @c
6767 @<Include files@>@/
6868 @h
6969 @<Common code for \.{CWEAVE} and \.{CTANGLE}@>@/
7070 @<Typedef declarations@>@/
71−@<Global variables@>@/
72−@<Predeclaration of procedures@>@/
71+@<Private variables@>@/
72+@<Predeclaration of procedures@>
7373
7474 @ \.{CTANGLE} has a fairly straightforward outline. It operates in
7575 two phases: First it reads the source file, saving the \CEE/ code in
@@ -126,13 +126,13 @@ typedef struct { · 50 unmodified lines
126126 } text;
127127 typedef text *text_pointer;
128128
129−@ @<Glob...@>=
130−text text_info[max_texts];
131−text_pointer text_info_end=text_info+max_texts-1;
132−text_pointer text_ptr; /* first unused position in |text_info| */
133−eight_bits tok_mem[max_toks];
134−eight_bits *tok_mem_end=tok_mem+max_toks-1;
135−eight_bits *tok_ptr; /* first unused position in |tok_mem| */
129+@ @<Private...@>=
130+static text text_info[max_texts];
131+static text_pointer text_info_end=text_info+max_texts-1;
132+static text_pointer text_ptr; /* first unused position in |text_info| */
133+static eight_bits tok_mem[max_toks];
134+static eight_bits *tok_mem_end=tok_mem+max_toks-1;
135+static eight_bits *tok_ptr; /* first unused position in |tok_mem| */
136136
137137 @ @<Set init...@>=
138138 text_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
195195
196196 @d section_flag max_texts /* final |text_link| in section replacement texts */
197197
198−@<Glob...@>=
199−text_pointer last_unnamed; /* most recent replacement text of unnamed section */
198+@<Private...@>=
199+static text_pointer last_unnamed; /* most recent replacement text of unnamed section */
200200
201201 @ @<Set init...@>= last_unnamed=text_info; text_info->text_link=0;
202202
@@ -228,11 +228,8 @@ construction or numerical constant. · 25 unmodified lines
228228 @ The following procedure is used to enter a two-byte value into
229229 |tok_mem| when a replacement text is being generated.
230230
231−@<Predecl...@>=
232−static void store_two_bytes(sixteen_bits);@/
233−
234−@ @c
235−void
231+@c
232+static void
236233 store_two_bytes(
237234 sixteen_bits x)
238235 {
@@ -241,6 +238,8 @@ sixteen_bits x) · 2 unmodified lines
241238 *tok_ptr++=x&0377; /* store low byte */
242239 }
243240
241+@ @<Predecl...@>=@+static void store_two_bytes(sixteen_bits);
242+
244243 @** Stacks for output. The output process uses a stack to keep track
245244 of what is going on at different ``levels'' as the sections are being
246245 written out. Entries on this stack have five parts:
@@ -283,12 +282,12 @@ typedef output_state *stack_pointer; · 36 unmodified lines
283282 @d cur_repl cur_state.repl_field /* pointer to current replacement text */
284283 @d cur_section cur_state.section_field /* current section number being expanded */
285284
286−@<Global...@>=
287−output_state cur_state; /* |cur_end|, |cur_byte|, |cur_name|, |cur_repl|,
285+@<Private...@>=
286+static output_state cur_state; /* |cur_end|, |cur_byte|, |cur_name|, |cur_repl|,
288287 and |cur_section| */
289−output_state stack[stack_size+1]; /* info for non-current levels */
290−stack_pointer stack_end=stack+stack_size; /* end of |stack| */
291−stack_pointer stack_ptr; /* first unused location in the output state stack */
288+static output_state stack[stack_size+1]; /* info for non-current levels */
289+static stack_pointer stack_end=stack+stack_size; /* end of |stack| */
290+static stack_pointer stack_ptr; /* first unused location in the output state stack */
292291
293292 @ To get the output process started, we will perform the following
294293 initialization steps. We may assume that |text_info->text_link| is nonzero,
@@ -307,11 +306,7 @@ the new one going. · 12 unmodified lines
307306 We assume that the \CEE/ compiler can copy structures.
308307 @^system dependencies@>
309308
310−@<Predecl...@>=
311−static void push_level(name_pointer);@/
312−static void pop_level(boolean);@/
313−
314−@ @c
309+@c
315310 static void
316311 push_level(@t\1\1@> /* suspends the current level */
317312 name_pointer p@t\2\2@>)
@@ -326,6 +321,10 @@ name_pointer p@t\2\2@>) · 8 unmodified lines
326321 }
327322 }
328323
324+@ @<Predecl...@>=
325+static void push_level(name_pointer);@/
326+static void pop_level(boolean);
327+
329328 @ When we come to the end of a replacement text, the |pop_level| subroutine
330329 does the right thing: It either moves to the continuation of this replacement
331330 text 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
359358 @d section_number 0201 /* code returned by |get_output| for section numbers */
360359 @d identifier 0202 /* code returned by |get_output| for identifiers */
361360
362−@<Global...@>=
363−int cur_val; /* additional information corresponding to output token */
361+@<Private...@>=
362+static int cur_val; /* additional information corresponding to output token */
364363
365364 @ If |get_output| finds that no more output remains, it returns with
366365 |stack_ptr==stack|.
367366 @^high-bit character handling@>
368367
369−@<Predecl...@>=
370−static void get_output(void);@/
371−
372−@ @c
368+@c
373369 static void
374370 get_output(void) /* sends next token to |out_char| */
375371 {
@@ -398,6 +394,8 @@ get_output(void) /* sends next token to |out_char| */ · 22 unmodified lines
398394 }
399395 }
400396
397+@ @<Predecl...@>=@+static void get_output(void);
398+
401399 @ The user may have forgotten to give any \CEE/ text for a section name,
402400 or the \CEE/ text may have been associated with a different name by mistake.
403401
@@ -451,18 +449,15 @@ are preceded by a `\.\\'. · 47 unmodified lines
451449 @d unbreakable 3 /* state associated with \.{@@\&} */
452450 @d verbatim 4 /* state in the middle of a string */
453451
454−@<Global...@>=
455−eight_bits out_state; /* current status of partial output */
456−boolean protect; /* should newline characters be quoted? */
452+@<Private...@>=
453+static eight_bits out_state; /* current status of partial output */
454+static boolean protect; /* should newline characters be quoted? */
457455
458456 @ Here is a routine that is invoked when we want to output the current line.
459457 During the output process, |cur_line| equals the number of the next line
460458 to be output.
461459
462−@<Predecl...@>=
463−static void flush_buffer(void);@/
464−
465−@ @c
460+@c
466461 static void
467462 flush_buffer(void) /* writes one line to output file */
468463 {
@@ -475,6 +470,8 @@ flush_buffer(void) /* writes one line to output file */ · 6 unmodified lines
475470 cur_line++;
476471 }
477472
473+@ @<Predecl...@>=@+static void flush_buffer(void);
474+
478475 @ Second, we have modified the original \.{TANGLE} so that it will write output
479476 on multiple files.
480477 If 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
483480 We write them out after we've done the unnamed section.
484481
485482 @d max_files 256
486−@<Glob...@>=
487−name_pointer output_files[max_files];
488−name_pointer *cur_out_file, *end_output_files, *an_output_file;
489−char cur_section_name_char; /* is it |'<'| or |'('| */
490−char output_file_name[longest_name+1]; /* name of the file */
483+@<Private...@>=
484+static name_pointer output_files[max_files];
485+static name_pointer *cur_out_file, *end_output_files, *an_output_file;
486+static char cur_section_name_char; /* is it |'<'| or |'('| */
487+static char output_file_name[longest_name+1]; /* name of the file */
491488
492489 @ We make |end_output_files| point just beyond the end of
493490 |output_files|. The stack pointer
@@ -514,10 +511,7 @@ complain we're out of room@>= · 20 unmodified lines
514511 @* The big output switch. Here then is the routine that does the
515512 output.
516513
517−@<Predecl...@>=
518−static void phase_two(void);@/
519−
520−@ @c
514+@c
521515 static void
522516 phase_two (void) {
523517 web_file_open=false;
@@ -552,6 +546,8 @@ writeloop: @<Write all the named output files@>@; · 28 unmodified lines
552546 }
553547 }
554548
549+@ @<Predecl...@>=@+static void phase_two(void);
550+
555551 @ To write the named output files, we proceed as for the unnamed
556552 section.
557553 The 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
583579 if (!output_defs_seen)
584580 output_defs();
585581
586−@ @<Glob...@>=
587−boolean output_defs_seen=false;
582+@ @<Private...@>=
583+static boolean output_defs_seen=false;
588584
589585 @ @<Predecl...@>=
590586 static void output_defs(void);@/
591−static void out_char(eight_bits);@/
587+static void out_char(eight_bits);
592588
593589 @ @c
594590 static void
@@ -692,8 +688,8 @@ This makes debugging a lot less confusing. · 97 unmodified lines
692688
693689 @d translit_length 10
694690
695−@<Glo...@>=
696−char translit[128][translit_length];
691+@<Private...@>=
692+static char translit[128][translit_length];
697693
698694 @ @<Set init...@>=
699695 {
@@ -771,8 +767,8 @@ milestones. · 71 unmodified lines
771767 @d section_name 0311 /* control code for `\.{@@<}' */
772768 @d new_section 0312 /* control code for `\.{@@\ }' and `\.{@@*}' */
773769
774−@<Global...@>=
775−eight_bits ccode[256]; /* meaning of a char following \.{@@} */
770+@<Private...@>=
771+static eight_bits ccode[256]; /* meaning of a char following \.{@@} */
776772
777773 @ @<Set ini...@>= {
778774 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
795791 @ The |skip_ahead| procedure reads through the input at fairly high speed
796792 until finding the next non-ignorable control code, which it returns.
797793
798−@<Predecl...@>=
799−static eight_bits skip_ahead(void);@/
800−static boolean skip_comment(boolean);@/
801−
802−@ @c
794+@c
803795 static eight_bits
804796 skip_ahead(void) /* skip to next control code */
805797 {
@@ -815,6 +807,10 @@ skip_ahead(void) /* skip to next control code */ · 9 unmodified lines
815807 }
816808 }
817809
810+@ @<Predecl...@>=
811+static eight_bits skip_ahead(void);@/
812+static boolean skip_comment(boolean);
813+
818814 @ The |skip_comment| procedure reads through the input at somewhat high
819815 speed in order to pass over comments, which \.{CTANGLE} does not transmit
820816 to the output. If the comment is introduced by \.{/*}, |skip_comment|
@@ -831,8 +827,8 @@ the two types of comments. · 10 unmodified lines
831827 If |skip_comment| comes to the end of the section, it prints an error message.
832828 No comment, long or short, is allowed to contain `\.{@@\ }' or `\.{@@*}'.
833829
834−@<Global...@>=
835−boolean comment_continues=false; /* are we scanning a comment? */
830+@<Private...@>=
831+static boolean comment_continues=false; /* are we scanning a comment? */
836832
837833 @ @c
838834 static boolean skip_comment(@t\1\1@> /* skips over comments */
@@ -870,9 +866,9 @@ boolean is_long_comment@t\2\2@>) · 31 unmodified lines
870866
871867 @d constant 03
872868
873−@<Global...@>=
874−name_pointer cur_section_name; /* name of section just scanned */
875−boolean no_where; /* suppress |print_where|? */
869+@<Private...@>=
870+static name_pointer cur_section_name; /* name of section just scanned */
871+static boolean no_where; /* suppress |print_where|? */
876872
877873 @ As one might expect, |get_next| consists mostly of a big switch
878874 that 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
882878 @d ishigh(c) ((eight_bits)(c)>0177)
883879 @^high-bit character handling@>
884880
885−@<Predecl...@>=
886−static eight_bits get_next(void);@/
887−
888−@ @c
881+@c
889882 static eight_bits
890883 get_next(void) /* produces the next input token */
891884 {
@@ -928,6 +921,8 @@ get_next(void) /* produces the next input token */ · 36 unmodified lines
928921 }
929922 }
930923
924+@ @<Predecl...@>=@+static eight_bits get_next(void);
925+
931926 @ The following code assigns values to the combinations \.{++},
932927 \.{--}, \.{->}, \.{>=}, \.{<=}, \.{==}, \.{<<}, \.{>>}, \.{!=}, \.{||} and
933928 \.{\&\&}, and to the \CPLUSPLUS/
@@ -1184,12 +1179,9 @@ acted, |cur_text| will point to the replacement text just generated, and · 250 unmodified lines
11841179 @d macro 0
11851180 @d app_repl(c) {if (tok_ptr==tok_mem_end) overflow("token"); *tok_ptr++=c;}
11861181
1187−@<Global...@>=
1188−text_pointer cur_text; /* replacement text formed by |scan_repl| */
1189−eight_bits next_control;
1190−
1191−@ @<Predecl...@>=
1192−static void scan_repl(eight_bits);@/
1182+@<Private...@>=
1183+static text_pointer cur_text; /* replacement text formed by |scan_repl| */
1184+static eight_bits next_control;
11931185
11941186 @ @c
11951187 static void
@@ -1213,6 +1205,8 @@ eight_bits t@t\2\2@>) · 17 unmodified lines
12131205 cur_text=text_ptr; (++text_ptr)->tok_start=tok_ptr;
12141206 }
12151207
1208+@ @<Predecl...@>=@+static void scan_repl(eight_bits);
1209+
12161210 @ Here is the code for the line number: first a |sixteen_bits| equal
12171211 to |0150000|; then the numeric line number; then a pointer to the
12181212 file name.
@@ -1236,7 +1230,7 @@ case identifier: a=id_lookup(id_first,id_loc,0)-name_dir; · 17 unmodified lines
12361230 app_repl(a % 0400); break;
12371231 case section_name: if (t!=section_name) goto done;
12381232 else {
1239− @<Was an `@@' missed here?@>@;
1233+ @<Was an `\.{@@}' missed here?@>@;
12401234 a=cur_section_name-name_dir;
12411235 app_repl((a / 0400)+0250);
12421236 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
12631257 }
12641258 case new_section: goto done;
12651259
1266−@ @<Was an `@@'...@>= {
1260+@ @<Was an `\.{@@}'...@>= {
12671261 char *try_loc=loc;
12681262 while (*try_loc==' ' && try_loc<limit) try_loc++;
12691263 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
13451339 uses |section_count| to keep track of the current section number; with luck,
13461340 \.{CWEAVE} and \.{CTANGLE} will both assign the same numbers to sections.
13471341
1348−@<Predecl...@>=
1349−static void scan_section(void);@/
1350−
1351−@ The body of |scan_section| is a loop where we look for control codes
1342+The body of |scan_section| is a loop where we look for control codes
13521343 that are significant to \.{CTANGLE}: those
13531344 that delimit a definition, the \CEE/ part of a module, or a new module.
13541345
@@ -1385,6 +1376,8 @@ scan_section(void) · 30 unmodified lines
13851376 @<Scan the \CEE/ part of the current section@>@;
13861377 }
13871378
1379+@ @<Predecl...@>=@+static void scan_section(void);
1380+
13881381 @ At the top of this loop, if |next_control==section_name|, the
13891382 section name has already been scanned (see |@<Get control code
13901383 and...@>|). Thus, if we encounter |next_control==section_name| in the
@@ -1452,9 +1445,6 @@ else { · 61 unmodified lines
14521445 cur_text->text_link=section_flag;
14531446 /* mark this replacement text as a nonmacro */
14541447
1455−@ @<Predec...@>=
1456−static void phase_one(void);@/
1457−
14581448 @ @c
14591449 static void
14601450 phase_one(void) {
@@ -1467,13 +1457,12 @@ phase_one(void) { · 6 unmodified lines
14671457 phase=2;
14681458 }
14691459
1460+@ @<Predec...@>=@+static void phase_one(void);
1461+
14701462 @ Only a small subset of the control codes is legal in limbo, so limbo
14711463 processing is straightforward.
14721464
1473−@<Predecl...@>=
1474−static void skip_limbo(void);@/
1475−
1476−@ @c
1465+@c
14771466 static void
14781467 skip_limbo(void)
14791468 {
@@ -1502,6 +1491,8 @@ skip_limbo(void) · 22 unmodified lines
15021491 }
15031492 }
15041493
1494+@ @<Predecl...@>=@+static void skip_limbo(void);
1495+
15051496 @ @<Read in transliteration of a character@>=
15061497 while(xisspace(*loc)&&loc<limit) loc++;
15071498 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
2020 The ``banner line'' defined here should be changed whenever \.{CWEAVE}
2121 is modified.
2222
23−@d banner "This is CWEAVE (Version 4.1)"
23+@d banner "This is CWEAVE (Version 4.2)"
2424 @y
2525 The ``banner line'' defined here should be changed whenever \.{CWEAVE}
2626 is modified.
2727
28−@d banner "This is CWEAVE (Version 4.1pc/big)"
28+@d banner "This is CWEAVE (Version 4.2pc/big)"
2929 @z
3030
3131
@@ -103,11 +103,11 @@ typedef xref_info huge* xref_pointer; · 71 unmodified lines
103103
104104
105105 @x Section 23.
106−xref_info xmem[max_refs]; /* contains cross-reference information */
107−xref_pointer xmem_end = xmem+max_refs-1;
106+static xref_info xmem[max_refs]; /* contains cross-reference information */
107+static xref_pointer xmem_end = xmem+max_refs-1;
108108 @y
109−xref_info huge xmem[max_refs]; /* contains cross-reference information */
110−xref_pointer xmem_end;
109+static xref_info huge xmem[max_refs]; /* contains cross-reference information */
110+static xref_pointer xmem_end;
111111 @z
112112
113113
@@ -129,21 +129,21 @@ xmem->num=0; /* sentinel value */ · 15 unmodified lines
129129
130130
131131 @x Section 30. (to please Borland's C++, version 4.02)
132−token tok_mem[max_toks]; /* tokens */
133−token_pointer tok_mem_end = tok_mem+max_toks-1; /* end of |tok_mem| */
134−token_pointer tok_ptr; /* first unused position in |tok_mem| */
135−token_pointer max_tok_ptr; /* largest value of |tok_ptr| */
136−token_pointer tok_start[max_texts]; /* directory into |tok_mem| */
137−text_pointer tok_start_end = tok_start+max_texts-1; /* end of |tok_start| */
138−text_pointer text_ptr; /* first unused position in |tok_start| */
139−@y
140−token tok_mem[max_toks]; /* tokens */
141−token_pointer tok_mem_end; /* end of |tok_mem| */
142−token_pointer tok_ptr; /* first unused position in |tok_mem| */
143−token_pointer max_tok_ptr; /* largest value of |tok_ptr| */
144−token_pointer tok_start[max_texts]; /* directory into |tok_mem| */
145−text_pointer tok_start_end; /* end of |tok_start| */
146−text_pointer text_ptr; /* first unused position in |tok_start| */
132+static token tok_mem[max_toks]; /* tokens */
133+static token_pointer tok_mem_end = tok_mem+max_toks-1; /* end of |tok_mem| */
134+static token_pointer tok_ptr; /* first unused position in |tok_mem| */
135+static token_pointer max_tok_ptr; /* largest value of |tok_ptr| */
136+static token_pointer tok_start[max_texts]; /* directory into |tok_mem| */
137+static text_pointer tok_start_end = tok_start+max_texts-1; /* end of |tok_start| */
138+static text_pointer text_ptr; /* first unused position in |tok_start| */
139+@y
140+static token tok_mem[max_toks]; /* tokens */
141+static token_pointer tok_mem_end; /* end of |tok_mem| */
142+static token_pointer tok_ptr; /* first unused position in |tok_mem| */
143+static token_pointer max_tok_ptr; /* largest value of |tok_ptr| */
144+static token_pointer tok_start[max_texts]; /* directory into |tok_mem| */
145+static text_pointer tok_start_end; /* end of |tok_start| */
146+static text_pointer text_ptr; /* first unused position in |tok_start| */
147147 @z
148148
149149 @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
212212
213213
214214 @x Section 246.
215−char *cur_byte; /* index into |byte_mem| */
215+static char *cur_byte; /* index into |byte_mem| */
216216 @y
217−char huge* cur_byte; /* index into |byte_mem| */
217+static char huge* cur_byte; /* index into |byte_mem| */
218218 @z
219219
220220
cweav-man.ch+1−1
@@ -16,7 +16,7 @@ under the terms of a permission notice identical to this one. · 15 unmodified lines
1616 }
1717 @y
1818 \def\botofcontents{\vfill\titlefalse}
19−\def\contentspagenumber{110}
19+\def\contentspagenumber{111}
2020 \def\title{APPENDIX F: CWEAVE}
2121 \let\K=\leftarrow
2222 @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
1111 change files that have -bs in their name instead of -pc.)
1212
1313 @x section 1
14−@d banner "This is CWEAVE (Version 4.1)"
14+@d banner "This is CWEAVE (Version 4.2)"
1515 @y
16−@d banner "This is CWEAVE (Version 4.1pc)"
16+@d banner "This is CWEAVE (Version 4.2pc)"
1717 @z
1818
1919 @x section 4
cweav-ql.ch+4−4
@@ -7,15 +7,15 @@ ex <dev_>cc;"-v -h -c =500000 cweave_c" · 6 unmodified lines
77
88
99 @x
10−\def\title{CWEAVE (Version 4.1)}
10+\def\title{CWEAVE (Version 4.2)}
1111 @y
12−\def\title{CWEAVE (QL Version 4.1)}
12+\def\title{CWEAVE (QL Version 4.2)}
1313 @z
1414
1515 @x section 1
16−@d banner "This is CWEAVE (Version 4.1)"
16+@d banner "This is CWEAVE (Version 4.2)"
1717 @y
18−@d banner "This is CWEAVE (QL Version 4.1)"
18+@d banner "This is CWEAVE (QL Version 4.2)"
1919 @z
2020
2121 @x
cweav-vms.ch+2−2
@@ -13,9 +13,9 @@ modified: · 12 unmodified lines
1313 (also modified by Don Knuth to keep version numbers uptodate)
1414
1515 @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)"
1717 @y
18−@d banner "This is CWEAVE (VAX/VMS Version 4.1)"
18+@d banner "This is CWEAVE (VAX/VMS Version 4.2)"
1919 @z
2020
2121 @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
22 (Contributed by Fabrice Popineau, February 2002)
33
44 @x section 1
5−@d banner "This is CWEAVE (Version 4.1)"
5+@d banner "This is CWEAVE (Version 4.2)"
66 @y
7−@d banner "This is CWEAVE (Version 4.1win32)"
7+@d banner "This is CWEAVE (Version 4.2win32)"
88 @z
99
1010 @x
cweave.w+151−166
@@ -2,7 +2,7 @@ · 1 unmodified line
22 % This program by Silvio Levy and Donald E. Knuth
33 % is based on a program by Knuth.
44 % It is distributed WITHOUT ANY WARRANTY, express or implied.
5−% Version 4.1 --- February 2021
5+% Version 4.2 --- February 2021
66
77 % Copyright (C) 1987,1990,1993,2000 Silvio Levy and Donald E. Knuth
88
@@ -32,11 +32,11 @@ · 23 unmodified lines
3232 \def\skipxTeX{\\{skip\_\TEX/}}
3333 \def\copyxTeX{\\{copy\_\TEX/}}
3434
35−\def\title{CWEAVE (Version 4.1)}
35+\def\title{CWEAVE (Version 4.2)}
3636 \def\topofcontents{\null\vfill
3737 \centerline{\titlefont The {\ttitlefont CWEAVE} processor}
3838 \vskip 15pt
39− \centerline{(Version 4.1)}
39+ \centerline{(Version 4.2)}
4040 \vfill}
4141 \def\botofcontents{\vfill
4242 \noindent
@@ -67,13 +67,13 @@ Crusius, and others who have contributed improvements. · 24 unmodified lines
6767 The ``banner line'' defined here should be changed whenever \.{CWEAVE}
6868 is modified.
6969
70−@d banner "This is CWEAVE (Version 4.1)"
70+@d banner "This is CWEAVE (Version 4.2)"
7171
7272 @c @<Include files@>@/
7373 @h
7474 @<Common code for \.{CWEAVE} and \.{CTANGLE}@>@/
7575 @<Typedef declarations@>@/
76−@<Global variables@>@/
76+@<Private variables@>@/
7777 @<Predeclaration of procedures@>
7878
7979 @ \.{CWEAVE} has a fairly straightforward outline. It operates in
@@ -99,6 +99,7 @@ char **av@t\2\2@>) /* argument values */ · 19 unmodified lines
9999 phase_one(); /* read all the user's text and store the cross-references */
100100 phase_two(); /* read all the text again and translate it to \TEX/ form */
101101 phase_three(); /* output the cross-reference index */
102+ if (tracing==2 && !show_progress) new_line;
102103 return wrap_up(); /* and exit gracefully */
103104 }
104105
@@ -181,8 +182,8 @@ is the total number of sections that have started. Sections which have · 76 unmodified lines
181182 been altered by a change file entry have their |changed_section| flag
182183 turned on during the first phase.
183184
184−@<Global...@>=
185−boolean change_exists; /* has any section changed? */
185+@<Private...@>=
186+static boolean change_exists; /* has any section changed? */
186187
187188 @ The other large memory area in \.{CWEAVE} keeps the cross-reference data.
188189 All uses of the name |p| are recorded in a linked list beginning at
@@ -213,11 +214,11 @@ typedef struct xref_info { · 24 unmodified lines
213214 } xref_info;
214215 typedef xref_info *xref_pointer;
215216
216−@ @<Global...@>=
217−xref_info xmem[max_refs]; /* contains cross-reference information */
218−xref_pointer xmem_end = xmem+max_refs-1;
219−xref_pointer xref_ptr; /* the largest occupied position in |xmem| */
220−sixteen_bits xref_switch,section_xref_switch; /* either zero or |def_flag| */
217+@ @<Private...@>=
218+static xref_info xmem[max_refs]; /* contains cross-reference information */
219+static xref_pointer xmem_end = xmem+max_refs-1;
220+static xref_pointer xref_ptr; /* the largest occupied position in |xmem| */
221+static sixteen_bits xref_switch,section_xref_switch; /* either zero or |def_flag| */
221222
222223 @ A section that is used for multi-file output (with the \.{@@(} feature)
223224 has 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
250251 @<Predecl...@>=
251252 static void new_xref(name_pointer);@/
252253 static void new_section_xref(name_pointer);@/
253−static void set_file_flag(name_pointer);@/
254+static void set_file_flag(name_pointer);
254255
255256 @ @c
256257 static void
@@ -332,15 +333,15 @@ that is unoccupied by replacement text is called |tok_ptr|, and the first · 75 unmodified lines
332333 unused location of |tok_start| is called |text_ptr|.
333334 Thus, we usually have |*text_ptr==tok_ptr|.
334335
335−@<Global...@>=
336−token tok_mem[max_toks]; /* tokens */
337−token_pointer tok_mem_end = tok_mem+max_toks-1; /* end of |tok_mem| */
338−token_pointer tok_ptr; /* first unused position in |tok_mem| */
339−token_pointer max_tok_ptr; /* largest value of |tok_ptr| */
340−token_pointer tok_start[max_texts]; /* directory into |tok_mem| */
341−text_pointer tok_start_end = tok_start+max_texts-1; /* end of |tok_start| */
342−text_pointer text_ptr; /* first unused position in |tok_start| */
343−text_pointer max_text_ptr; /* largest value of |text_ptr| */
336+@<Private...@>=
337+static token tok_mem[max_toks]; /* tokens */
338+static token_pointer tok_mem_end = tok_mem+max_toks-1; /* end of |tok_mem| */
339+static token_pointer tok_ptr; /* first unused position in |tok_mem| */
340+static token_pointer max_tok_ptr; /* largest value of |tok_ptr| */
341+static token_pointer tok_start[max_texts]; /* directory into |tok_mem| */
342+static text_pointer tok_start_end = tok_start+max_texts-1; /* end of |tok_start| */
343+static text_pointer text_ptr; /* first unused position in |tok_start| */
344+static text_pointer max_text_ptr; /* largest value of |text_ptr| */
344345
345346 @ @<Set init...@>=
346347 tok_ptr=max_tok_ptr=tok_mem+1;@/
@@ -382,8 +383,7 @@ name_pointer p) · 35 unmodified lines
382383 p->xref=(void *)xref_ptr;
383384 }
384385
385−@ @<Predecl...@>=
386−static void update_node(name_pointer p);@/
386+@ @<Predecl...@>=@+static void update_node(name_pointer p);
387387
388388 @ We have to get \CEE/'s
389389 reserved 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
489489 id_lookup("wchar_t",NULL,raw_int);
490490 id_lookup("while",NULL,for_like);
491491 id_lookup("xor",NULL,alfop);
492−id_lookup("xor_eq",NULL,alfop);
493−res_wd_end=name_ptr;
492+id_lookup("xor_eq",NULL,alfop);@+ res_wd_end=name_ptr;
494493 id_lookup("TeX",NULL,custom);
495494 id_lookup("make_pair",NULL,func_template);
496495
@@ -546,8 +545,8 @@ scanning routines. · 49 unmodified lines
546545 @ Control codes are converted to \.{CWEAVE}'s internal
547546 representation by means of the table |ccode|.
548547
549−@<Global...@>=
550−eight_bits ccode[256]; /* meaning of a char following \.{@@} */
548+@<Private...@>=
549+static eight_bits ccode[256]; /* meaning of a char following \.{@@} */
551550
552551 @ @<Set ini...@>=
553552 {int c; for (c=0; c<256; c++) ccode[c]=0;}
@@ -589,7 +588,7 @@ interpretation of identifiers. · 35 unmodified lines
589588
590589 @<Predec...@>=
591590 static void skip_limbo(void);@/
592−static eight_bits skip_TeX(void);@/
591+static eight_bits skip_TeX(void);
593592
594593 @ @c
595594 static void
@@ -597,7 +596,7 @@ skip_limbo(void) { · 1 unmodified line
597596 while(true) {
598597 if (loc>limit && get_line()==false) return;
599598 *(limit+1)='@@';
600− while (*loc!='@@') loc++; /* look for '@@', then skip two chars */
599+ while (*loc!='@@') loc++; /* look for `\.{@@}', then skip two chars */
601600 if (loc++ <=limit) { int c=ccode[(eight_bits)*loc++];
602601 if (c==new_section) return;
603602 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
666665 @d string 0201 /* \CEE/ string */
667666 @d identifier 0202 /* \CEE/ identifier or reserved word */
668667
669−@<Global...@>=
670−name_pointer cur_section; /* name of section just scanned */
671−char cur_section_char; /* the character just before that name */
668+@<Private...@>=
669+static name_pointer cur_section; /* name of section just scanned */
670+static char cur_section_char; /* the character just before that name */
672671
673672 @ As one might expect, |get_next| consists mostly of a big switch
674673 that branches to the various special cases that can arise.
@@ -680,10 +679,7 @@ compilers even allow the dollar sign. · 5 unmodified lines
680679 @d ishigh(c) ((eight_bits)(c)>0177)
681680 @^high-bit character handling@>
682681
683−@<Predecl...@>=
684−static eight_bits get_next(void);@/
685−
686−@ @c
682+@c
687683 static eight_bits
688684 get_next(void) /* produces the next input token */
689685 {
@@ -708,6 +704,8 @@ get_next(void) /* produces the next input token */ · 18 unmodified lines
708704 }
709705 }
710706
707+@ @<Predecl...@>=@+static eight_bits get_next(void);
708+
711709 @ Because preprocessor commands do not fit in with the rest of the syntax
712710 of \CEE/,
713711 we 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
721719 @d left_preproc ord /* begins a preprocessor command */
722720 @d right_preproc 0217 /* ends a preprocessor command */
723721
724−@<Glob...@>=
725−boolean preprocessing=false; /* are we scanning a preprocessor command? */
722+@<Private...@>=
723+static boolean preprocessing=false; /* are we scanning a preprocessor command? */
726724
727725 @ @<Raise prep...@>= {
728726 preprocessing=true;
@@ -734,8 +732,8 @@ boolean preprocessing=false; /* are we scanning a preprocessor command? */ · 5 unmodified lines
734732 a file name in lines that start with \.{\#include}. We must treat this file
735733 name as a string.
736734
737−@<Glob...@>=
738−boolean sharp_include_line=false; /* are we scanning a |#include| line? */
735+@<Private...@>=
736+static boolean sharp_include_line=false; /* are we scanning a \&{\#include} line? */
739737
740738 @ @<Check if next token is |include|@>=
741739 while (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
844842 if (delim=='u' && *loc=='8') { *++id_loc=*loc++; }
845843 delim=*loc++; *++id_loc=delim;
846844 }
847− if (delim=='<') delim='>'; /* for file names in |#include| lines */
845+ if (delim=='<') delim='>'; /* for file names in \&{\#include} lines */
848846 while (true) {
849847 if (loc>=limit) {
850848 if(*(limit-1)!='\\') {
@@ -960,10 +958,7 @@ if (c=='@@') { · 109 unmodified lines
960958
961959 @ This function skips over a restricted context at relatively high speed.
962960
963−@<Predecl...@>=
964−static void skip_restricted(void);@/
965−
966−@ @c
961+@c
967962 static void
968963 skip_restricted(void)
969964 {
@@ -983,6 +978,8 @@ false_alarm: · 13 unmodified lines
983978 }
984979 }
985980
981+@ @<Predecl...@>=@+static void skip_restricted(void);
982+
986983 @ At the present point in the program we
987984 have |*(loc-1)==verbatim|; we set |id_first| to the beginning
988985 of 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
10071004 |get_next|; in interesting cases, this will be the control code that
10081005 ended a section or part of a section.
10091006
1010−@<Global...@>=
1011−eight_bits next_control; /* control code waiting to be acting upon */
1007+@<Private...@>=
1008+static eight_bits next_control; /* control code waiting to be acting upon */
10121009
10131010 @ The overall processing strategy in phase one has the following
10141011 straightforward outline.
10151012
1016−@<Predecl...@>=
1017−static void phase_one(void);@/
1018−
1019−@ @c
1013+@c
10201014 static void
10211015 phase_one(void) {
10221016 phase=1; reset_input(); section_count=0;
@@ -1029,6 +1023,8 @@ phase_one(void) { · 6 unmodified lines
10291023 @<Print error messages about unused or undefined section names@>@;
10301024 }
10311025
1026+@ @<Predecl...@>=@+static void phase_one(void);
1027+
10321028 @ @<Store cross-reference data...@>=
10331029 {
10341030 if (++section_count==max_sections) overflow("section number");
@@ -1067,7 +1063,7 @@ as well as |normal==0|. · 32 unmodified lines
10671063
10681064 @<Predecl...@>=
10691065 static void C_xref(eight_bits);@/
1070−static void outer_xref(void);@/
1066+static void outer_xref(void);
10711067
10721068 @ @c
10731069 static void
@@ -1161,9 +1157,9 @@ entirely, even if it contains \pb\ constructions. · 87 unmodified lines
11611157 The variables |lhs| and |rhs| point to the respective identifiers involved
11621158 in a format definition.
11631159
1164−@<Global...@>=
1165−name_pointer lhs, rhs; /* pointers to |byte_start| for format identifiers */
1166−name_pointer res_wd_end; /* pointer to the first nonreserved identifier */
1160+@<Private...@>=
1161+static name_pointer lhs, rhs; /* pointers to |byte_start| for format identifiers */
1162+static name_pointer res_wd_end; /* pointer to the first nonreserved identifier */
11671163
11681164 @ When we get to the following code we have |next_control>=format_code|.
11691165
@@ -1245,18 +1241,15 @@ if (next_control<=section_name) { /* |begin_C| or |section_name| */ · 75 unmodified lines
12451241 section name was both defined and used. The variable |cur_xref| will point
12461242 to cross-references for the current section name of interest.
12471243
1248−@<Global...@>=
1249−xref_pointer cur_xref; /* temporary cross-reference pointer */
1250−boolean an_output; /* did |file_flag| precede |cur_xref|? */
1244+@<Private...@>=
1245+static xref_pointer cur_xref; /* temporary cross-reference pointer */
1246+static boolean an_output; /* did |file_flag| precede |cur_xref|? */
12511247
12521248 @ The following recursive procedure
12531249 walks through the tree of section names and prints out anomalies.
12541250 @^recursion@>
12551251
1256−@<Predecl...@>=
1257−static void section_check(name_pointer);@/
1258−
1259−@ @c
1252+@c
12601253 static void
12611254 section_check(
12621255 name_pointer p) /* print anomalies in subtree |p| */
@@ -1281,6 +1274,8 @@ name_pointer p) /* print anomalies in subtree |p| */ · 18 unmodified lines
12811274 }
12821275 }
12831276
1277+@ @<Predecl...@>=@+static void section_check(name_pointer);
1278+
12841279 @ @<Print error messages about un...@>=section_check(root);
12851280
12861281 @* Low-level output routines.
@@ -1289,11 +1284,11 @@ characters long, so we place it into an output buffer. During the output · 2 unmodified lines
12891284 process, |out_line| will hold the current line number of the line about to
12901285 be output.
12911286
1292−@<Global...@>=
1293−char out_buf[line_length+1]; /* assembled characters */
1294−char *out_buf_end = out_buf+line_length; /* end of |out_buf| */
1295−char *out_ptr; /* last character in |out_buf| */
1296−int out_line; /* number of next line to be output */
1287+@<Private...@>=
1288+static char out_buf[line_length+1]; /* assembled characters */
1289+static char *out_buf_end = out_buf+line_length; /* end of |out_buf| */
1290+static char *out_ptr; /* last character in |out_buf| */
1291+static int out_line; /* number of next line to be output */
12971292
12981293 @ The |flush_buffer| routine empties the buffer up to a given breakpoint,
12991294 and moves any remaining characters to the beginning of the next line.
@@ -1314,7 +1309,7 @@ of commented-out text). · 14 unmodified lines
13141309
13151310 @<Predecl...@>=
13161311 static void flush_buffer(char *,boolean,boolean);@/
1317−static void finish_line(void);@/
1312+static void finish_line(void);
13181313
13191314 @ @c
13201315 static void
@@ -1379,7 +1374,7 @@ A line break will occur at a space or after a single-nonletter · 58 unmodified lines
13791374
13801375 @<Predecl...@>=
13811376 static void out_str(const char *);@/
1382−static void break_out(void);@/
1377+static void break_out(void);
13831378
13841379 @ @c
13851380 static void
@@ -1437,7 +1432,7 @@ the section is changed, we output `\.{\\*}' just after the number. · 51 unmodified lines
14371432
14381433 @<Predecl...@>=
14391434 static void out_section(sixteen_bits);@/
1440−static void out_name(name_pointer,boolean);@/
1435+static void out_name(name_pointer,boolean);
14411436
14421437 @ @c
14431438 static void
@@ -1484,7 +1479,7 @@ The use of `\.{@@}' signs is severely restricted in such material: · 40 unmodified lines
14841479 @<Predecl...@>=
14851480 static void copy_limbo(void);@/
14861481 static eight_bits copy_TeX(void);@/
1487−static int copy_comment(boolean,int);@/
1482+static int copy_comment(boolean,int);
14881483
14891484 @ @c
14901485 static void
@@ -1716,8 +1711,8 @@ same initial letter; these subscripts are assigned from left to right. · 225 unmodified lines
17161711 @d begin_arg 61 /* \.{@@[} */
17171712 @d end_arg 62 /* \.{@@]} */
17181713
1719−@<Glo...@>=
1720−char cat_name[256][12];
1714+@<Private...@>=
1715+static char cat_name[256][12];
17211716
17221717 @ @<Set in...@>=
17231718 {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
17831778
17841779 @ This code allows \.{CWEAVE} to display its parsing steps.
17851780
1786−@<Predecl...@>=
1787−static void print_cat(eight_bits);@/
1788−
1789−@ @c
1781+@c
17901782 static void
17911783 print_cat(@t\1\1@> /* symbolic printout of a category */
17921784 eight_bits c@t\2\2@>)
@@ -1794,6 +1786,8 @@ eight_bits c@t\2\2@>) · 1 unmodified line
17941786 fputs(cat_name[c],stdout);
17951787 }
17961788
1789+@ @<Predecl...@>=@+static void print_cat(eight_bits);
1790+
17971791 @ The token lists for translated \TEX/ output contain some special control
17981792 symbols as well as ordinary characters. These control symbols are
17991793 interpreted by \.{CWEAVE} before they are written to the output file.
@@ -2104,15 +2098,15 @@ typedef scrap *scrap_pointer; · 304 unmodified lines
21042098
21052099 @ @d trans trans_plus.Trans /* translation texts of scraps */
21062100
2107−@<Global...@>=
2108−scrap scrap_info[max_scraps]; /* memory array for scraps */
2109−scrap_pointer scrap_info_end=scrap_info+max_scraps-1; /* end of |scrap_info| */
2110−scrap_pointer scrap_base; /* beginning of the current scrap sequence */
2111−scrap_pointer scrap_ptr; /* ending of the current scrap sequence */
2112−scrap_pointer max_scr_ptr; /* largest value assumed by |scrap_ptr| */
2113−scrap_pointer pp; /* current position for reducing productions */
2114−scrap_pointer lo_ptr; /* last scrap that has been examined */
2115−scrap_pointer hi_ptr; /* first scrap that has not been examined */
2101+@<Private...@>=
2102+static scrap scrap_info[max_scraps]; /* memory array for scraps */
2103+static scrap_pointer scrap_info_end=scrap_info+max_scraps-1; /* end of |scrap_info| */
2104+static scrap_pointer scrap_base; /* beginning of the current scrap sequence */
2105+static scrap_pointer scrap_ptr; /* ending of the current scrap sequence */
2106+static scrap_pointer max_scr_ptr; /* largest value assumed by |scrap_ptr| */
2107+static scrap_pointer pp; /* current position for reducing productions */
2108+static scrap_pointer lo_ptr; /* last scrap that has been examined */
2109+static scrap_pointer hi_ptr; /* first scrap that has not been examined */
21162110
21172111 @ @<Set init...@>=
21182112 scrap_base=scrap_info+1;
@@ -2141,10 +2135,7 @@ translated without line-break controls. · 22 unmodified lines
21412135 @d tok_flag 4*id_flag /* signifies a token list */
21422136 @d inner_tok_flag 5*id_flag /* signifies a token list in `\pb' */
21432137
2144−@<Predecl...@>=
2145−static void print_text(text_pointer p);@/
2146−
2147−@ @c
2138+@c
21482139 static void
21492140 print_text(@t\1\1@> /* prints a token list for debugging; not used in |main| */
21502141 text_pointer p@t\2\2@>)
@@ -2169,6 +2160,8 @@ text_pointer p@t\2\2@>) · 18 unmodified lines
21692160 update_terminal;
21702161 }
21712162
2163+@ @<Predecl...@>=@+static void print_text(text_pointer p);
2164+
21722165 @ @<Print token |r|...@>=
21732166 switch (r) {
21742167 case math_rel: printf("\\mathrel{"@q}@>); break;
@@ -2265,13 +2258,13 @@ productions as they were listed earlier. · 90 unmodified lines
22652258 @d app(a) *(tok_ptr++)=(token)(a)
22662259 @d app1(a) *(tok_ptr++)=(token)(tok_flag+(int)((a)->trans-tok_start))
22672260
2268−@<Global...@>=
2269−int cur_mathness, init_mathness;
2261+@<Private...@>=
2262+static int cur_mathness, init_mathness;
22702263
22712264 @ @<Predecl...@>=
22722265 static void app_str(const char *);@/
22732266 static void big_app(token);@/
2274−static void big_app1(scrap_pointer);@/
2267+static void big_app1(scrap_pointer);
22752268
22762269 @ @c
22772270 static void
@@ -2428,7 +2421,7 @@ more properly alpha\-betized, · 150 unmodified lines
24282421 static token_pointer find_first_ident(text_pointer);@/
24292422 static void make_reserved(scrap_pointer);@/
24302423 static void make_underlined(scrap_pointer);@/
2431−static void underline_xref(name_pointer);@/
2424+static void underline_xref(name_pointer);
24322425
24332426 @ @c
24342427 static token_pointer
@@ -3022,7 +3015,7 @@ too large, since it is assumed that this test was done beforehand. · 587 unmodified lines
30223015
30233016 @<Predecl...@>=
30243017 static void reduce(scrap_pointer,short,eight_bits,short,short);@/
3025−static void squash(scrap_pointer,short,eight_bits,short,short);@/
3018+static void squash(scrap_pointer,short,eight_bits,short,short);
30263019
30273020 @ @c
30283021 static void
@@ -3114,8 +3107,8 @@ current stack categories will be printed out when |tracing| is set to 2; · 85 unmodified lines
31143107 a sequence of two or more irreducible scraps will be printed out when
31153108 |tracing| is set to 1.
31163109
3117−@<Global...@>=
3118−int tracing; /* can be used to show parsing details */
3110+@<Private...@>=
3111+static int tracing; /* can be used to show parsing details */
31193112
31203113 @ @<Print a snapsh...@>=
31213114 { 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
31463139 since |translate| might add a new text and a new scrap before it checks
31473140 for overflow.
31483141
3149−@<Predecl...@>=
3150−static text_pointer translate(void);@/
3151−
3152−@ @c
3142+@c
31533143 static text_pointer
31543144 translate(void) /* converts a sequence of scraps */
31553145 {
@@ -3161,6 +3151,8 @@ translate(void) /* converts a sequence of scraps */ · 5 unmodified lines
31613151 @<Combine the irreducible scraps that remain@>@;
31623152 }
31633153
3154+@ @<Predecl...@>=@+static text_pointer translate(void);
3155+
31643156 @ If the initial sequence of scraps does not reduce to a single scrap,
31653157 we concatenate the translations of all remaining scraps, separated by
31663158 blank 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
32143206 what it reads are appended into the |cat| and |trans| arrays, and |scrap_ptr|
32153207 is advanced.
32163208
3217−@<Predecl...@>=
3218−static void C_parse(eight_bits);@/
3219−
3220−@ @c
3209+@c
32213210 static void
32223211 C_parse(@t\1\1@> /* creates scraps from \CEE/ tokens */
32233212 eight_bits spec_ctrl@t\2\2@>)
@@ -3231,6 +3220,8 @@ C_parse(@t\1\1@> /* creates scraps from \CEE/ tokens */ · 7 unmodified lines
32313220 }
32323221 }
32333222
3223+@ @<Predecl...@>=@+static void C_parse(eight_bits);
3224+
32343225 @ The following macro is used to append a scrap whose tokens have just
32353226 been appended:
32363227
@@ -3452,7 +3443,7 @@ token list; it also builds a new scrap if |scrapping==true|. · 215 unmodified lines
34523443 @<Predec...@>=
34533444 static void app_cur_id(boolean);@/
34543445 static text_pointer C_translate(void);@/
3455−static void outer_parse(void);@/
3446+static void outer_parse(void);
34563447
34573448 @ @c
34583449 static void
@@ -3604,12 +3595,12 @@ typedef output_state *stack_pointer; · 145 unmodified lines
36043595 @d cur_mode cur_state.mode_field /* current mode of interpretation */
36053596 @d init_stack stack_ptr=stack;cur_mode=outer /* initialize the stack */
36063597
3607−@<Global...@>=
3608−output_state cur_state; /* |cur_end|, |cur_tok|, |cur_mode| */
3609−output_state stack[stack_size]; /* info for non-current levels */
3610−stack_pointer stack_end=stack+stack_size-1; /* end of |stack| */
3611−stack_pointer stack_ptr; /* first unused location in the output state stack */
3612−stack_pointer max_stack_ptr; /* largest value assumed by |stack_ptr| */
3598+@<Private...@>=
3599+static output_state cur_state; /* |cur_end|, |cur_tok|, |cur_mode| */
3600+static output_state stack[stack_size]; /* info for non-current levels */
3601+static stack_pointer stack_end=stack+stack_size-1; /* end of |stack| */
3602+static stack_pointer stack_ptr; /* first unused location in the output state stack */
3603+static stack_pointer max_stack_ptr; /* largest value assumed by |stack_ptr| */
36133604
36143605 @ @<Set init...@>=
36153606 max_stack_ptr=stack;
@@ -3620,7 +3611,7 @@ The value of |cur_mode| is not changed. · 4 unmodified lines
36203611
36213612 @<Predecl...@>=
36223613 static void push_level(text_pointer);@/
3623−static void pop_level(void);@/
3614+static void pop_level(void);
36243615
36253616 @ @c
36263617 static void
@@ -3658,8 +3649,8 @@ by a complex routine that might generate additional levels of output). · 31 unmodified lines
36583649 In these cases |cur_name| points to the identifier or section name in
36593650 question.
36603651
3661−@<Global...@>=
3662−name_pointer cur_name;
3652+@<Private...@>=
3653+static name_pointer cur_name;
36633654
36643655 @ @d res_word 0201 /* returned by |get_output| for reserved words */
36653656 @d section_code 0200 /* returned by |get_output| for section names */
@@ -3667,7 +3658,7 @@ name_pointer cur_name; · 1 unmodified line
36673658 @<Predecl...@>=
36683659 static eight_bits get_output(void);@/
36693660 static void output_C(void);@/
3670−static void make_output(void);@/
3661+static void make_output(void);
36713662
36723663 @ @c
36733664 static eight_bits
@@ -3990,10 +3981,7 @@ is analogous to phase one, except that more work is involved because we must · 316 unmodified lines
39903981 actually output the \TEX/ material instead of merely looking at the
39913982 \.{CWEB} specifications.
39923983
3993−@<Predecl...@>=
3994−static void phase_two(void);@/
3995−
3996−@ @c
3984+@c
39973985 static void
39983986 phase_two(void) {
39993987 reset_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
40033991 while (!input_has_ended) @<Translate the current section@>@;
40043992 }
40053993
3994+@ @<Predecl...@>=@+static void phase_two(void);
3995+
40063996 @ The output file will contain the control sequence \.{\\Y} between non-null
40073997 sections of a section, e.g., between the \TEX/ and definition parts if both
40083998 are 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
40174007 space_checked=true;
40184008 @.\\Y@>
40194009
4020−@<Global...@>=
4021−int save_line; /* former value of |out_line| */
4022−char *save_place; /* former value of |out_ptr| */
4023−int sec_depth; /* the integer, if any, following \.{@@*} */
4024−boolean space_checked; /* have we done |emit_space_if_needed|? */
4025−boolean format_visible; /* should the next format declaration be output? */
4026−boolean doing_format=false; /* are we outputting a format declaration? */
4027−boolean group_found=false; /* has a starred section occurred? */
4010+@<Private...@>=
4011+static int save_line; /* former value of |out_line| */
4012+static char *save_place; /* former value of |out_ptr| */
4013+static int sec_depth; /* the integer, if any, following \.{@@*} */
4014+static boolean space_checked; /* have we done |emit_space_if_needed|? */
4015+static boolean format_visible; /* should the next format declaration be output? */
4016+static boolean doing_format=false; /* are we outputting a format declaration? */
4017+static boolean group_found=false; /* has a starred section occurred? */
40284018
40294019 @ @<Translate the current section@>= {
40304020 section_count++;
@@ -4113,10 +4103,7 @@ takes place, so that the translation will normally end with \.{\\6} or · 82 unmodified lines
41134103 \.{\\7} (the \TEX/ macros for |force| and |big_force|). This \.{\\6} or
41144104 \.{\\7} is replaced by the concluding \.{\\par} or by \.{\\Y\\par}.
41154105
4116−@<Predecl...@>=
4117−static void finish_C(boolean);@/
4118−
4119−@ @c
4106+@c
41204107 static void
41214108 finish_C(@t\1\1@> /* finishes a definition or a \CEE/ part */
41224109 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
41454132 /* forget the tokens and the scraps */
41464133 }
41474134
4135+@ @<Predecl...@>=@+static void finish_C(boolean);
4136+
41484137 @ Keeping in line with the conventions of the \CEE/ preprocessor (and
41494138 otherwise contrary to the rules of \.{CWEB}) we distinguish here
41504139 between the case that `\.(' immediately follows an identifier and the
@@ -4202,8 +4191,8 @@ it starts after we scan the matching `\.)'. · 51 unmodified lines
42024191 |next_control>=begin_C|. We will make the global variable |this_section|
42034192 point to the current section name, if it has a name.
42044193
4205−@<Global...@>=
4206−name_pointer this_section; /* the current section name, or zero */
4194+@<Private...@>=
4195+static name_pointer this_section; /* the current section name, or zero */
42074196
42084197 @ @<Translate the \CEE/...@>=
42094198 this_section=name_dir;
@@ -4286,10 +4275,7 @@ leaves |cur_xref| pointing to the first element not printed. Typical outputs: · 76 unmodified lines
42864275 Note that the output of \.{CWEAVE} is not English-specific; users may
42874276 supply new definitions for the macros \.{\\A}, \.{\\As}, etc.
42884277
4289−@<Predecl...@>=
4290−static void footnote(sixteen_bits);@/
4291−
4292−@ @c
4278+@c
42934279 static void
42944280 footnote(@t\1\1@> /* outputs section cross-references */
42954281 sixteen_bits flag@t\2\2@>)
@@ -4305,6 +4291,8 @@ sixteen_bits flag@t\2\2@>) · 9 unmodified lines
43054291 out('.');
43064292 }
43074293
4294+@ @<Predecl...@>=@+static void footnote(sixteen_bits);
4295+
43084296 @ The following code distinguishes three cases, according as the number
43094297 of cross-references is one, two, or more than two. Variable |q| points
43104298 to 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
43354323 just finish off the page, omitting the index, section name list, and table of
43364324 contents.
43374325
4338−@<Predecl...@>=
4339−static void phase_three(void);@/
4340−
4341−@ @c
4326+@c
43424327 static void
43434328 phase_three(void) {
43444329 if (no_xref) {
@@ -4386,11 +4371,13 @@ if (show_happiness) { · 41 unmodified lines
43864371 check_complete(); /* was all of the change file used? */
43874372 }
43884373
4374+@ @<Predecl...@>=@+static void phase_three(void);
4375+
43894376 @ Just before the index comes a list of all the changed sections, including
43904377 the index section itself.
43914378
4392−@<Global...@>=
4393−sixteen_bits k_section; /* runs through the sections */
4379+@<Private...@>=
4380+static sixteen_bits k_section; /* runs through the sections */
43944381
43954382 @ @<Tell about changed sections@>= {
43964383 /* 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
44154402 list for character |c| begins at location |bucket[c]| and continues through
44164403 the |blink| array.
44174404
4418−@<Global...@>=
4419−name_pointer bucket[256];
4420−name_pointer next_name; /* successor of |cur_name| when sorting */
4421−name_pointer blink[max_names]; /* links in the buckets */
4405+@<Private...@>=
4406+static name_pointer bucket[256];
4407+static name_pointer next_name; /* successor of |cur_name| when sorting */
4408+static name_pointer blink[max_names]; /* links in the buckets */
44224409
44234410 @ To begin the sorting, we go through all the hash lists and put each entry
44244411 having a nonempty cross-reference list into the proper bucket.
@@ -4458,11 +4445,11 @@ name_pointer Head; · 33 unmodified lines
44584445 @d sort_ptr scrap_ptr /* ditto */
44594446 @d max_sorts max_scraps /* ditto */
44604447
4461−@<Global...@>=
4462−eight_bits cur_depth; /* depth of current buckets */
4463−char *cur_byte; /* index into |byte_mem| */
4464−sixteen_bits cur_val; /* current cross-reference number */
4465−sort_pointer max_sort_ptr; /* largest value of |sort_ptr| */
4448+@<Private...@>=
4449+static eight_bits cur_depth; /* depth of current buckets */
4450+static char *cur_byte; /* index into |byte_mem| */
4451+static sixteen_bits cur_val; /* current cross-reference number */
4452+static sort_pointer max_sort_ptr; /* largest value of |sort_ptr| */
44664453
44674454 @ @<Set init...@>=
44684455 max_sort_ptr=scrap_info;
@@ -4470,8 +4457,8 @@ max_sort_ptr=scrap_info; · 1 unmodified line
44704457 @ The desired alphabetic order is specified by the |collate| array; namely,
44714458 $|collate|[0]<|collate|[1]<\cdots<|collate|[100]$.
44724459
4473−@<Global...@>=
4474−eight_bits collate[101+128]; /* collation order */
4460+@<Private...@>=
4461+static eight_bits collate[101+128]; /* collation order */
44754462 @^high-bit character handling@>
44764463
44774464 @ We use the order $\hbox{null}<\.\ <\hbox{other characters}<{}$\.\_${}<
@@ -4530,10 +4517,7 @@ regarded as identical. · 52 unmodified lines
45304517
45314518 @d infinity 255 /* $\infty$ (approximately) */
45324519
4533−@<Predecl...@>=
4534−static void unbucket(eight_bits);@/
4535−
4536−@ @c
4520+@c
45374521 static void
45384522 unbucket(@t\1\1@> /* empties buckets having depth |d| */
45394523 eight_bits d@t\2\2@>)
@@ -4551,6 +4535,8 @@ eight_bits d@t\2\2@>) · 11 unmodified lines
45514535 }
45524536 }
45534537
4538+@ @<Predecl...@>=@+static void unbucket(eight_bits);
4539+
45544540 @ @<Sort and output...@>=
45554541 sort_ptr=scrap_info; unbucket(1);
45564542 while (sort_ptr>scrap_info) {
@@ -4635,8 +4621,8 @@ out('.'); finish_line(); · 78 unmodified lines
46354621 @ List inversion is best thought of as popping elements off one stack and
46364622 pushing them onto another. In this case |cur_xref| will be the head of
46374623 the stack that we push things onto.
4638−@<Global...@>=
4639−xref_pointer next_xref, this_xref;
4624+@<Private...@>=
4625+static xref_pointer next_xref, this_xref;
46404626 /* pointer variables for rearranging a list */
46414627
46424628 @ @<Invert the cross-reference list at |cur_name|, making |cur_xref| the head@>=
@@ -4650,10 +4636,7 @@ do { · 7 unmodified lines
46504636 prints them.
46514637 @^recursion@>
46524638
4653−@<Predecl...@>=
4654−static void section_print(name_pointer);@/
4655−
4656−@ @c
4639+@c
46574640 static void
46584641 section_print(@t\1\1@> /* print all section names in subtree |p| */
46594642 name_pointer p@t\2\2@>)
@@ -4670,6 +4653,8 @@ name_pointer p@t\2\2@>) · 10 unmodified lines
46704653 }
46714654 }
46724655
4656+@ @<Predecl...@>=@+static void section_print(name_pointer);
4657+
46734658 @ @<Output all the section names@>=section_print(root);
46744659
46754660 @ Because on some systems the difference between two pointers is a |ptrdiff_t|
cwebmac.tex+2−2
@@ -1,7 +1,7 @@
11 % standard macros for CWEB listings (in addition to plain.tex)
2−% Version 4.1 --- February 2021
2+% Version 4.2 --- February 2021
33 \ifx\renewenvironment\undefined\else\endinput\fi % LaTeX will use other macros
4−\xdef\fmtversion{\fmtversion+CWEB4.1}
4+\xdef\fmtversion{\fmtversion+CWEB4.2}
55 \chardef\cwebversion=4 \chardef\cwebrevision=1
66 \newif\ifpdf
77 \ifx\pdf+\pdftrue\fi
cwebman.tex+15−15
@@ -36,7 +36,7 @@ · 35 unmodified lines
3636
3737 \def\lheader{\mainfont\the\pageno\hfill\sc\runninghead\hfill}
3838 \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)}
4040
4141 % This verbatim mode assumes that ! marks are !! in the text being copied.
4242 \def\verbatim{\begingroup
@@ -50,7 +50,7 @@ · 7 unmodified lines
5050 \null\vfill
5151 \centerline{\titlefont The {\ttitlefont CWEB} System of
5252 Structured Documentation}
53−\vskip 18pt\centerline{(Version 4.1 --- February 2021)}
53+\vskip 18pt\centerline{(Version 4.2 --- February 2021)}
5454 \vskip 24pt
5555 \centerline{\authorfont Donald E. Knuth and Silvio Levy}
5656 \vfill
@@ -398,15 +398,15 @@ $$\hbox{ If \\{pa} is declared as `\&{int} ${}{*}\\{pa}$', · 341 unmodified lines
398398 the assignment $\\{pa}\K{\AND}\|a[\T{0}]$ makes \\{pa}
399399 point to the zeroth element of \|a.}$$
400400 The \TEX/ text would look like this in your \.{CWEB} file:
401−$$\lpile{\.{If |pa| is declared as `|int *pa|', the}\cr
402−\.{assignment |pa=\&a[0]| makes |pa| point
403−to the zeroth element of |a|.}\cr}$$
404−And \.{CWEAVE} translates this into something you are glad you didn't have
405−to type:
406−$$\lpile{\.{If \\\\\{pa\} is declared as
407− `\\\&\{int\} \$\{\}\{*\}\\\\\{pa\}\$',}\cr
408−\.{the assignment \$\\\\\{pa\}\\K\{\\AND\}\\|a[\\T\{0\}]\$}\cr
409−\.{makes \\\\\{pa\} point to the zeroth element of \\|a.}\cr}$$
401+$$\lpile{\.{If |pa| is declared as `|int *pa|', the assignment}\cr
402+\.{|pa=\&a[0]| makes |pa| point to the zeroth element of |a|.}\cr}$$
403+And \.{CWEAVE} translates this into something
404+you are glad you didn't have to type:
405+$$\lpile{\.{If \\PB\{\\\\\{pa\}\} is declared as `\\PB\{\\\&\{int\}
406+ \$\{\}\{*\}\\\\\{pa\}\$\}', the}\cr
407+\.{assignment \\PB\{\$\\\\\{pa\}\\K\{\\AND\}\\|a[\\T\{0\}]\$\}
408+ makes \\PB\{\\\\\{pa\}\} point}\cr
409+\.{to the zeroth element of \\PB\{\\|a\}.}\cr}$$
410410 Incidentally, the cross-reference index that \.{CWEAVE} would make, in
411411 the presence of a comment like this, would include
412412 the 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
10111011
10121012 \section Running the programs.
10131013 The \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]]]}$$
10151015 and the same conventions apply to \.{CWEAVE}. If `\.-' or no change file is
10161016 specified, the change file is null. The extensions \.{.w} and \.{.ch}
10171017 are appended only if the given file names contain no dot. If the
@@ -1042,7 +1042,7 @@ by default.) · 24 unmodified lines
10421042
10431043 \option e Enclose \CEE/ material formatted by \.{CWEAVE} in
10441044 brackets \.{\\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}.)
10461046
10471047 \option f Force line breaks after each \CEE/ statement formatted
10481048 by \.{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
13361336 \def\runninghead{APPENDIX A --- TRANSLATION BY {\tentt CWEAVE}}
13371337
13381338 Here 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.)
13401340
13411341 \vskip6pt
13421342 \begingroup \def\tt{\eighttt} \baselineskip9pt
@@ -1591,7 +1591,7 @@ $$\lpile{\.{\\def\\topofcontents\{\\null\\vfill}\cr · 248 unmodified lines
15911591 \.{ { }\\titlefalse \% include headline on the contents page}\cr
15921592 \.{ { }\\def\\rheader\{\\mainfont The \{\\tt CWEAVE\}{ }processor\\hfil\}}\cr
15931593 \.{ { }\\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}$$
15951595 Redefining \.{\\rheader}, which is the headline for right-hand pages,
15961596 suffices in this case to put the desired information at the top of the
15971597 contents 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