Fix the mis-ordering of ruleset evaluation in a file with include element

This commit is contained in:
Akira TAGOH 2018-01-03 22:15:11 +09:00
parent 5cfd594c71
commit 97898b1158
2 changed files with 28 additions and 2 deletions

View File

@ -1650,6 +1650,10 @@ FcConfigSubstituteWithPat (FcConfig *config,
for (; FcPtrListIterIsValid (s, &iter); FcPtrListIterNext (s, &iter)) for (; FcPtrListIterIsValid (s, &iter); FcPtrListIterNext (s, &iter))
{ {
rs = (FcRuleSet *) FcPtrListIterGetValue (s, &iter); rs = (FcRuleSet *) FcPtrListIterGetValue (s, &iter);
if (FcDebug () & FC_DBG_EDIT)
{
printf ("\nRule Set: %s\n", rs->name);
}
FcPtrListIterInit (rs->subst[kind], &iter2); FcPtrListIterInit (rs->subst[kind], &iter2);
for (; FcPtrListIterIsValid (rs->subst[kind], &iter2); FcPtrListIterNext (rs->subst[kind], &iter2)) for (; FcPtrListIterIsValid (rs->subst[kind], &iter2); FcPtrListIterNext (rs->subst[kind], &iter2))
{ {
@ -2553,7 +2557,7 @@ FcRuleSetAddDescription (FcRuleSet *rs,
FcStrFree (rs->description); FcStrFree (rs->description);
rs->domain = domain ? FcStrdup (domain) : NULL; rs->domain = domain ? FcStrdup (domain) : NULL;
rs->description = FcStrdup (description); rs->description = description ? FcStrdup (description) : NULL;
} }
int int
@ -2594,7 +2598,7 @@ FcRuleSetAdd (FcRuleSet *rs,
} }
if (FcDebug () & FC_DBG_EDIT) if (FcDebug () & FC_DBG_EDIT)
{ {
printf ("Add Rule "); printf ("Add Rule(kind:%d, name: %s) ", kind, rs->name);
FcRulePrint (rule); FcRulePrint (rule);
} }
ret = FC_OBJ_ID (n) - FC_MAX_BASE_OBJECT; ret = FC_OBJ_ID (n) - FC_MAX_BASE_OBJECT;

View File

@ -2304,6 +2304,8 @@ FcParseInclude (FcConfigParse *parse)
#endif #endif
FcChar8 *prefix = NULL, *p; FcChar8 *prefix = NULL, *p;
FcChar8 *userdir = NULL, *userconf = NULL; FcChar8 *userdir = NULL, *userconf = NULL;
FcRuleSet *ruleset;
FcMatchKind k;
s = FcStrBufDoneStatic (&parse->pstack->str); s = FcStrBufDoneStatic (&parse->pstack->str);
if (!s) if (!s)
@ -2387,6 +2389,24 @@ FcParseInclude (FcConfigParse *parse)
goto userconf; goto userconf;
} }
} }
/* flush the ruleset into the queue */
ruleset = parse->ruleset;
parse->ruleset = FcRuleSetCreate (ruleset->name);
FcRuleSetEnable (parse->ruleset, ruleset->enabled);
FcRuleSetAddDescription (parse->ruleset, ruleset->domain, ruleset->description);
for (k = FcMatchKindBegin; k < FcMatchKindEnd; k++)
{
FcPtrListIter iter;
FcPtrListIterInit (ruleset->subst[k], &iter);
if (FcPtrListIterIsValid (ruleset->subst[k], &iter))
{
FcPtrListIterInitAtLast (parse->config->subst[k], &iter);
FcRuleSetReference (ruleset);
FcPtrListIterAdd (parse->config->subst[k], &iter, ruleset);
}
}
FcRuleSetDestroy (ruleset);
if (!FcConfigParseAndLoad (parse->config, s, !ignore_missing)) if (!FcConfigParseAndLoad (parse->config, s, !ignore_missing))
parse->error = FcTrue; parse->error = FcTrue;
#ifndef _WIN32 #ifndef _WIN32
@ -3351,6 +3371,8 @@ bail1:
FcConfigMessage (0, FcSevereError, "Cannot %s config file from %s", load ? "load" : "scan", filename); FcConfigMessage (0, FcSevereError, "Cannot %s config file from %s", load ? "load" : "scan", filename);
return FcFalse; return FcFalse;
} }
if (FcDebug () & FC_DBG_CONFIG)
printf ("\t%s config file from %s done\n", load ? "Loading" : "Scanning", filename);
return FcTrue; return FcTrue;
} }