aboutsummaryrefslogtreecommitdiffstats
path: root/src/globset.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/globset.c')
-rw-r--r--src/globset.c55
1 files changed, 2 insertions, 53 deletions
diff --git a/src/globset.c b/src/globset.c
index 2bad449f..0ea448be 100644
--- a/src/globset.c
+++ b/src/globset.c
@@ -22,8 +22,7 @@
#include <errno.h>
#include "globset.h"
-
-#define GLOB '*'
+#include "globmatch.h"
/*************************************************************************
* internal types
@@ -63,49 +62,6 @@ struct globset
};
/**
- * Matches whether the string 'str' matches the pattern 'pat'
- * and returns its matching score.
- *
- * @param pat the glob pattern
- * @param str the string to match
- * @return 0 if no match or number representing the matching score
- */
-static unsigned match(const char *pat, const char *str)
-{
- unsigned r, rs, rr;
- char c;
-
- /* scan the prefix without glob */
- r = 1;
- while ((c = *pat++) != GLOB) {
- if (c != *str++)
- return 0; /* no match */
- if (!c)
- return r; /* match up to end */
- r++;
- }
-
- /* glob found */
- c = *pat++;
- if (!c)
- return r; /* not followed by pattern */
-
- /* evaluate the best score for following pattern */
- rs = 0;
- while (*str) {
- if (*str++ == c) {
- /* first char matches, check remaining string */
- rr = match(pat, str);
- if (rr > rs)
- rs = rr;
- }
- }
-
- /* best score or not match if rs == 0 */
- return rs ? rs + r : 0;
-}
-
-/**
* Normalize the string 'from' to the string 'to' and computes the hash code.
* The normalization translates upper characters to lower characters.
* The returned hash code is greater than zero for exact patterns or zero
@@ -235,13 +191,6 @@ static struct pathndl *search(
return ph;
}
-
-
-
-
-
-
-
/**
* Allocates a new set of handlers
*
@@ -436,7 +385,7 @@ const struct globset_handler *globset_match(
s = 0;
iph = set->globs;
while(iph) {
- g = match(iph->handler.pattern, txt);
+ g = globmatch(iph->handler.pattern, txt);
if (g > s) {
s = g;
ph = iph;