[ scim-Bugs-1965543 ] Strange call to setlocale(LC_MESSAGES, "")

1 message Options
Embed this post
Permalink
SourceForge.net

[ scim-Bugs-1965543 ] Strange call to setlocale(LC_MESSAGES, "")

Reply Threaded More More options
Print post
Permalink
Bugs item #1965543, was opened at 2008-05-17 02:29
Message generated for change (Comment added) made by ryo-dairiki
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=650539&aid=1965543&group_id=108454

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Core: libscim
Group: CVS
Status: Open
>Resolution: Wont Fix
Priority: 5
Private: No
Submitted By: Benjamin Monate (ben_99_9)
Assigned to: James Su (suzhe)
Summary: Strange call to setlocale(LC_MESSAGES,"")

Initial Comment:
Dear dev team,
In file scim_private.cpp, the constructor fo TextdomainInitializer contains :
==========
char *locale = setlocale (LC_MESSAGES, 0);
        if (!locale || strcmp (locale, "C") == 0 || strcmp (locale, "POSIX") == 0)
            setlocale (LC_MESSAGES, "");
==========
The last call to setlocale changes the current LC_MESSAGES value.
The original locale value is never reset.

Here is an example of why this has undesired side effects for Gtk applications using GTK_IM_MODULE=scim

==main.c=
#include <gtk/gtk.h>
#include <locale.h>
int main (int argc, char *argv[])
{
    GtkWidget *window;
    GtkWidget *label;
    gtk_disable_setlocale ();
    gtk_init (&argc, &argv);
    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    label = gtk_text_view_new();
    printf ("BEFORE PACKING:%s\n",setlocale(LC_ALL,NULL));
    gtk_container_add (GTK_CONTAINER (window), label);
    gtk_widget_show_all (window);
    printf ("AFTER PACKING:%s\n",setlocale(LC_ALL,NULL));
    gtk_main ();
    return 0;}
=======

Compile with :
 gcc -g `pkg-config --libs --cflags gtk+-2.0` main.c

Running:
 GTK_IM_MODULE=scim ./a.out
outputs
===
BEFORE PACKING:C
AFTER PACKING:LC_CTYPE=C;LC_NUMERIC=C;LC_TIME=C;LC_COLLATE=C;LC_MONETARY=C;LC_MESSAGES=fr_FR.UTF-8;LC_PAPER=C;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=C;LC_IDENTIFICATION=C
===
whereas running  
 GTK_IM_MODULE= ./a.out
outputs
===
BEFORE PACKING:C
AFTER PACKING:C
====

Note the value for LC_MESSAGES (it is reset to the value that was defined in the calling shell)

The later is the valid behavior. Otherwise Gtk stock elements will be translated despite the call to     gtk_disable_setlocale.

Thanks for your attention,


----------------------------------------------------------------------

>Comment By: ryo-dairiki (ryo-dairiki)
Date: 2009-02-22 20:42

Message:
I think this problem cannot be fixed due to the basic architecture of
SCIM.
This problem is inevitable as long as processes load SCIM library.
I'll left this problem as "Wont Fix" for now.
Please revert it if somebody has a good idea.

----------------------------------------------------------------------

You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=650539&aid=1965543&group_id=108454

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Scim-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/scim-user