summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordas <das>2003-05-13 08:40:29 (GMT)
committerdas <das>2003-05-13 08:40:29 (GMT)
commitabbcb0c269fc4339825f49ec99f9799d03f0340e (patch)
tree7d20211b679af52f135bd538105f8017afb4d882
parentd9e8d364d0d3c76e689634b79e78346209c437d1 (diff)
downloadtcl-abbcb0c269fc4339825f49ec99f9799d03f0340e.zip
tcl-abbcb0c269fc4339825f49ec99f9799d03f0340e.tar.gz
tcl-abbcb0c269fc4339825f49ec99f9799d03f0340e.tar.bz2
* 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]
-rw-r--r--ChangeLog28
-rw-r--r--generic/tcl.decls10
-rw-r--r--generic/tclPlatDecls.h13
-rw-r--r--generic/tclStubInit.c3
-rw-r--r--macosx/tclMacOSXBundle.c82
-rw-r--r--unix/tclUnixInit.c8
-rw-r--r--unix/tclUnixPort.h9
7 files changed, 130 insertions, 23 deletions
diff --git a/ChangeLog b/ChangeLog
index 3b088ce..3c35afd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+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 Donal K. Fellows <fellowsd@cs.man.ac.uk>
* tests/cmdAH.test: General clean-up of tests so that all
@@ -6,9 +28,9 @@
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/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
diff --git a/generic/tcl.decls b/generic/tcl.decls
index f77543f..a6ed026 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.95 2003/04/05 01:25:10 dkf Exp $
+# RCS: @(#) $Id: tcl.decls,v 1.96 2003/05/13 08:40:30 das Exp $
library tcl
@@ -1876,3 +1876,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..2f07359 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.19 2003/05/13 08:40:31 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 df105fa..60fff39 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.82 2003/04/28 12:34:29 dkf Exp $
+ * RCS: @(#) $Id: tclStubInit.c,v 1.83 2003/05/13 08:40:31 das Exp $
*/
#include "tclInt.h"
@@ -372,6 +372,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..53853df 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.35 2003/05/13 08:40:31 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..396b7df 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.28 2003/05/13 08:40:31 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)