diff options
Diffstat (limited to 'unix')
-rw-r--r-- | unix/tclUnixInit.c | 55 |
1 files changed, 50 insertions, 5 deletions
diff --git a/unix/tclUnixInit.c b/unix/tclUnixInit.c index 092330d..5be58f5 100644 --- a/unix/tclUnixInit.c +++ b/unix/tclUnixInit.c @@ -7,7 +7,7 @@ * Copyright (c) 1999 by Scriptics Corporation. * All rights reserved. * - * RCS: @(#) $Id: tclUnixInit.c,v 1.33 2002/09/02 19:27:42 hobbs Exp $ + * RCS: @(#) $Id: tclUnixInit.c,v 1.34 2002/10/22 16:41:28 das Exp $ */ #if defined(HAVE_CFBUNDLE) @@ -404,9 +404,9 @@ CONST char *path; /* Path to the executable in native { #ifdef HAVE_CFBUNDLE - char tclLibPath[1024]; + char tclLibPath[MAXPATHLEN + 1]; - if (Tcl_MacOSXGetLibraryPath(NULL, 1024, tclLibPath) == TCL_OK) { + if (Tcl_MacOSXGetLibraryPath(NULL, MAXPATHLEN, tclLibPath) == TCL_OK) { str = tclLibPath; } else #endif /* HAVE_CFBUNDLE */ @@ -700,15 +700,60 @@ TclpSetVariables(interp) Tcl_DString ds; #ifdef HAVE_CFBUNDLE - char tclLibPath[1024]; + char tclLibPath[MAXPATHLEN + 1]; - if (Tcl_MacOSXGetLibraryPath(interp, 1024, tclLibPath) == TCL_OK) { + if (Tcl_MacOSXGetLibraryPath(interp, MAXPATHLEN, tclLibPath) == TCL_OK) { + CONST char *str; + Tcl_DString ds; + CFBundleRef bundleRef; + Tcl_SetVar(interp, "tclDefaultLibrary", tclLibPath, TCL_GLOBAL_ONLY); Tcl_SetVar(interp, "tcl_pkgPath", tclLibPath, TCL_GLOBAL_ONLY); Tcl_SetVar(interp, "tcl_pkgPath", " ", TCL_GLOBAL_ONLY | TCL_APPEND_VALUE); + 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_SetVar(interp, "tcl_pkgPath", Tcl_DStringValue(&ds), + TCL_GLOBAL_ONLY | TCL_APPEND_VALUE); + Tcl_SetVar(interp, "tcl_pkgPath", " ", + TCL_GLOBAL_ONLY | TCL_APPEND_VALUE); + Tcl_DStringFree(&ds); + } + if ((bundleRef = CFBundleGetMainBundle())) { + CFURLRef frameworksURL; + Tcl_StatBuf statBuf; + if((frameworksURL = CFBundleCopyPrivateFrameworksURL(bundleRef))) { + if(CFURLGetFileSystemRepresentation(frameworksURL, TRUE, + tclLibPath, MAXPATHLEN) && + ! TclOSstat(tclLibPath, &statBuf) && + S_ISDIR(statBuf.st_mode)) { + Tcl_SetVar(interp, "tcl_pkgPath", tclLibPath, + TCL_GLOBAL_ONLY | TCL_APPEND_VALUE); + Tcl_SetVar(interp, "tcl_pkgPath", " ", + TCL_GLOBAL_ONLY | TCL_APPEND_VALUE); + } + CFRelease(frameworksURL); + } + if((frameworksURL = CFBundleCopySharedFrameworksURL(bundleRef))) { + if(CFURLGetFileSystemRepresentation(frameworksURL, TRUE, + tclLibPath, MAXPATHLEN) && + ! TclOSstat(tclLibPath, &statBuf) && + S_ISDIR(statBuf.st_mode)) { + Tcl_SetVar(interp, "tcl_pkgPath", tclLibPath, + TCL_GLOBAL_ONLY | TCL_APPEND_VALUE); + Tcl_SetVar(interp, "tcl_pkgPath", " ", + TCL_GLOBAL_ONLY | TCL_APPEND_VALUE); + } + CFRelease(frameworksURL); + } + } Tcl_SetVar(interp, "tcl_pkgPath", pkgPath, TCL_GLOBAL_ONLY | TCL_APPEND_VALUE); } else |