Back to index

tetex-bin  3.0
ctangle.c
Go to the documentation of this file.
00001 /*1:*/
00002 #line 64 "ctangle.w"
00003 
00004 /*6:*/
00005 #line 35 "common.h"
00006 
00007 #include <stdio.h> 
00008 
00009 /*:6*//*62:*/
00010 #line 888 "ctangle.w"
00011 
00012 #include <ctype.h>  
00013 #include <stdlib.h>  
00014 
00015 /*:62*/
00016 #line 65 "ctangle.w"
00017 
00018 #define banner "This is CTANGLE (Version 3.64)\n" \
00019 
00020 #define max_bytes 90000 \
00021 
00022 #define max_toks 270000
00023 #define max_names 4000 \
00024 
00025 #define max_texts 2500
00026 #define hash_size 353
00027 #define longest_name 10000
00028 #define stack_size 50
00029 #define buf_size 100 \
00030 
00031 #define ctangle 0
00032 #define cweave 1 \
00033 
00034 #define and_and 04
00035 #define lt_lt 020
00036 #define gt_gt 021
00037 #define plus_plus 013
00038 #define minus_minus 01
00039 #define minus_gt 031
00040 #define not_eq 032
00041 #define lt_eq 034
00042 #define gt_eq 035
00043 #define eq_eq 036
00044 #define or_or 037
00045 #define dot_dot_dot 016
00046 #define colon_colon 06
00047 #define period_ast 026
00048 #define minus_gt_ast 027 \
00049 
00050 #define xisalpha(c) (isalpha(c) &&((eight_bits) c<0200) ) 
00051 #define xisdigit(c) (isdigit(c) &&((eight_bits) c<0200) ) 
00052 #define xisspace(c) (isspace(c) &&((eight_bits) c<0200) ) 
00053 #define xislower(c) (islower(c) &&((eight_bits) c<0200) ) 
00054 #define xisupper(c) (isupper(c) &&((eight_bits) c<0200) ) 
00055 #define xisxdigit(c) (isxdigit(c) &&((eight_bits) c<0200) )  \
00056 
00057 #define length(c) (c+1) ->byte_start-(c) ->byte_start
00058 #define print_id(c) term_write((c) ->byte_start,length((c) ) ) 
00059 #define llink link
00060 #define rlink dummy.Rlink
00061 #define root name_dir->rlink \
00062 
00063 #define chunk_marker 0 \
00064 
00065 #define spotless 0
00066 #define harmless_message 1
00067 #define error_message 2
00068 #define fatal_message 3
00069 #define mark_harmless {if(history==spotless) history= harmless_message;}
00070 #define mark_error history= error_message
00071 #define confusion(s) fatal("! This can't happen: ",s)  \
00072 
00073 #define max_file_name_length 60
00074 #define cur_file file[include_depth]
00075 #define cur_file_name file_name[include_depth]
00076 #define web_file_name file_name[0]
00077 #define cur_line line[include_depth] \
00078 
00079 #define show_banner flags['b']
00080 #define show_progress flags['p']
00081 #define show_happiness flags['h'] \
00082 
00083 #define update_terminal fflush(stdout) 
00084 #define new_line putchar('\n') 
00085 #define putxchar putchar
00086 #define term_write(a,b) fflush(stdout) ,fwrite(a,sizeof(char) ,b,stdout) 
00087 #define C_printf(c,a) fprintf(C_file,c,a) 
00088 #define C_putc(c) putc(c,C_file)  \
00089 
00090 #define equiv equiv_or_xref \
00091 
00092 #define section_flag max_texts \
00093 
00094 #define string 02
00095 #define join 0177
00096 #define output_defs_flag (2*024000-1)  \
00097 
00098 #define cur_end cur_state.end_field
00099 #define cur_byte cur_state.byte_field
00100 #define cur_name cur_state.name_field
00101 #define cur_repl cur_state.repl_field
00102 #define cur_section cur_state.section_field \
00103 
00104 #define section_number 0201
00105 #define identifier 0202 \
00106 
00107 #define normal 0
00108 #define num_or_id 1
00109 #define post_slash 2
00110 #define unbreakable 3
00111 #define verbatim 4 \
00112 
00113 #define max_files 256
00114 #define translit_length 10 \
00115 
00116 #define ignore 0
00117 #define ord 0302
00118 #define control_text 0303
00119 #define translit_code 0304
00120 #define output_defs_code 0305
00121 #define format_code 0306
00122 #define definition 0307
00123 #define begin_C 0310
00124 #define section_name 0311
00125 #define new_section 0312 \
00126 
00127 #define constant 03 \
00128 
00129 #define isxalpha(c) ((c) =='_'||(c) =='$')  \
00130 
00131 #define ishigh(c) ((unsigned char) (c) > 0177)  \
00132  \
00133 
00134 #define compress(c) if(loc++<=limit) return(c)  \
00135 
00136 #define macro 0
00137 #define app_repl(c) {if(tok_ptr==tok_mem_end) overflow("token") ;*tok_ptr++= c;} \
00138 
00139 
00140 #line 66 "ctangle.w"
00141 
00142 /*5:*/
00143 #line 29 "common.h"
00144 
00145 typedef short boolean;
00146 typedef char unsigned eight_bits;
00147 extern boolean program;
00148 extern int phase;
00149 
00150 /*:5*//*7:*/
00151 #line 57 "common.h"
00152 
00153 char section_text[longest_name+1];
00154 char*section_text_end= section_text+longest_name;
00155 char*id_first;
00156 char*id_loc;
00157 
00158 /*:7*//*8:*/
00159 #line 72 "common.h"
00160 
00161 extern char buffer[];
00162 extern char*buffer_end;
00163 extern char*loc;
00164 extern char*limit;
00165 
00166 /*:8*//*9:*/
00167 #line 87 "common.h"
00168 
00169 typedef struct name_info{
00170 char*byte_start;
00171 struct name_info*link;
00172 union{
00173 struct name_info*Rlink;
00174 
00175 char Ilk;
00176 }dummy;
00177 char*equiv_or_xref;
00178 }name_info;
00179 typedef name_info*name_pointer;
00180 typedef name_pointer*hash_pointer;
00181 extern char byte_mem[];
00182 extern char*byte_mem_end;
00183 extern name_info name_dir[];
00184 extern name_pointer name_dir_end;
00185 extern name_pointer name_ptr;
00186 extern char*byte_ptr;
00187 extern name_pointer hash[];
00188 extern hash_pointer hash_end;
00189 extern hash_pointer h;
00190 extern name_pointer id_lookup();
00191 extern name_pointer section_lookup();
00192 extern void print_section_name(),sprint_section_name();
00193 
00194 /*:9*//*10:*/
00195 #line 122 "common.h"
00196 
00197 extern history;
00198 extern err_print();
00199 extern wrap_up();
00200 extern void fatal();
00201 extern void overflow();
00202 
00203 /*:10*//*11:*/
00204 #line 137 "common.h"
00205 
00206 extern include_depth;
00207 extern FILE*file[];
00208 extern FILE*change_file;
00209 extern char C_file_name[];
00210 extern char tex_file_name[];
00211 extern char idx_file_name[];
00212 extern char scn_file_name[];
00213 extern char file_name[][max_file_name_length];
00214 
00215 extern char change_file_name[];
00216 extern line[];
00217 extern change_line;
00218 extern boolean input_has_ended;
00219 extern boolean changing;
00220 extern boolean web_file_open;
00221 extern reset_input();
00222 extern get_line();
00223 extern check_complete();
00224 
00225 /*:11*//*12:*/
00226 #line 158 "common.h"
00227 
00228 typedef unsigned short sixteen_bits;
00229 extern sixteen_bits section_count;
00230 extern boolean changed_section[];
00231 extern boolean change_pending;
00232 extern boolean print_where;
00233 
00234 /*:12*//*13:*/
00235 #line 170 "common.h"
00236 
00237 extern int argc;
00238 extern char**argv;
00239 extern boolean flags[];
00240 
00241 /*:13*//*14:*/
00242 #line 182 "common.h"
00243 
00244 extern FILE*C_file;
00245 extern FILE*tex_file;
00246 extern FILE*idx_file;
00247 extern FILE*scn_file;
00248 extern FILE*active_file;
00249 
00250 /*:14*//*15:*/
00251 #line 191 "common.h"
00252 
00253 extern void common_init();
00254 #line 128 "ctangle.w"
00255 
00256 /*:15*/
00257 #line 67 "ctangle.w"
00258 
00259 /*16:*/
00260 #line 152 "ctangle.w"
00261 
00262 typedef struct{
00263 eight_bits*tok_start;
00264 sixteen_bits text_link;
00265 }text;
00266 typedef text*text_pointer;
00267 
00268 /*:16*//*27:*/
00269 #line 296 "ctangle.w"
00270 
00271 typedef struct{
00272 eight_bits*end_field;
00273 eight_bits*byte_field;
00274 name_pointer name_field;
00275 text_pointer repl_field;
00276 sixteen_bits section_field;
00277 }output_state;
00278 typedef output_state*stack_pointer;
00279 
00280 /*:27*/
00281 #line 68 "ctangle.w"
00282 
00283 /*17:*/
00284 #line 159 "ctangle.w"
00285 
00286 text text_info[max_texts];
00287 text_pointer text_info_end= text_info+max_texts-1;
00288 text_pointer text_ptr;
00289 eight_bits tok_mem[max_toks];
00290 eight_bits*tok_mem_end= tok_mem+max_toks-1;
00291 eight_bits*tok_ptr;
00292 
00293 /*:17*//*23:*/
00294 #line 227 "ctangle.w"
00295 
00296 text_pointer last_unnamed;
00297 
00298 /*:23*//*28:*/
00299 #line 312 "ctangle.w"
00300 
00301 output_state cur_state;
00302 
00303 output_state stack[stack_size+1];
00304 stack_pointer stack_ptr;
00305 stack_pointer stack_end= stack+stack_size;
00306 
00307 /*:28*//*32:*/
00308 #line 384 "ctangle.w"
00309 
00310 int cur_val;
00311 
00312 /*:32*//*36:*/
00313 #line 473 "ctangle.w"
00314 
00315 eight_bits out_state;
00316 boolean protect;
00317 
00318 /*:36*//*38:*/
00319 #line 502 "ctangle.w"
00320 
00321 name_pointer output_files[max_files];
00322 name_pointer*cur_out_file,*end_output_files,*an_output_file;
00323 char cur_section_name_char;
00324 char output_file_name[longest_name];
00325 
00326 /*:38*//*45:*/
00327 #line 599 "ctangle.w"
00328 
00329 boolean output_defs_seen= 0;
00330 
00331 /*:45*//*51:*/
00332 #line 710 "ctangle.w"
00333 
00334 char translit[128][translit_length];
00335 
00336 /*:51*//*56:*/
00337 #line 789 "ctangle.w"
00338 
00339 eight_bits ccode[256];
00340 
00341 /*:56*//*59:*/
00342 #line 845 "ctangle.w"
00343 
00344 boolean comment_continues= 0;
00345 
00346 /*:59*//*61:*/
00347 #line 884 "ctangle.w"
00348 
00349 name_pointer cur_section_name;
00350 int no_where;
00351 
00352 /*:61*//*75:*/
00353 #line 1195 "ctangle.w"
00354 
00355 text_pointer cur_text;
00356 eight_bits next_control;
00357 
00358 /*:75*//*82:*/
00359 #line 1350 "ctangle.w"
00360 
00361 extern sixteen_bits section_count;
00362 
00363 /*:82*/
00364 #line 69 "ctangle.w"
00365 
00366 /*2:*/
00367 #line 77 "ctangle.w"
00368 
00369 extern int strlen();
00370 extern int strcmp();
00371 extern char*strcpy();
00372 extern int strncmp();
00373 extern char*strncpy();
00374 
00375 /*:2*//*41:*/
00376 #line 533 "ctangle.w"
00377 
00378 void phase_two();
00379 
00380 /*:41*//*46:*/
00381 #line 602 "ctangle.w"
00382 
00383 void output_defs();
00384 
00385 /*:46*//*48:*/
00386 #line 648 "ctangle.w"
00387 
00388 static void out_char();
00389 
00390 /*:48*//*90:*/
00391 #line 1457 "ctangle.w"
00392 
00393 void phase_one();
00394 
00395 /*:90*//*92:*/
00396 #line 1475 "ctangle.w"
00397 
00398 void skip_limbo();
00399 
00400 /*:92*/
00401 #line 70 "ctangle.w"
00402 
00403 
00404 /*:1*//*3:*/
00405 #line 91 "ctangle.w"
00406 
00407 int main(ac,av)
00408 int ac;
00409 char**av;
00410 {
00411 argc= ac;argv= av;
00412 program= ctangle;
00413 /*18:*/
00414 #line 167 "ctangle.w"
00415 
00416 text_info->tok_start= tok_ptr= tok_mem;
00417 text_ptr= text_info+1;text_ptr->tok_start= tok_mem;
00418 
00419 
00420 /*:18*//*20:*/
00421 #line 177 "ctangle.w"
00422 
00423 name_dir->equiv= (char*)text_info;
00424 
00425 /*:20*//*24:*/
00426 #line 230 "ctangle.w"
00427 last_unnamed= text_info;text_info->text_link= 0;
00428 
00429 /*:24*//*39:*/
00430 #line 512 "ctangle.w"
00431 
00432 cur_out_file= end_output_files= output_files+max_files;
00433 
00434 /*:39*//*52:*/
00435 #line 713 "ctangle.w"
00436 
00437 {
00438 int i;
00439 for(i= 0;i<128;i++)sprintf(translit[i],"X%02X",(unsigned)(128+i));
00440 }
00441 
00442 /*:52*//*57:*/
00443 #line 792 "ctangle.w"
00444 {
00445 int c;
00446 for(c= 0;c<256;c++)ccode[c]= ignore;
00447 ccode[' ']= ccode['\t']= ccode['\n']= ccode['\v']= ccode['\r']= ccode['\f']
00448 = ccode['*']= new_section;
00449 ccode['@']= '@';ccode['=']= string;
00450 ccode['d']= ccode['D']= definition;
00451 ccode['f']= ccode['F']= ccode['s']= ccode['S']= format_code;
00452 ccode['c']= ccode['C']= ccode['p']= ccode['P']= begin_C;
00453 ccode['^']= ccode[':']= ccode['.']= ccode['t']= ccode['T']= 
00454 ccode['q']= ccode['Q']= control_text;
00455 ccode['h']= ccode['H']= output_defs_code;
00456 ccode['l']= ccode['L']= translit_code;
00457 ccode['&']= join;
00458 ccode['<']= ccode['(']= section_name;
00459 ccode['\'']= ord;
00460 }
00461 
00462 /*:57*//*71:*/
00463 #line 1116 "ctangle.w"
00464 section_text[0]= ' ';
00465 
00466 /*:71*/
00467 #line 98 "ctangle.w"
00468 ;
00469 common_init();
00470 if(show_banner)printf(banner);
00471 phase_one();
00472 phase_two();
00473 return wrap_up();
00474 }
00475 
00476 /*:3*//*21:*/
00477 #line 183 "ctangle.w"
00478 
00479 int names_match(p,first,l)
00480 name_pointer p;
00481 char*first;
00482 int l;
00483 {
00484 if(length(p)!=l)return 0;
00485 return!strncmp(first,p->byte_start,l);
00486 }
00487 
00488 /*:21*//*22:*/
00489 #line 198 "ctangle.w"
00490 
00491 void
00492 init_node(node)
00493 name_pointer node;
00494 {
00495 node->equiv= (char*)text_info;
00496 }
00497 void
00498 init_p(){}
00499 
00500 /*:22*//*26:*/
00501 #line 260 "ctangle.w"
00502 
00503 void
00504 store_two_bytes(x)
00505 sixteen_bits x;
00506 {
00507 if(tok_ptr+2> tok_mem_end)overflow("token");
00508 *tok_ptr++= x>>8;
00509 *tok_ptr++= x&0377;
00510 }
00511 
00512 /*:26*//*30:*/
00513 #line 336 "ctangle.w"
00514 
00515 void
00516 push_level(p)
00517 name_pointer p;
00518 {
00519 if(stack_ptr==stack_end)overflow("stack");
00520 *stack_ptr= cur_state;
00521 stack_ptr++;
00522 if(p!=NULL){
00523 cur_name= p;cur_repl= (text_pointer)p->equiv;
00524 cur_byte= cur_repl->tok_start;cur_end= (cur_repl+1)->tok_start;
00525 cur_section= 0;
00526 }
00527 }
00528 
00529 /*:30*//*31:*/
00530 #line 355 "ctangle.w"
00531 
00532 void
00533 pop_level(flag)
00534 int flag;
00535 {
00536 if(flag&&cur_repl->text_link<section_flag){
00537 cur_repl= cur_repl->text_link+text_info;
00538 cur_byte= cur_repl->tok_start;cur_end= (cur_repl+1)->tok_start;
00539 return;
00540 }
00541 stack_ptr--;
00542 if(stack_ptr> stack)cur_state= *stack_ptr;
00543 }
00544 
00545 /*:31*//*33:*/
00546 #line 391 "ctangle.w"
00547 
00548 void
00549 get_output()
00550 {
00551 sixteen_bits a;
00552 restart:if(stack_ptr==stack)return;
00553 if(cur_byte==cur_end){
00554 cur_val= -((int)cur_section);
00555 pop_level(1);
00556 if(cur_val==0)goto restart;
00557 out_char(section_number);return;
00558 }
00559 a= *cur_byte++;
00560 if(out_state==verbatim&&a!=string&&a!=constant&&a!='\n')
00561 C_putc(a);
00562 else if(a<0200)out_char(a);
00563 else{
00564 a= (a-0200)*0400+*cur_byte++;
00565 switch(a/024000){
00566 case 0:cur_val= a;out_char(identifier);break;
00567 case 1:if(a==output_defs_flag)output_defs();
00568 else/*34:*/
00569 #line 423 "ctangle.w"
00570 
00571 {
00572 a-= 024000;
00573 if((a+name_dir)->equiv!=(char*)text_info)push_level(a+name_dir);
00574 else if(a!=0){
00575 printf("\n! Not present: <");
00576 print_section_name(a+name_dir);err_print(">");
00577 
00578 }
00579 goto restart;
00580 }
00581 
00582 /*:34*/
00583 #line 412 "ctangle.w"
00584 ;
00585 break;
00586 default:cur_val= a-050000;if(cur_val> 0)cur_section= cur_val;
00587 out_char(section_number);
00588 }
00589 }
00590 }
00591 
00592 /*:33*//*37:*/
00593 #line 481 "ctangle.w"
00594 
00595 void
00596 flush_buffer()
00597 {
00598 C_putc('\n');
00599 if(cur_line%100==0&&show_progress){
00600 printf(".");
00601 if(cur_line%500==0)printf("%d",cur_line);
00602 update_terminal;
00603 }
00604 cur_line++;
00605 }
00606 
00607 /*:37*//*42:*/
00608 #line 536 "ctangle.w"
00609 
00610 void
00611 phase_two(){
00612 web_file_open= 0;
00613 cur_line= 1;
00614 /*29:*/
00615 #line 325 "ctangle.w"
00616 
00617 stack_ptr= stack+1;cur_name= name_dir;cur_repl= text_info->text_link+text_info;
00618 cur_byte= cur_repl->tok_start;cur_end= (cur_repl+1)->tok_start;cur_section= 0;
00619 
00620 /*:29*/
00621 #line 541 "ctangle.w"
00622 ;
00623 /*44:*/
00624 #line 595 "ctangle.w"
00625 
00626 if(!output_defs_seen)
00627 output_defs();
00628 
00629 /*:44*/
00630 #line 542 "ctangle.w"
00631 ;
00632 if(text_info->text_link==0&&cur_out_file==end_output_files){
00633 printf("\n! No program text was specified.");mark_harmless;
00634 
00635 }
00636 else{
00637 if(cur_out_file==end_output_files){
00638 if(show_progress)
00639 printf("\nWriting the output file (%s):",C_file_name);
00640 }
00641 else{
00642 if(show_progress){
00643 printf("\nWriting the output files:");
00644 
00645 printf(" (%s)",C_file_name);
00646 update_terminal;
00647 }
00648 if(text_info->text_link==0)goto writeloop;
00649 }
00650 while(stack_ptr> stack)get_output();
00651 flush_buffer();
00652 writeloop:/*43:*/
00653 #line 572 "ctangle.w"
00654 
00655 for(an_output_file= end_output_files;an_output_file> cur_out_file;){
00656 an_output_file--;
00657 sprint_section_name(output_file_name,*an_output_file);
00658 fclose(C_file);
00659 C_file= fopen(output_file_name,"w");
00660 if(C_file==0)fatal("! Cannot open output file:",output_file_name);
00661 
00662 printf("\n(%s)",output_file_name);update_terminal;
00663 cur_line= 1;
00664 stack_ptr= stack+1;
00665 cur_name= (*an_output_file);
00666 cur_repl= (text_pointer)cur_name->equiv;
00667 cur_byte= cur_repl->tok_start;
00668 cur_end= (cur_repl+1)->tok_start;
00669 while(stack_ptr> stack)get_output();
00670 flush_buffer();
00671 }
00672 
00673 /*:43*/
00674 #line 563 "ctangle.w"
00675 ;
00676 if(show_happiness)printf("\nDone.");
00677 }
00678 }
00679 
00680 /*:42*//*47:*/
00681 #line 605 "ctangle.w"
00682 
00683 void
00684 output_defs()
00685 {
00686 sixteen_bits a;
00687 push_level(NULL);
00688 for(cur_text= text_info+1;cur_text<text_ptr;cur_text++)
00689 if(cur_text->text_link==0){
00690 cur_byte= cur_text->tok_start;
00691 cur_end= (cur_text+1)->tok_start;
00692 C_printf("%s","#define ");
00693 out_state= normal;
00694 protect= 1;
00695 while(cur_byte<cur_end){
00696 a= *cur_byte++;
00697 if(cur_byte==cur_end&&a=='\n')break;
00698 if(out_state==verbatim&&a!=string&&a!=constant&&a!='\n')
00699 C_putc(a);
00700 
00701 else if(a<0200)out_char(a);
00702 else{
00703 a= (a-0200)*0400+*cur_byte++;
00704 if(a<024000){
00705 cur_val= a;out_char(identifier);
00706 }
00707 else if(a<050000){confusion("macro defs have strange char");}
00708 else{
00709 cur_val= a-050000;cur_section= cur_val;out_char(section_number);
00710 }
00711 
00712 }
00713 }
00714 protect= 0;
00715 flush_buffer();
00716 }
00717 pop_level(0);
00718 }
00719 
00720 /*:47*//*49:*/
00721 #line 651 "ctangle.w"
00722 
00723 static void
00724 out_char(cur_char)
00725 eight_bits cur_char;
00726 {
00727 char*j,*k;
00728 restart:
00729 switch(cur_char){
00730 case'\n':if(protect&&out_state!=verbatim)C_putc(' ');
00731 if(protect||out_state==verbatim)C_putc('\\');
00732 flush_buffer();if(out_state!=verbatim)out_state= normal;break;
00733 /*53:*/
00734 #line 719 "ctangle.w"
00735 
00736 case identifier:
00737 if(out_state==num_or_id)C_putc(' ');
00738 j= (cur_val+name_dir)->byte_start;
00739 k= (cur_val+name_dir+1)->byte_start;
00740 while(j<k){
00741 if((unsigned char)(*j)<0200)C_putc(*j);
00742 
00743 else C_printf("%s",translit[(unsigned char)(*j)-0200]);
00744 j++;
00745 }
00746 out_state= num_or_id;break;
00747 
00748 /*:53*/
00749 #line 662 "ctangle.w"
00750 ;
00751 /*54:*/
00752 #line 732 "ctangle.w"
00753 
00754 case section_number:
00755 if(cur_val> 0)C_printf("/*%d:*/",cur_val);
00756 else if(cur_val<0)C_printf("/*:%d*/",-cur_val);
00757 else if(protect){
00758 cur_byte+= 4;
00759 cur_char= '\n';
00760 goto restart;
00761 }else{
00762 sixteen_bits a;
00763 a= 0400**cur_byte++;
00764 a+= *cur_byte++;
00765 C_printf("\n#line %d \"",a);
00766 
00767 cur_val= *cur_byte++;
00768 cur_val= 0400*(cur_val-0200)+*cur_byte++;
00769 for(j= (cur_val+name_dir)->byte_start,k= (cur_val+name_dir+1)->byte_start;
00770 j<k;j++){
00771 if(*j=='\\'||*j=='"')C_putc('\\');
00772 C_putc(*j);
00773 }
00774 C_printf("%s","\"\n");
00775 }
00776 break;
00777 
00778 /*:54*/
00779 #line 663 "ctangle.w"
00780 ;
00781 /*50:*/
00782 #line 681 "ctangle.w"
00783 
00784 case plus_plus:C_putc('+');C_putc('+');out_state= normal;break;
00785 case minus_minus:C_putc('-');C_putc('-');out_state= normal;break;
00786 case minus_gt:C_putc('-');C_putc('>');out_state= normal;break;
00787 case gt_gt:C_putc('>');C_putc('>');out_state= normal;break;
00788 case eq_eq:C_putc('=');C_putc('=');out_state= normal;break;
00789 case lt_lt:C_putc('<');C_putc('<');out_state= normal;break;
00790 case gt_eq:C_putc('>');C_putc('=');out_state= normal;break;
00791 case lt_eq:C_putc('<');C_putc('=');out_state= normal;break;
00792 case not_eq:C_putc('!');C_putc('=');out_state= normal;break;
00793 case and_and:C_putc('&');C_putc('&');out_state= normal;break;
00794 case or_or:C_putc('|');C_putc('|');out_state= normal;break;
00795 case dot_dot_dot:C_putc('.');C_putc('.');C_putc('.');out_state= normal;
00796 break;
00797 case colon_colon:C_putc(':');C_putc(':');out_state= normal;break;
00798 case period_ast:C_putc('.');C_putc('*');out_state= normal;break;
00799 case minus_gt_ast:C_putc('-');C_putc('>');C_putc('*');out_state= normal;
00800 break;
00801 
00802 /*:50*/
00803 #line 664 "ctangle.w"
00804 ;
00805 case'=':case'>':C_putc(cur_char);C_putc(' ');
00806 out_state= normal;break;
00807 case join:out_state= unbreakable;break;
00808 case constant:if(out_state==verbatim){
00809 out_state= num_or_id;break;
00810 }
00811 if(out_state==num_or_id)C_putc(' ');out_state= verbatim;break;
00812 case string:if(out_state==verbatim)out_state= normal;
00813 else out_state= verbatim;break;
00814 case'/':C_putc('/');out_state= post_slash;break;
00815 case'*':if(out_state==post_slash)C_putc(' ');
00816 
00817 default:C_putc(cur_char);out_state= normal;break;
00818 }
00819 }
00820 
00821 /*:49*//*58:*/
00822 #line 813 "ctangle.w"
00823 
00824 eight_bits
00825 skip_ahead()
00826 {
00827 eight_bits c;
00828 while(1){
00829 if(loc> limit&&(get_line()==0))return(new_section);
00830 *(limit+1)= '@';
00831 while(*loc!='@')loc++;
00832 if(loc<=limit){
00833 loc++;c= ccode[(eight_bits)*loc];loc++;
00834 if(c!=ignore||*(loc-1)=='>')return(c);
00835 }
00836 }
00837 }
00838 
00839 /*:58*//*60:*/
00840 #line 848 "ctangle.w"
00841 
00842 int skip_comment(is_long_comment)
00843 boolean is_long_comment;
00844 {
00845 char c;
00846 while(1){
00847 if(loc> limit){
00848 if(is_long_comment){
00849 if(get_line())return(comment_continues= 1);
00850 else{
00851 err_print("! Input ended in mid-comment");
00852 
00853 return(comment_continues= 0);
00854 }
00855 }
00856 else return(comment_continues= 0);
00857 }
00858 c= *(loc++);
00859 if(is_long_comment&&c=='*'&&*loc=='/'){
00860 loc++;return(comment_continues= 0);
00861 }
00862 if(c=='@'){
00863 if(ccode[(eight_bits)*loc]==new_section){
00864 err_print("! Section name ended in mid-comment");loc--;
00865 
00866 return(comment_continues= 0);
00867 }
00868 else loc++;
00869 }
00870 }
00871 }
00872 
00873 /*:60*//*63:*/
00874 #line 900 "ctangle.w"
00875 
00876 eight_bits
00877 get_next()
00878 {
00879 static int preprocessing= 0;
00880 eight_bits c;
00881 while(1){
00882 if(loc> limit){
00883 if(preprocessing&&*(limit-1)!='\\')preprocessing= 0;
00884 if(get_line()==0)return(new_section);
00885 else if(print_where&&!no_where){
00886 print_where= 0;
00887 /*77:*/
00888 #line 1225 "ctangle.w"
00889 
00890 store_two_bytes(0150000);
00891 if(changing)id_first= change_file_name;
00892 else id_first= cur_file_name;
00893 id_loc= id_first+strlen(id_first);
00894 if(changing)store_two_bytes((sixteen_bits)change_line);
00895 else store_two_bytes((sixteen_bits)cur_line);
00896 {int a= id_lookup(id_first,id_loc,0)-name_dir;app_repl((a/0400)+0200);
00897 app_repl(a%0400);}
00898 
00899 /*:77*/
00900 #line 912 "ctangle.w"
00901 ;
00902 }
00903 else return('\n');
00904 }
00905 c= *loc;
00906 if(comment_continues||(c=='/'&&(*(loc+1)=='*'||*(loc+1)=='/'))){
00907 skip_comment(comment_continues||*(loc+1)=='*');
00908 
00909 if(comment_continues)return('\n');
00910 else continue;
00911 }
00912 loc++;
00913 if(xisdigit(c)||c=='.')/*66:*/
00914 #line 978 "ctangle.w"
00915 {
00916 id_first= loc-1;
00917 if(*id_first=='.'&&!xisdigit(*loc))goto mistake;
00918 if(*id_first=='0'){
00919 if(*loc=='x'||*loc=='X'){
00920 loc++;while(xisxdigit(*loc))loc++;goto found;
00921 }
00922 }
00923 while(xisdigit(*loc))loc++;
00924 if(*loc=='.'){
00925 loc++;
00926 while(xisdigit(*loc))loc++;
00927 }
00928 if(*loc=='e'||*loc=='E'){
00929 if(*++loc=='+'||*loc=='-')loc++;
00930 while(xisdigit(*loc))loc++;
00931 }
00932 found:while(*loc=='u'||*loc=='U'||*loc=='l'||*loc=='L'
00933 ||*loc=='f'||*loc=='F')loc++;
00934 id_loc= loc;
00935 return(constant);
00936 }
00937 
00938 /*:66*/
00939 #line 924 "ctangle.w"
00940 
00941 else if(c=='\''||c=='"'||(c=='L'&&(*loc=='\''||*loc=='"')))
00942 /*67:*/
00943 #line 1006 "ctangle.w"
00944 {
00945 char delim= c;
00946 id_first= section_text+1;
00947 id_loc= section_text;*++id_loc= delim;
00948 if(delim=='L'){
00949 delim= *loc++;*++id_loc= delim;
00950 }
00951 while(1){
00952 if(loc>=limit){
00953 if(*(limit-1)!='\\'){
00954 err_print("! String didn't end");loc= limit;break;
00955 
00956 }
00957 if(get_line()==0){
00958 err_print("! Input ended in middle of string");loc= buffer;break;
00959 
00960 }
00961 else if(++id_loc<=section_text_end)*id_loc= '\n';
00962 
00963 }
00964 if((c= *loc++)==delim){
00965 if(++id_loc<=section_text_end)*id_loc= c;
00966 break;
00967 }
00968 if(c=='\\'){
00969 if(loc>=limit)continue;
00970 if(++id_loc<=section_text_end)*id_loc= '\\';
00971 c= *loc++;
00972 }
00973 if(++id_loc<=section_text_end)*id_loc= c;
00974 }
00975 if(id_loc>=section_text_end){
00976 printf("\n! String too long: ");
00977 
00978 term_write(section_text+1,25);
00979 err_print("...");
00980 }
00981 id_loc++;
00982 return(string);
00983 }
00984 
00985 /*:67*/
00986 #line 926 "ctangle.w"
00987 
00988 else if(isalpha(c)||isxalpha(c)||ishigh(c))
00989 /*65:*/
00990 #line 972 "ctangle.w"
00991 {
00992 id_first= --loc;
00993 while(isalpha(*++loc)||isdigit(*loc)||isxalpha(*loc)||ishigh(*loc));
00994 id_loc= loc;return(identifier);
00995 }
00996 
00997 /*:65*/
00998 #line 928 "ctangle.w"
00999 
01000 else if(c=='@')/*68:*/
01001 #line 1050 "ctangle.w"
01002 {
01003 c= ccode[(eight_bits)*loc++];
01004 switch(c){
01005 case ignore:continue;
01006 case translit_code:err_print("! Use @l in limbo only");continue;
01007 
01008 case control_text:while((c= skip_ahead())=='@');
01009 
01010 if(*(loc-1)!='>')
01011 err_print("! Double @ should be used in control text");
01012 
01013 continue;
01014 case section_name:
01015 cur_section_name_char= *(loc-1);
01016 /*70:*/
01017 #line 1098 "ctangle.w"
01018 {
01019 char*k;
01020 /*72:*/
01021 #line 1118 "ctangle.w"
01022 
01023 k= section_text;
01024 while(1){
01025 if(loc> limit&&get_line()==0){
01026 err_print("! Input ended in section name");
01027 
01028 loc= buffer+1;break;
01029 }
01030 c= *loc;
01031 /*73:*/
01032 #line 1142 "ctangle.w"
01033 
01034 if(c=='@'){
01035 c= *(loc+1);
01036 if(c=='>'){
01037 loc+= 2;break;
01038 }
01039 if(ccode[(eight_bits)c]==new_section){
01040 err_print("! Section name didn't end");break;
01041 
01042 }
01043 if(ccode[(eight_bits)c]==section_name){
01044 err_print("! Nesting of section names not allowed");break;
01045 
01046 }
01047 *(++k)= '@';loc++;
01048 }
01049 
01050 /*:73*/
01051 #line 1127 "ctangle.w"
01052 ;
01053 loc++;if(k<section_text_end)k++;
01054 if(xisspace(c)){
01055 c= ' ';if(*(k-1)==' ')k--;
01056 }
01057 *k= c;
01058 }
01059 if(k>=section_text_end){
01060 printf("\n! Section name too long: ");
01061 
01062 term_write(section_text+1,25);
01063 printf("...");mark_harmless;
01064 }
01065 if(*k==' '&&k> section_text)k--;
01066 
01067 /*:72*/
01068 #line 1100 "ctangle.w"
01069 ;
01070 if(k-section_text> 3&&strncmp(k-2,"...",3)==0)
01071 cur_section_name= section_lookup(section_text+1,k-3,1);
01072 else cur_section_name= section_lookup(section_text+1,k,0);
01073 if(cur_section_name_char=='(')
01074 /*40:*/
01075 #line 516 "ctangle.w"
01076 
01077 {
01078 for(an_output_file= cur_out_file;
01079 an_output_file<end_output_files;an_output_file++)
01080 if(*an_output_file==cur_section_name)break;
01081 if(an_output_file==end_output_files){
01082 if(cur_out_file> output_files)
01083 *--cur_out_file= cur_section_name;
01084 else{
01085 overflow("output files");
01086 }
01087 }
01088 }
01089 
01090 /*:40*/
01091 #line 1106 "ctangle.w"
01092 ;
01093 return(section_name);
01094 }
01095 
01096 /*:70*/
01097 #line 1064 "ctangle.w"
01098 ;
01099 case string:/*74:*/
01100 #line 1164 "ctangle.w"
01101 {
01102 id_first= loc++;*(limit+1)= '@';*(limit+2)= '>';
01103 while(*loc!='@'||*(loc+1)!='>')loc++;
01104 if(loc>=limit)err_print("! Verbatim string didn't end");
01105 
01106 id_loc= loc;loc+= 2;
01107 return(string);
01108 }
01109 
01110 /*:74*/
01111 #line 1065 "ctangle.w"
01112 ;
01113 case ord:/*69:*/
01114 #line 1077 "ctangle.w"
01115 
01116 id_first= loc;
01117 if(*loc=='\\'){
01118 if(*++loc=='\'')loc++;
01119 }
01120 while(*loc!='\''){
01121 if(*loc=='@'){
01122 if(*(loc+1)!='@')
01123 err_print("! Double @ should be used in ASCII constant");
01124 
01125 else loc++;
01126 }
01127 loc++;
01128 if(loc> limit){
01129 err_print("! String didn't end");loc= limit-1;break;
01130 
01131 }
01132 }
01133 loc++;
01134 return(ord);
01135 
01136 /*:69*/
01137 #line 1066 "ctangle.w"
01138 ;
01139 default:return(c);
01140 }
01141 }
01142 
01143 /*:68*/
01144 #line 929 "ctangle.w"
01145 
01146 else if(xisspace(c)){
01147 if(!preprocessing||loc> limit)continue;
01148 
01149 else return(' ');
01150 }
01151 else if(c=='#'&&loc==buffer+1)preprocessing= 1;
01152 mistake:/*64:*/
01153 #line 950 "ctangle.w"
01154 
01155 switch(c){
01156 case'+':if(*loc=='+')compress(plus_plus);break;
01157 case'-':if(*loc=='-'){compress(minus_minus);}
01158 else if(*loc=='>')if(*(loc+1)=='*'){loc++;compress(minus_gt_ast);}
01159 else compress(minus_gt);break;
01160 case'.':if(*loc=='*'){compress(period_ast);}
01161 else if(*loc=='.'&&*(loc+1)=='.'){
01162 loc++;compress(dot_dot_dot);
01163 }
01164 break;
01165 case':':if(*loc==':')compress(colon_colon);break;
01166 case'=':if(*loc=='=')compress(eq_eq);break;
01167 case'>':if(*loc=='='){compress(gt_eq);}
01168 else if(*loc=='>')compress(gt_gt);break;
01169 case'<':if(*loc=='='){compress(lt_eq);}
01170 else if(*loc=='<')compress(lt_lt);break;
01171 case'&':if(*loc=='&')compress(and_and);break;
01172 case'|':if(*loc=='|')compress(or_or);break;
01173 case'!':if(*loc=='=')compress(not_eq);break;
01174 }
01175 
01176 /*:64*/
01177 #line 936 "ctangle.w"
01178 
01179 return(c);
01180 }
01181 }
01182 
01183 /*:63*//*76:*/
01184 #line 1199 "ctangle.w"
01185 
01186 void
01187 scan_repl(t)
01188 eight_bits t;
01189 {
01190 sixteen_bits a;
01191 if(t==section_name){/*77:*/
01192 #line 1225 "ctangle.w"
01193 
01194 store_two_bytes(0150000);
01195 if(changing)id_first= change_file_name;
01196 else id_first= cur_file_name;
01197 id_loc= id_first+strlen(id_first);
01198 if(changing)store_two_bytes((sixteen_bits)change_line);
01199 else store_two_bytes((sixteen_bits)cur_line);
01200 {int a= id_lookup(id_first,id_loc,0)-name_dir;app_repl((a/0400)+0200);
01201 app_repl(a%0400);}
01202 
01203 /*:77*/
01204 #line 1205 "ctangle.w"
01205 ;}
01206 while(1)switch(a= get_next()){
01207 /*78:*/
01208 #line 1235 "ctangle.w"
01209 
01210 case identifier:a= id_lookup(id_first,id_loc,0)-name_dir;
01211 app_repl((a/0400)+0200);
01212 app_repl(a%0400);break;
01213 case section_name:if(t!=section_name)goto done;
01214 else{
01215 /*79:*/
01216 #line 1268 "ctangle.w"
01217 {
01218 char*try_loc= loc;
01219 while(*try_loc==' '&&try_loc<limit)try_loc++;
01220 if(*try_loc=='+'&&try_loc<limit)try_loc++;
01221 while(*try_loc==' '&&try_loc<limit)try_loc++;
01222 if(*try_loc=='=')err_print("! Missing `@ ' before a named section");
01223 
01224 
01225 
01226 }
01227 
01228 /*:79*/
01229 #line 1241 "ctangle.w"
01230 ;
01231 a= cur_section_name-name_dir;
01232 app_repl((a/0400)+0250);
01233 app_repl(a%0400);
01234 /*77:*/
01235 #line 1225 "ctangle.w"
01236 
01237 store_two_bytes(0150000);
01238 if(changing)id_first= change_file_name;
01239 else id_first= cur_file_name;
01240 id_loc= id_first+strlen(id_first);
01241 if(changing)store_two_bytes((sixteen_bits)change_line);
01242 else store_two_bytes((sixteen_bits)cur_line);
01243 {int a= id_lookup(id_first,id_loc,0)-name_dir;app_repl((a/0400)+0200);
01244 app_repl(a%0400);}
01245 
01246 /*:77*/
01247 #line 1245 "ctangle.w"
01248 ;break;
01249 }
01250 case output_defs_code:if(t!=section_name)err_print("! Misplaced @h");
01251 
01252 else{
01253 output_defs_seen= 1;
01254 a= output_defs_flag;
01255 app_repl((a/0400)+0200);
01256 app_repl(a%0400);
01257 /*77:*/
01258 #line 1225 "ctangle.w"
01259 
01260 store_two_bytes(0150000);
01261 if(changing)id_first= change_file_name;
01262 else id_first= cur_file_name;
01263 id_loc= id_first+strlen(id_first);
01264 if(changing)store_two_bytes((sixteen_bits)change_line);
01265 else store_two_bytes((sixteen_bits)cur_line);
01266 {int a= id_lookup(id_first,id_loc,0)-name_dir;app_repl((a/0400)+0200);
01267 app_repl(a%0400);}
01268 
01269 /*:77*/
01270 #line 1254 "ctangle.w"
01271 ;
01272 }
01273 break;
01274 case constant:case string:
01275 /*80:*/
01276 #line 1279 "ctangle.w"
01277 
01278 app_repl(a);
01279 while(id_first<id_loc){
01280 if(*id_first=='@'){
01281 if(*(id_first+1)=='@')id_first++;
01282 else err_print("! Double @ should be used in string");
01283 
01284 }
01285 app_repl(*id_first++);
01286 }
01287 app_repl(a);break;
01288 
01289 /*:80*/
01290 #line 1258 "ctangle.w"
01291 ;
01292 case ord:
01293 /*81:*/
01294 #line 1295 "ctangle.w"
01295 {
01296 int c= (eight_bits)*id_first;
01297 if(c=='\\'){
01298 c= *++id_first;
01299 if(c>='0'&&c<='7'){
01300 c-= '0';
01301 if(*(id_first+1)>='0'&&*(id_first+1)<='7'){
01302 c= 8*c+*(++id_first)-'0';
01303 if(*(id_first+1)>='0'&&*(id_first+1)<='7'&&c<32)
01304 c= 8*c+*(++id_first)-'0';
01305 }
01306 }
01307 else switch(c){
01308 case't':c= '\t';break;
01309 case'n':c= '\n';break;
01310 case'b':c= '\b';break;
01311 case'f':c= '\f';break;
01312 case'v':c= '\v';break;
01313 case'r':c= '\r';break;
01314 case'a':c= '\7';break;
01315 case'?':c= '?';break;
01316 case'x':
01317 if(xisdigit(*(id_first+1)))c= *(++id_first)-'0';
01318 else if(xisxdigit(*(id_first+1))){
01319 ++id_first;
01320 c= toupper(*id_first)-'A'+10;
01321 }
01322 if(xisdigit(*(id_first+1)))c= 16*c+*(++id_first)-'0';
01323 else if(xisxdigit(*(id_first+1))){
01324 ++id_first;
01325 c= 16*c+toupper(*id_first)-'A'+10;
01326 }
01327 break;
01328 case'\\':c= '\\';break;
01329 case'\'':c= '\'';break;
01330 case'\"':c= '\"';break;
01331 default:err_print("! Unrecognized escape sequence");
01332 
01333 }
01334 }
01335 
01336 app_repl(constant);
01337 if(c>=100)app_repl('0'+c/100);
01338 if(c>=10)app_repl('0'+(c/10)%10);
01339 app_repl('0'+c%10);
01340 app_repl(constant);
01341 }
01342 break;
01343 
01344 /*:81*/
01345 #line 1260 "ctangle.w"
01346 ;
01347 case definition:case format_code:case begin_C:if(t!=section_name)goto done;
01348 else{
01349 err_print("! @d, @f and @c are ignored in C text");continue;
01350 
01351 }
01352 case new_section:goto done;
01353 
01354 /*:78*/
01355 #line 1210 "ctangle.w"
01356 
01357 case')':app_repl(a);
01358 if(t==macro)app_repl(' ');
01359 break;
01360 default:app_repl(a);
01361 }
01362 done:next_control= (eight_bits)a;
01363 if(text_ptr> text_info_end)overflow("text");
01364 cur_text= text_ptr;(++text_ptr)->tok_start= tok_ptr;
01365 }
01366 
01367 /*:76*//*83:*/
01368 #line 1357 "ctangle.w"
01369 
01370 void
01371 scan_section()
01372 {
01373 name_pointer p;
01374 text_pointer q;
01375 sixteen_bits a;
01376 section_count++;no_where= 1;
01377 if(*(loc-1)=='*'&&show_progress){
01378 printf("*%d",section_count);update_terminal;
01379 }
01380 next_control= 0;
01381 while(1){
01382 /*84:*/
01383 #line 1396 "ctangle.w"
01384 
01385 while(next_control<definition)
01386 
01387 if((next_control= skip_ahead())==section_name){
01388 loc-= 2;next_control= get_next();
01389 }
01390 
01391 /*:84*/
01392 #line 1371 "ctangle.w"
01393 ;
01394 if(next_control==definition){
01395 /*85:*/
01396 #line 1403 "ctangle.w"
01397 {
01398 while((next_control= get_next())=='\n');
01399 if(next_control!=identifier){
01400 err_print("! Definition flushed, must start with identifier");
01401 
01402 continue;
01403 }
01404 app_repl(((a= id_lookup(id_first,id_loc,0)-name_dir)/0400)+0200);
01405 
01406 app_repl(a%0400);
01407 if(*loc!='('){
01408 app_repl(string);app_repl(' ');app_repl(string);
01409 }
01410 scan_repl(macro);
01411 cur_text->text_link= 0;
01412 }
01413 
01414 /*:85*/
01415 #line 1373 "ctangle.w"
01416 
01417 continue;
01418 }
01419 if(next_control==begin_C){
01420 p= name_dir;break;
01421 }
01422 if(next_control==section_name){
01423 p= cur_section_name;
01424 /*86:*/
01425 #line 1428 "ctangle.w"
01426 
01427 while((next_control= get_next())=='+');
01428 if(next_control!='='&&next_control!=eq_eq)
01429 continue;
01430 
01431 /*:86*/
01432 #line 1381 "ctangle.w"
01433 ;
01434 break;
01435 }
01436 return;
01437 }
01438 no_where= print_where= 0;
01439 /*87:*/
01440 #line 1433 "ctangle.w"
01441 
01442 /*88:*/
01443 #line 1438 "ctangle.w"
01444 
01445 store_two_bytes((sixteen_bits)(0150000+section_count));
01446 
01447 
01448 /*:88*/
01449 #line 1434 "ctangle.w"
01450 ;
01451 scan_repl(section_name);
01452 /*89:*/
01453 #line 1442 "ctangle.w"
01454 
01455 if(p==name_dir||p==0){
01456 (last_unnamed)->text_link= cur_text-text_info;last_unnamed= cur_text;
01457 }
01458 else if(p->equiv==(char*)text_info)p->equiv= (char*)cur_text;
01459 
01460 else{
01461 q= (text_pointer)p->equiv;
01462 while(q->text_link<section_flag)
01463 q= q->text_link+text_info;
01464 q->text_link= cur_text-text_info;
01465 }
01466 cur_text->text_link= section_flag;
01467 
01468 
01469 /*:89*/
01470 #line 1436 "ctangle.w"
01471 ;
01472 
01473 /*:87*/
01474 #line 1387 "ctangle.w"
01475 ;
01476 }
01477 
01478 /*:83*//*91:*/
01479 #line 1460 "ctangle.w"
01480 
01481 void
01482 phase_one(){
01483 phase= 1;
01484 section_count= 0;
01485 reset_input();
01486 skip_limbo();
01487 while(!input_has_ended)scan_section();
01488 check_complete();
01489 phase= 2;
01490 }
01491 
01492 /*:91*//*93:*/
01493 #line 1478 "ctangle.w"
01494 
01495 void
01496 skip_limbo()
01497 {
01498 char c;
01499 while(1){
01500 if(loc> limit&&get_line()==0)return;
01501 *(limit+1)= '@';
01502 while(*loc!='@')loc++;
01503 if(loc++<=limit){
01504 c= *loc++;
01505 if(ccode[(eight_bits)c]==new_section)break;
01506 switch(ccode[(eight_bits)c]){
01507 case translit_code:/*94:*/
01508 #line 1507 "ctangle.w"
01509 
01510 while(xisspace(*loc)&&loc<limit)loc++;
01511 loc+= 3;
01512 if(loc> limit||!xisxdigit(*(loc-3))||!xisxdigit(*(loc-2))
01513 ||(*(loc-3)>='0'&&*(loc-3)<='7')||!xisspace(*(loc-1)))
01514 err_print("! Improper hex number following @l");
01515 
01516 else{
01517 unsigned i;
01518 char*beg;
01519 sscanf(loc-3,"%x",&i);
01520 while(xisspace(*loc)&&loc<limit)loc++;
01521 beg= loc;
01522 while(loc<limit&&(xisalpha(*loc)||xisdigit(*loc)||*loc=='_'))loc++;
01523 if(loc-beg>=translit_length)
01524 err_print("! Replacement string in @l too long");
01525 
01526 else{
01527 strncpy(translit[i-0200],beg,loc-beg);
01528 translit[i-0200][loc-beg]= '\0';
01529 }
01530 }
01531 
01532 /*:94*/
01533 #line 1491 "ctangle.w"
01534 ;break;
01535 case format_code:case'@':break;
01536 case control_text:if(c=='q'||c=='Q'){
01537 while((c= skip_ahead())=='@');
01538 if(*(loc-1)!='>')
01539 err_print("! Double @ should be used in control text");
01540 
01541 break;
01542 }
01543 default:err_print("! Double @ should be used in limbo");
01544 
01545 }
01546 }
01547 }
01548 }
01549 
01550 /*:93*//*95:*/
01551 #line 1533 "ctangle.w"
01552 
01553 void
01554 print_stats(){
01555 printf("\nMemory usage statistics:\n");
01556 printf("%ld names (out of %ld)\n",
01557 (long)(name_ptr-name_dir),(long)max_names);
01558 printf("%ld replacement texts (out of %ld)\n",
01559 (long)(text_ptr-text_info),(long)max_texts);
01560 printf("%ld bytes (out of %ld)\n",
01561 (long)(byte_ptr-byte_mem),(long)max_bytes);
01562 printf("%ld tokens (out of %ld)\n",
01563 (long)(tok_ptr-tok_mem),(long)max_toks);
01564 }
01565 
01566 /*:95*/