なかだです。

At Wed, 4 Feb 2009 19:14:16 +0900,
Tanaka Akira wrote in [ruby-dev:37902]:
> > 「1.9.2 にしたのは」というのはrubyのバージョン番号の話ですよ
> > ね。
> > $LOAD_PATHなりsoバージョンなりを変えるつもりがなかったのであ
> > れば、まずは速やかにこれらを1.9.1に戻すべきだと思います。
> 
> たしかにそうですね。LOAD_PATH などを 1.9.2 に変えなければな
> らないという意図はありません。
> 
> はっきりした意図があるのは ruby -v で出るものについてです。

今まで使っていなかったRUBY_VERSION_{MAJOR,MINOR,TEENY}をライブラリ用に
流用してみました。


Index: configure.in =================================================================== --- configure.in (revision 22030) +++ configure.in (working copy) @@ -2013,12 +2013,24 @@ AC_ARG_WITH(ruby-version, [ruby_version=$withval], [ruby_version=full]) +unset RUBY_LIB_VERSION case "$ruby_version" in full) - ruby_version="${MAJOR}.${MINOR}.${TEENY}" + RUBY_LIB_VERSION='STRINGIZE(RUBY_VERSION_MAJOR)"."STRINGIZE(RUBY_VERSION_MINOR)"."STRINGIZE(RUBY_VERSION_TEENY)' ;; minor) - ruby_version="${MAJOR}.${MINOR}" + RUBY_LIB_VERSION='STRINGIZE(RUBY_VERSION_MAJOR)"."STRINGIZE(RUBY_VERSION_MINOR)' ;; esac +if test ${RUBY_LIB_VERSION+set}; then + { + echo '#include "version.h"' + echo "ruby_version=${RUBY_LIB_VERSION}" + } > conftest.c + xxx="`$CPP -I"${srcdir}" -D'STRINGIZE(x)=x' conftest.c | grep '^ruby_version='`" + echo "$xxx" 1>&2 + eval "$xxx" +else + RUBY_LIB_VERSION="\"${ruby_version}\"" +fi AC_ARG_WITH(sitedir, @@ -2046,13 +2058,35 @@ case "$target_os" in ;; esac -RUBY_LIB_PATH="${RUBY_LIB_PREFIX}/${ruby_version}" -RUBY_SITE_LIB_PATH2="${RUBY_SITE_LIB_PATH}/${ruby_version}" -RUBY_VENDOR_LIB_PATH2="${RUBY_VENDOR_LIB_PATH}/${ruby_version}" - -AC_DEFINE_UNQUOTED(RUBY_LIB, "${RUBY_LIB_PATH}") -AC_DEFINE_UNQUOTED(RUBY_SITE_LIB, "${RUBY_SITE_LIB_PATH}") -AC_DEFINE_UNQUOTED(RUBY_SITE_LIB2, "${RUBY_SITE_LIB_PATH2}") -AC_DEFINE_UNQUOTED(RUBY_VENDOR_LIB, "${RUBY_VENDOR_LIB_PATH}") -AC_DEFINE_UNQUOTED(RUBY_VENDOR_LIB2, "${RUBY_VENDOR_LIB_PATH2}") +RUBY_LIB_PATH='RUBY_LIB_PREFIX"/"RUBY_LIB_VERSION' +case "$RUBY_SITE_LIB_PATH" in + dnl ( + "$RUBY_LIB_PREFIX/"*) + RUBY_SITE_LIB_PATH='RUBY_LIB_PREFIX"/'"`expr \"$RUBY_SITE_LIB_PATH\" : \"$RUBY_LIB_PREFIX/\"'\(.*\)'`"'"' + ;; + dnl ( + *) + RUBY_SITE_LIB_PATH="\"${RUBY_SITE_LIB_PATH}\"" + ;; +esac +RUBY_SITE_LIB_PATH2='RUBY_SITE_LIB"/"RUBY_LIB_VERSION' +case "$RUBY_VENDOR_LIB_PATH" in + dnl ( + "$RUBY_LIB_PREFIX/"*) + RUBY_VENDOR_LIB_PATH='RUBY_LIB_PREFIX"/'"`expr \"$RUBY_VENDOR_LIB_PATH\" : \"$RUBY_LIB_PREFIX/\"'\(.*\)'`"'"' + ;; + dnl ( + *) + RUBY_VENDOR_LIB_PATH="\"${RUBY_VENDOR_LIB_PATH}\"" + ;; +esac +RUBY_VENDOR_LIB_PATH2='RUBY_VENDOR_LIB"/"RUBY_LIB_VERSION' + +AC_DEFINE_UNQUOTED(RUBY_LIB_VERSION, ${RUBY_LIB_VERSION}) +AC_DEFINE_UNQUOTED(RUBY_LIB_PREFIX, "${RUBY_LIB_PREFIX}") +AC_DEFINE_UNQUOTED(RUBY_LIB, ${RUBY_LIB_PATH}) +AC_DEFINE_UNQUOTED(RUBY_SITE_LIB, ${RUBY_SITE_LIB_PATH}) +AC_DEFINE_UNQUOTED(RUBY_SITE_LIB2, ${RUBY_SITE_LIB_PATH2}) +AC_DEFINE_UNQUOTED(RUBY_VENDOR_LIB, ${RUBY_VENDOR_LIB_PATH}) +AC_DEFINE_UNQUOTED(RUBY_VENDOR_LIB2, ${RUBY_VENDOR_LIB_PATH2}) AC_SUBST(arch)dnl @@ -2067,13 +2101,8 @@ AC_SUBST(configure_args)dnl if test "$fat_binary" != no ; then arch="fat-${target_os}" - - AC_DEFINE_UNQUOTED(RUBY_THIN_ARCHLIB, - "${RUBY_LIB_PATH}/" __ARCHITECTURE__ "-${target_os}") - - AC_DEFINE_UNQUOTED(RUBY_SITE_THIN_ARCHLIB, - "${RUBY_SITE_LIB_PATH}/" __ARCHITECTURE__ "-${target_os}") - AC_DEFINE_UNQUOTED(RUBY_VENDOR_THIN_ARCHLIB, - "${RUBY_VENDOR_LIB_PATH}/" __ARCHITECTURE__ "-${target_os}") - AC_DEFINE_UNQUOTED(RUBY_PLATFORM, __ARCHITECTURE__ "-${target_os}") + AC_DEFINE_UNQUOTED(RUBY_THIN_ARCHLIB, RUBY_LIB"/"RUBY_PLATFORM) + AC_DEFINE_UNQUOTED(RUBY_SITE_THIN_ARCHLIB, RUBY_SITE_LIB"/"RUBY_PLATFORM) + AC_DEFINE_UNQUOTED(RUBY_VENDOR_THIN_ARCHLIB, RUBY_VENDOR_LIB"/"RUBY_PLATFORM) + AC_DEFINE_UNQUOTED(RUBY_PLATFORM, __ARCHITECTURE__"-${target_os}") else arch="${target_cpu}-${target_os}" @@ -2081,12 +2110,13 @@ else fi +unset sitearch case "$target_os" in mingw*) sitearch="$target_cpu-$rb_cv_msvcrt" ;; - *) sitearch="${arch}" ;; esac +test ${sitearch+set} && AC_DEFINE_UNQUOTED(RUBY_SITEARCH, "${sitearch}") -AC_DEFINE_UNQUOTED(RUBY_ARCHLIB, "${RUBY_LIB_PATH}/${arch}") -AC_DEFINE_UNQUOTED(RUBY_SITE_ARCHLIB, "${RUBY_SITE_LIB_PATH2}/${sitearch}") -AC_DEFINE_UNQUOTED(RUBY_VENDOR_ARCHLIB, "${RUBY_VENDOR_LIB_PATH2}/${sitearch}") +AC_DEFINE_UNQUOTED(RUBY_ARCHLIB, RUBY_LIB"/"RUBY_ARCH) +AC_DEFINE_UNQUOTED(RUBY_SITE_ARCHLIB, RUBY_SITE_LIB2"/"RUBY_SITEARCH) +AC_DEFINE_UNQUOTED(RUBY_VENDOR_ARCHLIB, RUBY_VENDOR_LIB2"/"RUBY_SITEARCH) AC_ARG_WITH(search-path, Index: ruby.c =================================================================== --- ruby.c (revision 22030) +++ ruby.c (working copy) @@ -360,4 +360,6 @@ ruby_init_loadpath_safe(int safe_level) { VALUE load_path; + extern const char ruby_initial_load_paths[]; + const char *paths = ruby_initial_load_paths; #if defined LOAD_RELATIVE char libpath[MAXPATHLEN + 1]; @@ -396,5 +398,5 @@ ruby_init_loadpath_safe(int safe_level) rest = sizeof(libpath) - 1 - (p - libpath); -#define RUBY_RELATIVE(path) (strncpy(p, (path), rest), libpath) +#define RUBY_RELATIVE(path) (strlcpy(p, (path), rest), libpath) #else #define RUBY_RELATIVE(path) (path) @@ -407,27 +409,8 @@ ruby_init_loadpath_safe(int safe_level) } -#ifdef RUBY_SEARCH_PATH - incpush(RUBY_RELATIVE(RUBY_SEARCH_PATH)); -#endif - - incpush(RUBY_RELATIVE(RUBY_SITE_LIB2)); -#ifdef RUBY_SITE_THIN_ARCHLIB - incpush(RUBY_RELATIVE(RUBY_SITE_THIN_ARCHLIB)); -#endif - incpush(RUBY_RELATIVE(RUBY_SITE_ARCHLIB)); - incpush(RUBY_RELATIVE(RUBY_SITE_LIB)); - - incpush(RUBY_RELATIVE(RUBY_VENDOR_LIB2)); -#ifdef RUBY_VENDOR_THIN_ARCHLIB - incpush(RUBY_RELATIVE(RUBY_VENDOR_THIN_ARCHLIB)); -#endif - incpush(RUBY_RELATIVE(RUBY_VENDOR_ARCHLIB)); - incpush(RUBY_RELATIVE(RUBY_VENDOR_LIB)); - - incpush(RUBY_RELATIVE(RUBY_LIB)); -#ifdef RUBY_THIN_ARCHLIB - incpush(RUBY_RELATIVE(RUBY_THIN_ARCHLIB)); -#endif - incpush(RUBY_RELATIVE(RUBY_ARCHLIB)); + while (*paths) { + incpush(RUBY_RELATIVE(paths)); + paths += strlen(paths) + 1; + } if (safe_level == 0) { Index: version.c =================================================================== --- version.c (revision 22030) +++ version.c (working copy) @@ -17,4 +17,11 @@ #define MKSTR(type) rb_obj_freeze(rb_usascii_str_new(ruby_##type, sizeof(ruby_##type)-1)) +#ifndef RUBY_ARCH +#define RUBY_ARCH RUBY_PLATFORM +#endif +#ifndef RUBY_SITEARCH +#define RUBY_SITEARCH RUBY_ARCH +#endif + const char ruby_version[] = RUBY_VERSION; const char ruby_release_date[] = RUBY_RELEASE_DATE; @@ -25,4 +32,28 @@ const char ruby_copyright[] = RUBY_COPYR const char ruby_engine[] = "ruby"; +const char ruby_initial_load_paths[] = +#ifdef RUBY_SEARCH_PATH + RUBY_SEARCH_PATH "\0" +#endif + RUBY_SITE_LIB2 "\0" +#ifdef RUBY_SITE_THIN_ARCHLIB + RUBY_SITE_THIN_ARCHLIB "\0" +#endif + RUBY_SITE_ARCHLIB "\0" + RUBY_SITE_LIB "\0" + + RUBY_VENDOR_LIB2 "\0" +#ifdef RUBY_VENDOR_THIN_ARCHLIB + RUBY_VENDOR_THIN_ARCHLIB "\0" +#endif + RUBY_VENDOR_ARCHLIB "\0" + RUBY_VENDOR_LIB "\0" + + RUBY_LIB "\0" +#ifdef RUBY_THIN_ARCHLIB + RUBY_THIN_ARCHLIB "\0" +#endif + RUBY_ARCHLIB "\0"; + void Init_version(void) Index: version.h =================================================================== --- version.h (revision 22030) +++ version.h (working copy) @@ -6,5 +6,5 @@ #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 9 -#define RUBY_VERSION_TEENY 2 +#define RUBY_VERSION_TEENY 1 #define RUBY_RELEASE_YEAR 2009 #define RUBY_RELEASE_MONTH 2
-- --- 僕の前にBugはない。 --- 僕の後ろにBugはできる。 中田 伸悦