summaryrefslogtreecommitdiff
path: root/dln.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-06-17 01:54:51 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-06-17 01:54:51 +0000
commit7138dfa32523071b91d030e14f5fcd808f0af869 (patch)
tree1ab8a2151c5c7d7fcfda63683243a7644334762c /dln.c
parent3a6168af5b3a78b28b1829ce72bb2af51341c2b7 (diff)
* dln.c (dln_load): need to preserve dln_strerror() result,
calling other dl family can clear it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2575 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'dln.c')
-rw-r--r--dln.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/dln.c b/dln.c
index 563e18f..4db72cd 100644
--- a/dln.c
+++ b/dln.c
@@ -10,8 +10,7 @@
**********************************************************************/
-#include "config.h"
-#include "defines.h"
+#include "ruby.h"
#include "dln.h"
#ifdef HAVE_STDLIB_H
@@ -1241,6 +1240,11 @@ void*
dln_load(file)
const char *file;
{
+#if !defined(_AIX) && !defined(NeXT)
+ const char *error = 0;
+#define DLN_ERROR() (error = dln_strerror(), strcpy(ALLOCA_N(char, strlen(error) + 1), error))
+#endif
+
#if defined _WIN32 && !defined __CYGWIN__
HINSTANCE handle;
char winfile[MAXPATHLEN];
@@ -1256,6 +1260,7 @@ dln_load(file)
/* Load file */
if ((handle = LoadLibrary(winfile)) == NULL) {
+ error = dln_strerror();
goto failed;
}
@@ -1270,6 +1275,7 @@ dln_load(file)
#else
#ifdef USE_DLN_A_OUT
if (load(file) == -1) {
+ error = dln_strerror();
goto failed;
}
return 0;
@@ -1294,12 +1300,14 @@ dln_load(file)
/* Load file */
if ((handle = (void*)dlopen(file, RTLD_LAZY|RTLD_GLOBAL)) == NULL) {
+ error = dln_strerror();
goto failed;
}
init_fct = (void(*)())dlsym(handle, buf);
free(buf);
if (init_fct == NULL) {
+ error = DLN_ERROR();
dlclose(handle);
goto failed;
}
@@ -1538,10 +1546,12 @@ dln_load(file)
*p2 = '\0';
if ((handle = (void*)dlopen(fname, 0)) == NULL) {
+ error = dln_strerror();
goto failed;
}
if ((init_fct = (void (*)())dlsym(handle, buf)) == NULL) {
+ error = DLN_ERROR();
dlclose(handle);
goto failed;
}
@@ -1559,7 +1569,7 @@ dln_load(file)
#endif
#if !defined(_AIX) && !defined(NeXT)
failed:
- rb_loaderror("%s - %s", dln_strerror(), file);
+ rb_loaderror("%s - %s", error, file);
#endif
return 0; /* dummy return */
}