Argument is in UTF-8. Use wide character Win32 API if present.
authorTor Lillqvist <tml@iki.fi>
Thu, 4 Nov 2004 00:20:27 +0000 (00:20 +0000)
committerTor Lillqvist <tml@src.gnome.org>
Thu, 4 Nov 2004 00:20:27 +0000 (00:20 +0000)
2004-11-04  Tor Lillqvist  <tml@iki.fi>

* 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
gmodule/gmodule-win32.c
gmodule/gmodule.c

index 97caa0f..8c98209 100644 (file)
@@ -1,3 +1,13 @@
+2004-11-04  Tor Lillqvist  <tml@iki.fi>
+
+       * 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  <mclasen@redhat.com>
 
        * === Released 2.5.5 ===
index 97b3363..bf63091 100644 (file)
@@ -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 ();
 
index 507f527..1673b2e 100644 (file)
@@ -31,6 +31,7 @@
 #ifdef HAVE_CONFIG_H
 # include <config.h>
 #endif
+#include       "gstdio.h"
 #include       "gmodule.h"
 #include       "gmoduleconf.h"
 #include       <errno.h>
@@ -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)