Skip to content
Tcl Source Code View Ticket
Login

View Ticket

TCL_LIBRARY can not be a standard Unix path list

Closed / Rejected219309ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 25 years ago
Descriptionplain2000-10-26 05:10:29
OriginalBugID: 3401 RFE
Version: 8.2.1
SubmitDate: '1999-11-05'
LastModified: '2000-02-05'
Severity: LOW
Status: UnAssn
Submitter: techsupp
ChangedBy: hobbs
OS: Other
FixedDate: '2000-10-25'
ClosedDate: '2000-10-25'


Name:
Yu Zhang

CVS:
last update: 4:30pm, 10/21/99 RCS: @(#) $Id: tclUnixInit.c,v 1.17 1999/07/22 21:50:56 redman Exp

DesiredBehavior:
For our product, in different configurations, Tcl library path will be
    different. So it's desirable that TCL_LIBRARY becomes standard Unix path
    list, i.e. multiple directories split with ":" to support these
    configurations.

Patch:
--- tclUnixInit.c       Thu Oct 21 16:17:08 1999
***************
*** 238,252 ****
      str = Tcl_DStringValue(&buffer);

      if ((str != NULL) && (str[0] != '\0')) {
!       /*
!        * If TCL_LIBRARY is set, search there.
         */
!
!       objPtr = Tcl_NewStringObj(str, -1);
!       Tcl_ListObjAppendElement(NULL, pathPtr, objPtr);

!       Tcl_SplitPath(str, &pathc, &pathv);
!       if ((pathc > 0) && (strcasecmp(installLib + 4, pathv[pathc-1]) != 0)) {
            /*
             * If TCL_LIBRARY is set but refers to a different tcl
             * installation than the current version, try fiddling with the
--- 238,256 ----
      str = Tcl_DStringValue(&buffer);

      if ((str != NULL) && (str[0] != '\0')) {
!       /*
!        * If TCL_LIBRARY is set, add every path in TCL_LIBRARY into
!        * path list
         */
!       char *tmp_str, *last;

!       tmp_str = strtok_r(str, ":", &last);
!       while (tmp_str) {
!           objPtr = Tcl_NewStringObj(tmp_str, -1);
!           Tcl_ListObjAppendElement(NULL, pathPtr, objPtr);
!
!           Tcl_SplitPath(tmp_str, &pathc, &pathv);
!           if ((pathc > 0) && (strcasecmp(installLib + 4, pathv[pathc-1]) != 0)) {
            /*
             * If TCL_LIBRARY is set but refers to a different tcl
             * installation than the current version, try fiddling with the
***************
*** 255,267 ****
             * version string.
             */

!           pathv[pathc - 1] = installLib + 4;
!           str = Tcl_JoinPath(pathc, pathv, &ds);
!           objPtr = Tcl_NewStringObj(str, Tcl_DStringLength(&ds));
!           Tcl_ListObjAppendElement(NULL, pathPtr, objPtr);
!           Tcl_DStringFree(&ds);
!       }
!       ckfree((char *) pathv);
      }

      /*
--- 259,274 ----
             * version string.
             */

!               pathv[pathc - 1] = installLib + 4;
!               tmp_str = Tcl_JoinPath(pathc, pathv, &ds);
!               objPtr = Tcl_NewStringObj(tmp_str, Tcl_DStringLength(&ds));
!               Tcl_ListObjAppendElement(NULL, pathPtr, objPtr);
!               Tcl_DStringFree(&ds);
!           }
!           ckfree((char *) pathv);
!
!           tmp_str = strtok_r(NULL, ":", &last);
!        }
      }

      /*

PatchFiles:
tclUnixInit.c
dgp Ticket [219309ffff]: 2 changes [History diff]2001-02-08 12:40:29
dgp Ticket [219309ffff]: 1 change [History diff]2001-04-04 04:51:08
dgpplain2001-08-27 08:22:40
Logged In: YES 
user_id=80530


The default Tcl_Init() behavior Tcl is to look for the
init.tcl file first in the directory stored in the
TCL_LIBRARY environment variable, if any.  The purpose
is to allow the final end user an opportunity to direct
a program that calls Tcl_Init() exactly where to find
an appropriate init.tcl file.  This is really meant to
be used as a last resort, enabling an end user to work
around a broken installation of Tcl beyond his power to
repair.  It's not meant to provide a general-purpose search
path facility, like UNIX's PATH variable.

If you have a product that needs different values of
TCL_LIBRARY for different configurations, then write
a shell script wrapper around each configuration, setting
TCL_LIBRARY to the appropriate variable.

I don't see how having a multi-directory search path in
TCL_LIBRARY would help manage the multiple configuration
problem, because each configuration would still have the
same value of $TCL_LIBRARY, and each would find the first
init.tcl file available on that path.
Log in (anonymous is fine) to add a comment.