Warn about undefined/invalid attributes during config parsing

This commit is contained in:
Behdad Esfahbod 2013-01-02 01:31:34 -06:00
parent b604f10c0c
commit 6047ce7b9f
1 changed files with 19 additions and 0 deletions

View File

@ -1092,10 +1092,26 @@ FcPStackPop (FcConfigParse *parse)
FcConfigMessage (parse, FcSevereError, "mismatching element"); FcConfigMessage (parse, FcSevereError, "mismatching element");
return FcFalse; return FcFalse;
} }
if (parse->pstack->attr)
{
/* Warn about unused attrs. */
FcChar8 **attrs = parse->pstack->attr;
while (*attrs)
{
if (attrs[0][0])
{
FcConfigMessage (parse, FcSevereError, "invalid attribute '%s'", attrs[0]);
}
attrs += 2;
}
}
FcVStackClear (parse); FcVStackClear (parse);
old = parse->pstack; old = parse->pstack;
parse->pstack = old->prev; parse->pstack = old->prev;
FcStrBufDestroy (&old->str); FcStrBufDestroy (&old->str);
if (old->attr && old->attr != old->attr_buf_static) if (old->attr && old->attr != old->attr_buf_static)
free (old->attr); free (old->attr);
@ -1141,7 +1157,10 @@ FcConfigGetAttribute (FcConfigParse *parse, const char *attr)
while (*attrs) while (*attrs)
{ {
if (!strcmp ((char *) *attrs, attr)) if (!strcmp ((char *) *attrs, attr))
{
attrs[0][0] = '\0'; /* Mark as used. */
return attrs[1]; return attrs[1];
}
attrs += 2; attrs += 2;
} }
return 0; return 0;