summaryrefslogtreecommitdiffstats
path: root/mac/tclMacLoad.c
diff options
context:
space:
mode:
authordas <das>2001-11-23 01:26:52 (GMT)
committerdas <das>2001-11-23 01:26:52 (GMT)
commit5bf5a16c3a6e83b4297123ae905297ac723f7f81 (patch)
tree725fbc934e8cfe62511b965b22c0069a3e157e67 /mac/tclMacLoad.c
parent8ddfd6bbdf803f32768cf447560be0af0e97e08b (diff)
downloadtcl-5bf5a16c3a6e83b4297123ae905297ac723f7f81.zip
tcl-5bf5a16c3a6e83b4297123ae905297ac723f7f81.tar.gz
tcl-5bf5a16c3a6e83b4297123ae905297ac723f7f81.tar.bz2
** upport to 8.4 of mac code changes for 8.3.3 & various new
** changes for 8.4, some already backported to 8.3.4 (patch #435658) see ChangeLog for details
Diffstat (limited to 'mac/tclMacLoad.c')
-rw-r--r--mac/tclMacLoad.c56
1 files changed, 31 insertions, 25 deletions
diff --git a/mac/tclMacLoad.c b/mac/tclMacLoad.c
index f3419f2..8490fa9 100644
--- a/mac/tclMacLoad.c
+++ b/mac/tclMacLoad.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclMacLoad.c,v 1.7 2001/09/28 01:21:53 dgp Exp $
+ * RCS: @(#) $Id: tclMacLoad.c,v 1.8 2001/11/23 01:27:45 das Exp $
*/
#include <CodeFragments.h>
@@ -108,7 +108,7 @@ TclpLoadFile(
Tcl_PackageInitProc **proc2Ptr,
/* Where to return the addresses corresponding
* to sym1 and sym2. */
- ClientData *clientDataPtr; /* Filled with token for dynamically loaded
+ ClientData *clientDataPtr, /* Filled with token for dynamically loaded
* file which will be passed back to
* (*unloadProcPtr)() to unload the file. */
Tcl_FSUnloadFileProc **unloadProcPtr)
@@ -125,19 +125,11 @@ TclpLoadFile(
Handle fragResource;
UInt32 offset = 0;
UInt32 length = kCFragGoesToEOF;
- char packageName[255];
+ StringPtr fragName=NULL;
Str255 errName;
+ Tcl_DString ds;
char *native;
- /*
- * First thing we must do is infer the package name from the sym1
- * variable. This is kind of dumb since the caller actually knows
- * this value, it just doesn't give it to us.
- */
- strcpy(packageName, sym1);
- Tcl_UtfToLower(packageName);
- *(Tcl_UtfAtIndex(packageName, Tcl_NumUtfChars(packageName, -1) - 5)) = 0;
-
native = Tcl_FSGetNativePath(pathPtr);
err = FSpLocationFromPath(strlen(native), native, &fileSpec);
@@ -147,6 +139,14 @@ TclpLoadFile(
}
/*
+ * First thing we must do is infer the package name from the sym1
+ * variable. This is kind of dumb since the caller actually knows
+ * this value, it just doesn't give it to us.
+ */
+ native = Tcl_UtfToExternalDString(NULL, sym1, -1, &ds);
+ native[strlen(native) - 5] = 0;
+
+ /*
* See if this fragment has a 'cfrg' resource. It will tell us where
* to look for the fragment in the file. If it doesn't exist we will
* assume we have a ppc frag using the whole data fork. If it does
@@ -173,10 +173,11 @@ TclpLoadFile(
index++, itemStart += srcItem->itemSize) {
srcItem = (CfrgItem*)itemStart;
if (srcItem->archType != OUR_ARCH_TYPE) continue;
- if (!strncasecmp(packageName, (char *) srcItem->name + 1,
- srcItem->name[0])) {
+ if (!strncasecmp(native, (char *) srcItem->name + 1,
+ strlen(native))) {
offset = srcItem->codeOffset;
length = srcItem->codeLength;
+ fragName=srcItem->name;
}
}
}
@@ -190,6 +191,7 @@ TclpLoadFile(
CloseResFile(fragFileRef);
UseResFile(saveFileRef);
}
+ Tcl_DStringFree(&ds);
/*
* Now we can attempt to load the fragement using the offset & length
@@ -197,9 +199,11 @@ TclpLoadFile(
* as we are going to search for specific entry points passed to us.
*/
- c2pstr(packageName);
- err = GetDiskFragment(&fileSpec, offset, length, (StringPtr) packageName,
+ err = GetDiskFragment(&fileSpec, offset, length, fragName,
kLoadCFrag, &connID, &dummy, errName);
+
+ *clientDataPtr = (ClientData) connID;
+
if (err != fragNoErr) {
p2cstr(errName);
Tcl_AppendResult(interp, "couldn't load file \"",
@@ -208,9 +212,12 @@ TclpLoadFile(
return TCL_ERROR;
}
- c2pstr(sym1);
- err = FindSymbol(connID, (StringPtr) sym1, (Ptr *) proc1Ptr, &symClass);
- p2cstr((StringPtr) sym1);
+ *unloadProcPtr = &TclpUnloadFile;
+
+ native = Tcl_UtfToExternalDString(NULL, sym1, -1, &ds);
+ c2pstr(native);
+ err = FindSymbol(connID, (StringPtr) native, (Ptr *) proc1Ptr, &symClass);
+ Tcl_DStringFree(&ds);
if (err != fragNoErr || symClass == kDataCFragSymbol) {
Tcl_SetResult(interp,
"could not find Initialization routine in library",
@@ -218,16 +225,14 @@ TclpLoadFile(
return TCL_ERROR;
}
- c2pstr(sym2);
- err = FindSymbol(connID, (StringPtr) sym2, (Ptr *) proc2Ptr, &symClass);
- p2cstr((StringPtr) sym2);
+ native = Tcl_UtfToExternalDString(NULL, sym2, -1, &ds);
+ c2pstr(native);
+ err = FindSymbol(connID, (StringPtr) native, (Ptr *) proc2Ptr, &symClass);
+ Tcl_DStringFree(&ds);
if (err != fragNoErr || symClass == kDataCFragSymbol) {
*proc2Ptr = NULL;
}
- *clientDataPtr = (ClientData) connID;
- *unloadProcPtr = &TclpUnloadFile;
-
return TCL_OK;
}
@@ -256,6 +261,7 @@ TclpUnloadFile(clientData)
* a token that represents the loaded
* file. */
{
+ CloseConnection((CFragConnectionID*) &clientData);
}
/*