Merge pull request #38 from r-a-sattarov/master

vgui2/vgui_surfacelib/linuxfont: fix incorrect variadic casts
This commit is contained in:
nillerusr 2022-02-05 18:25:24 +03:00 committed by GitHub
commit c57fb24610
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -166,44 +166,40 @@ void CLinuxFont::CreateFontList()
}
#ifndef ANDROID
static FcPattern* FontMatch(const char* type, FcType vtype, const void* value,
...)
static FcPattern* FontMatch(const char* type, ...)
{
FcValue fcvalue;
va_list ap;
va_start(ap, value);
va_start(ap, type);
FcPattern* pattern = FcPatternCreate();
for (;;)
{
FcValue fcvalue;
fcvalue.type = vtype;
switch (vtype) {
for (;;) {
// FcType is promoted to int when passed through ...
fcvalue.type = static_cast<FcType>(va_arg(ap, int));
switch (fcvalue.type) {
case FcTypeString:
fcvalue.u.s = (FcChar8*) value;
fcvalue.u.s = va_arg(ap, const FcChar8 *);
break;
case FcTypeInteger:
fcvalue.u.i = (int) value;
fcvalue.u.i = va_arg(ap, int);
break;
default:
Assert(!"FontMatch unhandled type");
}
FcPatternAdd(pattern, type, fcvalue, 0);
FcPatternAdd(pattern, type, fcvalue, FcFalse);
type = va_arg(ap, const char *);
if (!type)
break;
// FcType is promoted to int when passed through ...
vtype = static_cast<FcType>(va_arg(ap, int));
value = va_arg(ap, const void *);
};
va_end(ap);
FcConfigSubstitute(0, pattern, FcMatchPattern);
FcConfigSubstitute(NULL, pattern, FcMatchPattern);
FcDefaultSubstitute(pattern);
FcResult result;
FcPattern* match = FcFontMatch(0, pattern, &result);
FcPattern* match = FcFontMatch(NULL, pattern, &result);
FcPatternDestroy(pattern);
return match;