[gtk-doc/wip/lantw/scangobj-reset-locale-environment-variables-before-running] scangobj: reset locale environment variables before running



commit 2872274f3d2e0246462fb36d0f9f447ce0cc67aa
Author: Ting-Wei Lan <lantw src gnome org>
Date:   Fri Jul 5 16:08:10 2019 +0800

    scangobj: reset locale environment variables before running
    
    GNU gettext runtime doesn't always honor the locale controlled by libc.
    On non-glibc platforms, if per-thread locale isn't set, it may try to
    read environment variables by itself in order to figure out the locale.
    Therefore, even if setlocale is never called, gettext may still decide
    to translate text based on environment variables, causing the content of
    the documentation to be irreproducible because it depends on the
    environment on the build machine. Furthermore, since setlocale isn't
    called, LC_CTYPE defaults to C and non-ASCII characters coming from
    translations get converted to question marks. The result is that the
    documentation for GObject properties without gtk-doc comments becomes
    unreadable because blurbs of properties are translated in a broken way.
    
    To avoid gettext from doing unnecessary translation during building the
    documentation, we should set LC_MESSAGES environment variable to C
    before running the main program. LC_ALL is unset because it overrides
    LC_MESSAGES. Doing so should be harmless because the program already
    operates in C locale on systems using glibc.

 gtkdoc/scangobj.py | 3 +++
 1 file changed, 3 insertions(+)
---
diff --git a/gtkdoc/scangobj.py b/gtkdoc/scangobj.py
index 5c604fb..378fd1c 100644
--- a/gtkdoc/scangobj.py
+++ b/gtkdoc/scangobj.py
@@ -128,6 +128,9 @@ static void output_object_args (FILE *fp, GType object_type);
 int
 main (${main_func_params})
 {
+  g_unsetenv ("LC_ALL");
+  g_setenv ("LC_MESSAGES", "C", TRUE);
+
   ${type_init_func};
 
   get_object_types ();


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