Take effects on dir, cachedir, acceptfont, and rejectfont only when loading
Those elements takes effects immediately during parsing config files so makes them conditional to ignore on scanning.
This commit is contained in:
parent
73cc842d1d
commit
ef748b39e0
30
src/fcxml.c
30
src/fcxml.c
|
@ -62,6 +62,11 @@ static FcChar8 *__fc_userconf = NULL;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
FcExprDestroy (FcExpr *e);
|
FcExprDestroy (FcExpr *e);
|
||||||
|
static FcBool
|
||||||
|
_FcConfigParse (FcConfig *config,
|
||||||
|
const FcChar8 *name,
|
||||||
|
FcBool complain,
|
||||||
|
FcBool load);
|
||||||
|
|
||||||
void
|
void
|
||||||
FcTestDestroy (FcTest *test)
|
FcTestDestroy (FcTest *test)
|
||||||
|
@ -557,6 +562,7 @@ typedef struct _FcConfigParse {
|
||||||
FcPStack pstack_static[8];
|
FcPStack pstack_static[8];
|
||||||
unsigned int vstack_static_used;
|
unsigned int vstack_static_used;
|
||||||
FcVStack vstack_static[64];
|
FcVStack vstack_static[64];
|
||||||
|
FcBool scanOnly;
|
||||||
} FcConfigParse;
|
} FcConfigParse;
|
||||||
|
|
||||||
typedef enum _FcConfigSeverity {
|
typedef enum _FcConfigSeverity {
|
||||||
|
@ -1221,6 +1227,7 @@ FcConfigParseInit (FcConfigParse *parse,
|
||||||
parse->config = config;
|
parse->config = config;
|
||||||
parse->ruleset = FcRuleSetCreate (name);
|
parse->ruleset = FcRuleSetCreate (name);
|
||||||
parse->parser = parser;
|
parse->parser = parser;
|
||||||
|
parse->scanOnly = !enabled;
|
||||||
FcRuleSetEnable (parse->ruleset, enabled);
|
FcRuleSetEnable (parse->ruleset, enabled);
|
||||||
|
|
||||||
return FcTrue;
|
return FcTrue;
|
||||||
|
@ -2147,7 +2154,7 @@ FcParseDir (FcConfigParse *parse)
|
||||||
#endif
|
#endif
|
||||||
if (strlen ((char *) data) == 0)
|
if (strlen ((char *) data) == 0)
|
||||||
FcConfigMessage (parse, FcSevereWarning, "empty font directory name ignored");
|
FcConfigMessage (parse, FcSevereWarning, "empty font directory name ignored");
|
||||||
else if (!FcStrUsesHome (data) || FcConfigHome ())
|
else if (!parse->scanOnly && (!FcStrUsesHome (data) || FcConfigHome ()))
|
||||||
{
|
{
|
||||||
if (!FcConfigAddDir (parse->config, data))
|
if (!FcConfigAddDir (parse->config, data))
|
||||||
FcConfigMessage (parse, FcSevereError, "out of memory; cannot add directory %s", data);
|
FcConfigMessage (parse, FcSevereError, "out of memory; cannot add directory %s", data);
|
||||||
|
@ -2263,7 +2270,7 @@ FcParseCacheDir (FcConfigParse *parse)
|
||||||
#endif
|
#endif
|
||||||
if (strlen ((char *) data) == 0)
|
if (strlen ((char *) data) == 0)
|
||||||
FcConfigMessage (parse, FcSevereWarning, "empty cache directory name ignored");
|
FcConfigMessage (parse, FcSevereWarning, "empty cache directory name ignored");
|
||||||
else if (!FcStrUsesHome (data) || FcConfigHome ())
|
else if (!parse->scanOnly && (!FcStrUsesHome (data) || FcConfigHome ()))
|
||||||
{
|
{
|
||||||
if (!FcConfigAddCacheDir (parse->config, data))
|
if (!FcConfigAddCacheDir (parse->config, data))
|
||||||
FcConfigMessage (parse, FcSevereError, "out of memory; cannot add cache directory %s", data);
|
FcConfigMessage (parse, FcSevereError, "out of memory; cannot add cache directory %s", data);
|
||||||
|
@ -2407,7 +2414,7 @@ FcParseInclude (FcConfigParse *parse)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FcRuleSetDestroy (ruleset);
|
FcRuleSetDestroy (ruleset);
|
||||||
if (!FcConfigParseAndLoad (parse->config, s, !ignore_missing))
|
if (!_FcConfigParse (parse->config, s, !ignore_missing, !parse->scanOnly))
|
||||||
parse->error = FcTrue;
|
parse->error = FcTrue;
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
else
|
else
|
||||||
|
@ -2760,17 +2767,17 @@ FcParseAcceptRejectFont (FcConfigParse *parse, FcElement element)
|
||||||
{
|
{
|
||||||
switch ((int) vstack->tag) {
|
switch ((int) vstack->tag) {
|
||||||
case FcVStackGlob:
|
case FcVStackGlob:
|
||||||
if (!FcConfigGlobAdd (parse->config,
|
if (!parse->scanOnly && !FcConfigGlobAdd (parse->config,
|
||||||
vstack->u.string,
|
vstack->u.string,
|
||||||
element == FcElementAcceptfont))
|
element == FcElementAcceptfont))
|
||||||
{
|
{
|
||||||
FcConfigMessage (parse, FcSevereError, "out of memory");
|
FcConfigMessage (parse, FcSevereError, "out of memory");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case FcVStackPattern:
|
case FcVStackPattern:
|
||||||
if (!FcConfigPatternsAdd (parse->config,
|
if (!parse->scanOnly && !FcConfigPatternsAdd (parse->config,
|
||||||
vstack->u.pattern,
|
vstack->u.pattern,
|
||||||
element == FcElementAcceptfont))
|
element == FcElementAcceptfont))
|
||||||
{
|
{
|
||||||
FcConfigMessage (parse, FcSevereError, "out of memory");
|
FcConfigMessage (parse, FcSevereError, "out of memory");
|
||||||
}
|
}
|
||||||
|
@ -3227,10 +3234,7 @@ FcConfigParseAndLoadDir (FcConfig *config,
|
||||||
qsort (files->strs, files->num, sizeof (FcChar8 *),
|
qsort (files->strs, files->num, sizeof (FcChar8 *),
|
||||||
(int (*)(const void *, const void *)) FcSortCmpStr);
|
(int (*)(const void *, const void *)) FcSortCmpStr);
|
||||||
for (i = 0; ret && i < files->num; i++)
|
for (i = 0; ret && i < files->num; i++)
|
||||||
if (load)
|
ret = _FcConfigParse (config, files->strs[i], complain, load);
|
||||||
ret = FcConfigParseAndLoad (config, files->strs[i], complain);
|
|
||||||
else
|
|
||||||
ret = FcConfigParseOnly (config, files->strs[i], complain);
|
|
||||||
}
|
}
|
||||||
bail3:
|
bail3:
|
||||||
FcStrSetDestroy (files);
|
FcStrSetDestroy (files);
|
||||||
|
|
Loading…
Reference in New Issue