1# regression tests for the POSIX grep utilitiy
2
3export LC_ALL=C
4
5KEEP "*.[pd]at"
6
7function DATA
8{
9	typeset f
10	integer i
11	typeset -i8 n
12	for f
13	do	test -f $f && continue
14		case $f in
15		big.dat)for ((i = 0; i <= 10000; i++))
16			do	print $i
17			done
18			;;
19		chars.dat)
20			for ((n = 1; n < 256; n++))
21			do	if	((n != 10))
22				then	eval c=\$\'\\${n#8#}\'
23					print -r -- "$c"
24				fi
25			done
26			;;
27		g1.dat)	cat <<'!'
28.xxxxxxxxxxx
29.xxxxxxxxxxxxxxxxxxx
30.xxxxxxxxxxxxxxxxxxxxxxxx
31.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
32.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
33.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
34.xxxxxxxxxxxxxxxxxxxxxxxx
35.xxxxxxxxxxxxxxxxxxxxxxxx
36.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
37.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
38.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
39.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
40.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
41.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
42.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
43.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
44.xxxxxxxxxxxxxxxxxxxxxxxxxxxx
45.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
46.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
47.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
48.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
49.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
50.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
51.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
52.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
53.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
54.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
55.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
56.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
57.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
58.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
59.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
60.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
61.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
62.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
63.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
64.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
65.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
66.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
67.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
68.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
69.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
70.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
71.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
72.xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
73.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
74.xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
75.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
76.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
77.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
78.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
79.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
80.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
81.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
82.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
83.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
84.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
85.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
86.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
87.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
88.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
89.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
90.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
91.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
92.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
93.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
94.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
95.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
96.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
97.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
98.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
99.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
100.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
101.xxxxxxxxxxxxxxxxxxxxxxxxxxxx
102.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
103.xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
104.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
105.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
106.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
107.xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
108.xxxxxxxxxxxxxxxxxxxxxxxxxxxx
109.xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
110.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
111.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
112.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
113.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
114.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
115.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
116.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
117.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
118.xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
119.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
120.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
121.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
122.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
123.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
124.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
125.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
126.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
127.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
128.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
129.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
130.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
131.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
132.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
133.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
134.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
135.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
136.xxxxxxxxxxxxxxxxxxxxxxx
137.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
138.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
139.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
140.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
141.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
142.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
143.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
144!
145			;;
146		g4.dat)	cat <<'!'
147   1 ZIPPORI, Israel
148	/usr/spool/ap/88/07/15/a0471: Israel-MonaLisa
149   1 ZERIFIN, Israel
150	/usr/spool/ap/88/05/17/a0823: Israel-Baez
151   1 ZEPHYRHILLS, Fla.
152	/usr/spool/ap/88/04/27/a0963: HelicopterEscape
153   1 ZENICA, Yugoslavia
154	/usr/spool/ap/88/07/13/a0814: Yugoslavia
155   1 ZAP, N.D.
156	/usr/spool/ap/88/03/13/a0776: CoalStrike
157   1 ZAMBRANO, Honduras
158	/usr/spool/ap/88/03/24/a0512: Honduras-Soldiers
159   1 ZACHARY, La.
160	/usr/spool/ap/88/04/05/a0745: Brites
161   1 YUCCA VALLEY, Calif.
162	/usr/spool/ap/88/08/26/a0624: BRF--SoCalQuake
163   1 YORKVILLE, Ill.
164	/usr/spool/ap/88/08/31/a0687: ReformedStudent
165   1 YORK, Maine
166	/usr/spool/ap/88/10/09/a0772: SeaSearches
167   1 YENAN, China
168	/usr/spool/ap/88/02/24/a0419: China-Yenan
169   1 YELOWSTONE NATIONAL PARK, Wyo.
170	/usr/spool/ap/88/09/15/a0792: Dukakis
171   1 YEADON, Pa.
172	/usr/spool/ap/88/05/14/a0689: Brites
173   1 YATTA, Occupied West Bank
174	/usr/spool/ap/88/10/29/a0417: Israel-Undercover
175   1 YASSIHOYUK, Turkey
176	/usr/spool/ap/88/09/09/a0423: MidasTomb
177   1 YAPHANK, N.Y.
178	/usr/spool/ap/88/05/10/a0686: Brites
179   1 YAMOUSSOUKRO, Ivory Coast
180	/usr/spool/ap/88/09/25/a0635: Africa-UN
181!
182			;;
183		g5.dat)	cat <<'!'
184com 1037117850
185com -113451303
186com -253844186
187com -591640727
188com -192085666
189com 875206176
190com -688908411
191com 116220732
192com -815364609
193com 393021566
194com -197586762
195com -979497332
196com 580876342
197com 857752251
198com -282427433
199com 440265772
200com 903702654
201com 377371259
202com -790446649
203com -407893353
204com 601447097
205com 311585929
206com -990601410
207com 273028495
208com -421520583
209com -620551282
210com -768217422
211com 722547274
212com 313902943
213com -729597068
214com 306062132
215com 773754585
216com -678639313
217com -345701409
218com -290065002
219com -974307104
220com 1047184566
221com 210828681
222com 108982822
223com 68031245
224com -1047141482
225com 227569703
226com -530798398
227com -822779044
228com 440691738
229com 624275796
230com 843073732
231com 228971433
232com 258376249
233com -308161170
234com -995590232
235com 856677272
236com 132296249
237com 633658628
238com 25935234
239com -1063085400
240com 148654970
241com -824172925
242com -659459669
243com 196909720
244com -393774825
245com 736667556
246com 674673107
247com 1007653812
248com -261383312
249com 263123663
250com -946595190
251com -396442
252com -506832213
253com 149702652
254com -937852087
255com -500943193
256com -288026147
257com -653808189
258com 801559288
259com -653395420
260com -405217270
261com -749529781
262com 965720542
263com 396739912
264com 250804267
265com 1058925867
266com 121948720
267com 129329115
268com -503214654
269com 758365427
270com -569717820
271com 191932303
272com 1041195498
273com -178872661
274com 719024931
275com 389365053
276com -695930677
277com -720993320
278com 659352079
279com -445359373
280com -405581235
281com -495515453
282com -861910553
283com -35979929
284com 1056535300
285com 188042833
286com -220408267
287com -766533595
288com 718865736
289com -614647852
290com 637296265
291com 607439702
292com -996163547
293com -354301843
294com 187216170
295com -524246340
296com 165453004
297com -922340816
298com -392313676
299com 933400965
300com -357455062
301com 876069330
302com 619850004
303com 34785127
304com -204461692
305com -1021142281
306com 261505948
307com 713447396
308com -264424205
309com -757624021
310com -697742264
311com -67902535
312com 813305897
313com 611213298
314com 810009586
315com -351033158
316com -757580248
317com -754765998
318com 96550293
319com 818835421
320com 625544984
321com -301866740
322com -363940120
323com 196940655
324com -990799410
325com -650380493
326com -823008037
327com 229313079
328com 480371766
329com 934025272
330com -223072319
331com 481173087
332com 101019846
333com -954562179
334com -267806909
335com 1004678320
336com 267997081
337com -691653747
338com 821221633
339com 11472834
340com -852175935
341com 145665121
342com 636788309
343com -38553220
344com -594562227
345com 893269786
346com -515632420
347com -504118519
348com -795555924
349com -896489800
350com 381679431
351com 451163332
352com 945690716
353com -474968721
354com -181646048
355com -477705084
356com 179336691
357com 944752723
358com -106013482
359com 295161509
360com -1026918852
361com -1008494120
362com -368542058
363com 6153383
364com 269567191
365com 221084616
366com -1015567145
367com 326752359
368com -253427460
369com -990923267
370com -745673545
371com -772482393
372com 12783572
373com 695087221
374com 782623860
375com 239322275
376com -920492686
377com -461345191
378com 304590436
379com -141131273
380com -1024267294
381com -289620401
382com -495626460
383com 948528218
384com 87006518
385com 395454722
386com 577392034
387com 814343604
388com 497169207
389com -567127307
390com 764271483
391com -866721319
392com -387005272
393com -501938820
394com 567881079
395com 453665993
396com -790328887
397com 390097892
398com 141055035
399com 990378016
400com -730626518
401com 732985962
402com -286073373
403com 22747858
404com -326949321
405com 1022500944
406com 905679100
407com -448120658
408com 363118089
409com 819248817
410com -691522154
411com 59581781
412com -450349154
413com -729823626
414com 646115018
415com -65922779
416com -373376656
417com 1004572328
418com 466654801
419com 128208377
420com 958497476
421com 22952708
422com -822443770
423com 689913706
424com 726815914
425com -128674860
426com 779809535
427com -316931412
428com -1025891272
429com 4804418
430com 309313283
431com 536922264
432com -876904372
433com 700688221
434com 186984467
435com 791829735
436com 237211732
437com 515173384
438com -911728294
439com -783718602
440com 160345621
441com -716237348
442com -185346360
443com -634816499
444com -845917397
445com 460946577
446com 777785415
447com -579223277
448com -127944050
449com -351414763
450com -1006508563
451com 934284417
452com -414601720
453com -328845777
454com 701421432
455com -680992028
456com 444048798
457com -277796693
458com -1014985030
459com 213438258
460com -863232710
461com -236044310
462com -593324426
463com -269273068
464com -163992668
465com -1026411186
466com 537134594
467com 321391768
468com -872419201
469com -795875760
470com 373186979
471com 616631783
472com -567696334
473com 554407297
474com 723377442
475com 1062001538
476com 152160308
477com 43834651
478com 902450760
479com -390697289
480com 431114551
481com -851289267
482com 454377388
483com 470923853
484com -950885734
485com -313255930
486com -388083168
487com -267037738
488com -601696282
489com -848277038
490com 745209391
491com -423687675
492com 646585818
493com -613632730
494com 151442994
495com 868010020
496com -589969477
497com 756495308
498com 482257575
499com -546245706
500com -56416295
501com -922688644
502com -927591869
503com -193091648
504com 505183574
505com -696294953
506com -676843648
507com -458233039
508com 1016060900
509com 235279194
510com 255314418
511com 821562352
512com 677435672
513com -137977226
514com -296008805
515com -284837634
516com 992052324
517com 848130900
518com -612135722
519com -242663012
520com 40910582
521com -633235255
522!
523			;;
524		g6.pat)	cat <<'!'
525^Aconv\(
526^Cconv\(
527^Uconv\(
528^bconv\(
529^begrewrite\(
530^bi_bread\(
531^bi_close\(
532^bi_open\(
533^bi_rand\(
534^bi_read\(
535^bi_write\(
536^bltinval\(
537^compattype\(
538^compile\(
539^concat\(
540^constants\(
541^curproc\(
542^dclformals\(
543^declare\(
544^decref\(
545^dump\(
546^dupgen\(
547^dupnode\(
548^econv\(
549^elemrewr\(
550^emalloc\(
551^emit\(
552^emitconst\(
553^emitspace\(
554^eqtype\(
555^erealloc\(
556^errflush\(
557^error\(
558^etypeof\(
559^etypeoft\(
560^execute\(
561^exits\(
562^fileline\(
563^freenode\(
564^gen\(
565^genfreeauto\(
566^halt\(
567^here\(
568^iconv\(
569^idnode\(
570^idump\(
571^istart\(
572^istopscope\(
573^length\(
574^lerror\(
575^lexinit\(
576^lfileline\(
577^lgen\(
578^lookup\(
579^mconv\(
580^mk\(
581^mkcheck\(
582^nargs\(
583^nconv\(
584^ndump\(
585^new\(
586^newc\(
587^newfile\(
588^newi\(
589^newl\(
590^panic\(
591^patch\(
592^popscope\(
593^pprint\(
594^printable\(
595^processes\(
596^procinit\(
597^proglocals\(
598^pushscope\(
599^pushval\(
600^recrewrite\(
601^rerror\(
602^rpanic\(
603^run\(
604^scopedecrefgen\(
605^setprog\(
606^tconv\(
607^topofstack\(
608^topscope\(
609^type\(
610^typeinit\(
611^typeof\(
612^typeoftid\(
613^warn\(
614^yylex\(
615^yyparse\(
616!
617			;;
618		g8.dat)	cat <<'!'
619b
620ba
621!
622			;;
623		g12.dat)cat <<'!'
624AAA	n
625AAAS	n
626Aaron	n
627AAU	n
628AAUP	d
629AAUW	d
630ABA	n
631Ababa	pc
632aback	d
633abacus	n
634abaft	d
635abalone	n
636abandon	v,er,va
637abase	v,er,va
638abash	v,er,va
639abate	v,er,va
640abattoir	n
641abbe	n
642abbess	n
643abbey	n
644abbot	n
645Abbott	n
646abbreviate	v,ion
647abc	n
648abdicate	v,ion,va
649abdomen	n
650abdominal	a
651abduct	v,ion
652Abe	pc
653abeam	d
654abed	d
655Abel	pc
656Abelian	pc
657Abelson	n
658Aberdeen	pc
659Abernathy	n
660aberrant	n,a
661aberrate	v,ion
662abet	v,va,ms
663abettor	n
664abeyant	a
665abhor	v,er,ms
666abhorrent	a
667abide	v,er
668Abidjan	pc
669Abigail	pc
670abject	a,ion
671abjuration	n
672abjure	v,er
673ablate	v,ion
674ablaut	n
675ablaze	d
676able	v,a,comp,va
677abloom	d
678ablution	n
679ABM	n
680abnegate	v,ion
681Abner	pc
682abnormal	n,a
683aboard	d
684abode	n
685abolish	v,er,va
686abolition	n,na
687abolitionary	n
688abominable	a
689abominate	v,ion
690aboriginal	n,a
691aborigine	n
692aborning	d
693abort	v,er,ion
694abortifacient	n
695abound	vi
696about	d,nopref
697above	d
698aboveboard	d
699aboveground	d
700abovementioned	d
701abracadabra	n
702abrade	v,er,va
703Abraham	n
704Abram	n
705Abramson	n
706abrasion	n,na
707abreact	v,ion
708abreast	d
709abridge	v,er,va
710abridgment	n
711abroad	d
712abrogate	v,ion
713abrupt	a,ion
714abscess	n,v
715abscissa	n
716abscissae	d
717abscission	n
718abscond	v,er
719absent	v,a
720absentee	n
721absenteeism	n
722absentia	n
723absentminded	a
724absinthe	n
725absolute	n,a,na
726absolution	n
727absolve	v,er
728absorb	v,er,va
729absorbent	a
730absorption	n,na
731abstain	v,er
732abstemious	a
733abstention	n
734abstinent	a
735abstract	n,v,a,er,ion
736abstruse	a
737absurd	a,na
738abuilding	d
739abundant	a
740abuse	n,v,er,va
741abusive	a
742abut	v,er,va,ms
743abysmal	a
744abyss	n
745abyssal	a
746Abyssinia	pc
747AC	d
748acacia	n
749academe	pc,na
750academia	pc
751academic	n,na
752academician	n
753academy	n
754Acadia	pc
755acanthus	n
756Acapulco	pc
757accede	v
758accelerando	d
759accelerate	v,ion
760accelerometer	n
761accent	n,v,na
762accentual	a
763accentuate	v,ion
764accept	v,er,va
765acceptant	a
766acceptor	n
767access	n,v
768accessible	a,in
769accession	n,v,na
770accessory	n,na
771accident	n,a
772accidental	a
773accipiter	n
774acclaim	n,v,er
775acclamation	n
776acclimate	n,v,ion
777acclimatize	v,er,ion
778accolade	n
779accommodate	v,ion
780accompaniment	n
781accompanist	n
782accompany	v,na
783accompli	d
784accomplice	n
785accomplish	v,er,va
786accord	n,v
787accordant	a
788accordion	n,na
789accost	v
790account	n,v,va
791accountant	n,a,na
792Accra	pc
793accredit	v,va
794accreditation	n
795accrete	v
796accretion	n,na
797accretionary	n
798accrual	a
799accrue	v,va
800acculturate	v,ion
801accumulate	v,ion
802accuracy	n,in
803accurate	a,in
804accursed	a
805accusation	n,na
806accusatory	d
807accuse	v,er
808accustom	v
809ace	n,v,nopref
810acentric	d
811acerb	a
812acerbic	a
813acetaldehyde	n
814acetate	n
815acetic	d
816acetone	n
817acetyl	n,na
818acetylene	n
819ache	n,v,er
820achieve	v,er,va
821Achilles	pc
822aching	a
823achondrite	n,na
824achromatic	a
825acid	n,a
826acidic	d
827acidify	v,er,ion
828acidimeter	n,na
829acidulous	a
830Ackerman	n
831Ackley	n
832acknowledge	v,va
833acknowledgeable	d
834ACLU	pc
835ACM	pc
836acme	pc
837acne	n
838acolyte	n
839acorn	n
840acoustic	n,a
841acoustician	n
842acoustoelectric	a,na
843acoustooptic	n,a,na
844acquaint	v
845acquaintance	n,na
846acquiesce	v
847acquiescent	a
848acquire	v,va
849acquisition	n,na
850acquit	v,ms
851acquittal	n
852acre	n
853acreage	pc
854acrid	a
855acrimonious	a
856acrimony	n
857acrobat	n
858acrobatic	n,na
859acrolein	n
860acronym	n
861acrophobia	n
862acropolis	n
863across	d
864acrostic	a
865acrylate	n
866acrylic	n
867ACS	pc
868act	n,v,ion,va
869Actaeon	pc
870actinic	na
871actinide	n
872actinium	n
873actinometer	n,na
874activate	v,ion,in
875activism	pc
876Acton	n
877actress	n
878actual	a,na
879actuarial	a
880actuary	n
881actuate	v,ion
882acuity	n
883acumen	n
884acupuncture	n
885acute	a
886acyclic	a
887acyl	n
888ad	n
889Ada	pc
890adage	n
891adagio	n
892Adair	pc
893Adam	pc
894adamant	a
895adamantine	a
896Adams	n
897Adamson	n
898adapt	v,er,ion,va
899adaptation	n,na
900adaptive	a
901adaptor	n
902add	v,er,va
903addend	n
904addenda	pc
905addendum	pc
906addict	n,v,ion
907Addis	pc
908Addison	n
909addition	n,na
910addle	v
911address	n,v,er,na,va
912addressee	n
913Addressograph	pc
914adduce	v,er,va
915Adelaide	pc
916Adele	pc
917Adelia	pc
918Aden	pc
919adenoid	n,na
920adenoma	n
921adenosine	n
922adept	n,a
923adequacy	n,in
924adequate	a,in
925adhere	v
926adherent	n,a
927adhesion	n,na
928adiabatic	n
929adieu	n
930adipose	a
931Adirondack	n
932adjacent	a
933adjectival	a
934adjective	n,a
935adjoin	v
936adjoint	n
937adjourn	v,va
938adjudge	v
939adjudicate	v,ion
940adjunct	n,a,ion
941adjuration	n
942adjure	v
943adjust	v,er,va
944adjutant	n,a
945Adkins	n
946Adler	n
947administer	v
948administrable	d
949administrate	v,ion
950administratrix	d
951admiral	n
952admiralty	n
953admiration	n
954admire	v,er,va
955admissible	a,in
956admission	n,na
957admit	v,er,ms
958admittance	n
959admix	v
960admixture	n
961admonish	v,er,va
962admonition	n
963admonitory	a
964ado	d,nopref
965adobe	n,er
966adolescent	n,a
967Adolph	pc
968Adolphus	pc
969Adonis	pc
970adopt	v,er,ion,va
971adoration	n
972adore	v,er,va
973adorn	v,er,va
974adrenal	n,a
975adrenaline	n
976Adrian	pc
977Adriatic	pc
978Adrienne	pc
979adrift	d
980adroit	a,comp
981adsorb	v,va
982adsorbate	n
983adsorbent	n
984adsorption	n,na
985adulate	v,ion
986adult	n,a
987adulterant	n
988adulterate	v,ion
989adulterer	n
990adulteress	n
991adulterous	a
992adultery	n
993adumbrate	v,ion
994advance	v,er,va
995advantage	n,v
996advantageous	a
997advection	n,na
998advent	n,na
999adventitial	a
1000adventitious	a
1001adventure	n,v,er,na
1002adventuresome	a
1003adventuress	n
1004adventurous	a
1005adverb	n
1006adverbial	a
1007adversary	n,a
1008adverse	a
1009advert	n,v
1010advertent	a,in
1011advertise	v,er,va
1012advice	pc
1013advise	v,er,va
1014advisee	n
1015advisor	n,y
1016advocacy	n
1017advocate	v,ion
1018adz	n
1019adze	n
1020Aegean	pc
1021aegis	n
1022Aeneas	pc
1023Aeneid	pc
1024aeolian	d
1025Aeolus	pc
1026aerate	v,a,ion,va
1027aerial	n,a,na
1028aerie	n
1029Aerobacter	pc
1030aerobatic	n
1031aerobic	n,na
1032aerodynamic	n,na
1033aeronautic	n,na
1034aerosol	n,na
1035aerospace	n
1036Aeschylus	pc
1037aesthete	n
1038aesthetic	n,na
1039afar	d
1040affable	a,va
1041affair	n
1042affect	n,v,ion,va
1043affectation	n
1044affectionate	a
1045afferent	a
1046affiance	n,v
1047affidavit	n
1048affiliate	n,v,ion
1049affine	n,ed,a
1050affinity	n
1051affirm	v,va
1052affirmation	n,na
1053affix	v,va
1054affixation	n
1055afflatus	n
1056afflict	v,er,ion
1057affluent	n,a
1058afford	v,va
1059afforest	v
1060afforestation	n
1061affray	n,v
1062affright	n,v
1063affront	n,v
1064afghan	n
1065Afghanistan	pc
1066aficionado	n
1067afield	d
1068afire	d
1069AFL	d
1070aflame	d
1071afloat	d
1072aflutter	d
1073afoot	d
1074aforementioned	d
1075aforesaid	d
1076aforethought	d
1077afoul	d
1078afraid	d
1079afresh	d
1080Africa	pc
1081Afrikaner	pc
1082afro	n
1083aft	er
1084afterbirth	n
1085afterburner	n
1086afterdeck	n
1087aftereffect	n
1088afterglow	n
1089afterimage	n
1090afterlife	n
1091aftermath	pc
1092aftermost	pc
1093afternoon	n
1094aftershock	n
1095aftertaste	n
1096afterthought	n
1097afterward	n
1098afterworld	n
1099again	d,nopref
1100against	d,nopref
1101Agamemnon	pc
1102agamic	a
1103agape	d
1104agar	n,nopref
1105agate	n,nopref
1106Agatha	pc
1107agave	n
1108age	n,v
1109Agee	n
1110agelong	d
1111agenda	pc,na
1112agendum	pc
1113agent	n,a
1114agglomerate	v,ion
1115agglutinate	v,ion
1116agglutinin	n
1117aggrade	v
1118aggravate	v,ion
1119aggregate	n,v,a,ion
1120aggression	n,na
1121aggressor	n
1122aggrieve	v
1123aghast	d
1124agile	a
1125agitate	v,ion
1126agitprop	pc
1127agleam	d
1128agley	d
1129aglitter	d
1130aglow	d
1131Agnes	pc
1132Agnew	n
1133agnomen	n
1134agnostic	n,na
1135ago	d,nopref
1136agog	d
1137agon	n
1138agone	na
1139agony	n
1140agora	n
1141agoraphobia	n
1142agouti	n
1143agrarian	n,na
1144agree	v,va
1145agreeable	a
1146agreeing	d
1147agribusiness	n
1148Agricola	pc
1149agricultural	a,na
1150agriculture	n,na
1151agrimony	n
1152agronomist	n
1153agronomy	n,na
1154aground	d
1155ague	n
1156Agway	pc
1157ah	n,nopref
1158Ahab	pc
1159ahead	d
1160ahem	d
1161Ahmadabad	pc
1162ahoy	d
1163aid	n,v,er,nopref
1164Aida	pc
1165aide	n,nopref
1166Aiken	pc
1167ail	n,v,nopref
1168ailanthus	pc
1169Aileen	pc
1170aileron	n
1171ailment	n
1172aim	n,v
1173ain't	d
1174Ainu	n
1175air	n,v,man,y
1176airborne	d
1177airbrush	n,v
1178Airbus	n
1179aircraft	n
1180airdrop	n,v,va
1181Aires	pc
1182airfare	n
1183airfield	n
1184airflow	n
1185airfoil	n
1186airframe	n
1187airhead	n
1188airlift	n,v
1189airline	n,er
1190airlock	n
1191airmail	n,v
1192airmass	n
1193airpark	n
1194airport	n
1195airscrew	n
1196airsick	a
1197airspace	n
1198airspeed	n
1199!
1200			;;
1201		g6.dat)	cat <<'!'
1202#include "alloc.h"
1203#include <libc.h>
1204
1205char *
1206emalloc(unsigned long n)
1207{
1208	char *p;
1209	p=malloc((unsigned)n);
1210	if(p==0){
1211		warn("out of memory; exiting");
1212		exits("out of memory");
1213	}
1214	return p;
1215}
1216char *
1217erealloc(char *p, unsigned long n)
1218{
1219	p=realloc(p, (unsigned)n);
1220	if(p==0){
1221		warn("out of memory; exiting");
1222		exits("out of memory");
1223	}
1224	return p;
1225}
1226#include "alloc.h"
1227#include "word.h"
1228#include "store.h"
1229#include "comm.h"
1230#include <libc.h>
1231
1232/*
1233 * Push constants
1234 */
1235
1236ipushconst(Proc *proc)
1237{
1238	*proc->sp++=(SWord)*++proc->pc;
1239	return 1;
1240}
1241
1242ipush_2(Proc *proc)
1243{
1244	*proc->sp++=-2;
1245	return 1;
1246}
1247
1248ipush_1(Proc *proc)
1249{
1250	*proc->sp++=-1;
1251	return 1;
1252}
1253
1254ipush0(Proc *proc)
1255{
1256	*proc->sp++=0;
1257	return 1;
1258}
1259
1260ipush1(Proc *proc)
1261{
1262	*proc->sp++=1;
1263	return 1;
1264}
1265
1266ipush2(Proc *proc)
1267{
1268	*proc->sp++=2;
1269	return 1;
1270}
1271
1272ipush3(Proc *proc)
1273{
1274	*proc->sp++=3;
1275	return 1;
1276}
1277
1278ipush4(Proc *proc)
1279{
1280	*proc->sp++=4;
1281	return 1;
1282}
1283
1284ipush5(Proc *proc)
1285{
1286	*proc->sp++=5;
1287	return 1;
1288}
1289
1290ipush6(Proc *proc)
1291{
1292	*proc->sp++=6;
1293	return 1;
1294}
1295
1296ipush7(Proc *proc)
1297{
1298	*proc->sp++=7;
1299	return 1;
1300}
1301
1302ipush8(Proc *proc)
1303{
1304	*proc->sp++=8;
1305	return 1;
1306}
1307
1308ipush9(Proc *proc)
1309{
1310	*proc->sp++=9;
1311	return 1;
1312}
1313
1314ipush10(Proc *proc)
1315{
1316	*proc->sp++=10;
1317	return 1;
1318}
1319
1320/*
1321 * Binary operators
1322 */
1323ige(Proc *proc)
1324{
1325	--proc->sp;
1326	proc->sp[-1]=proc->sp[-1]>=proc->sp[0];
1327	return 1;
1328}
1329
1330ile(Proc *proc)
1331{
1332	--proc->sp;
1333	proc->sp[-1]=proc->sp[-1]<=proc->sp[0];
1334	return 1;
1335}
1336
1337ine(Proc *proc)
1338{
1339	--proc->sp;
1340	proc->sp[-1]=proc->sp[-1]!=proc->sp[0];
1341	return 1;
1342}
1343
1344ieq(Proc *proc)
1345{
1346	--proc->sp;
1347	proc->sp[-1]=proc->sp[-1]==proc->sp[0];
1348	return 1;
1349}
1350
1351igt(Proc *proc)
1352{
1353	--proc->sp;
1354	proc->sp[-1]=proc->sp[-1]>proc->sp[0];
1355	return 1;
1356}
1357
1358ilt(Proc *proc)
1359{
1360	--proc->sp;
1361	proc->sp[-1]=proc->sp[-1]<proc->sp[0];
1362	return 1;
1363}
1364
1365iadd(Proc *proc)
1366{
1367	--proc->sp;
1368	proc->sp[-1]+=proc->sp[0];
1369	return 1;
1370}
1371
1372isub(Proc *proc)
1373{
1374	--proc->sp;
1375	proc->sp[-1]-=proc->sp[0];
1376	return 1;
1377}
1378
1379imul(Proc *proc)
1380{
1381	long l0, l1, l;
1382	--proc->sp;
1383	l0=proc->sp[-1];
1384	l1=proc->sp[0];
1385	l=l0*l1;
1386	if(l1 && l/l1 != l0)
1387		rerror("product overflow");
1388	proc->sp[-1]=l;
1389	return 1;
1390}
1391
1392idiv(Proc *proc)
1393{
1394	--proc->sp;
1395	if(proc->sp[0]==0)
1396		rerror("zero divide");
1397	proc->sp[-1]/=proc->sp[0];
1398	return 1;
1399}
1400
1401imod(Proc *proc)
1402{
1403	--proc->sp;
1404	if(proc->sp[0]==0)
1405		rerror("zero modulo");
1406	proc->sp[-1]%=proc->sp[0];
1407	return 1;
1408}
1409
1410iand(Proc *proc)
1411{
1412	--proc->sp;
1413	proc->sp[-1]&=proc->sp[0];
1414	return 1;
1415}
1416
1417ior(Proc *proc)
1418{
1419	--proc->sp;
1420	proc->sp[-1]|=proc->sp[0];
1421	return 1;
1422}
1423
1424ixor(Proc *proc)
1425{
1426	--proc->sp;
1427	proc->sp[-1]^=proc->sp[0];
1428	return 1;
1429}
1430
1431ilsh(Proc *proc)
1432{
1433	--proc->sp;
1434	proc->sp[-1]<<=proc->sp[0];
1435	return 1;
1436}
1437
1438irsh(Proc *proc)
1439{
1440	--proc->sp;
1441	proc->sp[-1]>>=proc->sp[0];
1442	return 1;
1443}
1444
1445imax(Proc *proc)
1446{
1447	SWord l;
1448	l=*--proc->sp;
1449	if(l>proc->sp[-1])
1450		proc->sp[-1]=l;
1451	return 1;
1452}
1453
1454/*
1455 * Unary operators
1456 */
1457
1458ineg(Proc *proc)
1459{
1460	proc->sp[-1]=-proc->sp[-1];
1461	return 1;
1462}
1463
1464inot(Proc *proc)
1465{
1466	proc->sp[-1]=~proc->sp[-1];
1467	return 1;
1468}
1469
1470ilnot(Proc *proc)
1471{
1472	proc->sp[-1]=!proc->sp[-1];
1473	return 1;
1474}
1475
1476iref(Proc *proc)
1477{
1478	Store *s=(Store *)*--proc->sp;
1479	*proc->sp++=s->ref-1;
1480	decref(&s);
1481	return 1;
1482}
1483
1484ilen(Proc *proc)
1485{
1486	Store *s=(Store *)*--proc->sp;
1487	*proc->sp++=s->len;
1488	decref(&s);
1489	return 1;
1490}
1491
1492/*
1493 * String comparison: put value of strcmp() on stack
1494 */
1495
1496istrcmp(Proc *proc)
1497{
1498	int cmp;
1499	Store *s1, *s2;
1500	s1=(Store *)proc->sp[-2];
1501	s2=(Store *)proc->sp[-1];
1502	cmp=strcmp((char *)s1->data, (char *)s2->data);
1503	decref(&s1);
1504	decref(&s2);
1505	proc->sp--;
1506	proc->sp[-1]=cmp;
1507	return 1;
1508}
1509
1510/*
1511 * Print
1512 */
1513
1514iprintint(Proc *proc)
1515{
1516	pprint(proc, "%ld", *--proc->sp);
1517	return 1;
1518}
1519
1520iprintnewline(Proc *proc)
1521{
1522	pprint(proc, "\n");
1523	return 1;
1524}
1525
1526iprintblank(Proc *proc)
1527{
1528	pprint(proc, " ");
1529	return 1;
1530}
1531
1532iprintunit(Proc *proc)
1533{
1534	pprint(proc, "(unit)");
1535	return 1;
1536}
1537
1538iprintchar(Proc *proc)
1539{
1540	pprint(proc, "%c", *--proc->sp);
1541	return 1;
1542}
1543
1544pprint(proc, fmt, a, b, c, d, e)
1545	Proc *proc;
1546	char *fmt;
1547{
1548	char buf[1024];
1549	long n;
1550	n=sprint(buf, fmt, a, b, c, d, e);
1551	if(proc->prbuf==0){
1552		proc->prbuf=emalloc(64+n);
1553		proc->maxprbuf=64+n;
1554		proc->nprbuf=0;
1555	}
1556	if(n+proc->nprbuf+1>proc->maxprbuf){
1557		proc->prbuf=erealloc(proc->prbuf, proc->maxprbuf+64+n);
1558		proc->maxprbuf+=64+n;
1559	}
1560	strcpy(proc->prbuf+proc->nprbuf, buf);
1561	proc->nprbuf+=n;
1562}
1563/*
1564 * Stack management
1565 */
1566
1567ipop(Proc *proc)
1568{
1569	--proc->sp;
1570	return 1;
1571}
1572
1573ipopptr(Proc *proc)
1574{
1575	decref((Store **)(proc->sp-1));
1576	--proc->sp;
1577	return 1;
1578}
1579
1580idup(Proc *proc)
1581{
1582	proc->sp++;
1583	proc->sp[-1]=proc->sp[-2];
1584	return 1;
1585}
1586
1587idupptr(Proc *proc)
1588{
1589	proc->sp++;
1590	proc->sp[-1]=proc->sp[-2];
1591	((Store *)(proc->sp[-1]))->ref++;
1592	return 1;
1593}
1594#include "node.h"
1595#include "symbol.h"
1596#include "alloc.h"
1597#include "word.h"
1598#include "store.h"
1599#include "comm.h"
1600#include "inst.h"
1601#include <libc.h>
1602
1603#define	FNS
1604#include "lib.h"
1605#undef	FNS
1606
1607#define	C	0x40000000
1608#define	I	0x20000000
1609#define	F	0x10000000
1610#define	M(x)	((x)&~(C|I|F))
1611
1612long call0[]={	/* plain function, 0 arguments */
1613	I+Ipushfp,	C+0,	F,	I+Iret,	C+0*WS,	I+Idone,	0
1614};
1615long call1[]={	/* plain function, 1 argument */
1616	I+Ipushfp,	C+0,	F,	I+Iret,	C+1*WS,	I+Idone,	0
1617};
1618long call2[]={	/* plain function, 2 arguments */
1619	I+Ipushfp,	C+0,	F,	I+Iret,	C+2*WS,	I+Idone,	0
1620};
1621long call3[]={	/* plain function, 3 arguments */
1622	I+Ipushfp,	C+0,	F,	I+Iret,	C+3*WS,	I+Idone,	0
1623};
1624long call4[]={	/* plain function, 4 arguments */
1625	I+Ipushfp,	C+0,	F,	I+Iret,	C+4*WS,	I+Idone,	0
1626};
1627long call5[]={	/* plain function, 5 arguments */
1628	I+Ipushfp,	C+0,	F,	I+Iret,	C+5*WS,	I+Idone,	0
1629};
1630long call2_0[]={/* two-step function, 0 arguments */
1631	I+Ipushfp,	C+0,	F+0,	F+1,	I+Iret,	C+0*WS,	I+Idone,	0
1632};
1633
1634struct{
1635	char	*name;
1636	int	(*fn[3])();
1637	int	nargs;
1638	long	*template;
1639}bltin[]={
1640#include "lib.h"
1641	0,	{0,	0,	0},	0,	0,
1642};
1643
1644bltinlookup(char *s)
1645{
1646	int i;
1647	for(i=0; bltin[i].name; i++)
1648		if(strcmp(s, bltin[i].name)==0)
1649			return i;
1650	error("%s not a builtin", s);
1651	return -1;
1652}
1653
1654long
1655bltinval(char *name, Node *t)
1656{
1657	int i, nargs, len;
1658	long *template, *p;
1659	Store *s;
1660	SWord *d;
1661	if(t->o.t!=TProg)
1662		error("builtin %s not a function", name);
1663	i=bltinlookup(name);
1664	nargs=bltin[i].nargs;
1665	if(nargs!=length(t->l))	/* necessary but not sufficient */
1666		error("wrong #args to builtin %s: %d (should be %d)", name, length(t->l), nargs);
1667	template=bltin[i].template;
1668	p=template;
1669	for(len=0; *p; p++)
1670		len++;
1671	s=(Store *)emalloc(SHSZ+len*LWS);
1672	s->ref=1;
1673	s->type=Sprog;
1674	s->sbits=0;
1675	s->len=len;
1676	d=s->data;
1677	for(p=template; *p; p++)
1678		if(*p&C)
1679			*d++=(SWord)M(*p);
1680		else if(*p&I)
1681			*d++=(SWord)insttab[M(*p)].fp;
1682		else if(*p&F)
1683			*d++=(SWord)bltin[i].fn[M(*p)];
1684	return (long)s;
1685}
1686
1687Store *
1688mk(type, len)
1689{
1690	Store *s;
1691	if(type==Sstruct)
1692		len++;
1693	s=(Store *)emalloc(SHSZ+len*LWS);
1694	s->ref=1;
1695	s->type=type;
1696	if(type==Sstruct){
1697		s->sbits=1;
1698		s->data[0]=0;
1699	}else
1700		s->sbits=0;
1701	s->len=len;
1702	return s;
1703}
1704#include "node.h"
1705#include "symbol.h"
1706#include "alloc.h"
1707#include "ydefs.h"
1708#include "word.h"
1709#include "store.h"
1710#include "comm.h"
1711#include "inst.h"
1712#include "errjmp.h"
1713#include <libc.h>
1714
1715long		resultloc;
1716long		returnloc;
1717Node		*formals;
1718long		autooffset;
1719extern int	bflag;
1720extern int	cflag;
1721extern int	nscope;
1722extern Node	arychartype;
1723
1724compile(n)	/* called from parser only */
1725	Node *n;
1726{
1727	extern long autooffset;
1728	Errjmp x;
1729	n=constants(n);
1730	if(cflag){
1731		fileline();
1732		fprint(2, "constants:\n");
1733		dump(n, 0);
1734	}
1735	errsave(x);
1736	if(errmark()){
1737		autooffset=0;
1738		freenode(n);
1739		errrest(x);
1740		errjmp();
1741	}
1742	istart();
1743	gen(n, 0);
1744	freenode(n);
1745	errrest(x);
1746}
1747
1748gen(Node *n, int retain)
1749{
1750	int i;
1751	if(n==0)
1752		return;
1753	switch(n->t){
1754	case NArrayref:
1755		arygen(n->l, n->r, 0, 0L);
1756		if(!retain)
1757			popgen(n->l->o.s->val->type->r);
1758		return;
1759	case NBecome:
1760		if(n->l->t==NCall && !bflag){
1761			callgen(n->l, Ibecome);
1762			return;
1763		}
1764		gen(n->l, 1);
1765		n=n->r;
1766		if(n->o.t==TID)
1767			n=typeoftid(n);
1768		switch(n->o.t){
1769		case TInt:
1770		case TChar:
1771			emit(Istoreauto);
1772			emitconst(-LWS*(3+length(formals)));
1773			break;
1774		case TArray:
1775		case TChan:
1776		case TProg:
1777		case TStruct:
1778			emit(Istoreptrauto);
1779			emitconst(-LWS*(3+length(formals)));
1780			break;
1781		case TUnit:
1782			break;
1783		default:
1784			panic("can't compile %t become", n->o.t);
1785		}
1786		scopedecrefgen();
1787		trlrgen();
1788		return;
1789	case NBegin:
1790		callgen(n->l, Ibegin);
1791		return;
1792	case NCall:
1793		callgen(n, Icall);
1794		if(!retain)
1795			popgen(etypeoft(n->l)->r);
1796		return;
1797	case NDecl:
1798	case NDeclsc:
1799		declare(n, 0, 0, 1);
1800		return;
1801	case NExpr:
1802		switch(n->o.i){
1803		case GE:
1804			i=Ige;
1805		Binop:
1806			gen(n->l, 1);
1807			gen(n->r, 1);
1808			if(eqtype(etypeof(n->l), &arychartype)){
1809				emit(Istrcmp);
1810				constgen(0L);
1811			}
1812			emit(i);
1813		Popit:
1814			if(!retain)
1815				emit(Ipop);
1816			return;
1817		case LE:
1818			i=Ile;
1819			goto Binop;
1820		case NE:
1821			i=Ine;
1822			goto Binop;
1823		case EQ:
1824			i=Ieq;
1825			goto Binop;
1826		case '>':
1827			i=Igt;
1828			goto Binop;
1829		case '<':
1830			i=Ilt;
1831			goto Binop;
1832		case '+':
1833			i=Iadd;
1834			goto Binop;
1835		case '-':
1836			i=Isub;
1837			goto Binop;
1838		case '*':
1839			i=Imul;
1840			goto Binop;
1841		case '/':
1842			i=Idiv;
1843			goto Binop;
1844		case '%':
1845			i=Imod;
1846			goto Binop;
1847		case '&':
1848			i=Iand;
1849			goto Binop;
1850		case '|':
1851			i=Ior;
1852			goto Binop;
1853		case '^':
1854			i=Ixor;
1855			goto Binop;
1856		case LSH:
1857			i=Ilsh;
1858			goto Binop;
1859		case RSH:
1860			i=Irsh;
1861			goto Binop;
1862		case ANDAND:
1863			condgen(n->l, n->r, Ijmptrue, Ijmpfalse, 0L, 1L, retain);
1864			return;
1865		case OROR:
1866			condgen(n->l, n->r, Ijmpfalse, Ijmptrue, 1L, 0L, retain);
1867			return;
1868		case PRINT:
1869			gen(n->l, 1);
1870			printgen(n->l);
1871			emit(Isprint);
1872			if(!retain)
1873				emit(Iprint);
1874			return;
1875		case SND:
1876			gen(n->l, 1);
1877			constgen((long)Cissnd);
1878			emit(Icommset1);
1879			emit(Icommcln1);
1880			gen(n->r, 1);
1881			if(isptrtype(etypeoft(n->l)->r))
1882				emit(Isndptr);
1883			else
1884				emit(Isnd);
1885			if(!retain)
1886				popgen(etypeof(n));
1887			return;
1888		case RCV:
1889			gen(n->l, 1);
1890			constgen(0L);	/* not Cissnd */
1891			emit(Icommset1);
1892			emit(Icommcln1);
1893			return;
1894		case '=':
1895			gen(n->r, 1);
1896			if(retain)
1897				dupgen(etypeof(n->r), 1);
1898			lgen(n->l);
1899			return;
1900		case LEN:
1901			gen(n->l, 1);
1902			emit(Ilen);
1903			goto Popit;
1904		case REF:
1905			if(isptrtype(etypeof(n->l))){
1906				gen(n->l, 1);
1907				emit(Iref);
1908			}else
1909				constgen(1L);
1910			goto Popit;
1911		case DEF:
1912			if(retain && n->l->t==NID && isinttype(etypeof(n->l))){
1913				constgen(1L);
1914				return;
1915			}
1916			/*
1917			 * don't really need to call lgen1, which will uniquify our
1918			 * array for us, but it does no harm, and it's easy.
1919			 */
1920			lgen1(n->l, Idefauto, Idef, Idefary);
1921			goto Popit;
1922		case UMINUS:
1923			gen(n->l, 1);
1924			emit(Ineg);
1925			goto Popit;
1926		case '~':
1927			gen(n->l, 1);
1928			emit(Inot);
1929			goto Popit;
1930		case '!':
1931			gen(n->l, 1);
1932			emit(Ilnot);
1933			goto Popit;
1934		case INC:
1935			lgen1(n->l, Iincauto, Iinc, Iincary);
1936			goto Popit;
1937		case DEC:
1938			lgen1(n->l, Idecauto, Idec, Idecary);
1939			goto Popit;
1940		default:
1941			panic("can't compile %e expression", n->o.i);
1942		}
1943
1944	case NExprlist:
1945		/*
1946		 * This is an arg or element list; first is pushed last
1947		 */
1948		gen(n->r, 1);
1949		gen(n->l, 1);
1950		return;
1951	case NID:
1952		if(!retain)
1953			return;
1954		switch(typeof(n)->o.t){
1955		case TInt:
1956		case TChar:
1957			if(n->o.s->val->isauto){
1958				emit(Ipushauto);
1959				emitconst(n->o.s->val->store.off);
1960			}else{
1961				emit(Ipush);
1962				emitconst((long)&n->o.s->val->store.l);
1963			}
1964			return;
1965		case TProg:
1966		case TArray:
1967		case TChan:
1968		case TStruct:
1969			if(n->o.s->val->isauto){
1970				emit(Ipushptrauto);
1971				emitconst(n->o.s->val->store.off);
1972			}else{
1973				emit(Ipushptr);
1974				emitconst((long)&n->o.s->val->store.l);
1975			}
1976			return;
1977		case TUnit:
1978			if(retain)
1979				constgen(0L);
1980			return;
1981		case TType:
1982			lerror(n, "attempt to evaluate type variable %m", n);
1983		default:
1984			panic("can't compile type %t", n->o.s->val->type->o.t);
1985		}
1986	case NIf:
1987		ifgen(n);
1988		return;
1989	case NList:
1990		gen(n->l, 0);
1991		gen(n->r, 0);
1992		return;
1993	case NLoop:
1994		loopgen(n);
1995		return;
1996	case NMk:
1997		mkgen(n->l, n->r);
1998		return;
1999	case NNum:
2000		if(retain)
2001			constgen(n->o.l);
2002		return;
2003	case NProg:
2004		if(retain)
2005			proggen(n->l, n->r);
2006		return;
2007	case NResult:
2008		gen(n->l, 1);
2009		emit(Ijmp);
2010		emitconst((long)(resultloc-here()-1)*WS);
2011		return;
2012	case NScope:
2013		pushscope();
2014		if(nscope==1){
2015			int nauto;
2016			autooffset=0;
2017			emit(Ipushfp);
2018			nauto=here();
2019			emitconst(0L);
2020			gen(n->l, 0);
2021			patch((int)nauto, autooffset);
2022		}else
2023			gen(n->l, 0);
2024		scopedecrefgen();
2025		popscope();
2026		return;
2027	case NSelect:
2028		selgen(n->l);
2029		return;
2030	case NSmash:{
2031		Value *vl, *vr;
2032		vl=n->l->o.s->val;
2033		vr=n->r->o.s->val;
2034		if(vr->type->o.t==TType){
2035			freenode(vl->type);
2036			vl->type=dupnode(vr->type);
2037			return;
2038		}
2039		gen(n->r, 1);
2040		/*
2041		 * Free old values; tricky: push as int, pop as ptr
2042		 */
2043		if(isptrtype(vl->type)){
2044			if(vl->isauto){
2045				emit(Ipushauto);
2046				emitconst(vl->store.off);
2047			}else{
2048				emit(Ipush);
2049				emitconst((long)&vl->store.l);
2050			}
2051			emit(Ipopptr);
2052		}
2053		if(vl->isauto){
2054			emit(Istoreauto);
2055			emitconst(vl->store.l);
2056			return;
2057		}
2058		emit(Istore);
2059		emitconst((long)&vl->store.l);
2060		return;
2061	}
2062	case NString:
2063		if(retain){
2064			Store *s;
2065			s=(Store *)emalloc(SHSZ+strlen(n->o.c)+1);
2066			strcpy((char *)(s->data), n->o.c);
2067			s->ref=1;
2068			s->len=strlen(n->o.c);
2069			s->type=Sarychar;
2070			emit(Ipushdata);
2071			emitconst((long)s);
2072		}
2073		return;
2074	case NStructref:
2075		arygen(n->l, n->r, 1, n->o.l);
2076		return;
2077	case NSwitch:
2078		switchgen(n->l, n->r);
2079		return;
2080	case NUnit:
2081		if(retain)
2082			constgen(0L);
2083		return;
2084	case NVal:
2085		valgen(n->l);
2086		if(!retain)
2087			popgen(n->o.n);
2088		return;
2089	}
2090	panic("can't compile node %n", n->t);
2091	return;
2092}
2093
2094arygen(Node *a, Node *i, int isstr, long off)
2095{
2096	int ptr, ischar;
2097	if(isstr){
2098		ptr=isptrtype(i);
2099		constgen(off);
2100		ischar=0;
2101	}else{
2102		Node *t=etypeoft(a)->r;
2103		ptr=isptrtype(t);
2104		gen(i, 1);
2105		ischar=t->o.t==TChar;
2106	}
2107	if(a->t!=NID){
2108		gen(a, 1);
2109		emit(ptr? Ipusharyptrexpr :
2110			(ischar? Ipusharycharexpr :Ipusharyexpr));
2111	}else if(a->o.s->val->isauto){
2112		emit(ptr? Ipusharyptrauto :
2113			(ischar? Ipusharycharauto :Ipusharyauto));
2114		emitconst(a->o.s->val->store.off);
2115	}else{
2116		emit(ptr? Ipusharyptr :
2117			(ischar? Ipusharychar :Ipushary));
2118		emitconst((long)&a->o.s->val->store.l);
2119	}
2120}
2121
2122lgen(Node *n)
2123{
2124	switch(n->t){
2125	case NID:
2126		switch(typeof(n)->o.t){
2127		case TChar:
2128			if(n->o.s->val->isauto){
2129				emit(Istorecharauto);
2130				emitconst(n->o.s->val->store.off);
2131				return;
2132			}
2133			emit(Istorechar);
2134			emitconst((long)&n->o.s->val->store.l);
2135			return;
2136		case TInt:
2137		case TUnit:
2138			if(n->o.s->val->isauto){
2139				emit(Istoreauto);
2140				emitconst(n->o.s->val->store.off);
2141				return;
2142			}
2143			emit(Istore);
2144			emitconst((long)&n->o.s->val->store.l);
2145			return;
2146		case TArray:
2147		case TChan:
2148		case TProg:
2149		case TStruct:
2150			if(n->o.s->val->isauto){
2151				emit(Istoreptrauto);
2152				emitconst(n->o.s->val->store.off);
2153				return;
2154			}
2155			emit(Istoreptr);
2156			emitconst((long)&n->o.s->val->store.l);
2157			return;
2158
2159		default:
2160			panic("lgen: ID type %t", n->o.s->val->type->o.t);
2161			return;
2162		}
2163	case NArrayref:
2164		gen(n->r, 1);
2165		goto Genref;
2166	case NStructref:
2167		constgen(n->o.l);
2168	Genref:
2169		lgen1(n->l, Ipushuniqauto, Ipushuniq, Ipushuniqary);
2170		emit(Istoreary);
2171		return;
2172	default:
2173		panic("lgen: lvalue node %n", n->t);
2174	}
2175}
2176
2177/*
2178 * n is a compound object about to be assigned into
2179 */
2180lgen1(Node *n, int Iauto, int Ivar, int Iary)
2181{
2182	switch(n->t){
2183	case NID:
2184		if(n->o.s->val->isauto){
2185			emit(Iauto);
2186			emitconst(n->o.s->val->store.off);
2187			return;
2188		}
2189		emit(Ivar);
2190		emitconst((long)&n->o.s->val->store.l);
2191		return;
2192	case NArrayref:
2193		gen(n->r, 1);
2194		goto Genref;
2195	case NStructref:
2196		constgen(n->o.l);
2197	Genref:
2198		lgen1(n->l, Ipushuniqauto, Ipushuniq, Ipushuniqary);
2199		emit(Iary);
2200		return;
2201	default:
2202		panic("lgen1: lvalue node %n", n->t);
2203	}
2204}
2205
2206ifgen(Node *n)
2207{
2208	int loc1, loc2;
2209	gen(n->o.n, 1);
2210	emit(Ijmpfalse);
2211	loc1=here();
2212	emit(0);
2213	gen(n->l, 0);
2214	if(n->r==0){
2215		patch(loc1, (long)(here()-loc1-1)*WS);
2216		return;
2217	}
2218	emit(Ijmp);
2219	loc2=here();
2220	emit(0);
2221	patch(loc1, (long)(here()-loc1-1)*WS);
2222	gen(n->r, 0);
2223	patch(loc2, (long)(here()-loc2-1)*WS);
2224	return;
2225}
2226
2227valgen(Node *n)
2228{
2229	int loc1, loc2;
2230	int orl;
2231	emit(Ijmp);
2232	loc1=here();
2233	emitconst(0L);
2234	orl=resultloc;
2235	resultloc=here();
2236	emit(Ijmp);
2237	loc2=here();
2238	emitconst(0L);
2239	patch(loc1, (long)(here()-loc1-1)*WS);
2240	gen(n, 1);
2241	emit(Ivalnoresult);
2242	patch(loc2, (long)(here()-loc2-1)*WS);
2243	resultloc=orl;
2244}
2245
2246loopgen(Node *n)
2247{
2248	int loc0, loc1, loc2;
2249	if(n->o.i){	/* enter loop at top, so jump to body */
2250		emit(Ijmp);
2251		loc0=here();
2252		emit(0);
2253	}
2254	gen(n->r->l, 0);	/* left expr */
2255	if(n->r->r){		/* jump to condition */
2256		emit(Ijmp);
2257		loc1=here();
2258		emit(0);
2259	}
2260	if(n->o.i)
2261		patch(loc0, (here()-loc0-1)*LWS);
2262	loc2=here();
2263	gen(n->l, 0);		/* body */
2264	gen(n->r->o.n, 0);	/* right expr */
2265	if(n->r->r){
2266		patch(loc1, (here()-loc1-1)*LWS);
2267		gen(n->r->r, 1);
2268		emit(Ijmptrue);
2269	}else
2270		emit(Ijmp);
2271	emitconst((loc2-here()-1)*LWS);
2272}
2273
2274condgen(Node *l, Node *r, Inst i1, Inst i2, long t1, long t2, int retain)
2275{
2276	int loc1, loc2, loc3;
2277	gen(l, 1);
2278	emit(i1);
2279	loc1=here();
2280	emit(0);
2281	loc2=here();
2282	if(retain)
2283		constgen(t1);
2284	emit(Ijmp);
2285	loc3=here();
2286	emit(0);
2287	patch(loc1, (long)(here()-loc1-1)*WS);
2288	gen(r, 1);
2289	emit(i2);
2290	emitconst((long)(loc2-here()-1)*WS);
2291	if(retain)
2292		constgen(t2);
2293	patch(loc3, (long)(here()-loc3-1)*WS);
2294}
2295
2296callgen(Node *n, int callinst)
2297{
2298	Node *pt;
2299	pt=etypeof(n->l);
2300	/*
2301	 * Space for result
2302	 */
2303	constgen(0L);
2304	/*
2305	 * Args
2306	 */
2307	gen(n->r, 1);
2308	/*
2309	 * Call
2310	 */
2311	emit(Ipushconst);
2312	if(n->l->t==NID)
2313		emitconst((long)n->l->o.s->name);
2314	else{
2315		char buf[128];
2316		char *p;
2317		sprint(buf, "prog(){call on line %d}", n->line);
2318		p=emalloc((unsigned long)strlen(buf)+1);
2319		strcpy(p, buf);
2320		emitconst((long)p);
2321	}
2322	gen(n->l, 1);
2323	switch(callinst){
2324	case Icall:
2325		emit(Icall);
2326		return;
2327	case Ibegin:
2328		constgen(LWS*(1+1+length(pt->l)));	/* result+procname+args */
2329		emit(Ibegin);
2330		return;
2331	case Ibecome:
2332		constgen(LWS*(1+1+length(pt->l)));	/* result+procname+args */
2333		scopedecrefgen();
2334		fdecrefgen(formals, -3L*WS);
2335		emit(Ibecome);
2336		if(formals)
2337			emitconst(length(formals)*LWS);
2338		else
2339			emitconst(0L);
2340		return;
2341	}
2342	panic("callgen");
2343}
2344
2345selgen(Node *n)
2346{
2347	int tbl, i;
2348	long l;
2349	int ends[200];
2350	selchangen(n);
2351	l=length(n);
2352	constgen(l);
2353	emit(Icommset);
2354	emit(Icommcln);
2355	if(l>(sizeof ends/sizeof ends[0]))
2356		panic("selgen table too small");
2357	tbl=here();
2358	emitspace(l);
2359	i=0;
2360	seltblgen(n, tbl, ends, &i);
2361	for(i=0; i<l; i++)
2362		patch(ends[i], (long)(here()-ends[i]-1)*WS);
2363}
2364
2365selchangen(Node *n)
2366{
2367	long flags;
2368	if(n->t==NList){
2369		selchangen(n->l);
2370		selchangen(n->r);
2371		return;
2372	}
2373	if(n->t!=NCase)
2374		panic("selchangen");
2375	n=n->l->l;
2376	if(n->o.t=='=')
2377		n=n->r;		/* n is now RCV or SND */
2378	flags=0;
2379	if(n->o.t==SND)
2380		flags|=Cissnd;
2381	n=n->l;			/* n is now channel */
2382	if(n->t==NArraycom){
2383		flags|=Cisary;
2384		n=n->l;
2385	}else if(etypeoft(n)->o.t==TArray)
2386		flags|=Cisary;
2387	gen(n, 1);
2388	constgen(flags);
2389}
2390
2391seltblgen(Node *n, int tbl, int *ends, int *ip)
2392{
2393	Node *c, *s, *l, *t;
2394	if(n->t==NList){
2395		/* chans are eval'ed from the top, so table is backwards */
2396		seltblgen(n->r, tbl, ends, ip);
2397		seltblgen(n->l, tbl, ends, ip);
2398		return;
2399	}
2400	if(n->t!=NCase)
2401		panic("seltblgen");
2402	if(n->l->t==NList)
2403		error("sorry, empty cases not implemented");
2404	patch(tbl+*ip, (long)(here()-tbl)*WS);
2405	c=n->l->l;	/* communication */
2406	s=n->r;		/* statement */
2407	l=0;
2408	if(c->o.t=='='){
2409		l=c->l;	/* lvalue */
2410		c=c->r;
2411	}
2412	if(c->o.t==SND){
2413		gen(c->r, 1);
2414		if(isptrtype(etypeoft(c->l)->r))
2415			emit(Isndptr);
2416		else
2417			emit(Isnd);
2418	}
2419	c=c->l;	/* channel expression */
2420	/*
2421	 * The value is still on the stack; save it or toss it
2422	 */
2423	if(l)
2424		lgen(l);
2425	else if(c->t==NArraycom){
2426		t=etypeoft(c->l)->r;
2427		if(t->o.t==TID)
2428			t=typeoftid(t);
2429		popgen(t->r);
2430	}else
2431		popgen(etypeoft(c)->r);
2432	if(c->t==NArraycom){	/* save array index */
2433		if(c->r)
2434			lgen(c->r);
2435		else
2436			emit(Ipop);
2437	}
2438	gen(s, 0);
2439	emit(Ijmp);
2440	ends[*ip]=here();
2441	(*ip)++;
2442	emitconst(0L);
2443}
2444
2445switchgen(Node *s, Node *e)
2446{
2447	int isptr, out;
2448	isptr=isptrtype(etypeof(e));
2449	gen(e, 1);
2450	emit(Ijmp);
2451	emitconst(2*LWS);
2452	emit(Ijmp);	/* each case jumps to here to get out */
2453	out=here();
2454	emitconst(0L);
2455	switchgen1(s, isptr, out-1);
2456	/* pop leftover value if no case matched */
2457	if(isptr)
2458		emit(Ipopptr);
2459	else
2460		emit(Ipop);
2461	patch(out, (here()-out-1)*LWS);
2462}
2463
2464switchgen1(Node *s, int isptr, int out)
2465{
2466	Node *e;
2467	int loc;
2468	if(s->t==NList){
2469		switchgen1(s->l, isptr, out);
2470		switchgen1(s->r, isptr, out);
2471		return;
2472	}
2473	if(s->t!=NCase)
2474		panic("switchgen1");
2475	if(s->r==0)
2476		error("sorry; can't fold cases together yet");
2477	if(s->l->t==NDefault)
2478		loc=-1;
2479	else{
2480		e=s->l->l;
2481		if(isptr){	/* string */
2482			emit(Idupptr);
2483			gen(e, 1);
2484			emit(Istrcmp);
2485			constgen(0L);
2486		}else{
2487			emit(Idup);
2488			gen(e, 1);
2489		}
2490		emit(Ieq);
2491		emit(Ijmpfalse);
2492		loc=here();
2493		emitconst(0L);
2494	}
2495	if(isptr)
2496		emit(Ipopptr);
2497	else
2498		emit(Ipop);
2499	gen(s->r, 0);
2500	emit(Ijmp);
2501	emitconst((out-here()-1)*LWS);
2502	if(loc!=-1)
2503		patch(loc, (here()-loc-1)*LWS);
2504}
2505
2506popgen(Node *t)
2507{
2508	if(isptrtype(t))
2509		emit(Ipopptr);
2510	else if(isinttype(t) || t->o.t==TUnit)
2511		emit(Ipop);
2512	else
2513		panic("popgen %t\n", t->o.t);
2514}
2515
2516genfreeauto(Symbol *s)
2517{
2518	if(!s->val->isauto)
2519		panic("genfreeauto");
2520	if(isptrtype(s->val->type)){
2521		emit(Idecrefauto);
2522		emitconst(s->val->store.off);
2523	}
2524}
2525
2526printgen(Node *n)
2527{
2528	Node *t;
2529	if(n==0)
2530		return;
2531	if(n->t==NExprlist){
2532		printgen(n->l);
2533		printgen(n->r);
2534		return;
2535	}
2536	t=etypeoft(n);
2537	switch(t->o.t){
2538	case TArray:
2539	case TChan:
2540	case TProg:
2541	case TStruct:
2542		emit(Iprintary);
2543		break;
2544	case TChar:
2545		emit(Iprintchar);
2546		break;
2547	case TInt:
2548		emit(Iprintint);
2549		break;
2550	case TUnit:
2551		emit(Iprintunit);
2552		break;
2553	default:
2554		panic("printgen: bad type %t", t->o.t);
2555	}
2556}
2557
2558proggen(Node *t, Node *n)
2559{
2560	int or;
2561	Node *of;
2562	Errjmp s;
2563	Store *p;
2564	long len, loc;
2565	long nauto, oao;
2566	extern int (*prog[])();
2567	oao=autooffset;
2568	or=returnloc;
2569	of=formals;
2570	autooffset=0;
2571	returnloc=0;
2572	formals=t->l;
2573	errsave(s);
2574	if(errmark()){
2575		returnloc=or;
2576		formals=of;
2577		autooffset=oao;
2578		errrest(s);
2579		errjmp();
2580	}
2581	loc=here();
2582	pushscope();
2583	dclformals(t->l);
2584	autooffset=0;
2585	emit(Ipushfp);
2586	nauto=here();
2587	emitconst(0L);
2588	gen(n, 0);
2589	trlrgen();
2590	patch((int)nauto, autooffset);
2591	popscope();
2592	errrest(s);
2593	autooffset=oao;
2594	returnloc=or;
2595	formals=of;
2596	len=here()-loc+1;
2597	p=(Store *)emalloc(SHSZ+len*LWS);
2598	memcpy((char *)(p->data), (char *)(prog+loc), len*LWS);
2599	p->ref=1;
2600	p->len=len;
2601	p->type=Sprog;
2602	setprog(loc);
2603	emit(Ipushdata);
2604	emitconst((long)p);
2605}
2606
2607trlrgen()
2608{
2609	if(returnloc){
2610		emit(Ijmp);
2611		emitconst((long)(returnloc-here()-1)*WS);
2612		return;
2613	}
2614	returnloc=here();
2615	fdecrefgen(formals, -3L*WS);
2616	emit(Iret);
2617	if(formals)
2618		emitconst(length(formals)*LWS);
2619	else
2620		emitconst(0L);
2621}
2622
2623fdecrefgen(Node *types, long offset)
2624{
2625	if(types==0)
2626		return 0;
2627	if(types->t==NList){
2628		offset=fdecrefgen(types->l, offset);
2629		return fdecrefgen(types->r, offset);
2630	}
2631	if(types->t!=NFormal)
2632		panic("fdecrefgen");
2633	types=types->r;
2634	if(isptrtype(types)){
2635		emit(Idecrefauto);
2636		emitconst(offset);
2637	}
2638	return offset-WS;
2639}
2640
2641dupgen(Node *t, int n)
2642{
2643	while(n--)
2644		emit(isptrtype(t)? Idupptr : Idup);
2645}
2646
2647mkgen(Node *t, Node *v)
2648{
2649	switch(t->o.t){
2650	case TChar:
2651	case TInt:
2652	case TUnit:
2653		if(v)
2654			gen(v, 1);
2655		else
2656			constgen(0L);
2657		return;
2658	case TID:
2659		mkgen(typeoftid(t), v);
2660		return;
2661	case TChan:
2662		if(v)
2663			gen(v, 1);
2664		else{
2665			constgen((long)(sizeof(Chan)-sizeof(Store)));
2666			mallocgen(t);
2667		}
2668		return;
2669	case TArray:
2670		if(v==0){
2671			gen(t->l, 1);
2672			mallocgen(t);
2673			return;
2674		}
2675		gen(v, 1);
2676		if(v->t!=NExprlist && eqtype(t, etypeof(v)))
2677			return;
2678		if(v->t==NString)
2679			constgen((long)strlen(v->o.c));
2680		else
2681			constgen((long)length(v));
2682		emit(Idup);
2683		if(t->l)
2684			gen(t->l, 1);
2685		else
2686			constgen(0L);
2687		emit(Imax);
2688		mallocgen(t);
2689		if(t->r->o.t==TChar){
2690			if(v->t==NString)
2691				emit(Imemcpychar);
2692			else
2693				emit(Imemcpycharint);
2694		}else
2695			emit(Imemcpy);
2696		return;
2697	case TProg:
2698		if(v==0){
2699			v=new(NProg, dupnode(t), (Node *)0, (Node *)0);
2700			gen(v, 1);
2701			freenode(v);
2702			return;
2703		}
2704		gen(v, 1);
2705		return;
2706	case TStruct:
2707		if(v==0){
2708			mallocgen(t);
2709			return;
2710		}
2711		gen(v, 1);
2712		if(v->t!=NExprlist && eqtype(t, etypeof(v)))
2713			return;
2714		constgen((long)length(v));
2715		mallocgen(t);
2716		emit(Imemcpystruct);
2717		return;
2718	default:
2719		panic("mkgen: bad type %t", t->o.t);
2720	}
2721}
2722
2723mallocgen(Node *t)
2724{
2725	switch(t->o.t){
2726	case TArray:
2727		t=t->r;
2728		if(t->o.t==TID)
2729			t=typeoftid(t);
2730		if(isptrtype(t)){
2731			constgen((long)Saryptr);
2732			emit(Imalloc);
2733		}else if(t->o.t==TInt || t->o.t==TUnit){
2734			constgen((long)Saryint);
2735			emit(Imalloc);
2736		}else if(t->o.t==TChar)
2737			emit(Imallocarychar);
2738		else
2739			panic("mallocgen array of %t", t->o.t);
2740		return;
2741	case TStruct:{
2742		int pos=0;
2743		long bits=0;
2744		t=t->l;
2745		elembitsgen(t, &pos, &bits);
2746		if(pos)
2747			constgen(bits);
2748		constgen((long)length(t));
2749		emit(Imallocstruct);
2750		return;
2751	}
2752	case TChan:
2753		constgen((long)Schan);
2754		emit(Imalloc);
2755		return;
2756	}
2757	panic("mallocgen of %t", t->o.t);
2758}
2759
2760elembitsgen(Node *t, int *pos, long *bits)
2761{
2762	int i;
2763	if(t->t==NList){
2764		elembitsgen(t->l, pos, bits);
2765		elembitsgen(t->r, pos, bits);
2766		return;
2767	}
2768	if(t->t!=NElem)
2769		panic("elembitsgen %n", t->t);
2770	for(i=length(t); --i>=0; ){
2771		if(*pos==BPW){
2772			constgen(*bits);
2773			*pos=0;
2774			*bits=0;
2775		}
2776		if(isptrtype(t->r))
2777			*bits|=1L<<*pos;
2778		(*pos)++;
2779	}
2780}
2781
2782constgen(long l)
2783{
2784	if(l<-2 || l>10){
2785		emit(Ipushconst);
2786		emitconst(l);
2787		return;
2788	};
2789	switch((int)l){
2790	case -2:
2791		emit(Ipush_2);
2792		break;
2793	case -1:
2794		emit(Ipush_1);
2795		break;
2796	case 0:
2797		emit(Ipush0);
2798		break;
2799	case 1:
2800		emit(Ipush1);
2801		break;
2802	case 2:
2803		emit(Ipush2);
2804		break;
2805	case 3:
2806		emit(Ipush3);
2807		break;
2808	case 4:
2809		emit(Ipush4);
2810		break;
2811	case 5:
2812		emit(Ipush5);
2813		break;
2814	case 6:
2815		emit(Ipush6);
2816		break;
2817	case 7:
2818		emit(Ipush7);
2819		break;
2820	case 8:
2821		emit(Ipush8);
2822		break;
2823	case 9:
2824		emit(Ipush9);
2825		break;
2826	case 10:
2827		emit(Ipush10);
2828		break;
2829	default:
2830		panic("constgen");
2831	}
2832}
2833
2834printable(Node *n)
2835{
2836	if(n==0)
2837		return 0;
2838	switch(n->t){
2839	case NExpr:
2840		return n->o.t!='=';
2841	case NArrayref:
2842	case NCall:
2843	case NID:
2844	case NMk:
2845	case NNum:
2846	case NProg:
2847	case NString:
2848	case NStructref:
2849	case NUnit:
2850	case NVal:
2851		return 1;
2852	}
2853	return 0;
2854}
2855#include "alloc.h"
2856#include "node.h"
2857#include "symbol.h"
2858#include "ydefs.h"
2859#include "word.h"
2860#include "store.h"
2861#include <libc.h>
2862
2863Node		*doconst();
2864extern int	Cflag;
2865
2866Node *
2867constants(Node *n)
2868{
2869	if(n==0)
2870		return 0;
2871	if(Cflag)
2872		return n;
2873	switch(n->t){
2874	case NArrayref:
2875		if(isconst(n))
2876			return doconst(n);
2877		break;
2878	case NArraycom:
2879		break;
2880	case NBecome:
2881		break;
2882	case NBegin:
2883		break;
2884	case NCall:
2885		break;
2886	case NCase:
2887		break;
2888	case NDecl:
2889		n->r=constants(n->r);
2890		n->o.n=constants(n->o.n);
2891		declare(n, 0, 0, 0);
2892		return n;
2893	case NDeclsc:
2894		break;
2895	case NDefault:
2896		return n;
2897	case NElem:
2898		n->r=constants(n->r);
2899		return n;
2900	case NExpr:
2901		switch(n->o.i){
2902		case GE:
2903		case LE:
2904		case NE:
2905		case EQ:
2906		case '>':
2907		case '<':
2908		case '+':
2909		case '-':
2910		case '*':
2911		case '/':
2912		case '%':
2913		case '&':
2914		case '|':
2915		case '^':
2916		case ANDAND:
2917		case OROR:
2918		case LSH:
2919		case RSH:
2920			if(isconst(n->l) && isconst(n->r))
2921				return doconst(n);
2922			break;
2923		case DEF:
2924		case REF:
2925		case LEN:
2926		case UMINUS:
2927		case '~':
2928		case '!':
2929			if(isconst(n->l))
2930				return doconst(n);
2931			break;
2932		case PRINT:
2933		case RCV:
2934		case SND:
2935		case INC:
2936		case DEC:
2937			break;
2938		case '=':
2939			break;
2940		default:
2941			fprint(2, "can't const expression %e\n", n->o.i);
2942			return n;
2943		}
2944		break;
2945	case NExprlist:
2946		break;
2947	case NFormal:
2948		n->r=constants(n->r);
2949		return n;
2950	case NLabel:
2951		break;
2952	case NID:
2953		if(isconst(n))
2954			return doconst(n);
2955		break;
2956	case NIf:
2957		n->l=constants(n->l);
2958		n->r=constants(n->r);
2959		n->o.n=constants(n->o.n);
2960		if(isconst(n->o.n)){
2961			Node *m;
2962			gen(n->o.n, 1);
2963			execute();
2964			if(topofstack()){
2965				m=n->l;
2966				n->l=0;
2967			}else{
2968				m=n->r;
2969				n->r=0;
2970			}
2971			freenode(n);
2972			return m;
2973		}
2974		return n;
2975	case NList:
2976		break;
2977	case NLoop:
2978		break;
2979	case NLoopexpr:
2980		n->o.n=constants(n->o.n);
2981		break;
2982	case NMk:
2983		break;
2984	case NNum:
2985		return n;
2986	case NProg:
2987		pushscope();
2988		dclformals(n->l->l);
2989		n->r=constants(n->r);
2990		popscope();
2991		return n;
2992	case NResult:
2993		break;
2994	case NScope:
2995		pushscope();
2996		n->l=constants(n->l);
2997		popscope();
2998		return n;
2999	case NSelect:
3000		break;
3001	case NSmash:
3002		return n;
3003	case NString:
3004		return n;
3005	case NSwitch:
3006		break;
3007	case NStructref:
3008		if(isconst(n))
3009			return (n);
3010		break;
3011	case NType:
3012		break;
3013	case NUnit:
3014		break;
3015	case NVal:
3016		if(isconst(n->l))
3017			return doconst(n);
3018		break;
3019	default:
3020		fprint(2, "can't const node %n\n", n->t);
3021		return n;
3022	}
3023	n->l=constants(n->l);
3024	n->r=constants(n->r);
3025	return n;
3026}
3027
3028isconst(Node *n)
3029{
3030	if(n==0)
3031		return 1;
3032	switch(n->t){
3033	case NArrayref:
3034		return isconst(n->l) && isconst(n->r);
3035	case NCall:
3036		return 0;
3037	case NExpr:
3038		switch(n->o.i){
3039		case GE:
3040		case LE:
3041		case NE:
3042		case EQ:
3043		case '>':
3044		case '<':
3045		case '+':
3046		case '-':
3047		case '*':
3048		case '/':
3049		case '%':
3050		case '&':
3051		case '|':
3052		case '^':
3053		case ANDAND:
3054		case OROR:
3055		case LSH:
3056		case RSH:
3057			return isconst(n->l) && isconst(n->r);
3058		case DEF:
3059		case LEN:
3060		case UMINUS:
3061		case '~':
3062		case '!':
3063			return isconst(n->l);
3064		case REF:
3065		case '=':
3066		case RCV:
3067		case SND:
3068		case INC:
3069		case DEC:
3070			return 0;
3071		}
3072		fprint(2, "can't isconst expression %e", n->o.i);
3073		return 0;
3074	case NID:
3075		return n->o.s->val->scope==0 && (n->o.s->val->stclass&SCconst);
3076	case NIf:
3077		return isconst(n->o.n) && isconst(n->l) && isconst(n->r);
3078	case NList:
3079		return 0;
3080	case NLoop:
3081		return 0;
3082	case NNum:
3083		return 1;
3084	case NResult:
3085		return isconst(n->l);
3086	case NScope:
3087		return isconst(n->l);
3088	case NString:
3089		return 1;
3090	case NStructref:
3091		return isconst(n->l);
3092	case NVal:
3093		return isconst(n->l);
3094	case NUnit:
3095		return 1;
3096	}
3097	fprint(2, "can't isconst node %n\n", n->t);
3098	return 0;
3099}
3100
3101Node *
3102doconst(Node *n)
3103{
3104	Node *t;
3105	if(n->t==NNum || n->t==NString || n->t==NUnit)
3106		return n;	/* already const */
3107	t=etypeoft(n);
3108	switch(t->o.t){
3109	case TChar:
3110	case TInt:
3111		gen(n, 1);
3112		freenode(n);
3113		execute();
3114		return new(NNum, (Node *)0, (Node *)0, (Node *)topofstack());
3115	case TUnit:
3116		return new(NUnit, (Node *)0, (Node *)0, (Node *)0);
3117	case TArray:
3118		if(t->r->o.t==TChar){
3119			Store *s;
3120			char *c;
3121			gen(n, 1);
3122			freenode(n);
3123			execute();
3124			s=(Store *)topofstack();
3125			c=emalloc(s->len+1);
3126			strncpy(c, (char *)s->data, (int)s->len);
3127			return newc(NString, (Node *)0, (Node *)0, c);
3128		}
3129		return n;
3130	}
3131	return n;
3132}
3133#include "alloc.h"
3134#include "word.h"
3135#include "store.h"
3136#include "comm.h"
3137#include <libc.h>
3138
3139extern	int	pflag;
3140
3141/*
3142 * Jumps
3143 */
3144
3145ijmp(Proc *proc)
3146{
3147	SWord l;
3148	l=(SWord)*++proc->pc;
3149	proc->pc+=l/WS;
3150	return 1;
3151}
3152
3153ijmpfalse(Proc *proc)
3154{
3155	SWord l;
3156	l=(SWord)*++proc->pc;
3157	if(*--proc->sp==0)
3158		proc->pc+=l/WS;
3159	return 1;
3160}
3161
3162ijmptrue(Proc *proc)
3163{
3164	SWord l;
3165	l=(SWord)*++proc->pc;
3166	if(*--proc->sp!=0)
3167		proc->pc+=l/WS;
3168	return 1;
3169}
3170
3171ivalnoresult(Proc *proc)
3172{
3173	rerror("val produces no result");
3174	return 0;
3175}
3176
3177/*
3178 * Progs
3179 *
3180 *   Layout of a stack frame
3181 *
3182 *	sp:
3183 *		automatics
3184 *	fp:	old fp
3185 *		old pc
3186 *		symbol
3187 *		arg1
3188 *		arg2
3189 *		...
3190 *		result
3191 */
3192
3193iret(Proc *proc)
3194{
3195	SWord nargs;
3196	nargs=(SWord)(proc->pc[1]);
3197	proc->sp=(SWord *)proc->fp+1;
3198	proc->fp=(SWord *)*--proc->sp;
3199	proc->pc=(int (**)())*--proc->sp;
3200	proc->sp-=(sizeof(char *)+nargs)/WS;
3201	if(proc->pc==0){
3202		if(pflag)
3203			fprint(2, "%d halts\n", proc->procnum);
3204		halt(proc);
3205		return 0;
3206	}
3207	return 1;
3208}
3209
3210ibecome(Proc *proc)
3211{
3212	int nargs;
3213	int (**newpc)();
3214	SWord oldfp, oldpc, *oldresultaddr, *newresultaddr;
3215	Store *s;
3216	nargs=*--proc->sp/LWS;
3217	nargs+=2;	/* includes result and sym; add pc, fp */
3218	s=(Store *)*--proc->sp;
3219	if(--(s->ref)==0)
3220		rpanic("ibecome ref==0");
3221	newpc=((int (**)())s->data);
3222	oldfp=proc->fp[0];
3223	oldpc=proc->fp[-1];
3224	*proc->sp++=oldpc;
3225	*proc->sp++=oldfp;
3226	oldresultaddr=proc->fp-3-(long)(*++proc->pc)/LWS;
3227	newresultaddr=proc->sp-nargs;
3228	memcpy((char *)oldresultaddr, (char *)newresultaddr, LWS*nargs);
3229	/* args in place.  do the call by hand, jmp to pushfp */
3230	proc->sp=oldresultaddr+(nargs-2);
3231	*proc->sp++=oldpc;
3232	proc->fp=(SWord *)oldfp;
3233	proc->pc=newpc-1;
3234	return 1;
3235}
3236
3237ipushfp(Proc *proc)
3238{
3239	int nauto;
3240	*proc->sp=(SWord)proc->fp;
3241	proc->fp=proc->sp++;
3242	nauto=((SWord)*++proc->pc)/WS;
3243	while(nauto--)
3244		*proc->sp++=0;
3245	if(proc->sp>=&proc->stack[NSTACK])
3246		rerror("stack overflow");
3247	return 1;
3248}
3249
3250icall(Proc *proc)
3251{
3252	int (**newpc)();
3253	Store *s;
3254	s=(Store *)*--proc->sp;
3255	if(--(s->ref)==0)
3256		rpanic("icall ref==0");
3257	newpc=((int (**)())s->data);
3258	*proc->sp++=(SWord)proc->pc;
3259	proc->pc=newpc-1;
3260	return 1;
3261}
3262#include "node.h"
3263#include "symbol.h"
3264#include "alloc.h"
3265#include "ydefs.h"
3266#include "word.h"
3267#include "store.h"
3268#include <libc.h>
3269
3270extern int	nscope;
3271
3272declare(Node *n, int stclass, int dotypchk, int docomp)
3273{
3274	extern int iflag;
3275	if(n==0)
3276		return;
3277	if(n->t==NList){
3278		declare(n->l, stclass, dotypchk, docomp);
3279		declare(n->r, stclass, dotypchk, docomp);
3280		return;
3281	}
3282	if(n->t==NDeclsc){
3283		declare(n->l, n->o.i, dotypchk, docomp);
3284		return;
3285	}
3286	if(dotypchk)
3287		type(n->o.n, 0);
3288	if(n->r==0){
3289		if(n->o.n==0)
3290			panic("declare: no type");
3291		if(n->o.n->t==NMk && n->o.n->l==0)
3292			lerror(n, "can't derive type in declaration");
3293		n->r=dupnode(etypeof(n->o.n));
3294	}
3295	if(dotypchk){
3296		type(n->r, 0);
3297		if(n->o.n){
3298			/*
3299			 * Make it a mk
3300			 */
3301			if(n->o.n->t!=NMk)
3302				n->o.n=new(NMk, (Node *)0, n->o.n, (Node *)0);
3303			/*
3304			 * Default type for mk
3305			 */
3306			if(n->o.n->l==0)
3307				n->o.n->l=dupnode(n->r);
3308			else if(!compattype(n->r, n->o.n->l))
3309				lerror(n, "type clash in declaration (%t %t)\n",
3310					n->r->o.t, etypeof(n->o.n)->o.t);
3311			mkcheck(n->o.n->l, n->o.n->r);
3312		}
3313	}
3314	if(docomp && n->o.n){
3315		if(dotypchk)	/* top level declaration */
3316			n->o.n=constants(n->o.n);
3317		gen(n->o.n, 1);
3318		dupgen(n->r, length(n->l)-1);
3319	}else
3320		docomp=0;
3321	dcl(n->l, n->r, stclass, n->o.n, docomp);
3322	if(n->o.n && docomp && nscope==0){
3323		if(iflag)
3324			idump();
3325		execute();
3326	}
3327}
3328
3329dcl(id, typ, stclass, val, docomp)
3330	Node *id, *typ, *val;
3331{
3332	if(id->t==NList){
3333		dcl(id->l, typ, stclass, val, docomp);
3334		dcl(id->r, typ, stclass, val, docomp);
3335		return;
3336	}
3337	if(typ->o.t==TID && typ->l->o.s->val->type->o.t!=TType)
3338		error("%m not a type", typ->l);
3339	if(id->t!=NID)
3340		panic("dcl not ID");
3341	pushval(id->o.s, dupnode(typ));
3342	if(stclass&SCbltin)
3343		id->o.s->val->store.l=bltinval(id->o.s->name, typ);
3344	if(docomp)
3345		lgen(id);
3346	id->o.s->val->stclass=stclass;
3347}
3348
3349/*
3350 * To compile this
3351 * 	rec {
3352 * 		x : chan of T = f(x,y);
3353 * 		y : chan of T = g(x,y);
3354 * 	};
3355 * convert it to this
3356 * 	x : chan of T = mk();
3357 * 	y : chan of T = mk();
3358 * 	x1 : chan of T = f(x,y);
3359 * 	y1 : chan of T = g(x,y);
3360 * 	x <- x1;
3361 * 	y <- y1;
3362 *	toss x1, y1;
3363 * where the operator x <- x1 means copy the representation of x1 into x.
3364 *
3365 *	rec type T: struct of { t:T; };
3366 *
3367 * is handled similarly.
3368 */
3369
3370Node *
3371op1(Node *n)
3372{
3373	Node *m;
3374	if(n->t==NDeclsc){
3375		m=op1(n->l);
3376		return newi(NDeclsc, m, (Node *)0, n->o.i);
3377	}
3378	if(n->r==0){
3379		if(n->o.n && (n->o.n->t==NProg || (n->o.n->t==NMk && n->o.n->l)))
3380			n->r=dupnode(n->o.n->l);
3381		else
3382			lerror(n, "can't deduce type for rec decl");
3383	}else if(n->r->o.t==TType){
3384		m=newi(NType, (Node *)0, (Node *)0, n->r->l->o.t);
3385		m=new(NDecl, dupnode(n->l), m, (Node *)0);
3386		return m;
3387	}
3388	m=new(NMk, dupnode(n->r), (Node *)0, (Node *)0);
3389	m=new(NDecl, dupnode(n->l), dupnode(n->r), m);
3390	return m;
3391}
3392
3393Node *
3394op2(Node *n)
3395{
3396	Node *m;
3397	char s[Namesize+2];
3398	if(n->t==NDeclsc){
3399		m=op2(n->l);
3400		return newi(NDeclsc, m, (Node *)0, n->o.i);
3401	}
3402	if(n->l->t==NList)
3403		error("no identifier lists in rec's, please");
3404	strcpy(s+1, n->l->o.s->name);
3405	s[0]='*';
3406	m=new(NDecl, idnode(lookup(s, ID)), dupnode(n->r), dupnode(n->o.n));
3407	return m;
3408}
3409
3410Node *
3411op3(Node *n)
3412{
3413	Node *m;
3414	char s[Namesize+2];
3415	if(n->t==NDeclsc)
3416		return op3(n->l);
3417	if(n->l->t==NList)
3418		error("no lists in rec's, please");
3419	strcpy(s+1, n->l->o.s->name);
3420	s[0]='*';
3421	m=new(NSmash, idnode(lookup(s+1, ID)), idnode(lookup(s, ID)), (Node *)0);
3422	return m;
3423}
3424
3425Node *
3426rewr(Node *n, Node *(*f)())
3427{
3428	if(n->t==NList)
3429		return new(NList, rewr(n->l, f), rewr(n->r, f), (Node *)0);
3430	return (*f)(n);
3431}
3432
3433recrewrite(Node *n)
3434{
3435	Node *n1, *n2, *n3;
3436	n1=rewr(n->l, op1);
3437	n2=rewr(n->l, op2);
3438	n3=rewr(n->l, op3);
3439	freenode(n->l);
3440	n->t=NList;
3441	n->r=n3;
3442	n->l=new(NList, n1, n2, (Node *)0);
3443	ndump(n);
3444}
3445
3446/*
3447 *
3448 * To compile this
3449 *
3450 *	prog(a:int){
3451 *		begin prog(b:int){ f(a, b); }(b);
3452 *	}
3453 *
3454 * convert it to this
3455 *
3456 *	prog(a:int){
3457 *		begin prog(b:int, a:int){ f(a, b); }(b, a);
3458 *	}
3459 *
3460 */
3461
3462Node 	*begf;
3463Node	*bega;
3464int	fscope;
3465int	progerr;
3466
3467proglocals(Node *n)
3468{
3469	progerr=1;
3470	pushscope();
3471	fscope=nscope;
3472	begf=n->l->l;
3473	bega=0;
3474	dclformals(begf);
3475	progid(n->r);
3476	popscope();
3477}
3478
3479begrewrite(Node *n)
3480{
3481	progerr=0;
3482	pushscope();
3483	fscope=nscope;
3484	begf=n->l->l->l;
3485	bega=n->r;
3486	dclformals(begf);
3487	progid(n->l->r);
3488	popscope();
3489	n->l->l->l=begf;
3490	n->r=bega;
3491}
3492
3493addformal(Node *n)
3494{
3495	Node *nf;
3496	if(!alreadyformal(n, begf)){
3497		nf=new(NFormal, dupnode(n), dupnode(n->o.s->val->type), (Node *)0);
3498		if(begf)
3499			begf=new(NList, begf, nf, (Node *)0);
3500		else
3501			begf=nf;
3502		nf=dupnode(n);
3503		if(bega)
3504			bega=new(NExprlist, bega, nf, (Node *)0);
3505		else
3506			bega=nf;
3507	}
3508}
3509
3510alreadyformal(Node *n, Node *f)
3511{
3512	if(f==0)
3513		return 0;
3514	if(f->t==NList)
3515		return alreadyformal(n, f->l) || alreadyformal(n, f->r);
3516	return strcmp(n->o.s->name, f->l->o.s->name)==0;
3517}
3518
3519progid(Node *n)
3520{
3521	if(n==0)
3522		return;
3523	switch(n->t){
3524	case NArrayref:
3525	case NArraycom:
3526	case NBecome:
3527	case NBegin:
3528	case NCall:
3529	case NCase:
3530		break;
3531	case NDecl:
3532		progid(n->r);
3533		progid(n->o.n);
3534		declare(n, 0, 0, 0);
3535		return;
3536	case NDeclsc:
3537	case NDefault:
3538		break;
3539	case NElem:
3540		return;
3541	case NExpr:
3542	case NExprlist:
3543	case NFormal:
3544		break;
3545	case NID:
3546		if(n->o.s->val)
3547		if(0<n->o.s->val->scope && n->o.s->val->scope<fscope){
3548			if(progerr)
3549				lerror(n, "%m not in an accessible scope", n);
3550			addformal(n);
3551		}
3552		return;
3553	case NLabel:
3554	case NList:
3555	case NLoop:
3556		break;
3557	case NLoopexpr:
3558		progid(n->o.n);
3559		break;
3560	case NIf:
3561		progid(n->o.n);
3562		break;
3563	case NMk:
3564		break;
3565	case NNum:
3566		return;
3567	case NProg:
3568		pushscope();
3569		dclformals(n->l->l);
3570		progid(n->r);
3571		popscope();
3572		return;
3573	case NResult:
3574		break;
3575	case NScope:
3576		pushscope();
3577		progid(n->l);
3578		popscope();
3579		return;
3580	case NSelect:
3581		break;
3582	case NSmash:
3583		return;	/* ?? */
3584	case NString:
3585		return;
3586	case NSwitch:
3587	case NStructref:
3588		break;
3589	case NType:
3590		break;
3591	case NUnit:
3592		return;
3593	case NVal:
3594		break;
3595	default:
3596		fprint(2, "can't progid node %n\n", n->t);
3597		return;
3598	}
3599	progid(n->l);
3600	progid(n->r);
3601}
3602
3603#include "nodenames.h"
3604#include "typenames.h"
3605#include "errjmp.h"
3606#include "node.h"
3607#include "symbol.h"
3608#include "ydefs.h"
3609#include <libc.h>
3610
3611lerror(Node *n, char *s, a, b, c, d, e, f)
3612{
3613	lfileline(n->line);
3614	fprint(2, s, a, b, c, d, e, f);
3615	if(s[strlen(s)-1]!='\n')
3616		fprint(2, "\n");
3617	errflush();
3618	errjmp();
3619}
3620
3621error(char *s, a, b, c, d, e, f)
3622{
3623	fileline();
3624	fprint(2, s, a, b, c, d, e, f);
3625	if(s[strlen(s)-1]!='\n')
3626		fprint(2, "\n");
3627	errflush();
3628	errjmp();
3629}
3630
3631rerror(char *s, a, b, c, d, e, f)
3632{
3633	fileline();
3634	fprint(2, s, a, b, c, d, e, f);
3635	fprint(2, "\n");
3636	processes(0);
3637	errflush();
3638	errjmp();
3639}
3640
3641warn(char *s, a, b, c, d, e, f)
3642{
3643	fileline();
3644	fprint(2, "warning: ");
3645	fprint(2, s, a, b, c, d, e, f);
3646	fprint(2, "\n");
3647}
3648
3649panic(char *s, a, b, c, d, e, f)
3650{
3651	fileline();
3652	fprint(2, "internal error: ");
3653	fprint(2, s, a, b, c, d, e, f);
3654	fprint(2, "\n");
3655	abort();
3656}
3657
3658rpanic(char *s, a, b, c, d, e, f)
3659{
3660	fileline();
3661	processes(0);
3662	fprint(2, "internal error: ");
3663	fprint(2, s, a, b, c, d, e, f);
3664	fprint(2, "\n");
3665	abort();
3666}
3667
3668bconv(int *o, int f1, int f2)
3669{
3670	extern int printcol;
3671	while(printcol<*o-8)
3672		strconv("\t", f1, f2);
3673	strconv("        "+(8-(*o-printcol)), f1, f2);
3674	return sizeof(int);
3675}
3676
3677nconv(int *o, int f1, int f2)
3678{
3679	if(*o<0 || sizeof(Ntypename)/sizeof(Ntypename[0])<=*o)
3680		strconv("mystery node", f1, f2);
3681	else
3682		strconv(Ntypename[*o], f1, f2);
3683	return sizeof(int);
3684}
3685
3686tconv(int *o, int f1, int f2)
3687{
3688	if(*o<0 || sizeof(Ttypename)/sizeof(Ttypename[0])<=*o)
3689		strconv("mystery type", f1, f2);
3690	else
3691		strconv(Ttypename[*o], f1, f2);
3692	return sizeof(int);
3693}
3694
3695char	bufx[128][10];
3696int	bufno=9;
3697
3698char *
3699prbuf(){
3700	if(++bufno==10)
3701		bufno=0;
3702	return bufx[bufno];
3703}
3704
3705econv(int *o, int f1, int f2)
3706{
3707	char *buf=prbuf();
3708	char *x;
3709	int t=*o;
3710	if(t<128 && strchr("+-*/%|&^~?!><=", t))
3711		sprint(buf, "%c", t);
3712	else{
3713		switch(t){
3714		case GE:
3715			x=">=";
3716			break;
3717		case LE:
3718			x="<=";
3719			break;
3720		case NE:
3721			x="!=";
3722			break;
3723		case EQ:
3724			x="==";
3725			break;
3726		case ANDAND:
3727			x="&&";
3728			break;
3729		case OROR:
3730			x="||";
3731			break;
3732		case REF:
3733			x="ref";
3734			break;
3735		case LEN:
3736			x="len";
3737			break;
3738		case UMINUS:
3739			x="unary -";
3740			break;
3741		case RCV:
3742			x="rcv";
3743			break;
3744		case SND:
3745			x="send";
3746			break;
3747		case LSH:
3748			x="<<";
3749			break;
3750		case RSH:
3751			x=">>";
3752			break;
3753		case DEC:
3754			x="--";
3755			break;
3756		case INC:
3757			x="++";
3758			break;
3759		default:
3760			x="mystery expression";
3761			break;
3762		}
3763		strcpy(buf, x);
3764	}
3765	strconv(buf, f1, f2);
3766	return sizeof(int);
3767}
3768
3769mconv(int *o, int f1, int f2)
3770{
3771	char *buf=prbuf();
3772	Node *n=(Node *)*o;
3773	switch(n->t){
3774!
3775			;;
3776		g7.dat)	cat <<'!'
3777#pragma prototyped
3778
3779#include "sed.h" /* define sed stuff */
3780
3781Text retemp;	/* holds a rewritten regex, without delimiter */
3782
3783int
3784recomp(Text *rebuf, Text *t, int sub)
3785{
3786	static int lastre;
3787	int code;
3788	int c;
3789	int n;
3790	if(!(c = *t->w) || c == '\n' || !(n = *(t->w + 1)) || n == '\n')
3791		syntax("unterminated regular expression");
3792	else if (c != n) {
3793		assure(rebuf, sizeof(regex_t));
3794		if (code = regcomp((regex_t*)rebuf->w,(char*)t->w,reflags|REG_DELIMITED|REG_MUSTDELIM|((reflags&REG_LENIENT)?0:REG_ESCAPE)))
3795			badre((regex_t*)rebuf->w,code);
3796		lastre = rebuf->w - rebuf->s;
3797		t->w += ((regex_t*)rebuf->w)->re_npat;
3798		rebuf->w += sizeof(regex_t);
3799	} else if(rebuf->w == rebuf->s)
3800		syntax("no previous regular expression");
3801	else {
3802		if (sub) {
3803			assure(rebuf, sizeof(regex_t));
3804			if (code = regdup(readdr(lastre), (regex_t*)rebuf->w))
3805				badre((regex_t*)rebuf->w,code);
3806			lastre = rebuf->w - rebuf->s;
3807			rebuf->w += sizeof(regex_t);
3808		}
3809		t->w += 2;
3810	}
3811	return lastre;
3812}
3813
3814void
3815reerror(regex_t* re, int code)
3816{
3817	if(code && code != REG_NOMATCH) {
3818		char buf[UCHAR_MAX+1];
3819		regerror(code, re, buf, sizeof(buf));
3820		error(3, "regular expression execution error: %s", buf);
3821	}
3822}
3823
3824int
3825reexec(regex_t* re, char* s, size_t n, size_t nmatch, regmatch_t* match, int flags)
3826{
3827	int code;
3828	if((code = regnexec(re, s, n, nmatch, match, flags)) && code != REG_NOMATCH)
3829		reerror(re, code);
3830	return code;
3831}
3832
3833int
3834substitute(regex_t *re, Text *data)
3835{
3836	int n;
3837	regmatch_t matches[10];
3838	if(reexec(re, (char*)data->s, data->w - data->s, elementsof(matches), matches, 0))
3839		return 0;
3840	if(n = regsubexec(re, (char*)data->s, elementsof(matches), matches)) {
3841		reerror(re, n);
3842		return 0;
3843	}
3844	n = re->re_sub->re_len;
3845	assure(data, n+1);
3846	memcpy(data->s, re->re_sub->re_buf, n+1);
3847	data->w = data->s + n;
3848	return 1;
3849}
3850!
3851			;;
3852		pat.dat)for ((i = 900; i <= 1000; i++))
3853			do	print $i
3854			done
3855			;;
3856		x.dat)	print x
3857			;;
3858		y.dat)	print y
3859			;;
3860		xyz.dat)print x
3861			print y
3862			print z
3863			;;
3864		AB.dat|BC.dat)
3865			print $f
3866			;;
3867		esac > $f
3868	done
3869}
3870
3871TEST 01 '-q, -v combinations'
3872
3873	EXEC	-q . /dev/null
3874		OUTPUT -
3875		EXIT '[12]'
3876	EXEC	-q -v . /dev/null
3877	EXEC	-q -v .
3878		INPUT - 'x'
3879	EXEC	-q .
3880		EXIT 0
3881
3882TEST 02 'BRE, ERE, -x, -v, -e sanity'
3883
3884	DO	DATA big.dat
3885	EXEC	'^10*$' big.dat
3886		OUTPUT - $'1\n10\n100\n1000\n10000'
3887	EXEC	-x '10*' big.dat
3888	EXEC	-x -e '10*' big.dat
3889	EXEC	-E '^1(00)*0?$' big.dat
3890	EXEC	-x '[^[:digit:]]*[[=1=]][[.0.]]\{0,\}' big.dat
3891	EXEC	-E -x '[^[:digit:]]*[[=1=]][[.0.]]{0,}' big.dat
3892	EXEC	-E -e $'^1((0)\\2)*$' -e $'^10((0)\\2)*$' big.dat
3893	EXEC	-E -e $'^1((0)\\2)*$\n^10((0)\\2)*$' big.dat
3894	EXEC	-E -e $'^1((0)\\2)*$|^10((0)\\4)*$' big.dat
3895	EXEC	-e $'^1\\(\\(0\\)\\2\\)*$' -e $'^10\\(\\(0\\)\\2\\)*$' big.dat
3896	EXEC	-e $'^1\\(\\(0\\)\\2\\)*$\n^10\\(\\(0\\)\\2\\)*$' big.dat
3897	EXEC	-e '^1\(\(0\)\2\)*$' -e '^10\(\(0\)\2\)*$' big.dat
3898	EXEC	-x -e '1\(\(0\)\2\)*' -e '10\(\(0\)\2\)*' big.dat
3899	EXEC	-E -v '[2-9]|1.*1|^0' big.dat
3900	EXEC	-E -x '1(0{0,2}){1,2}' big.dat
3901	EXEC	-E '1*^10*$' big.dat
3902	EXEC	-E -x 'a.|b'
3903		INPUT - $'a\nb\nab\nba'
3904		OUTPUT - $'b\nab'
3905	EXEC	'state.var.folder'
3906		INPUT - $'XXXXXXXXXXXXXXXXXXXXXXX\nfolder state.var.folder'
3907		OUTPUT - $'folder state.var.folder'
3908	EXEC	'XXXXXX'
3909		INPUT - $'..XXXXXX'
3910		OUTPUT - $'..XXXXXX'
3911	EXEC	-v /usr/include
3912		INPUT - $'aaa\n/usr/include/signal.h\nzzz'
3913		OUTPUT - $'aaa\nzzz'
3914	EXEC	-E -e $'(abc)' -e $'(def)\\1'
3915		INPUT - $'abc\ndefdef'
3916		OUTPUT - $'abc\ndefdef'
3917	EXEC	-E -e $'(abc)\n(def)\\1'
3918	EXEC	-E -e $'(abc)|(def)\\2'
3919	EXEC	-v 1
3920		INPUT - $'a\n'
3921		OUTPUT - $'a\n'
3922	EXEC	-v 12
3923	EXEC	-v 123
3924	EXEC	-v 1234
3925	EXEC	-v 123
3926		INPUT -n - $'x\n\nx'
3927		OUTPUT - $'x\n\nx'
3928	EXEC	-v 123
3929		INPUT - $'x\n\nx'
3930	EXEC	-v 123
3931		INPUT - $'x\n\nx\n'
3932		OUTPUT - $'x\n\nx\n'
3933	EXEC	-v 1
3934		INPUT - $''
3935		OUTPUT - $''
3936	EXEC	-v 12
3937	EXEC	-v 123
3938	EXEC	-v 1234
3939
3940TEST 03 'data chars except \0 \n'
3941
3942	DO	DATA chars.dat
3943	EXEC	-c . chars.dat
3944		OUTPUT - 254
3945	EXEC	-c -e '' chars.dat
3946	EXEC	-c -e $'\na' chars.dat
3947	EXEC	-c -e $'a\n' chars.dat
3948	EXEC	-c -e $'a\n' chars.dat
3949	EXEC	-c -e 'a' chars.dat
3950		OUTPUT - 1
3951	EXEC	-c -x '' chars.dat
3952		EXIT 1
3953		OUTPUT - 0
3954	EXEC	-E -c -x '' chars.dat
3955
3956TEST 04 'char class on data chars except \0 \n'
3957
3958	DO	DATA chars.dat
3959	EXEC	-c '[[:alnum:]]' chars.dat
3960		OUTPUT - 62
3961	EXEC	-c -i '[[:alnum:]]' chars.dat
3962	EXEC	-c '[[:alpha:]]' chars.dat
3963		OUTPUT - 52
3964	EXEC	-c '[[:blank:]]' chars.dat
3965		OUTPUT - 2
3966	EXEC	-c '[[:cntrl:]]' chars.dat
3967		OUTPUT - 31
3968	EXEC	-c '[[:digit:]]' chars.dat
3969		OUTPUT - 10
3970	EXEC	-c '[[:graph:]]' chars.dat
3971		OUTPUT - 94
3972	EXEC	-c '[[:lower:]]' chars.dat
3973		OUTPUT - 26
3974	EXEC	-c '[[:upper:]]' chars.dat
3975	EXEC	-c '[[:print:]]' chars.dat
3976		OUTPUT - 95
3977	EXEC	-c '[[:punct:]]' chars.dat
3978		OUTPUT - 32
3979	EXEC	-c '[[:space:]]' chars.dat
3980		OUTPUT - 5
3981	EXEC	-c '[[:xdigit:]]' chars.dat
3982		OUTPUT - 22
3983	EXEC	-c -i '[[:alpha:]]' chars.dat
3984		OUTPUT - 52
3985	EXEC	-c -i '[[:lower:]]' chars.dat
3986	EXEC	-c -i '[[:upper:]]' chars.dat
3987
3988TEST 05 '-f, -F, big pattern'
3989
3990	DO	DATA big.dat pat.dat
3991	DO	{ cp big.dat INPUT ;}
3992	EXEC	-c -f pat.dat
3993		OUTPUT - 1902
3994	EXEC	-c -E -fpat.dat
3995	EXEC	-c -F -fpat.dat
3996	EXEC	-v -c -f pat.dat
3997		OUTPUT - 8099
3998	EXEC	-v -c -F -fpat.dat
3999	EXEC	-v -c -E -fpat.dat
4000	EXEC	-c -x -fpat.dat
4001		OUTPUT - 101
4002	EXEC	-c -x -F -f pat.dat
4003	EXEC	-c -x -E -f pat.dat
4004	EXEC	-v -c -x -fpat.dat
4005		OUTPUT - 9900
4006	EXEC	-v -c -x -F -f pat.dat
4007	EXEC	-v -c -x -E -f pat.dat
4008
4009TEST 06 '-f, -F, big pattern'
4010
4011	DO	DATA big.dat
4012	EXEC	-n '\(.\)\(.\)\2\1' big.dat
4013		IGNORE	OUTPUT
4014	DO	cp OUTPUT out
4015	EXEC	-c . out
4016		OUTPUT - 91
4017	DO	cp out INPUT
4018	EXEC	-l . out
4019		OUTPUT - out
4020	EXEC	-l .
4021		OUTPUT - '(standard input)'
4022	EXEC	-l . big.dat big.dat
4023		OUTPUT - $'big.dat\nbig.dat'
4024	EXEC	-l . /dev/null big.dat big.dat /dev/null
4025	EXEC	-q -l . big.dat big.dat
4026		OUTPUT -
4027	EXEC	-c . big.dat big.dat
4028		OUTPUT - $'big.dat:10001\nbig.dat:10001'
4029	EXEC	-c . /dev/null
4030		OUTPUT - 0
4031		EXIT	1
4032	EXEC	-v -l . big.dat big.dat
4033		OUTPUT -
4034
4035TEST 07 '-h, -H'
4036
4037	DO	DATA x.dat xyz.dat
4038	EXEC	z x.dat xyz.dat
4039		OUTPUT - $'xyz.dat:z'
4040	EXEC	-h z x.dat xyz.dat
4041		OUTPUT - $'z'
4042	EXEC	-H z xyz.dat
4043		OUTPUT - $'xyz.dat:z'
4044
4045TEST 08 'exit status, -s, -q, -e, -c, -l combinations'
4046
4047	IGNORE	OUTPUT ERROR
4048	DO	DATA x.dat AB.dat BC.dat
4049	DO	for opt in -e -c -l
4050		do
4051
4052		EXEC	$opt . /dev/null
4053			EXIT 1
4054		EXEC	-q $opt . /dev/null
4055			EXIT 1
4056		EXEC	$opt .
4057			INPUT -	x
4058			EXIT 0
4059		EXEC	-q $opt .
4060			INPUT -	x
4061			EXIT 0
4062		EXEC	$opt . not_a_file
4063			EXIT '[!01]'
4064		EXEC	-q $opt . not_a_file
4065			EXIT 1
4066		EXEC	-s $opt . not_a_file
4067			EXIT 2
4068		EXEC	-q -s $opt . not_a_file
4069			EXIT 1
4070		EXEC	-s $opt . x.dat not_a_file
4071			EXIT 2
4072		EXEC	-q -s $opt . x.dat not_a_file
4073			EXIT 0
4074		EXEC	-q -s $opt . not_a_file x.dat
4075			EXIT 0
4076
4077		done
4078	EXEC	-l A AB.dat BC.dat
4079		OUTPUT - $'AB.dat'
4080		EXIT 0
4081	EXEC	-L C AB.dat BC.dat
4082	EXEC	-v -l C AB.dat BC.dat
4083	EXEC	-l C AB.dat BC.dat
4084		OUTPUT - $'BC.dat'
4085	EXEC	-L A AB.dat BC.dat
4086	EXEC	-v -l A AB.dat BC.dat
4087	EXEC	-l B AB.dat BC.dat
4088		OUTPUT - $'AB.dat\nBC.dat'
4089	EXEC	-L Z AB.dat BC.dat
4090	EXEC	-l Z AB.dat BC.dat
4091		OUTPUT -
4092		EXIT 1
4093	EXEC	-L B AB.dat BC.dat
4094
4095TEST 09 'file not found'
4096
4097	DIAGNOSTICS
4098	DO	DATA x.dat y.dat
4099	EXEC	y nope.dat
4100		EXIT 2
4101	EXEC	-F -f nope.dat x.dat
4102		EXIT 2
4103	EXEC	-F -f nope.dat -f x.dat xyz.dat
4104		EXIT 2
4105	EXEC	y x.dat nope.dat y.dat
4106		OUTPUT - $'y.dat:y'
4107		EXIT 2
4108
4109TEST 10 'simple gre tests from Andrew Hume'
4110
4111	EXEC	-q $'a'
4112		INPUT - $'a'
4113		OUTPUT -
4114	EXEC	-q $'a'
4115		INPUT - $'ba'
4116	EXEC	-q $'a'
4117		INPUT - $'bab'
4118	EXEC	-q $'.'
4119		INPUT - $'x'
4120	EXEC	-q $'.'
4121		INPUT - $'xxx'
4122	EXEC	-q $'.a'
4123		INPUT - $'xa'
4124	EXEC	-q $'.a'
4125		INPUT - $'xxa'
4126	EXEC	-q $'.a'
4127		INPUT - $'xax'
4128	EXEC	-q $'$'
4129		INPUT - $'x'
4130	EXEC	-q $'$'
4131		INPUT - $''
4132	EXEC	-q $'.$'
4133		INPUT - $'x'
4134	EXEC	-q $'a$'
4135		INPUT - $'a'
4136	EXEC	-q $'a$'
4137		INPUT - $'ba'
4138	EXEC	-q $'a$'
4139		INPUT - $'bbba'
4140	EXEC	-q $'^'
4141		INPUT - $'x'
4142	EXEC	-q $'^'
4143		INPUT - $''
4144	EXEC	-q $'^'
4145		INPUT - $'^'
4146	EXEC	-q $'^a$'
4147		INPUT - $'a'
4148	EXEC	-q $'^a.$'
4149		INPUT - $'ax'
4150	EXEC	-q $'^a.$'
4151		INPUT - $'aa'
4152	EXEC	-q $'^$'
4153		INPUT - $''
4154	EXEC	-q $'^.a'
4155		INPUT - $'xa'
4156	EXEC	-q $'^.a'
4157		INPUT - $'xaa'
4158	EXEC	-q $'^.*a'
4159		INPUT - $'a'
4160	EXEC	-q $'^.*a'
4161		INPUT - $'xa'
4162	EXEC	-q $'^.*a'
4163		INPUT - $'xxxxxxa'
4164	EXEC	-q -E $'^.+a'
4165		INPUT - $'xa'
4166	EXEC	-q -E $'^.+a'
4167		INPUT - $'xxxxxxa'
4168	EXEC	-q $'a*'
4169		INPUT - $''
4170	EXEC	-q $'a*'
4171		INPUT - $'a'
4172	EXEC	-q $'a*'
4173		INPUT - $'aaaa'
4174	EXEC	-q $'a*'
4175		INPUT - $'xa'
4176	EXEC	-q $'a*'
4177		INPUT - $'xxxx'
4178	EXEC	-q $'aa*'
4179		INPUT - $'a'
4180	EXEC	-q $'aa*'
4181		INPUT - $'aaa'
4182	EXEC	-q $'aa*'
4183		INPUT - $'xa'
4184	EXEC	-q $'\\$'
4185		INPUT - $'x$'
4186	EXEC	-q $'\\$'
4187		INPUT - $'$'
4188	EXEC	-q $'\\$'
4189		INPUT - $'$x'
4190	EXEC	-q $'\\.'
4191		INPUT - $'.'
4192	EXEC	-q -G $'.^$'
4193		INPUT - $'a^'
4194	EXEC	-q -G $'^x$'
4195		INPUT - $'x'
4196	EXEC	-q -G $'a\\$'
4197		INPUT - $'a$'
4198	EXEC	-q -G $'\\(ab\\)$'
4199		INPUT - $'cab'
4200	EXEC	-q -G $'\\(ab\\)$'
4201		INPUT - $'ab'
4202	EXEC	-q -E $'xr+y'
4203		INPUT - $'xry'
4204	EXEC	-q -E $'xr+y'
4205		INPUT - $'xrry'
4206	EXEC	-q -E $'xr+y'
4207		INPUT - $'xrrrrrry'
4208	EXEC	-q -E $'xr?y'
4209		INPUT - $'xy'
4210	EXEC	-q -E $'xr?y'
4211		INPUT - $'xry'
4212	EXEC	-q -E $'a(bc|def)g'
4213		INPUT - $'abcg'
4214	EXEC	-q -E $'a(bc|def)g'
4215		INPUT - $'adefg'
4216	EXEC	-q $'[0-9]'
4217		INPUT - $'1'
4218	EXEC	-q $'[0-9]'
4219		INPUT - $'567'
4220	EXEC	-q $'[0-9]'
4221		INPUT - $'x0y'
4222	EXEC	-q $'[^0-9]'
4223		INPUT - $'abc'
4224	EXEC	-q $'[^0-9]'
4225		INPUT - $'x0y'
4226	EXEC	-q -E $'x[0-9]+y'
4227		INPUT - $'x0y'
4228	EXEC	-q -E $'x[0-9]+y'
4229		INPUT - $'x23y'
4230	EXEC	-q -E $'x[0-9]+y'
4231		INPUT - $'x12345y'
4232	EXEC	-q -E $'x[0-9]?y'
4233		INPUT - $'xy'
4234	EXEC	-q -E $'x[0-9]?y'
4235		INPUT - $'x1y'
4236	EXEC	-q -i $'X'
4237		INPUT - $'x'
4238	EXEC	-q -x $'read'
4239		INPUT - $'read'
4240	EXEC	-q -xF $'read'
4241		INPUT - $'read'
4242	EXEC	-q -F $'read'
4243		INPUT - $'read'
4244	EXEC	-q -F $'read'
4245		INPUT - $'xy read'
4246	EXEC	-q -F $'read'
4247		INPUT - $'x read y'
4248	EXEC	-q -F $'read'
4249		INPUT - $'xread'
4250	EXEC	-q -F $'read'
4251		INPUT - $'readx'
4252	EXEC	-q $'[.]de..'
4253		INPUT - $'.dexx'
4254	EXEC	-q $'[.]de..'
4255		INPUT - $'.deyyy'
4256	EXEC	-q -G $'^|s'
4257		INPUT - $'|sec'
4258	EXEC	-q -G $'..B'
4259		INPUT - $'CDAB'
4260	EXEC	-q -G $'$.*tt.*\\$'
4261		INPUT - $'$tt$'
4262	EXEC	-q -E $'^([a-z]+)\\1$'
4263		INPUT - $'vivi'
4264	EXEC	-q -E $'([a-z]+)\\1'
4265		INPUT - $'vivi'
4266	EXEC	-q -E $'([a-z]+)\\1'
4267		INPUT - $'vivify'
4268	EXEC	-q -E $'([a-z]+)\\1'
4269		INPUT - $'revivi'
4270	EXEC	-q -G $'\\(....\\).*\\1'
4271		INPUT - $'beriberi'
4272	EXEC	-q -E $'(....).*\\1'
4273		INPUT - $'beriberi'
4274	EXEC	-q $'^$'
4275		INPUT - $''
4276	EXEC	-q -G $'^$'
4277		INPUT - $''
4278	EXEC	-q $'[ab]\\{2\\}k'
4279		INPUT - $'abk'
4280	EXEC	-q $'[ab]\\{2\\}k'
4281		INPUT - $'xyaak'
4282	EXEC	-q $'[ab]\\{2\\}k'
4283		INPUT - $'zabak'
4284	EXEC	-q $'[ab]\\{2,\\}d'
4285		INPUT - $'abd'
4286	EXEC	-q $'[ab]\\{2,\\}d'
4287		INPUT - $'abababad'
4288	EXEC	-q $'q[ab]\\{2,4\\}d'
4289		INPUT - $'qabd'
4290	EXEC	-q $'q[ab]\\{2,4\\}d'
4291		INPUT - $'qababd'
4292	EXEC	-q $'q[ab]\\{2,4\\}d'
4293		INPUT - $'qaaad'
4294	EXEC	-q -E $'a[]]b'
4295		INPUT - $'a]b'
4296	EXEC	-q -G $'a[]]b'
4297		INPUT - $'a]b'
4298	EXEC	-q -E $'a[^]b]c'
4299		INPUT - $'adc'
4300	EXEC	-q -G $'a[^]b]c'
4301		INPUT - $'adc'
4302	EXEC	-q -i $'angel[^e]'
4303		INPUT - $'angelo'
4304	EXEC	-q -i $'angel[^e]'
4305		INPUT - $'ANGELH'
4306	EXEC	-q -G $'^[^-].*>'
4307		INPUT - $'abc>'
4308	EXEC	-q -i $'^[A-Z]'
4309		INPUT - $'abc'
4310	EXEC	-q -i $'^[A-Z]'
4311		INPUT - $'ABC'
4312	EXEC	-q -i $'^[^A-Z]'
4313		INPUT - $'123'
4314	EXEC	-q -G $'|abc'
4315		INPUT - $'|abc'
4316	EXEC	-q -G $'\\(ac*\\)c*d[ac]*\\1'
4317		INPUT - $'acdacaaa'
4318	EXEC	-q -E $'(ac*)c*d[ac]*\\1'
4319		INPUT - $'acdacaaa'
4320	EXEC	-q -E $'ram|am'
4321		INPUT - $'am'
4322	EXEC	-q -E $'[a-za-za-za-za-za-za-za-za-za-z]'
4323		INPUT - $'for this line'
4324	EXEC	-q $'[a-za-za-za-za-za-za-za-za-za-z]'
4325		INPUT - $'for this line'
4326	EXEC	-q -E $'[a-za-za-za-za-za-za-za-za-z]'
4327		INPUT - $'but watch out'
4328	EXEC	-q $'[a-za-za-za-za-za-za-za-za-z]'
4329		INPUT - $'but watch out'
4330	EXEC	-q -E $'[ ]*([^ ]+)[ ]*'
4331		INPUT - $'foo'
4332	EXEC	-q -E $'[ ]*([^ ]+)[ ]*'
4333		INPUT - $'foo '
4334	EXEC	-q -E $'[ ]*([^ ]+)[ ]*([(].*[)])?'
4335		INPUT - $'foo'
4336	EXEC	-q -E $'[ ]*([^ ]+)[ ]*([(].*[)])?'
4337		INPUT - $'foo '
4338	EXEC	-q -E $'((foo)|(bar))!bas'
4339		INPUT - $'bar!bas'
4340	EXEC	-q -E $'((foo)|(bar))!bas'
4341		INPUT - $'foo!bar!bas'
4342	EXEC	-q -E $'((foo)|(bar))!bas'
4343		INPUT - $'bar!bas'
4344	EXEC	-q -E $'((foo)|(bar))!bas'
4345		INPUT - $'foo!bar!bas'
4346	EXEC	-q -E $'((foo)|bar)!bas'
4347		INPUT - $'bar!bas'
4348	EXEC	-q -E $'((foo)|bar)!bas'
4349		INPUT - $'foo!bar!bas'
4350	EXEC	-q -E $'(foo|(bar))!bas'
4351		INPUT - $'bar!bas'
4352	EXEC	-q -E $'(foo|(bar))!bas'
4353		INPUT - $'foo!bar!bas'
4354	EXEC	-q -E $'^([^!]+!)?([^!]+)$|^.+!([^!]+!)([^!]+)$'
4355		INPUT - $'bar!bas'
4356	EXEC	-q -E $'^[abf][0-9][0-9][0-9]([0-9]|(\\[[0-9]+\\]))'
4357		INPUT - $'b051[89]'
4358	EXEC	-q -E $'^[abf][0-9][0-9][0-9]([0-9]|(\\[[0-9]+\\]))'
4359		INPUT - $'b0123'
4360	EXEC	-q $'a'
4361		INPUT - $''
4362		EXIT 1
4363	EXEC	-q $'a'
4364		INPUT - $'x'
4365	EXEC	-q $'a'
4366		INPUT - $'xxxxx'
4367	EXEC	-q $'.'
4368		INPUT - $''
4369	EXEC	-q $'.a'
4370		INPUT - $'a'
4371	EXEC	-q $'.a'
4372		INPUT - $'ab'
4373	EXEC	-q $'.a'
4374		INPUT - $''
4375	EXEC	-q $'.$'
4376		INPUT - $''
4377	EXEC	-q $'a$'
4378		INPUT - $'ab'
4379	EXEC	-q $'a$'
4380		INPUT - $'x'
4381	EXEC	-q $'a$'
4382		INPUT - $''
4383	EXEC	-q $'^a$'
4384		INPUT - $'xa'
4385	EXEC	-q $'^a$'
4386		INPUT - $'ax'
4387	EXEC	-q $'^a$'
4388		INPUT - $'xax'
4389	EXEC	-q $'^a$'
4390		INPUT - $''
4391	EXEC	-q $'^a.$'
4392		INPUT - $'xa'
4393	EXEC	-q $'^a.$'
4394		INPUT - $'aaa'
4395	EXEC	-q $'^a.$'
4396		INPUT - $'axy'
4397	EXEC	-q $'^a.$'
4398		INPUT - $''
4399	EXEC	-q $'^$'
4400		INPUT - $'x'
4401	EXEC	-q $'^$'
4402		INPUT - $'^'
4403	EXEC	-q $'^.a'
4404		INPUT - $'a'
4405	EXEC	-q $'^.a'
4406		INPUT - $''
4407	EXEC	-q $'^.*a'
4408		INPUT - $''
4409	EXEC	-q -E $'^.+a'
4410		INPUT - $''
4411	EXEC	-q -E $'^.+a'
4412		INPUT - $'a'
4413	EXEC	-q -E $'^.+a'
4414		INPUT - $'ax'
4415	EXEC	-q $'aa*'
4416		INPUT - $'xxxx'
4417	EXEC	-q $'aa*'
4418		INPUT - $''
4419	EXEC	-q $'\\$'
4420		INPUT - $''
4421	EXEC	-q $'\\$'
4422		INPUT - $'x'
4423	EXEC	-q $'\\.'
4424		INPUT - $'x'
4425	EXEC	-q $'\\.'
4426		INPUT - $''
4427	EXEC	-q -G $'.^$'
4428		INPUT - $''
4429	EXEC	-q -G $'.^$'
4430		INPUT - $'a^$'
4431	EXEC	-q -G $'^x$'
4432		INPUT - $'yx'
4433	EXEC	-q -G $'^x$'
4434		INPUT - $'xy'
4435	EXEC	-q -G $'a\\$'
4436		INPUT - $'a'
4437	EXEC	-q -G $'\\(ab\\)$'
4438		INPUT - $'ab$'
4439	EXEC	-q -E $'xr+y'
4440		INPUT - $'ry'
4441	EXEC	-q -E $'xr+y'
4442		INPUT - $'xy'
4443	EXEC	-q -E $'xr?y'
4444		INPUT - $'xrry'
4445	EXEC	-q -E $'a(bc|def)g'
4446		INPUT - $'abc'
4447	EXEC	-q -E $'a(bc|def)g'
4448		INPUT - $'abg'
4449	EXEC	-q -E $'a(bc|def)g'
4450		INPUT - $'adef'
4451	EXEC	-q -E $'a(bc|def)g'
4452		INPUT - $'adeg'
4453	EXEC	-q $'[0-9]'
4454		INPUT - $'abc'
4455	EXEC	-q $'[0-9]'
4456		INPUT - $''
4457	EXEC	-q $'[^0-9]'
4458		INPUT - $'1'
4459	EXEC	-q $'[^0-9]'
4460		INPUT - $'567'
4461	EXEC	-q $'[^0-9]'
4462		INPUT - $''
4463	EXEC	-q -E $'x[0-9]+y'
4464		INPUT - $'0y'
4465	EXEC	-q -E $'x[0-9]+y'
4466		INPUT - $'xy'
4467	EXEC	-q -E $'x[0-9]?y'
4468		INPUT - $'x23y'
4469	EXEC	-q -x $'read'
4470		INPUT - $'xy read'
4471	EXEC	-q -x $'read'
4472		INPUT - $'x read y'
4473	EXEC	-q -x $'read'
4474		INPUT - $'xread'
4475	EXEC	-q -x $'read'
4476		INPUT - $'readx'
4477	EXEC	-q -xF $'read'
4478		INPUT - $'xy read'
4479	EXEC	-q -xF $'read'
4480		INPUT - $'x read y'
4481	EXEC	-q -xF $'read'
4482		INPUT - $'xread'
4483	EXEC	-q -xF $'read'
4484		INPUT - $'readx'
4485	EXEC	-q $'[.]de..'
4486		INPUT - $'.de'
4487	EXEC	-q $'[.]de..'
4488		INPUT - $'.dex'
4489	EXEC	-q -G $'^|s'
4490		INPUT - $'sec'
4491	EXEC	-q -G $'..B'
4492		INPUT - $'ABCD'
4493	EXEC	-q -E $'^([a-z]+)\\1$'
4494		INPUT - $'vivify'
4495	EXEC	-q -E $'([a-z]+)\\1'
4496		INPUT - $'vovify'
4497	EXEC	-q -E $'([a-z]+)\\1'
4498		INPUT - $'viv'
4499	EXEC	-q $'[ab]\\{2\\}k'
4500		INPUT - $'zad'
4501	EXEC	-q $'[ab]\\{2\\}k'
4502		INPUT - $'bq'
4503	EXEC	-q $'[ab]\\{2\\}k'
4504		INPUT - $'abq'
4505	EXEC	-q $'[ab]\\{2,\\}d'
4506		INPUT - $'ad'
4507	EXEC	-q $'[ab]\\{2,\\}d'
4508		INPUT - $'ababaq'
4509	EXEC	-q $'q[ab]\\{2,4\\}d'
4510		INPUT - $'qad'
4511	EXEC	-q $'q[ab]\\{2,4\\}d'
4512		INPUT - $'qababad'
4513	EXEC	-q -i $'angel[^e]'
4514		INPUT - $'angel'
4515	EXEC	-q -i $'angel[^e]'
4516		INPUT - $'ANGEL'
4517	EXEC	-q -i $'angel[^e]'
4518		INPUT - $'angele'
4519	EXEC	-q -i $'angel[^e]'
4520		INPUT - $'ANGELE'
4521	EXEC	-q -G $'^[^-].*>'
4522		INPUT - $'-a>'
4523	EXEC	-q -i $'^[^A-Z]'
4524		INPUT - $'abc'
4525	EXEC	-q -i $'^[^A-Z]'
4526		INPUT - $'ABC'
4527	EXEC	-q -G $'|abc'
4528		INPUT - $'abc'
4529	EXEC	-q -x $'.|..'
4530		INPUT - $'abc'
4531
4532TEST 11 'complex gre tests from Andrew Hume'
4533
4534	DO DATA g1.dat g4.dat g5.dat g6.pat g6.dat g8.dat g12.dat
4535	EXEC -xF $'defg\nabcd'
4536		INPUT - $'x\nabcd\nabcde\neabcd\ndefg\nxdefg\ndefgx\nabcd defg'
4537		OUTPUT - $'abcd\ndefg'
4538	EXEC	abc
4539		INPUT - 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaxyz
4540abc'
4541		OUTPUT - 'abc'
4542	EXEC	-E 'pm|xdhu'
4543		INPUT - $'/p1/usr/bin/pmxpc:
4544\t pm.sl\t2.94
4545\t xdhu.sl\t1.8
4546\t/lib/crt1.o.sl 1.1 4.0 01/15/86 12744 AT&T-SF
4547\t/usr/include/stdio.h.sl 1.1 4.0 01/15/86 4140 AT&T-SF
4548\t/usr/include/ctype.h.sl 1.1 4.0 01/15/86 45671 AT&T-SF
4549\t/usr/include/string.h.sl 1.1 4.0 01/15/86 51235 AT&T-SF
4550\t/usr/include/signal.h.sl 1.1 4.0 01/15/86 34302 AT&T-SF
4551\t/usr/include/sys/signal.h.sl 1.5 3.2 09/02/87 33640 AT&T-SF
4552\t/usr/include/sys/types.h.sl 1.3 3.1 06/02/86 48113 AT&T-SF
4553\t/usr/include/sys/stat.h.sl 1.3 3.0 12/19/85 41824
4554\t/usr/include/termio.h.sl 1.1 4.0 01/15/86 29141 AT&T-SF'
4555		OUTPUT - $'/p1/usr/bin/pmxpc:
4556\t pm.sl\t2.94
4557\t xdhu.sl\t1.8'
4558	EXEC	-v : g4.dat
4559		OUTPUT - $'   1 ZIPPORI, Israel
4560   1 ZERIFIN, Israel
4561   1 ZEPHYRHILLS, Fla.
4562   1 ZENICA, Yugoslavia
4563   1 ZAP, N.D.
4564   1 ZAMBRANO, Honduras
4565   1 ZACHARY, La.
4566   1 YUCCA VALLEY, Calif.
4567   1 YORKVILLE, Ill.
4568   1 YORK, Maine
4569   1 YENAN, China
4570   1 YELOWSTONE NATIONAL PARK, Wyo.
4571   1 YEADON, Pa.
4572   1 YATTA, Occupied West Bank
4573   1 YASSIHOYUK, Turkey
4574   1 YAPHANK, N.Y.
4575   1 YAMOUSSOUKRO, Ivory Coast'
4576	EXEC	'^com ' g5.dat
4577		SAME OUTPUT g5.dat
4578	EXEC	-E -f g6.pat g6.dat
4579		OUTPUT - $'emalloc(unsigned long n)
4580erealloc(char *p, unsigned long n)
4581pprint(proc, fmt, a, b, c, d, e)
4582bltinval(char *name, Node *t)
4583mk(type, len)
4584compile(n)\t/* called from parser only */
4585gen(Node *n, int retain)
4586lgen(Node *n)
4587genfreeauto(Symbol *s)
4588dupgen(Node *t, int n)
4589printable(Node *n)
4590constants(Node *n)
4591declare(Node *n, int stclass, int dotypchk, int docomp)
4592recrewrite(Node *n)
4593proglocals(Node *n)
4594begrewrite(Node *n)
4595lerror(Node *n, char *s, a, b, c, d, e, f)
4596error(char *s, a, b, c, d, e, f)
4597rerror(char *s, a, b, c, d, e, f)
4598warn(char *s, a, b, c, d, e, f)
4599panic(char *s, a, b, c, d, e, f)
4600rpanic(char *s, a, b, c, d, e, f)
4601bconv(int *o, int f1, int f2)
4602nconv(int *o, int f1, int f2)
4603tconv(int *o, int f1, int f2)
4604econv(int *o, int f1, int f2)
4605mconv(int *o, int f1, int f2)'
4606	EXEC	'^[^`]*`[^`]*$'
4607		INPUT - $'if [ `cat $HISTFILE | lct` -gt "$HISTMAXL" ]
4608
4609for i in `ls [0-9]*# | egrep \'^[0-9]+##?$\' | sed -e \'s/#*$//\'`
4610
4611do case "`ps -lx$i" in ?*);; *) rm -f ${i}# ${i}##;; esac
4612
4613NBRFILES=`ls -f $pubdir/jbk | fgrep -vi -x \'.
4614
4615..\'|lct`'
4616		OUTPUT - $'do case "`ps -lx$i" in ?*);; *) rm -f ${i}# ${i}##;; esac
4617NBRFILES=`ls -f $pubdir/jbk | fgrep -vi -x \'.
4618..\'|lct`'
4619	EXEC	-F -x -f g8.dat g8.dat
4620		SAME OUTPUT g8.dat
4621	EXEC	-F -f g8.dat
4622		INPUT - $'aba\ncad\nbad\nacb'
4623		OUTPUT - $'aba\nbad\nacb'
4624	EXEC	-v '^\.x' g1.dat
4625		OUTPUT -
4626		EXIT 1
4627	EXEC	-xvF -f g12.dat g12.dat
4628	EXEC	-xvF -f INPUT
4629		INPUT - $'at\nhematic'
4630
4631TEST 12 'alternating BM tests'
4632
4633	EXEC	-F $':::1:::0:\n:::1:1:0:'
4634		INPUT - ':::0:::1:::1:::0:'
4635		SAME OUTPUT INPUT
4636	EXEC	-F $':::1:::0:\n:::1:1:1:'
4637	EXEC	-E $':::1:::0:|:::1:1:0:'
4638	EXEC	-E $':::1:::0:|:::1:1:1:'
4639
4640TEST 13 '-c, -h, -t combinations'
4641
4642	DO	DATA x.dat xyz.dat
4643	EXEC	x x.dat xyz.dat
4644		OUTPUT - $'x.dat:x\nxyz.dat:x'
4645	EXEC	-c x x.dat xyz.dat
4646		OUTPUT - $'x.dat:1\nxyz.dat:1'
4647	EXEC	-ch x x.dat xyz.dat
4648		OUTPUT - $'1\n1'
4649	EXEC	-ct x x.dat xyz.dat
4650		OUTPUT - $'2'
4651	EXEC	-cht x x.dat xyz.dat
4652		OUTPUT - $'2'
4653	EXEC	-h x x.dat xyz.dat
4654		OUTPUT - $'x\nx'
4655	EXEC	-ht x x.dat xyz.dat
4656		OUTPUT - $'2'
4657	EXEC	-t x x.dat xyz.dat
4658		OUTPUT - $'2'
4659
4660TEST 14 '-m with -c, -h, -n, -t combinations'
4661
4662	DO	DATA g6.dat g7.dat
4663	EXEC	-m -e open:{ -e close:} g6.dat g7.dat
4664		OUTPUT - $'g6.dat:open:{
4665g6.dat:open:	if(p==0){
4666g6.dat:close:	}
4667g6.dat:close:}
4668g6.dat:open:{
4669g6.dat:open:	if(p==0){
4670g6.dat:close:	}
4671g6.dat:close:}
4672g6.dat:open:{
4673g6.dat:close:}
4674g6.dat:open:{
4675g6.dat:close:}
4676g6.dat:open:{
4677g6.dat:close:}
4678g6.dat:open:{
4679g6.dat:close:}
4680g6.dat:open:{
4681g6.dat:close:}
4682g6.dat:open:{
4683g6.dat:close:}
4684g6.dat:open:{
4685g6.dat:close:}
4686g6.dat:open:{
4687g6.dat:close:}
4688g6.dat:open:{
4689g6.dat:close:}
4690g6.dat:open:{
4691g6.dat:close:}
4692g6.dat:open:{
4693g6.dat:close:}
4694g6.dat:open:{
4695g6.dat:close:}
4696g6.dat:open:{
4697g6.dat:close:}
4698g6.dat:open:{
4699g6.dat:close:}
4700g6.dat:open:{
4701g6.dat:close:}
4702g6.dat:open:{
4703g6.dat:close:}
4704g6.dat:open:{
4705g6.dat:close:}
4706g6.dat:open:{
4707g6.dat:close:}
4708g6.dat:open:{
4709g6.dat:close:}
4710g6.dat:open:{
4711g6.dat:close:}
4712g6.dat:open:{
4713g6.dat:close:}
4714g6.dat:open:{
4715g6.dat:close:}
4716g6.dat:open:{
4717g6.dat:close:}
4718g6.dat:open:{
4719g6.dat:close:}
4720g6.dat:open:{
4721g6.dat:close:}
4722g6.dat:open:{
4723g6.dat:close:}
4724g6.dat:open:{
4725g6.dat:close:}
4726g6.dat:open:{
4727g6.dat:close:}
4728g6.dat:open:{
4729g6.dat:close:}
4730g6.dat:open:{
4731g6.dat:close:}
4732g6.dat:open:{
4733g6.dat:close:}
4734g6.dat:open:{
4735g6.dat:close:}
4736g6.dat:open:{
4737g6.dat:close:}
4738g6.dat:open:{
4739g6.dat:close:}
4740g6.dat:open:{
4741g6.dat:close:}
4742g6.dat:open:{
4743g6.dat:close:}
4744g6.dat:open:{
4745g6.dat:close:}
4746g6.dat:open:{
4747g6.dat:close:}
4748g6.dat:open:{
4749g6.dat:close:}
4750g6.dat:open:{
4751g6.dat:close:}
4752g6.dat:open:{
4753g6.dat:close:}
4754g6.dat:open:{
4755g6.dat:close:}
4756g6.dat:open:{
4757g6.dat:open:	if(proc->prbuf==0){
4758g6.dat:close:	}
4759g6.dat:open:	if(n+proc->nprbuf+1>proc->maxprbuf){
4760g6.dat:close:	}
4761g6.dat:close:}
4762g6.dat:open:{
4763g6.dat:close:}
4764g6.dat:open:{
4765g6.dat:close:}
4766g6.dat:open:{
4767g6.dat:close:}
4768g6.dat:open:{
4769g6.dat:close:}
4770g6.dat:open:long call0[]={	/* plain function, 0 arguments */
4771g6.dat:close:};
4772g6.dat:open:long call1[]={	/* plain function, 1 argument */
4773g6.dat:close:};
4774g6.dat:open:long call2[]={	/* plain function, 2 arguments */
4775g6.dat:close:};
4776g6.dat:open:long call3[]={	/* plain function, 3 arguments */
4777g6.dat:close:};
4778g6.dat:open:long call4[]={	/* plain function, 4 arguments */
4779g6.dat:close:};
4780g6.dat:open:long call5[]={	/* plain function, 5 arguments */
4781g6.dat:close:};
4782g6.dat:open:long call2_0[]={/* two-step function, 0 arguments */
4783g6.dat:close:};
4784g6.dat:open:struct{
4785g6.dat:close:}bltin[]={
4786g6.dat:open:	0,	{0,	0,	0},	0,	0,
4787g6.dat:close:};
4788g6.dat:open:{
4789g6.dat:close:}
4790g6.dat:open:{
4791g6.dat:close:}
4792g6.dat:open:{
4793g6.dat:open:	if(type==Sstruct){
4794g6.dat:close:	}else
4795g6.dat:close:}
4796g6.dat:open:{
4797g6.dat:open:	if(cflag){
4798g6.dat:close:	}
4799g6.dat:open:	if(errmark()){
4800g6.dat:close:	}
4801g6.dat:close:}
4802g6.dat:open:{
4803g6.dat:open:	switch(n->t){
4804g6.dat:open:		if(n->l->t==NCall && !bflag){
4805g6.dat:close:		}
4806g6.dat:open:		switch(n->o.t){
4807g6.dat:close:		}
4808g6.dat:open:		switch(n->o.i){
4809g6.dat:open:			if(eqtype(etypeof(n->l), &arychartype)){
4810g6.dat:close:			}
4811g6.dat:open:			if(isptrtype(etypeof(n->l))){
4812g6.dat:close:			}else
4813g6.dat:open:			if(retain && n->l->t==NID && isinttype(etypeof(n->l))){
4814g6.dat:close:			}
4815g6.dat:close:		}
4816g6.dat:open:		switch(typeof(n)->o.t){
4817g6.dat:open:			if(n->o.s->val->isauto){
4818g6.dat:close:			}else{
4819g6.dat:close:			}
4820g6.dat:open:			if(n->o.s->val->isauto){
4821g6.dat:close:			}else{
4822g6.dat:close:			}
4823g6.dat:close:		}
4824g6.dat:open:		if(nscope==1){
4825g6.dat:close:		}else
4826g6.dat:open:	case NSmash:{
4827g6.dat:open:		if(vr->type->o.t==TType){
4828g6.dat:close:		}
4829g6.dat:open:		if(isptrtype(vl->type)){
4830g6.dat:open:			if(vl->isauto){
4831g6.dat:close:			}else{
4832g6.dat:close:			}
4833g6.dat:close:		}
4834g6.dat:open:		if(vl->isauto){
4835g6.dat:close:		}
4836g6.dat:close:	}
4837g6.dat:open:		if(retain){
4838g6.dat:close:		}
4839g6.dat:close:	}
4840g6.dat:close:}
4841g6.dat:open:{
4842g6.dat:open:	if(isstr){
4843g6.dat:close:	}else{
4844g6.dat:close:	}
4845g6.dat:open:	if(a->t!=NID){
4846g6.dat:close:	}else if(a->o.s->val->isauto){
4847g6.dat:close:	}else{
4848g6.dat:close:	}
4849g6.dat:close:}
4850g6.dat:open:{
4851g6.dat:open:	switch(n->t){
4852g6.dat:open:		switch(typeof(n)->o.t){
4853g6.dat:open:			if(n->o.s->val->isauto){
4854g6.dat:close:			}
4855g6.dat:open:			if(n->o.s->val->isauto){
4856g6.dat:close:			}
4857g6.dat:open:			if(n->o.s->val->isauto){
4858g6.dat:close:			}
4859g6.dat:close:		}
4860g6.dat:close:	}
4861g6.dat:close:}
4862g6.dat:open:{
4863g6.dat:open:	switch(n->t){
4864g6.dat:open:		if(n->o.s->val->isauto){
4865g6.dat:close:		}
4866g6.dat:close:	}
4867g6.dat:close:}
4868g6.dat:open:{
4869g6.dat:open:	if(n->r==0){
4870g6.dat:close:	}
4871g6.dat:close:}
4872g6.dat:open:{
4873g6.dat:close:}
4874g6.dat:open:{
4875g6.dat:open:	if(n->o.i){	/* enter loop at top, so jump to body */
4876g6.dat:close:	}
4877g6.dat:open:	if(n->r->r){		/* jump to condition */
4878g6.dat:close:	}
4879g6.dat:open:	if(n->r->r){
4880g6.dat:close:	}else
4881g6.dat:close:}
4882g6.dat:open:{
4883g6.dat:close:}
4884g6.dat:open:{
4885g6.dat:open:	else{
4886g6.dat:open:		sprint(buf, "prog(){call on line %d}", n->line);
4887g6.dat:close:	}
4888g6.dat:open:	switch(callinst){
4889g6.dat:close:	}
4890g6.dat:close:}
4891g6.dat:open:{
4892g6.dat:close:}
4893g6.dat:open:{
4894g6.dat:open:	if(n->t==NList){
4895g6.dat:close:	}
4896g6.dat:open:	if(n->t==NArraycom){
4897g6.dat:close:	}else if(etypeoft(n)->o.t==TArray)
4898g6.dat:close:}
4899g6.dat:open:{
4900g6.dat:open:	if(n->t==NList){
4901g6.dat:close:	}
4902g6.dat:open:	if(c->o.t==\'=\'){
4903g6.dat:close:	}
4904g6.dat:open:	if(c->o.t==SND){
4905g6.dat:close:	}
4906g6.dat:open:	else if(c->t==NArraycom){
4907g6.dat:close:	}else
4908g6.dat:open:	if(c->t==NArraycom){	/* save array index */
4909g6.dat:close:	}
4910g6.dat:close:}
4911g6.dat:open:{
4912g6.dat:close:}
4913g6.dat:open:{
4914g6.dat:open:	if(s->t==NList){
4915g6.dat:close:	}
4916g6.dat:open:	else{
4917g6.dat:open:		if(isptr){	/* string */
4918g6.dat:close:		}else{
4919g6.dat:close:		}
4920g6.dat:close:	}
4921g6.dat:close:}
4922g6.dat:open:{
4923g6.dat:close:}
4924g6.dat:open:{
4925g6.dat:open:	if(isptrtype(s->val->type)){
4926g6.dat:close:	}
4927g6.dat:close:}
4928g6.dat:open:{
4929g6.dat:open:	if(n->t==NExprlist){
4930g6.dat:close:	}
4931g6.dat:open:	switch(t->o.t){
4932g6.dat:close:	}
4933g6.dat:close:}
4934g6.dat:open:{
4935g6.dat:open:	if(errmark()){
4936g6.dat:close:	}
4937g6.dat:close:}
4938g6.dat:open:{
4939g6.dat:open:	if(returnloc){
4940g6.dat:close:	}
4941g6.dat:close:}
4942g6.dat:open:{
4943g6.dat:open:	if(types->t==NList){
4944g6.dat:close:	}
4945g6.dat:open:	if(isptrtype(types)){
4946g6.dat:close:	}
4947g6.dat:close:}
4948g6.dat:open:{
4949g6.dat:close:}
4950g6.dat:open:{
4951g6.dat:open:	switch(t->o.t){
4952g6.dat:open:		else{
4953g6.dat:close:		}
4954g6.dat:open:		if(v==0){
4955g6.dat:close:		}
4956g6.dat:open:		if(t->r->o.t==TChar){
4957g6.dat:close:		}else
4958g6.dat:open:		if(v==0){
4959g6.dat:close:		}
4960g6.dat:open:		if(v==0){
4961g6.dat:close:		}
4962g6.dat:close:	}
4963g6.dat:close:}
4964g6.dat:open:{
4965g6.dat:open:	switch(t->o.t){
4966g6.dat:open:		if(isptrtype(t)){
4967g6.dat:close:		}else if(t->o.t==TInt || t->o.t==TUnit){
4968g6.dat:close:		}else if(t->o.t==TChar)
4969g6.dat:open:	case TStruct:{
4970g6.dat:close:	}
4971g6.dat:close:	}
4972g6.dat:close:}
4973g6.dat:open:{
4974g6.dat:open:	if(t->t==NList){
4975g6.dat:close:	}
4976g6.dat:open:	for(i=length(t); --i>=0; ){
4977g6.dat:open:		if(*pos==BPW){
4978g6.dat:close:		}
4979g6.dat:close:	}
4980g6.dat:close:}
4981g6.dat:open:{
4982g6.dat:open:	if(l<-2 || l>10){
4983g6.dat:close:	};
4984g6.dat:open:	switch((int)l){
4985g6.dat:close:	}
4986g6.dat:close:}
4987g6.dat:open:{
4988g6.dat:open:	switch(n->t){
4989g6.dat:close:	}
4990g6.dat:close:}
4991g6.dat:open:{
4992g6.dat:open:	switch(n->t){
4993g6.dat:open:		switch(n->o.i){
4994g6.dat:close:		}
4995g6.dat:open:		if(isconst(n->o.n)){
4996g6.dat:open:			if(topofstack()){
4997g6.dat:close:			}else{
4998g6.dat:close:			}
4999g6.dat:close:		}
5000g6.dat:close:	}
5001g6.dat:close:}
5002g6.dat:open:{
5003g6.dat:open:	switch(n->t){
5004g6.dat:open:		switch(n->o.i){
5005g6.dat:close:		}
5006g6.dat:close:	}
5007g6.dat:close:}
5008g6.dat:open:{
5009g6.dat:open:	switch(t->o.t){
5010g6.dat:open:		if(t->r->o.t==TChar){
5011g6.dat:close:		}
5012g6.dat:close:	}
5013g6.dat:close:}
5014g6.dat:open:{
5015g6.dat:close:}
5016g6.dat:open:{
5017g6.dat:close:}
5018g6.dat:open:{
5019g6.dat:close:}
5020g6.dat:open:{
5021g6.dat:close:}
5022g6.dat:open:{
5023g6.dat:open:	if(proc->pc==0){
5024g6.dat:close:	}
5025g6.dat:close:}
5026g6.dat:open:{
5027g6.dat:close:}
5028g6.dat:open:{
5029g6.dat:close:}
5030g6.dat:open:{
5031g6.dat:close:}
5032g6.dat:open:{
5033g6.dat:open:	if(n->t==NList){
5034g6.dat:close:	}
5035g6.dat:open:	if(n->t==NDeclsc){
5036g6.dat:close:	}
5037g6.dat:open:	if(n->r==0){
5038g6.dat:close:	}
5039g6.dat:open:	if(dotypchk){
5040g6.dat:open:		if(n->o.n){
5041g6.dat:close:		}
5042g6.dat:close:	}
5043g6.dat:open:	if(docomp && n->o.n){
5044g6.dat:close:	}else
5045g6.dat:open:	if(n->o.n && docomp && nscope==0){
5046g6.dat:close:	}
5047g6.dat:close:}
5048g6.dat:open:{
5049g6.dat:open:	if(id->t==NList){
5050g6.dat:close:	}
5051g6.dat:close:}
5052g6.dat:open: * 	rec {
5053g6.dat:close: * 	};
5054g6.dat:open: *	rec type T: struct of { t:T; };
5055g6.dat:open:{
5056g6.dat:open:	if(n->t==NDeclsc){
5057g6.dat:close:	}
5058g6.dat:open:	if(n->r==0){
5059g6.dat:close:	}else if(n->r->o.t==TType){
5060g6.dat:close:	}
5061g6.dat:close:}
5062g6.dat:open:{
5063g6.dat:open:	if(n->t==NDeclsc){
5064g6.dat:close:	}
5065g6.dat:close:}
5066g6.dat:open:{
5067g6.dat:close:}
5068g6.dat:open:{
5069g6.dat:close:}
5070g6.dat:open:{
5071g6.dat:close:}
5072g6.dat:open: *	prog(a:int){
5073g6.dat:open: *		begin prog(b:int){ f(a, b); }(b);
5074g6.dat:close: *	}
5075g6.dat:open: *	prog(a:int){
5076g6.dat:open: *		begin prog(b:int, a:int){ f(a, b); }(b, a);
5077g6.dat:close: *	}
5078g6.dat:open:{
5079g6.dat:close:}
5080g6.dat:open:{
5081g6.dat:close:}
5082g6.dat:open:{
5083g6.dat:open:	if(!alreadyformal(n, begf)){
5084g6.dat:close:	}
5085g6.dat:close:}
5086g6.dat:open:{
5087g6.dat:close:}
5088g6.dat:open:{
5089g6.dat:open:	switch(n->t){
5090g6.dat:open:		if(0<n->o.s->val->scope && n->o.s->val->scope<fscope){
5091g6.dat:close:		}
5092g6.dat:close:	}
5093g6.dat:close:}
5094g6.dat:open:{
5095g6.dat:close:}
5096g6.dat:open:{
5097g6.dat:close:}
5098g6.dat:open:{
5099g6.dat:close:}
5100g6.dat:open:{
5101g6.dat:close:}
5102g6.dat:open:{
5103g6.dat:close:}
5104g6.dat:open:{
5105g6.dat:close:}
5106g6.dat:open:{
5107g6.dat:close:}
5108g6.dat:open:{
5109g6.dat:close:}
5110g6.dat:open:{
5111g6.dat:close:}
5112g6.dat:open:prbuf(){
5113g6.dat:close:}
5114g6.dat:open:{
5115g6.dat:open:	else{
5116g6.dat:open:		switch(t){
5117g6.dat:close:		}
5118g6.dat:close:	}
5119g6.dat:close:}
5120g6.dat:open:{
5121g6.dat:open:	switch(n->t){
5122g7.dat:open:{
5123g7.dat:open:	else if (c != n) {
5124g7.dat:close:	} else if(rebuf->w == rebuf->s)
5125g7.dat:open:	else {
5126g7.dat:open:		if (sub) {
5127g7.dat:close:		}
5128g7.dat:close:	}
5129g7.dat:close:}
5130g7.dat:open:{
5131g7.dat:open:	if(code && code != REG_NOMATCH) {
5132g7.dat:close:	}
5133g7.dat:close:}
5134g7.dat:open:{
5135g7.dat:close:}
5136g7.dat:open:{
5137g7.dat:open:	if(n = regsubexec(re, (char*)data->s, elementsof(matches), matches)) {
5138g7.dat:close:	}
5139g7.dat:close:}'
5140	EXEC	-m -e include:include -e define:define g6.dat g7.dat
5141		OUTPUT - $'g6.dat:include:#include "alloc.h"
5142g6.dat:include:#include <libc.h>
5143g6.dat:include:#include "alloc.h"
5144g6.dat:include:#include "word.h"
5145g6.dat:include:#include "store.h"
5146g6.dat:include:#include "comm.h"
5147g6.dat:include:#include <libc.h>
5148g6.dat:include:#include "node.h"
5149g6.dat:include:#include "symbol.h"
5150g6.dat:include:#include "alloc.h"
5151g6.dat:include:#include "word.h"
5152g6.dat:include:#include "store.h"
5153g6.dat:include:#include "comm.h"
5154g6.dat:include:#include "inst.h"
5155g6.dat:include:#include <libc.h>
5156g6.dat:define:#define	FNS
5157g6.dat:include:#include "lib.h"
5158g6.dat:define:#define	C	0x40000000
5159g6.dat:define:#define	I	0x20000000
5160g6.dat:define:#define	F	0x10000000
5161g6.dat:define:#define	M(x)	((x)&~(C|I|F))
5162g6.dat:include:#include "lib.h"
5163g6.dat:include:#include "node.h"
5164g6.dat:include:#include "symbol.h"
5165g6.dat:include:#include "alloc.h"
5166g6.dat:include:#include "ydefs.h"
5167g6.dat:include:#include "word.h"
5168g6.dat:include:#include "store.h"
5169g6.dat:include:#include "comm.h"
5170g6.dat:include:#include "inst.h"
5171g6.dat:include:#include "errjmp.h"
5172g6.dat:include:#include <libc.h>
5173g6.dat:include:#include "alloc.h"
5174g6.dat:include:#include "node.h"
5175g6.dat:include:#include "symbol.h"
5176g6.dat:include:#include "ydefs.h"
5177g6.dat:include:#include "word.h"
5178g6.dat:include:#include "store.h"
5179g6.dat:include:#include <libc.h>
5180g6.dat:include:#include "alloc.h"
5181g6.dat:include:#include "word.h"
5182g6.dat:include:#include "store.h"
5183g6.dat:include:#include "comm.h"
5184g6.dat:include:#include <libc.h>
5185g6.dat:include:	nargs+=2;	/* includes result and sym; add pc, fp */
5186g6.dat:include:#include "node.h"
5187g6.dat:include:#include "symbol.h"
5188g6.dat:include:#include "alloc.h"
5189g6.dat:include:#include "ydefs.h"
5190g6.dat:include:#include "word.h"
5191g6.dat:include:#include "store.h"
5192g6.dat:include:#include <libc.h>
5193g6.dat:include:#include "nodenames.h"
5194g6.dat:include:#include "typenames.h"
5195g6.dat:include:#include "errjmp.h"
5196g6.dat:include:#include "node.h"
5197g6.dat:include:#include "symbol.h"
5198g6.dat:include:#include "ydefs.h"
5199g6.dat:include:#include <libc.h>
5200g7.dat:include:#include "sed.h" /* define sed stuff */'
5201	EXEC	-n -m -e open:{ -e close:} g6.dat g7.dat
5202		OUTPUT - $'g6.dat:6:open:{
5203g6.dat:9:open:	if(p==0){
5204g6.dat:12:close:	}
5205g6.dat:14:close:}
5206g6.dat:17:open:{
5207g6.dat:19:open:	if(p==0){
5208g6.dat:22:close:	}
5209g6.dat:24:close:}
5210g6.dat:36:open:{
5211g6.dat:39:close:}
5212g6.dat:42:open:{
5213g6.dat:45:close:}
5214g6.dat:48:open:{
5215g6.dat:51:close:}
5216g6.dat:54:open:{
5217g6.dat:57:close:}
5218g6.dat:60:open:{
5219g6.dat:63:close:}
5220g6.dat:66:open:{
5221g6.dat:69:close:}
5222g6.dat:72:open:{
5223g6.dat:75:close:}
5224g6.dat:78:open:{
5225g6.dat:81:close:}
5226g6.dat:84:open:{
5227g6.dat:87:close:}
5228g6.dat:90:open:{
5229g6.dat:93:close:}
5230g6.dat:96:open:{
5231g6.dat:99:close:}
5232g6.dat:102:open:{
5233g6.dat:105:close:}
5234g6.dat:108:open:{
5235g6.dat:111:close:}
5236g6.dat:114:open:{
5237g6.dat:117:close:}
5238g6.dat:123:open:{
5239g6.dat:127:close:}
5240g6.dat:130:open:{
5241g6.dat:134:close:}
5242g6.dat:137:open:{
5243g6.dat:141:close:}
5244g6.dat:144:open:{
5245g6.dat:148:close:}
5246g6.dat:151:open:{
5247g6.dat:155:close:}
5248g6.dat:158:open:{
5249g6.dat:162:close:}
5250g6.dat:165:open:{
5251g6.dat:169:close:}
5252g6.dat:172:open:{
5253g6.dat:176:close:}
5254g6.dat:179:open:{
5255g6.dat:189:close:}
5256g6.dat:192:open:{
5257g6.dat:198:close:}
5258g6.dat:201:open:{
5259g6.dat:207:close:}
5260g6.dat:210:open:{
5261g6.dat:214:close:}
5262g6.dat:217:open:{
5263g6.dat:221:close:}
5264g6.dat:224:open:{
5265g6.dat:228:close:}
5266g6.dat:231:open:{
5267g6.dat:235:close:}
5268g6.dat:238:open:{
5269g6.dat:242:close:}
5270g6.dat:245:open:{
5271g6.dat:251:close:}
5272g6.dat:258:open:{
5273g6.dat:261:close:}
5274g6.dat:264:open:{
5275g6.dat:267:close:}
5276g6.dat:270:open:{
5277g6.dat:273:close:}
5278g6.dat:276:open:{
5279g6.dat:281:close:}
5280g6.dat:284:open:{
5281g6.dat:289:close:}
5282g6.dat:296:open:{
5283g6.dat:307:close:}
5284g6.dat:314:open:{
5285g6.dat:317:close:}
5286g6.dat:320:open:{
5287g6.dat:323:close:}
5288g6.dat:326:open:{
5289g6.dat:329:close:}
5290g6.dat:332:open:{
5291g6.dat:335:close:}
5292g6.dat:338:open:{
5293g6.dat:341:close:}
5294g6.dat:346:open:{
5295g6.dat:350:open:	if(proc->prbuf==0){
5296g6.dat:354:close:	}
5297g6.dat:355:open:	if(n+proc->nprbuf+1>proc->maxprbuf){
5298g6.dat:358:close:	}
5299g6.dat:361:close:}
5300g6.dat:367:open:{
5301g6.dat:370:close:}
5302g6.dat:373:open:{
5303g6.dat:377:close:}
5304g6.dat:380:open:{
5305g6.dat:384:close:}
5306g6.dat:387:open:{
5307g6.dat:392:close:}
5308g6.dat:411:open:long call0[]={	/* plain function, 0 arguments */
5309g6.dat:413:close:};
5310g6.dat:414:open:long call1[]={	/* plain function, 1 argument */
5311g6.dat:416:close:};
5312g6.dat:417:open:long call2[]={	/* plain function, 2 arguments */
5313g6.dat:419:close:};
5314g6.dat:420:open:long call3[]={	/* plain function, 3 arguments */
5315g6.dat:422:close:};
5316g6.dat:423:open:long call4[]={	/* plain function, 4 arguments */
5317g6.dat:425:close:};
5318g6.dat:426:open:long call5[]={	/* plain function, 5 arguments */
5319g6.dat:428:close:};
5320g6.dat:429:open:long call2_0[]={/* two-step function, 0 arguments */
5321g6.dat:431:close:};
5322g6.dat:433:open:struct{
5323g6.dat:438:close:}bltin[]={
5324g6.dat:440:open:	0,	{0,	0,	0},	0,	0,
5325g6.dat:441:close:};
5326g6.dat:444:open:{
5327g6.dat:451:close:}
5328g6.dat:455:open:{
5329g6.dat:484:close:}
5330g6.dat:488:open:{
5331g6.dat:495:open:	if(type==Sstruct){
5332g6.dat:498:close:	}else
5333g6.dat:502:close:}
5334g6.dat:525:open:{
5335g6.dat:529:open:	if(cflag){
5336g6.dat:533:close:	}
5337g6.dat:535:open:	if(errmark()){
5338g6.dat:540:close:	}
5339g6.dat:545:close:}
5340g6.dat:548:open:{
5341g6.dat:552:open:	switch(n->t){
5342g6.dat:559:open:		if(n->l->t==NCall && !bflag){
5343g6.dat:562:close:		}
5344g6.dat:567:open:		switch(n->o.t){
5345g6.dat:584:close:		}
5346g6.dat:601:open:		switch(n->o.i){
5347g6.dat:607:open:			if(eqtype(etypeof(n->l), &arychartype)){
5348g6.dat:610:close:			}
5349g6.dat:704:open:			if(isptrtype(etypeof(n->l))){
5350g6.dat:707:close:			}else
5351g6.dat:711:open:			if(retain && n->l->t==NID && isinttype(etypeof(n->l))){
5352g6.dat:714:close:			}
5353g6.dat:741:close:		}
5354g6.dat:753:open:		switch(typeof(n)->o.t){
5355g6.dat:756:open:			if(n->o.s->val->isauto){
5356g6.dat:759:close:			}else{
5357g6.dat:762:close:			}
5358g6.dat:768:open:			if(n->o.s->val->isauto){
5359g6.dat:771:close:			}else{
5360g6.dat:774:close:			}
5361g6.dat:784:close:		}
5362g6.dat:813:open:		if(nscope==1){
5363g6.dat:821:close:		}else
5364g6.dat:829:open:	case NSmash:{
5365g6.dat:833:open:		if(vr->type->o.t==TType){
5366g6.dat:837:close:		}
5367g6.dat:842:open:		if(isptrtype(vl->type)){
5368g6.dat:843:open:			if(vl->isauto){
5369g6.dat:846:close:			}else{
5370g6.dat:849:close:			}
5371g6.dat:851:close:		}
5372g6.dat:852:open:		if(vl->isauto){
5373g6.dat:856:close:		}
5374g6.dat:860:close:	}
5375g6.dat:862:open:		if(retain){
5376g6.dat:871:close:		}
5377g6.dat:888:close:	}
5378g6.dat:891:close:}
5379g6.dat:894:open:{
5380g6.dat:896:open:	if(isstr){
5381g6.dat:900:close:	}else{
5382g6.dat:905:close:	}
5383g6.dat:906:open:	if(a->t!=NID){
5384g6.dat:910:close:	}else if(a->o.s->val->isauto){
5385g6.dat:914:close:	}else{
5386g6.dat:918:close:	}
5387g6.dat:919:close:}
5388g6.dat:922:open:{
5389g6.dat:923:open:	switch(n->t){
5390g6.dat:925:open:		switch(typeof(n)->o.t){
5391g6.dat:927:open:			if(n->o.s->val->isauto){
5392g6.dat:931:close:			}
5393g6.dat:937:open:			if(n->o.s->val->isauto){
5394g6.dat:941:close:			}
5395g6.dat:949:open:			if(n->o.s->val->isauto){
5396g6.dat:953:close:			}
5397g6.dat:961:close:		}
5398g6.dat:973:close:	}
5399g6.dat:974:close:}
5400g6.dat:980:open:{
5401g6.dat:981:open:	switch(n->t){
5402g6.dat:983:open:		if(n->o.s->val->isauto){
5403g6.dat:987:close:		}
5404g6.dat:1002:close:	}
5405g6.dat:1003:close:}
5406g6.dat:1006:open:{
5407g6.dat:1013:open:	if(n->r==0){
5408g6.dat:1016:close:	}
5409g6.dat:1024:close:}
5410g6.dat:1027:open:{
5411g6.dat:1043:close:}
5412g6.dat:1046:open:{
5413g6.dat:1048:open:	if(n->o.i){	/* enter loop at top, so jump to body */
5414g6.dat:1052:close:	}
5415g6.dat:1054:open:	if(n->r->r){		/* jump to condition */
5416g6.dat:1058:close:	}
5417g6.dat:1064:open:	if(n->r->r){
5418g6.dat:1068:close:	}else
5419g6.dat:1071:close:}
5420g6.dat:1074:open:{
5421g6.dat:1093:close:}
5422g6.dat:1096:open:{
5423g6.dat:1113:open:	else{
5424g6.dat:1116:open:		sprint(buf, "prog(){call on line %d}", n->line);
5425g6.dat:1120:close:	}
5426g6.dat:1122:open:	switch(callinst){
5427g6.dat:1140:close:	}
5428g6.dat:1142:close:}
5429g6.dat:1145:open:{
5430g6.dat:1162:close:}
5431g6.dat:1165:open:{
5432g6.dat:1167:open:	if(n->t==NList){
5433g6.dat:1171:close:	}
5434g6.dat:1181:open:	if(n->t==NArraycom){
5435g6.dat:1184:close:	}else if(etypeoft(n)->o.t==TArray)
5436g6.dat:1188:close:}
5437g6.dat:1191:open:{
5438g6.dat:1193:open:	if(n->t==NList){
5439g6.dat:1198:close:	}
5440g6.dat:1207:open:	if(c->o.t==\'=\'){
5441g6.dat:1210:close:	}
5442g6.dat:1211:open:	if(c->o.t==SND){
5443g6.dat:1217:close:	}
5444g6.dat:1224:open:	else if(c->t==NArraycom){
5445g6.dat:1229:close:	}else
5446g6.dat:1231:open:	if(c->t==NArraycom){	/* save array index */
5447g6.dat:1236:close:	}
5448g6.dat:1242:close:}
5449g6.dat:1245:open:{
5450g6.dat:1261:close:}
5451g6.dat:1264:open:{
5452g6.dat:1267:open:	if(s->t==NList){
5453g6.dat:1271:close:	}
5454g6.dat:1278:open:	else{
5455g6.dat:1280:open:		if(isptr){	/* string */
5456g6.dat:1285:close:		}else{
5457g6.dat:1288:close:		}
5458g6.dat:1293:close:	}
5459g6.dat:1303:close:}
5460g6.dat:1306:open:{
5461g6.dat:1313:close:}
5462g6.dat:1316:open:{
5463g6.dat:1319:open:	if(isptrtype(s->val->type)){
5464g6.dat:1322:close:	}
5465g6.dat:1323:close:}
5466g6.dat:1326:open:{
5467g6.dat:1330:open:	if(n->t==NExprlist){
5468g6.dat:1334:close:	}
5469g6.dat:1336:open:	switch(t->o.t){
5470g6.dat:1354:close:	}
5471g6.dat:1355:close:}
5472g6.dat:1358:open:{
5473g6.dat:1373:open:	if(errmark()){
5474g6.dat:1379:close:	}
5475g6.dat:1404:close:}
5476g6.dat:1407:open:{
5477g6.dat:1408:open:	if(returnloc){
5478g6.dat:1412:close:	}
5479g6.dat:1420:close:}
5480g6.dat:1423:open:{
5481g6.dat:1426:open:	if(types->t==NList){
5482g6.dat:1429:close:	}
5483g6.dat:1433:open:	if(isptrtype(types)){
5484g6.dat:1436:close:	}
5485g6.dat:1438:close:}
5486g6.dat:1441:open:{
5487g6.dat:1444:close:}
5488g6.dat:1447:open:{
5489g6.dat:1448:open:	switch(t->o.t){
5490g6.dat:1463:open:		else{
5491g6.dat:1466:close:		}
5492g6.dat:1469:open:		if(v==0){
5493g6.dat:1473:close:		}
5494g6.dat:1488:open:		if(t->r->o.t==TChar){
5495g6.dat:1493:close:		}else
5496g6.dat:1497:open:		if(v==0){
5497g6.dat:1502:close:		}
5498g6.dat:1506:open:		if(v==0){
5499g6.dat:1509:close:		}
5500g6.dat:1519:close:	}
5501g6.dat:1520:close:}
5502g6.dat:1523:open:{
5503g6.dat:1524:open:	switch(t->o.t){
5504g6.dat:1529:open:		if(isptrtype(t)){
5505g6.dat:1532:close:		}else if(t->o.t==TInt || t->o.t==TUnit){
5506g6.dat:1535:close:		}else if(t->o.t==TChar)
5507g6.dat:1540:open:	case TStruct:{
5508g6.dat:1550:close:	}
5509g6.dat:1555:close:	}
5510g6.dat:1557:close:}
5511g6.dat:1560:open:{
5512g6.dat:1562:open:	if(t->t==NList){
5513g6.dat:1566:close:	}
5514g6.dat:1569:open:	for(i=length(t); --i>=0; ){
5515g6.dat:1570:open:		if(*pos==BPW){
5516g6.dat:1574:close:		}
5517g6.dat:1578:close:	}
5518g6.dat:1579:close:}
5519g6.dat:1582:open:{
5520g6.dat:1583:open:	if(l<-2 || l>10){
5521g6.dat:1587:close:	};
5522g6.dat:1588:open:	switch((int)l){
5523g6.dat:1630:close:	}
5524g6.dat:1631:close:}
5525g6.dat:1634:open:{
5526g6.dat:1637:open:	switch(n->t){
5527g6.dat:1651:close:	}
5528g6.dat:1653:close:}
5529g6.dat:1667:open:{
5530g6.dat:1672:open:	switch(n->t){
5531g6.dat:1700:open:		switch(n->o.i){
5532g6.dat:1742:close:		}
5533g6.dat:1759:open:		if(isconst(n->o.n)){
5534g6.dat:1763:open:			if(topofstack()){
5535g6.dat:1766:close:			}else{
5536g6.dat:1769:close:			}
5537g6.dat:1772:close:		}
5538g6.dat:1821:close:	}
5539g6.dat:1825:close:}
5540g6.dat:1828:open:{
5541g6.dat:1831:open:	switch(n->t){
5542g6.dat:1837:open:		switch(n->o.i){
5543g6.dat:1870:close:		}
5544g6.dat:1895:close:	}
5545g6.dat:1898:close:}
5546g6.dat:1902:open:{
5547g6.dat:1907:open:	switch(t->o.t){
5548g6.dat:1917:open:		if(t->r->o.t==TChar){
5549g6.dat:1927:close:		}
5550g6.dat:1929:close:	}
5551g6.dat:1931:close:}
5552g6.dat:1945:open:{
5553g6.dat:1950:close:}
5554g6.dat:1953:open:{
5555g6.dat:1959:close:}
5556g6.dat:1962:open:{
5557g6.dat:1968:close:}
5558g6.dat:1971:open:{
5559g6.dat:1974:close:}
5560g6.dat:1993:open:{
5561g6.dat:2000:open:	if(proc->pc==0){
5562g6.dat:2005:close:	}
5563g6.dat:2007:close:}
5564g6.dat:2010:open:{
5565g6.dat:2034:close:}
5566g6.dat:2037:open:{
5567g6.dat:2047:close:}
5568g6.dat:2050:open:{
5569g6.dat:2060:close:}
5570g6.dat:2072:open:{
5571g6.dat:2076:open:	if(n->t==NList){
5572g6.dat:2080:close:	}
5573g6.dat:2081:open:	if(n->t==NDeclsc){
5574g6.dat:2084:close:	}
5575g6.dat:2087:open:	if(n->r==0){
5576g6.dat:2093:close:	}
5577g6.dat:2094:open:	if(dotypchk){
5578g6.dat:2096:open:		if(n->o.n){
5579g6.dat:2111:close:		}
5580g6.dat:2112:close:	}
5581g6.dat:2113:open:	if(docomp && n->o.n){
5582g6.dat:2118:close:	}else
5583g6.dat:2121:open:	if(n->o.n && docomp && nscope==0){
5584g6.dat:2125:close:	}
5585g6.dat:2126:close:}
5586g6.dat:2130:open:{
5587g6.dat:2131:open:	if(id->t==NList){
5588g6.dat:2135:close:	}
5589g6.dat:2146:close:}
5590g6.dat:2150:open: * 	rec {
5591g6.dat:2153:close: * 	};
5592g6.dat:2164:open: *	rec type T: struct of { t:T; };
5593g6.dat:2171:open:{
5594g6.dat:2173:open:	if(n->t==NDeclsc){
5595g6.dat:2176:close:	}
5596g6.dat:2177:open:	if(n->r==0){
5597g6.dat:2182:close:	}else if(n->r->o.t==TType){
5598g6.dat:2186:close:	}
5599g6.dat:2190:close:}
5600g6.dat:2194:open:{
5601g6.dat:2197:open:	if(n->t==NDeclsc){
5602g6.dat:2200:close:	}
5603g6.dat:2207:close:}
5604g6.dat:2211:open:{
5605g6.dat:2222:close:}
5606g6.dat:2226:open:{
5607g6.dat:2230:close:}
5608g6.dat:2233:open:{
5609g6.dat:2243:close:}
5610g6.dat:2249:open: *	prog(a:int){
5611g6.dat:2250:open: *		begin prog(b:int){ f(a, b); }(b);
5612g6.dat:2251:close: *	}
5613g6.dat:2255:open: *	prog(a:int){
5614g6.dat:2256:open: *		begin prog(b:int, a:int){ f(a, b); }(b, a);
5615g6.dat:2257:close: *	}
5616g6.dat:2267:open:{
5617g6.dat:2276:close:}
5618g6.dat:2279:open:{
5619g6.dat:2290:close:}
5620g6.dat:2293:open:{
5621g6.dat:2295:open:	if(!alreadyformal(n, begf)){
5622g6.dat:2306:close:	}
5623g6.dat:2307:close:}
5624g6.dat:2310:open:{
5625g6.dat:2316:close:}
5626g6.dat:2319:open:{
5627g6.dat:2322:open:	switch(n->t){
5628g6.dat:2346:open:		if(0<n->o.s->val->scope && n->o.s->val->scope<fscope){
5629g6.dat:2350:close:		}
5630g6.dat:2397:close:	}
5631g6.dat:2400:close:}
5632g6.dat:2411:open:{
5633g6.dat:2418:close:}
5634g6.dat:2421:open:{
5635g6.dat:2428:close:}
5636g6.dat:2431:open:{
5637g6.dat:2438:close:}
5638g6.dat:2441:open:{
5639g6.dat:2446:close:}
5640g6.dat:2449:open:{
5641g6.dat:2455:close:}
5642g6.dat:2458:open:{
5643g6.dat:2465:close:}
5644g6.dat:2468:open:{
5645g6.dat:2474:close:}
5646g6.dat:2477:open:{
5647g6.dat:2483:close:}
5648g6.dat:2486:open:{
5649g6.dat:2492:close:}
5650g6.dat:2498:open:prbuf(){
5651g6.dat:2502:close:}
5652g6.dat:2505:open:{
5653g6.dat:2511:open:	else{
5654g6.dat:2512:open:		switch(t){
5655g6.dat:2561:close:		}
5656g6.dat:2563:close:	}
5657g6.dat:2566:close:}
5658g6.dat:2569:open:{
5659g6.dat:2572:open:	switch(n->t){
5660g7.dat:9:open:{
5661g7.dat:16:open:	else if (c != n) {
5662g7.dat:23:close:	} else if(rebuf->w == rebuf->s)
5663g7.dat:25:open:	else {
5664g7.dat:26:open:		if (sub) {
5665g7.dat:32:close:		}
5666g7.dat:34:close:	}
5667g7.dat:36:close:}
5668g7.dat:40:open:{
5669g7.dat:41:open:	if(code && code != REG_NOMATCH) {
5670g7.dat:45:close:	}
5671g7.dat:46:close:}
5672g7.dat:50:open:{
5673g7.dat:55:close:}
5674g7.dat:59:open:{
5675g7.dat:64:open:	if(n = regsubexec(re, (char*)data->s, elementsof(matches), matches)) {
5676g7.dat:67:close:	}
5677g7.dat:73:close:}'
5678	EXEC	-n -m -e include:include -e define:define g6.dat g7.dat
5679		OUTPUT - $'g6.dat:1:include:#include "alloc.h"
5680g6.dat:2:include:#include <libc.h>
5681g6.dat:25:include:#include "alloc.h"
5682g6.dat:26:include:#include "word.h"
5683g6.dat:27:include:#include "store.h"
5684g6.dat:28:include:#include "comm.h"
5685g6.dat:29:include:#include <libc.h>
5686g6.dat:393:include:#include "node.h"
5687g6.dat:394:include:#include "symbol.h"
5688g6.dat:395:include:#include "alloc.h"
5689g6.dat:396:include:#include "word.h"
5690g6.dat:397:include:#include "store.h"
5691g6.dat:398:include:#include "comm.h"
5692g6.dat:399:include:#include "inst.h"
5693g6.dat:400:include:#include <libc.h>
5694g6.dat:402:define:#define	FNS
5695g6.dat:403:include:#include "lib.h"
5696g6.dat:406:define:#define	C	0x40000000
5697g6.dat:407:define:#define	I	0x20000000
5698g6.dat:408:define:#define	F	0x10000000
5699g6.dat:409:define:#define	M(x)	((x)&~(C|I|F))
5700g6.dat:439:include:#include "lib.h"
5701g6.dat:503:include:#include "node.h"
5702g6.dat:504:include:#include "symbol.h"
5703g6.dat:505:include:#include "alloc.h"
5704g6.dat:506:include:#include "ydefs.h"
5705g6.dat:507:include:#include "word.h"
5706g6.dat:508:include:#include "store.h"
5707g6.dat:509:include:#include "comm.h"
5708g6.dat:510:include:#include "inst.h"
5709g6.dat:511:include:#include "errjmp.h"
5710g6.dat:512:include:#include <libc.h>
5711g6.dat:1654:include:#include "alloc.h"
5712g6.dat:1655:include:#include "node.h"
5713g6.dat:1656:include:#include "symbol.h"
5714g6.dat:1657:include:#include "ydefs.h"
5715g6.dat:1658:include:#include "word.h"
5716g6.dat:1659:include:#include "store.h"
5717g6.dat:1660:include:#include <libc.h>
5718g6.dat:1932:include:#include "alloc.h"
5719g6.dat:1933:include:#include "word.h"
5720g6.dat:1934:include:#include "store.h"
5721g6.dat:1935:include:#include "comm.h"
5722g6.dat:1936:include:#include <libc.h>
5723g6.dat:2016:include:	nargs+=2;	/* includes result and sym; add pc, fp */
5724g6.dat:2061:include:#include "node.h"
5725g6.dat:2062:include:#include "symbol.h"
5726g6.dat:2063:include:#include "alloc.h"
5727g6.dat:2064:include:#include "ydefs.h"
5728g6.dat:2065:include:#include "word.h"
5729g6.dat:2066:include:#include "store.h"
5730g6.dat:2067:include:#include <libc.h>
5731g6.dat:2402:include:#include "nodenames.h"
5732g6.dat:2403:include:#include "typenames.h"
5733g6.dat:2404:include:#include "errjmp.h"
5734g6.dat:2405:include:#include "node.h"
5735g6.dat:2406:include:#include "symbol.h"
5736g6.dat:2407:include:#include "ydefs.h"
5737g6.dat:2408:include:#include <libc.h>
5738g7.dat:3:include:#include "sed.h" /* define sed stuff */'
5739	EXEC	-c -m -e open:{ -e close:} g6.dat g7.dat
5740		OUTPUT - $'g6.dat:open:227
5741g6.dat:close:231
5742g7.dat:open:9
5743g7.dat:close:9'
5744	EXEC	-c -m -e include:include -e define:define g6.dat g7.dat
5745		OUTPUT - $'g6.dat:include:54
5746g6.dat:define:5
5747g7.dat:include:1
5748g7.dat:define:0'
5749	EXEC	-h -m -e open:{ -e close:} g6.dat g7.dat
5750		OUTPUT - $'open:{
5751open:	if(p==0){
5752close:	}
5753close:}
5754open:{
5755open:	if(p==0){
5756close:	}
5757close:}
5758open:{
5759close:}
5760open:{
5761close:}
5762open:{
5763close:}
5764open:{
5765close:}
5766open:{
5767close:}
5768open:{
5769close:}
5770open:{
5771close:}
5772open:{
5773close:}
5774open:{
5775close:}
5776open:{
5777close:}
5778open:{
5779close:}
5780open:{
5781close:}
5782open:{
5783close:}
5784open:{
5785close:}
5786open:{
5787close:}
5788open:{
5789close:}
5790open:{
5791close:}
5792open:{
5793close:}
5794open:{
5795close:}
5796open:{
5797close:}
5798open:{
5799close:}
5800open:{
5801close:}
5802open:{
5803close:}
5804open:{
5805close:}
5806open:{
5807close:}
5808open:{
5809close:}
5810open:{
5811close:}
5812open:{
5813close:}
5814open:{
5815close:}
5816open:{
5817close:}
5818open:{
5819close:}
5820open:{
5821close:}
5822open:{
5823close:}
5824open:{
5825close:}
5826open:{
5827close:}
5828open:{
5829close:}
5830open:{
5831close:}
5832open:{
5833close:}
5834open:{
5835close:}
5836open:{
5837close:}
5838open:{
5839close:}
5840open:{
5841close:}
5842open:{
5843open:	if(proc->prbuf==0){
5844close:	}
5845open:	if(n+proc->nprbuf+1>proc->maxprbuf){
5846close:	}
5847close:}
5848open:{
5849close:}
5850open:{
5851close:}
5852open:{
5853close:}
5854open:{
5855close:}
5856open:long call0[]={	/* plain function, 0 arguments */
5857close:};
5858open:long call1[]={	/* plain function, 1 argument */
5859close:};
5860open:long call2[]={	/* plain function, 2 arguments */
5861close:};
5862open:long call3[]={	/* plain function, 3 arguments */
5863close:};
5864open:long call4[]={	/* plain function, 4 arguments */
5865close:};
5866open:long call5[]={	/* plain function, 5 arguments */
5867close:};
5868open:long call2_0[]={/* two-step function, 0 arguments */
5869close:};
5870open:struct{
5871close:}bltin[]={
5872open:	0,	{0,	0,	0},	0,	0,
5873close:};
5874open:{
5875close:}
5876open:{
5877close:}
5878open:{
5879open:	if(type==Sstruct){
5880close:	}else
5881close:}
5882open:{
5883open:	if(cflag){
5884close:	}
5885open:	if(errmark()){
5886close:	}
5887close:}
5888open:{
5889open:	switch(n->t){
5890open:		if(n->l->t==NCall && !bflag){
5891close:		}
5892open:		switch(n->o.t){
5893close:		}
5894open:		switch(n->o.i){
5895open:			if(eqtype(etypeof(n->l), &arychartype)){
5896close:			}
5897open:			if(isptrtype(etypeof(n->l))){
5898close:			}else
5899open:			if(retain && n->l->t==NID && isinttype(etypeof(n->l))){
5900close:			}
5901close:		}
5902open:		switch(typeof(n)->o.t){
5903open:			if(n->o.s->val->isauto){
5904close:			}else{
5905close:			}
5906open:			if(n->o.s->val->isauto){
5907close:			}else{
5908close:			}
5909close:		}
5910open:		if(nscope==1){
5911close:		}else
5912open:	case NSmash:{
5913open:		if(vr->type->o.t==TType){
5914close:		}
5915open:		if(isptrtype(vl->type)){
5916open:			if(vl->isauto){
5917close:			}else{
5918close:			}
5919close:		}
5920open:		if(vl->isauto){
5921close:		}
5922close:	}
5923open:		if(retain){
5924close:		}
5925close:	}
5926close:}
5927open:{
5928open:	if(isstr){
5929close:	}else{
5930close:	}
5931open:	if(a->t!=NID){
5932close:	}else if(a->o.s->val->isauto){
5933close:	}else{
5934close:	}
5935close:}
5936open:{
5937open:	switch(n->t){
5938open:		switch(typeof(n)->o.t){
5939open:			if(n->o.s->val->isauto){
5940close:			}
5941open:			if(n->o.s->val->isauto){
5942close:			}
5943open:			if(n->o.s->val->isauto){
5944close:			}
5945close:		}
5946close:	}
5947close:}
5948open:{
5949open:	switch(n->t){
5950open:		if(n->o.s->val->isauto){
5951close:		}
5952close:	}
5953close:}
5954open:{
5955open:	if(n->r==0){
5956close:	}
5957close:}
5958open:{
5959close:}
5960open:{
5961open:	if(n->o.i){	/* enter loop at top, so jump to body */
5962close:	}
5963open:	if(n->r->r){		/* jump to condition */
5964close:	}
5965open:	if(n->r->r){
5966close:	}else
5967close:}
5968open:{
5969close:}
5970open:{
5971open:	else{
5972open:		sprint(buf, "prog(){call on line %d}", n->line);
5973close:	}
5974open:	switch(callinst){
5975close:	}
5976close:}
5977open:{
5978close:}
5979open:{
5980open:	if(n->t==NList){
5981close:	}
5982open:	if(n->t==NArraycom){
5983close:	}else if(etypeoft(n)->o.t==TArray)
5984close:}
5985open:{
5986open:	if(n->t==NList){
5987close:	}
5988open:	if(c->o.t==\'=\'){
5989close:	}
5990open:	if(c->o.t==SND){
5991close:	}
5992open:	else if(c->t==NArraycom){
5993close:	}else
5994open:	if(c->t==NArraycom){	/* save array index */
5995close:	}
5996close:}
5997open:{
5998close:}
5999open:{
6000open:	if(s->t==NList){
6001close:	}
6002open:	else{
6003open:		if(isptr){	/* string */
6004close:		}else{
6005close:		}
6006close:	}
6007close:}
6008open:{
6009close:}
6010open:{
6011open:	if(isptrtype(s->val->type)){
6012close:	}
6013close:}
6014open:{
6015open:	if(n->t==NExprlist){
6016close:	}
6017open:	switch(t->o.t){
6018close:	}
6019close:}
6020open:{
6021open:	if(errmark()){
6022close:	}
6023close:}
6024open:{
6025open:	if(returnloc){
6026close:	}
6027close:}
6028open:{
6029open:	if(types->t==NList){
6030close:	}
6031open:	if(isptrtype(types)){
6032close:	}
6033close:}
6034open:{
6035close:}
6036open:{
6037open:	switch(t->o.t){
6038open:		else{
6039close:		}
6040open:		if(v==0){
6041close:		}
6042open:		if(t->r->o.t==TChar){
6043close:		}else
6044open:		if(v==0){
6045close:		}
6046open:		if(v==0){
6047close:		}
6048close:	}
6049close:}
6050open:{
6051open:	switch(t->o.t){
6052open:		if(isptrtype(t)){
6053close:		}else if(t->o.t==TInt || t->o.t==TUnit){
6054close:		}else if(t->o.t==TChar)
6055open:	case TStruct:{
6056close:	}
6057close:	}
6058close:}
6059open:{
6060open:	if(t->t==NList){
6061close:	}
6062open:	for(i=length(t); --i>=0; ){
6063open:		if(*pos==BPW){
6064close:		}
6065close:	}
6066close:}
6067open:{
6068open:	if(l<-2 || l>10){
6069close:	};
6070open:	switch((int)l){
6071close:	}
6072close:}
6073open:{
6074open:	switch(n->t){
6075close:	}
6076close:}
6077open:{
6078open:	switch(n->t){
6079open:		switch(n->o.i){
6080close:		}
6081open:		if(isconst(n->o.n)){
6082open:			if(topofstack()){
6083close:			}else{
6084close:			}
6085close:		}
6086close:	}
6087close:}
6088open:{
6089open:	switch(n->t){
6090open:		switch(n->o.i){
6091close:		}
6092close:	}
6093close:}
6094open:{
6095open:	switch(t->o.t){
6096open:		if(t->r->o.t==TChar){
6097close:		}
6098close:	}
6099close:}
6100open:{
6101close:}
6102open:{
6103close:}
6104open:{
6105close:}
6106open:{
6107close:}
6108open:{
6109open:	if(proc->pc==0){
6110close:	}
6111close:}
6112open:{
6113close:}
6114open:{
6115close:}
6116open:{
6117close:}
6118open:{
6119open:	if(n->t==NList){
6120close:	}
6121open:	if(n->t==NDeclsc){
6122close:	}
6123open:	if(n->r==0){
6124close:	}
6125open:	if(dotypchk){
6126open:		if(n->o.n){
6127close:		}
6128close:	}
6129open:	if(docomp && n->o.n){
6130close:	}else
6131open:	if(n->o.n && docomp && nscope==0){
6132close:	}
6133close:}
6134open:{
6135open:	if(id->t==NList){
6136close:	}
6137close:}
6138open: * 	rec {
6139close: * 	};
6140open: *	rec type T: struct of { t:T; };
6141open:{
6142open:	if(n->t==NDeclsc){
6143close:	}
6144open:	if(n->r==0){
6145close:	}else if(n->r->o.t==TType){
6146close:	}
6147close:}
6148open:{
6149open:	if(n->t==NDeclsc){
6150close:	}
6151close:}
6152open:{
6153close:}
6154open:{
6155close:}
6156open:{
6157close:}
6158open: *	prog(a:int){
6159open: *		begin prog(b:int){ f(a, b); }(b);
6160close: *	}
6161open: *	prog(a:int){
6162open: *		begin prog(b:int, a:int){ f(a, b); }(b, a);
6163close: *	}
6164open:{
6165close:}
6166open:{
6167close:}
6168open:{
6169open:	if(!alreadyformal(n, begf)){
6170close:	}
6171close:}
6172open:{
6173close:}
6174open:{
6175open:	switch(n->t){
6176open:		if(0<n->o.s->val->scope && n->o.s->val->scope<fscope){
6177close:		}
6178close:	}
6179close:}
6180open:{
6181close:}
6182open:{
6183close:}
6184open:{
6185close:}
6186open:{
6187close:}
6188open:{
6189close:}
6190open:{
6191close:}
6192open:{
6193close:}
6194open:{
6195close:}
6196open:{
6197close:}
6198open:prbuf(){
6199close:}
6200open:{
6201open:	else{
6202open:		switch(t){
6203close:		}
6204close:	}
6205close:}
6206open:{
6207open:	switch(n->t){
6208open:{
6209open:	else if (c != n) {
6210close:	} else if(rebuf->w == rebuf->s)
6211open:	else {
6212open:		if (sub) {
6213close:		}
6214close:	}
6215close:}
6216open:{
6217open:	if(code && code != REG_NOMATCH) {
6218close:	}
6219close:}
6220open:{
6221close:}
6222open:{
6223open:	if(n = regsubexec(re, (char*)data->s, elementsof(matches), matches)) {
6224close:	}
6225close:}'
6226	EXEC	-h -m -e include:include -e define:define g6.dat g7.dat
6227		OUTPUT - $'include:#include "alloc.h"
6228include:#include <libc.h>
6229include:#include "alloc.h"
6230include:#include "word.h"
6231include:#include "store.h"
6232include:#include "comm.h"
6233include:#include <libc.h>
6234include:#include "node.h"
6235include:#include "symbol.h"
6236include:#include "alloc.h"
6237include:#include "word.h"
6238include:#include "store.h"
6239include:#include "comm.h"
6240include:#include "inst.h"
6241include:#include <libc.h>
6242define:#define	FNS
6243include:#include "lib.h"
6244define:#define	C	0x40000000
6245define:#define	I	0x20000000
6246define:#define	F	0x10000000
6247define:#define	M(x)	((x)&~(C|I|F))
6248include:#include "lib.h"
6249include:#include "node.h"
6250include:#include "symbol.h"
6251include:#include "alloc.h"
6252include:#include "ydefs.h"
6253include:#include "word.h"
6254include:#include "store.h"
6255include:#include "comm.h"
6256include:#include "inst.h"
6257include:#include "errjmp.h"
6258include:#include <libc.h>
6259include:#include "alloc.h"
6260include:#include "node.h"
6261include:#include "symbol.h"
6262include:#include "ydefs.h"
6263include:#include "word.h"
6264include:#include "store.h"
6265include:#include <libc.h>
6266include:#include "alloc.h"
6267include:#include "word.h"
6268include:#include "store.h"
6269include:#include "comm.h"
6270include:#include <libc.h>
6271include:	nargs+=2;	/* includes result and sym; add pc, fp */
6272include:#include "node.h"
6273include:#include "symbol.h"
6274include:#include "alloc.h"
6275include:#include "ydefs.h"
6276include:#include "word.h"
6277include:#include "store.h"
6278include:#include <libc.h>
6279include:#include "nodenames.h"
6280include:#include "typenames.h"
6281include:#include "errjmp.h"
6282include:#include "node.h"
6283include:#include "symbol.h"
6284include:#include "ydefs.h"
6285include:#include <libc.h>
6286include:#include "sed.h" /* define sed stuff */'
6287	EXEC	-c -h -m -e open:{ -e close:} g6.dat g7.dat
6288		OUTPUT - $'open:227
6289close:231
6290open:9
6291close:9'
6292	EXEC	-c -h -m -e include:include -e define:define g6.dat g7.dat
6293		OUTPUT - $'include:54
6294define:5
6295include:1
6296define:0'
6297	EXEC	-t -m -e open:{ -e close:} g6.dat g7.dat
6298		OUTPUT - $'open:236
6299close:240'
6300	EXEC	-t -m -e include:include -e define:define g6.dat g7.dat
6301		OUTPUT - $'include:55
6302define:5'
6303
6304TEST 15 '-x with -e'
6305
6306	for op in '' -E -F
6307	do
6308
6309	EXEC	$op -x $'aa'
6310		INPUT - $'aa\naabbcc\nbb\nbbccdd\ncc\nccddee'
6311		OUTPUT - $'aa'
6312	EXEC	$op -x -e $'aa'
6313	EXEC	$op -x -e $'aa' -e $'bb'
6314		OUTPUT - $'aa\nbb'
6315	EXEC	$op -x $'aa\nbb'
6316	EXEC	$op -x -e $'aa\nbb'
6317	EXEC	$op -x -e $'aa' -e $'bb' -e $'cc'
6318		OUTPUT - $'aa\nbb\ncc'
6319	EXEC	$op -x -e $'aa\nbb' -e $'cc'
6320	EXEC	$op -x $'aa\nbb\ncc'
6321
6322	done
6323
6324TEST 16 'ast bm checks'
6325
6326	EXEC	'\(ab$\)'
6327		INPUT - $'abcdefghijklmnopqrstuvwxyz'
6328		OUTPUT -
6329		EXIT 1
6330	EXEC	'\(abcdef$\)'
6331	EXEC	'\(abcdefghijklmnopqrstuvwxy$\)'
6332	EXEC	-E '(ab$)'
6333	EXEC	-E '(abcdef$)'
6334	EXEC	'(abcdefghijklmnopqrstuvwxy$)'
6335
6336TEST 17 '--only-matching'
6337
6338	EXEC	-o 'foo.*bar'
6339		INPUT - $'123\nfoo-bar foo-yoyo-bar fixfoofuxbaxbarbox\n567'
6340		OUTPUT - $'foo-bar foo-yoyo-bar fixfoofuxbaxbar'
6341	EXEC	-o 'foo[^[:space:]]*bar'
6342		OUTPUT - $'foo-bar\nfoo-yoyo-bar\nfoofuxbaxbar'
6343
6344TEST 18 '--context[=before[,after]]'
6345
6346	EXEC	-C2 X i
6347		INPUT i $'A1\nX2\nX3\nX4\nX5\nA6\nA7\nA8\nA9\nA10\nX11X\nA12A'
6348		OUTPUT - $'A1\nX2\nX3\nX4\nX5\nA6\nA7\n--\nA9\nA10\nX11X\nA12A'
6349
6350	EXEC	-n -C2 X i
6351		OUTPUT - $'1-A1\n2:X2\n3:X3\n4:X4\n5:X5\n6-A6\n7-A7\n--\n9-A9\n10-A10\n11:X11X\n12-A12A'
6352
6353	EXEC	-H -C2 X i
6354		OUTPUT - $'i-A1\ni:X2\ni:X3\ni:X4\ni:X5\ni-A6\ni-A7\n--\ni-A9\ni-A10\ni:X11X\ni-A12A'
6355
6356	EXEC	-H -n -C2 X i
6357		OUTPUT - $'i-1-A1\ni:2:X2\ni:3:X3\ni:4:X4\ni:5:X5\ni-6-A6\ni-7-A7\n--\ni-9-A9\ni-10-A10\ni:11:X11X\ni-12-A12A'
6358
6359	EXEC	-o -C2 X i
6360		OUTPUT - $'X\nX\nX\nX\n--\nX\nX'
6361
6362	EXEC	-o -n -C2 X i
6363		OUTPUT - $'2:X\n3:X\n4:X\n5:X\n--\n11:X\n11:X'
6364
6365	EXEC	-o -H -C2 X i
6366		OUTPUT - $'i:X\ni:X\ni:X\ni:X\n--\ni:X\ni:X'
6367
6368	EXEC	-o -H -n -C2 X i
6369		OUTPUT - $'i:2:X\ni:3:X\ni:4:X\ni:5:X\n--\ni:11:X\ni:11:X'
6370
6371	EXEC	-B0 -A1 '[24]'
6372		INPUT - $'1\n2\n3\n4\n5\n6\n7\n8\n9'
6373		OUTPUT - $'2\n3\n4\n5'
6374
6375	EXEC	-C0,1 '[24]'
6376
6377	EXEC	-C,1 '[24]'
6378
6379	EXEC	-B0 -A1 '[25]'
6380		OUTPUT - $'2\n3\n--\n5\n6'
6381
6382	EXEC	-C0,1 '[25]'
6383
6384	EXEC	-C,1 '[25]'
6385
6386	EXEC	-B1 -A1 '[25]'
6387		OUTPUT - $'1\n2\n3\n4\n5\n6'
6388
6389	EXEC	-C1,1 '[25]'
6390
6391	EXEC	-C1 '[25]'
6392
6393	EXEC	-B1 -A1 '[26]'
6394		OUTPUT - $'1\n2\n3\n--\n5\n6\n7'
6395
6396	EXEC	-C1,1 '[26]'
6397
6398	EXEC	-C1 '[26]'
6399