Unified · Split
| @@ -7,12 +7,12 @@ · 6 unmodified lines | |||
| 7 | #include <ctype.h> | 7 | #include <ctype.h> |
| 8 | 8 | ||
| 9 | /*:5*//*8:*/ | 9 | /*:5*//*8:*/ |
| 10 | #line 163 "common.w" | 10 | #line 164 "common.w" |
| 11 | 11 | ||
| 12 | #include <stdio.h> | 12 | #include <stdio.h> |
| 13 | 13 | ||
| 14 | /*:8*//*22:*/ | 14 | /*:8*//*22:*/ |
| 15 | #line 468 "common.w" | 15 | #line 469 "common.w" |
| 16 | 16 | ||
| 17 | #include <stdlib.h> | 17 | #include <stdlib.h> |
| 18 | 18 | ||
| @@ -39,9 +39,10 @@ · 20 unmodified lines | |||
| 39 | #define minus_gt_ast 027 \ | 39 | #define minus_gt_ast 027 \ |
| 40 | 40 | ||
| 41 | #define buf_size 100 | 41 | #define buf_size 100 |
| 42 | #define long_buf_size 500 | 42 | #define longest_name 1000 |
| 43 | #define xisspace(c)(isspace(c)&&((unsigned char)c<0200)) | 43 | #define long_buf_size (buf_size+longest_name) |
| 44 | #define xisupper(c)(isupper(c)&&((unsigned char)c<0200)) \ | 44 | #define xisspace(c) (isspace(c) &&((unsigned char) c<0200) ) |
| 45 | #define xisupper(c) (isupper(c) &&((unsigned char) c<0200) ) \ | ||
| 45 | 46 | ||
| 46 | #define max_include_depth 10 \ | 47 | #define max_include_depth 10 \ |
| 47 | 48 | ||
| @@ -53,27 +54,27 @@ · 5 unmodified lines | |||
| 53 | #define web_file_name file_name[0] \ | 54 | #define web_file_name file_name[0] \ |
| 54 | 55 | ||
| 55 | #define lines_dont_match (change_limit-change_buffer!=limit-buffer|| \ | 56 | #define lines_dont_match (change_limit-change_buffer!=limit-buffer|| \ |
| 56 | strncmp(buffer,change_buffer,limit-buffer)) \ | 57 | strncmp(buffer,change_buffer,limit-buffer) ) \ |
| 57 | 58 | ||
| 58 | #define if_section_start_make_pending(b){*limit= '!'; \ | 59 | #define if_section_start_make_pending(b) {*limit= '!'; \ |
| 59 | for(loc= buffer;xisspace(*loc);loc++); \ | 60 | for(loc= buffer;xisspace(*loc) ;loc++) ; \ |
| 60 | *limit= ' '; \ | 61 | *limit= ' '; \ |
| 61 | if(*loc=='@'&&(xisspace(*(loc+1))||*(loc+1)=='*'))change_pending= b; \ | 62 | if(*loc=='@'&&(xisspace(*(loc+1) ) ||*(loc+1) =='*') ) change_pending= b; \ |
| 62 | } \ | 63 | } \ |
| 63 | 64 | ||
| 64 | #define max_sections 2000 \ | 65 | #define max_sections 2000 \ |
| 65 | \ | 66 | \ |
| 66 | 67 | ||
| 67 | #define too_long(){include_depth--; \ | 68 | #define too_long() {include_depth--; \ |
| 68 | err_print("! Include file name too long");goto restart;} \ | 69 | err_print("! Include file name too long") ;goto restart;} \ |
| 69 | 70 | ||
| 70 | #define max_bytes 90000 \ | 71 | #define max_bytes 90000 \ |
| 71 | 72 | ||
| 72 | #define max_names 4000 \ | 73 | #define max_names 4000 \ |
| 73 | \ | 74 | \ |
| 74 | 75 | ||
| 75 | #define length(c)(c+1)->byte_start-(c)->byte_start | 76 | #define length(c) (c+1) ->byte_start-(c) ->byte_start |
| 76 | #define print_id(c)term_write((c)->byte_start,length((c))) \ | 77 | #define print_id(c) term_write((c) ->byte_start,length((c) ) ) \ |
| 77 | 78 | ||
| 78 | #define hash_size 353 \ | 79 | #define hash_size 353 \ |
| 79 | 80 | ||
| @@ -82,11 +83,11 @@ err_print("! Include file name too long");goto restart;} \ · 2 unmodified lines | |||
| 82 | #define root name_dir->rlink \ | 83 | #define root name_dir->rlink \ |
| 83 | \ | 84 | \ |
| 84 | 85 | ||
| 85 | #define first_chunk(p)((p)->byte_start+2) | 86 | #define first_chunk(p) ((p) ->byte_start+2) |
| 86 | #define prefix_length(p)(int)((unsigned char)*((p)->byte_start)*256+ \ | 87 | #define prefix_length(p) (int) ((unsigned char) *((p) ->byte_start) *256+ \ |
| 87 | (unsigned char)*((p)->byte_start+1)) | 88 | (unsigned char) *((p) ->byte_start+1) ) |
| 88 | #define set_prefix_length(p,m)(*((p)->byte_start)= (m)/256, \ | 89 | #define set_prefix_length(p,m) (*((p) ->byte_start) = (m) /256, \ |
| 89 | *((p)->byte_start+1)= (m)%256) \ | 90 | *((p) ->byte_start+1) = (m) %256) \ |
| 90 | 91 | ||
| 91 | #define less 0 | 92 | #define less 0 |
| 92 | #define equal 1 | 93 | #define equal 1 |
| @@ -100,10 +101,10 @@ err_print("! Include file name too long");goto restart;} \ · 7 unmodified lines | |||
| 100 | #define harmless_message 1 | 101 | #define harmless_message 1 |
| 101 | #define error_message 2 | 102 | #define error_message 2 |
| 102 | #define fatal_message 3 | 103 | #define fatal_message 3 |
| 103 | #define mark_harmless {if(history==spotless)history= harmless_message;} | 104 | #define mark_harmless {if(history==spotless) history= harmless_message;} |
| 104 | #define mark_error history= error_message \ | 105 | #define mark_error history= error_message \ |
| 105 | 106 | ||
| 106 | #define confusion(s)fatal("! This can't happen: ",s) \ | 107 | #define confusion(s) fatal("! This can't happen: ",s) \ |
| 107 | \ | 108 | \ |
| 108 | 109 | ||
| 109 | #define show_banner flags['b'] | 110 | #define show_banner flags['b'] |
| @@ -111,13 +112,13 @@ err_print("! Include file name too long");goto restart;} \ · 1 unmodified line | |||
| 111 | #define show_stats flags['s'] | 112 | #define show_stats flags['s'] |
| 112 | #define show_happiness flags['h'] \ | 113 | #define show_happiness flags['h'] \ |
| 113 | 114 | ||
| 114 | #define update_terminal fflush(stdout) \ | 115 | #define update_terminal fflush(stdout) \ |
| 115 | 116 | ||
| 116 | #define new_line putchar('\n') | 117 | #define new_line putchar('\n') |
| 117 | #define putxchar putchar | 118 | #define putxchar putchar |
| 118 | #define term_write(a,b)fflush(stdout),fwrite(a,sizeof(char),b,stdout) | 119 | #define term_write(a,b) fflush(stdout) ,fwrite(a,sizeof(char) ,b,stdout) |
| 119 | #define C_printf(c,a)fprintf(C_file,c,a) | 120 | #define C_printf(c,a) fprintf(C_file,c,a) |
| 120 | #define C_putc(c)putc(c,C_file) \ | 121 | #define C_putc(c) putc(c,C_file) \ |
| 121 | 122 | ||
| 122 | 123 | ||
| 123 | #line 59 "common.w" | 124 | #line 59 "common.w" |
| @@ -129,7 +130,7 @@ typedef short boolean; · 5 unmodified lines | |||
| 129 | boolean program; | 130 | boolean program; |
| 130 | 131 | ||
| 131 | /*:2*//*7:*/ | 132 | /*:2*//*7:*/ |
| 132 | #line 157 "common.w" | 133 | #line 158 "common.w" |
| 133 | 134 | ||
| 134 | char buffer[long_buf_size]; | 135 | char buffer[long_buf_size]; |
| 135 | char*buffer_end= buffer+buf_size-2; | 136 | char*buffer_end= buffer+buf_size-2; |
| @@ -137,7 +138,7 @@ char*limit= buffer; · 1 unmodified line | |||
| 137 | char*loc= buffer; | 138 | char*loc= buffer; |
| 138 | 139 | ||
| 139 | /*:7*//*10:*/ | 140 | /*:7*//*10:*/ |
| 140 | #line 212 "common.w" | 141 | #line 213 "common.w" |
| 141 | 142 | ||
| 142 | int include_depth; | 143 | int include_depth; |
| 143 | FILE*file[max_include_depth]; | 144 | FILE*file[max_include_depth]; |
| @@ -154,7 +155,7 @@ boolean changing; · 10 unmodified lines | |||
| 154 | boolean web_file_open= 0; | 155 | boolean web_file_open= 0; |
| 155 | 156 | ||
| 156 | /*:10*//*20:*/ | 157 | /*:10*//*20:*/ |
| 157 | #line 416 "common.w" | 158 | #line 417 "common.w" |
| 158 | 159 | ||
| 159 | typedef unsigned short sixteen_bits; | 160 | typedef unsigned short sixteen_bits; |
| 160 | sixteen_bits section_count; | 161 | sixteen_bits section_count; |
| @@ -164,17 +165,17 @@ boolean change_pending; · 3 unmodified lines | |||
| 164 | boolean print_where= 0; | 165 | boolean print_where= 0; |
| 165 | 166 | ||
| 166 | /*:20*//*27:*/ | 167 | /*:20*//*27:*/ |
| 167 | #line 586 "common.w" | 168 | #line 587 "common.w" |
| 168 | 169 | ||
| 169 | typedef struct name_info{ | 170 | typedef struct name_info{ |
| 170 | char*byte_start; | 171 | char*byte_start; |
| 171 | /*31:*/ | 172 | /*31:*/ |
| 172 | #line 623 "common.w" | 173 | #line 624 "common.w" |
| 173 | 174 | ||
| 174 | struct name_info*link; | 175 | struct name_info*link; |
| 175 | 176 | ||
| 176 | /*:31*//*40:*/ | 177 | /*:31*//*40:*/ |
| 177 | #line 722 "common.w" | 178 | #line 723 "common.w" |
| 178 | 179 | ||
| 179 | union{ | 180 | union{ |
| 180 | struct name_info*Rlink; | 181 | struct name_info*Rlink; |
| @@ -183,12 +184,12 @@ char Ilk; · 2 unmodified lines | |||
| 183 | }dummy; | 184 | }dummy; |
| 184 | 185 | ||
| 185 | /*:40*//*55:*/ | 186 | /*:40*//*55:*/ |
| 186 | #line 1054 "common.w" | 187 | #line 1055 "common.w" |
| 187 | 188 | ||
| 188 | char*equiv_or_xref; | 189 | char*equiv_or_xref; |
| 189 | 190 | ||
| 190 | /*:55*/ | 191 | /*:55*/ |
| 191 | #line 589 "common.w" | 192 | #line 590 "common.w" |
| 192 | 193 | ||
| 193 | }name_info; | 194 | }name_info; |
| 194 | typedef name_info*name_pointer; | 195 | typedef name_info*name_pointer; |
| @@ -198,13 +199,13 @@ name_info name_dir[max_names]; · 3 unmodified lines | |||
| 198 | name_pointer name_dir_end= name_dir+max_names-1; | 199 | name_pointer name_dir_end= name_dir+max_names-1; |
| 199 | 200 | ||
| 200 | /*:27*//*29:*/ | 201 | /*:27*//*29:*/ |
| 201 | #line 609 "common.w" | 202 | #line 610 "common.w" |
| 202 | 203 | ||
| 203 | name_pointer name_ptr; | 204 | name_pointer name_ptr; |
| 204 | char*byte_ptr; | 205 | char*byte_ptr; |
| 205 | 206 | ||
| 206 | /*:29*//*32:*/ | 207 | /*:29*//*32:*/ |
| 207 | #line 636 "common.w" | 208 | #line 637 "common.w" |
| 208 | 209 | ||
| 209 | typedef name_pointer*hash_pointer; | 210 | typedef name_pointer*hash_pointer; |
| 210 | name_pointer hash[hash_size]; | 211 | name_pointer hash[hash_size]; |
| @@ -212,12 +213,12 @@ hash_pointer hash_end= hash+hash_size-1; · 1 unmodified line | |||
| 212 | hash_pointer h; | 213 | hash_pointer h; |
| 213 | 214 | ||
| 214 | /*:32*//*56:*/ | 215 | /*:32*//*56:*/ |
| 215 | #line 1074 "common.w" | 216 | #line 1075 "common.w" |
| 216 | 217 | ||
| 217 | int history= spotless; | 218 | int history= spotless; |
| 218 | 219 | ||
| 219 | /*:56*//*67:*/ | 220 | /*:56*//*67:*/ |
| 220 | #line 1212 "common.w" | 221 | #line 1213 "common.w" |
| 221 | 222 | ||
| 222 | int argc; | 223 | int argc; |
| 223 | char**argv; | 224 | char**argv; |
| @@ -228,7 +229,7 @@ char scn_file_name[max_file_name_length]; · 4 unmodified lines | |||
| 228 | boolean flags[128]; | 229 | boolean flags[128]; |
| 229 | 230 | ||
| 230 | /*:67*//*77:*/ | 231 | /*:67*//*77:*/ |
| 231 | #line 1366 "common.w" | 232 | #line 1367 "common.w" |
| 232 | 233 | ||
| 233 | FILE*C_file; | 234 | FILE*C_file; |
| 234 | FILE*tex_file; | 235 | FILE*tex_file; |
| @@ -244,7 +245,7 @@ FILE*active_file; · 9 unmodified lines | |||
| 244 | int phase; | 245 | int phase; |
| 245 | 246 | ||
| 246 | /*:3*//*11:*/ | 247 | /*:3*//*11:*/ |
| 247 | #line 238 "common.w" | 248 | #line 239 "common.w" |
| 248 | 249 | ||
| 249 | char change_buffer[buf_size]; | 250 | char change_buffer[buf_size]; |
| 250 | char*change_limit; | 251 | char*change_limit; |
| @@ -253,48 +254,48 @@ char*change_limit; · 2 unmodified lines | |||
| 253 | #line 61 "common.w" | 254 | #line 61 "common.w" |
| 254 | 255 | ||
| 255 | /*33:*/ | 256 | /*33:*/ |
| 256 | #line 642 "common.w" | 257 | #line 643 "common.w" |
| 257 | 258 | ||
| 258 | extern int names_match(); | 259 | extern int names_match(); |
| 259 | 260 | ||
| 260 | /*:33*//*38:*/ | 261 | /*:33*//*38:*/ |
| 261 | #line 695 "common.w" | 262 | #line 696 "common.w" |
| 262 | 263 | ||
| 263 | void init_p(); | 264 | void init_p(); |
| 264 | 265 | ||
| 265 | /*:38*//*46:*/ | 266 | /*:38*//*46:*/ |
| 266 | #line 844 "common.w" | 267 | #line 845 "common.w" |
| 267 | 268 | ||
| 268 | extern void init_node(); | 269 | extern void init_node(); |
| 269 | 270 | ||
| 270 | /*:46*//*53:*/ | 271 | /*:46*//*53:*/ |
| 271 | #line 1009 "common.w" | 272 | #line 1010 "common.w" |
| 272 | 273 | ||
| 273 | int section_name_cmp(); | 274 | int section_name_cmp(); |
| 274 | 275 | ||
| 275 | /*:53*//*57:*/ | 276 | /*:53*//*57:*/ |
| 276 | #line 1084 "common.w" | 277 | #line 1085 "common.w" |
| 277 | 278 | ||
| 278 | void err_print(); | 279 | void err_print(); |
| 279 | 280 | ||
| 280 | /*:57*//*60:*/ | 281 | /*:57*//*60:*/ |
| 281 | #line 1132 "common.w" | 282 | #line 1133 "common.w" |
| 282 | 283 | ||
| 283 | int wrap_up(); | 284 | int wrap_up(); |
| 284 | extern void print_stats(); | 285 | extern void print_stats(); |
| 285 | 286 | ||
| 286 | /*:60*//*63:*/ | 287 | /*:60*//*63:*/ |
| 287 | #line 1165 "common.w" | 288 | #line 1166 "common.w" |
| 288 | 289 | ||
| 289 | void fatal(),overflow(); | 290 | void fatal(),overflow(); |
| 290 | 291 | ||
| 291 | /*:63*//*69:*/ | 292 | /*:63*//*69:*/ |
| 292 | #line 1243 "common.w" | 293 | #line 1244 "common.w" |
| 293 | 294 | ||
| 294 | void scan_args(); | 295 | void scan_args(); |
| 295 | 296 | ||
| 296 | /*:69*//*81:*/ | 297 | /*:69*//*81:*/ |
| 297 | #line 1407 "common.w" | 298 | #line 1408 "common.w" |
| 298 | 299 | ||
| 299 | extern int strlen(); | 300 | extern int strlen(); |
| 300 | extern int strcmp(); | 301 | extern int strcmp(); |
| @@ -313,19 +314,19 @@ void · 12 unmodified lines | |||
| 313 | common_init() | 314 | common_init() |
| 314 | { | 315 | { |
| 315 | /*30:*/ | 316 | /*30:*/ |
| 316 | #line 613 "common.w" | 317 | #line 614 "common.w" |
| 317 | 318 | ||
| 318 | name_dir->byte_start= byte_ptr= byte_mem; | 319 | name_dir->byte_start= byte_ptr= byte_mem; |
| 319 | name_ptr= name_dir+1; | 320 | name_ptr= name_dir+1; |
| 320 | name_ptr->byte_start= byte_mem; | 321 | name_ptr->byte_start= byte_mem; |
| 321 | 322 | ||
| 322 | /*:30*//*34:*/ | 323 | /*:30*//*34:*/ |
| 323 | #line 647 "common.w" | 324 | #line 648 "common.w" |
| 324 | 325 | ||
| 325 | for(h= hash;h<=hash_end;*h++= NULL); | 326 | for(h= hash;h<=hash_end;*h++= NULL); |
| 326 | 327 | ||
| 327 | /*:34*//*41:*/ | 328 | /*:34*//*41:*/ |
| 328 | #line 729 "common.w" | 329 | #line 730 "common.w" |
| 329 | 330 | ||
| 330 | root= NULL; | 331 | root= NULL; |
| 331 | 332 | ||
| @@ -333,7 +334,7 @@ root= NULL; · 1 unmodified line | |||
| 333 | #line 92 "common.w" | 334 | #line 92 "common.w" |
| 334 | ; | 335 | ; |
| 335 | /*68:*/ | 336 | /*68:*/ |
| 336 | #line 1225 "common.w" | 337 | #line 1226 "common.w" |
| 337 | 338 | ||
| 338 | show_banner= show_happiness= show_progress= 1; | 339 | show_banner= show_happiness= show_progress= 1; |
| 339 | 340 | ||
| @@ -341,7 +342,7 @@ show_banner= show_happiness= show_progress= 1; · 1 unmodified line | |||
| 341 | #line 93 "common.w" | 342 | #line 93 "common.w" |
| 342 | ; | 343 | ; |
| 343 | /*78:*/ | 344 | /*78:*/ |
| 344 | #line 1373 "common.w" | 345 | #line 1374 "common.w" |
| 345 | 346 | ||
| 346 | scan_args(); | 347 | scan_args(); |
| 347 | if(program==ctangle){ | 348 | if(program==ctangle){ |
| @@ -360,7 +361,7 @@ fatal("! Cannot open output file ",tex_file_name); · 12 unmodified lines | |||
| 360 | } | 361 | } |
| 361 | 362 | ||
| 362 | /*:4*//*9:*/ | 363 | /*:4*//*9:*/ |
| 363 | #line 170 "common.w" | 364 | #line 171 "common.w" |
| 364 | 365 | ||
| 365 | int input_ln(fp) | 366 | int input_ln(fp) |
| 366 | FILE*fp; | 367 | FILE*fp; |
| @@ -382,14 +383,14 @@ return(1); · 15 unmodified lines | |||
| 382 | } | 383 | } |
| 383 | 384 | ||
| 384 | /*:9*//*12:*/ | 385 | /*:9*//*12:*/ |
| 385 | #line 249 "common.w" | 386 | #line 250 "common.w" |
| 386 | 387 | ||
| 387 | void | 388 | void |
| 388 | prime_the_change_buffer() | 389 | prime_the_change_buffer() |
| 389 | { | 390 | { |
| 390 | change_limit= change_buffer; | 391 | change_limit= change_buffer; |
| 391 | /*13:*/ | 392 | /*13:*/ |
| 392 | #line 263 "common.w" | 393 | #line 264 "common.w" |
| 393 | 394 | ||
| 394 | while(1){ | 395 | while(1){ |
| 395 | change_line++; | 396 | change_line++; |
| @@ -406,10 +407,10 @@ err_print("! Missing @x in change file"); · 10 unmodified lines | |||
| 406 | } | 407 | } |
| 407 | 408 | ||
| 408 | /*:13*/ | 409 | /*:13*/ |
| 409 | #line 254 "common.w" | 410 | #line 255 "common.w" |
| 410 | ; | 411 | ; |
| 411 | /*14:*/ | 412 | /*14:*/ |
| 412 | #line 280 "common.w" | 413 | #line 281 "common.w" |
| 413 | 414 | ||
| 414 | do{ | 415 | do{ |
| 415 | change_line++; | 416 | change_line++; |
| @@ -421,10 +422,10 @@ return; · 5 unmodified lines | |||
| 421 | }while(limit==buffer); | 422 | }while(limit==buffer); |
| 422 | 423 | ||
| 423 | /*:14*/ | 424 | /*:14*/ |
| 424 | #line 255 "common.w" | 425 | #line 256 "common.w" |
| 425 | ; | 426 | ; |
| 426 | /*15:*/ | 427 | /*15:*/ |
| 427 | #line 290 "common.w" | 428 | #line 291 "common.w" |
| 428 | 429 | ||
| 429 | { | 430 | { |
| 430 | change_limit= change_buffer-buffer+limit; | 431 | change_limit= change_buffer-buffer+limit; |
| @@ -432,12 +433,12 @@ strncpy(change_buffer,buffer,limit-buffer+1); · 1 unmodified line | |||
| 432 | } | 433 | } |
| 433 | 434 | ||
| 434 | /*:15*/ | 435 | /*:15*/ |
| 435 | #line 256 "common.w" | 436 | #line 257 "common.w" |
| 436 | ; | 437 | ; |
| 437 | } | 438 | } |
| 438 | 439 | ||
| 439 | /*:12*//*16:*/ | 440 | /*:12*//*16:*/ |
| 440 | #line 318 "common.w" | 441 | #line 319 "common.w" |
| 441 | 442 | ||
| 442 | void | 443 | void |
| 443 | check_change() | 444 | check_change() |
| @@ -460,7 +461,7 @@ return; · 16 unmodified lines | |||
| 460 | if(limit>buffer+1&&buffer[0]=='@'){ | 461 | if(limit>buffer+1&&buffer[0]=='@'){ |
| 461 | if(xisupper(buffer[1]))buffer[1]= tolower(buffer[1]); | 462 | if(xisupper(buffer[1]))buffer[1]= tolower(buffer[1]); |
| 462 | /*17:*/ | 463 | /*17:*/ |
| 463 | #line 356 "common.w" | 464 | #line 357 "common.w" |
| 464 | 465 | ||
| 465 | if(buffer[1]=='x'||buffer[1]=='z'){ | 466 | if(buffer[1]=='x'||buffer[1]=='z'){ |
| 466 | loc= buffer+2;err_print("! Where is the matching @y?"); | 467 | loc= buffer+2;err_print("! Where is the matching @y?"); |
| @@ -478,11 +479,11 @@ return; · 11 unmodified lines | |||
| 478 | } | 479 | } |
| 479 | 480 | ||
| 480 | /*:17*/ | 481 | /*:17*/ |
| 481 | #line 340 "common.w" | 482 | #line 341 "common.w" |
| 482 | ; | 483 | ; |
| 483 | } | 484 | } |
| 484 | /*15:*/ | 485 | /*15:*/ |
| 485 | #line 290 "common.w" | 486 | #line 291 "common.w" |
| 486 | 487 | ||
| 487 | { | 488 | { |
| 488 | change_limit= change_buffer-buffer+limit; | 489 | change_limit= change_buffer-buffer+limit; |
| @@ -490,7 +491,7 @@ strncpy(change_buffer,buffer,limit-buffer+1); · 1 unmodified line | |||
| 490 | } | 491 | } |
| 491 | 492 | ||
| 492 | /*:15*/ | 493 | /*:15*/ |
| 493 | #line 342 "common.w" | 494 | #line 343 "common.w" |
| 494 | ; | 495 | ; |
| 495 | changing= 0;cur_line++; | 496 | changing= 0;cur_line++; |
| 496 | while(!input_ln(cur_file)){ | 497 | while(!input_ln(cur_file)){ |
| @@ -506,14 +507,14 @@ if(lines_dont_match)n++; · 9 unmodified lines | |||
| 506 | } | 507 | } |
| 507 | 508 | ||
| 508 | /*:16*//*18:*/ | 509 | /*:16*//*18:*/ |
| 509 | #line 376 "common.w" | 510 | #line 377 "common.w" |
| 510 | 511 | ||
| 511 | void | 512 | void |
| 512 | reset_input() | 513 | reset_input() |
| 513 | { | 514 | { |
| 514 | limit= buffer;loc= buffer+1;buffer[0]= ' '; | 515 | limit= buffer;loc= buffer+1;buffer[0]= ' '; |
| 515 | /*19:*/ | 516 | /*19:*/ |
| 516 | #line 391 "common.w" | 517 | #line 392 "common.w" |
| 517 | 518 | ||
| 518 | if((web_file= fopen(web_file_name,"r"))==NULL){ | 519 | if((web_file= fopen(web_file_name,"r"))==NULL){ |
| 519 | strcpy(web_file_name,alt_web_file_name); | 520 | strcpy(web_file_name,alt_web_file_name); |
| @@ -527,7 +528,7 @@ if((change_file= fopen(change_file_name,"r"))==NULL) · 7 unmodified lines | |||
| 527 | fatal("! Cannot open change file ",change_file_name); | 528 | fatal("! Cannot open change file ",change_file_name); |
| 528 | 529 | ||
| 529 | /*:19*/ | 530 | /*:19*/ |
| 530 | #line 381 "common.w" | 531 | #line 382 "common.w" |
| 531 | ; | 532 | ; |
| 532 | include_depth= 0;cur_line= 0;change_line= 0; | 533 | include_depth= 0;cur_line= 0;change_line= 0; |
| 533 | change_depth= include_depth; | 534 | change_depth= include_depth; |
| @@ -536,14 +537,14 @@ limit= buffer;loc= buffer+1;buffer[0]= ' ';input_has_ended= 0; · 2 unmodified lines | |||
| 536 | } | 537 | } |
| 537 | 538 | ||
| 538 | /*:18*//*21:*/ | 539 | /*:18*//*21:*/ |
| 539 | #line 424 "common.w" | 540 | #line 425 "common.w" |
| 540 | 541 | ||
| 541 | int get_line() | 542 | int get_line() |
| 542 | { | 543 | { |
| 543 | restart: | 544 | restart: |
| 544 | if(changing&&include_depth==change_depth) | 545 | if(changing&&include_depth==change_depth) |
| 545 | /*25:*/ | 546 | /*25:*/ |
| 546 | #line 529 "common.w" | 547 | #line 530 "common.w" |
| 547 | { | 548 | { |
| 548 | change_line++; | 549 | change_line++; |
| 549 | if(!input_ln(change_file)){ | 550 | if(!input_ln(change_file)){ |
| @@ -574,11 +575,11 @@ prime_the_change_buffer();changing= !changing;print_where= 1; · 24 unmodified lines | |||
| 574 | } | 575 | } |
| 575 | 576 | ||
| 576 | /*:25*/ | 577 | /*:25*/ |
| 577 | #line 429 "common.w" | 578 | #line 430 "common.w" |
| 578 | ; | 579 | ; |
| 579 | if(!changing||include_depth>change_depth){ | 580 | if(!changing||include_depth>change_depth){ |
| 580 | /*24:*/ | 581 | /*24:*/ |
| 581 | #line 512 "common.w" | 582 | #line 513 "common.w" |
| 582 | { | 583 | { |
| 583 | cur_line++; | 584 | cur_line++; |
| 584 | while(!input_ln(cur_file)){ | 585 | while(!input_ln(cur_file)){ |
| @@ -597,7 +598,7 @@ if(change_limit>change_buffer)check_change(); · 12 unmodified lines | |||
| 597 | } | 598 | } |
| 598 | 599 | ||
| 599 | /*:24*/ | 600 | /*:24*/ |
| 600 | #line 431 "common.w" | 601 | #line 432 "common.w" |
| 601 | ; | 602 | ; |
| 602 | if(changing&&include_depth==change_depth)goto restart; | 603 | if(changing&&include_depth==change_depth)goto restart; |
| 603 | } | 604 | } |
| @@ -617,7 +618,7 @@ goto restart; · 13 unmodified lines | |||
| 617 | } | 618 | } |
| 618 | include_depth++; | 619 | include_depth++; |
| 619 | /*23:*/ | 620 | /*23:*/ |
| 620 | #line 471 "common.w" | 621 | #line 472 "common.w" |
| 621 | { | 622 | { |
| 622 | char temp_file_name[max_file_name_length]; | 623 | char temp_file_name[max_file_name_length]; |
| 623 | char*cur_file_name_end= cur_file_name+max_file_name_length-1; | 624 | char*cur_file_name_end= cur_file_name+max_file_name_length-1; |
| @@ -660,14 +661,14 @@ include_depth--;err_print("! Cannot open include file");goto restart; · 36 unmodified lines | |||
| 660 | } | 661 | } |
| 661 | 662 | ||
| 662 | /*:23*/ | 663 | /*:23*/ |
| 663 | #line 449 "common.w" | 664 | #line 450 "common.w" |
| 664 | ; | 665 | ; |
| 665 | } | 666 | } |
| 666 | return(!input_has_ended); | 667 | return(!input_has_ended); |
| 667 | } | 668 | } |
| 668 | 669 | ||
| 669 | /*:21*//*26:*/ | 670 | /*:21*//*26:*/ |
| 670 | #line 561 "common.w" | 671 | #line 562 "common.w" |
| 671 | 672 | ||
| 672 | void | 673 | void |
| 673 | check_complete(){ | 674 | check_complete(){ |
| @@ -681,7 +682,7 @@ err_print("! Change file entry did not match"); · 7 unmodified lines | |||
| 681 | } | 682 | } |
| 682 | 683 | ||
| 683 | /*:26*//*35:*/ | 684 | /*:26*//*35:*/ |
| 684 | #line 652 "common.w" | 685 | #line 653 "common.w" |
| 685 | 686 | ||
| 686 | name_pointer | 687 | name_pointer |
| 687 | id_lookup(first,last,t) | 688 | id_lookup(first,last,t) |
| @@ -696,17 +697,17 @@ name_pointer p; · 8 unmodified lines | |||
| 696 | if(last==NULL)for(last= first;*last!='\0';last++); | 697 | if(last==NULL)for(last= first;*last!='\0';last++); |
| 697 | l= last-first; | 698 | l= last-first; |
| 698 | /*36:*/ | 699 | /*36:*/ |
| 699 | #line 675 "common.w" | 700 | #line 676 "common.w" |
| 700 | 701 | ||
| 701 | h= (unsigned char)*i; | 702 | h= (unsigned char)*i; |
| 702 | while(++i<last)h= (h+h+(int)((unsigned char)*i))%hash_size; | 703 | while(++i<last)h= (h+h+(int)((unsigned char)*i))%hash_size; |
| 703 | 704 | ||
| 704 | 705 | ||
| 705 | /*:36*/ | 706 | /*:36*/ |
| 706 | #line 665 "common.w" | 707 | #line 666 "common.w" |
| 707 | ; | 708 | ; |
| 708 | /*37:*/ | 709 | /*37:*/ |
| 709 | #line 683 "common.w" | 710 | #line 684 "common.w" |
| 710 | 711 | ||
| 711 | p= hash[h]; | 712 | p= hash[h]; |
| 712 | while(p&&!names_match(p,first,l,t))p= p->link; | 713 | while(p&&!names_match(p,first,l,t))p= p->link; |
| @@ -716,10 +717,10 @@ p->link= hash[h];hash[h]= p; · 3 unmodified lines | |||
| 716 | } | 717 | } |
| 717 | 718 | ||
| 718 | /*:37*/ | 719 | /*:37*/ |
| 719 | #line 666 "common.w" | 720 | #line 667 "common.w" |
| 720 | ; | 721 | ; |
| 721 | if(p==name_ptr)/*39:*/ | 722 | if(p==name_ptr)/*39:*/ |
| 722 | #line 698 "common.w" | 723 | #line 699 "common.w" |
| 723 | { | 724 | { |
| 724 | if(byte_ptr+l>byte_mem_end)overflow("byte memory"); | 725 | if(byte_ptr+l>byte_mem_end)overflow("byte memory"); |
| 725 | if(name_ptr>=name_dir_end)overflow("name"); | 726 | if(name_ptr>=name_dir_end)overflow("name"); |
| @@ -729,13 +730,13 @@ if(program==cweave)init_p(p,t); · 3 unmodified lines | |||
| 729 | } | 730 | } |
| 730 | 731 | ||
| 731 | /*:39*/ | 732 | /*:39*/ |
| 732 | #line 667 "common.w" | 733 | #line 668 "common.w" |
| 733 | ; | 734 | ; |
| 734 | return(p); | 735 | return(p); |
| 735 | } | 736 | } |
| 736 | 737 | ||
| 737 | /*:35*//*42:*/ | 738 | /*:35*//*42:*/ |
| 738 | #line 756 "common.w" | 739 | #line 757 "common.w" |
| 739 | 740 | ||
| 740 | void | 741 | void |
| 741 | print_section_name(p) | 742 | print_section_name(p) |
| @@ -756,7 +757,7 @@ if(q)term_write("...",3); · 14 unmodified lines | |||
| 756 | } | 757 | } |
| 757 | 758 | ||
| 758 | /*:42*//*43:*/ | 759 | /*:42*//*43:*/ |
| 759 | #line 775 "common.w" | 760 | #line 776 "common.w" |
| 760 | 761 | ||
| 761 | void | 762 | void |
| 762 | sprint_section_name(dest,p) | 763 | sprint_section_name(dest,p) |
| @@ -779,7 +780,7 @@ s= p->byte_start; · 16 unmodified lines | |||
| 779 | } | 780 | } |
| 780 | 781 | ||
| 781 | /*:43*//*44:*/ | 782 | /*:43*//*44:*/ |
| 782 | #line 796 "common.w" | 783 | #line 797 "common.w" |
| 783 | 784 | ||
| 784 | void | 785 | void |
| 785 | print_prefix_name(p) | 786 | print_prefix_name(p) |
| @@ -792,7 +793,7 @@ if(s+l<(p+1)->byte_start)term_write("...",3); · 6 unmodified lines | |||
| 792 | } | 793 | } |
| 793 | 794 | ||
| 794 | /*:44*//*45:*/ | 795 | /*:44*//*45:*/ |
| 795 | #line 817 "common.w" | 796 | #line 818 "common.w" |
| 796 | 797 | ||
| 797 | int web_strcmp(j,j_len,k,k_len) | 798 | int web_strcmp(j,j_len,k,k_len) |
| 798 | char*j,*k; | 799 | char*j,*k; |
| @@ -808,7 +809,7 @@ else return greater; · 9 unmodified lines | |||
| 808 | } | 809 | } |
| 809 | 810 | ||
| 810 | /*:45*//*47:*/ | 811 | /*:45*//*47:*/ |
| 811 | #line 847 "common.w" | 812 | #line 848 "common.w" |
| 812 | 813 | ||
| 813 | name_pointer | 814 | name_pointer |
| 814 | add_section_name(par,c,first,last,ispref) | 815 | add_section_name(par,c,first,last,ispref) |
| @@ -839,7 +840,7 @@ return par==NULL?(root= p):c==less?(par->llink= p):(par->rlink= p); · 24 unmodified lines | |||
| 839 | } | 840 | } |
| 840 | 841 | ||
| 841 | /*:47*//*48:*/ | 842 | /*:47*//*48:*/ |
| 842 | #line 876 "common.w" | 843 | #line 877 "common.w" |
| 843 | 844 | ||
| 844 | void | 845 | void |
| 845 | extend_section_name(p,first,last,ispref) | 846 | extend_section_name(p,first,last,ispref) |
| @@ -863,7 +864,7 @@ if(ispref)*(byte_ptr-1)= ' '; · 17 unmodified lines | |||
| 863 | } | 864 | } |
| 864 | 865 | ||
| 865 | /*:48*//*49:*/ | 866 | /*:48*//*49:*/ |
| 866 | #line 904 "common.w" | 867 | #line 905 "common.w" |
| 867 | 868 | ||
| 868 | name_pointer | 869 | name_pointer |
| 869 | section_lookup(first,last,ispref) | 870 | section_lookup(first,last,ispref) |
| @@ -878,7 +879,7 @@ name_pointer par= NULL; · 8 unmodified lines | |||
| 878 | 879 | ||
| 879 | int name_len= last-first+1; | 880 | int name_len= last-first+1; |
| 880 | /*50:*/ | 881 | /*50:*/ |
| 881 | #line 928 "common.w" | 882 | #line 929 "common.w" |
| 882 | 883 | ||
| 883 | while(p){ | 884 | while(p){ |
| 884 | c= web_strcmp(first,name_len,first_chunk(p),prefix_length(p)); | 885 | c= web_strcmp(first,name_len,first_chunk(p),prefix_length(p)); |
| @@ -905,19 +906,19 @@ p= q,q= NULL; · 20 unmodified lines | |||
| 905 | } | 906 | } |
| 906 | 907 | ||
| 907 | /*:50*/ | 908 | /*:50*/ |
| 908 | #line 918 "common.w" | 909 | #line 919 "common.w" |
| 909 | ; | 910 | ; |
| 910 | /*51:*/ | 911 | /*51:*/ |
| 911 | #line 953 "common.w" | 912 | #line 954 "common.w" |
| 912 | 913 | ||
| 913 | if(r==NULL) | 914 | if(r==NULL) |
| 914 | return add_section_name(par,c,first,last+1,ispref); | 915 | return add_section_name(par,c,first,last+1,ispref); |
| 915 | 916 | ||
| 916 | /*:51*/ | 917 | /*:51*/ |
| 917 | #line 919 "common.w" | 918 | #line 920 "common.w" |
| 918 | ; | 919 | ; |
| 919 | /*52:*/ | 920 | /*52:*/ |
| 920 | #line 961 "common.w" | 921 | #line 962 "common.w" |
| 921 | 922 | ||
| 922 | switch(section_name_cmp(&first,name_len,r)){ | 923 | switch(section_name_cmp(&first,name_len,r)){ |
| 923 | 924 | ||
| @@ -951,12 +952,12 @@ return r; · 27 unmodified lines | |||
| 951 | } | 952 | } |
| 952 | 953 | ||
| 953 | /*:52*/ | 954 | /*:52*/ |
| 954 | #line 920 "common.w" | 955 | #line 921 "common.w" |
| 955 | ; | 956 | ; |
| 956 | } | 957 | } |
| 957 | 958 | ||
| 958 | /*:49*//*54:*/ | 959 | /*:49*//*54:*/ |
| 959 | #line 1012 "common.w" | 960 | #line 1013 "common.w" |
| 960 | 961 | ||
| 961 | int section_name_cmp(pfirst,len,r) | 962 | int section_name_cmp(pfirst,len,r) |
| 962 | char**pfirst; | 963 | char**pfirst; |
| @@ -990,7 +991,7 @@ default:return c; · 27 unmodified lines | |||
| 990 | } | 991 | } |
| 991 | 992 | ||
| 992 | /*:54*//*58:*/ | 993 | /*:54*//*58:*/ |
| 993 | #line 1087 "common.w" | 994 | #line 1088 "common.w" |
| 994 | 995 | ||
| 995 | void | 996 | void |
| 996 | err_print(s) | 997 | err_print(s) |
| @@ -999,7 +1000,7 @@ char*s; · 2 unmodified lines | |||
| 999 | char*k,*l; | 1000 | char*k,*l; |
| 1000 | printf(*s=='!'?"\n%s":"%s",s); | 1001 | printf(*s=='!'?"\n%s":"%s",s); |
| 1001 | if(web_file_open)/*59:*/ | 1002 | if(web_file_open)/*59:*/ |
| 1002 | #line 1107 "common.w" | 1003 | #line 1108 "common.w" |
| 1003 | 1004 | ||
| 1004 | {if(changing&&include_depth==change_depth) | 1005 | {if(changing&&include_depth==change_depth) |
| 1005 | printf(". (l. %d of change file)\n",change_line); | 1006 | printf(". (l. %d of change file)\n",change_line); |
| @@ -1019,20 +1020,20 @@ putchar(' '); · 13 unmodified lines | |||
| 1019 | } | 1020 | } |
| 1020 | 1021 | ||
| 1021 | /*:59*/ | 1022 | /*:59*/ |
| 1022 | #line 1094 "common.w" | 1023 | #line 1095 "common.w" |
| 1023 | ; | 1024 | ; |
| 1024 | update_terminal;mark_error; | 1025 | update_terminal;mark_error; |
| 1025 | } | 1026 | } |
| 1026 | 1027 | ||
| 1027 | /*:58*//*61:*/ | 1028 | /*:58*//*61:*/ |
| 1028 | #line 1142 "common.w" | 1029 | #line 1143 "common.w" |
| 1029 | 1030 | ||
| 1030 | int wrap_up(){ | 1031 | int wrap_up(){ |
| 1031 | putchar('\n'); | 1032 | putchar('\n'); |
| 1032 | if(show_stats) | 1033 | if(show_stats) |
| 1033 | print_stats(); | 1034 | print_stats(); |
| 1034 | /*62:*/ | 1035 | /*62:*/ |
| 1035 | #line 1152 "common.w" | 1036 | #line 1153 "common.w" |
| 1036 | 1037 | ||
| 1037 | switch(history){ | 1038 | switch(history){ |
| 1038 | case spotless:if(show_happiness)printf("(No errors were found.)\n");break; | 1039 | case spotless:if(show_happiness)printf("(No errors were found.)\n");break; |
| @@ -1044,14 +1045,14 @@ case fatal_message:printf("(That was a fatal error, my friend.)\n"); · 5 unmodified lines | |||
| 1044 | } | 1045 | } |
| 1045 | 1046 | ||
| 1046 | /*:62*/ | 1047 | /*:62*/ |
| 1047 | #line 1147 "common.w" | 1048 | #line 1148 "common.w" |
| 1048 | ; | 1049 | ; |
| 1049 | if(history>harmless_message)return(1); | 1050 | if(history>harmless_message)return(1); |
| 1050 | else return(0); | 1051 | else return(0); |
| 1051 | } | 1052 | } |
| 1052 | 1053 | ||
| 1053 | /*:61*//*64:*/ | 1054 | /*:61*//*64:*/ |
| 1054 | #line 1171 "common.w" | 1055 | #line 1172 "common.w" |
| 1055 | void | 1056 | void |
| 1056 | fatal(s,t) | 1057 | fatal(s,t) |
| 1057 | char*s,*t; | 1058 | char*s,*t; |
| @@ -1062,7 +1063,7 @@ history= fatal_message;exit(wrap_up()); · 4 unmodified lines | |||
| 1062 | } | 1063 | } |
| 1063 | 1064 | ||
| 1064 | /*:64*//*65:*/ | 1065 | /*:64*//*65:*/ |
| 1065 | #line 1182 "common.w" | 1066 | #line 1183 "common.w" |
| 1066 | void | 1067 | void |
| 1067 | overflow(t) | 1068 | overflow(t) |
| 1068 | char*t; | 1069 | char*t; |
| @@ -1072,7 +1073,7 @@ printf("\n! Sorry, %s capacity exceeded",t);fatal("",""); · 3 unmodified lines | |||
| 1072 | 1073 | ||
| 1073 | 1074 | ||
| 1074 | /*:65*//*70:*/ | 1075 | /*:65*//*70:*/ |
| 1075 | #line 1246 "common.w" | 1076 | #line 1247 "common.w" |
| 1076 | 1077 | ||
| 1077 | void | 1078 | void |
| 1078 | scan_args() | 1079 | scan_args() |
| @@ -1086,7 +1087,7 @@ boolean flag_change; · 7 unmodified lines | |||
| 1086 | 1087 | ||
| 1087 | while(--argc>0){ | 1088 | while(--argc>0){ |
| 1088 | if((**(++argv)=='-'||**argv=='+')&&*(*argv+1))/*74:*/ | 1089 | if((**(++argv)=='-'||**argv=='+')&&*(*argv+1))/*74:*/ |
| 1089 | #line 1340 "common.w" | 1090 | #line 1341 "common.w" |
| 1090 | 1091 | ||
| 1091 | { | 1092 | { |
| 1092 | if(**argv=='-')flag_change= 0; | 1093 | if(**argv=='-')flag_change= 0; |
| @@ -1096,7 +1097,7 @@ flags[*dot_pos]= flag_change; · 3 unmodified lines | |||
| 1096 | } | 1097 | } |
| 1097 | 1098 | ||
| 1098 | /*:74*/ | 1099 | /*:74*/ |
| 1099 | #line 1258 "common.w" | 1100 | #line 1259 "common.w" |
| 1100 | 1101 | ||
| 1101 | else{ | 1102 | else{ |
| 1102 | s= name_pos= *argv;dot_pos= NULL; | 1103 | s= name_pos= *argv;dot_pos= NULL; |
| @@ -1106,17 +1107,17 @@ else if(*s=='/')dot_pos= NULL,name_pos= ++s; · 3 unmodified lines | |||
| 1106 | else s++; | 1107 | else s++; |
| 1107 | } | 1108 | } |
| 1108 | if(!found_web)/*71:*/ | 1109 | if(!found_web)/*71:*/ |
| 1109 | #line 1284 "common.w" | 1110 | #line 1285 "common.w" |
| 1110 | 1111 | ||
| 1111 | { | 1112 | { |
| 1112 | if(s-*argv>max_file_name_length-5) | 1113 | if(s-*argv>max_file_name_length-5) |
| 1113 | /*76:*/ | 1114 | /*76:*/ |
| 1114 | #line 1360 "common.w" | 1115 | #line 1361 "common.w" |
| 1115 | fatal("! Filename too long\n",*argv); | 1116 | fatal("! Filename too long\n",*argv); |
| 1116 | 1117 | ||
| 1117 | 1118 | ||
| 1118 | /*:76*/ | 1119 | /*:76*/ |
| 1119 | #line 1287 "common.w" | 1120 | #line 1288 "common.w" |
| 1120 | ; | 1121 | ; |
| 1121 | if(dot_pos==NULL) | 1122 | if(dot_pos==NULL) |
| 1122 | sprintf(web_file_name,"%s.w",*argv); | 1123 | sprintf(web_file_name,"%s.w",*argv); |
| @@ -1133,22 +1134,22 @@ found_web= 1; · 10 unmodified lines | |||
| 1133 | } | 1134 | } |
| 1134 | 1135 | ||
| 1135 | /*:71*/ | 1136 | /*:71*/ |
| 1136 | #line 1267 "common.w" | 1137 | #line 1268 "common.w" |
| 1137 | 1138 | ||
| 1138 | else if(!found_change)/*72:*/ | 1139 | else if(!found_change)/*72:*/ |
| 1139 | #line 1302 "common.w" | 1140 | #line 1303 "common.w" |
| 1140 | 1141 | ||
| 1141 | { | 1142 | { |
| 1142 | if(strcmp(*argv,"-")==0)found_change= -1; | 1143 | if(strcmp(*argv,"-")==0)found_change= -1; |
| 1143 | else{ | 1144 | else{ |
| 1144 | if(s-*argv>max_file_name_length-4) | 1145 | if(s-*argv>max_file_name_length-4) |
| 1145 | /*76:*/ | 1146 | /*76:*/ |
| 1146 | #line 1360 "common.w" | 1147 | #line 1361 "common.w" |
| 1147 | fatal("! Filename too long\n",*argv); | 1148 | fatal("! Filename too long\n",*argv); |
| 1148 | 1149 | ||
| 1149 | 1150 | ||
| 1150 | /*:76*/ | 1151 | /*:76*/ |
| 1151 | #line 1307 "common.w" | 1152 | #line 1308 "common.w" |
| 1152 | ; | 1153 | ; |
| 1153 | if(dot_pos==NULL) | 1154 | if(dot_pos==NULL) |
| 1154 | sprintf(change_file_name,"%s.ch",*argv); | 1155 | sprintf(change_file_name,"%s.ch",*argv); |
| @@ -1158,20 +1159,20 @@ found_change= 1; · 3 unmodified lines | |||
| 1158 | } | 1159 | } |
| 1159 | 1160 | ||
| 1160 | /*:72*/ | 1161 | /*:72*/ |
| 1161 | #line 1268 "common.w" | 1162 | #line 1269 "common.w" |
| 1162 | 1163 | ||
| 1163 | else if(!found_out)/*73:*/ | 1164 | else if(!found_out)/*73:*/ |
| 1164 | #line 1315 "common.w" | 1165 | #line 1316 "common.w" |
| 1165 | 1166 | ||
| 1166 | { | 1167 | { |
| 1167 | if(s-*argv>max_file_name_length-5) | 1168 | if(s-*argv>max_file_name_length-5) |
| 1168 | /*76:*/ | 1169 | /*76:*/ |
| 1169 | #line 1360 "common.w" | 1170 | #line 1361 "common.w" |
| 1170 | fatal("! Filename too long\n",*argv); | 1171 | fatal("! Filename too long\n",*argv); |
| 1171 | 1172 | ||
| 1172 | 1173 | ||
| 1173 | /*:76*/ | 1174 | /*:76*/ |
| 1174 | #line 1318 "common.w" | 1175 | #line 1319 "common.w" |
| 1175 | ; | 1176 | ; |
| 1176 | if(dot_pos==NULL){ | 1177 | if(dot_pos==NULL){ |
| 1177 | sprintf(tex_file_name,"%s.tex",*argv); | 1178 | sprintf(tex_file_name,"%s.tex",*argv); |
| @@ -1195,10 +1196,10 @@ found_out= 1; · 17 unmodified lines | |||
| 1195 | } | 1196 | } |
| 1196 | 1197 | ||
| 1197 | /*:73*/ | 1198 | /*:73*/ |
| 1198 | #line 1269 "common.w" | 1199 | #line 1270 "common.w" |
| 1199 | 1200 | ||
| 1200 | else/*75:*/ | 1201 | else/*75:*/ |
| 1201 | #line 1348 "common.w" | 1202 | #line 1349 "common.w" |
| 1202 | 1203 | ||
| 1203 | { | 1204 | { |
| 1204 | if(program==ctangle) | 1205 | if(program==ctangle) |
| @@ -1212,12 +1213,12 @@ else fatal( · 7 unmodified lines | |||
| 1212 | } | 1213 | } |
| 1213 | 1214 | ||
| 1214 | /*:75*/ | 1215 | /*:75*/ |
| 1215 | #line 1270 "common.w" | 1216 | #line 1271 "common.w" |
| 1216 | ; | 1217 | ; |
| 1217 | } | 1218 | } |
| 1218 | } | 1219 | } |
| 1219 | if(!found_web)/*75:*/ | 1220 | if(!found_web)/*75:*/ |
| 1220 | #line 1348 "common.w" | 1221 | #line 1349 "common.w" |
| 1221 | 1222 | ||
| 1222 | { | 1223 | { |
| 1223 | if(program==ctangle) | 1224 | if(program==ctangle) |
| @@ -1231,7 +1232,7 @@ else fatal( · 7 unmodified lines | |||
| 1231 | } | 1232 | } |
| 1232 | 1233 | ||
| 1233 | /*:75*/ | 1234 | /*:75*/ |
| 1234 | #line 1273 "common.w" | 1235 | #line 1274 "common.w" |
| 1235 | ; | 1236 | ; |
| 1236 | if(found_change<=0)strcpy(change_file_name,"/dev/null"); | 1237 | if(found_change<=0)strcpy(change_file_name,"/dev/null"); |
| 1237 | } | 1238 | } |
| @@ -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.1 --- November 1993 (works with later versions too) | 5 | % Version 3.3 --- December 1994 (works with later versions too) |
| 6 | 6 | ||
| 7 | % Copyright (C) 1987,1990,1993 Silvio Levy and Donald E. Knuth | 7 | % Copyright (C) 1987,1990,1993 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.1)} | 20 | \def\title{Common code for CTANGLE and CWEAVE (Version 3.3)} |
| 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.1)} | 25 | \centerline{(Version 3.3)} |
| 26 | \vfill} | 26 | \vfill} |
| 27 | \def\botofcontents{\vfill | 27 | \def\botofcontents{\vfill |
| 28 | \noindent | 28 | \noindent |
| @@ -105,7 +105,7 @@ common_init() · 76 unmodified lines | |||
| 105 | using the definitions below. These definitions are consistent with | 105 | using the definitions below. These definitions are consistent with |
| 106 | an extension of ASCII code originally developed at MIT and explained in | 106 | an extension of ASCII code originally developed at MIT and explained in |
| 107 | Appendix~C of {\sl The \TEX/book\/}; thus, users who have such a | 107 | Appendix~C of {\sl The \TEX/book\/}; thus, users who have such a |
| 108 | character set can type things like \.{\char'32} and \.{char'4} instead | 108 | character set can type things like \.{\char'32} and \.{\char'4} instead |
| 109 | of \.{!=} and \.{\&\&}. (However, their files will not be too portable | 109 | of \.{!=} and \.{\&\&}. (However, their files will not be too portable |
| 110 | until more people adopt the extended code.) | 110 | until more people adopt the extended code.) |
| 111 | 111 | ||
| @@ -150,7 +150,8 @@ some of \.{CWEB}'s routines use the fact that it is safe to refer to · 38 unmodified lines | |||
| 150 | |*(limit+2)| without overstepping the bounds of the array. | 150 | |*(limit+2)| without overstepping the bounds of the array. |
| 151 | 151 | ||
| 152 | @d buf_size 100 /* for \.{CWEAVE} and \.{CTANGLE} */ | 152 | @d buf_size 100 /* for \.{CWEAVE} and \.{CTANGLE} */ |
| 153 | @d long_buf_size 500 /* for \.{CWEAVE} */ | 153 | @d longest_name 1000 |
| 154 | @d long_buf_size (buf_size+longest_name) /* for \.{CWEAVE} */ | ||
| 154 | @d xisspace(c) (isspace(c)&&((unsigned char)c<0200)) | 155 | @d xisspace(c) (isspace(c)&&((unsigned char)c<0200)) |
| 155 | @d xisupper(c) (isupper(c)&&((unsigned char)c<0200)) | 156 | @d xisupper(c) (isupper(c)&&((unsigned char)c<0200)) |
| 156 | 157 | ||
| @@ -897,7 +898,7 @@ int ispref; /* are we adding a prefix or a full name? */ · 740 unmodified lines | |||
| 897 | 898 | ||
| 898 | @ The |section_lookup| procedure is supposed to find a | 899 | @ The |section_lookup| procedure is supposed to find a |
| 899 | section name that matches a new name, installing the new name if | 900 | section name that matches a new name, installing the new name if |
| 900 | its doesn't match an existing one. The new name is the string | 901 | it doesn't match an existing one. The new name is the string |
| 901 | between |first| and |last|; a ``match'' means that the new name | 902 | between |first| and |last|; a ``match'' means that the new name |
| 902 | exactly equals or is a prefix or extension of a name in the tree. | 903 | exactly equals or is a prefix or extension of a name in the tree. |
| 903 | 904 | ||
| @@ -1079,7 +1080,7 @@ the user, by printing the error message at the beginning of a new line and · 175 unmodified lines | |||
| 1079 | then giving an indication of where the error was spotted in the source file. | 1080 | then giving an indication of where the error was spotted in the source file. |
| 1080 | Note that no period follows the error message, since the error routine | 1081 | Note that no period follows the error message, since the error routine |
| 1081 | will automatically supply a period. A newline is automatically supplied | 1082 | will automatically supply a period. A newline is automatically supplied |
| 1082 | if the string begins with |"|"|. | 1083 | if the string begins with |"!"|. |
| 1083 | 1084 | ||
| 1084 | @<Predecl...@>= | 1085 | @<Predecl...@>= |
| 1085 | void err_print(); | 1086 | void err_print(); |
| @@ -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.2)\n" | 20 | @d banner "This is CTANGLE (Version 3.3)\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.2pc/big)\n" | 25 | @d banner "This is CTANGLE (Version 3.3pc/big)\n" |
| 26 | @z | 26 | @z |
| 27 | 27 | ||
| 28 | 28 | ||
| @@ -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.2)\n" | 12 | @d banner "This is CTANGLE (Version 3.3)\n" |
| 13 | @y | 13 | @y |
| 14 | @d banner "This is CTANGLE (Version 3.2pc)\n" | 14 | @d banner "This is CTANGLE (Version 3.3pc)\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, |
| @@ -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.2)\n" | 13 | @d banner "This is CTANGLE (Version 3.3)\n" |
| 14 | @y | 14 | @y |
| 15 | @d banner "This is CTANGLE (VAX/VMS Version 3.2)\n" | 15 | @d banner "This is CTANGLE (VAX/VMS Version 3.3)\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) |
| @@ -7,7 +7,7 @@ · 6 unmodified lines | |||
| 7 | #include <stdio.h> | 7 | #include <stdio.h> |
| 8 | 8 | ||
| 9 | /*:6*//*62:*/ | 9 | /*:6*//*62:*/ |
| 10 | #line 874 "ctangle.w" | 10 | #line 875 "ctangle.w" |
| 11 | 11 | ||
| 12 | #include <ctype.h> | 12 | #include <ctype.h> |
| 13 | #include <stdlib.h> | 13 | #include <stdlib.h> |
| @@ -15,7 +15,7 @@ · 1 unmodified line | |||
| 15 | /*:62*/ | 15 | /*:62*/ |
| 16 | #line 62 "ctangle.w" | 16 | #line 62 "ctangle.w" |
| 17 | 17 | ||
| 18 | #define banner "This is CTANGLE (Version 3.2)\n" \ | 18 | #define banner "This is CTANGLE (Version 3.3)\n" \ |
| 19 | 19 | ||
| 20 | #define max_bytes 90000 \ | 20 | #define max_bytes 90000 \ |
| 21 | 21 | ||
| @@ -47,15 +47,15 @@ · 25 unmodified lines | |||
| 47 | #define period_ast 026 | 47 | #define period_ast 026 |
| 48 | #define minus_gt_ast 027 \ | 48 | #define minus_gt_ast 027 \ |
| 49 | 49 | ||
| 50 | #define xisalpha(c)(isalpha(c)&&((eight_bits)c<0200)) | 50 | #define xisalpha(c) (isalpha(c) &&((eight_bits) c<0200) ) |
| 51 | #define xisdigit(c)(isdigit(c)&&((eight_bits)c<0200)) | 51 | #define xisdigit(c) (isdigit(c) &&((eight_bits) c<0200) ) |
| 52 | #define xisspace(c)(isspace(c)&&((eight_bits)c<0200)) | 52 | #define xisspace(c) (isspace(c) &&((eight_bits) c<0200) ) |
| 53 | #define xislower(c)(islower(c)&&((eight_bits)c<0200)) | 53 | #define xislower(c) (islower(c) &&((eight_bits) c<0200) ) |
| 54 | #define xisupper(c)(isupper(c)&&((eight_bits)c<0200)) | 54 | #define xisupper(c) (isupper(c) &&((eight_bits) c<0200) ) |
| 55 | #define xisxdigit(c)(isxdigit(c)&&((eight_bits)c<0200)) \ | 55 | #define xisxdigit(c) (isxdigit(c) &&((eight_bits) c<0200) ) \ |
| 56 | 56 | ||
| 57 | #define length(c)(c+1)->byte_start-(c)->byte_start | 57 | #define length(c) (c+1) ->byte_start-(c) ->byte_start |
| 58 | #define print_id(c)term_write((c)->byte_start,length((c))) | 58 | #define print_id(c) term_write((c) ->byte_start,length((c) ) ) |
| 59 | #define llink link | 59 | #define llink link |
| 60 | #define rlink dummy.Rlink | 60 | #define rlink dummy.Rlink |
| 61 | #define root name_dir->rlink \ | 61 | #define root name_dir->rlink \ |
| @@ -66,9 +66,9 @@ · 4 unmodified lines | |||
| 66 | #define harmless_message 1 | 66 | #define harmless_message 1 |
| 67 | #define error_message 2 | 67 | #define error_message 2 |
| 68 | #define fatal_message 3 | 68 | #define fatal_message 3 |
| 69 | #define mark_harmless {if(history==spotless)history= harmless_message;} | 69 | #define mark_harmless {if(history==spotless) history= harmless_message;} |
| 70 | #define mark_error history= error_message | 70 | #define mark_error history= error_message |
| 71 | #define confusion(s)fatal("! This can't happen: ",s) \ | 71 | #define confusion(s) fatal("! This can't happen: ",s) \ |
| 72 | 72 | ||
| 73 | #define max_file_name_length 60 | 73 | #define max_file_name_length 60 |
| 74 | #define cur_file file[include_depth] | 74 | #define cur_file file[include_depth] |
| @@ -80,12 +80,12 @@ · 5 unmodified lines | |||
| 80 | #define show_progress flags['p'] | 80 | #define show_progress flags['p'] |
| 81 | #define show_happiness flags['h'] \ | 81 | #define show_happiness flags['h'] \ |
| 82 | 82 | ||
| 83 | #define update_terminal fflush(stdout) | 83 | #define update_terminal fflush(stdout) |
| 84 | #define new_line putchar('\n') | 84 | #define new_line putchar('\n') |
| 85 | #define putxchar putchar | 85 | #define putxchar putchar |
| 86 | #define term_write(a,b)fflush(stdout),fwrite(a,sizeof(char),b,stdout) | 86 | #define term_write(a,b) fflush(stdout) ,fwrite(a,sizeof(char) ,b,stdout) |
| 87 | #define C_printf(c,a)fprintf(C_file,c,a) | 87 | #define C_printf(c,a) fprintf(C_file,c,a) |
| 88 | #define C_putc(c)putc(c,C_file) \ | 88 | #define C_putc(c) putc(c,C_file) \ |
| 89 | 89 | ||
| 90 | #define equiv equiv_or_xref \ | 90 | #define equiv equiv_or_xref \ |
| 91 | 91 | ||
| @@ -93,7 +93,7 @@ · 1 unmodified line | |||
| 93 | 93 | ||
| 94 | #define string 02 | 94 | #define string 02 |
| 95 | #define join 0177 | 95 | #define join 0177 |
| 96 | #define output_defs_flag (2*024000-1) \ | 96 | #define output_defs_flag (2*024000-1) \ |
| 97 | 97 | ||
| 98 | #define cur_end cur_state.end_field | 98 | #define cur_end cur_state.end_field |
| 99 | #define cur_byte cur_state.byte_field | 99 | #define cur_byte cur_state.byte_field |
| @@ -125,14 +125,14 @@ · 25 unmodified lines | |||
| 125 | 125 | ||
| 126 | #define constant 03 \ | 126 | #define constant 03 \ |
| 127 | 127 | ||
| 128 | #define isxalpha(c)((c)=='_') | 128 | #define isxalpha(c) ((c) =='_') |
| 129 | #define ishigh(c)((unsigned char)(c)>0177) \ | 129 | #define ishigh(c) ((unsigned char) (c) >0177) \ |
| 130 | \ | 130 | \ |
| 131 | 131 | ||
| 132 | #define compress(c)if(loc++<=limit)return(c) \ | 132 | #define compress(c) if(loc++<=limit) return(c) \ |
| 133 | 133 | ||
| 134 | #define macro 0 | 134 | #define macro 0 |
| 135 | #define app_repl(c){if(tok_ptr==tok_mem_end)overflow("token");*tok_ptr++= c;} \ | 135 | #define app_repl(c) {if(tok_ptr==tok_mem_end) overflow("token") ;*tok_ptr++= c;} \ |
| 136 | 136 | ||
| 137 | 137 | ||
| 138 | #line 63 "ctangle.w" | 138 | #line 63 "ctangle.w" |
| @@ -345,15 +345,16 @@ boolean comment_continues= 0; · 206 unmodified lines | |||
| 345 | #line 871 "ctangle.w" | 345 | #line 871 "ctangle.w" |
| 346 | 346 | ||
| 347 | name_pointer cur_section_name; | 347 | name_pointer cur_section_name; |
| 348 | int no_where; | ||
| 348 | 349 | ||
| 349 | /*:61*//*75:*/ | 350 | /*:61*//*75:*/ |
| 350 | #line 1181 "ctangle.w" | 351 | #line 1185 "ctangle.w" |
| 351 | 352 | ||
| 352 | text_pointer cur_text; | 353 | text_pointer cur_text; |
| 353 | eight_bits next_control; | 354 | eight_bits next_control; |
| 354 | 355 | ||
| 355 | /*:75*//*82:*/ | 356 | /*:75*//*82:*/ |
| 356 | #line 1328 "ctangle.w" | 357 | #line 1335 "ctangle.w" |
| 357 | 358 | ||
| 358 | extern sixteen_bits section_count; | 359 | extern sixteen_bits section_count; |
| 359 | 360 | ||
| @@ -382,15 +383,15 @@ void output_defs(); · 22 unmodified lines | |||
| 382 | /*:46*//*48:*/ | 383 | /*:46*//*48:*/ |
| 383 | #line 642 "ctangle.w" | 384 | #line 642 "ctangle.w" |
| 384 | 385 | ||
| 385 | void out_char(); | 386 | static void out_char(); |
| 386 | 387 | ||
| 387 | /*:48*//*90:*/ | 388 | /*:48*//*90:*/ |
| 388 | #line 1434 "ctangle.w" | 389 | #line 1442 "ctangle.w" |
| 389 | 390 | ||
| 390 | void phase_one(); | 391 | void phase_one(); |
| 391 | 392 | ||
| 392 | /*:90*//*92:*/ | 393 | /*:90*//*92:*/ |
| 393 | #line 1452 "ctangle.w" | 394 | #line 1460 "ctangle.w" |
| 394 | 395 | ||
| 395 | void skip_limbo(); | 396 | void skip_limbo(); |
| 396 | 397 | ||
| @@ -457,7 +458,7 @@ ccode['\'']= ord; · 60 unmodified lines | |||
| 457 | } | 458 | } |
| 458 | 459 | ||
| 459 | /*:57*//*71:*/ | 460 | /*:57*//*71:*/ |
| 460 | #line 1105 "ctangle.w" | 461 | #line 1106 "ctangle.w" |
| 461 | section_text[0]= ' '; | 462 | section_text[0]= ' '; |
| 462 | 463 | ||
| 463 | /*:71*/ | 464 | /*:71*/ |
| @@ -717,7 +718,7 @@ pop_level(0); · 253 unmodified lines | |||
| 717 | /*:47*//*49:*/ | 718 | /*:47*//*49:*/ |
| 718 | #line 645 "ctangle.w" | 719 | #line 645 "ctangle.w" |
| 719 | 720 | ||
| 720 | void | 721 | static void |
| 721 | out_char(cur_char) | 722 | out_char(cur_char) |
| 722 | eight_bits cur_char; | 723 | eight_bits cur_char; |
| 723 | { | 724 | { |
| @@ -861,7 +862,7 @@ else loc++; · 137 unmodified lines | |||
| 861 | } | 862 | } |
| 862 | 863 | ||
| 863 | /*:60*//*63:*/ | 864 | /*:60*//*63:*/ |
| 864 | #line 885 "ctangle.w" | 865 | #line 886 "ctangle.w" |
| 865 | 866 | ||
| 866 | eight_bits | 867 | eight_bits |
| 867 | get_next() | 868 | get_next() |
| @@ -872,10 +873,10 @@ while(1){ · 4 unmodified lines | |||
| 872 | if(loc>limit){ | 873 | if(loc>limit){ |
| 873 | if(preprocessing&&*(limit-1)!='\\')preprocessing= 0; | 874 | if(preprocessing&&*(limit-1)!='\\')preprocessing= 0; |
| 874 | if(get_line()==0)return(new_section); | 875 | if(get_line()==0)return(new_section); |
| 875 | else if(print_where){ | 876 | else if(print_where&&!no_where){ |
| 876 | print_where= 0; | 877 | print_where= 0; |
| 877 | /*77:*/ | 878 | /*77:*/ |
| 878 | #line 1208 "ctangle.w" | 879 | #line 1215 "ctangle.w" |
| 879 | 880 | ||
| 880 | store_two_bytes(0150000); | 881 | store_two_bytes(0150000); |
| 881 | if(changing)id_first= change_file_name; | 882 | if(changing)id_first= change_file_name; |
| @@ -883,11 +884,11 @@ else id_first= cur_file_name; · 1 unmodified line | |||
| 883 | id_loc= id_first+strlen(id_first); | 884 | id_loc= id_first+strlen(id_first); |
| 884 | if(changing)store_two_bytes((sixteen_bits)change_line); | 885 | if(changing)store_two_bytes((sixteen_bits)change_line); |
| 885 | else store_two_bytes((sixteen_bits)cur_line); | 886 | else store_two_bytes((sixteen_bits)cur_line); |
| 886 | {int a= id_lookup(id_first,id_loc)-name_dir;app_repl((a/0400)+0200); | 887 | {int a= id_lookup(id_first,id_loc,0)-name_dir;app_repl((a/0400)+0200); |
| 887 | app_repl(a%0400);} | 888 | app_repl(a%0400);} |
| 888 | 889 | ||
| 889 | /*:77*/ | 890 | /*:77*/ |
| 890 | #line 897 "ctangle.w" | 891 | #line 898 "ctangle.w" |
| 891 | ; | 892 | ; |
| 892 | } | 893 | } |
| 893 | else return('\n'); | 894 | else return('\n'); |
| @@ -901,7 +902,7 @@ else continue; · 7 unmodified lines | |||
| 901 | } | 902 | } |
| 902 | loc++; | 903 | loc++; |
| 903 | if(xisdigit(c)||c=='\\'||c=='.')/*66:*/ | 904 | if(xisdigit(c)||c=='\\'||c=='.')/*66:*/ |
| 904 | #line 963 "ctangle.w" | 905 | #line 964 "ctangle.w" |
| 905 | { | 906 | { |
| 906 | id_first= loc-1; | 907 | id_first= loc-1; |
| 907 | if(*id_first=='.'&&!xisdigit(*loc))goto mistake; | 908 | if(*id_first=='.'&&!xisdigit(*loc))goto mistake; |
| @@ -929,11 +930,11 @@ return(constant); · 21 unmodified lines | |||
| 929 | } | 930 | } |
| 930 | 931 | ||
| 931 | /*:66*/ | 932 | /*:66*/ |
| 932 | #line 909 "ctangle.w" | 933 | #line 910 "ctangle.w" |
| 933 | 934 | ||
| 934 | else if(c=='\''||c=='"'||(c=='L'&&(*loc=='\''||*loc=='"'))) | 935 | else if(c=='\''||c=='"'||(c=='L'&&(*loc=='\''||*loc=='"'))) |
| 935 | /*67:*/ | 936 | /*67:*/ |
| 936 | #line 994 "ctangle.w" | 937 | #line 995 "ctangle.w" |
| 937 | { | 938 | { |
| 938 | char delim= c; | 939 | char delim= c; |
| 939 | id_first= section_text+1; | 940 | id_first= section_text+1; |
| @@ -976,11 +977,11 @@ return(string); · 36 unmodified lines | |||
| 976 | } | 977 | } |
| 977 | 978 | ||
| 978 | /*:67*/ | 979 | /*:67*/ |
| 979 | #line 911 "ctangle.w" | 980 | #line 912 "ctangle.w" |
| 980 | 981 | ||
| 981 | else if(isalpha(c)||isxalpha(c)||ishigh(c)) | 982 | else if(isalpha(c)||isxalpha(c)||ishigh(c)) |
| 982 | /*65:*/ | 983 | /*65:*/ |
| 983 | #line 957 "ctangle.w" | 984 | #line 958 "ctangle.w" |
| 984 | { | 985 | { |
| 985 | id_first= --loc; | 986 | id_first= --loc; |
| 986 | while(isalpha(*++loc)||isdigit(*loc)||isxalpha(*loc)||ishigh(*loc)); | 987 | while(isalpha(*++loc)||isdigit(*loc)||isxalpha(*loc)||ishigh(*loc)); |
| @@ -988,10 +989,10 @@ id_loc= loc;return(identifier); · 1 unmodified line | |||
| 988 | } | 989 | } |
| 989 | 990 | ||
| 990 | /*:65*/ | 991 | /*:65*/ |
| 991 | #line 913 "ctangle.w" | 992 | #line 914 "ctangle.w" |
| 992 | 993 | ||
| 993 | else if(c=='@')/*68:*/ | 994 | else if(c=='@')/*68:*/ |
| 994 | #line 1038 "ctangle.w" | 995 | #line 1039 "ctangle.w" |
| 995 | { | 996 | { |
| 996 | c= ccode[(eight_bits)*loc++]; | 997 | c= ccode[(eight_bits)*loc++]; |
| 997 | switch(c){ | 998 | switch(c){ |
| @@ -1008,11 +1009,11 @@ continue; · 10 unmodified lines | |||
| 1008 | case section_name: | 1009 | case section_name: |
| 1009 | cur_section_name_char= *(loc-1); | 1010 | cur_section_name_char= *(loc-1); |
| 1010 | /*70:*/ | 1011 | /*70:*/ |
| 1011 | #line 1087 "ctangle.w" | 1012 | #line 1088 "ctangle.w" |
| 1012 | { | 1013 | { |
| 1013 | char*k; | 1014 | char*k; |
| 1014 | /*72:*/ | 1015 | /*72:*/ |
| 1015 | #line 1107 "ctangle.w" | 1016 | #line 1108 "ctangle.w" |
| 1016 | 1017 | ||
| 1017 | k= section_text; | 1018 | k= section_text; |
| 1018 | while(1){ | 1019 | while(1){ |
| @@ -1023,7 +1024,7 @@ loc= buffer+1;break; · 4 unmodified lines | |||
| 1023 | } | 1024 | } |
| 1024 | c= *loc; | 1025 | c= *loc; |
| 1025 | /*73:*/ | 1026 | /*73:*/ |
| 1026 | #line 1131 "ctangle.w" | 1027 | #line 1132 "ctangle.w" |
| 1027 | 1028 | ||
| 1028 | if(c=='@'){ | 1029 | if(c=='@'){ |
| 1029 | c= *(loc+1); | 1030 | c= *(loc+1); |
| @@ -1042,7 +1043,7 @@ err_print("! Nesting of section names not allowed");break; · 12 unmodified lines | |||
| 1042 | } | 1043 | } |
| 1043 | 1044 | ||
| 1044 | /*:73*/ | 1045 | /*:73*/ |
| 1045 | #line 1116 "ctangle.w" | 1046 | #line 1117 "ctangle.w" |
| 1046 | ; | 1047 | ; |
| 1047 | loc++;if(k<section_text_end)k++; | 1048 | loc++;if(k<section_text_end)k++; |
| 1048 | if(xisspace(c)){ | 1049 | if(xisspace(c)){ |
| @@ -1059,7 +1060,7 @@ printf("...");mark_harmless; · 10 unmodified lines | |||
| 1059 | if(*k==' '&&k>section_text)k--; | 1060 | if(*k==' '&&k>section_text)k--; |
| 1060 | 1061 | ||
| 1061 | /*:72*/ | 1062 | /*:72*/ |
| 1062 | #line 1089 "ctangle.w" | 1063 | #line 1090 "ctangle.w" |
| 1063 | ; | 1064 | ; |
| 1064 | if(k-section_text>3&&strncmp(k-2,"...",3)==0) | 1065 | if(k-section_text>3&&strncmp(k-2,"...",3)==0) |
| 1065 | cur_section_name= section_lookup(section_text+1,k-3,1); | 1066 | cur_section_name= section_lookup(section_text+1,k-3,1); |
| @@ -1082,16 +1083,16 @@ overflow("output files"); · 16 unmodified lines | |||
| 1082 | } | 1083 | } |
| 1083 | 1084 | ||
| 1084 | /*:40*/ | 1085 | /*:40*/ |
| 1085 | #line 1095 "ctangle.w" | 1086 | #line 1096 "ctangle.w" |
| 1086 | ; | 1087 | ; |
| 1087 | return(section_name); | 1088 | return(section_name); |
| 1088 | } | 1089 | } |
| 1089 | 1090 | ||
| 1090 | /*:70*/ | 1091 | /*:70*/ |
| 1091 | #line 1053 "ctangle.w" | 1092 | #line 1054 "ctangle.w" |
| 1092 | ; | 1093 | ; |
| 1093 | case string:/*74:*/ | 1094 | case string:/*74:*/ |
| 1094 | #line 1153 "ctangle.w" | 1095 | #line 1154 "ctangle.w" |
| 1095 | { | 1096 | { |
| 1096 | id_first= loc++;*(limit+1)= '@';*(limit+2)= '>'; | 1097 | id_first= loc++;*(limit+1)= '@';*(limit+2)= '>'; |
| 1097 | while(*loc!='@'||*(loc+1)!='>')loc++; | 1098 | while(*loc!='@'||*(loc+1)!='>')loc++; |
| @@ -1102,10 +1103,10 @@ return(string); · 4 unmodified lines | |||
| 1102 | } | 1103 | } |
| 1103 | 1104 | ||
| 1104 | /*:74*/ | 1105 | /*:74*/ |
| 1105 | #line 1054 "ctangle.w" | 1106 | #line 1055 "ctangle.w" |
| 1106 | ; | 1107 | ; |
| 1107 | case ord:/*69:*/ | 1108 | case ord:/*69:*/ |
| 1108 | #line 1066 "ctangle.w" | 1109 | #line 1067 "ctangle.w" |
| 1109 | 1110 | ||
| 1110 | id_first= loc; | 1111 | id_first= loc; |
| 1111 | if(*loc=='\\'){ | 1112 | if(*loc=='\\'){ |
| @@ -1128,14 +1129,14 @@ loc++; · 16 unmodified lines | |||
| 1128 | return(ord); | 1129 | return(ord); |
| 1129 | 1130 | ||
| 1130 | /*:69*/ | 1131 | /*:69*/ |
| 1131 | #line 1055 "ctangle.w" | 1132 | #line 1056 "ctangle.w" |
| 1132 | ; | 1133 | ; |
| 1133 | default:return(c); | 1134 | default:return(c); |
| 1134 | } | 1135 | } |
| 1135 | } | 1136 | } |
| 1136 | 1137 | ||
| 1137 | /*:68*/ | 1138 | /*:68*/ |
| 1138 | #line 914 "ctangle.w" | 1139 | #line 915 "ctangle.w" |
| 1139 | 1140 | ||
| 1140 | else if(xisspace(c)){ | 1141 | else if(xisspace(c)){ |
| 1141 | if(!preprocessing||loc>limit)continue; | 1142 | if(!preprocessing||loc>limit)continue; |
| @@ -1144,7 +1145,7 @@ else return(' '); · 2 unmodified lines | |||
| 1144 | } | 1145 | } |
| 1145 | else if(c=='#'&&loc==buffer+1)preprocessing= 1; | 1146 | else if(c=='#'&&loc==buffer+1)preprocessing= 1; |
| 1146 | mistake:/*64:*/ | 1147 | mistake:/*64:*/ |
| 1147 | #line 935 "ctangle.w" | 1148 | #line 936 "ctangle.w" |
| 1148 | 1149 | ||
| 1149 | switch(c){ | 1150 | switch(c){ |
| 1150 | case'+':if(*loc=='+')compress(plus_plus);break; | 1151 | case'+':if(*loc=='+')compress(plus_plus);break; |
| @@ -1168,14 +1169,14 @@ case'!':if(*loc=='=')compress(not_eq);break; · 17 unmodified lines | |||
| 1168 | } | 1169 | } |
| 1169 | 1170 | ||
| 1170 | /*:64*/ | 1171 | /*:64*/ |
| 1171 | #line 921 "ctangle.w" | 1172 | #line 922 "ctangle.w" |
| 1172 | 1173 | ||
| 1173 | return(c); | 1174 | return(c); |
| 1174 | } | 1175 | } |
| 1175 | } | 1176 | } |
| 1176 | 1177 | ||
| 1177 | /*:63*//*76:*/ | 1178 | /*:63*//*76:*/ |
| 1178 | #line 1185 "ctangle.w" | 1179 | #line 1189 "ctangle.w" |
| 1179 | 1180 | ||
| 1180 | void | 1181 | void |
| 1181 | scan_repl(t) | 1182 | scan_repl(t) |
| @@ -1183,7 +1184,7 @@ eight_bits t; · 1 unmodified line | |||
| 1183 | { | 1184 | { |
| 1184 | sixteen_bits a; | 1185 | sixteen_bits a; |
| 1185 | if(t==section_name){/*77:*/ | 1186 | if(t==section_name){/*77:*/ |
| 1186 | #line 1208 "ctangle.w" | 1187 | #line 1215 "ctangle.w" |
| 1187 | 1188 | ||
| 1188 | store_two_bytes(0150000); | 1189 | store_two_bytes(0150000); |
| 1189 | if(changing)id_first= change_file_name; | 1190 | if(changing)id_first= change_file_name; |
| @@ -1191,23 +1192,23 @@ else id_first= cur_file_name; · 1 unmodified line | |||
| 1191 | id_loc= id_first+strlen(id_first); | 1192 | id_loc= id_first+strlen(id_first); |
| 1192 | if(changing)store_two_bytes((sixteen_bits)change_line); | 1193 | if(changing)store_two_bytes((sixteen_bits)change_line); |
| 1193 | else store_two_bytes((sixteen_bits)cur_line); | 1194 | else store_two_bytes((sixteen_bits)cur_line); |
| 1194 | {int a= id_lookup(id_first,id_loc)-name_dir;app_repl((a/0400)+0200); | 1195 | {int a= id_lookup(id_first,id_loc,0)-name_dir;app_repl((a/0400)+0200); |
| 1195 | app_repl(a%0400);} | 1196 | app_repl(a%0400);} |
| 1196 | 1197 | ||
| 1197 | /*:77*/ | 1198 | /*:77*/ |
| 1198 | #line 1191 "ctangle.w" | 1199 | #line 1195 "ctangle.w" |
| 1199 | ;} | 1200 | ;} |
| 1200 | while(1)switch(a= get_next()){ | 1201 | while(1)switch(a= get_next()){ |
| 1201 | /*78:*/ | 1202 | /*78:*/ |
| 1202 | #line 1218 "ctangle.w" | 1203 | #line 1225 "ctangle.w" |
| 1203 | 1204 | ||
| 1204 | case identifier:a= id_lookup(id_first,id_loc)-name_dir; | 1205 | case identifier:a= id_lookup(id_first,id_loc,0)-name_dir; |
| 1205 | app_repl((a/0400)+0200); | 1206 | app_repl((a/0400)+0200); |
| 1206 | app_repl(a%0400);break; | 1207 | app_repl(a%0400);break; |
| 1207 | case section_name:if(t!=section_name)goto done; | 1208 | case section_name:if(t!=section_name)goto done; |
| 1208 | else{ | 1209 | else{ |
| 1209 | /*79:*/ | 1210 | /*79:*/ |
| 1210 | #line 1246 "ctangle.w" | 1211 | #line 1253 "ctangle.w" |
| 1211 | { | 1212 | { |
| 1212 | char*try_loc= loc; | 1213 | char*try_loc= loc; |
| 1213 | while(*try_loc==' '&&try_loc<limit)try_loc++; | 1214 | while(*try_loc==' '&&try_loc<limit)try_loc++; |
| @@ -1220,13 +1221,13 @@ if(*try_loc=='=')err_print("! Missing `@ ' before a named section"); · 6 unmodified lines | |||
| 1220 | } | 1221 | } |
| 1221 | 1222 | ||
| 1222 | /*:79*/ | 1223 | /*:79*/ |
| 1223 | #line 1224 "ctangle.w" | 1224 | #line 1231 "ctangle.w" |
| 1224 | ; | 1225 | ; |
| 1225 | a= cur_section_name-name_dir; | 1226 | a= cur_section_name-name_dir; |
| 1226 | app_repl((a/0400)+0250); | 1227 | app_repl((a/0400)+0250); |
| 1227 | app_repl(a%0400); | 1228 | app_repl(a%0400); |
| 1228 | /*77:*/ | 1229 | /*77:*/ |
| 1229 | #line 1208 "ctangle.w" | 1230 | #line 1215 "ctangle.w" |
| 1230 | 1231 | ||
| 1231 | store_two_bytes(0150000); | 1232 | store_two_bytes(0150000); |
| 1232 | if(changing)id_first= change_file_name; | 1233 | if(changing)id_first= change_file_name; |
| @@ -1234,11 +1235,11 @@ else id_first= cur_file_name; · 1 unmodified line | |||
| 1234 | id_loc= id_first+strlen(id_first); | 1235 | id_loc= id_first+strlen(id_first); |
| 1235 | if(changing)store_two_bytes((sixteen_bits)change_line); | 1236 | if(changing)store_two_bytes((sixteen_bits)change_line); |
| 1236 | else store_two_bytes((sixteen_bits)cur_line); | 1237 | else store_two_bytes((sixteen_bits)cur_line); |
| 1237 | {int a= id_lookup(id_first,id_loc)-name_dir;app_repl((a/0400)+0200); | 1238 | {int a= id_lookup(id_first,id_loc,0)-name_dir;app_repl((a/0400)+0200); |
| 1238 | app_repl(a%0400);} | 1239 | app_repl(a%0400);} |
| 1239 | 1240 | ||
| 1240 | /*:77*/ | 1241 | /*:77*/ |
| 1241 | #line 1228 "ctangle.w" | 1242 | #line 1235 "ctangle.w" |
| 1242 | ;break; | 1243 | ;break; |
| 1243 | } | 1244 | } |
| 1244 | case output_defs_code: | 1245 | case output_defs_code: |
| @@ -1246,7 +1247,7 @@ a= output_defs_flag; · 1 unmodified line | |||
| 1246 | app_repl((a/0400)+0200); | 1247 | app_repl((a/0400)+0200); |
| 1247 | app_repl(a%0400); | 1248 | app_repl(a%0400); |
| 1248 | /*77:*/ | 1249 | /*77:*/ |
| 1249 | #line 1208 "ctangle.w" | 1250 | #line 1215 "ctangle.w" |
| 1250 | 1251 | ||
| 1251 | store_two_bytes(0150000); | 1252 | store_two_bytes(0150000); |
| 1252 | if(changing)id_first= change_file_name; | 1253 | if(changing)id_first= change_file_name; |
| @@ -1254,15 +1255,15 @@ else id_first= cur_file_name; · 1 unmodified line | |||
| 1254 | id_loc= id_first+strlen(id_first); | 1255 | id_loc= id_first+strlen(id_first); |
| 1255 | if(changing)store_two_bytes((sixteen_bits)change_line); | 1256 | if(changing)store_two_bytes((sixteen_bits)change_line); |
| 1256 | else store_two_bytes((sixteen_bits)cur_line); | 1257 | else store_two_bytes((sixteen_bits)cur_line); |
| 1257 | {int a= id_lookup(id_first,id_loc)-name_dir;app_repl((a/0400)+0200); | 1258 | {int a= id_lookup(id_first,id_loc,0)-name_dir;app_repl((a/0400)+0200); |
| 1258 | app_repl(a%0400);} | 1259 | app_repl(a%0400);} |
| 1259 | 1260 | ||
| 1260 | /*:77*/ | 1261 | /*:77*/ |
| 1261 | #line 1234 "ctangle.w" | 1262 | #line 1241 "ctangle.w" |
| 1262 | ;break; | 1263 | ;break; |
| 1263 | case constant:case string: | 1264 | case constant:case string: |
| 1264 | /*80:*/ | 1265 | /*80:*/ |
| 1265 | #line 1257 "ctangle.w" | 1266 | #line 1264 "ctangle.w" |
| 1266 | 1267 | ||
| 1267 | app_repl(a); | 1268 | app_repl(a); |
| 1268 | while(id_first<id_loc){ | 1269 | while(id_first<id_loc){ |
| @@ -1276,11 +1277,11 @@ app_repl(*id_first++); · 7 unmodified lines | |||
| 1276 | app_repl(a);break; | 1277 | app_repl(a);break; |
| 1277 | 1278 | ||
| 1278 | /*:80*/ | 1279 | /*:80*/ |
| 1279 | #line 1236 "ctangle.w" | 1280 | #line 1243 "ctangle.w" |
| 1280 | ; | 1281 | ; |
| 1281 | case ord: | 1282 | case ord: |
| 1282 | /*81:*/ | 1283 | /*81:*/ |
| 1283 | #line 1273 "ctangle.w" | 1284 | #line 1280 "ctangle.w" |
| 1284 | { | 1285 | { |
| 1285 | int c= (eight_bits)*id_first; | 1286 | int c= (eight_bits)*id_first; |
| 1286 | if(c=='\\'){ | 1287 | if(c=='\\'){ |
| @@ -1331,7 +1332,7 @@ app_repl(constant); · 44 unmodified lines | |||
| 1331 | break; | 1332 | break; |
| 1332 | 1333 | ||
| 1333 | /*:81*/ | 1334 | /*:81*/ |
| 1334 | #line 1238 "ctangle.w" | 1335 | #line 1245 "ctangle.w" |
| 1335 | ; | 1336 | ; |
| 1336 | case definition:case format_code:case begin_C:if(t!=section_name)goto done; | 1337 | case definition:case format_code:case begin_C:if(t!=section_name)goto done; |
| 1337 | else{ | 1338 | else{ |
| @@ -1341,8 +1342,11 @@ err_print("! @d, @f and @c are ignored in C text");continue; · 3 unmodified lines | |||
| 1341 | case new_section:goto done; | 1342 | case new_section:goto done; |
| 1342 | 1343 | ||
| 1343 | /*:78*/ | 1344 | /*:78*/ |
| 1344 | #line 1196 "ctangle.w" | 1345 | #line 1200 "ctangle.w" |
| 1345 | 1346 | ||
| 1347 | case')':app_repl(a); | ||
| 1348 | if(t==macro)app_repl(' '); | ||
| 1349 | break; | ||
| 1346 | default:app_repl(a); | 1350 | default:app_repl(a); |
| 1347 | } | 1351 | } |
| 1348 | done:next_control= (eight_bits)a; | 1352 | done:next_control= (eight_bits)a; |
| @@ -1351,7 +1355,7 @@ cur_text= text_ptr;(++text_ptr)->tok_start= tok_ptr; · 2 unmodified lines | |||
| 1351 | } | 1355 | } |
| 1352 | 1356 | ||
| 1353 | /*:76*//*83:*/ | 1357 | /*:76*//*83:*/ |
| 1354 | #line 1335 "ctangle.w" | 1358 | #line 1342 "ctangle.w" |
| 1355 | 1359 | ||
| 1356 | void | 1360 | void |
| 1357 | scan_section() | 1361 | scan_section() |
| @@ -1359,14 +1363,14 @@ scan_section() · 1 unmodified line | |||
| 1359 | name_pointer p; | 1363 | name_pointer p; |
| 1360 | text_pointer q; | 1364 | text_pointer q; |
| 1361 | sixteen_bits a; | 1365 | sixteen_bits a; |
| 1362 | section_count++; | 1366 | section_count++;no_where= 1; |
| 1363 | if(*(loc-1)=='*'&&show_progress){ | 1367 | if(*(loc-1)=='*'&&show_progress){ |
| 1364 | printf("*%d",section_count);update_terminal; | 1368 | printf("*%d",section_count);update_terminal; |
| 1365 | } | 1369 | } |
| 1366 | next_control= 0; | 1370 | next_control= 0; |
| 1367 | while(1){ | 1371 | while(1){ |
| 1368 | /*84:*/ | 1372 | /*84:*/ |
| 1369 | #line 1373 "ctangle.w" | 1373 | #line 1381 "ctangle.w" |
| 1370 | 1374 | ||
| 1371 | while(next_control<definition) | 1375 | while(next_control<definition) |
| 1372 | 1376 | ||
| @@ -1375,11 +1379,11 @@ loc-= 2;next_control= get_next(); · 2 unmodified lines | |||
| 1375 | } | 1379 | } |
| 1376 | 1380 | ||
| 1377 | /*:84*/ | 1381 | /*:84*/ |
| 1378 | #line 1349 "ctangle.w" | 1382 | #line 1356 "ctangle.w" |
| 1379 | ; | 1383 | ; |
| 1380 | if(next_control==definition){ | 1384 | if(next_control==definition){ |
| 1381 | /*85:*/ | 1385 | /*85:*/ |
| 1382 | #line 1380 "ctangle.w" | 1386 | #line 1388 "ctangle.w" |
| 1383 | { | 1387 | { |
| 1384 | while((next_control= get_next())=='\n'); | 1388 | while((next_control= get_next())=='\n'); |
| 1385 | if(next_control!=identifier){ | 1389 | if(next_control!=identifier){ |
| @@ -1387,18 +1391,18 @@ err_print("! Definition flushed, must start with identifier"); · 1 unmodified line | |||
| 1387 | 1391 | ||
| 1388 | continue; | 1392 | continue; |
| 1389 | } | 1393 | } |
| 1390 | app_repl(((a= id_lookup(id_first,id_loc)-name_dir)/0400)+0200); | 1394 | app_repl(((a= id_lookup(id_first,id_loc,0)-name_dir)/0400)+0200); |
| 1391 | 1395 | ||
| 1392 | app_repl(a%0400); | 1396 | app_repl(a%0400); |
| 1393 | if(*loc!='('){ | 1397 | if(*loc!='('){ |
| 1394 | app_repl(string);app_repl(' ');app_repl(string); | 1398 | app_repl(string);app_repl(' ');app_repl(string); |
| 1395 | } | 1399 | } |
| 1396 | print_where= 0;scan_repl(macro); | 1400 | scan_repl(macro); |
| 1397 | cur_text->text_link= 0; | 1401 | cur_text->text_link= 0; |
| 1398 | } | 1402 | } |
| 1399 | 1403 | ||
| 1400 | /*:85*/ | 1404 | /*:85*/ |
| 1401 | #line 1351 "ctangle.w" | 1405 | #line 1358 "ctangle.w" |
| 1402 | 1406 | ||
| 1403 | continue; | 1407 | continue; |
| 1404 | } | 1408 | } |
| @@ -1408,34 +1412,35 @@ p= name_dir;break; · 3 unmodified lines | |||
| 1408 | if(next_control==section_name){ | 1412 | if(next_control==section_name){ |
| 1409 | p= cur_section_name; | 1413 | p= cur_section_name; |
| 1410 | /*86:*/ | 1414 | /*86:*/ |
| 1411 | #line 1405 "ctangle.w" | 1415 | #line 1413 "ctangle.w" |
| 1412 | 1416 | ||
| 1413 | while((next_control= get_next())=='+'); | 1417 | while((next_control= get_next())=='+'); |
| 1414 | if(next_control!='='&&next_control!=eq_eq) | 1418 | if(next_control!='='&&next_control!=eq_eq) |
| 1415 | continue; | 1419 | continue; |
| 1416 | 1420 | ||
| 1417 | /*:86*/ | 1421 | /*:86*/ |
| 1418 | #line 1359 "ctangle.w" | 1422 | #line 1366 "ctangle.w" |
| 1419 | ; | 1423 | ; |
| 1420 | break; | 1424 | break; |
| 1421 | } | 1425 | } |
| 1422 | return; | 1426 | return; |
| 1423 | } | 1427 | } |
| 1428 | no_where= print_where= 0; | ||
| 1424 | /*87:*/ | 1429 | /*87:*/ |
| 1425 | #line 1410 "ctangle.w" | 1430 | #line 1418 "ctangle.w" |
| 1426 | 1431 | ||
| 1427 | /*88:*/ | 1432 | /*88:*/ |
| 1428 | #line 1415 "ctangle.w" | 1433 | #line 1423 "ctangle.w" |
| 1429 | 1434 | ||
| 1430 | store_two_bytes((sixteen_bits)(0150000+section_count)); | 1435 | store_two_bytes((sixteen_bits)(0150000+section_count)); |
| 1431 | 1436 | ||
| 1432 | 1437 | ||
| 1433 | /*:88*/ | 1438 | /*:88*/ |
| 1434 | #line 1411 "ctangle.w" | 1439 | #line 1419 "ctangle.w" |
| 1435 | ; | 1440 | ; |
| 1436 | scan_repl(section_name); | 1441 | scan_repl(section_name); |
| 1437 | /*89:*/ | 1442 | /*89:*/ |
| 1438 | #line 1419 "ctangle.w" | 1443 | #line 1427 "ctangle.w" |
| 1439 | 1444 | ||
| 1440 | if(p==name_dir||p==0){ | 1445 | if(p==name_dir||p==0){ |
| 1441 | (last_unnamed)->text_link= cur_text-text_info;last_unnamed= cur_text; | 1446 | (last_unnamed)->text_link= cur_text-text_info;last_unnamed= cur_text; |
| @@ -1452,16 +1457,16 @@ cur_text->text_link= section_flag; · 10 unmodified lines | |||
| 1452 | 1457 | ||
| 1453 | 1458 | ||
| 1454 | /*:89*/ | 1459 | /*:89*/ |
| 1455 | #line 1413 "ctangle.w" | 1460 | #line 1421 "ctangle.w" |
| 1456 | ; | 1461 | ; |
| 1457 | 1462 | ||
| 1458 | /*:87*/ | 1463 | /*:87*/ |
| 1459 | #line 1364 "ctangle.w" | 1464 | #line 1372 "ctangle.w" |
| 1460 | ; | 1465 | ; |
| 1461 | } | 1466 | } |
| 1462 | 1467 | ||
| 1463 | /*:83*//*91:*/ | 1468 | /*:83*//*91:*/ |
| 1464 | #line 1437 "ctangle.w" | 1469 | #line 1445 "ctangle.w" |
| 1465 | 1470 | ||
| 1466 | void | 1471 | void |
| 1467 | phase_one(){ | 1472 | phase_one(){ |
| @@ -1475,7 +1480,7 @@ phase= 2; · 7 unmodified lines | |||
| 1475 | } | 1480 | } |
| 1476 | 1481 | ||
| 1477 | /*:91*//*93:*/ | 1482 | /*:91*//*93:*/ |
| 1478 | #line 1455 "ctangle.w" | 1483 | #line 1463 "ctangle.w" |
| 1479 | 1484 | ||
| 1480 | void | 1485 | void |
| 1481 | skip_limbo() | 1486 | skip_limbo() |
| @@ -1490,7 +1495,7 @@ c= *loc++; · 8 unmodified lines | |||
| 1490 | if(ccode[(eight_bits)c]==new_section)break; | 1495 | if(ccode[(eight_bits)c]==new_section)break; |
| 1491 | switch(ccode[(eight_bits)c]){ | 1496 | switch(ccode[(eight_bits)c]){ |
| 1492 | case translit_code:/*94:*/ | 1497 | case translit_code:/*94:*/ |
| 1493 | #line 1484 "ctangle.w" | 1498 | #line 1492 "ctangle.w" |
| 1494 | 1499 | ||
| 1495 | while(xisspace(*loc)&&loc<limit)loc++; | 1500 | while(xisspace(*loc)&&loc<limit)loc++; |
| 1496 | loc+= 3; | 1501 | loc+= 3; |
| @@ -1515,7 +1520,7 @@ translit[i-0200][loc-beg]= '\0'; · 18 unmodified lines | |||
| 1515 | } | 1520 | } |
| 1516 | 1521 | ||
| 1517 | /*:94*/ | 1522 | /*:94*/ |
| 1518 | #line 1468 "ctangle.w" | 1523 | #line 1476 "ctangle.w" |
| 1519 | ;break; | 1524 | ;break; |
| 1520 | case format_code:case'@':break; | 1525 | case format_code:case'@':break; |
| 1521 | case control_text:if(c=='q'||c=='Q'){ | 1526 | case control_text:if(c=='q'||c=='Q'){ |
| @@ -1533,7 +1538,7 @@ default:err_print("! Double @ should be used in limbo"); · 11 unmodified lines | |||
| 1533 | } | 1538 | } |
| 1534 | 1539 | ||
| 1535 | /*:93*//*95:*/ | 1540 | /*:93*//*95:*/ |
| 1536 | #line 1510 "ctangle.w" | 1541 | #line 1518 "ctangle.w" |
| 1537 | 1542 | ||
| 1538 | void | 1543 | void |
| 1539 | print_stats(){ | 1544 | print_stats(){ |
| @@ -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.2 --- July 1994 | 5 | % Version 3.3 --- December 1994 |
| 6 | 6 | ||
| 7 | % Copyright (C) 1987,1990,1993 Silvio Levy and Donald E. Knuth | 7 | % Copyright (C) 1987,1990,1993 Silvio Levy and Donald E. Knuth |
| 8 | 8 | ||
| @@ -22,11 +22,11 @@ · 13 unmodified lines | |||
| 22 | \mathchardef\RA="3221 % right arrow | 22 | \mathchardef\RA="3221 % right arrow |
| 23 | \mathchardef\BA="3224 % double arrow | 23 | \mathchardef\BA="3224 % double arrow |
| 24 | 24 | ||
| 25 | \def\title{CTANGLE (Version 3.2)} | 25 | \def\title{CTANGLE (Version 3.3)} |
| 26 | \def\topofcontents{\null\vfill | 26 | \def\topofcontents{\null\vfill |
| 27 | \centerline{\titlefont The {\ttitlefont CTANGLE} processor} | 27 | \centerline{\titlefont The {\ttitlefont CTANGLE} processor} |
| 28 | \vskip 15pt | 28 | \vskip 15pt |
| 29 | \centerline{(Version 3.2)} | 29 | \centerline{(Version 3.3)} |
| 30 | \vfill} | 30 | \vfill} |
| 31 | \def\botofcontents{\vfill | 31 | \def\botofcontents{\vfill |
| 32 | \noindent | 32 | \noindent |
| @@ -56,7 +56,7 @@ Joachim Schrod, Lee Wittenberg, and others who have contributed improvements. · 23 unmodified lines | |||
| 56 | The ``banner line'' defined here should be changed whenever \.{CTANGLE} | 56 | The ``banner line'' defined here should be changed whenever \.{CTANGLE} |
| 57 | is modified. | 57 | is modified. |
| 58 | 58 | ||
| 59 | @d banner "This is CTANGLE (Version 3.2)\n" | 59 | @d banner "This is CTANGLE (Version 3.3)\n" |
| 60 | 60 | ||
| 61 | @c | 61 | @c |
| 62 | @<Include files@>@/ | 62 | @<Include files@>@/ |
| @@ -640,10 +640,10 @@ is not called if |out_state==verbatim|, except perhaps with arguments · 577 unmodified lines | |||
| 640 | (end the constant). | 640 | (end the constant). |
| 641 | 641 | ||
| 642 | @<Predecl...@>= | 642 | @<Predecl...@>= |
| 643 | void out_char(); | 643 | static void out_char(); |
| 644 | 644 | ||
| 645 | @ @c | 645 | @ @c |
| 646 | void | 646 | static void |
| 647 | out_char(cur_char) | 647 | out_char(cur_char) |
| 648 | eight_bits cur_char; | 648 | eight_bits cur_char; |
| 649 | { | 649 | { |
| @@ -827,7 +827,7 @@ newline. The boolean argument |is_long_comment| distinguishes between · 177 unmodified lines | |||
| 827 | the two types of comments. | 827 | the two types of comments. |
| 828 | 828 | ||
| 829 | If |skip_comment| comes to the end of the section, it prints an error message. | 829 | If |skip_comment| comes to the end of the section, it prints an error message. |
| 830 | No comment, long or short, is allowed to contain `\.{@@ }' or `\.{@@*}'. | 830 | No comment, long or short, is allowed to contain `\.{@@\ }' or `\.{@@*}'. |
| 831 | 831 | ||
| 832 | @<Global...@>= | 832 | @<Global...@>= |
| 833 | boolean comment_continues=0; /* are we scanning a comment? */ | 833 | boolean comment_continues=0; /* are we scanning a comment? */ |
| @@ -870,6 +870,7 @@ boolean is_long_comment; · 36 unmodified lines | |||
| 870 | 870 | ||
| 871 | @<Global...@>= | 871 | @<Global...@>= |
| 872 | name_pointer cur_section_name; /* name of section just scanned */ | 872 | name_pointer cur_section_name; /* name of section just scanned */ |
| 873 | int no_where; /* suppress |print_where|? */ | ||
| 873 | 874 | ||
| 874 | @ @<Include...@>= | 875 | @ @<Include...@>= |
| 875 | #include <ctype.h> /* definition of |isalpha|, |isdigit| and so on */ | 876 | #include <ctype.h> /* definition of |isalpha|, |isdigit| and so on */ |
| @@ -892,7 +893,7 @@ get_next() /* produces the next input token */ · 16 unmodified lines | |||
| 892 | if (loc>limit) { | 893 | if (loc>limit) { |
| 893 | if (preprocessing && *(limit-1)!='\\') preprocessing=0; | 894 | if (preprocessing && *(limit-1)!='\\') preprocessing=0; |
| 894 | if (get_line()==0) return(new_section); | 895 | if (get_line()==0) return(new_section); |
| 895 | else if (print_where) { | 896 | else if (print_where && !no_where) { |
| 896 | print_where=0; | 897 | print_where=0; |
| 897 | @<Insert the line number into |tok_mem|@>; | 898 | @<Insert the line number into |tok_mem|@>; |
| 898 | } | 899 | } |
| @@ -1170,6 +1171,9 @@ the name of the current section. · 271 unmodified lines | |||
| 1170 | \item{b)}The symbols \.{@@d} and \.{@@f} and \.{@@c} are not allowed after | 1171 | \item{b)}The symbols \.{@@d} and \.{@@f} and \.{@@c} are not allowed after |
| 1171 | section names, while they terminate macro definitions. | 1172 | section names, while they terminate macro definitions. |
| 1172 | 1173 | ||
| 1174 | \item{c)}Spaces are inserted after right parentheses in macros, because the | ||
| 1175 | ANSI \CEE/ preprocessor sometimes requires it. | ||
| 1176 | |||
| 1173 | \yskip Therefore there is a single procedure |scan_repl| whose parameter | 1177 | \yskip Therefore there is a single procedure |scan_repl| whose parameter |
| 1174 | |t| specifies either |macro| or |section_name|. After |scan_repl| has | 1178 | |t| specifies either |macro| or |section_name|. After |scan_repl| has |
| 1175 | acted, |cur_text| will point to the replacement text just generated, and | 1179 | acted, |cur_text| will point to the replacement text just generated, and |
| @@ -1194,6 +1198,9 @@ eight_bits t; · 18 unmodified lines | |||
| 1194 | |section_name|, etc.), either process it and change |a| to a byte | 1198 | |section_name|, etc.), either process it and change |a| to a byte |
| 1195 | that should be stored, or |continue| if |a| should be ignored, | 1199 | that should be stored, or |continue| if |a| should be ignored, |
| 1196 | or |goto done| if |a| signals the end of this replacement text@>@; | 1200 | or |goto done| if |a| signals the end of this replacement text@>@; |
| 1201 | case ')': app_repl(a); | ||
| 1202 | if (t==macro) app_repl(' '); | ||
| 1203 | break; | ||
| 1197 | default: app_repl(a); /* store |a| in |tok_mem| */ | 1204 | default: app_repl(a); /* store |a| in |tok_mem| */ |
| 1198 | } | 1205 | } |
| 1199 | done: next_control=(eight_bits) a; | 1206 | done: next_control=(eight_bits) a; |
| @@ -1212,11 +1219,11 @@ else id_first=cur_file_name; · 12 unmodified lines | |||
| 1212 | id_loc=id_first+strlen(id_first); | 1219 | id_loc=id_first+strlen(id_first); |
| 1213 | if (changing) store_two_bytes((sixteen_bits)change_line); | 1220 | if (changing) store_two_bytes((sixteen_bits)change_line); |
| 1214 | else store_two_bytes((sixteen_bits)cur_line); | 1221 | else store_two_bytes((sixteen_bits)cur_line); |
| 1215 | {int a=id_lookup(id_first,id_loc)-name_dir; app_repl((a / 0400)+0200); | 1222 | {int a=id_lookup(id_first,id_loc,0)-name_dir; app_repl((a / 0400)+0200); |
| 1216 | app_repl(a % 0400);} | 1223 | app_repl(a % 0400);} |
| 1217 | 1224 | ||
| 1218 | @ @<In cases that |a| is...@>= | 1225 | @ @<In cases that |a| is...@>= |
| 1219 | case identifier: a=id_lookup(id_first,id_loc)-name_dir; | 1226 | case identifier: a=id_lookup(id_first,id_loc,0)-name_dir; |
| 1220 | app_repl((a / 0400)+0200); | 1227 | app_repl((a / 0400)+0200); |
| 1221 | app_repl(a % 0400); break; | 1228 | app_repl(a % 0400); break; |
| 1222 | case section_name: if (t!=section_name) goto done; | 1229 | case section_name: if (t!=section_name) goto done; |
| @@ -1339,7 +1346,7 @@ scan_section() · 116 unmodified lines | |||
| 1339 | name_pointer p; /* section name for the current section */ | 1346 | name_pointer p; /* section name for the current section */ |
| 1340 | text_pointer q; /* text for the current section */ | 1347 | text_pointer q; /* text for the current section */ |
| 1341 | sixteen_bits a; /* token for left-hand side of definition */ | 1348 | sixteen_bits a; /* token for left-hand side of definition */ |
| 1342 | section_count++; | 1349 | section_count++; @+ no_where=1; |
| 1343 | if (*(loc-1)=='*' && show_progress) { /* starred section */ | 1350 | if (*(loc-1)=='*' && show_progress) { /* starred section */ |
| 1344 | printf("*%d",section_count); update_terminal; | 1351 | printf("*%d",section_count); update_terminal; |
| 1345 | } | 1352 | } |
| @@ -1361,6 +1368,7 @@ scan_section() · 15 unmodified lines | |||
| 1361 | } | 1368 | } |
| 1362 | return; /* \.{@@\ } or \.{@@*} */ | 1369 | return; /* \.{@@\ } or \.{@@*} */ |
| 1363 | } | 1370 | } |
| 1371 | no_where=print_where=0; | ||
| 1364 | @<Scan the \CEE/ part of the current section@>; | 1372 | @<Scan the \CEE/ part of the current section@>; |
| 1365 | } | 1373 | } |
| 1366 | 1374 | ||
| @@ -1384,13 +1392,13 @@ while (next_control<definition) · 17 unmodified lines | |||
| 1384 | @.Definition flushed...@> | 1392 | @.Definition flushed...@> |
| 1385 | continue; | 1393 | continue; |
| 1386 | } | 1394 | } |
| 1387 | app_repl(((a=id_lookup(id_first,id_loc)-name_dir) / 0400)+0200); | 1395 | app_repl(((a=id_lookup(id_first,id_loc,0)-name_dir) / 0400)+0200); |
| 1388 | /* append the lhs */ | 1396 | /* append the lhs */ |
| 1389 | app_repl(a % 0400); | 1397 | app_repl(a % 0400); |
| 1390 | if (*loc!='(') { /* identifier must be separated from replacement text */ | 1398 | if (*loc!='(') { /* identifier must be separated from replacement text */ |
| 1391 | app_repl(string); app_repl(' '); app_repl(string); | 1399 | app_repl(string); app_repl(' '); app_repl(string); |
| 1392 | } | 1400 | } |
| 1393 | print_where=0; scan_repl(macro); | 1401 | scan_repl(macro); |
| 1394 | cur_text->text_link=0; /* |text_link==0| characterizes a macro */ | 1402 | cur_text->text_link=0; /* |text_link==0| characterizes a macro */ |
| 1395 | } | 1403 | } |
| 1396 | 1404 | ||
| @@ -9,23 +9,23 @@ the code. (See makefile.bs.) · 8 unmodified lines | |||
| 9 | The main purpose of these changes is to support MSDOS with full-size arrays | 9 | The main purpose of these changes is to support MSDOS with full-size arrays |
| 10 | by using "huge" pointers. | 10 | by using "huge" pointers. |
| 11 | 11 | ||
| 12 | (This file contributed by Barry Schwartz, trashman@crud.mn.org, 28 Jun 94; | 12 | This file contributed by Barry Schwartz, trashman@crud.mn.org, 28 Jun 94. |
| 13 | revised 24 Jul 94.) | ||
| 14 | (Includes workaround for compiler bug [pointers wrapping around at | 13 | (Includes workaround for compiler bug [pointers wrapping around at |
| 15 | segment boundaries], November 1993, contributed by Jorge Fernandez Arnaiz | 14 | segment boundaries], November 1993, contributed by Jorge Fernandez Arnaiz |
| 16 | -- arnaiz@redvax1.dgsca.unam.mx) | 15 | -- arnaiz@redvax1.dgsca.unam.mx) |
| 16 | (Last revised 5 Dec 94 with help of bob@microprograms.com.) | ||
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | @x Section 1. | 19 | @x Section 1. |
| 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.2)\n" | 23 | @d banner "This is CWEAVE (Version 3.3)\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.2pc/big)\n" | 28 | @d banner "This is CWEAVE (Version 3.3pc/big)\n" |
| 29 | @z | 29 | @z |
| 30 | 30 | ||
| 31 | 31 | ||
| @@ -162,6 +162,34 @@ xmem->num=0; /* sentinel value */ · 130 unmodified lines | |||
| 162 | p->xref = (char huge*)xref_ptr; | 162 | p->xref = (char huge*)xref_ptr; |
| 163 | @z | 163 | @z |
| 164 | 164 | ||
| 165 | @x Section 25. (to please Borland's C++, version 4.02) | ||
| 166 | token tok_mem[max_toks]; /* tokens */ | ||
| 167 | token_pointer tok_mem_end = tok_mem+max_toks-1; /* end of |tok_mem| */ | ||
| 168 | token_pointer tok_start[max_texts]; /* directory into |tok_mem| */ | ||
| 169 | token_pointer tok_ptr; /* first unused position in |tok_mem| */ | ||
| 170 | text_pointer text_ptr; /* first unused position in |tok_start| */ | ||
| 171 | text_pointer tok_start_end = tok_start+max_texts-1; /* end of |tok_start| */ | ||
| 172 | token_pointer max_tok_ptr; /* largest value of |tok_ptr| */ | ||
| 173 | @y | ||
| 174 | token tok_mem[max_toks]; /* tokens */ | ||
| 175 | token_pointer tok_mem_end; /* end of |tok_mem| */ | ||
| 176 | token_pointer tok_start[max_texts]; /* directory into |tok_mem| */ | ||
| 177 | token_pointer tok_ptr; /* first unused position in |tok_mem| */ | ||
| 178 | text_pointer text_ptr; /* first unused position in |tok_start| */ | ||
| 179 | text_pointer tok_start_end; /* end of |tok_start| */ | ||
| 180 | token_pointer max_tok_ptr; /* largest value of |tok_ptr| */ | ||
| 181 | @z | ||
| 182 | |||
| 183 | @x Section 26. (goes with the previous change) | ||
| 184 | tok_start[1]=tok_mem+1; | ||
| 185 | max_tok_ptr=tok_mem+1; max_text_ptr=tok_start+1; | ||
| 186 | @y | ||
| 187 | tok_start[1]=tok_mem+1; | ||
| 188 | tok_mem_end=tok_mem+max_toks-1; | ||
| 189 | tok_start_end=tok_start+max_texts-1; | ||
| 190 | max_tok_ptr=tok_mem+1; max_text_ptr=tok_start+1; | ||
| 191 | @z | ||
| 192 | |||
| 165 | 193 | ||
| 166 | @x Section 27. | 194 | @x Section 27. |
| 167 | p->ilk=t; p->xref=(char*)xmem; | 195 | p->ilk=t; p->xref=(char*)xmem; |
| @@ -173,7 +201,7 @@ xmem->num=0; /* sentinel value */ · 5 unmodified lines | |||
| 173 | @x Section 27. | 201 | @x Section 27. |
| 174 | p->xref=(char*)xmem; | 202 | p->xref=(char*)xmem; |
| 175 | @y | 203 | @y |
| 176 | p->xref=(char*)xmem; | 204 | p->xref=(char huge*)xmem; |
| 177 | @z | 205 | @z |
| 178 | 206 | ||
| 179 | 207 | ||
| @@ -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.2)\n" | 14 | @d banner "This is CWEAVE (Version 3.3)\n" |
| 15 | @y | 15 | @y |
| 16 | @d banner "This is CWEAVE (Version 3.2pc)\n" | 16 | @d banner "This is CWEAVE (Version 3.3pc)\n" |
| 17 | @z | 17 | @z |
| 18 | 18 | ||
| 19 | @x section 4 | 19 | @x section 4 |
| @@ -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.2)\n" | 16 | @d banner "This is CWEAVE (Version 3.3)\n" |
| 17 | @y | 17 | @y |
| 18 | @d banner "This is CWEAVE (VAX/VMS Version 3.2)\n" | 18 | @d banner "This is CWEAVE (VAX/VMS Version 3.3)\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) |
| @@ -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.2 --- July 1994 | 5 | % Version 3.3 --- December 1994 |
| 6 | 6 | ||
| 7 | % Copyright (C) 1987,1990,1993 Silvio Levy and Donald E. Knuth | 7 | % Copyright (C) 1987,1990,1993 Silvio Levy and Donald E. Knuth |
| 8 | 8 | ||
| @@ -27,11 +27,11 @@ · 18 unmodified lines | |||
| 27 | \def\skipxTeX{\\{skip\_\TEX/}} | 27 | \def\skipxTeX{\\{skip\_\TEX/}} |
| 28 | \def\copyxTeX{\\{copy\_\TEX/}} | 28 | \def\copyxTeX{\\{copy\_\TEX/}} |
| 29 | 29 | ||
| 30 | \def\title{CWEAVE (Version 3.2)} | 30 | \def\title{CWEAVE (Version 3.3)} |
| 31 | \def\topofcontents{\null\vfill | 31 | \def\topofcontents{\null\vfill |
| 32 | \centerline{\titlefont The {\ttitlefont CWEAVE} processor} | 32 | \centerline{\titlefont The {\ttitlefont CWEAVE} processor} |
| 33 | \vskip 15pt | 33 | \vskip 15pt |
| 34 | \centerline{(Version 3.2)} | 34 | \centerline{(Version 3.3)} |
| 35 | \vfill} | 35 | \vfill} |
| 36 | \def\botofcontents{\vfill | 36 | \def\botofcontents{\vfill |
| 37 | \noindent | 37 | \noindent |
| @@ -61,7 +61,7 @@ Joachim Schrod, Lee Wittenberg, and others who have contributed improvements. · 23 unmodified lines | |||
| 61 | The ``banner line'' defined here should be changed whenever \.{CWEAVE} | 61 | The ``banner line'' defined here should be changed whenever \.{CWEAVE} |
| 62 | is modified. | 62 | is modified. |
| 63 | 63 | ||
| 64 | @d banner "This is CWEAVE (Version 3.2)\n" | 64 | @d banner "This is CWEAVE (Version 3.3)\n" |
| 65 | 65 | ||
| 66 | @c @<Include files@>@/ | 66 | @c @<Include files@>@/ |
| 67 | @h | 67 | @h |
| @@ -795,7 +795,7 @@ are pointers into the array |section_text|, not into |buffer|. · 727 unmodified lines | |||
| 795 | } | 795 | } |
| 796 | while (*loc=='u' || *loc=='U' || *loc=='l' || *loc=='L' | 796 | while (*loc=='u' || *loc=='U' || *loc=='l' || *loc=='L' |
| 797 | || *loc=='f' || *loc=='F') { | 797 | || *loc=='f' || *loc=='F') { |
| 798 | *id_loc++='$'; *id_loc++=toupper(*loc++); | 798 | *id_loc++='$'; *id_loc++=toupper(*loc); loc++; |
| 799 | } | 799 | } |
| 800 | return(constant); | 800 | return(constant); |
| 801 | } | 801 | } |
| @@ -1594,7 +1594,7 @@ The combination rules are given as context-sensitive productions that are · 792 unmodified lines | |||
| 1594 | applied from left to right. Suppose that we are currently working on the | 1594 | applied from left to right. Suppose that we are currently working on the |
| 1595 | sequence of scraps $s_1\,s_2\ldots s_n$. We try first to find the longest | 1595 | sequence of scraps $s_1\,s_2\ldots s_n$. We try first to find the longest |
| 1596 | production that applies to an initial substring $s_1\,s_2\ldots\,$; but if | 1596 | production that applies to an initial substring $s_1\,s_2\ldots\,$; but if |
| 1597 | no such productions exist, we find to find the longest production | 1597 | no such productions exist, we try to find the longest production |
| 1598 | applicable to the next substring $s_2\,s_3\ldots\,$; and if that fails, we | 1598 | applicable to the next substring $s_2\,s_3\ldots\,$; and if that fails, we |
| 1599 | try to match $s_3\,s_4\ldots\,$, etc. | 1599 | try to match $s_3\,s_4\ldots\,$, etc. |
| 1600 | 1600 | ||
| @@ -1850,9 +1850,9 @@ with discretionary breaks in between. · 249 unmodified lines | |||
| 1850 | \.-&|unorbinop|: \.-&yes\cr | 1850 | \.-&|unorbinop|: \.-&yes\cr |
| 1851 | \.*&|raw_unorbin|: \.*&yes\cr | 1851 | \.*&|raw_unorbin|: \.*&yes\cr |
| 1852 | \./&|binop|: \./&yes\cr | 1852 | \./&|binop|: \./&yes\cr |
| 1853 | \.<&|binop|: \.<&yes\cr | 1853 | \.<&|prelangle|: \.{\\langle}&yes\cr |
| 1854 | \.=&|binop|: \.{\\K}&yes\cr | 1854 | \.=&|binop|: \.{\\K}&yes\cr |
| 1855 | \.>&|binop|: \.>&yes\cr | 1855 | \.>&|prerangle|: \.{\\rangle}&yes\cr |
| 1856 | \..&|binop|: \..&yes\cr | 1856 | \..&|binop|: \..&yes\cr |
| 1857 | \.{\v}&|binop|: \.{\\OR}&yes\cr | 1857 | \.{\v}&|binop|: \.{\\OR}&yes\cr |
| 1858 | \.\^&|binop|: \.{\\XOR}&yes\cr | 1858 | \.\^&|binop|: \.{\\XOR}&yes\cr |
| @@ -2828,7 +2828,9 @@ if (cat1==public_like && cat2==exp) { · 969 unmodified lines | |||
| 2828 | } | 2828 | } |
| 2829 | 2829 | ||
| 2830 | @ @<Cases for |raw_rpar|@>= | 2830 | @ @<Cases for |raw_rpar|@>= |
| 2831 | if (cat1==const_like) { | 2831 | if (cat1==const_like && @| |
| 2832 | (cat2==semi || cat2==lbrace || cat2==comma || cat2==binop | ||
| 2833 | || cat2==const_like)) { | ||
| 2832 | big_app1(pp); big_app(' '); | 2834 | big_app1(pp); big_app(' '); |
| 2833 | big_app1(pp+1); reduce(pp,2,raw_rpar,0,103); | 2835 | big_app1(pp+1); reduce(pp,2,raw_rpar,0,103); |
| 2834 | } else squash(pp,1,rpar,-3,104); | 2836 | } else squash(pp,1,rpar,-3,104); |
| @@ -3253,9 +3255,19 @@ app_scrap(exp,maybe_math); · 418 unmodified lines | |||
| 3253 | 3255 | ||
| 3254 | @ We do not make the \TEX/ string into a scrap, because there is no | 3256 | @ We do not make the \TEX/ string into a scrap, because there is no |
| 3255 | telling what the user will be putting into it; instead we leave it | 3257 | telling what the user will be putting into it; instead we leave it |
| 3256 | open, to be picked up by next scrap. If it comes at the end of a | 3258 | open, to be picked up by the next scrap. If it comes at the end of a |
| 3257 | section, it will be made into a scrap when |finish_C| is called. | 3259 | section, it will be made into a scrap when |finish_C| is called. |
| 3258 | 3260 | ||
| 3261 | There's a known bug here, in cases where an adjacent scrap is | ||
| 3262 | |prelangle| or |prerangle|. Then the \TEX/ string can disappear | ||
| 3263 | when the \.{\\langle} or \.{\\rangle} becomes \.{<} or \.{>}. | ||
| 3264 | For example, if the user writes \.{\v x<@@ty@@>\v}, the \TEX/ string | ||
| 3265 | \.{\\hbox\{y\}} eventually becomes part of an |insert| scrap, which is combined | ||
| 3266 | with a |prelangle| scrap and eventually lost. The best way to work around | ||
| 3267 | this bug is probably to enclose the \.{@@t...@@>} in \.{@@[...@@]} so that | ||
| 3268 | the \TEX/ string is treated as an expression. | ||
| 3269 | @^bug, known@> | ||
| 3270 | |||
| 3259 | @<Append a \TEX/ string, without forming a scrap@>= | 3271 | @<Append a \TEX/ string, without forming a scrap@>= |
| 3260 | app_str("\\hbox{"@q}@>); | 3272 | app_str("\\hbox{"@q}@>); |
| 3261 | @^high-bit character handling@> | 3273 | @^high-bit character handling@> |
| @@ -3950,7 +3962,7 @@ text starts immediately after the identifier. In the former case, · 688 unmodified lines | |||
| 3950 | it starts after we scan the matching `\.)'. | 3962 | it starts after we scan the matching `\.)'. |
| 3951 | 3963 | ||
| 3952 | @<Start a macro...@>= { | 3964 | @<Start a macro...@>= { |
| 3953 | if (save_line!=out_line || save_place!=out_ptr) app(backup); | 3965 | if (save_line!=out_line || save_place!=out_ptr || space_checked) app(backup); |
| 3954 | if(!space_checked){emit_space_if_needed;save_position;} | 3966 | if(!space_checked){emit_space_if_needed;save_position;} |
| 3955 | app_str("\\D"); /* this will produce `\&{define }' */ | 3967 | app_str("\\D"); /* this will produce `\&{define }' */ |
| 3956 | @.\\D@> | 3968 | @.\\D@> |
| @@ -4127,7 +4139,7 @@ flush_buffer(out_buf,0,0); /* insert a blank line, it looks nice */ · 170 unmodified lines | |||
| 4127 | We are nearly finished! \.{CWEAVE}'s only remaining task is to write out the | 4139 | We are nearly finished! \.{CWEAVE}'s only remaining task is to write out the |
| 4128 | index, after sorting the identifiers and index entries. | 4140 | index, after sorting the identifiers and index entries. |
| 4129 | 4141 | ||
| 4130 | If the user has set the |no_xref| flag (the |-x| option on the command line), | 4142 | If the user has set the |no_xref| flag (the \.{-x} option on the command line), |
| 4131 | just finish off the page, omitting the index, section name list, and table of | 4143 | just finish off the page, omitting the index, section name list, and table of |
| 4132 | contents. | 4144 | contents. |
| 4133 | 4145 | ||
| @@ -1,7 +1,7 @@ | |||
| 1 | % standard macros for CWEB listings (in addition to plain.tex) | 1 | % standard macros for CWEB listings (in addition to plain.tex) |
| 2 | % Version 3.0 --- June 1993 | 2 | % Version 3.1 --- September 1994 |
| 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.0} | 4 | \xdef\fmtversion{\fmtversion+CWEB3.1} |
| 5 | 5 | ||
| 6 | \let\:=\. % preserve a way to get the dot accent | 6 | \let\:=\. % preserve a way to get the dot accent |
| 7 | % (all other accents will still work as usual) | 7 | % (all other accents will still work as usual) |
| @@ -119,7 +119,7 @@ · 111 unmodified lines | |||
| 119 | \def\B{\rightskip=0pt plus 100pt minus 10pt % go into C mode | 119 | \def\B{\rightskip=0pt plus 100pt minus 10pt % go into C mode |
| 120 | \sfcode`;=3000 | 120 | \sfcode`;=3000 |
| 121 | \pretolerance 10000 | 121 | \pretolerance 10000 |
| 122 | \hyphenpenalty 9999 % so strings can be broken (discretionary \ is inserted) | 122 | \hyphenpenalty 1000 % so strings can be broken (discretionary \ is inserted) |
| 123 | \exhyphenpenalty 10000 | 123 | \exhyphenpenalty 10000 |
| 124 | \global\ind=2 \1\ \unskip} | 124 | \global\ind=2 \1\ \unskip} |
| 125 | \def\C#1{\5\5\quad$/\ast\,${\cmntfont #1}$\,\ast/$} | 125 | \def\C#1{\5\5\quad$/\ast\,${\cmntfont #1}$\,\ast/$} |
| @@ -144,15 +144,15 @@ The \.{CWEB} system consists of two programs named \.{CWEAVE} and \.{CTANGLE}. · 143 unmodified lines | |||
| 144 | When writing a \.{CWEB} program the user keeps the | 144 | When writing a \.{CWEB} program the user keeps the |
| 145 | \CEE/ code and the documentation in the same file, called the \.{CWEB} | 145 | \CEE/ code and the documentation in the same file, called the \.{CWEB} |
| 146 | file and generally named \.{something.w}. The command | 146 | file and generally named \.{something.w}. The command |
| 147 | `\.{cweave something}' creates an output file \.{something.tex}, which | 147 | `\.{cweave} \.{something}' creates an output file \.{something.tex}, which |
| 148 | can then be fed to \TEX/, yielding a ``pretty printed'' version of | 148 | can then be fed to \TEX/, yielding a ``pretty printed'' version of |
| 149 | \.{something.w} that correctly handles | 149 | \.{something.w} that correctly handles |
| 150 | typographic details like page layout and the use of indentation, | 150 | typographic details like page layout and the use of indentation, |
| 151 | italics, boldface, and mathematical symbols. The typeset output also | 151 | italics, boldface, and mathematical symbols. The typeset output also |
| 152 | includes extensive cross-index | 152 | includes extensive cross-index |
| 153 | information that is gathered automatically. Similarly, if you run the | 153 | information that is gathered automatically. Similarly, if you run the |
| 154 | command `\.{ctangle something}' you will get a \CEE/ file \.{something.c}, | 154 | command `\.{ctangle} \.{something}' you will get a \CEE/ file \.{something.c}, |
| 155 | with can then be compiled to yield executable code. | 155 | which can then be compiled to yield executable code. |
| 156 | 156 | ||
| 157 | Besides providing a documentation tool, \.{CWEB} enhances the \CEE/ | 157 | Besides providing a documentation tool, \.{CWEB} enhances the \CEE/ |
| 158 | language by providing the | 158 | language by providing the |
| @@ -166,7 +166,7 @@ explained separately. The \.{CWEAVE} program is so named because it takes · 7 unmodified lines | |||
| 166 | a given web and intertwines the \TEX/ and \CEE/ portions contained in | 166 | a given web and intertwines the \TEX/ and \CEE/ portions contained in |
| 167 | each section, then it knits the whole fabric into a structured document. | 167 | each section, then it knits the whole fabric into a structured document. |
| 168 | (Get it? Wow.) Perhaps there is some deep connection here with the fact | 168 | (Get it? Wow.) Perhaps there is some deep connection here with the fact |
| 169 | that the German word for ``weave'' is ``{\it web\/}'', and the | 169 | that the German word for ``weave'' is ``{\it webe\/}'', and the |
| 170 | corresponding Latin imperative is ``{\it texe\/}''! | 170 | corresponding Latin imperative is ``{\it texe\/}''! |
| 171 | 171 | ||
| 172 | A user of \.{CWEB} should be fairly familiar with the \CEE/ | 172 | A user of \.{CWEB} should be fairly familiar with the \CEE/ |
| @@ -406,7 +406,8 @@ Although a section begins with \TEX/ text and ends with \CEE/ text, we · 233 unmodified lines | |||
| 406 | have noted that the dividing line isn't sharp, since \CEE/ text can be | 406 | have noted that the dividing line isn't sharp, since \CEE/ text can be |
| 407 | included in \TEX/ text if it is enclosed in `\pb'. Conversely, \TEX/ text | 407 | included in \TEX/ text if it is enclosed in `\pb'. Conversely, \TEX/ text |
| 408 | appears frequently within \CEE/ text, because everything in | 408 | appears frequently within \CEE/ text, because everything in |
| 409 | comments (i.e., between \.{/*} and \.{*/}) is treated as \TEX/ text. | 409 | comments (i.e., between \.{/*} and \.{*/}, or following \.{//}) |
| 410 | is treated as \TEX/ text. | ||
| 410 | Likewise, the text of a section name consists of \TEX/ text, but | 411 | Likewise, the text of a section name consists of \TEX/ text, but |
| 411 | the construct \.{@<section name@>} as a whole is is expected to be found | 412 | the construct \.{@<section name@>} as a whole is is expected to be found |
| 412 | in \CEE/ text; thus, one typically goes back and forth | 413 | in \CEE/ text; thus, one typically goes back and forth |
| @@ -665,7 +666,7 @@ be put into a \TEX/ \.{\\hbox} and formatted along with the neighboring · 252 unmodified lines | |||
| 665 | \CEE/ program. This text is ignored by \.{CTANGLE}, but it can be used | 666 | \CEE/ program. This text is ignored by \.{CTANGLE}, but it can be used |
| 666 | for various purposes within \.{CWEAVE}. For example, you can make comments | 667 | for various purposes within \.{CWEAVE}. For example, you can make comments |
| 667 | that mix \CEE/ and classical mathematics, as in `$\\{size}<2^{15}$', by | 668 | that mix \CEE/ and classical mathematics, as in `$\\{size}<2^{15}$', by |
| 668 | typing `\.{|size < @t\$2\^\{15\}\$@>|}'. | 669 | typing `\.{|size < 2@t\$\^\{15\}\$@>|}'. |
| 669 | 670 | ||
| 670 | \@= [MCc] $*$ The control text that follows will | 671 | \@= [MCc] $*$ The control text that follows will |
| 671 | be passed verbatim to the \CEE/ program. | 672 | be passed verbatim to the \CEE/ program. |
| @@ -689,13 +690,14 @@ code; for example, the definition · 17 unmodified lines | |||
| 689 | $$\hbox{\&{int} \\{array}[\\{max\_dim}], \\{count}${}=\\{old\_count};$}$$ | 690 | $$\hbox{\&{int} \\{array}[\\{max\_dim}], \\{count}${}=\\{old\_count};$}$$ |
| 690 | makes the names \\{array} and \\{count} get an underlined entry in the | 691 | makes the names \\{array} and \\{count} get an underlined entry in the |
| 691 | index. Statement labels, function definitions like | 692 | index. Statement labels, function definitions like |
| 692 | $\\{main}(\\{argc},\39\\{argv})$, and \&{typedef} definitions also | 693 | \\{main}(\&{int}~\\{argc},\,\&{char}~$*$\\{argv}[\,]), |
| 693 | imply underlining. A traditional-style | 694 | and \&{typedef} definitions also |
| 695 | imply underlining. An old-style | ||
| 694 | function definition (without prototyping) doesn't define its arguments; | 696 | function definition (without prototyping) doesn't define its arguments; |
| 695 | the arguments will, however, be defined | 697 | the arguments will, however, be considered to be defined |
| 696 | (i.e., their index entries will be underlined) if their types are | 698 | (i.e., their index entries will be underlined) if their types are |
| 697 | declared before the body of the function in the usual way | 699 | declared before the body of the function in the usual way |
| 698 | (e.g., `\.{int}~\\{argc}; \.{char}~${**}\\{argv}$; $\{\,\ldots\,\}$'). | 700 | (e.g., `\&{int}~\\{argc}; \&{char}~${*}\\{argv}[\,]$; $\{\,\ldots\,\}$'). |
| 699 | 701 | ||
| 700 | \subsec | 702 | \subsec |
| 701 | We now turn to control codes that affect only the operation of | 703 | We now turn to control codes that affect only the operation of |
| @@ -772,7 +774,8 @@ program formatted by \.{CWEAVE}. Line breaks · 70 unmodified lines | |||
| 772 | are chosen automatically by \TEX/ according to a scheme that works 99\%\ | 774 | are chosen automatically by \TEX/ according to a scheme that works 99\%\ |
| 773 | of the time, but sometimes you will prefer to force a line break so that | 775 | of the time, but sometimes you will prefer to force a line break so that |
| 774 | the program is segmented according to logical rather than visual | 776 | the program is segmented according to logical rather than visual |
| 775 | criteria. | 777 | criteria. If a comment follows, say `\.{@/@,}' to break the line |
| 778 | before the comment. | ||
| 776 | 779 | ||
| 777 | \@| [MC] This control code specifies an optional line break in the midst of | 780 | \@| [MC] This control code specifies an optional line break in the midst of |
| 778 | an expression. For example, if you have | 781 | an expression. For example, if you have |
| @@ -857,7 +860,7 @@ to time. · 78 unmodified lines | |||
| 857 | Furthermore the \\{web\_file} itself can be a combination of | 860 | Furthermore the \\{web\_file} itself can be a combination of |
| 858 | several files. When either \.{CWEAVE} or \.{CTANGLE} is reading a file and | 861 | several files. When either \.{CWEAVE} or \.{CTANGLE} is reading a file and |
| 859 | encounters the control code \.{@i} at the beginning of a line, it | 862 | encounters the control code \.{@i} at the beginning of a line, it |
| 860 | interrupts normal reading and start looking at the file named after the | 863 | interrupts normal reading and starts looking at the file named after the |
| 861 | \.{@i}, much as the \CEE/ preprocessor does when it encounters an \.{\#include} | 864 | \.{@i}, much as the \CEE/ preprocessor does when it encounters an \.{\#include} |
| 862 | line. After the included file has been entirely read, the program | 865 | line. After the included file has been entirely read, the program |
| 863 | goes back to the next line | 866 | goes back to the next line |
| @@ -963,10 +966,9 @@ contain labeled statements, so that the label will stick out a little at · 99 unmodified lines | |||
| 963 | the left.) You can also use `\.{@t\}\\3\{-5@>}' to force a break | 966 | the left.) You can also use `\.{@t\}\\3\{-5@>}' to force a break |
| 964 | in the middle of an expression. | 967 | in the middle of an expression. |
| 965 | 968 | ||
| 966 | 10. Don't use a change file to change just part of a macro call that | 969 | 10. Each identifier in \.{CWEB} has a single formatting convention. Therefore |
| 967 | extends over more than one line; change the whole call or nothing. | 970 | you shouldn't use the same identifier to denote, say, both a type name and |
| 968 | Otherwise \.{CTANGLE} will insert \.{\#line} directives that confuse | 971 | part of a \.{struct}, even though \CEE/ does allow this. |
| 969 | the \CEE/ preprocessor. | ||
| 970 | 972 | ||
| 971 | \section Running the programs. | 973 | \section Running the programs. |
| 972 | The \UNIX/ command line for \.{CTANGLE} is | 974 | The \UNIX/ command line for \.{CTANGLE} is |
| @@ -1083,8 +1085,7 @@ In this case you should help \.{CWEAVE} by putting `\.{@/}' after · 110 unmodified lines | |||
| 1083 | `\.{main(argc,argv)}'. | 1085 | `\.{main(argc,argv)}'. |
| 1084 | 1086 | ||
| 1085 | \.{CWEAVE} automatically inserts a bit of extra space between declarations | 1087 | \.{CWEAVE} automatically inserts a bit of extra space between declarations |
| 1086 | and the first apparent statement of a block, unless you turn off the | 1088 | and the first apparent statement of a block. One way to defeat this |
| 1087 | feature globally by running with the \.{-o} option. One way to defeat this | ||
| 1088 | spacing locally is | 1089 | spacing locally is |
| 1089 | $$\vbox{\halign{#\hfil\cr | 1090 | $$\vbox{\halign{#\hfil\cr |
| 1090 | \.{int x;@+@t\}\\6\{@>}\cr | 1091 | \.{int x;@+@t\}\\6\{@>}\cr |
| @@ -1590,7 +1591,8 @@ customary to make this the first change in your change file. · 499 unmodified lines | |||
| 1590 | 1591 | ||
| 1591 | \point 14. To get output in languages other than English, redefine the | 1592 | \point 14. To get output in languages other than English, redefine the |
| 1592 | macros \.{\\A}, \.{\\ET}, \.{\\Q}, \.{\\U}, | 1593 | macros \.{\\A}, \.{\\ET}, \.{\\Q}, \.{\\U}, |
| 1593 | \.{\\ch}, \.{\\fin}, and \.{\\con}. \.{CWEAVE} itself need not be changed. | 1594 | \.{\\ch}, \.{\\fin}, \.{\\con}, \.{\\today}, \.{\\datethis}, and |
| 1595 | \.{\\datecontentspage}. \.{CWEAVE} itself need not be changed. | ||
| 1594 | 1596 | ||
| 1595 | \point 15. Some output can be selectively suppressed with the macros | 1597 | \point 15. Some output can be selectively suppressed with the macros |
| 1596 | \.{\\noatl}, \.{\\noinx}, \.{\\nosecs}, \.{\\nocon}. | 1598 | \.{\\noatl}, \.{\\noinx}, \.{\\nosecs}, \.{\\nocon}. |
| @@ -19,6 +19,9 @@ A ``word'' is a maximal sequence of consecutive characters other than · 18 unmodified lines | |||
| 19 | newline, space, or tab, containing at least one visible ASCII code. | 19 | newline, space, or tab, containing at least one visible ASCII code. |
| 20 | (We assume that the standard ASCII code is in use.) | 20 | (We assume that the standard ASCII code is in use.) |
| 21 | 21 | ||
| 22 | This version of \.{wc} has a nonstandard ``silent'' option (\.{-s}), | ||
| 23 | which suppresses printing except for the grand totals over all files. | ||
| 24 | |||
| 22 | @ Most \.{CWEB} programs share a common structure. It's probably a | 25 | @ Most \.{CWEB} programs share a common structure. It's probably a |
| 23 | good idea to state the overall structure explicitly at the outset, | 26 | good idea to state the overall structure explicitly at the outset, |
| 24 | even though the various parts could all be introduced in unnamed | 27 | even though the various parts could all be introduced in unnamed |
| @@ -71,18 +74,27 @@ the desired counts and specifying the order in which they should be · 46 unmodified lines | |||
| 71 | displayed. Each selection is given by the initial character | 74 | displayed. Each selection is given by the initial character |
| 72 | (lines, words, or characters). For example, `\.{-cl}' would cause | 75 | (lines, words, or characters). For example, `\.{-cl}' would cause |
| 73 | just the number of characters and the number of lines to be printed, | 76 | just the number of characters and the number of lines to be printed, |
| 74 | in that order. | 77 | in that order. The default, if no special argument is given, is `\.{-lwc}'. |
| 75 | 78 | ||
| 76 | We do not process this string now; we simply remember where it is. | 79 | We do not process this string now; we simply remember where it is. |
| 77 | It will be used to control the formatting at output time. | 80 | It will be used to control the formatting at output time. |
| 81 | |||
| 82 | If the `\.{-}' is immediately followed by `\.{s}', only summary totals | ||
| 83 | are printed. | ||
| 78 | 84 | ||
| 79 | @<Var...@>= | 85 | @<Var...@>= |
| 80 | int file_count; /* how many files there are */ | 86 | int file_count; /* how many files there are */ |
| 81 | char *which; /* which counts to print */ | 87 | char *which; /* which counts to print */ |
| 88 | int silent=0; /* nonzero if the silent option was selected */ | ||
| 82 | 89 | ||
| 83 | @ @<Set up o...@>= | 90 | @ @<Set up o...@>= |
| 84 | which="lwc"; /* if no option is given, print all three values */ | 91 | which="lwc"; /* if no option is given, print all three values */ |
| 85 | if (argc>1 && *argv[1] == '-') { which=argv[1]+1; argc--; argv++; } | 92 | if (argc>1 && *argv[1] == '-') { |
| 93 | argv[1]++; | ||
| 94 | if (*argv[1]=='s') silent=1,argv[1]++; | ||
| 95 | if (*argv[1]) which=argv[1]; | ||
| 96 | argc--; argv++; | ||
| 97 | } | ||
| 86 | file_count=argc-1; | 98 | file_count=argc-1; |
| 87 | 99 | ||
| 88 | @ Now we scan the remaining arguments and try to open a file, if | 100 | @ Now we scan the remaining arguments and try to open a file, if |
| @@ -183,9 +195,11 @@ Additionally we must decide here if we know the name of the file · 94 unmodified lines | |||
| 183 | we have processed or if it was just |stdin|. | 195 | we have processed or if it was just |stdin|. |
| 184 | 196 | ||
| 185 | @<Write...@>= | 197 | @<Write...@>= |
| 186 | wc_print(which, char_count, word_count, line_count); | 198 | if (!silent) { |
| 187 | if (file_count) printf (" %s\n", *argv); /* not |stdin| */ | 199 | wc_print(which, char_count, word_count, line_count); |
| 188 | else printf ("\n"); /* |stdin| */ | 200 | if (file_count) printf (" %s\n", *argv); /* not |stdin| */ |
| 201 | else printf ("\n"); /* |stdin| */ | ||
| 202 | } | ||
| 189 | 203 | ||
| 190 | @ @<Upda...@>= | 204 | @ @<Upda...@>= |
| 191 | tot_line_count+=line_count; | 205 | tot_line_count+=line_count; |
| @@ -196,9 +210,10 @@ tot_char_count+=char_count; · 4 unmodified lines | |||
| 196 | number of files too. | 210 | number of files too. |
| 197 | 211 | ||
| 198 | @<Print the...@>= | 212 | @<Print the...@>= |
| 199 | if (file_count>1) { | 213 | if (file_count>1 || silent) { |
| 200 | wc_print(which, tot_char_count, tot_word_count, tot_line_count); | 214 | wc_print(which, tot_char_count, tot_word_count, tot_line_count); |
| 201 | printf(" total in %d files\n",file_count); | 215 | if (!file_count) printf("\n"); |
| 216 | else printf(" total in %d file%s\n",file_count,file_count>1?"s":""); | ||
| 202 | } | 217 | } |
| 203 | 218 | ||
| 204 | @ Here now is the function that prints the values according to the | 219 | @ Here now is the function that prints the values according to the |
| @@ -63,7 +63,7 @@ than |buf_size|, so that |buffer[buf_size-1]| is never filled. · 62 unmodified lines | |||
| 63 | Some of the routines use the fact that it is safe to refer to | 63 | Some of the routines use the fact that it is safe to refer to |
| 64 | |*(limit+2)| without overstepping the bounds of the array. | 64 | |*(limit+2)| without overstepping the bounds of the array. |
| 65 | 65 | ||
| 66 | @d buf_size 100 | 66 | @d buf_size 1024 |
| 67 | 67 | ||
| 68 | @<Definitions...@>= | 68 | @<Definitions...@>= |
| 69 | ASCII buffer[buf_size]; /* where each line of input goes */ | 69 | ASCII buffer[buf_size]; /* where each line of input goes */ |
| @@ -70,7 +70,7 @@ We use \\{in}, \\{out}, \\{back} and · 69 unmodified lines | |||
| 70 | \+& |lpar| |rpar| & |exp| \hfill $L\.{\\,}R$ & functions, declarations\cr | 70 | \+& |lpar| |rpar| & |exp| \hfill $L\.{\\,}R$ & functions, declarations\cr |
| 71 | \+& |lpar| \alt |decl_head| |int_like| |rpar| & |cast| & |(char*)|\cr | 71 | \+& |lpar| \alt |decl_head| |int_like| |rpar| & |cast| & |(char*)|\cr |
| 72 | \+& |lpar| \altt |decl_head| |int_like| |exp| |comma| & |lpar| \hfill | 72 | \+& |lpar| \altt |decl_head| |int_like| |exp| |comma| & |lpar| \hfill |
| 73 | L\,\altt $D$ $I$ $E$ C\,|opt|9 & |(int,|\cr | 73 | $L$\,\altt $D$ $I$ $E$ C\,|opt|9 & |(int,|\cr |
| 74 | \+& |lpar| \alt |stmt| |decl| & |lpar| \hfill \alt {$LS\.\ $} {$LD\.\ $} & | 74 | \+& |lpar| \alt |stmt| |decl| & |lpar| \hfill \alt {$LS\.\ $} {$LD\.\ $} & |
| 75 | \alt {|(k=5;|} {|(int k=5;|} \cr | 75 | \alt {|(k=5;|} {|(int k=5;|} \cr |
| 76 | \+& |question| |exp| |colon| & |binop| & |?x:|\cr | 76 | \+& |question| |exp| |colon| & |binop| & |?x:|\cr |
| @@ -197,14 +197,14 @@ We use \\{in}, \\{out}, \\{back} and · 120 unmodified lines | |||
| 197 | &$\langle\,$section name$\,\rangle$;\cr | 197 | &$\langle\,$section name$\,\rangle$;\cr |
| 198 | \+& |section_scrap| & |exp| &$\langle\,$section name$\,\rangle$\cr | 198 | \+& |section_scrap| & |exp| &$\langle\,$section name$\,\rangle$\cr |
| 199 | \+& |insert| |any| & |any| & \.{\v\#include\v}\cr | 199 | \+& |insert| |any| & |any| & \.{\v\#include\v}\cr |
| 200 | \+& |prelangle| & |binop| \hfill $<$ & $<$ not in template\cr | 200 | \+& |prelangle| & |binop| \hfill \.< & $<$ not in template\cr |
| 201 | \+& |prerangle| & |binop| \hfill $>$ & $>$ not in template\cr | 201 | \+& |prerangle| & |binop| \hfill \.> & $>$ not in template\cr |
| 202 | \+& |langle| |exp| |prerangle| & |cast| & $\langle\,0\,\rangle$\cr | 202 | \+& |langle| |exp| |prerangle| & |cast| & $\langle\,0\,\rangle$\cr |
| 203 | \+& |langle| |prerangle| & |cast| \hfill $L\.{\\,}P$ & $\langle\,\rangle$\cr | 203 | \+& |langle| |prerangle| & |cast| \hfill $L\.{\\,}P$ & $\langle\,\rangle$\cr |
| 204 | \+& |langle| \alt|decl_head| |int_like| |prerangle| & |cast| & | 204 | \+& |langle| \alt|decl_head| |int_like| |prerangle| & |cast| & |
| 205 | $\langle\&{class}\,\&C\rangle$\cr | 205 | $\langle\&{class}\,\&C\rangle$\cr |
| 206 | \+& |langle| \alt|decl_head| |int_like| |comma| & |langle| \hfill | 206 | \+& |langle| \alt|decl_head| |int_like| |comma| & |langle| \hfill |
| 207 | L\,\alt $D$ $I$ C\,|opt|9 & $\langle\&{class}\,\&C,$\cr | 207 | $L$\,\alt $D$ $I$ C\,|opt|9 & $\langle\&{class}\,\&C,$\cr |
| 208 | \+& |public_like| |colon| & |tag| & \&{private}:\cr | 208 | \+& |public_like| |colon| & |tag| & \&{private}:\cr |
| 209 | \+& |public_like| & |int_like| & \&{private}\cr | 209 | \+& |public_like| & |int_like| & \&{private}\cr |
| 210 | \+& |colcol| \alt|exp| |int_like| & \alt|exp| |int_like| & |::x|\cr | 210 | \+& |colcol| \alt|exp| |int_like| & \alt|exp| |int_like| & |::x|\cr |
| @@ -224,7 +224,8 @@ We use \\{in}, \\{out}, \\{back} and · 13 unmodified lines | |||
| 224 | : \&{public} $a$,\cr | 224 | : \&{public} $a$,\cr |
| 225 | \+& |base| |public_like| |exp| & |base| |int_like| \hfill $I=P\.\ E$ & | 225 | \+& |base| |public_like| |exp| & |base| |int_like| \hfill $I=P\.\ E$ & |
| 226 | : \&{public} $a$\cr | 226 | : \&{public} $a$\cr |
| 227 | \+& |raw_rpar| |const_like| & |raw_rpar| \hfill $R\.\ C$ & ) \&{const};\cr | 227 | \+\dag\theprodno& |raw_rpar| |const_like| & |raw_rpar| \hfill $R\.\ C$ & |
| 228 | ) \&{const};\cr | ||
| 228 | \+& |raw_rpar| & |rpar| & );\cr | 229 | \+& |raw_rpar| & |rpar| & );\cr |
| 229 | \+& |raw_unorbin| |const_like| & |raw_unorbin| \hfill $RC$\.{\\\ } | 230 | \+& |raw_unorbin| |const_like| & |raw_unorbin| \hfill $RC$\.{\\\ } |
| 230 | & $*$\&{const} |x|\cr | 231 | & $*$\&{const} |x|\cr |
| @@ -262,4 +263,7 @@ Rule 96: The |new_like| must not be immediately followed by |lpar|, · 31 unmodified lines | |||
| 262 | Rule 97: The operator after |operator_like| | 263 | Rule 97: The operator after |operator_like| |
| 263 | must not be immediately followed by a |binop|. | 264 | must not be immediately followed by a |binop|. |
| 264 | 265 | ||
| 266 | Rule 103: The operator after |const_like| must be |semi|, |lbrace|, |comma|, | ||
| 267 | |binop|, or |const_like|. | ||
| 268 | |||
| 265 | \endgroup | 269 | \endgroup |