1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* ruby.c (ruby_init_loadpath_safe): expands libpath and removes

last /lib.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22881 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2009-03-10 21:12:49 +00:00
parent 8231655dea
commit 745bc1fd83
2 changed files with 8 additions and 3 deletions

View file

@ -1,3 +1,8 @@
Wed Mar 11 06:12:47 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ruby.c (ruby_init_loadpath_safe): expands libpath and removes
last /lib.
Wed Mar 11 04:47:47 2009 Nobuyoshi Nakada <nobu@ruby-lang.org> Wed Mar 11 04:47:47 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* time.c (time_to_i, time_hash): time_t may be bigger than long * time.c (time_to_i, time_hash): time_t may be bigger than long

6
ruby.c
View file

@ -348,15 +348,15 @@ ruby_init_loadpath_safe(int safe_level)
char *p; char *p;
int baselen; int baselen;
libpath[0] = '\0';
#if defined _WIN32 || defined __CYGWIN__ #if defined _WIN32 || defined __CYGWIN__
GetModuleFileName(libruby, libpath, sizeof libpath); GetModuleFileName(libruby, libpath, sizeof libpath);
#elif defined(__EMX__) #elif defined(__EMX__)
_execname(libpath, sizeof(libpath) - 1); _execname(libpath, sizeof(libpath) - 1);
#elif defined(HAVE_DLADDR) #elif defined(HAVE_DLADDR)
Dl_info dli; Dl_info dli;
libpath[0] = '\0';
if (dladdr(expand_include_path, &dli)) { if (dladdr(expand_include_path, &dli)) {
strlcpy(libpath, dli.dli_fname, sizeof(libpath)); realpath(dli.dli_fname, libpath);
} }
#endif #endif
@ -373,7 +373,7 @@ ruby_init_loadpath_safe(int safe_level)
p = strrchr(libpath, '/'); p = strrchr(libpath, '/');
if (p) { if (p) {
*p = 0; *p = 0;
if (p - libpath > 3 && !STRCASECMP(p - 4, "/bin")) { if (p - libpath > 3 && !(STRCASECMP(p - 4, "/bin") && strcmp(p - 4, "/lib"))) {
p -= 4; p -= 4;
*p = 0; *p = 0;
} }