home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Fred Fish Collection 1.5
/
ffcollection-1-5-1992-11.iso
/
ff_progs
/
fileutil
/
scan.lha
/
src
/
newwildcmp.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-05-21
|
1KB
|
76 lines
/*
* NEWWILDCMP.C
*
* (c)Copyright 1987 Matthew Dillon, All Rights Reserved.
*
* Compare a wild card name with a normal name
*
* This function replaces wildcmp() in SUP32.LIB (as not everybody will
* have the latest SUP32.LIB). The only difference is that this call
* is case insensitive. Later releases of SUP32.LIB will fix the
* case-sensitive bug.
*/
#define MAXB 8
newwildcmp(wild, name)
char *wild, *name;
{
register char *w = wild;
register char *n = name;
char *back[MAXB][2];
register short bi = 0;
register char c1, c2;
while (*n || *w) {
switch (*w) {
case '*':
if (bi == MAXB) {
puts ("Too many levels of '*'");
return (0);
}
back[bi][0] = w;
back[bi][1] = n;
++bi;
++w;
continue;
goback:
--bi;
while (bi >= 0 && *back[bi][1] == '\0')
--bi;
if (bi < 0)
return (0);
w = back[bi][0] + 1;
n = ++back[bi][1];
++bi;
continue;
case '?':
if (!*n) {
if (bi)
goto goback;
return (0);
}
break;
default:
c1 = *n;
c2 = *w;
if (c1 >= 'A' && c1 <= 'Z') /* to lower case */
c1 |= 0x20;
if (c2 >= 'A' && c2 <= 'Z')
c2 |= 0x20;
if (c1 != c2) {
if (bi)
goto goback;
return (0);
}
break;
}
if (*n) ++n;
if (*w) ++w;
}
return (1);
}