w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

ctangleboot.c
Go to the documentation of this file.
1 /*1:*/
2 #line 66 "cwebdir/ctangle.w"
3 
4 /*4:*/
5 #line 53 "cwebdir/comm-w2c.h"
6 
7 #ifndef HAVE_GETTEXT
8 #define HAVE_GETTEXT 0
9 #endif
10 
11 #if HAVE_GETTEXT
12 #include <libintl.h>
13 #else
14 #define gettext(A) A
15 #endif
16 
17 #include <ctype.h>
18 #include <stdbool.h>
19 #include <stddef.h>
20 #include <stdint.h>
21 #include <stdlib.h>
22 #include <stdio.h>
23 #include <string.h>
24 
25 /*:4*/
26 #line 67 "cwebdir/ctangle.w"
27 
28 #define banner "This is CTANGLE, Version 4.2" \
29  \
30 
31 #define _(S) gettext(S) \
32 
33 #define and_and 04
34 #define lt_lt 020
35 #define gt_gt 021
36 #define plus_plus 013
37 #define minus_minus 01
38 #define minus_gt 031
39 #define non_eq 032
40 #define lt_eq 034
41 #define gt_eq 035
42 #define eq_eq 036
43 #define or_or 037
44 #define dot_dot_dot 016
45 #define colon_colon 06
46 #define period_ast 026
47 #define minus_gt_ast 027 \
48 
49 #define xisalpha(c) (isalpha((eight_bits) c) &&((eight_bits) c<0200) )
50 #define xisdigit(c) (isdigit((eight_bits) c) &&((eight_bits) c<0200) )
51 #define xisspace(c) (isspace((eight_bits) c) &&((eight_bits) c<0200) )
52 #define xislower(c) (islower((eight_bits) c) &&((eight_bits) c<0200) )
53 #define xisupper(c) (isupper((eight_bits) c) &&((eight_bits) c<0200) )
54 #define xisxdigit(c) (isxdigit((eight_bits) c) &&((eight_bits) c<0200) ) \
55 
56 #define max_include_depth 10 \
57 
58 #define max_file_name_length 1024
59 #define cur_file file[include_depth]
60 #define cur_file_name file_name[include_depth]
61 #define cur_line line[include_depth]
62 #define web_file file[0]
63 #define web_file_name file_name[0] \
64 
65 #define length(c) (size_t) ((c+1) ->byte_start-(c) ->byte_start)
66 #define print_id(c) term_write((c) ->byte_start,length((c) ) )
67 #define llink link
68 #define rlink dummy.Rlink
69 #define root name_dir->rlink \
70  \
71 
72 #define spotless 0
73 #define harmless_message 1
74 #define error_message 2
75 #define fatal_message 3
76 #define mark_harmless {if(history==spotless) history= harmless_message;}
77 #define mark_error history= error_message
78 #define confusion(s) fatal(_("! This can't happen: ") ,s) \
79  \
80 
81 #define show_banner flags['b']
82 #define show_progress flags['p']
83 #define show_stats flags['s']
84 #define show_happiness flags['h']
85 #define temporary_output flags['t']
86 #define make_xrefs flags['x'] \
87 
88 #define update_terminal fflush(stdout)
89 #define new_line putchar('\n')
90 #define putxchar putchar
91 #define term_write(a,b) fflush(stdout) ,fwrite(a,sizeof(char) ,b,stdout)
92 #define C_printf(c,a) fprintf(C_file,c,a)
93 #define C_putc(c) putc(c,C_file) \
94 
95 #define max_bytes 1000000 \
96 
97 #define max_toks 1000000
98 #define max_names 10239 \
99 
100 #define max_sections 4000
101 #define max_texts 10239
102 #define longest_name 10000
103 #define stack_size 500
104 #define buf_size 1000
105 #define long_buf_size (buf_size+longest_name) \
106 
107 #define equiv equiv_or_xref \
108 
109 #define section_flag max_texts \
110 
111 #define string 02
112 #define join 0177
113 #define output_defs_flag (2*024000-1) \
114 
115 #define cur_end cur_state.end_field
116 #define cur_byte cur_state.byte_field
117 #define cur_name cur_state.name_field
118 #define cur_repl cur_state.repl_field
119 #define cur_section cur_state.section_field \
120 
121 #define section_number 0201
122 #define identifier 0202 \
123 
124 #define normal 0
125 #define num_or_id 1
126 #define post_slash 2
127 #define unbreakable 3
128 #define verbatim 4 \
129 
130 #define max_files 256
131 #define translit_length 10 \
132 
133 #define ignore 0
134 #define ord 0302
135 #define control_text 0303
136 #define translit_code 0304
137 #define output_defs_code 0305
138 #define format_code 0306
139 #define definition 0307
140 #define begin_C 0310
141 #define section_name 0311
142 #define new_section 0312 \
143 
144 #define constant 03 \
145 
146 #define isxalpha(c) ((c) =='_'||(c) =='$') \
147 
148 #define ishigh(c) ((eight_bits) (c) > 0177) \
149  \
150 
151 #define compress(c) if(loc++<=limit) return c \
152 
153 #define macro 0
154 #define app_repl(c) {if(tok_ptr==tok_mem_end) overflow(_("token") ) ;*tok_ptr++= c;} \
155 
156 #define max_banner 50 \
157 
158 
159 #line 68 "cwebdir/ctangle.w"
160 
161 /*3:*/
162 #line 35 "cwebdir/comm-w2c.h"
163 
164 typedef bool boolean;
167 typedef enum{
170 extern cweb program;
171 extern int phase;
172 
173 /*:3*//*5:*/
174 #line 91 "cwebdir/comm-w2c.h"
175 
176 extern char section_text[];
177 extern char*section_text_end;
178 extern char*id_first;
179 extern char*id_loc;
180 
181 /*:5*//*6:*/
182 #line 105 "cwebdir/comm-w2c.h"
183 
184 extern char buffer[];
185 extern char*buffer_end;
186 extern char*loc;
187 extern char*limit;
188 
189 /*:6*//*7:*/
190 #line 122 "cwebdir/comm-w2c.h"
191 
192 extern int include_depth;
193 extern FILE*file[];
194 extern FILE*change_file;
195 extern char file_name[][max_file_name_length];
196 
197 extern char change_file_name[];
198 extern char check_file_name[];
199 extern int line[];
200 extern int change_line;
201 extern int change_depth;
202 extern boolean input_has_ended;
203 extern boolean changing;
204 extern boolean web_file_open;
205 
206 /*:7*//*9:*/
207 #line 143 "cwebdir/comm-w2c.h"
208 
210 extern boolean changed_section[];
211 extern boolean change_pending;
212 extern boolean print_where;
213 
214 /*:9*//*10:*/
215 #line 157 "cwebdir/comm-w2c.h"
216 
217 typedef struct name_info{
220 union{
222 
223 char Ilk;
229 extern char byte_mem[];
230 extern char*byte_mem_end;
231 extern char*byte_ptr;
232 extern name_info name_dir[];
234 extern name_pointer name_ptr;
235 extern name_pointer hash[];
236 extern hash_pointer hash_end;
237 extern hash_pointer h;
238 
239 /*:10*//*12:*/
240 #line 201 "cwebdir/comm-w2c.h"
241 
242 extern int history;
243 
244 /*:12*//*14:*/
245 #line 218 "cwebdir/comm-w2c.h"
246 
247 extern int argc;
248 extern char**argv;
249 extern char C_file_name[];
250 extern char tex_file_name[];
251 extern char idx_file_name[];
252 extern char scn_file_name[];
253 extern boolean flags[];
254 extern const char*use_language;
255 
256 /*:14*//*15:*/
257 #line 235 "cwebdir/comm-w2c.h"
258 
259 extern FILE*C_file;
260 extern FILE*tex_file;
261 extern FILE*idx_file;
262 extern FILE*scn_file;
263 extern FILE*active_file;
264 extern FILE*check_file;
265 
266 /*:15*//*115:*/
267 #line 473 "cwebdir/ctang-w2c.ch"
268 
269 extern char cb_banner[];
270 
271 /*:115*/
272 #line 69 "cwebdir/ctangle.w"
273 
274 /*19:*/
275 #line 122 "cwebdir/ctangle.w"
276 
277 typedef struct{
280 }text;
282 
283 /*:19*//*31:*/
284 #line 269 "cwebdir/ctangle.w"
285 
286 typedef struct{
292 }output_state;
294 
295 /*:31*/
296 #line 70 "cwebdir/ctangle.w"
297 
298 /*20:*/
299 #line 129 "cwebdir/ctangle.w"
300 
307 
308 /*:20*//*26:*/
309 #line 198 "cwebdir/ctangle.w"
310 
312 
313 /*:26*//*32:*/
314 #line 285 "cwebdir/ctangle.w"
315 
317 
321 
322 /*:32*//*37:*/
323 #line 361 "cwebdir/ctangle.w"
324 
325 static int cur_val;
326 
327 /*:37*//*42:*/
328 #line 452 "cwebdir/ctangle.w"
329 
331 static boolean protect;
332 
333 /*:42*//*45:*/
334 #line 483 "cwebdir/ctangle.w"
335 
340 
341 /*:45*//*52:*/
342 #line 582 "cwebdir/ctangle.w"
343 
344 static boolean output_defs_seen= false;
345 
346 /*:52*//*57:*/
347 #line 691 "cwebdir/ctangle.w"
348 
349 static char translit[128][translit_length];
350 
351 /*:57*//*62:*/
352 #line 770 "cwebdir/ctangle.w"
353 
354 static eight_bits ccode[256];
355 
356 /*:62*//*66:*/
357 #line 830 "cwebdir/ctangle.w"
358 
359 static boolean comment_continues= false;
360 
361 /*:66*//*68:*/
362 #line 869 "cwebdir/ctangle.w"
363 
365 static boolean no_where;
366 
367 /*:68*//*82:*/
368 #line 1182 "cwebdir/ctangle.w"
369 
372 
373 /*:82*/
374 #line 71 "cwebdir/ctangle.w"
375 
376 /*8:*/
377 #line 137 "cwebdir/comm-w2c.h"
378 
379 extern boolean get_line(void);
380 extern void check_complete(void);
381 extern void reset_input(void);
382 
383 /*:8*//*11:*/
384 #line 180 "cwebdir/comm-w2c.h"
385 
386 extern boolean names_match(name_pointer,const char*,size_t,eight_bits);
387 extern name_pointer id_lookup(const char*,const char*,char);
388 
389 extern name_pointer section_lookup(char*,char*,int);
390 extern void init_node(name_pointer);
391 extern void init_p(name_pointer,eight_bits);
392 extern void print_prefix_name(name_pointer);
393 extern void print_section_name(name_pointer);
394 extern void sprint_section_name(char*,name_pointer);
395 
396 /*:11*//*13:*/
397 #line 204 "cwebdir/comm-w2c.h"
398 
399 extern int wrap_up(void);
400 extern void err_print(const char*);
401 extern void fatal(const char*,const char*);
402 extern void overflow(const char*);
403 
404 /*:13*//*16:*/
405 #line 244 "cwebdir/comm-w2c.h"
406 
407 extern void common_init(void);
408 extern void print_stats(void);
409 extern void cb_show_banner(void);
410 
411 /*:16*//*30:*/
412 #line 241 "cwebdir/ctangle.w"
413 static void store_two_bytes(sixteen_bits);
414 
415 /*:30*//*35:*/
416 #line 324 "cwebdir/ctangle.w"
417 
418 static void push_level(name_pointer);
419 static void pop_level(boolean);
420 
421 /*:35*//*39:*/
422 #line 397 "cwebdir/ctangle.w"
423 static void get_output(void);
424 
425 /*:39*//*44:*/
426 #line 473 "cwebdir/ctangle.w"
427 static void flush_buffer(void);
428 
429 /*:44*//*49:*/
430 #line 549 "cwebdir/ctangle.w"
431 static void phase_two(void);
432 
433 /*:49*//*53:*/
434 #line 585 "cwebdir/ctangle.w"
435 
436 static void output_defs(void);
437 static void out_char(eight_bits);
438 
439 /*:53*//*65:*/
440 #line 810 "cwebdir/ctangle.w"
441 
442 static eight_bits skip_ahead(void);
443 static boolean skip_comment(boolean);
444 
445 /*:65*//*70:*/
446 #line 924 "cwebdir/ctangle.w"
447 static eight_bits get_next(void);
448 
449 /*:70*//*84:*/
450 #line 1208 "cwebdir/ctangle.w"
451 static void scan_repl(eight_bits);
452 
453 /*:84*//*91:*/
454 #line 1379 "cwebdir/ctangle.w"
455 static void scan_section(void);
456 
457 /*:91*//*99:*/
458 #line 1460 "cwebdir/ctangle.w"
459 static void phase_one(void);
460 
461 /*:99*//*101:*/
462 #line 1494 "cwebdir/ctangle.w"
463 static void skip_limbo(void);
464 
465 /*:101*/
466 #line 72 "cwebdir/ctangle.w"
467 
468 
469 /*:1*//*2:*/
470 #line 81 "cwebdir/ctangle.w"
471 
472 int main(
473 int ac,
474 char**av)
475 {
476 argc= ac;argv= av;
478 /*21:*/
479 #line 137 "cwebdir/ctangle.w"
480 
483 
484 
485 /*:21*//*23:*/
486 #line 147 "cwebdir/ctangle.w"
487 
489 
490 /*:23*//*27:*/
491 #line 201 "cwebdir/ctangle.w"
493 
494 /*:27*//*46:*/
495 #line 493 "cwebdir/ctangle.w"
496 
498 
499 /*:46*//*58:*/
500 #line 694 "cwebdir/ctangle.w"
501 
502 {
503 int i;
504 for(i= 0;i<128;i++)sprintf(translit[i],"X%02X",(unsigned int)(128+i));
505 }
506 
507 /*:58*//*63:*/
508 #line 773 "cwebdir/ctangle.w"
509 {
510 int c;
511 for(c= 0;c<256;c++)ccode[c]= ignore;
512 ccode[' ']= ccode['\t']= ccode['\n']= ccode['\v']= ccode['\r']= ccode['\f']
513 = ccode['*']= new_section;
514 ccode['@']= '@';ccode['=']= string;
515 ccode['d']= ccode['D']= definition;
516 ccode['f']= ccode['F']= ccode['s']= ccode['S']= format_code;
517 ccode['c']= ccode['C']= ccode['p']= ccode['P']= begin_C;
518 ccode['^']= ccode[':']= ccode['.']= ccode['t']= ccode['T']=
519 ccode['q']= ccode['Q']= control_text;
520 ccode['h']= ccode['H']= output_defs_code;
521 ccode['l']= ccode['L']= translit_code;
522 ccode['&']= join;
523 ccode['<']= ccode['(']= section_name;
524 ccode['\'']= ord;
525 }
526 
527 /*:63*//*78:*/
528 #line 1103 "cwebdir/ctangle.w"
529 section_text[0]= ' ';
530 
531 /*:78*//*116:*/
532 #line 476 "cwebdir/ctang-w2c.ch"
533 
535 
536 /*:116*/
537 #line 88 "cwebdir/ctangle.w"
538 
539 common_init();
540 #line 53 "cwebdir/ctang-w2c.ch"
542 #line 91 "cwebdir/ctangle.w"
543 phase_one();
544 phase_two();
545 return wrap_up();
546 }
547 
548 /*:2*//*24:*/
549 #line 153 "cwebdir/ctangle.w"
550 
551 boolean names_match(
553 const char*first,
554 size_t l,
555 eight_bits t)
556 {(void)t;
557 if(length(p)!=l)return false;
558 return!strncmp(first,p->byte_start,l);
559 }
560 
561 /*:24*//*25:*/
562 #line 169 "cwebdir/ctangle.w"
563 
564 void
567 {
568 node->equiv= (void*)text_info;
569 }
570 void
572 
573 /*:25*//*29:*/
574 #line 231 "cwebdir/ctangle.w"
575 
576 static void
579 {
580 #line 65 "cwebdir/ctang-w2c.ch"
581 if(tok_ptr+2> tok_mem_end)overflow(_("token"));
582 #line 237 "cwebdir/ctangle.w"
583 *tok_ptr++= x>>8;
584 *tok_ptr++= x&0377;
585 }
586 
587 /*:29*//*34:*/
588 #line 309 "cwebdir/ctangle.w"
589 
590 static void
593 {
594 #line 71 "cwebdir/ctang-w2c.ch"
595 if(stack_ptr==stack_end)overflow(_("stack"));
596 #line 315 "cwebdir/ctangle.w"
598 stack_ptr++;
599 if(p!=NULL){
600 cur_name= p;cur_repl= (text_pointer)p->equiv;
601 cur_byte= cur_repl->tok_start;cur_end= (cur_repl+1)->tok_start;
602 cur_section= 0;
603 }
604 }
605 
606 /*:34*//*36:*/
607 #line 332 "cwebdir/ctangle.w"
608 
609 static void
611 boolean flag)
612 {
613 if(flag&&cur_repl->text_link<section_flag){
614 cur_repl= cur_repl->text_link+text_info;
615 cur_byte= cur_repl->tok_start;cur_end= (cur_repl+1)->tok_start;
616 return;
617 }
618 stack_ptr--;
620 }
621 
622 /*:36*//*38:*/
623 #line 368 "cwebdir/ctangle.w"
624 
625 static void
627 {
629 restart:if(stack_ptr==stack)return;
630 if(cur_byte==cur_end){
631 cur_val= -((int)cur_section);
632 pop_level(true);
633 if(cur_val==0)goto restart;
634 out_char(section_number);return;
635 }
636 a= *cur_byte++;
637 if(out_state==verbatim&&a!=string&&a!=constant&&a!='\n')
638 C_putc(a);
639 else if(a<0200)out_char(a);
640 else{
641 a= (a-0200)*0400+*cur_byte++;
642 switch(a/024000){
643 case 0:cur_val= a;out_char(identifier);break;
644 case 1:if(a==output_defs_flag)output_defs();
645 else/*40:*/
646 #line 402 "cwebdir/ctangle.w"
647 
648 {
649 a-= 024000;
650 if((a+name_dir)->equiv!=(void*)text_info)push_level(a+name_dir);
651 else if(a!=0){
652 #line 77 "cwebdir/ctang-w2c.ch"
653 fputs(_("\n! Not present: <"),stdout);
654 #line 408 "cwebdir/ctangle.w"
656 
657 }
658 goto restart;
659 }
660 
661 /*:40*/
662 #line 389 "cwebdir/ctangle.w"
663 
664 break;
665 default:cur_val= a-050000;if(cur_val> 0)cur_section= cur_val;
667 }
668 }
669 }
670 
671 /*:38*//*43:*/
672 #line 460 "cwebdir/ctangle.w"
673 
674 static void
676 {
677 C_putc('\n');
678 if(cur_line%100==0&&show_progress){
679 printf(".");
680 if(cur_line%500==0)printf("%d",cur_line);
682 }
683 cur_line++;
684 }
685 
686 /*:43*//*48:*/
687 #line 514 "cwebdir/ctangle.w"
688 
689 static void
690 phase_two(void){
691 web_file_open= false;
692 cur_line= 1;
693 /*33:*/
694 #line 298 "cwebdir/ctangle.w"
695 
697 cur_byte= cur_repl->tok_start;cur_end= (cur_repl+1)->tok_start;cur_section= 0;
698 
699 /*:33*/
700 #line 519 "cwebdir/ctangle.w"
701 
702 /*51:*/
703 #line 578 "cwebdir/ctangle.w"
704 
705 if(!output_defs_seen)
706 output_defs();
707 
708 /*:51*/
709 #line 520 "cwebdir/ctangle.w"
710 
712 #line 89 "cwebdir/ctang-w2c.ch"
713 fputs(_("\n! No program text was specified."),stdout);mark_harmless;
714 #line 523 "cwebdir/ctangle.w"
715 
716 }
717 else{
719 if(show_progress)
720 #line 95 "cwebdir/ctang-w2c.ch"
721 printf(_("\nWriting the output file (%s):"),C_file_name);
722 #line 529 "cwebdir/ctangle.w"
723 }
724 else{
725 if(show_progress){
726 #line 101 "cwebdir/ctang-w2c.ch"
727 fputs(_("\nWriting the output files:"),stdout);
728 #line 533 "cwebdir/ctangle.w"
729 
730 printf(" (%s)",C_file_name);
732 }
733 if(text_info->text_link==0)goto writeloop;
734 }
735 while(stack_ptr> stack)get_output();
736 flush_buffer();
737 writeloop:/*50:*/
738 #line 130 "cwebdir/ctang-w2c.ch"
739 
741 /*105:*/
742 #line 356 "cwebdir/ctang-w2c.ch"
743 
744 if((C_file= fopen(C_file_name,"r"))!=NULL){
745 /*106:*/
746 #line 363 "cwebdir/ctang-w2c.ch"
747 
748 char x[BUFSIZ],y[BUFSIZ];
749 int x_size,y_size,comparison= false;
750 
752 fatal(_("! Cannot open output file "),check_file_name);
753 
754 
755 if(temporary_output)/*107:*/
756 #line 378 "cwebdir/ctang-w2c.ch"
757 
758 do{
759 x_size= fread(x,1,BUFSIZ,C_file);
760 y_size= fread(y,1,BUFSIZ,check_file);
761 comparison= (x_size==y_size);
762 if(comparison)comparison= !memcmp(x,y,x_size);
763 }while(comparison&&!feof(C_file)&&!feof(check_file));
764 
765 /*:107*/
766 #line 371 "cwebdir/ctang-w2c.ch"
767 
768 
771 
772 /*:106*/
773 #line 358 "cwebdir/ctang-w2c.ch"
774 
775 /*108:*/
776 #line 389 "cwebdir/ctang-w2c.ch"
777 
778 if(comparison)
780 else{
783 }
784 
785 /*:108*/
786 #line 359 "cwebdir/ctang-w2c.ch"
787 
788 }else
790 
791 /*:105*/
792 #line 132 "cwebdir/ctang-w2c.ch"
793 
797 if((C_file= fopen(output_file_name,"a"))==NULL)
798 fatal(_("! Cannot open output file "),output_file_name);
799 
800 else fclose(C_file);
801 if((C_file= fopen(check_file_name,"wb"))==NULL)
802 fatal(_("! Cannot open output file "),check_file_name);
804 cur_line= 1;
805 stack_ptr= stack+1;
806 cur_name= (*an_output_file);
808 cur_byte= cur_repl->tok_start;
809 cur_end= (cur_repl+1)->tok_start;
810 while(stack_ptr> stack)get_output();
812 /*109:*/
813 #line 402 "cwebdir/ctang-w2c.ch"
814 
815 if(0==strcmp("/dev/stdout",output_file_name))
816 /*111:*/
817 #line 429 "cwebdir/ctang-w2c.ch"
818 {
819 /*114:*/
820 #line 460 "cwebdir/ctang-w2c.ch"
821 
822 char in_buf[BUFSIZ+1];
823 int in_size,comparison= true;
825 fatal(_("! Cannot open output file "),check_file_name);
826 
827 
828 /*:114*/
829 #line 430 "cwebdir/ctang-w2c.ch"
830 
831 do{
832 in_size= fread(in_buf,1,BUFSIZ,check_file);
833 in_buf[in_size]= '\0';
834 fprintf(stdout,"%s",in_buf);
835 }while(!feof(check_file));
837 /*110:*/
838 #line 419 "cwebdir/ctang-w2c.ch"
839 
840 if(comparison)
842 else{
845 }
846 
847 /*:110*/
848 #line 437 "cwebdir/ctang-w2c.ch"
849 
850 }
851 
852 /*:111*/
853 #line 404 "cwebdir/ctang-w2c.ch"
854 
855 else if(0==strcmp("/dev/stderr",output_file_name))
856 /*112:*/
857 #line 442 "cwebdir/ctang-w2c.ch"
858 {
859 /*114:*/
860 #line 460 "cwebdir/ctang-w2c.ch"
861 
862 char in_buf[BUFSIZ+1];
863 int in_size,comparison= true;
865 fatal(_("! Cannot open output file "),check_file_name);
866 
867 
868 /*:114*/
869 #line 443 "cwebdir/ctang-w2c.ch"
870 
871 do{
872 in_size= fread(in_buf,1,BUFSIZ,check_file);
873 in_buf[in_size]= '\0';
874 fprintf(stderr,"%s",in_buf);
875 }while(!feof(check_file));
877 /*110:*/
878 #line 419 "cwebdir/ctang-w2c.ch"
879 
880 if(comparison)
882 else{
885 }
886 
887 /*:110*/
888 #line 450 "cwebdir/ctang-w2c.ch"
889 
890 }
891 
892 /*:112*/
893 #line 406 "cwebdir/ctang-w2c.ch"
894 
895 else if(0==strcmp("/dev/null",output_file_name))
896 /*113:*/
897 #line 455 "cwebdir/ctang-w2c.ch"
898 {
899 int comparison= true;
900 /*110:*/
901 #line 419 "cwebdir/ctang-w2c.ch"
902 
903 if(comparison)
905 else{
908 }
909 
910 /*:110*/
911 #line 457 "cwebdir/ctang-w2c.ch"
912 
913 }
914 
915 /*:113*/
916 #line 408 "cwebdir/ctang-w2c.ch"
917 
918 else{
919 if((C_file= fopen(output_file_name,"r"))!=NULL){
920 /*106:*/
921 #line 363 "cwebdir/ctang-w2c.ch"
922 
923 char x[BUFSIZ],y[BUFSIZ];
924 int x_size,y_size,comparison= false;
925 
927 fatal(_("! Cannot open output file "),check_file_name);
928 
929 
930 if(temporary_output)/*107:*/
931 #line 378 "cwebdir/ctang-w2c.ch"
932 
933 do{
934 x_size= fread(x,1,BUFSIZ,C_file);
935 y_size= fread(y,1,BUFSIZ,check_file);
936 comparison= (x_size==y_size);
937 if(comparison)comparison= !memcmp(x,y,x_size);
938 }while(comparison&&!feof(C_file)&&!feof(check_file));
939 
940 /*:107*/
941 #line 371 "cwebdir/ctang-w2c.ch"
942 
943 
946 
947 /*:106*/
948 #line 411 "cwebdir/ctang-w2c.ch"
949 
950 /*110:*/
951 #line 419 "cwebdir/ctang-w2c.ch"
952 
953 if(comparison)
955 else{
958 }
959 
960 /*:110*/
961 #line 412 "cwebdir/ctang-w2c.ch"
962 
963 }else
965 }
966 
967 /*:109*/
968 #line 151 "cwebdir/ctang-w2c.ch"
969 
970 }
972 #line 573 "cwebdir/ctangle.w"
973 
974 /*:50*/
975 #line 541 "cwebdir/ctangle.w"
976 
977 if(show_happiness){
979 #line 107 "cwebdir/ctang-w2c.ch"
980 fputs(_("Done."),stdout);
981 #line 545 "cwebdir/ctangle.w"
982 }
983 }
984 }
985 
986 /*:48*//*54:*/
987 #line 589 "cwebdir/ctangle.w"
988 
989 static void
991 {
995 if(cur_text->text_link==0){
997 cur_end= (cur_text+1)->tok_start;
998 C_printf("%s","#define ");
1000 protect= true;
1001 while(cur_byte<cur_end){
1002 a= *cur_byte++;
1003 if(cur_byte==cur_end&&a=='\n')break;
1004 if(out_state==verbatim&&a!=string&&a!=constant&&a!='\n')
1005 C_putc(a);
1006 
1007 else if(a<0200)out_char(a);
1008 else{
1009 a= (a-0200)*0400+*cur_byte++;
1010 if(a<024000){
1012 }
1013 #line 159 "cwebdir/ctang-w2c.ch"
1014 else if(a<050000){confusion(_("macro defs have strange char"));}
1015 #line 615 "cwebdir/ctangle.w"
1016 else{
1018 }
1019 
1020 }
1021 }
1022 protect= false;
1023 flush_buffer();
1024 }
1025 pop_level(false);
1026 }
1027 
1028 /*:54*//*55:*/
1029 #line 632 "cwebdir/ctangle.w"
1030 
1031 static void
1033 eight_bits cur_char)
1034 {
1035 char*j,*k;
1036 restart:
1037 switch(cur_char){
1038 case'\n':if(protect&&out_state!=verbatim)C_putc(' ');
1039 if(protect||out_state==verbatim)C_putc('\\');
1041 /*59:*/
1042 #line 700 "cwebdir/ctangle.w"
1043 
1044 case identifier:
1045 if(out_state==num_or_id)C_putc(' ');
1048 while(j<k){
1049 if((eight_bits)(*j)<0200)C_putc(*j);
1050 
1051 else C_printf("%s",translit[(eight_bits)(*j)-0200]);
1052 j++;
1053 }
1054 out_state= num_or_id;break;
1055 
1056 /*:59*/
1057 #line 643 "cwebdir/ctangle.w"
1058 
1059 /*60:*/
1060 #line 713 "cwebdir/ctangle.w"
1061 
1062 case section_number:
1063 if(cur_val> 0)C_printf("/*%d:*/",cur_val);
1064 else if(cur_val<0)C_printf("/*:%d*/",-cur_val);
1065 else if(protect){
1066 cur_byte+= 4;
1067 cur_char= '\n';
1068 goto restart;
1069 }else{
1070 sixteen_bits a;
1071 a= 0400**cur_byte++;
1072 a+= *cur_byte++;
1073 C_printf("\n#line %d \"",a);
1074 
1075 cur_val= *cur_byte++;
1076 cur_val= 0400*(cur_val-0200)+*cur_byte++;
1077 for(j= (cur_val+name_dir)->byte_start,k= (cur_val+name_dir+1)->byte_start;
1078 j<k;j++){
1079 if(*j=='\\'||*j=='"')C_putc('\\');
1080 C_putc(*j);
1081 }
1082 C_printf("%s","\"\n");
1083 }
1084 break;
1085 
1086 /*:60*/
1087 #line 644 "cwebdir/ctangle.w"
1088 
1089 /*56:*/
1090 #line 662 "cwebdir/ctangle.w"
1091 
1092 case plus_plus:C_putc('+');C_putc('+');out_state= normal;break;
1093 case minus_minus:C_putc('-');C_putc('-');out_state= normal;break;
1094 case minus_gt:C_putc('-');C_putc('>');out_state= normal;break;
1095 case gt_gt:C_putc('>');C_putc('>');out_state= normal;break;
1096 case eq_eq:C_putc('=');C_putc('=');out_state= normal;break;
1097 case lt_lt:C_putc('<');C_putc('<');out_state= normal;break;
1098 case gt_eq:C_putc('>');C_putc('=');out_state= normal;break;
1099 case lt_eq:C_putc('<');C_putc('=');out_state= normal;break;
1100 case non_eq:C_putc('!');C_putc('=');out_state= normal;break;
1101 case and_and:C_putc('&');C_putc('&');out_state= normal;break;
1102 case or_or:C_putc('|');C_putc('|');out_state= normal;break;
1103 case dot_dot_dot:C_putc('.');C_putc('.');C_putc('.');out_state= normal;
1104 break;
1105 case colon_colon:C_putc(':');C_putc(':');out_state= normal;break;
1106 case period_ast:C_putc('.');C_putc('*');out_state= normal;break;
1107 case minus_gt_ast:C_putc('-');C_putc('>');C_putc('*');out_state= normal;
1108 break;
1109 
1110 /*:56*/
1111 #line 645 "cwebdir/ctangle.w"
1112 
1113 case'=':case'>':C_putc(cur_char);C_putc(' ');
1114 out_state= normal;break;
1115 case join:out_state= unbreakable;break;
1116 case constant:if(out_state==verbatim){
1117 out_state= num_or_id;break;
1118 }
1119 if(out_state==num_or_id)C_putc(' ');out_state= verbatim;break;
1121 else out_state= verbatim;break;
1122 case'/':C_putc('/');out_state= post_slash;break;
1123 case'*':if(out_state==post_slash)C_putc(' ');
1124 
1125 default:C_putc(cur_char);out_state= normal;break;
1126 }
1127 }
1128 
1129 /*:55*//*64:*/
1130 #line 794 "cwebdir/ctangle.w"
1131 
1132 static eight_bits
1134 {
1135 eight_bits c;
1136 while(true){
1137 if(loc> limit&&(get_line()==false))return new_section;
1138 *(limit+1)= '@';
1139 while(*loc!='@')loc++;
1140 if(loc<=limit){
1141 loc++;c= ccode[(eight_bits)*loc];loc++;
1142 if(c!=ignore||*(loc-1)=='>')return c;
1143 }
1144 }
1145 }
1146 
1147 /*:64*//*67:*/
1148 #line 833 "cwebdir/ctangle.w"
1149 
1150 static boolean skip_comment(
1151 boolean is_long_comment)
1152 {
1153 char c;
1154 while(true){
1155 if(loc> limit){
1156 if(is_long_comment){
1157 if(get_line())return comment_continues= true;
1158 else{
1159 #line 165 "cwebdir/ctang-w2c.ch"
1160 err_print(_("! Input ended in mid-comment"));
1161 #line 844 "cwebdir/ctangle.w"
1162 
1163 return comment_continues= false;
1164 }
1165 }
1166 else return comment_continues= false;
1167 }
1168 c= *(loc++);
1169 if(is_long_comment&&c=='*'&&*loc=='/'){
1170 loc++;return comment_continues= false;
1171 }
1172 if(c=='@'){
1174 #line 171 "cwebdir/ctang-w2c.ch"
1175 err_print(_("! Section name ended in mid-comment"));loc--;
1176 #line 857 "cwebdir/ctangle.w"
1177 
1178 return comment_continues= false;
1179 }
1180 else loc++;
1181 }
1182 }
1183 }
1184 
1185 /*:67*//*69:*/
1186 #line 881 "cwebdir/ctangle.w"
1187 
1188 static eight_bits
1190 {
1191 static int preprocessing= 0;
1192 eight_bits c;
1193 while(true){
1194 if(loc> limit){
1195 if(preprocessing&&*(limit-1)!='\\')preprocessing= 0;
1196 if(get_line()==false)return new_section;
1197 else if(print_where&&!no_where){
1198 print_where= false;
1199 /*85:*/
1200 #line 1214 "cwebdir/ctangle.w"
1201 
1202 store_two_bytes(0150000);
1206 }else{
1209 }
1211 {int a_l= id_lookup(id_first,id_loc,0)-name_dir;app_repl((a_l/0400)+0200);
1212 app_repl(a_l%0400);}
1213 
1214 /*:85*/
1215 #line 893 "cwebdir/ctangle.w"
1216 
1217 }
1218 else return'\n';
1219 }
1220 c= *loc;
1221 if(comment_continues||(c=='/'&&(*(loc+1)=='*'||*(loc+1)=='/'))){
1222 skip_comment(comment_continues||*(loc+1)=='*');
1223 
1224 if(comment_continues)return'\n';
1225 else continue;
1226 }
1227 loc++;
1228 if(xisdigit(c)||c=='.')/*73:*/
1229 #line 964 "cwebdir/ctangle.w"
1230 {
1231 id_first= loc-1;
1232 if(*id_first=='.'&&!xisdigit(*loc))goto mistake;
1233 if(*id_first=='0'){
1234 if(*loc=='x'||*loc=='X'){
1235 loc++;while(xisxdigit(*loc))loc++;goto found;
1236 }
1237 }
1238 while(xisdigit(*loc))loc++;
1239 if(*loc=='.'){
1240 loc++;
1241 while(xisdigit(*loc))loc++;
1242 }
1243 if(*loc=='e'||*loc=='E'){
1244 if(*++loc=='+'||*loc=='-')loc++;
1245 while(xisdigit(*loc))loc++;
1246 }
1247 found:while(*loc=='u'||*loc=='U'||*loc=='l'||*loc=='L'
1248 ||*loc=='f'||*loc=='F')loc++;
1249 id_loc= loc;
1250 return constant;
1251 }
1252 
1253 /*:73*/
1254 #line 905 "cwebdir/ctangle.w"
1255 
1256 else if(c=='\''||c=='"'
1257 ||((c=='L'||c=='u'||c=='U')&&(*loc=='\''||*loc=='"'))
1258 ||((c=='u'&&*loc=='8')&&(*(loc+1)=='\''||*(loc+1)=='"')))
1259 /*74:*/
1260 #line 992 "cwebdir/ctangle.w"
1261 {
1262 char delim= c;
1265 if(delim=='L'||delim=='u'||delim=='U'){
1266 if(delim=='u'&&*loc=='8'){*++id_loc= *loc++;}
1267 delim= *loc++;*++id_loc= delim;
1268 }
1269 while(true){
1270 if(loc>=limit){
1271 if(*(limit-1)!='\\'){
1272 #line 177 "cwebdir/ctang-w2c.ch"
1273 err_print(_("! String didn't end"));loc= limit;break;
1274 #line 1004 "cwebdir/ctangle.w"
1275 
1276 }
1277 if(get_line()==false){
1278 #line 183 "cwebdir/ctang-w2c.ch"
1279 err_print(_("! Input ended in middle of string"));loc= buffer;break;
1280 #line 1008 "cwebdir/ctangle.w"
1281 
1282 }
1283 else if(++id_loc<=section_text_end)*id_loc= '\n';
1284 
1285 }
1286 if((c= *loc++)==delim){
1288 break;
1289 }
1290 if(c=='\\'){
1291 if(loc>=limit)continue;
1292 if(++id_loc<=section_text_end)*id_loc= '\\';
1293 c= *loc++;
1294 }
1296 }
1298 #line 189 "cwebdir/ctang-w2c.ch"
1299 fputs(_("\n! String too long: "),stdout);
1300 #line 1026 "cwebdir/ctangle.w"
1301 
1302 term_write(section_text+1,25);
1303 err_print("...");
1304 }
1305 id_loc++;
1306 return string;
1307 }
1308 
1309 /*:74*/
1310 #line 909 "cwebdir/ctangle.w"
1311 
1312 else if(isalpha(c)||isxalpha(c)||ishigh(c))
1313 /*72:*/
1314 #line 957 "cwebdir/ctangle.w"
1315 {
1316 id_first= --loc;
1317 while(isalpha((eight_bits)*++loc)||isdigit((eight_bits)*loc)
1319 id_loc= loc;return identifier;
1320 }
1321 
1322 /*:72*/
1323 #line 911 "cwebdir/ctangle.w"
1324 
1325 else if(c=='@')/*75:*/
1326 #line 1037 "cwebdir/ctangle.w"
1327 {
1328 c= ccode[(eight_bits)*loc++];
1329 switch(c){
1330 case ignore:continue;
1331 #line 195 "cwebdir/ctang-w2c.ch"
1332 case translit_code:err_print(_("! Use @l in limbo only"));continue;
1333 #line 1042 "cwebdir/ctangle.w"
1334 
1335 case control_text:while((c= skip_ahead())=='@');
1336 
1337 if(*(loc-1)!='>')
1338 #line 201 "cwebdir/ctang-w2c.ch"
1339 err_print(_("! Double @ should be used in control text"));
1340 #line 1047 "cwebdir/ctangle.w"
1341 
1342 continue;
1343 case section_name:
1345 /*77:*/
1346 #line 1085 "cwebdir/ctangle.w"
1347 {
1348 char*k;
1349 /*79:*/
1350 #line 1105 "cwebdir/ctangle.w"
1351 
1352 k= section_text;
1353 while(true){
1354 if(loc> limit&&get_line()==false){
1355 #line 219 "cwebdir/ctang-w2c.ch"
1356 err_print(_("! Input ended in section name"));
1357 #line 1110 "cwebdir/ctangle.w"
1358 
1359 loc= buffer+1;break;
1360 }
1361 c= *loc;
1362 /*80:*/
1363 #line 1129 "cwebdir/ctangle.w"
1364 
1365 if(c=='@'){
1366 c= *(loc+1);
1367 if(c=='>'){
1368 loc+= 2;break;
1369 }
1370 if(ccode[(eight_bits)c]==new_section){
1371 #line 231 "cwebdir/ctang-w2c.ch"
1372 err_print(_("! Section name didn't end"));break;
1373 #line 1137 "cwebdir/ctangle.w"
1374 
1375 }
1377 #line 237 "cwebdir/ctang-w2c.ch"
1378 err_print(_("! Nesting of section names not allowed"));break;
1379 #line 1141 "cwebdir/ctangle.w"
1380 
1381 }
1382 *(++k)= '@';loc++;
1383 }
1384 
1385 /*:80*/
1386 #line 1114 "cwebdir/ctangle.w"
1387 
1388 loc++;if(k<section_text_end)k++;
1389 if(xisspace(c)){
1390 c= ' ';if(*(k-1)==' ')k--;
1391 }
1392 *k= c;
1393 }
1394 if(k>=section_text_end){
1395 #line 225 "cwebdir/ctang-w2c.ch"
1396 fputs(_("\n! Section name too long: "),stdout);
1397 #line 1123 "cwebdir/ctangle.w"
1398 
1399 term_write(section_text+1,25);
1400 printf("...");mark_harmless;
1401 }
1402 if(*k==' '&&k> section_text)k--;
1403 
1404 /*:79*/
1405 #line 1087 "cwebdir/ctangle.w"
1406 
1407 if(k-section_text> 3&&strncmp(k-2,"...",3)==0)
1410 if(cur_section_name_char=='(')
1411 /*47:*/
1412 #line 497 "cwebdir/ctangle.w"
1413 
1414 {
1417 if(*an_output_file==cur_section_name)break;
1421 else{
1422 #line 83 "cwebdir/ctang-w2c.ch"
1423 overflow(_("output files"));
1424 #line 507 "cwebdir/ctangle.w"
1425 }
1426 }
1427 }
1428 
1429 /*:47*/
1430 #line 1093 "cwebdir/ctangle.w"
1431 
1432 return section_name;
1433 }
1434 
1435 /*:77*/
1436 #line 1051 "cwebdir/ctangle.w"
1437 
1438 case string:/*81:*/
1439 #line 1151 "cwebdir/ctangle.w"
1440 {
1441 id_first= loc++;*(limit+1)= '@';*(limit+2)= '>';
1442 while(*loc!='@'||*(loc+1)!='>')loc++;
1443 #line 243 "cwebdir/ctang-w2c.ch"
1444 if(loc>=limit)err_print(_("! Verbatim string didn't end"));
1445 #line 1155 "cwebdir/ctangle.w"
1446 
1447 id_loc= loc;loc+= 2;
1448 return string;
1449 }
1450 
1451 /*:81*/
1452 #line 1052 "cwebdir/ctangle.w"
1453 
1454 case ord:/*76:*/
1455 #line 1064 "cwebdir/ctangle.w"
1456 
1457 id_first= loc;
1458 if(*loc=='\\'){
1459 if(*++loc=='\'')loc++;
1460 }
1461 while(*loc!='\''){
1462 if(*loc=='@'){
1463 if(*(loc+1)!='@')
1464 #line 207 "cwebdir/ctang-w2c.ch"
1465 err_print(_("! Double @ should be used in ASCII constant"));
1466 #line 1073 "cwebdir/ctangle.w"
1467 
1468 else loc++;
1469 }
1470 loc++;
1471 if(loc> limit){
1472 #line 213 "cwebdir/ctang-w2c.ch"
1473 err_print(_("! String didn't end"));loc= limit-1;break;
1474 #line 1079 "cwebdir/ctangle.w"
1475 
1476 }
1477 }
1478 loc++;
1479 return ord;
1480 
1481 /*:76*/
1482 #line 1053 "cwebdir/ctangle.w"
1483 
1484 default:return c;
1485 }
1486 }
1487 
1488 /*:75*/
1489 #line 912 "cwebdir/ctangle.w"
1490 
1491 else if(xisspace(c)){
1492 if(!preprocessing||loc> limit)continue;
1493 
1494 else return' ';
1495 }
1496 else if(c=='#'&&loc==buffer+1)preprocessing= 1;
1497 mistake:/*71:*/
1498 #line 935 "cwebdir/ctangle.w"
1499 
1500 switch(c){
1501 case'+':if(*loc=='+')compress(plus_plus);break;
1502 case'-':if(*loc=='-'){compress(minus_minus);}
1503 else{if(*loc=='>'){if(*(loc+1)=='*'){loc++;compress(minus_gt_ast);}
1504 else compress(minus_gt);}}break;
1505 case'.':if(*loc=='*'){compress(period_ast);}
1506 else if(*loc=='.'&&*(loc+1)=='.'){
1508 }
1509 break;
1510 case':':if(*loc==':')compress(colon_colon);break;
1511 case'=':if(*loc=='=')compress(eq_eq);break;
1512 case'>':if(*loc=='='){compress(gt_eq);}
1513 else if(*loc=='>')compress(gt_gt);break;
1514 case'<':if(*loc=='='){compress(lt_eq);}
1515 else if(*loc=='<')compress(lt_lt);break;
1516 case'&':if(*loc=='&')compress(and_and);break;
1517 case'|':if(*loc=='|')compress(or_or);break;
1518 case'!':if(*loc=='=')compress(non_eq);break;
1519 }
1520 
1521 /*:71*/
1522 #line 919 "cwebdir/ctangle.w"
1523 
1524 return c;
1525 }
1526 }
1527 
1528 /*:69*//*83:*/
1529 #line 1186 "cwebdir/ctangle.w"
1530 
1531 static void
1533 eight_bits t)
1534 {
1535 sixteen_bits a;
1536 if(t==section_name){/*85:*/
1537 #line 1214 "cwebdir/ctangle.w"
1538 
1539 store_two_bytes(0150000);
1543 }else{
1546 }
1548 {int a_l= id_lookup(id_first,id_loc,0)-name_dir;app_repl((a_l/0400)+0200);
1549 app_repl(a_l%0400);}
1550 
1551 /*:85*/
1552 #line 1192 "cwebdir/ctangle.w"
1553 }
1554 while(true)switch(a= get_next()){
1555 /*86:*/
1556 #line 1227 "cwebdir/ctangle.w"
1557 
1559 app_repl((a/0400)+0200);
1560 app_repl(a%0400);break;
1561 case section_name:if(t!=section_name)goto done;
1562 else{
1563 /*87:*/
1564 #line 1260 "cwebdir/ctangle.w"
1565 {
1566 char*try_loc= loc;
1567 while(*try_loc==' '&&try_loc<limit)try_loc++;
1568 if(*try_loc=='+'&&try_loc<limit)try_loc++;
1569 while(*try_loc==' '&&try_loc<limit)try_loc++;
1570 #line 273 "cwebdir/ctang-w2c.ch"
1571 if(*try_loc=='=')err_print(_("! Missing `@ ' before a named section"));
1572 #line 1266 "cwebdir/ctangle.w"
1573 
1574 
1575 
1576 }
1577 
1578 /*:87*/
1579 #line 1233 "cwebdir/ctangle.w"
1580 
1582 app_repl((a/0400)+0250);
1583 app_repl(a%0400);
1584 /*85:*/
1585 #line 1214 "cwebdir/ctangle.w"
1586 
1587 store_two_bytes(0150000);
1591 }else{
1594 }
1596 {int a_l= id_lookup(id_first,id_loc,0)-name_dir;app_repl((a_l/0400)+0200);
1597 app_repl(a_l%0400);}
1598 
1599 /*:85*/
1600 #line 1237 "cwebdir/ctangle.w"
1601 break;
1602 }
1603 #line 261 "cwebdir/ctang-w2c.ch"
1604 case output_defs_code:if(t!=section_name)err_print(_("! Misplaced @h"));
1605 #line 1240 "cwebdir/ctangle.w"
1606 
1607 else{
1608 output_defs_seen= true;
1610 app_repl((a/0400)+0200);
1611 app_repl(a%0400);
1612 /*85:*/
1613 #line 1214 "cwebdir/ctangle.w"
1614 
1615 store_two_bytes(0150000);
1619 }else{
1622 }
1624 {int a_l= id_lookup(id_first,id_loc,0)-name_dir;app_repl((a_l/0400)+0200);
1625 app_repl(a_l%0400);}
1626 
1627 /*:85*/
1628 #line 1246 "cwebdir/ctangle.w"
1629 
1630 }
1631 break;
1632 case constant:case string:
1633 /*88:*/
1634 #line 1271 "cwebdir/ctangle.w"
1635 
1636 app_repl(a);
1637 while(id_first<id_loc){
1638 if(*id_first=='@'){
1639 if(*(id_first+1)=='@')id_first++;
1640 #line 279 "cwebdir/ctang-w2c.ch"
1641 else err_print(_("! Double @ should be used in string"));
1642 #line 1277 "cwebdir/ctangle.w"
1643 
1644 }
1645 app_repl(*id_first++);
1646 }
1647 app_repl(a);break;
1648 
1649 /*:88*/
1650 #line 1250 "cwebdir/ctangle.w"
1651 
1652 case ord:
1653 /*89:*/
1654 #line 1287 "cwebdir/ctangle.w"
1655 {
1656 int c= (eight_bits)*id_first;
1657 if(c=='\\'){
1658 c= *++id_first;
1659 if(c>='0'&&c<='7'){
1660 c-= '0';
1661 if(*(id_first+1)>='0'&&*(id_first+1)<='7'){
1662 c= 8*c+*(++id_first)-'0';
1663 if(*(id_first+1)>='0'&&*(id_first+1)<='7'&&c<32)
1664 c= 8*c+*(++id_first)-'0';
1665 }
1666 }
1667 else switch(c){
1668 case't':c= '\t';break;
1669 case'n':c= '\n';break;
1670 case'b':c= '\b';break;
1671 case'f':c= '\f';break;
1672 case'v':c= '\v';break;
1673 case'r':c= '\r';break;
1674 case'a':c= '\7';break;
1675 case'?':c= '?';break;
1676 case'x':
1677 if(xisdigit(*(id_first+1)))c= *(++id_first)-'0';
1678 else if(xisxdigit(*(id_first+1))){
1679 ++id_first;
1680 c= toupper((eight_bits)*id_first)-'A'+10;
1681 }
1682 if(xisdigit(*(id_first+1)))c= 16*c+*(++id_first)-'0';
1683 else if(xisxdigit(*(id_first+1))){
1684 ++id_first;
1685 c= 16*c+toupper((eight_bits)*id_first)-'A'+10;
1686 }
1687 break;
1688 case'\\':c= '\\';break;
1689 case'\'':c= '\'';break;
1690 case'\"':c= '\"';break;
1691 #line 285 "cwebdir/ctang-w2c.ch"
1692 default:err_print(_("! Unrecognized escape sequence"));
1693 #line 1324 "cwebdir/ctangle.w"
1694 
1695 }
1696 }
1697 
1699 if(c>=100)app_repl('0'+c/100);
1700 if(c>=10)app_repl('0'+(c/10)%10);
1701 app_repl('0'+c%10);
1703 }
1704 break;
1705 
1706 /*:89*/
1707 #line 1252 "cwebdir/ctangle.w"
1708 
1709 case definition:case format_code:case begin_C:if(t!=section_name)goto done;
1710 else{
1711 #line 267 "cwebdir/ctang-w2c.ch"
1712 err_print(_("! @d, @f and @c are ignored in C text"));continue;
1713 #line 1256 "cwebdir/ctangle.w"
1714 
1715 }
1716 case new_section:goto done;
1717 
1718 /*:86*/
1719 #line 1197 "cwebdir/ctangle.w"
1720 
1721 case')':app_repl(a);
1722 if(t==macro)app_repl(' ');
1723 break;
1724 default:app_repl(a);
1725 }
1726 done:next_control= (eight_bits)a;
1727 #line 255 "cwebdir/ctang-w2c.ch"
1728 if(text_ptr> text_info_end)overflow(_("text"));
1729 #line 1205 "cwebdir/ctangle.w"
1730 cur_text= text_ptr;(++text_ptr)->tok_start= tok_ptr;
1731 }
1732 
1733 /*:83*//*90:*/
1734 #line 1346 "cwebdir/ctangle.w"
1735 
1736 static void
1738 {
1739 name_pointer p;
1740 text_pointer q;
1741 sixteen_bits a;
1742 section_count++;no_where= true;
1743 if(*(loc-1)=='*'&&show_progress){
1745 }
1746 next_control= 0;
1747 while(true){
1748 /*92:*/
1749 #line 1387 "cwebdir/ctangle.w"
1750 
1751 while(next_control<definition)
1752 
1754 loc-= 2;next_control= get_next();
1755 }
1756 
1757 /*:92*/
1758 #line 1360 "cwebdir/ctangle.w"
1759 
1761 /*93:*/
1762 #line 1394 "cwebdir/ctangle.w"
1763 {
1764 while((next_control= get_next())=='\n');
1766 #line 291 "cwebdir/ctang-w2c.ch"
1767 err_print(_("! Definition flushed, must start with identifier"));
1768 #line 1398 "cwebdir/ctangle.w"
1769 
1770 continue;
1771 }
1772 app_repl(((a= id_lookup(id_first,id_loc,0)-name_dir)/0400)+0200);
1773 
1774 app_repl(a%0400);
1775 if(*loc!='('){
1776 app_repl(string);app_repl(' ');app_repl(string);
1777 }
1778 scan_repl(macro);
1780 }
1781 
1782 /*:93*/
1783 #line 1362 "cwebdir/ctangle.w"
1784 
1785 continue;
1786 }
1787 if(next_control==begin_C){
1788 p= name_dir;break;
1789 }
1792 /*94:*/
1793 #line 1419 "cwebdir/ctangle.w"
1794 
1795 while((next_control= get_next())=='+');
1796 if(next_control!='='&&next_control!=eq_eq)
1797 continue;
1798 
1799 /*:94*/
1800 #line 1370 "cwebdir/ctangle.w"
1801 
1802 break;
1803 }
1804 return;
1805 }
1806 no_where= print_where= false;
1807 /*95:*/
1808 #line 1424 "cwebdir/ctangle.w"
1809 
1810 /*96:*/
1811 #line 1429 "cwebdir/ctangle.w"
1812 
1814 
1815 
1816 /*:96*/
1817 #line 1425 "cwebdir/ctangle.w"
1818 
1820 /*97:*/
1821 #line 1433 "cwebdir/ctangle.w"
1822 
1823 if(p==name_dir||p==0){
1825 }
1826 else if(p->equiv==(void*)text_info)p->equiv= (void*)cur_text;
1827 
1828 else{
1829 q= (text_pointer)p->equiv;
1830 while(q->text_link<section_flag)
1831 q= q->text_link+text_info;
1832 q->text_link= cur_text-text_info;
1833 }
1835 
1836 
1837 /*:97*/
1838 #line 1427 "cwebdir/ctangle.w"
1839 
1840 
1841 /*:95*/
1842 #line 1376 "cwebdir/ctangle.w"
1843 
1844 }
1845 
1846 /*:90*//*98:*/
1847 #line 1448 "cwebdir/ctangle.w"
1848 
1849 static void
1851 phase= 1;
1852 section_count= 0;
1853 reset_input();
1854 skip_limbo();
1855 while(!input_has_ended)scan_section();
1856 check_complete();
1857 phase= 2;
1858 }
1859 
1860 /*:98*//*100:*/
1861 #line 1465 "cwebdir/ctangle.w"
1862 
1863 static void
1865 {
1866 char c;
1867 while(true){
1868 if(loc> limit&&get_line()==false)return;
1869 *(limit+1)= '@';
1870 while(*loc!='@')loc++;
1871 if(loc++<=limit){
1872 c= *loc++;
1873 if(ccode[(eight_bits)c]==new_section)break;
1874 switch(ccode[(eight_bits)c]){
1875 case translit_code:/*102:*/
1876 #line 1496 "cwebdir/ctangle.w"
1877 
1878 while(xisspace(*loc)&&loc<limit)loc++;
1879 loc+= 3;
1880 if(loc> limit||!xisxdigit(*(loc-3))||!xisxdigit(*(loc-2))
1881 ||(*(loc-3)>='0'&&*(loc-3)<='7')||!xisspace(*(loc-1)))
1882 #line 309 "cwebdir/ctang-w2c.ch"
1883 err_print(_("! Improper hex number following @l"));
1884 #line 1502 "cwebdir/ctangle.w"
1885 
1886 else{
1887 unsigned int i;
1888 char*beg;
1889 sscanf(loc-3,"%x",&i);
1890 while(xisspace(*loc)&&loc<limit)loc++;
1891 beg= loc;
1892 while(loc<limit&&(xisalpha(*loc)||xisdigit(*loc)||*loc=='_'))loc++;
1893 if(loc-beg>=translit_length)
1894 #line 315 "cwebdir/ctang-w2c.ch"
1895 err_print(_("! Replacement string in @l too long"));
1896 #line 1512 "cwebdir/ctangle.w"
1897 
1898 else{
1899 strncpy(translit[i-0200],beg,(size_t)(loc-beg));
1900 translit[i-0200][loc-beg]= '\0';
1901 }
1902 }
1903 
1904 /*:102*/
1905 #line 1478 "cwebdir/ctangle.w"
1906 break;
1907 case format_code:case'@':break;
1908 case control_text:if(c=='q'||c=='Q'){
1909 while((c= skip_ahead())=='@');
1910 if(*(loc-1)!='>')
1911 #line 297 "cwebdir/ctang-w2c.ch"
1912 err_print(_("! Double @ should be used in control text"));
1913 #line 1484 "cwebdir/ctangle.w"
1914 
1915 break;
1916 }
1917 #line 303 "cwebdir/ctang-w2c.ch"
1918 default:err_print(_("! Double @ should be used in limbo"));
1919 #line 1488 "cwebdir/ctangle.w"
1920 
1921 }
1922 }
1923 }
1924 }
1925 
1926 /*:100*//*103:*/
1927 #line 1522 "cwebdir/ctangle.w"
1928 
1929 void
1931 #line 328 "cwebdir/ctang-w2c.ch"
1932 puts(_("\nMemory usage statistics:"));
1933 printf(_("%ld names (out of %ld)\n"),
1935 printf(_("%ld replacement texts (out of %ld)\n"),
1937 printf(_("%ld bytes (out of %ld)\n"),
1939 printf(_("%ld tokens (out of %ld)\n"),
1940 #line 1533 "cwebdir/ctangle.w"
1941 (ptrdiff_t)(tok_ptr-tok_mem),(long)max_toks);
1942 }
1943 
1944 #line 341 "cwebdir/ctang-w2c.ch"
1945 /*:103*/
int ptrdiff_t
Definition: CPAL.d:3845
q
Definition: afm2pl.c:2287
#define text(a)
Definition: aptex-macros.h:925
#define fopen
Definition: xxstdio.h:21
#define fread
Definition: xxstdio.h:25
const char * delim
Definition: dvistuff.c:159
char * strncpy()
int strcmp()
Definition: coll.cpp:143
int sscanf()
int printf()
char * strcpy()
long int flag
Definition: f2c.h:53
static void
Definition: fpif.c:118
#define c(n)
Definition: gpos-common.c:150
#define a(n)
Definition: gpos-common.c:148
#define memcmp(s1, s2, n)
Definition: gsftopk.c:66
#define NULL
Definition: ftobjs.h:61
small capitals from c petite p
Definition: afcover.h:72
small capitals from c petite p scientific i
Definition: afcover.h:80
kerning y
Definition: ttdriver.c:212
unsigned short uint16_t
Definition: stdint.h:79
unsigned char uint8_t
Definition: stdint.h:78
#define fclose
Definition: debug.h:100
#define fputs
Definition: mendex.h:67
#define fprintf
Definition: mendex.h:64
static name_pointer cur_section_name
Definition: ctangleboot.c:364
#define control_text
Definition: ctangleboot.c:135
static void flush_buffer(void)
Definition: ctangleboot.c:675
#define update_terminal
Definition: ctangleboot.c:88
boolean flags[]
Definition: t4ht.c:1169
#define section_flag
Definition: ctangleboot.c:109
char byte_mem[]
Definition: cwebboot.c:347
static boolean output_defs_seen
Definition: ctangleboot.c:344
FILE * active_file
Definition: cwebboot.c:394
char idx_file_name[]
Definition: cwebboot.c:377
static void scan_repl(eight_bits)
Definition: ctangleboot.c:1532
int main(int ac, char **av)
Definition: ctangleboot.c:472
#define app_repl(c)
Definition: ctangleboot.c:154
boolean names_match(name_pointer, const char *, size_t, eight_bits)
Definition: ctangleboot.c:551
static eight_bits ccode[256]
Definition: ctangleboot.c:354
hash_pointer hash_end
Definition: cwebboot.c:362
#define cur_file_name
Definition: ctangleboot.c:60
#define normal
Definition: ctangleboot.c:124
void common_init(void)
Definition: cwebboot.c:495
#define max_bytes
Definition: ctangleboot.c:95
static void push_level(name_pointer)
Definition: ctangleboot.c:591
#define mark_harmless
Definition: ctangleboot.c:76
#define section_name
Definition: ctangleboot.c:141
boolean change_pending
Definition: cwebboot.c:340
char * limit
Definition: cwebboot.c:310
FILE * idx_file
Definition: cwebboot.c:389
#define stack_size
Definition: ctangleboot.c:103
boolean input_has_ended
Definition: cwebboot.c:325
void fatal(const char *, const char *)
Definition: cwebboot.c:1374
#define new_line
Definition: ctangleboot.c:89
char file_name[][1024]
Definition: cwebboot.c:318
#define max_file_name_length
Definition: ctangleboot.c:58
static eight_bits next_control
Definition: ctangleboot.c:371
#define xisalpha(c)
Definition: ctangleboot.c:49
#define string
Definition: ctangleboot.c:111
#define cur_repl
Definition: ctangleboot.c:118
#define cur_byte
Definition: ctangleboot.c:116
#define macro
Definition: ctangleboot.c:153
#define output_defs_flag
Definition: ctangleboot.c:113
char section_text[]
Definition: cwebboot.c:299
FILE * scn_file
Definition: cwebboot.c:391
int wrap_up(void)
Definition: ctie-k.c:543
boolean get_line(void)
Definition: cwebboot.c:807
struct name_info name_info
static text_pointer cur_text
Definition: ctangleboot.c:370
static eight_bits skip_ahead(void)
Definition: ctangleboot.c:1133
#define unbreakable
Definition: ctangleboot.c:127
sixteen_bits section_count
Definition: cwebboot.c:338
static eight_bits tok_mem[1000000]
Definition: ctangleboot.c:304
char * section_text_end
Definition: cwebboot.c:300
#define non_eq
Definition: ctangleboot.c:39
void print_stats(void)
Definition: ctangleboot.c:1930
static char cur_section_name_char
Definition: ctangleboot.c:338
static char output_file_name[10000+1]
Definition: ctangleboot.c:339
#define temporary_output
Definition: ctangleboot.c:85
static void pop_level(boolean)
Definition: ctangleboot.c:610
#define cur_end
Definition: ctangleboot.c:115
#define or_or
Definition: ctangleboot.c:43
uint16_t sixteen_bits
Definition: ctangleboot.c:166
#define max_toks
Definition: ctangleboot.c:97
char cb_banner[]
Definition: cwebboot.c:408
static boolean skip_comment(boolean)
Definition: ctangleboot.c:1150
int include_depth
Definition: cwebboot.c:315
#define max_banner
Definition: ctangleboot.c:156
#define banner
Definition: ctangleboot.c:28
#define C_putc(c)
Definition: ctangleboot.c:93
#define output_defs_code
Definition: ctangleboot.c:137
FILE * tex_file
Definition: cwebboot.c:388
FILE * check_file
Definition: cwebboot.c:392
#define isxalpha(c)
Definition: ctangleboot.c:146
#define join
Definition: ctangleboot.c:112
#define max_files
Definition: ctangleboot.c:130
name_pointer * hash_pointer
Definition: ctangleboot.c:228
static boolean no_where
Definition: ctangleboot.c:365
#define format_code
Definition: ctangleboot.c:138
#define term_write(a, b)
Definition: ctangleboot.c:91
int change_depth
Definition: cwebboot.c:324
#define equiv
Definition: ctangleboot.c:107
name_pointer name_dir_end
Definition: cwebboot.c:350
#define dot_dot_dot
Definition: ctangleboot.c:44
FILE * change_file
Definition: cwebboot.c:317
#define minus_gt_ast
Definition: ctangleboot.c:47
static name_pointer * end_output_files
Definition: ctangleboot.c:337
#define gt_gt
Definition: ctangleboot.c:35
const char * use_language
Definition: cwebboot.c:402
#define xisspace(c)
Definition: ctangleboot.c:51
static name_pointer * cur_out_file
Definition: ctangleboot.c:337
boolean changing
Definition: cwebboot.c:326
#define section_number
Definition: ctangleboot.c:121
#define cur_line
Definition: ctangleboot.c:61
char change_file_name[]
Definition: cwebboot.c:320
char buffer[]
Definition: afm2pl.c:182
#define new_section
Definition: ctangleboot.c:142
char tex_file_name[]
Definition: cwebboot.c:376
void sprint_section_name(char *, name_pointer)
Definition: cwebboot.c:1035
static text_pointer text_info_end
Definition: ctangleboot.c:302
#define show_progress
Definition: ctangleboot.c:82
static void store_two_bytes(sixteen_bits)
Definition: ctangleboot.c:577
name_pointer hash[]
Definition: cwebboot.c:361
char * loc
Definition: cwebboot.c:309
void err_print(const char *)
Definition: cwebboot.c:1289
char scn_file_name[]
Definition: cwebboot.c:379
static stack_pointer stack_end
Definition: ctangleboot.c:319
char * id_first
Definition: cwebboot.c:301
#define minus_gt
Definition: ctangleboot.c:38
#define length(c)
Definition: ctangleboot.c:65
static void out_char(eight_bits)
Definition: ctangleboot.c:1032
#define ishigh(c)
Definition: ctangleboot.c:148
name_info name_dir[]
Definition: cwebboot.c:349
#define lt_eq
Definition: ctangleboot.c:40
void cb_show_banner(void)
Definition: cwebboot.c:1652
static eight_bits * tok_ptr
Definition: ctangleboot.c:306
char * byte_ptr
Definition: cwebboot.c:355
static name_pointer * an_output_file
Definition: ctangleboot.c:337
static eight_bits out_state
Definition: ctangleboot.c:330
#define cur_name
Definition: ctangleboot.c:117
void init_p(name_pointer, eight_bits)
Definition: ctangleboot.c:571
static void phase_one(void)
Definition: ctangleboot.c:1850
#define ignore
Definition: ctangleboot.c:133
static int cur_val
Definition: ctangleboot.c:325
int history
Definition: cwebboot.c:368
uint8_t eight_bits
Definition: ctangleboot.c:165
static text_pointer last_unnamed
Definition: ctangleboot.c:311
#define _(S)
Definition: ctangleboot.c:31
char C_file_name[]
Definition: cwebboot.c:375
#define begin_C
Definition: ctangleboot.c:140
static boolean protect
Definition: ctangleboot.c:331
#define num_or_id
Definition: ctangleboot.c:125
char * id_loc
Definition: cwebboot.c:302
name_info * name_pointer
Definition: ctangleboot.c:227
#define cur_section
Definition: ctangleboot.c:119
static eight_bits * tok_mem_end
Definition: ctangleboot.c:305
static name_pointer output_files[256]
Definition: ctangleboot.c:336
#define constant
Definition: ctangleboot.c:144
static stack_pointer stack_ptr
Definition: ctangleboot.c:320
#define translit_length
Definition: ctangleboot.c:131
#define compress(c)
Definition: ctangleboot.c:151
#define definition
Definition: ctangleboot.c:139
#define show_happiness
Definition: ctangleboot.c:84
#define longest_name
Definition: ctangleboot.c:102
name_pointer id_lookup(const char *, const char *, char)
Definition: cwebboot.c:958
void overflow(const char *)
Definition: cwebboot.c:1385
cweb program
Definition: dv2dt.c:152
static eight_bits get_next(void)
Definition: ctangleboot.c:1189
#define translit_code
Definition: ctangleboot.c:136
static char translit[128][10]
Definition: ctangleboot.c:349
output_state * stack_pointer
Definition: ctangleboot.c:293
#define minus_minus
Definition: ctangleboot.c:37
static output_state cur_state
Definition: ctangleboot.c:316
name_pointer section_lookup(char *, char *, int)
Definition: cwebboot.c:1150
#define show_banner
Definition: ctangleboot.c:81
void print_prefix_name(name_pointer)
Definition: cwebboot.c:1058
boolean web_file_open
Definition: cwebboot.c:327
#define gt_eq
Definition: ctangleboot.c:41
#define period_ast
Definition: ctangleboot.c:46
static void phase_two(void)
Definition: ctangleboot.c:690
static text text_info[10239]
Definition: ctangleboot.c:301
void check_complete(void)
Definition: cwebboot.c:942
static boolean comment_continues
Definition: ctangleboot.c:359
#define identifier
Definition: ctangleboot.c:122
int phase
Definition: cwebboot.c:294
#define xisdigit(c)
Definition: ctangleboot.c:50
text * text_pointer
Definition: ctangleboot.c:281
Bool__ boolean
Definition: ctangleboot.c:164
int argc
Definition: t4ht.c:1664
#define eq_eq
Definition: ctangleboot.c:42
FILE * C_file
Definition: cwebboot.c:387
#define xisxdigit(c)
Definition: ctangleboot.c:54
#define plus_plus
Definition: ctangleboot.c:36
#define and_and
Definition: ctangleboot.c:33
#define confusion(s)
Definition: ctangleboot.c:78
#define verbatim
Definition: ctangleboot.c:128
#define C_printf(c, a)
Definition: ctangleboot.c:92
char check_file_name[]
Definition: cwebboot.c:380
boolean changed_section[]
Definition: cwebboot.c:339
char * byte_mem_end
Definition: cwebboot.c:348
#define lt_lt
Definition: ctangleboot.c:34
void print_section_name(name_pointer)
Definition: cwebboot.c:1014
void init_node(name_pointer)
Definition: ctangleboot.c:565
static void output_defs(void)
Definition: ctangleboot.c:990
#define ord
Definition: ctangleboot.c:134
void reset_input(void)
Definition: cwebboot.c:761
name_pointer name_ptr
Definition: cwebboot.c:356
int change_line
Definition: cwebboot.c:323
#define max_names
Definition: ctangleboot.c:98
hash_pointer h
Definition: dviconv.c:9
char ** argv
Definition: config.h:9
static text_pointer text_ptr
Definition: ctangleboot.c:303
static void get_output(void)
Definition: ctangleboot.c:626
static void skip_limbo(void)
Definition: ctangleboot.c:1864
#define post_slash
Definition: ctangleboot.c:126
static void scan_section(void)
Definition: ctangleboot.c:1737
char * buffer_end
Definition: cwebboot.c:308
#define colon_colon
Definition: ctangleboot.c:45
#define max_texts
Definition: ctangleboot.c:101
cweb
Definition: ctangleboot.c:167
@ ctwill
Definition: ctangleboot.c:168
@ ctangle
Definition: ctangleboot.c:168
@ cweave
Definition: ctangleboot.c:168
boolean print_where
Definition: cwebboot.c:342
int remove()
int strncmp()
#define sprintf
Definition: snprintf.c:44
#define isdigit(c)
Definition: snprintf.c:177
float x
Definition: cordic.py:15
int k
Definition: otp-parser.c:70
output_state
Definition: pdftypes.h:120
logical rename
Definition: pmxab.c:724
static int32_t first
Definition: ppagelist.c:29
type_C toupper(type_C)
#define isalpha(ch)
Definition: utype.h:82
Definition: utils.c:300
Definition: filedef.h:30
Definition: bdf.c:133
struct name_info * Rlink
Definition: ctangleboot.c:221
union name_info::@205 dummy
char * byte_start
Definition: ctangleboot.c:218
struct name_info * link
Definition: ctangleboot.c:219
void * equiv_or_xref
Definition: ctangleboot.c:225
sixteen_bits section_field
Definition: ctangleboot.c:291
name_pointer name_field
Definition: ctangleboot.c:289
text_pointer repl_field
Definition: ctangleboot.c:290
eight_bits * end_field
Definition: ctangleboot.c:287
eight_bits * byte_field
Definition: ctangleboot.c:288
Definition: spc_misc.c:56
Definition: dvips.h:235
sixteen_bits text_link
Definition: ctangleboot.c:279
eight_bits * tok_start
Definition: ctangleboot.c:278
#define FILE
Definition: t1stdio.h:34
#define feof(f)
Definition: t1stdio.h:109
int j
Definition: t4ht.c:1589
*job_name strlen((char *) job_name) - 4)
found
Definition: tex4ht.c:5000
return() int(((double) *(font_tbl[cur_fnt].wtbl+(int)(*(font_tbl[cur_fnt].char_wi+(int)(ch - font_tbl[cur_fnt].char_f)% 256)))/(double)(1L<< 20)) *(double) font_tbl[cur_fnt].scale)
#define BUFSIZ
Definition: ps.c:61