From fffd436e9c2ec6f5aa501ee57d0e4ade7293ee60 Mon Sep 17 00:00:00 2001 From: marha Date: Fri, 13 Apr 2012 11:34:03 +0200 Subject: fontconfig xserver xkeyboard-config mesa git update 13 Apr 2012 --- fontconfig/src/fcstr.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'fontconfig/src/fcstr.c') diff --git a/fontconfig/src/fcstr.c b/fontconfig/src/fcstr.c index b712e5daf..a6f0ba766 100644 --- a/fontconfig/src/fcstr.c +++ b/fontconfig/src/fcstr.c @@ -26,6 +26,9 @@ #include #include #include +#ifdef HAVE_REGEX_H +#include +#endif #ifdef _WIN32 #include #endif @@ -269,6 +272,55 @@ FcStrCmp (const FcChar8 *s1, const FcChar8 *s2) return (int) c1 - (int) c2; } +#ifdef USE_REGEX +static FcBool +_FcStrRegexCmp (const FcChar8 *s, const FcChar8 *regex, int cflags, int eflags) +{ + int ret = -1; + regex_t reg; + + if ((ret = regcomp (®, (const char *)regex, cflags)) != 0) + { + if (FcDebug () & FC_DBG_MATCHV) + { + char buf[512]; + + regerror (ret, ®, buf, 512); + printf("Regexp compile error: %s\n", buf); + } + return FcFalse; + } + ret = regexec (®, (const char *)s, 0, NULL, eflags); + if (ret != 0) + { + if (FcDebug () & FC_DBG_MATCHV) + { + char buf[512]; + + regerror (ret, ®, buf, 512); + printf("Regexp exec error: %s\n", buf); + } + } + regfree (®); + + return ret == 0 ? FcTrue : FcFalse; +} +#else +# define _FcStrRegexCmp(_s_, _regex_) (FcFalse) +#endif + +FcBool +FcStrRegexCmp (const FcChar8 *s, const FcChar8 *regex) +{ + return _FcStrRegexCmp (s, regex, REG_EXTENDED | REG_NOSUB, 0); +} + +FcBool +FcStrRegexCmpIgnoreCase (const FcChar8 *s, const FcChar8 *regex) +{ + return _FcStrRegexCmp (s, regex, REG_EXTENDED | REG_NOSUB | REG_ICASE, 0); +} + /* * Return a hash value for a string */ -- cgit v1.2.3