-
Notifications
You must be signed in to change notification settings - Fork 11
/
ctangle.c
1659 lines (1343 loc) · 32 KB
/
ctangle.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*1:*/
#line 66 "ctangle.w"
/*5:*/
#line 48 "common.h"
#include <ctype.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/*:5*/
#line 67 "ctangle.w"
#define banner "This is CTANGLE (Version 4.12)" \
#define ctangle false
#define cweave true \
#define and_and 04
#define lt_lt 020
#define gt_gt 021
#define plus_plus 013
#define minus_minus 01
#define minus_gt 031
#define non_eq 032
#define lt_eq 034
#define gt_eq 035
#define eq_eq 036
#define or_or 037
#define dot_dot_dot 016
#define colon_colon 06
#define period_ast 026
#define minus_gt_ast 027 \
#define compress(c) if(loc++<=limit) return c \
#define xisalpha(c) (isalpha((int) (c) ) &&((eight_bits) (c) <0200) )
#define xisdigit(c) (isdigit((int) (c) ) &&((eight_bits) (c) <0200) )
#define xisspace(c) (isspace((int) (c) ) &&((eight_bits) (c) <0200) )
#define xislower(c) (islower((int) (c) ) &&((eight_bits) (c) <0200) )
#define xisupper(c) (isupper((int) (c) ) &&((eight_bits) (c) <0200) )
#define xisxdigit(c) (isxdigit((int) (c) ) &&((eight_bits) (c) <0200) )
#define isxalpha(c) ((c) =='_'||(c) =='$') \
#define ishigh(c) ((eight_bits) (c) > 0177) \
\
#define max_include_depth 10 \
#define max_file_name_length 60
#define cur_file file[include_depth]
#define cur_file_name file_name[include_depth]
#define cur_line line[include_depth]
#define web_file file[0]
#define web_file_name file_name[0] \
#define length(c) (size_t) ((c+1) ->byte_start-(c) ->byte_start)
#define print_id(c) term_write((c) ->byte_start,length(c) )
#define llink link
#define rlink dummy.Rlink
#define root name_dir->rlink \
#define ilk dummy.Ilk \
#define spotless 0
#define harmless_message 1
#define error_message 2
#define fatal_message 3
#define mark_harmless() if(history==spotless) history= harmless_message
#define mark_error() history= error_message
#define confusion(s) fatal("! This can't happen: ",s) \
\
#define show_banner flags['b']
#define show_progress flags['p']
#define show_happiness flags['h']
#define show_stats flags['s']
#define make_xrefs flags['x'] \
#define update_terminal() fflush(stdout)
#define new_line() putchar('\n')
#define term_write(a,b) fflush(stdout) ,fwrite(a,sizeof(char) ,b,stdout) \
#define buf_size 200
#define longest_name 10000 \
#define long_buf_size (buf_size+longest_name)
#define max_bytes 100000 \
#define max_names 5000 \
#define max_sections 2000 \
#define max_texts 4000
#define max_toks 270000
#define equiv equiv_or_xref \
#define macro 0
#define section_flag max_texts \
#define string 02
#define constant 03
#define join 0177
#define output_defs_flag (2*024000-1) \
#define stack_size 50
#define cur_state stack[stack_size+1] \
#define cur_byte cur_state.byte_field
#define cur_name cur_state.name_field
#define cur_repl cur_state.repl_field
#define cur_section cur_state.section_field
#define cur_end (cur_repl+1) ->tok_start \
#define section_number 0201
#define identifier 0202 \
#define normal 0
#define num_or_id 1
#define post_slash 2
#define unbreakable 3
#define verbatim 4 \
#define max_files 256
#define macro_end (cur_text+1) ->tok_start \
#define C_printf(c,a) fprintf(C_file,c,a)
#define C_putc(c) fputc((int) (c) ,C_file) \
#define translit_length 10 \
#define ignore 00
#define ord 0302
#define control_text 0303
#define translit_code 0304
#define output_defs_code 0305
#define format_code 0306
#define definition 0307
#define begin_C 0310
#define section_name 0311
#define new_section 0312 \
#define app_repl(c) { \
if(tok_ptr==tok_mem_end) overflow("token") ; \
else*(tok_ptr++) = (eight_bits) c; \
} \
#define store_id(a) a= id_lookup(id_first,id_loc,'\0') -name_dir; \
app_repl((a/0400) +0200) ; \
app_repl(a%0400) \
#define keep_digit_separators flags['k'] \
#line 68 "ctangle.w"
/*3:*/
#line 35 "common.h"
typedef bool boolean;
typedef uint8_t eight_bits;
typedef uint16_t sixteen_bits;
extern boolean program;
extern int phase;
/*:3*//*6:*/
#line 78 "common.h"
extern char section_text[];
extern char*section_text_end;
extern char*id_first;
extern char*id_loc;
/*:6*//*7:*/
#line 96 "common.h"
extern char buffer[];
extern char*buffer_end;
extern char*loc;
extern char*limit;
/*:7*//*8:*/
#line 113 "common.h"
extern int include_depth;
extern FILE*file[];
extern FILE*change_file;
extern char file_name[][max_file_name_length];
extern char change_file_name[];
extern int line[];
extern int change_line;
extern int change_depth;
extern boolean input_has_ended;
extern boolean changing;
extern boolean web_file_open;
/*:8*//*10:*/
#line 133 "common.h"
extern sixteen_bits section_count;
extern boolean changed_section[];
extern boolean change_pending;
extern boolean print_where;
/*:10*//*11:*/
#line 148 "common.h"
typedef struct name_info{
char*byte_start;
struct name_info*link;
union{
struct name_info*Rlink;
eight_bits Ilk;
}dummy;
void*equiv_or_xref;
}name_info;
typedef name_info*name_pointer;
typedef name_pointer*hash_pointer;
extern char byte_mem[];
extern char*byte_mem_end;
extern char*byte_ptr;
extern name_info name_dir[];
extern name_pointer name_dir_end;
extern name_pointer name_ptr;
extern name_pointer hash[];
extern hash_pointer hash_end;
extern hash_pointer hash_ptr;
/*:11*//*13:*/
#line 193 "common.h"
extern int history;
/*:13*//*15:*/
#line 211 "common.h"
extern int argc;
extern char**argv;
extern char C_file_name[];
extern char tex_file_name[];
extern char idx_file_name[];
extern char scn_file_name[];
extern boolean flags[];
/*:15*//*16:*/
#line 225 "common.h"
extern FILE*C_file;
extern FILE*tex_file;
extern FILE*idx_file;
extern FILE*scn_file;
extern FILE*active_file;
/*:16*/
#line 69 "ctangle.w"
/*19:*/
#line 122 "ctangle.w"
typedef struct{
eight_bits*tok_start;
sixteen_bits text_link;
}text;
typedef text*text_pointer;
/*:19*//*31:*/
#line 267 "ctangle.w"
typedef struct{
eight_bits*byte_field;
name_pointer name_field;
text_pointer repl_field;
sixteen_bits section_field;
}output_state;
typedef output_state*stack_pointer;
/*:31*/
#line 70 "ctangle.w"
/*20:*/
#line 131 "ctangle.w"
static text text_info[max_texts];
static text_pointer text_info_end= text_info+max_texts-1;
static text_pointer text_ptr;
static eight_bits tok_mem[max_toks];
static eight_bits*tok_mem_end= tok_mem+max_toks-1;
static eight_bits*tok_ptr;
/*:20*//*26:*/
#line 196 "ctangle.w"
static text_pointer last_unnamed;
/*:26*//*32:*/
#line 285 "ctangle.w"
static output_state stack[stack_size+2];
static stack_pointer stack_end= stack+stack_size;
static stack_pointer stack_ptr;
/*:32*//*38:*/
#line 367 "ctangle.w"
static int cur_val;
/*:38*//*42:*/
#line 457 "ctangle.w"
static eight_bits out_state;
static boolean protect;
/*:42*//*45:*/
#line 488 "ctangle.w"
static name_pointer output_files[max_files];
static name_pointer*cur_out_file,*end_output_files,*an_output_file;
static char cur_section_name_char;
static char output_file_name[longest_name+1];
/*:45*//*53:*/
#line 584 "ctangle.w"
static boolean output_defs_seen= false;
/*:53*//*57:*/
#line 694 "ctangle.w"
static char translit[0200][translit_length];
/*:57*//*62:*/
#line 770 "ctangle.w"
static eight_bits ccode[256]= {ignore};
/*:62*//*66:*/
#line 827 "ctangle.w"
static boolean comment_continues= false;
/*:66*//*68:*/
#line 864 "ctangle.w"
static name_pointer cur_section_name;
static boolean no_where;
/*:68*//*82:*/
#line 1182 "ctangle.w"
static text_pointer cur_text;
static eight_bits next_control;
/*:82*/
#line 71 "ctangle.w"
/*4:*/
#line 43 "common.h"
extern void common_init(void);
/*:4*//*9:*/
#line 127 "common.h"
extern boolean get_line(void);
extern void check_complete(void);
extern void reset_input(void);
/*:9*//*12:*/
#line 171 "common.h"
extern name_pointer id_lookup(const char*,const char*,eight_bits);
extern name_pointer section_lookup(char*,char*,boolean);
extern void print_prefix_name(name_pointer);
extern void print_section_name(name_pointer);
extern void sprint_section_name(char*,name_pointer);
extern boolean names_match(name_pointer,const char*,size_t,eight_bits);
extern void init_node(name_pointer);
/*:12*//*14:*/
#line 196 "common.h"
extern int wrap_up(void);
extern void err_print(const char*);
extern void fatal(const char*,const char*);
extern void overflow(const char*);
extern void print_stats(void);
/*:14*//*30:*/
#line 242 "ctangle.w"
static void store_two_bytes(sixteen_bits);
/*:30*//*37:*/
#line 347 "ctangle.w"
static void push_level(name_pointer);
static void pop_level(boolean);
static void get_output(void);
/*:37*//*44:*/
#line 478 "ctangle.w"
static void flush_buffer(void);
/*:44*//*49:*/
#line 547 "ctangle.w"
static void phase_two(void);
static void output_defs(void);
static void out_char(eight_bits);
/*:49*//*65:*/
#line 807 "ctangle.w"
static eight_bits skip_ahead(void);
static boolean skip_comment(boolean);
/*:65*//*70:*/
#line 915 "ctangle.w"
static eight_bits get_next(void);
/*:70*//*84:*/
#line 1208 "ctangle.w"
static void scan_repl(eight_bits);
/*:84*//*91:*/
#line 1399 "ctangle.w"
static void scan_section(void);
/*:91*//*99:*/
#line 1476 "ctangle.w"
static void phase_one(void);
/*:99*//*101:*/
#line 1509 "ctangle.w"
static void skip_limbo(void);
/*:101*/
#line 72 "ctangle.w"
/*:1*//*2:*/
#line 81 "ctangle.w"
int main(
int ac,
char**av)
{
argc= ac;argv= av;
program= ctangle;
/*21:*/
#line 139 "ctangle.w"
text_info->tok_start= tok_ptr= tok_mem;
text_ptr= text_info+1;text_ptr->tok_start= tok_mem;
/*:21*//*23:*/
#line 149 "ctangle.w"
init_node(name_dir);
/*:23*//*27:*/
#line 199 "ctangle.w"
last_unnamed= text_info;text_info->text_link= macro;
/*:27*//*46:*/
#line 498 "ctangle.w"
cur_out_file= end_output_files= output_files+max_files;
/*:46*//*58:*/
#line 697 "ctangle.w"
{int i;
for(i= 0;i<0200;i++)
snprintf(translit[i],translit_length,"X%02X",(unsigned int)(0200+i));
}
/*:58*//*63:*/
#line 773 "ctangle.w"
ccode[' ']= ccode['\t']= ccode['\n']= ccode['\v']= ccode['\r']= ccode['\f']
= ccode['*']= new_section;
ccode['@']= (eight_bits)'@';ccode['=']= string;
ccode['d']= ccode['D']= definition;
ccode['f']= ccode['F']= ccode['s']= ccode['S']= format_code;
ccode['c']= ccode['C']= ccode['p']= ccode['P']= begin_C;
ccode['^']= ccode[':']= ccode['.']= ccode['t']= ccode['T']=
ccode['q']= ccode['Q']= control_text;
ccode['h']= ccode['H']= output_defs_code;
ccode['l']= ccode['L']= translit_code;
ccode['&']= join;
ccode['<']= ccode['(']= section_name;
ccode['\'']= ord;
/*:63*//*78:*/
#line 1103 "ctangle.w"
section_text[0]= ' ';
/*:78*/
#line 88 "ctangle.w"
common_init();
if(show_banner)puts(banner);
phase_one();
phase_two();
return wrap_up();
}
/*:2*//*24:*/
#line 155 "ctangle.w"
boolean names_match(
name_pointer p,
const char*first,
size_t l,
eight_bits t)
{(void)t;
return length(p)==l&&strncmp(first,p->byte_start,l)==0;
}
/*:24*//*25:*/
#line 168 "ctangle.w"
void
init_node(
name_pointer node)
{
node->equiv= (void*)text_info;
}
/*:25*//*29:*/
#line 232 "ctangle.w"
static void
store_two_bytes(
sixteen_bits x)
{
if(tok_ptr+2> tok_mem_end)overflow("token");
*tok_ptr++= x>>8;
*tok_ptr++= x&0377;
}
/*:29*//*35:*/
#line 315 "ctangle.w"
static void
push_level(
name_pointer p)
{
if(stack_ptr==stack_end)overflow("stack");
*stack_ptr= cur_state;
stack_ptr++;
if(p!=NULL){
cur_name= p;cur_repl= (text_pointer)p->equiv;
cur_byte= cur_repl->tok_start;cur_section= 0;
}
}
/*:35*//*36:*/
#line 334 "ctangle.w"
static void
pop_level(
boolean flag)
{
if(flag&&cur_repl->text_link<section_flag){
cur_repl= cur_repl->text_link+text_info;
cur_byte= cur_repl->tok_start;return;
}
stack_ptr--;
if(stack_ptr> stack)cur_state= *stack_ptr;
}
/*:36*//*39:*/
#line 374 "ctangle.w"
static void
get_output(void)
{
sixteen_bits a;
restart:if(stack_ptr==stack)return;
if(cur_byte==cur_end){
cur_val= -((int)cur_section);
pop_level(true);
if(cur_val==0)goto restart;
out_char(section_number);return;
}
a= *cur_byte++;
if(out_state==verbatim&&a!=string&&a!=constant&&a!='\n')
C_putc(a);
else if(a<0200)out_char(a);
else{
a= (a-0200)*0400+*cur_byte++;
switch(a/024000){
case 0:cur_val= (int)a;out_char(identifier);break;
case 1:if(a==output_defs_flag)output_defs();
else/*40:*/
#line 407 "ctangle.w"
{
a-= 024000;
if((a+name_dir)->equiv!=(void*)text_info)push_level(a+name_dir);
else if(a!=0){
printf("%s","\n! Not present: <");
print_section_name(a+name_dir);err_print(">");
}
goto restart;
}
/*:40*/
#line 395 "ctangle.w"
break;
default:cur_val= (int)a-050000;
if(cur_val> 0)cur_section= (sixteen_bits)cur_val;
out_char(section_number);
}
}
}
/*:39*//*43:*/
#line 465 "ctangle.w"
static void
flush_buffer(void)
{
C_putc('\n');
if(cur_line%100==0&&show_progress){
putchar('.');
if(cur_line%500==0)printf("%d",cur_line);
update_terminal();
}
cur_line++;
}
/*:43*//*48:*/
#line 517 "ctangle.w"
static void
phase_two(void){
phase= 2;
web_file_open= false;
cur_line= 1;
/*33:*/
#line 296 "ctangle.w"
stack_ptr= stack+1;cur_name= name_dir;
cur_repl= text_info->text_link+text_info;
cur_byte= cur_repl->tok_start;cur_section= 0;
/*:33*/
#line 523 "ctangle.w"
/*52:*/
#line 580 "ctangle.w"
if(!output_defs_seen)
output_defs();
/*:52*/
#line 524 "ctangle.w"
if(text_info->text_link==macro&&cur_out_file==end_output_files){
printf("%s","\n! No program text was specified.");mark_harmless();
}
else{
if(show_progress){
printf(cur_out_file==end_output_files?
"\nWriting the output file (%s):":
"\nWriting the output files: (%s)",C_file_name);
update_terminal();
}
if(text_info->text_link!=macro)
/*51:*/
#line 570 "ctangle.w"
{
while(stack_ptr> stack)get_output();
flush_buffer();
}
/*:51*/
#line 538 "ctangle.w"
/*50:*/
#line 556 "ctangle.w"
for(an_output_file= end_output_files;an_output_file> cur_out_file;){
an_output_file--;
sprint_section_name(output_file_name,*an_output_file);
fclose(C_file);
if((C_file= fopen(output_file_name,"wb"))==NULL)
fatal("! Cannot open output file ",output_file_name);
if(show_progress){printf("\n(%s)",output_file_name);update_terminal();}
cur_line= 1;
/*34:*/
#line 303 "ctangle.w"
stack_ptr= stack+1;cur_name= *an_output_file;
cur_repl= (text_pointer)cur_name->equiv;
cur_byte= cur_repl->tok_start;
/*:34*/
#line 566 "ctangle.w"
/*51:*/
#line 570 "ctangle.w"
{
while(stack_ptr> stack)get_output();
flush_buffer();
}
/*:51*/
#line 567 "ctangle.w"
}
/*:50*/
#line 539 "ctangle.w"
if(show_happiness){
if(show_progress)new_line();
printf("%s","Done.");
}
}
}
/*:48*//*54:*/
#line 592 "ctangle.w"
static void
output_defs(void)
{
sixteen_bits a;
push_level(NULL);
for(cur_text= text_info+1;cur_text<text_ptr;cur_text++)
if(cur_text->text_link==macro){
cur_byte= cur_text->tok_start;
C_printf("%s","#define ");
out_state= normal;
protect= true;
while(cur_byte<macro_end){
a= *cur_byte++;
if(cur_byte==macro_end&&a=='\n')break;
if(out_state==verbatim&&a!=string&&a!=constant&&a!='\n')
C_putc(a);
else if(a<0200)out_char(a);
else{
a= (a-0200)*0400+*cur_byte++;
if(a<024000){
cur_val= (int)a;out_char(identifier);
}
else if(a<050000)confusion("macro defs have strange char");
else{
cur_val= (int)a-050000;cur_section= (sixteen_bits)cur_val;
out_char(section_number);
}
}
}
protect= false;
flush_buffer();
}
pop_level(false);
}
/*:54*//*55:*/
#line 635 "ctangle.w"
static void
out_char(
eight_bits cur_char)
{
char*j;
restart:
switch(cur_char){
case'\n':if(protect&&out_state!=verbatim)C_putc(' ');
if(protect||out_state==verbatim)C_putc('\\');
flush_buffer();if(out_state!=verbatim)out_state= normal;break;
/*59:*/
#line 703 "ctangle.w"
case identifier:
if(out_state==num_or_id)C_putc(' ');
for(j= (cur_val+name_dir)->byte_start;
j<(cur_val+name_dir+1)->byte_start;j++)
if((eight_bits)(*j)<0200)C_putc(*j);
else C_printf("%s",translit[(eight_bits)(*j)-0200]);
out_state= num_or_id;break;
/*:59*/
#line 646 "ctangle.w"
/*60:*/
#line 713 "ctangle.w"
case section_number:
if(cur_val> 0)C_printf("/*%d:*/",cur_val);
else if(cur_val<0)C_printf("/*:%d*/",-cur_val);
else if(protect){
cur_byte+= 4;
cur_char= (eight_bits)'\n';
goto restart;
}else{
sixteen_bits a;
a= *cur_byte++*0400;
a+= *cur_byte++;
C_printf("\n#line %d \"",(int)a);
cur_val= (int)(*cur_byte++-0200)*0400;
cur_val+= *cur_byte++;
for(j= (cur_val+name_dir)->byte_start;
j<(cur_val+name_dir+1)->byte_start;j++){
if(*j=='\\'||*j=='"')C_putc('\\');
C_putc(*j);
}
C_putc('"');C_putc('\n');
}
break;
/*:60*/
#line 647 "ctangle.w"
/*56:*/
#line 665 "ctangle.w"
case plus_plus:C_putc('+');C_putc('+');out_state= normal;break;
case minus_minus:C_putc('-');C_putc('-');out_state= normal;break;
case minus_gt:C_putc('-');C_putc('>');out_state= normal;break;
case gt_gt:C_putc('>');C_putc('>');out_state= normal;break;
case eq_eq:C_putc('=');C_putc('=');out_state= normal;break;
case lt_lt:C_putc('<');C_putc('<');out_state= normal;break;
case gt_eq:C_putc('>');C_putc('=');out_state= normal;break;
case lt_eq:C_putc('<');C_putc('=');out_state= normal;break;
case non_eq:C_putc('!');C_putc('=');out_state= normal;break;
case and_and:C_putc('&');C_putc('&');out_state= normal;break;
case or_or:C_putc('|');C_putc('|');out_state= normal;break;
case dot_dot_dot:C_putc('.');C_putc('.');C_putc('.');out_state= normal;
break;
case colon_colon:C_putc(':');C_putc(':');out_state= normal;break;
case period_ast:C_putc('.');C_putc('*');out_state= normal;break;
case minus_gt_ast:C_putc('-');C_putc('>');C_putc('*');out_state= normal;
break;
/*:56*/
#line 648 "ctangle.w"
case'=':case'>':C_putc(cur_char);C_putc(' ');
out_state= normal;break;
case join:out_state= unbreakable;break;
case constant:if(out_state==verbatim){
out_state= num_or_id;break;
}
if(out_state==num_or_id)C_putc(' ');out_state= verbatim;break;
case string:if(out_state==verbatim)out_state= normal;
else out_state= verbatim;break;
case'/':C_putc('/');out_state= post_slash;break;
case'*':if(out_state==post_slash)C_putc(' ');
/* fall through */
default:C_putc(cur_char);out_state= normal;break;
}
}
/*:55*//*64:*/
#line 791 "ctangle.w"
static eight_bits
skip_ahead(void)
{
eight_bits c;
while(true){
if(loc> limit&&(get_line()==false))return new_section;
*(limit+1)= '@';
while(*loc!='@')loc++;
if(loc<=limit){
loc++;c= ccode[(eight_bits)*loc];loc++;
if(c!=ignore||*(loc-1)=='>')return c;
}
}
}
/*:64*//*67:*/
#line 830 "ctangle.w"
static boolean skip_comment(
boolean is_long_comment)
{
char c;
while(true){
if(loc> limit){
if(is_long_comment){
if(get_line())return comment_continues= true;
else{
err_print("! Input ended in mid-comment");
return comment_continues= false;
}
}
else return comment_continues= false;
}
c= *(loc++);
if(is_long_comment&&c=='*'&&*loc=='/'){
loc++;return comment_continues= false;
}
if(c=='@'){
if(ccode[(eight_bits)*loc]==new_section){
err_print("! Section name ended in mid-comment");loc--;
return comment_continues= false;
}
else loc++;
}
}
}
/*:67*//*69:*/
#line 871 "ctangle.w"
static eight_bits
get_next(void)
{
static boolean preprocessing= false;
eight_bits c;
while(true){
if(loc> limit){
if(preprocessing&&*(limit-1)!='\\')preprocessing= false;
if(get_line()==false)return new_section;
else if(print_where&&!no_where){
sixteen_bits a;
print_where= false;
/*85:*/
#line 1218 "ctangle.w"
{
store_two_bytes(0150000);
if(changing&&include_depth==change_depth){
id_first= change_file_name;
store_two_bytes((sixteen_bits)change_line);
}else{
id_first= cur_file_name;
store_two_bytes((sixteen_bits)cur_line);
}
id_loc= id_first+strlen(id_first);
store_id(a);
}
/*:85*/
#line 884 "ctangle.w"
}
else return(eight_bits)'\n';
}
c= (eight_bits)*loc;
if(comment_continues||(c=='/'&&(*(loc+1)=='*'||*(loc+1)=='/'))){
if(skip_comment(comment_continues||*(loc+1)=='*'))return'\n';
else continue;
}
loc++;
if(xisdigit(c)||c=='.')/*73:*/
#line 956 "ctangle.w"
{
boolean hex_flag= false;
id_first= loc-1;
if(*id_first=='.'&&!xisdigit(*loc))goto mistake;
if(*id_first=='0'){
if(*loc=='x'||*loc=='X'){
hex_flag= true;
loc++;while(xisxdigit(*loc)||*loc=='\'')loc++;
}
else if(*loc=='b'||*loc=='B'){
loc++;while(*loc=='0'||*loc=='1'||*loc=='\'')loc++;goto found;
}
}
while(xisdigit(*loc)||*loc=='\'')loc++;
if(*loc=='.'){
loc++;
while((hex_flag&&xisxdigit(*loc))||xisdigit(*loc)||*loc=='\'')loc++;
}
if(*loc=='e'||*loc=='E'){
if(*++loc=='+'||*loc=='-')loc++;
while(xisdigit(*loc)||*loc=='\'')loc++;