diff options
-rw-r--r-- | ChangeLog | 28 | ||||
-rw-r--r-- | generic/tcl.decls | 10 | ||||
-rw-r--r-- | generic/tclPlatDecls.h | 13 | ||||
-rw-r--r-- | generic/tclStubInit.c | 3 | ||||
-rw-r--r-- | macosx/tclMacOSXBundle.c | 82 | ||||
-rw-r--r-- | unix/tclUnixInit.c | 8 | ||||
-rw-r--r-- | unix/tclUnixPort.h | 9 |
7 files changed, 130 insertions, 23 deletions
@@ -1,12 +1,34 @@ +2003-05-13 Daniel Steffen <das@users.sourceforge.net> + + * generic/tcl.decls: + * macosx/tclMacOSXBundle.c: added extended version of the + Tcl_MacOSXOpenBundleResources() API taking an extra version number + argument: Tcl_MacOSXOpenVersionedBundleResources(). + This is needed to be able to access bundle resources in versioned + frameworks such as Tcl and Tk, otherwise if multiple versions were + installed, only the latest version's resources could be accessed. + [Bug 736774] + + * unix/tclUnixInit.c (Tcl_MacOSXGetLibraryPath): use new versioned + bundle resource API to get tcl runtime library for TCL_VERSION. + [Bug 736774] + + * generic/tclPlatDecls.h: + * generic/tclStubInit.c: regen. + + * unix/tclUnixPort.h: worked around the issue of realpath() not + being thread-safe on Mac OS X by defining NO_REALPATH for threaded + builds on Mac OS X. [Bug 711232] + 2003-05-12 Don Porter <dgp@users.sourceforge.net> * generic/tclInterp.c: (AliasObjCmd): Added refCounting of the words * tests/interp.test (interp-33.1): of the target of an interp alias during its execution. Also added test. [Bug 730244]. - * generic/tclBasic.c (TclInvokeObjectCommand): objv[argc] is no - longer set to NULL (Tcl_CreateObjCommand docs already say that it - should not be accessed). + * generic/tclBasic.c (TclInvokeObjectCommand): objv[argc] is no + longer set to NULL (Tcl_CreateObjCommand docs already say that it + should not be accessed). * generic/tclObj.c (tclCmdNameType): Corrected variable use of the otherValuePtr or the twoPtrValue.ptr1 fields to store a diff --git a/generic/tcl.decls b/generic/tcl.decls index 2dbc2c5..ff94f2f 100644 --- a/generic/tcl.decls +++ b/generic/tcl.decls @@ -11,7 +11,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: tcl.decls,v 1.94 2002/08/31 06:09:45 das Exp $ +# RCS: @(#) $Id: tcl.decls,v 1.94.2.1 2003/05/13 08:41:26 das Exp $ library tcl @@ -1833,3 +1833,11 @@ declare 0 macosx { int maxPathLen, char *libraryPath) } +declare 1 macosx { + int Tcl_MacOSXOpenVersionedBundleResources(Tcl_Interp *interp, + CONST char *bundleName, + CONST char *bundleVersion, + int hasResourceFile, + int maxPathLen, + char *libraryPath) +} diff --git a/generic/tclPlatDecls.h b/generic/tclPlatDecls.h index 3404542..6067217 100644 --- a/generic/tclPlatDecls.h +++ b/generic/tclPlatDecls.h @@ -6,7 +6,7 @@ * Copyright (c) 1998-1999 by Scriptics Corporation. * All rights reserved. * - * RCS: @(#) $Id: tclPlatDecls.h,v 1.18 2002/09/27 00:50:10 hobbs Exp $ + * RCS: @(#) $Id: tclPlatDecls.h,v 1.18.2.1 2003/05/13 08:41:26 das Exp $ */ #ifndef _TCLPLATDECLS @@ -82,6 +82,12 @@ EXTERN int Tcl_MacOSXOpenBundleResources _ANSI_ARGS_(( Tcl_Interp * interp, CONST char * bundleName, int hasResourceFile, int maxPathLen, char * libraryPath)); +/* 1 */ +EXTERN int Tcl_MacOSXOpenVersionedBundleResources _ANSI_ARGS_(( + Tcl_Interp * interp, CONST char * bundleName, + CONST char * bundleVersion, + int hasResourceFile, int maxPathLen, + char * libraryPath)); #endif /* MAC_OSX_TCL */ typedef struct TclPlatStubs { @@ -105,6 +111,7 @@ typedef struct TclPlatStubs { #endif /* MAC_TCL */ #ifdef MAC_OSX_TCL int (*tcl_MacOSXOpenBundleResources) _ANSI_ARGS_((Tcl_Interp * interp, CONST char * bundleName, int hasResourceFile, int maxPathLen, char * libraryPath)); /* 0 */ + int (*tcl_MacOSXOpenVersionedBundleResources) _ANSI_ARGS_((Tcl_Interp * interp, CONST char * bundleName, CONST char * bundleVersion, int hasResourceFile, int maxPathLen, char * libraryPath)); /* 1 */ #endif /* MAC_OSX_TCL */ } TclPlatStubs; @@ -175,6 +182,10 @@ extern TclPlatStubs *tclPlatStubsPtr; #define Tcl_MacOSXOpenBundleResources \ (tclPlatStubsPtr->tcl_MacOSXOpenBundleResources) /* 0 */ #endif +#ifndef Tcl_MacOSXOpenVersionedBundleResources +#define Tcl_MacOSXOpenVersionedBundleResources \ + (tclPlatStubsPtr->tcl_MacOSXOpenVersionedBundleResources) /* 1 */ +#endif #endif /* MAC_OSX_TCL */ #endif /* defined(USE_TCL_STUBS) && !defined(USE_TCL_STUB_PROCS) */ diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c index f70c479..c1ed1df 100644 --- a/generic/tclStubInit.c +++ b/generic/tclStubInit.c @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclStubInit.c,v 1.79.2.1 2003/03/21 03:24:08 dgp Exp $ + * RCS: @(#) $Id: tclStubInit.c,v 1.79.2.2 2003/05/13 08:41:26 das Exp $ */ #include "tclInt.h" @@ -371,6 +371,7 @@ TclPlatStubs tclPlatStubs = { #endif /* MAC_TCL */ #ifdef MAC_OSX_TCL Tcl_MacOSXOpenBundleResources, /* 0 */ + Tcl_MacOSXOpenVersionedBundleResources, /* 1 */ #endif /* MAC_OSX_TCL */ }; diff --git a/macosx/tclMacOSXBundle.c b/macosx/tclMacOSXBundle.c index 7e3dfe7..88def57 100644 --- a/macosx/tclMacOSXBundle.c +++ b/macosx/tclMacOSXBundle.c @@ -83,8 +83,44 @@ Tcl_MacOSXOpenBundleResources( int maxPathLen, char *libraryPath) { + return Tcl_MacOSXOpenVersionedBundleResources(interp, bundleName, + NULL, hasResourceFile, maxPathLen, libraryPath); +} + +/* + *---------------------------------------------------------------------- + * + * Tcl_MacOSXOpenVersionedBundleResources -- + * + * Given the bundle and version name for a shared library (version + * name can be NULL to indicate latest version), this routine sets + * libraryPath to the Resources/Scripts directory in the framework + * package. If hasResourceFile is true, it will also open the main + * resource file for the bundle. + * + * + * Results: + * TCL_OK if the bundle could be opened, and the Scripts folder found. + * TCL_ERROR otherwise. + * + * Side effects: + * libraryVariableName may be set, and the resource file opened. + * + *---------------------------------------------------------------------- + */ + +int +Tcl_MacOSXOpenVersionedBundleResources( + Tcl_Interp *interp, + CONST char *bundleName, + CONST char *bundleVersion, + int hasResourceFile, + int maxPathLen, + char *libraryPath) +{ CFBundleRef bundleRef; CFStringRef bundleNameRef; + CFURLRef libURL; libraryPath[0] = '\0'; @@ -94,11 +130,32 @@ Tcl_MacOSXOpenBundleResources( bundleRef = CFBundleGetBundleWithIdentifier(bundleNameRef); CFRelease(bundleNameRef); - if (bundleRef == 0) { - return TCL_ERROR; - } else { - CFURLRef libURL; + if (bundleVersion && bundleRef) { + /* create bundle from bundleVersion subdirectory of 'Versions' */ + CFBundleRef versionedBundleRef = NULL; + CFURLRef versionedBundleURL = NULL; + CFStringRef bundleVersionRef = CFStringCreateWithCString(NULL, + bundleVersion, kCFStringEncodingUTF8); + CFURLRef bundleURL = CFBundleCopyBundleURL(bundleRef); + if (bundleURL) { + CFURLRef versURL = CFURLCreateCopyAppendingPathComponent(NULL, + bundleURL, CFSTR("Versions"), TRUE); + if (versURL) { + versionedBundleURL = CFURLCreateCopyAppendingPathComponent( + NULL, versURL, bundleVersionRef, TRUE); + CFRelease(versURL); + } + CFRelease(bundleURL); + } + CFRelease(bundleVersionRef); + if (versionedBundleURL) { + versionedBundleRef = CFBundleCreate(NULL, versionedBundleURL); + CFRelease(versionedBundleURL); + } + bundleRef = versionedBundleRef; + } + if (bundleRef) { if (hasResourceFile) { short refNum; refNum = CFBundleOpenBundleResourceMap(bundleRef); @@ -107,20 +164,21 @@ Tcl_MacOSXOpenBundleResources( libURL = CFBundleCopyResourceURL(bundleRef, CFSTR("Scripts"), NULL, NULL); - if (libURL != NULL) { + if (libURL) { /* * FIXME: This is a quick fix, it is probably not right * for internationalization. */ - if (CFURLGetFileSystemRepresentation(libURL, true, - libraryPath, maxPathLen)) { - } + CFURLGetFileSystemRepresentation(libURL, TRUE, + libraryPath, maxPathLen); CFRelease(libURL); - } else { - return TCL_ERROR; } } - - return TCL_OK; + + if (libraryPath[0]) { + return TCL_OK; + } else { + return TCL_ERROR; + } } diff --git a/unix/tclUnixInit.c b/unix/tclUnixInit.c index 5be58f5..ae3d2a3 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.34 2002/10/22 16:41:28 das Exp $ + * RCS: @(#) $Id: tclUnixInit.c,v 1.34.2.1 2003/05/13 08:41:26 das Exp $ */ #if defined(HAVE_CFBUNDLE) @@ -1027,7 +1027,7 @@ TclpCheckStackSpace() * TCL_OK if we have found the tcl library; TCL_ERROR otherwise. * * Side effects: - * Same as for Tcl_MacOSXOpenBundleResources. + * Same as for Tcl_MacOSXOpenVersionedBundleResources. * *---------------------------------------------------------------------- */ @@ -1035,8 +1035,8 @@ static int Tcl_MacOSXGetLibraryPath(Tcl_Interp *interp, int maxPathLen, char *tc { int foundInFramework = TCL_ERROR; if (strcmp(defaultLibraryDir, "@TCL_IN_FRAMEWORK@") == 0) { - foundInFramework = Tcl_MacOSXOpenBundleResources(interp, - "com.tcltk.tcllibrary", 0, maxPathLen, tclLibPath); + foundInFramework = Tcl_MacOSXOpenVersionedBundleResources(interp, + "com.tcltk.tcllibrary", TCL_VERSION, 0, maxPathLen, tclLibPath); } return foundInFramework; } diff --git a/unix/tclUnixPort.h b/unix/tclUnixPort.h index 511e09b..8574bfa 100644 --- a/unix/tclUnixPort.h +++ b/unix/tclUnixPort.h @@ -19,7 +19,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclUnixPort.h,v 1.27 2003/02/20 00:34:09 hobbs Exp $ + * RCS: @(#) $Id: tclUnixPort.h,v 1.27.2.1 2003/05/13 08:41:26 das Exp $ */ #ifndef _TCLUNIXPORT @@ -571,6 +571,13 @@ EXTERN char * TclpInetNtoa(struct in_addr); #define inet_ntoa(x) TclpInetNtoa(x) #undef TclOSreaddir #define TclOSreaddir(x) TclpReaddir(x) +#ifdef MAC_OSX_TCL +/* + * On Mac OS X, realpath is currently not + * thread safe, c.f. SF bug # 711232. + */ +#define NO_REALPATH +#endif #else typedef int TclpMutex; #define TclpMutexInit(a) |