diff options
author | vincentdarley <vincentdarley@noemail.net> | 2002-10-10 12:25:52 (GMT) |
---|---|---|
committer | vincentdarley <vincentdarley@noemail.net> | 2002-10-10 12:25:52 (GMT) |
commit | 91bb0051e7d19c110afa67bd8e0ebafa052edcdc (patch) | |
tree | 53b758745c52382936e9eab9d435276110cf48e6 /unix/tclLoadDld.c | |
parent | afdb69445888c884ed001e631ecbfd387496c98f (diff) | |
download | tcl-91bb0051e7d19c110afa67bd8e0ebafa052edcdc.zip tcl-91bb0051e7d19c110afa67bd8e0ebafa052edcdc.tar.gz tcl-91bb0051e7d19c110afa67bd8e0ebafa052edcdc.tar.bz2 |
load fixes for Bug 611108
FossilOrigin-Name: 4a2a8cda84e8705e04c0b6b3b5a9d8e445298b35
Diffstat (limited to 'unix/tclLoadDld.c')
-rw-r--r-- | unix/tclLoadDld.c | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/unix/tclLoadDld.c b/unix/tclLoadDld.c index 9603e7e..bc9bc8e 100644 --- a/unix/tclLoadDld.c +++ b/unix/tclLoadDld.c @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclLoadDld.c,v 1.11 2002/07/18 16:26:04 vincentdarley Exp $ + * RCS: @(#) $Id: tclLoadDld.c,v 1.12 2002/10/10 12:25:53 vincentdarley Exp $ */ #include "tclInt.h" @@ -60,7 +60,8 @@ TclpDlopen(interp, pathPtr, loadHandle, unloadProcPtr) { static int firstTime = 1; int returnCode; - char *fileName = Tcl_GetString(pathPtr); + char *fileName; + CONST char *native; /* * The dld package needs to know the pathname to the tcl binary. @@ -84,13 +85,30 @@ TclpDlopen(interp, pathPtr, loadHandle, unloadProcPtr) firstTime = 0; } - if ((returnCode = dld_link(Tcl_GetString(pathPtr))) != 0) { + fileName = Tcl_GetString(pathPtr); + + /* + * First try the full path the user gave us. This is particularly + * important if the cwd is inside a vfs, and we are trying to load + * using a relative path. + */ + native = Tcl_FSGetNativePath(pathPtr); + returnCode = dld_link(native); + + if (returnCode != 0) { + Tcl_DString ds; + native = Tcl_UtfToExternalDString(NULL, fileName, -1, &ds); + returnCode = dld_link(native); + Tcl_DStringFree(&ds); + } + + if (returnCode != 0) { Tcl_AppendResult(interp, "couldn't load file \"", - Tcl_GetString(pathPtr), - "\": ", dld_strerror(returnCode), (char *) NULL); + fileName, "\": ", + dld_strerror(returnCode), (char *) NULL); return TCL_ERROR; } - *loadHandle = strcpy( + *loadHandle = (Tcl_LoadHandle) strcpy( (char *) ckalloc((unsigned) (strlen(fileName) + 1)), fileName); *unloadProcPtr = &TclpUnloadFile; return TCL_OK; |