From 03ef7ba5abab928c17142f553f86b97d28ecf946 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Thu, 15 Nov 2012 18:18:54 -0500 Subject: [PATCH] win32: re-fix the _utf8 compat function situation The previous fix didn't work, because every place within glib that used any of the functions also needed to be including win32compat.h. So, move the prototypes back to their original headers (but at least all in one place at the bottom). https://bugzilla.gnome.org/show_bug.cgi?id=688109 --- docs/reference/glib/Makefile.am | 3 +- glib/Makefile.am | 1 - glib/gconvert.c | 1 - glib/gconvert.h | 24 ++++++ glib/gdir.c | 1 - glib/gdir.h | 10 +++ glib/genviron.h | 12 +++ glib/gfileutils.h | 20 +++++ glib/giochannel.h | 8 ++ glib/glib.h | 4 - glib/gspawn.h | 46 +++++++++++ glib/gutils.h | 14 ++++ glib/gwin32.h | 14 ++++ glib/gwin32compat.h | 178 ---------------------------------------- 14 files changed, 149 insertions(+), 187 deletions(-) delete mode 100644 glib/gwin32compat.h diff --git a/docs/reference/glib/Makefile.am b/docs/reference/glib/Makefile.am index b27f8c9..54918c8 100644 --- a/docs/reference/glib/Makefile.am +++ b/docs/reference/glib/Makefile.am @@ -51,8 +51,7 @@ IGNORE_HFILES = \ gvariant-serialiser.h \ gvariant-core.h \ gvarianttypeinfo.h \ - gwakeup.h \ - gwin32compat.h + gwakeup.h # Images to copy into HTML directory HTML_IMAGES = \ diff --git a/glib/Makefile.am b/glib/Makefile.am index 042eac9..3168b1a 100644 --- a/glib/Makefile.am +++ b/glib/Makefile.am @@ -325,7 +325,6 @@ glibsubinclude_HEADERS = \ gversion.h \ gversionmacros.h \ gwin32.h \ - gwin32compat.h \ gprintf.h # This is read by gobject-introspection/misc/ and gtk-doc diff --git a/glib/gconvert.c b/glib/gconvert.c index c73a80c..f189c24 100644 --- a/glib/gconvert.c +++ b/glib/gconvert.c @@ -57,7 +57,6 @@ #endif #include "glibintl.h" -#include "gwin32compat.h" #if defined(USE_LIBICONV_GNU) && !defined (_LIBICONV_H) #error GNU libiconv in use but included iconv.h not from libiconv diff --git a/glib/gconvert.h b/glib/gconvert.h index d8da997..e85556e 100644 --- a/glib/gconvert.h +++ b/glib/gconvert.h @@ -150,6 +150,30 @@ gchar *g_filename_display_basename (const gchar *filename) G_GNUC_MALLOC; gchar **g_uri_list_extract_uris (const gchar *uri_list) G_GNUC_MALLOC; +#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 + +gchar* g_filename_to_utf8_utf8 (const gchar *opsysstring, + gssize len, + gsize *bytes_read, + gsize *bytes_written, + GError **error) G_GNUC_MALLOC; +gchar* g_filename_from_utf8_utf8 (const gchar *utf8string, + gssize len, + gsize *bytes_read, + gsize *bytes_written, + GError **error) G_GNUC_MALLOC; +gchar *g_filename_from_uri_utf8 (const gchar *uri, + gchar **hostname, + GError **error) G_GNUC_MALLOC; +gchar *g_filename_to_uri_utf8 (const gchar *filename, + const gchar *hostname, + GError **error) G_GNUC_MALLOC; +#endif + G_END_DECLS #endif /* __G_CONVERT_H__ */ diff --git a/glib/gdir.c b/glib/gdir.c index e04e63b..0c304f6 100644 --- a/glib/gdir.c +++ b/glib/gdir.c @@ -41,7 +41,6 @@ #include "gstrfuncs.h" #include "gtestutils.h" #include "glibintl.h" -#include "gwin32compat.h" #if defined (_MSC_VER) && !defined (HAVE_DIRENT_H) #include "../build/win32/dirent/dirent.h" diff --git a/glib/gdir.h b/glib/gdir.h index 8cdcd1d..2e734ac 100644 --- a/glib/gdir.h +++ b/glib/gdir.h @@ -41,6 +41,16 @@ const gchar * g_dir_read_name (GDir *dir); void g_dir_rewind (GDir *dir); void g_dir_close (GDir *dir); +#ifdef G_OS_WIN32 +#define g_dir_open g_dir_open_utf8 +#define g_dir_read_name g_dir_read_name_utf8 + +GDir *g_dir_open_utf8 (const gchar *path, + guint flags, + GError **error); +const gchar *g_dir_read_name_utf8 (GDir *dir); +#endif /* G_OS_WIN32 */ + G_END_DECLS #endif /* __G_DIR_H__ */ diff --git a/glib/genviron.h b/glib/genviron.h index dc6737b..2f23b58 100644 --- a/glib/genviron.h +++ b/glib/genviron.h @@ -52,6 +52,18 @@ gchar ** g_environ_setenv (gchar **envp, gchar ** g_environ_unsetenv (gchar **envp, const gchar *variable) G_GNUC_WARN_UNUSED_RESULT; +#ifdef G_OS_WIN32 +#define g_getenv g_getenv_utf8 +#define g_setenv g_setenv_utf8 +#define g_unsetenv g_unsetenv_utf8 + +const gchar *g_getenv_utf8 (const gchar *variable); +gboolean g_setenv_utf8 (const gchar *variable, + const gchar *value, + gboolean overwrite); +void g_unsetenv_utf8 (const gchar *variable); +#endif + G_END_DECLS #endif /* __G_ENVIRON_H__ */ diff --git a/glib/gfileutils.h b/glib/gfileutils.h index 2a86a92..17b2acb 100644 --- a/glib/gfileutils.h +++ b/glib/gfileutils.h @@ -159,6 +159,26 @@ gchar *g_get_current_dir (void); gchar *g_path_get_basename (const gchar *file_name) G_GNUC_MALLOC; gchar *g_path_get_dirname (const gchar *file_name) G_GNUC_MALLOC; +#ifdef G_OS_WIN32 +#define g_file_test g_file_test_utf8 +#define g_file_get_contents g_file_get_contents_utf8 +#define g_mkstemp g_mkstemp_utf8 +#define g_file_open_tmp g_file_open_tmp_utf8 +#define g_get_current_dir g_get_current_dir_utf8 + +gboolean g_file_test_utf8 (const gchar *filename, + GFileTest test); +gboolean g_file_get_contents_utf8 (const gchar *filename, + gchar **contents, + gsize *length, + GError **error); +gint g_mkstemp_utf8 (gchar *tmpl); +gint g_file_open_tmp_utf8 (const gchar *tmpl, + gchar **name_used, + GError **error); +gchar *g_get_current_dir_utf8 (void); +#endif /* G_OS_WIN32 */ + G_END_DECLS #endif /* __G_FILEUTILS_H__ */ diff --git a/glib/giochannel.h b/glib/giochannel.h index b8f11ff..013ee19 100644 --- a/glib/giochannel.h +++ b/glib/giochannel.h @@ -371,6 +371,14 @@ void g_io_channel_win32_set_debug (GIOChannel *channel, #endif +#ifdef G_OS_WIN32 +#define g_io_channel_new_file g_io_channel_new_file_utf8 + +GIOChannel *g_io_channel_new_file_utf8 (const gchar *filename, + const gchar *mode, + GError **error); +#endif + G_END_DECLS #endif /* __G_IOCHANNEL_H__ */ diff --git a/glib/glib.h b/glib/glib.h index 71fe358..77abf23 100644 --- a/glib/glib.h +++ b/glib/glib.h @@ -107,10 +107,6 @@ #include #include -#ifdef G_OS_WIN32 -#include -#endif - #undef __GLIB_H_INSIDE__ #endif /* __G_LIB_H__ */ diff --git a/glib/gspawn.h b/glib/gspawn.h index 1cf201e..3145641 100644 --- a/glib/gspawn.h +++ b/glib/gspawn.h @@ -241,6 +241,52 @@ gboolean g_spawn_check_exit_status (gint exit_status, void g_spawn_close_pid (GPid pid); +#ifdef G_OS_WIN32 +#define g_spawn_async g_spawn_async_utf8 +#define g_spawn_async_with_pipes g_spawn_async_with_pipes_utf8 +#define g_spawn_sync g_spawn_sync_utf8 +#define g_spawn_command_line_sync g_spawn_command_line_sync_utf8 +#define g_spawn_command_line_async g_spawn_command_line_async_utf8 + +gboolean g_spawn_async_utf8 (const gchar *working_directory, + gchar **argv, + gchar **envp, + GSpawnFlags flags, + GSpawnChildSetupFunc child_setup, + gpointer user_data, + GPid *child_pid, + GError **error); +gboolean g_spawn_async_with_pipes_utf8 (const gchar *working_directory, + gchar **argv, + gchar **envp, + GSpawnFlags flags, + GSpawnChildSetupFunc child_setup, + gpointer user_data, + GPid *child_pid, + gint *standard_input, + gint *standard_output, + gint *standard_error, + GError **error); +gboolean g_spawn_sync_utf8 (const gchar *working_directory, + gchar **argv, + gchar **envp, + GSpawnFlags flags, + GSpawnChildSetupFunc child_setup, + gpointer user_data, + gchar **standard_output, + gchar **standard_error, + gint *exit_status, + GError **error); + +gboolean g_spawn_command_line_sync_utf8 (const gchar *command_line, + gchar **standard_output, + gchar **standard_error, + gint *exit_status, + GError **error); +gboolean g_spawn_command_line_async_utf8 (const gchar *command_line, + GError **error); +#endif + G_END_DECLS #endif /* __G_SPAWN_H__ */ diff --git a/glib/gutils.h b/glib/gutils.h index da92654..c256800 100644 --- a/glib/gutils.h +++ b/glib/gutils.h @@ -358,4 +358,18 @@ DllMain (HINSTANCE hinstDLL, \ #endif /* G_PLATFORM_WIN32 */ +#ifdef G_OS_WIN32 +#define g_get_user_name g_get_user_name_utf8 +#define g_get_real_name g_get_real_name_utf8 +#define g_get_home_dir g_get_home_dir_utf8 +#define g_get_tmp_dir g_get_tmp_dir_utf8 +#define g_find_program_in_path g_find_program_in_path_utf8 + +const gchar *g_get_user_name_utf8 (void); +const gchar *g_get_real_name_utf8 (void); +const gchar *g_get_home_dir_utf8 (void); +const gchar *g_get_tmp_dir_utf8 (void); +gchar *g_find_program_in_path_utf8 (const gchar *program); +#endif + #endif /* __G_UTILS_H__ */ diff --git a/glib/gwin32.h b/glib/gwin32.h index 7771b04..03a1f11 100644 --- a/glib/gwin32.h +++ b/glib/gwin32.h @@ -108,4 +108,18 @@ G_END_DECLS #endif /* G_PLATFORM_WIN32 */ +#ifdef G_OS_WIN32 +#ifdef _WIN64 +#define g_win32_get_package_installation_directory g_win32_get_package_installation_directory_utf8 +#define g_win32_get_package_installation_subdirectory g_win32_get_package_installation_subdirectory_utf8 +#endif + +gchar *g_win32_get_package_installation_directory_utf8 (const gchar *package, + const gchar *dll_name); +gchar *g_win32_get_package_installation_subdirectory_utf8 (const gchar *package, + const gchar *dll_name, + const gchar *subdir); + +#endif /* G_OS_WIN32 */ + #endif /* __G_WIN32_H__ */ diff --git a/glib/gwin32compat.h b/glib/gwin32compat.h deleted file mode 100644 index 83edf39..0000000 --- a/glib/gwin32compat.h +++ /dev/null @@ -1,178 +0,0 @@ -/* GLIB - Library of useful routines for C programming - * Copyright (C) 2012 Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - -#ifndef __G_WIN32COMPAT_H__ -#define __G_WIN32COMPAT_H__ - -#include -#include -#include -#include - -G_BEGIN_DECLS - -#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 - -gchar* g_filename_to_utf8_utf8 (const gchar *opsysstring, - gssize len, - gsize *bytes_read, - gsize *bytes_written, - GError **error) G_GNUC_MALLOC; -gchar* g_filename_from_utf8_utf8 (const gchar *utf8string, - gssize len, - gsize *bytes_read, - gsize *bytes_written, - GError **error) G_GNUC_MALLOC; -gchar *g_filename_from_uri_utf8 (const gchar *uri, - gchar **hostname, - GError **error) G_GNUC_MALLOC; -gchar *g_filename_to_uri_utf8 (const gchar *filename, - const gchar *hostname, - GError **error) G_GNUC_MALLOC; - - -#define g_dir_open g_dir_open_utf8 -#define g_dir_read_name g_dir_read_name_utf8 - -GDir *g_dir_open_utf8 (const gchar *path, - guint flags, - GError **error); -const gchar *g_dir_read_name_utf8 (GDir *dir); - - -#define g_getenv g_getenv_utf8 -#define g_setenv g_setenv_utf8 -#define g_unsetenv g_unsetenv_utf8 - -const gchar *g_getenv_utf8 (const gchar *variable); -gboolean g_setenv_utf8 (const gchar *variable, - const gchar *value, - gboolean overwrite); -void g_unsetenv_utf8 (const gchar *variable); - - -#define g_file_test g_file_test_utf8 -#define g_file_get_contents g_file_get_contents_utf8 -#define g_mkstemp g_mkstemp_utf8 -#define g_file_open_tmp g_file_open_tmp_utf8 -#define g_get_current_dir g_get_current_dir_utf8 - -gboolean g_file_test_utf8 (const gchar *filename, - GFileTest test); -gboolean g_file_get_contents_utf8 (const gchar *filename, - gchar **contents, - gsize *length, - GError **error); -gint g_mkstemp_utf8 (gchar *tmpl); -gint g_file_open_tmp_utf8 (const gchar *tmpl, - gchar **name_used, - GError **error); -gchar *g_get_current_dir_utf8 (void); - - -#define g_io_channel_new_file g_io_channel_new_file_utf8 - -GIOChannel *g_io_channel_new_file_utf8 (const gchar *filename, - const gchar *mode, - GError **error); - - -#define g_spawn_async g_spawn_async_utf8 -#define g_spawn_async_with_pipes g_spawn_async_with_pipes_utf8 -#define g_spawn_sync g_spawn_sync_utf8 -#define g_spawn_command_line_sync g_spawn_command_line_sync_utf8 -#define g_spawn_command_line_async g_spawn_command_line_async_utf8 - -gboolean g_spawn_async_utf8 (const gchar *working_directory, - gchar **argv, - gchar **envp, - GSpawnFlags flags, - GSpawnChildSetupFunc child_setup, - gpointer user_data, - GPid *child_pid, - GError **error); -gboolean g_spawn_async_with_pipes_utf8 (const gchar *working_directory, - gchar **argv, - gchar **envp, - GSpawnFlags flags, - GSpawnChildSetupFunc child_setup, - gpointer user_data, - GPid *child_pid, - gint *standard_input, - gint *standard_output, - gint *standard_error, - GError **error); -gboolean g_spawn_sync_utf8 (const gchar *working_directory, - gchar **argv, - gchar **envp, - GSpawnFlags flags, - GSpawnChildSetupFunc child_setup, - gpointer user_data, - gchar **standard_output, - gchar **standard_error, - gint *exit_status, - GError **error); - -gboolean g_spawn_command_line_sync_utf8 (const gchar *command_line, - gchar **standard_output, - gchar **standard_error, - gint *exit_status, - GError **error); -gboolean g_spawn_command_line_async_utf8 (const gchar *command_line, - GError **error); - - -#define g_get_user_name g_get_user_name_utf8 -#define g_get_real_name g_get_real_name_utf8 -#define g_get_home_dir g_get_home_dir_utf8 -#define g_get_tmp_dir g_get_tmp_dir_utf8 -#define g_find_program_in_path g_find_program_in_path_utf8 - -const gchar *g_get_user_name_utf8 (void); -const gchar *g_get_real_name_utf8 (void); -const gchar *g_get_home_dir_utf8 (void); -const gchar *g_get_tmp_dir_utf8 (void); -gchar *g_find_program_in_path_utf8 (const gchar *program); - - -#ifdef _WIN64 -#define g_win32_get_package_installation_directory g_win32_get_package_installation_directory_utf8 -#define g_win32_get_package_installation_subdirectory g_win32_get_package_installation_subdirectory_utf8 -#endif - -gchar *g_win32_get_package_installation_directory_utf8 (const gchar *package, - const gchar *dll_name); -gchar *g_win32_get_package_installation_subdirectory_utf8 (const gchar *package, - const gchar *dll_name, - const gchar *subdir); - -#endif - -G_END_DECLS - -#endif /* __G_WIN32COMPAT_H__ */ -- 2.7.4