From 2ad3bc4a66b6cf841a09819153f0c8607ac6edd9 Mon Sep 17 00:00:00 2001 From: r-a-sattarov Date: Fri, 28 Jan 2022 23:49:27 +0300 Subject: [PATCH] vgui2/vgui_surfacelib/linuxfont: fix incorrect variadic casts backport from MainUI C++ Ref: https://github.com/FWGS/mainui_cpp/commit/fad4805fabba6cc6075a768636ebdf49ed4ff058 --- vgui2/vgui_surfacelib/linuxfont.cpp | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/vgui2/vgui_surfacelib/linuxfont.cpp b/vgui2/vgui_surfacelib/linuxfont.cpp index f94d7a4083..234480ef46 100644 --- a/vgui2/vgui_surfacelib/linuxfont.cpp +++ b/vgui2/vgui_surfacelib/linuxfont.cpp @@ -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(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(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;