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 #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_list ap;
va_start(ap, value); va_start(ap, type);
FcPattern* pattern = FcPatternCreate(); FcPattern* pattern = FcPatternCreate();
for (;;) for (;;) {
{ // FcType is promoted to int when passed through ...
FcValue fcvalue; fcvalue.type = static_cast<FcType>(va_arg(ap, int));
fcvalue.type = vtype; switch (fcvalue.type) {
switch (vtype) {
case FcTypeString: case FcTypeString:
fcvalue.u.s = (FcChar8*) value; fcvalue.u.s = va_arg(ap, const FcChar8 *);
break; break;
case FcTypeInteger: case FcTypeInteger:
fcvalue.u.i = (int) value; fcvalue.u.i = va_arg(ap, int);
break; break;
default: default:
Assert(!"FontMatch unhandled type"); Assert(!"FontMatch unhandled type");
} }
FcPatternAdd(pattern, type, fcvalue, 0); FcPatternAdd(pattern, type, fcvalue, FcFalse);
type = va_arg(ap, const char *); type = va_arg(ap, const char *);
if (!type) if (!type)
break; 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); va_end(ap);
FcConfigSubstitute(0, pattern, FcMatchPattern); FcConfigSubstitute(NULL, pattern, FcMatchPattern);
FcDefaultSubstitute(pattern); FcDefaultSubstitute(pattern);
FcResult result; FcResult result;
FcPattern* match = FcFontMatch(0, pattern, &result); FcPattern* match = FcFontMatch(NULL, pattern, &result);
FcPatternDestroy(pattern); FcPatternDestroy(pattern);
return match; return match;