Unified · Split
| @@ -1,6 +1,6 @@ | |||
| 1 | # This file is part of CWEB. | 1 | # This file is part of CWEB. |
| 2 | # It is distributed WITHOUT ANY WARRANTY, express or implied. | 2 | # It is distributed WITHOUT ANY WARRANTY, express or implied. |
| 3 | # Version 3.63 --- January 2001 | 3 | # Version 3.64 --- February 2002 |
| 4 | 4 | ||
| 5 | # Copyright (C) 1987,1990,1993,2000 Silvio Levy and Donald E. Knuth | 5 | # Copyright (C) 1987,1990,1993,2000 Silvio Levy and Donald E. Knuth |
| 6 | 6 | ||
| @@ -78,6 +78,7 @@ ALL = common.w ctangle.w cweave.w prod.w \ · 71 unmodified lines | |||
| 78 | comm-pc.ch ctang-pc.ch cweav-pc.ch comm-amiga.ch \ | 78 | comm-pc.ch ctang-pc.ch cweav-pc.ch comm-amiga.ch \ |
| 79 | comm-bs.ch ctang-bs.ch cweav-bs.ch makefile.bs \ | 79 | comm-bs.ch ctang-bs.ch cweav-bs.ch makefile.bs \ |
| 80 | comm-ql.ch ctang-ql.ch cweav-ql.ch readme.ql \ | 80 | comm-ql.ch ctang-ql.ch cweav-ql.ch readme.ql \ |
| 81 | comm-w32.ch ctang-w32.ch cweav-w32.ch \ | ||
| 81 | comm-os2.ch comm-mac.ch cweb.1 cweb.el c++lib.w README | 82 | comm-os2.ch comm-mac.ch cweb.1 cweb.el c++lib.w README |
| 82 | 83 | ||
| 83 | .SUFFIXES: .dvi .tex .w .pdf | 84 | .SUFFIXES: .dvi .tex .w .pdf |
| @@ -27,6 +27,7 @@ comm-man.ch · 26 unmodified lines | |||
| 27 | comm-pc.ch | 27 | comm-pc.ch |
| 28 | comm-ql.ch | 28 | comm-ql.ch |
| 29 | comm-vms.ch | 29 | comm-vms.ch |
| 30 | comm-w32.ch | ||
| 30 | common.c | 31 | common.c |
| 31 | common.h | 32 | common.h |
| 32 | common.w | 33 | common.w |
| @@ -35,6 +36,7 @@ ctang-man.ch · 2 unmodified lines | |||
| 35 | ctang-pc.ch | 36 | ctang-pc.ch |
| 36 | ctang-ql.ch | 37 | ctang-ql.ch |
| 37 | ctang-vms.ch | 38 | ctang-vms.ch |
| 39 | ctang-w32.ch | ||
| 38 | ctangle.c | 40 | ctangle.c |
| 39 | ctangle.w | 41 | ctangle.w |
| 40 | cweav-bs.ch | 42 | cweav-bs.ch |
| @@ -42,6 +44,7 @@ cweav-man.ch · 1 unmodified line | |||
| 42 | cweav-pc.ch | 44 | cweav-pc.ch |
| 43 | cweav-ql.ch | 45 | cweav-ql.ch |
| 44 | cweav-vms.ch | 46 | cweav-vms.ch |
| 47 | cweave-w32.ch | ||
| 45 | cweave.w | 48 | cweave.w |
| 46 | cweb.1 | 49 | cweb.1 |
| 47 | cweb.el | 50 | cweb.el |
| @@ -59,10 +62,11 @@ The files common.c and ctangle.c are used for bootstrapping. · 11 unmodified lines | |||
| 59 | The file cweb.1 is a manual page. | 62 | The file cweb.1 is a manual page. |
| 60 | The file cweb.el is suggested for GNU-Emacs users. | 63 | The file cweb.el is suggested for GNU-Emacs users. |
| 61 | The file c++lib.w is for C++ users (say `@i c++lib.w' at beginning of program). | 64 | 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. |
| 63 | The files *-bs.ch are used instead of *-pc.ch if you are doing BIG programs. | 66 | The files *-bs.ch are used instead of *-pc.ch if you are doing BIG programs. |
| 64 | You can use makefile.bs to make CWEB with *-bs.ch. | 67 | You can use makefile.bs to make CWEB with *-bs.ch. |
| 65 | The files *-ql.ch are for QDOS/SMSQ systems; see readme.ql for further info. | 68 | 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. | ||
| 66 | The file comm-mac.ch is for Macintosh conventions. | 70 | The file comm-mac.ch is for Macintosh conventions. |
| 67 | The other files named *.ch are sample change files for local customization. | 71 | The other files named *.ch are sample change files for local customization. |
| 68 | 72 | ||
| @@ -4,9 +4,9 @@ No changes to CTANGLE or CWEAVE are needed. · 3 unmodified lines | |||
| 4 | (Contributed 13 Oct 2000 by AndPio@aol.com; slightly edited by Don Knuth) | 4 | (Contributed 13 Oct 2000 by AndPio@aol.com; slightly edited by Don Knuth) |
| 5 | 5 | ||
| 6 | @x in limbo, change the title page document to specify Mac version | 6 | @x in limbo, change the title page document to specify Mac version |
| 7 | \centerline{(Version 3.61)} | 7 | \centerline{(Version 3.64)} |
| 8 | @y | 8 | @y |
| 9 | \centerline{(Version 3.61 for MacOS)} | 9 | \centerline{(Version 3.64 for MacOS)} |
| 10 | @z | 10 | @z |
| 11 | 11 | ||
| 12 | @x section 9: Make input_ln accept \n, \r, \n\r, or \r\n as line endings | 12 | @x section 9: Make input_ln accept \n, \r, \n\r, or \r\n as line endings |
| @@ -16,7 +16,7 @@ under the terms of a permission notice identical to this one. · 15 unmodified lines | |||
| 16 | } | 16 | } |
| 17 | @y | 17 | @y |
| 18 | \def\botofcontents{\vfill\titlefalse} | 18 | \def\botofcontents{\vfill\titlefalse} |
| 19 | \def\contentspagenumber{27} | 19 | \def\contentspagenumber{28} |
| 20 | \def\title{APPENDIX D: COMMON} | 20 | \def\title{APPENDIX D: COMMON} |
| 21 | \let\K=\leftarrow | 21 | \let\K=\leftarrow |
| 22 | @z | 22 | @z |
| @@ -10,24 +10,24 @@ ex <dev_>cc;'-v -h -c -=500000 -DCWEBINPUTS=flp2_ common_c' · 9 unmodified lines | |||
| 10 | @x | 10 | @x |
| 11 | \def\v{\char'174} % vertical (|) in typewriter font | 11 | \def\v{\char'174} % vertical (|) in typewriter font |
| 12 | 12 | ||
| 13 | \def\title{Common code for CTANGLE and CWEAVE (Version 3.61)} | 13 | \def\title{Common code for CTANGLE and CWEAVE (Version 3.64)} |
| 14 | \def\topofcontents{\null\vfill | 14 | \def\topofcontents{\null\vfill |
| 15 | \centerline{\titlefont Common code for {\ttitlefont CTANGLE} and | 15 | \centerline{\titlefont Common code for {\ttitlefont CTANGLE} and |
| 16 | {\ttitlefont CWEAVE}} | 16 | {\ttitlefont CWEAVE}} |
| 17 | \vskip 15pt | 17 | \vskip 15pt |
| 18 | \centerline{(Version 3.61)} | 18 | \centerline{(Version 3.64)} |
| 19 | \vfill} | 19 | \vfill} |
| 20 | \def\botofcontents{\vfill | 20 | \def\botofcontents{\vfill |
| 21 | \noindent | 21 | \noindent |
| 22 | @y | 22 | @y |
| 23 | \def\v{\char'174} % vertical (|) in typewriter font | 23 | \def\v{\char'174} % vertical (|) in typewriter font |
| 24 | 24 | ||
| 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)} |
| 26 | \def\topofcontents{\null\vfill | 26 | \def\topofcontents{\null\vfill |
| 27 | \centerline{\titlefont Common code for {\ttitlefont CTANGLE} and | 27 | \centerline{\titlefont Common code for {\ttitlefont CTANGLE} and |
| 28 | {\ttitlefont CWEAVE}} | 28 | {\ttitlefont CWEAVE}} |
| 29 | \vskip 15pt | 29 | \vskip 15pt |
| 30 | \centerline{(Version 3.61)} | 30 | \centerline{(Version 3.64)} |
| 31 | \vfill} | 31 | \vfill} |
| 32 | \def\botofcontents{\vfill | 32 | \def\botofcontents{\vfill |
| 33 | \noindent | 33 | \noindent |
| @@ -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 | ||
| @@ -12,7 +12,7 @@ · 11 unmodified lines | |||
| 12 | #include <stdio.h> | 12 | #include <stdio.h> |
| 13 | 13 | ||
| 14 | /*:8*//*22:*/ | 14 | /*:8*//*22:*/ |
| 15 | #line 470 "common.w" | 15 | #line 471 "common.w" |
| 16 | 16 | ||
| 17 | #include <stdlib.h> | 17 | #include <stdlib.h> |
| 18 | 18 | ||
| @@ -165,17 +165,17 @@ boolean change_pending; · 146 unmodified lines | |||
| 165 | boolean print_where= 0; | 165 | boolean print_where= 0; |
| 166 | 166 | ||
| 167 | /*:20*//*27:*/ | 167 | /*:20*//*27:*/ |
| 168 | #line 588 "common.w" | 168 | #line 594 "common.w" |
| 169 | 169 | ||
| 170 | typedef struct name_info{ | 170 | typedef struct name_info{ |
| 171 | char*byte_start; | 171 | char*byte_start; |
| 172 | /*31:*/ | 172 | /*31:*/ |
| 173 | #line 625 "common.w" | 173 | #line 631 "common.w" |
| 174 | 174 | ||
| 175 | struct name_info*link; | 175 | struct name_info*link; |
| 176 | 176 | ||
| 177 | /*:31*//*40:*/ | 177 | /*:31*//*40:*/ |
| 178 | #line 724 "common.w" | 178 | #line 730 "common.w" |
| 179 | 179 | ||
| 180 | union{ | 180 | union{ |
| 181 | struct name_info*Rlink; | 181 | struct name_info*Rlink; |
| @@ -184,12 +184,12 @@ char Ilk; · 2 unmodified lines | |||
| 184 | }dummy; | 184 | }dummy; |
| 185 | 185 | ||
| 186 | /*:40*//*55:*/ | 186 | /*:40*//*55:*/ |
| 187 | #line 1056 "common.w" | 187 | #line 1062 "common.w" |
| 188 | 188 | ||
| 189 | char*equiv_or_xref; | 189 | char*equiv_or_xref; |
| 190 | 190 | ||
| 191 | /*:55*/ | 191 | /*:55*/ |
| 192 | #line 591 "common.w" | 192 | #line 597 "common.w" |
| 193 | 193 | ||
| 194 | }name_info; | 194 | }name_info; |
| 195 | typedef name_info*name_pointer; | 195 | typedef name_info*name_pointer; |
| @@ -199,13 +199,13 @@ name_info name_dir[max_names]; · 3 unmodified lines | |||
| 199 | name_pointer name_dir_end= name_dir+max_names-1; | 199 | name_pointer name_dir_end= name_dir+max_names-1; |
| 200 | 200 | ||
| 201 | /*:27*//*29:*/ | 201 | /*:27*//*29:*/ |
| 202 | #line 611 "common.w" | 202 | #line 617 "common.w" |
| 203 | 203 | ||
| 204 | name_pointer name_ptr; | 204 | name_pointer name_ptr; |
| 205 | char*byte_ptr; | 205 | char*byte_ptr; |
| 206 | 206 | ||
| 207 | /*:29*//*32:*/ | 207 | /*:29*//*32:*/ |
| 208 | #line 638 "common.w" | 208 | #line 644 "common.w" |
| 209 | 209 | ||
| 210 | typedef name_pointer*hash_pointer; | 210 | typedef name_pointer*hash_pointer; |
| 211 | name_pointer hash[hash_size]; | 211 | name_pointer hash[hash_size]; |
| @@ -213,12 +213,12 @@ hash_pointer hash_end= hash+hash_size-1; · 1 unmodified line | |||
| 213 | hash_pointer h; | 213 | hash_pointer h; |
| 214 | 214 | ||
| 215 | /*:32*//*56:*/ | 215 | /*:32*//*56:*/ |
| 216 | #line 1076 "common.w" | 216 | #line 1082 "common.w" |
| 217 | 217 | ||
| 218 | int history= spotless; | 218 | int history= spotless; |
| 219 | 219 | ||
| 220 | /*:56*//*67:*/ | 220 | /*:56*//*67:*/ |
| 221 | #line 1214 "common.w" | 221 | #line 1220 "common.w" |
| 222 | 222 | ||
| 223 | int argc; | 223 | int argc; |
| 224 | char**argv; | 224 | char**argv; |
| @@ -229,7 +229,7 @@ char scn_file_name[max_file_name_length]; · 4 unmodified lines | |||
| 229 | boolean flags[128]; | 229 | boolean flags[128]; |
| 230 | 230 | ||
| 231 | /*:67*//*77:*/ | 231 | /*:67*//*77:*/ |
| 232 | #line 1364 "common.w" | 232 | #line 1370 "common.w" |
| 233 | 233 | ||
| 234 | FILE*C_file; | 234 | FILE*C_file; |
| 235 | FILE*tex_file; | 235 | FILE*tex_file; |
| @@ -254,48 +254,48 @@ char*change_limit; · 18 unmodified lines | |||
| 254 | #line 62 "common.w" | 254 | #line 62 "common.w" |
| 255 | 255 | ||
| 256 | /*33:*/ | 256 | /*33:*/ |
| 257 | #line 644 "common.w" | 257 | #line 650 "common.w" |
| 258 | 258 | ||
| 259 | extern int names_match(); | 259 | extern int names_match(); |
| 260 | 260 | ||
| 261 | /*:33*//*38:*/ | 261 | /*:33*//*38:*/ |
| 262 | #line 697 "common.w" | 262 | #line 703 "common.w" |
| 263 | 263 | ||
| 264 | void init_p(); | 264 | void init_p(); |
| 265 | 265 | ||
| 266 | /*:38*//*46:*/ | 266 | /*:38*//*46:*/ |
| 267 | #line 846 "common.w" | 267 | #line 852 "common.w" |
| 268 | 268 | ||
| 269 | extern void init_node(); | 269 | extern void init_node(); |
| 270 | 270 | ||
| 271 | /*:46*//*53:*/ | 271 | /*:46*//*53:*/ |
| 272 | #line 1011 "common.w" | 272 | #line 1017 "common.w" |
| 273 | 273 | ||
| 274 | int section_name_cmp(); | 274 | int section_name_cmp(); |
| 275 | 275 | ||
| 276 | /*:53*//*57:*/ | 276 | /*:53*//*57:*/ |
| 277 | #line 1086 "common.w" | 277 | #line 1092 "common.w" |
| 278 | 278 | ||
| 279 | void err_print(); | 279 | void err_print(); |
| 280 | 280 | ||
| 281 | /*:57*//*60:*/ | 281 | /*:57*//*60:*/ |
| 282 | #line 1134 "common.w" | 282 | #line 1140 "common.w" |
| 283 | 283 | ||
| 284 | int wrap_up(); | 284 | int wrap_up(); |
| 285 | extern void print_stats(); | 285 | extern void print_stats(); |
| 286 | 286 | ||
| 287 | /*:60*//*63:*/ | 287 | /*:60*//*63:*/ |
| 288 | #line 1167 "common.w" | 288 | #line 1173 "common.w" |
| 289 | 289 | ||
| 290 | void fatal(),overflow(); | 290 | void fatal(),overflow(); |
| 291 | 291 | ||
| 292 | /*:63*//*69:*/ | 292 | /*:63*//*69:*/ |
| 293 | #line 1245 "common.w" | 293 | #line 1251 "common.w" |
| 294 | 294 | ||
| 295 | void scan_args(); | 295 | void scan_args(); |
| 296 | 296 | ||
| 297 | /*:69*//*81:*/ | 297 | /*:69*//*81:*/ |
| 298 | #line 1405 "common.w" | 298 | #line 1411 "common.w" |
| 299 | 299 | ||
| 300 | extern int strlen(); | 300 | extern int strlen(); |
| 301 | extern int strcmp(); | 301 | extern int strcmp(); |
| @@ -314,19 +314,19 @@ void · 12 unmodified lines | |||
| 314 | common_init() | 314 | common_init() |
| 315 | { | 315 | { |
| 316 | /*30:*/ | 316 | /*30:*/ |
| 317 | #line 615 "common.w" | 317 | #line 621 "common.w" |
| 318 | 318 | ||
| 319 | name_dir->byte_start= byte_ptr= byte_mem; | 319 | name_dir->byte_start= byte_ptr= byte_mem; |
| 320 | name_ptr= name_dir+1; | 320 | name_ptr= name_dir+1; |
| 321 | name_ptr->byte_start= byte_mem; | 321 | name_ptr->byte_start= byte_mem; |
| 322 | 322 | ||
| 323 | /*:30*//*34:*/ | 323 | /*:30*//*34:*/ |
| 324 | #line 649 "common.w" | 324 | #line 655 "common.w" |
| 325 | 325 | ||
| 326 | for(h= hash;h<=hash_end;*h++= NULL); | 326 | for(h= hash;h<=hash_end;*h++= NULL); |
| 327 | 327 | ||
| 328 | /*:34*//*41:*/ | 328 | /*:34*//*41:*/ |
| 329 | #line 731 "common.w" | 329 | #line 737 "common.w" |
| 330 | 330 | ||
| 331 | root= NULL; | 331 | root= NULL; |
| 332 | 332 | ||
| @@ -334,7 +334,7 @@ root= NULL; · 1 unmodified line | |||
| 334 | #line 93 "common.w" | 334 | #line 93 "common.w" |
| 335 | ; | 335 | ; |
| 336 | /*68:*/ | 336 | /*68:*/ |
| 337 | #line 1227 "common.w" | 337 | #line 1233 "common.w" |
| 338 | 338 | ||
| 339 | show_banner= show_happiness= show_progress= 1; | 339 | show_banner= show_happiness= show_progress= 1; |
| 340 | 340 | ||
| @@ -342,7 +342,7 @@ show_banner= show_happiness= show_progress= 1; · 1 unmodified line | |||
| 342 | #line 94 "common.w" | 342 | #line 94 "common.w" |
| 343 | ; | 343 | ; |
| 344 | /*78:*/ | 344 | /*78:*/ |
| 345 | #line 1371 "common.w" | 345 | #line 1377 "common.w" |
| 346 | 346 | ||
| 347 | scan_args(); | 347 | scan_args(); |
| 348 | if(program==ctangle){ | 348 | if(program==ctangle){ |
| @@ -428,7 +428,7 @@ return; · 79 unmodified lines | |||
| 428 | #line 292 "common.w" | 428 | #line 292 "common.w" |
| 429 | 429 | ||
| 430 | { | 430 | { |
| 431 | change_limit= change_buffer-buffer+limit; | 431 | change_limit= change_buffer+(limit-buffer); |
| 432 | strncpy(change_buffer,buffer,limit-buffer+1); | 432 | strncpy(change_buffer,buffer,limit-buffer+1); |
| 433 | } | 433 | } |
| 434 | 434 | ||
| @@ -459,15 +459,15 @@ change_limit= change_buffer;changing= 0; · 24 unmodified lines | |||
| 459 | return; | 459 | return; |
| 460 | } | 460 | } |
| 461 | if(limit> buffer+1&&buffer[0]=='@'){ | 461 | 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]; |
| 463 | /*17:*/ | 463 | /*17:*/ |
| 464 | #line 358 "common.w" | 464 | #line 358 "common.w" |
| 465 | 465 | ||
| 466 | if(buffer[1]=='x'||buffer[1]=='z'){ | 466 | if(xyz_code=='x'||xyz_code=='z'){ |
| 467 | loc= buffer+2;err_print("! Where is the matching @y?"); | 467 | loc= buffer+2;err_print("! Where is the matching @y?"); |
| 468 | 468 | ||
| 469 | } | 469 | } |
| 470 | else if(buffer[1]=='y'){ | 470 | else if(xyz_code=='y'){ |
| 471 | if(n> 0){ | 471 | if(n> 0){ |
| 472 | loc= buffer+2; | 472 | loc= buffer+2; |
| 473 | printf("\n! Hmm... %d ",n); | 473 | printf("\n! Hmm... %d ",n); |
| @@ -486,7 +486,7 @@ return; · 12 unmodified lines | |||
| 486 | #line 292 "common.w" | 486 | #line 292 "common.w" |
| 487 | 487 | ||
| 488 | { | 488 | { |
| 489 | change_limit= change_buffer-buffer+limit; | 489 | change_limit= change_buffer+(limit-buffer); |
| 490 | strncpy(change_buffer,buffer,limit-buffer+1); | 490 | strncpy(change_buffer,buffer,limit-buffer+1); |
| 491 | } | 491 | } |
| 492 | 492 | ||
| @@ -544,7 +544,7 @@ int get_line() · 51 unmodified lines | |||
| 544 | restart: | 544 | restart: |
| 545 | if(changing&&include_depth==change_depth) | 545 | if(changing&&include_depth==change_depth) |
| 546 | /*25:*/ | 546 | /*25:*/ |
| 547 | #line 531 "common.w" | 547 | #line 537 "common.w" |
| 548 | { | 548 | { |
| 549 | change_line++; | 549 | change_line++; |
| 550 | if(!input_ln(change_file)){ | 550 | if(!input_ln(change_file)){ |
| @@ -579,7 +579,7 @@ prime_the_change_buffer();changing= !changing;print_where= 1; · 28 unmodified lines | |||
| 579 | ; | 579 | ; |
| 580 | if(!changing||include_depth> change_depth){ | 580 | if(!changing||include_depth> change_depth){ |
| 581 | /*24:*/ | 581 | /*24:*/ |
| 582 | #line 514 "common.w" | 582 | #line 520 "common.w" |
| 583 | { | 583 | { |
| 584 | cur_line++; | 584 | cur_line++; |
| 585 | while(!input_ln(cur_file)){ | 585 | while(!input_ln(cur_file)){ |
| @@ -602,10 +602,11 @@ if(change_limit> change_buffer)check_change(); · 16 unmodified lines | |||
| 602 | ; | 602 | ; |
| 603 | if(changing&&include_depth==change_depth)goto restart; | 603 | if(changing&&include_depth==change_depth)goto restart; |
| 604 | } | 604 | } |
| 605 | if(input_has_ended)return 0; | ||
| 605 | loc= buffer;*limit= ' '; | 606 | loc= buffer;*limit= ' '; |
| 606 | if(*buffer=='@'&&(*(buffer+1)=='i'||*(buffer+1)=='I')){ | 607 | if(buffer[0]=='@'&&(buffer[1]=='i'||buffer[1]=='I')){ |
| 607 | loc= buffer+2; | 608 | loc= buffer+2;*limit= '"'; |
| 608 | while(loc<=limit&&(*loc==' '||*loc=='\t'||*loc=='"'))loc++; | 609 | while(*loc==' '||*loc=='\t')loc++; |
| 609 | if(loc>=limit){ | 610 | if(loc>=limit){ |
| 610 | err_print("! Include file name not given"); | 611 | err_print("! Include file name not given"); |
| 611 | 612 | ||
| @@ -618,13 +619,18 @@ goto restart; · 6 unmodified lines | |||
| 618 | } | 619 | } |
| 619 | include_depth++; | 620 | include_depth++; |
| 620 | /*23:*/ | 621 | /*23:*/ |
| 621 | #line 473 "common.w" | 622 | #line 474 "common.w" |
| 622 | { | 623 | { |
| 623 | char temp_file_name[max_file_name_length]; | 624 | char temp_file_name[max_file_name_length]; |
| 624 | char*cur_file_name_end= cur_file_name+max_file_name_length-1; | 625 | char*cur_file_name_end= cur_file_name+max_file_name_length-1; |
| 625 | char*k= cur_file_name,*kk; | 626 | char*k= cur_file_name,*kk; |
| 626 | int l; | 627 | int l; |
| 627 | 628 | ||
| 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 | ||
| 628 | while(*loc!=' '&&*loc!='\t'&&*loc!='"'&&k<=cur_file_name_end)*k++= *loc++; | 634 | while(*loc!=' '&&*loc!='\t'&&*loc!='"'&&k<=cur_file_name_end)*k++= *loc++; |
| 629 | if(k> cur_file_name_end)too_long(); | 635 | if(k> cur_file_name_end)too_long(); |
| 630 | 636 | ||
| @@ -661,14 +667,14 @@ include_depth--;err_print("! Cannot open include file");goto restart; · 30 unmodified lines | |||
| 661 | } | 667 | } |
| 662 | 668 | ||
| 663 | /*:23*/ | 669 | /*:23*/ |
| 664 | #line 451 "common.w" | 670 | #line 452 "common.w" |
| 665 | ; | 671 | ; |
| 666 | } | 672 | } |
| 667 | return(!input_has_ended); | 673 | return 1; |
| 668 | } | 674 | } |
| 669 | 675 | ||
| 670 | /*:21*//*26:*/ | 676 | /*:21*//*26:*/ |
| 671 | #line 563 "common.w" | 677 | #line 569 "common.w" |
| 672 | 678 | ||
| 673 | void | 679 | void |
| 674 | check_complete(){ | 680 | check_complete(){ |
| @@ -682,7 +688,7 @@ err_print("! Change file entry did not match"); · 7 unmodified lines | |||
| 682 | } | 688 | } |
| 683 | 689 | ||
| 684 | /*:26*//*35:*/ | 690 | /*:26*//*35:*/ |
| 685 | #line 654 "common.w" | 691 | #line 660 "common.w" |
| 686 | 692 | ||
| 687 | name_pointer | 693 | name_pointer |
| 688 | id_lookup(first,last,t) | 694 | id_lookup(first,last,t) |
| @@ -697,17 +703,17 @@ name_pointer p; · 8 unmodified lines | |||
| 697 | if(last==NULL)for(last= first;*last!='\0';last++); | 703 | if(last==NULL)for(last= first;*last!='\0';last++); |
| 698 | l= last-first; | 704 | l= last-first; |
| 699 | /*36:*/ | 705 | /*36:*/ |
| 700 | #line 677 "common.w" | 706 | #line 683 "common.w" |
| 701 | 707 | ||
| 702 | h= (unsigned char)*i; | 708 | h= (unsigned char)*i; |
| 703 | while(++i<last)h= (h+h+(int)((unsigned char)*i))%hash_size; | 709 | while(++i<last)h= (h+h+(int)((unsigned char)*i))%hash_size; |
| 704 | 710 | ||
| 705 | 711 | ||
| 706 | /*:36*/ | 712 | /*:36*/ |
| 707 | #line 667 "common.w" | 713 | #line 673 "common.w" |
| 708 | ; | 714 | ; |
| 709 | /*37:*/ | 715 | /*37:*/ |
| 710 | #line 685 "common.w" | 716 | #line 691 "common.w" |
| 711 | 717 | ||
| 712 | p= hash[h]; | 718 | p= hash[h]; |
| 713 | while(p&&!names_match(p,first,l,t))p= p->link; | 719 | 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 | |||
| 717 | } | 723 | } |
| 718 | 724 | ||
| 719 | /*:37*/ | 725 | /*:37*/ |
| 720 | #line 668 "common.w" | 726 | #line 674 "common.w" |
| 721 | ; | 727 | ; |
| 722 | if(p==name_ptr)/*39:*/ | 728 | if(p==name_ptr)/*39:*/ |
| 723 | #line 700 "common.w" | 729 | #line 706 "common.w" |
| 724 | { | 730 | { |
| 725 | if(byte_ptr+l> byte_mem_end)overflow("byte memory"); | 731 | if(byte_ptr+l> byte_mem_end)overflow("byte memory"); |
| 726 | if(name_ptr>=name_dir_end)overflow("name"); | 732 | if(name_ptr>=name_dir_end)overflow("name"); |
| @@ -730,13 +736,13 @@ if(program==cweave)init_p(p,t); · 3 unmodified lines | |||
| 730 | } | 736 | } |
| 731 | 737 | ||
| 732 | /*:39*/ | 738 | /*:39*/ |
| 733 | #line 669 "common.w" | 739 | #line 675 "common.w" |
| 734 | ; | 740 | ; |
| 735 | return(p); | 741 | return(p); |
| 736 | } | 742 | } |
| 737 | 743 | ||
| 738 | /*:35*//*42:*/ | 744 | /*:35*//*42:*/ |
| 739 | #line 758 "common.w" | 745 | #line 764 "common.w" |
| 740 | 746 | ||
| 741 | void | 747 | void |
| 742 | print_section_name(p) | 748 | print_section_name(p) |
| @@ -757,7 +763,7 @@ if(q)term_write("...",3); · 14 unmodified lines | |||
| 757 | } | 763 | } |
| 758 | 764 | ||
| 759 | /*:42*//*43:*/ | 765 | /*:42*//*43:*/ |
| 760 | #line 777 "common.w" | 766 | #line 783 "common.w" |
| 761 | 767 | ||
| 762 | void | 768 | void |
| 763 | sprint_section_name(dest,p) | 769 | sprint_section_name(dest,p) |
| @@ -780,7 +786,7 @@ s= p->byte_start; · 16 unmodified lines | |||
| 780 | } | 786 | } |
| 781 | 787 | ||
| 782 | /*:43*//*44:*/ | 788 | /*:43*//*44:*/ |
| 783 | #line 798 "common.w" | 789 | #line 804 "common.w" |
| 784 | 790 | ||
| 785 | void | 791 | void |
| 786 | print_prefix_name(p) | 792 | print_prefix_name(p) |
| @@ -793,7 +799,7 @@ if(s+l<(p+1)->byte_start)term_write("...",3); · 6 unmodified lines | |||
| 793 | } | 799 | } |
| 794 | 800 | ||
| 795 | /*:44*//*45:*/ | 801 | /*:44*//*45:*/ |
| 796 | #line 819 "common.w" | 802 | #line 825 "common.w" |
| 797 | 803 | ||
| 798 | int web_strcmp(j,j_len,k,k_len) | 804 | int web_strcmp(j,j_len,k,k_len) |
| 799 | char*j,*k; | 805 | char*j,*k; |
| @@ -809,7 +815,7 @@ else return greater; · 9 unmodified lines | |||
| 809 | } | 815 | } |
| 810 | 816 | ||
| 811 | /*:45*//*47:*/ | 817 | /*:45*//*47:*/ |
| 812 | #line 849 "common.w" | 818 | #line 855 "common.w" |
| 813 | 819 | ||
| 814 | name_pointer | 820 | name_pointer |
| 815 | add_section_name(par,c,first,last,ispref) | 821 | 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 | |||
| 840 | } | 846 | } |
| 841 | 847 | ||
| 842 | /*:47*//*48:*/ | 848 | /*:47*//*48:*/ |
| 843 | #line 878 "common.w" | 849 | #line 884 "common.w" |
| 844 | 850 | ||
| 845 | void | 851 | void |
| 846 | extend_section_name(p,first,last,ispref) | 852 | extend_section_name(p,first,last,ispref) |
| @@ -864,7 +870,7 @@ if(ispref)*(byte_ptr-1)= ' '; · 17 unmodified lines | |||
| 864 | } | 870 | } |
| 865 | 871 | ||
| 866 | /*:48*//*49:*/ | 872 | /*:48*//*49:*/ |
| 867 | #line 906 "common.w" | 873 | #line 912 "common.w" |
| 868 | 874 | ||
| 869 | name_pointer | 875 | name_pointer |
| 870 | section_lookup(first,last,ispref) | 876 | section_lookup(first,last,ispref) |
| @@ -879,7 +885,7 @@ name_pointer par= NULL; · 8 unmodified lines | |||
| 879 | 885 | ||
| 880 | int name_len= last-first+1; | 886 | int name_len= last-first+1; |
| 881 | /*50:*/ | 887 | /*50:*/ |
| 882 | #line 930 "common.w" | 888 | #line 936 "common.w" |
| 883 | 889 | ||
| 884 | while(p){ | 890 | while(p){ |
| 885 | c= web_strcmp(first,name_len,first_chunk(p),prefix_length(p)); | 891 | c= web_strcmp(first,name_len,first_chunk(p),prefix_length(p)); |
| @@ -906,19 +912,19 @@ p= q,q= NULL; · 20 unmodified lines | |||
| 906 | } | 912 | } |
| 907 | 913 | ||
| 908 | /*:50*/ | 914 | /*:50*/ |
| 909 | #line 920 "common.w" | 915 | #line 926 "common.w" |
| 910 | ; | 916 | ; |
| 911 | /*51:*/ | 917 | /*51:*/ |
| 912 | #line 955 "common.w" | 918 | #line 961 "common.w" |
| 913 | 919 | ||
| 914 | if(r==NULL) | 920 | if(r==NULL) |
| 915 | return add_section_name(par,c,first,last+1,ispref); | 921 | return add_section_name(par,c,first,last+1,ispref); |
| 916 | 922 | ||
| 917 | /*:51*/ | 923 | /*:51*/ |
| 918 | #line 921 "common.w" | 924 | #line 927 "common.w" |
| 919 | ; | 925 | ; |
| 920 | /*52:*/ | 926 | /*52:*/ |
| 921 | #line 963 "common.w" | 927 | #line 969 "common.w" |
| 922 | 928 | ||
| 923 | switch(section_name_cmp(&first,name_len,r)){ | 929 | switch(section_name_cmp(&first,name_len,r)){ |
| 924 | 930 | ||
| @@ -952,12 +958,12 @@ return r; · 27 unmodified lines | |||
| 952 | } | 958 | } |
| 953 | 959 | ||
| 954 | /*:52*/ | 960 | /*:52*/ |
| 955 | #line 922 "common.w" | 961 | #line 928 "common.w" |
| 956 | ; | 962 | ; |
| 957 | } | 963 | } |
| 958 | 964 | ||
| 959 | /*:49*//*54:*/ | 965 | /*:49*//*54:*/ |
| 960 | #line 1014 "common.w" | 966 | #line 1020 "common.w" |
| 961 | 967 | ||
| 962 | int section_name_cmp(pfirst,len,r) | 968 | int section_name_cmp(pfirst,len,r) |
| 963 | char**pfirst; | 969 | char**pfirst; |
| @@ -991,7 +997,7 @@ default:return c; · 27 unmodified lines | |||
| 991 | } | 997 | } |
| 992 | 998 | ||
| 993 | /*:54*//*58:*/ | 999 | /*:54*//*58:*/ |
| 994 | #line 1089 "common.w" | 1000 | #line 1095 "common.w" |
| 995 | 1001 | ||
| 996 | void | 1002 | void |
| 997 | err_print(s) | 1003 | err_print(s) |
| @@ -1000,7 +1006,7 @@ char*s; · 2 unmodified lines | |||
| 1000 | char*k,*l; | 1006 | char*k,*l; |
| 1001 | printf(*s=='!'?"\n%s":"%s",s); | 1007 | printf(*s=='!'?"\n%s":"%s",s); |
| 1002 | if(web_file_open)/*59:*/ | 1008 | if(web_file_open)/*59:*/ |
| 1003 | #line 1109 "common.w" | 1009 | #line 1115 "common.w" |
| 1004 | 1010 | ||
| 1005 | {if(changing&&include_depth==change_depth) | 1011 | {if(changing&&include_depth==change_depth) |
| 1006 | printf(". (l. %d of change file)\n",change_line); | 1012 | printf(". (l. %d of change file)\n",change_line); |
| @@ -1020,20 +1026,20 @@ putchar(' '); · 13 unmodified lines | |||
| 1020 | } | 1026 | } |
| 1021 | 1027 | ||
| 1022 | /*:59*/ | 1028 | /*:59*/ |
| 1023 | #line 1096 "common.w" | 1029 | #line 1102 "common.w" |
| 1024 | ; | 1030 | ; |
| 1025 | update_terminal;mark_error; | 1031 | update_terminal;mark_error; |
| 1026 | } | 1032 | } |
| 1027 | 1033 | ||
| 1028 | /*:58*//*61:*/ | 1034 | /*:58*//*61:*/ |
| 1029 | #line 1144 "common.w" | 1035 | #line 1150 "common.w" |
| 1030 | 1036 | ||
| 1031 | int wrap_up(){ | 1037 | int wrap_up(){ |
| 1032 | putchar('\n'); | 1038 | putchar('\n'); |
| 1033 | if(show_stats) | 1039 | if(show_stats) |
| 1034 | print_stats(); | 1040 | print_stats(); |
| 1035 | /*62:*/ | 1041 | /*62:*/ |
| 1036 | #line 1154 "common.w" | 1042 | #line 1160 "common.w" |
| 1037 | 1043 | ||
| 1038 | switch(history){ | 1044 | switch(history){ |
| 1039 | case spotless:if(show_happiness)printf("(No errors were found.)\n");break; | 1045 | 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 | |||
| 1045 | } | 1051 | } |
| 1046 | 1052 | ||
| 1047 | /*:62*/ | 1053 | /*:62*/ |
| 1048 | #line 1149 "common.w" | 1054 | #line 1155 "common.w" |
| 1049 | ; | 1055 | ; |
| 1050 | if(history> harmless_message)return(1); | 1056 | if(history> harmless_message)return(1); |
| 1051 | else return(0); | 1057 | else return(0); |
| 1052 | } | 1058 | } |
| 1053 | 1059 | ||
| 1054 | /*:61*//*64:*/ | 1060 | /*:61*//*64:*/ |
| 1055 | #line 1173 "common.w" | 1061 | #line 1179 "common.w" |
| 1056 | void | 1062 | void |
| 1057 | fatal(s,t) | 1063 | fatal(s,t) |
| 1058 | char*s,*t; | 1064 | char*s,*t; |
| @@ -1063,7 +1069,7 @@ history= fatal_message;exit(wrap_up()); · 4 unmodified lines | |||
| 1063 | } | 1069 | } |
| 1064 | 1070 | ||
| 1065 | /*:64*//*65:*/ | 1071 | /*:64*//*65:*/ |
| 1066 | #line 1184 "common.w" | 1072 | #line 1190 "common.w" |
| 1067 | void | 1073 | void |
| 1068 | overflow(t) | 1074 | overflow(t) |
| 1069 | char*t; | 1075 | char*t; |
| @@ -1073,7 +1079,7 @@ printf("\n! Sorry, %s capacity exceeded",t);fatal("",""); · 3 unmodified lines | |||
| 1073 | 1079 | ||
| 1074 | 1080 | ||
| 1075 | /*:65*//*70:*/ | 1081 | /*:65*//*70:*/ |
| 1076 | #line 1248 "common.w" | 1082 | #line 1254 "common.w" |
| 1077 | 1083 | ||
| 1078 | void | 1084 | void |
| 1079 | scan_args() | 1085 | scan_args() |
| @@ -1087,7 +1093,7 @@ boolean flag_change; · 7 unmodified lines | |||
| 1087 | 1093 | ||
| 1088 | while(--argc> 0){ | 1094 | while(--argc> 0){ |
| 1089 | if((**(++argv)=='-'||**argv=='+')&&*(*argv+1))/*74:*/ | 1095 | if((**(++argv)=='-'||**argv=='+')&&*(*argv+1))/*74:*/ |
| 1090 | #line 1338 "common.w" | 1096 | #line 1344 "common.w" |
| 1091 | 1097 | ||
| 1092 | { | 1098 | { |
| 1093 | if(**argv=='-')flag_change= 0; | 1099 | if(**argv=='-')flag_change= 0; |
| @@ -1097,7 +1103,7 @@ flags[*dot_pos]= flag_change; · 3 unmodified lines | |||
| 1097 | } | 1103 | } |
| 1098 | 1104 | ||
| 1099 | /*:74*/ | 1105 | /*:74*/ |
| 1100 | #line 1260 "common.w" | 1106 | #line 1266 "common.w" |
| 1101 | 1107 | ||
| 1102 | else{ | 1108 | else{ |
| 1103 | s= name_pos= *argv;dot_pos= NULL; | 1109 | s= name_pos= *argv;dot_pos= NULL; |
| @@ -1107,17 +1113,17 @@ else if(*s=='/')dot_pos= NULL,name_pos= ++s; · 3 unmodified lines | |||
| 1107 | else s++; | 1113 | else s++; |
| 1108 | } | 1114 | } |
| 1109 | if(!found_web)/*71:*/ | 1115 | if(!found_web)/*71:*/ |
| 1110 | #line 1286 "common.w" | 1116 | #line 1292 "common.w" |
| 1111 | 1117 | ||
| 1112 | { | 1118 | { |
| 1113 | if(s-*argv> max_file_name_length-5) | 1119 | if(s-*argv> max_file_name_length-5) |
| 1114 | /*76:*/ | 1120 | /*76:*/ |
| 1115 | #line 1358 "common.w" | 1121 | #line 1364 "common.w" |
| 1116 | fatal("! Filename too long\n",*argv); | 1122 | fatal("! Filename too long\n",*argv); |
| 1117 | 1123 | ||
| 1118 | 1124 | ||
| 1119 | /*:76*/ | 1125 | /*:76*/ |
| 1120 | #line 1289 "common.w" | 1126 | #line 1295 "common.w" |
| 1121 | ; | 1127 | ; |
| 1122 | if(dot_pos==NULL) | 1128 | if(dot_pos==NULL) |
| 1123 | sprintf(web_file_name,"%s.w",*argv); | 1129 | sprintf(web_file_name,"%s.w",*argv); |
| @@ -1134,22 +1140,22 @@ found_web= 1; · 10 unmodified lines | |||
| 1134 | } | 1140 | } |
| 1135 | 1141 | ||
| 1136 | /*:71*/ | 1142 | /*:71*/ |
| 1137 | #line 1269 "common.w" | 1143 | #line 1275 "common.w" |
| 1138 | 1144 | ||
| 1139 | else if(!found_change)/*72:*/ | 1145 | else if(!found_change)/*72:*/ |
| 1140 | #line 1304 "common.w" | 1146 | #line 1310 "common.w" |
| 1141 | 1147 | ||
| 1142 | { | 1148 | { |
| 1143 | if(strcmp(*argv,"-")==0)found_change= -1; | 1149 | if(strcmp(*argv,"-")==0)found_change= -1; |
| 1144 | else{ | 1150 | else{ |
| 1145 | if(s-*argv> max_file_name_length-4) | 1151 | if(s-*argv> max_file_name_length-4) |
| 1146 | /*76:*/ | 1152 | /*76:*/ |
| 1147 | #line 1358 "common.w" | 1153 | #line 1364 "common.w" |
| 1148 | fatal("! Filename too long\n",*argv); | 1154 | fatal("! Filename too long\n",*argv); |
| 1149 | 1155 | ||
| 1150 | 1156 | ||
| 1151 | /*:76*/ | 1157 | /*:76*/ |
| 1152 | #line 1309 "common.w" | 1158 | #line 1315 "common.w" |
| 1153 | ; | 1159 | ; |
| 1154 | if(dot_pos==NULL) | 1160 | if(dot_pos==NULL) |
| 1155 | sprintf(change_file_name,"%s.ch",*argv); | 1161 | sprintf(change_file_name,"%s.ch",*argv); |
| @@ -1159,20 +1165,20 @@ found_change= 1; · 3 unmodified lines | |||
| 1159 | } | 1165 | } |
| 1160 | 1166 | ||
| 1161 | /*:72*/ | 1167 | /*:72*/ |
| 1162 | #line 1270 "common.w" | 1168 | #line 1276 "common.w" |
| 1163 | 1169 | ||
| 1164 | else if(!found_out)/*73:*/ | 1170 | else if(!found_out)/*73:*/ |
| 1165 | #line 1317 "common.w" | 1171 | #line 1323 "common.w" |
| 1166 | 1172 | ||
| 1167 | { | 1173 | { |
| 1168 | if(s-*argv> max_file_name_length-5) | 1174 | if(s-*argv> max_file_name_length-5) |
| 1169 | /*76:*/ | 1175 | /*76:*/ |
| 1170 | #line 1358 "common.w" | 1176 | #line 1364 "common.w" |
| 1171 | fatal("! Filename too long\n",*argv); | 1177 | fatal("! Filename too long\n",*argv); |
| 1172 | 1178 | ||
| 1173 | 1179 | ||
| 1174 | /*:76*/ | 1180 | /*:76*/ |
| 1175 | #line 1320 "common.w" | 1181 | #line 1326 "common.w" |
| 1176 | ; | 1182 | ; |
| 1177 | if(dot_pos==NULL){ | 1183 | if(dot_pos==NULL){ |
| 1178 | sprintf(tex_file_name,"%s.tex",*argv); | 1184 | sprintf(tex_file_name,"%s.tex",*argv); |
| @@ -1192,10 +1198,10 @@ found_out= 1; · 13 unmodified lines | |||
| 1192 | } | 1198 | } |
| 1193 | 1199 | ||
| 1194 | /*:73*/ | 1200 | /*:73*/ |
| 1195 | #line 1271 "common.w" | 1201 | #line 1277 "common.w" |
| 1196 | 1202 | ||
| 1197 | else/*75:*/ | 1203 | else/*75:*/ |
| 1198 | #line 1346 "common.w" | 1204 | #line 1352 "common.w" |
| 1199 | 1205 | ||
| 1200 | { | 1206 | { |
| 1201 | if(program==ctangle) | 1207 | if(program==ctangle) |
| @@ -1209,12 +1215,12 @@ else fatal( · 7 unmodified lines | |||
| 1209 | } | 1215 | } |
| 1210 | 1216 | ||
| 1211 | /*:75*/ | 1217 | /*:75*/ |
| 1212 | #line 1272 "common.w" | 1218 | #line 1278 "common.w" |
| 1213 | ; | 1219 | ; |
| 1214 | } | 1220 | } |
| 1215 | } | 1221 | } |
| 1216 | if(!found_web)/*75:*/ | 1222 | if(!found_web)/*75:*/ |
| 1217 | #line 1346 "common.w" | 1223 | #line 1352 "common.w" |
| 1218 | 1224 | ||
| 1219 | { | 1225 | { |
| 1220 | if(program==ctangle) | 1226 | if(program==ctangle) |
| @@ -1228,7 +1234,7 @@ else fatal( · 7 unmodified lines | |||
| 1228 | } | 1234 | } |
| 1229 | 1235 | ||
| 1230 | /*:75*/ | 1236 | /*:75*/ |
| 1231 | #line 1275 "common.w" | 1237 | #line 1281 "common.w" |
| 1232 | ; | 1238 | ; |
| 1233 | if(found_change<=0)strcpy(change_file_name,"/dev/null"); | 1239 | if(found_change<=0)strcpy(change_file_name,"/dev/null"); |
| 1234 | } | 1240 | } |
| @@ -2,7 +2,7 @@ · 1 unmodified line | |||
| 2 | % This program by Silvio Levy and Donald E. Knuth | 2 | % This program by Silvio Levy and Donald E. Knuth |
| 3 | % is based on a program by Knuth. | 3 | % is based on a program by Knuth. |
| 4 | % It is distributed WITHOUT ANY WARRANTY, express or implied. | 4 | % It is distributed WITHOUT ANY WARRANTY, express or implied. |
| 5 | % Version 3.61 --- July 2000 (works with later versions too) | 5 | % Version 3.64 --- January 2002 |
| 6 | 6 | ||
| 7 | % Copyright (C) 1987,1990,1993,2000 Silvio Levy and Donald E. Knuth | 7 | % Copyright (C) 1987,1990,1993,2000 Silvio Levy and Donald E. Knuth |
| 8 | 8 | ||
| @@ -17,12 +17,12 @@ · 8 unmodified lines | |||
| 17 | 17 | ||
| 18 | \def\v{\char'174} % vertical (|) in typewriter font | 18 | \def\v{\char'174} % vertical (|) in typewriter font |
| 19 | 19 | ||
| 20 | \def\title{Common code for CTANGLE and CWEAVE (Version 3.61)} | 20 | \def\title{Common code for CTANGLE and CWEAVE (Version 3.64)} |
| 21 | \def\topofcontents{\null\vfill | 21 | \def\topofcontents{\null\vfill |
| 22 | \centerline{\titlefont Common code for {\ttitlefont CTANGLE} and | 22 | \centerline{\titlefont Common code for {\ttitlefont CTANGLE} and |
| 23 | {\ttitlefont CWEAVE}} | 23 | {\ttitlefont CWEAVE}} |
| 24 | \vskip 15pt | 24 | \vskip 15pt |
| 25 | \centerline{(Version 3.61)} | 25 | \centerline{(Version 3.64)} |
| 26 | \vfill} | 26 | \vfill} |
| 27 | \def\botofcontents{\vfill | 27 | \def\botofcontents{\vfill |
| 28 | \noindent | 28 | \noindent |
| @@ -291,7 +291,7 @@ do { · 262 unmodified lines | |||
| 291 | 291 | ||
| 292 | @ @<Move |buffer| and |limit| to |change_buffer| and |change_limit|@>= | 292 | @ @<Move |buffer| and |limit| to |change_buffer| and |change_limit|@>= |
| 293 | { | 293 | { |
| 294 | change_limit=change_buffer-buffer+limit; | 294 | change_limit=change_buffer+(limit-buffer); |
| 295 | strncpy(change_buffer,buffer,limit-buffer+1); | 295 | strncpy(change_buffer,buffer,limit-buffer+1); |
| 296 | } | 296 | } |
| 297 | 297 | ||
| @@ -337,7 +337,7 @@ check_change() /* switches to |change_file| if the buffers match */ · 39 unmodified lines | |||
| 337 | return; | 337 | return; |
| 338 | } | 338 | } |
| 339 | if (limit>buffer+1 && buffer[0]=='@@') { | 339 | 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]; |
| 341 | @<If the current line starts with \.{@@y}, | 341 | @<If the current line starts with \.{@@y}, |
| 342 | report any discrepancies and |return|@>; | 342 | report any discrepancies and |return|@>; |
| 343 | } | 343 | } |
| @@ -356,11 +356,11 @@ check_change() /* switches to |change_file| if the buffers match */ · 12 unmodified lines | |||
| 356 | } | 356 | } |
| 357 | 357 | ||
| 358 | @ @<If the current line starts with \.{@@y}...@>= | 358 | @ @<If the current line starts with \.{@@y}...@>= |
| 359 | if (buffer[1]=='x' || buffer[1]=='z') { | 359 | if (xyz_code=='x' || xyz_code=='z') { |
| 360 | loc=buffer+2; err_print("! Where is the matching @@y?"); | 360 | loc=buffer+2; err_print("! Where is the matching @@y?"); |
| 361 | @.Where is the match...@> | 361 | @.Where is the match...@> |
| 362 | } | 362 | } |
| 363 | else if (buffer[1]=='y') { | 363 | else if (xyz_code=='y') { |
| 364 | if (n>0) { | 364 | if (n>0) { |
| 365 | loc=buffer+2; | 365 | loc=buffer+2; |
| 366 | printf("\n! Hmm... %d ",n); | 366 | printf("\n! Hmm... %d ",n); |
| @@ -433,10 +433,11 @@ int get_line() /* inputs the next line */ · 66 unmodified lines | |||
| 433 | @<Read from |cur_file| and maybe turn on |changing|@>; | 433 | @<Read from |cur_file| and maybe turn on |changing|@>; |
| 434 | if (changing && include_depth==change_depth) goto restart; | 434 | if (changing && include_depth==change_depth) goto restart; |
| 435 | } | 435 | } |
| 436 | if (input_has_ended) return 0; | ||
| 436 | loc=buffer; *limit=' '; | 437 | loc=buffer; *limit=' '; |
| 437 | if (*buffer=='@@' && (*(buffer+1)=='i' || *(buffer+1)=='I')) { | 438 | if (buffer[0]=='@@' && (buffer[1]=='i' || buffer[1]=='I')) { |
| 438 | loc=buffer+2; | 439 | loc=buffer+2; *limit='"'; |
| 439 | while (loc<=limit && (*loc==' '||*loc=='\t'||*loc=='"')) loc++; | 440 | while (*loc==' '||*loc=='\t') loc++; |
| 440 | if (loc>=limit) { | 441 | if (loc>=limit) { |
| 441 | err_print("! Include file name not given"); | 442 | err_print("! Include file name not given"); |
| 442 | @.Include file name ...@> | 443 | @.Include file name ...@> |
| @@ -450,7 +451,7 @@ int get_line() /* inputs the next line */ · 7 unmodified lines | |||
| 450 | include_depth++; /* push input stack */ | 451 | include_depth++; /* push input stack */ |
| 451 | @<Try to open include file, abort push if unsuccessful, go to |restart|@>; | 452 | @<Try to open include file, abort push if unsuccessful, go to |restart|@>; |
| 452 | } | 453 | } |
| 453 | return (!input_has_ended); | 454 | return 1; |
| 454 | } | 455 | } |
| 455 | 456 | ||
| 456 | @ When an \.{@@i} line is found in the |cur_file|, we must temporarily | 457 | @ 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 | |||
| 476 | char *k=cur_file_name, *kk; | 477 | char *k=cur_file_name, *kk; |
| 477 | int l; /* length of file name */ | 478 | int l; /* length of file name */ |
| 478 | 479 | ||
| 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++; | ||
| 480 | if (k>cur_file_name_end) too_long(); | 486 | if (k>cur_file_name_end) too_long(); |
| 481 | @.Include file name ...@> | 487 | @.Include file name ...@> |
| 482 | *k='\0'; | 488 | *k='\0'; |
| @@ -17,12 +17,12 @@ by using "huge" pointers. · 16 unmodified lines | |||
| 17 | The ``banner line'' defined here should be changed whenever \.{CTANGLE} | 17 | The ``banner line'' defined here should be changed whenever \.{CTANGLE} |
| 18 | is modified. | 18 | is modified. |
| 19 | 19 | ||
| 20 | @d banner "This is CTANGLE (Version 3.62)\n" | 20 | @d banner "This is CTANGLE (Version 3.64)\n" |
| 21 | @y | 21 | @y |
| 22 | The ``banner line'' defined here should be changed whenever \.{CTANGLE} | 22 | The ``banner line'' defined here should be changed whenever \.{CTANGLE} |
| 23 | is modified. | 23 | is modified. |
| 24 | 24 | ||
| 25 | @d banner "This is CTANGLE (Version 3.62pc/big)\n" | 25 | @d banner "This is CTANGLE (Version 3.64pc/big)\n" |
| 26 | @z | 26 | @z |
| 27 | 27 | ||
| 28 | 28 | ||
| @@ -16,7 +16,7 @@ under the terms of a permission notice identical to this one. · 15 unmodified lines | |||
| 16 | } | 16 | } |
| 17 | @y | 17 | @y |
| 18 | \def\botofcontents{\vfill\titlefalse} | 18 | \def\botofcontents{\vfill\titlefalse} |
| 19 | \def\contentspagenumber{62} | 19 | \def\contentspagenumber{63} |
| 20 | \def\title{APPENDIX E: CTANGLE} | 20 | \def\title{APPENDIX E: CTANGLE} |
| 21 | \let\K=\leftarrow | 21 | \let\K=\leftarrow |
| 22 | @z | 22 | @z |
| @@ -9,9 +9,9 @@ that allows >64K arrays. If you need lots of bytes and toks, try the · 8 unmodified lines | |||
| 9 | alternate change files with -bs suffix instead of -pc. | 9 | alternate change files with -bs suffix instead of -pc. |
| 10 | 10 | ||
| 11 | @x section 1 | 11 | @x section 1 |
| 12 | @d banner "This is CTANGLE (Version 3.62)\n" | 12 | @d banner "This is CTANGLE (Version 3.64)\n" |
| 13 | @y | 13 | @y |
| 14 | @d banner "This is CTANGLE (Version 3.62pc)\n" | 14 | @d banner "This is CTANGLE (Version 3.64pc)\n" |
| 15 | @z | 15 | @z |
| 16 | @x section 4 | 16 | @x section 4 |
| 17 | @d max_bytes 90000 /* the number of bytes in identifiers, | 17 | @d max_bytes 90000 /* the number of bytes in identifiers, |
| @@ -7,15 +7,15 @@ ex <dev_>cc;"-v -h -c -=500000 ctangle_c" · 6 unmodified lines | |||
| 7 | 7 | ||
| 8 | 8 | ||
| 9 | @x | 9 | @x |
| 10 | \def\title{CTANGLE (Version 3.62)} | 10 | \def\title{CTANGLE (Version 3.64)} |
| 11 | @y | 11 | @y |
| 12 | \def\title{CTANGLE (QL Version 3.62)} | 12 | \def\title{CTANGLE (QL Version 3.64)} |
| 13 | @z | 13 | @z |
| 14 | 14 | ||
| 15 | @x section 1 | 15 | @x section 1 |
| 16 | @d banner "This is CTANGLE (Version 3.62)\n" | 16 | @d banner "This is CTANGLE (Version 3.64)\n" |
| 17 | @y | 17 | @y |
| 18 | @d banner "This is CTANGLE (QL Version 3.62)\n" | 18 | @d banner "This is CTANGLE (QL Version 3.64)\n" |
| 19 | @z | 19 | @z |
| 20 | 20 | ||
| 21 | @x | 21 | @x |
| @@ -10,9 +10,9 @@ created: · 9 unmodified lines | |||
| 10 | (these changes not necessary for initial bootstrapping) | 10 | (these changes not necessary for initial bootstrapping) |
| 11 | 11 | ||
| 12 | @x section 1 (01-FEB-1992 ST) | 12 | @x section 1 (01-FEB-1992 ST) |
| 13 | @d banner "This is CTANGLE (Version 3.62)\n" | 13 | @d banner "This is CTANGLE (Version 3.64)\n" |
| 14 | @y | 14 | @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" |
| 16 | @z | 16 | @z |
| 17 | 17 | ||
| 18 | @x section 6 (from common.h) (01-FEB-1992 ST) | 18 | @x section 6 (from common.h) (01-FEB-1992 ST) |
| @@ -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 | ||
| @@ -15,7 +15,7 @@ · 14 unmodified lines | |||
| 15 | /*:62*/ | 15 | /*:62*/ |
| 16 | #line 65 "ctangle.w" | 16 | #line 65 "ctangle.w" |
| 17 | 17 | ||
| 18 | #define banner "This is CTANGLE (Version 3.62)\n" \ | 18 | #define banner "This is CTANGLE (Version 3.64)\n" \ |
| 19 | 19 | ||
| 20 | #define max_bytes 90000 \ | 20 | #define max_bytes 90000 \ |
| 21 | 21 | ||
| @@ -350,13 +350,13 @@ name_pointer cur_section_name; · 328 unmodified lines | |||
| 350 | int no_where; | 350 | int no_where; |
| 351 | 351 | ||
| 352 | /*:61*//*75:*/ | 352 | /*:61*//*75:*/ |
| 353 | #line 1199 "ctangle.w" | 353 | #line 1195 "ctangle.w" |
| 354 | 354 | ||
| 355 | text_pointer cur_text; | 355 | text_pointer cur_text; |
| 356 | eight_bits next_control; | 356 | eight_bits next_control; |
| 357 | 357 | ||
| 358 | /*:75*//*82:*/ | 358 | /*:75*//*82:*/ |
| 359 | #line 1349 "ctangle.w" | 359 | #line 1350 "ctangle.w" |
| 360 | 360 | ||
| 361 | extern sixteen_bits section_count; | 361 | extern sixteen_bits section_count; |
| 362 | 362 | ||
| @@ -388,12 +388,12 @@ void output_defs(); · 25 unmodified lines | |||
| 388 | static void out_char(); | 388 | static void out_char(); |
| 389 | 389 | ||
| 390 | /*:48*//*90:*/ | 390 | /*:48*//*90:*/ |
| 391 | #line 1456 "ctangle.w" | 391 | #line 1457 "ctangle.w" |
| 392 | 392 | ||
| 393 | void phase_one(); | 393 | void phase_one(); |
| 394 | 394 | ||
| 395 | /*:90*//*92:*/ | 395 | /*:90*//*92:*/ |
| 396 | #line 1474 "ctangle.w" | 396 | #line 1475 "ctangle.w" |
| 397 | 397 | ||
| 398 | void skip_limbo(); | 398 | void skip_limbo(); |
| 399 | 399 | ||
| @@ -460,7 +460,7 @@ ccode['\'']= ord; · 60 unmodified lines | |||
| 460 | } | 460 | } |
| 461 | 461 | ||
| 462 | /*:57*//*71:*/ | 462 | /*:57*//*71:*/ |
| 463 | #line 1120 "ctangle.w" | 463 | #line 1116 "ctangle.w" |
| 464 | section_text[0]= ' '; | 464 | section_text[0]= ' '; |
| 465 | 465 | ||
| 466 | /*:71*/ | 466 | /*:71*/ |
| @@ -885,7 +885,7 @@ if(get_line()==0)return(new_section); · 418 unmodified lines | |||
| 885 | else if(print_where&&!no_where){ | 885 | else if(print_where&&!no_where){ |
| 886 | print_where= 0; | 886 | print_where= 0; |
| 887 | /*77:*/ | 887 | /*77:*/ |
| 888 | #line 1229 "ctangle.w" | 888 | #line 1225 "ctangle.w" |
| 889 | 889 | ||
| 890 | store_two_bytes(0150000); | 890 | store_two_bytes(0150000); |
| 891 | if(changing)id_first= change_file_name; | 891 | if(changing)id_first= change_file_name; |
| @@ -910,13 +910,11 @@ if(comment_continues)return('\n'); · 18 unmodified lines | |||
| 910 | else continue; | 910 | else continue; |
| 911 | } | 911 | } |
| 912 | loc++; | 912 | loc++; |
| 913 | if(xisdigit(c)||c=='\\'||c=='.')/*66:*/ | 913 | if(xisdigit(c)||c=='.')/*66:*/ |
| 914 | #line 978 "ctangle.w" | 914 | #line 978 "ctangle.w" |
| 915 | { | 915 | { |
| 916 | id_first= loc-1; | 916 | id_first= loc-1; |
| 917 | if(*id_first=='.'&&!xisdigit(*loc))goto mistake; | 917 | if(*id_first=='.'&&!xisdigit(*loc))goto mistake; |
| 918 | if(*id_first=='\\')while(xisdigit(*loc))loc++; | ||
| 919 | else{ | ||
| 920 | if(*id_first=='0'){ | 918 | if(*id_first=='0'){ |
| 921 | if(*loc=='x'||*loc=='X'){ | 919 | if(*loc=='x'||*loc=='X'){ |
| 922 | loc++;while(xisxdigit(*loc))loc++;goto found; | 920 | loc++;while(xisxdigit(*loc))loc++;goto found; |
| @@ -931,7 +929,6 @@ if(*loc=='e'||*loc=='E'){ · 8 unmodified lines | |||
| 931 | if(*++loc=='+'||*loc=='-')loc++; | 929 | if(*++loc=='+'||*loc=='-')loc++; |
| 932 | while(xisdigit(*loc))loc++; | 930 | while(xisdigit(*loc))loc++; |
| 933 | } | 931 | } |
| 934 | } | ||
| 935 | found:while(*loc=='u'||*loc=='U'||*loc=='l'||*loc=='L' | 932 | found:while(*loc=='u'||*loc=='U'||*loc=='l'||*loc=='L' |
| 936 | ||*loc=='f'||*loc=='F')loc++; | 933 | ||*loc=='f'||*loc=='F')loc++; |
| 937 | id_loc= loc; | 934 | id_loc= loc; |
| @@ -943,7 +940,7 @@ return(constant); · 5 unmodified lines | |||
| 943 | 940 | ||
| 944 | else if(c=='\''||c=='"'||(c=='L'&&(*loc=='\''||*loc=='"'))) | 941 | else if(c=='\''||c=='"'||(c=='L'&&(*loc=='\''||*loc=='"'))) |
| 945 | /*67:*/ | 942 | /*67:*/ |
| 946 | #line 1009 "ctangle.w" | 943 | #line 1006 "ctangle.w" |
| 947 | { | 944 | { |
| 948 | char delim= c; | 945 | char delim= c; |
| 949 | id_first= section_text+1; | 946 | id_first= section_text+1; |
| @@ -1001,12 +998,11 @@ id_loc= loc;return(identifier); · 51 unmodified lines | |||
| 1001 | #line 928 "ctangle.w" | 998 | #line 928 "ctangle.w" |
| 1002 | 999 | ||
| 1003 | else if(c=='@')/*68:*/ | 1000 | else if(c=='@')/*68:*/ |
| 1004 | #line 1053 "ctangle.w" | 1001 | #line 1050 "ctangle.w" |
| 1005 | { | 1002 | { |
| 1006 | c= ccode[(eight_bits)*loc++]; | 1003 | c= ccode[(eight_bits)*loc++]; |
| 1007 | switch(c){ | 1004 | switch(c){ |
| 1008 | case ignore:continue; | 1005 | case ignore:continue; |
| 1009 | case output_defs_code:output_defs_seen= 1;return(c); | ||
| 1010 | case translit_code:err_print("! Use @l in limbo only");continue; | 1006 | case translit_code:err_print("! Use @l in limbo only");continue; |
| 1011 | 1007 | ||
| 1012 | case control_text:while((c= skip_ahead())=='@'); | 1008 | case control_text:while((c= skip_ahead())=='@'); |
| @@ -1018,11 +1014,11 @@ continue; · 5 unmodified lines | |||
| 1018 | case section_name: | 1014 | case section_name: |
| 1019 | cur_section_name_char= *(loc-1); | 1015 | cur_section_name_char= *(loc-1); |
| 1020 | /*70:*/ | 1016 | /*70:*/ |
| 1021 | #line 1102 "ctangle.w" | 1017 | #line 1098 "ctangle.w" |
| 1022 | { | 1018 | { |
| 1023 | char*k; | 1019 | char*k; |
| 1024 | /*72:*/ | 1020 | /*72:*/ |
| 1025 | #line 1122 "ctangle.w" | 1021 | #line 1118 "ctangle.w" |
| 1026 | 1022 | ||
| 1027 | k= section_text; | 1023 | k= section_text; |
| 1028 | while(1){ | 1024 | while(1){ |
| @@ -1033,7 +1029,7 @@ loc= buffer+1;break; · 4 unmodified lines | |||
| 1033 | } | 1029 | } |
| 1034 | c= *loc; | 1030 | c= *loc; |
| 1035 | /*73:*/ | 1031 | /*73:*/ |
| 1036 | #line 1146 "ctangle.w" | 1032 | #line 1142 "ctangle.w" |
| 1037 | 1033 | ||
| 1038 | if(c=='@'){ | 1034 | if(c=='@'){ |
| 1039 | c= *(loc+1); | 1035 | c= *(loc+1); |
| @@ -1052,7 +1048,7 @@ err_print("! Nesting of section names not allowed");break; · 12 unmodified lines | |||
| 1052 | } | 1048 | } |
| 1053 | 1049 | ||
| 1054 | /*:73*/ | 1050 | /*:73*/ |
| 1055 | #line 1131 "ctangle.w" | 1051 | #line 1127 "ctangle.w" |
| 1056 | ; | 1052 | ; |
| 1057 | loc++;if(k<section_text_end)k++; | 1053 | loc++;if(k<section_text_end)k++; |
| 1058 | if(xisspace(c)){ | 1054 | if(xisspace(c)){ |
| @@ -1069,7 +1065,7 @@ printf("...");mark_harmless; · 10 unmodified lines | |||
| 1069 | if(*k==' '&&k> section_text)k--; | 1065 | if(*k==' '&&k> section_text)k--; |
| 1070 | 1066 | ||
| 1071 | /*:72*/ | 1067 | /*:72*/ |
| 1072 | #line 1104 "ctangle.w" | 1068 | #line 1100 "ctangle.w" |
| 1073 | ; | 1069 | ; |
| 1074 | if(k-section_text> 3&&strncmp(k-2,"...",3)==0) | 1070 | if(k-section_text> 3&&strncmp(k-2,"...",3)==0) |
| 1075 | cur_section_name= section_lookup(section_text+1,k-3,1); | 1071 | cur_section_name= section_lookup(section_text+1,k-3,1); |
| @@ -1092,16 +1088,16 @@ overflow("output files"); · 16 unmodified lines | |||
| 1092 | } | 1088 | } |
| 1093 | 1089 | ||
| 1094 | /*:40*/ | 1090 | /*:40*/ |
| 1095 | #line 1110 "ctangle.w" | 1091 | #line 1106 "ctangle.w" |
| 1096 | ; | 1092 | ; |
| 1097 | return(section_name); | 1093 | return(section_name); |
| 1098 | } | 1094 | } |
| 1099 | 1095 | ||
| 1100 | /*:70*/ | 1096 | /*:70*/ |
| 1101 | #line 1068 "ctangle.w" | 1097 | #line 1064 "ctangle.w" |
| 1102 | ; | 1098 | ; |
| 1103 | case string:/*74:*/ | 1099 | case string:/*74:*/ |
| 1104 | #line 1168 "ctangle.w" | 1100 | #line 1164 "ctangle.w" |
| 1105 | { | 1101 | { |
| 1106 | id_first= loc++;*(limit+1)= '@';*(limit+2)= '>'; | 1102 | id_first= loc++;*(limit+1)= '@';*(limit+2)= '>'; |
| 1107 | while(*loc!='@'||*(loc+1)!='>')loc++; | 1103 | while(*loc!='@'||*(loc+1)!='>')loc++; |
| @@ -1112,10 +1108,10 @@ return(string); · 4 unmodified lines | |||
| 1112 | } | 1108 | } |
| 1113 | 1109 | ||
| 1114 | /*:74*/ | 1110 | /*:74*/ |
| 1115 | #line 1069 "ctangle.w" | 1111 | #line 1065 "ctangle.w" |
| 1116 | ; | 1112 | ; |
| 1117 | case ord:/*69:*/ | 1113 | case ord:/*69:*/ |
| 1118 | #line 1081 "ctangle.w" | 1114 | #line 1077 "ctangle.w" |
| 1119 | 1115 | ||
| 1120 | id_first= loc; | 1116 | id_first= loc; |
| 1121 | if(*loc=='\\'){ | 1117 | if(*loc=='\\'){ |
| @@ -1138,7 +1134,7 @@ loc++; · 16 unmodified lines | |||
| 1138 | return(ord); | 1134 | return(ord); |
| 1139 | 1135 | ||
| 1140 | /*:69*/ | 1136 | /*:69*/ |
| 1141 | #line 1070 "ctangle.w" | 1137 | #line 1066 "ctangle.w" |
| 1142 | ; | 1138 | ; |
| 1143 | default:return(c); | 1139 | default:return(c); |
| 1144 | } | 1140 | } |
| @@ -1185,7 +1181,7 @@ return(c); · 40 unmodified lines | |||
| 1185 | } | 1181 | } |
| 1186 | 1182 | ||
| 1187 | /*:63*//*76:*/ | 1183 | /*:63*//*76:*/ |
| 1188 | #line 1203 "ctangle.w" | 1184 | #line 1199 "ctangle.w" |
| 1189 | 1185 | ||
| 1190 | void | 1186 | void |
| 1191 | scan_repl(t) | 1187 | scan_repl(t) |
| @@ -1193,7 +1189,7 @@ eight_bits t; · 1 unmodified line | |||
| 1193 | { | 1189 | { |
| 1194 | sixteen_bits a; | 1190 | sixteen_bits a; |
| 1195 | if(t==section_name){/*77:*/ | 1191 | if(t==section_name){/*77:*/ |
| 1196 | #line 1229 "ctangle.w" | 1192 | #line 1225 "ctangle.w" |
| 1197 | 1193 | ||
| 1198 | store_two_bytes(0150000); | 1194 | store_two_bytes(0150000); |
| 1199 | if(changing)id_first= change_file_name; | 1195 | if(changing)id_first= change_file_name; |
| @@ -1205,11 +1201,11 @@ else store_two_bytes((sixteen_bits)cur_line); · 5 unmodified lines | |||
| 1205 | app_repl(a%0400);} | 1201 | app_repl(a%0400);} |
| 1206 | 1202 | ||
| 1207 | /*:77*/ | 1203 | /*:77*/ |
| 1208 | #line 1209 "ctangle.w" | 1204 | #line 1205 "ctangle.w" |
| 1209 | ;} | 1205 | ;} |
| 1210 | while(1)switch(a= get_next()){ | 1206 | while(1)switch(a= get_next()){ |
| 1211 | /*78:*/ | 1207 | /*78:*/ |
| 1212 | #line 1239 "ctangle.w" | 1208 | #line 1235 "ctangle.w" |
| 1213 | 1209 | ||
| 1214 | case identifier:a= id_lookup(id_first,id_loc,0)-name_dir; | 1210 | case identifier:a= id_lookup(id_first,id_loc,0)-name_dir; |
| 1215 | app_repl((a/0400)+0200); | 1211 | app_repl((a/0400)+0200); |
| @@ -1217,7 +1213,7 @@ app_repl(a%0400);break; · 1 unmodified line | |||
| 1217 | case section_name:if(t!=section_name)goto done; | 1213 | case section_name:if(t!=section_name)goto done; |
| 1218 | else{ | 1214 | else{ |
| 1219 | /*79:*/ | 1215 | /*79:*/ |
| 1220 | #line 1267 "ctangle.w" | 1216 | #line 1268 "ctangle.w" |
| 1221 | { | 1217 | { |
| 1222 | char*try_loc= loc; | 1218 | char*try_loc= loc; |
| 1223 | while(*try_loc==' '&&try_loc<limit)try_loc++; | 1219 | 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 | |||
| 1230 | } | 1226 | } |
| 1231 | 1227 | ||
| 1232 | /*:79*/ | 1228 | /*:79*/ |
| 1233 | #line 1245 "ctangle.w" | 1229 | #line 1241 "ctangle.w" |
| 1234 | ; | 1230 | ; |
| 1235 | a= cur_section_name-name_dir; | 1231 | a= cur_section_name-name_dir; |
| 1236 | app_repl((a/0400)+0250); | 1232 | app_repl((a/0400)+0250); |
| 1237 | app_repl(a%0400); | 1233 | app_repl(a%0400); |
| 1238 | /*77:*/ | 1234 | /*77:*/ |
| 1239 | #line 1229 "ctangle.w" | 1235 | #line 1225 "ctangle.w" |
| 1240 | 1236 | ||
| 1241 | store_two_bytes(0150000); | 1237 | store_two_bytes(0150000); |
| 1242 | if(changing)id_first= change_file_name; | 1238 | if(changing)id_first= change_file_name; |
| @@ -1248,15 +1244,18 @@ else store_two_bytes((sixteen_bits)cur_line); · 5 unmodified lines | |||
| 1248 | app_repl(a%0400);} | 1244 | app_repl(a%0400);} |
| 1249 | 1245 | ||
| 1250 | /*:77*/ | 1246 | /*:77*/ |
| 1251 | #line 1249 "ctangle.w" | 1247 | #line 1245 "ctangle.w" |
| 1252 | ;break; | 1248 | ;break; |
| 1253 | } | 1249 | } |
| 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; | ||
| 1255 | a= output_defs_flag; | 1254 | a= output_defs_flag; |
| 1256 | app_repl((a/0400)+0200); | 1255 | app_repl((a/0400)+0200); |
| 1257 | app_repl(a%0400); | 1256 | app_repl(a%0400); |
| 1258 | /*77:*/ | 1257 | /*77:*/ |
| 1259 | #line 1229 "ctangle.w" | 1258 | #line 1225 "ctangle.w" |
| 1260 | 1259 | ||
| 1261 | store_two_bytes(0150000); | 1260 | store_two_bytes(0150000); |
| 1262 | if(changing)id_first= change_file_name; | 1261 | if(changing)id_first= change_file_name; |
| @@ -1268,11 +1267,13 @@ else store_two_bytes((sixteen_bits)cur_line); · 5 unmodified lines | |||
| 1268 | app_repl(a%0400);} | 1267 | app_repl(a%0400);} |
| 1269 | 1268 | ||
| 1270 | /*:77*/ | 1269 | /*:77*/ |
| 1271 | #line 1255 "ctangle.w" | 1270 | #line 1254 "ctangle.w" |
| 1272 | ;break; | 1271 | ; |
| 1272 | } | ||
| 1273 | break; | ||
| 1273 | case constant:case string: | 1274 | case constant:case string: |
| 1274 | /*80:*/ | 1275 | /*80:*/ |
| 1275 | #line 1278 "ctangle.w" | 1276 | #line 1279 "ctangle.w" |
| 1276 | 1277 | ||
| 1277 | app_repl(a); | 1278 | app_repl(a); |
| 1278 | while(id_first<id_loc){ | 1279 | while(id_first<id_loc){ |
| @@ -1286,11 +1287,11 @@ app_repl(*id_first++); · 7 unmodified lines | |||
| 1286 | app_repl(a);break; | 1287 | app_repl(a);break; |
| 1287 | 1288 | ||
| 1288 | /*:80*/ | 1289 | /*:80*/ |
| 1289 | #line 1257 "ctangle.w" | 1290 | #line 1258 "ctangle.w" |
| 1290 | ; | 1291 | ; |
| 1291 | case ord: | 1292 | case ord: |
| 1292 | /*81:*/ | 1293 | /*81:*/ |
| 1293 | #line 1294 "ctangle.w" | 1294 | #line 1295 "ctangle.w" |
| 1294 | { | 1295 | { |
| 1295 | int c= (eight_bits)*id_first; | 1296 | int c= (eight_bits)*id_first; |
| 1296 | if(c=='\\'){ | 1297 | if(c=='\\'){ |
| @@ -1341,7 +1342,7 @@ app_repl(constant); · 44 unmodified lines | |||
| 1341 | break; | 1342 | break; |
| 1342 | 1343 | ||
| 1343 | /*:81*/ | 1344 | /*:81*/ |
| 1344 | #line 1259 "ctangle.w" | 1345 | #line 1260 "ctangle.w" |
| 1345 | ; | 1346 | ; |
| 1346 | case definition:case format_code:case begin_C:if(t!=section_name)goto done; | 1347 | case definition:case format_code:case begin_C:if(t!=section_name)goto done; |
| 1347 | else{ | 1348 | else{ |
| @@ -1351,7 +1352,7 @@ err_print("! @d, @f and @c are ignored in C text");continue; · 3 unmodified lines | |||
| 1351 | case new_section:goto done; | 1352 | case new_section:goto done; |
| 1352 | 1353 | ||
| 1353 | /*:78*/ | 1354 | /*:78*/ |
| 1354 | #line 1214 "ctangle.w" | 1355 | #line 1210 "ctangle.w" |
| 1355 | 1356 | ||
| 1356 | case')':app_repl(a); | 1357 | case')':app_repl(a); |
| 1357 | if(t==macro)app_repl(' '); | 1358 | if(t==macro)app_repl(' '); |
| @@ -1364,7 +1365,7 @@ cur_text= text_ptr;(++text_ptr)->tok_start= tok_ptr; · 6 unmodified lines | |||
| 1364 | } | 1365 | } |
| 1365 | 1366 | ||
| 1366 | /*:76*//*83:*/ | 1367 | /*:76*//*83:*/ |
| 1367 | #line 1356 "ctangle.w" | 1368 | #line 1357 "ctangle.w" |
| 1368 | 1369 | ||
| 1369 | void | 1370 | void |
| 1370 | scan_section() | 1371 | scan_section() |
| @@ -1379,7 +1380,7 @@ printf("*%d",section_count);update_terminal; · 8 unmodified lines | |||
| 1379 | next_control= 0; | 1380 | next_control= 0; |
| 1380 | while(1){ | 1381 | while(1){ |
| 1381 | /*84:*/ | 1382 | /*84:*/ |
| 1382 | #line 1395 "ctangle.w" | 1383 | #line 1396 "ctangle.w" |
| 1383 | 1384 | ||
| 1384 | while(next_control<definition) | 1385 | while(next_control<definition) |
| 1385 | 1386 | ||
| @@ -1388,11 +1389,11 @@ loc-= 2;next_control= get_next(); · 2 unmodified lines | |||
| 1388 | } | 1389 | } |
| 1389 | 1390 | ||
| 1390 | /*:84*/ | 1391 | /*:84*/ |
| 1391 | #line 1370 "ctangle.w" | 1392 | #line 1371 "ctangle.w" |
| 1392 | ; | 1393 | ; |
| 1393 | if(next_control==definition){ | 1394 | if(next_control==definition){ |
| 1394 | /*85:*/ | 1395 | /*85:*/ |
| 1395 | #line 1402 "ctangle.w" | 1396 | #line 1403 "ctangle.w" |
| 1396 | { | 1397 | { |
| 1397 | while((next_control= get_next())=='\n'); | 1398 | while((next_control= get_next())=='\n'); |
| 1398 | if(next_control!=identifier){ | 1399 | if(next_control!=identifier){ |
| @@ -1411,7 +1412,7 @@ cur_text->text_link= 0; · 12 unmodified lines | |||
| 1411 | } | 1412 | } |
| 1412 | 1413 | ||
| 1413 | /*:85*/ | 1414 | /*:85*/ |
| 1414 | #line 1372 "ctangle.w" | 1415 | #line 1373 "ctangle.w" |
| 1415 | 1416 | ||
| 1416 | continue; | 1417 | continue; |
| 1417 | } | 1418 | } |
| @@ -1421,14 +1422,14 @@ p= name_dir;break; · 3 unmodified lines | |||
| 1421 | if(next_control==section_name){ | 1422 | if(next_control==section_name){ |
| 1422 | p= cur_section_name; | 1423 | p= cur_section_name; |
| 1423 | /*86:*/ | 1424 | /*86:*/ |
| 1424 | #line 1427 "ctangle.w" | 1425 | #line 1428 "ctangle.w" |
| 1425 | 1426 | ||
| 1426 | while((next_control= get_next())=='+'); | 1427 | while((next_control= get_next())=='+'); |
| 1427 | if(next_control!='='&&next_control!=eq_eq) | 1428 | if(next_control!='='&&next_control!=eq_eq) |
| 1428 | continue; | 1429 | continue; |
| 1429 | 1430 | ||
| 1430 | /*:86*/ | 1431 | /*:86*/ |
| 1431 | #line 1380 "ctangle.w" | 1432 | #line 1381 "ctangle.w" |
| 1432 | ; | 1433 | ; |
| 1433 | break; | 1434 | break; |
| 1434 | } | 1435 | } |
| @@ -1436,20 +1437,20 @@ return; · 1 unmodified line | |||
| 1436 | } | 1437 | } |
| 1437 | no_where= print_where= 0; | 1438 | no_where= print_where= 0; |
| 1438 | /*87:*/ | 1439 | /*87:*/ |
| 1439 | #line 1432 "ctangle.w" | 1440 | #line 1433 "ctangle.w" |
| 1440 | 1441 | ||
| 1441 | /*88:*/ | 1442 | /*88:*/ |
| 1442 | #line 1437 "ctangle.w" | 1443 | #line 1438 "ctangle.w" |
| 1443 | 1444 | ||
| 1444 | store_two_bytes((sixteen_bits)(0150000+section_count)); | 1445 | store_two_bytes((sixteen_bits)(0150000+section_count)); |
| 1445 | 1446 | ||
| 1446 | 1447 | ||
| 1447 | /*:88*/ | 1448 | /*:88*/ |
| 1448 | #line 1433 "ctangle.w" | 1449 | #line 1434 "ctangle.w" |
| 1449 | ; | 1450 | ; |
| 1450 | scan_repl(section_name); | 1451 | scan_repl(section_name); |
| 1451 | /*89:*/ | 1452 | /*89:*/ |
| 1452 | #line 1441 "ctangle.w" | 1453 | #line 1442 "ctangle.w" |
| 1453 | 1454 | ||
| 1454 | if(p==name_dir||p==0){ | 1455 | if(p==name_dir||p==0){ |
| 1455 | (last_unnamed)->text_link= cur_text-text_info;last_unnamed= cur_text; | 1456 | (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 | |||
| 1466 | 1467 | ||
| 1467 | 1468 | ||
| 1468 | /*:89*/ | 1469 | /*:89*/ |
| 1469 | #line 1435 "ctangle.w" | 1470 | #line 1436 "ctangle.w" |
| 1470 | ; | 1471 | ; |
| 1471 | 1472 | ||
| 1472 | /*:87*/ | 1473 | /*:87*/ |
| 1473 | #line 1386 "ctangle.w" | 1474 | #line 1387 "ctangle.w" |
| 1474 | ; | 1475 | ; |
| 1475 | } | 1476 | } |
| 1476 | 1477 | ||
| 1477 | /*:83*//*91:*/ | 1478 | /*:83*//*91:*/ |
| 1478 | #line 1459 "ctangle.w" | 1479 | #line 1460 "ctangle.w" |
| 1479 | 1480 | ||
| 1480 | void | 1481 | void |
| 1481 | phase_one(){ | 1482 | phase_one(){ |
| @@ -1489,7 +1490,7 @@ phase= 2; · 7 unmodified lines | |||
| 1489 | } | 1490 | } |
| 1490 | 1491 | ||
| 1491 | /*:91*//*93:*/ | 1492 | /*:91*//*93:*/ |
| 1492 | #line 1477 "ctangle.w" | 1493 | #line 1478 "ctangle.w" |
| 1493 | 1494 | ||
| 1494 | void | 1495 | void |
| 1495 | skip_limbo() | 1496 | skip_limbo() |
| @@ -1504,7 +1505,7 @@ c= *loc++; · 8 unmodified lines | |||
| 1504 | if(ccode[(eight_bits)c]==new_section)break; | 1505 | if(ccode[(eight_bits)c]==new_section)break; |
| 1505 | switch(ccode[(eight_bits)c]){ | 1506 | switch(ccode[(eight_bits)c]){ |
| 1506 | case translit_code:/*94:*/ | 1507 | case translit_code:/*94:*/ |
| 1507 | #line 1506 "ctangle.w" | 1508 | #line 1507 "ctangle.w" |
| 1508 | 1509 | ||
| 1509 | while(xisspace(*loc)&&loc<limit)loc++; | 1510 | while(xisspace(*loc)&&loc<limit)loc++; |
| 1510 | loc+= 3; | 1511 | loc+= 3; |
| @@ -1529,7 +1530,7 @@ translit[i-0200][loc-beg]= '\0'; · 18 unmodified lines | |||
| 1529 | } | 1530 | } |
| 1530 | 1531 | ||
| 1531 | /*:94*/ | 1532 | /*:94*/ |
| 1532 | #line 1490 "ctangle.w" | 1533 | #line 1491 "ctangle.w" |
| 1533 | ;break; | 1534 | ;break; |
| 1534 | case format_code:case'@':break; | 1535 | case format_code:case'@':break; |
| 1535 | case control_text:if(c=='q'||c=='Q'){ | 1536 | case control_text:if(c=='q'||c=='Q'){ |
| @@ -1547,7 +1548,7 @@ default:err_print("! Double @ should be used in limbo"); · 11 unmodified lines | |||
| 1547 | } | 1548 | } |
| 1548 | 1549 | ||
| 1549 | /*:93*//*95:*/ | 1550 | /*:93*//*95:*/ |
| 1550 | #line 1532 "ctangle.w" | 1551 | #line 1533 "ctangle.w" |
| 1551 | 1552 | ||
| 1552 | void | 1553 | void |
| 1553 | print_stats(){ | 1554 | print_stats(){ |
| @@ -2,8 +2,8 @@ · 1 unmodified line | |||
| 2 | % This program by Silvio Levy and Donald E. Knuth | 2 | % This program by Silvio Levy and Donald E. Knuth |
| 3 | % is based on a program by Knuth. | 3 | % is based on a program by Knuth. |
| 4 | % It is distributed WITHOUT ANY WARRANTY, express or implied. | 4 | % It is distributed WITHOUT ANY WARRANTY, express or implied. |
| 5 | % Version 3.62 --- September 2000 | 5 | % Version 3.64 --- February 2002 |
| 6 | % (same as Version 3.5 except for minor typographic/stylistic corrections) | 6 | % (same as Version 3.5 except for minor corrections) |
| 7 | % (also quotes backslashes in file names of #line directives) | 7 | % (also quotes backslashes in file names of #line directives) |
| 8 | 8 | ||
| 9 | % Copyright (C) 1987,1990,1993,2000 Silvio Levy and Donald E. Knuth | 9 | % Copyright (C) 1987,1990,1993,2000 Silvio Levy and Donald E. Knuth |
| @@ -24,11 +24,11 @@ · 14 unmodified lines | |||
| 24 | \mathchardef\RA="3221 % right arrow | 24 | \mathchardef\RA="3221 % right arrow |
| 25 | \mathchardef\BA="3224 % double arrow | 25 | \mathchardef\BA="3224 % double arrow |
| 26 | 26 | ||
| 27 | \def\title{CTANGLE (Version 3.62)} | 27 | \def\title{CTANGLE (Version 3.64)} |
| 28 | \def\topofcontents{\null\vfill | 28 | \def\topofcontents{\null\vfill |
| 29 | \centerline{\titlefont The {\ttitlefont CTANGLE} processor} | 29 | \centerline{\titlefont The {\ttitlefont CTANGLE} processor} |
| 30 | \vskip 15pt | 30 | \vskip 15pt |
| 31 | \centerline{(Version 3.62)} | 31 | \centerline{(Version 3.64)} |
| 32 | \vfill} | 32 | \vfill} |
| 33 | \def\botofcontents{\vfill | 33 | \def\botofcontents{\vfill |
| 34 | \noindent | 34 | \noindent |
| @@ -59,7 +59,7 @@ Joachim Schrod, Lee Wittenberg, and others who have contributed improvements. · 24 unmodified lines | |||
| 59 | The ``banner line'' defined here should be changed whenever \.{CTANGLE} | 59 | The ``banner line'' defined here should be changed whenever \.{CTANGLE} |
| 60 | is modified. | 60 | is modified. |
| 61 | 61 | ||
| 62 | @d banner "This is CTANGLE (Version 3.62)\n" | 62 | @d banner "This is CTANGLE (Version 3.64)\n" |
| 63 | 63 | ||
| 64 | @c | 64 | @c |
| 65 | @<Include files@>@/ | 65 | @<Include files@>@/ |
| @@ -921,7 +921,7 @@ get_next() /* produces the next input token */ · 855 unmodified lines | |||
| 921 | else continue; | 921 | else continue; |
| 922 | } | 922 | } |
| 923 | loc++; | 923 | loc++; |
| 924 | if (xisdigit(c) || c=='\\' || c=='.') @<Get a constant@>@; | 924 | if (xisdigit(c) || c=='.') @<Get a constant@>@; |
| 925 | else if (c=='\'' || c=='"' || (c=='L'&&(*loc=='\'' || *loc=='"'))) | 925 | else if (c=='\'' || c=='"' || (c=='L'&&(*loc=='\'' || *loc=='"'))) |
| 926 | @<Get a string@>@; | 926 | @<Get a string@>@; |
| 927 | else if (isalpha(c) || isxalpha(c) || ishigh(c)) | 927 | else if (isalpha(c) || isxalpha(c) || ishigh(c)) |
| @@ -978,24 +978,21 @@ switch(c) { · 50 unmodified lines | |||
| 978 | @ @<Get a constant@>= { | 978 | @ @<Get a constant@>= { |
| 979 | id_first=loc-1; | 979 | id_first=loc-1; |
| 980 | if (*id_first=='.' && !xisdigit(*loc)) goto mistake; /* not a constant */ | 980 | if (*id_first=='.' && !xisdigit(*loc)) goto mistake; /* not a constant */ |
| 981 | if (*id_first=='\\') while (xisdigit(*loc)) loc++; /* octal constant */ | 981 | if (*id_first=='0') { |
| 982 | else { | 982 | if (*loc=='x' || *loc=='X') { /* hex constant */ |
| 983 | if (*id_first=='0') { | 983 | loc++; while (xisxdigit(*loc)) loc++; goto found; |
| 984 | if (*loc=='x' || *loc=='X') { /* hex constant */ | ||
| 985 | loc++; while (xisxdigit(*loc)) loc++; goto found; | ||
| 986 | } | ||
| 987 | } | 984 | } |
| 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++; | ||
| 988 | while (xisdigit(*loc)) loc++; | 993 | 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 | } | ||
| 997 | } | 994 | } |
| 998 | found: while (*loc=='u' || *loc=='U' || *loc=='l' || *loc=='L' | 995 | found: while (*loc=='u' || *loc=='U' || *loc=='l' || *loc=='L' |
| 999 | || *loc=='f' || *loc=='F') loc++; | 996 | || *loc=='f' || *loc=='F') loc++; |
| 1000 | id_loc=loc; | 997 | id_loc=loc; |
| 1001 | return(constant); | 998 | return(constant); |
| @@ -1054,7 +1051,6 @@ whether there is more work to do. · 52 unmodified lines | |||
| 1054 | c=ccode[(eight_bits)*loc++]; | 1051 | c=ccode[(eight_bits)*loc++]; |
| 1055 | switch(c) { | 1052 | switch(c) { |
| 1056 | case ignore: continue; | 1053 | case ignore: continue; |
| 1057 | case output_defs_code: output_defs_seen=1; return(c); | ||
| 1058 | case translit_code: err_print("! Use @@l in limbo only"); continue; | 1054 | case translit_code: err_print("! Use @@l in limbo only"); continue; |
| 1059 | @.Use @@l in limbo...@> | 1055 | @.Use @@l in limbo...@> |
| 1060 | case control_text: while ((c=skip_ahead())=='@@'); | 1056 | case control_text: while ((c=skip_ahead())=='@@'); |
| @@ -1248,11 +1244,16 @@ case section_name: if (t!=section_name) goto done; · 187 unmodified lines | |||
| 1248 | app_repl(a % 0400); | 1244 | app_repl(a % 0400); |
| 1249 | @<Insert the line number into |tok_mem|@>; break; | 1245 | @<Insert the line number into |tok_mem|@>; break; |
| 1250 | } | 1246 | } |
| 1251 | case output_defs_code: | 1247 | case output_defs_code: if (t!=section_name) err_print("! Misplaced @@h"); |
| 1252 | a=output_defs_flag; | 1248 | @.Misplaced @@h@> |
| 1253 | app_repl((a / 0400)+0200); | 1249 | else { |
| 1254 | app_repl(a % 0400); | 1250 | output_defs_seen=1; |
| 1255 | @<Insert the line number into |tok_mem|@>; break; | 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; | ||
| 1256 | case constant: case string: | 1257 | case constant: case string: |
| 1257 | @<Copy a string or verbatim construction or numerical constant@>; | 1258 | @<Copy a string or verbatim construction or numerical constant@>; |
| 1258 | case ord: | 1259 | case ord: |
| @@ -20,12 +20,12 @@ This file contributed by Barry Schwartz, trashman@crud.mn.org, 28 Jun 94. · 19 unmodified lines | |||
| 20 | The ``banner line'' defined here should be changed whenever \.{CWEAVE} | 20 | The ``banner line'' defined here should be changed whenever \.{CWEAVE} |
| 21 | is modified. | 21 | is modified. |
| 22 | 22 | ||
| 23 | @d banner "This is CWEAVE (Version 3.61)\n" | 23 | @d banner "This is CWEAVE (Version 3.64)\n" |
| 24 | @y | 24 | @y |
| 25 | The ``banner line'' defined here should be changed whenever \.{CWEAVE} | 25 | The ``banner line'' defined here should be changed whenever \.{CWEAVE} |
| 26 | is modified. | 26 | is modified. |
| 27 | 27 | ||
| 28 | @d banner "This is CWEAVE (Version 3.61pc/big)\n" | 28 | @d banner "This is CWEAVE (Version 3.64pc/big)\n" |
| 29 | @z | 29 | @z |
| 30 | 30 | ||
| 31 | 31 | ||
| @@ -16,7 +16,7 @@ under the terms of a permission notice identical to this one. · 15 unmodified lines | |||
| 16 | } | 16 | } |
| 17 | @y | 17 | @y |
| 18 | \def\botofcontents{\vfill\titlefalse} | 18 | \def\botofcontents{\vfill\titlefalse} |
| 19 | \def\contentspagenumber{107} | 19 | \def\contentspagenumber{109} |
| 20 | \def\title{APPENDIX F: CWEAVE} | 20 | \def\title{APPENDIX F: CWEAVE} |
| 21 | \let\K=\leftarrow | 21 | \let\K=\leftarrow |
| 22 | @z | 22 | @z |
| @@ -11,9 +11,9 @@ that allows >64K arrays. (If you need lots more bytes, try the alternate · 10 unmodified lines | |||
| 11 | change files that have -bs in their name instead of -pc.) | 11 | change files that have -bs in their name instead of -pc.) |
| 12 | 12 | ||
| 13 | @x section 1 | 13 | @x section 1 |
| 14 | @d banner "This is CWEAVE (Version 3.61)\n" | 14 | @d banner "This is CWEAVE (Version 3.64)\n" |
| 15 | @y | 15 | @y |
| 16 | @d banner "This is CWEAVE (Version 3.61pc)\n" | 16 | @d banner "This is CWEAVE (Version 3.64pc)\n" |
| 17 | @z | 17 | @z |
| 18 | 18 | ||
| 19 | @x section 4 | 19 | @x section 4 |
| @@ -7,15 +7,15 @@ ex <dev_>cc;"-v -h -c =500000 cweave_c" · 6 unmodified lines | |||
| 7 | 7 | ||
| 8 | 8 | ||
| 9 | @x | 9 | @x |
| 10 | \def\title{CWEAVE (Version 3.61)} | 10 | \def\title{CWEAVE (Version 3.64)} |
| 11 | @y | 11 | @y |
| 12 | \def\title{CWEAVE (QL Version 3.61)} | 12 | \def\title{CWEAVE (QL Version 3.64)} |
| 13 | @z | 13 | @z |
| 14 | 14 | ||
| 15 | @x section 1 | 15 | @x section 1 |
| 16 | @d banner "This is CWEAVE (Version 3.61)\n" | 16 | @d banner "This is CWEAVE (Version 3.64)\n" |
| 17 | @y | 17 | @y |
| 18 | @d banner "This is CWEAVE (QL Version 3.61)\n" | 18 | @d banner "This is CWEAVE (QL Version 3.64)\n" |
| 19 | @z | 19 | @z |
| 20 | 20 | ||
| 21 | @x | 21 | @x |
| @@ -13,9 +13,9 @@ modified: · 12 unmodified lines | |||
| 13 | (also modified by Don Knuth to keep version numbers uptodate) | 13 | (also modified by Don Knuth to keep version numbers uptodate) |
| 14 | 14 | ||
| 15 | @x section 1 (01-FEB-1992 ST) | 15 | @x section 1 (01-FEB-1992 ST) |
| 16 | @d banner "This is CWEAVE (Version 3.61)\n" | 16 | @d banner "This is CWEAVE (Version 3.64)\n" |
| 17 | @y | 17 | @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" |
| 19 | @z | 19 | @z |
| 20 | 20 | ||
| 21 | @x section 6 (from common.h) (01-FEB-1992 ST) | 21 | @x section 6 (from common.h) (01-FEB-1992 ST) |
| @@ -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 | ||
| @@ -2,7 +2,7 @@ · 1 unmodified line | |||
| 2 | % This program by Silvio Levy and Donald E. Knuth | 2 | % This program by Silvio Levy and Donald E. Knuth |
| 3 | % is based on a program by Knuth. | 3 | % is based on a program by Knuth. |
| 4 | % It is distributed WITHOUT ANY WARRANTY, express or implied. | 4 | % It is distributed WITHOUT ANY WARRANTY, express or implied. |
| 5 | % Version 3.61 --- July 2000 | 5 | % Version 3.64 --- February 2002 |
| 6 | % (essentially the same as version 3.6, which added | 6 | % (essentially the same as version 3.6, which added |
| 7 | % recently introduced features of standard C++ to version 3.4) | 7 | % recently introduced features of standard C++ to version 3.4) |
| 8 | 8 | ||
| @@ -29,11 +29,11 @@ · 20 unmodified lines | |||
| 29 | \def\skipxTeX{\\{skip\_\TEX/}} | 29 | \def\skipxTeX{\\{skip\_\TEX/}} |
| 30 | \def\copyxTeX{\\{copy\_\TEX/}} | 30 | \def\copyxTeX{\\{copy\_\TEX/}} |
| 31 | 31 | ||
| 32 | \def\title{CWEAVE (Version 3.61)} | 32 | \def\title{CWEAVE (Version 3.64)} |
| 33 | \def\topofcontents{\null\vfill | 33 | \def\topofcontents{\null\vfill |
| 34 | \centerline{\titlefont The {\ttitlefont CWEAVE} processor} | 34 | \centerline{\titlefont The {\ttitlefont CWEAVE} processor} |
| 35 | \vskip 15pt | 35 | \vskip 15pt |
| 36 | \centerline{(Version 3.61)} | 36 | \centerline{(Version 3.64)} |
| 37 | \vfill} | 37 | \vfill} |
| 38 | \def\botofcontents{\vfill | 38 | \def\botofcontents{\vfill |
| 39 | \noindent | 39 | \noindent |
| @@ -65,7 +65,7 @@ Crusius, and others who have contributed improvements. · 25 unmodified lines | |||
| 65 | The ``banner line'' defined here should be changed whenever \.{CWEAVE} | 65 | The ``banner line'' defined here should be changed whenever \.{CWEAVE} |
| 66 | is modified. | 66 | is modified. |
| 67 | 67 | ||
| 68 | @d banner "This is CWEAVE (Version 3.61)\n" | 68 | @d banner "This is CWEAVE (Version 3.64)\n" |
| 69 | 69 | ||
| 70 | @c @<Include files@>@/ | 70 | @c @<Include files@>@/ |
| 71 | @h | 71 | @h |
| @@ -101,7 +101,7 @@ char **av; /* argument values */ · 29 unmodified lines | |||
| 101 | { | 101 | { |
| 102 | argc=ac; argv=av; | 102 | argc=ac; argv=av; |
| 103 | program=cweave; | 103 | 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 */ |
| 105 | common_init(); | 105 | common_init(); |
| 106 | @<Set initial values@>; | 106 | @<Set initial values@>; |
| 107 | if (show_banner) printf(banner); /* print a ``banner line'' */ | 107 | if (show_banner) printf(banner); /* print a ``banner line'' */ |
| @@ -703,7 +703,7 @@ get_next() /* produces the next input token */ · 595 unmodified lines | |||
| 703 | @<Check if we're at the end of a preprocessor command@>; | 703 | @<Check if we're at the end of a preprocessor command@>; |
| 704 | if (loc>limit && get_line()==0) return(new_section); | 704 | if (loc>limit && get_line()==0) return(new_section); |
| 705 | c=*(loc++); | 705 | c=*(loc++); |
| 706 | if (xisdigit(c) || c=='\\' || c=='.') @<Get a constant@>@; | 706 | if (xisdigit(c) || c=='.') @<Get a constant@>@; |
| 707 | else if (c=='\'' || c=='"' || (c=='L'&&(*loc=='\'' || *loc=='"'))@| | 707 | else if (c=='\'' || c=='"' || (c=='L'&&(*loc=='\'' || *loc=='"'))@| |
| 708 | || (c=='<' && sharp_include_line==1)) | 708 | || (c=='<' && sharp_include_line==1)) |
| 709 | @<Get a string@>@; | 709 | @<Get a string@>@; |
| @@ -805,7 +805,7 @@ switch(c) { · 95 unmodified lines | |||
| 805 | and hexadecimal numbers; it is reasonable to stick to each convention | 805 | and hexadecimal numbers; it is reasonable to stick to each convention |
| 806 | within its realm. Thus the \CEE/ part of a \.{CWEB} file has octals | 806 | within its realm. Thus the \CEE/ part of a \.{CWEB} file has octals |
| 807 | introduced by \.0 and hexadecimals by \.{0x}, but \.{CWEAVE} will print | 807 | 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. |
| 809 | In order to simplify such macros, we replace some of the characters. | 809 | In order to simplify such macros, we replace some of the characters. |
| 810 | 810 | ||
| 811 | Notice that in this section and the next, |id_first| and |id_loc| | 811 | 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 | |||
| 813 | 813 | ||
| 814 | @<Get a constant@>= { | 814 | @<Get a constant@>= { |
| 815 | id_first=id_loc=section_text+1; | 815 | id_first=id_loc=section_text+1; |
| 816 | if (*(loc-1)=='\\') {*id_loc++='~'; | 816 | if (*(loc-1)=='0') { |
| 817 | while (xisdigit(*loc)) *id_loc++=*loc++;} /* octal constant */ | ||
| 818 | else if (*(loc-1)=='0') { | ||
| 819 | if (*loc=='x' || *loc=='X') {*id_loc++='^'; loc++; | 817 | if (*loc=='x' || *loc=='X') {*id_loc++='^'; loc++; |
| 820 | while (xisxdigit(*loc)) *id_loc++=*loc++;} /* hex constant */ | 818 | while (xisxdigit(*loc)) *id_loc++=*loc++;} /* hex constant */ |
| 821 | else if (xisdigit(*loc)) {*id_loc++='~'; | 819 | else if (xisdigit(*loc)) {*id_loc++='~'; |
| @@ -1,26 +1,30 @@ | |||
| 1 | .TH CWEB 1L 6/15/92 | 1 | .TH CWEB 1L 2002-Apr-13 |
| 2 | . | ||
| 2 | .SH NAME | 3 | .SH NAME |
| 3 | ctangle, cweave \- translate CWEB to C and/or TeX | 4 | ctangle, cweave \- translate CWEB to C and/or TeX |
| 5 | . | ||
| 4 | .SH SYNOPSIS | 6 | .SH SYNOPSIS |
| 7 | .na | ||
| 5 | .B ctangle | 8 | .B ctangle |
| 6 | [ | 9 | [ |
| 7 | .B \-bhp | 10 | .B \-bhp |
| 8 | ] [ | 11 | ] [ |
| 9 | .B \+s | 12 | .B +s |
| 10 | ] webfile[.w] [changefile[.ch]] [outputfile[.c]] | 13 | ] webfile[.w] [changefile[.ch]] [outputfile[.c]] |
| 11 | .br | 14 | .br |
| 12 | .B cweave | 15 | .B cweave |
| 13 | [ | 16 | [ |
| 14 | .B \-bfhpx | 17 | .B \-befhpx |
| 15 | ] [ | 18 | ] [ |
| 16 | .B \+es | 19 | .B +s |
| 17 | ] webfile[.w] [changefile[.ch]] [outputfile[.tex]] | 20 | ] webfile[.w] [changefile[.ch]] [outputfile[.tex]] |
| 18 | 21 | .ad | |
| 22 | . | ||
| 19 | .SH DESCRIPTION | 23 | .SH DESCRIPTION |
| 20 | The | 24 | The |
| 21 | .I ctangle | 25 | .I ctangle |
| 22 | program converts a CWEB | 26 | 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. |
| 24 | The output file includes #line specifications so that debugging can be | 28 | The output file includes #line specifications so that debugging can be |
| 25 | done in terms of the CWEB source file. | 29 | done in terms of the CWEB source file. |
| 26 | .PP | 30 | .PP |
| @@ -34,73 +38,101 @@ extensive cross-index information that it gathers automatically. · 7 unmodified lines | |||
| 34 | .PP | 38 | .PP |
| 35 | CWEB allows you to prepare a single | 39 | CWEB allows you to prepare a single |
| 36 | document containing all the information that is needed both to produce | 40 | document containing all the information that is needed both to produce |
| 37 | a compilable C program and to produce a well-formatted document | 41 | 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 | 42 | describing the program in as much detail as the writer may desire. |
| 39 | user of CWEB ought to be familiar with TeX as well as C. | 43 | The user of CWEB ought to be familiar with TeX as well as\ C. |
| 40 | .PP | 44 | .PP |
| 41 | The command line should have one, two, or three names on it. | 45 | The command line should have one, two, or three names on it. |
| 42 | The first is taken as the CWEB file (and .w is added if there is no | 46 | 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 | 47 | extension). |
| 44 | tried instead. (But .w is recommended, since .web usually implies Pascal.) | 48 | If that file cannot be opened, the extension .web is tried instead. |
| 49 | (But .w is recommended, since .web usually implies Pascal.) | ||
| 45 | If there is a second name, it is a change file (and .ch is added if there is | 50 | 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, | 51 | no extension). |
| 47 | as described in the documentation. If there is a third name, it overrides | 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 | ||
| 48 | the default name of the output file, which is ordinarily the same as | 55 | the default name of the output file, which is ordinarily the same as |
| 49 | the name of the input file (but on the current directory) with the | 56 | the name of the input file (but on the current directory) with the |
| 50 | extension .c or .tex. | 57 | extension .c or .tex. |
| 51 | .PP | 58 | .PP |
| 52 | Options in the command line may be either turned off with - | 59 | 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 | 60 | (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, | 61 | default). |
| 55 | so a sequence like -f +f corresponds to +f (which is the 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). | ||
| 56 | .PP | 64 | .PP |
| 57 | The | 65 | The |
| 58 | .B \-b | 66 | .B \-b |
| 59 | option suppresses the banner line that normally appears on your terminal | 67 | 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 | ||
| 61 | .B \-h | 70 | .B \-h |
| 62 | option suppresses the happy message that normally appears if the processing | 71 | option suppresses the happy message that normally appears if the processing |
| 63 | was successful. The | 72 | was successful. |
| 73 | The | ||
| 64 | .B \-p | 74 | .B \-p |
| 65 | option suppresses progress reports (starred module numbers) as the processing | 75 | 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. | ||
| 67 | .PP | 78 | .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 | ||
| 69 | (assuming that the programs have been compiled with the -DSTAT switch). | 82 | (assuming that the programs have been compiled with the -DSTAT switch). |
| 70 | .PP | 83 | .PP |
| 71 | The \+e option encloses C material formatted by | 84 | There are three other options applicable to |
| 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 | ||
| 80 | .I cweave | 85 | .I cweave |
| 81 | only: | 86 | only: |
| 82 | .B \-f | 87 | .B \-f |
| 83 | means do not force a newline after every statement in the formatted output. | 88 | 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. | ||
| 84 | .B \-x | 98 | .B \-x |
| 85 | means omit the index and table of contents. | 99 | means omit the index and table of contents. |
| 86 | .PP | 100 | . |
| 87 | .SH FILES | 101 | .SH FILES |
| 88 | /usr/local/lib/tex/inputs/cwebmac.tex TeX macros used by cweave output. | 102 | .TP |
| 89 | .br | 103 | /usr/local/lib/tex/inputs/cwebmac.tex |
| 90 | /usr/local/src/cweb/cwebman.tex The user manual. | 104 | TeX macros used by cweave output. |
| 91 | .br | 105 | .TP |
| 92 | /usr/local/src/cweb/examples/wc.w An introductory example. | 106 | /usr/local/src/cweb/cwebman.tex |
| 93 | .br | 107 | The user manual. |
| 94 | /usr/local/lib/cweb Directory for cweb "include" files. | 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 | . | ||
| 95 | .SH "SEE ALSO" | 118 | .SH "SEE ALSO" |
| 119 | .TP | ||
| 96 | .I Literate Programming | 120 | .I Literate Programming |
| 97 | by D.E. Knuth. | 121 | by D. E. Knuth |
| 98 | .br | 122 | .TP |
| 99 | .I Weaving a Program | 123 | .I Weaving a Program |
| 100 | by Wayne Sewell | 124 | 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 | ||
| 102 | tex(1), cc(1) | 130 | tex(1), cc(1) |
| 103 | .SH "AUTHORS" | 131 | . |
| 104 | Don Knuth wrote WEB for TeX and Pascal. Silvio Levy designed and developed CWEB | 132 | .SH AUTHORS |
| 105 | by adapting the WEB conventions to C and by recoding everything in CWEB. | 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. | ||
| 106 | Knuth began using CWEB and made further refinements. | 136 | Knuth began using CWEB and made further refinements. |
| 137 | Many other helpers are acknowledged in the CWEB manual. | ||
| 138 | |||
| @@ -1,15 +1,16 @@ | |||
| 1 | % standard macros for CWEB listings (in addition to plain.tex) | 1 | % standard macros for CWEB listings (in addition to plain.tex) |
| 2 | % Version 3.63 --- January 2001 | 2 | % Version 3.64 --- February 2002 |
| 3 | \ifx\documentstyle\undefined\else\endinput\fi % LaTeX will use other macros | 3 | \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 | ||
| 5 | \newif\ifpdf | 6 | \newif\ifpdf |
| 6 | \ifx\pdf+\pdftrue\fi | 7 | \ifx\pdf+\pdftrue\fi |
| 7 | % Uncomment the following line if you want PDF goodies to be the default | 8 | % Uncomment the following line if you want PDF goodies to be the default |
| 8 | %\ifx\pdf-\else\pdftrue\fi | 9 | %\ifx\pdf-\else\pdftrue\fi |
| 9 | \def\pdflinkcolor{0 0 1} % the RGB values for hyperlink color | 10 | \def\pdflinkcolor{0 0 1} % the RGB values for hyperlink color |
| 10 | \newif\ifpdftex | 11 | \newif\ifpdftex |
| 11 | \ifx\pdfoutput\undefined \pdftexfalse | 12 | \ifx\pdfoutput\undefined \pdftexfalse \else\ifnum\pdfoutput=0 \pdftexfalse |
| 12 | \else \pdftextrue \pdfoutput=1 \pdfcompresslevel=9 \input pdfcolor \fi | 13 | \else \pdftextrue \pdfoutput=1 \input pdfcolor \let\setcolor\pdfsetcolor \fi\fi |
| 13 | \newif\ifacro \ifpdf\acrotrue\fi \ifpdftex\acrotrue\fi | 14 | \newif\ifacro \ifpdf\acrotrue\fi \ifpdftex\acrotrue\fi |
| 14 | 15 | ||
| 15 | \let\:=\. % preserve a way to get the dot accent | 16 | \let\:=\. % preserve a way to get the dot accent |
| @@ -120,49 +121,52 @@ · 104 unmodified lines | |||
| 120 | \def\?{\mathrel?} | 121 | \def\?{\mathrel?} |
| 121 | \def\note#1#2.{\Y\noindent{\hangindent2em% | 122 | \def\note#1#2.{\Y\noindent{\hangindent2em% |
| 122 | \baselineskip10pt\eightrm#1~\ifacro{\pdfnote#2.}\else#2\fi.\par}} | 123 | \baselineskip10pt\eightrm#1~\ifacro{\pdfnote#2.}\else#2\fi.\par}} |
| 123 | % The following are pdf macros | 124 | |
| 124 | \newtoks\toksA \newtoks\toksB \newtoks\toksC \newtoks\toksD | 125 | \newtoks\toksA \newtoks\toksB \newtoks\toksC \newtoks\toksD |
| 126 | \newtoks\toksE \newtoks\toksF \newtoks\usersanitizer | ||
| 125 | \newcount\countA \countA=0 \newcount\countB \countB=0 | 127 | \newcount\countA \countA=0 \newcount\countB \countB=0 |
| 126 | \def\thewidth{\the\wd0\space} | 128 | \newcount\countC \countC=0 |
| 127 | \def\theheight{\the\ht0\space} | 129 | \newif\iftokprocessed \newif\ifTnum \newif\ifinstr |
| 128 | \def\thedepth{\the\dp0\space} | 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} | ||
| 129 | \ifpdftex | 136 | \ifpdftex |
| 130 | \ifx\pdfannotlink\undefined\let\pdfannotlink\pdfstartlink\fi% for pdfTeX 0.14 | 137 | \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 | 138 | \def\pdflink#1#2{\hbox{\pdfannotlink height\ht\strutbox depth\dp\strutbox |
| 132 | \BlueGreen #1\Black\pdfendlink}} | 139 | attr{/Border [0 0 0]} goto num #1 \BlueGreen #1\Black\pdfendlink}} |
| 133 | \else\def\pdflink#1#2{\setbox0=\hbox{\special{pdf: bc [ \pdflinkcolor ]}{#1}% | 140 | \else\def\pdflink#1#2{\setbox0=\hbox{\special{pdf: bc [ \pdflinkcolor ]}{#1}% |
| 134 | \special{pdf: ec}}\special{pdf: ann width \thewidth\space height \theheight | 141 | \special{pdf: ec}}\special{pdf: ann width \thewidth height \theheight |
| 135 | \space depth \thedepth\space << /Type /Annot /Subtype /Link | 142 | depth \thedepth << /Type /Annot /Subtype /Link |
| 136 | /Border [0 0 0] /A << /S /GoTo /D (#2) >> >>}\box0\relax}\fi | 143 | /Border [0 0 0] /A << /S /GoTo /D (#2) >> >>}\box0\relax}\fi |
| 137 | \def\pdfnote#1.{\setbox0=\hbox{\toksA={#1.}\toksB={}\maketoks}\the\toksA} | 144 | \def\pdfnote#1.{\setbox0=\hbox{\toksA={#1.}\toksB={}\maketoks}\the\toksA} |
| 138 | \def\firstsecno#1.{\setbox0=\hbox{\toksA={#1.}\toksB={} | 145 | \def\firstsecno#1.{\setbox0=\hbox{\toksA={#1.}\toksB={}% |
| 139 | \def\makenote{\addtokens{\toksB}{\the\toksC}\def\makenote{\toksD={} | 146 | \def\makenote{\addtokens\toksB{\the\toksC}\def\makenote{\toksD={} |
| 140 | \toksC={}\let\space\empty}\makenote}\maketoks}} | 147 | \toksC={}\let\space\empty}\makenote}\maketoks}} |
| 141 | \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks} | 148 | \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} | 149 | \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}% |
| 143 | \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}} | 150 | \ifcat\noexpand\first0\countB=`#1\else\countB=0\fi\toksA={#2}} |
| 144 | \def\maketoks{% | 151 | \def\maketoks{\expandafter\poptoks\the\toksA|ENDTOKS|% |
| 145 | \expandafter\poptoks\the\toksA|ENDTOKS| | 152 | \ifnum\countB>`9 \countB=0 \fi |
| 146 | \ifx\first0\adn0 | 153 | \ifnum\countB<`0 |
| 147 | \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3 | 154 | \ifnum0=\countC\else\makenote\fi |
| 148 | \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6 | 155 | \ifx\first.\let\next=\maketoksdone\else |
| 149 | \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9 | 156 | \let\next=\maketoks |
| 150 | \else | 157 | \addtokens\toksB{\the\toksD} |
| 151 | \ifnum0=\countA\else\makenote\fi | 158 | \ifx\first,\addtokens\toksB{\space}\fi |
| 152 | \ifx\first.\let\next=\done\else | 159 | \fi |
| 153 | \let\next=\maketoks | 160 | \else \addtokens\toksC{\the\toksD}\global\countC=1\let\next=\maketoks |
| 154 | \addtokens{\toksB}{\the\toksD} | 161 | \fi |
| 155 | \ifx\first,\addtokens{\toksB}{\space}\fi | 162 | \next |
| 156 | \fi | ||
| 157 | \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi | ||
| 158 | \next | ||
| 159 | } | 163 | } |
| 160 | \def\makenote{\addtokens{\toksB}% | 164 | \def\makenote{\addtokens\toksB |
| 161 | {\noexpand\pdflink{\the\toksC}{\romannumeral\the\toksC}}\toksC={}\global\countA=0} | 165 | {\noexpand\pdflink{\the\toksC}{\romannumeral\the\toksC}}\toksC={}\global\countC=0} |
| 162 | \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st} | 166 | \def\maketoksdone{\edef\st{\global\noexpand\toksA={\the\toksB}}\st} |
| 163 | \def\pdfURL#1#2{\ifpdftex\pdfannotlink attr {/Border [0 0 0]} user { | 167 | \def\pdfURL#1#2{\ifpdftex\pdfannotlink height\ht\strutbox depth\dp\strutbox |
| 164 | /Type /Action /Subtype /Link /A << /S /URI /URI (#2) >> | 168 | attr {/Border [0 0 0]} user { /Type /Action /Subtype /Link /A |
| 165 | }\BlueGreen #1\Black \pdfendlink | 169 | << /S /URI /URI (#2) >>}\BlueGreen #1\Black \pdfendlink |
| 166 | \else \ifpdf{\setbox0=\hbox{\special{pdf: bc [ \pdflinkcolor ]}{#1}% | 170 | \else \ifpdf{\setbox0=\hbox{\special{pdf: bc [ \pdflinkcolor ]}{#1}% |
| 167 | \special{pdf: ec}}\special{pdf: ann width \thewidth\space height \theheight | 171 | \special{pdf: ec}}\special{pdf: ann width \thewidth\space height \theheight |
| 168 | \space depth \thedepth\space << /Border [0 0 0] | 172 | \space depth \thedepth\space << /Border [0 0 0] |
| @@ -170,7 +174,105 @@ · 1 unmodified line | |||
| 170 | \else #1 ({\tt#2})\fi\fi} | 174 | \else #1 ({\tt#2})\fi\fi} |
| 171 | {\catcode`\~=12 \gdef\TILDE/{~}} % ~ in a URL | 175 | {\catcode`\~=12 \gdef\TILDE/{~}} % ~ in a URL |
| 172 | {\catcode`\_=12 \gdef\UNDER/{_}} % _ in a URL | 176 | {\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 | |||
| 174 | \def\lapstar{\rlap{*}} | 276 | \def\lapstar{\rlap{*}} |
| 175 | \def\stsec{\rightskip=0pt % get out of C mode (cf. \B) | 277 | \def\stsec{\rightskip=0pt % get out of C mode (cf. \B) |
| 176 | \sfcode`;=1500 \pretolerance 200 \hyphenpenalty 50 \exhyphenpenalty 50 | 278 | \sfcode`;=1500 \pretolerance 200 \hyphenpenalty 50 \exhyphenpenalty 50 |
| @@ -208,13 +310,20 @@ · 31 unmodified lines | |||
| 208 | % \L is Polish letter suppressed-L | 310 | % \L is Polish letter suppressed-L |
| 209 | \outer\def\M#1{\MN{#1}\ifon\vfil\penalty-100\vfilneg % beginning of section | 311 | \outer\def\M#1{\MN{#1}\ifon\vfil\penalty-100\vfilneg % beginning of section |
| 210 | \vskip\intersecskip\startsection\ignorespaces} | 312 | \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}% | ||
| 212 | \ifon\ifnum#1<\secpagedepth \vfil\eject % force page break if depth is small | 316 | \ifon\ifnum#1<\secpagedepth \vfil\eject % force page break if depth is small |
| 213 | \else\vfil\penalty-100\vfilneg\vskip\intersecskip\fi\fi | 317 | \else\vfil\penalty-100\vfilneg\vskip\intersecskip\fi\fi |
| 214 | \message{*\secno} % progress report | 318 | \message{*\secno} % progress report |
| 215 | \edef\next{\write\cont{\ZZ{#3}{#1}{\secno}% write to contents file | 319 | \def\stripprefix##1>{}\def\gtitletoks{#3}% |
| 216 | {\noexpand\the\pageno}}}\next % \ZZ{title}{depth}{sec}{page} | 320 | \edef\gtitletoks{\expandafter\stripprefix\meaning\gtitletoks}% |
| 217 | \ifpdf\special{pdf: outline #1 << /Title (#3) /Dest | 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 | ||
| 218 | [ @thispage /FitH @ypos ] >>}\fi | 327 | [ @thispage /FitH @ypos ] >>}\fi |
| 219 | \ifon\startsection{\bf#3.\quad}\ignorespaces} | 328 | \ifon\startsection{\bf#3.\quad}\ignorespaces} |
| 220 | \def\MN#1{\par % common code for \M, \N | 329 | \def\MN#1{\par % common code for \M, \N |
| @@ -245,17 +354,9 @@ · 24 unmodified lines | |||
| 245 | \let\ZZ=\let % now you can \write the control sequence \ZZ | 354 | \let\ZZ=\let % now you can \write the control sequence \ZZ |
| 246 | \let\*=* | 355 | \let\*=* |
| 247 | 356 | ||
| 248 | \let\Xand=\W | 357 | \def\Xand{\W} \def\Xandxeq{\MRL{{\AND}{\K}}} \def\Xbitand{\AND} |
| 249 | \def\Xandxeq{\MRL{{\W}{\K}}} | 358 | \def\Xbitor{\OR} \def\Xcompl{\CM} \def\Xnot{\R} \def\Xnotxeq{\I} \def\Xor{\V} |
| 250 | \let\Xbitand=\AND | 359 | \def\Xorxeq{\MRL{{\OR}{\K}}} \def\Xxor{\XOR} \def\Xxorxeq{\MRL{{\XOR}{\K}}} |
| 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}}} | ||
| 259 | 360 | ||
| 260 | %\def\oct{\hbox{\rm\char'23\kern-.2em\it\aftergroup\?\aftergroup}} % WEB style | 361 | %\def\oct{\hbox{\rm\char'23\kern-.2em\it\aftergroup\?\aftergroup}} % WEB style |
| 261 | %\def\hex{\hbox{\rm\char"7D\tt\aftergroup}} % WEB style | 362 | %\def\hex{\hbox{\rm\char"7D\tt\aftergroup}} % WEB style |
| @@ -268,10 +369,11 @@ · 6 unmodified lines | |||
| 268 | \def\onmaybe{\let\ifon=\maybe} \let\maybe=\iftrue | 369 | \def\onmaybe{\let\ifon=\maybe} \let\maybe=\iftrue |
| 269 | \newif\ifon \newif\iftitle \newif\ifpagesaved | 370 | \newif\ifon \newif\iftitle \newif\ifpagesaved |
| 270 | 371 | ||
| 271 | \def\lheader{\mainfont\the\pageno\eightrm\qquad\grouptitle\hfill\title\qquad | 372 | \newif\ifheader |
| 272 | \mainfont\topsecno} % top line on left-hand pages | 373 | \def\lheader{\headertrue\mainfont\the\pageno\eightrm\qquad\grouptitle |
| 273 | \def\rheader{\mainfont\topsecno\eightrm\qquad\title\hfill\grouptitle | 374 | \hfill\title\qquad\mainfont\topsecno} % top line on left-hand pages |
| 274 | \qquad\mainfont\the\pageno} % top line on right-hand pages | 375 | \def\rheader{\headertrue\mainfont\topsecno\eightrm\qquad\title\hfill |
| 376 | \grouptitle\qquad\mainfont\the\pageno} % top line on right-hand pages | ||
| 275 | \def\grouptitle{\let\i=I\let\j=J\uppercase\expandafter{\expandafter | 377 | \def\grouptitle{\let\i=I\let\j=J\uppercase\expandafter{\expandafter |
| 276 | \takethree\topmark}} | 378 | \takethree\topmark}} |
| 277 | \def\topsecno{\expandafter\takeone\topmark} | 379 | \def\topsecno{\expandafter\takeone\topmark} |
| @@ -356,18 +458,6 @@ · 78 unmodified lines | |||
| 356 | \if L\lr\else\null\vfill\eject\fi % finish the current page | 458 | \if L\lr\else\null\vfill\eject\fi % finish the current page |
| 357 | \parfillskip 0pt plus 1fil | 459 | \parfillskip 0pt plus 1fil |
| 358 | \def\grouptitle{NAMES OF THE SECTIONS} | 460 | \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 | ||
| 371 | \let\topsecno=\nullsec | 461 | \let\topsecno=\nullsec |
| 372 | \message{Section names:} | 462 | \message{Section names:} |
| 373 | \output={\normaloutput\page\lheader\rheader} | 463 | \output={\normaloutput\page\lheader\rheader} |
| @@ -378,20 +468,29 @@ · 4 unmodified lines | |||
| 378 | \def\U{\note{Used in section}} % crossref for use of a section | 468 | \def\U{\note{Used in section}} % crossref for use of a section |
| 379 | \def\Us{\note{Used in sections}} % crossref for uses of a section | 469 | \def\Us{\note{Used in sections}} % crossref for uses of a section |
| 380 | \def\I{\par\hangindent 2em}\let\*=* | 470 | \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 | ||
| 381 | \readsections} | 485 | \readsections} |
| 382 | \def\makebookmarks{% read contents info for PDF outlines (twice) | 486 | \def\makebookmarks{\let\ZZ=\writebookmarkline \readcontents\relax} |
| 383 | \let\ZZ=\scanbookmarkline \readcontents\relax | ||
| 384 | \let\ZZ=\writebookmarkline \readcontents\relax} | ||
| 385 | \def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0% | 487 | \def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0% |
| 386 | \else \csname#1\endcsname \fi} % Petr Olsak's macros from texinfo.tex | 488 | \else \csname#1\endcsname \fi} % Petr Olsak's macros from texinfo.tex |
| 387 | \def\advancenumber#1{\countA=\expnumber{#1}\relax \advance\countA by1 | 489 | \def\advancenumber#1{\countA=\expnumber{#1}\relax \advance\countA by1 |
| 388 | \expandafter\xdef\csname#1\endcsname{\the\countA}} | 490 | \expandafter\xdef\csname#1\endcsname{\the\countA}} |
| 389 | \def\scanbookmarkline#1#2#3#4{% remember last level item and add to parent | 491 | \def\writebookmarkline#1#2#3#4#5{{% |
| 390 | \expandafter\xdef\csname curr#2\endcsname{#3} | 492 | \let\(=\let \let\)=\let \let\[=\let \let\]=\let \let\/=\let |
| 391 | \ifnum#2>0\countB=#2 \advance\countB by-1 | 493 | \pdfoutline goto num #3 count -\expnumber{chunk#2.#3} {#5}}} |
| 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}} | ||
| 395 | \def\con{\par\vfill\eject % finish the section names | 494 | \def\con{\par\vfill\eject % finish the section names |
| 396 | % \ifodd\pageno\else\titletrue\null\vfill\eject\fi % for duplex printers | 495 | % \ifodd\pageno\else\titletrue\null\vfill\eject\fi % for duplex printers |
| 397 | \rightskip 0pt \hyphenpenalty 50 \tolerance 200 | 496 | \rightskip 0pt \hyphenpenalty 50 \tolerance 200 |
| @@ -405,7 +504,7 @@ · 7 unmodified lines | |||
| 405 | \let\ZZ=\contentsline | 504 | \let\ZZ=\contentsline |
| 406 | \readcontents\relax % read the contents info | 505 | \readcontents\relax % read the contents info |
| 407 | \botofcontents \end} % print the contents page(s) and terminate | 506 | \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 |
| 409 | \line{\consetup{#2}#1 | 508 | \line{\consetup{#2}#1 |
| 410 | \rm\leaders\hbox to .5em{.\hfil}\hfil | 509 | \rm\leaders\hbox to .5em{.\hfil}\hfil |
| 411 | \ \ifacro\pdflink{#3}{\romannumeral#3}\else#3\fi\hbox to3em{\hss#4}}} | 510 | \ \ifacro\pdflink{#3}{\romannumeral#3}\else#3\fi\hbox to3em{\hss#4}}} |
| @@ -2,6 +2,7 @@ · 1 unmodified line | |||
| 2 | 2 | ||
| 3 | \def\tangref{3} % where the main explanation of CTANGLing is given | 3 | \def\tangref{3} % where the main explanation of CTANGLing is given |
| 4 | \input cwebmac | 4 | \input cwebmac |
| 5 | \acrofalse\pdffalse\pdftexfalse | ||
| 5 | \def\page{\box255 } \normalbottom | 6 | \def\page{\box255 } \normalbottom |
| 6 | \parskip 0pt plus 1pt | 7 | \parskip 0pt plus 1pt |
| 7 | \def\RA{\char'31 } % right arrow | 8 | \def\RA{\char'31 } % right arrow |
| @@ -34,7 +35,7 @@ · 26 unmodified lines | |||
| 34 | 35 | ||
| 35 | \def\lheader{\mainfont\the\pageno\hfill\sc\runninghead\hfill} | 36 | \def\lheader{\mainfont\the\pageno\hfill\sc\runninghead\hfill} |
| 36 | \def\rheader{\hfill\sc\runninghead\hfill\mainfont\the\pageno} | 37 | \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)} |
| 38 | 39 | ||
| 39 | % This verbatim mode assumes that ! marks are !! in the text being copied. | 40 | % This verbatim mode assumes that ! marks are !! in the text being copied. |
| 40 | \def\verbatim{\begingroup | 41 | \def\verbatim{\begingroup |
| @@ -48,7 +49,7 @@ · 7 unmodified lines | |||
| 48 | \null\vfill | 49 | \null\vfill |
| 49 | \centerline{\titlefont The {\ttitlefont CWEB} System of | 50 | \centerline{\titlefont The {\ttitlefont CWEB} System of |
| 50 | Structured Documentation} | 51 | Structured Documentation} |
| 51 | \vskip 18pt\centerline{(Version 3.63 --- January 2001)} | 52 | \vskip 18pt\centerline{(Version 3.64 --- February 2002)} |
| 52 | \vskip 24pt | 53 | \vskip 24pt |
| 53 | \centerline{\authorfont Donald E. Knuth and Silvio Levy} | 54 | \centerline{\authorfont Donald E. Knuth and Silvio Levy} |
| 54 | \vfill | 55 | \vfill |
| @@ -1143,8 +1144,9 @@ $$\vbox{\halign{\.{#}\hfil\cr · 1088 unmodified lines | |||
| 1143 | tex "\\let\\pdf+ \\input cob"\cr | 1144 | tex "\\let\\pdf+ \\input cob"\cr |
| 1144 | dvipdfm cob\cr | 1145 | dvipdfm cob\cr |
| 1145 | acroread cob.pdf\cr}}$$ | 1146 | acroread cob.pdf\cr}}$$ |
| 1146 | instead of invoking \TeX\ in the normal way. (Thanks to Hans Hagen and | 1147 | instead of invoking \TeX\ in the normal way. (Thanks to Hans Hagen, |
| 1147 | C\'esar Augusto Rorato Crusius for the macros that make this work.) | 1148 | C\'esar Augusto Rorato Crusius, and Julian Gilbey |
| 1149 | for the macros that make this work.) | ||
| 1148 | Alternatively, thanks to H\`an Th\^e\kern-.3em\raise.3ex\hbox{\'{}} Th\`anh | 1150 | Alternatively, thanks to H\`an Th\^e\kern-.3em\raise.3ex\hbox{\'{}} Th\`anh |
| 1149 | and Andreas Scherer, you can generate \.{cob.pdf} in one step by simply | 1151 | and Andreas Scherer, you can generate \.{cob.pdf} in one step by simply |
| 1150 | saying `\.{pdftex}~\.{cob}'. | 1152 | saying `\.{pdftex}~\.{cob}'. |
| @@ -1493,10 +1495,12 @@ features needed by the output of \.{CWEAVE}. · 342 unmodified lines | |||
| 1493 | 1495 | ||
| 1494 | \vskip6pt | 1496 | \vskip6pt |
| 1495 | \begingroup \def\tt{\eighttt} \baselineskip9pt | 1497 | \begingroup \def\tt{\eighttt} \baselineskip9pt |
| 1496 | \def\printmacs{\input cwebmac} | 1498 | \def\printmacs{\begingroup |
| 1497 | \verbatim | 1499 | \def\do##1{\catcode`##1=12 } \dospecials |
| 1498 | !printmacs | 1500 | \parskip 0pt \parindent 0pt |
| 1499 | !endgroup | 1501 | \catcode`\ =13 \catcode`\^^M=13 |
| 1502 | \tt \verbatimdefs \input cwebmac \endgroup} | ||
| 1503 | \printmacs | ||
| 1500 | \endgroup | 1504 | \endgroup |
| 1501 | \vfill\eject | 1505 | \vfill\eject |
| 1502 | 1506 | ||
| @@ -1521,7 +1525,7 @@ it `\.{|identifier|}'. But you can also say `\.{\\\\\{identifier\}}'. The · 18 unmodified lines | |||
| 1521 | output will look the same in both cases, but the second alternative | 1525 | output will look the same in both cases, but the second alternative |
| 1522 | doesn't put \\{identifier} into the index, since | 1526 | doesn't put \\{identifier} into the index, since |
| 1523 | it bypasses \.{CWEAVE}'s translation from \CEE/ mode. In the second | 1527 | 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 |
| 1525 | in the identifier. | 1529 | in the identifier. |
| 1526 | 1530 | ||
| 1527 | \point 3. To get typewriter-like type, as when referring to `\.{CWEB}', you | 1531 | \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 | |||
| 1574 | \.{ { }\\titlefalse \% include headline on the contents page}\cr | 1578 | \.{ { }\\titlefalse \% include headline on the contents page}\cr |
| 1575 | \.{ { }\\def\\rheader\{\\mainfont The \{\\tt CWEAVE\}{ }processor\\hfil\}}\cr | 1579 | \.{ { }\\def\\rheader\{\\mainfont The \{\\tt CWEAVE\}{ }processor\\hfil\}}\cr |
| 1576 | \.{ { }\\centerline\{\\titlefont The \{\\ttitlefont CWEAVE\}{ }processor\}}\cr | 1580 | \.{ { }\\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}$$ |
| 1578 | Redefining \.{\\rheader}, which is the headline for right-hand pages, | 1582 | Redefining \.{\\rheader}, which is the headline for right-hand pages, |
| 1579 | suffices in this case to put the desired information at the top of the | 1583 | suffices in this case to put the desired information at the top of the |
| 1580 | contents page. | 1584 | contents page. |
| @@ -1582,10 +1586,11 @@ contents page. · 1 unmodified line | |||
| 1582 | \point 9. Data for the table of contents is written to a file that | 1586 | \point 9. Data for the table of contents is written to a file that |
| 1583 | is read after the indexes have been \TEX/ed; there's one line of data | 1587 | is read after the indexes have been \TEX/ed; there's one line of data |
| 1584 | for every starred section. The file \.{common.toc} might look like this: | 1588 | for every starred section. The file \.{common.toc} might look like this: |
| 1585 | $$\lpile{\.{\\ZZ \{Introduction\}\{0\}\{1\}\{26\}}\cr | 1589 | $$\lpile{\.{\\ZZ \{Introduction\}\{0\}\{1\}\{28\}\{\}}\cr |
| 1586 | \.{\\ZZ \{The character set\}\{2\}\{5\}\{27\}}\cr}$$ | 1590 | \.{\\ZZ \{The character set\}\{2\}\{5\}\{29\}\{\}}\cr}$$ |
| 1587 | and so on. The \.{\\topofcontents} macro could | 1591 | and so on. The \.{\\topofcontents} macro could |
| 1588 | redefine \.{\\ZZ} so that the information appears in any desired format. | 1592 | redefine \.{\\ZZ} so that the information appears in any desired format. |
| 1593 | (See also point~19 below.) | ||
| 1589 | 1594 | ||
| 1590 | \point 10. Sometimes it is necessary or desirable to divide the output of | 1595 | \point 10. Sometimes it is necessary or desirable to divide the output of |
| 1591 | \.{CWEAVE} into subfiles that can be processed separately. For example, | 1596 | \.{CWEAVE} into subfiles that can be processed separately. For example, |
| @@ -1700,7 +1705,7 @@ You can send email to · 108 unmodified lines | |||
| 1700 | \\pdfURL\{the author\}\{mailto:andreas.scherer@@pobox.com\}\cr | 1705 | \\pdfURL\{the author\}\{mailto:andreas.scherer@@pobox.com\}\cr |
| 1701 | or visit \\pdfURL\{his home page\}\{http://www.pobox.com/% | 1706 | or visit \\pdfURL\{his home page\}\{http://www.pobox.com/% |
| 1702 | \\TILDE/scherer\}.\cr}}$$ | 1707 | \\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 |
| 1704 | clickable text; the Acrobat reader, if correctly configured, will then | 1709 | clickable text; the Acrobat reader, if correctly configured, will then |
| 1705 | redirect those links to the user's browser and open either the | 1710 | redirect those links to the user's browser and open either the |
| 1706 | email client or the HTML viewer. In a hardcopy document, both arguments | 1711 | 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 | |||
| 1710 | will not confuse them with formatting controls: Use \.{@@} for \.@ | 1715 | will not confuse them with formatting controls: Use \.{@@} for \.@ |
| 1711 | and \.{\\TILDE/} for \.\~ and \.{\\UNDER/} for \.\_. | 1716 | and \.{\\TILDE/} for \.\~ and \.{\\UNDER/} for \.\_. |
| 1712 | 1717 | ||
| 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 | |||
| 1713 | \vfill\end | 1760 | \vfill\end |
| 1761 | |||
| @@ -1,10 +1,12 @@ | |||
| 1 | % Modified 16 Jan 2002 to agree with COMMON version 3.64 | ||
| 2 | |||
| 1 | \def\9#1{} % this hack is explained in CWEB manual Appendix F11 | 3 | \def\9#1{} % this hack is explained in CWEB manual Appendix F11 |
| 2 | 4 | ||
| 3 | @* Introduction. This file contains the program \.{wmerge}, | 5 | @* Introduction. This file contains the program \.{wmerge}, |
| 4 | which takes two or more files and merges them according | 6 | which takes two or more files and merges them according |
| 5 | to the conventions of \.{CWEB}. Namely, it takes an ordinary \.{.w} | 7 | to the conventions of \.{CWEB}. Namely, it takes an ordinary \.{.w} |
| 6 | file and and optional \.{.ch} file and sends the corresponding | 8 | 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), |
| 8 | expanding all ``includes'' | 10 | expanding all ``includes'' |
| 9 | that might be specified by \.{@@i} in the original \.{.w} file. | 11 | that might be specified by \.{@@i} in the original \.{.w} file. |
| 10 | (A more precise description appears in the section on ``command line | 12 | (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 | |||
| 88 | \.{WEAVE} know that this is a type, either by including the \.{.h} file | 90 | \.{WEAVE} know that this is a type, either by including the \.{.h} file |
| 89 | at \.{WEB} time (saying \.{@@i /usr/include/sys/types.h}), or by | 91 | at \.{WEB} time (saying \.{@@i /usr/include/sys/types.h}), or by |
| 90 | using \.{WEB}'s format command (saying \.{@@f caddr\_t int}). Either of | 92 | 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|. |
| 92 | 94 | ||
| 93 | @<Func...@>= | 95 | @<Func...@>= |
| 94 | input_ln(fp) /* copies a line into |buffer| or returns 0 */ | 96 | input_ln(fp) /* copies a line into |buffer| or returns 0 */ |
| @@ -211,7 +213,7 @@ do { · 116 unmodified lines | |||
| 211 | 213 | ||
| 212 | @ @<Move |buffer| and |limit| to |change_buffer| and |change_limit|@>= | 214 | @ @<Move |buffer| and |limit| to |change_buffer| and |change_limit|@>= |
| 213 | { | 215 | { |
| 214 | change_limit=change_buffer-buffer+limit; | 216 | change_limit=change_buffer+(limit-buffer); |
| 215 | strncpy(change_buffer,buffer,limit-buffer+1); | 217 | strncpy(change_buffer,buffer,limit-buffer+1); |
| 216 | } | 218 | } |
| 217 | 219 | ||
| @@ -242,7 +244,7 @@ check_change() /* switches to |change_file| if the buffers match */ · 24 unmodified lines | |||
| 242 | return; | 244 | return; |
| 243 | } | 245 | } |
| 244 | if (limit>buffer+1 && buffer[0]=='@@') { | 246 | 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]; |
| 246 | @<If the current line starts with \.{@@y}, | 248 | @<If the current line starts with \.{@@y}, |
| 247 | report any discrepancies and |return|@>; | 249 | report any discrepancies and |return|@>; |
| 248 | } | 250 | } |
| @@ -261,11 +263,11 @@ check_change() /* switches to |change_file| if the buffers match */ · 12 unmodified lines | |||
| 261 | } | 263 | } |
| 262 | 264 | ||
| 263 | @ @<If the current line starts with \.{@@y}...@>= | 265 | @ @<If the current line starts with \.{@@y}...@>= |
| 264 | if (buffer[1]=='x' || buffer[1]=='z') { | 266 | if (xyz_code=='x' || xyz_code=='z') { |
| 265 | loc=buffer+2; err_print("! Where is the matching @@y?"); | 267 | loc=buffer+2; err_print("! Where is the matching @@y?"); |
| 266 | @.Where is the match...@> | 268 | @.Where is the match...@> |
| 267 | } | 269 | } |
| 268 | else if (buffer[1]=='y') { | 270 | else if (xyz_code=='y') { |
| 269 | if (n>0) { | 271 | if (n>0) { |
| 270 | loc=buffer+2; | 272 | loc=buffer+2; |
| 271 | fprintf(stderr,"\n! Hmm... %d ",n); | 273 | fprintf(stderr,"\n! Hmm... %d ",n); |
| @@ -313,7 +315,7 @@ This procedure returns |!input_has_ended| because we often want to · 41 unmodified lines | |||
| 313 | check the value of that variable after calling the procedure. | 315 | check the value of that variable after calling the procedure. |
| 314 | 316 | ||
| 315 | @<Fun...@>= | 317 | @<Fun...@>= |
| 316 | get_line() /* inputs the next line */ | 318 | int get_line() /* inputs the next line */ |
| 317 | { | 319 | { |
| 318 | restart: | 320 | restart: |
| 319 | if (changing && include_depth==change_depth) | 321 | if (changing && include_depth==change_depth) |
| @@ -322,10 +324,11 @@ get_line() /* inputs the next line */ · 2 unmodified lines | |||
| 322 | @<Read from |cur_file| and maybe turn on |changing|@>; | 324 | @<Read from |cur_file| and maybe turn on |changing|@>; |
| 323 | if (changing && include_depth==change_depth) goto restart; | 325 | if (changing && include_depth==change_depth) goto restart; |
| 324 | } | 326 | } |
| 327 | if (input_has_ended) return 0; | ||
| 325 | loc=buffer; *limit=' '; | 328 | loc=buffer; *limit=' '; |
| 326 | if (*buffer=='@@' && (*(buffer+1)=='i' || *(buffer+1)=='I')) { | 329 | if (buffer[0]=='@@' && (buffer[1]=='i' || buffer[1]=='I')) { |
| 327 | loc=buffer+2; | 330 | loc=buffer+2; *limit='"'; |
| 328 | while (loc<=limit && (*loc==' '||*loc=='\t'||*loc=='"')) loc++; | 331 | while (*loc==' '||*loc=='\t') loc++; |
| 329 | if (loc>=limit) { | 332 | if (loc>=limit) { |
| 330 | err_print("! Include file name not given"); | 333 | err_print("! Include file name not given"); |
| 331 | @.Include file name ...@> | 334 | @.Include file name ...@> |
| @@ -335,11 +338,11 @@ get_line() /* inputs the next line */ · 3 unmodified lines | |||
| 335 | err_print("! Too many nested includes"); | 338 | err_print("! Too many nested includes"); |
| 336 | @.Too many nested includes@> | 339 | @.Too many nested includes@> |
| 337 | goto restart; | 340 | goto restart; |
| 338 | } | 341 | } |
| 339 | include_depth++; /* push input stack */ | 342 | include_depth++; /* push input stack */ |
| 340 | @<Try to open include file, abort push if unsuccessful, go to |restart|@>; | 343 | @<Try to open include file, abort push if unsuccessful, go to |restart|@>; |
| 341 | } | 344 | } |
| 342 | return (!input_has_ended); | 345 | return 1; |
| 343 | } | 346 | } |
| 344 | 347 | ||
| 345 | void put_line() | 348 | void put_line() |
| @@ -353,28 +356,33 @@ void put_line() · 7 unmodified lines | |||
| 353 | stop reading it and start reading from the named include file. The | 356 | stop reading it and start reading from the named include file. The |
| 354 | \.{@@i} line should give a complete file name with or without | 357 | \.{@@i} line should give a complete file name with or without |
| 355 | double quotes. | 358 | 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 |
| 357 | of the same name was defined at compile time, | 360 | of the same name was defined at compile time, |
| 358 | \.{CWEB} will look for include files in the directory thus named, if | 361 | \.{CWEB} will look for include files in the directory thus named, if |
| 359 | it cannot find them in the current directory. | 362 | it cannot find them in the current directory. |
| 360 | (Colon-separated paths are not supported.) | 363 | (Colon-separated paths are not supported.) |
| 361 | The remainder of the \.{@@i} line after the file name is ignored. | 364 | The remainder of the \.{@@i} line after the file name is ignored. |
| 362 | 365 | ||
| 363 | @d too_long() {include_depth--; | 366 | @d too_long() {include_depth--; |
| 364 | err_print("! Include file name too long"); goto restart;} | 367 | err_print("! Include file name too long"); goto restart;} |
| 365 | 368 | ||
| 366 | @ @<Try to open...@>= { | 369 | @ @<Try to open...@>= { |
| 367 | char temp_file_name[max_file_name_length]; | 370 | char temp_file_name[max_file_name_length]; |
| 368 | char *cur_file_name_end=cur_file_name+max_file_name_length-1; | 371 | char *cur_file_name_end=cur_file_name+max_file_name_length-1; |
| 369 | char *k=cur_file_name, *kk; | 372 | char *k=cur_file_name, *kk; |
| 370 | int l; /* length of file name */ | 373 | int l; /* length of file name */ |
| 371 | 374 | ||
| 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++; | ||
| 373 | if (k>cur_file_name_end) too_long(); | 381 | if (k>cur_file_name_end) too_long(); |
| 374 | @.Include file name ...@> | 382 | @.Include file name ...@> |
| 375 | *k='\0'; | 383 | *k='\0'; |
| 376 | if ((cur_file=fopen(cur_file_name,"r"))!=NULL) { | 384 | if ((cur_file=fopen(cur_file_name,"r"))!=NULL) { |
| 377 | cur_line=0; | 385 | cur_line=0; |
| 378 | goto restart; /* success */ | 386 | goto restart; /* success */ |
| 379 | } | 387 | } |
| 380 | kk=getenv("CWEBINPUTS"); | 388 | kk=getenv("CWEBINPUTS"); |
| @@ -387,7 +395,7 @@ The remainder of the \.{@@i} line after the file name is ignored. · 6 unmodified lines | |||
| 387 | if ((l=strlen(CWEBINPUTS))>max_file_name_length-2) too_long(); | 395 | if ((l=strlen(CWEBINPUTS))>max_file_name_length-2) too_long(); |
| 388 | strcpy(temp_file_name,CWEBINPUTS); | 396 | strcpy(temp_file_name,CWEBINPUTS); |
| 389 | #else | 397 | #else |
| 390 | l=0; | 398 | l=0; |
| 391 | #endif /* |CWEBINPUTS| */ | 399 | #endif /* |CWEBINPUTS| */ |
| 392 | } | 400 | } |
| 393 | if (l>0) { | 401 | if (l>0) { |
| @@ -397,7 +405,7 @@ The remainder of the \.{@@i} line after the file name is ignored. · 3 unmodified lines | |||
| 397 | strcpy(cur_file_name,temp_file_name); | 405 | strcpy(cur_file_name,temp_file_name); |
| 398 | cur_file_name[l]='/'; /* \UNIX/ pathname separator */ | 406 | cur_file_name[l]='/'; /* \UNIX/ pathname separator */ |
| 399 | if ((cur_file=fopen(cur_file_name,"r"))!=NULL) { | 407 | if ((cur_file=fopen(cur_file_name,"r"))!=NULL) { |
| 400 | cur_line=0; | 408 | cur_line=0; |
| 401 | goto restart; /* success */ | 409 | goto restart; /* success */ |
| 402 | } | 410 | } |
| 403 | } | 411 | } |
| @@ -437,7 +445,7 @@ The remainder of the \.{@@i} line after the file name is ignored. · 33 unmodified lines | |||
| 437 | @.Where is the match...@> | 445 | @.Where is the match...@> |
| 438 | } | 446 | } |
| 439 | else if (buffer[1]=='z') { | 447 | else if (buffer[1]=='z') { |
| 440 | prime_the_change_buffer(); changing=!changing; | 448 | prime_the_change_buffer(); changing=!changing; |
| 441 | } | 449 | } |
| 442 | } | 450 | } |
| 443 | } | 451 | } |