diff options
author | Poul-Henning Kamp <phk@FreeBSD.org> | 1997-07-25 19:27:55 +0000 |
---|---|---|
committer | Poul-Henning Kamp <phk@FreeBSD.org> | 1997-07-25 19:27:55 +0000 |
commit | 3d33409926539d866dcea9fc5cb14113b312adf0 (patch) | |
tree | d2f88b3e9ffa79ffb2cc1a0699dd3ee96c47c3e5 /contrib/tcl/unix/tclLoadDl.c | |
parent | 8569730d6bc2e4cb5e784997313325b13518e066 (diff) |
Notes
Diffstat (limited to 'contrib/tcl/unix/tclLoadDl.c')
-rw-r--r-- | contrib/tcl/unix/tclLoadDl.c | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/contrib/tcl/unix/tclLoadDl.c b/contrib/tcl/unix/tclLoadDl.c index 4f073631760ba..2619bfd38c375 100644 --- a/contrib/tcl/unix/tclLoadDl.c +++ b/contrib/tcl/unix/tclLoadDl.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. * - * SCCS: @(#) tclLoadDl.c 1.7 96/03/14 09:03:33 + * SCCS: @(#) tclLoadDl.c 1.8 96/12/03 16:57:00 */ #include "tclInt.h" @@ -68,6 +68,7 @@ TclLoadFile(interp, fileName, sym1, sym2, proc1Ptr, proc2Ptr) * to sym1 and sym2. */ { VOID *handle; + Tcl_DString newName; handle = dlopen(fileName, RTLD_NOW | RTLD_GLOBAL); if (handle == NULL) { @@ -75,8 +76,31 @@ TclLoadFile(interp, fileName, sym1, sym2, proc1Ptr, proc2Ptr) "\": ", dlerror(), (char *) NULL); return TCL_ERROR; } - *proc1Ptr = (Tcl_PackageInitProc *) dlsym(handle, sym1); - *proc2Ptr = (Tcl_PackageInitProc *) dlsym(handle, sym2); + + /* + * Some platforms still add an underscore to the beginning of symbol + * names. If we can't find a name without an underscore, try again + * with the underscore. + */ + + *proc1Ptr = (Tcl_PackageInitProc *) dlsym(handle, (char *) sym1); + if (*proc1Ptr == NULL) { + Tcl_DStringInit(&newName); + Tcl_DStringAppend(&newName, "_", 1); + Tcl_DStringAppend(&newName, sym1, -1); + *proc1Ptr = (Tcl_PackageInitProc *) dlsym(handle, + Tcl_DStringValue(&newName)); + Tcl_DStringFree(&newName); + } + *proc2Ptr = (Tcl_PackageInitProc *) dlsym(handle, (char *) sym2); + if (*proc2Ptr == NULL) { + Tcl_DStringInit(&newName); + Tcl_DStringAppend(&newName, "_", 1); + Tcl_DStringAppend(&newName, sym2, -1); + *proc2Ptr = (Tcl_PackageInitProc *) dlsym(handle, + Tcl_DStringValue(&newName)); + Tcl_DStringFree(&newName); + } return TCL_OK; } |