winansi: simplify loading the GetCurrentConsoleFontEx() function
We introduced helper macros to simplify loading functions dynamically. Might just as well use them. This also side-steps a compiler warning when building with GCC v8.x: it would complain about casting between incompatible function pointers. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Schindelin committed
Jun 13, 2019 at 04:49 UTC
4fa42df972dc40fa3b50195ace838f2269da977a
1 file changed
+5
-9
compat/winansi.c
+5
-9
@@ -7,6 +7,7 @@
7
#include <wingdi.h>
8
#include <winreg.h>
9
#include "win32.h"
10
+#include "win32/lazyload.h"
11
12
static int fd_is_interactive[3] = { 0, 0, 0 };
13
#define FD_CONSOLE 0x1
@@ -41,26 +42,21 @@ typedef struct _CONSOLE_FONT_INFOEX {
42
#endif
43
#endif
44
44
-typedef BOOL (WINAPI *PGETCURRENTCONSOLEFONTEX)(HANDLE, BOOL,
45
- PCONSOLE_FONT_INFOEX);
46
-
45
static void warn_if_raster_font(void)
46
{
47
DWORD fontFamily = 0;
50
- PGETCURRENTCONSOLEFONTEX pGetCurrentConsoleFontEx;
48
+ DECLARE_PROC_ADDR(kernel32.dll, BOOL, GetCurrentConsoleFontEx,
49
+ HANDLE, BOOL, PCONSOLE_FONT_INFOEX);
50
51
/* don't bother if output was ascii only */
52
if (!non_ascii_used)
53
return;
54
55
/* GetCurrentConsoleFontEx is available since Vista */
57
- pGetCurrentConsoleFontEx = (PGETCURRENTCONSOLEFONTEX) GetProcAddress(
58
- GetModuleHandle("kernel32.dll"),
59
- "GetCurrentConsoleFontEx");
60
- if (pGetCurrentConsoleFontEx) {
56
+ if (INIT_PROC_ADDR(GetCurrentConsoleFontEx)) {
57
CONSOLE_FONT_INFOEX cfi;
58
cfi.cbSize = sizeof(cfi);
63
- if (pGetCurrentConsoleFontEx(console, 0, &cfi))
59
+ if (GetCurrentConsoleFontEx(console, 0, &cfi))
60
fontFamily = cfi.FontFamily;
61
} else {
62
/* pre-Vista: check default console font in registry */