summaryrefslogtreecommitdiff
path: root/web/matlabweb/common.c
blob: 1ed02bb3b06fe488671c45ae843565d5dcd03419 (plain)
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
/*1:*/
#line 75 "/home/mark/litprog/spider/src/master/common.web"

#include<stdio.h>
#ifdef MSDOS
#define index strchr
#endif

/*3:*/
#line 97 "/home/mark/litprog/spider/src/master/common.web"

extern char the_at_sign;


/*:3*//*65:*/
#line 1089 "/home/mark/litprog/spider/src/master/common.web"
extern char C_file_extension[];
#line 1090 "/home/mark/litprog/spider/src/master/common.web"

/*:65*/
#line 81 "/home/mark/litprog/spider/src/master/common.web"

/*9:*/
#line 229 "/home/mark/litprog/spider/src/master/common.web"
char setting_up;
#line 230 "/home/mark/litprog/spider/src/master/common.web"

/*:9*/
#line 82 "/home/mark/litprog/spider/src/master/common.web"

/*4:*/
#line 104 "/home/mark/litprog/spider/src/master/common.web"

#line 105 "/home/mark/litprog/spider/src/master/common.web"
typedef short boolean;
typedef char unsigned eight_bits;
boolean program;

/*:4*//*6:*/
#line 191 "/home/mark/litprog/spider/src/master/common.web"

typedef char ASCII;
typedef char outer_char;

/*:6*//*7:*/
#line 199 "/home/mark/litprog/spider/src/master/common.web"

#line 200 "/home/mark/litprog/spider/src/master/common.web"
ASCII xord[127+1];
outer_char xchr[128];

/*:7*//*12:*/
#line 291 "/home/mark/litprog/spider/src/master/common.web"

ASCII buffer[500];
ASCII *buffer_end= buffer+200-2;
ASCII *limit;
ASCII *loc;

/*:12*//*14:*/
#line 344 "/home/mark/litprog/spider/src/master/common.web"

int include_depth;
FILE *file[10];
FILE *change_file;
char file_name[10][60];

char change_file_name[60];
int line[10];
int change_line;
boolean input_has_ended;
boolean changing;

/*:14*//*26:*/
#line 534 "/home/mark/litprog/spider/src/master/common.web"

typedef unsigned short sixteen_bits;
sixteen_bits module_count;
boolean changed_module[2000];
boolean print_where= 0;

/*:26*//*37:*/
#line 672 "/home/mark/litprog/spider/src/master/common.web"

typedef struct name_info{
ASCII *byte_start;
 /*41:*/
#line 711 "/home/mark/litprog/spider/src/master/common.web"

#line 712 "/home/mark/litprog/spider/src/master/common.web"
struct name_info *link;

/*:41*//*48:*/
#line 804 "/home/mark/litprog/spider/src/master/common.web"

union{
struct name_info *Rlink;

eight_bits Ilk;
}dummy;

/*:48*//*55:*/
#line 943 "/home/mark/litprog/spider/src/master/common.web"

ASCII *equiv_or_xref;

/*:55*/
#line 675 "/home/mark/litprog/spider/src/master/common.web"

}name_info;
typedef name_info *name_pointer;
ASCII byte_mem[90000];
ASCII *byte_mem_end= byte_mem+90000-1;
name_info name_dir[4000];
name_pointer name_dir_end= name_dir+4000-1;

/*:37*//*39:*/
#line 697 "/home/mark/litprog/spider/src/master/common.web"

name_pointer name_ptr;
ASCII *byte_ptr;

/*:39*//*42:*/
#line 727 "/home/mark/litprog/spider/src/master/common.web"

typedef name_pointer *hash_pointer;
name_pointer hash[353];
hash_pointer hash_end= hash+353-1;
hash_pointer h;

/*:42*//*56:*/
#line 963 "/home/mark/litprog/spider/src/master/common.web"

int history= 0;

/*:56*//*64:*/
#line 1076 "/home/mark/litprog/spider/src/master/common.web"

#line 1077 "/home/mark/litprog/spider/src/master/common.web"
int argc;
char * *argv;
char C_file_name[60];
char tex_file_name[60];
int no_xref;

/*:64*//*75:*/
#line 1202 "/home/mark/litprog/spider/src/master/common.web"

#line 1203 "/home/mark/litprog/spider/src/master/common.web"
FILE *C_file;
FILE *tex_file;

/*:75*/
#line 83 "/home/mark/litprog/spider/src/master/common.web"

/*5:*/
#line 115 "/home/mark/litprog/spider/src/master/common.web"
int phase;
#line 116 "/home/mark/litprog/spider/src/master/common.web"

/*:5*//*15:*/
#line 366 "/home/mark/litprog/spider/src/master/common.web"

ASCII change_buffer[200];
ASCII *change_limit;

/*:15*//*30:*/
#line 569 "/home/mark/litprog/spider/src/master/common.web"

#line 1 "pathopen.h"

#line 187"/u/norman/pu/web/dist/src/master/pathopen.web"

#line 188"/u/norman/pu/web/dist/src/master/pathopen.web"
void pathaddname();
void pathaddpath();
void pathreset();
FILE *pathopen();

#line 571 "/home/mark/litprog/spider/src/master/common.web"
/*:30*//*50:*/
#line 829 "/home/mark/litprog/spider/src/master/common.web"

name_pointer install_node();

/*:50*/
#line 84 "/home/mark/litprog/spider/src/master/common.web"

/*8:*/
#line 215 "/home/mark/litprog/spider/src/master/common.web"

#line 216 "/home/mark/litprog/spider/src/master/common.web"
common_init()
{
strncpy(xchr,"                                 !\"#$%&'()*+,-./0123456789\
:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ ",128);
/*11:*/
#line 270 "/home/mark/litprog/spider/src/master/common.web"


/*:11*/
#line 220 "/home/mark/litprog/spider/src/master/common.web"
;
/*10:*/
#line 234 "/home/mark/litprog/spider/src/master/common.web"
{
#line 235 "/home/mark/litprog/spider/src/master/common.web"
int i;
for(i= 0;i<=127;i++)
xord[i]= 32;
for(i= 1;i<127;i++)xord[xchr[i]]= i;
}

/*:10*/
#line 221 "/home/mark/litprog/spider/src/master/common.web"
;
/*40:*/
#line 701 "/home/mark/litprog/spider/src/master/common.web"

#line 702 "/home/mark/litprog/spider/src/master/common.web"
name_dir->byte_start= byte_ptr= byte_mem;
name_ptr= name_dir+1;
name_ptr->byte_start= byte_mem;

/*:40*//*43:*/
#line 735 "/home/mark/litprog/spider/src/master/common.web"

#line 736 "/home/mark/litprog/spider/src/master/common.web"
for(h= hash;h<=hash_end; *h++= NULL);

/*:43*//*49:*/
#line 811 "/home/mark/litprog/spider/src/master/common.web"

#line 812 "/home/mark/litprog/spider/src/master/common.web"
name_dir->dummy.Rlink= NULL;

/*:49*/
#line 222 "/home/mark/litprog/spider/src/master/common.web"
;
setting_up= 1;
/*76:*/
#line 1206 "/home/mark/litprog/spider/src/master/common.web"

#line 1207 "/home/mark/litprog/spider/src/master/common.web"
scan_args();
/*28:*/
#line 565 "/home/mark/litprog/spider/src/master/common.web"

#line 566 "/home/mark/litprog/spider/src/master/common.web"
pathaddpath(getenv("WEBPATH"),':');
/*:28*/
#line 1208 "/home/mark/litprog/spider/src/master/common.web"

if(program==0){
if((C_file= fopen(C_file_name,"w"))==NULL)
{printf("! Cannot open output file ");err_print(C_file_name);history= 3;wrap_up();};
}
else{
if((tex_file= fopen(tex_file_name,"w"))==NULL)
{printf("! Cannot open output file ");err_print(tex_file_name);history= 3;wrap_up();};
}

/*:76*/
#line 224 "/home/mark/litprog/spider/src/master/common.web"
;
setting_up= 0;
}

/*:8*//*13:*/
#line 301 "/home/mark/litprog/spider/src/master/common.web"

#line 302 "/home/mark/litprog/spider/src/master/common.web"
#include<stdio.h>
input_ln(fp)
FILE *fp;
{
register int c;
register ASCII *k;
if(feof(fp))return(0);
limit= k= buffer;
while(k<=buffer_end&&(c= getc(fp))!=EOF&&c!='\n')
if(( *(k++)= xord[c])!=32)limit= k;
if(k>buffer_end)
if((c= getc(fp))!=EOF&&c!='\n'){
ungetc(c,fp);loc= buffer;err_print("\n! Input line too long");

}
if(c==EOF&&limit==buffer)return(0);

return(1);
}

/*:13*//*16:*/
#line 376 "/home/mark/litprog/spider/src/master/common.web"

#line 377 "/home/mark/litprog/spider/src/master/common.web"
prime_the_change_buffer()
{
change_limit= 0;
/*17:*/
#line 390 "/home/mark/litprog/spider/src/master/common.web"

#line 391 "/home/mark/litprog/spider/src/master/common.web"
while(1){
change_line++;
if(!input_ln(change_file))return;
if(limit<buffer+2)continue;
if(buffer[0]!=the_at_sign)continue;
/*18:*/
#line 408 "/home/mark/litprog/spider/src/master/common.web"

#line 409 "/home/mark/litprog/spider/src/master/common.web"
if(buffer[1]>=88&&buffer[1]<=90||buffer[1]==73)buffer[1]+= 122-90;

/*:18*/
#line 396 "/home/mark/litprog/spider/src/master/common.web"
;
/*19:*/
#line 413 "/home/mark/litprog/spider/src/master/common.web"
{
#line 414 "/home/mark/litprog/spider/src/master/common.web"
if(buffer[1]==105){
loc= buffer+2;
err_print("! No includes allowed in change file");

}
}

/*:19*/
#line 397 "/home/mark/litprog/spider/src/master/common.web"
;
if(buffer[1]==120)break;
if(buffer[1]==121||buffer[1]==122){
loc= buffer+2;
err_print("! Where is the matching @x?");

}
}

/*:17*/
#line 380 "/home/mark/litprog/spider/src/master/common.web"
;
/*20:*/
#line 423 "/home/mark/litprog/spider/src/master/common.web"

#line 424 "/home/mark/litprog/spider/src/master/common.web"
do{
change_line++;
if(!input_ln(change_file)){
err_print("! Change file ended after @x");

return;
}
}while(limit==buffer);

/*:20*/
#line 381 "/home/mark/litprog/spider/src/master/common.web"
;
/*21:*/
#line 433 "/home/mark/litprog/spider/src/master/common.web"

#line 434 "/home/mark/litprog/spider/src/master/common.web"
{
change_limit= change_buffer-buffer+limit;
strncpy(change_buffer,buffer,limit-buffer+1);
}

/*:21*/
#line 382 "/home/mark/litprog/spider/src/master/common.web"
;
}

/*:16*//*22:*/
#line 448 "/home/mark/litprog/spider/src/master/common.web"

#line 449 "/home/mark/litprog/spider/src/master/common.web"
check_change()
{
int n= 0;
if((change_limit-change_buffer!=limit-buffer||strncmp(buffer,change_buffer,limit-buffer)))return;
while(1){
changing= 1;print_where= 1;change_line++;
if(!input_ln(change_file)){
err_print("! Change file ended before @y");

change_limit= 0;changing= 0;print_where= 1;
return;
}
if(limit>buffer+1&&buffer[0]==the_at_sign)
/*19:*/
#line 413 "/home/mark/litprog/spider/src/master/common.web"
{
#line 414 "/home/mark/litprog/spider/src/master/common.web"
if(buffer[1]==105){
loc= buffer+2;
err_print("! No includes allowed in change file");

}
}

/*:19*/
#line 462 "/home/mark/litprog/spider/src/master/common.web"
;
/*23:*/
#line 479 "/home/mark/litprog/spider/src/master/common.web"

#line 480 "/home/mark/litprog/spider/src/master/common.web"
if(limit>buffer+1&&buffer[0]==the_at_sign){
/*18:*/
#line 408 "/home/mark/litprog/spider/src/master/common.web"

#line 409 "/home/mark/litprog/spider/src/master/common.web"
if(buffer[1]>=88&&buffer[1]<=90||buffer[1]==73)buffer[1]+= 122-90;

/*:18*/
#line 481 "/home/mark/litprog/spider/src/master/common.web"
;
if(buffer[1]==120||buffer[1]==122){
loc= buffer+2;err_print("! Where is the matching @y?");

}
else if(buffer[1]==121){
if(n>0){
loc= buffer+2;
err_print("! Hmm... some of the preceding lines failed to match");

}
return;
}
}

/*:23*/
#line 464 "/home/mark/litprog/spider/src/master/common.web"
;
/*21:*/
#line 433 "/home/mark/litprog/spider/src/master/common.web"

#line 434 "/home/mark/litprog/spider/src/master/common.web"
{
change_limit= change_buffer-buffer+limit;
strncpy(change_buffer,buffer,limit-buffer+1);
}

/*:21*/
#line 465 "/home/mark/litprog/spider/src/master/common.web"
;
changing= 0;print_where= 1;line[include_depth]++;
while(!input_ln(file[include_depth])){
if(include_depth==0){
err_print("! WEB file ended during a change");

input_has_ended= 1;return;
}
include_depth--;print_where= 1;line[include_depth]++;
}
if((change_limit-change_buffer!=limit-buffer||strncmp(buffer,change_buffer,limit-buffer)))n++;
}
}

/*:22*//*24:*/
#line 499 "/home/mark/litprog/spider/src/master/common.web"

#line 500 "/home/mark/litprog/spider/src/master/common.web"
reset_input()
{
limit= buffer;loc= buffer+1;buffer[0]= 32;
/*25:*/
#line 512 "/home/mark/litprog/spider/src/master/common.web"

#line 513 "/home/mark/litprog/spider/src/master/common.web"
if((file[0]= fopen(file_name[0],"r"))==NULL)
{printf("! Cannot open input file ");err_print(file_name[0]);history= 3;wrap_up();};
if((change_file= fopen(change_file_name,"r"))==NULL)
{printf("! Cannot open change file ");err_print(change_file_name);history= 3;wrap_up();};

/*:25*/
#line 503 "/home/mark/litprog/spider/src/master/common.web"
;
line[include_depth]= 0;change_line= 0;include_depth= 0;
changing= 1;prime_the_change_buffer();changing= !changing;
limit= buffer;loc= buffer+1;buffer[0]= 32;input_has_ended= 0;
}

/*:24*//*27:*/
#line 540 "/home/mark/litprog/spider/src/master/common.web"

#line 541 "/home/mark/litprog/spider/src/master/common.web"
get_line()
{
restart:
if(changing)changed_module[module_count]= 1;
else/*34:*/
#line 607 "/home/mark/litprog/spider/src/master/common.web"
{
#line 608 "/home/mark/litprog/spider/src/master/common.web"
line[include_depth]++;
while(!input_ln(file[include_depth])){
print_where= 1;
if(include_depth==0){input_has_ended= 1;break;}
else{fclose(file[include_depth]);include_depth--;line[include_depth]++;}
}
if(!input_has_ended)
if(limit==change_limit-change_buffer+buffer)
if(buffer[0]==change_buffer[0])
if(change_limit>change_buffer)check_change();
}

/*:34*/
#line 545 "/home/mark/litprog/spider/src/master/common.web"
;
if(changing){
/*35:*/
#line 620 "/home/mark/litprog/spider/src/master/common.web"
{
#line 621 "/home/mark/litprog/spider/src/master/common.web"
change_line++;
if(!input_ln(change_file)){
err_print("! Change file ended without @z");

buffer[0]= the_at_sign;buffer[1]= 122;limit= buffer+2;
}
if(limit>buffer+1)
if(buffer[0]==the_at_sign){
/*18:*/
#line 408 "/home/mark/litprog/spider/src/master/common.web"

#line 409 "/home/mark/litprog/spider/src/master/common.web"
if(buffer[1]>=88&&buffer[1]<=90||buffer[1]==73)buffer[1]+= 122-90;

/*:18*/
#line 629 "/home/mark/litprog/spider/src/master/common.web"
;
/*19:*/
#line 413 "/home/mark/litprog/spider/src/master/common.web"
{
#line 414 "/home/mark/litprog/spider/src/master/common.web"
if(buffer[1]==105){
loc= buffer+2;
err_print("! No includes allowed in change file");

}
}

/*:19*/
#line 630 "/home/mark/litprog/spider/src/master/common.web"
;
if(buffer[1]==120||buffer[1]==121){
loc= buffer+2;err_print("! Where is the matching @z?");

}
else if(buffer[1]==122){
prime_the_change_buffer();changing= !changing;print_where= 1;
}
}
}

/*:35*/
#line 547 "/home/mark/litprog/spider/src/master/common.web"
;
if(!changing){
changed_module[module_count]= 1;goto restart;
}
}
loc= buffer; *limit= 32;
if( *buffer==the_at_sign&&( *(buffer+1)==105|| *(buffer+1)==73))
/*33:*/
#line 579 "/home/mark/litprog/spider/src/master/common.web"
{
#line 580 "/home/mark/litprog/spider/src/master/common.web"
ASCII *k, *j;
loc= buffer+2;
while(loc<=limit&&( *loc==32|| *loc==9|| *loc==34))loc++;
if(loc>=limit)err_print("! Include file name not given");

else{
if(++include_depth<10){
k= file_name[include_depth];j= loc;
while( *loc!=32&& *loc!=9&& *loc!=34) *k++= xchr[ *loc++];
 *k= '\0';
if((file[include_depth]= pathopen(file_name[include_depth],"r"))==NULL){
loc= j;
include_depth--;
err_print("! Cannot find include file on path");

}
else{line[include_depth]= 0;print_where= 1;}
}
else{
include_depth--;
err_print("! Too many nested includes");

}
}
goto restart;
}

/*:33*/
#line 554 "/home/mark/litprog/spider/src/master/common.web"
;
return(!input_has_ended);
}

/*:27*//*32:*/
#line 572 "/home/mark/litprog/spider/src/master/common.web"

#line 573 "/home/mark/litprog/spider/src/master/common.web"
void overflow (s)
char *s;
{{{printf("\n! Sorry, capacity exceeded: ");err_print(s);history= 3;wrap_up();};};}
/*:32*//*36:*/
#line 644 "/home/mark/litprog/spider/src/master/common.web"

#line 645 "/home/mark/litprog/spider/src/master/common.web"
check_complete(){
if(change_limit!=0){
strncpy(buffer,change_buffer,change_limit-change_buffer+1);
limit= change_limit-change_buffer+buffer;
changing= 1;loc= change_limit;
err_print("! Change file entry did not match");

}
}

/*:36*//*57:*/
#line 977 "/home/mark/litprog/spider/src/master/common.web"

#line 978 "/home/mark/litprog/spider/src/master/common.web"
err_print(s)
char *s;
{
ASCII *k, *l;
printf("\n%s",(s==(char *)0)?"Bad error message!!!":s);
if(setting_up){
printf("\nError occurred while scanning arguments or opening output files. ");
}else{
/*58:*/
#line 1000 "/home/mark/litprog/spider/src/master/common.web"

#line 1001 "/home/mark/litprog/spider/src/master/common.web"
if(changing)printf(". (l. %d of change file)\n",change_line);
else if(include_depth==0)printf(". (l. %d)\n",line[include_depth]);
else printf(". (l. %d of include file %s)\n",line[include_depth],file_name[include_depth]);
l= (loc>=limit?limit:loc);
if(l>buffer){
for(k= buffer;k<l;k++)
if( *k=='\t')putchar(' ');
else putchar(xchr[ *k]);
putchar('\n');
for(k= buffer;k<l;k++)putchar(' ');
}
for(k= l;k<limit;k++)putchar(xchr[ *k]);
if( *limit==124)putchar('|');
putchar(' ');

/*:58*/
#line 986 "/home/mark/litprog/spider/src/master/common.web"
;
}
fflush(stdout);history= 2;
}

/*:57*//*62:*/
#line 1046 "/home/mark/litprog/spider/src/master/common.web"

wrap_up(){
putchar('\n');
/*63:*/
#line 1054 "/home/mark/litprog/spider/src/master/common.web"

#line 1055 "/home/mark/litprog/spider/src/master/common.web"
switch(history){
case 0:printf("(No errors were found.)\n");break;
case 1:
printf("(Did you see the warning message above?)\n");break;
case 2:
printf("(Pardon me, but I think I spotted something wrong.)\n");break;
case 3:printf("(That was a fatal error, my friend.)\n");
}

/*:63*/
#line 1049 "/home/mark/litprog/spider/src/master/common.web"
;
if(history>1)exit(1);
else exit(0);
}

/*:62*//*66:*/
#line 1097 "/home/mark/litprog/spider/src/master/common.web"

#line 1098 "/home/mark/litprog/spider/src/master/common.web"
scan_args()
{
char *dot_pos, *index();
boolean found_web= 0,found_change= 0;
no_xref= 0;
while(--argc>0){
if( * *(++argv)!='-'){
if(!found_web)/*67:*/
#line 1121 "/home/mark/litprog/spider/src/master/common.web"

#line 1122 "/home/mark/litprog/spider/src/master/common.web"
{
if(strlen( *argv)>60-5)
/*73:*/
#line 1193 "/home/mark/litprog/spider/src/master/common.web"
{printf("! Filename %s too long\n");err_print( *argv);history= 3;wrap_up();};
#line 1194 "/home/mark/litprog/spider/src/master/common.web"

/*:73*/
#line 1124 "/home/mark/litprog/spider/src/master/common.web"
;
if((dot_pos= index( *argv,'.'))==NULL)
sprintf(file_name[0],"%s.web", *argv);
else{
sprintf(file_name[0],"%s", *argv);
/*68:*/
#line 1137 "/home/mark/litprog/spider/src/master/common.web"

#line 1138 "/home/mark/litprog/spider/src/master/common.web"
{char *p;
p= dot_pos;
while( *++p!='\0')
if( *p=='.')dot_pos= p;
}

/*:68*/
#line 1129 "/home/mark/litprog/spider/src/master/common.web"

 *dot_pos= 0;
}
sprintf(tex_file_name,"%s.tex", *argv);
sprintf(C_file_name,"%s.%s", *argv,C_file_extension);
found_web= 1;
}

/*:67*/
#line 1106 "/home/mark/litprog/spider/src/master/common.web"

else if(!found_change)/*69:*/
#line 1144 "/home/mark/litprog/spider/src/master/common.web"

#line 1145 "/home/mark/litprog/spider/src/master/common.web"
{
if(strlen( *argv)>60-5)
/*73:*/
#line 1193 "/home/mark/litprog/spider/src/master/common.web"
{printf("! Filename %s too long\n");err_print( *argv);history= 3;wrap_up();};
#line 1194 "/home/mark/litprog/spider/src/master/common.web"

/*:73*/
#line 1147 "/home/mark/litprog/spider/src/master/common.web"
;
if((dot_pos= index( *argv,'.'))==NULL)
sprintf(change_file_name,"%s.ch", *argv);
else sprintf(change_file_name,"%s", *argv);
found_change= 1;
}

/*:69*/
#line 1107 "/home/mark/litprog/spider/src/master/common.web"

else/*72:*/
#line 1184 "/home/mark/litprog/spider/src/master/common.web"

#line 1185 "/home/mark/litprog/spider/src/master/common.web"
{
if(program==0)
{printf("! Usage: tangle webfile[.web] [changefile[.ch]] [-Ipathname ...]\n");err_print(0);history= 3;wrap_up();}
else
{printf("! Usage: weave webfile[.web] [changefile[.ch]] [-x] [-Ipathname ...]\n");err_print(
0);history= 3;wrap_up();};
}

/*:72*/
#line 1108 "/home/mark/litprog/spider/src/master/common.web"
;
}
else/*71:*/
#line 1169 "/home/mark/litprog/spider/src/master/common.web"

#line 1170 "/home/mark/litprog/spider/src/master/common.web"
{
switch(( *argv)[1]){
case'x':
no_xref= 1;
break;
case'I':
/*29:*/
#line 567 "/home/mark/litprog/spider/src/master/common.web"

#line 568 "/home/mark/litprog/spider/src/master/common.web"
pathaddname( *argv+2);
/*:29*/
#line 1176 "/home/mark/litprog/spider/src/master/common.web"

break;
default:
/*74:*/
#line 1195 "/home/mark/litprog/spider/src/master/common.web"
{
#line 1196 "/home/mark/litprog/spider/src/master/common.web"
printf("! Unknown option in argument %s\n", *argv);{if(history==0)history= 1;};
}

/*:74*/
#line 1179 "/home/mark/litprog/spider/src/master/common.web"
;
break;
}
}

/*:71*/
#line 1110 "/home/mark/litprog/spider/src/master/common.web"
;
}
if(!found_web)/*72:*/
#line 1184 "/home/mark/litprog/spider/src/master/common.web"

#line 1185 "/home/mark/litprog/spider/src/master/common.web"
{
if(program==0)
{printf("! Usage: tangle webfile[.web] [changefile[.ch]] [-Ipathname ...]\n");err_print(0);history= 3;wrap_up();}
else
{printf("! Usage: weave webfile[.web] [changefile[.ch]] [-x] [-Ipathname ...]\n");err_print(
0);history= 3;wrap_up();};
}

/*:72*/
#line 1112 "/home/mark/litprog/spider/src/master/common.web"
;
if(!found_change)/*70:*/
#line 1154 "/home/mark/litprog/spider/src/master/common.web"

#line 1155 "/home/mark/litprog/spider/src/master/common.web"
#ifdef MSDOS
strcpy(change_file_name,"NUL");
#else
strcpy(change_file_name,"/dev/null");
#endif
/*:70*/
#line 1113 "/home/mark/litprog/spider/src/master/common.web"
;
}

/*:66*/
#line 85 "/home/mark/litprog/spider/src/master/common.web"
;

/*:1*//*44:*/
#line 740 "/home/mark/litprog/spider/src/master/common.web"
name_pointer
#line 741 "/home/mark/litprog/spider/src/master/common.web"
 id_lookup(first,last,t)
ASCII *first;
ASCII *last;
eight_bits t;
{
ASCII *i= first;
int h;
int l;
name_pointer p;
if(last==NULL)for(last= first; *last!='\0';last++);
l= last-first;
/*45:*/
#line 762 "/home/mark/litprog/spider/src/master/common.web"

h=  *i;while(++i<last)h= (h+h+ *i)%353;

/*:45*/
#line 752 "/home/mark/litprog/spider/src/master/common.web"
;
/*46:*/
#line 768 "/home/mark/litprog/spider/src/master/common.web"

#line 769 "/home/mark/litprog/spider/src/master/common.web"
p= hash[h];
while(p&&!names_match(p,first,l,t))p= p->link;
if(p==NULL){
p= name_ptr;
p->link= hash[h];hash[h]= p;
}

/*:46*/
#line 753 "/home/mark/litprog/spider/src/master/common.web"
;
if(p==name_ptr)/*47:*/
#line 780 "/home/mark/litprog/spider/src/master/common.web"
{
#line 781 "/home/mark/litprog/spider/src/master/common.web"
if(byte_ptr+l>byte_mem_end){{printf("\n! Sorry, capacity exceeded: ");err_print("byte memory");history= 3;wrap_up();};};
if(name_ptr>=name_dir_end){{printf("\n! Sorry, capacity exceeded: ");err_print("name");history= 3;wrap_up();};};
strncpy(byte_ptr,first,l);
(++name_ptr)->byte_start= byte_ptr+= l;
init_p(p,t);
}

/*:47*/
#line 754 "/home/mark/litprog/spider/src/master/common.web"
;
return(p);
}

/*:44*//*51:*/
#line 832 "/home/mark/litprog/spider/src/master/common.web"
name_pointer
#line 833 "/home/mark/litprog/spider/src/master/common.web"
 mod_lookup(k,l)
ASCII *k;
ASCII *l;
{
short c= 2;
name_pointer p= name_dir->dummy.Rlink;
name_pointer q= name_dir;
while(p){
c= web_strcmp(k,l+1,p->byte_start,(p+1)->byte_start);
q= p;
switch(c){
case 0:p= p->link;continue;
case 2:p= p->dummy.Rlink;continue;
case 1:return p;
default:err_print("! Incompatible section names");return NULL;

}
}
return(install_node(q,c,k,l-k+1));
}

/*:51*//*52:*/
#line 857 "/home/mark/litprog/spider/src/master/common.web"

web_strcmp(j,j1,k,k1)
ASCII *j;
ASCII *j1;
ASCII *k;
ASCII *k1;
{
while(k<k1&&j<j1&& *j== *k)k++,j++;
if(k==k1)if(j==j1)return 1;
else return 4;
else if(j==j1)return 3;
else if( *j< *k)return 0;
else return 2;
}

/*:52*//*53:*/
#line 880 "/home/mark/litprog/spider/src/master/common.web"
name_pointer
install_node(parent,c,j,name_len)
name_pointer parent;
int c;
ASCII *j;
int name_len;
{
name_pointer node= name_ptr;
if(byte_ptr+name_len>byte_mem_end){{printf("\n! Sorry, capacity exceeded: ");err_print("byte memory");history= 3;wrap_up();};};
if(name_ptr==name_dir_end){{printf("\n! Sorry, capacity exceeded: ");err_print("name");history= 3;wrap_up();};};
if(c==0)parent->link= node;else parent->dummy.Rlink= node;
node->link= NULL;node->dummy.Rlink= NULL;
init_node(node);
strncpy(byte_ptr,j,name_len);
(++name_ptr)->byte_start= byte_ptr+= name_len;
return(node);
}

/*:53*//*54:*/
#line 904 "/home/mark/litprog/spider/src/master/common.web"
name_pointer
prefix_lookup(k,l)
ASCII *k;
ASCII *l;
{
short c= 2;
short count= 0;
name_pointer p= name_dir->dummy.Rlink;
name_pointer q= NULL;

name_pointer r= NULL;
while(p){
c= web_strcmp(k,l+1,p->byte_start,(p+1)->byte_start);
switch(c){
case 0:p= p->link;break;
case 2:p= p->dummy.Rlink;break;
default:r= p;count++;q= p->dummy.Rlink;p= p->link;
}
if(p==NULL){
p= q;q= NULL;
}
}
if(count==0)err_print("! Name does not match");

if(count>1)err_print("! Ambiguous prefix");

return(r);
}

/*:54*/