Commit 8c42a663 authored by Allison Karlitskaya's avatar Allison Karlitskaya

win32: Drop old codepage ABI from gutils.c

This is a source-compatible change and only breaks ABI with respect to
truly ancient binaries (and those binaries are already broken for other

Back in the day, functions like g_get_user_name() used to return strings
in the system codepage instead of utf8 (as they do today).

It was decided at some point to change these functions to return utf8,
breaking source compatibility but keeping ABI compatibility.  This was
done by exporting new symbols with names like g_get_user_name_utf8() and
using a #define of the old name over to the new name (so that newly
compiled code would link against the _utf8 version, but old binaries
would continue to use the non-utf8 variant).

Meanwhile, glib has undergone several ABI breaks on Windows since, so
those old binaries don't work anymore.

Start to clean up this mess by removing the #define renaming.  New
binaries calling g_get_user_name() will now link against
g_get_user_name() and it will return utf8.

We must keep the functions like g_get_user_name_utf8() for binary
compatibility with recently built programs (ie: ones built with the
renaming).  Nobody should have ever been calling these directly and of
course they can return utf8, so just add them as internal wrappers in the
.c file and declare them _GLIB_EXTERN there.

One day, if we feel like breaking Windows ABI again, we can finish the
cleanup by dropping the wrappers.  There is some talk of introducing
something like 'ABI compatible for two years' and this change would be
compatible with such a regime.
parent b029135e
......@@ -583,16 +583,6 @@ static gchar *g_real_name = NULL;
static gchar *g_home_dir = NULL;
static gchar *g_host_name = NULL;
#ifdef G_OS_WIN32
/* System codepage versions of the above, kept at file level so that they,
* too, are produced only once.
static gchar *g_tmp_dir_cp = NULL;
static gchar *g_user_name_cp = NULL;
static gchar *g_real_name_cp = NULL;
static gchar *g_home_dir_cp = NULL;
static gchar *g_user_data_dir = NULL;
static gchar **g_system_data_dirs = NULL;
static gchar *g_user_cache_dir = NULL;
......@@ -2360,59 +2350,22 @@ g_format_size_for_display (goffset size)
/* Binary compatibility versions. Not for newly compiled code. */
#undef g_find_program_in_path
g_find_program_in_path (const gchar *program)
gchar *utf8_program = g_locale_to_utf8 (program, -1, NULL, NULL, NULL);
gchar *utf8_retval = g_find_program_in_path_utf8 (utf8_program);
gchar *retval;
g_free (utf8_program);
if (utf8_retval == NULL)
return NULL;
retval = g_locale_from_utf8 (utf8_retval, -1, NULL, NULL, NULL);
g_free (utf8_retval);
return retval;
#undef g_get_user_name
_GLIB_EXTERN const gchar *g_get_user_name_utf8 (void);
_GLIB_EXTERN const gchar *g_get_real_name_utf8 (void);
_GLIB_EXTERN const gchar *g_get_home_dir_utf8 (void);
_GLIB_EXTERN const gchar *g_get_tmp_dir_utf8 (void);
_GLIB_EXTERN gchar *g_find_program_in_path_utf8 (const gchar *program);
const gchar *
g_get_user_name (void)
g_get_any_init_locked ();
return g_user_name_cp;
#undef g_get_real_name
const gchar *
g_get_real_name (void)
g_get_any_init_locked ();
return g_real_name_cp;
#undef g_get_home_dir
const gchar *
g_get_home_dir (void)
gchar *
g_find_program_in_path_utf8 (const gchar *program)
g_get_any_init_locked ();
return g_home_dir_cp;
return g_find_program_in_path (program);
#undef g_get_tmp_dir
const gchar *
g_get_tmp_dir (void)
g_get_any_init_locked ();
return g_tmp_dir_cp;
const gchar *g_get_user_name_utf8 (void) { return g_get_user_name (); }
const gchar *g_get_real_name_utf8 (void) { return g_get_real_name (); }
const gchar *g_get_home_dir_utf8 (void) { return g_get_home_dir (); }
const gchar *g_get_tmp_dir_utf8 (void) { return g_get_tmp_dir (); }
......@@ -380,25 +380,6 @@ 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 /* __G_UTILS_H__ */
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment