Some fixes for the regexp code

This commit is contained in:
Michiel Broek 2002-05-08 19:23:34 +00:00
parent b1ba68ebac
commit 103539250e
2 changed files with 10 additions and 6 deletions

View File

@ -127,7 +127,7 @@ int CheckHatch(char *temp)
return FALSE;
}
Temp = xstrcpy(temp);
Temp = xstrcpy(fn);
p = tl(Temp);
q = mask;
*q++ = '^';
@ -138,14 +138,16 @@ int CheckHatch(char *temp)
case '.': *q++ = '\\'; *q++ = '.'; break;
case '+': *q++ = '\\'; *q++ = '+'; break;
case '*': *q++ = '.'; *q++ = '*'; break;
default: *q++ = toupper(*p); break;
case '@': sprintf(q, "[:alpha:]"); while (*q) q++; break;
case '#': sprintf(q, "[:digit:]"); while (*q) q++; break;
default: *q++ = *p; break;
}
p++;
}
*q++ = '$';
*q = '\0';
Syslog('f', "Hatch mask \"%s\" -> \"%s\"", MBSE_SS(Temp), MBSE_SS(mask));
if ((re_comp(mask)) != NULL)
if ((re_comp(mask)) == NULL)
Syslog('f', "re_comp() accepted");
else
Syslog('f', "re_comp() returned NULL");

View File

@ -144,20 +144,22 @@ int GetMagicRec(int Typ, int First)
case '.': *q++ = '\\'; *q++ = '.'; break;
case '+': *q++ = '\\'; *q++ = '+'; break;
case '*': *q++ = '.'; *q++ = '*'; break;
default: *q++ = toupper(*p); break;
case '@': sprintf(q, "[:alpha:]"); while (*q) q++; break;
case '#': sprintf(q, "[:digit:]"); while (*q) q++; break;
default: *q++ = *p; break;
}
p++;
}
*q++ = '$';
*q = '\0';
Syslog('f', "Magic mask \"%s\" -> \"%s\"", MBSE_SS(Magic), MBSE_SS(mask));
if ((re_comp(mask)) != NULL) {
if ((re_comp(mask)) == NULL) {
if (re_exec(TIC.NewName))
Syslog('f', "Should matched using regexp");
else
Syslog('f', "No match using regexp");
} else {
Syslog('f', "re_comp returned NULL");
Syslog('f', "re_comp() failed");
}
free(Magic);