-From e943a89efd63dcfb80a0ab8d9a4db37f523f508e Mon Sep 17 00:00:00 2001
+From e24d97c938c481450ed80ec83e5399595946c1ae Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch@redhat.com>
Date: Fri, 8 Feb 2013 22:48:41 +0100
Subject: [PATCH] Prevent duplicated paths when empty version string is
configured.
---
- configure.in | 3 +++
- version.c | 10 ++++++++++
- 2 files changed, 13 insertions(+)
+ configure.in | 3 ++-
+ loadpath.c | 12 ++++++++++++
+ tool/mkconfig.rb | 2 +-
+ 3 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/configure.in b/configure.in
-index 5850bbf..7604bb8 100644
+index db37cd6..ce8d149 100644
--- a/configure.in
+++ b/configure.in
-@@ -3367,6 +3367,9 @@ unexpand_shvar exec_prefix prefix
- if test ${RUBY_LIB_VERSION_STYLE+set}; then
- AC_DEFINE_UNQUOTED(RUBY_LIB_VERSION_STYLE, $RUBY_LIB_VERSION_STYLE !<verconf>!)
- else
-+ if test "x${ruby_version}" = 'x'; then
-+ AC_DEFINE(RUBY_LIB_VERSION_BLANK, 1)
-+ fi
- AC_DEFINE_UNQUOTED(RUBY_LIB_VERSION, [$RUBY_LIB_VERSION] !<verconf>!)
+@@ -4228,7 +4228,8 @@ AS_CASE(["$ruby_version_dir_name"],
+ ruby_version_dir=/'${ruby_version_dir_name}'
+
+ if test -z "${ruby_version_dir_name}"; then
+- AC_MSG_ERROR([No ruby version, No place for bundled libraries])
++ unset ruby_version_dir
++ AC_DEFINE(RUBY_LIB_VERSION_BLANK, 1)
fi
- AC_DEFINE_UNQUOTED(RUBY_EXEC_PREFIX, ${RUBY_EXEC_PREFIX})
-diff --git a/version.c b/version.c
-index 282960d..54c4513 100644
---- a/version.c
-+++ b/version.c
-@@ -39,9 +39,15 @@
- #define RUBY_VENDOR_LIB RUBY_LIB_PREFIX"/vendor_ruby"
- #endif
+ rubylibdir='${rubylibprefix}'${ruby_version_dir}
+diff --git a/loadpath.c b/loadpath.c
+index 9160031..0d4d953 100644
+--- a/loadpath.c
++++ b/loadpath.c
+@@ -65,22 +65,34 @@ const char ruby_initial_load_paths[] =
+ RUBY_SEARCH_PATH "\0"
+ #endif
+ #ifndef NO_RUBY_SITE_LIB
+#ifdef RUBY_LIB_VERSION_BLANK
-+#define RUBY_LIB RUBY_LIB_PREFIX
-+#define RUBY_SITE_LIB2 RUBY_SITE_LIB
-+#define RUBY_VENDOR_LIB2 RUBY_VENDOR_LIB
++ RUBY_SITE_LIB "\0"
+#else
- #define RUBY_LIB RUBY_LIB_PREFIX "/"RUBY_LIB_VERSION
- #define RUBY_SITE_LIB2 RUBY_SITE_LIB "/"RUBY_LIB_VERSION
- #define RUBY_VENDOR_LIB2 RUBY_VENDOR_LIB "/"RUBY_LIB_VERSION
+ RUBY_SITE_LIB2 "\0"
+#endif
- #ifndef RUBY_ARCH_LIB_FOR
- #define RUBY_ARCH_LIB_FOR(arch) RUBY_LIB "/"arch
- #endif
-@@ -77,8 +83,10 @@ const char ruby_initial_load_paths[] =
+ #ifdef RUBY_THINARCH
RUBY_SITE_ARCH_LIB_FOR(RUBY_THINARCH) "\0"
#endif
RUBY_SITE_ARCH_LIB_FOR(RUBY_SITEARCH) "\0"
+#endif
#ifndef NO_RUBY_VENDOR_LIB
++#ifdef RUBY_LIB_VERSION_BLANK
++ RUBY_VENDOR_LIB "\0"
++#else
RUBY_VENDOR_LIB2 "\0"
-@@ -86,8 +94,10 @@ const char ruby_initial_load_paths[] =
++#endif
+ #ifdef RUBY_THINARCH
RUBY_VENDOR_ARCH_LIB_FOR(RUBY_THINARCH) "\0"
#endif
RUBY_VENDOR_ARCH_LIB_FOR(RUBY_SITEARCH) "\0"
RUBY_LIB "\0"
#ifdef RUBY_THINARCH
+diff --git a/tool/mkconfig.rb b/tool/mkconfig.rb
+index 07076d4..35e6c3c 100755
+--- a/tool/mkconfig.rb
++++ b/tool/mkconfig.rb
+@@ -122,7 +122,7 @@ def config.write(arg)
+ val = val.gsub(/\$(?:\$|\{?(\w+)\}?)/) {$1 ? "$(#{$1})" : $&}.dump
+ case name
+ when /^prefix$/
+- val = "(TOPDIR || DESTDIR + #{val})"
++ val = "(((TOPDIR && TOPDIR.empty?) ? nil : TOPDIR) || DESTDIR + #{val})"
+ when /^ARCH_FLAG$/
+ val = "arch_flag || #{val}" if universal
+ when /^UNIVERSAL_ARCHNAMES$/
--
-1.8.1.2
+1.9.0