beta-0.89.2
[luatex.git] / source / texk / web2c / ctangleboot.cin
blobcaa5fdee8ac2ebb86b973fc1f9d05cc5996b6ef3
1 /*1:*/
2 #line 64 "cwebdir/ctangle.w"
4 /*5:*/
5 #line 35 "cwebdir/common.h"
7 #line 121 "cwebdir/ctang-w2c.ch"
8 #include <kpathsea/kpathsea.h> 
9 #include <stdio.h> 
10 #line 37 "cwebdir/common.h"
12 /*:5*//*61:*/
13 #line 888 "cwebdir/ctangle.w"
15 #line 890 "cwebdir/ctangle.w"
16 #include <stdlib.h>  
18 /*:61*/
19 #line 65 "cwebdir/ctangle.w"
21 #define banner "This is CTANGLE, Version 3.64" \
23 #define max_bytes 1000000 \
25 #define max_toks 1000000
26 #define max_names 10239 \
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 \
34 #define ctangle 0
35 #define cweave 1 \
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 \
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) )  \
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 \
66 #define chunk_marker 0 \
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)  \
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] \
82 #define show_banner flags['b']
83 #define show_progress flags['p']
84 #define show_happiness flags['h'] \
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)  \
93 #define equiv equiv_or_xref \
95 #define section_flag max_texts \
97 #define string 02
98 #define join 0177
99 #define output_defs_flag (2*024000-1)  \
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 \
107 #define section_number 0201
108 #define identifier 0202 \
110 #define normal 0
111 #define num_or_id 1
112 #define post_slash 2
113 #define unbreakable 3
114 #define verbatim 4 \
116 #define max_files 256
117 #define translit_length 10 \
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 \
130 #define constant 03 \
132 #define isxalpha(c) ((c) =='_'||(c) =='$')  \
134 #define ishigh(c) ((unsigned char) (c) > 0177)  \
137 #define compress(c) if(loc++<=limit) return(c)  \
139 #define macro 0
140 #define app_repl(c) {if(tok_ptr==tok_mem_end) overflow("token") ;*tok_ptr++= c;} \
143 #line 66 "cwebdir/ctangle.w"
145 /*4:*/
146 #line 29 "cwebdir/common.h"
148 #line 31 "cwebdir/common.h"
149 typedef char unsigned eight_bits;
150 extern boolean program;
151 extern int phase;
153 /*:4*//*6:*/
154 #line 57 "cwebdir/common.h"
156 char section_text[longest_name+1];
157 char*section_text_end= section_text+longest_name;
158 char*id_first;
159 char*id_loc;
161 /*:6*//*7:*/
162 #line 72 "cwebdir/common.h"
164 extern char buffer[];
165 extern char*buffer_end;
166 extern char*loc;
167 extern char*limit;
169 /*:7*//*8:*/
170 #line 87 "cwebdir/common.h"
172 typedef struct name_info{
173 char*byte_start;
174 struct name_info*link;
175 union{
176 struct name_info*Rlink;
178 char Ilk;
179 }dummy;
180 char*equiv_or_xref;
181 }name_info;
182 typedef name_info*name_pointer;
183 typedef name_pointer*hash_pointer;
184 extern char byte_mem[];
185 extern char*byte_mem_end;
186 extern name_info name_dir[];
187 extern name_pointer name_dir_end;
188 extern name_pointer name_ptr;
189 extern char*byte_ptr;
190 extern name_pointer hash[];
191 extern hash_pointer hash_end;
192 extern hash_pointer h;
193 #line 148 "cwebdir/ctang-w2c.ch"
194 #include "cwebboot.h"
195 #line 112 "cwebdir/common.h"
197 /*:8*//*9:*/
198 #line 122 "cwebdir/common.h"
200 #line 160 "cwebdir/ctang-w2c.ch"
201 extern int history;
202 #line 128 "cwebdir/common.h"
204 /*:9*//*10:*/
205 #line 137 "cwebdir/common.h"
207 #line 174 "cwebdir/ctang-w2c.ch"
208 extern int include_depth;
209 #line 139 "cwebdir/common.h"
210 extern FILE*file[];
211 extern FILE*change_file;
212 extern char C_file_name[];
213 extern char tex_file_name[];
214 extern char idx_file_name[];
215 extern char scn_file_name[];
216 extern char file_name[][max_file_name_length];
218 extern char change_file_name[];
219 #line 181 "cwebdir/ctang-w2c.ch"
220 extern int line[];
221 extern int change_line;
222 #line 150 "cwebdir/common.h"
223 extern boolean input_has_ended;
224 extern boolean changing;
225 extern boolean web_file_open;
226 #line 156 "cwebdir/common.h"
228 /*:10*//*11:*/
229 #line 158 "cwebdir/common.h"
231 typedef unsigned short sixteen_bits;
232 extern sixteen_bits section_count;
233 extern boolean changed_section[];
234 extern boolean change_pending;
235 extern boolean print_where;
237 /*:11*//*12:*/
238 #line 170 "cwebdir/common.h"
240 extern int argc;
241 extern char**argv;
242 extern boolean flags[];
244 /*:12*//*13:*/
245 #line 182 "cwebdir/common.h"
247 extern FILE*C_file;
248 extern FILE*tex_file;
249 extern FILE*idx_file;
250 extern FILE*scn_file;
251 extern FILE*active_file;
253 /*:13*//*14:*/
254 #line 191 "cwebdir/common.h"
256 #line 128 "cwebdir/ctangle.w"
258 /*:14*/
259 #line 67 "cwebdir/ctangle.w"
261 /*15:*/
262 #line 152 "cwebdir/ctangle.w"
264 typedef struct{
265 eight_bits*tok_start;
266 sixteen_bits text_link;
267 }text;
268 typedef text*text_pointer;
270 /*:15*//*26:*/
271 #line 296 "cwebdir/ctangle.w"
273 typedef struct{
274 eight_bits*end_field;
275 eight_bits*byte_field;
276 name_pointer name_field;
277 text_pointer repl_field;
278 sixteen_bits section_field;
279 }output_state;
280 typedef output_state*stack_pointer;
282 /*:26*/
283 #line 68 "cwebdir/ctangle.w"
285 /*16:*/
286 #line 159 "cwebdir/ctangle.w"
288 text text_info[max_texts];
289 text_pointer text_info_end= text_info+max_texts-1;
290 text_pointer text_ptr;
291 eight_bits tok_mem[max_toks];
292 eight_bits*tok_mem_end= tok_mem+max_toks-1;
293 eight_bits*tok_ptr;
295 /*:16*//*22:*/
296 #line 227 "cwebdir/ctangle.w"
298 text_pointer last_unnamed;
300 /*:22*//*27:*/
301 #line 312 "cwebdir/ctangle.w"
303 output_state cur_state;
305 output_state stack[stack_size+1];
306 stack_pointer stack_ptr;
307 stack_pointer stack_end= stack+stack_size;
309 /*:27*//*31:*/
310 #line 384 "cwebdir/ctangle.w"
312 int cur_val;
314 /*:31*//*35:*/
315 #line 473 "cwebdir/ctangle.w"
317 eight_bits out_state;
318 boolean protect;
320 /*:35*//*37:*/
321 #line 502 "cwebdir/ctangle.w"
323 name_pointer output_files[max_files];
324 name_pointer*cur_out_file,*end_output_files,*an_output_file;
325 char cur_section_name_char;
326 char output_file_name[longest_name];
328 /*:37*//*44:*/
329 #line 599 "cwebdir/ctangle.w"
331 boolean output_defs_seen= 0;
333 /*:44*//*50:*/
334 #line 710 "cwebdir/ctangle.w"
336 char translit[128][translit_length];
338 /*:50*//*55:*/
339 #line 789 "cwebdir/ctangle.w"
341 eight_bits ccode[256];
343 /*:55*//*58:*/
344 #line 845 "cwebdir/ctangle.w"
346 boolean comment_continues= 0;
348 /*:58*//*60:*/
349 #line 884 "cwebdir/ctangle.w"
351 name_pointer cur_section_name;
352 int no_where;
354 /*:60*//*74:*/
355 #line 1195 "cwebdir/ctangle.w"
357 text_pointer cur_text;
358 eight_bits next_control;
360 /*:74*//*81:*/
361 #line 1350 "cwebdir/ctangle.w"
363 extern sixteen_bits section_count;
365 /*:81*/
366 #line 69 "cwebdir/ctangle.w"
368 /*40:*/
369 #line 533 "cwebdir/ctangle.w"
371 #line 283 "cwebdir/ctang-w2c.ch"
372 static void phase_two(void);
373 #line 535 "cwebdir/ctangle.w"
375 /*:40*//*45:*/
376 #line 602 "cwebdir/ctangle.w"
378 #line 309 "cwebdir/ctang-w2c.ch"
379 static void output_defs(void);
380 #line 604 "cwebdir/ctangle.w"
382 /*:45*//*47:*/
383 #line 648 "cwebdir/ctangle.w"
385 #line 327 "cwebdir/ctang-w2c.ch"
386 static void out_char(eight_bits);
387 #line 650 "cwebdir/ctangle.w"
389 /*:47*//*89:*/
390 #line 1457 "cwebdir/ctangle.w"
392 #line 441 "cwebdir/ctang-w2c.ch"
393 static void phase_one(void);
394 #line 1459 "cwebdir/ctangle.w"
396 /*:89*//*91:*/
397 #line 1475 "cwebdir/ctangle.w"
399 #line 459 "cwebdir/ctang-w2c.ch"
400 static void skip_limbo(void);
401 #line 1477 "cwebdir/ctangle.w"
403 /*:91*/
404 #line 70 "cwebdir/ctangle.w"
407 #line 83 "cwebdir/ctangle.w"
409 /*:1*//*2:*/
410 #line 91 "cwebdir/ctangle.w"
412 #line 70 "cwebdir/ctang-w2c.ch"
413 int main(int ac,char**av)
414 #line 95 "cwebdir/ctangle.w"
416 argc= ac;argv= av;
417 program= ctangle;
418 /*17:*/
419 #line 167 "cwebdir/ctangle.w"
421 text_info->tok_start= tok_ptr= tok_mem;
422 text_ptr= text_info+1;text_ptr->tok_start= tok_mem;
425 /*:17*//*19:*/
426 #line 177 "cwebdir/ctangle.w"
428 name_dir->equiv= (char*)text_info;
430 /*:19*//*23:*/
431 #line 230 "cwebdir/ctangle.w"
432 last_unnamed= text_info;text_info->text_link= 0;
434 /*:23*//*38:*/
435 #line 512 "cwebdir/ctangle.w"
437 cur_out_file= end_output_files= output_files+max_files;
439 /*:38*//*51:*/
440 #line 713 "cwebdir/ctangle.w"
443 int i;
444 for(i= 0;i<128;i++)sprintf(translit[i],"X%02X",(unsigned)(128+i));
447 /*:51*//*56:*/
448 #line 792 "cwebdir/ctangle.w"
450 int c;
451 for(c= 0;c<256;c++)ccode[c]= ignore;
452 ccode[' ']= ccode['\t']= ccode['\n']= ccode['\v']= ccode['\r']= ccode['\f']
453 = ccode['*']= new_section;
454 ccode['@']= '@';ccode['=']= string;
455 ccode['d']= ccode['D']= definition;
456 ccode['f']= ccode['F']= ccode['s']= ccode['S']= format_code;
457 ccode['c']= ccode['C']= ccode['p']= ccode['P']= begin_C;
458 ccode['^']= ccode[':']= ccode['.']= ccode['t']= ccode['T']= 
459 ccode['q']= ccode['Q']= control_text;
460 ccode['h']= ccode['H']= output_defs_code;
461 ccode['l']= ccode['L']= translit_code;
462 ccode['&']= join;
463 ccode['<']= ccode['(']= section_name;
464 ccode['\'']= ord;
467 /*:56*//*70:*/
468 #line 1116 "cwebdir/ctangle.w"
469 section_text[0]= ' ';
471 /*:70*/
472 #line 98 "cwebdir/ctangle.w"
474 common_init();
475 #line 76 "cwebdir/ctang-w2c.ch"
476 if(show_banner){
477 printf("%s%s\n",banner,versionstring);
479 #line 101 "cwebdir/ctangle.w"
480 phase_one();
481 phase_two();
482 return wrap_up();
485 /*:2*//*20:*/
486 #line 183 "cwebdir/ctangle.w"
488 #line 207 "cwebdir/ctang-w2c.ch"
489 int names_match(name_pointer p,const char*first,int l,char t)
490 #line 188 "cwebdir/ctangle.w"
492 if(length(p)!=l)return 0;
493 return!strncmp(first,p->byte_start,l);
496 /*:20*//*21:*/
497 #line 198 "cwebdir/ctangle.w"
499 void
500 #line 216 "cwebdir/ctang-w2c.ch"
501  init_node(name_pointer node)
502 #line 202 "cwebdir/ctangle.w"
504 node->equiv= (char*)text_info;
506 void
507 #line 222 "cwebdir/ctang-w2c.ch"
508  init_p(name_pointer p,char t){}
509 #line 207 "cwebdir/ctangle.w"
511 /*:21*//*25:*/
512 #line 260 "cwebdir/ctangle.w"
514 #line 232 "cwebdir/ctang-w2c.ch"
515 static void
516 store_two_bytes(sixteen_bits x)
517 #line 264 "cwebdir/ctangle.w"
519 if(tok_ptr+2> tok_mem_end)overflow("token");
520 *tok_ptr++= x>>8;
521 *tok_ptr++= x&0377;
524 /*:25*//*29:*/
525 #line 336 "cwebdir/ctangle.w"
527 #line 243 "cwebdir/ctang-w2c.ch"
528 static void
529 push_level(name_pointer p)
530 #line 340 "cwebdir/ctangle.w"
532 if(stack_ptr==stack_end)overflow("stack");
533 *stack_ptr= cur_state;
534 stack_ptr++;
535 if(p!=NULL){
536 cur_name= p;cur_repl= (text_pointer)p->equiv;
537 cur_byte= cur_repl->tok_start;cur_end= (cur_repl+1)->tok_start;
538 cur_section= 0;
542 /*:29*//*30:*/
543 #line 355 "cwebdir/ctangle.w"
545 #line 254 "cwebdir/ctang-w2c.ch"
546 static void
547 pop_level(int flag)
548 #line 359 "cwebdir/ctangle.w"
550 if(flag&&cur_repl->text_link<section_flag){
551 cur_repl= cur_repl->text_link+text_info;
552 cur_byte= cur_repl->tok_start;cur_end= (cur_repl+1)->tok_start;
553 return;
555 stack_ptr--;
556 if(stack_ptr> stack)cur_state= *stack_ptr;
559 /*:30*//*32:*/
560 #line 391 "cwebdir/ctangle.w"
562 #line 264 "cwebdir/ctang-w2c.ch"
563 static void
564 get_output(void)
565 #line 394 "cwebdir/ctangle.w"
567 sixteen_bits a;
568 restart:if(stack_ptr==stack)return;
569 if(cur_byte==cur_end){
570 cur_val= -((int)cur_section);
571 pop_level(1);
572 if(cur_val==0)goto restart;
573 out_char(section_number);return;
575 a= *cur_byte++;
576 if(out_state==verbatim&&a!=string&&a!=constant&&a!='\n')
577 C_putc(a);
578 else if(a<0200)out_char(a);
579 else{
580 a= (a-0200)*0400+*cur_byte++;
581 switch(a/024000){
582 case 0:cur_val= a;out_char(identifier);break;
583 case 1:if(a==output_defs_flag)output_defs();
584 else/*33:*/
585 #line 423 "cwebdir/ctangle.w"
588 a-= 024000;
589 if((a+name_dir)->equiv!=(char*)text_info)push_level(a+name_dir);
590 else if(a!=0){
591 printf("\n! Not present: <");
592 print_section_name(a+name_dir);err_print(">");
595 goto restart;
598 /*:33*/
599 #line 412 "cwebdir/ctangle.w"
601 break;
602 default:cur_val= a-050000;if(cur_val> 0)cur_section= cur_val;
603 out_char(section_number);
608 /*:32*//*36:*/
609 #line 481 "cwebdir/ctangle.w"
611 #line 274 "cwebdir/ctang-w2c.ch"
612 static void
613 flush_buffer(void)
614 #line 484 "cwebdir/ctangle.w"
616 C_putc('\n');
617 if(cur_line%100==0&&show_progress){
618 printf(".");
619 if(cur_line%500==0)printf("%d",cur_line);
620 update_terminal;
622 cur_line++;
625 /*:36*//*41:*/
626 #line 536 "cwebdir/ctangle.w"
628 #line 292 "cwebdir/ctang-w2c.ch"
629 static void
630 phase_two(void){
631 #line 539 "cwebdir/ctangle.w"
632 web_file_open= 0;
633 cur_line= 1;
634 /*28:*/
635 #line 325 "cwebdir/ctangle.w"
637 stack_ptr= stack+1;cur_name= name_dir;cur_repl= text_info->text_link+text_info;
638 cur_byte= cur_repl->tok_start;cur_end= (cur_repl+1)->tok_start;cur_section= 0;
640 /*:28*/
641 #line 541 "cwebdir/ctangle.w"
643 /*43:*/
644 #line 595 "cwebdir/ctangle.w"
646 if(!output_defs_seen)
647 output_defs();
649 /*:43*/
650 #line 542 "cwebdir/ctangle.w"
652 if(text_info->text_link==0&&cur_out_file==end_output_files){
653 printf("\n! No program text was specified.");mark_harmless;
656 else{
657 if(cur_out_file==end_output_files){
658 if(show_progress)
659 printf("\nWriting the output file (%s):",C_file_name);
661 else{
662 if(show_progress){
663 printf("\nWriting the output files:");
665 printf(" (%s)",C_file_name);
666 update_terminal;
668 if(text_info->text_link==0)goto writeloop;
670 while(stack_ptr> stack)get_output();
671 flush_buffer();
672 writeloop:/*42:*/
673 #line 572 "cwebdir/ctangle.w"
675 for(an_output_file= end_output_files;an_output_file> cur_out_file;){
676 an_output_file--;
677 sprint_section_name(output_file_name,*an_output_file);
678 fclose(C_file);
679 #line 301 "cwebdir/ctang-w2c.ch"
680 C_file= fopen(output_file_name,"wb");
681 #line 578 "cwebdir/ctangle.w"
682 if(C_file==0)fatal("! Cannot open output file:",output_file_name);
684 printf("\n(%s)",output_file_name);update_terminal;
685 cur_line= 1;
686 stack_ptr= stack+1;
687 cur_name= (*an_output_file);
688 cur_repl= (text_pointer)cur_name->equiv;
689 cur_byte= cur_repl->tok_start;
690 cur_end= (cur_repl+1)->tok_start;
691 while(stack_ptr> stack)get_output();
692 flush_buffer();
695 /*:42*/
696 #line 563 "cwebdir/ctangle.w"
698 if(show_happiness)printf("\nDone.");
702 /*:41*//*46:*/
703 #line 605 "cwebdir/ctangle.w"
705 #line 318 "cwebdir/ctang-w2c.ch"
706 static void
707 output_defs(void)
708 #line 608 "cwebdir/ctangle.w"
710 sixteen_bits a;
711 push_level(NULL);
712 for(cur_text= text_info+1;cur_text<text_ptr;cur_text++)
713 if(cur_text->text_link==0){
714 cur_byte= cur_text->tok_start;
715 cur_end= (cur_text+1)->tok_start;
716 C_printf("%s","#define ");
717 out_state= normal;
718 protect= 1;
719 while(cur_byte<cur_end){
720 a= *cur_byte++;
721 if(cur_byte==cur_end&&a=='\n')break;
722 if(out_state==verbatim&&a!=string&&a!=constant&&a!='\n')
723 C_putc(a);
725 else if(a<0200)out_char(a);
726 else{
727 a= (a-0200)*0400+*cur_byte++;
728 if(a<024000){
729 cur_val= a;out_char(identifier);
731 else if(a<050000){confusion("macro defs have strange char");}
732 else{
733 cur_val= a-050000;cur_section= cur_val;out_char(section_number);
738 protect= 0;
739 flush_buffer();
741 pop_level(0);
744 /*:46*//*48:*/
745 #line 651 "cwebdir/ctangle.w"
747 static void
748 #line 336 "cwebdir/ctang-w2c.ch"
749  out_char(eight_bits cur_char)
750 #line 655 "cwebdir/ctangle.w"
752 char*j,*k;
753 restart:
754 switch(cur_char){
755 case'\n':if(protect&&out_state!=verbatim)C_putc(' ');
756 if(protect||out_state==verbatim)C_putc('\\');
757 flush_buffer();if(out_state!=verbatim)out_state= normal;break;
758 /*52:*/
759 #line 719 "cwebdir/ctangle.w"
761 case identifier:
762 if(out_state==num_or_id)C_putc(' ');
763 j= (cur_val+name_dir)->byte_start;
764 k= (cur_val+name_dir+1)->byte_start;
765 while(j<k){
766 if((unsigned char)(*j)<0200)C_putc(*j);
768 else C_printf("%s",translit[(unsigned char)(*j)-0200]);
769 j++;
771 out_state= num_or_id;break;
773 /*:52*/
774 #line 662 "cwebdir/ctangle.w"
776 /*53:*/
777 #line 732 "cwebdir/ctangle.w"
779 case section_number:
780 if(cur_val> 0)C_printf("/*%d:*/",cur_val);
781 else if(cur_val<0)C_printf("/*:%d*/",-cur_val);
782 else if(protect){
783 cur_byte+= 4;
784 cur_char= '\n';
785 goto restart;
786 }else{
787 sixteen_bits a;
788 a= 0400**cur_byte++;
789 a+= *cur_byte++;
790 C_printf("\n#line %d \"",a);
792 cur_val= *cur_byte++;
793 cur_val= 0400*(cur_val-0200)+*cur_byte++;
794 for(j= (cur_val+name_dir)->byte_start,k= (cur_val+name_dir+1)->byte_start;
795 j<k;j++){
796 if(*j=='\\'||*j=='"')C_putc('\\');
797 C_putc(*j);
799 C_printf("%s","\"\n");
801 break;
803 /*:53*/
804 #line 663 "cwebdir/ctangle.w"
806 /*49:*/
807 #line 681 "cwebdir/ctangle.w"
809 case plus_plus:C_putc('+');C_putc('+');out_state= normal;break;
810 case minus_minus:C_putc('-');C_putc('-');out_state= normal;break;
811 case minus_gt:C_putc('-');C_putc('>');out_state= normal;break;
812 case gt_gt:C_putc('>');C_putc('>');out_state= normal;break;
813 case eq_eq:C_putc('=');C_putc('=');out_state= normal;break;
814 case lt_lt:C_putc('<');C_putc('<');out_state= normal;break;
815 case gt_eq:C_putc('>');C_putc('=');out_state= normal;break;
816 case lt_eq:C_putc('<');C_putc('=');out_state= normal;break;
817 case not_eq:C_putc('!');C_putc('=');out_state= normal;break;
818 case and_and:C_putc('&');C_putc('&');out_state= normal;break;
819 case or_or:C_putc('|');C_putc('|');out_state= normal;break;
820 case dot_dot_dot:C_putc('.');C_putc('.');C_putc('.');out_state= normal;
821 break;
822 case colon_colon:C_putc(':');C_putc(':');out_state= normal;break;
823 case period_ast:C_putc('.');C_putc('*');out_state= normal;break;
824 case minus_gt_ast:C_putc('-');C_putc('>');C_putc('*');out_state= normal;
825 break;
827 /*:49*/
828 #line 664 "cwebdir/ctangle.w"
830 case'=':case'>':C_putc(cur_char);C_putc(' ');
831 out_state= normal;break;
832 case join:out_state= unbreakable;break;
833 case constant:if(out_state==verbatim){
834 out_state= num_or_id;break;
836 if(out_state==num_or_id)C_putc(' ');out_state= verbatim;break;
837 case string:if(out_state==verbatim)out_state= normal;
838 else out_state= verbatim;break;
839 case'/':C_putc('/');out_state= post_slash;break;
840 case'*':if(out_state==post_slash)C_putc(' ');
842 default:C_putc(cur_char);out_state= normal;break;
846 /*:48*//*57:*/
847 #line 813 "cwebdir/ctangle.w"
849 #line 345 "cwebdir/ctang-w2c.ch"
850 static eight_bits
851 skip_ahead(void)
852 #line 816 "cwebdir/ctangle.w"
854 eight_bits c;
855 while(1){
856 if(loc> limit&&(get_line()==0))return(new_section);
857 *(limit+1)= '@';
858 while(*loc!='@')loc++;
859 if(loc<=limit){
860 loc++;c= ccode[(eight_bits)*loc];loc++;
861 if(c!=ignore||*(loc-1)=='>')return(c);
866 /*:57*//*59:*/
867 #line 848 "cwebdir/ctangle.w"
869 #line 355 "cwebdir/ctang-w2c.ch"
870 static int
871 skip_comment(boolean is_long_comment)
872 #line 851 "cwebdir/ctangle.w"
874 char c;
875 while(1){
876 if(loc> limit){
877 if(is_long_comment){
878 if(get_line())return(comment_continues= 1);
879 else{
880 err_print("! Input ended in mid-comment");
882 return(comment_continues= 0);
885 else return(comment_continues= 0);
887 c= *(loc++);
888 if(is_long_comment&&c=='*'&&*loc=='/'){
889 loc++;return(comment_continues= 0);
891 if(c=='@'){
892 if(ccode[(eight_bits)*loc]==new_section){
893 err_print("! Section name ended in mid-comment");loc--;
895 return(comment_continues= 0);
897 else loc++;
902 /*:59*//*62:*/
903 #line 900 "cwebdir/ctangle.w"
905 #line 372 "cwebdir/ctang-w2c.ch"
906 static eight_bits
907 get_next(void)
908 #line 903 "cwebdir/ctangle.w"
910 static int preprocessing= 0;
911 eight_bits c;
912 while(1){
913 if(loc> limit){
914 if(preprocessing&&*(limit-1)!='\\')preprocessing= 0;
915 if(get_line()==0)return(new_section);
916 else if(print_where&&!no_where){
917 print_where= 0;
918 /*76:*/
919 #line 1225 "cwebdir/ctangle.w"
921 store_two_bytes(0150000);
922 if(changing)id_first= change_file_name;
923 else id_first= cur_file_name;
924 id_loc= id_first+strlen(id_first);
925 if(changing)store_two_bytes((sixteen_bits)change_line);
926 else 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);
929 app_repl(a_l%0400);}
930 #line 1234 "cwebdir/ctangle.w"
932 /*:76*/
933 #line 912 "cwebdir/ctangle.w"
936 else return('\n');
938 c= *loc;
939 if(comment_continues||(c=='/'&&(*(loc+1)=='*'||*(loc+1)=='/'))){
940 skip_comment(comment_continues||*(loc+1)=='*');
942 if(comment_continues)return('\n');
943 else continue;
945 loc++;
946 if(xisdigit(c)||c=='.')/*65:*/
947 #line 978 "cwebdir/ctangle.w"
949 id_first= loc-1;
950 if(*id_first=='.'&&!xisdigit(*loc))goto mistake;
951 if(*id_first=='0'){
952 if(*loc=='x'||*loc=='X'){
953 loc++;while(xisxdigit(*loc))loc++;goto found;
956 while(xisdigit(*loc))loc++;
957 if(*loc=='.'){
958 loc++;
959 while(xisdigit(*loc))loc++;
961 if(*loc=='e'||*loc=='E'){
962 if(*++loc=='+'||*loc=='-')loc++;
963 while(xisdigit(*loc))loc++;
965 found:while(*loc=='u'||*loc=='U'||*loc=='l'||*loc=='L'
966 ||*loc=='f'||*loc=='F')loc++;
967 id_loc= loc;
968 return(constant);
971 /*:65*/
972 #line 924 "cwebdir/ctangle.w"
974 else if(c=='\''||c=='"'||(c=='L'&&(*loc=='\''||*loc=='"')))
975 /*66:*/
976 #line 1006 "cwebdir/ctangle.w"
978 char delim= c;
979 id_first= section_text+1;
980 id_loc= section_text;*++id_loc= delim;
981 if(delim=='L'){
982 delim= *loc++;*++id_loc= delim;
984 while(1){
985 if(loc>=limit){
986 if(*(limit-1)!='\\'){
987 err_print("! String didn't end");loc= limit;break;
990 if(get_line()==0){
991 err_print("! Input ended in middle of string");loc= buffer;break;
994 else if(++id_loc<=section_text_end)*id_loc= '\n';
997 if((c= *loc++)==delim){
998 if(++id_loc<=section_text_end)*id_loc= c;
999 break;
1001 if(c=='\\'){
1002 if(loc>=limit)continue;
1003 if(++id_loc<=section_text_end)*id_loc= '\\';
1004 c= *loc++;
1006 if(++id_loc<=section_text_end)*id_loc= c;
1008 if(id_loc>=section_text_end){
1009 printf("\n! String too long: ");
1011 term_write(section_text+1,25);
1012 err_print("...");
1014 id_loc++;
1015 return(string);
1018 /*:66*/
1019 #line 926 "cwebdir/ctangle.w"
1021 else if(isalpha(c)||isxalpha(c)||ishigh(c))
1022 /*64:*/
1023 #line 972 "cwebdir/ctangle.w"
1025 id_first= --loc;
1026 #line 389 "cwebdir/ctang-w2c.ch"
1027 while(isalpha((unsigned char)*++loc)||isdigit((unsigned char)*loc)||isxalpha(*loc)||ishigh(*loc));
1028 #line 975 "cwebdir/ctangle.w"
1029 id_loc= loc;return(identifier);
1032 /*:64*/
1033 #line 928 "cwebdir/ctangle.w"
1035 else if(c=='@')/*67:*/
1036 #line 1050 "cwebdir/ctangle.w"
1038 c= ccode[(eight_bits)*loc++];
1039 switch(c){
1040 case ignore:continue;
1041 case translit_code:err_print("! Use @l in limbo only");continue;
1043 case control_text:while((c= skip_ahead())=='@');
1045 if(*(loc-1)!='>')
1046 err_print("! Double @ should be used in control text");
1048 continue;
1049 case section_name:
1050 cur_section_name_char= *(loc-1);
1051 /*69:*/
1052 #line 1098 "cwebdir/ctangle.w"
1054 char*k;
1055 /*71:*/
1056 #line 1118 "cwebdir/ctangle.w"
1058 k= section_text;
1059 while(1){
1060 if(loc> limit&&get_line()==0){
1061 err_print("! Input ended in section name");
1063 loc= buffer+1;break;
1065 c= *loc;
1066 /*72:*/
1067 #line 1142 "cwebdir/ctangle.w"
1069 if(c=='@'){
1070 c= *(loc+1);
1071 if(c=='>'){
1072 loc+= 2;break;
1074 if(ccode[(eight_bits)c]==new_section){
1075 err_print("! Section name didn't end");break;
1078 if(ccode[(eight_bits)c]==section_name){
1079 err_print("! Nesting of section names not allowed");break;
1082 *(++k)= '@';loc++;
1085 /*:72*/
1086 #line 1127 "cwebdir/ctangle.w"
1088 loc++;if(k<section_text_end)k++;
1089 if(xisspace(c)){
1090 c= ' ';if(*(k-1)==' ')k--;
1092 *k= c;
1094 if(k>=section_text_end){
1095 printf("\n! Section name too long: ");
1097 term_write(section_text+1,25);
1098 printf("...");mark_harmless;
1100 if(*k==' '&&k> section_text)k--;
1102 /*:71*/
1103 #line 1100 "cwebdir/ctangle.w"
1105 if(k-section_text> 3&&strncmp(k-2,"...",3)==0)
1106 cur_section_name= section_lookup(section_text+1,k-3,1);
1107 else cur_section_name= section_lookup(section_text+1,k,0);
1108 if(cur_section_name_char=='(')
1109 /*39:*/
1110 #line 516 "cwebdir/ctangle.w"
1113 for(an_output_file= cur_out_file;
1114 an_output_file<end_output_files;an_output_file++)
1115 if(*an_output_file==cur_section_name)break;
1116 if(an_output_file==end_output_files){
1117 if(cur_out_file> output_files)
1118 *--cur_out_file= cur_section_name;
1119 else{
1120 overflow("output files");
1125 /*:39*/
1126 #line 1106 "cwebdir/ctangle.w"
1128 return(section_name);
1131 /*:69*/
1132 #line 1064 "cwebdir/ctangle.w"
1134 case string:/*73:*/
1135 #line 1164 "cwebdir/ctangle.w"
1137 id_first= loc++;*(limit+1)= '@';*(limit+2)= '>';
1138 while(*loc!='@'||*(loc+1)!='>')loc++;
1139 if(loc>=limit)err_print("! Verbatim string didn't end");
1141 id_loc= loc;loc+= 2;
1142 return(string);
1145 /*:73*/
1146 #line 1065 "cwebdir/ctangle.w"
1148 case ord:/*68:*/
1149 #line 1077 "cwebdir/ctangle.w"
1151 id_first= loc;
1152 if(*loc=='\\'){
1153 if(*++loc=='\'')loc++;
1155 while(*loc!='\''){
1156 if(*loc=='@'){
1157 if(*(loc+1)!='@')
1158 err_print("! Double @ should be used in ASCII constant");
1160 else loc++;
1162 loc++;
1163 if(loc> limit){
1164 err_print("! String didn't end");loc= limit-1;break;
1168 loc++;
1169 return(ord);
1171 /*:68*/
1172 #line 1066 "cwebdir/ctangle.w"
1174 default:return(c);
1178 /*:67*/
1179 #line 929 "cwebdir/ctangle.w"
1181 else if(xisspace(c)){
1182 if(!preprocessing||loc> limit)continue;
1184 else return(' ');
1186 else if(c=='#'&&loc==buffer+1)preprocessing= 1;
1187 mistake:/*63:*/
1188 #line 950 "cwebdir/ctangle.w"
1190 switch(c){
1191 case'+':if(*loc=='+')compress(plus_plus);break;
1192 case'-':if(*loc=='-'){compress(minus_minus);}
1193 #line 382 "cwebdir/ctang-w2c.ch"
1194 else if(*loc=='>'){if(*(loc+1)=='*'){loc++;compress(minus_gt_ast);}
1195 else compress(minus_gt);}break;
1196 #line 956 "cwebdir/ctangle.w"
1197 case'.':if(*loc=='*'){compress(period_ast);}
1198 else if(*loc=='.'&&*(loc+1)=='.'){
1199 loc++;compress(dot_dot_dot);
1201 break;
1202 case':':if(*loc==':')compress(colon_colon);break;
1203 case'=':if(*loc=='=')compress(eq_eq);break;
1204 case'>':if(*loc=='='){compress(gt_eq);}
1205 else if(*loc=='>')compress(gt_gt);break;
1206 case'<':if(*loc=='='){compress(lt_eq);}
1207 else if(*loc=='<')compress(lt_lt);break;
1208 case'&':if(*loc=='&')compress(and_and);break;
1209 case'|':if(*loc=='|')compress(or_or);break;
1210 case'!':if(*loc=='=')compress(not_eq);break;
1213 /*:63*/
1214 #line 936 "cwebdir/ctangle.w"
1216 return(c);
1220 /*:62*//*75:*/
1221 #line 1199 "cwebdir/ctangle.w"
1223 #line 399 "cwebdir/ctang-w2c.ch"
1224 static void
1225 scan_repl(eight_bits t)
1226 #line 1203 "cwebdir/ctangle.w"
1228 sixteen_bits a;
1229 if(t==section_name){/*76:*/
1230 #line 1225 "cwebdir/ctangle.w"
1232 store_two_bytes(0150000);
1233 if(changing)id_first= change_file_name;
1234 else id_first= cur_file_name;
1235 id_loc= id_first+strlen(id_first);
1236 if(changing)store_two_bytes((sixteen_bits)change_line);
1237 else 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);
1240 app_repl(a_l%0400);}
1241 #line 1234 "cwebdir/ctangle.w"
1243 /*:76*/
1244 #line 1205 "cwebdir/ctangle.w"
1246 while(1)switch(a= get_next()){
1247 /*77:*/
1248 #line 1235 "cwebdir/ctangle.w"
1250 case identifier:a= id_lookup(id_first,id_loc,0)-name_dir;
1251 app_repl((a/0400)+0200);
1252 app_repl(a%0400);break;
1253 case section_name:if(t!=section_name)goto done;
1254 else{
1255 /*78:*/
1256 #line 1268 "cwebdir/ctangle.w"
1258 char*try_loc= loc;
1259 while(*try_loc==' '&&try_loc<limit)try_loc++;
1260 if(*try_loc=='+'&&try_loc<limit)try_loc++;
1261 while(*try_loc==' '&&try_loc<limit)try_loc++;
1262 if(*try_loc=='=')err_print("! Missing `@ ' before a named section");
1268 /*:78*/
1269 #line 1241 "cwebdir/ctangle.w"
1271 a= cur_section_name-name_dir;
1272 app_repl((a/0400)+0250);
1273 app_repl(a%0400);
1274 /*76:*/
1275 #line 1225 "cwebdir/ctangle.w"
1277 store_two_bytes(0150000);
1278 if(changing)id_first= change_file_name;
1279 else id_first= cur_file_name;
1280 id_loc= id_first+strlen(id_first);
1281 if(changing)store_two_bytes((sixteen_bits)change_line);
1282 else 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);
1285 app_repl(a_l%0400);}
1286 #line 1234 "cwebdir/ctangle.w"
1288 /*:76*/
1289 #line 1245 "cwebdir/ctangle.w"
1290 ;break;
1292 case output_defs_code:if(t!=section_name)err_print("! Misplaced @h");
1294 else{
1295 output_defs_seen= 1;
1296 a= output_defs_flag;
1297 app_repl((a/0400)+0200);
1298 app_repl(a%0400);
1299 /*76:*/
1300 #line 1225 "cwebdir/ctangle.w"
1302 store_two_bytes(0150000);
1303 if(changing)id_first= change_file_name;
1304 else id_first= cur_file_name;
1305 id_loc= id_first+strlen(id_first);
1306 if(changing)store_two_bytes((sixteen_bits)change_line);
1307 else 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);
1310 app_repl(a_l%0400);}
1311 #line 1234 "cwebdir/ctangle.w"
1313 /*:76*/
1314 #line 1254 "cwebdir/ctangle.w"
1317 break;
1318 case constant:case string:
1319 /*79:*/
1320 #line 1279 "cwebdir/ctangle.w"
1322 app_repl(a);
1323 while(id_first<id_loc){
1324 if(*id_first=='@'){
1325 if(*(id_first+1)=='@')id_first++;
1326 else err_print("! Double @ should be used in string");
1329 app_repl(*id_first++);
1331 app_repl(a);break;
1333 /*:79*/
1334 #line 1258 "cwebdir/ctangle.w"
1336 case ord:
1337 /*80:*/
1338 #line 1295 "cwebdir/ctangle.w"
1340 int c= (eight_bits)*id_first;
1341 if(c=='\\'){
1342 c= *++id_first;
1343 if(c>='0'&&c<='7'){
1344 c-= '0';
1345 if(*(id_first+1)>='0'&&*(id_first+1)<='7'){
1346 c= 8*c+*(++id_first)-'0';
1347 if(*(id_first+1)>='0'&&*(id_first+1)<='7'&&c<32)
1348 c= 8*c+*(++id_first)-'0';
1351 else switch(c){
1352 case't':c= '\t';break;
1353 case'n':c= '\n';break;
1354 case'b':c= '\b';break;
1355 case'f':c= '\f';break;
1356 case'v':c= '\v';break;
1357 case'r':c= '\r';break;
1358 case'a':c= '\7';break;
1359 case'?':c= '?';break;
1360 case'x':
1361 if(xisdigit(*(id_first+1)))c= *(++id_first)-'0';
1362 else if(xisxdigit(*(id_first+1))){
1363 ++id_first;
1364 #line 418 "cwebdir/ctang-w2c.ch"
1365 c= toupper((unsigned char)*id_first)-'A'+10;
1366 #line 1321 "cwebdir/ctangle.w"
1368 if(xisdigit(*(id_first+1)))c= 16*c+*(++id_first)-'0';
1369 else if(xisxdigit(*(id_first+1))){
1370 ++id_first;
1371 #line 423 "cwebdir/ctang-w2c.ch"
1372 c= 16*c+toupper((unsigned char)*id_first)-'A'+10;
1373 #line 1326 "cwebdir/ctangle.w"
1375 break;
1376 case'\\':c= '\\';break;
1377 case'\'':c= '\'';break;
1378 case'\"':c= '\"';break;
1379 default:err_print("! Unrecognized escape sequence");
1384 app_repl(constant);
1385 if(c>=100)app_repl('0'+c/100);
1386 if(c>=10)app_repl('0'+(c/10)%10);
1387 app_repl('0'+c%10);
1388 app_repl(constant);
1390 break;
1392 /*:80*/
1393 #line 1260 "cwebdir/ctangle.w"
1395 case definition:case format_code:case begin_C:if(t!=section_name)goto done;
1396 else{
1397 err_print("! @d, @f and @c are ignored in C text");continue;
1400 case new_section:goto done;
1402 /*:77*/
1403 #line 1210 "cwebdir/ctangle.w"
1405 case')':app_repl(a);
1406 if(t==macro)app_repl(' ');
1407 break;
1408 default:app_repl(a);
1410 done:next_control= (eight_bits)a;
1411 if(text_ptr> text_info_end)overflow("text");
1412 cur_text= text_ptr;(++text_ptr)->tok_start= tok_ptr;
1415 /*:75*//*82:*/
1416 #line 1357 "cwebdir/ctangle.w"
1418 #line 432 "cwebdir/ctang-w2c.ch"
1419 static void
1420 scan_section(void)
1421 #line 1360 "cwebdir/ctangle.w"
1423 name_pointer p;
1424 text_pointer q;
1425 sixteen_bits a;
1426 section_count++;no_where= 1;
1427 if(*(loc-1)=='*'&&show_progress){
1428 printf("*%d",section_count);update_terminal;
1430 next_control= 0;
1431 while(1){
1432 /*83:*/
1433 #line 1396 "cwebdir/ctangle.w"
1435 while(next_control<definition)
1437 if((next_control= skip_ahead())==section_name){
1438 loc-= 2;next_control= get_next();
1441 /*:83*/
1442 #line 1371 "cwebdir/ctangle.w"
1444 if(next_control==definition){
1445 /*84:*/
1446 #line 1403 "cwebdir/ctangle.w"
1448 while((next_control= get_next())=='\n');
1449 if(next_control!=identifier){
1450 err_print("! Definition flushed, must start with identifier");
1452 continue;
1454 app_repl(((a= id_lookup(id_first,id_loc,0)-name_dir)/0400)+0200);
1456 app_repl(a%0400);
1457 if(*loc!='('){
1458 app_repl(string);app_repl(' ');app_repl(string);
1460 scan_repl(macro);
1461 cur_text->text_link= 0;
1464 /*:84*/
1465 #line 1373 "cwebdir/ctangle.w"
1467 continue;
1469 if(next_control==begin_C){
1470 p= name_dir;break;
1472 if(next_control==section_name){
1473 p= cur_section_name;
1474 /*85:*/
1475 #line 1428 "cwebdir/ctangle.w"
1477 while((next_control= get_next())=='+');
1478 if(next_control!='='&&next_control!=eq_eq)
1479 continue;
1481 /*:85*/
1482 #line 1381 "cwebdir/ctangle.w"
1484 break;
1486 return;
1488 no_where= print_where= 0;
1489 /*86:*/
1490 #line 1433 "cwebdir/ctangle.w"
1492 /*87:*/
1493 #line 1438 "cwebdir/ctangle.w"
1495 store_two_bytes((sixteen_bits)(0150000+section_count));
1498 /*:87*/
1499 #line 1434 "cwebdir/ctangle.w"
1501 scan_repl(section_name);
1502 /*88:*/
1503 #line 1442 "cwebdir/ctangle.w"
1505 if(p==name_dir||p==0){
1506 (last_unnamed)->text_link= cur_text-text_info;last_unnamed= cur_text;
1508 else if(p->equiv==(char*)text_info)p->equiv= (char*)cur_text;
1510 else{
1511 q= (text_pointer)p->equiv;
1512 while(q->text_link<section_flag)
1513 q= q->text_link+text_info;
1514 q->text_link= cur_text-text_info;
1516 cur_text->text_link= section_flag;
1519 /*:88*/
1520 #line 1436 "cwebdir/ctangle.w"
1523 /*:86*/
1524 #line 1387 "cwebdir/ctangle.w"
1528 /*:82*//*90:*/
1529 #line 1460 "cwebdir/ctangle.w"
1531 #line 450 "cwebdir/ctang-w2c.ch"
1532 static void
1533 phase_one(void){
1534 #line 1463 "cwebdir/ctangle.w"
1535 phase= 1;
1536 section_count= 0;
1537 reset_input();
1538 skip_limbo();
1539 while(!input_has_ended)scan_section();
1540 check_complete();
1541 phase= 2;
1544 /*:90*//*92:*/
1545 #line 1478 "cwebdir/ctangle.w"
1547 #line 468 "cwebdir/ctang-w2c.ch"
1548 static void
1549 skip_limbo(void)
1550 #line 1481 "cwebdir/ctangle.w"
1552 char c;
1553 while(1){
1554 if(loc> limit&&get_line()==0)return;
1555 *(limit+1)= '@';
1556 while(*loc!='@')loc++;
1557 if(loc++<=limit){
1558 c= *loc++;
1559 if(ccode[(eight_bits)c]==new_section)break;
1560 switch(ccode[(eight_bits)c]){
1561 case translit_code:/*93:*/
1562 #line 1507 "cwebdir/ctangle.w"
1564 while(xisspace(*loc)&&loc<limit)loc++;
1565 loc+= 3;
1566 if(loc> limit||!xisxdigit(*(loc-3))||!xisxdigit(*(loc-2))
1567 ||(*(loc-3)>='0'&&*(loc-3)<='7')||!xisspace(*(loc-1)))
1568 err_print("! Improper hex number following @l");
1570 else{
1571 unsigned i;
1572 char*beg;
1573 sscanf(loc-3,"%x",&i);
1574 while(xisspace(*loc)&&loc<limit)loc++;
1575 beg= loc;
1576 while(loc<limit&&(xisalpha(*loc)||xisdigit(*loc)||*loc=='_'))loc++;
1577 if(loc-beg>=translit_length)
1578 err_print("! Replacement string in @l too long");
1580 else{
1581 strncpy(translit[i-0200],beg,loc-beg);
1582 translit[i-0200][loc-beg]= '\0';
1586 /*:93*/
1587 #line 1491 "cwebdir/ctangle.w"
1588 ;break;
1589 case format_code:case'@':break;
1590 case control_text:if(c=='q'||c=='Q'){
1591 while((c= skip_ahead())=='@');
1592 if(*(loc-1)!='>')
1593 err_print("! Double @ should be used in control text");
1595 break;
1597 default:err_print("! Double @ should be used in limbo");
1604 /*:92*//*94:*/
1605 #line 1533 "cwebdir/ctangle.w"
1607 void
1608 #line 477 "cwebdir/ctang-w2c.ch"
1609  print_stats(void){
1610 #line 1536 "cwebdir/ctangle.w"
1611 printf("\nMemory usage statistics:\n");
1612 printf("%ld names (out of %ld)\n",
1613 (long)(name_ptr-name_dir),(long)max_names);
1614 printf("%ld replacement texts (out of %ld)\n",
1615 (long)(text_ptr-text_info),(long)max_texts);
1616 printf("%ld bytes (out of %ld)\n",
1617 (long)(byte_ptr-byte_mem),(long)max_bytes);
1618 printf("%ld tokens (out of %ld)\n",
1619 (long)(tok_ptr-tok_mem),(long)max_toks);
1622 /*:94*/