[glib] win32: Drop old codepage ABI from gutils.c



commit 8c42a663f8182f8281c083390aa761e8e9badc63
Author: Ryan Lortie <desrt desrt ca>
Date:   Mon Feb 4 14:04:05 2013 +0100

    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
    reasons).
    
    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.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=693204

 glib/gutils.c |   71 +++++++++-----------------------------------------------
 glib/gutils.h |   19 ---------------
 2 files changed, 12 insertions(+), 78 deletions(-)
---
diff --git a/glib/gutils.c b/glib/gutils.c
index 2e9c95f..f82ba56 100644
--- a/glib/gutils.c
+++ b/glib/gutils.c
@@ -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;
-#endif
-
 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
-
-gchar*
-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 (); }
 
 #endif
 
diff --git a/glib/gutils.h b/glib/gutils.h
index 8c09b7d..ed75fb8 100644
--- a/glib/gutils.h
+++ b/glib/gutils.h
@@ -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
-
-GLIB_AVAILABLE_IN_ALL
-const gchar *g_get_user_name_utf8        (void);
-GLIB_AVAILABLE_IN_ALL
-const gchar *g_get_real_name_utf8        (void);
-GLIB_AVAILABLE_IN_ALL
-const gchar *g_get_home_dir_utf8         (void);
-GLIB_AVAILABLE_IN_ALL
-const gchar *g_get_tmp_dir_utf8          (void);
-GLIB_AVAILABLE_IN_ALL
-gchar       *g_find_program_in_path_utf8 (const gchar *program);
-#endif
-
 G_END_DECLS
 
 #endif /* __G_UTILS_H__ */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]