mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
3a6168af5b
commit
7138dfa325
2 changed files with 18 additions and 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
|
||||
|
|
16
dln.c
16
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 */
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue