aboutsummaryrefslogtreecommitdiff
path: root/fontconfig/src/fcstr.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-04-13 11:34:03 +0200
committermarha <marha@users.sourceforge.net>2012-04-13 11:34:03 +0200
commitfffd436e9c2ec6f5aa501ee57d0e4ade7293ee60 (patch)
tree6fbefab2db2acc7f2d5b066b06649ea88e0d6ab3 /fontconfig/src/fcstr.c
parent5f8448ef6b85a9ff72c5af4cec99183c8bb60dc6 (diff)
downloadvcxsrv-fffd436e9c2ec6f5aa501ee57d0e4ade7293ee60.tar.gz
vcxsrv-fffd436e9c2ec6f5aa501ee57d0e4ade7293ee60.tar.bz2
vcxsrv-fffd436e9c2ec6f5aa501ee57d0e4ade7293ee60.zip
fontconfig xserver xkeyboard-config mesa git update 13 Apr 2012
Diffstat (limited to 'fontconfig/src/fcstr.c')
-rw-r--r--fontconfig/src/fcstr.c52
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 (&reg, (const char *)regex, cflags)) != 0)
+ {
+ if (FcDebug () & FC_DBG_MATCHV)
+ {
+ char buf[512];
+
+ regerror (ret, &reg, buf, 512);
+ printf("Regexp compile error: %s\n", buf);
+ }
+ return FcFalse;
+ }
+ ret = regexec (&reg, (const char *)s, 0, NULL, eflags);
+ if (ret != 0)
+ {
+ if (FcDebug () & FC_DBG_MATCHV)
+ {
+ char buf[512];
+
+ regerror (ret, &reg, buf, 512);
+ printf("Regexp exec error: %s\n", buf);
+ }
+ }
+ regfree (&reg);
+
+ 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
*/