diff options
| author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2024-03-04 09:40:28 (GMT) |
|---|---|---|
| committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2024-03-04 09:40:28 (GMT) |
| commit | 3e363b51d5cbb58cfba8d6375fe9190fd40f89dc (patch) | |
| tree | 6d3b647fd42662159816335953cd570dd36f9c86 /unix/tclUnixInit.c | |
| parent | 899174261fca68ba566c1b2a0123f0359d38642b (diff) | |
| download | tcl-3e363b51d5cbb58cfba8d6375fe9190fd40f89dc.zip tcl-3e363b51d5cbb58cfba8d6375fe9190fd40f89dc.tar.gz tcl-3e363b51d5cbb58cfba8d6375fe9190fd40f89dc.tar.bz2 | |
Proposed fix for [1b8a893ded]: TCL_PACKAGE_PATH path is (wrongly) braced.
Diffstat (limited to 'unix/tclUnixInit.c')
| -rw-r--r-- | unix/tclUnixInit.c | 61 |
1 files changed, 26 insertions, 35 deletions
diff --git a/unix/tclUnixInit.c b/unix/tclUnixInit.c index 2d17027..4e22e5b 100644 --- a/unix/tclUnixInit.c +++ b/unix/tclUnixInit.c @@ -110,7 +110,7 @@ static char defaultLibraryDir[sizeof(TCL_LIBRARY)+200] = TCL_LIBRARY; * Makefile. */ -static char pkgPath[sizeof(TCL_PACKAGE_PATH)+200] = TCL_PACKAGE_PATH; +static char pkgPath1[sizeof(TCL_PACKAGE_PATH)+200] = TCL_PACKAGE_PATH; /* * The following table is used to map from Unix locale strings to encoding @@ -792,7 +792,8 @@ TclpSetVariables( struct utsname name; #endif int unameOK; - Tcl_DString ds; + const char *p, *q; + Tcl_Obj *pkgListObj = Tcl_NewObj(); #ifdef HAVE_COREFOUNDATION char tclLibPath[MAXPATHLEN + 1]; @@ -808,29 +809,20 @@ TclpSetVariables( if (MacOSXGetLibraryPath(interp, MAXPATHLEN, tclLibPath) == TCL_OK) { const char *str; CFBundleRef bundleRef; + Tcl_DString ds; Tcl_SetVar2(interp, "tclDefaultLibrary", NULL, tclLibPath, TCL_GLOBAL_ONLY); - Tcl_SetVar2(interp, "tcl_pkgPath", NULL, tclLibPath, TCL_GLOBAL_ONLY); - Tcl_SetVar2(interp, "tcl_pkgPath", NULL, " ", - TCL_GLOBAL_ONLY | TCL_APPEND_VALUE); - + Tcl_ListObjAppendElement(NULL, pkgListObj, Tcl_NewStringObj(tclLibPath, -1)); str = TclGetEnv("DYLD_FRAMEWORK_PATH", &ds); if ((str != NULL) && (str[0] != '\0')) { - char *p = Tcl_DStringValue(&ds); - - /* - * Convert DYLD_FRAMEWORK_PATH from colon to space separated. - */ - - do { - if (*p == ':') { - *p = ' '; - } - } while (*p++); - Tcl_SetVar2(interp, "tcl_pkgPath", NULL, Tcl_DStringValue(&ds), - TCL_GLOBAL_ONLY | TCL_APPEND_VALUE); - Tcl_SetVar2(interp, "tcl_pkgPath", NULL, " ", - TCL_GLOBAL_ONLY | TCL_APPEND_VALUE); + p = Tcl_DStringValue(&ds); + while ((q = strchr(p, ':')) != NULL) { + Tcl_ListObjAppendElement(NULL, pkgListObj, Tcl_NewStringObj(p, q-p)); + p = q+1; + } + if (*p) { + Tcl_ListObjAppendElement(NULL, pkgListObj, Tcl_NewStringObj(p, -1)); + } Tcl_DStringFree(&ds); } bundleRef = CFBundleGetMainBundle(); @@ -844,10 +836,7 @@ TclpSetVariables( (unsigned char*) tclLibPath, MAXPATHLEN) && ! TclOSstat(tclLibPath, &statBuf) && S_ISDIR(statBuf.st_mode)) { - Tcl_SetVar2(interp, "tcl_pkgPath", NULL, tclLibPath, - TCL_GLOBAL_ONLY | TCL_APPEND_VALUE); - Tcl_SetVar2(interp, "tcl_pkgPath", NULL, " ", - TCL_GLOBAL_ONLY | TCL_APPEND_VALUE); + Tcl_ListObjAppendElement(NULL, pkgListObj, Tcl_NewStringObj(tclLibPath, -1)); } CFRelease(frameworksURL); } @@ -857,21 +846,22 @@ TclpSetVariables( (unsigned char*) tclLibPath, MAXPATHLEN) && ! TclOSstat(tclLibPath, &statBuf) && S_ISDIR(statBuf.st_mode)) { - Tcl_SetVar2(interp, "tcl_pkgPath", NULL, tclLibPath, - TCL_GLOBAL_ONLY | TCL_APPEND_VALUE); - Tcl_SetVar2(interp, "tcl_pkgPath", NULL, " ", - TCL_GLOBAL_ONLY | TCL_APPEND_VALUE); + Tcl_ListObjAppendElement(NULL, pkgListObj, Tcl_NewStringObj(tclLibPath, -1)); } CFRelease(frameworksURL); } } - Tcl_SetVar2(interp, "tcl_pkgPath", NULL, pkgPath, - TCL_GLOBAL_ONLY | TCL_APPEND_VALUE); - } else -#endif /* HAVE_COREFOUNDATION */ - { - Tcl_SetVar2(interp, "tcl_pkgPath", NULL, pkgPath, TCL_GLOBAL_ONLY); } +#endif /* HAVE_COREFOUNDATION */ + p = pkgPath1; + while ((q = strchr(p, ':')) != NULL) { + Tcl_ListObjAppendElement(NULL, pkgListObj, Tcl_NewStringObj(p, q-p)); + p = q+1; + } + if (*p) { + Tcl_ListObjAppendElement(NULL, pkgListObj, Tcl_NewStringObj(p, -1)); + } + Tcl_ObjSetVar2(interp, Tcl_NewStringObj("tcl_pkgPath", -1), NULL, pkgListObj, TCL_GLOBAL_ONLY); #ifdef DJGPP Tcl_SetVar2(interp, "tcl_platform", "platform", "dos", TCL_GLOBAL_ONLY); @@ -971,6 +961,7 @@ TclpSetVariables( { struct passwd *pwEnt = TclpGetPwUid(getuid()); const char *user; + Tcl_DString ds; if (pwEnt == NULL) { user = ""; |
