Add tests for UpdateCrypto
[TortoiseGit.git] / ext / libgit2-0007-Unbreak-Windows-XP.patch
blob7eb7d4571ca803e9cff7a719d985301a4591d055
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>
7 ---
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
15 @@ -9,6 +9,7 @@
16 #include "buffer.h"
17 #include "../buffer.h"
18 #include "utf-conv.h"
19 +#include "version.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;
25 size_t new_size;
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);
31 if (!len_w)
32 return 0;
34 assert(string_w);
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)
39 return 0;
41 assert(utf8_len > 0);
42 @@ -43,7 +48,7 @@ int git_buf_put_w(git_buf *buf, const wchar_t *string_w, size_t len_w)
43 return -1;
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);
51 --
52 2.4.5.windows.1