src/win32/utf-conv.c


Log

Author Commit Date CI Message
Patrick Steinhardt 0c7f49dd 2017-06-30T13:39:01 Make sure to always include "common.h" first Next to including several files, our "common.h" header also declares various macros which are then used throughout the project. As such, we have to make sure to always include this file first in all implementation files. Otherwise, we might encounter problems or even silent behavioural differences due to macros or defines not being defined as they should be. So in fact, our header and implementation files should make sure to always include "common.h" first. This commit does so by establishing a common include pattern. Header files inside of "src" will now always include "common.h" as its first other file, separated by a newline from all the other includes to make it stand out as special. There are two cases for the implementation files. If they do have a matching header file, they will always include this one first, leading to "common.h" being transitively included as first file. If they do not have a matching header file, they instead include "common.h" as first file themselves. This fixes the outlined problems and will become our standard practice for header and source files inside of the "src/" from now on.
Edward Thomson 494e61b8 2016-02-09T17:44:59 win32: drop xp support in WideCharToMultiByte
Edward Thomson cd39e4e2 2015-04-29T18:12:51 git_buf_put_w: introduce utf16->utf8 conversion
Edward Thomson 3603cb09 2015-02-10T23:13:49 git__*allocarray: safer realloc and malloc Introduce git__reallocarray that checks the product of the number of elements and element size for overflow before allocation. Also introduce git__mallocarray that behaves like calloc, but without the `c`. (It does not zero memory, for those truly worried about every cycle.)
Edward Thomson 392702ee 2015-02-09T23:41:13 allocations: test for overflow of requested size Introduce some helper macros to test integer overflow from arithmetic and set error message appropriately.
Edward Thomson cceae9a2 2014-12-01T13:09:58 win32: use NT-prefixed "\\?\" paths When turning UTF-8 paths into UCS-2 paths for Windows, always use the \\?\-prefixed paths. Because this bypasses the system's path canonicalization, handle the canonicalization functions ourselves. We must: 1. always use a backslash as a directory separator 2. only use a single backslash between directories 3. not rely on the system to translate "." and ".." in paths 4. remove trailing backslashes, except at the drive root (C:\)
Philip Kelley 7110000d 2014-04-22T10:21:19 React to feedback for UTF-8 <-> WCHAR and reparse work
Philip Kelley c2c81615 2014-04-19T18:05:31 Win32: UTF-8 <-> WCHAR conversion overhaul
Edward Thomson 55d257e7 2014-02-05T15:03:00 Remove unused utf8 -> utf16 conversion code
Ben Straub aa0af729 2013-08-10T14:56:58 Fix 64-bit MSVC warnings
Ben Straub aaefbdee 2013-08-08T08:48:57 Discriminate path-specific and general UTF-X conversions
Ben Straub 2c0128ee 2013-08-07T19:29:33 Rename git_win_str_utf* to git_win32_path_utf*
Ben Straub 9c38f7a6 2013-08-07T13:22:41 Add typedefs for win32 utf-8 and utf-16 buffers ...and normalize the signatures of the two conversion functions.
Ben Straub d8563619 2013-08-05T11:41:39 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.
Edward Thomson 359fc2d2 2013-01-08T17:07:25 update copyrights
Russell Belfer cccacac5 2012-11-14T22:41:51 Add POSIX compat lstat() variant for win32 The existing p_lstat implementation on win32 is not quite POSIX compliant when setting errno to ENOTDIR. This adds an option to make is be compliant so that code (such as checkout) that cares to have separate behavior for ENOTDIR can use it portably. This also contains a couple of other minor cleanups in the posix_w32.c implementations to avoid unnecessary work.
nulltoken 9ac8b113 2012-09-20T14:06:49 Fix MSVC amd64 compilation warnings
Vicent Marti 0f4c6175 2012-08-28T22:19:08 Add bounds checking to UTF-8 conversion
Vicent Marti 6813169a 2012-08-06T12:45:59 windows: Keep UTF-8 on the stack yo
Vicent Martí 3b73a034 2012-04-25T16:26:12 UTF-8 changes yo
Russell Belfer 9e35d7fd 2012-05-24T13:44:24 Fix bugs in UTF-8 <-> UTF-16 conversion The function to convert UTF-16 to UTF-8 was only allocating a buffer of wcslen(utf16str) bytes for the UTF-8 string, but that is not sufficient if you have multibyte characters, and so when those occured, the conversion was failing. This updates the conversion functions to use the Win APIs to calculate the correct buffer lengths. Also fixes a comparison in the unit tests that would fail if you did not have a particular environment variable set.
Vicent Martí cd58c15c 2012-05-05T16:47:20 Merge remote-tracking branch 'scottjg/fix-mingw32' into development Conflicts: src/netops.c src/netops.h src/transports/http.c tests-clar/clar
Scott J. Goldman b47e0a71 2012-05-05T13:52:48 Fix missing prototype warning in utf-conv.c
Russell Belfer 44ef8b1b 2012-04-13T13:00:10 Fix warnings on 64-bit windows builds This fixes all the warnings on win64 except those in deps, which come from the regex code.
Russell Belfer deafee7b 2012-03-14T17:36:15 Continue error conversion This converts blob.c, fileops.c, and all of the win32 files. Also, various minor cleanups throughout the code. Plus, in testing the win32 build, I cleaned up a bunch (although not all) of the warnings with the 64-bit build.
schu 5e0de328 2012-02-13T17:10:24 Update Copyright header Signed-off-by: schu <schu-github@schulog.org>
Russell Belfer 73b51450 2011-12-28T23:28:50 Add support for macros and cache flush API. Add support for git attribute macro definitions. Also, add support for cache flush API to clear the attribute file content cache when needed. Additionally, improved the handling of global and system files, making common utility functions in fileops and converting config and attr to both use the common functions. Adds a bunch more tests and fixed some memory leaks. Note that adding macros required me to use refcounted attribute assignment definitions, which complicated, but probably improved memory usage.
Vicent Marti 3286c408 2011-10-28T14:51:13 global: Properly use `git__` memory wrappers Ensure that all memory related functions (malloc, calloc, strdup, free, etc) are using their respective `git__` wrappers.
Vicent Marti 11d51ca6 2011-10-26T16:43:55 windows: Add support for non-UTF codepages Our previous assumption that all paths in Windows are encoded in UTF-8 is rather weak, specially when considering that Git is encoding-agnostic. These set of functions allow the user to change the library's active codepage globally, so it is possible to access paths and files on all international versions of Windows. Note that the default encoding here is UTF-8 because we assume that 99% of all Git repositories will be in UTF-8. Also, if you use non-ascii characters in paths, anywhere, please burn on a fire.