diff options
author | marha <marha@users.sourceforge.net> | 2012-04-13 11:42:04 +0200 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2012-04-13 11:42:04 +0200 |
commit | d2d4fd66a0c1fca50d07fce3f383d6a84a57f09a (patch) | |
tree | b50ae20ca22bc564b145906d6c84395285933859 /fontconfig/src/fcstr.c | |
parent | 120bd371deb2b73a0bae5ce331511e4ea27bcff2 (diff) | |
parent | fffd436e9c2ec6f5aa501ee57d0e4ade7293ee60 (diff) | |
download | vcxsrv-d2d4fd66a0c1fca50d07fce3f383d6a84a57f09a.tar.gz vcxsrv-d2d4fd66a0c1fca50d07fce3f383d6a84a57f09a.tar.bz2 vcxsrv-d2d4fd66a0c1fca50d07fce3f383d6a84a57f09a.zip |
Merge remote-tracking branch 'origin/released'
Diffstat (limited to 'fontconfig/src/fcstr.c')
-rw-r--r-- | fontconfig/src/fcstr.c | 52 |
1 files changed, 52 insertions, 0 deletions
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 <stdlib.h> #include <ctype.h> #include <string.h> +#ifdef HAVE_REGEX_H +#include <regex.h> +#endif #ifdef _WIN32 #include <windows.h> #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 */ |