diff options
author | marha <marha@users.sourceforge.net> | 2013-03-25 10:20:34 +0100 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2013-04-11 11:13:37 +0200 |
commit | dde22e946ccfb0bd937224daf42403b80528c2a6 (patch) | |
tree | c4235cb922c8cd854bc3ef2e670bb6802dc743de /fontconfig/src/fcstr.c | |
parent | accd8a3364ffd1e91a4ab52b06b5e3b9d250ae92 (diff) | |
download | vcxsrv-dde22e946ccfb0bd937224daf42403b80528c2a6.tar.gz vcxsrv-dde22e946ccfb0bd937224daf42403b80528c2a6.tar.bz2 vcxsrv-dde22e946ccfb0bd937224daf42403b80528c2a6.zip |
fontconfig mesa pixman xserver git update 25 Mar 2013
xserver commit 2967391c6d35f03121afa8003e0fb94b62495129
pixman commit d8ac35af1208a4fa4d67f03fee10b5449fb8495a
fontconfig commit b561ff2016ce84eef3c81f16dfb0481be6a13f9b
mesa commit 92b8a37fdfff9e83f39b8885f51ed2f60326ab6a
Diffstat (limited to 'fontconfig/src/fcstr.c')
-rw-r--r-- | fontconfig/src/fcstr.c | 85 |
1 files changed, 48 insertions, 37 deletions
diff --git a/fontconfig/src/fcstr.c b/fontconfig/src/fcstr.c index 4d11a4c65..339a3465d 100644 --- a/fontconfig/src/fcstr.c +++ b/fontconfig/src/fcstr.c @@ -137,27 +137,7 @@ FcStrCaseWalkerLong (FcCaseWalker *w, FcChar8 r) } static FcChar8 -FcStrCaseWalkerNext (FcCaseWalker *w) -{ - FcChar8 r; - - if (w->read) - { - if ((r = *w->read++)) - return r; - w->read = 0; - } - r = *w->src++; - - if ((r & 0xc0) == 0xc0) - return FcStrCaseWalkerLong (w, r); - if ('A' <= r && r <= 'Z') - r = r - 'A' + 'a'; - return r; -} - -static FcChar8 -FcStrCaseWalkerNextIgnoreBlanks (FcCaseWalker *w) +FcStrCaseWalkerNext (FcCaseWalker *w, const char *delims) { FcChar8 r; @@ -170,7 +150,7 @@ FcStrCaseWalkerNextIgnoreBlanks (FcCaseWalker *w) do { r = *w->src++; - } while (r == ' '); + } while (r != 0 && delims && strchr (delims, r)); if ((r & 0xc0) == 0xc0) return FcStrCaseWalkerLong (w, r); @@ -187,13 +167,13 @@ FcStrDowncase (const FcChar8 *s) FcChar8 *dst, *d; FcStrCaseWalkerInit (s, &w); - while (FcStrCaseWalkerNext (&w)) + while (FcStrCaseWalkerNext (&w, NULL)) len++; d = dst = malloc (len + 1); if (!d) return 0; FcStrCaseWalkerInit (s, &w); - while ((*d++ = FcStrCaseWalkerNext (&w))); + while ((*d++ = FcStrCaseWalkerNext (&w, NULL))); return dst; } @@ -210,8 +190,8 @@ FcStrCmpIgnoreCase (const FcChar8 *s1, const FcChar8 *s2) for (;;) { - c1 = FcStrCaseWalkerNext (&w1); - c2 = FcStrCaseWalkerNext (&w2); + c1 = FcStrCaseWalkerNext (&w1, NULL); + c2 = FcStrCaseWalkerNext (&w2, NULL); if (!c1 || (c1 != c2)) break; } @@ -221,6 +201,12 @@ FcStrCmpIgnoreCase (const FcChar8 *s1, const FcChar8 *s2) int FcStrCmpIgnoreBlanksAndCase (const FcChar8 *s1, const FcChar8 *s2) { + return FcStrCmpIgnoreCaseAndDelims (s1, s2, (const FcChar8 *)" "); +} + +int +FcStrCmpIgnoreCaseAndDelims (const FcChar8 *s1, const FcChar8 *s2, const FcChar8 *delims) +{ FcCaseWalker w1, w2; FcChar8 c1, c2; @@ -231,8 +217,8 @@ FcStrCmpIgnoreBlanksAndCase (const FcChar8 *s1, const FcChar8 *s2) for (;;) { - c1 = FcStrCaseWalkerNextIgnoreBlanks (&w1); - c2 = FcStrCaseWalkerNextIgnoreBlanks (&w2); + c1 = FcStrCaseWalkerNext (&w1, (const char *)delims); + c2 = FcStrCaseWalkerNext (&w2, (const char *)delims); if (!c1 || (c1 != c2)) break; } @@ -317,7 +303,7 @@ FcStrHashIgnoreCase (const FcChar8 *s) FcChar8 c; FcStrCaseWalkerInit (s, &w); - while ((c = FcStrCaseWalkerNext (&w))) + while ((c = FcStrCaseWalkerNext (&w, NULL))) h = ((h << 3) ^ (h >> 3)) ^ c; return h; } @@ -337,8 +323,8 @@ FcStrIsAtIgnoreBlanksAndCase (const FcChar8 *s1, const FcChar8 *s2) for (;;) { - c1 = FcStrCaseWalkerNextIgnoreBlanks (&w1); - c2 = FcStrCaseWalkerNextIgnoreBlanks (&w2); + c1 = FcStrCaseWalkerNext (&w1, " "); + c2 = FcStrCaseWalkerNext (&w2, " "); if (!c1 || (c1 != c2)) break; } @@ -396,8 +382,8 @@ FcStrIsAtIgnoreCase (const FcChar8 *s1, const FcChar8 *s2) for (;;) { - c1 = FcStrCaseWalkerNext (&w1); - c2 = FcStrCaseWalkerNext (&w2); + c1 = FcStrCaseWalkerNext (&w1, NULL); + c2 = FcStrCaseWalkerNext (&w2, NULL); if (!c1 || (c1 != c2)) break; } @@ -448,6 +434,31 @@ FcStrContainsWord (const FcChar8 *s1, const FcChar8 *s2) return 0; } +/* + * returns the number of strings (ignoring delimitors and case) being matched + */ + +int +FcStrMatchIgnoreCaseAndDelims (const FcChar8 *s1, const FcChar8 *s2, const FcChar8 *delims) +{ + FcCaseWalker w1, w2; + FcChar8 c1, c2; + + if (s1 == s2) return 0; + + FcStrCaseWalkerInit (s1, &w1); + FcStrCaseWalkerInit (s2, &w2); + + for (;;) + { + c1 = FcStrCaseWalkerNext (&w1, (const char *)delims); + c2 = FcStrCaseWalkerNext (&w2, (const char *)delims); + if (!c1 || (c1 != c2)) + break; + } + return w1.src - s1 - 1; +} + const FcChar8 * FcStrStrIgnoreCase (const FcChar8 *s1, const FcChar8 *s2) { @@ -464,12 +475,12 @@ FcStrStrIgnoreCase (const FcChar8 *s1, const FcChar8 *s2) FcStrCaseWalkerInit (s1, &w1); FcStrCaseWalkerInit (s2, &w2); - c2 = FcStrCaseWalkerNext (&w2); + c2 = FcStrCaseWalkerNext (&w2, NULL); for (;;) { cur = w1.src; - c1 = FcStrCaseWalkerNext (&w1); + c1 = FcStrCaseWalkerNext (&w1, NULL); if (!c1) break; if (c1 == c2) @@ -480,8 +491,8 @@ FcStrStrIgnoreCase (const FcChar8 *s1, const FcChar8 *s2) for (;;) { - c1t = FcStrCaseWalkerNext (&w1t); - c2t = FcStrCaseWalkerNext (&w2t); + c1t = FcStrCaseWalkerNext (&w1t, NULL); + c2t = FcStrCaseWalkerNext (&w2t, NULL); if (!c2t) return cur; |