11177Sbill /* Yacc productions for "expr" command: */ 21177Sbill 31177Sbill %token OR AND ADD SUBT MULT DIV REM EQ GT GEQ LT LEQ NEQ 41177Sbill %token A_STRING SUBSTR LENGTH INDEX NOARG MATCH 51177Sbill 61177Sbill /* operators listed below in increasing precedence: */ 71177Sbill %left OR 81177Sbill %left AND 91177Sbill %left EQ LT GT GEQ LEQ NEQ 101177Sbill %left ADD SUBT 111177Sbill %left MULT DIV REM 121177Sbill %left MCH 131177Sbill %left MATCH 141177Sbill %left SUBSTR 151177Sbill %left LENGTH INDEX 161177Sbill %% 171177Sbill 181177Sbill /* a single `expression' is evaluated and printed: */ 191177Sbill 201177Sbill expression: expr NOARG = { 211177Sbill printf("%s\n", $1); 221177Sbill exit((!strcmp($1,"0")||!strcmp($1,"\0"))? 1: 0); 231177Sbill } 241177Sbill ; 251177Sbill 261177Sbill 271177Sbill expr: '(' expr ')' = { $$ = $2; } 281177Sbill | expr OR expr = { $$ = conj(OR, $1, $3); } 291177Sbill | expr AND expr = { $$ = conj(AND, $1, $3); } 301177Sbill | expr EQ expr = { $$ = rel(EQ, $1, $3); } 311177Sbill | expr GT expr = { $$ = rel(GT, $1, $3); } 321177Sbill | expr GEQ expr = { $$ = rel(GEQ, $1, $3); } 331177Sbill | expr LT expr = { $$ = rel(LT, $1, $3); } 341177Sbill | expr LEQ expr = { $$ = rel(LEQ, $1, $3); } 351177Sbill | expr NEQ expr = { $$ = rel(NEQ, $1, $3); } 361177Sbill | expr ADD expr = { $$ = arith(ADD, $1, $3); } 371177Sbill | expr SUBT expr = { $$ = arith(SUBT, $1, $3); } 381177Sbill | expr MULT expr = { $$ = arith(MULT, $1, $3); } 391177Sbill | expr DIV expr = { $$ = arith(DIV, $1, $3); } 401177Sbill | expr REM expr = { $$ = arith(REM, $1, $3); } 411177Sbill | expr MCH expr = { $$ = match($1, $3); } 421177Sbill | MATCH expr expr = { $$ = match($2, $3); } 431177Sbill | SUBSTR expr expr expr = { $$ = substr($2, $3, $4); } 441177Sbill | LENGTH expr = { $$ = length($2); } 451177Sbill | INDEX expr expr = { $$ = index($2, $3); } 461177Sbill | A_STRING 471177Sbill ; 481177Sbill %% 491177Sbill /* expression command */ 501177Sbill #include <stdio.h> 511177Sbill #define ESIZE 256 521177Sbill #define error(c) errxx(c) 531177Sbill #define EQL(x,y) !strcmp(x,y) 541177Sbill long atol(); 551177Sbill char **Av; 561177Sbill int Ac; 571177Sbill int Argi; 581177Sbill 591177Sbill char Mstring[1][128]; 601177Sbill char *malloc(); 611177Sbill extern int nbra; 621177Sbill 631177Sbill main(argc, argv) char **argv; { 641177Sbill Ac = argc; 651177Sbill Argi = 1; 661177Sbill Av = argv; 671177Sbill yyparse(); 681177Sbill } 691177Sbill 701177Sbill char *operators[] = { "|", "&", "+", "-", "*", "/", "%", ":", 711177Sbill "=", "==", "<", "<=", ">", ">=", "!=", 721177Sbill "match", "substr", "length", "index", "\0" }; 731177Sbill int op[] = { OR, AND, ADD, SUBT, MULT, DIV, REM, MCH, 741177Sbill EQ, EQ, LT, LEQ, GT, GEQ, NEQ, 751177Sbill MATCH, SUBSTR, LENGTH, INDEX }; 761177Sbill yylex() { 771177Sbill register char *p; 781177Sbill register i; 791177Sbill 801177Sbill if(Argi >= Ac) return NOARG; 811177Sbill 821177Sbill p = Av[Argi++]; 831177Sbill 841177Sbill if(*p == '(' || *p == ')') 851177Sbill return (int)*p; 861177Sbill for(i = 0; *operators[i]; ++i) 871177Sbill if(EQL(operators[i], p)) 881177Sbill return op[i]; 891177Sbill 901177Sbill yylval = p; 911177Sbill return A_STRING; 921177Sbill } 931177Sbill 941177Sbill char *rel(op, r1, r2) register char *r1, *r2; { 951177Sbill register i; 961177Sbill 971177Sbill if(ematch(r1, "-*[0-9]*$") && ematch(r2, "[0-9]*$")) 981177Sbill i = atol(r1) - atol(r2); 991177Sbill else 1001177Sbill i = strcmp(r1, r2); 1011177Sbill switch(op) { 1021177Sbill case EQ: i = i==0; break; 1031177Sbill case GT: i = i>0; break; 1041177Sbill case GEQ: i = i>=0; break; 1051177Sbill case LT: i = i<0; break; 106*3175Swnj case LEQ: i = i<=0; break; 1071177Sbill case NEQ: i = i!=0; break; 1081177Sbill } 1091177Sbill return i? "1": "0"; 1101177Sbill } 1111177Sbill 1121177Sbill char *arith(op, r1, r2) char *r1, *r2; { 1131177Sbill long i1, i2; 1141177Sbill register char *rv; 1151177Sbill 1161177Sbill if(!(ematch(r1, "[0-9]*$") && ematch(r2, "[0-9]*$"))) 1171177Sbill yyerror("non-numeric argument"); 1181177Sbill i1 = atol(r1); 1191177Sbill i2 = atol(r2); 1201177Sbill 1211177Sbill switch(op) { 1221177Sbill case ADD: i1 = i1 + i2; break; 1231177Sbill case SUBT: i1 = i1 - i2; break; 1241177Sbill case MULT: i1 = i1 * i2; break; 1251177Sbill case DIV: i1 = i1 / i2; break; 1261177Sbill case REM: i1 = i1 % i2; break; 1271177Sbill } 1281177Sbill rv = malloc(16); 1291177Sbill sprintf(rv, "%D", i1); 1301177Sbill return rv; 1311177Sbill } 1321177Sbill char *conj(op, r1, r2) char *r1, *r2; { 1331177Sbill register char *rv; 1341177Sbill 1351177Sbill switch(op) { 1361177Sbill 1371177Sbill case OR: 1381177Sbill if(EQL(r1, "0") 1391177Sbill || EQL(r1, "")) 1401177Sbill if(EQL(r2, "0") 1411177Sbill || EQL(r2, "")) 1421177Sbill rv = "0"; 1431177Sbill else 1441177Sbill rv = r2; 1451177Sbill else 1461177Sbill rv = r1; 1471177Sbill break; 1481177Sbill case AND: 1491177Sbill if(EQL(r1, "0") 1501177Sbill || EQL(r1, "")) 1511177Sbill rv = "0"; 1521177Sbill else if(EQL(r2, "0") 1531177Sbill || EQL(r2, "")) 1541177Sbill rv = "0"; 1551177Sbill else 1561177Sbill rv = r1; 1571177Sbill break; 1581177Sbill } 1591177Sbill return rv; 1601177Sbill } 1611177Sbill 1621177Sbill char *substr(v, s, w) char *v, *s, *w; { 1631177Sbill register si, wi; 1641177Sbill register char *res; 1651177Sbill 1661177Sbill si = atol(s); 1671177Sbill wi = atol(w); 1681177Sbill while(--si) if(*v) ++v; 1691177Sbill 1701177Sbill res = v; 1711177Sbill 1721177Sbill while(wi--) if(*v) ++v; 1731177Sbill 1741177Sbill *v = '\0'; 1751177Sbill return res; 1761177Sbill } 1771177Sbill 1781177Sbill char *length(s) register char *s; { 1791177Sbill register i = 0; 1801177Sbill register char *rv; 1811177Sbill 1821177Sbill while(*s++) ++i; 1831177Sbill 1841177Sbill rv = malloc(8); 1851177Sbill sprintf(rv, "%d", i); 1861177Sbill return rv; 1871177Sbill } 1881177Sbill 1891177Sbill char *index(s, t) char *s, *t; { 1901177Sbill register i, j; 1911177Sbill register char *rv; 1921177Sbill 1931177Sbill for(i = 0; s[i] ; ++i) 1941177Sbill for(j = 0; t[j] ; ++j) 1951177Sbill if(s[i]==t[j]) { 1961177Sbill sprintf(rv = malloc(8), "%d", ++i); 1971177Sbill return rv; 1981177Sbill } 1991177Sbill return "0"; 2001177Sbill } 2011177Sbill 2021177Sbill char *match(s, p) 2031177Sbill { 2041177Sbill register char *rv; 2051177Sbill 2061177Sbill sprintf(rv = malloc(8), "%d", ematch(s, p)); 2071177Sbill if(nbra) { 2081177Sbill rv = malloc(strlen(Mstring[0])+1); 2091177Sbill strcpy(rv, Mstring[0]); 2101177Sbill } 2111177Sbill return rv; 2121177Sbill } 2131177Sbill 2141177Sbill #define INIT register char *sp = instring; 2151177Sbill #define GETC() (*sp++) 2161177Sbill #define PEEKC() (*sp) 2171177Sbill #define UNGETC(c) (--sp) 2181177Sbill #define RETURN(c) return 2191177Sbill #define ERROR(c) errxx(c) 2201177Sbill 2211177Sbill 2221177Sbill ematch(s, p) 2231177Sbill char *s; 2241177Sbill register char *p; 2251177Sbill { 2261177Sbill static char expbuf[ESIZE]; 2271177Sbill char *compile(); 2281177Sbill register num; 2291177Sbill extern char *braslist[], *braelist[], *loc2; 2301177Sbill 2311177Sbill compile(p, expbuf, &expbuf[512], 0); 2321177Sbill if(nbra > 1) 2331177Sbill yyerror("Too many '\\('s"); 2341177Sbill if(advance(s, expbuf)) { 2351177Sbill if(nbra == 1) { 2361177Sbill p = braslist[0]; 2371177Sbill num = braelist[0] - p; 2381177Sbill strncpy(Mstring[0], p, num); 2391177Sbill Mstring[0][num] = '\0'; 2401177Sbill } 2411177Sbill return(loc2-s); 2421177Sbill } 2431177Sbill return(0); 2441177Sbill } 2451177Sbill 2461177Sbill errxx(c) 2471177Sbill { 2481177Sbill yyerror("RE error"); 2491177Sbill } 2501177Sbill 2511177Sbill #define CBRA 2 2521177Sbill #define CCHR 4 2531177Sbill #define CDOT 8 2541177Sbill #define CCL 12 2551177Sbill #define CDOL 20 2561177Sbill #define CEOF 22 2571177Sbill #define CKET 24 2581177Sbill #define CBACK 36 2591177Sbill 2601177Sbill #define STAR 01 2611177Sbill #define RNGE 03 2621177Sbill 2631177Sbill #define NBRA 9 2641177Sbill 2651177Sbill #define PLACE(c) ep[c >> 3] |= bittab[c & 07] 2661177Sbill #define ISTHERE(c) (ep[c >> 3] & bittab[c & 07]) 2671177Sbill 2681177Sbill char *braslist[NBRA]; 2691177Sbill char *braelist[NBRA]; 2701177Sbill int nbra; 2711177Sbill char *loc1, *loc2, *locs; 2721177Sbill int sed; 2731177Sbill 2741177Sbill int circf; 2751177Sbill int low; 2761177Sbill int size; 2771177Sbill 2781177Sbill char bittab[] = { 2791177Sbill 1, 2801177Sbill 2, 2811177Sbill 4, 2821177Sbill 8, 2831177Sbill 16, 2841177Sbill 32, 2851177Sbill 64, 2861177Sbill 128 2871177Sbill }; 2881177Sbill 2891177Sbill char * 2901177Sbill compile(instring, ep, endbuf, seof) 2911177Sbill register char *ep; 2921177Sbill char *instring, *endbuf; 2931177Sbill { 2941177Sbill INIT /* Dependent declarations and initializations */ 2951177Sbill register c; 2961177Sbill register eof = seof; 2971177Sbill char *lastep = instring; 2981177Sbill int cclcnt; 2991177Sbill char bracket[NBRA], *bracketp; 3001177Sbill int closed; 3011177Sbill char neg; 3021177Sbill int lc; 3031177Sbill int i, cflg; 3041177Sbill 3051177Sbill lastep = 0; 3061177Sbill if((c = GETC()) == eof) { 3071177Sbill if(*ep == 0 && !sed) 3081177Sbill ERROR(41); 3091177Sbill RETURN(ep); 3101177Sbill } 3111177Sbill bracketp = bracket; 3121177Sbill circf = closed = nbra = 0; 3131177Sbill if (c == '^') 3141177Sbill circf++; 3151177Sbill else 3161177Sbill UNGETC(c); 3171177Sbill for (;;) { 3181177Sbill if (ep >= endbuf) 3191177Sbill ERROR(50); 3201177Sbill if((c = GETC()) != '*' && ((c != '\\') || (PEEKC() != '{'))) 3211177Sbill lastep = ep; 3221177Sbill if (c == eof) { 3231177Sbill *ep++ = CEOF; 3241177Sbill RETURN(ep); 3251177Sbill } 3261177Sbill switch (c) { 3271177Sbill 3281177Sbill case '.': 3291177Sbill *ep++ = CDOT; 3301177Sbill continue; 3311177Sbill 3321177Sbill case '\n': 3331177Sbill ERROR(36); 3341177Sbill case '*': 3351177Sbill if (lastep==0 || *lastep==CBRA || *lastep==CKET) 3361177Sbill goto defchar; 3371177Sbill *lastep |= STAR; 3381177Sbill continue; 3391177Sbill 3401177Sbill case '$': 3411177Sbill if(PEEKC() != eof) 3421177Sbill goto defchar; 3431177Sbill *ep++ = CDOL; 3441177Sbill continue; 3451177Sbill 3461177Sbill case '[': 3471177Sbill if(&ep[17] >= endbuf) 3481177Sbill ERROR(50); 3491177Sbill 3501177Sbill *ep++ = CCL; 3511177Sbill lc = 0; 3521177Sbill for(i = 0; i < 16; i++) 3531177Sbill ep[i] = 0; 3541177Sbill 3551177Sbill neg = 0; 3561177Sbill if((c = GETC()) == '^') { 3571177Sbill neg = 1; 3581177Sbill c = GETC(); 3591177Sbill } 3601177Sbill 3611177Sbill do { 3621177Sbill if(c == '\0' || c == '\n') 3631177Sbill ERROR(49); 3641177Sbill if(c == '-' && lc != 0) { 3651177Sbill if ((c = GETC()) == ']') { 3661177Sbill PLACE('-'); 3671177Sbill break; 3681177Sbill } 3691177Sbill while(lc < c) { 3701177Sbill PLACE(lc); 3711177Sbill lc++; 3721177Sbill } 3731177Sbill } 3741177Sbill lc = c; 3751177Sbill PLACE(c); 3761177Sbill } while((c = GETC()) != ']'); 3771177Sbill if(neg) { 3781177Sbill for(cclcnt = 0; cclcnt < 16; cclcnt++) 3791177Sbill ep[cclcnt] ^= -1; 3801177Sbill ep[0] &= 0376; 3811177Sbill } 3821177Sbill 3831177Sbill ep += 16; 3841177Sbill 3851177Sbill continue; 3861177Sbill 3871177Sbill case '\\': 3881177Sbill switch(c = GETC()) { 3891177Sbill 3901177Sbill case '(': 3911177Sbill if(nbra >= NBRA) 3921177Sbill ERROR(43); 3931177Sbill *bracketp++ = nbra; 3941177Sbill *ep++ = CBRA; 3951177Sbill *ep++ = nbra++; 3961177Sbill continue; 3971177Sbill 3981177Sbill case ')': 3991177Sbill if(bracketp <= bracket) 4001177Sbill ERROR(42); 4011177Sbill *ep++ = CKET; 4021177Sbill *ep++ = *--bracketp; 4031177Sbill closed++; 4041177Sbill continue; 4051177Sbill 4061177Sbill case '{': 4071177Sbill if(lastep == (char *) (0)) 4081177Sbill goto defchar; 4091177Sbill *lastep |= RNGE; 4101177Sbill cflg = 0; 4111177Sbill nlim: 4121177Sbill c = GETC(); 4131177Sbill i = 0; 4141177Sbill do { 4151177Sbill if ('0' <= c && c <= '9') 4161177Sbill i = 10 * i + c - '0'; 4171177Sbill else 4181177Sbill ERROR(16); 4191177Sbill } while(((c = GETC()) != '\\') && (c != ',')); 4201177Sbill if (i > 255) 4211177Sbill ERROR(11); 4221177Sbill *ep++ = i; 4231177Sbill if (c == ',') { 4241177Sbill if(cflg++) 4251177Sbill ERROR(44); 4261177Sbill if((c = GETC()) == '\\') 4271177Sbill *ep++ = 255; 4281177Sbill else { 4291177Sbill UNGETC(c); 4301177Sbill goto nlim; /* get 2'nd number */ 4311177Sbill } 4321177Sbill } 4331177Sbill if(GETC() != '}') 4341177Sbill ERROR(45); 4351177Sbill if(!cflg) /* one number */ 4361177Sbill *ep++ = i; 4371177Sbill else if((ep[-1] & 0377) < (ep[-2] & 0377)) 4381177Sbill ERROR(46); 4391177Sbill continue; 4401177Sbill 4411177Sbill case '\n': 4421177Sbill ERROR(36); 4431177Sbill 4441177Sbill case 'n': 4451177Sbill c = '\n'; 4461177Sbill goto defchar; 4471177Sbill 4481177Sbill default: 4491177Sbill if(c >= '1' && c <= '9') { 4501177Sbill if((c -= '1') >= closed) 4511177Sbill ERROR(25); 4521177Sbill *ep++ = CBACK; 4531177Sbill *ep++ = c; 4541177Sbill continue; 4551177Sbill } 4561177Sbill } 4571177Sbill /* Drop through to default to use \ to turn off special chars */ 4581177Sbill 4591177Sbill defchar: 4601177Sbill default: 4611177Sbill lastep = ep; 4621177Sbill *ep++ = CCHR; 4631177Sbill *ep++ = c; 4641177Sbill } 4651177Sbill } 4661177Sbill } 4671177Sbill 4681177Sbill step(p1, p2) 4691177Sbill register char *p1, *p2; 4701177Sbill { 4711177Sbill register c; 4721177Sbill 4731177Sbill if (circf) { 4741177Sbill loc1 = p1; 4751177Sbill return(advance(p1, p2)); 4761177Sbill } 4771177Sbill /* fast check for first character */ 4781177Sbill if (*p2==CCHR) { 4791177Sbill c = p2[1]; 4801177Sbill do { 4811177Sbill if (*p1 != c) 4821177Sbill continue; 4831177Sbill if (advance(p1, p2)) { 4841177Sbill loc1 = p1; 4851177Sbill return(1); 4861177Sbill } 4871177Sbill } while (*p1++); 4881177Sbill return(0); 4891177Sbill } 4901177Sbill /* regular algorithm */ 4911177Sbill do { 4921177Sbill if (advance(p1, p2)) { 4931177Sbill loc1 = p1; 4941177Sbill return(1); 4951177Sbill } 4961177Sbill } while (*p1++); 4971177Sbill return(0); 4981177Sbill } 4991177Sbill 5001177Sbill advance(lp, ep) 5011177Sbill register char *lp, *ep; 5021177Sbill { 5031177Sbill register char *curlp; 5041177Sbill char c; 5051177Sbill char *bbeg; 5061177Sbill int ct; 5071177Sbill 5081177Sbill for (;;) switch (*ep++) { 5091177Sbill 5101177Sbill case CCHR: 5111177Sbill if (*ep++ == *lp++) 5121177Sbill continue; 5131177Sbill return(0); 5141177Sbill 5151177Sbill case CDOT: 5161177Sbill if (*lp++) 5171177Sbill continue; 5181177Sbill return(0); 5191177Sbill 5201177Sbill case CDOL: 5211177Sbill if (*lp==0) 5221177Sbill continue; 5231177Sbill return(0); 5241177Sbill 5251177Sbill case CEOF: 5261177Sbill loc2 = lp; 5271177Sbill return(1); 5281177Sbill 5291177Sbill case CCL: 5301177Sbill c = *lp++ & 0177; 5311177Sbill if(ISTHERE(c)) { 5321177Sbill ep += 16; 5331177Sbill continue; 5341177Sbill } 5351177Sbill return(0); 5361177Sbill case CBRA: 5371177Sbill braslist[*ep++] = lp; 5381177Sbill continue; 5391177Sbill 5401177Sbill case CKET: 5411177Sbill braelist[*ep++] = lp; 5421177Sbill continue; 5431177Sbill 5441177Sbill case CCHR|RNGE: 5451177Sbill c = *ep++; 5461177Sbill getrnge(ep); 5471177Sbill while(low--) 5481177Sbill if(*lp++ != c) 5491177Sbill return(0); 5501177Sbill curlp = lp; 5511177Sbill while(size--) 5521177Sbill if(*lp++ != c) 5531177Sbill break; 5541177Sbill if(size < 0) 5551177Sbill lp++; 5561177Sbill ep += 2; 5571177Sbill goto star; 5581177Sbill 5591177Sbill case CDOT|RNGE: 5601177Sbill getrnge(ep); 5611177Sbill while(low--) 5621177Sbill if(*lp++ == '\0') 5631177Sbill return(0); 5641177Sbill curlp = lp; 5651177Sbill while(size--) 5661177Sbill if(*lp++ == '\0') 5671177Sbill break; 5681177Sbill if(size < 0) 5691177Sbill lp++; 5701177Sbill ep += 2; 5711177Sbill goto star; 5721177Sbill 5731177Sbill case CCL|RNGE: 5741177Sbill getrnge(ep + 16); 5751177Sbill while(low--) { 5761177Sbill c = *lp++ & 0177; 5771177Sbill if(!ISTHERE(c)) 5781177Sbill return(0); 5791177Sbill } 5801177Sbill curlp = lp; 5811177Sbill while(size--) { 5821177Sbill c = *lp++ & 0177; 5831177Sbill if(!ISTHERE(c)) 5841177Sbill break; 5851177Sbill } 5861177Sbill if(size < 0) 5871177Sbill lp++; 5881177Sbill ep += 18; /* 16 + 2 */ 5891177Sbill goto star; 5901177Sbill 5911177Sbill case CBACK: 5921177Sbill bbeg = braslist[*ep]; 5931177Sbill ct = braelist[*ep++] - bbeg; 5941177Sbill 5951177Sbill if(ecmp(bbeg, lp, ct)) { 5961177Sbill lp += ct; 5971177Sbill continue; 5981177Sbill } 5991177Sbill return(0); 6001177Sbill 6011177Sbill case CBACK|STAR: 6021177Sbill bbeg = braslist[*ep]; 6031177Sbill ct = braelist[*ep++] - bbeg; 6041177Sbill curlp = lp; 6051177Sbill while(ecmp(bbeg, lp, ct)) 6061177Sbill lp += ct; 6071177Sbill 6081177Sbill while(lp >= curlp) { 6091177Sbill if(advance(lp, ep)) return(1); 6101177Sbill lp -= ct; 6111177Sbill } 6121177Sbill return(0); 6131177Sbill 6141177Sbill 6151177Sbill case CDOT|STAR: 6161177Sbill curlp = lp; 6171177Sbill while (*lp++); 6181177Sbill goto star; 6191177Sbill 6201177Sbill case CCHR|STAR: 6211177Sbill curlp = lp; 6221177Sbill while (*lp++ == *ep); 6231177Sbill ep++; 6241177Sbill goto star; 6251177Sbill 6261177Sbill case CCL|STAR: 6271177Sbill curlp = lp; 6281177Sbill do { 6291177Sbill c = *lp++ & 0177; 6301177Sbill } while(ISTHERE(c)); 6311177Sbill ep += 16; 6321177Sbill goto star; 6331177Sbill 6341177Sbill star: 6351177Sbill do { 6361177Sbill if(--lp == locs) 6371177Sbill break; 6381177Sbill if (advance(lp, ep)) 6391177Sbill return(1); 6401177Sbill } while (lp > curlp); 6411177Sbill return(0); 6421177Sbill 6431177Sbill } 6441177Sbill } 6451177Sbill 6461177Sbill getrnge(str) 6471177Sbill register char *str; 6481177Sbill { 6491177Sbill low = *str++ & 0377; 6501177Sbill size = *str == 255 ? 20000 : (*str &0377) - low; 6511177Sbill } 6521177Sbill 6531177Sbill ecmp(a, b, count) 6541177Sbill register char *a, *b; 6551177Sbill register count; 6561177Sbill { 6571177Sbill if(a == b) /* should have been caught in compile() */ 6581177Sbill error(51); 6591177Sbill while(count--) 6601177Sbill if(*a++ != *b++) return(0); 6611177Sbill return(1); 6621177Sbill } 6631177Sbill 664*3175Swnj static char *sccsid = "@(#)expr.y 4.2 (Berkeley) 03/10/81"; 6651177Sbill yyerror(s) 6661177Sbill 6671177Sbill { 6681177Sbill fprintf(stderr, "%s\n", s); 6691177Sbill exit(2); 6701177Sbill } 671