After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 335159 - bonobo-activation doesn't bind textdomain codeset
bonobo-activation doesn't bind textdomain codeset
Status: RESOLVED FIXED
Product: bonobo
Classification: Deprecated
Component: libbonobo
CVS HEAD
Other Linux
: Normal normal
: ---
Assigned To: Michael Meeks
bonobo qa
Depends on:
Blocks:
 
 
Reported: 2006-03-19 21:31 UTC by Christian Persch
Modified: 2006-05-03 19:46 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
proposed fix (1.18 KB, patch)
2006-03-19 22:04 UTC, Christian Persch
none Details | Review
alternative patch (1.77 KB, patch)
2006-03-19 22:16 UTC, Christian Persch
committed Details | Review

Description Christian Persch 2006-03-19 21:31:16 UTC
Bonobo-activation doesn't use bind_textdomain_codeset (DOMAIN, "UTF-8") in its gettext initialisation. This leads to garbage output when using libgnome's goption argument parsing and specifying --help-bonobo-activation:

LANGUAGE=fr LANG=ja_JP.EUC-JP ./test-gnome --help-bonobo-activation

Result:

Bonobo Activation
  --oaf-ior-fd=FD                  Descripteur de fichier pour imprimer IOR sur
[Invalid UTF-8]   --oaf-activate-iid=IID           IID \x8f\xab\xa2 activer
[Invalid UTF-8]   --oaf-private                    Emp\x8f\xab\xb4cher l'enregistrement du serveur avec OAF
Comment 1 Christian Persch 2006-03-19 22:04:55 UTC
Created attachment 61575 [details] [review]
proposed fix

I also fixed a bug I spotted where bindtextdomain was called for the wrong domain name.

Ok to commit?
Comment 2 Christian Persch 2006-03-19 22:16:06 UTC
Created attachment 61576 [details] [review]
alternative patch

bindtextdomain is going to be called more than once otherwise, and it's not exactly a no-op. So this patch makes sure to only init once.

I'm not totally sure we need to not bind the codeset in some cases, but I remember sth about a problem with popt otherwise? Best to just bind it when using goption.
Comment 3 Nickolay V. Shmyrev 2006-03-29 20:17:06 UTC
There are dozen calls of bindtextdomain over the code, isn't it better to drop them completely and use normal initialization of gettext bonobo_activation_init instead?
Comment 4 Christian Persch 2006-03-29 20:25:20 UTC
nsh: The problem is that if you use popt, you must NOT bind the textdomain codeset before parsing options, but only after; while with goption you must do so. So we need to ensure it's done correctly on every entry path...
Comment 5 Kjartan Maraas 2006-04-04 10:53:49 UTC
I'd just trust Christian on this one :-) I commited a similar fix from him in libgnomeui.
Comment 6 Christian Persch 2006-05-03 12:55:06 UTC
Ping? Is is ok to commit this?
Comment 7 Kjartan Maraas 2006-05-03 14:51:58 UTC
Comment on attachment 61576 [details] [review]
alternative patch

>? P
>? goption.diff
>? libbonobo-zip
>? p
>? doc/api/tmpl/libbonobo-unused.sgml
>? po/stamp-it
>Index: bonobo-activation/bonobo-activation-init.c
>===================================================================
>RCS file: /cvs/gnome/libbonobo/bonobo-activation/bonobo-activation-init.c,v
>retrieving revision 1.67
>diff -p -u -u -p -r1.67 bonobo-activation-init.c
>--- bonobo-activation/bonobo-activation-init.c	7 Feb 2006 12:24:04 -0000	1.67
>+++ bonobo-activation/bonobo-activation-init.c	19 Mar 2006 22:11:46 -0000
>@@ -366,11 +366,35 @@ static const GOptionEntry bonobo_activat
>         { NULL }
> };
> 
>+static void
>+init_gettext (gboolean bind_codeset)
>+{
>+	static gboolean initialized = FALSE;
>+#ifdef HAVE_BIND_TEXTDOMAIN_CODESET	
>+	static gboolean codeset_bound = FALSE;
>+#endif
>+
>+	if (!initialized)
>+	{
>+		bindtextdomain (GETTEXT_PACKAGE, BONOBO_ACTIVATION_LOCALEDIR);
>+		initialized = TRUE;
>+	}
>+#ifdef HAVE_BIND_TEXTDOMAIN_CODESET	
>+	if (bind_codeset && !codeset_bound)
>+	{
>+		bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
>+		codeset_bound = TRUE;
>+	}
>+#endif
>+}
>+
> GOptionGroup *
> bonobo_activation_get_goption_group (void)
> {
> 	GOptionGroup *group;
> 
>+	init_gettext (TRUE);
>+
> 	group = g_option_group_new ("bonobo-activation",
> 				    N_("Bonobo Activation"),
> 				    N_("Show Bonobo Activation options"),
>@@ -405,7 +429,7 @@ bonobo_activation_ior_fd_get (void)
> void
> bonobo_activation_preinit (gpointer app, gpointer mod_info)
> {
>-        bindtextdomain (GETTEXT_PACKAGE, BONOBO_ACTIVATION_LOCALEDIR);
>+	init_gettext (FALSE);
> }
> 
> void
>@@ -467,7 +491,7 @@ bonobo_activation_is_initialized (void)
> char *
> bonobo_activation_get_popt_table_name (void)
> {
>-        bindtextdomain (PACKAGE, BONOBO_ACTIVATION_LOCALEDIR);
>+	init_gettext (FALSE);
>         return _("Bonobo activation options");
> }
> 
Other than the two tabs vs spaces things in the last two modified lines it looks good. Please change that and commit.
Comment 8 Christian Persch 2006-05-03 19:46:08 UTC
Looks like predominant style in that file is to use tabs, so I fixed up the surrounding line (which used spaces) instead :)

2006-05-03  Christian Persch  <chpe@cvs.gnome.org>

        * bonobo-activation/bonobo-activation-init.c: (init_gettext),
        (bonobo_activation_get_goption_group), (bonobo_activation_preinit),
        (bonobo_activation_get_popt_table_name): Make sure to initialise
        the textdomain codeset if we're using goption. Bug #335159.