From 4645eedfcc7e36751503bf023a0d1db2a993ad52 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 21 Jun 2002 06:14:45 +0000 Subject: [PATCH] Fix automatic file time checking, transcoding table searches. Actually add config files used to config structure so they can be time checked as well --- src/fccfg.c | 31 ++++++++++++++----------------- src/fccharset.c | 11 +++-------- src/fcxml.c | 5 ++++- 3 files changed, 21 insertions(+), 26 deletions(-) diff --git a/src/fccfg.c b/src/fccfg.c index 8c0ae99..6191324 100644 --- a/src/fccfg.c +++ b/src/fccfg.c @@ -1,5 +1,5 @@ /* - * $XFree86: xc/lib/fontconfig/src/fccfg.c,v 1.13 2002/06/19 20:08:22 keithp Exp $ + * $XFree86: xc/lib/fontconfig/src/fccfg.c,v 1.14 2002/06/20 03:43:09 keithp Exp $ * * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc. * @@ -79,27 +79,25 @@ bail0: return 0; } -static time_t +typedef struct _FcFileTime { + time_t time; + FcBool set; +} FcFileTime; + +static FcFileTime FcConfigNewestFile (FcStrSet *files) { FcStrList *list = FcStrListCreate (files); - FcBool set = FcFalse; - time_t newest = 0; + FcFileTime newest = { 0, FcFalse }; FcChar8 *file; struct stat statb; if (list) { while ((file = FcStrListNext (list))) - { if (stat ((char *) file, &statb) == 0) - { - if (!set) - newest = statb.st_mtime; - else if (statb.st_mtime - newest > 0) - newest = statb.st_mtime; - } - } + if (!newest.set || statb.st_mtime - newest.time > 0) + newest.time = statb.st_mtime; FcStrListDone (list); } return newest; @@ -108,9 +106,8 @@ FcConfigNewestFile (FcStrSet *files) FcBool FcConfigUptoDate (FcConfig *config) { - time_t config_time; - time_t font_time; - time_t now = time(0); + FcFileTime config_time, font_time; + time_t now = time(0); if (!config) { config = FcConfigGetCurrent (); @@ -119,8 +116,8 @@ FcConfigUptoDate (FcConfig *config) } config_time = FcConfigNewestFile (config->configFiles); font_time = FcConfigNewestFile (config->configDirs); - if (config_time - config->rescanTime > 0 || - font_time - config->rescanTime > 0) + if ((config_time.set && config_time.time - config->rescanTime > 0) || + (font_time.set && font_time.time - config->rescanTime) > 0) { return FcFalse; } diff --git a/src/fccharset.c b/src/fccharset.c index c5ff183..86c59ad 100644 --- a/src/fccharset.c +++ b/src/fccharset.c @@ -1597,21 +1597,16 @@ FcFreeTypeMapChar (FcChar32 ucs4, const FcCharMap *map) high = map->nent - 1; if (ucs4 < map->ent[low].bmp || map->ent[high].bmp < ucs4) return ~0; - while (high - low > 1) + while (low <= high) { mid = (high + low) >> 1; bmp = map->ent[mid].bmp; if (ucs4 == bmp) return (FT_ULong) map->ent[mid].encode; if (ucs4 < bmp) - high = mid; + high = mid - 1; else - low = mid; - } - for (mid = low; mid <= high; mid++) - { - if (ucs4 == map->ent[mid].bmp) - return (FT_ULong) map->ent[mid].encode; + low = mid + 1; } return ~0; } diff --git a/src/fcxml.c b/src/fcxml.c index 0c1304e..91d8d3f 100644 --- a/src/fcxml.c +++ b/src/fcxml.c @@ -1,5 +1,5 @@ /* - * $XFree86: xc/lib/fontconfig/src/fcxml.c,v 1.10 2002/06/08 17:32:05 keithp Exp $ + * $XFree86: xc/lib/fontconfig/src/fcxml.c,v 1.12 2002/06/19 20:08:22 keithp Exp $ * * Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc. * @@ -1667,6 +1667,9 @@ FcConfigParseAndLoad (FcConfig *config, if (!FcConfigInit (&parse, name, config, p)) goto bail2; + if (!FcConfigAddConfigFile (config, filename)) + goto bail3; + XML_SetUserData (p, &parse); XML_SetDoctypeDeclHandler (p, FcStartDoctypeDecl, FcEndDoctypeDecl);