--- ray/src/common/rexpr.c 1991/09/05 15:03:48 1.3 +++ ray/src/common/rexpr.c 1993/11/18 09:27:03 2.3 @@ -28,6 +28,8 @@ static char SCCSid[] = "$SunId$ LBL"; #define memcpy(to,from,len) bcopy(from,to,len) #endif +static int advance(), cclass(); + static char expbuf[ESIZE]; static int iflag; static int circf; @@ -105,7 +107,8 @@ int iflg, wflag; if ((c = *sp++) == '\0') return(-1); if (c == '<') { - *ep++ = CBRC; + if (ep == expbuf || ep[-1] != CBRC) + *ep++ = CBRC; continue; } if (c == '>') { @@ -146,28 +149,26 @@ register char *ep; } char * -eindex(sp) /* find the expression in str */ +eindex(sp) /* find the expression in string sp */ register char *sp; { - if (circf) { - if (advance(sp, expbuf)) - return(sp); + /* check for match at beginning of line, watch CBRC */ + if (advance(sp, expbuf[0]==CBRC ? expbuf+1 : expbuf)) + return(sp); + if (circf) return(NULL); - } /* fast check for first character */ if (expbuf[0]==CCHR) { register c = expbuf[1]; - do { + while (*++sp) if (same(*sp, c) && advance(sp, expbuf)) return(sp); - } while (*sp++); return(NULL); } /* regular algorithm */ - do { + while (*++sp) if (advance(sp, expbuf)) return(sp); - } while (*sp++); return(NULL); } @@ -245,8 +246,6 @@ register char *ep; return(0); case CBRC: - if (lp == alp) - continue; if ((isalnum(*lp) || *lp == '_') && !(isalnum(lp[-1]) || lp[-1] == '_')) continue; return (0); @@ -265,6 +264,7 @@ static int cclass(set, c, af) register char *set; register c; +int af; { register n;