Logo Search packages:      
Sourcecode: bglibs version File versions

int str_matchb ( const str s,
const char *  pptr,
unsigned  plen 
)

Simple but fast (linear time) pattern matching on binary pattern.

Definition at line 23 of file match.c.

References len, and s.

Referenced by str_match(), and str_matchs().

{
  const char* sptr;
  long slen = s->len;
  if (plen == 0) return slen == 0;
  for (sptr = s->s; plen > 0; ++sptr, --slen, ++pptr, --plen) {
    char p = *pptr;
    if (p == '*') {
      ++pptr, --plen;
      if (plen == 0) return 1;
      p = *pptr;
      while (slen > 0) {
      if (*sptr == p) break;
      ++sptr, --slen;
      }
      if (slen == 0) return 0;
    }
    else {
      if (slen == 0) return 0;
      if (*sptr != p) return 0;
    }
  }
  return slen == 0;
}


Generated by  Doxygen 1.6.0   Back to index