Advertisement
7_2009-2012 Debugging and Error Handling #221124

^NEW^ -- wildcard string compare (globbing)

matches a string against a wildcard string such as "*.*" or "bl?h.*" etc. This is good for file globbing or to match hostmasks.

AI

AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Source Code
original-source
int wildcmp(char *wild, char *string) {
 char *cp, *mp;
 while ((*string) && (*wild != '*')) {
 if ((*wild != *string) && (*wild != '?')) {
  return 0;
 }
 wild++;
 string++;
 }
 while (*string) {
 if (*wild == '*') {
  if (!*++wild) {
  return 1;
  }
  mp = wild;
  cp = string+1;
 } else if ((*wild == *string) || (*wild == '?')) {
  wild++;
  string++;
 } else {
  wild = mp;
  string = cp++;
 }
 }
 while (*wild == '*') {
 wild++;
 }
 return !*wild;
}
Original Comments (3)
Recovered from Wayback Machine