Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 98c3fef0ccffd7aeb17678cdbebe3588ba5a7c1d
Ticket: 217899ffffffffffffffffffffffffffffffffff
Locale support is broken again
User & Date: nobody on 2000-10-26 00:45:36
Changes

  1. assignee changed to: "nobody"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    OriginalBugID: 2521 Bug
    Version: 8.2b2
    SubmitDate: '1999-08-11'
    LastModified: '2000-04-09'
    Severity: SER
    Status: Closed
    Submitter: techsupp
    ChangedBy: hobbs
    RelatedBugIDs: 2522 3345 4236
    OS: Linux
    OSVersion: Debian 2.1
    Machine: Other
    FixedDate: '2000-10-25'
    ClosedDate: '2000-04-09'
    
    
    Name: Victor Wagner
    
    
    
    Comments:
    
    It would be nice to be able to change locale inside Tcl script (for
    
        example
    
        via traces on LC_ environment variables). It would save much trouble
    
        with date
    
        formatting and parsing.
    
    
    
    ReproducibleScript:
    
    Any wish script with locale ru_RU.KOI8-R
    
    
    
    ObservedBehavior:
    
    Tk scripts don't accept Cyrillic keyboard input. 
    
        Investigation shows that when current encoding is determined from LANG
    
        environment variable and this variable has
    
        <language>_<country>.<encoding> format, goto resetPath statement is
    
        performed and setlocale call
    
        is skipped. Moreover, even if this code is executed, Tcl sets locale
    
        temporarily
    
        to user settings and then resets it (all categories) back, when
    
        resetting of
    
        LC_NUMERIC only is enough for correct parsing of numbers (and this is
    
        performed
    
        two lines down the code).
    
        
    
        clock format prints date in English when explicitely told to use
    
        locale-specific
    
        format  (-format "%c"). When Tcl is patched to support locale, clock
    
        format
    
        incorrectly assumes that strftime returns string in ISO8859-1 encoding
    
        and
    
        doesn't attempt to convert it from current system default encoding.
    
    
    
    DesiredBehavior:
    
    All locale categories, except LC_NUMERIC should be set to user locale.
    
        setlocale call should be performed to initilize X input method
    
        correctly,
    
        regardless of locale value.
    
        
    
        date/time values should be formatted according to user preferences. If
    
        app author wished, he always can set format to recognizable by clock
    
        scan explicitely. May be even default format should be one of those,
    
        instead of "%c",
    
        but there should be way to obtain locale-specific date/time format via
    
        clock format.
    
    
    
    Patch:
    
    diff -c -r tcl8.2b2/generic/tclClock.c tcl8.2b2-patched/generic/tclClock.c
    
    *** tcl8.2b2/generic/tclClock.cFri Apr 16 04:46:43 1999
    
    --- tcl8.2b2-patched/generic/tclClock.cWed Aug 11 17:23:22 1999
    
    ***************
    
    *** 228,234 ****
    
          char *format;/* Format string */
    
      {
    
          struct tm *timeDataPtr;
    
    !     Tcl_DString buffer;
    
          int bufSize;
    
          char *p;
    
          Tcl_Obj *resultPtr;
    
    --- 228,234 ----
    
          char *format;/* Format string */
    
      {
    
          struct tm *timeDataPtr;
    
    !     Tcl_DString buffer,unicode_buffer;
    
          int bufSize;
    
          char *p;
    
          Tcl_Obj *resultPtr;
    
    ***************
    
    *** 315,322 ****
    
      "\"", (char *) NULL);
    
      return TCL_ERROR;
    
          }
    
    ! 
    
    !     Tcl_SetStringObj(resultPtr, buffer.string, -1);
    
          Tcl_DStringFree(&buffer);
    
          return TCL_OK;
    
      }
    
    --- 315,324 ----
    
      "\"", (char *) NULL);
    
      return TCL_ERROR;
    
          }
    
    !     Tcl_DStringInit(&unicode_buffer);
    
    !     Tcl_ExternalToUtfDString(NULL,buffer.string,-1,&unicode_buffer);
    
    !     Tcl_SetStringObj(resultPtr, unicode_buffer.string, -1 );
    
    !     Tcl_DStringFree(&unicode_buffer);
    
          Tcl_DStringFree(&buffer);
    
          return TCL_OK;
    
      }
    
    diff -c -r tcl8.2b2/unix/tclUnixInit.c tcl8.2b2-patched/unix/tclUnixInit.c
    
    *** tcl8.2b2/unix/tclUnixInit.cFri Jul 23 01:50:56 1999
    
    --- tcl8.2b2-patched/unix/tclUnixInit.cWed Aug 11 17:00:57 1999
    
    ***************
    
    *** 432,437 ****
    
    --- 432,438 ----
    
      
    
          Tcl_SetSystemEncoding(NULL, encoding);
    
      
    
    +     resetPath:
    
          /*
    
           * Initialize the C library's locale subsystem.  This is required
    
           * for input methods to work properly on X11. Note that we need to
    
    ***************
    
    *** 443,449 ****
    
          Tcl_DStringInit(&ds);
    
          Tcl_DStringAppend(&ds, setlocale(LC_ALL, NULL), -1);
    
          setlocale(LC_ALL, "");
    
    -     setlocale(LC_ALL, Tcl_DStringValue(&ds));
    
          Tcl_DStringFree(&ds);
    
      [ED NOTE: SHOULD REMOVE ALL DString STUFF, IF ANY]
    
          /*
    
    --- 444,449 ----
    
    ***************
    
    *** 478,484 ****
    
           * encoding.
    
           */
    
      
    
    -     resetPath:
    
          pathPtr = TclGetLibraryPath();
    
          if (pathPtr != NULL) {
    
      int objc;
    
    --- 478,483 ----
    
    
    
    PatchFiles:
    
    generic/tclClock.c
    
        unix/tkUnixInit.c
    
    
    
    
    
    With this patch, the locale would be set to the user defined
    environment, which may cause problems in the Tcl C library.
    The intent of the above setlocale NULL->""->original, is that
    we expect to get the current runtime setting (should be C for
    the C runtime library), set it to "" to force loading of the
    locale tables for X, and then back to the runtime.  The idea
    is that users could change the runtime in their own extension.
    
    The solution may be to provide a 'tcl locale type ?settotype?'
    Tcl level command. 
    -- 10/21/1999 hobbs
    
  4. foundin changed to: "obsolete: 8.2b2"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "nobody"
  9. subsystem changed to: "57. zlib"
  10. title changed to: "Locale support is broken again"
  11. type changed to: "RFE"