ruby.c: no VARIABLE_LIBPATH
* ruby.c (ruby_init_loadpath_safe): removed code using fixed size path buffer. relative load path is supported only on platforms where dladdr is available, or on Windows, so !VARIABLE_LIBPATH code is not used. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62086 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
9a8b38cacf
commit
592dcccdf9
28
ruby.c
28
ruby.c
@ -485,17 +485,8 @@ ruby_init_loadpath_safe(int safe_level)
|
|||||||
ID id_initial_load_path_mark;
|
ID id_initial_load_path_mark;
|
||||||
const char *paths = ruby_initial_load_paths;
|
const char *paths = ruby_initial_load_paths;
|
||||||
#if defined LOAD_RELATIVE
|
#if defined LOAD_RELATIVE
|
||||||
# if defined HAVE_DLADDR || defined __CYGWIN__ || defined _WIN32
|
|
||||||
# define VARIABLE_LIBPATH 1
|
|
||||||
# else
|
|
||||||
# define VARIABLE_LIBPATH 0
|
|
||||||
# endif
|
|
||||||
# if VARIABLE_LIBPATH
|
|
||||||
char *libpath;
|
char *libpath;
|
||||||
VALUE sopath;
|
VALUE sopath;
|
||||||
# else
|
|
||||||
char libpath[MAXPATHLEN + 1];
|
|
||||||
# endif
|
|
||||||
size_t baselen;
|
size_t baselen;
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
@ -527,11 +518,10 @@ ruby_init_loadpath_safe(int safe_level)
|
|||||||
#elif defined(HAVE_DLADDR)
|
#elif defined(HAVE_DLADDR)
|
||||||
sopath = dladdr_path((void *)(VALUE)expand_include_path);
|
sopath = dladdr_path((void *)(VALUE)expand_include_path);
|
||||||
libpath = RSTRING_PTR(sopath);
|
libpath = RSTRING_PTR(sopath);
|
||||||
|
#else
|
||||||
|
# error relative load path is not supported on this platform.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !VARIABLE_LIBPATH
|
|
||||||
libpath[sizeof(libpath) - 1] = '\0';
|
|
||||||
#endif
|
|
||||||
#if defined DOSISH && !defined _WIN32
|
#if defined DOSISH && !defined _WIN32
|
||||||
translit_char(libpath, '\\', '/');
|
translit_char(libpath, '\\', '/');
|
||||||
#elif defined __CYGWIN__
|
#elif defined __CYGWIN__
|
||||||
@ -581,27 +571,13 @@ ruby_init_loadpath_safe(int safe_level)
|
|||||||
if (p) goto multiarch;
|
if (p) goto multiarch;
|
||||||
p = p2;
|
p = p2;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
#if !VARIABLE_LIBPATH
|
|
||||||
*p = 0;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#if !VARIABLE_LIBPATH
|
|
||||||
else {
|
|
||||||
strlcpy(libpath, ".", sizeof(libpath));
|
|
||||||
p = libpath + 1;
|
|
||||||
}
|
|
||||||
baselen = p - libpath;
|
|
||||||
#define PREFIX_PATH() rb_str_new(libpath, baselen)
|
|
||||||
#else
|
|
||||||
baselen = p - libpath;
|
baselen = p - libpath;
|
||||||
rb_str_resize(sopath, baselen);
|
rb_str_resize(sopath, baselen);
|
||||||
libpath = RSTRING_PTR(sopath);
|
libpath = RSTRING_PTR(sopath);
|
||||||
#define PREFIX_PATH() sopath
|
#define PREFIX_PATH() sopath
|
||||||
#endif
|
|
||||||
|
|
||||||
#define BASEPATH() rb_str_buf_cat(rb_str_buf_new(baselen+len), libpath, baselen)
|
#define BASEPATH() rb_str_buf_cat(rb_str_buf_new(baselen+len), libpath, baselen)
|
||||||
|
|
||||||
#define RUBY_RELATIVE(path, len) rb_str_buf_cat(BASEPATH(), (path), (len))
|
#define RUBY_RELATIVE(path, len) rb_str_buf_cat(BASEPATH(), (path), (len))
|
||||||
#else
|
#else
|
||||||
const size_t exec_prefix_len = strlen(ruby_exec_prefix);
|
const size_t exec_prefix_len = strlen(ruby_exec_prefix);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user