diff --git a/src/fccfg.c b/src/fccfg.c index 7da50b5..fcdf73e 100644 --- a/src/fccfg.c +++ b/src/fccfg.c @@ -2210,50 +2210,6 @@ FcConfigGlobAdd (FcConfig *config, return FcStrSetAdd (set, glob); } -static FcBool -FcConfigGlobMatch (const FcChar8 *glob, - const FcChar8 *string) -{ - FcChar8 c; - - while ((c = *glob++)) - { - switch (c) { - case '*': - /* short circuit common case */ - if (!*glob) - return FcTrue; - /* short circuit another common case */ - if (strchr ((char *) glob, '*') == 0) - { - size_t l1, l2; - - l1 = strlen ((char *) string); - l2 = strlen ((char *) glob); - if (l1 < l2) - return FcFalse; - string += (l1 - l2); - } - while (*string) - { - if (FcConfigGlobMatch (glob, string)) - return FcTrue; - string++; - } - return FcFalse; - case '?': - if (*string++ == '\0') - return FcFalse; - break; - default: - if (*string++ != c) - return FcFalse; - break; - } - } - return *string == '\0'; -} - static FcBool FcConfigGlobsMatch (const FcStrSet *globs, const FcChar8 *string) @@ -2261,7 +2217,7 @@ FcConfigGlobsMatch (const FcStrSet *globs, int i; for (i = 0; i < globs->num; i++) - if (FcConfigGlobMatch (globs->strs[i], string)) + if (FcStrGlobMatch (globs->strs[i], string)) return FcTrue; return FcFalse; } diff --git a/src/fcint.h b/src/fcint.h index 8919958..65bf333 100644 --- a/src/fcint.h +++ b/src/fcint.h @@ -1089,6 +1089,10 @@ FcStrContainsWord (const FcChar8 *s1, const FcChar8 *s2); FcPrivate int FcStrMatchIgnoreCaseAndDelims (const FcChar8 *s1, const FcChar8 *s2, const FcChar8 *delims); +FcPrivate FcBool +FcStrGlobMatch (const FcChar8 *glob, + const FcChar8 *string); + FcPrivate FcBool FcStrUsesHome (const FcChar8 *s); diff --git a/src/fcmatch.c b/src/fcmatch.c index 2d7b798..84c9a9a 100644 --- a/src/fcmatch.c +++ b/src/fcmatch.c @@ -196,12 +196,10 @@ FcCompareFilename (FcValue *v1, FcValue *v2) return 0.0; else if (FcStrCmpIgnoreCase (s1, s2) == 0) return 1.0; - else if (FcStrRegexCmp (s2, s1)) + else if (FcStrGlobMatch (s1, s2)) return 2.0; - else if (FcStrRegexCmpIgnoreCase (s2, s1)) - return 3.0; else - return 4.0; + return 3.0; } #define PRI_NULL(n) \ diff --git a/src/fcstr.c b/src/fcstr.c index 339a346..3a32031 100644 --- a/src/fcstr.c +++ b/src/fcstr.c @@ -459,6 +459,50 @@ FcStrMatchIgnoreCaseAndDelims (const FcChar8 *s1, const FcChar8 *s2, const FcCha return w1.src - s1 - 1; } +FcBool +FcStrGlobMatch (const FcChar8 *glob, + const FcChar8 *string) +{ + FcChar8 c; + + while ((c = *glob++)) + { + switch (c) { + case '*': + /* short circuit common case */ + if (!*glob) + return FcTrue; + /* short circuit another common case */ + if (strchr ((char *) glob, '*') == 0) + { + size_t l1, l2; + + l1 = strlen ((char *) string); + l2 = strlen ((char *) glob); + if (l1 < l2) + return FcFalse; + string += (l1 - l2); + } + while (*string) + { + if (FcStrGlobMatch (glob, string)) + return FcTrue; + string++; + } + return FcFalse; + case '?': + if (*string++ == '\0') + return FcFalse; + break; + default: + if (*string++ != c) + return FcFalse; + break; + } + } + return *string == '\0'; +} + const FcChar8 * FcStrStrIgnoreCase (const FcChar8 *s1, const FcChar8 *s2) {