On Monday, 6. February 2006 15:22, Patrick Lam wrote: > Hopefully Dirk will have a patch soon. It should only need to change > FcCacheReadString. There's a convenient 'len' parameter to > FcCacheReadString which would be useful in deciding how much to read, so > it should be something like this: > > read (fd, dest, len); > // iterate though and replace \\ with \, etc > lseek (fd, strlen(dest)-len, SEEK_SET); Yes, except that the de-escaping isn't needed, since we don't escape anyway in FcCacheWriteString(). See patch below (survived my testing):
2006-02-07 Dirk Mueller <dmueller@xxxxxxxx> src/fccache.c (FcCacheReadString, FcCacheSkipString): Remove de-escaping logic because FcCacheWriteString doesn't escape anyway. Do blockwise reading instead of byte-wise for performance. --- src/fccache.c 2006-01-22 15:43:26.000000000 +0100 +++ src/fccache.c 2006-02-07 02:12:25.000000000 +0100 @@ -82,68 +82,43 @@ static char * FcCacheReadString (int fd, char *dest, int len) { - FcChar8 c; - FcBool escape; - int size; - int i; + int size; + int slen; if (len == 0) - return 0; - - size = len; - i = 0; - escape = FcFalse; - while (read (fd, &c, 1) == 1) + return 0; + + size = read (fd, dest, len-1); + + if (size > 0) { - if (!escape) - { - switch (c) { - case '"': - c = '\0'; - break; - case '\\': - escape = FcTrue; - continue; - } - } - if (i == size) - { - dest[i++] = 0; - return dest; - } - dest[i++] = c; - if (c == '\0') - return dest; - escape = FcFalse; + dest[size] = '\0'; + int slen = strlen (dest); + + lseek (fd, slen - size + 1, SEEK_CUR); + return slen < len ? dest : 0; } + return 0; } static void FcCacheSkipString (int fd) { - FcChar8 c; - FcBool escape; - - escape = FcFalse; - while (read (fd, &c, 1) == 1) - { - if (!escape) - { - switch (c) { - case '"': - c = '\0'; - break; - case '\\': - escape = FcTrue; - continue; - } - } - if (c == '\0') - return; - escape = FcFalse; + char buf[256]; + int size; + int slen; + + while ( (size = read (fd, buf, sizeof (buf)-1)) > 0) + { + buf [size] = '\0'; + slen = strlen (buf); + if (slen < size) + { + lseek (fd, slen - size + 1, SEEK_CUR); + return; + } } - return; } static FcBool
_______________________________________________ Fontconfig mailing list Fontconfig@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/fontconfig