Attachment "tcl.diff" to
ticket [736774ffff]
added by
das
2003-05-22 08:23:27.
Index: ChangeLog
===================================================================
RCS file: /cvsroot/tcl/tcl/ChangeLog,v
retrieving revision 1.1453.2.61
diff -u -r1.1453.2.61 ChangeLog
--- ChangeLog 12 May 2003 22:35:38 -0000 1.1453.2.61
+++ ChangeLog 13 May 2003 01:11:10 -0000
@@ -1,3 +1,19 @@
+2003-05-13 Daniel Steffen <[email protected]>
+
+ * generic/tcl.decls:
+ * macosx/tclMacOSXBundle.c: added extended version of the
+ Tcl_MacOSXOpenBundleResources() API that takes a 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.
+
+ * unix/tclUnixInit.c (Tcl_MacOSXGetLibraryPath): use new versioned
+ bundle resource API to get tcl runtime library for TCL_VERSION.
+
+ * generic/tclPlatDecls.h:
+ * generic/tclStubInit.c: regen.
+
2003-05-12 Don Porter <[email protected]>
* generic/tclInterp.c: (AliasObjCmd): Added refCounting of the words
Index: generic/tcl.decls
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tcl.decls,v
retrieving revision 1.94
diff -u -r1.94 tcl.decls
--- generic/tcl.decls 31 Aug 2002 06:09:45 -0000 1.94
+++ generic/tcl.decls 13 May 2003 01:11:10 -0000
@@ -1833,3 +1833,11 @@
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)
+}
Index: generic/tclPlatDecls.h
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclPlatDecls.h,v
retrieving revision 1.18
diff -u -r1.18 tclPlatDecls.h
--- generic/tclPlatDecls.h 27 Sep 2002 00:50:10 -0000 1.18
+++ generic/tclPlatDecls.h 13 May 2003 01:11:10 -0000
@@ -82,6 +82,12 @@
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 @@
#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;
@@ -174,6 +181,10 @@
#ifndef Tcl_MacOSXOpenBundleResources
#define Tcl_MacOSXOpenBundleResources \
(tclPlatStubsPtr->tcl_MacOSXOpenBundleResources) /* 0 */
+#endif
+#ifndef Tcl_MacOSXOpenVersionedBundleResources
+#define Tcl_MacOSXOpenVersionedBundleResources \
+ (tclPlatStubsPtr->tcl_MacOSXOpenVersionedBundleResources) /* 1 */
#endif
#endif /* MAC_OSX_TCL */
Index: generic/tclStubInit.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclStubInit.c,v
retrieving revision 1.79.2.1
diff -u -r1.79.2.1 tclStubInit.c
--- generic/tclStubInit.c 21 Mar 2003 03:24:08 -0000 1.79.2.1
+++ generic/tclStubInit.c 13 May 2003 01:11:10 -0000
@@ -371,6 +371,7 @@
#endif /* MAC_TCL */
#ifdef MAC_OSX_TCL
Tcl_MacOSXOpenBundleResources, /* 0 */
+ Tcl_MacOSXOpenVersionedBundleResources, /* 1 */
#endif /* MAC_OSX_TCL */
};
Index: macosx/tclMacOSXBundle.c
===================================================================
RCS file: /cvsroot/tcl/tcl/macosx/tclMacOSXBundle.c,v
retrieving revision 1.3
diff -u -r1.3 tclMacOSXBundle.c
--- macosx/tclMacOSXBundle.c 9 Oct 2002 10:46:23 -0000 1.3
+++ macosx/tclMacOSXBundle.c 22 May 2003 01:15:33 -0000 1.3.2.2
@@ -83,8 +83,44 @@
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,42 @@
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) {
+ CFStringRef bundleTailRef = CFURLCopyLastPathComponent(bundleURL);
+ if (bundleTailRef) {
+ if (CFStringCompare(bundleTailRef,bundleVersionRef,0)
+ == kCFCompareEqualTo) {
+ versionedBundleRef = bundleRef;
+ }
+ CFRelease(bundleTailRef);
+ }
+ }
+ if (bundleURL && !versionedBundleRef) {
+ 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 +174,21 @@
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;
+ }
}
Index: unix/tclUnixInit.c
===================================================================
RCS file: /cvsroot/tcl/tcl/unix/tclUnixInit.c,v
retrieving revision 1.34
diff -u -r1.34 tclUnixInit.c
--- unix/tclUnixInit.c 22 Oct 2002 16:41:28 -0000 1.34
+++ unix/tclUnixInit.c 13 May 2003 01:11:10 -0000
@@ -1027,7 +1027,7 @@
* 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 @@
{
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;
}