Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b85d0af

Browse files
committed
Merge pull request libgit2#3606 from ethomson/drop_xp
win32: drop xp support in WideCharToMultiByte
2 parents 5663d4f + 494e61b commit b85d0af

File tree

1 file changed

+3
-18
lines changed

1 file changed

+3
-18
lines changed

src/win32/utf-conv.c

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,6 @@
88
#include "common.h"
99
#include "utf-conv.h"
1010

11-
GIT_INLINE(DWORD) get_wc_flags(void)
12-
{
13-
static char inited = 0;
14-
static DWORD flags;
15-
16-
/* Invalid code point check supported on Vista+ only */
17-
if (!inited) {
18-
flags = git_has_win32_version(6, 0, 0) ? WC_ERR_INVALID_CHARS : 0;
19-
inited = 1;
20-
}
21-
22-
return flags;
23-
}
24-
2511
GIT_INLINE(void) git__set_errno(void)
2612
{
2713
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)
@@ -66,7 +52,7 @@ int git__utf16_to_8(char *dest, size_t dest_size, const wchar_t *src)
6652
/* Length of -1 indicates NULL termination of the input string. Subtract 1 from the result to
6753
* turn 0 into -1 (an error code) and to not count the NULL terminator as part of the string's
6854
* length. WideCharToMultiByte never returns int's minvalue, so underflow is not possible */
69-
if ((len = WideCharToMultiByte(CP_UTF8, get_wc_flags(), src, -1, dest, (int)dest_size, NULL, NULL) - 1) < 0)
55+
if ((len = WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, src, -1, dest, (int)dest_size, NULL, NULL) - 1) < 0)
7056
git__set_errno();
7157

7258
return len;
@@ -127,12 +113,11 @@ int git__utf8_to_16_alloc(wchar_t **dest, const char *src)
127113
int git__utf16_to_8_alloc(char **dest, const wchar_t *src)
128114
{
129115
int utf8_size;
130-
DWORD dwFlags = get_wc_flags();
131116

132117
*dest = NULL;
133118

134119
/* Length of -1 indicates NULL termination of the input string */
135-
utf8_size = WideCharToMultiByte(CP_UTF8, dwFlags, src, -1, NULL, 0, NULL, NULL);
120+
utf8_size = WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, src, -1, NULL, 0, NULL, NULL);
136121

137122
if (!utf8_size) {
138123
git__set_errno();
@@ -146,7 +131,7 @@ int git__utf16_to_8_alloc(char **dest, const wchar_t *src)
146131
return -1;
147132
}
148133

149-
utf8_size = WideCharToMultiByte(CP_UTF8, dwFlags, src, -1, *dest, utf8_size, NULL, NULL);
134+
utf8_size = WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, src, -1, *dest, utf8_size, NULL, NULL);
150135

151136
if (!utf8_size) {
152137
git__set_errno();

0 commit comments

Comments
 (0)