diff options
| author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-06-17 01:54:51 +0000 |
|---|---|---|
| committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-06-17 01:54:51 +0000 |
| commit | f141077ae351ab809ef9bf733804fa6277aa046b (patch) | |
| tree | 1ab8a2151c5c7d7fcfda63683243a7644334762c | |
| parent | 6f644990a58f6d03a3c8f43f6d8c46fd6bf98e4c (diff) | |
| download | ruby-f141077ae351ab809ef9bf733804fa6277aa046b.tar.gz ruby-f141077ae351ab809ef9bf733804fa6277aa046b.tar.xz ruby-f141077ae351ab809ef9bf733804fa6277aa046b.zip | |
* dln.c (dln_load): need to preserve dln_strerror() result,
calling other dl family can clear it.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@2575 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
| -rw-r--r-- | ChangeLog | 5 | ||||
| -rw-r--r-- | dln.c | 16 |
2 files changed, 18 insertions, 3 deletions
@@ -1,3 +1,8 @@ +Mon Jun 17 10:51:37 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net> + + * 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 <knu@iDaemons.org> * dir.c (glob_helper): Use lstat() instead of stat() so it catches @@ -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 */ } |
