Sophie

Sophie

distrib > Mandriva > 2009.0 > i586 > by-pkgid > 888ddc10cb7de84dfdc75983e70ae863 > files > 1

tcl-8.5.4-1mdv2009.0.src.rpm

--- tcl8.5.0/unix/tclLoadDl.c	2006-06-13 15:10:19.000000000 -0700
+++ tcl8.5.0/unix/tclLoadDl.c.new	2008-01-11 15:55:39.000000000 -0800
@@ -33,6 +33,9 @@
 #ifndef RTLD_GLOBAL
 #   define RTLD_GLOBAL 0
 #endif
+
+#include <errno.h>
+
 
 /*
  *---------------------------------------------------------------------------
@@ -66,7 +69,8 @@
 				 * file. */
 {
     void *handle;
-    CONST char *native;
+    CONST char *native, *native_so;
+    size_t n;
 
     /*
      * First try the full path the user gave us. This is particularly
@@ -87,7 +91,21 @@
 	char *fileName = Tcl_GetString(pathPtr);
 
 	native = Tcl_UtfToExternalDString(NULL, fileName, -1, &ds);
-	handle = dlopen(native, RTLD_NOW | RTLD_GLOBAL);
+	n = strlen(native);
+	n += strlen(TCL_SHLIB_EXT);
+	native_so = malloc(++n);
+	if (native_so == NULL) {
+	  Tcl_AppendResult(interp, "couldn't load file \"", fileName, "\": ",strerror(errno), NULL);
+	  return TCL_ERROR;
+	}
+	strcpy(native_so, native);
+	/*
+	 * if the extension for a dynamic lib is not there, add it
+	 */
+	if (strstr(native_so, TCL_SHLIB_EXT) == NULL)
+	  strcat(native_so, TCL_SHLIB_EXT);
+	handle = dlopen(native_so, RTLD_NOW | RTLD_GLOBAL);       /* INTL: Native. */
+	free(native_so);
 	Tcl_DStringFree(&ds);
     }