diff -ru fontconfig-2.1/src/fccache.c fontconfig-2.1-opt/src/fccache.c --- fontconfig-2.1/src/fccache.c 2002-09-25 19:16:23.000000000 -0500 +++ fontconfig-2.1-opt/src/fccache.c 2003-01-09 03:02:10.000000000 -0600 @@ -44,37 +44,19 @@ static FcChar8 * FcCacheReadString (FILE *f, FcChar8 *dest, int len) { + enum {seeking, reading, quoted} state = seeking; int c; FcBool escape; FcChar8 *d; int size; int i; - while ((c = GETC (f)) != EOF) - if (c == '"') - break; - if (c == EOF) - return FcFalse; - if (len == 0) - return FcFalse; - size = len; i = 0; d = dest; - escape = FcFalse; + while ((c = GETC (f)) != EOF) { - if (!escape) - { - switch (c) { - case '"': - c = '\0'; - break; - case '\\': - escape = FcTrue; - continue; - } - } if (i == size) { FcChar8 *new = malloc (size * 2); /* freed in caller */ @@ -86,11 +68,36 @@ free (d); d = new; } - d[i++] = c; - if (c == '\0') - return d; - escape = FcFalse; + if(state == reading) + { + if(c == '\\') + state = quoted; + else if(c == '"') + { + d[i++] = '\0'; + return d; + } + else + d[i++] = c; + } + else if(state == seeking) + { + if (c == '"') + { + state=reading; + if (len == 0) //between seeking and reading + return FcFalse; + } + if (c == EOF) + return FcFalse; + } + else //if(state == quoted) + { + d[i++] = c; + state = reading; + } } + if (d != dest) free (d); return 0; diff -ru fontconfig-2.1/src/fclang.c fontconfig-2.1-opt/src/fclang.c --- fontconfig-2.1/src/fclang.c 2002-08-26 18:34:31.000000000 -0500 +++ fontconfig-2.1-opt/src/fclang.c 2003-01-09 13:00:41.000000000 -0600 @@ -234,16 +234,29 @@ while (low <= high) { mid = (high + low) >> 1; - cmp = FcStrCmpIgnoreCase (fcLangCharSets[mid].lang, lang); - if (cmp == 0) - return mid; - if (cmp < 0) + if(fcLangCharSets[mid].lang[0] > lang[0]) // check first chars + high = mid - 1; + else if(fcLangCharSets[mid].lang[0] < lang[0]) low = mid + 1; - else + else if( fcLangCharSets[mid].lang[1] == '\0' && lang[1] == '\0') + return mid; // we're done + else if(fcLangCharSets[mid].lang[1] > lang[1]) // check second chars high = mid - 1; + else if(fcLangCharSets[mid].lang[1] < lang[1]) + low = mid + 1; + else if( fcLangCharSets[mid].lang[2] == '\0' && lang[2] == '\0') + return mid; // all done + else // too far for the fastpath, let strcmp take the rest + { + cmp = strcmp (fcLangCharSets[mid].lang+2, lang+2); /* they are equal at least to the second char */ + if (cmp == 0) + return mid; + if (cmp < 0) + low = mid + 1; + else + high = mid - 1; + } } - if (cmp < 0) - mid++; return -(mid + 1); } diff -ru fontconfig-2.1/src/fcname.c fontconfig-2.1-opt/src/fcname.c --- fontconfig-2.1/src/fcname.c 2002-10-02 02:11:30.000000000 -0500 +++ fontconfig-2.1-opt/src/fcname.c 2003-01-09 11:59:07.000000000 -0600 @@ -246,9 +253,7 @@ { char c0, c1; - c0 = *v; - if (isupper (c0)) - c0 = tolower (c0); + c0 = tolower (v[0]); if (c0 == 't' || c0 == 'y' || c0 == '1') { *result = FcTrue; @@ -261,9 +266,7 @@ } if (c0 == 'o') { - c1 = v[1]; - if (isupper (c1)) - c1 = tolower (c1); + c1 = tolower (v[1]); if (c1 == 'n') { *result = FcTrue; @@ -282,6 +285,7 @@ FcNameConvert (FcType type, FcChar8 *string, FcMatrix *m) { FcValue v; + FcChar8 *s = string; v.type = type; switch (v.type) { @@ -307,6 +311,11 @@ v.u.c = FcNameParseCharSet (string); break; case FcTypeLangSet: + while(*s) + { + *s = tolower(*s); + s++; + } v.u.l = FcNameParseLangSet (string); break; default: @@ -320,16 +329,33 @@ { FcChar8 c; + /* build a bitfield for quick identification of all the given delimiters */ + unsigned long specialTest[8] = {0,0,0,0,0,0,0,0}; + const unsigned char *d = delim; + + specialTest['\\' / 32] |= 1 << ('\\' % 32); // this char is magic for other reasons + for(d=delim;*d;d++) + specialTest[*d / 32] |= 1 << (*d % 32); + while ((c = *cur)) { + /* if (c == '\\') { ++cur; if (!(c = *cur)) break; + } + else */ if (specialTest[c / 32] & 1 << (c % 32)) + { + if (c == '\\') // check this only on the slowpath of having found a 'magic char' + { + ++cur; + if (!(c = *cur)) + break; + } else + break; // if the special char isn't one we know, it's a delimiter } - else if (strchr (delim, c)) - break; ++cur; *save++ = c; }