diff options
Diffstat (limited to 'media-libs/fontconfig/files/fontconfig-2.10.92-use-glob.patch')
-rw-r--r-- | media-libs/fontconfig/files/fontconfig-2.10.92-use-glob.patch | 164 |
1 files changed, 164 insertions, 0 deletions
diff --git a/media-libs/fontconfig/files/fontconfig-2.10.92-use-glob.patch b/media-libs/fontconfig/files/fontconfig-2.10.92-use-glob.patch new file mode 100644 index 000000000000..e2040fcd4b10 --- /dev/null +++ b/media-libs/fontconfig/files/fontconfig-2.10.92-use-glob.patch @@ -0,0 +1,164 @@ +From f6244d2cf231e1dc756f3e941e61b9bf124879bb Mon Sep 17 00:00:00 2001 +From: Akira TAGOH <akira@tagoh.org> +Date: Wed, 08 May 2013 02:57:49 +0000 +Subject: Use the glob matching for filename + +Regex is expensive to compare filenames. we already have the glob matching +and it works enough in this case. + +Prior to this change, renaming FcConfigGlobMatch() to FcStrGlobMatch() and moving to fcstr.c +--- +diff --git a/src/fccfg.c b/src/fccfg.c +index 7da50b5..fcdf73e 100644 +--- a/src/fccfg.c ++++ b/src/fccfg.c +@@ -2211,57 +2211,13 @@ FcConfigGlobAdd (FcConfig *config, + } + + 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) + { + 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 +@@ -1090,6 +1090,10 @@ 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); + + FcPrivate FcChar8 * +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) + { +-- +cgit v0.9.0.2-2-gbebe |