Skip to content
Tcl Source Code History Of Ticket 75ecc0
Login

History Of Ticket 75ecc0

Artifacts Associated With Ticket 75ecc0

  1. Ticket change [2be723385e] (rid 163651) by sebres on 2018-05-30 18:53:55:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/x-fossil-wiki"
    4. comment initialized to:
      Set the system encoding via environment/locale failed somitimes dependent of the system constellation (distribution and/or some env-settings).
      
      Who saw already the test "unixInit-3.2" failed? :)
      
      This cumulates from two actual issues:
      
      1. setlocale (called from TclpInitPlatform) may overwrite environment "LANG" (to "C"), so the try searching of current encoding later in Tcl_GetEncodingNameFromEnvironment <b>will failback to "C"</b> (so the call of "setlocale" takes place <b>too early</b> in some cases, resp. get initial environment via getenv("LANG") <b>too late</b>);
      
      2. second thing which can happen, if 1st issue with "setlocale" gets repaired, would be the fact, that Tcl_GetEncodingSearchPath (called from TclpSetInitialEncodings/Tcl_SetSystemEncoding) may return "" <b>before still any interpreter instance created</b> (and it is so if TclpInitPlatform called).<br/>
      In this case setting of something other as already available system-encodings going to "C" (iso8859-1), because the load of encoding simply fails.<br/>
      The reason for this trouble is the wrong value returned by callback TclpInitLibraryPath.<br/> But later (after first interp going created) the init.tcl (as well as the counterpart script hard-coded in Tcl_Init) will indirectly call Tcl_SetEncodingSearchPath to the proper value (after tcl_library correct resolved and TclGetProcessGlobalValue(&libraryPath) returns correct value) and then the load of the same encoding works.
      
      Following code can illustrate this behavior:
      <pre style="padding-left:10pt"><code>
      $ echo 'puts ==[encoding system]; encoding system euc-jp; puts ==[encoding system]' | LANG=japanese ./tclsh
      
      ==iso8859-1
      ==euc-jp
      </code></pre>
      But setting of proper tcl_library env-variable resolves it:
      <pre style="padding-left:10pt"><code>
      $ echo 'puts ==[encoding system]; encoding system euc-jp; puts ==[encoding system]' | LANG=japanese TCL_LIBRARY=../library ./tclsh
      
      ==euc-jp
      ==euc-jp
      </code></pre>
      
      I saw it already too often, but following cases are affected especially:
      
      - usage of portable-like (not installed) tcl's instance or tcl-ed applications (where TCL_LIBRARY environment variable does not set by start);
      
      - call of other tcl-instance from tcl-app via [open "| some-tcl-app"] inside the tcl-interpterer with changed environment (LC_... resp. LANG are changed);
      
      - call of tcl from development environment (also not istalled), like this:
      <pre style="padding-left:10pt"><code>
      $ cd ~projects/tcl8.6/unix
      $ LD_LIBRARY_PATH=. ./tclsh ../tests/all.tcl -file '*unixInit*' -match '*unixInit-3.2*'
      
      ...
      ==== unixInit-3.2 TclpSetInitialEncodings FAILED
      ...
      ---- Result was:
      1
      ---- Result should have been (exact matching):
      0
      ==== unixInit-3.2 FAILED
      ...
      </code></pre>
      
      I've localized the "wrong" places and will try to fix it soon.<br/>
      WiP.
      
    5. foundin initialized to: ">= 8.5 (partially), >= 8.6"
    6. is_private initialized to: "0"
    7. login: "sebres"
    8. priority initialized to: "5 Medium"
    9. resolution initialized to: "None"
    10. severity initialized to: "Severe"
    11. status initialized to: "Open"
    12. submitter initialized to: "sebres"
    13. subsystem initialized to: "38. Init - Library - Autoload"
    14. title initialized to:
      TclInitSubsystems issues: sporadical the lack of of encodings
      
    15. type initialized to: "Bug"
  2. Ticket change [e7e3c1be72] (rid 163652) by sebres on 2018-05-30 18:54:09:

    1. assignee changed to: "sebres"
    2. login: "sebres"
    3. mimetype: "text/plain"
  3. Ticket change [362596a403] (rid 163653) by sebres on 2018-05-30 18:54:54:

    1. login: "sebres"
    2. mimetype: "text/plain"
    3. title changed to:
      TclInitSubsystems issues: the sporadic lack of encodings
      
  4. Ticket change [4e5e428adf] (rid 163675) by sebres on 2018-05-31 13:50:42:

    1. comment changed to:
      Set the system encoding via environment/locale failed sometimes dependent of the system constellation (distribution and/or some env-settings).
      
      Who saw already the test "unixInit-3.2" failed? :)
      
      This cumulates from two actual issues:
      
      1. setlocale (called from TclpInitPlatform) may overwrite environment "LANG" (to "C"), so the try searching of current encoding later in Tcl_GetEncodingNameFromEnvironment <b>will failback to "C"</b> (so the call of "setlocale" takes place <b>too early</b> in some cases, resp. get initial environment via getenv("LANG") <b>too late</b>);
      
      2. second thing which can happen, if 1st issue with "setlocale" gets repaired, would be the fact, that Tcl_GetEncodingSearchPath (called from TclpSetInitialEncodings/Tcl_SetSystemEncoding) may return "" <b>before still any interpreter instance created</b> (and it is so if TclpInitPlatform called).<br/>
      In this case setting of something other as already available system-encodings going to "C" (iso8859-1), because the load of encoding simply fails.<br/>
      The reason for this trouble is the wrong value returned by callback TclpInitLibraryPath.<br/> But later (after first interp going created) the init.tcl (as well as the counterpart script hard-coded in Tcl_Init) will indirectly call Tcl_SetEncodingSearchPath to the proper value (after tcl_library correct resolved and TclGetProcessGlobalValue(&libraryPath) returns correct value) and then the load of the same encoding works.
      
      Following code can illustrate this behavior:
      <pre style="padding-left:10pt"><code>
      $ echo 'puts ==[encoding system]; encoding system euc-jp; puts ==[encoding system]' | LANG=japanese ./tclsh
      
      ==iso8859-1
      ==euc-jp
      </code></pre>
      But setting of proper tcl_library env-variable resolves it:
      <pre style="padding-left:10pt"><code>
      $ echo 'puts ==[encoding system]; encoding system euc-jp; puts ==[encoding system]' | LANG=japanese TCL_LIBRARY=../library ./tclsh
      
      ==euc-jp
      ==euc-jp
      </code></pre>
      
      I saw it already too often, but following cases are affected especially:
      
      - usage of portable-like (not installed) tcl's instance or tcl-ed applications (where TCL_LIBRARY environment variable does not set by start);
      
      - call of other tcl-instance from tcl-app via [open "| some-tcl-app"] inside the tcl-interpterer with changed environment (LC_... resp. LANG are changed);
      
      - call of tcl from development environment (also not istalled), like this:
      <pre style="padding-left:10pt"><code>
      $ cd ~projects/tcl8.6/unix
      $ LD_LIBRARY_PATH=. ./tclsh ../tests/all.tcl -file '*unixInit*' -match '*unixInit-3.2*'
      
      ...
      ==== unixInit-3.2 TclpSetInitialEncodings FAILED
      ...
      ---- Result was:
      1
      ---- Result should have been (exact matching):
      0
      ==== unixInit-3.2 FAILED
      ...
      </code></pre>
      
      I've localized the "wrong" places and will try to fix it soon.<br/>
      WiP.
      
    2. icomment:
      The branch "<a href="https://core.tcl.tk/tcl/timeline?r=fix-initsubsystem-75ecc0e6cb9899bf">fix-initsubsystem-75ecc0e6cb9899bf</a>" provides a fix for this ticket (for 8.6th).
      
      All tests passed on my reference systems (*nix as well as windows).
      
    3. login: "sebres"
    4. mimetype: "text/x-fossil-wiki"
  5. Ticket change [021ac42b0d] (rid 163676) by sebres on 2018-05-31 14:15:37:

    1. icomment:
      BTW There is a new C-routine "TclpExtendWithRelativeLibraryPaths" now, which could 
      be used later as replacement for some hard-coded script-parts of the tclInit (which belong to parents relative the path of "nameofexecutable").
      
      I mean this scripts:<code><pre style="padding-left: 10pt">
        file join $parentDir lib tcl[info tclversion]
        file join $grandParentDir lib tcl[info tclversion]
        file join $parentDir library 
        file join $grandParentDir library
        file join $grandParentDir tcl[info patchlevel] library
        file join [file dirname $grandParentDir] tcl[info patchlevel] library
      </pre></code>
      Indirectly TclpExtendWithRelativeLibraryPaths returns all valid (existing) paths of above-mentioned combinations in the same sequence.
      
    2. login: "sebres"
    3. mimetype: "text/x-fossil-wiki"
  6. Ticket change [03809c58a5] (rid 207159) by jan.nijtmans on 2022-11-22 19:44:35:

    1. icomment: "This came up again. See: [fccb9f322]"
    2. login: "jan.nijtmans"
    3. mimetype: "text/x-fossil-wiki"
  7. Ticket change [7e873e51c1] (rid 258283) by serhiy.storchaka on 2026-10-16 20:52:31:

    1. foundin changed to: "8.6.18, 9.1.0"
    2. icomment:
      The system-encoding part was fixed in 9.0 by [17c53b7edd]; 8.6 still shows it for an uninstalled or relocated tclsh.
      On main, TIP 732 dropped the <nowiki>[encoding dirs]</nowiki> addition from init.tcl, so a --disable-zipfs tclsh with a relocated library has no encoding directories at all (9.1.0).
      Proposed fix in branch [/timeline?r=init-encoding-dirs|init-encoding-dirs], test encoding-26.1.
      
    3. login: "serhiy.storchaka"
    4. mimetype: "text/x-fossil-wiki"
  8. Ticket change [a8379bc004] (rid 258358) by dgp on 2026-10-16 22:41:00:

    1. icomment:
      
      I thought one of the intents of TIP 732 was to simplify and reduce
      the search paths.  Before growing them again, someone involved
      in TIP 732 should comment.
      
    2. login: "dgp"
    3. mimetype: "text/plain"
  9. Ticket change [49b02f7691] (rid 258452) by serhiy.storchaka on 2026-10-17 07:30:00:

    1. icomment:
      It does not grow the search path, it restores what 9.0 does: init.tcl adds <nowiki>[file join $::tcl_library encoding]</nowiki> to <nowiki>[encoding dirs]</nowiki> if it is not there. TIP 732 ([83e88416ac]) moved that part of init.tcl to InitAutoPathObjCmd(), whose comment still says "The function also adds the encoding subdirectory of tcl_library to the encodings search path if not already present", but the code was not moved. So in 9.1 a tclsh without zipfs whose library is not at the compiled-in place has no encoding directories at all.
      @apnadkarni, was dropping it intended?
      
    2. login: "serhiy.storchaka"
    3. mimetype: "text/x-fossil-wiki"
  10. Ticket change [8e256e9b83] (rid 258628) by apnadkarni on 2026-10-17 16:53:24:

    1. assignee changed to: "apnadkarni"
    2. icomment:
      I have to retrace but will need some time before I can look at it. I vaguely recall it was supposed to be done elsewhere (which would mean the comment was not fixed) but I could be wrong.
      
    3. login: "apnadkarni"
    4. mimetype: "text/plain"
  11. Ticket change [c4744a30a5] (rid 261258) by apnadkarni on 2026-11-06 15:40:08:

    1. icomment:
      Proposed fix in branch [apn-bug-75ecc0e6cb](https://core.tcl-lang.org/tcl/timeline?r=apn-bug-75ecc0e6cb).
      
      Implementation differs from the init-encoding-dirs branch. Encoding directory should be added irrespective of whether `InitAutoPath` is called by a (custom) init.tcl or not so it's called from `LocatePreInitScript` which sets `tcl_library`. Implementation is shared with the zipfs enabled case.
      
      Question, in case anyone feels one way or another -
      
      - new encoding dirs are added to the front, not the back (the new encoding-26.1 test has been modified accordingly). My thinking is directories added later by any mechanism should be searched to earlier ones. Easy enough to change.
      
      - After an application sets the encoding directories through `encoding dirs` new interpreters will modify the search path established through that command. I don't know if that is desirable or not but that is the 8.6 behaviour and preserved.
      
    2. login: "apnadkarni"
    3. mimetype: "text/x-markdown"
  12. Ticket change [32e8d4c586] (rid 261276) by apnadkarni on 2026-11-07 11:08:42:

    1. closedate changed to: "2461351.9643800231"
    2. closer changed to: "apnadkarni"
    3. icomment:
      Merged into 9.1 in [1bc3a58eac].
      
      Not applicable to 9.0.
      
      Please re-open if you still see an issue.
      
    4. login: "apnadkarni"
    5. mimetype: "text/x-fossil-plain"
    6. resolution changed to: "Fixed"
    7. status changed to: "Closed"