X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=lib%2Fpatmatch.c;h=837ae1a1c6bbf1e77f05db37de2d33bfeee927d1;hb=9a707ec946b4c159e9505c855dff193eef0176bb;hp=c1d60932cd44544252f1777adc04a06ae3310e93;hpb=b0ccc07f3011959ac4a11e76e1b50c84ba31efe9;p=libucw.git diff --git a/lib/patmatch.c b/lib/patmatch.c index c1d60932..837ae1a1 100644 --- a/lib/patmatch.c +++ b/lib/patmatch.c @@ -1,42 +1,12 @@ /* * Sherlock Library -- Shell-Like Pattern Matching (currently only '?' and '*') * - * (c) 1997 Martin Mares, + * (c) 1997 Martin Mares */ -#include -#include +#include "lib/lib.h" -#include "lib.h" +#define Convert(x) (x) +#define MATCH_FUNC_NAME match_pattern -int -match_pattern(byte *p, byte *s) -{ - while (*p) - { - if (*p == '?' && *s) - p++, s++; - else if (*p == '*') - { - int z = p[1]; - - if (!z) - return 1; - while (s = strchr(s, z)) - { - if (match_pattern(p+1, s)) - return 1; - s++; - } - return 0; - } - else - { - if (*p == '\\' && p[1]) - p++; - if (*p++ != *s++) - return 0; - } - } - return !*s; -} +#include "lib/patmatch.h"