From 103539250ed27a95eaa0189b7d3c1b5cf652f532 Mon Sep 17 00:00:00 2001 From: Michiel Broek Date: Wed, 8 May 2002 19:23:34 +0000 Subject: [PATCH] Some fixes for the regexp code --- mbfido/hatch.c | 8 +++++--- mbfido/magic.c | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/mbfido/hatch.c b/mbfido/hatch.c index 60937674..140711a0 100644 --- a/mbfido/hatch.c +++ b/mbfido/hatch.c @@ -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"); diff --git a/mbfido/magic.c b/mbfido/magic.c index 8f68fc68..d202c16d 100644 --- a/mbfido/magic.c +++ b/mbfido/magic.c @@ -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);