diff options
author | Werner Koch <[email protected]> | 2021-03-05 15:13:53 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2021-03-05 15:19:41 +0000 |
commit | 618ce381f9d70f3a94e87f58f667a6138411018e (patch) | |
tree | c5c1c29e72c8f06f957a0a3c69de43aa96e89594 | |
parent | w32: Minor cleanup of w32-gettext (diff) | |
download | libgpg-error-618ce381f9d70f3a94e87f58f667a6138411018e.tar.gz libgpg-error-618ce381f9d70f3a94e87f58f667a6138411018e.zip |
w32: Allow Unicode paths for the gettext domain.
* src/w32-gettext.c: Remove remaining WindowsCE support
(load_domain): Use CreateFileW.
-rw-r--r-- | src/w32-gettext.c | 57 |
1 files changed, 12 insertions, 45 deletions
diff --git a/src/w32-gettext.c b/src/w32-gettext.c index e8bdb54..7c4c9b0 100644 --- a/src/w32-gettext.c +++ b/src/w32-gettext.c @@ -34,9 +34,7 @@ #include <sys/types.h> #endif #include <stdint.h> -#ifndef HAVE_W32CE_SYSTEM -# include <locale.h> -#endif /*HAVE_W32CE_SYSTEM*/ +#include <locale.h> #include <windows.h> #ifdef JNLIB_IN_JNLIB @@ -64,37 +62,6 @@ static struct } override_locale; -#ifdef HAVE_W32CE_SYSTEM -/* Forward declaration. */ -static wchar_t *utf8_to_wchar (const char *string, size_t length, size_t *retlen); - -static HANDLE -MyCreateFileA (LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwSharedMode, - LPSECURITY_ATTRIBUTES lpSecurityAttributes, - DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, - HANDLE hTemplateFile) -{ - wchar_t *filename; - HANDLE result; - int err; - size_t size; - - filename = utf8_to_wchar (lpFileName, -1, &size); - if (!filename) - return INVALID_HANDLE_VALUE; - - result = CreateFileW (filename, dwDesiredAccess, dwSharedMode, - lpSecurityAttributes, dwCreationDisposition, - dwFlagsAndAttributes, hTemplateFile); - - err = GetLastError (); - free (filename); - SetLastError (err); - return result; -} -#undef CreateFileA -#define CreateFileA MyCreateFileA -#endif /* localname.c from gettext BEGIN. */ @@ -655,9 +622,7 @@ MyCreateFileA (LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwSharedMode, static const char * my_nl_locale_name (const char *categoryname) { -#ifndef HAVE_W32CE_SYSTEM const char *retval; -#endif LANGID langid; int primary, sub; @@ -673,7 +638,6 @@ my_nl_locale_name (const char *categoryname) /* Let the user override the system settings through environment * variables, as on POSIX systems. */ -#ifndef HAVE_W32CE_SYSTEM retval = getenv ("LC_ALL"); if (retval != NULL && retval[0] != '\0') return retval; @@ -683,14 +647,9 @@ my_nl_locale_name (const char *categoryname) retval = getenv ("LANG"); if (retval != NULL && retval[0] != '\0') return retval; -#endif /*!HAVE_W32CE_SYSTEM*/ /* Use native Win32 API locale ID. */ -#ifdef HAVE_W32CE_SYSTEM - lcid = GetSystemDefaultLCID (); -#else lcid = GetThreadLocale (); -#endif /* Strip off the sorting rules, keep only the language part. */ langid = LANGIDFROMLCID (lcid); } @@ -1251,8 +1210,16 @@ load_domain (const char *filename) size_t to_read; char *read_ptr; - fh = CreateFileA (filename, GENERIC_READ, FILE_SHARE_WRITE, NULL, - OPEN_EXISTING, 0, NULL); + { + wchar_t *wfilename = _gpgrt_utf8_to_wchar (filename); + + if (!wfilename) + fh = INVALID_HANDLE_VALUE; + else + fh = CreateFileW (wfilename, GENERIC_READ, FILE_SHARE_WRITE, NULL, + OPEN_EXISTING, 0, NULL); + xfree (wfilename); + } if (fh == INVALID_HANDLE_VALUE) return NULL; @@ -2042,7 +2009,7 @@ main (int argc, char **argv) return 0; } /* - * Local Variables: + *No-Local Variables: * compile-command: "i586-mingw32msvc-gcc -DTEST -Wall -g w32-gettext.c" * End: */ |