summaryrefslogtreecommitdiff
path: root/ruby.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-02-21 03:45:07 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-02-21 03:45:07 +0000
commit74016f1842e1c741faf14a5c07988112dc4978fa (patch)
treeb882c35a28e98dbdebcdffb954d0edaec5b93a3e /ruby.c
parent739c8ffcee36f8e6df4a55fbfaf8a4e015e6c44a (diff)
ruby.c: fix for multiarch library
* ruby.c (ruby_init_loadpath_safe): try two levels upper for stripping libdir name. [Bug #7874] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39348 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ruby.c')
-rw-r--r--ruby.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/ruby.c b/ruby.c
index f8b05f7..af4cf45 100644
--- a/ruby.c
+++ b/ruby.c
@@ -464,15 +464,30 @@ ruby_init_loadpath_safe(int safe_level)
#endif
const ptrdiff_t bindir_len = (ptrdiff_t)sizeof(bindir) - 1;
const ptrdiff_t libdir_len = (ptrdiff_t)sizeof(libdir) - 1;
- *p = 0;
- if (p - libpath >= bindir_len && !STRCASECMP(p - bindir_len, bindir)) {
+
+#ifdef ENABLE_MULTIARCH
+ char *p2 = NULL;
+
+ multiarch:
+#endif
+ if (p - libpath >= bindir_len && !STRNCASECMP(p - bindir_len, bindir, bindir_len)) {
p -= bindir_len;
- *p = 0;
}
- else if (p - libpath >= libdir_len && !strcmp(p - libdir_len, libdir)) {
+ else if (p - libpath >= libdir_len && !strncmp(p - libdir_len, libdir, libdir_len)) {
p -= libdir_len;
- *p = 0;
}
+#ifdef ENABLE_MULTIARCH
+ else if (p2) {
+ p = p2;
+ }
+ else {
+ p2 = p;
+ p = rb_enc_path_last_separator(libpath, p, rb_ascii8bit_encoding());
+ if (p) goto multiarch;
+ p = p2;
+ }
+#endif
+ *p = 0;
}
#if !VARIABLE_LIBPATH
else {