1 From 94e65a13c3a77dfb539203c754a04d1ad940d032 Mon Sep 17 00:00:00 2001
2 From: Sven Strickroth <email@cs-ware.de>
3 Date: Fri, 24 Jul 2015 01:23:41 +0200
4 Subject: [PATCH] Unbreak Windows XP
6 Signed-off-by: Sven Strickroth <email@cs-ware.de>
8 src/win32/buffer.c | 9 +++++++--
9 1 file changed, 7 insertions(+), 2 deletions(-)
11 diff --git a/src/win32/buffer.c b/src/win32/buffer.c
12 index 7495018..02e7988 100644
13 --- a/src/win32/buffer.c
14 +++ b/src/win32/buffer.c
17 #include "../buffer.h"
21 GIT_INLINE(int) handle_wc_error(void)
23 @@ -25,13 +26,17 @@ int git_buf_put_w(git_buf *buf, const wchar_t *string_w, size_t len_w)
24 int utf8_len, utf8_write_len;
27 + static int is_vista_or_later = -1;
28 + if (is_vista_or_later < 0)
29 + is_vista_or_later = git_has_win32_version(6, 0, 0);
36 /* Measure the string necessary for conversion */
37 - if ((utf8_len = WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, string_w, len_w, NULL, 0, NULL, NULL)) == 0)
38 + if ((utf8_len = WideCharToMultiByte(CP_UTF8, is_vista_or_later ? WC_ERR_INVALID_CHARS : 0, string_w, len_w, NULL, 0, NULL, NULL)) == 0)
42 @@ -43,7 +48,7 @@ int git_buf_put_w(git_buf *buf, const wchar_t *string_w, size_t len_w)
45 if ((utf8_write_len = WideCharToMultiByte(
46 - CP_UTF8, WC_ERR_INVALID_CHARS, string_w, len_w, &buf->ptr[buf->size], utf8_len, NULL, NULL)) == 0)
47 + CP_UTF8, is_vista_or_later ? WC_ERR_INVALID_CHARS : 0, string_w, len_w, &buf->ptr[buf->size], utf8_len, NULL, NULL)) == 0)
48 return handle_wc_error();
50 assert(utf8_write_len == utf8_len);