From f5de06030414fcd3c416833b22fab0be1ed21967 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Thu, 4 Nov 2004 00:20:27 +0000 Subject: [PATCH] Argument is in UTF-8. Use wide character Win32 API if present. 2004-11-04 Tor Lillqvist * gmodule-win32.c (_g_module_open): Argument is in UTF-8. Use wide character Win32 API if present. * gmodule.c (parse_libtool_archive, g_module_open): Convert file name to UTF-8 before storing in the error message string. * gmodule.c (parse_libtool_archive): Use g_open(). --- gmodule/ChangeLog | 10 ++++++++++ gmodule/gmodule-win32.c | 15 ++++++++++++++- gmodule/gmodule.c | 17 +++++++++++++---- 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/gmodule/ChangeLog b/gmodule/ChangeLog index 97caa0f..8c98209 100644 --- a/gmodule/ChangeLog +++ b/gmodule/ChangeLog @@ -1,3 +1,13 @@ +2004-11-04 Tor Lillqvist + + * gmodule-win32.c (_g_module_open): Argument is in UTF-8. Use wide + character Win32 API if present. + + * gmodule.c (parse_libtool_archive, g_module_open): Convert file + name to UTF-8 before storing in the error message string. + + * gmodule.c (parse_libtool_archive): Use g_open(). + 2004-11-02 Matthias Clasen * === Released 2.5.5 === diff --git a/gmodule/gmodule-win32.c b/gmodule/gmodule-win32.c index 97b3363..bf63091 100644 --- a/gmodule/gmodule-win32.c +++ b/gmodule/gmodule-win32.c @@ -62,8 +62,21 @@ _g_module_open (const gchar *file_name, cygwin_conv_to_win32_path(file_name, tmp); file_name = tmp; #endif + if (G_WIN32_HAVE_WIDECHAR_API ()) + { + wchar_t *wfilename = g_utf8_to_utf16 (file_name, -1, NULL, NULL, NULL); - handle = LoadLibrary (file_name); + handle = LoadLibraryW (wfilename); + g_free (wfilename); + } + else + { + gchar *cp_filename = g_locale_from_utf8 (file_name, -1, NULL, NULL, NULL); + + handle = LoadLibraryA (cp_filename); + g_free (cp_filename); + } + if (!handle) set_error (); diff --git a/gmodule/gmodule.c b/gmodule/gmodule.c index 507f527..1673b2e 100644 --- a/gmodule/gmodule.c +++ b/gmodule/gmodule.c @@ -31,6 +31,7 @@ #ifdef HAVE_CONFIG_H # include #endif +#include "gstdio.h" #include "gmodule.h" #include "gmoduleconf.h" #include @@ -207,10 +208,12 @@ parse_libtool_archive (const gchar* libtool_name) GTokenType token; GScanner *scanner; - int fd = open (libtool_name, O_RDONLY, 0); + int fd = g_open (libtool_name, O_RDONLY, 0); if (fd < 0) { - g_module_set_error_unduped (g_strdup_printf ("failed to open libtool archive \"%s\"", libtool_name)); + gchar *display_libtool_name = g_filename_display_name (libtool_name); + g_module_set_error_unduped (g_strdup_printf ("failed to open libtool archive \"%s\"", display_libtool_name)); + g_free (display_libtool_name); return NULL; } /* search libtool's dlname specification */ @@ -234,7 +237,9 @@ parse_libtool_archive (const gchar* libtool_name) (token == TOKEN_INSTALLED ? G_TOKEN_IDENTIFIER : G_TOKEN_STRING)) { - g_module_set_error_unduped (g_strdup_printf ("unable to parse libtool archive \"%s\"", libtool_name)); + gchar *display_libtool_name = g_filename_display_name (libtool_name); + g_module_set_error_unduped (g_strdup_printf ("unable to parse libtool archive \"%s\"", display_libtool_name)); + g_free (display_libtool_name); g_free (lt_dlname); g_free (lt_libdir); @@ -392,7 +397,11 @@ g_module_open (const gchar *file_name, (flags & G_MODULE_BIND_LOCAL) != 0); } else - g_module_set_error_unduped (g_strdup_printf ("unable to access file \"%s\"", file_name)); + { + gchar *display_file_name = g_filename_display_name (file_name); + g_module_set_error_unduped (g_strdup_printf ("unable to access file \"%s\"", display_file_name)); + g_free (display_file_name); + } g_free (name); if (handle) -- 2.7.4