1/*1:*/ 2#line 64 "cwebdir/ctangle.w" 3 4/*5:*/ 5#line 35 "cwebdir/common.h" 6 7#line 121 "cwebdir/ctang-w2c.ch" 8#include <kpathsea/kpathsea.h> 9#include <stdio.h> 10#line 37 "cwebdir/common.h" 11 12/*:5*//*61:*/ 13#line 888 "cwebdir/ctangle.w" 14 15#line 890 "cwebdir/ctangle.w" 16#include <stdlib.h> 17 18/*:61*/ 19#line 65 "cwebdir/ctangle.w" 20 21#define banner "This is CTANGLE, Version 3.64" \ 22 23#define max_bytes 1000000 \ 24 25#define max_toks 1000000 26#define max_names 10239 \ 27 28#define max_texts 10239 29#define hash_size 8501 30#define longest_name 10000 31#define stack_size 50 32#define buf_size 1000 \ 33 34#define ctangle 0 35#define cweave 1 \ 36 37#define and_and 04 38#define lt_lt 020 39#define gt_gt 021 40#define plus_plus 013 41#define minus_minus 01 42#define minus_gt 031 43#define not_eq 032 44#define lt_eq 034 45#define gt_eq 035 46#define eq_eq 036 47#define or_or 037 48#define dot_dot_dot 016 49#define colon_colon 06 50#define period_ast 026 51#define minus_gt_ast 027 \ 52 53#define xisalpha(c) (isalpha((eight_bits) c) &&((eight_bits) c<0200) ) 54#define xisdigit(c) (isdigit((eight_bits) c) &&((eight_bits) c<0200) ) 55#define xisspace(c) (isspace((eight_bits) c) &&((eight_bits) c<0200) ) 56#define xislower(c) (islower((eight_bits) c) &&((eight_bits) c<0200) ) 57#define xisupper(c) (isupper((eight_bits) c) &&((eight_bits) c<0200) ) 58#define xisxdigit(c) (isxdigit((eight_bits) c) &&((eight_bits) c<0200) ) \ 59 60#define length(c) (c+1) ->byte_start-(c) ->byte_start 61#define print_id(c) term_write((c) ->byte_start,length((c) ) ) 62#define llink link 63#define rlink dummy.Rlink 64#define root name_dir->rlink \ 65 66#define chunk_marker 0 \ 67 68#define spotless 0 69#define harmless_message 1 70#define error_message 2 71#define fatal_message 3 72#define mark_harmless {if(history==spotless) history= harmless_message;} 73#define mark_error history= error_message 74#define confusion(s) fatal("! This can't happen: ",s) \ 75 76#define max_file_name_length 1024 77#define cur_file file[include_depth] 78#define cur_file_name file_name[include_depth] 79#define web_file_name file_name[0] 80#define cur_line line[include_depth] \ 81 82#define show_banner flags['b'] 83#define show_progress flags['p'] 84#define show_happiness flags['h'] \ 85 86#define update_terminal fflush(stdout) 87#define new_line putchar('\n') 88#define putxchar putchar 89#define term_write(a,b) fflush(stdout) ,fwrite(a,sizeof(char) ,b,stdout) 90#define C_printf(c,a) fprintf(C_file,c,a) 91#define C_putc(c) putc(c,C_file) \ 92 93#define equiv equiv_or_xref \ 94 95#define section_flag max_texts \ 96 97#define string 02 98#define join 0177 99#define output_defs_flag (2*024000-1) \ 100 101#define cur_end cur_state.end_field 102#define cur_byte cur_state.byte_field 103#define cur_name cur_state.name_field 104#define cur_repl cur_state.repl_field 105#define cur_section cur_state.section_field \ 106 107#define section_number 0201 108#define identifier 0202 \ 109 110#define normal 0 111#define num_or_id 1 112#define post_slash 2 113#define unbreakable 3 114#define verbatim 4 \ 115 116#define max_files 256 117#define translit_length 10 \ 118 119#define ignore 0 120#define ord 0302 121#define control_text 0303 122#define translit_code 0304 123#define output_defs_code 0305 124#define format_code 0306 125#define definition 0307 126#define begin_C 0310 127#define section_name 0311 128#define new_section 0312 \ 129 130#define constant 03 \ 131 132#define isxalpha(c) ((c) =='_'||(c) =='$') \ 133 134#define ishigh(c) ((unsigned char) (c) > 0177) \ 135 \ 136 137#define compress(c) if(loc++<=limit) return(c) \ 138 139#define macro 0 140#define app_repl(c) {if(tok_ptr==tok_mem_end) overflow("token") ;*tok_ptr++= c;} \ 141 142 143#line 66 "cwebdir/ctangle.w" 144 145/*4:*/ 146#line 29 "cwebdir/common.h" 147 148#line 31 "cwebdir/common.h" 149typedef char unsigned eight_bits; 150extern boolean program; 151extern int phase; 152 153/*:4*//*6:*/ 154#line 57 "cwebdir/common.h" 155 156char section_text[longest_name+1]; 157char*section_text_end= section_text+longest_name; 158char*id_first; 159char*id_loc; 160 161/*:6*//*7:*/ 162#line 72 "cwebdir/common.h" 163 164extern char buffer[]; 165extern char*buffer_end; 166extern char*loc; 167extern char*limit; 168 169/*:7*//*8:*/ 170#line 87 "cwebdir/common.h" 171 172typedef struct name_info{ 173char*byte_start; 174struct name_info*link; 175union{ 176struct name_info*Rlink; 177 178char Ilk; 179}dummy; 180char*equiv_or_xref; 181}name_info; 182typedef name_info*name_pointer; 183typedef name_pointer*hash_pointer; 184extern char byte_mem[]; 185extern char*byte_mem_end; 186extern name_info name_dir[]; 187extern name_pointer name_dir_end; 188extern name_pointer name_ptr; 189extern char*byte_ptr; 190extern name_pointer hash[]; 191extern hash_pointer hash_end; 192extern hash_pointer h; 193#line 148 "cwebdir/ctang-w2c.ch" 194#include "cwebboot.h" 195#line 112 "cwebdir/common.h" 196 197/*:8*//*9:*/ 198#line 122 "cwebdir/common.h" 199 200#line 160 "cwebdir/ctang-w2c.ch" 201extern int history; 202#line 128 "cwebdir/common.h" 203 204/*:9*//*10:*/ 205#line 137 "cwebdir/common.h" 206 207#line 174 "cwebdir/ctang-w2c.ch" 208extern int include_depth; 209#line 139 "cwebdir/common.h" 210extern FILE*file[]; 211extern FILE*change_file; 212extern char C_file_name[]; 213extern char tex_file_name[]; 214extern char idx_file_name[]; 215extern char scn_file_name[]; 216extern char file_name[][max_file_name_length]; 217 218extern char change_file_name[]; 219#line 181 "cwebdir/ctang-w2c.ch" 220extern int line[]; 221extern int change_line; 222#line 150 "cwebdir/common.h" 223extern boolean input_has_ended; 224extern boolean changing; 225extern boolean web_file_open; 226#line 156 "cwebdir/common.h" 227 228/*:10*//*11:*/ 229#line 158 "cwebdir/common.h" 230 231typedef unsigned short sixteen_bits; 232extern sixteen_bits section_count; 233extern boolean changed_section[]; 234extern boolean change_pending; 235extern boolean print_where; 236 237/*:11*//*12:*/ 238#line 170 "cwebdir/common.h" 239 240extern int argc; 241extern char**argv; 242extern boolean flags[]; 243 244/*:12*//*13:*/ 245#line 182 "cwebdir/common.h" 246 247extern FILE*C_file; 248extern FILE*tex_file; 249extern FILE*idx_file; 250extern FILE*scn_file; 251extern FILE*active_file; 252 253/*:13*//*14:*/ 254#line 191 "cwebdir/common.h" 255 256#line 128 "cwebdir/ctangle.w" 257 258/*:14*/ 259#line 67 "cwebdir/ctangle.w" 260 261/*15:*/ 262#line 152 "cwebdir/ctangle.w" 263 264typedef struct{ 265eight_bits*tok_start; 266sixteen_bits text_link; 267}text; 268typedef text*text_pointer; 269 270/*:15*//*26:*/ 271#line 296 "cwebdir/ctangle.w" 272 273typedef struct{ 274eight_bits*end_field; 275eight_bits*byte_field; 276name_pointer name_field; 277text_pointer repl_field; 278sixteen_bits section_field; 279}output_state; 280typedef output_state*stack_pointer; 281 282/*:26*/ 283#line 68 "cwebdir/ctangle.w" 284 285/*16:*/ 286#line 159 "cwebdir/ctangle.w" 287 288text text_info[max_texts]; 289text_pointer text_info_end= text_info+max_texts-1; 290text_pointer text_ptr; 291eight_bits tok_mem[max_toks]; 292eight_bits*tok_mem_end= tok_mem+max_toks-1; 293eight_bits*tok_ptr; 294 295/*:16*//*22:*/ 296#line 227 "cwebdir/ctangle.w" 297 298text_pointer last_unnamed; 299 300/*:22*//*27:*/ 301#line 312 "cwebdir/ctangle.w" 302 303output_state cur_state; 304 305output_state stack[stack_size+1]; 306stack_pointer stack_ptr; 307stack_pointer stack_end= stack+stack_size; 308 309/*:27*//*31:*/ 310#line 384 "cwebdir/ctangle.w" 311 312int cur_val; 313 314/*:31*//*35:*/ 315#line 473 "cwebdir/ctangle.w" 316 317eight_bits out_state; 318boolean protect; 319 320/*:35*//*37:*/ 321#line 502 "cwebdir/ctangle.w" 322 323name_pointer output_files[max_files]; 324name_pointer*cur_out_file,*end_output_files,*an_output_file; 325char cur_section_name_char; 326char output_file_name[longest_name]; 327 328/*:37*//*44:*/ 329#line 599 "cwebdir/ctangle.w" 330 331boolean output_defs_seen= 0; 332 333/*:44*//*50:*/ 334#line 710 "cwebdir/ctangle.w" 335 336char translit[128][translit_length]; 337 338/*:50*//*55:*/ 339#line 789 "cwebdir/ctangle.w" 340 341eight_bits ccode[256]; 342 343/*:55*//*58:*/ 344#line 845 "cwebdir/ctangle.w" 345 346boolean comment_continues= 0; 347 348/*:58*//*60:*/ 349#line 884 "cwebdir/ctangle.w" 350 351name_pointer cur_section_name; 352int no_where; 353 354/*:60*//*74:*/ 355#line 1195 "cwebdir/ctangle.w" 356 357text_pointer cur_text; 358eight_bits next_control; 359 360/*:74*//*81:*/ 361#line 1350 "cwebdir/ctangle.w" 362 363extern sixteen_bits section_count; 364 365/*:81*/ 366#line 69 "cwebdir/ctangle.w" 367 368/*40:*/ 369#line 533 "cwebdir/ctangle.w" 370 371#line 283 "cwebdir/ctang-w2c.ch" 372static void phase_two(void); 373#line 535 "cwebdir/ctangle.w" 374 375/*:40*//*45:*/ 376#line 602 "cwebdir/ctangle.w" 377 378#line 309 "cwebdir/ctang-w2c.ch" 379static void output_defs(void); 380#line 604 "cwebdir/ctangle.w" 381 382/*:45*//*47:*/ 383#line 648 "cwebdir/ctangle.w" 384 385#line 327 "cwebdir/ctang-w2c.ch" 386static void out_char(eight_bits); 387#line 650 "cwebdir/ctangle.w" 388 389/*:47*//*89:*/ 390#line 1457 "cwebdir/ctangle.w" 391 392#line 441 "cwebdir/ctang-w2c.ch" 393static void phase_one(void); 394#line 1459 "cwebdir/ctangle.w" 395 396/*:89*//*91:*/ 397#line 1475 "cwebdir/ctangle.w" 398 399#line 459 "cwebdir/ctang-w2c.ch" 400static void skip_limbo(void); 401#line 1477 "cwebdir/ctangle.w" 402 403/*:91*/ 404#line 70 "cwebdir/ctangle.w" 405 406 407#line 83 "cwebdir/ctangle.w" 408 409/*:1*//*2:*/ 410#line 91 "cwebdir/ctangle.w" 411 412#line 70 "cwebdir/ctang-w2c.ch" 413int main(int ac,char**av) 414#line 95 "cwebdir/ctangle.w" 415{ 416argc= ac;argv= av; 417program= ctangle; 418/*17:*/ 419#line 167 "cwebdir/ctangle.w" 420 421text_info->tok_start= tok_ptr= tok_mem; 422text_ptr= text_info+1;text_ptr->tok_start= tok_mem; 423 424 425/*:17*//*19:*/ 426#line 177 "cwebdir/ctangle.w" 427 428name_dir->equiv= (char*)text_info; 429 430/*:19*//*23:*/ 431#line 230 "cwebdir/ctangle.w" 432last_unnamed= text_info;text_info->text_link= 0; 433 434/*:23*//*38:*/ 435#line 512 "cwebdir/ctangle.w" 436 437cur_out_file= end_output_files= output_files+max_files; 438 439/*:38*//*51:*/ 440#line 713 "cwebdir/ctangle.w" 441 442{ 443int i; 444for(i= 0;i<128;i++)sprintf(translit[i],"X%02X",(unsigned)(128+i)); 445} 446 447/*:51*//*56:*/ 448#line 792 "cwebdir/ctangle.w" 449{ 450int c; 451for(c= 0;c<256;c++)ccode[c]= ignore; 452ccode[' ']= ccode['\t']= ccode['\n']= ccode['\v']= ccode['\r']= ccode['\f'] 453= ccode['*']= new_section; 454ccode['@']= '@';ccode['=']= string; 455ccode['d']= ccode['D']= definition; 456ccode['f']= ccode['F']= ccode['s']= ccode['S']= format_code; 457ccode['c']= ccode['C']= ccode['p']= ccode['P']= begin_C; 458ccode['^']= ccode[':']= ccode['.']= ccode['t']= ccode['T']= 459ccode['q']= ccode['Q']= control_text; 460ccode['h']= ccode['H']= output_defs_code; 461ccode['l']= ccode['L']= translit_code; 462ccode['&']= join; 463ccode['<']= ccode['(']= section_name; 464ccode['\'']= ord; 465} 466 467/*:56*//*70:*/ 468#line 1116 "cwebdir/ctangle.w" 469section_text[0]= ' '; 470 471/*:70*/ 472#line 98 "cwebdir/ctangle.w" 473; 474common_init(); 475#line 76 "cwebdir/ctang-w2c.ch" 476if(show_banner){ 477printf("%s%s\n",banner,versionstring); 478} 479#line 101 "cwebdir/ctangle.w" 480phase_one(); 481phase_two(); 482return wrap_up(); 483} 484 485/*:2*//*20:*/ 486#line 183 "cwebdir/ctangle.w" 487 488#line 207 "cwebdir/ctang-w2c.ch" 489int names_match(name_pointer p,const char*first,int l,char t) 490#line 188 "cwebdir/ctangle.w" 491{ 492if(length(p)!=l)return 0; 493return!strncmp(first,p->byte_start,l); 494} 495 496/*:20*//*21:*/ 497#line 198 "cwebdir/ctangle.w" 498 499void 500#line 216 "cwebdir/ctang-w2c.ch" 501 init_node(name_pointer node) 502#line 202 "cwebdir/ctangle.w" 503{ 504node->equiv= (char*)text_info; 505} 506void 507#line 222 "cwebdir/ctang-w2c.ch" 508 init_p(name_pointer p,char t){} 509#line 207 "cwebdir/ctangle.w" 510 511/*:21*//*25:*/ 512#line 260 "cwebdir/ctangle.w" 513 514#line 232 "cwebdir/ctang-w2c.ch" 515static void 516store_two_bytes(sixteen_bits x) 517#line 264 "cwebdir/ctangle.w" 518{ 519if(tok_ptr+2> tok_mem_end)overflow("token"); 520*tok_ptr++= x>>8; 521*tok_ptr++= x&0377; 522} 523 524/*:25*//*29:*/ 525#line 336 "cwebdir/ctangle.w" 526 527#line 243 "cwebdir/ctang-w2c.ch" 528static void 529push_level(name_pointer p) 530#line 340 "cwebdir/ctangle.w" 531{ 532if(stack_ptr==stack_end)overflow("stack"); 533*stack_ptr= cur_state; 534stack_ptr++; 535if(p!=NULL){ 536cur_name= p;cur_repl= (text_pointer)p->equiv; 537cur_byte= cur_repl->tok_start;cur_end= (cur_repl+1)->tok_start; 538cur_section= 0; 539} 540} 541 542/*:29*//*30:*/ 543#line 355 "cwebdir/ctangle.w" 544 545#line 254 "cwebdir/ctang-w2c.ch" 546static void 547pop_level(int flag) 548#line 359 "cwebdir/ctangle.w" 549{ 550if(flag&&cur_repl->text_link<section_flag){ 551cur_repl= cur_repl->text_link+text_info; 552cur_byte= cur_repl->tok_start;cur_end= (cur_repl+1)->tok_start; 553return; 554} 555stack_ptr--; 556if(stack_ptr> stack)cur_state= *stack_ptr; 557} 558 559/*:30*//*32:*/ 560#line 391 "cwebdir/ctangle.w" 561 562#line 264 "cwebdir/ctang-w2c.ch" 563static void 564get_output(void) 565#line 394 "cwebdir/ctangle.w" 566{ 567sixteen_bits a; 568restart:if(stack_ptr==stack)return; 569if(cur_byte==cur_end){ 570cur_val= -((int)cur_section); 571pop_level(1); 572if(cur_val==0)goto restart; 573out_char(section_number);return; 574} 575a= *cur_byte++; 576if(out_state==verbatim&&a!=string&&a!=constant&&a!='\n') 577C_putc(a); 578else if(a<0200)out_char(a); 579else{ 580a= (a-0200)*0400+*cur_byte++; 581switch(a/024000){ 582case 0:cur_val= a;out_char(identifier);break; 583case 1:if(a==output_defs_flag)output_defs(); 584else/*33:*/ 585#line 423 "cwebdir/ctangle.w" 586 587{ 588a-= 024000; 589if((a+name_dir)->equiv!=(char*)text_info)push_level(a+name_dir); 590else if(a!=0){ 591printf("\n! Not present: <"); 592print_section_name(a+name_dir);err_print(">"); 593 594} 595goto restart; 596} 597 598/*:33*/ 599#line 412 "cwebdir/ctangle.w" 600; 601break; 602default:cur_val= a-050000;if(cur_val> 0)cur_section= cur_val; 603out_char(section_number); 604} 605} 606} 607 608/*:32*//*36:*/ 609#line 481 "cwebdir/ctangle.w" 610 611#line 274 "cwebdir/ctang-w2c.ch" 612static void 613flush_buffer(void) 614#line 484 "cwebdir/ctangle.w" 615{ 616C_putc('\n'); 617if(cur_line%100==0&&show_progress){ 618printf("."); 619if(cur_line%500==0)printf("%d",cur_line); 620update_terminal; 621} 622cur_line++; 623} 624 625/*:36*//*41:*/ 626#line 536 "cwebdir/ctangle.w" 627 628#line 292 "cwebdir/ctang-w2c.ch" 629static void 630phase_two(void){ 631#line 539 "cwebdir/ctangle.w" 632web_file_open= 0; 633cur_line= 1; 634/*28:*/ 635#line 325 "cwebdir/ctangle.w" 636 637stack_ptr= stack+1;cur_name= name_dir;cur_repl= text_info->text_link+text_info; 638cur_byte= cur_repl->tok_start;cur_end= (cur_repl+1)->tok_start;cur_section= 0; 639 640/*:28*/ 641#line 541 "cwebdir/ctangle.w" 642; 643/*43:*/ 644#line 595 "cwebdir/ctangle.w" 645 646if(!output_defs_seen) 647output_defs(); 648 649/*:43*/ 650#line 542 "cwebdir/ctangle.w" 651; 652if(text_info->text_link==0&&cur_out_file==end_output_files){ 653printf("\n! No program text was specified.");mark_harmless; 654 655} 656else{ 657if(cur_out_file==end_output_files){ 658if(show_progress) 659printf("\nWriting the output file (%s):",C_file_name); 660} 661else{ 662if(show_progress){ 663printf("\nWriting the output files:"); 664 665printf(" (%s)",C_file_name); 666update_terminal; 667} 668if(text_info->text_link==0)goto writeloop; 669} 670while(stack_ptr> stack)get_output(); 671flush_buffer(); 672writeloop:/*42:*/ 673#line 572 "cwebdir/ctangle.w" 674 675for(an_output_file= end_output_files;an_output_file> cur_out_file;){ 676an_output_file--; 677sprint_section_name(output_file_name,*an_output_file); 678fclose(C_file); 679#line 301 "cwebdir/ctang-w2c.ch" 680C_file= fopen(output_file_name,"wb"); 681#line 578 "cwebdir/ctangle.w" 682if(C_file==0)fatal("! Cannot open output file:",output_file_name); 683 684printf("\n(%s)",output_file_name);update_terminal; 685cur_line= 1; 686stack_ptr= stack+1; 687cur_name= (*an_output_file); 688cur_repl= (text_pointer)cur_name->equiv; 689cur_byte= cur_repl->tok_start; 690cur_end= (cur_repl+1)->tok_start; 691while(stack_ptr> stack)get_output(); 692flush_buffer(); 693} 694 695/*:42*/ 696#line 563 "cwebdir/ctangle.w" 697; 698if(show_happiness)printf("\nDone."); 699} 700} 701 702/*:41*//*46:*/ 703#line 605 "cwebdir/ctangle.w" 704 705#line 318 "cwebdir/ctang-w2c.ch" 706static void 707output_defs(void) 708#line 608 "cwebdir/ctangle.w" 709{ 710sixteen_bits a; 711push_level(NULL); 712for(cur_text= text_info+1;cur_text<text_ptr;cur_text++) 713if(cur_text->text_link==0){ 714cur_byte= cur_text->tok_start; 715cur_end= (cur_text+1)->tok_start; 716C_printf("%s","#define "); 717out_state= normal; 718protect= 1; 719while(cur_byte<cur_end){ 720a= *cur_byte++; 721if(cur_byte==cur_end&&a=='\n')break; 722if(out_state==verbatim&&a!=string&&a!=constant&&a!='\n') 723C_putc(a); 724 725else if(a<0200)out_char(a); 726else{ 727a= (a-0200)*0400+*cur_byte++; 728if(a<024000){ 729cur_val= a;out_char(identifier); 730} 731else if(a<050000){confusion("macro defs have strange char");} 732else{ 733cur_val= a-050000;cur_section= cur_val;out_char(section_number); 734} 735 736} 737} 738protect= 0; 739flush_buffer(); 740} 741pop_level(0); 742} 743 744/*:46*//*48:*/ 745#line 651 "cwebdir/ctangle.w" 746 747static void 748#line 336 "cwebdir/ctang-w2c.ch" 749 out_char(eight_bits cur_char) 750#line 655 "cwebdir/ctangle.w" 751{ 752char*j,*k; 753restart: 754switch(cur_char){ 755case'\n':if(protect&&out_state!=verbatim)C_putc(' '); 756if(protect||out_state==verbatim)C_putc('\\'); 757flush_buffer();if(out_state!=verbatim)out_state= normal;break; 758/*52:*/ 759#line 719 "cwebdir/ctangle.w" 760 761case identifier: 762if(out_state==num_or_id)C_putc(' '); 763j= (cur_val+name_dir)->byte_start; 764k= (cur_val+name_dir+1)->byte_start; 765while(j<k){ 766if((unsigned char)(*j)<0200)C_putc(*j); 767 768else C_printf("%s",translit[(unsigned char)(*j)-0200]); 769j++; 770} 771out_state= num_or_id;break; 772 773/*:52*/ 774#line 662 "cwebdir/ctangle.w" 775; 776/*53:*/ 777#line 732 "cwebdir/ctangle.w" 778 779case section_number: 780if(cur_val> 0)C_printf("/*%d:*/",cur_val); 781else if(cur_val<0)C_printf("/*:%d*/",-cur_val); 782else if(protect){ 783cur_byte+= 4; 784cur_char= '\n'; 785goto restart; 786}else{ 787sixteen_bits a; 788a= 0400**cur_byte++; 789a+= *cur_byte++; 790C_printf("\n#line %d \"",a); 791 792cur_val= *cur_byte++; 793cur_val= 0400*(cur_val-0200)+*cur_byte++; 794for(j= (cur_val+name_dir)->byte_start,k= (cur_val+name_dir+1)->byte_start; 795j<k;j++){ 796if(*j=='\\'||*j=='"')C_putc('\\'); 797C_putc(*j); 798} 799C_printf("%s","\"\n"); 800} 801break; 802 803/*:53*/ 804#line 663 "cwebdir/ctangle.w" 805; 806/*49:*/ 807#line 681 "cwebdir/ctangle.w" 808 809case plus_plus:C_putc('+');C_putc('+');out_state= normal;break; 810case minus_minus:C_putc('-');C_putc('-');out_state= normal;break; 811case minus_gt:C_putc('-');C_putc('>');out_state= normal;break; 812case gt_gt:C_putc('>');C_putc('>');out_state= normal;break; 813case eq_eq:C_putc('=');C_putc('=');out_state= normal;break; 814case lt_lt:C_putc('<');C_putc('<');out_state= normal;break; 815case gt_eq:C_putc('>');C_putc('=');out_state= normal;break; 816case lt_eq:C_putc('<');C_putc('=');out_state= normal;break; 817case not_eq:C_putc('!');C_putc('=');out_state= normal;break; 818case and_and:C_putc('&');C_putc('&');out_state= normal;break; 819case or_or:C_putc('|');C_putc('|');out_state= normal;break; 820case dot_dot_dot:C_putc('.');C_putc('.');C_putc('.');out_state= normal; 821break; 822case colon_colon:C_putc(':');C_putc(':');out_state= normal;break; 823case period_ast:C_putc('.');C_putc('*');out_state= normal;break; 824case minus_gt_ast:C_putc('-');C_putc('>');C_putc('*');out_state= normal; 825break; 826 827/*:49*/ 828#line 664 "cwebdir/ctangle.w" 829; 830case'=':case'>':C_putc(cur_char);C_putc(' '); 831out_state= normal;break; 832case join:out_state= unbreakable;break; 833case constant:if(out_state==verbatim){ 834out_state= num_or_id;break; 835} 836if(out_state==num_or_id)C_putc(' ');out_state= verbatim;break; 837case string:if(out_state==verbatim)out_state= normal; 838else out_state= verbatim;break; 839case'/':C_putc('/');out_state= post_slash;break; 840case'*':if(out_state==post_slash)C_putc(' '); 841 842default:C_putc(cur_char);out_state= normal;break; 843} 844} 845 846/*:48*//*57:*/ 847#line 813 "cwebdir/ctangle.w" 848 849#line 345 "cwebdir/ctang-w2c.ch" 850static eight_bits 851skip_ahead(void) 852#line 816 "cwebdir/ctangle.w" 853{ 854eight_bits c; 855while(1){ 856if(loc> limit&&(get_line()==0))return(new_section); 857*(limit+1)= '@'; 858while(*loc!='@')loc++; 859if(loc<=limit){ 860loc++;c= ccode[(eight_bits)*loc];loc++; 861if(c!=ignore||*(loc-1)=='>')return(c); 862} 863} 864} 865 866/*:57*//*59:*/ 867#line 848 "cwebdir/ctangle.w" 868 869#line 355 "cwebdir/ctang-w2c.ch" 870static int 871skip_comment(boolean is_long_comment) 872#line 851 "cwebdir/ctangle.w" 873{ 874char c; 875while(1){ 876if(loc> limit){ 877if(is_long_comment){ 878if(get_line())return(comment_continues= 1); 879else{ 880err_print("! Input ended in mid-comment"); 881 882return(comment_continues= 0); 883} 884} 885else return(comment_continues= 0); 886} 887c= *(loc++); 888if(is_long_comment&&c=='*'&&*loc=='/'){ 889loc++;return(comment_continues= 0); 890} 891if(c=='@'){ 892if(ccode[(eight_bits)*loc]==new_section){ 893err_print("! Section name ended in mid-comment");loc--; 894 895return(comment_continues= 0); 896} 897else loc++; 898} 899} 900} 901 902/*:59*//*62:*/ 903#line 900 "cwebdir/ctangle.w" 904 905#line 372 "cwebdir/ctang-w2c.ch" 906static eight_bits 907get_next(void) 908#line 903 "cwebdir/ctangle.w" 909{ 910static int preprocessing= 0; 911eight_bits c; 912while(1){ 913if(loc> limit){ 914if(preprocessing&&*(limit-1)!='\\')preprocessing= 0; 915if(get_line()==0)return(new_section); 916else if(print_where&&!no_where){ 917print_where= 0; 918/*76:*/ 919#line 1225 "cwebdir/ctangle.w" 920 921store_two_bytes(0150000); 922if(changing)id_first= change_file_name; 923else id_first= cur_file_name; 924id_loc= id_first+strlen(id_first); 925if(changing)store_two_bytes((sixteen_bits)change_line); 926else store_two_bytes((sixteen_bits)cur_line); 927#line 409 "cwebdir/ctang-w2c.ch" 928{int a_l= id_lookup(id_first,id_loc,0)-name_dir;app_repl((a_l/0400)+0200); 929app_repl(a_l%0400);} 930#line 1234 "cwebdir/ctangle.w" 931 932/*:76*/ 933#line 912 "cwebdir/ctangle.w" 934; 935} 936else return('\n'); 937} 938c= *loc; 939if(comment_continues||(c=='/'&&(*(loc+1)=='*'||*(loc+1)=='/'))){ 940skip_comment(comment_continues||*(loc+1)=='*'); 941 942if(comment_continues)return('\n'); 943else continue; 944} 945loc++; 946if(xisdigit(c)||c=='.')/*65:*/ 947#line 978 "cwebdir/ctangle.w" 948{ 949id_first= loc-1; 950if(*id_first=='.'&&!xisdigit(*loc))goto mistake; 951if(*id_first=='0'){ 952if(*loc=='x'||*loc=='X'){ 953loc++;while(xisxdigit(*loc))loc++;goto found; 954} 955} 956while(xisdigit(*loc))loc++; 957if(*loc=='.'){ 958loc++; 959while(xisdigit(*loc))loc++; 960} 961if(*loc=='e'||*loc=='E'){ 962if(*++loc=='+'||*loc=='-')loc++; 963while(xisdigit(*loc))loc++; 964} 965found:while(*loc=='u'||*loc=='U'||*loc=='l'||*loc=='L' 966||*loc=='f'||*loc=='F')loc++; 967id_loc= loc; 968return(constant); 969} 970 971/*:65*/ 972#line 924 "cwebdir/ctangle.w" 973 974else if(c=='\''||c=='"'||(c=='L'&&(*loc=='\''||*loc=='"'))) 975/*66:*/ 976#line 1006 "cwebdir/ctangle.w" 977{ 978char delim= c; 979id_first= section_text+1; 980id_loc= section_text;*++id_loc= delim; 981if(delim=='L'){ 982delim= *loc++;*++id_loc= delim; 983} 984while(1){ 985if(loc>=limit){ 986if(*(limit-1)!='\\'){ 987err_print("! String didn't end");loc= limit;break; 988 989} 990if(get_line()==0){ 991err_print("! Input ended in middle of string");loc= buffer;break; 992 993} 994else if(++id_loc<=section_text_end)*id_loc= '\n'; 995 996} 997if((c= *loc++)==delim){ 998if(++id_loc<=section_text_end)*id_loc= c; 999break; 1000} 1001if(c=='\\'){ 1002if(loc>=limit)continue; 1003if(++id_loc<=section_text_end)*id_loc= '\\'; 1004c= *loc++; 1005} 1006if(++id_loc<=section_text_end)*id_loc= c; 1007} 1008if(id_loc>=section_text_end){ 1009printf("\n! String too long: "); 1010 1011term_write(section_text+1,25); 1012err_print("..."); 1013} 1014id_loc++; 1015return(string); 1016} 1017 1018/*:66*/ 1019#line 926 "cwebdir/ctangle.w" 1020 1021else if(isalpha(c)||isxalpha(c)||ishigh(c)) 1022/*64:*/ 1023#line 972 "cwebdir/ctangle.w" 1024{ 1025id_first= --loc; 1026#line 389 "cwebdir/ctang-w2c.ch" 1027while(isalpha((unsigned char)*++loc)||isdigit((unsigned char)*loc)||isxalpha(*loc)||ishigh(*loc)); 1028#line 975 "cwebdir/ctangle.w" 1029id_loc= loc;return(identifier); 1030} 1031 1032/*:64*/ 1033#line 928 "cwebdir/ctangle.w" 1034 1035else if(c=='@')/*67:*/ 1036#line 1050 "cwebdir/ctangle.w" 1037{ 1038c= ccode[(eight_bits)*loc++]; 1039switch(c){ 1040case ignore:continue; 1041case translit_code:err_print("! Use @l in limbo only");continue; 1042 1043case control_text:while((c= skip_ahead())=='@'); 1044 1045if(*(loc-1)!='>') 1046err_print("! Double @ should be used in control text"); 1047 1048continue; 1049case section_name: 1050cur_section_name_char= *(loc-1); 1051/*69:*/ 1052#line 1098 "cwebdir/ctangle.w" 1053{ 1054char*k; 1055/*71:*/ 1056#line 1118 "cwebdir/ctangle.w" 1057 1058k= section_text; 1059while(1){ 1060if(loc> limit&&get_line()==0){ 1061err_print("! Input ended in section name"); 1062 1063loc= buffer+1;break; 1064} 1065c= *loc; 1066/*72:*/ 1067#line 1142 "cwebdir/ctangle.w" 1068 1069if(c=='@'){ 1070c= *(loc+1); 1071if(c=='>'){ 1072loc+= 2;break; 1073} 1074if(ccode[(eight_bits)c]==new_section){ 1075err_print("! Section name didn't end");break; 1076 1077} 1078if(ccode[(eight_bits)c]==section_name){ 1079err_print("! Nesting of section names not allowed");break; 1080 1081} 1082*(++k)= '@';loc++; 1083} 1084 1085/*:72*/ 1086#line 1127 "cwebdir/ctangle.w" 1087; 1088loc++;if(k<section_text_end)k++; 1089if(xisspace(c)){ 1090c= ' ';if(*(k-1)==' ')k--; 1091} 1092*k= c; 1093} 1094if(k>=section_text_end){ 1095printf("\n! Section name too long: "); 1096 1097term_write(section_text+1,25); 1098printf("...");mark_harmless; 1099} 1100if(*k==' '&&k> section_text)k--; 1101 1102/*:71*/ 1103#line 1100 "cwebdir/ctangle.w" 1104; 1105if(k-section_text> 3&&strncmp(k-2,"...",3)==0) 1106cur_section_name= section_lookup(section_text+1,k-3,1); 1107else cur_section_name= section_lookup(section_text+1,k,0); 1108if(cur_section_name_char=='(') 1109/*39:*/ 1110#line 516 "cwebdir/ctangle.w" 1111 1112{ 1113for(an_output_file= cur_out_file; 1114an_output_file<end_output_files;an_output_file++) 1115if(*an_output_file==cur_section_name)break; 1116if(an_output_file==end_output_files){ 1117if(cur_out_file> output_files) 1118*--cur_out_file= cur_section_name; 1119else{ 1120overflow("output files"); 1121} 1122} 1123} 1124 1125/*:39*/ 1126#line 1106 "cwebdir/ctangle.w" 1127; 1128return(section_name); 1129} 1130 1131/*:69*/ 1132#line 1064 "cwebdir/ctangle.w" 1133; 1134case string:/*73:*/ 1135#line 1164 "cwebdir/ctangle.w" 1136{ 1137id_first= loc++;*(limit+1)= '@';*(limit+2)= '>'; 1138while(*loc!='@'||*(loc+1)!='>')loc++; 1139if(loc>=limit)err_print("! Verbatim string didn't end"); 1140 1141id_loc= loc;loc+= 2; 1142return(string); 1143} 1144 1145/*:73*/ 1146#line 1065 "cwebdir/ctangle.w" 1147; 1148case ord:/*68:*/ 1149#line 1077 "cwebdir/ctangle.w" 1150 1151id_first= loc; 1152if(*loc=='\\'){ 1153if(*++loc=='\'')loc++; 1154} 1155while(*loc!='\''){ 1156if(*loc=='@'){ 1157if(*(loc+1)!='@') 1158err_print("! Double @ should be used in ASCII constant"); 1159 1160else loc++; 1161} 1162loc++; 1163if(loc> limit){ 1164err_print("! String didn't end");loc= limit-1;break; 1165 1166} 1167} 1168loc++; 1169return(ord); 1170 1171/*:68*/ 1172#line 1066 "cwebdir/ctangle.w" 1173; 1174default:return(c); 1175} 1176} 1177 1178/*:67*/ 1179#line 929 "cwebdir/ctangle.w" 1180 1181else if(xisspace(c)){ 1182if(!preprocessing||loc> limit)continue; 1183 1184else return(' '); 1185} 1186else if(c=='#'&&loc==buffer+1)preprocessing= 1; 1187mistake:/*63:*/ 1188#line 950 "cwebdir/ctangle.w" 1189 1190switch(c){ 1191case'+':if(*loc=='+')compress(plus_plus);break; 1192case'-':if(*loc=='-'){compress(minus_minus);} 1193#line 382 "cwebdir/ctang-w2c.ch" 1194else if(*loc=='>'){if(*(loc+1)=='*'){loc++;compress(minus_gt_ast);} 1195else compress(minus_gt);}break; 1196#line 956 "cwebdir/ctangle.w" 1197case'.':if(*loc=='*'){compress(period_ast);} 1198else if(*loc=='.'&&*(loc+1)=='.'){ 1199loc++;compress(dot_dot_dot); 1200} 1201break; 1202case':':if(*loc==':')compress(colon_colon);break; 1203case'=':if(*loc=='=')compress(eq_eq);break; 1204case'>':if(*loc=='='){compress(gt_eq);} 1205else if(*loc=='>')compress(gt_gt);break; 1206case'<':if(*loc=='='){compress(lt_eq);} 1207else if(*loc=='<')compress(lt_lt);break; 1208case'&':if(*loc=='&')compress(and_and);break; 1209case'|':if(*loc=='|')compress(or_or);break; 1210case'!':if(*loc=='=')compress(not_eq);break; 1211} 1212 1213/*:63*/ 1214#line 936 "cwebdir/ctangle.w" 1215 1216return(c); 1217} 1218} 1219 1220/*:62*//*75:*/ 1221#line 1199 "cwebdir/ctangle.w" 1222 1223#line 399 "cwebdir/ctang-w2c.ch" 1224static void 1225scan_repl(eight_bits t) 1226#line 1203 "cwebdir/ctangle.w" 1227{ 1228sixteen_bits a; 1229if(t==section_name){/*76:*/ 1230#line 1225 "cwebdir/ctangle.w" 1231 1232store_two_bytes(0150000); 1233if(changing)id_first= change_file_name; 1234else id_first= cur_file_name; 1235id_loc= id_first+strlen(id_first); 1236if(changing)store_two_bytes((sixteen_bits)change_line); 1237else store_two_bytes((sixteen_bits)cur_line); 1238#line 409 "cwebdir/ctang-w2c.ch" 1239{int a_l= id_lookup(id_first,id_loc,0)-name_dir;app_repl((a_l/0400)+0200); 1240app_repl(a_l%0400);} 1241#line 1234 "cwebdir/ctangle.w" 1242 1243/*:76*/ 1244#line 1205 "cwebdir/ctangle.w" 1245;} 1246while(1)switch(a= get_next()){ 1247/*77:*/ 1248#line 1235 "cwebdir/ctangle.w" 1249 1250case identifier:a= id_lookup(id_first,id_loc,0)-name_dir; 1251app_repl((a/0400)+0200); 1252app_repl(a%0400);break; 1253case section_name:if(t!=section_name)goto done; 1254else{ 1255/*78:*/ 1256#line 1268 "cwebdir/ctangle.w" 1257{ 1258char*try_loc= loc; 1259while(*try_loc==' '&&try_loc<limit)try_loc++; 1260if(*try_loc=='+'&&try_loc<limit)try_loc++; 1261while(*try_loc==' '&&try_loc<limit)try_loc++; 1262if(*try_loc=='=')err_print("! Missing `@ ' before a named section"); 1263 1264 1265 1266} 1267 1268/*:78*/ 1269#line 1241 "cwebdir/ctangle.w" 1270; 1271a= cur_section_name-name_dir; 1272app_repl((a/0400)+0250); 1273app_repl(a%0400); 1274/*76:*/ 1275#line 1225 "cwebdir/ctangle.w" 1276 1277store_two_bytes(0150000); 1278if(changing)id_first= change_file_name; 1279else id_first= cur_file_name; 1280id_loc= id_first+strlen(id_first); 1281if(changing)store_two_bytes((sixteen_bits)change_line); 1282else store_two_bytes((sixteen_bits)cur_line); 1283#line 409 "cwebdir/ctang-w2c.ch" 1284{int a_l= id_lookup(id_first,id_loc,0)-name_dir;app_repl((a_l/0400)+0200); 1285app_repl(a_l%0400);} 1286#line 1234 "cwebdir/ctangle.w" 1287 1288/*:76*/ 1289#line 1245 "cwebdir/ctangle.w" 1290;break; 1291} 1292case output_defs_code:if(t!=section_name)err_print("! Misplaced @h"); 1293 1294else{ 1295output_defs_seen= 1; 1296a= output_defs_flag; 1297app_repl((a/0400)+0200); 1298app_repl(a%0400); 1299/*76:*/ 1300#line 1225 "cwebdir/ctangle.w" 1301 1302store_two_bytes(0150000); 1303if(changing)id_first= change_file_name; 1304else id_first= cur_file_name; 1305id_loc= id_first+strlen(id_first); 1306if(changing)store_two_bytes((sixteen_bits)change_line); 1307else store_two_bytes((sixteen_bits)cur_line); 1308#line 409 "cwebdir/ctang-w2c.ch" 1309{int a_l= id_lookup(id_first,id_loc,0)-name_dir;app_repl((a_l/0400)+0200); 1310app_repl(a_l%0400);} 1311#line 1234 "cwebdir/ctangle.w" 1312 1313/*:76*/ 1314#line 1254 "cwebdir/ctangle.w" 1315; 1316} 1317break; 1318case constant:case string: 1319/*79:*/ 1320#line 1279 "cwebdir/ctangle.w" 1321 1322app_repl(a); 1323while(id_first<id_loc){ 1324if(*id_first=='@'){ 1325if(*(id_first+1)=='@')id_first++; 1326else err_print("! Double @ should be used in string"); 1327 1328} 1329app_repl(*id_first++); 1330} 1331app_repl(a);break; 1332 1333/*:79*/ 1334#line 1258 "cwebdir/ctangle.w" 1335; 1336case ord: 1337/*80:*/ 1338#line 1295 "cwebdir/ctangle.w" 1339{ 1340int c= (eight_bits)*id_first; 1341if(c=='\\'){ 1342c= *++id_first; 1343if(c>='0'&&c<='7'){ 1344c-= '0'; 1345if(*(id_first+1)>='0'&&*(id_first+1)<='7'){ 1346c= 8*c+*(++id_first)-'0'; 1347if(*(id_first+1)>='0'&&*(id_first+1)<='7'&&c<32) 1348c= 8*c+*(++id_first)-'0'; 1349} 1350} 1351else switch(c){ 1352case't':c= '\t';break; 1353case'n':c= '\n';break; 1354case'b':c= '\b';break; 1355case'f':c= '\f';break; 1356case'v':c= '\v';break; 1357case'r':c= '\r';break; 1358case'a':c= '\7';break; 1359case'?':c= '?';break; 1360case'x': 1361if(xisdigit(*(id_first+1)))c= *(++id_first)-'0'; 1362else if(xisxdigit(*(id_first+1))){ 1363++id_first; 1364#line 418 "cwebdir/ctang-w2c.ch" 1365c= toupper((unsigned char)*id_first)-'A'+10; 1366#line 1321 "cwebdir/ctangle.w" 1367} 1368if(xisdigit(*(id_first+1)))c= 16*c+*(++id_first)-'0'; 1369else if(xisxdigit(*(id_first+1))){ 1370++id_first; 1371#line 423 "cwebdir/ctang-w2c.ch" 1372c= 16*c+toupper((unsigned char)*id_first)-'A'+10; 1373#line 1326 "cwebdir/ctangle.w" 1374} 1375break; 1376case'\\':c= '\\';break; 1377case'\'':c= '\'';break; 1378case'\"':c= '\"';break; 1379default:err_print("! Unrecognized escape sequence"); 1380 1381} 1382} 1383 1384app_repl(constant); 1385if(c>=100)app_repl('0'+c/100); 1386if(c>=10)app_repl('0'+(c/10)%10); 1387app_repl('0'+c%10); 1388app_repl(constant); 1389} 1390break; 1391 1392/*:80*/ 1393#line 1260 "cwebdir/ctangle.w" 1394; 1395case definition:case format_code:case begin_C:if(t!=section_name)goto done; 1396else{ 1397err_print("! @d, @f and @c are ignored in C text");continue; 1398 1399} 1400case new_section:goto done; 1401 1402/*:77*/ 1403#line 1210 "cwebdir/ctangle.w" 1404 1405case')':app_repl(a); 1406if(t==macro)app_repl(' '); 1407break; 1408default:app_repl(a); 1409} 1410done:next_control= (eight_bits)a; 1411if(text_ptr> text_info_end)overflow("text"); 1412cur_text= text_ptr;(++text_ptr)->tok_start= tok_ptr; 1413} 1414 1415/*:75*//*82:*/ 1416#line 1357 "cwebdir/ctangle.w" 1417 1418#line 432 "cwebdir/ctang-w2c.ch" 1419static void 1420scan_section(void) 1421#line 1360 "cwebdir/ctangle.w" 1422{ 1423name_pointer p; 1424text_pointer q; 1425sixteen_bits a; 1426section_count++;no_where= 1; 1427if(*(loc-1)=='*'&&show_progress){ 1428printf("*%d",section_count);update_terminal; 1429} 1430next_control= 0; 1431while(1){ 1432/*83:*/ 1433#line 1396 "cwebdir/ctangle.w" 1434 1435while(next_control<definition) 1436 1437if((next_control= skip_ahead())==section_name){ 1438loc-= 2;next_control= get_next(); 1439} 1440 1441/*:83*/ 1442#line 1371 "cwebdir/ctangle.w" 1443; 1444if(next_control==definition){ 1445/*84:*/ 1446#line 1403 "cwebdir/ctangle.w" 1447{ 1448while((next_control= get_next())=='\n'); 1449if(next_control!=identifier){ 1450err_print("! Definition flushed, must start with identifier"); 1451 1452continue; 1453} 1454app_repl(((a= id_lookup(id_first,id_loc,0)-name_dir)/0400)+0200); 1455 1456app_repl(a%0400); 1457if(*loc!='('){ 1458app_repl(string);app_repl(' ');app_repl(string); 1459} 1460scan_repl(macro); 1461cur_text->text_link= 0; 1462} 1463 1464/*:84*/ 1465#line 1373 "cwebdir/ctangle.w" 1466 1467continue; 1468} 1469if(next_control==begin_C){ 1470p= name_dir;break; 1471} 1472if(next_control==section_name){ 1473p= cur_section_name; 1474/*85:*/ 1475#line 1428 "cwebdir/ctangle.w" 1476 1477while((next_control= get_next())=='+'); 1478if(next_control!='='&&next_control!=eq_eq) 1479continue; 1480 1481/*:85*/ 1482#line 1381 "cwebdir/ctangle.w" 1483; 1484break; 1485} 1486return; 1487} 1488no_where= print_where= 0; 1489/*86:*/ 1490#line 1433 "cwebdir/ctangle.w" 1491 1492/*87:*/ 1493#line 1438 "cwebdir/ctangle.w" 1494 1495store_two_bytes((sixteen_bits)(0150000+section_count)); 1496 1497 1498/*:87*/ 1499#line 1434 "cwebdir/ctangle.w" 1500; 1501scan_repl(section_name); 1502/*88:*/ 1503#line 1442 "cwebdir/ctangle.w" 1504 1505if(p==name_dir||p==0){ 1506(last_unnamed)->text_link= cur_text-text_info;last_unnamed= cur_text; 1507} 1508else if(p->equiv==(char*)text_info)p->equiv= (char*)cur_text; 1509 1510else{ 1511q= (text_pointer)p->equiv; 1512while(q->text_link<section_flag) 1513q= q->text_link+text_info; 1514q->text_link= cur_text-text_info; 1515} 1516cur_text->text_link= section_flag; 1517 1518 1519/*:88*/ 1520#line 1436 "cwebdir/ctangle.w" 1521; 1522 1523/*:86*/ 1524#line 1387 "cwebdir/ctangle.w" 1525; 1526} 1527 1528/*:82*//*90:*/ 1529#line 1460 "cwebdir/ctangle.w" 1530 1531#line 450 "cwebdir/ctang-w2c.ch" 1532static void 1533phase_one(void){ 1534#line 1463 "cwebdir/ctangle.w" 1535phase= 1; 1536section_count= 0; 1537reset_input(); 1538skip_limbo(); 1539while(!input_has_ended)scan_section(); 1540check_complete(); 1541phase= 2; 1542} 1543 1544/*:90*//*92:*/ 1545#line 1478 "cwebdir/ctangle.w" 1546 1547#line 468 "cwebdir/ctang-w2c.ch" 1548static void 1549skip_limbo(void) 1550#line 1481 "cwebdir/ctangle.w" 1551{ 1552char c; 1553while(1){ 1554if(loc> limit&&get_line()==0)return; 1555*(limit+1)= '@'; 1556while(*loc!='@')loc++; 1557if(loc++<=limit){ 1558c= *loc++; 1559if(ccode[(eight_bits)c]==new_section)break; 1560switch(ccode[(eight_bits)c]){ 1561case translit_code:/*93:*/ 1562#line 1507 "cwebdir/ctangle.w" 1563 1564while(xisspace(*loc)&&loc<limit)loc++; 1565loc+= 3; 1566if(loc> limit||!xisxdigit(*(loc-3))||!xisxdigit(*(loc-2)) 1567||(*(loc-3)>='0'&&*(loc-3)<='7')||!xisspace(*(loc-1))) 1568err_print("! Improper hex number following @l"); 1569 1570else{ 1571unsigned i; 1572char*beg; 1573sscanf(loc-3,"%x",&i); 1574while(xisspace(*loc)&&loc<limit)loc++; 1575beg= loc; 1576while(loc<limit&&(xisalpha(*loc)||xisdigit(*loc)||*loc=='_'))loc++; 1577if(loc-beg>=translit_length) 1578err_print("! Replacement string in @l too long"); 1579 1580else{ 1581strncpy(translit[i-0200],beg,loc-beg); 1582translit[i-0200][loc-beg]= '\0'; 1583} 1584} 1585 1586/*:93*/ 1587#line 1491 "cwebdir/ctangle.w" 1588;break; 1589case format_code:case'@':break; 1590case control_text:if(c=='q'||c=='Q'){ 1591while((c= skip_ahead())=='@'); 1592if(*(loc-1)!='>') 1593err_print("! Double @ should be used in control text"); 1594 1595break; 1596} 1597default:err_print("! Double @ should be used in limbo"); 1598 1599} 1600} 1601} 1602} 1603 1604/*:92*//*94:*/ 1605#line 1533 "cwebdir/ctangle.w" 1606 1607void 1608#line 477 "cwebdir/ctang-w2c.ch" 1609 print_stats(void){ 1610#line 1536 "cwebdir/ctangle.w" 1611printf("\nMemory usage statistics:\n"); 1612printf("%ld names (out of %ld)\n", 1613(long)(name_ptr-name_dir),(long)max_names); 1614printf("%ld replacement texts (out of %ld)\n", 1615(long)(text_ptr-text_info),(long)max_texts); 1616printf("%ld bytes (out of %ld)\n", 1617(long)(byte_ptr-byte_mem),(long)max_bytes); 1618printf("%ld tokens (out of %ld)\n", 1619(long)(tok_ptr-tok_mem),(long)max_toks); 1620} 1621 1622/*:94*/ 1623