Skip to content
Tcl Source Code View Ticket
Login

View Ticket

Localization bug

Closed / Fixed217900ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 00:45:37
OriginalBugID: 2522 Bug
Version: 8.2b2
SubmitDate: '1999-08-11'
LastModified: '1999-10-21'
Severity: SER
Status: Closed
Submitter: techsupp
ChangedBy: hobbs
RelatedBugIDs: 2521
OS: Linux-Red Hat
Machine: Other
FixedDate: '2000-10-25'
ClosedDate: '1999-10-21'


Name:

Serg Oskin



Comments:

Sorry for my english. :)



ReproducibleScript:

I modify file unix/tclUnixInit.c for test:

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

    --- unix/tclUnixInit.c.orig  Wed Aug 11 16:55:03 1999

    +++ unix/tclUnixInit.c       Wed Aug 11 17:13:11 1999

    @@ -389,6 +391,7 @@

            langEnv = NULL;

         }

    

    +printf( "LC_ALL = %s\n", (langEnv?langEnv:"null"));

         encoding = NULL;

         if (langEnv != NULL) {

            for (i = 0; localeTable[i].lang != NULL; i++) {

    @@ -402,6 +405,7 @@

             * encoding subfield, we can try to guess from that.

             */

    

    +printf( "Encoding1 = %s\n", encoding);

            if (encoding == NULL) {

                char *p;

                for (p = langEnv; *p != '\0'; p++) {

    @@ -416,7 +420,9 @@

                    Tcl_DStringAppend(&ds, p, -1);

    

                    encoding = Tcl_DStringValue(&ds);

    +printf( "Encoding2 = %s\n", Tcl_DStringValue(&ds));

                    Tcl_UtfToLower(Tcl_DStringValue(&ds));

    +printf( "Encoding3 = %s\n", Tcl_DStringValue(&ds));

                    if (Tcl_SetSystemEncoding(NULL, encoding) == TCL_OK) {

                        Tcl_DStringFree(&ds);

                        goto resetPath;

    @@ -430,6 +436,7 @@

            encoding = "iso8859-1";

         }

    

    +printf( "Encoding = %s\n", encoding);

         Tcl_SetSystemEncoding(NULL, encoding);

    

         /*

    @@ -441,9 +448,12 @@

          */

    

         Tcl_DStringInit(&ds);

    +printf( "Current locale 1 = %s\n", setlocale(LC_ALL, NULL));

         Tcl_DStringAppend(&ds, setlocale(LC_ALL, NULL), -1);

         setlocale(LC_ALL, "");

    +printf( "Current locale 2 = %s\n", setlocale(LC_ALL, NULL));

         setlocale(LC_ALL, Tcl_DStringValue(&ds));

    +printf( "Current locale 3 = %s\n", setlocale(LC_ALL, NULL));

         Tcl_DStringFree(&ds);

    

         /*

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



ObservedBehavior:

1.

    ~$ LC_ALL=ru_SU ./tclsh

    LC_ALL = ru_SU

    Encoding1 = iso8859-5

    Encoding = iso8859-5

    Current locale 1 = C

    Current locale 2 = ru_SU

    Current locale 3 = C

    % 

    Bug: retore the initial "C" locale

    Solution:

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

    --- unix/tclUnixInit.c.orig  Wed Aug 11 16:55:03 1999

    +++ unix/tclUnixInit.c1      Wed Aug 11 17:24:16 1999

    @@ -440,11 +440,7 @@

          * load any locale specific modules that are needed by X.

          */

    

    -    Tcl_DStringInit(&ds);

    -    Tcl_DStringAppend(&ds, setlocale(LC_ALL, NULL), -1);

         setlocale(LC_ALL, "");

    -    setlocale(LC_ALL, Tcl_DStringValue(&ds));

    -    Tcl_DStringFree(&ds);

    

         /*

          * In case the initial locale is not "C", ensure that the numeric

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

    

    2.

    ~$ LC_ALL=ru_SU.KOI8-R ./tclsh 

    LC_ALL = ru_SU.KOI8-R

    Encoding1 = (null)

    Encoding2 = KOI8-R

    Encoding3 = koi8-r

    % 

    Bug: Don't call setlocale()

    Solution: Move setlocale(LC_ALL,"") to before encoding define.

    

    3.

    Bug: Default charset for locale "ru_SU" - KOI8-R.

    Solution: patch. :)



Patch:

--- unix/tclUnixInit.c.orig  Wed Aug 11 16:55:03 1999

+++ unix/tclUnixInit.c       Wed Aug 11 17:42:41 1999

@@ -86,7 +86,7 @@



     {"ru",             "iso8859-5"},

     {"ru_RU",          "iso8859-5"},

-    {"ru_SU",          "iso8859-5"},

+    {"ru_SU",          "koi8-r"},



     {"zh",             "cp936"},



@@ -369,7 +369,6 @@

     int i;

     Tcl_Obj *pathPtr;

     char *langEnv;

-    Tcl_DString ds;



     /*

      * Determine the current encoding from the LC_* or LANG environment

@@ -389,6 +388,25 @@

        langEnv = NULL;

     }



+    /*

+     * Initialize the C library's locale subsystem.  This is required

+     * for input methods to work properly on X11. Note that we need to

+     * retore the initial "C" locale so that Tcl can parse numbers

+     * properly.  The side effect of setting the default locale should be to

+     * load any locale specific modules that are needed by X.

+     */



+    setlocale(LC_ALL, "");



+    /*

+     * In case the initial locale is not "C", ensure that the numeric

+     * processing is done in "C" locale regardless.  This is needed because

+     * Tcl relies on routines like strtod, but should not have locale

+     * dependent behavior.

+     */



+    setlocale(LC_NUMERIC, "C");



     encoding = NULL;

     if (langEnv != NULL) {

        for (i = 0; localeTable[i].lang != NULL; i++) {

@@ -432,29 +450,6 @@



     Tcl_SetSystemEncoding(NULL, encoding);



-    /*

-     * Initialize the C library's locale subsystem.  This is required

-     * for input methods to work properly on X11. Note that we need to

-     * retore the initial "C" locale so that Tcl can parse numbers

-     * properly.  The side effect of setting the default locale should be to

-     * load any locale specific modules that are needed by X.

-     */



-    Tcl_DStringInit(&ds);

-    Tcl_DStringAppend(&ds, setlocale(LC_ALL, NULL), -1);

-    setlocale(LC_ALL, "");

-    setlocale(LC_ALL, Tcl_DStringValue(&ds));

-    Tcl_DStringFree(&ds);



-    /*

-     * In case the initial locale is not "C", ensure that the numeric

-     * processing is done in "C" locale regardless.  This is needed because

-     * Tcl relies on routines like strtod, but should not have locale

-     * dependent behavior.

-     */



-    setlocale(LC_NUMERIC, "C");





     /*

      * Until the system encoding was actually set, the library path was



PatchFiles:

unix/tclUnixInit.c
welch Closed ticket [217900ffff]. [History diff]2000-10-26 08:09:11
dgp Ticket [217900ffff]: 3 changes [History diff]2001-04-14 02:04:56
Log in (anonymous is fine) to add a comment.