diff options
author | Ben Straub <bs@github.com> | 2013-08-05 22:41:39 +0400 |
---|---|---|
committer | Ben Straub <bs@github.com> | 2013-08-05 22:41:39 +0400 |
commit | d85636190f127efa2ec4a6593124c037dfec0ba9 (patch) | |
tree | 1c19c3cd463e69472d6d58cebd560d8ec025796e /tests-clar/clar_libgit2.c | |
parent | 9b7d02ff2d9b87d61778ee7ef5e2d43bf4c561f0 (diff) |
Split UTF-16 and UTF-8 buffer sizes for win32
Also fixed up call-sites to use the correct buffer sizes, especially
when converting to utf-8.
Diffstat (limited to 'tests-clar/clar_libgit2.c')
-rw-r--r-- | tests-clar/clar_libgit2.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/tests-clar/clar_libgit2.c b/tests-clar/clar_libgit2.c index de0e41bf7..34d54cd94 100644 --- a/tests-clar/clar_libgit2.c +++ b/tests-clar/clar_libgit2.c @@ -56,17 +56,17 @@ void cl_git_rewritefile(const char *filename, const char *new_content) char *cl_getenv(const char *name) { - wchar_t name_utf16[GIT_WIN_PATH]; + wchar_t name_utf16[GIT_WIN_PATH_UTF16]; DWORD alloc_len; wchar_t *value_utf16; char *value_utf8; - git__utf8_to_16(name_utf16, GIT_WIN_PATH, name); + git__utf8_to_16(name_utf16, GIT_WIN_PATH_UTF16, name); alloc_len = GetEnvironmentVariableW(name_utf16, NULL, 0); if (alloc_len <= 0) return NULL; - alloc_len = GIT_WIN_PATH; + alloc_len = GIT_WIN_PATH_UTF8; cl_assert(value_utf16 = git__calloc(alloc_len, sizeof(wchar_t))); GetEnvironmentVariableW(name_utf16, value_utf16, alloc_len); @@ -81,13 +81,13 @@ char *cl_getenv(const char *name) int cl_setenv(const char *name, const char *value) { - wchar_t name_utf16[GIT_WIN_PATH]; - wchar_t value_utf16[GIT_WIN_PATH]; + wchar_t name_utf16[GIT_WIN_PATH_UTF16]; + wchar_t value_utf16[GIT_WIN_PATH_UTF16]; - git__utf8_to_16(name_utf16, GIT_WIN_PATH, name); + git__utf8_to_16(name_utf16, GIT_WIN_PATH_UTF16, name); if (value) { - git__utf8_to_16(value_utf16, GIT_WIN_PATH, value); + git__utf8_to_16(value_utf16, GIT_WIN_PATH_UTF16, value); cl_assert(SetEnvironmentVariableW(name_utf16, value_utf16)); } else { /* Windows XP returns 0 (failed) when passing NULL for lpValue when @@ -107,12 +107,12 @@ int cl_setenv(const char *name, const char *value) * the source is a directory, a child of the source). */ int cl_rename(const char *source, const char *dest) { - wchar_t source_utf16[GIT_WIN_PATH]; - wchar_t dest_utf16[GIT_WIN_PATH]; + wchar_t source_utf16[GIT_WIN_PATH_UTF16]; + wchar_t dest_utf16[GIT_WIN_PATH_UTF16]; unsigned retries = 1; - git__utf8_to_16(source_utf16, GIT_WIN_PATH, source); - git__utf8_to_16(dest_utf16, GIT_WIN_PATH, dest); + git__utf8_to_16(source_utf16, GIT_WIN_PATH_UTF16, source); + git__utf8_to_16(dest_utf16, GIT_WIN_PATH_UTF16, dest); while (!MoveFileW(source_utf16, dest_utf16)) { /* Only retry if the error is ERROR_ACCESS_DENIED; |