From e6da5d082eee4e0e7b3f0b8cc021f49b336e36f5 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Sun, 12 Dec 2004 20:53:02 +0000 Subject: [PATCH] glib/glib.symbols Implement Windows DLL ABI stability also for 2004-12-12 Tor Lillqvist * glib/glib.symbols * glib/gconvert.[ch]: Implement Windows DLL ABI stability also for g_filename_{to,from}_uri(). --- ChangeLog | 6 ++++++ ChangeLog.pre-2-10 | 6 ++++++ ChangeLog.pre-2-12 | 6 ++++++ ChangeLog.pre-2-6 | 6 ++++++ ChangeLog.pre-2-8 | 6 ++++++ glib/gconvert.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++--- glib/gconvert.h | 2 ++ glib/glib.symbols | 10 ++++++++-- 8 files changed, 94 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index f3f193e..adc8bd2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2004-12-12 Tor Lillqvist + + * glib/glib.symbols + * glib/gconvert.[ch]: Implement Windows DLL ABI stability also for + g_filename_{to,from}_uri(). + 2004-12-11 Tor Lillqvist * glib/gstdio.c (g_rename, g_unlink, g_remove): Add doc comments diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index f3f193e..adc8bd2 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,9 @@ +2004-12-12 Tor Lillqvist + + * glib/glib.symbols + * glib/gconvert.[ch]: Implement Windows DLL ABI stability also for + g_filename_{to,from}_uri(). + 2004-12-11 Tor Lillqvist * glib/gstdio.c (g_rename, g_unlink, g_remove): Add doc comments diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index f3f193e..adc8bd2 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,9 @@ +2004-12-12 Tor Lillqvist + + * glib/glib.symbols + * glib/gconvert.[ch]: Implement Windows DLL ABI stability also for + g_filename_{to,from}_uri(). + 2004-12-11 Tor Lillqvist * glib/gstdio.c (g_rename, g_unlink, g_remove): Add doc comments diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index f3f193e..adc8bd2 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,9 @@ +2004-12-12 Tor Lillqvist + + * glib/glib.symbols + * glib/gconvert.[ch]: Implement Windows DLL ABI stability also for + g_filename_{to,from}_uri(). + 2004-12-11 Tor Lillqvist * glib/gstdio.c (g_rename, g_unlink, g_remove): Add doc comments diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index f3f193e..adc8bd2 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,9 @@ +2004-12-12 Tor Lillqvist + + * glib/glib.symbols + * glib/gconvert.[ch]: Implement Windows DLL ABI stability also for + g_filename_{to,from}_uri(). + 2004-12-11 Tor Lillqvist * glib/gstdio.c (g_rename, g_unlink, g_remove): Add doc comments diff --git a/glib/gconvert.c b/glib/gconvert.c index d22a1c1..5509bd6 100644 --- a/glib/gconvert.c +++ b/glib/gconvert.c @@ -1019,8 +1019,11 @@ filename_charset_cache_free (gpointer data) * subsequent character sets are used when trying to generate a displayable * representation of a filename, see g_filename_display_name(). * - * The character sets are determined by consulting the environment variables - * G_FILENAME_ENCODING and G_BROKEN_FILENAMES. + * On Unix, the character sets are determined by consulting the + * environment variables G_FILENAME_ENCODING and + * G_BROKEN_FILENAMES. On Windows, the character set + * used in the GLib API is always UTF-8 and said environment variables + * have no effect. * * G_FILENAME_ENCODING may be set to a comma-separated list * of character set names. The special token "@locale" is taken to mean the @@ -1176,7 +1179,7 @@ _g_convert_thread_init (void) * @error: location to store the error occuring, or %NULL to ignore * errors. Any of the errors in #GConvertError may occur. * - * Converts a string which is in the encoding used for filenames + * Converts a string which is in the encoding used by GLib for filenames * into a UTF-8 string. * * Return value: The converted string, or %NULL on an error. @@ -1694,6 +1697,29 @@ g_filename_from_uri (const gchar *uri, return result; } +#ifdef G_OS_WIN32 + +#undef g_filename_from_uri + +gchar * +g_filename_from_uri (const gchar *uri, + gchar **hostname, + GError **error) +{ + gchar *utf8_filename; + gchar *retval = NULL; + + utf8_filename = g_filename_from_uri_utf8 (uri, hostname, error); + if (utf8_filename) + { + retval = g_locale_from_utf8 (utf8_filename, -1, NULL, NULL, error); + g_free (utf8_filename); + } + return retval; +} + +#endif + /** * g_filename_to_uri: * @filename: an absolute filename specified in the encoding @@ -1744,6 +1770,31 @@ g_filename_to_uri (const gchar *filename, return escaped_uri; } +#ifdef G_OS_WIN32 + +#undef g_filename_to_uri + +gchar * +g_filename_to_uri (const gchar *filename, + const gchar *hostname, + GError **error) +{ + gchar *utf8_filename; + gchar *retval = NULL; + + utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, error); + + if (utf8_filename) + { + retval = g_filename_to_uri_utf8 (utf8_filename, hostname, error); + g_free (utf8_filename); + } + + return retval; +} + +#endif + /** * g_uri_list_extract_uris: * @uri_list: an URI list diff --git a/glib/gconvert.h b/glib/gconvert.h index 7883879..4629a1b1 100644 --- a/glib/gconvert.h +++ b/glib/gconvert.h @@ -101,6 +101,8 @@ gchar* g_locale_from_utf8 (const gchar *utf8string, #ifdef G_OS_WIN32 #define g_filename_to_utf8 g_filename_to_utf8_utf8 #define g_filename_from_utf8 g_filename_from_utf8_utf8 +#define g_filename_from_uri g_filename_from_uri_utf8 +#define g_filename_to_uri g_filename_to_uri_utf8 #endif gchar* g_filename_to_utf8 (const gchar *opsysstring, diff --git a/glib/glib.symbols b/glib/glib.symbols index 4631b77..cbb2af2 100644 --- a/glib/glib.symbols +++ b/glib/glib.symbols @@ -169,12 +169,18 @@ g_file_get_contents PRIVATE g_file_get_contents_utf8 #endif g_filename_display_name G_GNUC_MALLOC -g_filename_from_uri G_GNUC_MALLOC +g_filename_from_uri PRIVATE G_GNUC_MALLOC +#ifdef G_OS_WIN32 +g_filename_from_uri_utf8 G_GNUC_MALLOC +#endif g_filename_from_utf8 PRIVATE G_GNUC_MALLOC #ifdef G_OS_WIN32 g_filename_from_utf8_utf8 #endif -g_filename_to_uri G_GNUC_MALLOC +g_filename_to_uri PRIVATE G_GNUC_MALLOC +#ifdef G_OS_WIN32 +g_filename_to_uri_utf8 G_GNUC_MALLOC +#endif g_filename_to_utf8 PRIVATE G_GNUC_MALLOC #ifdef G_OS_WIN32 g_filename_to_utf8_utf8 -- 2.7.4