Skip to content

Commit d14b572

Browse files
authored
Winansi: Drop pre-Vista workaround (#6109)
1edeb9a (Win32: warn if the console font doesn't support Unicode, 2014-06-10) introduced both code to detect the current console font on Windows Vista and newer and a fallback for older systems to detect the default console font and issue a warning if that font doesn't support unicode. Since we haven't supported any Windows older than Vista in almost a decade, we don't need to keep the workaround. This more or less fell out of #6108, but didn't quite fit into that PR. There are also some other version specific hacks and workarounds I considered dropping, but decided against: * 492f709 * I'm unsure if this regression has ever been fixed or just become the new normal. * #5042 * So far this hasn't been an issue on Windows 8.1, but officially Go 1.21 and newer only support Windows 10 and newer. So this might become a problem at any point.
2 parents a2409ca + 44760f1 commit d14b572

File tree

6 files changed

+11
-38
lines changed

6 files changed

+11
-38
lines changed

compat/mingw.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2952,7 +2952,7 @@ int mingw_rename(const char *pold, const char *pnew)
29522952
if (supports_file_rename_info_ex) {
29532953
/*
29542954
* Our minimum required Windows version is still set to Windows
2955-
* Vista. We thus have to declare required infrastructure for
2955+
* 8.1. We thus have to declare required infrastructure for
29562956
* FileRenameInfoEx ourselves until we bump _WIN32_WINNT to
29572957
* 0x0A00. Furthermore, we have to handle cases where the
29582958
* FileRenameInfoEx call isn't supported yet.

compat/nedmalloc/malloc.c.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ MAX_RELEASE_CHECK_RATE default: 4095 unless not HAVE_MMAP
500500
#ifdef WIN32
501501
#define WIN32_LEAN_AND_MEAN
502502
#ifndef _WIN32_WINNT
503-
#define _WIN32_WINNT 0x403
503+
#define _WIN32_WINNT 0x603
504504
#endif
505505
#include <windows.h>
506506
#define HAVE_MMAP 1

compat/poll/poll.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
#define DISABLE_SIGN_COMPARE_WARNINGS
2222

23-
/* To bump the minimum Windows version to Windows Vista */
23+
/* To bump the minimum Windows version to Windows 8.1 */
2424
#include "git-compat-util.h"
2525

2626
/* Tell gcc not to warn about the (nfd < 0) tests, below. */
@@ -41,7 +41,7 @@
4141
#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
4242
# define WIN32_NATIVE
4343
# if defined (_MSC_VER) && !defined(_WIN32_WINNT)
44-
# define _WIN32_WINNT 0x0502
44+
# define _WIN32_WINNT 0x0603
4545
# endif
4646
# include <winsock2.h>
4747
# include <windows.h>

compat/posix.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878

7979
#if defined(WIN32) && !defined(__CYGWIN__) /* Both MinGW and MSVC */
8080
# if !defined(_WIN32_WINNT)
81-
# define _WIN32_WINNT 0x0600
81+
# define _WIN32_WINNT 0x0603
8282
# endif
8383
#define WIN32_LEAN_AND_MEAN /* stops windows.h including winsock.h */
8484
#include <winsock2.h>

compat/win32/flush.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ int win32_fsync_no_flush(int fd)
66
{
77
IO_STATUS_BLOCK io_status;
88

9+
#ifndef FLUSH_FLAGS_FILE_DATA_ONLY
910
#define FLUSH_FLAGS_FILE_DATA_ONLY 1
11+
#endif
1012

1113
DECLARE_PROC_ADDR(ntdll.dll, NTSTATUS, NTAPI, NtFlushBuffersFileEx,
1214
HANDLE FileHandle, ULONG Flags, PVOID Parameters, ULONG ParameterSize,

compat/winansi.c

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -32,47 +32,18 @@ static int non_ascii_used = 0;
3232
static HANDLE hthread, hread, hwrite;
3333
static HANDLE hconsole1, hconsole2;
3434

35-
#ifdef __MINGW32__
36-
#if !defined(__MINGW64_VERSION_MAJOR) || __MINGW64_VERSION_MAJOR < 5
37-
typedef struct _CONSOLE_FONT_INFOEX {
38-
ULONG cbSize;
39-
DWORD nFont;
40-
COORD dwFontSize;
41-
UINT FontFamily;
42-
UINT FontWeight;
43-
WCHAR FaceName[LF_FACESIZE];
44-
} CONSOLE_FONT_INFOEX, *PCONSOLE_FONT_INFOEX;
45-
#endif
46-
#endif
47-
4835
static void warn_if_raster_font(void)
4936
{
5037
DWORD fontFamily = 0;
51-
DECLARE_PROC_ADDR(kernel32.dll, BOOL, WINAPI,
52-
GetCurrentConsoleFontEx, HANDLE, BOOL,
53-
PCONSOLE_FONT_INFOEX);
38+
CONSOLE_FONT_INFOEX cfi;
5439

5540
/* don't bother if output was ascii only */
5641
if (!non_ascii_used)
5742
return;
5843

59-
/* GetCurrentConsoleFontEx is available since Vista */
60-
if (INIT_PROC_ADDR(GetCurrentConsoleFontEx)) {
61-
CONSOLE_FONT_INFOEX cfi;
62-
cfi.cbSize = sizeof(cfi);
63-
if (GetCurrentConsoleFontEx(console, 0, &cfi))
64-
fontFamily = cfi.FontFamily;
65-
} else {
66-
/* pre-Vista: check default console font in registry */
67-
HKEY hkey;
68-
if (ERROR_SUCCESS == RegOpenKeyExA(HKEY_CURRENT_USER, "Console",
69-
0, KEY_READ, &hkey)) {
70-
DWORD size = sizeof(fontFamily);
71-
RegQueryValueExA(hkey, "FontFamily", NULL, NULL,
72-
(LPVOID) &fontFamily, &size);
73-
RegCloseKey(hkey);
74-
}
75-
}
44+
cfi.cbSize = sizeof(cfi);
45+
if (GetCurrentConsoleFontEx(console, 0, &cfi))
46+
fontFamily = cfi.FontFamily;
7647

7748
if (!(fontFamily & TMPF_TRUETYPE)) {
7849
const wchar_t *msg = L"\nWarning: Your console font probably "

0 commit comments

Comments
 (0)