diff -ru fontconfig-2.1.pristine/src/fcname.c fontconfig-2.1/src/fcname.c --- fontconfig-2.1.pristine/src/fcname.c 2002-10-02 02:11:30.000000000 -0500 +++ fontconfig-2.1/src/fcname.c 2003-01-10 15:47:47.000000000 -0600 @@ -320,23 +323,36 @@ { FcChar8 c; - while ((c = *cur)) - { - if (c == '\\') - { - ++cur; - if (!(c = *cur)) - break; + /* + * build a bitfield for quick identification of all the given delimiters + * (plus any other special chars we need to handle) + */ + unsigned char testMask[32] = + {1,0,0,0, 0,0,0,0, 0,0,0,0x10, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0 }; + /* always include '\\' and '\0' since we specially handle them below */ + while((c = *delim++) != '\0') + testMask[c / 8] |= 1 << (c % 8); + + /* scan the string for delimiters in the bitfield */ + for(;;) + { + c = *cur++; + if (testMask[c / 8] & 1 << (c % 8)) + { /* found a magic character, what is it */ + if (c == '\\') + { + if ((c = *cur++) == '\0') /* null is the only special char after an escape so just handle it here */ + break; + } + else + break; /* if the special char isn't one we know, so it's a delimiter we exit for (this handles '\0' too) */ } - else if (strchr (delim, c)) - break; - ++cur; *save++ = c; } - *save = 0; - *last = *cur; - if (*cur) - cur++; + *save = '\0'; + *last = c; + if (c == '\0') + cur--; /* return it to the '\0' if we exited at end-of-string, else it should point right after the delimiter we found */ return cur; } @@ -451,6 +467,7 @@ bail0: return 0; } + static FcBool FcNameUnparseString (FcStrBuf *buf, const FcChar8 *string,