diff options
author | welch <welch@noemail.net> | 1998-08-17 11:56:45 (GMT) |
---|---|---|
committer | welch <welch@noemail.net> | 1998-08-17 11:56:45 (GMT) |
commit | 9081a61bee1b8000d5642721f9ef46c7d1401330 (patch) | |
tree | 9f7c117541016a56b541eff227ca138c9ffee029 /mac | |
parent | 6537799cde3910814c13193d40dc48ec940f4509 (diff) | |
download | tcl-9081a61bee1b8000d5642721f9ef46c7d1401330.zip tcl-9081a61bee1b8000d5642721f9ef46c7d1401330.tar.gz tcl-9081a61bee1b8000d5642721f9ef46c7d1401330.tar.bz2 |
Updates for Jim
FossilOrigin-Name: 8f4a7201bdef5bbe946bc1392655048e8a43a1ce
Diffstat (limited to 'mac')
-rw-r--r-- | mac/tclMacResource.c | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/mac/tclMacResource.c b/mac/tclMacResource.c index db06571..0689860 100644 --- a/mac/tclMacResource.c +++ b/mac/tclMacResource.c @@ -1241,7 +1241,7 @@ Tcl_MacEvalResource( Handle sourceText; Str255 rezName; char msg[200]; - int result; + int result, iOpenedResFile = false; short saveRef, fileRef = -1; char idStr[64]; FSSpec fileSpec; @@ -1257,7 +1257,8 @@ Tcl_MacEvalResource( if (nativeName == NULL) { return TCL_ERROR; } - err = FSpLocationFromPath(strlen(nativeName), nativeName, &fileSpec); + err = FSpLocationFromPath(strlen(nativeName), nativeName, + &fileSpec); Tcl_DStringFree(&buffer); if (err != noErr) { Tcl_AppendResult(interp, "Error finding the file: \"", @@ -1273,6 +1274,7 @@ Tcl_MacEvalResource( } UseResFile(fileRef); + iOpenedResFile = true; } else { /* * The default behavior will search through all open resource files. @@ -1313,7 +1315,8 @@ Tcl_MacEvalResource( if (result == TCL_RETURN) { result = TCL_OK; } else if (result == TCL_ERROR) { - sprintf(msg, "\n (rsrc \"%.150s\" line %d)", resourceName, + sprintf(msg, "\n (rsrc \"%.150s\" line %d)", + resourceName, interp->errorLine); Tcl_AddErrorInfo(interp, msg); } @@ -1330,12 +1333,27 @@ Tcl_MacEvalResource( ".", NULL); rezEvalCleanUp: + + /* + * TRICKY POINT: The code that you are sourcing here could load a + * shared library. This will go AHEAD of the resource we stored away + * in saveRef on the resource path. + * If you restore the saveRef in this case, you will never be able + * to get to the resources in the shared library, since you are now + * pointing too far down on the resource list. + * So, we only reset the current resource file if WE opened a resource + * explicitly, and then only if the CurResFile is still the + * one we opened... + */ + + if (iOpenedResFile && (CurResFile() == fileRef)) { + UseResFile(saveRef); + } + if (fileRef != -1) { CloseResFile(fileRef); } - UseResFile(saveRef); - return result; } |