Archive-Unzip-Burst
view release on metacpan or search on metacpan
unzip-6.0/match.c view on Meta::CPAN
}
}
return r ? recmatch(q + CLEN(q), s + CLEN(s), ic __WDL) : 0;
/* bracket match failed */
}
/* if escape ('\\'), just compare next character */
if (c == '\\' && (c = *p++) == 0) /* if \ at end, then syntax error */
return 0;
/* just a character--compare it */
#ifdef QDOS
return QMatch(Case((uch)c), Case(*s)) ?
recmatch(p, s + CLEN(s), ic __WDL) : 0;
#else
return Case((uch)c) == Case(*s) ?
recmatch(p, s + CLEN(s), ic __WDL) : 0;
#endif
} /* end function recmatch() */
static char *isshexp(p)
ZCONST char *p;
/* If p is a sh expression, a pointer to the first special character is
returned. Otherwise, NULL is returned. */
{
for (; *p; INCSTR(p))
if (*p == '\\' && *(p+1))
p++;
else if (*p == WILDCHAR || *p == '*' || *p == BEG_RANGE)
return (char *)p;
return NULL;
} /* end function isshexp() */
static int namecmp(s1, s2)
ZCONST char *s1, *s2;
{
int d;
for (;;) {
d = (int)ToLower((uch)*s1)
- (int)ToLower((uch)*s2);
if (d || *s1 == 0 || *s2 == 0)
return d;
s1++;
s2++;
}
} /* end function namecmp() */
#endif /* !THEOS */
int iswild(p) /* originally only used for stat()-bug workaround in */
ZCONST char *p; /* VAX C, Turbo/Borland C, Watcom C, Atari MiNT libs; */
{ /* now used in process_zipfiles() as well */
for (; *p; INCSTR(p))
if (*p == '\\' && *(p+1))
++p;
#ifdef THEOS
else if (*p == '?' || *p == '*' || *p=='#'|| *p == '@')
#else /* !THEOS */
#ifdef VMS
else if (*p == '%' || *p == '*')
#else /* !VMS */
#ifdef AMIGA
else if (*p == '?' || *p == '*' || (*p=='#' && p[1]=='?') || *p == '[')
#else /* !AMIGA */
else if (*p == '?' || *p == '*' || *p == '[')
#endif /* ?AMIGA */
#endif /* ?VMS */
#endif /* ?THEOS */
#ifdef QDOS
return (int)p;
#else
return TRUE;
#endif
return FALSE;
} /* end function iswild() */
#ifdef TEST_MATCH
#define put(s) {fputs(s,stdout); fflush(stdout);}
#ifdef main
# undef main
#endif
int main(int argc, char **argv)
{
char pat[256], str[256];
for (;;) {
put("Pattern (return to exit): ");
gets(pat);
if (!pat[0])
break;
for (;;) {
put("String (return for new pattern): ");
gets(str);
if (!str[0])
break;
printf("Case sensitive: %s insensitive: %s\n",
match(str, pat, 0) ? "YES" : "NO",
match(str, pat, 1) ? "YES" : "NO");
}
}
EXIT(0);
}
( run in 1.915 second using v1.01-cache-2.11-cpan-f0ff5d10edf )