From 7138dfa32523071b91d030e14f5fcd808f0af869 Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 17 Jun 2002 01:54:51 +0000 Subject: * 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 --- ChangeLog | 5 +++++ dln.c | 16 +++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 01efb4d955..9677b4988f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Mon Jun 17 10:51:37 2002 Nobuyoshi Nakada + + * dln.c (dln_load): need to preserve dln_strerror() result, + calling other dl family can clear it. + Sat Jun 15 18:51:13 2002 Akinori MUSHA * dir.c (glob_helper): Use lstat() instead of stat() so it catches diff --git a/dln.c b/dln.c index 563e18f555..4db72cdead 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 */ } -- cgit v1.2.3