12086Smckusick /* Copyright (c) 1979 Regents of the University of California */ 22086Smckusick 3*15840Saoki static char sccsid[] = "@(#)langpats.c 1.16 01/11/84"; 42086Smckusick 52086Smckusick #include <stdio.h> 62086Smckusick #include <ctype.h> 72086Smckusick /* 82086Smckusick * The hash table must be at least twice as big as the number 92086Smckusick * of patterns, preferably bigger. It must also be a prime number 102086Smckusick */ 112086Smckusick #define HSHSIZ 101 122086Smckusick 1311877Smckusick #ifdef vax 1411877Smckusick #define CALLTEMPLATE "calls\t$" 1511877Smckusick #define TEMPLATESIZE 7 1611877Smckusick #endif vax 1711877Smckusick 1811877Smckusick #ifdef mc68000 1911877Smckusick #define CALLTEMPLATE "jbsr\t" 2011877Smckusick #define TEMPLATESIZE 5 2111877Smckusick #endif mc68000 2211877Smckusick 232086Smckusick struct pats { 242086Smckusick char *name; 252086Smckusick char *replace; 262086Smckusick } ptab[] = { 272086Smckusick 2811877Smckusick #ifdef vax 299141Smckusick /* 309141Smckusick * C library routines 319141Smckusick */ 322189Smckusic { "1,_fgetc\n", 332189Smckusic " sobgeq *(sp),1f\n\ 342086Smckusick calls $1,__filbuf\n\ 352086Smckusick jbr 2f\n\ 362086Smckusick 1:\n\ 372086Smckusick addl3 $4,(sp)+,r1\n\ 382086Smckusick movzbl *(r1),r0\n\ 392086Smckusick incl (r1)\n\ 402086Smckusick 2:\n" }, 412086Smckusick 422189Smckusic { "2,_fputc\n", 432189Smckusic " sobgeq *4(sp),1f\n\ 442086Smckusick calls $2,__flsbuf\n\ 452086Smckusick jbr 2f\n\ 462086Smckusick 1:\n\ 472195Smckusic popr $0x3\n\ 482195Smckusic movb r0,*4(r1)\n\ 492195Smckusic incl 4(r1)\n\ 502086Smckusick 2:\n" }, 512086Smckusick 529141Smckusick /* 539141Smckusick * VAX special instructions 549141Smckusick */ 552189Smckusic { "3,_blkcpy\n", 569141Smckusick " popr $0xa\n\ 572195Smckusic jbr 2f\n\ 582086Smckusick 1:\n\ 592195Smckusic subl2 r0,(sp)\n\ 602195Smckusic movc3 r0,(r1),(r3)\n\ 612195Smckusic 2:\n\ 622086Smckusick movzwl $65535,r0\n\ 632086Smckusick cmpl (sp),r0\n\ 642195Smckusic jgtr 1b\n\ 654015Smckusic movl (sp)+,r0\n\ 662086Smckusick movc3 r0,(r1),(r3)\n" }, 672086Smckusick 682189Smckusic { "2,_blkclr\n", 699141Smckusick " movl (sp)+,r3\n\ 702189Smckusic jbr 2f\n\ 712086Smckusick 1:\n\ 722189Smckusic subl2 r0,(sp)\n\ 732189Smckusic movc5 $0,(r3),$0,r0,(r3)\n\ 742189Smckusic 2:\n\ 752086Smckusick movzwl $65535,r0\n\ 762086Smckusick cmpl (sp),r0\n\ 772189Smckusic jgtr 1b\n\ 789141Smckusick movl (sp)+,r0\n\ 792189Smckusic movc5 $0,(r3),$0,r0,(r3)\n" }, 802086Smckusick 812189Smckusic { "3,_LOCC\n", 822195Smckusic " popr $0x30\n\ 834015Smckusic movl (sp)+,r1\n\ 842086Smckusick 1:\n\ 852086Smckusick movzwl $65535,r0\n\ 862195Smckusic cmpl r5,r0\n\ 872102Smckusic jleq 1f\n\ 882195Smckusic subl2 r0,r5\n\ 892195Smckusic locc r4,r0,(r1)\n\ 902102Smckusic jeql 1b\n\ 912195Smckusic addl2 r5,r0\n\ 922102Smckusic jbr 2f\n\ 932086Smckusick 1:\n\ 942195Smckusic locc r4,r5,(r1)\n\ 952086Smckusick 2:\n" }, 962086Smckusick 972962Smckusic { "2,_ROUND\n", 982086Smckusick " cvtrdl (sp)+,r0\n" }, 992086Smckusick 1002962Smckusic { "2,_TRUNC\n", 1012086Smckusick " cvtdl (sp)+,r0\n" }, 1022086Smckusick 1039141Smckusick /* 1049141Smckusick * General Pascal library routines 1059141Smckusick */ 1069141Smckusick { "1,_ACTFILE\n", 1079141Smckusick " movl (sp)+,r1\n\ 1089141Smckusick movl 12(r1),r0\n" }, 1099141Smckusick 1103437Smckusic { "2,_FCALL\n", 1113437Smckusic " movl 4(sp),r0\n\ 1124015Smckusic movc3 4(r0),__disply+8,*(sp)+\n\ 1133437Smckusic movl (sp)+,r0\n\ 1144015Smckusic movc3 4(r0),8(r0),__disply+8\n" }, 1152086Smckusick 1162189Smckusic { "2,_FRTN\n", 1173437Smckusic " movl (sp)+,r0\n\ 1184015Smckusic movc3 4(r0),*(sp)+,__disply+8\n" }, 1192086Smckusick 1202189Smckusic { "3,_FSAV\n", 1212086Smckusick " movl 8(sp),r0\n\ 1222086Smckusick movl (sp)+,(r0)\n\ 1234015Smckusic ashl $3,(sp)+,4(r0)\n\ 1244015Smckusic movc3 4(r0),__disply+8,8(r0)\n\ 1254015Smckusic movl (sp)+,r0\n" }, 1262086Smckusick 1279141Smckusick /* 1289141Smckusick * Pascal relational comparisons 1299141Smckusick */ 1302189Smckusic { "3,_RELEQ\n", 1314015Smckusic " popr $0xb\n\ 1324015Smckusic movl r0,r4\n\ 1332102Smckusic 1:\n\ 1342102Smckusic movzwl $65535,r0\n\ 1352102Smckusic cmpl r4,r0\n\ 1362195Smckusic jleq 3f\n\ 1372102Smckusic subl2 r0,r4\n\ 1382102Smckusic cmpc3 r0,(r1),(r3)\n\ 1392102Smckusic jeql 1b\n\ 1402102Smckusic 2:\n\ 1412195Smckusic clrl r0\n\ 1422195Smckusic jbr 4f\n\ 1432195Smckusic 3:\n\ 1442102Smckusic cmpc3 r4,(r1),(r3)\n\ 1452195Smckusic jneq 2b\n\ 1462102Smckusic incl r0\n\ 1472102Smckusic 4:\n" }, 1482086Smckusick 1492189Smckusic { "3,_RELNE\n", 1504015Smckusic " popr $0xb\n\ 1514015Smckusic movl r0,r4\n\ 1522086Smckusick 1:\n\ 1532102Smckusic movzwl $65535,r0\n\ 1542102Smckusic cmpl r4,r0\n\ 1552195Smckusic jleq 3f\n\ 1562102Smckusic subl2 r0,r4\n\ 1572102Smckusic cmpc3 r0,(r1),(r3)\n\ 1582102Smckusic jeql 1b\n\ 1592102Smckusic 2:\n\ 1602195Smckusic movl $1,r0\n\ 1612195Smckusic jbr 4f\n\ 1622195Smckusic 3:\n\ 1632102Smckusic cmpc3 r4,(r1),(r3)\n\ 1642195Smckusic jneq 2b\n\ 1652102Smckusic 4:\n" }, 1662086Smckusick 1672189Smckusic { "3,_RELSLT\n", 1684015Smckusic " popr $0xb\n\ 1694015Smckusic movl r0,r4\n\ 1702195Smckusic jbr 2f\n\ 1712102Smckusic 1:\n\ 1722102Smckusic subl2 r0,r4\n\ 1732102Smckusic cmpc3 r0,(r1),(r3)\n\ 1742195Smckusic jneq 3f\n\ 1752102Smckusic 2:\n\ 1762195Smckusic movzwl $65535,r0\n\ 1772195Smckusic cmpl r4,r0\n\ 1782195Smckusic jgtr 1b\n\ 1792102Smckusic cmpc3 r4,(r1),(r3)\n\ 1802102Smckusic 3:\n\ 1812102Smckusic jlss 4f\n\ 1822086Smckusick clrl r0\n\ 1832102Smckusic jbr 5f\n\ 1842102Smckusic 4:\n\ 1852086Smckusick movl $1,r0\n\ 1862102Smckusic 5:\n" }, 1872086Smckusick 1882189Smckusic { "3,_RELSLE\n", 1894015Smckusic " popr $0xb\n\ 1904015Smckusic movl r0,r4\n\ 1912195Smckusic jbr 2f\n\ 1922102Smckusic 1:\n\ 1932102Smckusic subl2 r0,r4\n\ 1942102Smckusic cmpc3 r0,(r1),(r3)\n\ 1952195Smckusic jneq 3f\n\ 1962102Smckusic 2:\n\ 1972195Smckusic movzwl $65535,r0\n\ 1982195Smckusic cmpl r4,r0\n\ 1992195Smckusic jgtr 1b\n\ 2002102Smckusic cmpc3 r4,(r1),(r3)\n\ 2012102Smckusic 3:\n\ 2022102Smckusic jleq 4f\n\ 2032086Smckusick clrl r0\n\ 2042102Smckusic jbr 5f\n\ 2052102Smckusic 4:\n\ 2062086Smckusick movl $1,r0\n\ 2072102Smckusic 5:\n" }, 2082086Smckusick 2092189Smckusic { "3,_RELSGT\n", 2104015Smckusic " popr $0xb\n\ 2114015Smckusic movl r0,r4\n\ 2122195Smckusic jbr 2f\n\ 2132102Smckusic 1:\n\ 2142102Smckusic subl2 r0,r4\n\ 2152102Smckusic cmpc3 r0,(r1),(r3)\n\ 2162195Smckusic jneq 3f\n\ 2172102Smckusic 2:\n\ 2182195Smckusic movzwl $65535,r0\n\ 2192195Smckusic cmpl r4,r0\n\ 2202195Smckusic jgtr 1b\n\ 2212102Smckusic cmpc3 r4,(r1),(r3)\n\ 2222102Smckusic 3:\n\ 2232102Smckusic jgtr 4f\n\ 2242086Smckusick clrl r0\n\ 2252102Smckusic jbr 5f\n\ 2262102Smckusic 4:\n\ 2272086Smckusick movl $1,r0\n\ 2282102Smckusic 5:\n" }, 2292086Smckusick 2302189Smckusic { "3,_RELSGE\n", 2314015Smckusic " popr $0xb\n\ 2324015Smckusic movl r0,r4\n\ 2332195Smckusic jbr 2f\n\ 2342102Smckusic 1:\n\ 2352102Smckusic subl2 r0,r4\n\ 2362102Smckusic cmpc3 r0,(r1),(r3)\n\ 2372195Smckusic jneq 3f\n\ 2382102Smckusic 2:\n\ 2392195Smckusic movzwl $65535,r0\n\ 2402195Smckusic cmpl r4,r0\n\ 2412195Smckusic jgtr 1b\n\ 2422102Smckusic cmpc3 r4,(r1),(r3)\n\ 2432102Smckusic 3:\n\ 2442102Smckusic jgeq 4f\n\ 2452086Smckusick clrl r0\n\ 2462102Smckusic jbr 5f\n\ 2472102Smckusic 4:\n\ 2482086Smckusick movl $1,r0\n\ 2492102Smckusic 5:\n" }, 2502086Smckusick 2519141Smckusick /* 2529141Smckusick * Pascal set operations. 2539141Smckusick */ 2542189Smckusic { "4,_ADDT\n", 2552195Smckusic " popr $0x17\n\ 2562086Smckusick movl r0,r3\n\ 2572086Smckusick 1:\n\ 2582086Smckusick bisl3 (r1)+,(r2)+,(r3)+\n\ 2592086Smckusick sobgtr r4,1b\n" }, 2602086Smckusick 2612189Smckusic { "4,_SUBT\n", 2622195Smckusic " popr $0x17\n\ 2632086Smckusick movl r0,r3\n\ 2642086Smckusick 1:\n\ 2652086Smckusick bicl3 (r2)+,(r1)+,(r3)+\n\ 2662086Smckusick sobgtr r4,1b\n" }, 2672086Smckusick 2682189Smckusic { "4,_MULT\n", 2692195Smckusic " popr $0x17\n\ 2702086Smckusick movl r0,r3\n\ 2712086Smckusick 1:\n\ 2722086Smckusick mcoml (r1)+,r5\n\ 2732086Smckusick bicl3 r5,(r2)+,(r3)+\n\ 2742086Smckusick sobgtr r4,1b\n" }, 2752086Smckusick 2762189Smckusic { "4,_IN\n", 2772230Smckusic " popr $0x1e\n\ 2782230Smckusic clrl r0\n\ 2792195Smckusic subl2 r2,r1\n\ 2802195Smckusic cmpl r1,r3\n\ 2812102Smckusic jgtru 1f\n\ 2822195Smckusic jbc r1,(r4),1f\n\ 2832195Smckusic incl r0\n\ 2849141Smckusick 1:\n" }, 2859141Smckusick 2869141Smckusick /* 2879141Smckusick * Pascal runtime checks 2889141Smckusick */ 2899141Smckusick { "1,_ASRT\n", 2909141Smckusick " tstl (sp)+\n\ 2919141Smckusick jneq 1f\n\ 2929141Smckusick pushl $0\n\ 2939141Smckusick pushl $_EASRT\n\ 2949141Smckusick calls $2,_ERROR\n\ 2959141Smckusick 1:\n" }, 2969141Smckusick 2979141Smckusick { "2,_ASRTS\n", 2989141Smckusick " popr $0x03\n\ 2999141Smckusick tstl r0\n\ 3009141Smckusick jneq 1f\n\ 3019141Smckusick pushl r1\n\ 3029141Smckusick pushl $_EASRTS\n\ 3039141Smckusick calls $2,_ERROR\n\ 3049141Smckusick 1:\n" }, 3059141Smckusick 3069141Smckusick { "1,_CHR\n", 3079141Smckusick " movl (sp)+,r0\n\ 3089141Smckusick cmpl r0,$127\n\ 3099141Smckusick jlequ 1f\n\ 3109141Smckusick pushl r0\n\ 3119141Smckusick pushl $_ECHR\n\ 3129141Smckusick calls $2,_ERROR\n\ 3139141Smckusick 1:\n" }, 3149141Smckusick 3159141Smckusick { "0,_LINO\n", 3169141Smckusick " incl __stcnt\n\ 3179141Smckusick cmpl __stcnt,__stlim\n\ 3189141Smckusick jlss 1f\n\ 3199141Smckusick pushl __stcnt\n\ 3209141Smckusick pushl $_ELINO\n\ 3219141Smckusick calls $2,_ERROR\n\ 3229141Smckusick 1:\n" }, 3239141Smckusick 3249141Smckusick { "1,_NIL\n", 3259141Smckusick " movl (sp)+,r0\n\ 3269141Smckusick cmpl r0,__maxptr\n\ 3279141Smckusick jgtr 1f\n\ 3289141Smckusick cmpl r0,__minptr\n\ 3299141Smckusick jgeq 2f\n\ 3309141Smckusick 1:\n\ 3319141Smckusick pushl $0\n\ 3329141Smckusick pushl $_ENIL\n\ 3339141Smckusick calls $2,_ERROR\n\ 3349141Smckusick 2:\n" }, 3359141Smckusick 3369141Smckusick { "2,_RANDOM\n", 3379141Smckusick " addl2 $8,sp\n\ 3389141Smckusick emul __seed,$1103515245,$0,r0\n\ 3399141Smckusick ediv $0x7fffffff,r0,r1,r0\n\ 3409141Smckusick movl r0,__seed\n\ 3419141Smckusick cvtld r0,r0\n\ 3429141Smckusick divd2 $0d2.147483647e+09,r0\n" }, 3439141Smckusick 3449141Smckusick { "3,_RANG4\n", 3459141Smckusick " popr $0x07\n\ 3469141Smckusick cmpl r0,r1\n\ 3479141Smckusick jlss 1f\n\ 3489141Smckusick cmpl r0,r2\n\ 3499141Smckusick jleq 2f\n\ 3509141Smckusick 1:\n\ 3519141Smckusick pushl r0\n\ 3529141Smckusick pushl $_ERANG\n\ 3539141Smckusick calls $2,_ERROR\n\ 3549141Smckusick 2:\n" }, 3559141Smckusick 3569141Smckusick { "2,_RSNG4\n", 3579141Smckusick " popr $0x03\n\ 3589141Smckusick cmpl r0,r1\n\ 3599141Smckusick jlequ 1f\n\ 3609141Smckusick pushl r0\n\ 3619141Smckusick pushl $_ERANG\n\ 3629141Smckusick calls $2,_ERROR\n\ 3639141Smckusick 1:\n" }, 3649141Smckusick 3659141Smckusick { "1,_SEED\n", 3669141Smckusick " movl __seed,r0\n\ 3679141Smckusick movl (sp)+,__seed\n" }, 3689141Smckusick 3699141Smckusick { "3,_SUBSC\n", 3709141Smckusick " popr $0x07\n\ 3719141Smckusick cmpl r0,r1\n\ 3729141Smckusick jlss 1f\n\ 3739141Smckusick cmpl r0,r2\n\ 3749141Smckusick jleq 2f\n\ 3759141Smckusick 1:\n\ 3769141Smckusick pushl r0\n\ 3779141Smckusick pushl $_ESUBSC\n\ 3789141Smckusick calls $2,_ERROR\n\ 3799141Smckusick 2:\n" }, 3809141Smckusick 3819141Smckusick { "2,_SUBSCZ\n", 3829141Smckusick " popr $0x03\n\ 3839141Smckusick cmpl r0,r1\n\ 3849141Smckusick jlequ 1f\n\ 3859141Smckusick pushl r0\n\ 3869141Smckusick pushl $_ESUBSC\n\ 3879141Smckusick calls $2,_ERROR\n\ 3889141Smckusick 1:\n" }, 38911877Smckusick #endif vax 3909141Smckusick 39111877Smckusick #ifdef mc68000 39212871Smckusick 39312871Smckusick /* 39412871Smckusick * General Pascal library routines 39512871Smckusick */ 39612871Smckusick { "_ACTFILE\n", 39712871Smckusick " movl sp@,a0\n\ 39812871Smckusick movl a0@(12),d0\n" }, 39912871Smckusick 40012871Smckusick { "_ADDT\n", 40112871Smckusick " movl a2,sp@-\n\ 40212871Smckusick movl sp@(8),a2\n\ 40312871Smckusick movl sp@(12),a1\n\ 40412871Smckusick movl sp@(4),a0\n\ 40512871Smckusick movl sp@(16),d1\n\ 40612871Smckusick subql #1,d1\n\ 40712871Smckusick 1:\n\ 40812871Smckusick movl a2@+,d0\n\ 40912871Smckusick orl a1@+,d0\n\ 41012871Smckusick movl d0,a0@+\n\ 41112871Smckusick dbra d1,1b\n\ 41212871Smckusick movl sp@+,a2\n\ 41312871Smckusick movl sp@,d0\n" }, 41412871Smckusick 41512871Smckusick { "_SUBT\n", 41612871Smckusick " movl a2,sp@-\n\ 41712871Smckusick movl sp@(8),a2\n\ 41812871Smckusick movl sp@(12),a1\n\ 41912871Smckusick movl sp@(4),a0\n\ 42012871Smckusick movl sp@(16),d1\n\ 42112871Smckusick subql #1,d1\n\ 42212871Smckusick 1:\n\ 42312871Smckusick movl a1@+,d0\n\ 42412871Smckusick notl d0\n\ 42512871Smckusick andl a2@+,d0\n\ 42612871Smckusick movl d0,a0@+\n\ 42712871Smckusick dbra d1,1b\n\ 42812871Smckusick movl sp@+,a2\n\ 42912871Smckusick movl sp@,d0\n" }, 43012871Smckusick 43112871Smckusick { "_MULT\n", 43212871Smckusick " movl a2,sp@-\n\ 43312871Smckusick movl sp@(8),a2\n\ 43412871Smckusick movl sp@(12),a1\n\ 43512871Smckusick movl sp@(4),a0\n\ 43612871Smckusick movl sp@(16),d1\n\ 43712871Smckusick subql #1,d1\n\ 43812871Smckusick 1:\n\ 43912871Smckusick movl a2@+,d0\n\ 44012871Smckusick andl a1@+,d0\n\ 44112871Smckusick movl d0,a0@+\n\ 44212871Smckusick dbra d1,1b\n\ 44312871Smckusick movl sp@+,a2\n\ 44412871Smckusick movl sp@,d0\n" }, 44512871Smckusick 44612871Smckusick { "_IN\n", 44712871Smckusick " movl sp@,d1\n\ 44812871Smckusick subl sp@(4),d1\n\ 44912871Smckusick cmpl sp@(8),d1\n\ 45015124Speter jhi 1f\n\ 45112871Smckusick movl sp@(12),a0\n\ 45212871Smckusick movl d1,d0\n\ 45312871Smckusick lsrl #3,d0\n\ 45412871Smckusick btst d1,a0@(0,d0:l)\n\ 45515124Speter jeq 1f\n\ 45612871Smckusick moveq #1,d0\n\ 45715124Speter jra 2f\n\ 45812871Smckusick 1:\n\ 45912871Smckusick moveq #0,d0\n\ 46012871Smckusick 2:\n" }, 461*15840Saoki { "_RANG4\n", 462*15840Saoki " movl sp@,d0\n\ 463*15840Saoki cmpl sp@(4),d0\n\ 464*15840Saoki jlt 1f\n\ 465*15840Saoki cmpl sp@(8),d0\n\ 466*15840Saoki jle 2f\n\ 467*15840Saoki 1:\n\ 468*15840Saoki pea _ERANG\n\ 469*15840Saoki jbsr _ERROR\n\ 470*15840Saoki addqw #4,sp\n\ 471*15840Saoki 2:\n" }, 472*15840Saoki { "_RSNG4\n", 473*15840Saoki " movl sp@,d0\n\ 474*15840Saoki cmpl sp@(4),d0\n\ 475*15840Saoki jls 1f\n\ 476*15840Saoki pea _ERANG\n\ 477*15840Saoki jbsr _ERROR\n\ 478*15840Saoki addqw #4,sp\n\ 479*15840Saoki 1:\n" }, 480*15840Saoki 48111877Smckusick #endif mc68000 48211877Smckusick 4832086Smckusick }; 4842086Smckusick 4852086Smckusick struct pats *htbl[HSHSIZ]; 4862086Smckusick 4872086Smckusick 4882086Smckusick #define HASH(cp, hp) {\ 4892086Smckusick hash = 0; rehash = 1; ccp = cp; \ 4902086Smckusick do { \ 4912086Smckusick hash *= (int)*ccp++; \ 4922086Smckusick } while (*ccp && *ccp != '\n'); \ 4932086Smckusick hash >>= 7; hash %= HSHSIZ; hp = &htbl[hash]; size = ccp - cp + 1; \ 4942086Smckusick } 4952086Smckusick 4962086Smckusick #define REHASH(hp) {\ 4972086Smckusick hp += rehash; rehash += 2; \ 4982086Smckusick if (hp >= &htbl[HSHSIZ]) \ 4992086Smckusick hp -= HSHSIZ; \ 5002086Smckusick } 5012086Smckusick 5022086Smckusick 5032086Smckusick main(argc, argv) 5042086Smckusick 5052086Smckusick int argc; 5062086Smckusick char **argv; 5072086Smckusick { 5082086Smckusick register struct pats *pp; 5092086Smckusick register struct pats **hp; 5102341Smckusic register char *cp, *ccp, *lp; 5112086Smckusick register int hash, rehash, size; 5122086Smckusick char line[BUFSIZ]; 5132341Smckusic extern char *index(); 5142086Smckusick 5152086Smckusick if (argc > 1) 5162086Smckusick freopen(argv[1], "r", stdin); 5172086Smckusick if (argc > 2) 5182086Smckusick freopen(argv[2], "w", stdout); 5192086Smckusick /* 5202086Smckusick * set up the hash table 5212086Smckusick */ 5222086Smckusick for(pp = ptab; pp < &ptab[sizeof ptab/sizeof ptab[0]]; pp++) { 5232086Smckusick HASH(pp->name, hp); 5242086Smckusick while (*hp) 5252086Smckusick REHASH(hp); 5262086Smckusick *hp = pp; 5272086Smckusick } 5282086Smckusick /* 5292086Smckusick * check each line and replace as appropriate 5302086Smckusick */ 5312086Smckusick while (fgets(line, BUFSIZ, stdin)) { 5322341Smckusic lp = index(line, ':'); 5332341Smckusic for (cp = (lp != NULL) ? ++lp : line; *cp == '\t'; ) 5342086Smckusick cp++; 53515684Speter if (strncmp(cp, CALLTEMPLATE, TEMPLATESIZE) != 0) { 5362341Smckusic fputs(line, stdout); 5372341Smckusic continue; 5382341Smckusic } 53912871Smckusick cp += TEMPLATESIZE; 5402086Smckusick HASH(cp, hp); 5412086Smckusick while (*hp) { 54215684Speter if (strncmp((*hp)->name, cp, size)==NULL) { 5432341Smckusic if (lp != NULL) { 5442341Smckusic *lp++ = '\n'; 5452341Smckusic *lp = '\0'; 5462341Smckusic fputs(line, stdout); 5472341Smckusic } 5482086Smckusick fputs((*hp)->replace, stdout); 5492086Smckusick goto nextline; 5502086Smckusick } 5512086Smckusick REHASH(hp); 5522086Smckusick } 5532086Smckusick fputs(line, stdout); 5542086Smckusick nextline:; 5552086Smckusick } 5562086Smckusick exit(0); 5572086Smckusick } 558