Logo Search packages:      
Sourcecode: bglibs version File versions

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

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

Definition at line 24 of file case_match.c.

References len, and s.

Referenced by str_case_match(), and str_case_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;
    char c;
    if (p == '*') {
      ++pptr, --plen;
      if (plen == 0) return 1;
      p = *pptr;
      if (isupper(p)) p = tolower(p);
      while (slen > 0) {
      c = *sptr;
      if (isupper(c)) c = tolower(c);
      if (c == p) break;
      ++sptr, --slen;
      }
      if (slen == 0) return 0;
    }
    else {
      if (slen == 0) return 0;
      c = *sptr;
      if (isupper(c)) c = tolower(c);
      if (isupper(p)) p = tolower(p);
      if (c != p) return 0;
    }
  }
  return slen == 0;
}


Generated by  Doxygen 1.6.0   Back to index