Allow the modification on FcTypeVoid with FcTypeLangSet and FcTypeCharSet

FcTypeVoid is likely to happen when 'lang' and 'charset'
is deleted by 'delete' or 'delete_all' mode in edit.
Without this change, any modification on them are simply
ignored.

This is useful to make a lot of changes, particularly
when one wants to add a few and delete a lot say.
This commit is contained in:
Akira TAGOH 2014-05-13 21:21:43 +09:00
parent 81664fe54f
commit 48c8b7938a
4 changed files with 43 additions and 12 deletions

View File

@ -722,6 +722,16 @@ FcConfigPromote (FcValue v, FcValue u, FcValuePromotionBuffer *buf)
v.u.l = FcLangSetPromote (v.u.s, buf); v.u.l = FcLangSetPromote (v.u.s, buf);
v.type = FcTypeLangSet; v.type = FcTypeLangSet;
} }
else if (v.type == FcTypeVoid && u.type == FcTypeLangSet)
{
v.u.l = FcLangSetPromote (NULL, buf);
v.type = FcTypeLangSet;
}
else if (v.type == FcTypeVoid && u.type == FcTypeCharSet)
{
v.u.c = FcCharSetPromote (buf);
v.type = FcTypeCharSet;
}
if (buf && v.type == FcTypeDouble && u.type == FcTypeRange) if (buf && v.type == FcTypeDouble && u.type == FcTypeRange)
{ {
v.u.r = FcRangePromote (v.u.d, buf); v.u.r = FcRangePromote (v.u.d, buf);

View File

@ -42,6 +42,21 @@ FcCharSetCreate (void)
return fcs; return fcs;
} }
FcCharSet *
FcCharSetPromote (FcValuePromotionBuffer *vbuf)
{
FcCharSet *fcs = (FcCharSet *) vbuf;
FC_ASSERT_STATIC (sizeof (FcCharSet) <= sizeof (FcValuePromotionBuffer));
FcRefSetConst (&fcs->ref);
fcs->num = 0;
fcs->leaves_offset = 0;
fcs->numbers_offset = 0;
return fcs;
}
FcCharSet * FcCharSet *
FcCharSetNew (void) FcCharSetNew (void)
{ {

View File

@ -720,6 +720,9 @@ FcPrivate FcLangSet *
FcLangSetSerialize(FcSerialize *serialize, const FcLangSet *l); FcLangSetSerialize(FcSerialize *serialize, const FcLangSet *l);
/* fccharset.c */ /* fccharset.c */
FcPrivate FcCharSet *
FcCharSetPromote (FcValuePromotionBuffer *vbuf);
FcPrivate void FcPrivate void
FcLangCharSetPopulate (void); FcLangCharSetPopulate (void);

View File

@ -720,6 +720,8 @@ FcLangSetPromote (const FcChar8 *lang, FcValuePromotionBuffer *vbuf)
memset (buf->ls.map, '\0', sizeof (buf->ls.map)); memset (buf->ls.map, '\0', sizeof (buf->ls.map));
buf->ls.map_size = NUM_LANG_SET_MAP; buf->ls.map_size = NUM_LANG_SET_MAP;
buf->ls.extra = 0; buf->ls.extra = 0;
if (lang)
{
id = FcLangSetIndex (lang); id = FcLangSetIndex (lang);
if (id > 0) if (id > 0)
{ {
@ -734,6 +736,7 @@ FcLangSetPromote (const FcChar8 *lang, FcValuePromotionBuffer *vbuf)
FcRefInit (&buf->strs.ref, 1); FcRefInit (&buf->strs.ref, 1);
buf->str = (FcChar8 *) lang; buf->str = (FcChar8 *) lang;
} }
}
return &buf->ls; return &buf->ls;
} }