- Introduced a help system - introduced a module for handling automatic updates of files during long measurements - Added a circular buffer and handling facilities to varlog - Upgraded documentation SKIPPED: psi/faverage.h psi/nxamor.tex psi/pimotor.h psi/pimotor.tex
51 lines
1.5 KiB
C
51 lines
1.5 KiB
C
#define MAX_CALLS 200
|
|
#include <ctype.h>
|
|
|
|
int match(const char *mask, const char *name)
|
|
{
|
|
int calls=0, wild=0, q=0;
|
|
const char *m=mask, *n=name, *ma=mask, *na=name;
|
|
|
|
for(;;) {
|
|
if (++calls > MAX_CALLS) return 1;
|
|
if (*m == '*') {
|
|
while (*m == '*') ++m;
|
|
wild = 1;
|
|
ma = m;
|
|
na = n;
|
|
}
|
|
|
|
if (!*m) {
|
|
if (!*n) return 0;
|
|
|
|
for (--m; (m > mask) && (*m == '?'); --m) ;
|
|
|
|
if ((*m == '*') && (m > mask) &&
|
|
(m[-1] != '\\'))
|
|
return 0;
|
|
if (!wild)
|
|
return 1;
|
|
m = ma;
|
|
} else if (!*n) {
|
|
while(*m == '*') ++m;
|
|
return (*m != 0);
|
|
}
|
|
if ((*m == '\\') && ((m[1] == '*') || (m[1] == '?'))) {
|
|
++m;
|
|
q = 1;
|
|
} else {
|
|
q = 0;
|
|
}
|
|
|
|
if ((tolower(*m) != tolower(*n)) && ((*m != '?') || q)) {
|
|
if (!wild) return 1;
|
|
m = ma;
|
|
n = ++na;
|
|
} else {
|
|
if (*m) ++m;
|
|
if (*n) ++n;
|
|
}
|
|
}
|
|
}
|
|
|