History

CWEB — Release 3.64, 2002-07-12.

Andreas Scherer committed 15 years ago

Commit f6febbe1 parent f6c448327 files · +800 −384Browse files

Unified · Split

27 files
  1. Makefile +2 −1
  2. README +5 −1
  3. comm-mac.ch +2 −2
  4. comm-man.ch +1 −1
  5. comm-ql.ch +4 −4
  6. comm-w32.ch +94 −0
  7. common.c +93 −87
  8. common.w +18 −12
  9. ctang-bs.ch +2 −2
  10. ctang-man.ch +1 −1
  11. ctang-pc.ch +2 −2
  12. ctang-ql.ch +4 −4
  13. ctang-vms.ch +2 −2
  14. ctang-w32.ch +66 −0
  15. ctangle.c +61 −60
  16. ctangle.w +28 −27
  17. cweav-bs.ch +2 −2
  18. cweav-man.ch +1 −1
  19. cweav-pc.ch +2 −2
  20. cweav-ql.ch +4 −4
  21. cweav-vms.ch +2 −2
  22. cweav-w32.ch +52 −0
  23. cweave.w +8 −10
  24. cweb.1 +76 −44
  25. cwebmac.tex +178 −79
  26. cwebman.tex +61 −13
  27. examples/wmerge.w +29 −21
Makefile+2−1
@@ -1,6 +1,6 @@
11 # This file is part of CWEB.
22 # It is distributed WITHOUT ANY WARRANTY, express or implied.
3−# Version 3.63 --- January 2001
3+# Version 3.64 --- February 2002
44
55 # Copyright (C) 1987,1990,1993,2000 Silvio Levy and Donald E. Knuth
66
@@ -78,6 +78,7 @@ ALL = common.w ctangle.w cweave.w prod.w \ · 71 unmodified lines
7878 comm-pc.ch ctang-pc.ch cweav-pc.ch comm-amiga.ch \
7979 comm-bs.ch ctang-bs.ch cweav-bs.ch makefile.bs \
8080 comm-ql.ch ctang-ql.ch cweav-ql.ch readme.ql \
81+ comm-w32.ch ctang-w32.ch cweav-w32.ch \
8182 comm-os2.ch comm-mac.ch cweb.1 cweb.el c++lib.w README
8283
8384 .SUFFIXES: .dvi .tex .w .pdf
README+5−1
@@ -27,6 +27,7 @@ comm-man.ch · 26 unmodified lines
2727 comm-pc.ch
2828 comm-ql.ch
2929 comm-vms.ch
30+comm-w32.ch
3031 common.c
3132 common.h
3233 common.w
@@ -35,6 +36,7 @@ ctang-man.ch · 2 unmodified lines
3536 ctang-pc.ch
3637 ctang-ql.ch
3738 ctang-vms.ch
39+ctang-w32.ch
3840 ctangle.c
3941 ctangle.w
4042 cweav-bs.ch
@@ -42,6 +44,7 @@ cweav-man.ch · 1 unmodified line
4244 cweav-pc.ch
4345 cweav-ql.ch
4446 cweav-vms.ch
47+cweave-w32.ch
4548 cweave.w
4649 cweb.1
4750 cweb.el
@@ -59,10 +62,11 @@ The files common.c and ctangle.c are used for bootstrapping. · 11 unmodified lines
5962 The file cweb.1 is a manual page.
6063 The file cweb.el is suggested for GNU-Emacs users.
6164 The file c++lib.w is for C++ users (say `@i c++lib.w' at beginning of program).
62−The files *-man.ch are used if you want to make the full 237-page CWEB manual.
65+The files *-man.ch are used if you want to make the full 239-page CWEB manual.
6366 The files *-bs.ch are used instead of *-pc.ch if you are doing BIG programs.
6467 You can use makefile.bs to make CWEB with *-bs.ch.
6568 The files *-ql.ch are for QDOS/SMSQ systems; see readme.ql for further info.
69+The files *-w32.ch use __fastcall conventions on win32 systems.
6670 The file comm-mac.ch is for Macintosh conventions.
6771 The other files named *.ch are sample change files for local customization.
6872
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 3.61)}
7+ \centerline{(Version 3.64)}
88 @y
9− \centerline{(Version 3.61 for MacOS)}
9+ \centerline{(Version 3.64 for MacOS)}
1010 @z
1111
1212 @x section 9: Make input_ln accept \n, \r, \n\r, or \r\n as line endings
comm-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{27}
19+\def\contentspagenumber{28}
2020 \def\title{APPENDIX D: COMMON}
2121 \let\K=\leftarrow
2222 @z
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 3.61)}
13+\def\title{Common code for CTANGLE and CWEAVE (Version 3.64)}
1414 \def\topofcontents{\null\vfill
1515 \centerline{\titlefont Common code for {\ttitlefont CTANGLE} and
1616 {\ttitlefont CWEAVE}}
1717 \vskip 15pt
18− \centerline{(Version 3.61)}
18+ \centerline{(Version 3.64)}
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 3.61)}
25+\def\title{Common code for CTANGLE and CWEAVE (QL Version 3.64)}
2626 \def\topofcontents{\null\vfill
2727 \centerline{\titlefont Common code for {\ttitlefont CTANGLE} and
2828 {\ttitlefont CWEAVE}}
2929 \vskip 15pt
30− \centerline{(Version 3.61)}
30+ \centerline{(Version 3.64)}
3131 \vfill}
3232 \def\botofcontents{\vfill
3333 \noindent
comm-w32.ch+94−0
@@ -0,0 +1,94 @@
1+This is the change file for CWEB's COMMON under Win32
2+(Contributed by Fabrice Popineau, February 2002 <Fabrice.Popineau@supelec.fr>)
3+
4+The Microsoft C compiler included in Visual Studio allows for different
5+parameter passing conventions than the standard one. This is actually
6+specified with the Intel IA32 architecture. There exist three
7+calling conventions under the IA32 architecture as defined by Intel.
8+
9+One of them is the standard C calling convention: Parameters are passed on
10+the stack, calling function is responsible to unstack arguments. Names are
11+decorated with a prefixed underscore. It is called the __cdecl convention.
12+
13+Another calling convention is the __fastcall convention. The first two 32bits
14+arguments are passed on the stack. The called function is responsible for
15+stack maintenance. Names are decorated with an @ sign as prefix, and another
16+@ sign followed by the size of the arguments as suffix.
17+
18+The third one is the __stdcall convention and is basically the Pascal calling
19+convention.
20+
21+Using the __fastcall convention is usually faster on Intel architecture. Names
22+are decorated because obviously a __cdecl function can't behave the same way
23+as a __fastcall one of the same prototype. So the new full prototype includes
24+the keyword __cdecl or __fastcall. A compiler option allows to compile all
25+functions using one or the other calling convention. If you compile using
26+__fastcall, then you are bound to explicitly declare a few functions as
27+__cdecl : the ones that are passed to the C library (like function pointers
28+for qsort() or signal()) or functions that replace functions from the C
29+library, because the standard headers have a __cdecl prototype for these
30+functions. Also, you cannot declare a library function without giving it the
31+exact prototype used in the library headers files. So you'd better use the
32+header files to be safe.
33+
34+Admittedly, this is not vital for cweb, except that I build the whole texlive
35+set of programs using the __fastcall convention.
36+
37+@x
38+@<Include files@>=
39+#include <ctype.h>
40+@y
41+@<Include files@>=
42+#include <ctype.h>
43+#include <string.h>
44+@z
45+
46+@x
47+@ @<Predec...@>=
48+extern int names_match();
49+@y
50+@ @<Predec...@>=
51+extern int __cdecl names_match();
52+@z
53+
54+@x
55+@<Pred...@>=
56+void init_p();
57+@y
58+@<Pred...@>=
59+void __cdecl init_p();
60+@z
61+
62+@x section 69
63+An omitted change file argument means that |"/dev/null"| should be used,
64+@y
65+An omitted change file argument means that |"NUL"| should be used,
66+@z
67+
68+@x section 70 (this change copied from comm-bs.ch, July 94)
69+ else if (*s=='/') dot_pos=NULL,name_pos=++s;
70+@y
71+ else if (*s == ':' || *s == '\\' || *s == '/')
72+ dot_pos=NULL,name_pos=++s;
73+@z
74+
75+@x section 70
76+ if (found_change<=0) strcpy(change_file_name,"/dev/null");
77+@y
78+ if (found_change<=0) strcpy(change_file_name,"NUL");
79+@z
80+
81+@x
82+@ We predeclare several standard system functions here instead of including
83+their system header files, because the names of the header files are not as
84+standard as the names of the functions. (For example, some \CEE/ environments
85+have \.{<string.h>} where others have \.{<strings.h>}.)
86+
87+@<Predecl...@>=
88+extern int strlen(); /* length of string */
89+extern int strcmp(); /* compare strings lexicographically */
90+extern char* strcpy(); /* copy one string to another */
91+extern int strncmp(); /* compare up to $n$ string characters */
92+extern char* strncpy(); /* copy up to $n$ string characters */
93+@y
94+@z
common.c+93−87
@@ -12,7 +12,7 @@ · 11 unmodified lines
1212 #include <stdio.h>
1313
1414 /*:8*//*22:*/
15−#line 470 "common.w"
15+#line 471 "common.w"
1616
1717 #include <stdlib.h>
1818
@@ -165,17 +165,17 @@ boolean change_pending; · 146 unmodified lines
165165 boolean print_where= 0;
166166
167167 /*:20*//*27:*/
168−#line 588 "common.w"
168+#line 594 "common.w"
169169
170170 typedef struct name_info{
171171 char*byte_start;
172172 /*31:*/
173−#line 625 "common.w"
173+#line 631 "common.w"
174174
175175 struct name_info*link;
176176
177177 /*:31*//*40:*/
178−#line 724 "common.w"
178+#line 730 "common.w"
179179
180180 union{
181181 struct name_info*Rlink;
@@ -184,12 +184,12 @@ char Ilk; · 2 unmodified lines
184184 }dummy;
185185
186186 /*:40*//*55:*/
187−#line 1056 "common.w"
187+#line 1062 "common.w"
188188
189189 char*equiv_or_xref;
190190
191191 /*:55*/
192−#line 591 "common.w"
192+#line 597 "common.w"
193193
194194 }name_info;
195195 typedef name_info*name_pointer;
@@ -199,13 +199,13 @@ name_info name_dir[max_names]; · 3 unmodified lines
199199 name_pointer name_dir_end= name_dir+max_names-1;
200200
201201 /*:27*//*29:*/
202−#line 611 "common.w"
202+#line 617 "common.w"
203203
204204 name_pointer name_ptr;
205205 char*byte_ptr;
206206
207207 /*:29*//*32:*/
208−#line 638 "common.w"
208+#line 644 "common.w"
209209
210210 typedef name_pointer*hash_pointer;
211211 name_pointer hash[hash_size];
@@ -213,12 +213,12 @@ hash_pointer hash_end= hash+hash_size-1; · 1 unmodified line
213213 hash_pointer h;
214214
215215 /*:32*//*56:*/
216−#line 1076 "common.w"
216+#line 1082 "common.w"
217217
218218 int history= spotless;
219219
220220 /*:56*//*67:*/
221−#line 1214 "common.w"
221+#line 1220 "common.w"
222222
223223 int argc;
224224 char**argv;
@@ -229,7 +229,7 @@ char scn_file_name[max_file_name_length]; · 4 unmodified lines
229229 boolean flags[128];
230230
231231 /*:67*//*77:*/
232−#line 1364 "common.w"
232+#line 1370 "common.w"
233233
234234 FILE*C_file;
235235 FILE*tex_file;
@@ -254,48 +254,48 @@ char*change_limit; · 18 unmodified lines
254254 #line 62 "common.w"
255255
256256 /*33:*/
257−#line 644 "common.w"
257+#line 650 "common.w"
258258
259259 extern int names_match();
260260
261261 /*:33*//*38:*/
262−#line 697 "common.w"
262+#line 703 "common.w"
263263
264264 void init_p();
265265
266266 /*:38*//*46:*/
267−#line 846 "common.w"
267+#line 852 "common.w"
268268
269269 extern void init_node();
270270
271271 /*:46*//*53:*/
272−#line 1011 "common.w"
272+#line 1017 "common.w"
273273
274274 int section_name_cmp();
275275
276276 /*:53*//*57:*/
277−#line 1086 "common.w"
277+#line 1092 "common.w"
278278
279279 void err_print();
280280
281281 /*:57*//*60:*/
282−#line 1134 "common.w"
282+#line 1140 "common.w"
283283
284284 int wrap_up();
285285 extern void print_stats();
286286
287287 /*:60*//*63:*/
288−#line 1167 "common.w"
288+#line 1173 "common.w"
289289
290290 void fatal(),overflow();
291291
292292 /*:63*//*69:*/
293−#line 1245 "common.w"
293+#line 1251 "common.w"
294294
295295 void scan_args();
296296
297297 /*:69*//*81:*/
298−#line 1405 "common.w"
298+#line 1411 "common.w"
299299
300300 extern int strlen();
301301 extern int strcmp();
@@ -314,19 +314,19 @@ void · 12 unmodified lines
314314 common_init()
315315 {
316316 /*30:*/
317−#line 615 "common.w"
317+#line 621 "common.w"
318318
319319 name_dir->byte_start= byte_ptr= byte_mem;
320320 name_ptr= name_dir+1;
321321 name_ptr->byte_start= byte_mem;
322322
323323 /*:30*//*34:*/
324−#line 649 "common.w"
324+#line 655 "common.w"
325325
326326 for(h= hash;h<=hash_end;*h++= NULL);
327327
328328 /*:34*//*41:*/
329−#line 731 "common.w"
329+#line 737 "common.w"
330330
331331 root= NULL;
332332
@@ -334,7 +334,7 @@ root= NULL; · 1 unmodified line
334334 #line 93 "common.w"
335335 ;
336336 /*68:*/
337−#line 1227 "common.w"
337+#line 1233 "common.w"
338338
339339 show_banner= show_happiness= show_progress= 1;
340340
@@ -342,7 +342,7 @@ show_banner= show_happiness= show_progress= 1; · 1 unmodified line
342342 #line 94 "common.w"
343343 ;
344344 /*78:*/
345−#line 1371 "common.w"
345+#line 1377 "common.w"
346346
347347 scan_args();
348348 if(program==ctangle){
@@ -428,7 +428,7 @@ return; · 79 unmodified lines
428428 #line 292 "common.w"
429429
430430 {
431−change_limit= change_buffer-buffer+limit;
431+change_limit= change_buffer+(limit-buffer);
432432 strncpy(change_buffer,buffer,limit-buffer+1);
433433 }
434434
@@ -459,15 +459,15 @@ change_limit= change_buffer;changing= 0; · 24 unmodified lines
459459 return;
460460 }
461461 if(limit> buffer+1&&buffer[0]=='@'){
462−if(xisupper(buffer[1]))buffer[1]= tolower(buffer[1]);
462+char xyz_code= xisupper(buffer[1])?tolower(buffer[1]):buffer[1];
463463 /*17:*/
464464 #line 358 "common.w"
465465
466−if(buffer[1]=='x'||buffer[1]=='z'){
466+if(xyz_code=='x'||xyz_code=='z'){
467467 loc= buffer+2;err_print("! Where is the matching @y?");
468468
469469 }
470−else if(buffer[1]=='y'){
470+else if(xyz_code=='y'){
471471 if(n> 0){
472472 loc= buffer+2;
473473 printf("\n! Hmm... %d ",n);
@@ -486,7 +486,7 @@ return; · 12 unmodified lines
486486 #line 292 "common.w"
487487
488488 {
489−change_limit= change_buffer-buffer+limit;
489+change_limit= change_buffer+(limit-buffer);
490490 strncpy(change_buffer,buffer,limit-buffer+1);
491491 }
492492
@@ -544,7 +544,7 @@ int get_line() · 51 unmodified lines
544544 restart:
545545 if(changing&&include_depth==change_depth)
546546 /*25:*/
547−#line 531 "common.w"
547+#line 537 "common.w"
548548 {
549549 change_line++;
550550 if(!input_ln(change_file)){
@@ -579,7 +579,7 @@ prime_the_change_buffer();changing= !changing;print_where= 1; · 28 unmodified lines
579579 ;
580580 if(!changing||include_depth> change_depth){
581581 /*24:*/
582−#line 514 "common.w"
582+#line 520 "common.w"
583583 {
584584 cur_line++;
585585 while(!input_ln(cur_file)){
@@ -602,10 +602,11 @@ if(change_limit> change_buffer)check_change(); · 16 unmodified lines
602602 ;
603603 if(changing&&include_depth==change_depth)goto restart;
604604 }
605+if(input_has_ended)return 0;
605606 loc= buffer;*limit= ' ';
606−if(*buffer=='@'&&(*(buffer+1)=='i'||*(buffer+1)=='I')){
607−loc= buffer+2;
608−while(loc<=limit&&(*loc==' '||*loc=='\t'||*loc=='"'))loc++;
607+if(buffer[0]=='@'&&(buffer[1]=='i'||buffer[1]=='I')){
608+loc= buffer+2;*limit= '"';
609+while(*loc==' '||*loc=='\t')loc++;
609610 if(loc>=limit){
610611 err_print("! Include file name not given");
611612
@@ -618,13 +619,18 @@ goto restart; · 6 unmodified lines
618619 }
619620 include_depth++;
620621 /*23:*/
621−#line 473 "common.w"
622+#line 474 "common.w"
622623 {
623624 char temp_file_name[max_file_name_length];
624625 char*cur_file_name_end= cur_file_name+max_file_name_length-1;
625626 char*k= cur_file_name,*kk;
626627 int l;
627628
629+if(*loc=='"'){
630+loc++;
631+while(*loc!='"'&&k<=cur_file_name_end)*k++= *loc++;
632+if(loc==limit)k= cur_file_name_end+1;
633+}else
628634 while(*loc!=' '&&*loc!='\t'&&*loc!='"'&&k<=cur_file_name_end)*k++= *loc++;
629635 if(k> cur_file_name_end)too_long();
630636
@@ -661,14 +667,14 @@ include_depth--;err_print("! Cannot open include file");goto restart; · 30 unmodified lines
661667 }
662668
663669 /*:23*/
664−#line 451 "common.w"
670+#line 452 "common.w"
665671 ;
666672 }
667−return(!input_has_ended);
673+return 1;
668674 }
669675
670676 /*:21*//*26:*/
671−#line 563 "common.w"
677+#line 569 "common.w"
672678
673679 void
674680 check_complete(){
@@ -682,7 +688,7 @@ err_print("! Change file entry did not match"); · 7 unmodified lines
682688 }
683689
684690 /*:26*//*35:*/
685−#line 654 "common.w"
691+#line 660 "common.w"
686692
687693 name_pointer
688694 id_lookup(first,last,t)
@@ -697,17 +703,17 @@ name_pointer p; · 8 unmodified lines
697703 if(last==NULL)for(last= first;*last!='\0';last++);
698704 l= last-first;
699705 /*36:*/
700−#line 677 "common.w"
706+#line 683 "common.w"
701707
702708 h= (unsigned char)*i;
703709 while(++i<last)h= (h+h+(int)((unsigned char)*i))%hash_size;
704710
705711
706712 /*:36*/
707−#line 667 "common.w"
713+#line 673 "common.w"
708714 ;
709715 /*37:*/
710−#line 685 "common.w"
716+#line 691 "common.w"
711717
712718 p= hash[h];
713719 while(p&&!names_match(p,first,l,t))p= p->link;
@@ -717,10 +723,10 @@ p->link= hash[h];hash[h]= p; · 3 unmodified lines
717723 }
718724
719725 /*:37*/
720−#line 668 "common.w"
726+#line 674 "common.w"
721727 ;
722728 if(p==name_ptr)/*39:*/
723−#line 700 "common.w"
729+#line 706 "common.w"
724730 {
725731 if(byte_ptr+l> byte_mem_end)overflow("byte memory");
726732 if(name_ptr>=name_dir_end)overflow("name");
@@ -730,13 +736,13 @@ if(program==cweave)init_p(p,t); · 3 unmodified lines
730736 }
731737
732738 /*:39*/
733−#line 669 "common.w"
739+#line 675 "common.w"
734740 ;
735741 return(p);
736742 }
737743
738744 /*:35*//*42:*/
739−#line 758 "common.w"
745+#line 764 "common.w"
740746
741747 void
742748 print_section_name(p)
@@ -757,7 +763,7 @@ if(q)term_write("...",3); · 14 unmodified lines
757763 }
758764
759765 /*:42*//*43:*/
760−#line 777 "common.w"
766+#line 783 "common.w"
761767
762768 void
763769 sprint_section_name(dest,p)
@@ -780,7 +786,7 @@ s= p->byte_start; · 16 unmodified lines
780786 }
781787
782788 /*:43*//*44:*/
783−#line 798 "common.w"
789+#line 804 "common.w"
784790
785791 void
786792 print_prefix_name(p)
@@ -793,7 +799,7 @@ if(s+l<(p+1)->byte_start)term_write("...",3); · 6 unmodified lines
793799 }
794800
795801 /*:44*//*45:*/
796−#line 819 "common.w"
802+#line 825 "common.w"
797803
798804 int web_strcmp(j,j_len,k,k_len)
799805 char*j,*k;
@@ -809,7 +815,7 @@ else return greater; · 9 unmodified lines
809815 }
810816
811817 /*:45*//*47:*/
812−#line 849 "common.w"
818+#line 855 "common.w"
813819
814820 name_pointer
815821 add_section_name(par,c,first,last,ispref)
@@ -840,7 +846,7 @@ return par==NULL?(root= p):c==less?(par->llink= p):(par->rlink= p); · 24 unmodified lines
840846 }
841847
842848 /*:47*//*48:*/
843−#line 878 "common.w"
849+#line 884 "common.w"
844850
845851 void
846852 extend_section_name(p,first,last,ispref)
@@ -864,7 +870,7 @@ if(ispref)*(byte_ptr-1)= ' '; · 17 unmodified lines
864870 }
865871
866872 /*:48*//*49:*/
867−#line 906 "common.w"
873+#line 912 "common.w"
868874
869875 name_pointer
870876 section_lookup(first,last,ispref)
@@ -879,7 +885,7 @@ name_pointer par= NULL; · 8 unmodified lines
879885
880886 int name_len= last-first+1;
881887 /*50:*/
882−#line 930 "common.w"
888+#line 936 "common.w"
883889
884890 while(p){
885891 c= web_strcmp(first,name_len,first_chunk(p),prefix_length(p));
@@ -906,19 +912,19 @@ p= q,q= NULL; · 20 unmodified lines
906912 }
907913
908914 /*:50*/
909−#line 920 "common.w"
915+#line 926 "common.w"
910916 ;
911917 /*51:*/
912−#line 955 "common.w"
918+#line 961 "common.w"
913919
914920 if(r==NULL)
915921 return add_section_name(par,c,first,last+1,ispref);
916922
917923 /*:51*/
918−#line 921 "common.w"
924+#line 927 "common.w"
919925 ;
920926 /*52:*/
921−#line 963 "common.w"
927+#line 969 "common.w"
922928
923929 switch(section_name_cmp(&first,name_len,r)){
924930
@@ -952,12 +958,12 @@ return r; · 27 unmodified lines
952958 }
953959
954960 /*:52*/
955−#line 922 "common.w"
961+#line 928 "common.w"
956962 ;
957963 }
958964
959965 /*:49*//*54:*/
960−#line 1014 "common.w"
966+#line 1020 "common.w"
961967
962968 int section_name_cmp(pfirst,len,r)
963969 char**pfirst;
@@ -991,7 +997,7 @@ default:return c; · 27 unmodified lines
991997 }
992998
993999 /*:54*//*58:*/
994−#line 1089 "common.w"
1000+#line 1095 "common.w"
9951001
9961002 void
9971003 err_print(s)
@@ -1000,7 +1006,7 @@ char*s; · 2 unmodified lines
10001006 char*k,*l;
10011007 printf(*s=='!'?"\n%s":"%s",s);
10021008 if(web_file_open)/*59:*/
1003−#line 1109 "common.w"
1009+#line 1115 "common.w"
10041010
10051011 {if(changing&&include_depth==change_depth)
10061012 printf(". (l. %d of change file)\n",change_line);
@@ -1020,20 +1026,20 @@ putchar(' '); · 13 unmodified lines
10201026 }
10211027
10221028 /*:59*/
1023−#line 1096 "common.w"
1029+#line 1102 "common.w"
10241030 ;
10251031 update_terminal;mark_error;
10261032 }
10271033
10281034 /*:58*//*61:*/
1029−#line 1144 "common.w"
1035+#line 1150 "common.w"
10301036
10311037 int wrap_up(){
10321038 putchar('\n');
10331039 if(show_stats)
10341040 print_stats();
10351041 /*62:*/
1036−#line 1154 "common.w"
1042+#line 1160 "common.w"
10371043
10381044 switch(history){
10391045 case spotless:if(show_happiness)printf("(No errors were found.)\n");break;
@@ -1045,14 +1051,14 @@ case fatal_message:printf("(That was a fatal error, my friend.)\n"); · 5 unmodified lines
10451051 }
10461052
10471053 /*:62*/
1048−#line 1149 "common.w"
1054+#line 1155 "common.w"
10491055 ;
10501056 if(history> harmless_message)return(1);
10511057 else return(0);
10521058 }
10531059
10541060 /*:61*//*64:*/
1055−#line 1173 "common.w"
1061+#line 1179 "common.w"
10561062 void
10571063 fatal(s,t)
10581064 char*s,*t;
@@ -1063,7 +1069,7 @@ history= fatal_message;exit(wrap_up()); · 4 unmodified lines
10631069 }
10641070
10651071 /*:64*//*65:*/
1066−#line 1184 "common.w"
1072+#line 1190 "common.w"
10671073 void
10681074 overflow(t)
10691075 char*t;
@@ -1073,7 +1079,7 @@ printf("\n! Sorry, %s capacity exceeded",t);fatal("",""); · 3 unmodified lines
10731079
10741080
10751081 /*:65*//*70:*/
1076−#line 1248 "common.w"
1082+#line 1254 "common.w"
10771083
10781084 void
10791085 scan_args()
@@ -1087,7 +1093,7 @@ boolean flag_change; · 7 unmodified lines
10871093
10881094 while(--argc> 0){
10891095 if((**(++argv)=='-'||**argv=='+')&&*(*argv+1))/*74:*/
1090−#line 1338 "common.w"
1096+#line 1344 "common.w"
10911097
10921098 {
10931099 if(**argv=='-')flag_change= 0;
@@ -1097,7 +1103,7 @@ flags[*dot_pos]= flag_change; · 3 unmodified lines
10971103 }
10981104
10991105 /*:74*/
1100−#line 1260 "common.w"
1106+#line 1266 "common.w"
11011107
11021108 else{
11031109 s= name_pos= *argv;dot_pos= NULL;
@@ -1107,17 +1113,17 @@ else if(*s=='/')dot_pos= NULL,name_pos= ++s; · 3 unmodified lines
11071113 else s++;
11081114 }
11091115 if(!found_web)/*71:*/
1110−#line 1286 "common.w"
1116+#line 1292 "common.w"
11111117
11121118 {
11131119 if(s-*argv> max_file_name_length-5)
11141120 /*76:*/
1115−#line 1358 "common.w"
1121+#line 1364 "common.w"
11161122 fatal("! Filename too long\n",*argv);
11171123
11181124
11191125 /*:76*/
1120−#line 1289 "common.w"
1126+#line 1295 "common.w"
11211127 ;
11221128 if(dot_pos==NULL)
11231129 sprintf(web_file_name,"%s.w",*argv);
@@ -1134,22 +1140,22 @@ found_web= 1; · 10 unmodified lines
11341140 }
11351141
11361142 /*:71*/
1137−#line 1269 "common.w"
1143+#line 1275 "common.w"
11381144
11391145 else if(!found_change)/*72:*/
1140−#line 1304 "common.w"
1146+#line 1310 "common.w"
11411147
11421148 {
11431149 if(strcmp(*argv,"-")==0)found_change= -1;
11441150 else{
11451151 if(s-*argv> max_file_name_length-4)
11461152 /*76:*/
1147−#line 1358 "common.w"
1153+#line 1364 "common.w"
11481154 fatal("! Filename too long\n",*argv);
11491155
11501156
11511157 /*:76*/
1152−#line 1309 "common.w"
1158+#line 1315 "common.w"
11531159 ;
11541160 if(dot_pos==NULL)
11551161 sprintf(change_file_name,"%s.ch",*argv);
@@ -1159,20 +1165,20 @@ found_change= 1; · 3 unmodified lines
11591165 }
11601166
11611167 /*:72*/
1162−#line 1270 "common.w"
1168+#line 1276 "common.w"
11631169
11641170 else if(!found_out)/*73:*/
1165−#line 1317 "common.w"
1171+#line 1323 "common.w"
11661172
11671173 {
11681174 if(s-*argv> max_file_name_length-5)
11691175 /*76:*/
1170−#line 1358 "common.w"
1176+#line 1364 "common.w"
11711177 fatal("! Filename too long\n",*argv);
11721178
11731179
11741180 /*:76*/
1175−#line 1320 "common.w"
1181+#line 1326 "common.w"
11761182 ;
11771183 if(dot_pos==NULL){
11781184 sprintf(tex_file_name,"%s.tex",*argv);
@@ -1192,10 +1198,10 @@ found_out= 1; · 13 unmodified lines
11921198 }
11931199
11941200 /*:73*/
1195−#line 1271 "common.w"
1201+#line 1277 "common.w"
11961202
11971203 else/*75:*/
1198−#line 1346 "common.w"
1204+#line 1352 "common.w"
11991205
12001206 {
12011207 if(program==ctangle)
@@ -1209,12 +1215,12 @@ else fatal( · 7 unmodified lines
12091215 }
12101216
12111217 /*:75*/
1212−#line 1272 "common.w"
1218+#line 1278 "common.w"
12131219 ;
12141220 }
12151221 }
12161222 if(!found_web)/*75:*/
1217−#line 1346 "common.w"
1223+#line 1352 "common.w"
12181224
12191225 {
12201226 if(program==ctangle)
@@ -1228,7 +1234,7 @@ else fatal( · 7 unmodified lines
12281234 }
12291235
12301236 /*:75*/
1231−#line 1275 "common.w"
1237+#line 1281 "common.w"
12321238 ;
12331239 if(found_change<=0)strcpy(change_file_name,"/dev/null");
12341240 }
common.w+18−12
@@ -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 3.61 --- July 2000 (works with later versions too)
5+% Version 3.64 --- January 2002
66
77 % Copyright (C) 1987,1990,1993,2000 Silvio Levy and Donald E. Knuth
88
@@ -17,12 +17,12 @@ · 8 unmodified lines
1717
1818 \def\v{\char'174} % vertical (|) in typewriter font
1919
20−\def\title{Common code for CTANGLE and CWEAVE (Version 3.61)}
20+\def\title{Common code for CTANGLE and CWEAVE (Version 3.64)}
2121 \def\topofcontents{\null\vfill
2222 \centerline{\titlefont Common code for {\ttitlefont CTANGLE} and
2323 {\ttitlefont CWEAVE}}
2424 \vskip 15pt
25− \centerline{(Version 3.61)}
25+ \centerline{(Version 3.64)}
2626 \vfill}
2727 \def\botofcontents{\vfill
2828 \noindent
@@ -291,7 +291,7 @@ do { · 262 unmodified lines
291291
292292 @ @<Move |buffer| and |limit| to |change_buffer| and |change_limit|@>=
293293 {
294− change_limit=change_buffer-buffer+limit;
294+ change_limit=change_buffer+(limit-buffer);
295295 strncpy(change_buffer,buffer,limit-buffer+1);
296296 }
297297
@@ -337,7 +337,7 @@ check_change() /* switches to |change_file| if the buffers match */ · 39 unmodified lines
337337 return;
338338 }
339339 if (limit>buffer+1 && buffer[0]=='@@') {
340− if (xisupper(buffer[1])) buffer[1]=tolower(buffer[1]);
340+ char xyz_code=xisupper(buffer[1])? tolower(buffer[1]): buffer[1];
341341 @<If the current line starts with \.{@@y},
342342 report any discrepancies and |return|@>;
343343 }
@@ -356,11 +356,11 @@ check_change() /* switches to |change_file| if the buffers match */ · 12 unmodified lines
356356 }
357357
358358 @ @<If the current line starts with \.{@@y}...@>=
359−if (buffer[1]=='x' || buffer[1]=='z') {
359+if (xyz_code=='x' || xyz_code=='z') {
360360 loc=buffer+2; err_print("! Where is the matching @@y?");
361361 @.Where is the match...@>
362362 }
363−else if (buffer[1]=='y') {
363+else if (xyz_code=='y') {
364364 if (n>0) {
365365 loc=buffer+2;
366366 printf("\n! Hmm... %d ",n);
@@ -433,10 +433,11 @@ int get_line() /* inputs the next line */ · 66 unmodified lines
433433 @<Read from |cur_file| and maybe turn on |changing|@>;
434434 if (changing && include_depth==change_depth) goto restart;
435435 }
436+ if (input_has_ended) return 0;
436437 loc=buffer; *limit=' ';
437− if (*buffer=='@@' && (*(buffer+1)=='i' || *(buffer+1)=='I')) {
438− loc=buffer+2;
439− while (loc<=limit && (*loc==' '||*loc=='\t'||*loc=='"')) loc++;
438+ if (buffer[0]=='@@' && (buffer[1]=='i' || buffer[1]=='I')) {
439+ loc=buffer+2; *limit='"';
440+ while (*loc==' '||*loc=='\t') loc++;
440441 if (loc>=limit) {
441442 err_print("! Include file name not given");
442443 @.Include file name ...@>
@@ -450,7 +451,7 @@ int get_line() /* inputs the next line */ · 7 unmodified lines
450451 include_depth++; /* push input stack */
451452 @<Try to open include file, abort push if unsuccessful, go to |restart|@>;
452453 }
453− return (!input_has_ended);
454+ return 1;
454455 }
455456
456457 @ When an \.{@@i} line is found in the |cur_file|, we must temporarily
@@ -476,7 +477,12 @@ The remainder of the \.{@@i} line after the file name is ignored. · 19 unmodified lines
476477 char *k=cur_file_name, *kk;
477478 int l; /* length of file name */
478479
479− while (*loc!=' '&&*loc!='\t'&&*loc!='"'&&k<=cur_file_name_end) *k++=*loc++;
480+ if (*loc=='"') {
481+ loc++;
482+ while (*loc!='"' && k<=cur_file_name_end) *k++=*loc++;
483+ if (loc==limit) k=cur_file_name_end+1; /* unmatched quote is `too long' */
484+ } else
485+ while (*loc!=' '&&*loc!='\t'&&*loc!='"'&&k<=cur_file_name_end) *k++=*loc++;
480486 if (k>cur_file_name_end) too_long();
481487 @.Include file name ...@>
482488 *k='\0';
ctang-bs.ch+2−2
@@ -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 3.62)\n"
20+@d banner "This is CTANGLE (Version 3.64)\n"
2121 @y
2222 The ``banner line'' defined here should be changed whenever \.{CTANGLE}
2323 is modified.
2424
25−@d banner "This is CTANGLE (Version 3.62pc/big)\n"
25+@d banner "This is CTANGLE (Version 3.64pc/big)\n"
2626 @z
2727
2828
ctang-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{62}
19+\def\contentspagenumber{63}
2020 \def\title{APPENDIX E: CTANGLE}
2121 \let\K=\leftarrow
2222 @z
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 3.62)\n"
12+@d banner "This is CTANGLE (Version 3.64)\n"
1313 @y
14−@d banner "This is CTANGLE (Version 3.62pc)\n"
14+@d banner "This is CTANGLE (Version 3.64pc)\n"
1515 @z
1616 @x section 4
1717 @d max_bytes 90000 /* 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 3.62)}
10+\def\title{CTANGLE (Version 3.64)}
1111 @y
12−\def\title{CTANGLE (QL Version 3.62)}
12+\def\title{CTANGLE (QL Version 3.64)}
1313 @z
1414
1515 @x section 1
16−@d banner "This is CTANGLE (Version 3.62)\n"
16+@d banner "This is CTANGLE (Version 3.64)\n"
1717 @y
18−@d banner "This is CTANGLE (QL Version 3.62)\n"
18+@d banner "This is CTANGLE (QL Version 3.64)\n"
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 3.62)\n"
13+@d banner "This is CTANGLE (Version 3.64)\n"
1414 @y
15−@d banner "This is CTANGLE (VAX/VMS Version 3.62)\n"
15+@d banner "This is CTANGLE (VAX/VMS Version 3.64)\n"
1616 @z
1717
1818 @x section 6 (from common.h) (01-FEB-1992 ST)
ctang-w32.ch+66−0
@@ -0,0 +1,66 @@
1+This is the change file for CWEB's CTANGLE under Win32
2+(Contributed by Fabrice Popineau, February 2002)
3+
4+Changes necessary for compiling with Borland C/C++
5+
6+@x section 1
7+@d banner "This is CTANGLE (Version 3.64)\n"
8+@y
9+@d banner "This is CTANGLE (Version 3.64win32)\n"
10+@z
11+
12+@x
13+@ We predeclare several standard system functions here instead of including
14+their system header files, because the names of the header files are not as
15+standard as the names of the functions. (For example, some \CEE/ environments
16+have \.{<string.h>} where others have \.{<strings.h>}.)
17+
18+@<Predecl...@>=
19+extern int strlen(); /* length of string */
20+extern int strcmp(); /* compare strings lexicographically */
21+extern char* strcpy(); /* copy one string to another */
22+extern int strncmp(); /* compare up to $n$ string characters */
23+extern char* strncpy(); /* copy up to $n$ string characters */
24+@y
25+@z
26+
27+@x
28+int names_match(p,first,l)
29+name_pointer p; /* points to the proposed match */
30+char *first; /* position of first character of string */
31+@y
32+int __cdecl names_match(p,first,l)
33+name_pointer p; /* points to the proposed match */
34+char *first; /* position of first character of string */
35+@z
36+
37+@x
38+void
39+init_node(node)
40+name_pointer node;
41+{
42+ node->equiv=(char *)text_info;
43+}
44+void
45+init_p() {}
46+@y
47+void
48+init_node(node)
49+name_pointer node;
50+{
51+ node->equiv=(char *)text_info;
52+}
53+void __cdecl
54+init_p() {}
55+@z
56+
57+@x
58+@ @<Include...@>=
59+#include <ctype.h> /* definition of |isalpha|, |isdigit| and so on */
60+#include <stdlib.h> /* definition of |exit| */
61+@y
62+@ @<Include...@>=
63+#include <ctype.h> /* definition of |isalpha|, |isdigit| and so on */
64+#include <stdlib.h> /* definition of |exit| */
65+#include <string.h>
66+@z
ctangle.c+61−60
@@ -15,7 +15,7 @@ · 14 unmodified lines
1515 /*:62*/
1616 #line 65 "ctangle.w"
1717
18−#define banner "This is CTANGLE (Version 3.62)\n" \
18+#define banner "This is CTANGLE (Version 3.64)\n" \
1919
2020 #define max_bytes 90000 \
2121
@@ -350,13 +350,13 @@ name_pointer cur_section_name; · 328 unmodified lines
350350 int no_where;
351351
352352 /*:61*//*75:*/
353−#line 1199 "ctangle.w"
353+#line 1195 "ctangle.w"
354354
355355 text_pointer cur_text;
356356 eight_bits next_control;
357357
358358 /*:75*//*82:*/
359−#line 1349 "ctangle.w"
359+#line 1350 "ctangle.w"
360360
361361 extern sixteen_bits section_count;
362362
@@ -388,12 +388,12 @@ void output_defs(); · 25 unmodified lines
388388 static void out_char();
389389
390390 /*:48*//*90:*/
391−#line 1456 "ctangle.w"
391+#line 1457 "ctangle.w"
392392
393393 void phase_one();
394394
395395 /*:90*//*92:*/
396−#line 1474 "ctangle.w"
396+#line 1475 "ctangle.w"
397397
398398 void skip_limbo();
399399
@@ -460,7 +460,7 @@ ccode['\'']= ord; · 60 unmodified lines
460460 }
461461
462462 /*:57*//*71:*/
463−#line 1120 "ctangle.w"
463+#line 1116 "ctangle.w"
464464 section_text[0]= ' ';
465465
466466 /*:71*/
@@ -885,7 +885,7 @@ if(get_line()==0)return(new_section); · 418 unmodified lines
885885 else if(print_where&&!no_where){
886886 print_where= 0;
887887 /*77:*/
888−#line 1229 "ctangle.w"
888+#line 1225 "ctangle.w"
889889
890890 store_two_bytes(0150000);
891891 if(changing)id_first= change_file_name;
@@ -910,13 +910,11 @@ if(comment_continues)return('\n'); · 18 unmodified lines
910910 else continue;
911911 }
912912 loc++;
913−if(xisdigit(c)||c=='\\'||c=='.')/*66:*/
913+if(xisdigit(c)||c=='.')/*66:*/
914914 #line 978 "ctangle.w"
915915 {
916916 id_first= loc-1;
917917 if(*id_first=='.'&&!xisdigit(*loc))goto mistake;
918−if(*id_first=='\\')while(xisdigit(*loc))loc++;
919−else{
920918 if(*id_first=='0'){
921919 if(*loc=='x'||*loc=='X'){
922920 loc++;while(xisxdigit(*loc))loc++;goto found;
@@ -931,7 +929,6 @@ if(*loc=='e'||*loc=='E'){ · 8 unmodified lines
931929 if(*++loc=='+'||*loc=='-')loc++;
932930 while(xisdigit(*loc))loc++;
933931 }
934−}
935932 found:while(*loc=='u'||*loc=='U'||*loc=='l'||*loc=='L'
936933 ||*loc=='f'||*loc=='F')loc++;
937934 id_loc= loc;
@@ -943,7 +940,7 @@ return(constant); · 5 unmodified lines
943940
944941 else if(c=='\''||c=='"'||(c=='L'&&(*loc=='\''||*loc=='"')))
945942 /*67:*/
946−#line 1009 "ctangle.w"
943+#line 1006 "ctangle.w"
947944 {
948945 char delim= c;
949946 id_first= section_text+1;
@@ -1001,12 +998,11 @@ id_loc= loc;return(identifier); · 51 unmodified lines
1001998 #line 928 "ctangle.w"
1002999
10031000 else if(c=='@')/*68:*/
1004−#line 1053 "ctangle.w"
1001+#line 1050 "ctangle.w"
10051002 {
10061003 c= ccode[(eight_bits)*loc++];
10071004 switch(c){
10081005 case ignore:continue;
1009−case output_defs_code:output_defs_seen= 1;return(c);
10101006 case translit_code:err_print("! Use @l in limbo only");continue;
10111007
10121008 case control_text:while((c= skip_ahead())=='@');
@@ -1018,11 +1014,11 @@ continue; · 5 unmodified lines
10181014 case section_name:
10191015 cur_section_name_char= *(loc-1);
10201016 /*70:*/
1021−#line 1102 "ctangle.w"
1017+#line 1098 "ctangle.w"
10221018 {
10231019 char*k;
10241020 /*72:*/
1025−#line 1122 "ctangle.w"
1021+#line 1118 "ctangle.w"
10261022
10271023 k= section_text;
10281024 while(1){
@@ -1033,7 +1029,7 @@ loc= buffer+1;break; · 4 unmodified lines
10331029 }
10341030 c= *loc;
10351031 /*73:*/
1036−#line 1146 "ctangle.w"
1032+#line 1142 "ctangle.w"
10371033
10381034 if(c=='@'){
10391035 c= *(loc+1);
@@ -1052,7 +1048,7 @@ err_print("! Nesting of section names not allowed");break; · 12 unmodified lines
10521048 }
10531049
10541050 /*:73*/
1055−#line 1131 "ctangle.w"
1051+#line 1127 "ctangle.w"
10561052 ;
10571053 loc++;if(k<section_text_end)k++;
10581054 if(xisspace(c)){
@@ -1069,7 +1065,7 @@ printf("...");mark_harmless; · 10 unmodified lines
10691065 if(*k==' '&&k> section_text)k--;
10701066
10711067 /*:72*/
1072−#line 1104 "ctangle.w"
1068+#line 1100 "ctangle.w"
10731069 ;
10741070 if(k-section_text> 3&&strncmp(k-2,"...",3)==0)
10751071 cur_section_name= section_lookup(section_text+1,k-3,1);
@@ -1092,16 +1088,16 @@ overflow("output files"); · 16 unmodified lines
10921088 }
10931089
10941090 /*:40*/
1095−#line 1110 "ctangle.w"
1091+#line 1106 "ctangle.w"
10961092 ;
10971093 return(section_name);
10981094 }
10991095
11001096 /*:70*/
1101−#line 1068 "ctangle.w"
1097+#line 1064 "ctangle.w"
11021098 ;
11031099 case string:/*74:*/
1104−#line 1168 "ctangle.w"
1100+#line 1164 "ctangle.w"
11051101 {
11061102 id_first= loc++;*(limit+1)= '@';*(limit+2)= '>';
11071103 while(*loc!='@'||*(loc+1)!='>')loc++;
@@ -1112,10 +1108,10 @@ return(string); · 4 unmodified lines
11121108 }
11131109
11141110 /*:74*/
1115−#line 1069 "ctangle.w"
1111+#line 1065 "ctangle.w"
11161112 ;
11171113 case ord:/*69:*/
1118−#line 1081 "ctangle.w"
1114+#line 1077 "ctangle.w"
11191115
11201116 id_first= loc;
11211117 if(*loc=='\\'){
@@ -1138,7 +1134,7 @@ loc++; · 16 unmodified lines
11381134 return(ord);
11391135
11401136 /*:69*/
1141−#line 1070 "ctangle.w"
1137+#line 1066 "ctangle.w"
11421138 ;
11431139 default:return(c);
11441140 }
@@ -1185,7 +1181,7 @@ return(c); · 40 unmodified lines
11851181 }
11861182
11871183 /*:63*//*76:*/
1188−#line 1203 "ctangle.w"
1184+#line 1199 "ctangle.w"
11891185
11901186 void
11911187 scan_repl(t)
@@ -1193,7 +1189,7 @@ eight_bits t; · 1 unmodified line
11931189 {
11941190 sixteen_bits a;
11951191 if(t==section_name){/*77:*/
1196−#line 1229 "ctangle.w"
1192+#line 1225 "ctangle.w"
11971193
11981194 store_two_bytes(0150000);
11991195 if(changing)id_first= change_file_name;
@@ -1205,11 +1201,11 @@ else store_two_bytes((sixteen_bits)cur_line); · 5 unmodified lines
12051201 app_repl(a%0400);}
12061202
12071203 /*:77*/
1208−#line 1209 "ctangle.w"
1204+#line 1205 "ctangle.w"
12091205 ;}
12101206 while(1)switch(a= get_next()){
12111207 /*78:*/
1212−#line 1239 "ctangle.w"
1208+#line 1235 "ctangle.w"
12131209
12141210 case identifier:a= id_lookup(id_first,id_loc,0)-name_dir;
12151211 app_repl((a/0400)+0200);
@@ -1217,7 +1213,7 @@ app_repl(a%0400);break; · 1 unmodified line
12171213 case section_name:if(t!=section_name)goto done;
12181214 else{
12191215 /*79:*/
1220−#line 1267 "ctangle.w"
1216+#line 1268 "ctangle.w"
12211217 {
12221218 char*try_loc= loc;
12231219 while(*try_loc==' '&&try_loc<limit)try_loc++;
@@ -1230,13 +1226,13 @@ if(*try_loc=='=')err_print("! Missing `@ ' before a named section"); · 6 unmodified lines
12301226 }
12311227
12321228 /*:79*/
1233−#line 1245 "ctangle.w"
1229+#line 1241 "ctangle.w"
12341230 ;
12351231 a= cur_section_name-name_dir;
12361232 app_repl((a/0400)+0250);
12371233 app_repl(a%0400);
12381234 /*77:*/
1239−#line 1229 "ctangle.w"
1235+#line 1225 "ctangle.w"
12401236
12411237 store_two_bytes(0150000);
12421238 if(changing)id_first= change_file_name;
@@ -1248,15 +1244,18 @@ else store_two_bytes((sixteen_bits)cur_line); · 5 unmodified lines
12481244 app_repl(a%0400);}
12491245
12501246 /*:77*/
1251−#line 1249 "ctangle.w"
1247+#line 1245 "ctangle.w"
12521248 ;break;
12531249 }
1254−case output_defs_code:
1250+case output_defs_code:if(t!=section_name)err_print("! Misplaced @h");
1251+
1252+else{
1253+output_defs_seen= 1;
12551254 a= output_defs_flag;
12561255 app_repl((a/0400)+0200);
12571256 app_repl(a%0400);
12581257 /*77:*/
1259−#line 1229 "ctangle.w"
1258+#line 1225 "ctangle.w"
12601259
12611260 store_two_bytes(0150000);
12621261 if(changing)id_first= change_file_name;
@@ -1268,11 +1267,13 @@ else store_two_bytes((sixteen_bits)cur_line); · 5 unmodified lines
12681267 app_repl(a%0400);}
12691268
12701269 /*:77*/
1271−#line 1255 "ctangle.w"
1272−;break;
1270+#line 1254 "ctangle.w"
1271+;
1272+}
1273+break;
12731274 case constant:case string:
12741275 /*80:*/
1275−#line 1278 "ctangle.w"
1276+#line 1279 "ctangle.w"
12761277
12771278 app_repl(a);
12781279 while(id_first<id_loc){
@@ -1286,11 +1287,11 @@ app_repl(*id_first++); · 7 unmodified lines
12861287 app_repl(a);break;
12871288
12881289 /*:80*/
1289−#line 1257 "ctangle.w"
1290+#line 1258 "ctangle.w"
12901291 ;
12911292 case ord:
12921293 /*81:*/
1293−#line 1294 "ctangle.w"
1294+#line 1295 "ctangle.w"
12941295 {
12951296 int c= (eight_bits)*id_first;
12961297 if(c=='\\'){
@@ -1341,7 +1342,7 @@ app_repl(constant); · 44 unmodified lines
13411342 break;
13421343
13431344 /*:81*/
1344−#line 1259 "ctangle.w"
1345+#line 1260 "ctangle.w"
13451346 ;
13461347 case definition:case format_code:case begin_C:if(t!=section_name)goto done;
13471348 else{
@@ -1351,7 +1352,7 @@ err_print("! @d, @f and @c are ignored in C text");continue; · 3 unmodified lines
13511352 case new_section:goto done;
13521353
13531354 /*:78*/
1354−#line 1214 "ctangle.w"
1355+#line 1210 "ctangle.w"
13551356
13561357 case')':app_repl(a);
13571358 if(t==macro)app_repl(' ');
@@ -1364,7 +1365,7 @@ cur_text= text_ptr;(++text_ptr)->tok_start= tok_ptr; · 6 unmodified lines
13641365 }
13651366
13661367 /*:76*//*83:*/
1367−#line 1356 "ctangle.w"
1368+#line 1357 "ctangle.w"
13681369
13691370 void
13701371 scan_section()
@@ -1379,7 +1380,7 @@ printf("*%d",section_count);update_terminal; · 8 unmodified lines
13791380 next_control= 0;
13801381 while(1){
13811382 /*84:*/
1382−#line 1395 "ctangle.w"
1383+#line 1396 "ctangle.w"
13831384
13841385 while(next_control<definition)
13851386
@@ -1388,11 +1389,11 @@ loc-= 2;next_control= get_next(); · 2 unmodified lines
13881389 }
13891390
13901391 /*:84*/
1391−#line 1370 "ctangle.w"
1392+#line 1371 "ctangle.w"
13921393 ;
13931394 if(next_control==definition){
13941395 /*85:*/
1395−#line 1402 "ctangle.w"
1396+#line 1403 "ctangle.w"
13961397 {
13971398 while((next_control= get_next())=='\n');
13981399 if(next_control!=identifier){
@@ -1411,7 +1412,7 @@ cur_text->text_link= 0; · 12 unmodified lines
14111412 }
14121413
14131414 /*:85*/
1414−#line 1372 "ctangle.w"
1415+#line 1373 "ctangle.w"
14151416
14161417 continue;
14171418 }
@@ -1421,14 +1422,14 @@ p= name_dir;break; · 3 unmodified lines
14211422 if(next_control==section_name){
14221423 p= cur_section_name;
14231424 /*86:*/
1424−#line 1427 "ctangle.w"
1425+#line 1428 "ctangle.w"
14251426
14261427 while((next_control= get_next())=='+');
14271428 if(next_control!='='&&next_control!=eq_eq)
14281429 continue;
14291430
14301431 /*:86*/
1431−#line 1380 "ctangle.w"
1432+#line 1381 "ctangle.w"
14321433 ;
14331434 break;
14341435 }
@@ -1436,20 +1437,20 @@ return; · 1 unmodified line
14361437 }
14371438 no_where= print_where= 0;
14381439 /*87:*/
1439−#line 1432 "ctangle.w"
1440+#line 1433 "ctangle.w"
14401441
14411442 /*88:*/
1442−#line 1437 "ctangle.w"
1443+#line 1438 "ctangle.w"
14431444
14441445 store_two_bytes((sixteen_bits)(0150000+section_count));
14451446
14461447
14471448 /*:88*/
1448−#line 1433 "ctangle.w"
1449+#line 1434 "ctangle.w"
14491450 ;
14501451 scan_repl(section_name);
14511452 /*89:*/
1452−#line 1441 "ctangle.w"
1453+#line 1442 "ctangle.w"
14531454
14541455 if(p==name_dir||p==0){
14551456 (last_unnamed)->text_link= cur_text-text_info;last_unnamed= cur_text;
@@ -1466,16 +1467,16 @@ cur_text->text_link= section_flag; · 10 unmodified lines
14661467
14671468
14681469 /*:89*/
1469−#line 1435 "ctangle.w"
1470+#line 1436 "ctangle.w"
14701471 ;
14711472
14721473 /*:87*/
1473−#line 1386 "ctangle.w"
1474+#line 1387 "ctangle.w"
14741475 ;
14751476 }
14761477
14771478 /*:83*//*91:*/
1478−#line 1459 "ctangle.w"
1479+#line 1460 "ctangle.w"
14791480
14801481 void
14811482 phase_one(){
@@ -1489,7 +1490,7 @@ phase= 2; · 7 unmodified lines
14891490 }
14901491
14911492 /*:91*//*93:*/
1492−#line 1477 "ctangle.w"
1493+#line 1478 "ctangle.w"
14931494
14941495 void
14951496 skip_limbo()
@@ -1504,7 +1505,7 @@ c= *loc++; · 8 unmodified lines
15041505 if(ccode[(eight_bits)c]==new_section)break;
15051506 switch(ccode[(eight_bits)c]){
15061507 case translit_code:/*94:*/
1507−#line 1506 "ctangle.w"
1508+#line 1507 "ctangle.w"
15081509
15091510 while(xisspace(*loc)&&loc<limit)loc++;
15101511 loc+= 3;
@@ -1529,7 +1530,7 @@ translit[i-0200][loc-beg]= '\0'; · 18 unmodified lines
15291530 }
15301531
15311532 /*:94*/
1532−#line 1490 "ctangle.w"
1533+#line 1491 "ctangle.w"
15331534 ;break;
15341535 case format_code:case'@':break;
15351536 case control_text:if(c=='q'||c=='Q'){
@@ -1547,7 +1548,7 @@ default:err_print("! Double @ should be used in limbo"); · 11 unmodified lines
15471548 }
15481549
15491550 /*:93*//*95:*/
1550−#line 1532 "ctangle.w"
1551+#line 1533 "ctangle.w"
15511552
15521553 void
15531554 print_stats(){
ctangle.w+28−27
@@ -2,8 +2,8 @@ · 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 3.62 --- September 2000
6−% (same as Version 3.5 except for minor typographic/stylistic corrections)
5+% Version 3.64 --- February 2002
6+% (same as Version 3.5 except for minor corrections)
77 % (also quotes backslashes in file names of #line directives)
88
99 % Copyright (C) 1987,1990,1993,2000 Silvio Levy and Donald E. Knuth
@@ -24,11 +24,11 @@ · 14 unmodified lines
2424 \mathchardef\RA="3221 % right arrow
2525 \mathchardef\BA="3224 % double arrow
2626
27−\def\title{CTANGLE (Version 3.62)}
27+\def\title{CTANGLE (Version 3.64)}
2828 \def\topofcontents{\null\vfill
2929 \centerline{\titlefont The {\ttitlefont CTANGLE} processor}
3030 \vskip 15pt
31− \centerline{(Version 3.62)}
31+ \centerline{(Version 3.64)}
3232 \vfill}
3333 \def\botofcontents{\vfill
3434 \noindent
@@ -59,7 +59,7 @@ Joachim Schrod, Lee Wittenberg, and others who have contributed improvements. · 24 unmodified lines
5959 The ``banner line'' defined here should be changed whenever \.{CTANGLE}
6060 is modified.
6161
62−@d banner "This is CTANGLE (Version 3.62)\n"
62+@d banner "This is CTANGLE (Version 3.64)\n"
6363
6464 @c
6565 @<Include files@>@/
@@ -921,7 +921,7 @@ get_next() /* produces the next input token */ · 855 unmodified lines
921921 else continue;
922922 }
923923 loc++;
924− if (xisdigit(c) || c=='\\' || c=='.') @<Get a constant@>@;
924+ if (xisdigit(c) || c=='.') @<Get a constant@>@;
925925 else if (c=='\'' || c=='"' || (c=='L'&&(*loc=='\'' || *loc=='"')))
926926 @<Get a string@>@;
927927 else if (isalpha(c) || isxalpha(c) || ishigh(c))
@@ -978,24 +978,21 @@ switch(c) { · 50 unmodified lines
978978 @ @<Get a constant@>= {
979979 id_first=loc-1;
980980 if (*id_first=='.' && !xisdigit(*loc)) goto mistake; /* not a constant */
981− if (*id_first=='\\') while (xisdigit(*loc)) loc++; /* octal constant */
982− else {
983− if (*id_first=='0') {
984− if (*loc=='x' || *loc=='X') { /* hex constant */
985− loc++; while (xisxdigit(*loc)) loc++; goto found;
986− }
981+ if (*id_first=='0') {
982+ if (*loc=='x' || *loc=='X') { /* hex constant */
983+ loc++; while (xisxdigit(*loc)) loc++; goto found;
987984 }
985+ }
986+ while (xisdigit(*loc)) loc++;
987+ if (*loc=='.') {
988+ loc++;
989+ while (xisdigit(*loc)) loc++;
990+ }
991+ if (*loc=='e' || *loc=='E') { /* float constant */
992+ if (*++loc=='+' || *loc=='-') loc++;
988993 while (xisdigit(*loc)) loc++;
989− if (*loc=='.') {
990− loc++;
991− while (xisdigit(*loc)) loc++;
992− }
993− if (*loc=='e' || *loc=='E') { /* float constant */
994− if (*++loc=='+' || *loc=='-') loc++;
995− while (xisdigit(*loc)) loc++;
996− }
997994 }
998− found: while (*loc=='u' || *loc=='U' || *loc=='l' || *loc=='L'
995+ found: while (*loc=='u' || *loc=='U' || *loc=='l' || *loc=='L'
999996 || *loc=='f' || *loc=='F') loc++;
1000997 id_loc=loc;
1001998 return(constant);
@@ -1054,7 +1051,6 @@ whether there is more work to do. · 52 unmodified lines
10541051 c=ccode[(eight_bits)*loc++];
10551052 switch(c) {
10561053 case ignore: continue;
1057− case output_defs_code: output_defs_seen=1; return(c);
10581054 case translit_code: err_print("! Use @@l in limbo only"); continue;
10591055 @.Use @@l in limbo...@>
10601056 case control_text: while ((c=skip_ahead())=='@@');
@@ -1248,11 +1244,16 @@ case section_name: if (t!=section_name) goto done; · 187 unmodified lines
12481244 app_repl(a % 0400);
12491245 @<Insert the line number into |tok_mem|@>; break;
12501246 }
1251−case output_defs_code:
1252− a=output_defs_flag;
1253− app_repl((a / 0400)+0200);
1254− app_repl(a % 0400);
1255− @<Insert the line number into |tok_mem|@>; break;
1247+case output_defs_code: if (t!=section_name) err_print("! Misplaced @@h");
1248+@.Misplaced @@h@>
1249+ else {
1250+ output_defs_seen=1;
1251+ a=output_defs_flag;
1252+ app_repl((a / 0400)+0200);
1253+ app_repl(a % 0400);
1254+ @<Insert the line number into |tok_mem|@>;
1255+ }
1256+ break;
12561257 case constant: case string:
12571258 @<Copy a string or verbatim construction or numerical constant@>;
12581259 case ord:
cweav-bs.ch+2−2
@@ -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 3.61)\n"
23+@d banner "This is CWEAVE (Version 3.64)\n"
2424 @y
2525 The ``banner line'' defined here should be changed whenever \.{CWEAVE}
2626 is modified.
2727
28−@d banner "This is CWEAVE (Version 3.61pc/big)\n"
28+@d banner "This is CWEAVE (Version 3.64pc/big)\n"
2929 @z
3030
3131
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{107}
19+\def\contentspagenumber{109}
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 3.61)\n"
14+@d banner "This is CWEAVE (Version 3.64)\n"
1515 @y
16−@d banner "This is CWEAVE (Version 3.61pc)\n"
16+@d banner "This is CWEAVE (Version 3.64pc)\n"
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 3.61)}
10+\def\title{CWEAVE (Version 3.64)}
1111 @y
12−\def\title{CWEAVE (QL Version 3.61)}
12+\def\title{CWEAVE (QL Version 3.64)}
1313 @z
1414
1515 @x section 1
16−@d banner "This is CWEAVE (Version 3.61)\n"
16+@d banner "This is CWEAVE (Version 3.64)\n"
1717 @y
18−@d banner "This is CWEAVE (QL Version 3.61)\n"
18+@d banner "This is CWEAVE (QL Version 3.64)\n"
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 3.61)\n"
16+@d banner "This is CWEAVE (Version 3.64)\n"
1717 @y
18−@d banner "This is CWEAVE (VAX/VMS Version 3.61)\n"
18+@d banner "This is CWEAVE (VAX/VMS Version 3.64)\n"
1919 @z
2020
2121 @x section 6 (from common.h) (01-FEB-1992 ST)
cweav-w32.ch+52−0
@@ -0,0 +1,52 @@
1+This is the change file for CWEB's CWEAVE under Win32
2+(Contributed by Fabrice Popineau, February 2002)
3+
4+@x section 1
5+@d banner "This is CWEAVE (Version 3.64)\n"
6+@y
7+@d banner "This is CWEAVE (Version 3.64win32)\n"
8+@z
9+
10+@x
11+@ We predeclare several standard system functions here instead of including
12+their system header files, because the names of the header files are not as
13+standard as the names of the functions. (For example, some \CEE/ environments
14+have \.{<string.h>} where others have \.{<strings.h>}.)
15+
16+@<Predecl...@>=
17+extern int strlen(); /* length of string */
18+extern int strcmp(); /* compare strings lexicographically */
19+extern char* strcpy(); /* copy one string to another */
20+extern int strncmp(); /* compare up to $n$ string characters */
21+extern char* strncpy(); /* copy up to $n$ string characters */
22+@y
23+@z
24+
25+@x
26+int names_match(p,first,l,t)
27+name_pointer p; /* points to the proposed match */
28+@y
29+int __cdecl names_match(p,first,l,t)
30+name_pointer p; /* points to the proposed match */
31+@z
32+
33+@x
34+void
35+init_p(p,t)
36+name_pointer p;
37+@y
38+void __cdecl
39+init_p(p,t)
40+name_pointer p;
41+@z
42+
43+@x
44+@ @<Include...@>=
45+#include <ctype.h> /* definition of |isalpha|, |isdigit| and so on */
46+#include <stdlib.h> /* definition of |exit| */
47+@y
48+@ @<Include...@>=
49+#include <ctype.h> /* definition of |isalpha|, |isdigit| and so on */
50+#include <stdlib.h> /* definition of |exit| */
51+#include <string.h> /* definition of |strncmp| and |strncpy| */
52+@z
cweave.w+8−10
@@ -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 3.61 --- July 2000
5+% Version 3.64 --- February 2002
66 % (essentially the same as version 3.6, which added
77 % recently introduced features of standard C++ to version 3.4)
88
@@ -29,11 +29,11 @@ · 20 unmodified lines
2929 \def\skipxTeX{\\{skip\_\TEX/}}
3030 \def\copyxTeX{\\{copy\_\TEX/}}
3131
32−\def\title{CWEAVE (Version 3.61)}
32+\def\title{CWEAVE (Version 3.64)}
3333 \def\topofcontents{\null\vfill
3434 \centerline{\titlefont The {\ttitlefont CWEAVE} processor}
3535 \vskip 15pt
36− \centerline{(Version 3.61)}
36+ \centerline{(Version 3.64)}
3737 \vfill}
3838 \def\botofcontents{\vfill
3939 \noindent
@@ -65,7 +65,7 @@ Crusius, and others who have contributed improvements. · 25 unmodified lines
6565 The ``banner line'' defined here should be changed whenever \.{CWEAVE}
6666 is modified.
6767
68−@d banner "This is CWEAVE (Version 3.61)\n"
68+@d banner "This is CWEAVE (Version 3.64)\n"
6969
7070 @c @<Include files@>@/
7171 @h
@@ -101,7 +101,7 @@ char **av; /* argument values */ · 29 unmodified lines
101101 {
102102 argc=ac; argv=av;
103103 program=cweave;
104− make_xrefs=force_lines=1; /* controlled by command-line options */
104+ make_xrefs=force_lines=make_pb=1; /* controlled by command-line options */
105105 common_init();
106106 @<Set initial values@>;
107107 if (show_banner) printf(banner); /* print a ``banner line'' */
@@ -703,7 +703,7 @@ get_next() /* produces the next input token */ · 595 unmodified lines
703703 @<Check if we're at the end of a preprocessor command@>;
704704 if (loc>limit && get_line()==0) return(new_section);
705705 c=*(loc++);
706− if (xisdigit(c) || c=='\\' || c=='.') @<Get a constant@>@;
706+ if (xisdigit(c) || c=='.') @<Get a constant@>@;
707707 else if (c=='\'' || c=='"' || (c=='L'&&(*loc=='\'' || *loc=='"'))@|
708708 || (c=='<' && sharp_include_line==1))
709709 @<Get a string@>@;
@@ -805,7 +805,7 @@ switch(c) { · 95 unmodified lines
805805 and hexadecimal numbers; it is reasonable to stick to each convention
806806 within its realm. Thus the \CEE/ part of a \.{CWEB} file has octals
807807 introduced by \.0 and hexadecimals by \.{0x}, but \.{CWEAVE} will print
808−with \TeX/ macros that the user can redefine to fit the context.
808+with \TEX/ macros that the user can redefine to fit the context.
809809 In order to simplify such macros, we replace some of the characters.
810810
811811 Notice that in this section and the next, |id_first| and |id_loc|
@@ -813,9 +813,7 @@ are pointers into the array |section_text|, not into |buffer|. · 1 unmodified line
813813
814814 @<Get a constant@>= {
815815 id_first=id_loc=section_text+1;
816− if (*(loc-1)=='\\') {*id_loc++='~';
817− while (xisdigit(*loc)) *id_loc++=*loc++;} /* octal constant */
818− else if (*(loc-1)=='0') {
816+ if (*(loc-1)=='0') {
819817 if (*loc=='x' || *loc=='X') {*id_loc++='^'; loc++;
820818 while (xisxdigit(*loc)) *id_loc++=*loc++;} /* hex constant */
821819 else if (xisdigit(*loc)) {*id_loc++='~';
cweb.1+76−44
@@ -1,26 +1,30 @@
1−.TH CWEB 1L 6/15/92
1+.TH CWEB 1L 2002-Apr-13
2+.
23 .SH NAME
34 ctangle, cweave \- translate CWEB to C and/or TeX
5+.
46 .SH SYNOPSIS
7+.na
58 .B ctangle
69 [
710 .B \-bhp
811 ] [
9−.B \+s
12+.B +s
1013 ] webfile[.w] [changefile[.ch]] [outputfile[.c]]
1114 .br
1215 .B cweave
1316 [
14−.B \-bfhpx
17+.B \-befhpx
1518 ] [
16−.B \+es
19+.B +s
1720 ] webfile[.w] [changefile[.ch]] [outputfile[.tex]]
18−
21+.ad
22+.
1923 .SH DESCRIPTION
2024 The
2125 .I ctangle
2226 program converts a CWEB
23−source document into a C program that may be compiled in the usual way.
27+source document into a C\ program that may be compiled in the usual way.
2428 The output file includes #line specifications so that debugging can be
2529 done in terms of the CWEB source file.
2630 .PP
@@ -34,73 +38,101 @@ extensive cross-index information that it gathers automatically. · 7 unmodified lines
3438 .PP
3539 CWEB allows you to prepare a single
3640 document containing all the information that is needed both to produce
37−a compilable C program and to produce a well-formatted document
38−describing the program in as much detail as the writer may desire. The
39−user of CWEB ought to be familiar with TeX as well as C.
41+a compilable C\ program and to produce a well-formatted document
42+describing the program in as much detail as the writer may desire.
43+The user of CWEB ought to be familiar with TeX as well as\ C.
4044 .PP
4145 The command line should have one, two, or three names on it.
4246 The first is taken as the CWEB file (and .w is added if there is no
43−extension). If that file cannot be opened, the extension .web is
44−tried instead. (But .w is recommended, since .web usually implies Pascal.)
47+extension).
48+If that file cannot be opened, the extension .web is tried instead.
49+(But .w is recommended, since .web usually implies Pascal.)
4550 If there is a second name, it is a change file (and .ch is added if there is
46−no extension). The change file overrides parts of the WEB file,
47−as described in the documentation. If there is a third name, it overrides
51+no extension).
52+The change file overrides parts of the WEB file,
53+as described in the documentation.
54+If there is a third name, it overrides
4855 the default name of the output file, which is ordinarily the same as
4956 the name of the input file (but on the current directory) with the
5057 extension .c or .tex.
5158 .PP
52−Options in the command line may be either turned off with -
53−(if they are on by default) or turned on with + (if they are off by
54−default). In fact, the options are processed from left to right,
55−so a sequence like -f +f corresponds to +f (which is the default).
59+Options in the command line may be either turned off with\ \-
60+(if they are on by default) or turned on with\ + (if they are off by
61+default).
62+In fact, the options are processed from left to right,
63+so a sequence like -f\ +f corresponds to +f (which is the default).
5664 .PP
5765 The
5866 .B \-b
5967 option suppresses the banner line that normally appears on your terminal
60−when ctangle or cweave begins. The
68+when ctangle or cweave begins.
69+The
6170 .B \-h
6271 option suppresses the happy message that normally appears if the processing
63−was successful. The
72+was successful.
73+The
6474 .B \-p
6575 option suppresses progress reports (starred module numbers) as the processing
66−takes place. If you say -bhp, you get nothing but error messages.
76+takes place.
77+If you say -bhp, you get nothing but error messages.
6778 .PP
68−The \+s option prints statistics about memory usage at the end of a run
79+The
80+.B +s
81+option prints statistics about memory usage at the end of a run
6982 (assuming that the programs have been compiled with the -DSTAT switch).
7083 .PP
71−The \+e option encloses C material formatted by
72−.I cweave
73−in brackets
74−\\PB\{...\}, so that special hooks can be used. This is commonly used by
75−.I cweb-latex
76−, although it can mess up index entries of PDF output if
77−module names refer to C objects (as they often do).
78−.PP
79−There are two other options applicable to
84+There are three other options applicable to
8085 .I cweave
8186 only:
8287 .B \-f
8388 means do not force a newline after every statement in the formatted output.
89+.B \-e
90+inhibits the enclosure of C\ material formatted by
91+.I cweave
92+in brackets
93+\ePB{...}.
94+Such brackets are normally inserted so that special hooks
95+can be used by
96+.I cweb-latex
97+and similar programs.
8498 .B \-x
8599 means omit the index and table of contents.
86−.PP
100+.
87101 .SH FILES
88−/usr/local/lib/tex/inputs/cwebmac.tex TeX macros used by cweave output.
89−.br
90−/usr/local/src/cweb/cwebman.tex The user manual.
91−.br
92−/usr/local/src/cweb/examples/wc.w An introductory example.
93−.br
94−/usr/local/lib/cweb Directory for cweb "include" files.
102+.TP
103+/usr/local/lib/tex/inputs/cwebmac.tex
104+TeX macros used by cweave output.
105+.TP
106+/usr/local/src/cweb/cwebman.tex
107+The user manual.
108+.TP
109+/usr/local/src/cweb/examples/wc.w
110+An introductory example.
111+.TP
112+/usr/local/src/cweb/examples/wmerge.w
113+Patch program based on CWEB-style change files.
114+.TP
115+/usr/local/lib/cweb
116+Directory for cweb "include" files.
117+.
95118 .SH "SEE ALSO"
119+.TP
96120 .I Literate Programming
97−by D.E. Knuth.
98−.br
121+by D. E. Knuth
122+.TP
99123 .I Weaving a Program
100124 by Wayne Sewell
101−.br
125+.TP
126+.I The CWEB System of Structured Documentation
127+by Donald E. Knuth and Silvio Levy (hardcopy version of cwebman.tex
128+and the source code listings)
129+.TP
102130 tex(1), cc(1)
103−.SH "AUTHORS"
104−Don Knuth wrote WEB for TeX and Pascal. Silvio Levy designed and developed CWEB
105−by adapting the WEB conventions to C and by recoding everything in CWEB.
131+.
132+.SH AUTHORS
133+Don Knuth wrote WEB for TeX and Pascal.
134+Silvio Levy designed and developed CWEB
135+by adapting the WEB conventions to\ C and by recoding everything in CWEB.
106136 Knuth began using CWEB and made further refinements.
137+Many other helpers are acknowledged in the CWEB manual.
138+
cwebmac.tex+178−79
@@ -1,15 +1,16 @@
11 % standard macros for CWEB listings (in addition to plain.tex)
2−% Version 3.63 --- January 2001
2+% Version 3.64 --- February 2002
33 \ifx\documentstyle\undefined\else\endinput\fi % LaTeX will use other macros
4−\xdef\fmtversion{\fmtversion+CWEB3.63}
4+\xdef\fmtversion{\fmtversion+CWEB3.64}
5+\chardef\cwebversion=3 \chardef\cwebrevision=64
56 \newif\ifpdf
67 \ifx\pdf+\pdftrue\fi
78 % Uncomment the following line if you want PDF goodies to be the default
89 %\ifx\pdf-\else\pdftrue\fi
910 \def\pdflinkcolor{0 0 1} % the RGB values for hyperlink color
1011 \newif\ifpdftex
11−\ifx\pdfoutput\undefined \pdftexfalse
12−\else \pdftextrue \pdfoutput=1 \pdfcompresslevel=9 \input pdfcolor \fi
12+\ifx\pdfoutput\undefined \pdftexfalse \else\ifnum\pdfoutput=0 \pdftexfalse
13+\else \pdftextrue \pdfoutput=1 \input pdfcolor \let\setcolor\pdfsetcolor \fi\fi
1314 \newif\ifacro \ifpdf\acrotrue\fi \ifpdftex\acrotrue\fi
1415
1516 \let\:=\. % preserve a way to get the dot accent
@@ -120,49 +121,52 @@ · 104 unmodified lines
120121 \def\?{\mathrel?}
121122 \def\note#1#2.{\Y\noindent{\hangindent2em%
122123 \baselineskip10pt\eightrm#1~\ifacro{\pdfnote#2.}\else#2\fi.\par}}
123−% The following are pdf macros
124+
124125 \newtoks\toksA \newtoks\toksB \newtoks\toksC \newtoks\toksD
126+\newtoks\toksE \newtoks\toksF \newtoks\usersanitizer
125127 \newcount\countA \countA=0 \newcount\countB \countB=0
126−\def\thewidth{\the\wd0\space}
127−\def\theheight{\the\ht0\space}
128−\def\thedepth{\the\dp0\space}
128+\newcount\countC \countC=0
129+\newif\iftokprocessed \newif\ifTnum \newif\ifinstr
130+{\def\\{\global\let\spacechar= }\\ }
131+
132+\ifacro % The following are pdf macros
133+\def\thewidth{\the\wd0 \space}
134+\def\theheight{\the\ht\strutbox\space}
135+\def\thedepth{\the\dp\strutbox\space}
129136 \ifpdftex
130137 \ifx\pdfannotlink\undefined\let\pdfannotlink\pdfstartlink\fi% for pdfTeX 0.14
131− \def\pdflink#1#2{\hbox{\pdfannotlink attr{/Border [0 0 0]} goto num #1
132− \BlueGreen #1\Black\pdfendlink}}
138+ \def\pdflink#1#2{\hbox{\pdfannotlink height\ht\strutbox depth\dp\strutbox
139+ attr{/Border [0 0 0]} goto num #1 \BlueGreen #1\Black\pdfendlink}}
133140 \else\def\pdflink#1#2{\setbox0=\hbox{\special{pdf: bc [ \pdflinkcolor ]}{#1}%
134− \special{pdf: ec}}\special{pdf: ann width \thewidth\space height \theheight
135− \space depth \thedepth\space << /Type /Annot /Subtype /Link
141+ \special{pdf: ec}}\special{pdf: ann width \thewidth height \theheight
142+ depth \thedepth << /Type /Annot /Subtype /Link
136143 /Border [0 0 0] /A << /S /GoTo /D (#2) >> >>}\box0\relax}\fi
137144 \def\pdfnote#1.{\setbox0=\hbox{\toksA={#1.}\toksB={}\maketoks}\the\toksA}
138−\def\firstsecno#1.{\setbox0=\hbox{\toksA={#1.}\toksB={}
139− \def\makenote{\addtokens{\toksB}{\the\toksC}\def\makenote{\toksD={}
145+\def\firstsecno#1.{\setbox0=\hbox{\toksA={#1.}\toksB={}%
146+ \def\makenote{\addtokens\toksB{\the\toksC}\def\makenote{\toksD={}
140147 \toksC={}\let\space\empty}\makenote}\maketoks}}
141148 \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
142−\def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks}
143−\def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}}
144−\def\maketoks{%
145− \expandafter\poptoks\the\toksA|ENDTOKS|
146− \ifx\first0\adn0
147− \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3
148− \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6
149− \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9
150− \else
151− \ifnum0=\countA\else\makenote\fi
152− \ifx\first.\let\next=\done\else
153− \let\next=\maketoks
154− \addtokens{\toksB}{\the\toksD}
155− \ifx\first,\addtokens{\toksB}{\space}\fi
156− \fi
157− \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
158− \next
149+\def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}%
150+ \ifcat\noexpand\first0\countB=`#1\else\countB=0\fi\toksA={#2}}
151+\def\maketoks{\expandafter\poptoks\the\toksA|ENDTOKS|%
152+ \ifnum\countB>`9 \countB=0 \fi
153+ \ifnum\countB<`0
154+ \ifnum0=\countC\else\makenote\fi
155+ \ifx\first.\let\next=\maketoksdone\else
156+ \let\next=\maketoks
157+ \addtokens\toksB{\the\toksD}
158+ \ifx\first,\addtokens\toksB{\space}\fi
159+ \fi
160+ \else \addtokens\toksC{\the\toksD}\global\countC=1\let\next=\maketoks
161+ \fi
162+ \next
159163 }
160−\def\makenote{\addtokens{\toksB}%
161− {\noexpand\pdflink{\the\toksC}{\romannumeral\the\toksC}}\toksC={}\global\countA=0}
162−\def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
163−\def\pdfURL#1#2{\ifpdftex\pdfannotlink attr {/Border [0 0 0]} user {
164− /Type /Action /Subtype /Link /A << /S /URI /URI (#2) >>
165− }\BlueGreen #1\Black \pdfendlink
164+\def\makenote{\addtokens\toksB
165+ {\noexpand\pdflink{\the\toksC}{\romannumeral\the\toksC}}\toksC={}\global\countC=0}
166+\def\maketoksdone{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
167+\def\pdfURL#1#2{\ifpdftex\pdfannotlink height\ht\strutbox depth\dp\strutbox
168+ attr {/Border [0 0 0]} user { /Type /Action /Subtype /Link /A
169+ << /S /URI /URI (#2) >>}\BlueGreen #1\Black \pdfendlink
166170 \else \ifpdf{\setbox0=\hbox{\special{pdf: bc [ \pdflinkcolor ]}{#1}%
167171 \special{pdf: ec}}\special{pdf: ann width \thewidth\space height \theheight
168172 \space depth \thedepth\space << /Border [0 0 0]
@@ -170,7 +174,105 @@ · 1 unmodified line
170174 \else #1 ({\tt#2})\fi\fi}
171175 {\catcode`\~=12 \gdef\TILDE/{~}} % ~ in a URL
172176 {\catcode`\_=12 \gdef\UNDER/{_}} % _ in a URL
173−% End of pdf macros
177+\def\sanitizecommand#1#2{\addtokens\usersanitizer
178+ {\noexpand\dosanitizecommand\noexpand#1{#2}}}
179+\def\dosanitizecommand#1#2{\ifx\nxt#1\addF{#2}\fi}
180+
181+\catcode`\[=1 \catcode`\]=2 \catcode`\{=12 \catcode`\}=12
182+ \def\lbchar[{] \def\rbchar[}]
183+\catcode`\[=12 \catcode`\]=12 \catcode`\{=1 \catcode`\}=2
184+\catcode`\~=12 \def\tildechar{~} \catcode`\~=13
185+\catcode`\|=0 |catcode`|\=12 |def|bschar{\} |catcode`|\=0 \catcode`\|=12
186+\def\makeoutlinetoks{\Tnumfalse\afterassignment\makeolproctok\let\nxt= }
187+\def\makeolnexttok{\afterassignment\makeolproctok\let\nxt= }
188+\def\makeolgobbletok{\afterassignment\makeolnexttok\let\nxt= }
189+\def\addF#1{\addtokens\toksF{#1}\tokprocessedtrue}
190+% now comes a routine to "sanitize" section names, for pdf outlines
191+\def\makeolproctok{\tokprocessedfalse
192+ \let\next\makeolnexttok % default
193+ \ifx\nxt\outlinedone\let\next\outlinedone
194+ \else\ifx{\nxt \else\ifx}\nxt \Tnumfalse \instrfalse % skip braces
195+ \else\ifx$\nxt % or a $ sign
196+ \else\ifx^\nxt \addF^\else\ifx_\nxt \addF_% sanitize ^ and _
197+ \else\ifx\nxt\spacechar \addF\space
198+ \else\if\noexpand\nxt\relax % we have a control sequence; is it one we know?
199+ \ifx\nxt~\addF\space
200+ \else\ifx\nxt\onespace\addF\space
201+ \else\the\usersanitizer
202+ \iftokprocessed\else\makeolproctokctli
203+ \iftokprocessed\else\makeolproctokctlii
204+ \iftokprocessed\else\makeolproctokctliii % if not recognised, skip it
205+ \fi\fi\fi\fi\fi
206+ \else % we don't have a control sequence, it's an ordinary char
207+ \ifx/\nxt \addF{\string\/}% quote chars special to PDF with backslash
208+ \else\ifx(\nxt \addF{\string\(}\else\ifx)\nxt \addF{\string\)}%
209+ \else\ifx[\nxt \addF{\string\[}\else\ifx]\nxt \addF{\string\]}%
210+ \else\expandafter\makeolproctokchar\meaning\nxt
211+ \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
212+ \next
213+}
214+\def\makeolproctokchar#1 #2 #3{\addF{#3}}
215+\def\makeolproctokctli{%
216+ \ifx\nxt\CEE\addF{C}\let\next\makeolgobbletok % \CEE/
217+ \else\ifx\nxt\UNIX\addF{UNIX}\let\next\makeolgobbletok % \UNIX/
218+ \else\ifx\nxt\TEX\addF{TeX}\let\next\makeolgobbletok % \TEX/
219+ \else\ifx\nxt\TeX\addF{TeX}\else\ifx\nxt\LaTeX\addF{LaTeX}%
220+ \else\ifx\nxt\CPLUSPLUS\addF{C++}\let\next\makeolgobbletok % \CPLUSPLUS/
221+ \else\ifx\nxt\Cee\addF{C}%
222+ \else\ifx\nxt\PB \let\next\makeolgobbletok \tokprocessedtrue % \PB{...}
223+ \else\ifx\nxt\.\tokprocessedtrue\instrtrue % \.{...}
224+ % skip \|
225+ \else\ifx\nxt\\\ifinstr\addF{\bschar\bschar}\else\tokprocessedtrue\fi
226+ \else\ifx\nxt\&\ifinstr\addF&\else\tokprocessedtrue\fi
227+ \else\ifx\nxt\~\ifTnum\addF{0}\else\addF\tildechar\fi % 077->\T{\~77}
228+ \else\ifx\nxt\_\ifTnum\addF{E}\else\addF_\fi % 0.1E5->\T{0.1\_5}
229+ \else\ifx\nxt\^\ifTnum\addF{0x}\else\addF^\fi % 0x77 -> \T{\^77}
230+ \else\ifx\nxt\$\ifTnum\tokprocessedtrue\else\addF$\fi % \T{77\$L}
231+ \else\ifx\nxt\{\addF\lbchar \else\ifx\nxt\}\addF\rbchar
232+ \else\ifx\nxt\ \addF\space \else\ifx\nxt\#\addF{\string\#}%
233+ \else\ifx\nxt\PP\addF{++}\else\ifx\nxt\MM\addF{--}%
234+ \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
235+}
236+\def\makeolproctokctlii{%
237+ \ifx\nxt\MG\addF{->}\else\ifx\nxt\GG\addF{>>}%
238+ \else\ifx\nxt\LL\addF{<<}\else\ifx\nxt\NULL\addF{NULL}%
239+ \else\ifx\nxt\AND\addF&\else\ifx\nxt\OR\addF|%
240+ \else\ifx\nxt\XOR\addF^\else\ifx\nxt\CM\addF\tildechar
241+ \else\ifx\nxt\MOD\addF{\string\%}\else\ifx\nxt\DC\addF{::}%
242+ \else\ifx\nxt\PA\addF{.*}\else\ifx\nxt\MGA\addF{->*}%
243+ \else\ifx\nxt\this\addF{this}\else\ifx\nxt\?\addF?%
244+ \else\ifx\nxt\E\addF{==}\else\ifx\nxt\G\addF{>=}%
245+ \else\ifx\nxt\I\addF{!=}\else\ifx\nxt\K\addF{=}%
246+ \else\ifx\nxt\l\addF{l}\else\ifx\nxt\L\addF{L}%
247+ \else\ifx\nxt\o\addF{o}\else\ifx\nxt\O\addF{O}%
248+ \else\ifx\nxt\R\addF!%
249+ \else\ifx\nxt\T \Tnumtrue \let\next\makeolgobbletok
250+ \tokprocessedtrue % \T{number}
251+ \else\ifx\nxt\AM\addF&\else\ifx\nxt\%\addF{\string\%}%
252+ \fi\fi\fi\fi\fi \fi\fi\fi\fi\fi
253+ \fi\fi\fi\fi\fi \fi\fi\fi\fi\fi
254+ \fi\fi\fi\fi\fi\fi
255+}
256+\def\makeolproctokctliii{%
257+ \ifx\nxt\V\addF{||}\else\ifx\nxt\W\addF{&&}\else\ifx\nxt\Z\addF{<=}%
258+ \else\ifx\nxt\*\addF*\else\ifx\nxt\Xand\addF{\space and\space}%
259+ \else\ifx\nxt\Xandxeq\addF{\space and_eq\space}%
260+ \else\ifx\nxt\Xbitand\addF{\space bitand\space}%
261+ \else\ifx\nxt\Xbitor\addF{\space bitor\space}%
262+ \else\ifx\nxt\Xcompl\addF{\space compl\space}%
263+ \else\ifx\nxt\Xnot\addF{\space not\space}%
264+ \else\ifx\nxt\Xnotxeq\addF{\space not_eq\space}%
265+ \else\ifx\nxt\Xor\addF{\space or\space}%
266+ \else\ifx\nxt\Xorxeq\addF{\space or_eq\space}%
267+ \else\ifx\nxt\Xxor\addF{\space xor\space}%
268+ \else\ifx\nxt\Xxorxeq\addF{\space xor_eq\space}%
269+ \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
270+ \fi\fi\fi\fi\fi
271+}
272+\def\outlinedone{\edef\outlinest{\global\noexpand\toksE={\the\toksF}}%
273+ \outlinest\let\outlinedone=\relax}
274+\fi % End of pdf macros
275+
174276 \def\lapstar{\rlap{*}}
175277 \def\stsec{\rightskip=0pt % get out of C mode (cf. \B)
176278 \sfcode`;=1500 \pretolerance 200 \hyphenpenalty 50 \exhyphenpenalty 50
@@ -208,13 +310,20 @@ · 31 unmodified lines
208310 % \L is Polish letter suppressed-L
209311 \outer\def\M#1{\MN{#1}\ifon\vfil\penalty-100\vfilneg % beginning of section
210312 \vskip\intersecskip\startsection\ignorespaces}
211−\outer\def\N#1#2#3.{\gdepth=#1\gtitle={#3}\MN{#2}% beginning of starred section
313+\outer\def\N#1#2#3.{% beginning of starred section
314+ \ifacro{\toksF={}\makeoutlinetoks#3\outlinedone\outlinedone}\fi
315+ \gdepth=#1\gtitle={#3}\MN{#2}%
212316 \ifon\ifnum#1<\secpagedepth \vfil\eject % force page break if depth is small
213317 \else\vfil\penalty-100\vfilneg\vskip\intersecskip\fi\fi
214318 \message{*\secno} % progress report
215− \edef\next{\write\cont{\ZZ{#3}{#1}{\secno}% write to contents file
216− {\noexpand\the\pageno}}}\next % \ZZ{title}{depth}{sec}{page}
217− \ifpdf\special{pdf: outline #1 << /Title (#3) /Dest
319+ \def\stripprefix##1>{}\def\gtitletoks{#3}%
320+ \edef\gtitletoks{\expandafter\stripprefix\meaning\gtitletoks}%
321+ \edef\next{\write\cont{\ZZ{\gtitletoks}{#1}{\secno}% write to contents file
322+ {\noexpand\the\pageno}{\the\toksE}}}\next % \ZZ{title}{depth}{sec}{page}{ss}
323+ \ifpdftex\expandafter\xdef\csname curr#1\endcsname{\secno}
324+ \ifnum#1>0\countB=#1 \advance\countB by-1
325+ \advancenumber{chunk\the\countB.\expnumber{curr\the\countB}}\fi\fi
326+ \ifpdf\special{pdf: outline #1 << /Title (\the\toksE) /Dest
218327 [ @thispage /FitH @ypos ] >>}\fi
219328 \ifon\startsection{\bf#3.\quad}\ignorespaces}
220329 \def\MN#1{\par % common code for \M, \N
@@ -245,17 +354,9 @@ · 24 unmodified lines
245354 \let\ZZ=\let % now you can \write the control sequence \ZZ
246355 \let\*=*
247356
248−\let\Xand=\W
249−\def\Xandxeq{\MRL{{\W}{\K}}}
250−\let\Xbitand=\AND
251−\let\Xbitor=\OR
252−\let\Xcompl=\CM
253−\let\Xnot=\R
254−\let\Xnotxeq=\I
255−\let\Xor=\V
256−\def\Xorxeq{\MRL{{\OR}{\K}}}
257−\let\Xxor=\XOR
258−\def\Xxorxeq{\MRL{{\XOR}{\K}}}
357+\def\Xand{\W} \def\Xandxeq{\MRL{{\AND}{\K}}} \def\Xbitand{\AND}
358+\def\Xbitor{\OR} \def\Xcompl{\CM} \def\Xnot{\R} \def\Xnotxeq{\I} \def\Xor{\V}
359+\def\Xorxeq{\MRL{{\OR}{\K}}} \def\Xxor{\XOR} \def\Xxorxeq{\MRL{{\XOR}{\K}}}
259360
260361 %\def\oct{\hbox{\rm\char'23\kern-.2em\it\aftergroup\?\aftergroup}} % WEB style
261362 %\def\hex{\hbox{\rm\char"7D\tt\aftergroup}} % WEB style
@@ -268,10 +369,11 @@ · 6 unmodified lines
268369 \def\onmaybe{\let\ifon=\maybe} \let\maybe=\iftrue
269370 \newif\ifon \newif\iftitle \newif\ifpagesaved
270371
271−\def\lheader{\mainfont\the\pageno\eightrm\qquad\grouptitle\hfill\title\qquad
272− \mainfont\topsecno} % top line on left-hand pages
273−\def\rheader{\mainfont\topsecno\eightrm\qquad\title\hfill\grouptitle
274− \qquad\mainfont\the\pageno} % top line on right-hand pages
372+\newif\ifheader
373+\def\lheader{\headertrue\mainfont\the\pageno\eightrm\qquad\grouptitle
374+ \hfill\title\qquad\mainfont\topsecno} % top line on left-hand pages
375+\def\rheader{\headertrue\mainfont\topsecno\eightrm\qquad\title\hfill
376+ \grouptitle\qquad\mainfont\the\pageno} % top line on right-hand pages
275377 \def\grouptitle{\let\i=I\let\j=J\uppercase\expandafter{\expandafter
276378 \takethree\topmark}}
277379 \def\topsecno{\expandafter\takeone\topmark}
@@ -356,18 +458,6 @@ · 78 unmodified lines
356458 \if L\lr\else\null\vfill\eject\fi % finish the current page
357459 \parfillskip 0pt plus 1fil
358460 \def\grouptitle{NAMES OF THE SECTIONS}
359− \ifacro \def\outsecname{Names of the sections} \let\Xpdf\X \fi
360− \ifpdftex \makebookmarks \pdfdest name {NOS} fitb
361− \pdfoutline goto name {NOS} count -\secno {\outsecname}
362− \def\X##1:##2\X{\Xpdf##1:##2\X
363− \firstsecno##1.\toks0{##2}\pdfoutline goto num \the\toksA {\the\toks0}}
364− \else\ifpdf
365− \special{pdf: outline -1 << /Title (\outsecname)
366− /Dest [ @thispage /FitH @ypos ] >>}
367− \def\X##1:##2\X{\Xpdf##1:##2\X
368− \firstsecno##1.\toks0{##2} \special{pdf: outline 0 << /Title
369− (\the\toks0) /A << /S /GoTo /D (\romannumeral\the\toksA) >> >>}}
370− \fi\fi
371461 \let\topsecno=\nullsec
372462 \message{Section names:}
373463 \output={\normaloutput\page\lheader\rheader}
@@ -378,20 +468,29 @@ · 4 unmodified lines
378468 \def\U{\note{Used in section}} % crossref for use of a section
379469 \def\Us{\note{Used in sections}} % crossref for uses of a section
380470 \def\I{\par\hangindent 2em}\let\*=*
471+ \ifacro \def\outsecname{Names of the sections} \let\Xpdf\X
472+ \ifpdftex \makebookmarks \pdfdest name {NOS} fitb
473+ \pdfoutline goto name {NOS} count -\secno {\outsecname}
474+ \def\X##1:##2\X{\Xpdf##1:##2\X \firstsecno##1.%
475+ {\toksF={}\makeoutlinetoks##2\outlinedone\outlinedone}%
476+ \pdfoutline goto num \the\toksA \expandafter{\the\toksE}}
477+ \else\ifpdf
478+ \special{pdf: outline -1 << /Title (\outsecname)
479+ /Dest [ @thispage /FitH @ypos ] >>}
480+ \def\X##1:##2\X{\Xpdf##1:##2\X \firstsecno##1.%
481+ {\toksF={}\makeoutlinetoks##2\outlinedone\outlinedone}%
482+ \special{pdf: outline 0 << /Title (\the\toksE)
483+ /A << /S /GoTo /D (\romannumeral\the\toksA) >> >>}}
484+ \fi\fi\fi
381485 \readsections}
382−\def\makebookmarks{% read contents info for PDF outlines (twice)
383− \let\ZZ=\scanbookmarkline \readcontents\relax
384− \let\ZZ=\writebookmarkline \readcontents\relax}
486+\def\makebookmarks{\let\ZZ=\writebookmarkline \readcontents\relax}
385487 \def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0%
386488 \else \csname#1\endcsname \fi} % Petr Olsak's macros from texinfo.tex
387489 \def\advancenumber#1{\countA=\expnumber{#1}\relax \advance\countA by1
388490 \expandafter\xdef\csname#1\endcsname{\the\countA}}
389−\def\scanbookmarkline#1#2#3#4{% remember last level item and add to parent
390− \expandafter\xdef\csname curr#2\endcsname{#3}
391− \ifnum#2>0\countB=#2 \advance\countB by-1
392− \advancenumber{chunk\the\countB.\expnumber{curr\the\countB}}\fi}
393−\def\writebookmarkline#1#2#3#4{\pdfoutline goto num #3
394− count -\expnumber{chunk#2.#3}{#1}}
491+\def\writebookmarkline#1#2#3#4#5{{%
492+ \let\(=\let \let\)=\let \let\[=\let \let\]=\let \let\/=\let
493+ \pdfoutline goto num #3 count -\expnumber{chunk#2.#3} {#5}}}
395494 \def\con{\par\vfill\eject % finish the section names
396495 % \ifodd\pageno\else\titletrue\null\vfill\eject\fi % for duplex printers
397496 \rightskip 0pt \hyphenpenalty 50 \tolerance 200
@@ -405,7 +504,7 @@ · 7 unmodified lines
405504 \let\ZZ=\contentsline
406505 \readcontents\relax % read the contents info
407506 \botofcontents \end} % print the contents page(s) and terminate
408−\def\contentsline#1#2#3#4{\ifnum#2=0 \smallbreak\fi
507+\def\contentsline#1#2#3#4#5{\ifnum#2=0 \smallbreak\fi
409508 \line{\consetup{#2}#1
410509 \rm\leaders\hbox to .5em{.\hfil}\hfil
411510 \ \ifacro\pdflink{#3}{\romannumeral#3}\else#3\fi\hbox to3em{\hss#4}}}
cwebman.tex+61−13
@@ -2,6 +2,7 @@ · 1 unmodified line
22
33 \def\tangref{3} % where the main explanation of CTANGLing is given
44 \input cwebmac
5+\acrofalse\pdffalse\pdftexfalse
56 \def\page{\box255 } \normalbottom
67 \parskip 0pt plus 1pt
78 \def\RA{\char'31 } % right arrow
@@ -34,7 +35,7 @@ · 26 unmodified lines
3435
3536 \def\lheader{\mainfont\the\pageno\hfill\sc\runninghead\hfill}
3637 \def\rheader{\hfill\sc\runninghead\hfill\mainfont\the\pageno}
37−\def\runninghead{{\tentt CWEB} USER MANUAL (VERSION 3.63)}
38+\def\runninghead{{\tentt CWEB} USER MANUAL (VERSION 3.64)}
3839
3940 % This verbatim mode assumes that ! marks are !! in the text being copied.
4041 \def\verbatim{\begingroup
@@ -48,7 +49,7 @@ · 7 unmodified lines
4849 \null\vfill
4950 \centerline{\titlefont The {\ttitlefont CWEB} System of
5051 Structured Documentation}
51−\vskip 18pt\centerline{(Version 3.63 --- January 2001)}
52+\vskip 18pt\centerline{(Version 3.64 --- February 2002)}
5253 \vskip 24pt
5354 \centerline{\authorfont Donald E. Knuth and Silvio Levy}
5455 \vfill
@@ -1143,8 +1144,9 @@ $$\vbox{\halign{\.{#}\hfil\cr · 1088 unmodified lines
11431144 tex "\\let\\pdf+ \\input cob"\cr
11441145 dvipdfm cob\cr
11451146 acroread cob.pdf\cr}}$$
1146−instead of invoking \TeX\ in the normal way. (Thanks to Hans Hagen and
1147−C\'esar Augusto Rorato Crusius for the macros that make this work.)
1147+instead of invoking \TeX\ in the normal way. (Thanks to Hans Hagen,
1148+C\'esar Augusto Rorato Crusius, and Julian Gilbey
1149+for the macros that make this work.)
11481150 Alternatively, thanks to H\`an Th\^e\kern-.3em\raise.3ex\hbox{\'{}} Th\`anh
11491151 and Andreas Scherer, you can generate \.{cob.pdf} in one step by simply
11501152 saying `\.{pdftex}~\.{cob}'.
@@ -1493,10 +1495,12 @@ features needed by the output of \.{CWEAVE}. · 342 unmodified lines
14931495
14941496 \vskip6pt
14951497 \begingroup \def\tt{\eighttt} \baselineskip9pt
1496−\def\printmacs{\input cwebmac}
1497−\verbatim
1498−!printmacs
1499−!endgroup
1498+\def\printmacs{\begingroup
1499+ \def\do##1{\catcode`##1=12 } \dospecials
1500+ \parskip 0pt \parindent 0pt
1501+ \catcode`\ =13 \catcode`\^^M=13
1502+ \tt \verbatimdefs \input cwebmac \endgroup}
1503+\printmacs
15001504 \endgroup
15011505 \vfill\eject
15021506
@@ -1521,7 +1525,7 @@ it `\.{|identifier|}'. But you can also say `\.{\\\\\{identifier\}}'. The · 18 unmodified lines
15211525 output will look the same in both cases, but the second alternative
15221526 doesn't put \\{identifier} into the index, since
15231527 it bypasses \.{CWEAVE}'s translation from \CEE/ mode. In the second
1524−case you have to put a backslash before each underline character
1528+case you must put a backslash before each underline character
15251529 in the identifier.
15261530
15271531 \point 3. To get typewriter-like type, as when referring to `\.{CWEB}', you
@@ -1574,7 +1578,7 @@ $$\lpile{\.{\\def\\topofcontents\{\\null\\vfill}\cr · 46 unmodified lines
15741578 \.{ { }\\titlefalse \% include headline on the contents page}\cr
15751579 \.{ { }\\def\\rheader\{\\mainfont The \{\\tt CWEAVE\}{ }processor\\hfil\}}\cr
15761580 \.{ { }\\centerline\{\\titlefont The \{\\ttitlefont CWEAVE\}{ }processor\}}\cr
1577− \.{ { }\\vskip 15pt \\centerline\{(Version 3.61)\}{ }\\vfill\}}\cr}$$
1581+ \.{ { }\\vskip 15pt \\centerline\{(Version 3.64)\}{ }\\vfill\}}\cr}$$
15781582 Redefining \.{\\rheader}, which is the headline for right-hand pages,
15791583 suffices in this case to put the desired information at the top of the
15801584 contents page.
@@ -1582,10 +1586,11 @@ contents page. · 1 unmodified line
15821586 \point 9. Data for the table of contents is written to a file that
15831587 is read after the indexes have been \TEX/ed; there's one line of data
15841588 for every starred section. The file \.{common.toc} might look like this:
1585−$$\lpile{\.{\\ZZ \{Introduction\}\{0\}\{1\}\{26\}}\cr
1586− \.{\\ZZ \{The character set\}\{2\}\{5\}\{27\}}\cr}$$
1589+$$\lpile{\.{\\ZZ \{Introduction\}\{0\}\{1\}\{28\}\{\}}\cr
1590+ \.{\\ZZ \{The character set\}\{2\}\{5\}\{29\}\{\}}\cr}$$
15871591 and so on. The \.{\\topofcontents} macro could
15881592 redefine \.{\\ZZ} so that the information appears in any desired format.
1593+(See also point~19 below.)
15891594
15901595 \point 10. Sometimes it is necessary or desirable to divide the output of
15911596 \.{CWEAVE} into subfiles that can be processed separately. For example,
@@ -1700,7 +1705,7 @@ You can send email to · 108 unmodified lines
17001705 \\pdfURL\{the author\}\{mailto:andreas.scherer@@pobox.com\}\cr
17011706 or visit \\pdfURL\{his home page\}\{http://www.pobox.com/%
17021707 \\TILDE/scherer\}.\cr}}$$
1703−In a PDF document, the first argument will appear in blue as
1708+In a {\mc PDF} document, the first argument will appear in blue as
17041709 clickable text; the Acrobat reader, if correctly configured, will then
17051710 redirect those links to the user's browser and open either the
17061711 email client or the HTML viewer. In a hardcopy document, both arguments
@@ -1710,4 +1715,47 @@ in a somewhat awkward way, so that \.{CWEAVE} and/or \TeX\ · 3 unmodified lines
17101715 will not confuse them with formatting controls: Use \.{@@} for \.@
17111716 and \.{\\TILDE/} for \.\~ and \.{\\UNDER/} for \.\_.
17121717
1718+\point 19. {\mc PDF} documents contain bookmarks that list all the major group
1719+titles in the table of contents, some of which will be subsidiary to
1720+others if the depth feature of \.{@*} has been used.
1721+Such bookmark entries are also known as ``outlines.''
1722+Moreover, the final group title, `Names of the sections',
1723+can be opened up to list every section name; Acrobat users can therefore
1724+navigate easily to any desired section.
1725+
1726+The macros of \.{cwebmac.tex} are careful to ``sanitize'' all the names
1727+that appear as bookmarks, by removing special characters and
1728+formatting codes that are inappropriate for the limited typographic
1729+capabilities of {\mc PDF} outlines. For example, one section of \.{CWEAVE}
1730+is named `Cases for \\{case\_like}', which is represented by the \TeX\ code
1731+`\.{Cases} \.{for} \.{\\PB\{\\\\\{case\\\_like\}\}}' in \.{cweave.tex}; its
1732+sanitized name is simply `\.{Cases} \.{for} \.{case\_like}'.
1733+(When \.{.pdf} files are produced, the fifth parameter of every \.{\\ZZ} in
1734+the \.{.toc} file is set to the sanitized form of the first parameter;
1735+see point~9 above and point~20 below.)
1736+
1737+In general, sanitization removes \TeX\ control sequences and braces,
1738+except for control sequences defined by \.{CWEB} itself. Such a translation
1739+works most of the time, but you can override the defaults and obtain any
1740+translation that you want by using \TeX nical tricks. For example, after
1741+$$\.{\\sanitizecommand\\foo\{bar\}}$$
1742+the control sequence \.{\\foo} will sanitize to `\.{bar}'. And after
1743+$$\.{\\def\\kluj\#1\\\\\{foo\}}$$
1744+the \TeX\ code `\.{\\kluj bar\\\\}' will print as `foo' but sanitize
1745+to `\.{bar}', because the control sequences \.{\\kluj} and
1746+\.{\\\\} are removed by sanitization.
1747+
1748+\point 20. Furthermore, group titles can be converted to an arbitrary
1749+sanitized text while also changing their form in running headlines, by
1750+using \.{\\ifheader}. Consider, for example, a \.{CWEB} source file that
1751+begins with the two lines
1752+$$\lpile{\.{\\def\\klujj\#1\\\\\{\\ifheader FOO\\else foo\\fi\}}\cr
1753+\.{@*Chinese \\klujj bar\\.}\cr}$$
1754+This coding introduces a major group entitled `{\bf Chinese foo}', with
1755+running headline `{\eightrm CHINESE FOO}' and table-of-contents entry
1756+`Chinese foo'. The corresponding bookmark is, however, `\.{Chinese} \.{bar}'.
1757+And the corresponding \.{.toc} file entry is
1758+`\.{\\ZZ \{Chinese \\klujj bar\\\\\}\{1\}\{1\}\{1\}\{Chinese bar\}}'.
1759+
17131760 \vfill\end
1761+
examples/wmerge.w+29−21
@@ -1,10 +1,12 @@
1+% Modified 16 Jan 2002 to agree with COMMON version 3.64
2+
13 \def\9#1{} % this hack is explained in CWEB manual Appendix F11
24
35 @* Introduction. This file contains the program \.{wmerge},
46 which takes two or more files and merges them according
57 to the conventions of \.{CWEB}. Namely, it takes an ordinary \.{.w}
68 file and and optional \.{.ch} file and sends the corresponding
7−\.{.w}-style file to standard output (or to a named file),
9+\.{.w}-style file to standard output (or to a named file),
810 expanding all ``includes''
911 that might be specified by \.{@@i} in the original \.{.w} file.
1012 (A more precise description appears in the section on ``command line
@@ -88,7 +90,7 @@ which is defined in \.{/usr/include/sys/types.h}, you should let · 77 unmodified lines
8890 \.{WEAVE} know that this is a type, either by including the \.{.h} file
8991 at \.{WEB} time (saying \.{@@i /usr/include/sys/types.h}), or by
9092 using \.{WEB}'s format command (saying \.{@@f caddr\_t int}). Either of
91−these will make {\bf caddr\_t} be treated in the same way as |int|.
93+these will make {\bf caddr\_t} be treated in the same way as |int|.
9294
9395 @<Func...@>=
9496 input_ln(fp) /* copies a line into |buffer| or returns 0 */
@@ -211,7 +213,7 @@ do { · 116 unmodified lines
211213
212214 @ @<Move |buffer| and |limit| to |change_buffer| and |change_limit|@>=
213215 {
214− change_limit=change_buffer-buffer+limit;
216+ change_limit=change_buffer+(limit-buffer);
215217 strncpy(change_buffer,buffer,limit-buffer+1);
216218 }
217219
@@ -242,7 +244,7 @@ check_change() /* switches to |change_file| if the buffers match */ · 24 unmodified lines
242244 return;
243245 }
244246 if (limit>buffer+1 && buffer[0]=='@@') {
245− if (isupper(buffer[1])) buffer[1]=tolower(buffer[1]);
247+ char xyz_code=isupper(buffer[1])? tolower(buffer[1]): buffer[1];
246248 @<If the current line starts with \.{@@y},
247249 report any discrepancies and |return|@>;
248250 }
@@ -261,11 +263,11 @@ check_change() /* switches to |change_file| if the buffers match */ · 12 unmodified lines
261263 }
262264
263265 @ @<If the current line starts with \.{@@y}...@>=
264−if (buffer[1]=='x' || buffer[1]=='z') {
266+if (xyz_code=='x' || xyz_code=='z') {
265267 loc=buffer+2; err_print("! Where is the matching @@y?");
266268 @.Where is the match...@>
267269 }
268−else if (buffer[1]=='y') {
270+else if (xyz_code=='y') {
269271 if (n>0) {
270272 loc=buffer+2;
271273 fprintf(stderr,"\n! Hmm... %d ",n);
@@ -313,7 +315,7 @@ This procedure returns |!input_has_ended| because we often want to · 41 unmodified lines
313315 check the value of that variable after calling the procedure.
314316
315317 @<Fun...@>=
316−get_line() /* inputs the next line */
318+int get_line() /* inputs the next line */
317319 {
318320 restart:
319321 if (changing && include_depth==change_depth)
@@ -322,10 +324,11 @@ get_line() /* inputs the next line */ · 2 unmodified lines
322324 @<Read from |cur_file| and maybe turn on |changing|@>;
323325 if (changing && include_depth==change_depth) goto restart;
324326 }
327+ if (input_has_ended) return 0;
325328 loc=buffer; *limit=' ';
326− if (*buffer=='@@' && (*(buffer+1)=='i' || *(buffer+1)=='I')) {
327− loc=buffer+2;
328− while (loc<=limit && (*loc==' '||*loc=='\t'||*loc=='"')) loc++;
329+ if (buffer[0]=='@@' && (buffer[1]=='i' || buffer[1]=='I')) {
330+ loc=buffer+2; *limit='"';
331+ while (*loc==' '||*loc=='\t') loc++;
329332 if (loc>=limit) {
330333 err_print("! Include file name not given");
331334 @.Include file name ...@>
@@ -335,11 +338,11 @@ get_line() /* inputs the next line */ · 3 unmodified lines
335338 err_print("! Too many nested includes");
336339 @.Too many nested includes@>
337340 goto restart;
338− }
341+ }
339342 include_depth++; /* push input stack */
340343 @<Try to open include file, abort push if unsuccessful, go to |restart|@>;
341344 }
342− return (!input_has_ended);
345+ return 1;
343346 }
344347
345348 void put_line()
@@ -353,28 +356,33 @@ void put_line() · 7 unmodified lines
353356 stop reading it and start reading from the named include file. The
354357 \.{@@i} line should give a complete file name with or without
355358 double quotes.
356−If the environment variable \.{CWEBINPUTS} is set, or if the compiler flag
359+If the environment variable \.{CWEBINPUTS} is set, or if the compiler flag
357360 of the same name was defined at compile time,
358361 \.{CWEB} will look for include files in the directory thus named, if
359362 it cannot find them in the current directory.
360363 (Colon-separated paths are not supported.)
361364 The remainder of the \.{@@i} line after the file name is ignored.
362365
363−@d too_long() {include_depth--;
366+@d too_long() {include_depth--;
364367 err_print("! Include file name too long"); goto restart;}
365368
366369 @ @<Try to open...@>= {
367− char temp_file_name[max_file_name_length];
368− char *cur_file_name_end=cur_file_name+max_file_name_length-1;
370+ char temp_file_name[max_file_name_length];
371+ char *cur_file_name_end=cur_file_name+max_file_name_length-1;
369372 char *k=cur_file_name, *kk;
370373 int l; /* length of file name */
371374
372− while (*loc!=' '&&*loc!='\t'&&*loc!='"'&&k<=cur_file_name_end) *k++=*loc++;
375+ if (*loc=='"') {
376+ loc++;
377+ while (*loc!='"' && k<=cur_file_name_end) *k++=*loc++;
378+ if (loc==limit) k=cur_file_name_end+1; /* unmatched quote is `too long' */
379+ } else
380+ while (*loc!=' '&&*loc!='\t'&&*loc!='"'&&k<=cur_file_name_end) *k++=*loc++;
373381 if (k>cur_file_name_end) too_long();
374382 @.Include file name ...@>
375383 *k='\0';
376384 if ((cur_file=fopen(cur_file_name,"r"))!=NULL) {
377− cur_line=0;
385+ cur_line=0;
378386 goto restart; /* success */
379387 }
380388 kk=getenv("CWEBINPUTS");
@@ -387,7 +395,7 @@ The remainder of the \.{@@i} line after the file name is ignored. · 6 unmodified lines
387395 if ((l=strlen(CWEBINPUTS))>max_file_name_length-2) too_long();
388396 strcpy(temp_file_name,CWEBINPUTS);
389397 #else
390− l=0;
398+ l=0;
391399 #endif /* |CWEBINPUTS| */
392400 }
393401 if (l>0) {
@@ -397,7 +405,7 @@ The remainder of the \.{@@i} line after the file name is ignored. · 3 unmodified lines
397405 strcpy(cur_file_name,temp_file_name);
398406 cur_file_name[l]='/'; /* \UNIX/ pathname separator */
399407 if ((cur_file=fopen(cur_file_name,"r"))!=NULL) {
400− cur_line=0;
408+ cur_line=0;
401409 goto restart; /* success */
402410 }
403411 }
@@ -437,7 +445,7 @@ The remainder of the \.{@@i} line after the file name is ignored. · 33 unmodified lines
437445 @.Where is the match...@>
438446 }
439447 else if (buffer[1]=='z') {
440− prime_the_change_buffer(); changing=!changing;
448+ prime_the_change_buffer(); changing=!changing;
441449 }
442450 }
443451 }

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