From 2b4becd6bc377b23375b59a0d31afb2c559273b6 Mon Sep 17 00:00:00 2001 From: naruse Date: Mon, 27 Jan 2014 07:47:11 +0000 Subject: [PATCH 001/343] merge revision(s) 44402: [Backport #9301] * ext/openssl/ossl_ssl.c (Init_ossl_ssl): Declare a constant `OP_MSIE_SSLV2_RSA_PADDING` only if the macro is defined. The `SSL_OP_MSIE_SSLV2_RSA_PADDING` has been removed from latest snapshot of OpenSSL 1.0.1. [Fixes GH-488] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@44710 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ ext/openssl/ossl_ssl.c | 2 ++ version.h | 6 +++--- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index e7f0cc4a1f070c..8db20d22286c02 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Mon Jan 27 16:45:34 2014 Yamashita Yuu + + * ext/openssl/ossl_ssl.c (Init_ossl_ssl): Declare a constant + `OP_MSIE_SSLV2_RSA_PADDING` only if the macro is defined. The + `SSL_OP_MSIE_SSLV2_RSA_PADDING` has been removed from latest + snapshot of OpenSSL 1.0.1. [Fixes GH-488] + Thu Jan 23 10:37:24 2014 Nobuyoshi Nakada * hash.c (HAS_EXTRA_STATES): warn extra states only when something diff --git a/ext/openssl/ossl_ssl.c b/ext/openssl/ossl_ssl.c index ec7135064a48c6..206470cbfe90f0 100644 --- a/ext/openssl/ossl_ssl.c +++ b/ext/openssl/ossl_ssl.c @@ -2229,7 +2229,9 @@ Init_ossl_ssl() ossl_ssl_def_const(OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG); ossl_ssl_def_const(OP_SSLREF2_REUSE_CERT_TYPE_BUG); ossl_ssl_def_const(OP_MICROSOFT_BIG_SSLV3_BUFFER); +#if defined(SSL_OP_MSIE_SSLV2_RSA_PADDING) ossl_ssl_def_const(OP_MSIE_SSLV2_RSA_PADDING); +#endif ossl_ssl_def_const(OP_SSLEAY_080_CLIENT_DH_BUG); ossl_ssl_def_const(OP_TLS_D5_BUG); ossl_ssl_def_const(OP_TLS_BLOCK_PADDING_BUG); diff --git a/version.h b/version.h index 96a672d5bbeae5..e0d16aeffb3de7 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.1" -#define RUBY_RELEASE_DATE "2014-01-23" -#define RUBY_PATCHLEVEL 8 +#define RUBY_RELEASE_DATE "2014-01-27" +#define RUBY_PATCHLEVEL 9 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 1 -#define RUBY_RELEASE_DAY 23 +#define RUBY_RELEASE_DAY 27 #include "ruby/version.h" From 16c8a6d4b4588635a9009152392d62cc0f5d29c7 Mon Sep 17 00:00:00 2001 From: naruse Date: Mon, 27 Jan 2014 07:56:58 +0000 Subject: [PATCH 002/343] merge revision(s) 44588: [Backport #9316] * ext/bigdecimal/bigdecimal.c (BigDecimal_divide): Add an additional digit for the quotient to be compatible with bigdecimal 1.2.1 and the former. [ruby-core:59365] [#9316] [#9305] * test/bigdecimal/test_bigdecimal.rb: tests for the above change. * ext/bigdecimal/bigdecimal.gemspec: bigdecimal version 1.2.4. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@44711 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 10 ++++++++++ ext/bigdecimal/bigdecimal.c | 6 ++++-- ext/bigdecimal/bigdecimal.gemspec | 2 +- test/bigdecimal/test_bigdecimal.rb | 4 ++++ version.h | 2 +- 5 files changed, 20 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8db20d22286c02..0def40481bbe0b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +Mon Jan 27 16:49:52 2014 Kenta Murata + + * ext/bigdecimal/bigdecimal.c (BigDecimal_divide): Add an additional + digit for the quotient to be compatible with bigdecimal 1.2.1 and + the former. [ruby-core:59365] [#9316] [#9305] + + * test/bigdecimal/test_bigdecimal.rb: tests for the above change. + + * ext/bigdecimal/bigdecimal.gemspec: bigdecimal version 1.2.4. + Mon Jan 27 16:45:34 2014 Yamashita Yuu * ext/openssl/ossl_ssl.c (Init_ossl_ssl): Declare a constant diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c index e0b7c01e0853d6..8537817e86b636 100644 --- a/ext/bigdecimal/bigdecimal.c +++ b/ext/bigdecimal/bigdecimal.c @@ -1221,8 +1221,10 @@ BigDecimal_divide(Real **c, Real **res, Real **div, VALUE self, VALUE r) *div = b; mx = a->Prec + vabs(a->exponent); - if (mxPrec + vabs(b->exponent)) mx = b->Prec + vabs(b->exponent); - mx =(mx + 1) * VpBaseFig(); + if (mx < b->Prec + vabs(b->exponent)) mx = b->Prec + vabs(b->exponent); + mx++; /* NOTE: An additional digit is needed for the compatibility to + the version 1.2.1 and the former. */ + mx = (mx + 1) * VpBaseFig(); GUARD_OBJ((*c), VpCreateRbObject(mx, "#0")); GUARD_OBJ((*res), VpCreateRbObject((mx+1) * 2 +(VpBaseFig() + 1), "#0")); VpDivd(*c, *res, a, b); diff --git a/ext/bigdecimal/bigdecimal.gemspec b/ext/bigdecimal/bigdecimal.gemspec index 676e05bacbff48..7be9d7275bd2fa 100644 --- a/ext/bigdecimal/bigdecimal.gemspec +++ b/ext/bigdecimal/bigdecimal.gemspec @@ -1,5 +1,5 @@ # -*- ruby -*- -_VERSION = "1.2.3" +_VERSION = "1.2.4" date = %w$Date:: $[1] Gem::Specification.new do |s| diff --git a/test/bigdecimal/test_bigdecimal.rb b/test/bigdecimal/test_bigdecimal.rb index 6fdc422fdf61e3..02bb5a51755924 100644 --- a/test/bigdecimal/test_bigdecimal.rb +++ b/test/bigdecimal/test_bigdecimal.rb @@ -701,6 +701,10 @@ def test_div assert_equal(BigDecimal::SIGN_NEGATIVE_ZERO, (BigDecimal.new("-0") / 1).sign) assert_equal(2, BigDecimal.new("2") / 1) assert_equal(-2, BigDecimal.new("2") / -1) + + assert_equal(BigDecimal('1486.868686869'), BigDecimal('1472.0') / BigDecimal('0.99'), '[ruby-core:59365] [#9316]') + + assert_equal(4.124045235, BigDecimal('0.9932') / (700 * BigDecimal('0.344045') / BigDecimal('1000.0')), '[#9305]') end def test_div_with_float diff --git a/version.h b/version.h index e0d16aeffb3de7..8ea34368f62f85 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-01-27" -#define RUBY_PATCHLEVEL 9 +#define RUBY_PATCHLEVEL 10 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 1 From 342ed0b8575498f4f566d2972174b22381c85f56 Mon Sep 17 00:00:00 2001 From: naruse Date: Thu, 30 Jan 2014 06:03:02 +0000 Subject: [PATCH 003/343] merge revision(s) 44756: * configure.in: use $@ instead of $(.TARGET) because .TARGET is not supported by GNU make. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@44757 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ configure.in | 2 +- version.h | 6 +++--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0def40481bbe0b..3766b864ae61ad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Thu Jan 30 15:02:35 2014 Shugo Maeda + + * configure.in: use $@ instead of $(.TARGET) because .TARGET is not + supported by GNU make. + Mon Jan 27 16:49:52 2014 Kenta Murata * ext/bigdecimal/bigdecimal.c (BigDecimal_divide): Add an additional diff --git a/configure.in b/configure.in index ea14b941ed2c97..68da9e3f58bd4c 100644 --- a/configure.in +++ b/configure.in @@ -2656,7 +2656,7 @@ if test "$with_dln_a_out" != yes; then : ${LDSHARED='$(CC) -shared'} if test "$rb_cv_binary_elf" = yes; then LDFLAGS="$LDFLAGS -rdynamic" - DLDFLAGS="$DLDFLAGS "'-Wl,-soname,$(.TARGET)' + DLDFLAGS="$DLDFLAGS "'-Wl,-soname,$@' else test "$GCC" = yes && test "$rb_cv_prog_gnu_ld" = yes || LDSHARED='$(LD) -Bshareable' fi diff --git a/version.h b/version.h index 8ea34368f62f85..6d8bbb872b8c8f 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.1" -#define RUBY_RELEASE_DATE "2014-01-27" -#define RUBY_PATCHLEVEL 10 +#define RUBY_RELEASE_DATE "2014-01-30" +#define RUBY_PATCHLEVEL 11 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 1 -#define RUBY_RELEASE_DAY 27 +#define RUBY_RELEASE_DAY 30 #include "ruby/version.h" From edacfadad6dc07801adcfedab4ca901775ecd909 Mon Sep 17 00:00:00 2001 From: naruse Date: Fri, 31 Jan 2014 03:07:00 +0000 Subject: [PATCH 004/343] merge revision(s) 44406: [Backport #9324] * configure.in: let mingw do something black-magic, and check if _gmtime64_s() is available actually. * win32/win32.c (gmtime_s, localtime_s): use _gmtime64_s() and _localtime64_s() if available, not depending on very confusing mingw variants macros. based on the patch by phasis68 (Heesob Park) at [ruby-core:58764]. [ruby-core:58391] [Bug #9119] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@44774 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 10 ++++++++++ configure.in | 2 ++ version.h | 6 +++--- win32/win32.c | 12 ++++++++---- 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3766b864ae61ad..2dafde58451f31 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +Fri Jan 31 12:05:59 2014 Nobuyoshi Nakada + + * configure.in: let mingw do something black-magic, and check if + _gmtime64_s() is available actually. + + * win32/win32.c (gmtime_s, localtime_s): use _gmtime64_s() and + _localtime64_s() if available, not depending on very confusing + mingw variants macros. based on the patch by phasis68 (Heesob + Park) at [ruby-core:58764]. [ruby-core:58391] [Bug #9119] + Thu Jan 30 15:02:35 2014 Shugo Maeda * configure.in: use $@ instead of $(.TARGET) because .TARGET is not diff --git a/configure.in b/configure.in index 68da9e3f58bd4c..84f176dd9415be 100644 --- a/configure.in +++ b/configure.in @@ -888,6 +888,7 @@ AC_ARG_WITH(winnt-ver, AS_CASE(["$target_os"], [mingw*], [ RUBY_APPEND_OPTION(CPPFLAGS, -D_WIN32_WINNT=$with_winnt_ver) + RUBY_APPEND_OPTION(CPPFLAGS, -D__MINGW_USE_VC2005_COMPAT) ]) AS_CASE(["$target_os"], @@ -1040,6 +1041,7 @@ main() if test x"$ac_cv_type_NET_LUID" = xyes; then AC_DEFINE(HAVE_TYPE_NET_LUID, 1) fi + AC_CHECK_FUNCS(_gmtime64_s) AC_LIBOBJ([langinfo]) ], [os2-emx*], [ LIBS="-lm $LIBS" diff --git a/version.h b/version.h index 6d8bbb872b8c8f..072bf28ce92ee9 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.1" -#define RUBY_RELEASE_DATE "2014-01-30" -#define RUBY_PATCHLEVEL 11 +#define RUBY_RELEASE_DATE "2014-01-31" +#define RUBY_PATCHLEVEL 12 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 1 -#define RUBY_RELEASE_DAY 30 +#define RUBY_RELEASE_DAY 31 #include "ruby/version.h" diff --git a/win32/win32.c b/win32/win32.c index 9cbd07f6697a97..2c888ae4c4a192 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -6965,7 +6965,7 @@ rb_w32_fd_is_text(int fd) return _osfile(fd) & FTEXT; } -#if RUBY_MSVCRT_VERSION < 80 && !defined(__MINGW64__) +#if RUBY_MSVCRT_VERSION < 80 && !defined(HAVE__GMTIME64_S) /* License: Ruby's */ static int unixtime_to_systemtime(const time_t t, SYSTEMTIME *st) @@ -7027,7 +7027,11 @@ systemtime_to_localtime(TIME_ZONE_INFORMATION *tz, SYSTEMTIME *gst, SYSTEMTIME * } #endif -#ifdef __MINGW64__ +#ifdef HAVE__GMTIME64_S +# ifndef HAVE__LOCALTIME64_S +/* assume same as _gmtime64_s() */ +# define HAVE__LOCALTIME64_S 1 +# endif # ifndef MINGW_HAS_SECURE_API _CRTIMP errno_t __cdecl _gmtime64_s(struct tm* tm, const __time64_t *time); _CRTIMP errno_t __cdecl _localtime64_s(struct tm* tm, const __time64_t *time); @@ -7046,7 +7050,7 @@ gmtime_r(const time_t *tp, struct tm *rp) errno = e; return NULL; } -#if RUBY_MSVCRT_VERSION >= 80 || defined(__MINGW64__) +#if RUBY_MSVCRT_VERSION >= 80 || defined(HAVE__GMTIME64_S) e = gmtime_s(rp, tp); if (e != 0) goto error; #else @@ -7070,7 +7074,7 @@ localtime_r(const time_t *tp, struct tm *rp) errno = e; return NULL; } -#if RUBY_MSVCRT_VERSION >= 80 || defined(__MINGW64__) +#if RUBY_MSVCRT_VERSION >= 80 || defined(HAVE__LOCALTIME64_S) e = localtime_s(rp, tp); if (e) goto error; #else From 32e4d034ca81bffeb6415379eb91a4e90254c886 Mon Sep 17 00:00:00 2001 From: naruse Date: Fri, 31 Jan 2014 08:58:59 +0000 Subject: [PATCH 005/343] merge revision(s) 44455,44458,44510: [Backport #9349] * vm_insnhelper.c (vm_search_super_method): direct superclass of a module is found when super called in a Method object generated a method defined in a module, call method_missing in that case. [ruby-core:59358] [Bug #9315] * proc.c (mnew_from_me): keep iclass as-is, to make inheritance chain consistent. [ruby-core:59358] [Bug #9315] * proc.c (method_owner): return the original defined_class from prepended iclass, instead. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@44777 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ proc.c | 13 ++++++++----- test/ruby/test_super.rb | 33 +++++++++++++++++++++++++++++++++ version.h | 2 +- 4 files changed, 50 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2dafde58451f31..601436f3261c95 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Fri Jan 31 12:10:16 2014 Nobuyoshi Nakada + + * proc.c (mnew_from_me): keep iclass as-is, to make inheritance + chain consistent. [ruby-core:59358] [Bug #9315] + + * proc.c (method_owner): return the original defined_class from + prepended iclass, instead. + Fri Jan 31 12:05:59 2014 Nobuyoshi Nakada * configure.in: let mingw do something black-magic, and check if diff --git a/proc.c b/proc.c index f8b2e3b3a9012f..e52beaf9d813d4 100644 --- a/proc.c +++ b/proc.c @@ -1171,10 +1171,6 @@ mnew_from_me(rb_method_entry_t *me, VALUE defined_class, VALUE klass, goto again; } - if (RB_TYPE_P(defined_class, T_ICLASS)) { - defined_class = RBASIC_CLASS(defined_class); - } - klass = defined_class; while (rclass != klass && @@ -1396,9 +1392,16 @@ static VALUE method_owner(VALUE obj) { struct METHOD *data; + VALUE defined_class; TypedData_Get_Struct(obj, struct METHOD, &method_data_type, data); - return data->defined_class; + defined_class = data->defined_class; + + if (RB_TYPE_P(defined_class, T_ICLASS)) { + defined_class = RBASIC_CLASS(defined_class); + } + + return defined_class; } void diff --git a/test/ruby/test_super.rb b/test/ruby/test_super.rb index 846f40946db9b6..c5f724ebb8c900 100644 --- a/test/ruby/test_super.rb +++ b/test/ruby/test_super.rb @@ -407,4 +407,37 @@ def test_super_splat assert_equal([false, false], y.foo(false, false)) assert_equal([1, 2, 3, false, 5], y.foo(1, 2, 3, false, 5)) end + + def test_missing_super_in_method_module + bug9315 = '[ruby-core:59358] [Bug #9315]' + a = Module.new do + def foo + super + end + end + b = Class.new do + include a + end + assert_raise(NoMethodError, bug9315) do + b.new.method(:foo).call + end + end + + def test_module_super_in_method_module + bug9315 = '[ruby-core:59589] [Bug #9315]' + a = Module.new do + def foo + super + end + end + c = Class.new do + def foo + :ok + end + end + o = c.new.extend(a) + assert_nothing_raised(NoMethodError, bug9315) do + assert_equal(:ok, o.method(:foo).call, bug9315) + end + end end diff --git a/version.h b/version.h index 072bf28ce92ee9..c361122024b2b0 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-01-31" -#define RUBY_PATCHLEVEL 12 +#define RUBY_PATCHLEVEL 13 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 1 From 3efb494a213df6393a6f9aa83297e06bd68faa5e Mon Sep 17 00:00:00 2001 From: naruse Date: Fri, 31 Jan 2014 09:17:42 +0000 Subject: [PATCH 006/343] merge revision(s) 44515: [Backport #9375] * lib/rubygems: Update to RubyGems master 21e409d / RubyGems 2.2.1. See http://rubygems.rubyforge.org/rubygems-update/History_txt.html for a list of bug fixes. * test/rubygems: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@44778 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 9 ++ NEWS | 2 + lib/rubygems.rb | 19 ++-- lib/rubygems/basic_specification.rb | 18 ++++ lib/rubygems/commands/contents_command.rb | 6 +- lib/rubygems/commands/install_command.rb | 20 ++-- lib/rubygems/commands/setup_command.rb | 16 +-- lib/rubygems/compatibility.rb | 4 +- lib/rubygems/defaults.rb | 20 ++-- lib/rubygems/deprecate.rb | 2 +- lib/rubygems/installer.rb | 4 +- lib/rubygems/platform.rb | 2 +- lib/rubygems/rdoc.rb | 2 +- lib/rubygems/request_set/lockfile.rb | 7 +- lib/rubygems/resolver.rb | 21 ---- lib/rubygems/resolver/installer_set.rb | 35 +----- lib/rubygems/specification.rb | 2 +- lib/rubygems/test_case.rb | 12 +-- lib/rubygems/uninstaller.rb | 2 +- test/rubygems/test_gem.rb | 102 +++++++++++------- .../test_gem_commands_contents_command.rb | 6 +- .../test_gem_commands_environment_command.rb | 2 +- .../test_gem_commands_install_command.rb | 15 +++ .../test_gem_commands_update_command.rb | 2 +- .../rubygems/test_gem_dependency_installer.rb | 2 +- test/rubygems/test_gem_installer.rb | 8 +- .../rubygems/test_gem_request_set_lockfile.rb | 10 +- test/rubygems/test_gem_specification.rb | 50 ++++++++- test/rubygems/test_gem_uninstaller.rb | 17 +++ version.h | 2 +- 30 files changed, 256 insertions(+), 163 deletions(-) diff --git a/ChangeLog b/ChangeLog index 601436f3261c95..e88b8e13949c57 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Fri Jan 31 18:13:43 2014 Eric Hodel + + * lib/rubygems: Update to RubyGems master 21e409d / RubyGems 2.2.1. + + See http://rubygems.rubyforge.org/rubygems-update/History_txt.html + for a list of bug fixes. + + * test/rubygems: ditto. + Fri Jan 31 12:10:16 2014 Nobuyoshi Nakada * proc.c (mnew_from_me): keep iclass as-is, to make inheritance diff --git a/NEWS b/NEWS index a096ad9d28fc85..f622b9f2ed3ff8 100644 --- a/NEWS +++ b/NEWS @@ -276,6 +276,8 @@ String * Improved, iterative resolver (compared to RubyGems 2.1 and earlier) * Support for a sharing a GEM_HOME across ruby platforms and versions + * Updated to 2.2.1. Fixes some minor bugs and performance regressions. + For a complete list of enhancements and bug fixes see: https://github.com/rubygems/rubygems/tree/master/History.txt diff --git a/lib/rubygems.rb b/lib/rubygems.rb index 73c4846f8274de..7afc85bda5174d 100644 --- a/lib/rubygems.rb +++ b/lib/rubygems.rb @@ -8,7 +8,7 @@ require 'rbconfig' module Gem - VERSION = '2.2.0' + VERSION = '2.2.1' end # Must be first since it unloads the prelude from 1.9.2 @@ -572,7 +572,7 @@ def self.host= host # gem's paths are inserted before site lib directory by default. def self.load_path_insert_index - index = $LOAD_PATH.index ConfigMap[:sitelibdir] + index = $LOAD_PATH.index RbConfig::CONFIG['sitelibdir'] index end @@ -743,8 +743,8 @@ def self.pre_uninstall(&hook) def self.prefix prefix = File.dirname RUBYGEMS_DIR - if prefix != File.expand_path(ConfigMap[:sitelibdir]) and - prefix != File.expand_path(ConfigMap[:libdir]) and + if prefix != File.expand_path(RbConfig::CONFIG['sitelibdir']) and + prefix != File.expand_path(RbConfig::CONFIG['libdir']) and 'lib' == File.basename(RUBYGEMS_DIR) then prefix end @@ -765,6 +765,10 @@ def self.read_binary(path) f.flock(File::LOCK_EX) f.read end + rescue Errno::EACCES + open path, 'rb' do |f| + f.read + end end ## @@ -772,8 +776,8 @@ def self.read_binary(path) def self.ruby if @ruby.nil? then - @ruby = File.join(ConfigMap[:bindir], - "#{ConfigMap[:ruby_install_name]}#{ConfigMap[:EXEEXT]}") + @ruby = File.join(RbConfig::CONFIG['bindir'], + "#{RbConfig::CONFIG['ruby_install_name']}#{RbConfig::CONFIG['EXEEXT']}") @ruby = "\"#{@ruby}\"" if @ruby =~ /\s/ end @@ -785,8 +789,7 @@ def self.ruby # Returns a String containing the API compatibility version of Ruby def self.ruby_api_version - @ruby_api_version ||= - "#{ConfigMap[:MAJOR]}.#{ConfigMap[:MINOR]}.#{ConfigMap[:TEENY]}" + @ruby_api_version ||= RbConfig::CONFIG['ruby_version'].dup end ## diff --git a/lib/rubygems/basic_specification.rb b/lib/rubygems/basic_specification.rb index a52377ff22e067..470a6ebc8b5c43 100644 --- a/lib/rubygems/basic_specification.rb +++ b/lib/rubygems/basic_specification.rb @@ -206,6 +206,24 @@ def require_paths [relative_extension_dir].concat @require_paths end + ## + # Returns the paths to the source files for use with analysis and + # documentation tools. These paths are relative to full_gem_path. + + def source_paths + paths = raw_require_paths.dup + + if @extensions then + ext_dirs = @extensions.map do |extension| + extension.split(File::SEPARATOR, 2).first + end.uniq + + paths.concat ext_dirs + end + + paths.uniq + end + ## # Return a Gem::Specification from this gem diff --git a/lib/rubygems/commands/contents_command.rb b/lib/rubygems/commands/contents_command.rb index 97218848edac15..603f1d072aaa6f 100644 --- a/lib/rubygems/commands/contents_command.rb +++ b/lib/rubygems/commands/contents_command.rb @@ -94,11 +94,11 @@ def files_in_default_gem spec spec.files.sort.map do |file| case file when /\A#{spec.bindir}\// - [Gem::ConfigMap[:bindir], $POSTMATCH] + [RbConfig::CONFIG['bindir'], $POSTMATCH] when /\.so\z/ - [Gem::ConfigMap[:archdir], file] + [RbConfig::CONFIG['archdir'], file] else - [Gem::ConfigMap[:rubylibdir], file] + [RbConfig::CONFIG['rubylibdir'], file] end end end diff --git a/lib/rubygems/commands/install_command.rb b/lib/rubygems/commands/install_command.rb index 4485eb12e81719..8219eef6ead096 100644 --- a/lib/rubygems/commands/install_command.rb +++ b/lib/rubygems/commands/install_command.rb @@ -228,7 +228,18 @@ def install_gem name, version # :nodoc: def install_gem_without_dependencies name, req # :nodoc: gem = nil - if remote? then + if local? then + if name =~ /\.gem$/ and File.file? name then + source = Gem::Source::SpecificFile.new name + spec = source.spec + else + source = Gem::Source::Local.new + spec = source.find_gem name, req + end + gem = source.download spec if spec + end + + if remote? and not gem then dependency = Gem::Dependency.new name, req dependency.prerelease = options[:prerelease] @@ -236,13 +247,6 @@ def install_gem_without_dependencies name, req # :nodoc: gem = fetcher.download_to_cache dependency end - if local? and not gem then - source = Gem::Source::Local.new - spec = source.find_gem name, req - - gem = source.download spec - end - inst = Gem::Installer.new gem, options inst.install diff --git a/lib/rubygems/commands/setup_command.rb b/lib/rubygems/commands/setup_command.rb index face77fae9ce28..681db0dc1d19fc 100644 --- a/lib/rubygems/commands/setup_command.rb +++ b/lib/rubygems/commands/setup_command.rb @@ -13,7 +13,7 @@ def initialize super 'setup', 'Install RubyGems', :format_executable => true, :document => %w[ri], - :site_or_vendor => :sitelibdir, + :site_or_vendor => 'sitelibdir', :destdir => '', :prefix => '', :previous_version => '' add_option '--previous-version=VERSION', @@ -36,7 +36,7 @@ def initialize add_option '--[no-]vendor', 'Install into vendorlibdir not sitelibdir' do |vendor, options| - options[:site_or_vendor] = vendor ? :vendorlibdir : :sitelibdir + options[:site_or_vendor] = vendor ? 'vendorlibdir' : 'sitelibdir' end add_option '--[no-]format-executable', @@ -343,19 +343,19 @@ def generate_default_dirs(install_destdir) site_or_vendor = options[:site_or_vendor] if prefix.empty? then - lib_dir = Gem::ConfigMap[site_or_vendor] - bin_dir = Gem::ConfigMap[:bindir] + lib_dir = RbConfig::CONFIG[site_or_vendor] + bin_dir = RbConfig::CONFIG['bindir'] else # Apple installed RubyGems into libdir, and RubyGems <= 1.1.0 gets # confused about installation location, so switch back to # sitelibdir/vendorlibdir. if defined?(APPLE_GEM_HOME) and # just in case Apple and RubyGems don't get this patched up proper. - (prefix == Gem::ConfigMap[:libdir] or + (prefix == RbConfig::CONFIG['libdir'] or # this one is important - prefix == File.join(Gem::ConfigMap[:libdir], 'ruby')) then - lib_dir = Gem::ConfigMap[site_or_vendor] - bin_dir = Gem::ConfigMap[:bindir] + prefix == File.join(RbConfig::CONFIG['libdir'], 'ruby')) then + lib_dir = RbConfig::CONFIG[site_or_vendor] + bin_dir = RbConfig::CONFIG['bindir'] else lib_dir = File.join prefix, 'lib' bin_dir = File.join prefix, 'bin' diff --git a/lib/rubygems/compatibility.rb b/lib/rubygems/compatibility.rb index 5e8618fe39c088..d06ade1fa662ba 100644 --- a/lib/rubygems/compatibility.rb +++ b/lib/rubygems/compatibility.rb @@ -33,6 +33,8 @@ class << Gem module Gem RubyGemsVersion = VERSION + # TODO remove at RubyGems 3 + RbConfigPriorities = %w[ MAJOR MINOR @@ -45,7 +47,7 @@ module Gem unless defined?(ConfigMap) ## # Configuration settings from ::RbConfig - ConfigMap = Hash.new do |cm, key| + ConfigMap = Hash.new do |cm, key| # TODO remove at RubyGems 3 cm[key] = RbConfig::CONFIG[key.to_s] end else diff --git a/lib/rubygems/defaults.rb b/lib/rubygems/defaults.rb index 715c0b71b36181..6924f48e5ade92 100644 --- a/lib/rubygems/defaults.rb +++ b/lib/rubygems/defaults.rb @@ -29,22 +29,22 @@ def self.default_spec_cache_dir def self.default_dir path = if defined? RUBY_FRAMEWORK_VERSION then [ - File.dirname(ConfigMap[:sitedir]), + File.dirname(RbConfig::CONFIG['sitedir']), 'Gems', - ConfigMap[:ruby_version] + RbConfig::CONFIG['ruby_version'] ] - elsif ConfigMap[:rubylibprefix] then + elsif RbConfig::CONFIG['rubylibprefix'] then [ - ConfigMap[:rubylibprefix], + RbConfig::CONFIG['rubylibprefix'], 'gems', - ConfigMap[:ruby_version] + RbConfig::CONFIG['ruby_version'] ] else [ - ConfigMap[:libdir], + RbConfig::CONFIG['libdir'], ruby_engine, 'gems', - ConfigMap[:ruby_version] + RbConfig::CONFIG['ruby_version'] ] end @@ -74,7 +74,7 @@ def self.default_rubygems_dirs def self.user_dir parts = [Gem.user_home, '.gem', ruby_engine] - parts << ConfigMap[:ruby_version] unless ConfigMap[:ruby_version].empty? + parts << RbConfig::CONFIG['ruby_version'] unless RbConfig::CONFIG['ruby_version'].empty? File.join parts end @@ -100,7 +100,7 @@ def self.default_path # Deduce Ruby's --program-prefix and --program-suffix from its install name def self.default_exec_format - exec_format = ConfigMap[:ruby_install_name].sub('ruby', '%s') rescue '%s' + exec_format = RbConfig::CONFIG['ruby_install_name'].sub('ruby', '%s') rescue '%s' unless exec_format =~ /%s/ then raise Gem::Exception, @@ -117,7 +117,7 @@ def self.default_bindir if defined? RUBY_FRAMEWORK_VERSION then # mac framework support '/usr/bin' else # generic install - ConfigMap[:bindir] + RbConfig::CONFIG['bindir'] end end diff --git a/lib/rubygems/deprecate.rb b/lib/rubygems/deprecate.rb index 274d6a5c12023f..e19360da13a81f 100644 --- a/lib/rubygems/deprecate.rb +++ b/lib/rubygems/deprecate.rb @@ -50,7 +50,7 @@ def deprecate name, repl, year, month class_eval { old = "_deprecated_#{name}" alias_method old, name - define_method name do |*args, &block| # TODO: really works on 1.8.7? + define_method name do |*args, &block| klass = self.kind_of? Module target = klass ? "#{self}." : "#{self.class}#" msg = [ "NOTE: #{target}#{name} is deprecated", diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb index f8eb2c2145fa1e..33d2f78d46a429 100644 --- a/lib/rubygems/installer.rb +++ b/lib/rubygems/installer.rb @@ -480,7 +480,7 @@ def generate_bin_symlink(filename, bindir) # def shebang(bin_file_name) - ruby_name = Gem::ConfigMap[:ruby_install_name] if @env_shebang + ruby_name = RbConfig::CONFIG['ruby_install_name'] if @env_shebang path = File.join gem_dir, spec.bindir, bin_file_name first_line = File.open(path, "rb") {|file| file.gets} @@ -493,7 +493,7 @@ def shebang(bin_file_name) if which = Gem.configuration[:custom_shebang] # replace bin_file_name with "ruby" to avoid endless loops - which = which.gsub(/ #{bin_file_name}$/," #{Gem::ConfigMap[:ruby_install_name]}") + which = which.gsub(/ #{bin_file_name}$/," #{RbConfig::CONFIG['ruby_install_name']}") which = which.gsub(/\$(\w+)/) do case $1 diff --git a/lib/rubygems/platform.rb b/lib/rubygems/platform.rb index e050959dc6fde5..1bcd7549ad4f79 100644 --- a/lib/rubygems/platform.rb +++ b/lib/rubygems/platform.rb @@ -16,7 +16,7 @@ class Gem::Platform attr_accessor :version def self.local - arch = Gem::ConfigMap[:arch] + arch = RbConfig::CONFIG['arch'] arch = "#{arch}_60" if arch =~ /mswin32$/ @local ||= new(arch) end diff --git a/lib/rubygems/rdoc.rb b/lib/rubygems/rdoc.rb index 52249dc267aa88..633bd893a5df0c 100644 --- a/lib/rubygems/rdoc.rb +++ b/lib/rubygems/rdoc.rb @@ -193,7 +193,7 @@ def generate ::RDoc::Parser::C.reset args = @spec.rdoc_options - args.concat @spec.require_paths + args.concat @spec.source_paths args.concat @spec.extra_rdoc_files case config_args = Gem.configuration[:rdoc] diff --git a/lib/rubygems/request_set/lockfile.rb b/lib/rubygems/request_set/lockfile.rb index 522caf15026af0..0433d2a7fc86e5 100644 --- a/lib/rubygems/request_set/lockfile.rb +++ b/lib/rubygems/request_set/lockfile.rb @@ -303,7 +303,12 @@ def parse_GEM # :nodoc: type, data, = get [:text, :requirement] if type == :text and column == 4 then - last_spec = set.add name, data, Gem::Platform::RUBY + version, platform = data.split '-', 2 + + platform = + platform ? Gem::Platform.new(platform) : Gem::Platform::RUBY + + last_spec = set.add name, version, platform else dependency = parse_dependency name, data diff --git a/lib/rubygems/resolver.rb b/lib/rubygems/resolver.rb index d455e03c0576fb..15a96693e95275 100644 --- a/lib/rubygems/resolver.rb +++ b/lib/rubygems/resolver.rb @@ -178,27 +178,6 @@ def resolve res.to_a end - ## - # Finds the State in +states+ that matches the +conflict+ so that we can try - # other possible sets. - # - # If no good candidate is found, the first state is tried. - - def find_conflict_state conflict, states # :nodoc: - until states.empty? do - state = states.pop - - explain :consider, state.dep, conflict.failed_dep - - if conflict.for_spec? state.spec - state.conflicts << [state.spec, conflict] - return state - end - end - - nil - end - ## # Extracts the specifications that may be able to fulfill +dependency+ and # returns those that match the local platform and all those that match. diff --git a/lib/rubygems/resolver/installer_set.rb b/lib/rubygems/resolver/installer_set.rb index e35e0aabecc92a..27e64551480f61 100644 --- a/lib/rubygems/resolver/installer_set.rb +++ b/lib/rubygems/resolver/installer_set.rb @@ -28,11 +28,10 @@ def initialize domain @f = Gem::SpecFetcher.fetcher - @all = Hash.new { |h,k| h[k] = [] } @always_install = [] @ignore_dependencies = false @ignore_installed = false - @loaded_remote_specs = [] + @remote_set = Gem::Resolver::BestSet.new if consider_remote? @specs = {} end @@ -79,16 +78,7 @@ def find_all req end end - if consider_remote? then - load_remote_specs dep - - @all[name].each do |remote_source, n| - if dep.match? n then - res << Gem::Resolver::IndexSpecification.new( - self, n.name, n.version, remote_source, n.platform) - end - end - end + res.concat @remote_set.find_all req if consider_remote? res end @@ -101,27 +91,6 @@ def inspect # :nodoc: ] end - ## - # Loads remote prerelease specs if +dep+ is a prerelease dependency - - def load_remote_specs dep # :nodoc: - types = [:released] - types << :prerelease if dep.prerelease? - - types.each do |type| - next if @loaded_remote_specs.include? type - @loaded_remote_specs << type - - list, = @f.available_specs type - - list.each do |uri, specs| - specs.each do |n| - @all[n.name] << [uri, n] - end - end - end - end - ## # Called from IndexSpecification to get a true Specification # object. diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb index 59d71d378bb3f7..e98f3284cd0bd2 100644 --- a/lib/rubygems/specification.rb +++ b/lib/rubygems/specification.rb @@ -327,7 +327,7 @@ def files add_bindir(@executables), @extra_rdoc_files, @extensions, - ].flatten.sort.uniq.compact + ].flatten.uniq.compact.sort end ###################################################################### diff --git a/lib/rubygems/test_case.rb b/lib/rubygems/test_case.rb index 8dc37d67204dc6..ff261f7816e796 100644 --- a/lib/rubygems/test_case.rb +++ b/lib/rubygems/test_case.rb @@ -294,10 +294,10 @@ def setup Gem.searcher = nil Gem::SpecFetcher.fetcher = nil - @orig_BASERUBY = Gem::ConfigMap[:BASERUBY] - Gem::ConfigMap[:BASERUBY] = Gem::ConfigMap[:ruby_install_name] + @orig_BASERUBY = RbConfig::CONFIG['BASERUBY'] + RbConfig::CONFIG['BASERUBY'] = RbConfig::CONFIG['ruby_install_name'] - @orig_arch = Gem::ConfigMap[:arch] + @orig_arch = RbConfig::CONFIG['arch'] if win_platform? util_set_arch 'i386-mswin32' @@ -315,8 +315,8 @@ def setup def teardown $LOAD_PATH.replace @orig_LOAD_PATH if @orig_LOAD_PATH - Gem::ConfigMap[:BASERUBY] = @orig_BASERUBY - Gem::ConfigMap[:arch] = @orig_arch + RbConfig::CONFIG['BASERUBY'] = @orig_BASERUBY + RbConfig::CONFIG['arch'] = @orig_arch if defined? Gem::RemoteFetcher then Gem::RemoteFetcher.fetcher = nil @@ -898,7 +898,7 @@ def util_make_gems(prerelease = false) # Set the platform to +arch+ def util_set_arch(arch) - Gem::ConfigMap[:arch] = arch + RbConfig::CONFIG['arch'] = arch platform = Gem::Platform.new arch Gem.instance_variable_set :@platforms, nil diff --git a/lib/rubygems/uninstaller.rb b/lib/rubygems/uninstaller.rb index 4cb2a1d33334ba..fa838333cd4543 100644 --- a/lib/rubygems/uninstaller.rb +++ b/lib/rubygems/uninstaller.rb @@ -237,7 +237,7 @@ def remove(spec) unless path_ok?(@gem_home, spec) or (@user_install and path_ok?(Gem.user_dir, spec)) then e = Gem::GemNotInHomeException.new \ - "Gem is not installed in directory #{@gem_home}" + "Gem '#{spec.full_name}' is not installed in directory #{@gem_home}" e.spec = spec raise e diff --git a/test/rubygems/test_gem.rb b/test/rubygems/test_gem.rb index 759c2fe9070759..513f2d4e58e835 100644 --- a/test/rubygems/test_gem.rb +++ b/test/rubygems/test_gem.rb @@ -199,30 +199,30 @@ def test_self_datadir_nonexistent_package end def test_self_default_exec_format - orig_RUBY_INSTALL_NAME = Gem::ConfigMap[:ruby_install_name] - Gem::ConfigMap[:ruby_install_name] = 'ruby' + orig_RUBY_INSTALL_NAME = RbConfig::CONFIG['ruby_install_name'] + RbConfig::CONFIG['ruby_install_name'] = 'ruby' assert_equal '%s', Gem.default_exec_format ensure - Gem::ConfigMap[:ruby_install_name] = orig_RUBY_INSTALL_NAME + RbConfig::CONFIG['ruby_install_name'] = orig_RUBY_INSTALL_NAME end def test_self_default_exec_format_18 - orig_RUBY_INSTALL_NAME = Gem::ConfigMap[:ruby_install_name] - Gem::ConfigMap[:ruby_install_name] = 'ruby18' + orig_RUBY_INSTALL_NAME = RbConfig::CONFIG['ruby_install_name'] + RbConfig::CONFIG['ruby_install_name'] = 'ruby18' assert_equal '%s18', Gem.default_exec_format ensure - Gem::ConfigMap[:ruby_install_name] = orig_RUBY_INSTALL_NAME + RbConfig::CONFIG['ruby_install_name'] = orig_RUBY_INSTALL_NAME end def test_self_default_exec_format_jruby - orig_RUBY_INSTALL_NAME = Gem::ConfigMap[:ruby_install_name] - Gem::ConfigMap[:ruby_install_name] = 'jruby' + orig_RUBY_INSTALL_NAME = RbConfig::CONFIG['ruby_install_name'] + RbConfig::CONFIG['ruby_install_name'] = 'jruby' assert_equal 'j%s', Gem.default_exec_format ensure - Gem::ConfigMap[:ruby_install_name] = orig_RUBY_INSTALL_NAME + RbConfig::CONFIG['ruby_install_name'] = orig_RUBY_INSTALL_NAME end def test_self_default_sources @@ -230,6 +230,7 @@ def test_self_default_sources end def test_self_detect_gemdeps + skip 'Insecure operation - chdir' if RUBY_VERSION <= "1.8.7" rubygems_gemdeps, ENV['RUBYGEMS_GEMDEPS'] = ENV['RUBYGEMS_GEMDEPS'], '-' FileUtils.mkdir_p 'detect/a/b' @@ -565,24 +566,43 @@ def test_self_prefix end def test_self_prefix_libdir - orig_libdir = Gem::ConfigMap[:libdir] - Gem::ConfigMap[:libdir] = @@project_dir + orig_libdir = RbConfig::CONFIG['libdir'] + RbConfig::CONFIG['libdir'] = @@project_dir assert_nil Gem.prefix ensure - Gem::ConfigMap[:libdir] = orig_libdir + RbConfig::CONFIG['libdir'] = orig_libdir end def test_self_prefix_sitelibdir - orig_sitelibdir = Gem::ConfigMap[:sitelibdir] - Gem::ConfigMap[:sitelibdir] = @@project_dir + orig_sitelibdir = RbConfig::CONFIG['sitelibdir'] + RbConfig::CONFIG['sitelibdir'] = @@project_dir assert_nil Gem.prefix ensure - Gem::ConfigMap[:sitelibdir] = orig_sitelibdir + RbConfig::CONFIG['sitelibdir'] = orig_sitelibdir + end + + def test_self_read_binary + open 'test', 'w' do |io| + io.write "\xCF\x80" + end + + assert_equal ["\xCF", "\x80"], Gem.read_binary('test').chars.to_a + + skip 'chmod not supported' if Gem.win_platform? + + begin + File.chmod 0444, 'test' + + assert_equal ["\xCF", "\x80"], Gem.read_binary('test').chars.to_a + ensure + File.chmod 0644, 'test' + end end def test_self_refresh + skip 'Insecure operation - mkdir' if RUBY_VERSION <= "1.8.7" util_make_gems a1_spec = @a1.spec_file @@ -602,6 +622,7 @@ def test_self_refresh end def test_self_refresh_keeps_loaded_specs_activated + skip 'Insecure operation - mkdir' if RUBY_VERSION <= "1.8.7" util_make_gems a1_spec = @a1.spec_file @@ -624,46 +645,44 @@ def test_self_refresh_keeps_loaded_specs_activated def test_self_ruby_escaping_spaces_in_path orig_ruby = Gem.ruby - orig_bindir = Gem::ConfigMap[:bindir] - orig_ruby_install_name = Gem::ConfigMap[:ruby_install_name] - orig_exe_ext = Gem::ConfigMap[:EXEEXT] + orig_bindir = RbConfig::CONFIG['bindir'] + orig_ruby_install_name = RbConfig::CONFIG['ruby_install_name'] + orig_exe_ext = RbConfig::CONFIG['EXEEXT'] - Gem::ConfigMap[:bindir] = "C:/Ruby 1.8/bin" - Gem::ConfigMap[:ruby_install_name] = "ruby" - Gem::ConfigMap[:EXEEXT] = ".exe" + RbConfig::CONFIG['bindir'] = "C:/Ruby 1.8/bin" + RbConfig::CONFIG['ruby_install_name'] = "ruby" + RbConfig::CONFIG['EXEEXT'] = ".exe" Gem.instance_variable_set("@ruby", nil) assert_equal "\"C:/Ruby 1.8/bin/ruby.exe\"", Gem.ruby ensure Gem.instance_variable_set("@ruby", orig_ruby) - Gem::ConfigMap[:bindir] = orig_bindir - Gem::ConfigMap[:ruby_install_name] = orig_ruby_install_name - Gem::ConfigMap[:EXEEXT] = orig_exe_ext + RbConfig::CONFIG['bindir'] = orig_bindir + RbConfig::CONFIG['ruby_install_name'] = orig_ruby_install_name + RbConfig::CONFIG['EXEEXT'] = orig_exe_ext end def test_self_ruby_path_without_spaces orig_ruby = Gem.ruby - orig_bindir = Gem::ConfigMap[:bindir] - orig_ruby_install_name = Gem::ConfigMap[:ruby_install_name] - orig_exe_ext = Gem::ConfigMap[:EXEEXT] + orig_bindir = RbConfig::CONFIG['bindir'] + orig_ruby_install_name = RbConfig::CONFIG['ruby_install_name'] + orig_exe_ext = RbConfig::CONFIG['EXEEXT'] - Gem::ConfigMap[:bindir] = "C:/Ruby18/bin" - Gem::ConfigMap[:ruby_install_name] = "ruby" - Gem::ConfigMap[:EXEEXT] = ".exe" + RbConfig::CONFIG['bindir'] = "C:/Ruby18/bin" + RbConfig::CONFIG['ruby_install_name'] = "ruby" + RbConfig::CONFIG['EXEEXT'] = ".exe" Gem.instance_variable_set("@ruby", nil) assert_equal "C:/Ruby18/bin/ruby.exe", Gem.ruby ensure Gem.instance_variable_set("@ruby", orig_ruby) - Gem::ConfigMap[:bindir] = orig_bindir - Gem::ConfigMap[:ruby_install_name] = orig_ruby_install_name - Gem::ConfigMap[:EXEEXT] = orig_exe_ext + RbConfig::CONFIG['bindir'] = orig_bindir + RbConfig::CONFIG['ruby_install_name'] = orig_ruby_install_name + RbConfig::CONFIG['EXEEXT'] = orig_exe_ext end def test_self_ruby_api_version - orig_MAJOR, Gem::ConfigMap[:MAJOR] = Gem::ConfigMap[:MAJOR], '1' - orig_MINOR, Gem::ConfigMap[:MINOR] = Gem::ConfigMap[:MINOR], '2' - orig_TEENY, Gem::ConfigMap[:TEENY] = Gem::ConfigMap[:TEENY], '3' + orig_ruby_version, RbConfig::CONFIG['ruby_version'] = RbConfig::CONFIG['ruby_version'], '1.2.3' Gem.instance_variable_set :@ruby_api_version, nil @@ -671,9 +690,7 @@ def test_self_ruby_api_version ensure Gem.instance_variable_set :@ruby_api_version, nil - Gem::ConfigMap[:MAJOR] = orig_MAJOR - Gem::ConfigMap[:MINOR] = orig_MINOR - Gem::ConfigMap[:TEENY] = orig_TEENY + RbConfig::CONFIG['ruby_version'] = orig_ruby_version end def test_self_ruby_version_1_8_5 @@ -825,7 +842,7 @@ def test_self_use_paths def test_self_user_dir parts = [@userhome, '.gem', Gem.ruby_engine] - parts << Gem::ConfigMap[:ruby_version] unless Gem::ConfigMap[:ruby_version].empty? + parts << RbConfig::CONFIG['ruby_version'] unless RbConfig::CONFIG['ruby_version'].empty? assert_equal File.join(parts), Gem.user_dir end @@ -857,6 +874,7 @@ def test_self_needs end def test_self_needs_picks_up_unresolved_deps + skip 'loading from unsafe file' if RUBY_VERSION <= "1.8.7" save_loaded_features do util_clear_gems a = util_spec "a", "1" @@ -949,6 +967,7 @@ def test_self_user_home_user_drive_and_path end def test_load_plugins + skip 'Insecure operation - chdir' if RUBY_VERSION <= "1.8.7" plugin_path = File.join "lib", "rubygems_plugin.rb" Dir.chdir @tempdir do @@ -1102,6 +1121,7 @@ def test_auto_activation_of_specific_gemdeps_file end def test_auto_activation_of_detected_gemdeps_file + skip 'Insecure operation - chdir' if RUBY_VERSION <= "1.8.7" util_clear_gems a = new_spec "a", "1", nil, "lib/a.rb" @@ -1264,6 +1284,7 @@ def test_use_gemdeps end def test_use_gemdeps_automatic + skip 'Insecure operation - chdir' if RUBY_VERSION <= "1.8.7" rubygems_gemdeps, ENV['RUBYGEMS_GEMDEPS'] = ENV['RUBYGEMS_GEMDEPS'], '-' spec = util_spec 'a', 1 @@ -1300,6 +1321,7 @@ def test_use_gemdeps_disabled end def test_use_gemdeps_specific + skip 'Insecure operation - read' if RUBY_VERSION <= "1.8.7" rubygems_gemdeps, ENV['RUBYGEMS_GEMDEPS'] = ENV['RUBYGEMS_GEMDEPS'], 'x' spec = util_spec 'a', 1 diff --git a/test/rubygems/test_gem_commands_contents_command.rb b/test/rubygems/test_gem_commands_contents_command.rb index d87e84fc829fc0..7f5cf22223cff5 100644 --- a/test/rubygems/test_gem_commands_contents_command.rb +++ b/test/rubygems/test_gem_commands_contents_command.rb @@ -169,9 +169,9 @@ def test_execute_default_gem end expected = [ - File.join(Gem::ConfigMap[:bindir], 'default_command'), - File.join(Gem::ConfigMap[:rubylibdir], 'default/gem.rb'), - File.join(Gem::ConfigMap[:archdir], 'default_gem.so') + File.join(RbConfig::CONFIG['bindir'], 'default_command'), + File.join(RbConfig::CONFIG['rubylibdir'], 'default/gem.rb'), + File.join(RbConfig::CONFIG['archdir'], 'default_gem.so') ].sort.join "\n" assert_equal expected, @ui.output.chomp diff --git a/test/rubygems/test_gem_commands_environment_command.rb b/test/rubygems/test_gem_commands_environment_command.rb index 253c459d942840..bb7589f50de1c3 100644 --- a/test/rubygems/test_gem_commands_environment_command.rb +++ b/test/rubygems/test_gem_commands_environment_command.rb @@ -26,7 +26,7 @@ def test_execute assert_match %r|INSTALLATION DIRECTORY: #{Regexp.escape @gemhome}|, @ui.output assert_match %r|RUBYGEMS PREFIX: |, @ui.output - assert_match %r|RUBY EXECUTABLE:.*#{Gem::ConfigMap[:ruby_install_name]}|, + assert_match %r|RUBY EXECUTABLE:.*#{RbConfig::CONFIG['ruby_install_name']}|, @ui.output assert_match %r|EXECUTABLE DIRECTORY:|, @ui.output assert_match %r|RUBYGEMS PLATFORMS:|, @ui.output diff --git a/test/rubygems/test_gem_commands_install_command.rb b/test/rubygems/test_gem_commands_install_command.rb index 00bbf7bae7eca2..6315cb5d95b5ed 100644 --- a/test/rubygems/test_gem_commands_install_command.rb +++ b/test/rubygems/test_gem_commands_install_command.rb @@ -316,6 +316,7 @@ def test_execute_prerelease_skipped_when_non_pre_available end def test_execute_rdoc + skip if RUBY_VERSION <= "1.8.7" specs = spec_fetcher do |fetcher| fetcher.gem 'a', 2 end @@ -559,6 +560,20 @@ def test_install_gem_ignore_dependencies_remote assert_equal %w[a-2], @cmd.installed_specs.map { |spec| spec.full_name } end + def test_install_gem_ignore_dependencies_specific_file + spec = quick_spec 'a', 2 + + util_build_gem spec + + FileUtils.mv spec.cache_file, @tempdir + + @cmd.options[:ignore_dependencies] = true + + @cmd.install_gem File.join(@tempdir, spec.file_name), nil + + assert_equal %w[a-2], @cmd.installed_specs.map { |s| s.full_name } + end + def test_parses_requirement_from_gemname spec_fetcher do |fetcher| fetcher.gem 'a', 2 diff --git a/test/rubygems/test_gem_commands_update_command.rb b/test/rubygems/test_gem_commands_update_command.rb index 7537c1c9c10532..d259383ba2fbb2 100644 --- a/test/rubygems/test_gem_commands_update_command.rb +++ b/test/rubygems/test_gem_commands_update_command.rb @@ -217,6 +217,7 @@ def test_execute_dependencies end def test_execute_rdoc + skip if RUBY_VERSION <= "1.8.7" spec_fetcher do |fetcher| fetcher.gem 'a', 2 @@ -239,7 +240,6 @@ def test_execute_rdoc a2 = @specs['a-2'] - assert_path_exists File.join(a2.doc_dir, 'ri') assert_path_exists File.join(a2.doc_dir, 'rdoc') end diff --git a/test/rubygems/test_gem_dependency_installer.rb b/test/rubygems/test_gem_dependency_installer.rb index 0a82fa63cbbd19..352ebbb54ff513 100644 --- a/test/rubygems/test_gem_dependency_installer.rb +++ b/test/rubygems/test_gem_dependency_installer.rb @@ -551,7 +551,7 @@ def test_install_env_shebang env = "/\\S+/env" unless Gem.win_platform? - assert_match %r|\A#!#{env} #{Gem::ConfigMap[:ruby_install_name]}\n|, + assert_match %r|\A#!#{env} #{RbConfig::CONFIG['ruby_install_name']}\n|, File.read(File.join(@gemhome, 'bin', 'a_bin')) end diff --git a/test/rubygems/test_gem_installer.rb b/test/rubygems/test_gem_installer.rb index 615a9b57ba4afa..54ac853135b9cf 100644 --- a/test/rubygems/test_gem_installer.rb +++ b/test/rubygems/test_gem_installer.rb @@ -84,8 +84,8 @@ def test_check_executable_overwrite_default_bin_dir orig_RUBY_FRAMEWORK_VERSION = RUBY_FRAMEWORK_VERSION Object.send :remove_const, :RUBY_FRAMEWORK_VERSION end - orig_bindir = Gem::ConfigMap[:bindir] - Gem::ConfigMap[:bindir] = Gem.bindir + orig_bindir = RbConfig::CONFIG['bindir'] + RbConfig::CONFIG['bindir'] = Gem.bindir util_conflict_executable false @@ -102,7 +102,7 @@ def test_check_executable_overwrite_default_bin_dir ensure Object.const_set :RUBY_FRAMEWORK_VERSION, orig_RUBY_FRAMEWORK_VERSION if orig_RUBY_FRAMEWORK_VERSION - Gem::ConfigMap[:bindir] = orig_bindir + RbConfig::CONFIG['bindir'] = orig_bindir end def test_check_executable_overwrite_format_executable @@ -1192,7 +1192,7 @@ def test_shebang_env_shebang env_shebang = "/usr/bin/env" unless Gem.win_platform? - assert_equal("#!#{env_shebang} #{Gem::ConfigMap[:ruby_install_name]}", + assert_equal("#!#{env_shebang} #{RbConfig::CONFIG['ruby_install_name']}", shebang) end diff --git a/test/rubygems/test_gem_request_set_lockfile.rb b/test/rubygems/test_gem_request_set_lockfile.rb index 9e0cab4d1a8f79..0be69bf92b30d4 100644 --- a/test/rubygems/test_gem_request_set_lockfile.rb +++ b/test/rubygems/test_gem_request_set_lockfile.rb @@ -218,6 +218,7 @@ def test_parse_gem_specs_dependency c (~> 4) d e (~> 5.0, >= 5.0.1) + b (3-x86_64-linux) PLATFORMS #{Gem::Platform::RUBY} @@ -238,7 +239,14 @@ def test_parse_gem_specs_dependency assert lockfile_set, 'could not find a LockSet' - assert_equal %w[a-2], lockfile_set.specs.map { |tuple| tuple.full_name } + assert_equal %w[a-2 b-3], lockfile_set.specs.map { |tuple| tuple.full_name } + + expected = [ + Gem::Platform::RUBY, + Gem::Platform.new('x86_64-linux'), + ] + + assert_equal expected, lockfile_set.specs.map { |tuple| tuple.platform } spec = lockfile_set.specs.first diff --git a/test/rubygems/test_gem_specification.rb b/test/rubygems/test_gem_specification.rb index 7aa9d5aeb17a4a..b72a5d1baf01cd 100644 --- a/test/rubygems/test_gem_specification.rb +++ b/test/rubygems/test_gem_specification.rb @@ -999,8 +999,8 @@ def test_initialize_copy assert_equal 'summary', spec.summary assert_same spec.summary, new_spec.summary - assert_equal %w[lib/file.rb test/file.rb bin/exec README.txt - ext/extconf.rb].sort, + assert_equal %w[README.txt bin/exec ext/extconf.rb lib/file.rb + test/file.rb].sort, spec.files refute_same spec.files, new_spec.files, 'files' @@ -1109,7 +1109,31 @@ def test_bindir_equals_nil @a2.executable = 'app' assert_equal nil, @a2.bindir - assert_equal %w[lib/code.rb app].sort, @a2.files + assert_equal %w[app lib/code.rb].sort, @a2.files + end + + def test_extensions_equals_nil + @a2.instance_variable_set(:@extensions, nil) + assert_equal nil, @a2.instance_variable_get(:@extensions) + assert_equal %w[lib/code.rb], @a2.files + end + + def test_test_files_equals_nil + @a2.instance_variable_set(:@test_files, nil) + assert_equal nil, @a2.instance_variable_get(:@test_files) + assert_equal %w[lib/code.rb], @a2.files + end + + def test_executables_equals_nil + @a2.instance_variable_set(:@executables, nil) + assert_equal nil, @a2.instance_variable_get(:@executables) + assert_equal %w[lib/code.rb], @a2.files + end + + def test_extra_rdoc_files_equals_nil + @a2.instance_variable_set(:@extra_rdoc_files, nil) + assert_equal nil, @a2.instance_variable_get(:@extra_rdoc_files) + assert_equal %w[lib/code.rb], @a2.files end def test_build_extensions @@ -1437,7 +1461,7 @@ def test_executables def test_executable_equals @a2.executable = 'app' assert_equal 'app', @a2.executable - assert_equal %w[lib/code.rb bin/app].sort, @a2.files + assert_equal %w[bin/app lib/code.rb].sort, @a2.files end def test_extensions @@ -1785,6 +1809,22 @@ def test_source assert_kind_of Gem::Source::Installed, @a1.source end + def test_source_paths + ext_spec + + @ext.require_paths = %w[lib ext foo] + @ext.extensions << 'bar/baz' + + expected = %w[ + lib + ext + foo + bar + ] + + assert_equal expected, @ext.source_paths + end + def test_full_require_paths ext_spec @@ -2435,7 +2475,7 @@ def test_validate_files assert_equal '["lib2"] are not files', e.message end - assert_equal %w[lib/code.rb test/suite.rb bin/exec ext/a/extconf.rb lib2].sort, + assert_equal %w[bin/exec ext/a/extconf.rb lib/code.rb lib2 test/suite.rb].sort, @a1.files end diff --git a/test/rubygems/test_gem_uninstaller.rb b/test/rubygems/test_gem_uninstaller.rb index 1eea30fb9403d6..11fdaf68e22118 100644 --- a/test/rubygems/test_gem_uninstaller.rb +++ b/test/rubygems/test_gem_uninstaller.rb @@ -131,6 +131,23 @@ def test_remove_executables_user_format_disabled Gem::Installer.exec_format = nil end + def test_remove_not_in_home + uninstaller = Gem::Uninstaller.new nil, :install_dir => "#{@gemhome}2" + + e = assert_raises Gem::GemNotInHomeException do + use_ui ui do + uninstaller.remove @spec + end + end + + expected = + "Gem '#{@spec.full_name}' is not installed in directory #{@gemhome}2" + + assert_equal expected, e.message + + assert_path_exists @spec.gem_dir + end + def test_path_ok_eh uninstaller = Gem::Uninstaller.new nil diff --git a/version.h b/version.h index c361122024b2b0..8553f79047718a 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-01-31" -#define RUBY_PATCHLEVEL 13 +#define RUBY_PATCHLEVEL 14 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 1 From 8f87be4e22e61ca92c856ef977d0f6924974bdcf Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 1 Feb 2014 08:19:06 +0000 Subject: [PATCH 007/343] Revert r44778 #9375 It breaks test-all if all tests are in a single process git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@44786 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 9 -- NEWS | 2 - lib/rubygems.rb | 19 ++-- lib/rubygems/basic_specification.rb | 18 ---- lib/rubygems/commands/contents_command.rb | 6 +- lib/rubygems/commands/install_command.rb | 20 ++-- lib/rubygems/commands/setup_command.rb | 16 +-- lib/rubygems/compatibility.rb | 4 +- lib/rubygems/defaults.rb | 20 ++-- lib/rubygems/deprecate.rb | 2 +- lib/rubygems/installer.rb | 4 +- lib/rubygems/platform.rb | 2 +- lib/rubygems/rdoc.rb | 2 +- lib/rubygems/request_set/lockfile.rb | 7 +- lib/rubygems/resolver.rb | 21 ++++ lib/rubygems/resolver/installer_set.rb | 35 +++++- lib/rubygems/specification.rb | 2 +- lib/rubygems/test_case.rb | 12 +-- lib/rubygems/uninstaller.rb | 2 +- test/rubygems/test_gem.rb | 102 +++++++----------- .../test_gem_commands_contents_command.rb | 6 +- .../test_gem_commands_environment_command.rb | 2 +- .../test_gem_commands_install_command.rb | 15 --- .../test_gem_commands_update_command.rb | 2 +- .../rubygems/test_gem_dependency_installer.rb | 2 +- test/rubygems/test_gem_installer.rb | 8 +- .../rubygems/test_gem_request_set_lockfile.rb | 10 +- test/rubygems/test_gem_specification.rb | 50 +-------- test/rubygems/test_gem_uninstaller.rb | 17 --- version.h | 2 +- 30 files changed, 163 insertions(+), 256 deletions(-) diff --git a/ChangeLog b/ChangeLog index e88b8e13949c57..601436f3261c95 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,12 +1,3 @@ -Fri Jan 31 18:13:43 2014 Eric Hodel - - * lib/rubygems: Update to RubyGems master 21e409d / RubyGems 2.2.1. - - See http://rubygems.rubyforge.org/rubygems-update/History_txt.html - for a list of bug fixes. - - * test/rubygems: ditto. - Fri Jan 31 12:10:16 2014 Nobuyoshi Nakada * proc.c (mnew_from_me): keep iclass as-is, to make inheritance diff --git a/NEWS b/NEWS index f622b9f2ed3ff8..a096ad9d28fc85 100644 --- a/NEWS +++ b/NEWS @@ -276,8 +276,6 @@ String * Improved, iterative resolver (compared to RubyGems 2.1 and earlier) * Support for a sharing a GEM_HOME across ruby platforms and versions - * Updated to 2.2.1. Fixes some minor bugs and performance regressions. - For a complete list of enhancements and bug fixes see: https://github.com/rubygems/rubygems/tree/master/History.txt diff --git a/lib/rubygems.rb b/lib/rubygems.rb index 7afc85bda5174d..73c4846f8274de 100644 --- a/lib/rubygems.rb +++ b/lib/rubygems.rb @@ -8,7 +8,7 @@ require 'rbconfig' module Gem - VERSION = '2.2.1' + VERSION = '2.2.0' end # Must be first since it unloads the prelude from 1.9.2 @@ -572,7 +572,7 @@ def self.host= host # gem's paths are inserted before site lib directory by default. def self.load_path_insert_index - index = $LOAD_PATH.index RbConfig::CONFIG['sitelibdir'] + index = $LOAD_PATH.index ConfigMap[:sitelibdir] index end @@ -743,8 +743,8 @@ def self.pre_uninstall(&hook) def self.prefix prefix = File.dirname RUBYGEMS_DIR - if prefix != File.expand_path(RbConfig::CONFIG['sitelibdir']) and - prefix != File.expand_path(RbConfig::CONFIG['libdir']) and + if prefix != File.expand_path(ConfigMap[:sitelibdir]) and + prefix != File.expand_path(ConfigMap[:libdir]) and 'lib' == File.basename(RUBYGEMS_DIR) then prefix end @@ -765,10 +765,6 @@ def self.read_binary(path) f.flock(File::LOCK_EX) f.read end - rescue Errno::EACCES - open path, 'rb' do |f| - f.read - end end ## @@ -776,8 +772,8 @@ def self.read_binary(path) def self.ruby if @ruby.nil? then - @ruby = File.join(RbConfig::CONFIG['bindir'], - "#{RbConfig::CONFIG['ruby_install_name']}#{RbConfig::CONFIG['EXEEXT']}") + @ruby = File.join(ConfigMap[:bindir], + "#{ConfigMap[:ruby_install_name]}#{ConfigMap[:EXEEXT]}") @ruby = "\"#{@ruby}\"" if @ruby =~ /\s/ end @@ -789,7 +785,8 @@ def self.ruby # Returns a String containing the API compatibility version of Ruby def self.ruby_api_version - @ruby_api_version ||= RbConfig::CONFIG['ruby_version'].dup + @ruby_api_version ||= + "#{ConfigMap[:MAJOR]}.#{ConfigMap[:MINOR]}.#{ConfigMap[:TEENY]}" end ## diff --git a/lib/rubygems/basic_specification.rb b/lib/rubygems/basic_specification.rb index 470a6ebc8b5c43..a52377ff22e067 100644 --- a/lib/rubygems/basic_specification.rb +++ b/lib/rubygems/basic_specification.rb @@ -206,24 +206,6 @@ def require_paths [relative_extension_dir].concat @require_paths end - ## - # Returns the paths to the source files for use with analysis and - # documentation tools. These paths are relative to full_gem_path. - - def source_paths - paths = raw_require_paths.dup - - if @extensions then - ext_dirs = @extensions.map do |extension| - extension.split(File::SEPARATOR, 2).first - end.uniq - - paths.concat ext_dirs - end - - paths.uniq - end - ## # Return a Gem::Specification from this gem diff --git a/lib/rubygems/commands/contents_command.rb b/lib/rubygems/commands/contents_command.rb index 603f1d072aaa6f..97218848edac15 100644 --- a/lib/rubygems/commands/contents_command.rb +++ b/lib/rubygems/commands/contents_command.rb @@ -94,11 +94,11 @@ def files_in_default_gem spec spec.files.sort.map do |file| case file when /\A#{spec.bindir}\// - [RbConfig::CONFIG['bindir'], $POSTMATCH] + [Gem::ConfigMap[:bindir], $POSTMATCH] when /\.so\z/ - [RbConfig::CONFIG['archdir'], file] + [Gem::ConfigMap[:archdir], file] else - [RbConfig::CONFIG['rubylibdir'], file] + [Gem::ConfigMap[:rubylibdir], file] end end end diff --git a/lib/rubygems/commands/install_command.rb b/lib/rubygems/commands/install_command.rb index 8219eef6ead096..4485eb12e81719 100644 --- a/lib/rubygems/commands/install_command.rb +++ b/lib/rubygems/commands/install_command.rb @@ -228,18 +228,7 @@ def install_gem name, version # :nodoc: def install_gem_without_dependencies name, req # :nodoc: gem = nil - if local? then - if name =~ /\.gem$/ and File.file? name then - source = Gem::Source::SpecificFile.new name - spec = source.spec - else - source = Gem::Source::Local.new - spec = source.find_gem name, req - end - gem = source.download spec if spec - end - - if remote? and not gem then + if remote? then dependency = Gem::Dependency.new name, req dependency.prerelease = options[:prerelease] @@ -247,6 +236,13 @@ def install_gem_without_dependencies name, req # :nodoc: gem = fetcher.download_to_cache dependency end + if local? and not gem then + source = Gem::Source::Local.new + spec = source.find_gem name, req + + gem = source.download spec + end + inst = Gem::Installer.new gem, options inst.install diff --git a/lib/rubygems/commands/setup_command.rb b/lib/rubygems/commands/setup_command.rb index 681db0dc1d19fc..face77fae9ce28 100644 --- a/lib/rubygems/commands/setup_command.rb +++ b/lib/rubygems/commands/setup_command.rb @@ -13,7 +13,7 @@ def initialize super 'setup', 'Install RubyGems', :format_executable => true, :document => %w[ri], - :site_or_vendor => 'sitelibdir', + :site_or_vendor => :sitelibdir, :destdir => '', :prefix => '', :previous_version => '' add_option '--previous-version=VERSION', @@ -36,7 +36,7 @@ def initialize add_option '--[no-]vendor', 'Install into vendorlibdir not sitelibdir' do |vendor, options| - options[:site_or_vendor] = vendor ? 'vendorlibdir' : 'sitelibdir' + options[:site_or_vendor] = vendor ? :vendorlibdir : :sitelibdir end add_option '--[no-]format-executable', @@ -343,19 +343,19 @@ def generate_default_dirs(install_destdir) site_or_vendor = options[:site_or_vendor] if prefix.empty? then - lib_dir = RbConfig::CONFIG[site_or_vendor] - bin_dir = RbConfig::CONFIG['bindir'] + lib_dir = Gem::ConfigMap[site_or_vendor] + bin_dir = Gem::ConfigMap[:bindir] else # Apple installed RubyGems into libdir, and RubyGems <= 1.1.0 gets # confused about installation location, so switch back to # sitelibdir/vendorlibdir. if defined?(APPLE_GEM_HOME) and # just in case Apple and RubyGems don't get this patched up proper. - (prefix == RbConfig::CONFIG['libdir'] or + (prefix == Gem::ConfigMap[:libdir] or # this one is important - prefix == File.join(RbConfig::CONFIG['libdir'], 'ruby')) then - lib_dir = RbConfig::CONFIG[site_or_vendor] - bin_dir = RbConfig::CONFIG['bindir'] + prefix == File.join(Gem::ConfigMap[:libdir], 'ruby')) then + lib_dir = Gem::ConfigMap[site_or_vendor] + bin_dir = Gem::ConfigMap[:bindir] else lib_dir = File.join prefix, 'lib' bin_dir = File.join prefix, 'bin' diff --git a/lib/rubygems/compatibility.rb b/lib/rubygems/compatibility.rb index d06ade1fa662ba..5e8618fe39c088 100644 --- a/lib/rubygems/compatibility.rb +++ b/lib/rubygems/compatibility.rb @@ -33,8 +33,6 @@ class << Gem module Gem RubyGemsVersion = VERSION - # TODO remove at RubyGems 3 - RbConfigPriorities = %w[ MAJOR MINOR @@ -47,7 +45,7 @@ module Gem unless defined?(ConfigMap) ## # Configuration settings from ::RbConfig - ConfigMap = Hash.new do |cm, key| # TODO remove at RubyGems 3 + ConfigMap = Hash.new do |cm, key| cm[key] = RbConfig::CONFIG[key.to_s] end else diff --git a/lib/rubygems/defaults.rb b/lib/rubygems/defaults.rb index 6924f48e5ade92..715c0b71b36181 100644 --- a/lib/rubygems/defaults.rb +++ b/lib/rubygems/defaults.rb @@ -29,22 +29,22 @@ def self.default_spec_cache_dir def self.default_dir path = if defined? RUBY_FRAMEWORK_VERSION then [ - File.dirname(RbConfig::CONFIG['sitedir']), + File.dirname(ConfigMap[:sitedir]), 'Gems', - RbConfig::CONFIG['ruby_version'] + ConfigMap[:ruby_version] ] - elsif RbConfig::CONFIG['rubylibprefix'] then + elsif ConfigMap[:rubylibprefix] then [ - RbConfig::CONFIG['rubylibprefix'], + ConfigMap[:rubylibprefix], 'gems', - RbConfig::CONFIG['ruby_version'] + ConfigMap[:ruby_version] ] else [ - RbConfig::CONFIG['libdir'], + ConfigMap[:libdir], ruby_engine, 'gems', - RbConfig::CONFIG['ruby_version'] + ConfigMap[:ruby_version] ] end @@ -74,7 +74,7 @@ def self.default_rubygems_dirs def self.user_dir parts = [Gem.user_home, '.gem', ruby_engine] - parts << RbConfig::CONFIG['ruby_version'] unless RbConfig::CONFIG['ruby_version'].empty? + parts << ConfigMap[:ruby_version] unless ConfigMap[:ruby_version].empty? File.join parts end @@ -100,7 +100,7 @@ def self.default_path # Deduce Ruby's --program-prefix and --program-suffix from its install name def self.default_exec_format - exec_format = RbConfig::CONFIG['ruby_install_name'].sub('ruby', '%s') rescue '%s' + exec_format = ConfigMap[:ruby_install_name].sub('ruby', '%s') rescue '%s' unless exec_format =~ /%s/ then raise Gem::Exception, @@ -117,7 +117,7 @@ def self.default_bindir if defined? RUBY_FRAMEWORK_VERSION then # mac framework support '/usr/bin' else # generic install - RbConfig::CONFIG['bindir'] + ConfigMap[:bindir] end end diff --git a/lib/rubygems/deprecate.rb b/lib/rubygems/deprecate.rb index e19360da13a81f..274d6a5c12023f 100644 --- a/lib/rubygems/deprecate.rb +++ b/lib/rubygems/deprecate.rb @@ -50,7 +50,7 @@ def deprecate name, repl, year, month class_eval { old = "_deprecated_#{name}" alias_method old, name - define_method name do |*args, &block| + define_method name do |*args, &block| # TODO: really works on 1.8.7? klass = self.kind_of? Module target = klass ? "#{self}." : "#{self.class}#" msg = [ "NOTE: #{target}#{name} is deprecated", diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb index 33d2f78d46a429..f8eb2c2145fa1e 100644 --- a/lib/rubygems/installer.rb +++ b/lib/rubygems/installer.rb @@ -480,7 +480,7 @@ def generate_bin_symlink(filename, bindir) # def shebang(bin_file_name) - ruby_name = RbConfig::CONFIG['ruby_install_name'] if @env_shebang + ruby_name = Gem::ConfigMap[:ruby_install_name] if @env_shebang path = File.join gem_dir, spec.bindir, bin_file_name first_line = File.open(path, "rb") {|file| file.gets} @@ -493,7 +493,7 @@ def shebang(bin_file_name) if which = Gem.configuration[:custom_shebang] # replace bin_file_name with "ruby" to avoid endless loops - which = which.gsub(/ #{bin_file_name}$/," #{RbConfig::CONFIG['ruby_install_name']}") + which = which.gsub(/ #{bin_file_name}$/," #{Gem::ConfigMap[:ruby_install_name]}") which = which.gsub(/\$(\w+)/) do case $1 diff --git a/lib/rubygems/platform.rb b/lib/rubygems/platform.rb index 1bcd7549ad4f79..e050959dc6fde5 100644 --- a/lib/rubygems/platform.rb +++ b/lib/rubygems/platform.rb @@ -16,7 +16,7 @@ class Gem::Platform attr_accessor :version def self.local - arch = RbConfig::CONFIG['arch'] + arch = Gem::ConfigMap[:arch] arch = "#{arch}_60" if arch =~ /mswin32$/ @local ||= new(arch) end diff --git a/lib/rubygems/rdoc.rb b/lib/rubygems/rdoc.rb index 633bd893a5df0c..52249dc267aa88 100644 --- a/lib/rubygems/rdoc.rb +++ b/lib/rubygems/rdoc.rb @@ -193,7 +193,7 @@ def generate ::RDoc::Parser::C.reset args = @spec.rdoc_options - args.concat @spec.source_paths + args.concat @spec.require_paths args.concat @spec.extra_rdoc_files case config_args = Gem.configuration[:rdoc] diff --git a/lib/rubygems/request_set/lockfile.rb b/lib/rubygems/request_set/lockfile.rb index 0433d2a7fc86e5..522caf15026af0 100644 --- a/lib/rubygems/request_set/lockfile.rb +++ b/lib/rubygems/request_set/lockfile.rb @@ -303,12 +303,7 @@ def parse_GEM # :nodoc: type, data, = get [:text, :requirement] if type == :text and column == 4 then - version, platform = data.split '-', 2 - - platform = - platform ? Gem::Platform.new(platform) : Gem::Platform::RUBY - - last_spec = set.add name, version, platform + last_spec = set.add name, data, Gem::Platform::RUBY else dependency = parse_dependency name, data diff --git a/lib/rubygems/resolver.rb b/lib/rubygems/resolver.rb index 15a96693e95275..d455e03c0576fb 100644 --- a/lib/rubygems/resolver.rb +++ b/lib/rubygems/resolver.rb @@ -178,6 +178,27 @@ def resolve res.to_a end + ## + # Finds the State in +states+ that matches the +conflict+ so that we can try + # other possible sets. + # + # If no good candidate is found, the first state is tried. + + def find_conflict_state conflict, states # :nodoc: + until states.empty? do + state = states.pop + + explain :consider, state.dep, conflict.failed_dep + + if conflict.for_spec? state.spec + state.conflicts << [state.spec, conflict] + return state + end + end + + nil + end + ## # Extracts the specifications that may be able to fulfill +dependency+ and # returns those that match the local platform and all those that match. diff --git a/lib/rubygems/resolver/installer_set.rb b/lib/rubygems/resolver/installer_set.rb index 27e64551480f61..e35e0aabecc92a 100644 --- a/lib/rubygems/resolver/installer_set.rb +++ b/lib/rubygems/resolver/installer_set.rb @@ -28,10 +28,11 @@ def initialize domain @f = Gem::SpecFetcher.fetcher + @all = Hash.new { |h,k| h[k] = [] } @always_install = [] @ignore_dependencies = false @ignore_installed = false - @remote_set = Gem::Resolver::BestSet.new if consider_remote? + @loaded_remote_specs = [] @specs = {} end @@ -78,7 +79,16 @@ def find_all req end end - res.concat @remote_set.find_all req if consider_remote? + if consider_remote? then + load_remote_specs dep + + @all[name].each do |remote_source, n| + if dep.match? n then + res << Gem::Resolver::IndexSpecification.new( + self, n.name, n.version, remote_source, n.platform) + end + end + end res end @@ -91,6 +101,27 @@ def inspect # :nodoc: ] end + ## + # Loads remote prerelease specs if +dep+ is a prerelease dependency + + def load_remote_specs dep # :nodoc: + types = [:released] + types << :prerelease if dep.prerelease? + + types.each do |type| + next if @loaded_remote_specs.include? type + @loaded_remote_specs << type + + list, = @f.available_specs type + + list.each do |uri, specs| + specs.each do |n| + @all[n.name] << [uri, n] + end + end + end + end + ## # Called from IndexSpecification to get a true Specification # object. diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb index e98f3284cd0bd2..59d71d378bb3f7 100644 --- a/lib/rubygems/specification.rb +++ b/lib/rubygems/specification.rb @@ -327,7 +327,7 @@ def files add_bindir(@executables), @extra_rdoc_files, @extensions, - ].flatten.uniq.compact.sort + ].flatten.sort.uniq.compact end ###################################################################### diff --git a/lib/rubygems/test_case.rb b/lib/rubygems/test_case.rb index ff261f7816e796..8dc37d67204dc6 100644 --- a/lib/rubygems/test_case.rb +++ b/lib/rubygems/test_case.rb @@ -294,10 +294,10 @@ def setup Gem.searcher = nil Gem::SpecFetcher.fetcher = nil - @orig_BASERUBY = RbConfig::CONFIG['BASERUBY'] - RbConfig::CONFIG['BASERUBY'] = RbConfig::CONFIG['ruby_install_name'] + @orig_BASERUBY = Gem::ConfigMap[:BASERUBY] + Gem::ConfigMap[:BASERUBY] = Gem::ConfigMap[:ruby_install_name] - @orig_arch = RbConfig::CONFIG['arch'] + @orig_arch = Gem::ConfigMap[:arch] if win_platform? util_set_arch 'i386-mswin32' @@ -315,8 +315,8 @@ def setup def teardown $LOAD_PATH.replace @orig_LOAD_PATH if @orig_LOAD_PATH - RbConfig::CONFIG['BASERUBY'] = @orig_BASERUBY - RbConfig::CONFIG['arch'] = @orig_arch + Gem::ConfigMap[:BASERUBY] = @orig_BASERUBY + Gem::ConfigMap[:arch] = @orig_arch if defined? Gem::RemoteFetcher then Gem::RemoteFetcher.fetcher = nil @@ -898,7 +898,7 @@ def util_make_gems(prerelease = false) # Set the platform to +arch+ def util_set_arch(arch) - RbConfig::CONFIG['arch'] = arch + Gem::ConfigMap[:arch] = arch platform = Gem::Platform.new arch Gem.instance_variable_set :@platforms, nil diff --git a/lib/rubygems/uninstaller.rb b/lib/rubygems/uninstaller.rb index fa838333cd4543..4cb2a1d33334ba 100644 --- a/lib/rubygems/uninstaller.rb +++ b/lib/rubygems/uninstaller.rb @@ -237,7 +237,7 @@ def remove(spec) unless path_ok?(@gem_home, spec) or (@user_install and path_ok?(Gem.user_dir, spec)) then e = Gem::GemNotInHomeException.new \ - "Gem '#{spec.full_name}' is not installed in directory #{@gem_home}" + "Gem is not installed in directory #{@gem_home}" e.spec = spec raise e diff --git a/test/rubygems/test_gem.rb b/test/rubygems/test_gem.rb index 513f2d4e58e835..759c2fe9070759 100644 --- a/test/rubygems/test_gem.rb +++ b/test/rubygems/test_gem.rb @@ -199,30 +199,30 @@ def test_self_datadir_nonexistent_package end def test_self_default_exec_format - orig_RUBY_INSTALL_NAME = RbConfig::CONFIG['ruby_install_name'] - RbConfig::CONFIG['ruby_install_name'] = 'ruby' + orig_RUBY_INSTALL_NAME = Gem::ConfigMap[:ruby_install_name] + Gem::ConfigMap[:ruby_install_name] = 'ruby' assert_equal '%s', Gem.default_exec_format ensure - RbConfig::CONFIG['ruby_install_name'] = orig_RUBY_INSTALL_NAME + Gem::ConfigMap[:ruby_install_name] = orig_RUBY_INSTALL_NAME end def test_self_default_exec_format_18 - orig_RUBY_INSTALL_NAME = RbConfig::CONFIG['ruby_install_name'] - RbConfig::CONFIG['ruby_install_name'] = 'ruby18' + orig_RUBY_INSTALL_NAME = Gem::ConfigMap[:ruby_install_name] + Gem::ConfigMap[:ruby_install_name] = 'ruby18' assert_equal '%s18', Gem.default_exec_format ensure - RbConfig::CONFIG['ruby_install_name'] = orig_RUBY_INSTALL_NAME + Gem::ConfigMap[:ruby_install_name] = orig_RUBY_INSTALL_NAME end def test_self_default_exec_format_jruby - orig_RUBY_INSTALL_NAME = RbConfig::CONFIG['ruby_install_name'] - RbConfig::CONFIG['ruby_install_name'] = 'jruby' + orig_RUBY_INSTALL_NAME = Gem::ConfigMap[:ruby_install_name] + Gem::ConfigMap[:ruby_install_name] = 'jruby' assert_equal 'j%s', Gem.default_exec_format ensure - RbConfig::CONFIG['ruby_install_name'] = orig_RUBY_INSTALL_NAME + Gem::ConfigMap[:ruby_install_name] = orig_RUBY_INSTALL_NAME end def test_self_default_sources @@ -230,7 +230,6 @@ def test_self_default_sources end def test_self_detect_gemdeps - skip 'Insecure operation - chdir' if RUBY_VERSION <= "1.8.7" rubygems_gemdeps, ENV['RUBYGEMS_GEMDEPS'] = ENV['RUBYGEMS_GEMDEPS'], '-' FileUtils.mkdir_p 'detect/a/b' @@ -566,43 +565,24 @@ def test_self_prefix end def test_self_prefix_libdir - orig_libdir = RbConfig::CONFIG['libdir'] - RbConfig::CONFIG['libdir'] = @@project_dir + orig_libdir = Gem::ConfigMap[:libdir] + Gem::ConfigMap[:libdir] = @@project_dir assert_nil Gem.prefix ensure - RbConfig::CONFIG['libdir'] = orig_libdir + Gem::ConfigMap[:libdir] = orig_libdir end def test_self_prefix_sitelibdir - orig_sitelibdir = RbConfig::CONFIG['sitelibdir'] - RbConfig::CONFIG['sitelibdir'] = @@project_dir + orig_sitelibdir = Gem::ConfigMap[:sitelibdir] + Gem::ConfigMap[:sitelibdir] = @@project_dir assert_nil Gem.prefix ensure - RbConfig::CONFIG['sitelibdir'] = orig_sitelibdir - end - - def test_self_read_binary - open 'test', 'w' do |io| - io.write "\xCF\x80" - end - - assert_equal ["\xCF", "\x80"], Gem.read_binary('test').chars.to_a - - skip 'chmod not supported' if Gem.win_platform? - - begin - File.chmod 0444, 'test' - - assert_equal ["\xCF", "\x80"], Gem.read_binary('test').chars.to_a - ensure - File.chmod 0644, 'test' - end + Gem::ConfigMap[:sitelibdir] = orig_sitelibdir end def test_self_refresh - skip 'Insecure operation - mkdir' if RUBY_VERSION <= "1.8.7" util_make_gems a1_spec = @a1.spec_file @@ -622,7 +602,6 @@ def test_self_refresh end def test_self_refresh_keeps_loaded_specs_activated - skip 'Insecure operation - mkdir' if RUBY_VERSION <= "1.8.7" util_make_gems a1_spec = @a1.spec_file @@ -645,44 +624,46 @@ def test_self_refresh_keeps_loaded_specs_activated def test_self_ruby_escaping_spaces_in_path orig_ruby = Gem.ruby - orig_bindir = RbConfig::CONFIG['bindir'] - orig_ruby_install_name = RbConfig::CONFIG['ruby_install_name'] - orig_exe_ext = RbConfig::CONFIG['EXEEXT'] + orig_bindir = Gem::ConfigMap[:bindir] + orig_ruby_install_name = Gem::ConfigMap[:ruby_install_name] + orig_exe_ext = Gem::ConfigMap[:EXEEXT] - RbConfig::CONFIG['bindir'] = "C:/Ruby 1.8/bin" - RbConfig::CONFIG['ruby_install_name'] = "ruby" - RbConfig::CONFIG['EXEEXT'] = ".exe" + Gem::ConfigMap[:bindir] = "C:/Ruby 1.8/bin" + Gem::ConfigMap[:ruby_install_name] = "ruby" + Gem::ConfigMap[:EXEEXT] = ".exe" Gem.instance_variable_set("@ruby", nil) assert_equal "\"C:/Ruby 1.8/bin/ruby.exe\"", Gem.ruby ensure Gem.instance_variable_set("@ruby", orig_ruby) - RbConfig::CONFIG['bindir'] = orig_bindir - RbConfig::CONFIG['ruby_install_name'] = orig_ruby_install_name - RbConfig::CONFIG['EXEEXT'] = orig_exe_ext + Gem::ConfigMap[:bindir] = orig_bindir + Gem::ConfigMap[:ruby_install_name] = orig_ruby_install_name + Gem::ConfigMap[:EXEEXT] = orig_exe_ext end def test_self_ruby_path_without_spaces orig_ruby = Gem.ruby - orig_bindir = RbConfig::CONFIG['bindir'] - orig_ruby_install_name = RbConfig::CONFIG['ruby_install_name'] - orig_exe_ext = RbConfig::CONFIG['EXEEXT'] + orig_bindir = Gem::ConfigMap[:bindir] + orig_ruby_install_name = Gem::ConfigMap[:ruby_install_name] + orig_exe_ext = Gem::ConfigMap[:EXEEXT] - RbConfig::CONFIG['bindir'] = "C:/Ruby18/bin" - RbConfig::CONFIG['ruby_install_name'] = "ruby" - RbConfig::CONFIG['EXEEXT'] = ".exe" + Gem::ConfigMap[:bindir] = "C:/Ruby18/bin" + Gem::ConfigMap[:ruby_install_name] = "ruby" + Gem::ConfigMap[:EXEEXT] = ".exe" Gem.instance_variable_set("@ruby", nil) assert_equal "C:/Ruby18/bin/ruby.exe", Gem.ruby ensure Gem.instance_variable_set("@ruby", orig_ruby) - RbConfig::CONFIG['bindir'] = orig_bindir - RbConfig::CONFIG['ruby_install_name'] = orig_ruby_install_name - RbConfig::CONFIG['EXEEXT'] = orig_exe_ext + Gem::ConfigMap[:bindir] = orig_bindir + Gem::ConfigMap[:ruby_install_name] = orig_ruby_install_name + Gem::ConfigMap[:EXEEXT] = orig_exe_ext end def test_self_ruby_api_version - orig_ruby_version, RbConfig::CONFIG['ruby_version'] = RbConfig::CONFIG['ruby_version'], '1.2.3' + orig_MAJOR, Gem::ConfigMap[:MAJOR] = Gem::ConfigMap[:MAJOR], '1' + orig_MINOR, Gem::ConfigMap[:MINOR] = Gem::ConfigMap[:MINOR], '2' + orig_TEENY, Gem::ConfigMap[:TEENY] = Gem::ConfigMap[:TEENY], '3' Gem.instance_variable_set :@ruby_api_version, nil @@ -690,7 +671,9 @@ def test_self_ruby_api_version ensure Gem.instance_variable_set :@ruby_api_version, nil - RbConfig::CONFIG['ruby_version'] = orig_ruby_version + Gem::ConfigMap[:MAJOR] = orig_MAJOR + Gem::ConfigMap[:MINOR] = orig_MINOR + Gem::ConfigMap[:TEENY] = orig_TEENY end def test_self_ruby_version_1_8_5 @@ -842,7 +825,7 @@ def test_self_use_paths def test_self_user_dir parts = [@userhome, '.gem', Gem.ruby_engine] - parts << RbConfig::CONFIG['ruby_version'] unless RbConfig::CONFIG['ruby_version'].empty? + parts << Gem::ConfigMap[:ruby_version] unless Gem::ConfigMap[:ruby_version].empty? assert_equal File.join(parts), Gem.user_dir end @@ -874,7 +857,6 @@ def test_self_needs end def test_self_needs_picks_up_unresolved_deps - skip 'loading from unsafe file' if RUBY_VERSION <= "1.8.7" save_loaded_features do util_clear_gems a = util_spec "a", "1" @@ -967,7 +949,6 @@ def test_self_user_home_user_drive_and_path end def test_load_plugins - skip 'Insecure operation - chdir' if RUBY_VERSION <= "1.8.7" plugin_path = File.join "lib", "rubygems_plugin.rb" Dir.chdir @tempdir do @@ -1121,7 +1102,6 @@ def test_auto_activation_of_specific_gemdeps_file end def test_auto_activation_of_detected_gemdeps_file - skip 'Insecure operation - chdir' if RUBY_VERSION <= "1.8.7" util_clear_gems a = new_spec "a", "1", nil, "lib/a.rb" @@ -1284,7 +1264,6 @@ def test_use_gemdeps end def test_use_gemdeps_automatic - skip 'Insecure operation - chdir' if RUBY_VERSION <= "1.8.7" rubygems_gemdeps, ENV['RUBYGEMS_GEMDEPS'] = ENV['RUBYGEMS_GEMDEPS'], '-' spec = util_spec 'a', 1 @@ -1321,7 +1300,6 @@ def test_use_gemdeps_disabled end def test_use_gemdeps_specific - skip 'Insecure operation - read' if RUBY_VERSION <= "1.8.7" rubygems_gemdeps, ENV['RUBYGEMS_GEMDEPS'] = ENV['RUBYGEMS_GEMDEPS'], 'x' spec = util_spec 'a', 1 diff --git a/test/rubygems/test_gem_commands_contents_command.rb b/test/rubygems/test_gem_commands_contents_command.rb index 7f5cf22223cff5..d87e84fc829fc0 100644 --- a/test/rubygems/test_gem_commands_contents_command.rb +++ b/test/rubygems/test_gem_commands_contents_command.rb @@ -169,9 +169,9 @@ def test_execute_default_gem end expected = [ - File.join(RbConfig::CONFIG['bindir'], 'default_command'), - File.join(RbConfig::CONFIG['rubylibdir'], 'default/gem.rb'), - File.join(RbConfig::CONFIG['archdir'], 'default_gem.so') + File.join(Gem::ConfigMap[:bindir], 'default_command'), + File.join(Gem::ConfigMap[:rubylibdir], 'default/gem.rb'), + File.join(Gem::ConfigMap[:archdir], 'default_gem.so') ].sort.join "\n" assert_equal expected, @ui.output.chomp diff --git a/test/rubygems/test_gem_commands_environment_command.rb b/test/rubygems/test_gem_commands_environment_command.rb index bb7589f50de1c3..253c459d942840 100644 --- a/test/rubygems/test_gem_commands_environment_command.rb +++ b/test/rubygems/test_gem_commands_environment_command.rb @@ -26,7 +26,7 @@ def test_execute assert_match %r|INSTALLATION DIRECTORY: #{Regexp.escape @gemhome}|, @ui.output assert_match %r|RUBYGEMS PREFIX: |, @ui.output - assert_match %r|RUBY EXECUTABLE:.*#{RbConfig::CONFIG['ruby_install_name']}|, + assert_match %r|RUBY EXECUTABLE:.*#{Gem::ConfigMap[:ruby_install_name]}|, @ui.output assert_match %r|EXECUTABLE DIRECTORY:|, @ui.output assert_match %r|RUBYGEMS PLATFORMS:|, @ui.output diff --git a/test/rubygems/test_gem_commands_install_command.rb b/test/rubygems/test_gem_commands_install_command.rb index 6315cb5d95b5ed..00bbf7bae7eca2 100644 --- a/test/rubygems/test_gem_commands_install_command.rb +++ b/test/rubygems/test_gem_commands_install_command.rb @@ -316,7 +316,6 @@ def test_execute_prerelease_skipped_when_non_pre_available end def test_execute_rdoc - skip if RUBY_VERSION <= "1.8.7" specs = spec_fetcher do |fetcher| fetcher.gem 'a', 2 end @@ -560,20 +559,6 @@ def test_install_gem_ignore_dependencies_remote assert_equal %w[a-2], @cmd.installed_specs.map { |spec| spec.full_name } end - def test_install_gem_ignore_dependencies_specific_file - spec = quick_spec 'a', 2 - - util_build_gem spec - - FileUtils.mv spec.cache_file, @tempdir - - @cmd.options[:ignore_dependencies] = true - - @cmd.install_gem File.join(@tempdir, spec.file_name), nil - - assert_equal %w[a-2], @cmd.installed_specs.map { |s| s.full_name } - end - def test_parses_requirement_from_gemname spec_fetcher do |fetcher| fetcher.gem 'a', 2 diff --git a/test/rubygems/test_gem_commands_update_command.rb b/test/rubygems/test_gem_commands_update_command.rb index d259383ba2fbb2..7537c1c9c10532 100644 --- a/test/rubygems/test_gem_commands_update_command.rb +++ b/test/rubygems/test_gem_commands_update_command.rb @@ -217,7 +217,6 @@ def test_execute_dependencies end def test_execute_rdoc - skip if RUBY_VERSION <= "1.8.7" spec_fetcher do |fetcher| fetcher.gem 'a', 2 @@ -240,6 +239,7 @@ def test_execute_rdoc a2 = @specs['a-2'] + assert_path_exists File.join(a2.doc_dir, 'ri') assert_path_exists File.join(a2.doc_dir, 'rdoc') end diff --git a/test/rubygems/test_gem_dependency_installer.rb b/test/rubygems/test_gem_dependency_installer.rb index 352ebbb54ff513..0a82fa63cbbd19 100644 --- a/test/rubygems/test_gem_dependency_installer.rb +++ b/test/rubygems/test_gem_dependency_installer.rb @@ -551,7 +551,7 @@ def test_install_env_shebang env = "/\\S+/env" unless Gem.win_platform? - assert_match %r|\A#!#{env} #{RbConfig::CONFIG['ruby_install_name']}\n|, + assert_match %r|\A#!#{env} #{Gem::ConfigMap[:ruby_install_name]}\n|, File.read(File.join(@gemhome, 'bin', 'a_bin')) end diff --git a/test/rubygems/test_gem_installer.rb b/test/rubygems/test_gem_installer.rb index 54ac853135b9cf..615a9b57ba4afa 100644 --- a/test/rubygems/test_gem_installer.rb +++ b/test/rubygems/test_gem_installer.rb @@ -84,8 +84,8 @@ def test_check_executable_overwrite_default_bin_dir orig_RUBY_FRAMEWORK_VERSION = RUBY_FRAMEWORK_VERSION Object.send :remove_const, :RUBY_FRAMEWORK_VERSION end - orig_bindir = RbConfig::CONFIG['bindir'] - RbConfig::CONFIG['bindir'] = Gem.bindir + orig_bindir = Gem::ConfigMap[:bindir] + Gem::ConfigMap[:bindir] = Gem.bindir util_conflict_executable false @@ -102,7 +102,7 @@ def test_check_executable_overwrite_default_bin_dir ensure Object.const_set :RUBY_FRAMEWORK_VERSION, orig_RUBY_FRAMEWORK_VERSION if orig_RUBY_FRAMEWORK_VERSION - RbConfig::CONFIG['bindir'] = orig_bindir + Gem::ConfigMap[:bindir] = orig_bindir end def test_check_executable_overwrite_format_executable @@ -1192,7 +1192,7 @@ def test_shebang_env_shebang env_shebang = "/usr/bin/env" unless Gem.win_platform? - assert_equal("#!#{env_shebang} #{RbConfig::CONFIG['ruby_install_name']}", + assert_equal("#!#{env_shebang} #{Gem::ConfigMap[:ruby_install_name]}", shebang) end diff --git a/test/rubygems/test_gem_request_set_lockfile.rb b/test/rubygems/test_gem_request_set_lockfile.rb index 0be69bf92b30d4..9e0cab4d1a8f79 100644 --- a/test/rubygems/test_gem_request_set_lockfile.rb +++ b/test/rubygems/test_gem_request_set_lockfile.rb @@ -218,7 +218,6 @@ def test_parse_gem_specs_dependency c (~> 4) d e (~> 5.0, >= 5.0.1) - b (3-x86_64-linux) PLATFORMS #{Gem::Platform::RUBY} @@ -239,14 +238,7 @@ def test_parse_gem_specs_dependency assert lockfile_set, 'could not find a LockSet' - assert_equal %w[a-2 b-3], lockfile_set.specs.map { |tuple| tuple.full_name } - - expected = [ - Gem::Platform::RUBY, - Gem::Platform.new('x86_64-linux'), - ] - - assert_equal expected, lockfile_set.specs.map { |tuple| tuple.platform } + assert_equal %w[a-2], lockfile_set.specs.map { |tuple| tuple.full_name } spec = lockfile_set.specs.first diff --git a/test/rubygems/test_gem_specification.rb b/test/rubygems/test_gem_specification.rb index b72a5d1baf01cd..7aa9d5aeb17a4a 100644 --- a/test/rubygems/test_gem_specification.rb +++ b/test/rubygems/test_gem_specification.rb @@ -999,8 +999,8 @@ def test_initialize_copy assert_equal 'summary', spec.summary assert_same spec.summary, new_spec.summary - assert_equal %w[README.txt bin/exec ext/extconf.rb lib/file.rb - test/file.rb].sort, + assert_equal %w[lib/file.rb test/file.rb bin/exec README.txt + ext/extconf.rb].sort, spec.files refute_same spec.files, new_spec.files, 'files' @@ -1109,31 +1109,7 @@ def test_bindir_equals_nil @a2.executable = 'app' assert_equal nil, @a2.bindir - assert_equal %w[app lib/code.rb].sort, @a2.files - end - - def test_extensions_equals_nil - @a2.instance_variable_set(:@extensions, nil) - assert_equal nil, @a2.instance_variable_get(:@extensions) - assert_equal %w[lib/code.rb], @a2.files - end - - def test_test_files_equals_nil - @a2.instance_variable_set(:@test_files, nil) - assert_equal nil, @a2.instance_variable_get(:@test_files) - assert_equal %w[lib/code.rb], @a2.files - end - - def test_executables_equals_nil - @a2.instance_variable_set(:@executables, nil) - assert_equal nil, @a2.instance_variable_get(:@executables) - assert_equal %w[lib/code.rb], @a2.files - end - - def test_extra_rdoc_files_equals_nil - @a2.instance_variable_set(:@extra_rdoc_files, nil) - assert_equal nil, @a2.instance_variable_get(:@extra_rdoc_files) - assert_equal %w[lib/code.rb], @a2.files + assert_equal %w[lib/code.rb app].sort, @a2.files end def test_build_extensions @@ -1461,7 +1437,7 @@ def test_executables def test_executable_equals @a2.executable = 'app' assert_equal 'app', @a2.executable - assert_equal %w[bin/app lib/code.rb].sort, @a2.files + assert_equal %w[lib/code.rb bin/app].sort, @a2.files end def test_extensions @@ -1809,22 +1785,6 @@ def test_source assert_kind_of Gem::Source::Installed, @a1.source end - def test_source_paths - ext_spec - - @ext.require_paths = %w[lib ext foo] - @ext.extensions << 'bar/baz' - - expected = %w[ - lib - ext - foo - bar - ] - - assert_equal expected, @ext.source_paths - end - def test_full_require_paths ext_spec @@ -2475,7 +2435,7 @@ def test_validate_files assert_equal '["lib2"] are not files', e.message end - assert_equal %w[bin/exec ext/a/extconf.rb lib/code.rb lib2 test/suite.rb].sort, + assert_equal %w[lib/code.rb test/suite.rb bin/exec ext/a/extconf.rb lib2].sort, @a1.files end diff --git a/test/rubygems/test_gem_uninstaller.rb b/test/rubygems/test_gem_uninstaller.rb index 11fdaf68e22118..1eea30fb9403d6 100644 --- a/test/rubygems/test_gem_uninstaller.rb +++ b/test/rubygems/test_gem_uninstaller.rb @@ -131,23 +131,6 @@ def test_remove_executables_user_format_disabled Gem::Installer.exec_format = nil end - def test_remove_not_in_home - uninstaller = Gem::Uninstaller.new nil, :install_dir => "#{@gemhome}2" - - e = assert_raises Gem::GemNotInHomeException do - use_ui ui do - uninstaller.remove @spec - end - end - - expected = - "Gem '#{@spec.full_name}' is not installed in directory #{@gemhome}2" - - assert_equal expected, e.message - - assert_path_exists @spec.gem_dir - end - def test_path_ok_eh uninstaller = Gem::Uninstaller.new nil diff --git a/version.h b/version.h index 8553f79047718a..c361122024b2b0 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-01-31" -#define RUBY_PATCHLEVEL 14 +#define RUBY_PATCHLEVEL 13 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 1 From d985425d2801c94fae95c710815fc82b2bd0dc7e Mon Sep 17 00:00:00 2001 From: svn Date: Sat, 1 Feb 2014 08:19:15 +0000 Subject: [PATCH 008/343] * 2014-02-01 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@44787 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- version.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/version.h b/version.h index c361122024b2b0..1e17ddec77a182 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.1" -#define RUBY_RELEASE_DATE "2014-01-31" +#define RUBY_RELEASE_DATE "2014-02-01" #define RUBY_PATCHLEVEL 13 #define RUBY_RELEASE_YEAR 2014 -#define RUBY_RELEASE_MONTH 1 -#define RUBY_RELEASE_DAY 31 +#define RUBY_RELEASE_MONTH 2 +#define RUBY_RELEASE_DAY 1 #include "ruby/version.h" From 484a6ffb788fd0f0ee5fc6448125a7e0980c0c4d Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 1 Feb 2014 08:35:30 +0000 Subject: [PATCH 009/343] merge revision(s) 44373: [Backport #9417] test_alias.rb: rename duplicate name * test/ruby/test_alias.rb (test_alias_wb_miss): rename duplicate name to get rid of redefinition. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@44788 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_alias.rb | 2 +- version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/ruby/test_alias.rb b/test/ruby/test_alias.rb index cef39d690f6429..956fdb41f05b0d 100644 --- a/test/ruby/test_alias.rb +++ b/test/ruby/test_alias.rb @@ -121,7 +121,7 @@ def test_super_in_aliased_module_method # fails in 1.8 assert_equal([:Base, :M], SuperInAliasedModuleMethod::Derived.new.bar) end - def test_alias + def test_alias_wb_miss assert_normal_exit %q{ require 'stringio' GC.verify_internal_consistency diff --git a/version.h b/version.h index 1e17ddec77a182..1bc3dec1f1a5ba 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-01" -#define RUBY_PATCHLEVEL 13 +#define RUBY_PATCHLEVEL 14 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 3da0a0cead8eb70dba54d291151d2e9458a0159d Mon Sep 17 00:00:00 2001 From: naruse Date: Sun, 2 Feb 2014 13:46:46 +0000 Subject: [PATCH 010/343] merge revision(s) 44630,44631: [Backport #9403] * lib/delegate.rb (Delegator): keep source information methods which start and end with '__'. [ruby-core:58572] [Bug #9155] which start and end with '__'. [ruby-core:59718] [Bug #9403] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@44794 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 ++++ lib/delegate.rb | 2 +- test/test_delegate.rb | 57 +++++++++++++++++++++++++++++++++++++++++++ version.h | 6 ++--- 4 files changed, 66 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 601436f3261c95..65ab2491f772e6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sun Feb 2 22:39:28 2014 Nobuyoshi Nakada + + * lib/delegate.rb (Delegator): keep source information methods + which start and end with '__'. [ruby-core:59718] [Bug #9403] + Fri Jan 31 12:10:16 2014 Nobuyoshi Nakada * proc.c (mnew_from_me): keep iclass as-is, to make inheritance diff --git a/lib/delegate.rb b/lib/delegate.rb index c33f7e40df766c..d7902292f03355 100644 --- a/lib/delegate.rb +++ b/lib/delegate.rb @@ -48,7 +48,7 @@ class Delegator < BasicObject undef_method m end private_instance_methods.each do |m| - if /\Ablock_given\?\z|iterator\?\z|\A__raise__\z/ =~ m + if /\Ablock_given\?\z|iterator\?\z|\A__.*__\z/ =~ m next end undef_method m diff --git a/test/test_delegate.rb b/test/test_delegate.rb index ca65ef3daadb52..6270cc61b6e45d 100644 --- a/test/test_delegate.rb +++ b/test/test_delegate.rb @@ -180,4 +180,61 @@ def test_global_method_if_no_target x = assert_nothing_raised(ArgumentError, bug9155) {break Bug9155.new(1)} assert_equal(1, x.to_i, bug9155) end + + class Bug9403 + Name = '[ruby-core:59718] [Bug #9403]' + SD = SimpleDelegator.new(new) + class << SD + def method_name + __method__ + end + def callee_name + __callee__ + end + alias aliased_name callee_name + def dir_name + __dir__ + end + end + dc = DelegateClass(self) + dc.class_eval do + def method_name + __method__ + end + def callee_name + __callee__ + end + alias aliased_name callee_name + def dir_name + __dir__ + end + end + DC = dc.new(new) + end + + def test_method_in_simple_delegator + assert_equal(:method_name, Bug9403::SD.method_name, Bug9403::Name) + end + + def test_callee_in_simple_delegator + assert_equal(:callee_name, Bug9403::SD.callee_name, Bug9403::Name) + assert_equal(:aliased_name, Bug9403::SD.aliased_name, Bug9403::Name) + end + + def test_dir_in_simple_delegator + assert_equal(__dir__, Bug9403::SD.dir_name, Bug9403::Name) + end + + def test_method_in_delegator_class + assert_equal(:method_name, Bug9403::DC.method_name, Bug9403::Name) + end + + def test_callee_in_delegator_class + assert_equal(:callee_name, Bug9403::DC.callee_name, Bug9403::Name) + assert_equal(:aliased_name, Bug9403::DC.aliased_name, Bug9403::Name) + end + + def test_dir_in_delegator_class + assert_equal(__dir__, Bug9403::DC.dir_name, Bug9403::Name) + end end diff --git a/version.h b/version.h index 1bc3dec1f1a5ba..a62e4f128d9a87 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.1" -#define RUBY_RELEASE_DATE "2014-02-01" -#define RUBY_PATCHLEVEL 14 +#define RUBY_RELEASE_DATE "2014-02-02" +#define RUBY_PATCHLEVEL 15 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 -#define RUBY_RELEASE_DAY 1 +#define RUBY_RELEASE_DAY 2 #include "ruby/version.h" From 673745f7999bdb5b8c0909f00b7d0fa14a0af43c Mon Sep 17 00:00:00 2001 From: naruse Date: Wed, 5 Feb 2014 02:35:13 +0000 Subject: [PATCH 011/343] merge revision(s) 44803: [Backport #9478] * string.c (rb_str_modify_expand): enable capacity and disable assocation with packed objects when setting capa, so that pack("p") string fails to unpack properly after modified. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@44819 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ string.c | 1 + test/ruby/test_pack.rb | 1 + version.h | 6 +++--- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 65ab2491f772e6..465620e557e9fc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Wed Feb 5 11:13:21 2014 Nobuyoshi Nakada + + * string.c (rb_str_modify_expand): enable capacity and disable + assocation with packed objects when setting capa, so that + pack("p") string fails to unpack properly after modified. + Sun Feb 2 22:39:28 2014 Nobuyoshi Nakada * lib/delegate.rb (Delegator): keep source information methods diff --git a/string.c b/string.c index 900f900f160dff..cc307866dbfb68 100644 --- a/string.c +++ b/string.c @@ -1465,6 +1465,7 @@ rb_str_modify_expand(VALUE str, long expand) int termlen = TERM_LEN(str); if (!STR_EMBED_P(str)) { REALLOC_N(RSTRING(str)->as.heap.ptr, char, capa + termlen); + STR_UNSET_NOCAPA(str); RSTRING(str)->as.heap.aux.capa = capa; } else if (capa + termlen > RSTRING_EMBED_LEN_MAX + 1) { diff --git a/test/ruby/test_pack.rb b/test/ruby/test_pack.rb index 621a06beba5b25..3f0931bdc0cfb2 100644 --- a/test/ruby/test_pack.rb +++ b/test/ruby/test_pack.rb @@ -181,6 +181,7 @@ def test_pack_p assert_equal a[0], a.pack("p").unpack("p")[0] assert_equal a, a.pack("p").freeze.unpack("p*") assert_raise(ArgumentError) { (a.pack("p") + "").unpack("p*") } + assert_raise(ArgumentError) { (a.pack("p") << "d").unpack("p*") } end def test_format_string_modified diff --git a/version.h b/version.h index a62e4f128d9a87..98bc2a3642a193 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.1" -#define RUBY_RELEASE_DATE "2014-02-02" -#define RUBY_PATCHLEVEL 15 +#define RUBY_RELEASE_DATE "2014-02-05" +#define RUBY_PATCHLEVEL 16 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 -#define RUBY_RELEASE_DAY 2 +#define RUBY_RELEASE_DAY 5 #include "ruby/version.h" From bda2300c4d50a73bcda66f886c362e7f4da82da5 Mon Sep 17 00:00:00 2001 From: naruse Date: Wed, 5 Feb 2014 04:05:53 +0000 Subject: [PATCH 012/343] merge revision(s) 44501: [Backport #9353] * struct.c (rb_struct_set): return assigned value from setter method rather than struct object. [Bug #9353] [ruby-core:59509] * test/ruby/test_struct.rb (test_setter_method_returns_value): add test git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@44826 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ struct.c | 3 ++- test/ruby/test_struct.rb | 6 ++++++ version.h | 2 +- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 465620e557e9fc..d8aae5a0433d4b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Wed Feb 5 11:48:42 2014 Charlie Somerville + + * struct.c (rb_struct_set): return assigned value from setter method + rather than struct object. [Bug #9353] [ruby-core:59509] + + * test/ruby/test_struct.rb (test_setter_method_returns_value): add test + Wed Feb 5 11:13:21 2014 Nobuyoshi Nakada * string.c (rb_str_modify_expand): enable capacity and disable diff --git a/struct.c b/struct.c index 6be512eaee8132..2e026fbc7fdef5 100644 --- a/struct.c +++ b/struct.c @@ -156,7 +156,8 @@ rb_struct_set(VALUE obj, VALUE val) for (i=0; i Date: Wed, 5 Feb 2014 11:29:40 +0000 Subject: [PATCH 013/343] merge revision(s) 44512: [Backport #9340] * array.c (ary_add_hash): Fix consistency issue between Array#uniq and Array#uniq! [Bug #9340] [ruby-core:59457] * test/ruby/test_array.rb (class TestArray): regression test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@44839 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ array.c | 4 +++- test/ruby/test_array.rb | 5 +++++ version.h | 2 +- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index d8aae5a0433d4b..01018edd175a1e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Wed Feb 5 17:55:28 2014 Aman Gupta + + * array.c (ary_add_hash): Fix consistency issue between Array#uniq and + Array#uniq! [Bug #9340] [ruby-core:59457] + * test/ruby/test_array.rb (class TestArray): regression test for above. + Wed Feb 5 11:48:42 2014 Charlie Somerville * struct.c (rb_struct_set): return assigned value from setter method diff --git a/array.c b/array.c index 45713c55b03198..ff77a3ed949842 100644 --- a/array.c +++ b/array.c @@ -3904,7 +3904,9 @@ ary_add_hash(VALUE hash, VALUE ary) for (i=0; i Date: Wed, 5 Feb 2014 12:43:19 +0000 Subject: [PATCH 014/343] merge revision(s) 44517,44518,44519,44523: [Backport #9354] * lib/timeout.rb (Timeout#timeout): when a custom exception is given, no instance is needed to be caught, so defer creating new instance until it is raised. [ruby-core:59511] [Bug #9354] * lib/timeout.rb (Timeout#timeout): should not rescue ordinarily raised ExitException, which should not be thrown. * lib/timeout.rb (Timeout::ExitException.catch): set @thread only if it ought to be caught. * lib/timeout.rb (Timeout::ExitException.catch): pass arguments for new instance. * lib/timeout.rb (Timeout::ExitException#exception): fallback to Timeout::Error if couldn't throw. [ruby-dev:47872] [Bug #9380] * lib/timeout.rb (Timeout#timeout): initialize ExitException with message for the fallback case. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@44841 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 23 +++++++++++++++++++++++ lib/timeout.rb | 34 +++++++++++++++++++++++++--------- test/test_timeout.rb | 29 +++++++++++++++++++++++++++++ version.h | 2 +- 4 files changed, 78 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 01018edd175a1e..c585352f63dce0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,26 @@ +Wed Feb 5 21:12:02 2014 Nobuyoshi Nakada + + * lib/timeout.rb (Timeout::ExitException.catch): pass arguments + for new instance. + + * lib/timeout.rb (Timeout::ExitException#exception): fallback to + Timeout::Error if couldn't throw. [ruby-dev:47872] [Bug #9380] + + * lib/timeout.rb (Timeout#timeout): initialize ExitException with + message for the fallback case. + +Wed Feb 5 21:12:02 2014 Nobuyoshi Nakada + + * lib/timeout.rb (Timeout#timeout): should not rescue ordinarily + raised ExitException, which should not be thrown. + + * lib/timeout.rb (Timeout::ExitException.catch): set @thread only if + it ought to be caught. + + * lib/timeout.rb (Timeout#timeout): when a custom exception is given, + no instance is needed to be caught, so defer creating new instance + until it is raised. [ruby-core:59511] [Bug #9354] + Wed Feb 5 17:55:28 2014 Aman Gupta * array.c (ary_add_hash): Fix consistency issue between Array#uniq and diff --git a/lib/timeout.rb b/lib/timeout.rb index ad951d2ffa406e..d805dce2a3fdad 100644 --- a/lib/timeout.rb +++ b/lib/timeout.rb @@ -26,16 +26,25 @@ module Timeout class Error < RuntimeError end class ExitException < ::Exception # :nodoc: - attr_reader :klass, :thread + attr_reader :thread - def initialize(*) - super - @thread = Thread.current - freeze + def self.catch(*args) + exc = new(*args) + exc.instance_variable_set(:@thread, Thread.current) + exc.freeze + ::Kernel.catch(exc) {yield exc} end def exception(*) - throw(self, caller) if self.thread == Thread.current + if self.thread == Thread.current + bt = caller + begin + throw(self, bt) + rescue ArgumentError => e + raise unless e.message.start_with?("uncaught throw") + raise Error, message, backtrace + end + end self end end @@ -67,7 +76,7 @@ def timeout(sec, klass = nil) #:yield: +sec+ return yield(sec) if sec == nil or sec.zero? message = "execution expired" e = Error - bt = catch((klass||ExitException).new) do |exception| + bl = proc do |exception| begin x = Thread.current y = Thread.start { @@ -80,8 +89,6 @@ def timeout(sec, klass = nil) #:yield: +sec+ end } return yield(sec) - rescue (klass||ExitException) => e - e.backtrace ensure if y y.kill @@ -89,6 +96,15 @@ def timeout(sec, klass = nil) #:yield: +sec+ end end end + if klass + begin + bl.call(klass) + rescue klass => e + bt = e.backtrace + end + else + bt = ExitException.catch(message, &bl) + end rej = /\A#{Regexp.quote(__FILE__)}:#{__LINE__-4}\z/o bt.reject! {|m| rej =~ m} level = -caller(CALLER_OFFSET).size diff --git a/test/test_timeout.rb b/test/test_timeout.rb index 9d51ca5be3b625..e849cc5741282f 100644 --- a/test/test_timeout.rb +++ b/test/test_timeout.rb @@ -57,4 +57,33 @@ def test_rescue_exit end assert_raise_with_message(exc, /execution expired/) {raise e if e} end + + def test_custom_exception + bug9354 = '[ruby-core:59511] [Bug #9354]' + err = Class.new(StandardError) do + def initialize(msg) super end + end + assert_nothing_raised(ArgumentError, bug9354) do + assert_equal(:ok, timeout(100, err) {:ok}) + end + end + + def test_exit_exception + assert_raise_with_message(Timeout::ExitException, "boon") do + Timeout.timeout(10, Timeout::ExitException) do + raise Timeout::ExitException, "boon" + end + end + end + + def test_enumerator_next + bug9380 = '[ruby-dev:47872] [Bug #9380]: timeout in Enumerator#next' + e = (o=Object.new).to_enum + def o.each + sleep + end + assert_raise_with_message(Timeout::Error, 'execution expired', bug9380) do + Timeout.timeout(0.01) {e.next} + end + end end diff --git a/version.h b/version.h index 7e623c538d6eb4..3511d6415dcbc3 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-05" -#define RUBY_PATCHLEVEL 18 +#define RUBY_PATCHLEVEL 19 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 1b05b4f4abbb7352f04e718ba7a4c62859f91a92 Mon Sep 17 00:00:00 2001 From: naruse Date: Wed, 5 Feb 2014 13:08:32 +0000 Subject: [PATCH 015/343] merge revision(s) 44490,44496: [Backport #9352] * ext/socket/socket.c (rsock_sys_fail_host_port): save and restore errno before calling rb_sys_fail_str to prevent [BUG] errno == 0. Patch by Eric Wong. [ruby-core:59498] [Bug #9352] * ext/socket/socket.c (rsock_sys_fail_path): ditto * ext/socket/socket.c (rsock_sys_fail_sockaddr): ditto * ext/socket/socket.c (rsock_sys_fail_raddrinfo): ditto * ext/socket/socket.c (rsock_sys_fail_raddrinfo_or_sockaddr): ditto * ext/socket/socket.c (rsock_syserr_fail_host_port): add errno argument version anduse rb_syserr_fail_str() instead of rb_sys_fail_str() with restoring errno. * ext/socket/socket.c (rsock_syserr_fail_path): ditto, and rb_syserr_fail(). * ext/socket/socket.c (rsock_sys_fail_sockaddr): ditto, use rsock_syserr_fail_raddrinfo(). * ext/socket/socket.c (rsock_sys_fail_raddrinfo): ditto. * ext/socket/socket.c (setup_domain_and_type): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@44842 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 27 ++++++++++++++++++++++++ ext/socket/rubysocket.h | 6 ++++++ ext/socket/socket.c | 46 ++++++++++++++++++++++++++++++++++------- version.h | 2 +- 4 files changed, 73 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index c585352f63dce0..a208fa97384b84 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,30 @@ +Wed Feb 5 21:57:40 2014 Nobuyoshi Nakada + + * ext/socket/socket.c (rsock_syserr_fail_host_port): add errno + argument version anduse rb_syserr_fail_str() instead of + rb_sys_fail_str() with restoring errno. + + * ext/socket/socket.c (rsock_syserr_fail_path): ditto, and + rb_syserr_fail(). + + * ext/socket/socket.c (rsock_sys_fail_sockaddr): ditto, use + rsock_syserr_fail_raddrinfo(). + + * ext/socket/socket.c (rsock_sys_fail_raddrinfo): ditto. + + * ext/socket/socket.c (setup_domain_and_type): ditto. + +Wed Feb 5 21:57:40 2014 Eric Wong + + * ext/socket/socket.c (rsock_sys_fail_host_port): save and restore errno + before calling rb_sys_fail_str to prevent [BUG] errno == 0. + Patch by Eric Wong. [ruby-core:59498] [Bug #9352] + + * ext/socket/socket.c (rsock_sys_fail_path): ditto + * ext/socket/socket.c (rsock_sys_fail_sockaddr): ditto + * ext/socket/socket.c (rsock_sys_fail_raddrinfo): ditto + * ext/socket/socket.c (rsock_sys_fail_raddrinfo_or_sockaddr): ditto + Wed Feb 5 21:12:02 2014 Nobuyoshi Nakada * lib/timeout.rb (Timeout::ExitException.catch): pass arguments diff --git a/ext/socket/rubysocket.h b/ext/socket/rubysocket.h index 97c02fc4101b89..c74fb326ec16c4 100644 --- a/ext/socket/rubysocket.h +++ b/ext/socket/rubysocket.h @@ -374,6 +374,12 @@ void rsock_init_sockopt(void); void rsock_init_sockifaddr(void); void rsock_init_socket_init(void); +NORETURN(void rsock_syserr_fail_host_port(int err, const char *, VALUE, VALUE)); +NORETURN(void rsock_syserr_fail_path(int err, const char *, VALUE)); +NORETURN(void rsock_syserr_fail_sockaddr(int err, const char *mesg, struct sockaddr *addr, socklen_t len)); +NORETURN(void rsock_syserr_fail_raddrinfo(int err, const char *mesg, VALUE rai)); +NORETURN(void rsock_syserr_fail_raddrinfo_or_sockaddr(int err, const char *mesg, VALUE addr, VALUE rai)); + NORETURN(void rsock_sys_fail_host_port(const char *, VALUE, VALUE)); NORETURN(void rsock_sys_fail_path(const char *, VALUE)); NORETURN(void rsock_sys_fail_sockaddr(const char *, struct sockaddr *addr, socklen_t len)); diff --git a/ext/socket/socket.c b/ext/socket/socket.c index 5fd74652c629e0..c7fc5b76cbf348 100644 --- a/ext/socket/socket.c +++ b/ext/socket/socket.c @@ -14,6 +14,12 @@ static VALUE sock_s_unpack_sockaddr_in(VALUE, VALUE); void rsock_sys_fail_host_port(const char *mesg, VALUE host, VALUE port) +{ + rsock_syserr_fail_host_port(errno, mesg, host, port); +} + +void +rsock_syserr_fail_host_port(int err, const char *mesg, VALUE host, VALUE port) { VALUE message; @@ -22,13 +28,20 @@ rsock_sys_fail_host_port(const char *mesg, VALUE host, VALUE port) message = rb_sprintf("%s for \"%s\" port %s", mesg, StringValueCStr(host), StringValueCStr(port)); - rb_sys_fail_str(message); + rb_syserr_fail_str(err, message); } void rsock_sys_fail_path(const char *mesg, VALUE path) +{ + rsock_syserr_fail_path(errno, mesg, path); +} + +void +rsock_syserr_fail_path(int err, const char *mesg, VALUE path) { VALUE message; + if (RB_TYPE_P(path, T_STRING)) { if (memchr(RSTRING_PTR(path), '\0', RSTRING_LEN(path))) { path = rb_str_inspect(path); @@ -39,45 +52,64 @@ rsock_sys_fail_path(const char *mesg, VALUE path) message = rb_sprintf("%s for \"%s\"", mesg, StringValueCStr(path)); } - rb_sys_fail_str(message); + rb_syserr_fail_str(err, message); } else { - rb_sys_fail(mesg); + rb_syserr_fail(err, mesg); } } void rsock_sys_fail_sockaddr(const char *mesg, struct sockaddr *addr, socklen_t len) +{ + rsock_syserr_fail_sockaddr(errno, mesg, addr, len); +} + +void +rsock_syserr_fail_sockaddr(int err, const char *mesg, struct sockaddr *addr, socklen_t len) { VALUE rai; rai = rsock_addrinfo_new(addr, len, PF_UNSPEC, 0, 0, Qnil, Qnil); - rsock_sys_fail_raddrinfo(mesg, rai); + rsock_syserr_fail_raddrinfo(err, mesg, rai); } void rsock_sys_fail_raddrinfo(const char *mesg, VALUE rai) +{ + rsock_syserr_fail_raddrinfo(errno, mesg, rai); +} + +void +rsock_syserr_fail_raddrinfo(int err, const char *mesg, VALUE rai) { VALUE str, message; str = rsock_addrinfo_inspect_sockaddr(rai); message = rb_sprintf("%s for %s", mesg, StringValueCStr(str)); - rb_sys_fail_str(message); + rb_syserr_fail_str(err, message); } void rsock_sys_fail_raddrinfo_or_sockaddr(const char *mesg, VALUE addr, VALUE rai) +{ + rsock_syserr_fail_raddrinfo_or_sockaddr(errno, mesg, addr, rai); +} + +void +rsock_syserr_fail_raddrinfo_or_sockaddr(int err, const char *mesg, VALUE addr, VALUE rai) { if (NIL_P(rai)) { StringValue(addr); - rsock_sys_fail_sockaddr(mesg, + + rsock_syserr_fail_sockaddr(err, mesg, (struct sockaddr *)RSTRING_PTR(addr), (socklen_t)RSTRING_LEN(addr)); /* overflow should be checked already */ } else - rsock_sys_fail_raddrinfo(mesg, rai); + rsock_syserr_fail_raddrinfo(err, mesg, rai); } static void diff --git a/version.h b/version.h index 3511d6415dcbc3..97d3d9c0745d60 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-05" -#define RUBY_PATCHLEVEL 19 +#define RUBY_PATCHLEVEL 20 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From e7a2c4251e98cd515d861facbba2fa86983dfb89 Mon Sep 17 00:00:00 2001 From: naruse Date: Wed, 5 Feb 2014 13:41:03 +0000 Subject: [PATCH 016/343] merge revision(s) 44527,44552,44553: * vm_insnhelper.c (vm_search_super_method): when super called in a bound UnboundMethod generated from a module, no superclass is found since the current defined class is the module, then call method_missing in that case. [ruby-core:59619] [Bug #9377] * vm_insnhelper.c (vm_search_super_method): allow bound method from a module, yet another method transplanting. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@44843 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 12 ++++++++++++ test/ruby/test_super.rb | 13 +++++++++++++ version.h | 2 +- vm_insnhelper.c | 9 ++++++++- 4 files changed, 34 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index a208fa97384b84..922bdcafdd79f8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +Wed Feb 5 22:28:41 2014 Nobuyoshi Nakada + + * vm_insnhelper.c (vm_search_super_method): allow bound method from a + module, yet another method transplanting. + +Wed Feb 5 22:28:41 2014 Nobuyoshi Nakada + + * vm_insnhelper.c (vm_search_super_method): when super called in a + bound UnboundMethod generated from a module, no superclass is + found since the current defined class is the module, then call + method_missing in that case. [ruby-core:59619] [Bug #9377] + Wed Feb 5 21:57:40 2014 Nobuyoshi Nakada * ext/socket/socket.c (rsock_syserr_fail_host_port): add errno diff --git a/test/ruby/test_super.rb b/test/ruby/test_super.rb index c5f724ebb8c900..82d6e19ec4ba1c 100644 --- a/test/ruby/test_super.rb +++ b/test/ruby/test_super.rb @@ -440,4 +440,17 @@ def foo assert_equal(:ok, o.method(:foo).call, bug9315) end end + + def test_missing_super_in_module_unbound_method + bug9377 = '[ruby-core:59619] [Bug #9377]' + + a = Module.new do + def foo; super end + end + + m = a.instance_method(:foo).bind(Object.new) + assert_raise(NoMethodError, bug9377) do + m.call + end + end end diff --git a/version.h b/version.h index 97d3d9c0745d60..0e69916f3cd37b 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-05" -#define RUBY_PATCHLEVEL 20 +#define RUBY_PATCHLEVEL 21 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 diff --git a/vm_insnhelper.c b/vm_insnhelper.c index c8cbaa07bf4a18..edf4e46652dc37 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -2004,7 +2004,8 @@ vm_search_super_method(rb_thread_t *th, rb_control_frame_t *reg_cfp, rb_call_inf current_defined_class = RCLASS_REFINED_CLASS(current_defined_class); } - if (!FL_TEST(current_defined_class, RMODULE_INCLUDED_INTO_REFINEMENT) && + if (BUILTIN_TYPE(current_defined_class) != T_MODULE && + !FL_TEST(current_defined_class, RMODULE_INCLUDED_INTO_REFINEMENT) && !rb_obj_is_kind_of(ci->recv, current_defined_class)) { VALUE m = RB_TYPE_P(current_defined_class, T_ICLASS) ? RBASIC(current_defined_class)->klass : current_defined_class; @@ -2024,6 +2025,12 @@ vm_search_super_method(rb_thread_t *th, rb_control_frame_t *reg_cfp, rb_call_inf " by define_method() is not supported." " Specify all arguments explicitly."); } + if (!ci->klass) { + /* bound instance method of module */ + ci->aux.missing_reason = NOEX_SUPER; + CI_SET_FASTPATH(ci, vm_call_method_missing, 1); + return; + } /* TODO: use inline cache */ ci->me = rb_method_entry(ci->klass, ci->mid, &ci->defined_class); From 72d18038d914e7c2e383f09bae5e5bd7b06721a8 Mon Sep 17 00:00:00 2001 From: naruse Date: Wed, 5 Feb 2014 14:53:48 +0000 Subject: [PATCH 017/343] merge revision(s) 44525,44534,44537: [Backport #9381] * hash.c (rb_objid_hash): return hash value from object ID with a salt, extract from rb_any_hash(). * object.c (rb_obj_hash): return same value as rb_any_hash(). fix r44125. [ruby-core:59638] [Bug #9381] * hash.c (rb_any_hash): should treat the return value of rb_objid_hash() as `long', because ruby assumes the object id of an object is `long'. this fixes test failures on mswin64 introduced at r44525. * hash.c (rb_objid_hash): should return `long'. brushup r44534. * object.c (rb_obj_hash): follow above change. as `long', because ruby assumes the hash value of the object id of an object is `long'. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@44846 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 21 +++++++++++++++++++++ hash.c | 15 ++++++++++++--- object.c | 4 ++-- test/ruby/test_hash.rb | 21 +++++++++++++++++++++ version.h | 2 +- 5 files changed, 57 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 922bdcafdd79f8..d8a73d3aec6257 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,24 @@ +Wed Feb 5 23:43:30 2014 NAKAMURA Usaku + + * hash.c (rb_objid_hash): should return `long'. brushup r44534. + + * object.c (rb_obj_hash): follow above change. + +Wed Feb 5 23:43:30 2014 NAKAMURA Usaku + + * hash.c (rb_any_hash): should treat the return value of rb_objid_hash() + as `long', because ruby assumes the hash value of the object id of + an object is `long'. + this fixes test failures on mswin64 introduced at r44525. + +Wed Feb 5 23:43:30 2014 Nobuyoshi Nakada + + * hash.c (rb_objid_hash): return hash value from object ID with a + salt, extract from rb_any_hash(). + + * object.c (rb_obj_hash): return same value as rb_any_hash(). + fix r44125. [ruby-core:59638] [Bug #9381] + Wed Feb 5 22:28:41 2014 Nobuyoshi Nakada * vm_insnhelper.c (vm_search_super_method): allow bound method from a diff --git a/hash.c b/hash.c index 0cbc46baf5f039..1c285c2b232df2 100644 --- a/hash.c +++ b/hash.c @@ -123,6 +123,8 @@ rb_hash(VALUE obj) return hval; } +long rb_objid_hash(st_index_t index); + static st_index_t rb_any_hash(VALUE a) { @@ -131,9 +133,7 @@ rb_any_hash(VALUE a) if (SPECIAL_CONST_P(a)) { if (a == Qundef) return 0; - hnum = rb_hash_start((st_index_t)a); - hnum = rb_hash_uint(hnum, (st_index_t)rb_any_hash); - hnum = rb_hash_end(hnum); + hnum = rb_objid_hash((st_index_t)a); } else if (BUILTIN_TYPE(a) == T_STRING) { hnum = rb_str_hash(a); @@ -146,6 +146,15 @@ rb_any_hash(VALUE a) return (st_index_t)RSHIFT(hnum, 1); } +long +rb_objid_hash(st_index_t index) +{ + st_index_t hnum = rb_hash_start(index); + hnum = rb_hash_uint(hnum, (st_index_t)rb_any_hash); + hnum = rb_hash_end(hnum); + return hnum; +} + static const struct st_hash_type objhash = { rb_any_cmp, rb_any_hash, diff --git a/object.c b/object.c index 466ec754929987..bb43b4617e5cd1 100644 --- a/object.c +++ b/object.c @@ -161,6 +161,7 @@ rb_obj_equal(VALUE obj1, VALUE obj2) VALUE rb_obj_hash(VALUE obj) { + long rb_objid_hash(st_index_t index); VALUE oid = rb_obj_id(obj); #if SIZEOF_LONG == SIZEOF_VOIDP st_index_t index = NUM2LONG(oid); @@ -169,8 +170,7 @@ rb_obj_hash(VALUE obj) #else # error not supported #endif - st_index_t h = rb_hash_end(rb_hash_start(index)); - return LONG2FIX(h); + return LONG2FIX(rb_objid_hash(index)); } /* diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb index 910da9374a1106..c872b11a3c6c97 100644 --- a/test/ruby/test_hash.rb +++ b/test/ruby/test_hash.rb @@ -1228,6 +1228,27 @@ def hash assert_no_memory_leak([], prepare, code, bug9187) end + def test_wrapper_of_special_const + bug9381 = '[ruby-core:59638] [Bug #9381]' + + wrapper = Class.new do + def initialize(obj) + @obj = obj + end + + def hash + @obj.hash + end + + def eql?(other) + @obj.eql?(other) + end + end + + hash = {5 => bug9381} + assert_equal(bug9381, hash[wrapper.new(5)]) + end + class TestSubHash < TestHash class SubHash < Hash def reject(*) diff --git a/version.h b/version.h index 0e69916f3cd37b..7b9f857e619f87 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-05" -#define RUBY_PATCHLEVEL 21 +#define RUBY_PATCHLEVEL 22 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From eef4a3cd72a4010b56e8aec2f1fe7c4d14333b5a Mon Sep 17 00:00:00 2001 From: naruse Date: Wed, 5 Feb 2014 14:57:11 +0000 Subject: [PATCH 018/343] merge revision(s) 44583: [Backport #9302] * ext/thread/thread.c (rb_szqueue_push): check GET_SZQUEUE_WAITERS instead of GET_QUEUE_WAITERS to prevent deadlock. Patch by Eric Wong. [Bug #9302] [ruby-core:59324] * test/thread/test_queue.rb: add test git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@44847 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ ext/thread/thread.c | 2 +- test/thread/test_queue.rb | 23 +++++++++++++++++++++++ version.h | 2 +- 4 files changed, 33 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index d8a73d3aec6257..1a2ad053669539 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Wed Feb 5 23:57:05 2014 Charlie Somerville + + * ext/thread/thread.c (rb_szqueue_push): check GET_SZQUEUE_WAITERS + instead of GET_QUEUE_WAITERS to prevent deadlock. Patch by Eric Wong. + [Bug #9302] [ruby-core:59324] + + * test/thread/test_queue.rb: add test + Wed Feb 5 23:43:30 2014 NAKAMURA Usaku * hash.c (rb_objid_hash): should return `long'. brushup r44534. diff --git a/ext/thread/thread.c b/ext/thread/thread.c index b8be5d883ff3f4..208d1172dfb3ab 100644 --- a/ext/thread/thread.c +++ b/ext/thread/thread.c @@ -459,7 +459,7 @@ static VALUE rb_szqueue_push(VALUE self, VALUE obj) { struct waiting_delete args; - args.waiting = GET_QUEUE_WAITERS(self); + args.waiting = GET_SZQUEUE_WAITERS(self); args.th = rb_thread_current(); while (queue_length(self) >= GET_SZQUEUE_ULONGMAX(self)) { diff --git a/test/thread/test_queue.rb b/test/thread/test_queue.rb index 563b91e748e72b..438e1e75e3edd4 100644 --- a/test/thread/test_queue.rb +++ b/test/thread/test_queue.rb @@ -134,6 +134,29 @@ def test_sized_queue_clear_return_value assert_same q, retval end + def test_sized_queue_throttle + q = SizedQueue.new(1) + i = 0 + consumer = Thread.new do + while q.pop + i += 1 + Thread.pass + end + end + nprod = 4 + npush = 100 + + producer = nprod.times.map do + Thread.new do + npush.times { q.push(true) } + end + end + producer.each(&:join) + q.push(nil) + consumer.join + assert_equal(nprod * npush, i) + end + def test_queue_thread_raise q = Queue.new th1 = Thread.new do diff --git a/version.h b/version.h index 7b9f857e619f87..4ebbd65adfe68d 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-05" -#define RUBY_PATCHLEVEL 22 +#define RUBY_PATCHLEVEL 23 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 1f478676c4636c2a31dc5dbbcfcaa06edd6a8a8e Mon Sep 17 00:00:00 2001 From: naruse Date: Wed, 5 Feb 2014 15:47:37 +0000 Subject: [PATCH 019/343] merge revision(s) 44555: test_weakref.rb: find collected weakref * test/test_weakref.rb (test_recycled): retry and find a WeakRef whose the target is collected, to fix circumstance dependent. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@44850 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/test_weakref.rb | 11 ++++++++--- version.h | 6 +++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/test/test_weakref.rb b/test/test_weakref.rb index 85820b17b8af70..f12e943423c61c 100644 --- a/test/test_weakref.rb +++ b/test/test_weakref.rb @@ -19,9 +19,14 @@ def test_ref end def test_recycled - weak = make_weakref - ObjectSpace.garbage_collect - ObjectSpace.garbage_collect + weaks = [] + weak = nil + 100.times do + weaks << make_weakref + ObjectSpace.garbage_collect + ObjectSpace.garbage_collect + break if weak = weaks.find {|w| !w.weakref_alive?} + end assert_raise(WeakRef::RefError) {weak.to_s} assert_not_predicate(weak, :weakref_alive?) end diff --git a/version.h b/version.h index 4ebbd65adfe68d..a7c0dc8624a296 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.1" -#define RUBY_RELEASE_DATE "2014-02-05" -#define RUBY_PATCHLEVEL 23 +#define RUBY_RELEASE_DATE "2014-02-06" +#define RUBY_PATCHLEVEL 24 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 -#define RUBY_RELEASE_DAY 5 +#define RUBY_RELEASE_DAY 6 #include "ruby/version.h" From 39cb7840950e87a4a77f066fd07dac6bb2e0b41c Mon Sep 17 00:00:00 2001 From: naruse Date: Thu, 6 Feb 2014 02:24:40 +0000 Subject: [PATCH 020/343] merge revision(s) 44853: [Backport #9490] * gc.c (ruby_gc_set_params): if RUBY_GC_OLDMALLOC_LIMIT is provided, then set objspace->rgengc.oldmalloc_increase_limit. Without this fix, the env variable RUBY_GC_OLDMALLOC_LIMIT does not work. * gc.c (get_envparam_int): accept a value equals to lowerbounds. * gc.c (get_envparam_double): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@44856 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 11 +++++++++++ gc.c | 13 +++++++++---- version.h | 2 +- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1a2ad053669539..465c45dec77b2e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +Thu Feb 6 11:23:59 2014 Koichi Sasada + + * gc.c (ruby_gc_set_params): if RUBY_GC_OLDMALLOC_LIMIT is provided, + then set objspace->rgengc.oldmalloc_increase_limit. + Without this fix, the env variable RUBY_GC_OLDMALLOC_LIMIT + does not work. + + * gc.c (get_envparam_int): accept a value equals to lowerbounds. + + * gc.c (get_envparam_double): ditto. + Wed Feb 5 23:57:05 2014 Charlie Somerville * ext/thread/thread.c (rb_szqueue_push): check GET_SZQUEUE_WAITERS diff --git a/gc.c b/gc.c index 19e942d77db094..e51b727ecd5f84 100644 --- a/gc.c +++ b/gc.c @@ -2916,7 +2916,9 @@ gc_before_sweep(rb_objspace_t *objspace) } } - if (0) fprintf(stderr, "%d\t%d\t%u\t%u\t%d\n", (int)rb_gc_count(), objspace->rgengc.need_major_gc, + if (0) fprintf(stderr, "%d\t%d\t%u\t%u\t%d\n", + (int)rb_gc_count(), + (int)objspace->rgengc.need_major_gc, (unsigned int)objspace->rgengc.oldmalloc_increase, (unsigned int)objspace->rgengc.oldmalloc_increase_limit, (unsigned int)gc_params.oldmalloc_limit_max); @@ -5647,7 +5649,7 @@ get_envparam_int(const char *name, unsigned int *default_value, int lower_bound) if (ptr != NULL) { val = atoi(ptr); - if (val > lower_bound) { + if (val >= lower_bound) { if (RTEST(ruby_verbose)) fprintf(stderr, "%s=%d (%d)\n", name, val, *default_value); *default_value = val; return 1; @@ -5667,7 +5669,7 @@ get_envparam_double(const char *name, double *default_value, double lower_bound) if (ptr != NULL) { val = strtod(ptr, NULL); - if (val > lower_bound) { + if (val >= lower_bound) { if (RTEST(ruby_verbose)) fprintf(stderr, "%s=%f (%f)\n", name, val, *default_value); *default_value = val; return 1; @@ -5746,7 +5748,10 @@ ruby_gc_set_params(int safe_level) get_envparam_double("RUBY_GC_MALLOC_LIMIT_GROWTH_FACTOR", &gc_params.malloc_limit_growth_factor, 1.0); #ifdef RGENGC_ESTIMATE_OLDMALLOC - get_envparam_int("RUBY_GC_OLDMALLOC_LIMIT", &gc_params.oldmalloc_limit_min, 0); + if (get_envparam_int("RUBY_GC_OLDMALLOC_LIMIT", &gc_params.oldmalloc_limit_min, 0)) { + rb_objspace_t *objspace = &rb_objspace; + objspace->rgengc.oldmalloc_increase_limit = gc_params.oldmalloc_limit_min; + } get_envparam_int("RUBY_GC_OLDMALLOC_LIMIT_MAX", &gc_params.oldmalloc_limit_max, 0); get_envparam_double("RUBY_GC_OLDMALLOC_LIMIT_GROWTH_FACTOR", &gc_params.oldmalloc_limit_growth_factor, 1.0); #endif diff --git a/version.h b/version.h index a7c0dc8624a296..ffd78c8e59fe29 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-06" -#define RUBY_PATCHLEVEL 24 +#define RUBY_PATCHLEVEL 25 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 9b9d3bac4d5fb0d0287b898885a2e6f1125f807c Mon Sep 17 00:00:00 2001 From: naruse Date: Thu, 6 Feb 2014 02:59:36 +0000 Subject: [PATCH 021/343] * lib/rubygems: RubyGems 2.2.2 which contains the following bug fixes: http://rubygems.rubyforge.org/rubygems-update/History_txt.html#label-2.2.2+%2F+2014-02-05 https://bugs.ruby-lang.org/issues/9489 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@44858 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 + NEWS | 2 + lib/rubygems.rb | 19 ++- lib/rubygems/available_set.rb | 3 + lib/rubygems/basic_specification.rb | 18 +++ lib/rubygems/commands/contents_command.rb | 6 +- .../commands/generate_index_command.rb | 2 +- lib/rubygems/commands/install_command.rb | 20 ++- lib/rubygems/commands/setup_command.rb | 16 +- lib/rubygems/compatibility.rb | 4 +- lib/rubygems/config_file.rb | 5 +- lib/rubygems/defaults.rb | 20 +-- lib/rubygems/dependency_installer.rb | 1 + lib/rubygems/deprecate.rb | 2 +- lib/rubygems/ext/ext_conf_builder.rb | 6 +- lib/rubygems/installer.rb | 6 +- lib/rubygems/package/tar_header.rb | 2 +- lib/rubygems/platform.rb | 2 +- lib/rubygems/rdoc.rb | 2 +- lib/rubygems/remote_fetcher.rb | 40 +++-- lib/rubygems/request.rb | 8 +- lib/rubygems/request_set.rb | 8 + lib/rubygems/request_set/lockfile.rb | 7 +- lib/rubygems/resolver.rb | 23 +-- lib/rubygems/resolver/api_set.rb | 7 +- lib/rubygems/resolver/best_set.rb | 21 ++- lib/rubygems/resolver/composed_set.rb | 11 ++ lib/rubygems/resolver/git_set.rb | 3 + lib/rubygems/resolver/index_set.rb | 4 + lib/rubygems/resolver/installer_set.rb | 49 ++---- lib/rubygems/resolver/lock_set.rb | 2 + lib/rubygems/resolver/set.rb | 17 +++ lib/rubygems/resolver/vendor_set.rb | 2 + lib/rubygems/security.rb | 6 +- lib/rubygems/source/git.rb | 14 ++ lib/rubygems/specification.rb | 46 +++--- lib/rubygems/test_case.rb | 40 ++++- lib/rubygems/uninstaller.rb | 2 +- lib/rubygems/version.rb | 28 ++-- test/rubygems/test_gem.rb | 142 ++++++++++-------- .../test_gem_commands_contents_command.rb | 6 +- .../test_gem_commands_environment_command.rb | 2 +- .../test_gem_commands_install_command.rb | 15 ++ .../test_gem_commands_update_command.rb | 2 +- .../rubygems/test_gem_dependency_installer.rb | 2 +- .../rubygems/test_gem_ext_ext_conf_builder.rb | 68 +++++---- test/rubygems/test_gem_installer.rb | 14 +- test/rubygems/test_gem_package_tar_header.rb | 14 ++ test/rubygems/test_gem_platform.rb | 6 +- test/rubygems/test_gem_remote_fetcher.rb | 6 +- test/rubygems/test_gem_request.rb | 69 +++++++++ test/rubygems/test_gem_request_set.rb | 21 +++ .../rubygems/test_gem_request_set_lockfile.rb | 10 +- test/rubygems/test_gem_resolver.rb | 8 + test/rubygems/test_gem_resolver_api_set.rb | 41 +++++ test/rubygems/test_gem_resolver_best_set.rb | 50 ++++++ test/rubygems/test_gem_resolver_git_set.rb | 15 ++ test/rubygems/test_gem_resolver_index_set.rb | 35 +++++ .../test_gem_resolver_installer_set.rb | 70 +++++++++ test/rubygems/test_gem_source_git.rb | 43 ++++++ test/rubygems/test_gem_specification.rb | 71 ++++++--- test/rubygems/test_gem_uninstaller.rb | 17 +++ test/rubygems/test_gem_version.rb | 10 ++ version.h | 2 +- 64 files changed, 927 insertions(+), 292 deletions(-) diff --git a/ChangeLog b/ChangeLog index 465c45dec77b2e..86fbbe34019209 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Thu Feb 6 11:27:39 2014 Eric Hodel + + * lib/rubygems: RubyGems 2.2.2 which contains the following bug fixes: + http://rubygems.rubyforge.org/rubygems-update/History_txt.html#label-2.2.2+%2F+2014-02-05 + https://bugs.ruby-lang.org/issues/9489 + Thu Feb 6 11:23:59 2014 Koichi Sasada * gc.c (ruby_gc_set_params): if RUBY_GC_OLDMALLOC_LIMIT is provided, diff --git a/NEWS b/NEWS index a096ad9d28fc85..afd15faf3b128c 100644 --- a/NEWS +++ b/NEWS @@ -276,6 +276,8 @@ String * Improved, iterative resolver (compared to RubyGems 2.1 and earlier) * Support for a sharing a GEM_HOME across ruby platforms and versions + * Updated to 2.2.2. Fixes some minor bugs and performance regressions. + For a complete list of enhancements and bug fixes see: https://github.com/rubygems/rubygems/tree/master/History.txt diff --git a/lib/rubygems.rb b/lib/rubygems.rb index 73c4846f8274de..456273ed19d763 100644 --- a/lib/rubygems.rb +++ b/lib/rubygems.rb @@ -8,7 +8,7 @@ require 'rbconfig' module Gem - VERSION = '2.2.0' + VERSION = '2.2.2' end # Must be first since it unloads the prelude from 1.9.2 @@ -572,7 +572,7 @@ def self.host= host # gem's paths are inserted before site lib directory by default. def self.load_path_insert_index - index = $LOAD_PATH.index ConfigMap[:sitelibdir] + index = $LOAD_PATH.index RbConfig::CONFIG['sitelibdir'] index end @@ -743,8 +743,8 @@ def self.pre_uninstall(&hook) def self.prefix prefix = File.dirname RUBYGEMS_DIR - if prefix != File.expand_path(ConfigMap[:sitelibdir]) and - prefix != File.expand_path(ConfigMap[:libdir]) and + if prefix != File.expand_path(RbConfig::CONFIG['sitelibdir']) and + prefix != File.expand_path(RbConfig::CONFIG['libdir']) and 'lib' == File.basename(RUBYGEMS_DIR) then prefix end @@ -765,6 +765,10 @@ def self.read_binary(path) f.flock(File::LOCK_EX) f.read end + rescue Errno::EACCES + open path, 'rb' do |f| + f.read + end end ## @@ -772,8 +776,8 @@ def self.read_binary(path) def self.ruby if @ruby.nil? then - @ruby = File.join(ConfigMap[:bindir], - "#{ConfigMap[:ruby_install_name]}#{ConfigMap[:EXEEXT]}") + @ruby = File.join(RbConfig::CONFIG['bindir'], + "#{RbConfig::CONFIG['ruby_install_name']}#{RbConfig::CONFIG['EXEEXT']}") @ruby = "\"#{@ruby}\"" if @ruby =~ /\s/ end @@ -785,8 +789,7 @@ def self.ruby # Returns a String containing the API compatibility version of Ruby def self.ruby_api_version - @ruby_api_version ||= - "#{ConfigMap[:MAJOR]}.#{ConfigMap[:MINOR]}.#{ConfigMap[:TEENY]}" + @ruby_api_version ||= RbConfig::CONFIG['ruby_version'].dup end ## diff --git a/lib/rubygems/available_set.rb b/lib/rubygems/available_set.rb index d8655afc34a000..fabdd6e79d71c3 100644 --- a/lib/rubygems/available_set.rb +++ b/lib/rubygems/available_set.rb @@ -4,9 +4,12 @@ class Gem::AvailableSet Tuple = Struct.new(:spec, :source) + attr_accessor :remote # :nodoc: + def initialize @set = [] @sorted = nil + @remote = true end attr_reader :set diff --git a/lib/rubygems/basic_specification.rb b/lib/rubygems/basic_specification.rb index a52377ff22e067..470a6ebc8b5c43 100644 --- a/lib/rubygems/basic_specification.rb +++ b/lib/rubygems/basic_specification.rb @@ -206,6 +206,24 @@ def require_paths [relative_extension_dir].concat @require_paths end + ## + # Returns the paths to the source files for use with analysis and + # documentation tools. These paths are relative to full_gem_path. + + def source_paths + paths = raw_require_paths.dup + + if @extensions then + ext_dirs = @extensions.map do |extension| + extension.split(File::SEPARATOR, 2).first + end.uniq + + paths.concat ext_dirs + end + + paths.uniq + end + ## # Return a Gem::Specification from this gem diff --git a/lib/rubygems/commands/contents_command.rb b/lib/rubygems/commands/contents_command.rb index 97218848edac15..603f1d072aaa6f 100644 --- a/lib/rubygems/commands/contents_command.rb +++ b/lib/rubygems/commands/contents_command.rb @@ -94,11 +94,11 @@ def files_in_default_gem spec spec.files.sort.map do |file| case file when /\A#{spec.bindir}\// - [Gem::ConfigMap[:bindir], $POSTMATCH] + [RbConfig::CONFIG['bindir'], $POSTMATCH] when /\.so\z/ - [Gem::ConfigMap[:archdir], file] + [RbConfig::CONFIG['archdir'], file] else - [Gem::ConfigMap[:rubylibdir], file] + [RbConfig::CONFIG['rubylibdir'], file] end end end diff --git a/lib/rubygems/commands/generate_index_command.rb b/lib/rubygems/commands/generate_index_command.rb index a7db013caf9deb..ca6f694bc56d7d 100644 --- a/lib/rubygems/commands/generate_index_command.rb +++ b/lib/rubygems/commands/generate_index_command.rb @@ -62,7 +62,7 @@ def description # :nodoc: end def execute - # This is always true becasue it's the only way now. + # This is always true because it's the only way now. options[:build_modern] = true if not File.exist?(options[:directory]) or diff --git a/lib/rubygems/commands/install_command.rb b/lib/rubygems/commands/install_command.rb index 4485eb12e81719..8219eef6ead096 100644 --- a/lib/rubygems/commands/install_command.rb +++ b/lib/rubygems/commands/install_command.rb @@ -228,7 +228,18 @@ def install_gem name, version # :nodoc: def install_gem_without_dependencies name, req # :nodoc: gem = nil - if remote? then + if local? then + if name =~ /\.gem$/ and File.file? name then + source = Gem::Source::SpecificFile.new name + spec = source.spec + else + source = Gem::Source::Local.new + spec = source.find_gem name, req + end + gem = source.download spec if spec + end + + if remote? and not gem then dependency = Gem::Dependency.new name, req dependency.prerelease = options[:prerelease] @@ -236,13 +247,6 @@ def install_gem_without_dependencies name, req # :nodoc: gem = fetcher.download_to_cache dependency end - if local? and not gem then - source = Gem::Source::Local.new - spec = source.find_gem name, req - - gem = source.download spec - end - inst = Gem::Installer.new gem, options inst.install diff --git a/lib/rubygems/commands/setup_command.rb b/lib/rubygems/commands/setup_command.rb index face77fae9ce28..681db0dc1d19fc 100644 --- a/lib/rubygems/commands/setup_command.rb +++ b/lib/rubygems/commands/setup_command.rb @@ -13,7 +13,7 @@ def initialize super 'setup', 'Install RubyGems', :format_executable => true, :document => %w[ri], - :site_or_vendor => :sitelibdir, + :site_or_vendor => 'sitelibdir', :destdir => '', :prefix => '', :previous_version => '' add_option '--previous-version=VERSION', @@ -36,7 +36,7 @@ def initialize add_option '--[no-]vendor', 'Install into vendorlibdir not sitelibdir' do |vendor, options| - options[:site_or_vendor] = vendor ? :vendorlibdir : :sitelibdir + options[:site_or_vendor] = vendor ? 'vendorlibdir' : 'sitelibdir' end add_option '--[no-]format-executable', @@ -343,19 +343,19 @@ def generate_default_dirs(install_destdir) site_or_vendor = options[:site_or_vendor] if prefix.empty? then - lib_dir = Gem::ConfigMap[site_or_vendor] - bin_dir = Gem::ConfigMap[:bindir] + lib_dir = RbConfig::CONFIG[site_or_vendor] + bin_dir = RbConfig::CONFIG['bindir'] else # Apple installed RubyGems into libdir, and RubyGems <= 1.1.0 gets # confused about installation location, so switch back to # sitelibdir/vendorlibdir. if defined?(APPLE_GEM_HOME) and # just in case Apple and RubyGems don't get this patched up proper. - (prefix == Gem::ConfigMap[:libdir] or + (prefix == RbConfig::CONFIG['libdir'] or # this one is important - prefix == File.join(Gem::ConfigMap[:libdir], 'ruby')) then - lib_dir = Gem::ConfigMap[site_or_vendor] - bin_dir = Gem::ConfigMap[:bindir] + prefix == File.join(RbConfig::CONFIG['libdir'], 'ruby')) then + lib_dir = RbConfig::CONFIG[site_or_vendor] + bin_dir = RbConfig::CONFIG['bindir'] else lib_dir = File.join prefix, 'lib' bin_dir = File.join prefix, 'bin' diff --git a/lib/rubygems/compatibility.rb b/lib/rubygems/compatibility.rb index 5e8618fe39c088..d06ade1fa662ba 100644 --- a/lib/rubygems/compatibility.rb +++ b/lib/rubygems/compatibility.rb @@ -33,6 +33,8 @@ class << Gem module Gem RubyGemsVersion = VERSION + # TODO remove at RubyGems 3 + RbConfigPriorities = %w[ MAJOR MINOR @@ -45,7 +47,7 @@ module Gem unless defined?(ConfigMap) ## # Configuration settings from ::RbConfig - ConfigMap = Hash.new do |cm, key| + ConfigMap = Hash.new do |cm, key| # TODO remove at RubyGems 3 cm[key] = RbConfig::CONFIG[key.to_s] end else diff --git a/lib/rubygems/config_file.rb b/lib/rubygems/config_file.rb index 1acae9b52942e3..cf14017ea2d5be 100644 --- a/lib/rubygems/config_file.rb +++ b/lib/rubygems/config_file.rb @@ -137,9 +137,10 @@ class Gem::ConfigFile attr_reader :ssl_verify_mode ## - # Path name of directory or file of openssl CA certificate, used for remote https connection + # Path name of directory or file of openssl CA certificate, used for remote + # https connection - attr_reader :ssl_ca_cert + attr_accessor :ssl_ca_cert ## # Path name of directory or file of openssl client certificate, used for remote https connection with client authentication diff --git a/lib/rubygems/defaults.rb b/lib/rubygems/defaults.rb index 715c0b71b36181..6924f48e5ade92 100644 --- a/lib/rubygems/defaults.rb +++ b/lib/rubygems/defaults.rb @@ -29,22 +29,22 @@ def self.default_spec_cache_dir def self.default_dir path = if defined? RUBY_FRAMEWORK_VERSION then [ - File.dirname(ConfigMap[:sitedir]), + File.dirname(RbConfig::CONFIG['sitedir']), 'Gems', - ConfigMap[:ruby_version] + RbConfig::CONFIG['ruby_version'] ] - elsif ConfigMap[:rubylibprefix] then + elsif RbConfig::CONFIG['rubylibprefix'] then [ - ConfigMap[:rubylibprefix], + RbConfig::CONFIG['rubylibprefix'], 'gems', - ConfigMap[:ruby_version] + RbConfig::CONFIG['ruby_version'] ] else [ - ConfigMap[:libdir], + RbConfig::CONFIG['libdir'], ruby_engine, 'gems', - ConfigMap[:ruby_version] + RbConfig::CONFIG['ruby_version'] ] end @@ -74,7 +74,7 @@ def self.default_rubygems_dirs def self.user_dir parts = [Gem.user_home, '.gem', ruby_engine] - parts << ConfigMap[:ruby_version] unless ConfigMap[:ruby_version].empty? + parts << RbConfig::CONFIG['ruby_version'] unless RbConfig::CONFIG['ruby_version'].empty? File.join parts end @@ -100,7 +100,7 @@ def self.default_path # Deduce Ruby's --program-prefix and --program-suffix from its install name def self.default_exec_format - exec_format = ConfigMap[:ruby_install_name].sub('ruby', '%s') rescue '%s' + exec_format = RbConfig::CONFIG['ruby_install_name'].sub('ruby', '%s') rescue '%s' unless exec_format =~ /%s/ then raise Gem::Exception, @@ -117,7 +117,7 @@ def self.default_bindir if defined? RUBY_FRAMEWORK_VERSION then # mac framework support '/usr/bin' else # generic install - ConfigMap[:bindir] + RbConfig::CONFIG['bindir'] end end diff --git a/lib/rubygems/dependency_installer.rb b/lib/rubygems/dependency_installer.rb index b7babf6d386e41..da6994a9beb4d3 100644 --- a/lib/rubygems/dependency_installer.rb +++ b/lib/rubygems/dependency_installer.rb @@ -419,6 +419,7 @@ def resolve_dependencies dep_or_name, version # :nodoc: request_set = as.to_request_set install_development_deps request_set.soft_missing = @force + request_set.remote = false unless consider_remote? installer_set = Gem::Resolver::InstallerSet.new @domain installer_set.always_install.concat request_set.always_install diff --git a/lib/rubygems/deprecate.rb b/lib/rubygems/deprecate.rb index 274d6a5c12023f..e19360da13a81f 100644 --- a/lib/rubygems/deprecate.rb +++ b/lib/rubygems/deprecate.rb @@ -50,7 +50,7 @@ def deprecate name, repl, year, month class_eval { old = "_deprecated_#{name}" alias_method old, name - define_method name do |*args, &block| # TODO: really works on 1.8.7? + define_method name do |*args, &block| klass = self.kind_of? Module target = klass ? "#{self}." : "#{self.class}#" msg = [ "NOTE: #{target}#{name} is deprecated", diff --git a/lib/rubygems/ext/ext_conf_builder.rb b/lib/rubygems/ext/ext_conf_builder.rb index 402aa966c07791..990fd18524caac 100644 --- a/lib/rubygems/ext/ext_conf_builder.rb +++ b/lib/rubygems/ext/ext_conf_builder.rb @@ -34,7 +34,11 @@ def self.build(extension, directory, dest_path, results, args=[], lib_dir=nil) ENV["RUBYOPT"] = ["-r#{siteconf_path}", rubyopt].compact.join(' ') cmd = [Gem.ruby, File.basename(extension), *args].join ' ' - run cmd, results + begin + run cmd, results + ensure + FileUtils.mv 'mkmf.log', dest_path if File.exist? 'mkmf.log' + end ENV["DESTDIR"] = nil ENV["RUBYOPT"] = rubyopt diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb index f8eb2c2145fa1e..c80981682f14b1 100644 --- a/lib/rubygems/installer.rb +++ b/lib/rubygems/installer.rb @@ -480,7 +480,7 @@ def generate_bin_symlink(filename, bindir) # def shebang(bin_file_name) - ruby_name = Gem::ConfigMap[:ruby_install_name] if @env_shebang + ruby_name = RbConfig::CONFIG['ruby_install_name'] if @env_shebang path = File.join gem_dir, spec.bindir, bin_file_name first_line = File.open(path, "rb") {|file| file.gets} @@ -493,7 +493,7 @@ def shebang(bin_file_name) if which = Gem.configuration[:custom_shebang] # replace bin_file_name with "ruby" to avoid endless loops - which = which.gsub(/ #{bin_file_name}$/," #{Gem::ConfigMap[:ruby_install_name]}") + which = which.gsub(/ #{bin_file_name}$/," #{RbConfig::CONFIG['ruby_install_name']}") which = which.gsub(/\$(\w+)/) do case $1 @@ -641,7 +641,7 @@ def app_script_text(bin_file_name) if ARGV.first str = ARGV.first str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding - if str =~ /\\A_(.*)_\\z/ + if str =~ /\\A_(.*)_\\z/ and Gem::Version.correct?($1) then version = $1 ARGV.shift end diff --git a/lib/rubygems/package/tar_header.rb b/lib/rubygems/package/tar_header.rb index 28da1db0b508fa..f9ab13aca77447 100644 --- a/lib/rubygems/package/tar_header.rb +++ b/lib/rubygems/package/tar_header.rb @@ -134,7 +134,7 @@ def initialize(vals) vals[:gid] ||= 0 vals[:mtime] ||= 0 vals[:checksum] ||= "" - vals[:typeflag] ||= "0" + vals[:typeflag] = "0" if vals[:typeflag].nil? || vals[:typeflag].empty? vals[:magic] ||= "ustar" vals[:version] ||= "00" vals[:uname] ||= "wheel" diff --git a/lib/rubygems/platform.rb b/lib/rubygems/platform.rb index e050959dc6fde5..1bcd7549ad4f79 100644 --- a/lib/rubygems/platform.rb +++ b/lib/rubygems/platform.rb @@ -16,7 +16,7 @@ class Gem::Platform attr_accessor :version def self.local - arch = Gem::ConfigMap[:arch] + arch = RbConfig::CONFIG['arch'] arch = "#{arch}_60" if arch =~ /mswin32$/ @local ||= new(arch) end diff --git a/lib/rubygems/rdoc.rb b/lib/rubygems/rdoc.rb index 52249dc267aa88..633bd893a5df0c 100644 --- a/lib/rubygems/rdoc.rb +++ b/lib/rubygems/rdoc.rb @@ -193,7 +193,7 @@ def generate ::RDoc::Parser::C.reset args = @spec.rdoc_options - args.concat @spec.require_paths + args.concat @spec.source_paths args.concat @spec.extra_rdoc_files case config_args = Gem.configuration[:rdoc] diff --git a/lib/rubygems/remote_fetcher.rb b/lib/rubygems/remote_fetcher.rb index e32c0249896f53..58991caeda93da 100644 --- a/lib/rubygems/remote_fetcher.rb +++ b/lib/rubygems/remote_fetcher.rb @@ -131,11 +131,19 @@ def download(spec, source_uri, install_dir = Gem.dir) FileUtils.mkdir_p cache_dir rescue nil unless File.exist? cache_dir - # Always escape URI's to deal with potential spaces and such - unless URI::Generic === source_uri - source_uri = URI.parse(URI.const_defined?(:DEFAULT_PARSER) ? - URI::DEFAULT_PARSER.escape(source_uri.to_s) : - URI.escape(source_uri.to_s)) + # Always escape URI's to deal with potential spaces and such + # It should also be considered that source_uri may already be + # a valid URI with escaped characters. e.g. "{DESede}" is encoded + # as "%7BDESede%7D". If this is escaped again the percentage + # symbols will be escaped. + unless source_uri.is_a?(URI::Generic) + begin + source_uri = URI.parse(source_uri) + rescue + source_uri = URI.parse(URI.const_defined?(:DEFAULT_PARSER) ? + URI::DEFAULT_PARSER.escape(source_uri.to_s) : + URI.escape(source_uri.to_s)) + end end scheme = source_uri.scheme @@ -285,20 +293,20 @@ def fetch_path(uri, mtime = nil, head = false) def cache_update_path uri, path = nil, update = true mtime = path && File.stat(path).mtime rescue nil - if mtime && Net::HTTPNotModified === fetch_path(uri, mtime, true) - Gem.read_binary(path) - else - data = fetch_path(uri) + data = fetch_path(uri, mtime) - if update and path then - open(path, 'wb') do |io| - io.flock(File::LOCK_EX) - io.write data - end - end + if data == nil # indicates the server returned 304 Not Modified + return Gem.read_binary(path) + end - data + if update and path + open(path, 'wb') do |io| + io.flock(File::LOCK_EX) + io.write data + end end + + data end ## diff --git a/lib/rubygems/request.rb b/lib/rubygems/request.rb index e8707630c5b1fb..d2f076f58110ce 100644 --- a/lib/rubygems/request.rb +++ b/lib/rubygems/request.rb @@ -48,15 +48,14 @@ def configure_connection_for_https(connection) connection.key = OpenSSL::PKey::RSA.new pem end + store.set_default_paths + add_rubygems_trusted_certs(store) if Gem.configuration.ssl_ca_cert if File.directory? Gem.configuration.ssl_ca_cert store.add_path Gem.configuration.ssl_ca_cert else store.add_file Gem.configuration.ssl_ca_cert end - else - store.set_default_paths - add_rubygems_trusted_certs(store) end connection.cert_store = store rescue LoadError => e @@ -106,7 +105,8 @@ def fetch request = @request_class.new @uri.request_uri unless @uri.nil? || @uri.user.nil? || @uri.user.empty? then - request.basic_auth @uri.user, @uri.password + request.basic_auth Gem::UriFormatter.new(@uri.user).unescape, + Gem::UriFormatter.new(@uri.password).unescape end request.add_field 'User-Agent', @user_agent diff --git a/lib/rubygems/request_set.rb b/lib/rubygems/request_set.rb index aa3f27c9c1a191..fb54e344bdfd3d 100644 --- a/lib/rubygems/request_set.rb +++ b/lib/rubygems/request_set.rb @@ -38,6 +38,11 @@ class Gem::RequestSet attr_accessor :ignore_dependencies + ## + # When false no remote sets are used for resolving gems. + + attr_accessor :remote + ## # Sets used for resolution @@ -71,6 +76,7 @@ def initialize *deps @git_set = nil @ignore_dependencies = false @install_dir = Gem.dir + @remote = true @requests = [] @sets = [] @soft_missing = false @@ -150,6 +156,7 @@ def install_from_gemdeps options, &block gemdeps = options[:gemdeps] @install_dir = options[:install_dir] || Gem.dir + @remote = options[:domain] != :local load_gemdeps gemdeps, options[:without_groups] @@ -235,6 +242,7 @@ def resolve set = Gem::Resolver::BestSet.new @sets << @vendor_set set = Gem::Resolver.compose_sets(*@sets) + set.remote = @remote resolver = Gem::Resolver.new @dependencies, set resolver.development = @development diff --git a/lib/rubygems/request_set/lockfile.rb b/lib/rubygems/request_set/lockfile.rb index 522caf15026af0..0433d2a7fc86e5 100644 --- a/lib/rubygems/request_set/lockfile.rb +++ b/lib/rubygems/request_set/lockfile.rb @@ -303,7 +303,12 @@ def parse_GEM # :nodoc: type, data, = get [:text, :requirement] if type == :text and column == 4 then - last_spec = set.add name, data, Gem::Platform::RUBY + version, platform = data.split '-', 2 + + platform = + platform ? Gem::Platform.new(platform) : Gem::Platform::RUBY + + last_spec = set.add name, version, platform else dependency = parse_dependency name, data diff --git a/lib/rubygems/resolver.rb b/lib/rubygems/resolver.rb index d455e03c0576fb..65e92bbf29b409 100644 --- a/lib/rubygems/resolver.rb +++ b/lib/rubygems/resolver.rb @@ -59,6 +59,8 @@ def self.compose_sets *sets sets = sets.map do |set| case set + when Gem::Resolver::BestSet then + set when Gem::Resolver::ComposedSet then set.sets else @@ -178,27 +180,6 @@ def resolve res.to_a end - ## - # Finds the State in +states+ that matches the +conflict+ so that we can try - # other possible sets. - # - # If no good candidate is found, the first state is tried. - - def find_conflict_state conflict, states # :nodoc: - until states.empty? do - state = states.pop - - explain :consider, state.dep, conflict.failed_dep - - if conflict.for_spec? state.spec - state.conflicts << [state.spec, conflict] - return state - end - end - - nil - end - ## # Extracts the specifications that may be able to fulfill +dependency+ and # returns those that match the local platform and all those that match. diff --git a/lib/rubygems/resolver/api_set.rb b/lib/rubygems/resolver/api_set.rb index 89ee3c9b15c2a6..5475e626e6e70b 100644 --- a/lib/rubygems/resolver/api_set.rb +++ b/lib/rubygems/resolver/api_set.rb @@ -25,10 +25,12 @@ class Gem::Resolver::APISet < Gem::Resolver::Set # http://guides.rubygems.org/rubygems-org-api def initialize dep_uri = 'https://rubygems.org/api/v1/dependencies' + super() + dep_uri = URI dep_uri unless URI === dep_uri # for ruby 1.8 @dep_uri = dep_uri - @uri = dep_uri + '../../..' + @uri = dep_uri + '../..' @data = Hash.new { |h,k| h[k] = [] } @source = Gem::Source.new @uri @@ -41,6 +43,8 @@ def initialize dep_uri = 'https://rubygems.org/api/v1/dependencies' def find_all req res = [] + return res unless @remote + versions(req.name).each do |ver| if req.dependency.match? req.name, ver[:number] res << Gem::Resolver::APISpecification.new(self, ver) @@ -55,6 +59,7 @@ def find_all req # data for DependencyRequests +reqs+. def prefetch reqs + return unless @remote names = reqs.map { |r| r.dependency.name } needed = names - @data.keys diff --git a/lib/rubygems/resolver/best_set.rb b/lib/rubygems/resolver/best_set.rb index fa6c9f84c0ee90..20bb94827b0f27 100644 --- a/lib/rubygems/resolver/best_set.rb +++ b/lib/rubygems/resolver/best_set.rb @@ -12,11 +12,30 @@ class Gem::Resolver::BestSet < Gem::Resolver::ComposedSet def initialize sources = Gem.sources super() - sources.each_source do |source| + @sources = sources + end + + ## + # Picks which sets to use for the configured sources. + + def pick_sets # :nodoc: + @sources.each_source do |source| @sets << source.dependency_resolver_set end end + def find_all req # :nodoc: + pick_sets if @remote and @sets.empty? + + super + end + + def prefetch reqs # :nodoc: + pick_sets if @remote and @sets.empty? + + super + end + def pretty_print q # :nodoc: q.group 2, '[BestSet', ']' do q.breakable diff --git a/lib/rubygems/resolver/composed_set.rb b/lib/rubygems/resolver/composed_set.rb index 19227e095b6b0a..6f912b0afe1cdc 100644 --- a/lib/rubygems/resolver/composed_set.rb +++ b/lib/rubygems/resolver/composed_set.rb @@ -16,9 +16,20 @@ class Gem::Resolver::ComposedSet < Gem::Resolver::Set # Gem::Resolver::compose_sets instead. def initialize *sets + super() + @sets = sets end + ## + # Sets the remote network access for all composed sets. + + def remote= remote + super + + @sets.each { |set| set.remote = remote } + end + ## # Finds all specs matching +req+ in all sets. diff --git a/lib/rubygems/resolver/git_set.rb b/lib/rubygems/resolver/git_set.rb index 1a2b230b809367..d32710e3d61ca8 100644 --- a/lib/rubygems/resolver/git_set.rb +++ b/lib/rubygems/resolver/git_set.rb @@ -33,6 +33,8 @@ class Gem::Resolver::GitSet < Gem::Resolver::Set attr_reader :specs # :nodoc: def initialize # :nodoc: + super() + @git = ENV['git'] || 'git' @need_submodules = {} @repositories = {} @@ -91,6 +93,7 @@ def prefetch reqs @repositories.each do |name, (repository, reference)| source = Gem::Source::Git.new name, repository, reference source.root_dir = @root_dir + source.remote = @remote source.specs.each do |spec| git_spec = Gem::Resolver::GitSpecification.new self, spec, source diff --git a/lib/rubygems/resolver/index_set.rb b/lib/rubygems/resolver/index_set.rb index a6ef56bb7f3ea8..ef01f0f0ad5cc2 100644 --- a/lib/rubygems/resolver/index_set.rb +++ b/lib/rubygems/resolver/index_set.rb @@ -5,6 +5,8 @@ class Gem::Resolver::IndexSet < Gem::Resolver::Set def initialize source = nil # :nodoc: + super() + @f = if source then sources = Gem::SourceList.from [source] @@ -34,6 +36,8 @@ def initialize source = nil # :nodoc: def find_all req res = [] + return res unless @remote + name = req.dependency.name @all[name].each do |uri, n| diff --git a/lib/rubygems/resolver/installer_set.rb b/lib/rubygems/resolver/installer_set.rb index e35e0aabecc92a..045c893fdc4f3d 100644 --- a/lib/rubygems/resolver/installer_set.rb +++ b/lib/rubygems/resolver/installer_set.rb @@ -24,15 +24,17 @@ class Gem::Resolver::InstallerSet < Gem::Resolver::Set # Creates a new InstallerSet that will look for gems in +domain+. def initialize domain + super() + @domain = domain + @remote = consider_remote? @f = Gem::SpecFetcher.fetcher - @all = Hash.new { |h,k| h[k] = [] } @always_install = [] @ignore_dependencies = false @ignore_installed = false - @loaded_remote_specs = [] + @remote_set = Gem::Resolver::BestSet.new @specs = {} end @@ -79,16 +81,7 @@ def find_all req end end - if consider_remote? then - load_remote_specs dep - - @all[name].each do |remote_source, n| - if dep.match? n then - res << Gem::Resolver::IndexSpecification.new( - self, n.name, n.version, remote_source, n.platform) - end - end - end + res.concat @remote_set.find_all req if consider_remote? res end @@ -101,27 +94,6 @@ def inspect # :nodoc: ] end - ## - # Loads remote prerelease specs if +dep+ is a prerelease dependency - - def load_remote_specs dep # :nodoc: - types = [:released] - types << :prerelease if dep.prerelease? - - types.each do |type| - next if @loaded_remote_specs.include? type - @loaded_remote_specs << type - - list, = @f.available_specs type - - list.each do |uri, specs| - specs.each do |n| - @all[n.name] << [uri, n] - end - end - end - end - ## # Called from IndexSpecification to get a true Specification # object. @@ -151,5 +123,16 @@ def pretty_print q # :nodoc: end end + def remote= remote # :nodoc: + case @domain + when :local then + @domain = :both if remote + when :remote then + @domain = nil unless remote + when :both then + @domain = :local unless remote + end + end + end diff --git a/lib/rubygems/resolver/lock_set.rb b/lib/rubygems/resolver/lock_set.rb index cdb41b22bf2292..f4987576ec1993 100644 --- a/lib/rubygems/resolver/lock_set.rb +++ b/lib/rubygems/resolver/lock_set.rb @@ -9,6 +9,8 @@ class Gem::Resolver::LockSet < Gem::Resolver::Set # Creates a new LockSet from the given +source+ def initialize source + super() + @source = Gem::Source::Lock.new source @specs = [] end diff --git a/lib/rubygems/resolver/set.rb b/lib/rubygems/resolver/set.rb index 32c137ef6b1c0d..f053b65e1564d9 100644 --- a/lib/rubygems/resolver/set.rb +++ b/lib/rubygems/resolver/set.rb @@ -4,6 +4,15 @@ class Gem::Resolver::Set + ## + # Set to true to disable network access for this set + + attr_accessor :remote + + def initialize # :nodoc: + @remote = true + end + ## # The find_all method must be implemented. It returns all Resolver # Specification objects matching the given DependencyRequest +req+. @@ -23,5 +32,13 @@ def find_all req def prefetch reqs end + ## + # When true, this set is allowed to access the network when looking up + # specifications or dependencies. + + def remote? # :nodoc: + @remote + end + end diff --git a/lib/rubygems/resolver/vendor_set.rb b/lib/rubygems/resolver/vendor_set.rb index 3db637f4a3d353..6e867073be74f6 100644 --- a/lib/rubygems/resolver/vendor_set.rb +++ b/lib/rubygems/resolver/vendor_set.rb @@ -21,6 +21,8 @@ class Gem::Resolver::VendorSet < Gem::Resolver::Set attr_reader :specs # :nodoc: def initialize # :nodoc: + super() + @directories = {} @specs = {} end diff --git a/lib/rubygems/security.rb b/lib/rubygems/security.rb index bfd6fd225b47ba..8c5fb7d9f2e146 100644 --- a/lib/rubygems/security.rb +++ b/lib/rubygems/security.rb @@ -120,11 +120,11 @@ # * HighSecurity - Here's the bugger that got us into this mess. # The HighSecurity policy is identical to the MediumSecurity policy, # except that it does not allow unsigned gems. A malicious user -# doesn't have a whole lot of options here; he can't modify the -# package contents without invalidating the signature, and he can't +# doesn't have a whole lot of options here; they can't modify the +# package contents without invalidating the signature, and they can't # modify or remove signature or the signing certificate chain, or # RubyGems will simply refuse to install the package. Oh well, maybe -# he'll have better luck causing problems for CPAN users instead :). +# they'll have better luck causing problems for CPAN users instead :). # # The reason RubyGems refused to install your shiny new signed gem was because # it was from an untrusted source. Well, your code is infallible (naturally), diff --git a/lib/rubygems/source/git.rb b/lib/rubygems/source/git.rb index 28178a5f4f1bb6..2e3fa037309e27 100644 --- a/lib/rubygems/source/git.rb +++ b/lib/rubygems/source/git.rb @@ -23,6 +23,11 @@ class Gem::Source::Git < Gem::Source attr_reader :reference + ## + # When false the cache for this repository will not be updated. + + attr_accessor :remote + ## # The git repository this gem is sourced from. @@ -53,6 +58,7 @@ def initialize name, repository, reference, submodules = false @reference = reference @need_submodules = submodules + @remote = true @root_dir = Gem.dir @git = ENV['git'] || 'git' end @@ -85,6 +91,8 @@ def == other # :nodoc: def checkout # :nodoc: cache + return false unless File.exist? repo_cache_dir + unless File.exist? install_dir then system @git, 'clone', '--quiet', '--no-checkout', repo_cache_dir, install_dir @@ -107,6 +115,8 @@ def checkout # :nodoc: # Creates a local cache repository for the git gem. def cache # :nodoc: + return unless @remote + if File.exist? repo_cache_dir then Dir.chdir repo_cache_dir do system @git, 'fetch', '--quiet', '--force', '--tags', @@ -142,6 +152,8 @@ def download full_spec, path # :nodoc: # The directory where the git gem will be installed. def install_dir # :nodoc: + return unless File.exist? repo_cache_dir + File.join base_dir, 'gems', "#{@name}-#{dir_shortref}" end @@ -177,6 +189,8 @@ def rev_parse # :nodoc: def specs checkout + return [] unless install_dir + Dir.chdir install_dir do Dir['{,*,*/*}.gemspec'].map do |spec_file| directory = File.dirname spec_file diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb index 59d71d378bb3f7..f4e609a5eb4742 100644 --- a/lib/rubygems/specification.rb +++ b/lib/rubygems/specification.rb @@ -240,6 +240,28 @@ class Gem::Specification < Gem::BasicSpecification attr_reader :summary + ## + # Singular writer for #authors + # + # Usage: + # + # spec.author = 'John Jones' + + def author= o + self.authors = [o] + end + + ## + # Sets the list of authors, ensuring it is an array. + # + # Usage: + # + # spec.authors = ['John Jones', 'Mary Smith'] + + def authors= value + @authors = Array(value).flatten.grep(String) + end + ## # The platform this gem runs on. # @@ -327,7 +349,7 @@ def files add_bindir(@executables), @extra_rdoc_files, @extensions, - ].flatten.sort.uniq.compact + ].flatten.uniq.compact.sort end ###################################################################### @@ -442,28 +464,6 @@ def add_runtime_dependency(gem, *requirements) add_dependency_with_type(gem, :runtime, *requirements) end - ## - # Singular writer for #authors - # - # Usage: - # - # spec.author = 'John Jones' - - def author= o - self.authors = [o] - end - - ## - # Sets the list of authors, ensuring it is an array. - # - # Usage: - # - # spec.authors = ['John Jones', 'Mary Smith'] - - def authors= value - @authors = Array(value).flatten.grep(String) - end - ## # Executables included in the gem. # diff --git a/lib/rubygems/test_case.rb b/lib/rubygems/test_case.rb index 8dc37d67204dc6..328731d4eac729 100644 --- a/lib/rubygems/test_case.rb +++ b/lib/rubygems/test_case.rb @@ -115,6 +115,23 @@ def assert_path_exists path, msg = nil assert File.exist?(path), msg end + ## + # Sets the ENABLE_SHARED entry in RbConfig::CONFIG to +value+ and restores + # the original value when the block ends + + def enable_shared value + enable_shared = RbConfig::CONFIG['ENABLE_SHARED'] + RbConfig::CONFIG['ENABLE_SHARED'] = value + + yield + ensure + if enable_shared then + RbConfig::CONFIG['enable_shared'] = enable_shared + else + RbConfig::CONFIG.delete 'enable_shared' + end + end + # TODO: move to minitest def refute_path_exists path, msg = nil msg = message(msg) { "Expected path '#{path}' to not exist" } @@ -294,10 +311,10 @@ def setup Gem.searcher = nil Gem::SpecFetcher.fetcher = nil - @orig_BASERUBY = Gem::ConfigMap[:BASERUBY] - Gem::ConfigMap[:BASERUBY] = Gem::ConfigMap[:ruby_install_name] + @orig_BASERUBY = RbConfig::CONFIG['BASERUBY'] + RbConfig::CONFIG['BASERUBY'] = RbConfig::CONFIG['ruby_install_name'] - @orig_arch = Gem::ConfigMap[:arch] + @orig_arch = RbConfig::CONFIG['arch'] if win_platform? util_set_arch 'i386-mswin32' @@ -315,8 +332,12 @@ def setup def teardown $LOAD_PATH.replace @orig_LOAD_PATH if @orig_LOAD_PATH - Gem::ConfigMap[:BASERUBY] = @orig_BASERUBY - Gem::ConfigMap[:arch] = @orig_arch + if @orig_BASERUBY + RbConfig::CONFIG['BASERUBY'] = @orig_BASERUBY + else + RbConfig::CONFIG.delete('BASERUBY') + end + RbConfig::CONFIG['arch'] = @orig_arch if defined? Gem::RemoteFetcher then Gem::RemoteFetcher.fetcher = nil @@ -898,7 +919,7 @@ def util_make_gems(prerelease = false) # Set the platform to +arch+ def util_set_arch(arch) - Gem::ConfigMap[:arch] = arch + RbConfig::CONFIG['arch'] = arch platform = Gem::Platform.new arch Gem.instance_variable_set :@platforms, nil @@ -1244,11 +1265,18 @@ def vendor_gem name = 'a', version = 1 class StaticSet + ## + # A StaticSet ignores remote because it has a fixed set of gems. + + attr_accessor :remote + ## # Creates a new StaticSet for the given +specs+ def initialize(specs) @specs = specs + + @remote = true end ## diff --git a/lib/rubygems/uninstaller.rb b/lib/rubygems/uninstaller.rb index 4cb2a1d33334ba..fa838333cd4543 100644 --- a/lib/rubygems/uninstaller.rb +++ b/lib/rubygems/uninstaller.rb @@ -237,7 +237,7 @@ def remove(spec) unless path_ok?(@gem_home, spec) or (@user_install and path_ok?(Gem.user_dir, spec)) then e = Gem::GemNotInHomeException.new \ - "Gem is not installed in directory #{@gem_home}" + "Gem '#{spec.full_name}' is not installed in directory #{@gem_home}" e.spec = spec raise e diff --git a/lib/rubygems/version.rb b/lib/rubygems/version.rb index fda8b0b5d49407..20663326ef4b01 100644 --- a/lib/rubygems/version.rb +++ b/lib/rubygems/version.rb @@ -22,6 +22,11 @@ # 3. 1.0.a.2 # 4. 0.9 # +# If you want to specify a version restriction that includes both prereleases +# and regular releases of the 1.x series this is the best way: +# +# s.add_dependency 'example', '>= 1.0.0.a', '< 2.0.0' +# # == How Software Changes # # Users expect to be able to specify a version constraint that gives them @@ -81,8 +86,8 @@ # # * Any "public" release of a gem should have a different version. Normally # that means incrementing the build number. This means a developer can -# generate builds all day long for himself, but as soon as he/she makes a -# public release, the version must be updated. +# generate builds all day long, but as soon as they make a public release, +# the version must be updated. # # === Examples # @@ -99,26 +104,25 @@ # Version 1.1.1:: Fixed a bug in the linked list implementation. # Version 1.1.2:: Fixed a bug introduced in the last fix. # -# Client A needs a stack with basic push/pop capability. He writes to the -# original interface (no top), so his version constraint looks -# like: +# Client A needs a stack with basic push/pop capability. They write to the +# original interface (no top), so their version constraint looks like: # # gem 'stack', '~> 0.0' # # Essentially, any version is OK with Client A. An incompatible change to -# the library will cause him grief, but he is willing to take the chance (we -# call Client A optimistic). +# the library will cause them grief, but they are willing to take the chance +# (we call Client A optimistic). # -# Client B is just like Client A except for two things: (1) He uses the -# depth method and (2) he is worried about future -# incompatibilities, so he writes his version constraint like this: +# Client B is just like Client A except for two things: (1) They use the +# depth method and (2) they are worried about future +# incompatibilities, so they write their version constraint like this: # # gem 'stack', '~> 0.1' # # The depth method was introduced in version 0.1.0, so that version # or anything later is fine, as long as the version stays below version 1.0 # where incompatibilities are introduced. We call Client B pessimistic -# because he is worried about incompatible future changes (it is OK to be +# because they are worried about incompatible future changes (it is OK to be # pessimistic!). # # == Preventing Version Catastrophe: @@ -185,6 +189,8 @@ def self.create input @@all = {} def self.new version # :nodoc: + return super unless Gem::VERSION == self.class + @@all[version] ||= super end diff --git a/test/rubygems/test_gem.rb b/test/rubygems/test_gem.rb index 759c2fe9070759..e33742049ce68b 100644 --- a/test/rubygems/test_gem.rb +++ b/test/rubygems/test_gem.rb @@ -199,30 +199,21 @@ def test_self_datadir_nonexistent_package end def test_self_default_exec_format - orig_RUBY_INSTALL_NAME = Gem::ConfigMap[:ruby_install_name] - Gem::ConfigMap[:ruby_install_name] = 'ruby' - - assert_equal '%s', Gem.default_exec_format - ensure - Gem::ConfigMap[:ruby_install_name] = orig_RUBY_INSTALL_NAME + ruby_install_name 'ruby' do + assert_equal '%s', Gem.default_exec_format + end end def test_self_default_exec_format_18 - orig_RUBY_INSTALL_NAME = Gem::ConfigMap[:ruby_install_name] - Gem::ConfigMap[:ruby_install_name] = 'ruby18' - - assert_equal '%s18', Gem.default_exec_format - ensure - Gem::ConfigMap[:ruby_install_name] = orig_RUBY_INSTALL_NAME + ruby_install_name 'ruby18' do + assert_equal '%s18', Gem.default_exec_format + end end def test_self_default_exec_format_jruby - orig_RUBY_INSTALL_NAME = Gem::ConfigMap[:ruby_install_name] - Gem::ConfigMap[:ruby_install_name] = 'jruby' - - assert_equal 'j%s', Gem.default_exec_format - ensure - Gem::ConfigMap[:ruby_install_name] = orig_RUBY_INSTALL_NAME + ruby_install_name 'jruby' do + assert_equal 'j%s', Gem.default_exec_format + end end def test_self_default_sources @@ -230,6 +221,7 @@ def test_self_default_sources end def test_self_detect_gemdeps + skip 'Insecure operation - chdir' if RUBY_VERSION <= "1.8.7" rubygems_gemdeps, ENV['RUBYGEMS_GEMDEPS'] = ENV['RUBYGEMS_GEMDEPS'], '-' FileUtils.mkdir_p 'detect/a/b' @@ -339,21 +331,15 @@ def test_self_ensure_gem_directories_write_protected_parents end def test_self_extension_dir_shared - enable_shared, RbConfig::CONFIG['ENABLE_SHARED'] = - RbConfig::CONFIG['ENABLE_SHARED'], 'yes' - - assert_equal Gem.ruby_api_version, Gem.extension_api_version - ensure - RbConfig::CONFIG['ENABLE_SHARED'] = enable_shared + enable_shared 'yes' do + assert_equal Gem.ruby_api_version, Gem.extension_api_version + end end def test_self_extension_dir_static - enable_shared, RbConfig::CONFIG['ENABLE_SHARED'] = - RbConfig::CONFIG['ENABLE_SHARED'], 'no' - - assert_equal "#{Gem.ruby_api_version}-static", Gem.extension_api_version - ensure - RbConfig::CONFIG['ENABLE_SHARED'] = enable_shared + enable_shared 'no' do + assert_equal "#{Gem.ruby_api_version}-static", Gem.extension_api_version + end end def test_self_find_files @@ -565,24 +551,43 @@ def test_self_prefix end def test_self_prefix_libdir - orig_libdir = Gem::ConfigMap[:libdir] - Gem::ConfigMap[:libdir] = @@project_dir + orig_libdir = RbConfig::CONFIG['libdir'] + RbConfig::CONFIG['libdir'] = @@project_dir assert_nil Gem.prefix ensure - Gem::ConfigMap[:libdir] = orig_libdir + RbConfig::CONFIG['libdir'] = orig_libdir end def test_self_prefix_sitelibdir - orig_sitelibdir = Gem::ConfigMap[:sitelibdir] - Gem::ConfigMap[:sitelibdir] = @@project_dir + orig_sitelibdir = RbConfig::CONFIG['sitelibdir'] + RbConfig::CONFIG['sitelibdir'] = @@project_dir assert_nil Gem.prefix ensure - Gem::ConfigMap[:sitelibdir] = orig_sitelibdir + RbConfig::CONFIG['sitelibdir'] = orig_sitelibdir + end + + def test_self_read_binary + open 'test', 'w' do |io| + io.write "\xCF\x80" + end + + assert_equal ["\xCF", "\x80"], Gem.read_binary('test').chars.to_a + + skip 'chmod not supported' if Gem.win_platform? + + begin + File.chmod 0444, 'test' + + assert_equal ["\xCF", "\x80"], Gem.read_binary('test').chars.to_a + ensure + File.chmod 0644, 'test' + end end def test_self_refresh + skip 'Insecure operation - mkdir' if RUBY_VERSION <= "1.8.7" util_make_gems a1_spec = @a1.spec_file @@ -602,6 +607,7 @@ def test_self_refresh end def test_self_refresh_keeps_loaded_specs_activated + skip 'Insecure operation - mkdir' if RUBY_VERSION <= "1.8.7" util_make_gems a1_spec = @a1.spec_file @@ -624,46 +630,44 @@ def test_self_refresh_keeps_loaded_specs_activated def test_self_ruby_escaping_spaces_in_path orig_ruby = Gem.ruby - orig_bindir = Gem::ConfigMap[:bindir] - orig_ruby_install_name = Gem::ConfigMap[:ruby_install_name] - orig_exe_ext = Gem::ConfigMap[:EXEEXT] + orig_bindir = RbConfig::CONFIG['bindir'] + orig_ruby_install_name = RbConfig::CONFIG['ruby_install_name'] + orig_exe_ext = RbConfig::CONFIG['EXEEXT'] - Gem::ConfigMap[:bindir] = "C:/Ruby 1.8/bin" - Gem::ConfigMap[:ruby_install_name] = "ruby" - Gem::ConfigMap[:EXEEXT] = ".exe" + RbConfig::CONFIG['bindir'] = "C:/Ruby 1.8/bin" + RbConfig::CONFIG['ruby_install_name'] = "ruby" + RbConfig::CONFIG['EXEEXT'] = ".exe" Gem.instance_variable_set("@ruby", nil) assert_equal "\"C:/Ruby 1.8/bin/ruby.exe\"", Gem.ruby ensure Gem.instance_variable_set("@ruby", orig_ruby) - Gem::ConfigMap[:bindir] = orig_bindir - Gem::ConfigMap[:ruby_install_name] = orig_ruby_install_name - Gem::ConfigMap[:EXEEXT] = orig_exe_ext + RbConfig::CONFIG['bindir'] = orig_bindir + RbConfig::CONFIG['ruby_install_name'] = orig_ruby_install_name + RbConfig::CONFIG['EXEEXT'] = orig_exe_ext end def test_self_ruby_path_without_spaces orig_ruby = Gem.ruby - orig_bindir = Gem::ConfigMap[:bindir] - orig_ruby_install_name = Gem::ConfigMap[:ruby_install_name] - orig_exe_ext = Gem::ConfigMap[:EXEEXT] + orig_bindir = RbConfig::CONFIG['bindir'] + orig_ruby_install_name = RbConfig::CONFIG['ruby_install_name'] + orig_exe_ext = RbConfig::CONFIG['EXEEXT'] - Gem::ConfigMap[:bindir] = "C:/Ruby18/bin" - Gem::ConfigMap[:ruby_install_name] = "ruby" - Gem::ConfigMap[:EXEEXT] = ".exe" + RbConfig::CONFIG['bindir'] = "C:/Ruby18/bin" + RbConfig::CONFIG['ruby_install_name'] = "ruby" + RbConfig::CONFIG['EXEEXT'] = ".exe" Gem.instance_variable_set("@ruby", nil) assert_equal "C:/Ruby18/bin/ruby.exe", Gem.ruby ensure Gem.instance_variable_set("@ruby", orig_ruby) - Gem::ConfigMap[:bindir] = orig_bindir - Gem::ConfigMap[:ruby_install_name] = orig_ruby_install_name - Gem::ConfigMap[:EXEEXT] = orig_exe_ext + RbConfig::CONFIG['bindir'] = orig_bindir + RbConfig::CONFIG['ruby_install_name'] = orig_ruby_install_name + RbConfig::CONFIG['EXEEXT'] = orig_exe_ext end def test_self_ruby_api_version - orig_MAJOR, Gem::ConfigMap[:MAJOR] = Gem::ConfigMap[:MAJOR], '1' - orig_MINOR, Gem::ConfigMap[:MINOR] = Gem::ConfigMap[:MINOR], '2' - orig_TEENY, Gem::ConfigMap[:TEENY] = Gem::ConfigMap[:TEENY], '3' + orig_ruby_version, RbConfig::CONFIG['ruby_version'] = RbConfig::CONFIG['ruby_version'], '1.2.3' Gem.instance_variable_set :@ruby_api_version, nil @@ -671,9 +675,7 @@ def test_self_ruby_api_version ensure Gem.instance_variable_set :@ruby_api_version, nil - Gem::ConfigMap[:MAJOR] = orig_MAJOR - Gem::ConfigMap[:MINOR] = orig_MINOR - Gem::ConfigMap[:TEENY] = orig_TEENY + RbConfig::CONFIG['ruby_version'] = orig_ruby_version end def test_self_ruby_version_1_8_5 @@ -825,7 +827,7 @@ def test_self_use_paths def test_self_user_dir parts = [@userhome, '.gem', Gem.ruby_engine] - parts << Gem::ConfigMap[:ruby_version] unless Gem::ConfigMap[:ruby_version].empty? + parts << RbConfig::CONFIG['ruby_version'] unless RbConfig::CONFIG['ruby_version'].empty? assert_equal File.join(parts), Gem.user_dir end @@ -857,6 +859,7 @@ def test_self_needs end def test_self_needs_picks_up_unresolved_deps + skip 'loading from unsafe file' if RUBY_VERSION <= "1.8.7" save_loaded_features do util_clear_gems a = util_spec "a", "1" @@ -949,6 +952,7 @@ def test_self_user_home_user_drive_and_path end def test_load_plugins + skip 'Insecure operation - chdir' if RUBY_VERSION <= "1.8.7" plugin_path = File.join "lib", "rubygems_plugin.rb" Dir.chdir @tempdir do @@ -1102,6 +1106,7 @@ def test_auto_activation_of_specific_gemdeps_file end def test_auto_activation_of_detected_gemdeps_file + skip 'Insecure operation - chdir' if RUBY_VERSION <= "1.8.7" util_clear_gems a = new_spec "a", "1", nil, "lib/a.rb" @@ -1264,6 +1269,7 @@ def test_use_gemdeps end def test_use_gemdeps_automatic + skip 'Insecure operation - chdir' if RUBY_VERSION <= "1.8.7" rubygems_gemdeps, ENV['RUBYGEMS_GEMDEPS'] = ENV['RUBYGEMS_GEMDEPS'], '-' spec = util_spec 'a', 1 @@ -1300,6 +1306,7 @@ def test_use_gemdeps_disabled end def test_use_gemdeps_specific + skip 'Insecure operation - read' if RUBY_VERSION <= "1.8.7" rubygems_gemdeps, ENV['RUBYGEMS_GEMDEPS'] = ENV['RUBYGEMS_GEMDEPS'], 'x' spec = util_spec 'a', 1 @@ -1317,6 +1324,19 @@ def test_use_gemdeps_specific ENV['RUBYGEMS_GEMDEPS'] = rubygems_gemdeps end + def ruby_install_name name + orig_RUBY_INSTALL_NAME = RbConfig::CONFIG['ruby_install_name'] + RbConfig::CONFIG['ruby_install_name'] = name + + yield + ensure + if orig_RUBY_INSTALL_NAME then + RbConfig::CONFIG['ruby_install_name'] = orig_RUBY_INSTALL_NAME + else + RbConfig::CONFIG.delete 'ruby_install_name' + end + end + def with_plugin(path) test_plugin_path = File.expand_path("test/rubygems/plugin/#{path}", @@project_dir) diff --git a/test/rubygems/test_gem_commands_contents_command.rb b/test/rubygems/test_gem_commands_contents_command.rb index d87e84fc829fc0..7f5cf22223cff5 100644 --- a/test/rubygems/test_gem_commands_contents_command.rb +++ b/test/rubygems/test_gem_commands_contents_command.rb @@ -169,9 +169,9 @@ def test_execute_default_gem end expected = [ - File.join(Gem::ConfigMap[:bindir], 'default_command'), - File.join(Gem::ConfigMap[:rubylibdir], 'default/gem.rb'), - File.join(Gem::ConfigMap[:archdir], 'default_gem.so') + File.join(RbConfig::CONFIG['bindir'], 'default_command'), + File.join(RbConfig::CONFIG['rubylibdir'], 'default/gem.rb'), + File.join(RbConfig::CONFIG['archdir'], 'default_gem.so') ].sort.join "\n" assert_equal expected, @ui.output.chomp diff --git a/test/rubygems/test_gem_commands_environment_command.rb b/test/rubygems/test_gem_commands_environment_command.rb index 253c459d942840..bb7589f50de1c3 100644 --- a/test/rubygems/test_gem_commands_environment_command.rb +++ b/test/rubygems/test_gem_commands_environment_command.rb @@ -26,7 +26,7 @@ def test_execute assert_match %r|INSTALLATION DIRECTORY: #{Regexp.escape @gemhome}|, @ui.output assert_match %r|RUBYGEMS PREFIX: |, @ui.output - assert_match %r|RUBY EXECUTABLE:.*#{Gem::ConfigMap[:ruby_install_name]}|, + assert_match %r|RUBY EXECUTABLE:.*#{RbConfig::CONFIG['ruby_install_name']}|, @ui.output assert_match %r|EXECUTABLE DIRECTORY:|, @ui.output assert_match %r|RUBYGEMS PLATFORMS:|, @ui.output diff --git a/test/rubygems/test_gem_commands_install_command.rb b/test/rubygems/test_gem_commands_install_command.rb index 00bbf7bae7eca2..6315cb5d95b5ed 100644 --- a/test/rubygems/test_gem_commands_install_command.rb +++ b/test/rubygems/test_gem_commands_install_command.rb @@ -316,6 +316,7 @@ def test_execute_prerelease_skipped_when_non_pre_available end def test_execute_rdoc + skip if RUBY_VERSION <= "1.8.7" specs = spec_fetcher do |fetcher| fetcher.gem 'a', 2 end @@ -559,6 +560,20 @@ def test_install_gem_ignore_dependencies_remote assert_equal %w[a-2], @cmd.installed_specs.map { |spec| spec.full_name } end + def test_install_gem_ignore_dependencies_specific_file + spec = quick_spec 'a', 2 + + util_build_gem spec + + FileUtils.mv spec.cache_file, @tempdir + + @cmd.options[:ignore_dependencies] = true + + @cmd.install_gem File.join(@tempdir, spec.file_name), nil + + assert_equal %w[a-2], @cmd.installed_specs.map { |s| s.full_name } + end + def test_parses_requirement_from_gemname spec_fetcher do |fetcher| fetcher.gem 'a', 2 diff --git a/test/rubygems/test_gem_commands_update_command.rb b/test/rubygems/test_gem_commands_update_command.rb index 7537c1c9c10532..d259383ba2fbb2 100644 --- a/test/rubygems/test_gem_commands_update_command.rb +++ b/test/rubygems/test_gem_commands_update_command.rb @@ -217,6 +217,7 @@ def test_execute_dependencies end def test_execute_rdoc + skip if RUBY_VERSION <= "1.8.7" spec_fetcher do |fetcher| fetcher.gem 'a', 2 @@ -239,7 +240,6 @@ def test_execute_rdoc a2 = @specs['a-2'] - assert_path_exists File.join(a2.doc_dir, 'ri') assert_path_exists File.join(a2.doc_dir, 'rdoc') end diff --git a/test/rubygems/test_gem_dependency_installer.rb b/test/rubygems/test_gem_dependency_installer.rb index 0a82fa63cbbd19..352ebbb54ff513 100644 --- a/test/rubygems/test_gem_dependency_installer.rb +++ b/test/rubygems/test_gem_dependency_installer.rb @@ -551,7 +551,7 @@ def test_install_env_shebang env = "/\\S+/env" unless Gem.win_platform? - assert_match %r|\A#!#{env} #{Gem::ConfigMap[:ruby_install_name]}\n|, + assert_match %r|\A#!#{env} #{RbConfig::CONFIG['ruby_install_name']}\n|, File.read(File.join(@gemhome, 'bin', 'a_bin')) end diff --git a/test/rubygems/test_gem_ext_ext_conf_builder.rb b/test/rubygems/test_gem_ext_ext_conf_builder.rb index aa9008c7937d69..367c933a4cd6ad 100644 --- a/test/rubygems/test_gem_ext_ext_conf_builder.rb +++ b/test/rubygems/test_gem_ext_ext_conf_builder.rb @@ -42,47 +42,46 @@ def test_class_build end def test_class_build_rbconfig_make_prog - configure_args = RbConfig::CONFIG['configure_args'] + configure_args do - File.open File.join(@ext, 'extconf.rb'), 'w' do |extconf| - extconf.puts "require 'mkmf'\ncreate_makefile 'foo'" - end + File.open File.join(@ext, 'extconf.rb'), 'w' do |extconf| + extconf.puts "require 'mkmf'\ncreate_makefile 'foo'" + end - output = [] + output = [] - Dir.chdir @ext do - Gem::Ext::ExtConfBuilder.build 'extconf.rb', nil, @dest_path, output - end + Dir.chdir @ext do + Gem::Ext::ExtConfBuilder.build 'extconf.rb', nil, @dest_path, output + end - assert_equal "creating Makefile\n", output[1] - assert_contains_make_command 'clean', output[2] - assert_contains_make_command '', output[4] - assert_contains_make_command 'install', output[6] - ensure - RbConfig::CONFIG['configure_args'] = configure_args + assert_equal "creating Makefile\n", output[1] + assert_contains_make_command 'clean', output[2] + assert_contains_make_command '', output[4] + assert_contains_make_command 'install', output[6] + end end def test_class_build_env_make - configure_args, env_make = RbConfig::CONFIG['configure_args'], ENV.delete('make') - RbConfig::CONFIG['configure_args'] = '' + env_make = ENV.delete 'make' ENV['make'] = 'anothermake' - File.open File.join(@ext, 'extconf.rb'), 'w' do |extconf| - extconf.puts "require 'mkmf'\ncreate_makefile 'foo'" - end + configure_args '' do + File.open File.join(@ext, 'extconf.rb'), 'w' do |extconf| + extconf.puts "require 'mkmf'\ncreate_makefile 'foo'" + end - output = [] + output = [] - assert_raises Gem::InstallError do - Dir.chdir @ext do - Gem::Ext::ExtConfBuilder.build 'extconf.rb', nil, @dest_path, output + assert_raises Gem::InstallError do + Dir.chdir @ext do + Gem::Ext::ExtConfBuilder.build 'extconf.rb', nil, @dest_path, output + end end - end - assert_equal "creating Makefile\n", output[1] - assert_contains_make_command 'clean', output[2] + assert_equal "creating Makefile\n", output[1] + assert_contains_make_command 'clean', output[2] + end ensure - RbConfig::CONFIG['configure_args'] = configure_args ENV['make'] = env_make end @@ -108,6 +107,7 @@ def test_class_build_extconf_fail assert_equal 'extconf failed, exit code 1', error.message assert_equal("#{Gem.ruby} extconf.rb", output[0]) + assert_path_exists File.join @dest_path, 'mkmf.log' end def test_class_build_unconventional @@ -188,5 +188,19 @@ def test_class_make_no_Makefile assert_equal 'Makefile not found', error.message end + def configure_args args = nil + configure_args = RbConfig::CONFIG['configure_args'] + RbConfig::CONFIG['configure_args'] = args if args + + yield + + ensure + if configure_args then + RbConfig::CONFIG['configure_args'] = configure_args + else + RbConfig::CONFIG.delete 'configure_args' + end + end + end diff --git a/test/rubygems/test_gem_installer.rb b/test/rubygems/test_gem_installer.rb index 615a9b57ba4afa..eff62ab28b2886 100644 --- a/test/rubygems/test_gem_installer.rb +++ b/test/rubygems/test_gem_installer.rb @@ -41,7 +41,7 @@ def test_app_script_text if ARGV.first str = ARGV.first str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding - if str =~ /\\A_(.*)_\\z/ + if str =~ /\\A_(.*)_\\z/ and Gem::Version.correct?($1) then version = $1 ARGV.shift end @@ -84,8 +84,8 @@ def test_check_executable_overwrite_default_bin_dir orig_RUBY_FRAMEWORK_VERSION = RUBY_FRAMEWORK_VERSION Object.send :remove_const, :RUBY_FRAMEWORK_VERSION end - orig_bindir = Gem::ConfigMap[:bindir] - Gem::ConfigMap[:bindir] = Gem.bindir + orig_bindir = RbConfig::CONFIG['bindir'] + RbConfig::CONFIG['bindir'] = Gem.bindir util_conflict_executable false @@ -102,7 +102,11 @@ def test_check_executable_overwrite_default_bin_dir ensure Object.const_set :RUBY_FRAMEWORK_VERSION, orig_RUBY_FRAMEWORK_VERSION if orig_RUBY_FRAMEWORK_VERSION - Gem::ConfigMap[:bindir] = orig_bindir + if orig_bindir then + RbConfig::CONFIG['bindir'] = orig_bindir + else + RbConfig::CONFIG.delete 'bindir' + end end def test_check_executable_overwrite_format_executable @@ -1192,7 +1196,7 @@ def test_shebang_env_shebang env_shebang = "/usr/bin/env" unless Gem.win_platform? - assert_equal("#!#{env_shebang} #{Gem::ConfigMap[:ruby_install_name]}", + assert_equal("#!#{env_shebang} #{RbConfig::CONFIG['ruby_install_name']}", shebang) end diff --git a/test/rubygems/test_gem_package_tar_header.rb b/test/rubygems/test_gem_package_tar_header.rb index 5d855435ec69f9..8f1f0c45619679 100644 --- a/test/rubygems/test_gem_package_tar_header.rb +++ b/test/rubygems/test_gem_package_tar_header.rb @@ -72,6 +72,20 @@ def test_initialize_bad end end + def test_initialize_typeflag + header = { + :mode => '', + :name => '', + :prefix => '', + :size => '', + :typeflag => '', + } + + tar_header = Gem::Package::TarHeader.new header + + assert_equal '0', tar_header.typeflag + end + def test_empty_eh refute_empty @tar_header diff --git a/test/rubygems/test_gem_platform.rb b/test/rubygems/test_gem_platform.rb index 5966710dad30b5..17577dc744a8de 100644 --- a/test/rubygems/test_gem_platform.rb +++ b/test/rubygems/test_gem_platform.rb @@ -116,7 +116,11 @@ def test_initialize_mswin32_vc6 assert_equal expected, platform.to_a, 'i386-mswin32 VC6' ensure - RbConfig::CONFIG['RUBY_SO_NAME'] = orig_RUBY_SO_NAME + if orig_RUBY_SO_NAME then + RbConfig::CONFIG['RUBY_SO_NAME'] = orig_RUBY_SO_NAME + else + RbConfig::CONFIG.delete 'RUBY_SO_NAME' + end end def test_initialize_platform diff --git a/test/rubygems/test_gem_remote_fetcher.rb b/test/rubygems/test_gem_remote_fetcher.rb index 7e6d9c76934881..79f3a58bfb07ef 100644 --- a/test/rubygems/test_gem_remote_fetcher.rb +++ b/test/rubygems/test_gem_remote_fetcher.rb @@ -208,15 +208,15 @@ def util_fuck_with_fetcher data, blow = false fetcher.instance_variable_set :@test_data, data unless blow then - def fetcher.fetch_path arg + def fetcher.fetch_path arg, *rest @test_arg = arg @test_data end else - def fetcher.fetch_path arg + def fetcher.fetch_path arg, *rest # OMG I'm such an ass class << self; remove_method :fetch_path; end - def self.fetch_path arg + def self.fetch_path arg, *rest @test_arg = arg @test_data end diff --git a/test/rubygems/test_gem_request.rb b/test/rubygems/test_gem_request.rb index 04ff50786f85c3..bcbbcf1f99ef6e 100644 --- a/test/rubygems/test_gem_request.rb +++ b/test/rubygems/test_gem_request.rb @@ -1,9 +1,16 @@ require 'rubygems/test_case' require 'rubygems/request' require 'ostruct' +require 'base64' class TestGemRequest < Gem::TestCase + CA_CERT_FILE = cert_path 'ca' + CHILD_CERT = load_cert 'child' + PUBLIC_CERT = load_cert 'public' + PUBLIC_CERT_FILE = cert_path 'public' + SSL_CERT = load_cert 'ssl' + def setup @proxies = %w[http_proxy HTTP_PROXY http_proxy_user HTTP_PROXY_USER http_proxy_pass HTTP_PROXY_PASS no_proxy NO_PROXY] @old_proxies = @proxies.map {|k| ENV[k] } @@ -62,6 +69,44 @@ def test_initialize_proxy_ENV_https assert_equal URI(@proxy_uri), proxy end + def test_configure_connection_for_https + connection = Net::HTTP.new 'localhost', 443 + + request = Gem::Request.new URI('https://example'), nil, nil, nil + + def request.add_rubygems_trusted_certs store + store.add_cert TestGemRequest::PUBLIC_CERT + end + + request.configure_connection_for_https connection + + cert_store = connection.cert_store + + assert cert_store.verify CHILD_CERT + end + + def test_configure_connection_for_https_ssl_ca_cert + ssl_ca_cert, Gem.configuration.ssl_ca_cert = + Gem.configuration.ssl_ca_cert, CA_CERT_FILE + + connection = Net::HTTP.new 'localhost', 443 + + request = Gem::Request.new URI('https://example'), nil, nil, nil + + def request.add_rubygems_trusted_certs store + store.add_cert TestGemRequest::PUBLIC_CERT + end + + request.configure_connection_for_https connection + + cert_store = connection.cert_store + + assert cert_store.verify CHILD_CERT + assert cert_store.verify SSL_CERT + ensure + Gem.configuration.ssl_ca_cert = ssl_ca_cert + end + def test_get_proxy_from_env_fallback ENV['http_proxy'] = @proxy_uri @@ -124,6 +169,30 @@ def test_fetch assert_equal :junk, response.body end + def test_fetch_basic_auth + uri = URI.parse "https://user:pass@example.rubygems/specs.#{Gem.marshal_version}" + @request = Gem::Request.new(uri, Net::HTTP::Get, nil, nil) + conn = util_stub_connection_for :body => :junk, :code => 200 + + @request.fetch + + auth_header = conn.payload['Authorization'] + + assert_equal "Basic #{Base64.encode64('user:pass')}".strip, auth_header + end + + def test_fetch_basic_auth_encoded + uri = URI.parse "https://user:%7BDEScede%7Dpass@example.rubygems/specs.#{Gem.marshal_version}" + @request = Gem::Request.new(uri, Net::HTTP::Get, nil, nil) + conn = util_stub_connection_for :body => :junk, :code => 200 + + @request.fetch + + auth_header = conn.payload['Authorization'] + + assert_equal "Basic #{Base64.encode64('user:{DEScede}pass')}".strip, auth_header + end + def test_fetch_head uri = URI.parse "#{@gem_repo}/specs.#{Gem.marshal_version}" @request = Gem::Request.new(uri, Net::HTTP::Get, nil, nil) diff --git a/test/rubygems/test_gem_request_set.rb b/test/rubygems/test_gem_request_set.rb index 82757958c82517..a5fcdcc2fb31f7 100644 --- a/test/rubygems/test_gem_request_set.rb +++ b/test/rubygems/test_gem_request_set.rb @@ -59,6 +59,8 @@ def test_install_from_gemdeps assert_includes installed, 'a-2' assert_path_exists File.join @gemhome, 'gems', 'a-2' assert_path_exists 'gem.deps.rb.lock' + + assert rs.remote end def test_install_from_gemdeps_install_dir @@ -89,6 +91,25 @@ def test_install_from_gemdeps_install_dir refute_path_exists File.join Gem.dir, 'gems', 'a-2' end + def test_install_from_gemdeps_local + spec_fetcher do |fetcher| + fetcher.gem 'a', 2 + end + + rs = Gem::RequestSet.new + + open 'gem.deps.rb', 'w' do |io| + io.puts 'gem "a"' + io.flush + + assert_raises Gem::UnsatisfiableDependencyError do + rs.install_from_gemdeps :gemdeps => io.path, :domain => :local + end + end + + refute rs.remote + end + def test_install_from_gemdeps_lockfile spec_fetcher do |fetcher| fetcher.gem 'a', 1 diff --git a/test/rubygems/test_gem_request_set_lockfile.rb b/test/rubygems/test_gem_request_set_lockfile.rb index 9e0cab4d1a8f79..0be69bf92b30d4 100644 --- a/test/rubygems/test_gem_request_set_lockfile.rb +++ b/test/rubygems/test_gem_request_set_lockfile.rb @@ -218,6 +218,7 @@ def test_parse_gem_specs_dependency c (~> 4) d e (~> 5.0, >= 5.0.1) + b (3-x86_64-linux) PLATFORMS #{Gem::Platform::RUBY} @@ -238,7 +239,14 @@ def test_parse_gem_specs_dependency assert lockfile_set, 'could not find a LockSet' - assert_equal %w[a-2], lockfile_set.specs.map { |tuple| tuple.full_name } + assert_equal %w[a-2 b-3], lockfile_set.specs.map { |tuple| tuple.full_name } + + expected = [ + Gem::Platform::RUBY, + Gem::Platform.new('x86_64-linux'), + ] + + assert_equal expected, lockfile_set.specs.map { |tuple| tuple.platform } spec = lockfile_set.specs.first diff --git a/test/rubygems/test_gem_resolver.rb b/test/rubygems/test_gem_resolver.rb index 7d3311c14ce47a..c97e9e710cc0b4 100644 --- a/test/rubygems/test_gem_resolver.rb +++ b/test/rubygems/test_gem_resolver.rb @@ -33,6 +33,14 @@ def test_self_compatibility assert_same Gem::Resolver, Gem::DependencyResolver end + def test_self_compose_sets_best_set + best_set = @DR::BestSet.new + + composed = @DR.compose_sets best_set + + assert_equal best_set, composed + end + def test_self_compose_sets_multiple index_set = @DR::IndexSet.new vendor_set = @DR::VendorSet.new diff --git a/test/rubygems/test_gem_resolver_api_set.rb b/test/rubygems/test_gem_resolver_api_set.rb index 288f496c931ff8..245f6c1d24cad2 100644 --- a/test/rubygems/test_gem_resolver_api_set.rb +++ b/test/rubygems/test_gem_resolver_api_set.rb @@ -17,6 +17,14 @@ def test_initialize assert_equal Gem::Source.new(URI('https://rubygems.org')), set.source end + def test_initialize_deeper_uri + set = @DR::APISet.new 'https://rubygemsserver.com/mygems/api/v1/dependencies' + + assert_equal URI('https://rubygemsserver.com/mygems/api/v1/dependencies'), set.dep_uri + assert_equal URI('https://rubygemsserver.com/mygems/'), set.uri + assert_equal Gem::Source.new(URI('https://rubygemsserver.com/mygems/')), set.source + end + def test_initialize_uri set = @DR::APISet.new @dep_uri @@ -74,6 +82,15 @@ def test_find_all_cache assert_equal expected, set.find_all(a_dep) end + def test_find_all_local + set = @DR::APISet.new @dep_uri + set.remote = false + + a_dep = @DR::DependencyRequest.new dep('a'), nil + + assert_empty set.find_all(a_dep) + end + def test_find_all_missing spec_fetcher @@ -163,5 +180,29 @@ def test_prefetch_cache_missing set.prefetch [a_dep, b_dep] end + def test_prefetch_local + spec_fetcher + + data = [ + { :name => 'a', + :number => '1', + :platform => 'ruby', + :dependencies => [], }, + ] + + @fetcher.data["#{@dep_uri}?gems=a,b"] = Marshal.dump data + @fetcher.data["#{@dep_uri}?gems=b"] = Marshal.dump [] + + set = @DR::APISet.new @dep_uri + set.remote = false + + a_dep = @DR::DependencyRequest.new dep('a'), nil + b_dep = @DR::DependencyRequest.new dep('b'), nil + + set.prefetch [a_dep, b_dep] + + assert_empty set.instance_variable_get :@data + end + end diff --git a/test/rubygems/test_gem_resolver_best_set.rb b/test/rubygems/test_gem_resolver_best_set.rb index 5bcff4aca7d66e..2d16f8b701a88b 100644 --- a/test/rubygems/test_gem_resolver_best_set.rb +++ b/test/rubygems/test_gem_resolver_best_set.rb @@ -8,6 +8,12 @@ def setup @DR = Gem::Resolver end + def test_initialize + set = @DR::BestSet.new + + assert_empty set.sets + end + def test_find_all_index spec_fetcher do |fetcher| fetcher.spec 'a', 1 @@ -26,5 +32,49 @@ def test_find_all_index assert_equal %w[a-1], found.map { |s| s.full_name } end + def test_find_all_local + spec_fetcher do |fetcher| + fetcher.spec 'a', 1 + fetcher.spec 'a', 2 + fetcher.spec 'b', 1 + end + + set = @DR::BestSet.new + set.remote = false + + dependency = dep 'a', '~> 1' + + req = @DR::DependencyRequest.new dependency, nil + + found = set.find_all req + + assert_empty found + end + + def test_prefetch + spec_fetcher do |fetcher| + fetcher.spec 'a', 1 + end + + set = @DR::BestSet.new + + set.prefetch [] + + refute_empty set.sets + end + + def test_prefetch_local + spec_fetcher do |fetcher| + fetcher.spec 'a', 1 + end + + set = @DR::BestSet.new + set.remote = false + + set.prefetch [] + + assert_empty set.sets + end + end diff --git a/test/rubygems/test_gem_resolver_git_set.rb b/test/rubygems/test_gem_resolver_git_set.rb index 4643624ee02eaa..f82b9427775ba7 100644 --- a/test/rubygems/test_gem_resolver_git_set.rb +++ b/test/rubygems/test_gem_resolver_git_set.rb @@ -70,6 +70,21 @@ def test_find_all assert_equal [@set.specs['a']], found end + def test_find_all_local + name, _, repository, = git_gem + + @set.add_git_gem name, repository, 'master', false + @set.remote = false + + dependency = dep 'a', '~> 1.0' + req = Gem::Resolver::DependencyRequest.new dependency, nil + @reqs.add req + + @set.prefetch @reqs + + assert_empty @set.find_all dependency + end + def test_root_dir assert_equal Gem.dir, @set.root_dir diff --git a/test/rubygems/test_gem_resolver_index_set.rb b/test/rubygems/test_gem_resolver_index_set.rb index 137e9b5cacabec..b0adc511c997e1 100644 --- a/test/rubygems/test_gem_resolver_index_set.rb +++ b/test/rubygems/test_gem_resolver_index_set.rb @@ -24,5 +24,40 @@ def test_initialize_source refute_same Gem::SpecFetcher.fetcher, fetcher end + def test_find_all + spec_fetcher do |fetcher| + fetcher.spec 'a', 1 + fetcher.spec 'a', 2 + fetcher.spec 'b', 1 + end + + set = @DR::BestSet.new + + dependency = dep 'a', '~> 1' + + req = @DR::DependencyRequest.new dependency, nil + + found = set.find_all req + + assert_equal %w[a-1], found.map { |s| s.full_name } + end + + def test_find_all_local + spec_fetcher do |fetcher| + fetcher.spec 'a', 1 + fetcher.spec 'a', 2 + fetcher.spec 'b', 1 + end + + set = @DR::BestSet.new + set.remote = false + + dependency = dep 'a', '~> 1' + + req = @DR::DependencyRequest.new dependency, nil + + assert_empty set.find_all req + end + end diff --git a/test/rubygems/test_gem_resolver_installer_set.rb b/test/rubygems/test_gem_resolver_installer_set.rb index af4db646a9ddeb..258f9bc8034669 100644 --- a/test/rubygems/test_gem_resolver_installer_set.rb +++ b/test/rubygems/test_gem_resolver_installer_set.rb @@ -2,6 +2,34 @@ class TestGemResolverInstallerSet < Gem::TestCase + def test_consider_local_eh + set = Gem::Resolver::InstallerSet.new :remote + + refute set.consider_local? + + set = Gem::Resolver::InstallerSet.new :both + + assert set.consider_local? + + set = Gem::Resolver::InstallerSet.new :local + + assert set.consider_local? + end + + def test_consider_remote_eh + set = Gem::Resolver::InstallerSet.new :remote + + assert set.consider_remote? + + set = Gem::Resolver::InstallerSet.new :both + + assert set.consider_remote? + + set = Gem::Resolver::InstallerSet.new :local + + refute set.consider_remote? + end + def test_load_spec specs = spec_fetcher do |fetcher| fetcher.spec 'a', 2 @@ -18,5 +46,47 @@ def test_load_spec assert_equal specs["a-2-#{Gem::Platform.local}"].full_name, spec.full_name end + def test_remote_equals_both + set = Gem::Resolver::InstallerSet.new :both + set.remote = true + + assert set.consider_local? + assert set.consider_remote? + + set = Gem::Resolver::InstallerSet.new :both + set.remote = false + + assert set.consider_local? + refute set.consider_remote? + end + + def test_remote_equals_local + set = Gem::Resolver::InstallerSet.new :local + set.remote = true + + assert set.consider_local? + assert set.consider_remote? + + set = Gem::Resolver::InstallerSet.new :local + set.remote = false + + assert set.consider_local? + refute set.consider_remote? + end + + def test_remote_equals_remote + set = Gem::Resolver::InstallerSet.new :remote + set.remote = true + + refute set.consider_local? + assert set.consider_remote? + + set = Gem::Resolver::InstallerSet.new :remote + set.remote = false + + refute set.consider_local? + refute set.consider_remote? + end + end diff --git a/test/rubygems/test_gem_source_git.rb b/test/rubygems/test_gem_source_git.rb index 026492ece02efa..58bff844906c1b 100644 --- a/test/rubygems/test_gem_source_git.rb +++ b/test/rubygems/test_gem_source_git.rb @@ -27,6 +27,26 @@ def test_checkout assert_path_exists File.join @source.install_dir, 'a.gemspec' end + def test_checkout_local + @source.remote = false + + @source.checkout + + install_dir = File.join Gem.dir, 'bundler', 'gems', "a-#{@head[0..11]}" + + refute_path_exists File.join install_dir, 'a.gemspec' + end + + def test_checkout_local_cached + @source.cache + + @source.remote = false + + @source.checkout + + assert_path_exists File.join @source.install_dir, 'a.gemspec' + end + def test_checkout_submodules source = Gem::Source::Git.new @name, @repository, 'master', true @@ -54,6 +74,14 @@ def test_cache end end + def test_cache_local + @source.remote = false + + @source.cache + + refute_path_exists @source.repo_cache_dir + end + def test_dir_shortref @source.cache @@ -99,6 +127,12 @@ def test_install_dir assert_equal expected, @source.install_dir end + def test_install_dir_local + @source.remote = false + + assert_nil @source.install_dir + end + def test_repo_cache_dir expected = File.join Gem.dir, 'cache', 'bundler', 'git', "a-#{@hash}" @@ -211,6 +245,15 @@ def test_specs assert_equal extension_dir, b_spec.extension_dir end + def test_specs_local + source = Gem::Source::Git.new @name, @repository, 'master', true + source.remote = false + + capture_io do + assert_empty source.specs + end + end + def test_uri_hash assert_equal @hash, @source.uri_hash diff --git a/test/rubygems/test_gem_specification.rb b/test/rubygems/test_gem_specification.rb index 7aa9d5aeb17a4a..1afb5ba247c414 100644 --- a/test/rubygems/test_gem_specification.rb +++ b/test/rubygems/test_gem_specification.rb @@ -999,8 +999,8 @@ def test_initialize_copy assert_equal 'summary', spec.summary assert_same spec.summary, new_spec.summary - assert_equal %w[lib/file.rb test/file.rb bin/exec README.txt - ext/extconf.rb].sort, + assert_equal %w[README.txt bin/exec ext/extconf.rb lib/file.rb + test/file.rb].sort, spec.files refute_same spec.files, new_spec.files, 'files' @@ -1109,7 +1109,31 @@ def test_bindir_equals_nil @a2.executable = 'app' assert_equal nil, @a2.bindir - assert_equal %w[lib/code.rb app].sort, @a2.files + assert_equal %w[app lib/code.rb].sort, @a2.files + end + + def test_extensions_equals_nil + @a2.instance_variable_set(:@extensions, nil) + assert_equal nil, @a2.instance_variable_get(:@extensions) + assert_equal %w[lib/code.rb], @a2.files + end + + def test_test_files_equals_nil + @a2.instance_variable_set(:@test_files, nil) + assert_equal nil, @a2.instance_variable_get(:@test_files) + assert_equal %w[lib/code.rb], @a2.files + end + + def test_executables_equals_nil + @a2.instance_variable_set(:@executables, nil) + assert_equal nil, @a2.instance_variable_get(:@executables) + assert_equal %w[lib/code.rb], @a2.files + end + + def test_extra_rdoc_files_equals_nil + @a2.instance_variable_set(:@extra_rdoc_files, nil) + assert_equal nil, @a2.instance_variable_get(:@extra_rdoc_files) + assert_equal %w[lib/code.rb], @a2.files end def test_build_extensions @@ -1437,7 +1461,7 @@ def test_executables def test_executable_equals @a2.executable = 'app' assert_equal 'app', @a2.executable - assert_equal %w[lib/code.rb bin/app].sort, @a2.files + assert_equal %w[bin/app lib/code.rb].sort, @a2.files end def test_extensions @@ -1765,26 +1789,39 @@ def test_prerelease_spec_adds_required_rubygems_version end def test_require_paths - enable_shared, RbConfig::CONFIG['ENABLE_SHARED'] = - RbConfig::CONFIG['ENABLE_SHARED'], 'no' + enable_shared 'no' do + ext_spec - ext_spec - - @ext.require_path = 'lib' + @ext.require_path = 'lib' - ext_install_dir = Pathname(@ext.extension_dir) - full_gem_path = Pathname(@ext.full_gem_path) - relative_install_dir = ext_install_dir.relative_path_from full_gem_path + ext_install_dir = Pathname(@ext.extension_dir) + full_gem_path = Pathname(@ext.full_gem_path) + relative_install_dir = ext_install_dir.relative_path_from full_gem_path - assert_equal [relative_install_dir.to_s, 'lib'], @ext.require_paths - ensure - RbConfig::CONFIG['ENABLE_SHARED'] = enable_shared + assert_equal [relative_install_dir.to_s, 'lib'], @ext.require_paths + end end def test_source assert_kind_of Gem::Source::Installed, @a1.source end + def test_source_paths + ext_spec + + @ext.require_paths = %w[lib ext foo] + @ext.extensions << 'bar/baz' + + expected = %w[ + lib + ext + foo + bar + ] + + assert_equal expected, @ext.source_paths + end + def test_full_require_paths ext_spec @@ -2435,7 +2472,7 @@ def test_validate_files assert_equal '["lib2"] are not files', e.message end - assert_equal %w[lib/code.rb test/suite.rb bin/exec ext/a/extconf.rb lib2].sort, + assert_equal %w[bin/exec ext/a/extconf.rb lib/code.rb lib2 test/suite.rb].sort, @a1.files end @@ -2911,9 +2948,9 @@ def util_setup_validate def with_syck begin + verbose, $VERBOSE = $VERBOSE, nil require "yaml" old_engine = YAML::ENGINE.yamler - verbose, $VERBOSE = $VERBOSE, nil YAML::ENGINE.yamler = 'syck' load 'rubygems/syck_hack.rb' rescue NameError diff --git a/test/rubygems/test_gem_uninstaller.rb b/test/rubygems/test_gem_uninstaller.rb index 1eea30fb9403d6..11fdaf68e22118 100644 --- a/test/rubygems/test_gem_uninstaller.rb +++ b/test/rubygems/test_gem_uninstaller.rb @@ -131,6 +131,23 @@ def test_remove_executables_user_format_disabled Gem::Installer.exec_format = nil end + def test_remove_not_in_home + uninstaller = Gem::Uninstaller.new nil, :install_dir => "#{@gemhome}2" + + e = assert_raises Gem::GemNotInHomeException do + use_ui ui do + uninstaller.remove @spec + end + end + + expected = + "Gem '#{@spec.full_name}' is not installed in directory #{@gemhome}2" + + assert_equal expected, e.message + + assert_path_exists @spec.gem_dir + end + def test_path_ok_eh uninstaller = Gem::Uninstaller.new nil diff --git a/test/rubygems/test_gem_version.rb b/test/rubygems/test_gem_version.rb index e0499fe73f9783..5a65b5c9c7b506 100644 --- a/test/rubygems/test_gem_version.rb +++ b/test/rubygems/test_gem_version.rb @@ -3,6 +3,9 @@ class TestGemVersion < Gem::TestCase + class V < ::Gem::Version + end + def test_bump assert_bumped_version_equal "5.3", "5.2.4" end @@ -37,6 +40,13 @@ def test_class_create assert_equal v('1.1'), Gem::Version.create(ver) end + def test_class_new_subclass + v1 = Gem::Version.new '1' + v2 = V.new '1' + + refute_same v1, v2 + end + def test_eql_eh assert_version_eql "1.2", "1.2" refute_version_eql "1.2", "1.2.0" diff --git a/version.h b/version.h index ffd78c8e59fe29..e3174fd8e53b32 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-06" -#define RUBY_PATCHLEVEL 25 +#define RUBY_PATCHLEVEL 26 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 0de6eef3d2551974f9f48af0298d3c415c4e7727 Mon Sep 17 00:00:00 2001 From: naruse Date: Thu, 6 Feb 2014 07:24:46 +0000 Subject: [PATCH 022/343] merge revision(s) 44852: [Backport #9343] * ext/thread/thread.c (rb_szqueue_max_set): use correct queue and limit wakeups. [Bug #9343][ruby-core:60517] * test/thread/test_queue.rb (test_sized_queue_assign_max): test for bug git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@44863 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ ext/thread/thread.c | 2 +- test/thread/test_queue.rb | 7 +++++++ version.h | 2 +- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 86fbbe34019209..66ef0e4b6b2c90 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Thu Feb 6 08:23:28 2014 Eric Wong + + * ext/thread/thread.c (rb_szqueue_max_set): use correct queue and + limit wakeups. [Bug #9343][ruby-core:60517] + * test/thread/test_queue.rb (test_sized_queue_assign_max): + test for bug + Thu Feb 6 11:27:39 2014 Eric Hodel * lib/rubygems: RubyGems 2.2.2 which contains the following bug fixes: diff --git a/ext/thread/thread.c b/ext/thread/thread.c index 208d1172dfb3ab..a8f675c55ba309 100644 --- a/ext/thread/thread.c +++ b/ext/thread/thread.c @@ -437,7 +437,7 @@ rb_szqueue_max_set(VALUE self, VALUE vmax) diff = max - GET_SZQUEUE_ULONGMAX(self); } RSTRUCT_SET(self, SZQUEUE_MAX, vmax); - while (diff > 0 && !NIL_P(t = rb_ary_shift(GET_QUEUE_QUE(self)))) { + while (diff-- > 0 && !NIL_P(t = rb_ary_shift(GET_SZQUEUE_WAITERS(self)))) { rb_thread_wakeup_alive(t); } return vmax; diff --git a/test/thread/test_queue.rb b/test/thread/test_queue.rb index 438e1e75e3edd4..2126500bd81d70 100644 --- a/test/thread/test_queue.rb +++ b/test/thread/test_queue.rb @@ -55,6 +55,13 @@ def test_sized_queue_assign_max assert_equal(1, q.max) assert_raise(ArgumentError) { q.max = -1 } assert_equal(1, q.max) + + before = q.max + q.max.times { q << 1 } + t1 = Thread.new { q << 1 } + sleep 0.01 until t1.stop? + q.max = q.max + 1 + assert_equal before + 1, q.max end def test_queue_pop_interrupt diff --git a/version.h b/version.h index e3174fd8e53b32..d4e9771d69bf78 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-06" -#define RUBY_PATCHLEVEL 26 +#define RUBY_PATCHLEVEL 27 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 3c00535d1a29222aa9995a6d8090fa74bff86e45 Mon Sep 17 00:00:00 2001 From: naruse Date: Thu, 6 Feb 2014 18:11:13 +0000 Subject: [PATCH 023/343] Add missing file of r44858 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@44866 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- .../rubygems/test_gem_resolver_composed_set.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 test/rubygems/test_gem_resolver_composed_set.rb diff --git a/test/rubygems/test_gem_resolver_composed_set.rb b/test/rubygems/test_gem_resolver_composed_set.rb new file mode 100644 index 00000000000000..85026f7eb98f95 --- /dev/null +++ b/test/rubygems/test_gem_resolver_composed_set.rb @@ -0,0 +1,18 @@ +require 'rubygems/test_case' + +class TestGemResolverComposedSet < Gem::TestCase + + def test_remote_equals + best_set = Gem::Resolver::BestSet.new + current_set = Gem::Resolver::CurrentSet.new + + set = Gem::Resolver::ComposedSet.new best_set, current_set + + set.remote = false + + refute best_set.remote? + refute current_set.remote? + end + +end + From 5d0f801aaef21df2d704993d99c623d72a11ae33 Mon Sep 17 00:00:00 2001 From: svn Date: Thu, 6 Feb 2014 18:11:17 +0000 Subject: [PATCH 024/343] * 2014-02-07 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@44867 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- version.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/version.h b/version.h index d4e9771d69bf78..d24a723923a949 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.1" -#define RUBY_RELEASE_DATE "2014-02-06" +#define RUBY_RELEASE_DATE "2014-02-07" #define RUBY_PATCHLEVEL 27 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 -#define RUBY_RELEASE_DAY 6 +#define RUBY_RELEASE_DAY 7 #include "ruby/version.h" From 73fc780998054e9ca4835b784b6fc9051f83332f Mon Sep 17 00:00:00 2001 From: naruse Date: Thu, 6 Feb 2014 19:21:40 +0000 Subject: [PATCH 025/343] merge revision(s) 44861,44862: [Backport #9493] * gc.c (get_envparam_int): don't accept a value equals to lowerbound (changed by last commit) because "" or "foo" (not a number) strings are parsed as 0. They should be rejected. * gc.c (get_envparam_double): ditto. * gc.c (get_envparam_int): accept a value equals to lowerbound. * gc.c (get_envparam_int): correct warning messsages. * gc.c (get_envparam_double): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@44868 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 16 +++++++++++++++- gc.c | 10 +++++----- version.h | 2 +- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 66ef0e4b6b2c90..7f7d3e092c1ab0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +Fri Feb 7 04:19:19 2014 Koichi Sasada + + * gc.c (get_envparam_int): correct warning messsages. + + * gc.c (get_envparam_double): ditto. + +Fri Feb 7 04:19:19 2014 Koichi Sasada + + * gc.c (get_envparam_int): don't accept a value equals to lowerbound + (changed by last commit) because "" or "foo" (not a number) strings + are parsed as 0. They should be rejected. + + * gc.c (get_envparam_double): ditto. + Thu Feb 6 08:23:28 2014 Eric Wong * ext/thread/thread.c (rb_szqueue_max_set): use correct queue and @@ -18,7 +32,7 @@ Thu Feb 6 11:23:59 2014 Koichi Sasada Without this fix, the env variable RUBY_GC_OLDMALLOC_LIMIT does not work. - * gc.c (get_envparam_int): accept a value equals to lowerbounds. + * gc.c (get_envparam_int): accept a value equals to lowerbound. * gc.c (get_envparam_double): ditto. diff --git a/gc.c b/gc.c index e51b727ecd5f84..1d182310e0f066 100644 --- a/gc.c +++ b/gc.c @@ -5649,13 +5649,13 @@ get_envparam_int(const char *name, unsigned int *default_value, int lower_bound) if (ptr != NULL) { val = atoi(ptr); - if (val >= lower_bound) { - if (RTEST(ruby_verbose)) fprintf(stderr, "%s=%d (%d)\n", name, val, *default_value); + if (val > lower_bound) { + if (RTEST(ruby_verbose)) fprintf(stderr, "%s=%d (default value: %d)\n", name, val, *default_value); *default_value = val; return 1; } else { - if (RTEST(ruby_verbose)) fprintf(stderr, "%s=%d (%d), but ignored because lower than %d\n", name, val, *default_value, lower_bound); + if (RTEST(ruby_verbose)) fprintf(stderr, "%s=%d (default value: %d) is ignored because it must be greater than %d.\n", name, val, *default_value, lower_bound); } } return 0; @@ -5669,13 +5669,13 @@ get_envparam_double(const char *name, double *default_value, double lower_bound) if (ptr != NULL) { val = strtod(ptr, NULL); - if (val >= lower_bound) { + if (val > lower_bound) { if (RTEST(ruby_verbose)) fprintf(stderr, "%s=%f (%f)\n", name, val, *default_value); *default_value = val; return 1; } else { - if (RTEST(ruby_verbose)) fprintf(stderr, "%s=%f (%f), but ignored because lower than %f\n", name, val, *default_value, lower_bound); + if (RTEST(ruby_verbose)) fprintf(stderr, "%s=%f (default value: %f) is ignored because it must be greater than %f.\n", name, val, *default_value, lower_bound); } } return 0; diff --git a/version.h b/version.h index d24a723923a949..1f780eb14d11f5 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-07" -#define RUBY_PATCHLEVEL 27 +#define RUBY_PATCHLEVEL 28 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 565d568a45855f138364c414ea266b3fd80ec05c Mon Sep 17 00:00:00 2001 From: naruse Date: Mon, 10 Feb 2014 11:45:14 +0000 Subject: [PATCH 026/343] merge revision(s) 44572,44578,44591,44592: [Backport #9490] ext: use rb_sprintf() and rb_vsprintf() with PRIsVALUE git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@44903 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/dl/cptr.c | 5 ++-- ext/fiddle/pointer.c | 6 ++-- ext/openssl/ossl.c | 18 +++++++----- ext/pty/pty.c | 6 ++-- ext/strscan/strscan.c | 61 ++++++++++++++++++----------------------- ext/tk/tcltklib.c | 7 ++--- ext/win32ole/win32ole.c | 11 ++++---- ext/zlib/zlib.c | 7 ++--- version.h | 6 ++-- 9 files changed, 58 insertions(+), 69 deletions(-) diff --git a/ext/dl/cptr.c b/ext/dl/cptr.c index 9e59139fc9d0a0..3f8858c4b37c2e 100644 --- a/ext/dl/cptr.c +++ b/ext/dl/cptr.c @@ -391,9 +391,8 @@ rb_dlptr_inspect(VALUE self) char str[1024]; TypedData_Get_Struct(self, struct ptr_data, &dlptr_data_type, data); - snprintf(str, 1023, "#<%s:%p ptr=%p size=%ld free=%p>", - rb_class2name(CLASS_OF(self)), data, data->ptr, data->size, data->free); - return rb_str_new2(str); + return rb_sprintf("#<%"PRIsVALUE":%p ptr=%p size=%ld free=%p>", + rb_obj_class(self), data, data->ptr, data->size, data->free); } /* diff --git a/ext/fiddle/pointer.c b/ext/fiddle/pointer.c index 4f4842fc334d53..0129363a8df2de 100644 --- a/ext/fiddle/pointer.c +++ b/ext/fiddle/pointer.c @@ -427,12 +427,10 @@ static VALUE rb_fiddle_ptr_inspect(VALUE self) { struct ptr_data *data; - char str[1024]; TypedData_Get_Struct(self, struct ptr_data, &fiddle_ptr_data_type, data); - snprintf(str, 1023, "#<%s:%p ptr=%p size=%ld free=%p>", - rb_class2name(CLASS_OF(self)), data, data->ptr, data->size, data->free); - return rb_str_new2(str); + return rb_sprintf("#<%"PRIsVALUE":%p ptr=%p size=%ld free=%p>", + rb_obj_class(self), data, data->ptr, data->size, data->free); } /* diff --git a/ext/openssl/ossl.c b/ext/openssl/ossl.c index 43ccf4c3fdf7fe..3961d3ea33424c 100644 --- a/ext/openssl/ossl.c +++ b/ext/openssl/ossl.c @@ -293,10 +293,9 @@ ossl_to_der_if_possible(VALUE obj) static VALUE ossl_make_error(VALUE exc, const char *fmt, va_list args) { - char buf[BUFSIZ]; + VALUE str = Qnil; const char *msg; long e; - int len = 0; #ifdef HAVE_ERR_PEEK_LAST_ERROR e = ERR_peek_last_error(); @@ -304,14 +303,19 @@ ossl_make_error(VALUE exc, const char *fmt, va_list args) e = ERR_peek_error(); #endif if (fmt) { - len = vsnprintf(buf, BUFSIZ, fmt, args); + str = rb_vsprintf(fmt, args); } - if (len < BUFSIZ && e) { + if (e) { if (dOSSL == Qtrue) /* FULL INFO */ msg = ERR_error_string(e, NULL); else msg = ERR_reason_error_string(e); - len += snprintf(buf+len, BUFSIZ-len, "%s%s", (len ? ": " : ""), msg); + if (NIL_P(str)) { + str = rb_str_new_cstr(msg); + } + else { + rb_str_cat2(rb_str_cat2(str, ": "), msg); + } } if (dOSSL == Qtrue){ /* show all errors on the stack */ while ((e = ERR_get_error()) != 0){ @@ -320,8 +324,8 @@ ossl_make_error(VALUE exc, const char *fmt, va_list args) } ERR_clear_error(); - if(len > BUFSIZ) len = rb_long2int(strlen(buf)); - return rb_exc_new(exc, buf, len); + if (NIL_P(str)) str = rb_str_new(0, 0); + return rb_exc_new3(exc, str); } void diff --git a/ext/pty/pty.c b/ext/pty/pty.c index 4ba1cba6212b91..f54bbb52e58a91 100644 --- a/ext/pty/pty.c +++ b/ext/pty/pty.c @@ -613,7 +613,7 @@ static void raise_from_check(rb_pid_t pid, int status) { const char *state; - char buf[1024]; + VALUE msg; VALUE exc; #if defined(WIFSTOPPED) @@ -631,8 +631,8 @@ raise_from_check(rb_pid_t pid, int status) else { state = "exited"; } - snprintf(buf, sizeof(buf), "pty - %s: %ld", state, (long)pid); - exc = rb_exc_new2(eChildExited, buf); + msg = rb_sprintf("pty - %s: %ld", state, (long)pid); + exc = rb_exc_new_str(eChildExited, msg); rb_iv_set(exc, "status", rb_last_status_get()); rb_exc_raise(exc); } diff --git a/ext/strscan/strscan.c b/ext/strscan/strscan.c index f020ba780dd8e4..ec983e1f5046e8 100644 --- a/ext/strscan/strscan.c +++ b/ext/strscan/strscan.c @@ -1155,76 +1155,69 @@ static VALUE strscan_inspect(VALUE self) { struct strscanner *p; - char buf[BUFSIZE]; - long len; VALUE a, b; p = check_strscan(self); if (NIL_P(p->str)) { - len = snprintf(buf, BUFSIZE, "#<%s (uninitialized)>", - rb_class2name(CLASS_OF(self))); - return infect(rb_str_new(buf, len), p); + a = rb_sprintf("#<%"PRIsVALUE" (uninitialized)>", rb_obj_class(self)); + return infect(a, p); } if (EOS_P(p)) { - len = snprintf(buf, BUFSIZE, "#<%s fin>", - rb_class2name(CLASS_OF(self))); - return infect(rb_str_new(buf, len), p); + a = rb_sprintf("#<%"PRIsVALUE" fin>", rb_obj_class(self)); + return infect(a, p); } if (p->curr == 0) { - b = inspect2(p); - len = snprintf(buf, BUFSIZE, "#<%s %ld/%ld @ %s>", - rb_class2name(CLASS_OF(self)), - p->curr, S_LEN(p), - RSTRING_PTR(b)); - return infect(rb_str_new(buf, len), p); + b = inspect2(p); + a = rb_sprintf("#<%"PRIsVALUE" %ld/%ld @ %"PRIsVALUE">", + rb_obj_class(self), + p->curr, S_LEN(p), + b); + return infect(a, p); } a = inspect1(p); b = inspect2(p); - len = snprintf(buf, BUFSIZE, "#<%s %ld/%ld %s @ %s>", - rb_class2name(CLASS_OF(self)), - p->curr, S_LEN(p), - RSTRING_PTR(a), - RSTRING_PTR(b)); - return infect(rb_str_new(buf, len), p); + a = rb_sprintf("#<%"PRIsVALUE" %ld/%ld %"PRIsVALUE" @ %"PRIsVALUE">", + rb_obj_class(self), + p->curr, S_LEN(p), + a, b); + return infect(a, p); } static VALUE inspect1(struct strscanner *p) { - char buf[BUFSIZE]; - char *bp = buf; + VALUE str; long len; if (p->curr == 0) return rb_str_new2(""); if (p->curr > INSPECT_LENGTH) { - strcpy(bp, "..."); bp += 3; - len = INSPECT_LENGTH; + str = rb_str_new_cstr("..."); + len = INSPECT_LENGTH; } else { - len = p->curr; + str = rb_str_new(0, 0); + len = p->curr; } - memcpy(bp, CURPTR(p) - len, len); bp += len; - return rb_str_dump(rb_str_new(buf, bp - buf)); + rb_str_cat(str, CURPTR(p) - len, len); + return rb_str_dump(str); } static VALUE inspect2(struct strscanner *p) { - char buf[BUFSIZE]; - char *bp = buf; + VALUE str; long len; if (EOS_P(p)) return rb_str_new2(""); len = S_LEN(p) - p->curr; if (len > INSPECT_LENGTH) { - len = INSPECT_LENGTH; - memcpy(bp, CURPTR(p), len); bp += len; - strcpy(bp, "..."); bp += 3; + str = rb_str_new(CURPTR(p), INSPECT_LENGTH); + rb_str_cat2(str, "..."); } else { - memcpy(bp, CURPTR(p), len); bp += len; + str = rb_str_new(CURPTR(p), len); } - return rb_str_dump(rb_str_new(buf, bp - buf)); + return rb_str_dump(str); } /* ======================================================================= diff --git a/ext/tk/tcltklib.c b/ext/tk/tcltklib.c index d269f9c43ed6f4..237462fc3b3894 100644 --- a/ext/tk/tcltklib.c +++ b/ext/tk/tcltklib.c @@ -848,15 +848,14 @@ create_ip_exc(interp, exc, fmt, va_alist) #endif { va_list args; - char buf[BUFSIZ]; + VALUE msg; VALUE einfo; struct tcltkip *ptr = get_ip(interp); va_init_list(args,fmt); - vsnprintf(buf, BUFSIZ, fmt, args); - buf[BUFSIZ - 1] = '\0'; + msg = rb_vsprintf(fmt, args); va_end(args); - einfo = rb_exc_new2(exc, buf); + einfo = rb_exc_new_str(exc, msg); rb_ivar_set(einfo, ID_at_interp, interp); if (ptr) { Tcl_ResetResult(ptr->ip); diff --git a/ext/win32ole/win32ole.c b/ext/win32ole/win32ole.c index 9765929f345423..072638a10b5920 100644 --- a/ext/win32ole/win32ole.c +++ b/ext/win32ole/win32ole.c @@ -1209,19 +1209,18 @@ static void ole_raise(HRESULT hr, VALUE ecs, const char *fmt, ...) { va_list args; - char buf[BUFSIZ]; + VALUE msg; VALUE err_msg; va_init_list(args, fmt); - vsnprintf(buf, BUFSIZ, fmt, args); + msg = rb_vsprintf(fmt, args); va_end(args); err_msg = ole_hresult2msg(hr); if(err_msg != Qnil) { - rb_raise(ecs, "%s\n%s", buf, StringValuePtr(err_msg)); - } - else { - rb_raise(ecs, "%s", buf); + rb_str_cat2(msg, "\n"); + rb_str_append(msg, err_msg); } + rb_exc_raise(rb_exc_new_str(ecs, msg)); } void diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c index df2a2501b21031..391bec17226f8a 100644 --- a/ext/zlib/zlib.c +++ b/ext/zlib/zlib.c @@ -337,11 +337,8 @@ raise_zlib_error(int err, const char *msg) rb_sys_fail(msg); /* no return */ default: - { - char buf[BUFSIZ]; - snprintf(buf, BUFSIZ, "unknown zlib error %d: %s", err, msg); - exc = rb_exc_new2(cZError, buf); - } + exc = rb_exc_new_str(cZError, + rb_sprintf("unknown zlib error %d: %s", err, msg)); } rb_exc_raise(exc); diff --git a/version.h b/version.h index 1f780eb14d11f5..017ef2810c5a6e 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.1" -#define RUBY_RELEASE_DATE "2014-02-07" -#define RUBY_PATCHLEVEL 28 +#define RUBY_RELEASE_DATE "2014-02-10" +#define RUBY_PATCHLEVEL 29 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 -#define RUBY_RELEASE_DAY 7 +#define RUBY_RELEASE_DAY 10 #include "ruby/version.h" From 22ce47745b45b1a1230ba1b6ab6cb3815cf85bad Mon Sep 17 00:00:00 2001 From: naruse Date: Mon, 10 Feb 2014 13:35:07 +0000 Subject: [PATCH 027/343] merge revision(s) 44579: [Backport #9500] ext: use PRIsVALUE for rb_raise and rb_warn * ext/bigdecimal/bigdecimal.c (BigDecimal_new): use PRIsVALUE for rb_raise() and rb_warn(). * ext/openssl/ossl_cipher.c (ossl_cipher_init): ditto. * ext/racc/cparse/cparse.c (extract_user_token): ditto. * ext/syslog/syslog.c (mSyslog_log): ditto. * ext/openssl/ossl.h (OSSL_Check_Kind, OSSL_Check_Instance): now ossl_raise() also accepts PRIsVALUE. * ext/openssl/ossl_asn1.c (ossl_asn1_default_tag): git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@44904 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/bigdecimal/bigdecimal.c | 4 ++-- ext/openssl/ossl.h | 8 ++++---- ext/openssl/ossl_asn1.c | 4 ++-- ext/openssl/ossl_cipher.c | 6 +++--- ext/racc/cparse/cparse.c | 4 ++-- ext/syslog/syslog.c | 2 +- version.h | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c index 8537817e86b636..8c470fc2b77d82 100644 --- a/ext/bigdecimal/bigdecimal.c +++ b/ext/bigdecimal/bigdecimal.c @@ -2519,8 +2519,8 @@ BigDecimal_new(int argc, VALUE *argv) case T_RATIONAL: if (NIL_P(nFig)) { rb_raise(rb_eArgError, - "can't omit precision for a %s.", - rb_class2name(CLASS_OF(iniValue))); + "can't omit precision for a %"PRIsVALUE".", + rb_obj_class(iniValue)); } return GetVpValueWithPrec(iniValue, mf, 1); diff --git a/ext/openssl/ossl.h b/ext/openssl/ossl.h index 96d0ade11e0d24..83a927dabe585e 100644 --- a/ext/openssl/ossl.h +++ b/ext/openssl/ossl.h @@ -95,15 +95,15 @@ extern VALUE eOSSLError; */ #define OSSL_Check_Kind(obj, klass) do {\ if (!rb_obj_is_kind_of((obj), (klass))) {\ - ossl_raise(rb_eTypeError, "wrong argument (%s)! (Expected kind of %s)",\ - rb_obj_classname(obj), rb_class2name(klass));\ + ossl_raise(rb_eTypeError, "wrong argument (%"PRIsVALUE")! (Expected kind of %"PRIsVALUE")",\ + rb_obj_class(obj), (klass));\ }\ } while (0) #define OSSL_Check_Instance(obj, klass) do {\ if (!rb_obj_is_instance_of((obj), (klass))) {\ - ossl_raise(rb_eTypeError, "wrong argument (%s)! (Expected instance of %s)",\ - rb_obj_classname(obj), rb_class2name(klass));\ + ossl_raise(rb_eTypeError, "wrong argument (%"PRIsVALUE")! (Expected instance of %"PRIsVALUE")",\ + rb_obj_class(obj), (klass));\ }\ } while (0) diff --git a/ext/openssl/ossl_asn1.c b/ext/openssl/ossl_asn1.c index e3f59bfe1e16f7..c2344affa69145 100644 --- a/ext/openssl/ossl_asn1.c +++ b/ext/openssl/ossl_asn1.c @@ -624,8 +624,8 @@ ossl_asn1_default_tag(VALUE obj) } tmp_class = rb_class_superclass(tmp_class); } - ossl_raise(eASN1Error, "universal tag for %s not found", - rb_class2name(CLASS_OF(obj))); + ossl_raise(eASN1Error, "universal tag for %"PRIsVALUE" not found", + rb_obj_class(obj)); return -1; /* dummy */ } diff --git a/ext/openssl/ossl_cipher.c b/ext/openssl/ossl_cipher.c index 03374372ad0d6a..df6fd108878b40 100644 --- a/ext/openssl/ossl_cipher.c +++ b/ext/openssl/ossl_cipher.c @@ -213,9 +213,9 @@ ossl_cipher_init(int argc, VALUE *argv, VALUE self, int mode) * We deprecated the arguments for this method, but we decided * keeping this behaviour for backward compatibility. */ - const char *cname = rb_class2name(rb_obj_class(self)); - rb_warn("arguments for %s#encrypt and %s#decrypt were deprecated; " - "use %s#pkcs5_keyivgen to derive key and IV", + VALUE cname = rb_class_path(rb_obj_class(self)); + rb_warn("arguments for %"PRIsVALUE"#encrypt and %"PRIsVALUE"#decrypt were deprecated; " + "use %"PRIsVALUE"#pkcs5_keyivgen to derive key and IV", cname, cname, cname); StringValue(pass); GetCipher(self, ctx); diff --git a/ext/racc/cparse/cparse.c b/ext/racc/cparse/cparse.c index 9bb40e74830f8e..36ad9592229463 100644 --- a/ext/racc/cparse/cparse.c +++ b/ext/racc/cparse/cparse.c @@ -418,10 +418,10 @@ extract_user_token(struct cparse_params *v, VALUE block_args, if (!RB_TYPE_P(block_args, T_ARRAY)) { rb_raise(rb_eTypeError, - "%s() %s %s (must be Array[2])", + "%s() %s %"PRIsVALUE" (must be Array[2])", v->lex_is_iterator ? rb_id2name(v->lexmid) : "next_token", v->lex_is_iterator ? "yielded" : "returned", - rb_class2name(CLASS_OF(block_args))); + rb_obj_class(block_args)); } if (RARRAY_LEN(block_args) != 2) { rb_raise(rb_eArgError, diff --git a/ext/syslog/syslog.c b/ext/syslog/syslog.c index 17c5ef89697e0e..482a0a2eeeb541 100644 --- a/ext/syslog/syslog.c +++ b/ext/syslog/syslog.c @@ -312,7 +312,7 @@ static VALUE mSyslog_log(int argc, VALUE *argv, VALUE self) pri = *argv++; if (!FIXNUM_P(pri)) { - rb_raise(rb_eTypeError, "type mismatch: %s given", rb_class2name(CLASS_OF(pri))); + rb_raise(rb_eTypeError, "type mismatch: %"PRIsVALUE" given", rb_obj_class(pri)); } syslog_write(FIX2INT(pri), argc, argv); diff --git a/version.h b/version.h index 017ef2810c5a6e..1f1fb66024ff2f 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-10" -#define RUBY_PATCHLEVEL 29 +#define RUBY_PATCHLEVEL 30 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From c83ad9aaedf690bcae947e27a09a217c2948e75e Mon Sep 17 00:00:00 2001 From: naruse Date: Sun, 16 Feb 2014 00:13:51 +0000 Subject: [PATCH 028/343] merge revision(s) 44474,44538,44539,44890,44896: [Backport #9495] * configure.in: use SSE2 instructions for drop unexpected precisions. [ruby-core:54738] [Bug #8358] * configure.in: use SSE2 instructions to drop unexpected precisions on other than mingw. [ruby-core:59472] [Bug #8358] * configure.in: -mstackrealign is necessary for -msse2 working. [ruby-core:54716] [Bug #8349] * configure.in: -mstackrealign is necessary for -msse2 working. [ruby-core:54716] [Bug #8349] * configure.in: add qouting brackets and append wildcard for the rest after target_cpu, to properly detect platform for SSE2 instructions. [ruby-core:60576] [Bug #8358] * configure.in: Fix compilation error. https://bugs.ruby-lang.org/issues/8358#note-16 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@44993 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 29 +++++++++++++++++++++++++++++ configure.in | 16 ++++++++++++++++ version.h | 6 +++--- 3 files changed, 48 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7f7d3e092c1ab0..cdc4eb6fc032ac 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,32 @@ +Sun Feb 16 07:13:36 2014 Tanaka Akira + + * configure.in: Fix compilation error. + https://bugs.ruby-lang.org/issues/8358#note-16 + +Sun Feb 16 07:13:36 2014 Vit Ondruch + + * configure.in: add qouting brackets and append wildcard for the + rest after target_cpu, to properly detect platform for SSE2 + instructions. [ruby-core:60576] [Bug #8358] + +Sun Feb 16 07:13:36 2014 Nobuyoshi Nakada + + * configure.in: -mstackrealign is necessary for -msse2 working. + [ruby-core:54716] [Bug #8349] + +Sun Feb 16 07:13:36 2014 Nobuyoshi Nakada + + * configure.in: -mstackrealign is necessary for -msse2 working. + [ruby-core:54716] [Bug #8349] + + * configure.in: use SSE2 instructions to drop unexpected precisions on + other than mingw. [ruby-core:59472] [Bug #8358] + +Sun Feb 16 07:13:36 2014 Nobuyoshi Nakada + + * configure.in: use SSE2 instructions for drop unexpected + precisions. [ruby-core:54738] [Bug #8358] + Fri Feb 7 04:19:19 2014 Koichi Sasada * gc.c (get_envparam_int): correct warning messsages. diff --git a/configure.in b/configure.in index 84f176dd9415be..95ab2723a44eb2 100644 --- a/configure.in +++ b/configure.in @@ -856,6 +856,22 @@ if test "$GCC" = yes; then for oflag in -fno-fast-math; do RUBY_TRY_CFLAGS($oflag, [RUBY_APPEND_OPTION(optflags, $oflag)]) done + AS_CASE(["$target"], + [*-darwin*], [ + # doesn't seem necessary on Mac OS X + ], + [[i[4-6]86*]], [ + RUBY_TRY_CFLAGS(-msse2 -mfpmath=sse, [ + RUBY_APPEND_OPTION(XCFLAGS, -msse2 -mfpmath=sse) + ]) + AS_CASE(["$XCFLAGS"], + [[*-msse2*]], [ + RUBY_TRY_CFLAGS(-mstackrealign, [ + RUBY_APPEND_OPTION(XCFLAGS, -mstackrealign) + ]) + ]) + ] + ) fi AC_ARG_WITH(opt-dir, diff --git a/version.h b/version.h index 1f1fb66024ff2f..183459c52550f2 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.1" -#define RUBY_RELEASE_DATE "2014-02-10" -#define RUBY_PATCHLEVEL 30 +#define RUBY_RELEASE_DATE "2014-02-16" +#define RUBY_PATCHLEVEL 31 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 -#define RUBY_RELEASE_DAY 10 +#define RUBY_RELEASE_DAY 16 #include "ruby/version.h" From 4ee9d27f3a909a4eef2a2966a94629202312925a Mon Sep 17 00:00:00 2001 From: naruse Date: Sun, 16 Feb 2014 21:28:55 +0000 Subject: [PATCH 029/343] merge revision(s) 44476: [Backport #9317] * configure.in: reset LDFLAGS and DLDFLAGS for opt-dir again after LIBPATHFLAG and RPATHFLAG are set. [ruby-dev:47868] [Bug #9317] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45017 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ configure.in | 29 +++++++++++++++++++---------- version.h | 6 +++--- 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index cdc4eb6fc032ac..f83313a6592863 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Mon Feb 17 05:43:20 2014 Nobuyoshi Nakada + + * configure.in: reset LDFLAGS and DLDFLAGS for opt-dir again after + LIBPATHFLAG and RPATHFLAG are set. [ruby-dev:47868] [Bug #9317] + Sun Feb 16 07:13:36 2014 Tanaka Akira * configure.in: Fix compilation error. diff --git a/configure.in b/configure.in index 95ab2723a44eb2..a920fd5675a71b 100644 --- a/configure.in +++ b/configure.in @@ -880,17 +880,11 @@ AC_ARG_WITH(opt-dir, [ val=`echo "$PATH_SEPARATOR$withval" | sed "s|$PATH_SEPARATOR\([[^$PATH_SEPARATOR]*]\)| -I\1/include|g;s/^ //"` CPPFLAGS="$CPPFLAGS $val" - val=`IFS="$PATH_SEPARATOR" - for dir in $withval; do - echo x ${LIBPATHFLAG} ${RPATHFLAG} | - sed "s/^x *//;s${IFS}"'%1\\$-s'"${IFS}${dir}/lib${IFS}g;s${IFS}%s${IFS}${dir}/lib${IFS}g" - done | tr '\012' ' '` + val=`echo "$PATH_SEPARATOR$withval" | sed "s|$PATH_SEPARATOR\([[^$PATH_SEPARATOR]*]\)| -L\1/lib|g;s/^ //"` + LDFLAGS="$LDFLAGS $val" LDFLAGS_OPTDIR="$val" - test x"${LDFLAGS}" = x || LDFLAGS="$LDFLAGS " - LDFLAGS="$LDFLAGS$val" - test x"${DLDFLAGS}" = x || DLDFLAGS="$DLDFLAGS " - DLDFLAGS="$DLDFLAGS$val" - ]) + OPT_DIR="$withval" + ], [OPT_DIR=]) test -z "${ac_env_CFLAGS_set}" -a -n "${cflags+set}" && eval CFLAGS="\"$cflags $ARCH_FLAG\"" test -z "${ac_env_CXXFLAGS_set}" -a -n "${cxxflags+set}" && eval CXXFLAGS="\"$cxxflags $ARCH_FLAG\"" @@ -2777,6 +2771,21 @@ AC_SUBST(RPATHFLAG) AC_SUBST(LIBPATHENV, "${LIBPATHENV-LD_LIBRARY_PATH}") AC_SUBST(TRY_LINK) +if test "x$OPT_DIR" != x; then + pat=`echo "${LDFLAGS_OPTDIR}" | sed ['s/[][\\.*|]/\\\\&/']` + LDFLAGS=`echo "${LDFLAGS}" | sed "s| ${pat}||"` + val=`IFS="$PATH_SEPARATOR" + for dir in $OPT_DIR; do + echo x ${LIBPATHFLAG} ${RPATHFLAG} | + sed "s/^x *//;s${IFS}"'%1\\$-s'"${IFS}${dir}/lib${IFS}g;s${IFS}%s${IFS}${dir}/lib${IFS}g" + done | tr '\012' ' '` + test x"${LDFLAGS}" = x || LDFLAGS="$LDFLAGS " + LDFLAGS="$LDFLAGS$val" + test x"${DLDFLAGS}" = x || DLDFLAGS="$DLDFLAGS " + DLDFLAGS="$DLDFLAGS$val" + LDFLAGS_OPTDIR="$val" +fi + AS_CASE(["$target_cpu-$target_os"], [*-darwin*], [ AC_CHECK_HEADERS([execinfo.h]) diff --git a/version.h b/version.h index 183459c52550f2..2f767ea943ed6a 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.1" -#define RUBY_RELEASE_DATE "2014-02-16" -#define RUBY_PATCHLEVEL 31 +#define RUBY_RELEASE_DATE "2014-02-17" +#define RUBY_PATCHLEVEL 32 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 -#define RUBY_RELEASE_DAY 16 +#define RUBY_RELEASE_DAY 17 #include "ruby/version.h" From 879ac9dec2ccb6a006ae6aa075110f6a8946547c Mon Sep 17 00:00:00 2001 From: naruse Date: Tue, 18 Feb 2014 23:07:51 +0000 Subject: [PATCH 030/343] merge revision(s) 44492: [Backport #9351] * lib/rinda/ring.rb (Rinda::RingFinger#make_socket): Use ipv4_multicast_loop option for portability. Patch by Jeremy Evans. [ruby-trunk - Bug #9351] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45041 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ lib/rinda/ring.rb | 2 +- version.h | 6 +++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index f83313a6592863..b09dc5a0ea6fc2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Wed Feb 19 07:51:02 2014 Eric Hodel + + * lib/rinda/ring.rb (Rinda::RingFinger#make_socket): Use + ipv4_multicast_loop option for portability. Patch by Jeremy Evans. + [ruby-trunk - Bug #9351] + Mon Feb 17 05:43:20 2014 Nobuyoshi Nakada * configure.in: reset LDFLAGS and DLDFLAGS for opt-dir again after diff --git a/lib/rinda/ring.rb b/lib/rinda/ring.rb index 1ecc56a4f5b75b..4e9efadc357317 100644 --- a/lib/rinda/ring.rb +++ b/lib/rinda/ring.rb @@ -413,7 +413,7 @@ def make_socket(address) # :nodoc: soc = Socket.new(addrinfo.pfamily, addrinfo.socktype, addrinfo.protocol) if addrinfo.ipv4_multicast? then - soc.setsockopt(:IPPROTO_IP, :IP_MULTICAST_LOOP, true) + soc.setsockopt(Socket::Option.ipv4_multicast_loop(1)) soc.setsockopt(:IPPROTO_IP, :IP_MULTICAST_TTL, [@multicast_hops].pack('c')) elsif addrinfo.ipv6_multicast? then diff --git a/version.h b/version.h index 2f767ea943ed6a..faa1c6aa3e46ef 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.1" -#define RUBY_RELEASE_DATE "2014-02-17" -#define RUBY_PATCHLEVEL 32 +#define RUBY_RELEASE_DATE "2014-02-19" +#define RUBY_PATCHLEVEL 33 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 -#define RUBY_RELEASE_DAY 17 +#define RUBY_RELEASE_DAY 19 #include "ruby/version.h" From 56b6eed32320c4793ee105d5bf23041804d0a0e3 Mon Sep 17 00:00:00 2001 From: naruse Date: Wed, 19 Feb 2014 06:00:46 +0000 Subject: [PATCH 031/343] merge revision(s) 45021,45022,45028: [Backport #9524] * gc.c: introduce new environment variable "RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR" to control major/minor GC frequency. Do full GC when the number of old objects is more than R * N where R is this factor and * test/ruby/test_gc.rb: add a test. * gc.c (get_envparam_double): fix a warning message. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45044 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 21 +++++++++++++++++++++ gc.c | 20 ++++++++++++++++---- test/ruby/test_gc.rb | 10 ++++++++++ version.h | 2 +- 4 files changed, 48 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index b09dc5a0ea6fc2..0d20e2821919c5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,24 @@ +Wed Feb 19 14:25:55 2014 Koichi Sasada + + * test/ruby/test_gc.rb: ignore warning messages for running with -w + option such as chkbuild. + +Wed Feb 19 14:25:55 2014 Koichi Sasada + + * gc.c (get_envparam_double): fix a warning message. + +Wed Feb 19 14:25:55 2014 Koichi Sasada + + * gc.c: introduce new environment variable + "RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR" to control major/minor GC + frequency. + + Do full GC when the number of old objects is more than R * N + where R is this factor and + N is the number of old objects just after last full GC. + + * test/ruby/test_gc.rb: add a test. + Wed Feb 19 07:51:02 2014 Eric Hodel * lib/rinda/ring.rb (Rinda::RingFinger#make_socket): Use diff --git a/gc.c b/gc.c index 1d182310e0f066..bcf4769b7f9e4b 100644 --- a/gc.c +++ b/gc.c @@ -108,6 +108,9 @@ rb_gc_guarded_ptr(volatile VALUE *ptr) #ifndef GC_HEAP_GROWTH_MAX_SLOTS #define GC_HEAP_GROWTH_MAX_SLOTS 0 /* 0 is disable */ #endif +#ifndef GC_HEAP_OLDOBJECT_LIMIT_FACTOR +#define GC_HEAP_OLDOBJECT_LIMIT_FACTOR 2.0 +#endif #ifndef GC_MALLOC_LIMIT_MIN #define GC_MALLOC_LIMIT_MIN (16 * 1024 * 1024 /* 16MB */) @@ -134,6 +137,7 @@ typedef struct { unsigned int heap_free_slots; double growth_factor; unsigned int growth_max_slots; + double oldobject_limit_factor; unsigned int malloc_limit_min; unsigned int malloc_limit_max; double malloc_limit_growth_factor; @@ -150,6 +154,7 @@ static ruby_gc_params_t gc_params = { GC_HEAP_INIT_SLOTS, GC_HEAP_GROWTH_FACTOR, GC_HEAP_GROWTH_MAX_SLOTS, + GC_HEAP_OLDOBJECT_LIMIT_FACTOR, GC_MALLOC_LIMIT_MIN, GC_MALLOC_LIMIT_MAX, GC_MALLOC_LIMIT_GROWTH_FACTOR, @@ -4498,10 +4503,12 @@ gc_marks(rb_objspace_t *objspace, int full_mark) #endif gc_marks_body(objspace, TRUE); - - /* Do full GC if old/remembered_shady object counts is greater than counts two times at last full GC counts */ - objspace->rgengc.remembered_shady_object_limit = objspace->rgengc.remembered_shady_object_count * 2; - objspace->rgengc.old_object_limit = objspace->rgengc.old_object_count * 2; + { + /* See the comment about RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR */ + const double r = gc_params.oldobject_limit_factor; + objspace->rgengc.remembered_shady_object_limit = objspace->rgengc.remembered_shady_object_count * r; + objspace->rgengc.old_object_limit = objspace->rgengc.old_object_count * r; + } } else { /* minor GC */ gc_marks_body(objspace, FALSE); @@ -5706,6 +5713,10 @@ gc_set_initial_pages(void) * - (next slots number) = (current slots number) * (this factor) * * RUBY_GC_HEAP_GROWTH_MAX_SLOTS (new from 2.1) * - Allocation rate is limited to this factor. + * * RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR (new from 2.1.1) + * - Do full GC when the number of old objects is more than R * N + * where R is this factor and + * N is the number of old objects just after last full GC. * * * obsolete * * RUBY_FREE_MIN -> RUBY_GC_HEAP_FREE_SLOTS (from 2.1) @@ -5742,6 +5753,7 @@ ruby_gc_set_params(int safe_level) get_envparam_double("RUBY_GC_HEAP_GROWTH_FACTOR", &gc_params.growth_factor, 1.0); get_envparam_int ("RUBY_GC_HEAP_GROWTH_MAX_SLOTS", &gc_params.growth_max_slots, 0); + get_envparam_double("RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR", &gc_params.oldobject_limit_factor, 0.0); get_envparam_int("RUBY_GC_MALLOC_LIMIT", &gc_params.malloc_limit_min, 0); get_envparam_int("RUBY_GC_MALLOC_LIMIT_MAX", &gc_params.malloc_limit_max, 0); diff --git a/test/ruby/test_gc.rb b/test/ruby/test_gc.rb index 7c13978dc1bb13..c644aa5d9a2e81 100644 --- a/test/ruby/test_gc.rb +++ b/test/ruby/test_gc.rb @@ -177,6 +177,16 @@ def test_gc_parameter assert_in_out_err([env, "-w", "-e", "exit"], "", [], /RUBY_GC_HEAP_GROWTH_FACTOR=2.0/, "") assert_in_out_err([env, "-w", "-e", "exit"], "", [], /RUBY_GC_HEAP_GROWTH_MAX_SLOTS=10000/, "[ruby-core:57928]") + env = { + "RUBY_GC_HEAP_INIT_SLOTS" => "100000", + "RUBY_GC_HEAP_FREE_SLOTS" => "10000", + "RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR" => "0.9", + } + assert_normal_exit("exit", "", :child_env => env) + assert_in_out_err([env, "-w", "-e", "exit"], "", [], /RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR=0\.9/, "") + # always full GC when RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR < 1.0 + assert_in_out_err([env, "-e", "1000_000.times{Object.new}; p(GC.stat[:minor_gc_count] < GC.stat[:major_gc_count])"], "", ['true'], //, "") + # check obsolete assert_in_out_err([{'RUBY_FREE_MIN' => '100'}, '-w', '-eexit'], '', [], /RUBY_FREE_MIN is obsolete. Use RUBY_GC_HEAP_FREE_SLOTS instead/) diff --git a/version.h b/version.h index faa1c6aa3e46ef..89fbf00c34981e 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-19" -#define RUBY_PATCHLEVEL 33 +#define RUBY_PATCHLEVEL 34 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 3b36c8da5c923445787dde6098faae8c0627bc54 Mon Sep 17 00:00:00 2001 From: naruse Date: Wed, 19 Feb 2014 21:24:30 +0000 Subject: [PATCH 032/343] merge revision(s) 44327: [Backport #9276] * gc.c (ruby_gc_set_params): don't show obsolete warnings for RUBY_FREE_MIN/RUBY_HEAP_MIN_SLOTS if RUBY_GC_HEAP_FREE_SLOTS/RUBY_GC_HEAP_INIT_SLOTS are given. [Bug #9276] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45054 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ gc.c | 12 +++++++----- version.h | 2 +- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0d20e2821919c5..b15412cae54216 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Wed Feb 19 15:25:13 2014 Koichi Sasada + + * gc.c (ruby_gc_set_params): don't show obsolete warnings for + RUBY_FREE_MIN/RUBY_HEAP_MIN_SLOTS if + RUBY_GC_HEAP_FREE_SLOTS/RUBY_GC_HEAP_INIT_SLOTS are given. + [Bug #9276] + Wed Feb 19 14:25:55 2014 Koichi Sasada * test/ruby/test_gc.rb: ignore warning messages for running with -w diff --git a/gc.c b/gc.c index bcf4769b7f9e4b..2762db4529a9ad 100644 --- a/gc.c +++ b/gc.c @@ -5737,17 +5737,19 @@ ruby_gc_set_params(int safe_level) if (safe_level > 0) return; /* RUBY_GC_HEAP_FREE_SLOTS */ - if (get_envparam_int ("RUBY_FREE_MIN", &gc_params.heap_free_slots, 0)) { + if (get_envparam_int("RUBY_GC_HEAP_FREE_SLOTS", &gc_params.heap_free_slots, 0)) { + /* ok */ + } + else if (get_envparam_int("RUBY_FREE_MIN", &gc_params.heap_free_slots, 0)) { rb_warn("RUBY_FREE_MIN is obsolete. Use RUBY_GC_HEAP_FREE_SLOTS instead."); } - get_envparam_int ("RUBY_GC_HEAP_FREE_SLOTS", &gc_params.heap_free_slots, 0); /* RUBY_GC_HEAP_INIT_SLOTS */ - if (get_envparam_int("RUBY_HEAP_MIN_SLOTS", &gc_params.heap_init_slots, 0)) { - rb_warn("RUBY_HEAP_MIN_SLOTS is obsolete. Use RUBY_GC_HEAP_INIT_SLOTS instead."); + if (get_envparam_int("RUBY_GC_HEAP_INIT_SLOTS", &gc_params.heap_init_slots, 0)) { gc_set_initial_pages(); } - if (get_envparam_int("RUBY_GC_HEAP_INIT_SLOTS", &gc_params.heap_init_slots, 0)) { + else if (get_envparam_int("RUBY_HEAP_MIN_SLOTS", &gc_params.heap_init_slots, 0)) { + rb_warn("RUBY_HEAP_MIN_SLOTS is obsolete. Use RUBY_GC_HEAP_INIT_SLOTS instead."); gc_set_initial_pages(); } diff --git a/version.h b/version.h index 89fbf00c34981e..a1b9f3b9d6e358 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-19" -#define RUBY_PATCHLEVEL 34 +#define RUBY_PATCHLEVEL 35 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From d1411c87c6ef69e867e8bb9b825bd07a6423ef02 Mon Sep 17 00:00:00 2001 From: svn Date: Wed, 19 Feb 2014 21:24:33 +0000 Subject: [PATCH 033/343] * 2014-02-20 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45055 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- version.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/version.h b/version.h index a1b9f3b9d6e358..7f46c320f44aa1 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.1" -#define RUBY_RELEASE_DATE "2014-02-19" +#define RUBY_RELEASE_DATE "2014-02-20" #define RUBY_PATCHLEVEL 35 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 -#define RUBY_RELEASE_DAY 19 +#define RUBY_RELEASE_DAY 20 #include "ruby/version.h" From 781159e7ba76511b3eba266fe57e566b447cc47e Mon Sep 17 00:00:00 2001 From: naruse Date: Thu, 20 Feb 2014 01:56:10 +0000 Subject: [PATCH 034/343] merge revision(s) 44638: [Backport #9350] * ext/socket/option.c: IP_MULTICAST_LOOP and IP_MULTICAST_TTL socket option takes a byte on OpenBSD. Fixed by Jeremy Evans. [ruby-core:59496] [Bug #9350] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45056 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ ext/socket/option.c | 14 +++++++------- version.h | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index b15412cae54216..f97112c5fc0302 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Thu Feb 20 10:19:40 2014 Tanaka Akira + + * ext/socket/option.c: IP_MULTICAST_LOOP and IP_MULTICAST_TTL socket + option takes a byte on OpenBSD. + Fixed by Jeremy Evans. [ruby-core:59496] [Bug #9350] + Wed Feb 19 15:25:13 2014 Koichi Sasada * gc.c (ruby_gc_set_params): don't show obsolete warnings for diff --git a/ext/socket/option.c b/ext/socket/option.c index 3e32230aabcd95..28bdc07db621e4 100644 --- a/ext/socket/option.c +++ b/ext/socket/option.c @@ -357,7 +357,7 @@ static VALUE sockopt_s_ipv4_multicast_loop(VALUE klass, VALUE value) { #if defined(IPPROTO_IP) && defined(IP_MULTICAST_LOOP) -# ifdef __NetBSD__ +# if defined(__NetBSD__) || defined(__OpenBSD__) unsigned char i = NUM2CHR(rb_to_int(value)); # else int i = NUM2INT(rb_to_int(value)); @@ -387,7 +387,7 @@ sockopt_ipv4_multicast_loop(VALUE self) #if defined(IPPROTO_IP) && defined(IP_MULTICAST_LOOP) if (family == AF_INET && level == IPPROTO_IP && optname == IP_MULTICAST_LOOP) { -# ifdef __NetBSD__ +# if defined(__NetBSD__) || defined(__OpenBSD__) return sockopt_byte(self); # else return sockopt_int(self); @@ -398,7 +398,7 @@ sockopt_ipv4_multicast_loop(VALUE self) UNREACHABLE; } -#ifdef __NetBSD__ +#if defined(__NetBSD__) || defined(__OpenBSD__) # define inspect_ipv4_multicast_loop(a,b,c,d) inspect_byte(a,b,c,d) #else # define inspect_ipv4_multicast_loop(a,b,c,d) inspect_int(a,b,c,d) @@ -420,7 +420,7 @@ static VALUE sockopt_s_ipv4_multicast_ttl(VALUE klass, VALUE value) { #if defined(IPPROTO_IP) && defined(IP_MULTICAST_TTL) -# ifdef __NetBSD__ +# if defined(__NetBSD__) || defined(__OpenBSD__) unsigned char i = NUM2CHR(rb_to_int(value)); # else int i = NUM2INT(rb_to_int(value)); @@ -450,7 +450,7 @@ sockopt_ipv4_multicast_ttl(VALUE self) #if defined(IPPROTO_IP) && defined(IP_MULTICAST_TTL) if (family == AF_INET && level == IPPROTO_IP && optname == IP_MULTICAST_TTL) { -# ifdef __NetBSD__ +# if defined(__NetBSD__) || defined(__OpenBSD__) return sockopt_byte(self); # else return sockopt_int(self); @@ -461,7 +461,7 @@ sockopt_ipv4_multicast_ttl(VALUE self) UNREACHABLE; } -#ifdef __NetBSD__ +#if defined(__NetBSD__) || defined(__OpenBSD__) # define inspect_ipv4_multicast_ttl(a,b,c,d) inspect_byte(a,b,c,d) #else # define inspect_ipv4_multicast_ttl(a,b,c,d) inspect_int(a,b,c,d) @@ -481,7 +481,7 @@ inspect_int(int level, int optname, VALUE data, VALUE ret) } } -#ifdef __NetBSD__ +#if defined(__NetBSD__) || defined(__OpenBSD__) static int inspect_byte(int level, int optname, VALUE data, VALUE ret) { diff --git a/version.h b/version.h index 7f46c320f44aa1..ad83d4db76b1ae 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-20" -#define RUBY_PATCHLEVEL 35 +#define RUBY_PATCHLEVEL 36 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From f851d5dea640be815df95f7f4525c0045eb278f1 Mon Sep 17 00:00:00 2001 From: naruse Date: Thu, 20 Feb 2014 03:25:08 +0000 Subject: [PATCH 035/343] merge revision(s) 44494: * lib/rinda/ring.rb (Rinda::RingFinger#make_socket): Use ipv4_multicast_ttl option for portability. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45060 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ lib/rinda/ring.rb | 3 +-- version.h | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index f97112c5fc0302..c861fb89390640 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Thu Feb 20 12:24:59 2014 Eric Hodel + + * lib/rinda/ring.rb (Rinda::RingFinger#make_socket): Use + ipv4_multicast_ttl option for portability. + Thu Feb 20 10:19:40 2014 Tanaka Akira * ext/socket/option.c: IP_MULTICAST_LOOP and IP_MULTICAST_TTL socket diff --git a/lib/rinda/ring.rb b/lib/rinda/ring.rb index 4e9efadc357317..2c29977d11bdbe 100644 --- a/lib/rinda/ring.rb +++ b/lib/rinda/ring.rb @@ -414,8 +414,7 @@ def make_socket(address) # :nodoc: if addrinfo.ipv4_multicast? then soc.setsockopt(Socket::Option.ipv4_multicast_loop(1)) - soc.setsockopt(:IPPROTO_IP, :IP_MULTICAST_TTL, - [@multicast_hops].pack('c')) + soc.setsockopt(Socket::Option.ipv4_multicast_ttl(@multicast_hops)) elsif addrinfo.ipv6_multicast? then soc.setsockopt(:IPPROTO_IPV6, :IPV6_MULTICAST_LOOP, true) soc.setsockopt(:IPPROTO_IPV6, :IPV6_MULTICAST_HOPS, diff --git a/version.h b/version.h index ad83d4db76b1ae..2c6e0abeb2d096 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-20" -#define RUBY_PATCHLEVEL 36 +#define RUBY_PATCHLEVEL 37 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 6770402812366dac38469876c7493c9e3ab71ffe Mon Sep 17 00:00:00 2001 From: naruse Date: Thu, 20 Feb 2014 04:44:35 +0000 Subject: [PATCH 036/343] merge revision(s) 44687,44706,44727: [Backport #8770] * process.c (recv_child_error): Fix deadlock in rb_fork_internal when a signal is sent to the parent process while Ruby is forking in IO.popen. Patch by Scott Francis. Closes GH-513. * process.c (send_child_error): retry write on EINTR to fix occasional Errno::EINTR from Process.spawn. * process.c (recv_child_error): retry read on EINTR to fix occasional Errno::EINTR from Process.spawn. * process.c (READ_FROM_CHILD): Apply the last hunk of 0001-process.c-avoid-EINTR-from-Process.spawn.patch written by Eric Wong in [Bug #8770]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45061 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 14 ++++++++++++++ process.c | 34 +++++++++++++++++++++++++++++----- version.h | 2 +- 3 files changed, 44 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index c861fb89390640..21fae88fde84d7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +Thu Feb 20 12:58:45 2014 Tanaka Akira + + * process.c (READ_FROM_CHILD): Apply the last hunk of + 0001-process.c-avoid-EINTR-from-Process.spawn.patch written by + Eric Wong in [Bug #8770]. + +Thu Feb 20 12:58:45 2014 Eric Wong + + * process.c (send_child_error): retry write on EINTR to fix + occasional Errno::EINTR from Process.spawn. + + * process.c (recv_child_error): retry read on EINTR to fix + occasional Errno::EINTR from Process.spawn. + Thu Feb 20 12:24:59 2014 Eric Hodel * lib/rinda/ring.rb (Rinda::RingFinger#make_socket): Use diff --git a/process.c b/process.c index f5d84973c40533..e50a047c8634da 100644 --- a/process.c +++ b/process.c @@ -3296,6 +3296,30 @@ retry_fork(int *status, int *ep, int chfunc_is_async_signal_safe) } } +static ssize_t +write_retry(int fd, const void *buf, size_t len) +{ + ssize_t w; + + do { + w = write(fd, buf, len); + } while (w < 0 && errno == EINTR); + + return w; +} + +static ssize_t +read_retry(int fd, void *buf, size_t len) +{ + ssize_t r; + + do { + r = read(fd, buf, len); + } while (r < 0 && errno == EINTR); + + return r; +} + static void send_child_error(int fd, int state, char *errmsg, size_t errmsg_buflen, int chfunc_is_async_signal_safe) { @@ -3303,7 +3327,7 @@ send_child_error(int fd, int state, char *errmsg, size_t errmsg_buflen, int chfu int err; if (!chfunc_is_async_signal_safe) { - if (write(fd, &state, sizeof(state)) == sizeof(state) && state) { + if (write_retry(fd, &state, sizeof(state)) == sizeof(state) && state) { VALUE errinfo = rb_errinfo(); io = rb_io_fdopen(fd, O_WRONLY|O_BINARY, NULL); rb_marshal_dump(errinfo, io); @@ -3311,11 +3335,11 @@ send_child_error(int fd, int state, char *errmsg, size_t errmsg_buflen, int chfu } } err = errno; - if (write(fd, &err, sizeof(err)) < 0) err = errno; + if (write_retry(fd, &err, sizeof(err)) < 0) err = errno; if (errmsg && 0 < errmsg_buflen) { errmsg[errmsg_buflen-1] = '\0'; errmsg_buflen = strlen(errmsg); - if (errmsg_buflen > 0 && write(fd, errmsg, errmsg_buflen) < 0) + if (errmsg_buflen > 0 && write_retry(fd, errmsg, errmsg_buflen) < 0) err = errno; } if (!NIL_P(io)) rb_io_close(io); @@ -3329,7 +3353,7 @@ recv_child_error(int fd, int *statep, VALUE *excp, int *errp, char *errmsg, size ssize_t size; VALUE exc = Qnil; if (!chfunc_is_async_signal_safe) { - if ((read(fd, &state, sizeof(state))) == sizeof(state) && state) { + if ((read_retry(fd, &state, sizeof(state))) == sizeof(state) && state) { io = rb_io_fdopen(fd, O_RDONLY|O_BINARY, NULL); exc = rb_marshal_load(io); rb_set_errinfo(exc); @@ -3338,7 +3362,7 @@ recv_child_error(int fd, int *statep, VALUE *excp, int *errp, char *errmsg, size *excp = exc; } #define READ_FROM_CHILD(ptr, len) \ - (NIL_P(io) ? read(fd, (ptr), (len)) : rb_io_bufread(io, (ptr), (len))) + (NIL_P(io) ? read_retry(fd, (ptr), (len)) : rb_io_bufread(io, (ptr), (len))) if ((size = READ_FROM_CHILD(&err, sizeof(err))) < 0) { err = errno; } diff --git a/version.h b/version.h index 2c6e0abeb2d096..9cb1376d7a0def 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-20" -#define RUBY_PATCHLEVEL 37 +#define RUBY_PATCHLEVEL 38 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 575ff86a4b01d91fef49484de70caf7c5212bb22 Mon Sep 17 00:00:00 2001 From: naruse Date: Thu, 20 Feb 2014 07:30:24 +0000 Subject: [PATCH 037/343] merge revision(s) 44654: [Backport #9426] tracepoint.c: disable tracepoint * ext/-test-/tracepoint/tracepoint.c (tracepoint_track_objspace_events): ensure tracepoint disabled. [ruby-dev:47901] [Bug #9426] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45062 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/-test-/tracepoint/tracepoint.c | 3 +-- version.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/ext/-test-/tracepoint/tracepoint.c b/ext/-test-/tracepoint/tracepoint.c index 245dbd6191673b..aa8c212f99b71d 100644 --- a/ext/-test-/tracepoint/tracepoint.c +++ b/ext/-test-/tracepoint/tracepoint.c @@ -64,8 +64,7 @@ tracepoint_track_objspace_events(VALUE self) VALUE result = rb_ary_new(); rb_tracepoint_enable(tpval); - rb_yield(Qundef); - rb_tracepoint_disable(tpval); + rb_ensure(rb_yield, Qundef, rb_tracepoint_disable, tpval); rb_ary_push(result, SIZET2NUM(track.newobj_count)); rb_ary_push(result, SIZET2NUM(track.free_count)); diff --git a/version.h b/version.h index 9cb1376d7a0def..024fb772fa7174 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-20" -#define RUBY_PATCHLEVEL 38 +#define RUBY_PATCHLEVEL 39 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 4423b56753be681b4ddd4541c48044ce289d122e Mon Sep 17 00:00:00 2001 From: naruse Date: Fri, 21 Feb 2014 05:52:00 +0000 Subject: [PATCH 038/343] merge revision(s) 44720: [Backport #9455] * compile.c (iseq_build_from_ary_body): Use :blockptr instead of :block as hash key when loading serialized instruction sequences from arrays. [Bug #9455] [ruby-core:60146] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45069 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ compile.c | 2 +- version.h | 6 +++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 21fae88fde84d7..e13d7c5e9ce025 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Fri Feb 21 13:39:21 2014 Charlie Somerville + + * compile.c (iseq_build_from_ary_body): Use :blockptr instead of :block + as hash key when loading serialized instruction sequences from arrays. + [Bug #9455] [ruby-core:60146] + Thu Feb 20 12:58:45 2014 Tanaka Akira * process.c (READ_FROM_CHILD): Apply the last hunk of diff --git a/compile.c b/compile.c index 48479338c995c0..3d6a4627e9f475 100644 --- a/compile.c +++ b/compile.c @@ -5766,7 +5766,7 @@ iseq_build_from_ary_body(rb_iseq_t *iseq, LINK_ANCHOR *anchor, VALUE vmid = rb_hash_aref(op, ID2SYM(rb_intern("mid"))); VALUE vflag = rb_hash_aref(op, ID2SYM(rb_intern("flag"))); VALUE vorig_argc = rb_hash_aref(op, ID2SYM(rb_intern("orig_argc"))); - VALUE vblock = rb_hash_aref(op, ID2SYM(rb_intern("block"))); + VALUE vblock = rb_hash_aref(op, ID2SYM(rb_intern("blockptr"))); if (!NIL_P(vmid)) mid = SYM2ID(vmid); if (!NIL_P(vflag)) flag = NUM2ULONG(vflag); diff --git a/version.h b/version.h index 024fb772fa7174..dc6ac3919e5477 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.1" -#define RUBY_RELEASE_DATE "2014-02-20" -#define RUBY_PATCHLEVEL 39 +#define RUBY_RELEASE_DATE "2014-02-21" +#define RUBY_PATCHLEVEL 40 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 -#define RUBY_RELEASE_DAY 20 +#define RUBY_RELEASE_DAY 21 #include "ruby/version.h" From 862b86f2e4cc561861053c1485dc378c23ad794f Mon Sep 17 00:00:00 2001 From: naruse Date: Fri, 21 Feb 2014 08:34:35 +0000 Subject: [PATCH 039/343] merge revision(s) 44604,44605,44606: [Backport #9415] test_m17n.rb: split tests for inspect * test/ruby/test_m17n.rb (test_utf_16_32_inspect): split tests for each encodings. * string.c (get_actual_encoding): get actual encoding according to the BOM if exists. * string.c (rb_str_inspect): use according encoding, instead of pseudo encodings, UTF-{16,32}. [ruby-core:59757] [Bug #8940] * string.c (get_encoding): respect BOM on pseudo encodings. [ruby-dev:47895] [Bug #9415] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45074 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 13 ++++++++ encoding.c | 6 ++++ string.c | 69 +++++++++++++++++++++++++++--------------- test/ruby/test_m17n.rb | 35 +++++++++++++-------- version.h | 2 +- 5 files changed, 88 insertions(+), 37 deletions(-) diff --git a/ChangeLog b/ChangeLog index e13d7c5e9ce025..45f26694185572 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +Fri Feb 21 16:47:20 2014 Nobuyoshi Nakada + + * string.c (get_encoding): respect BOM on pseudo encodings. + [ruby-dev:47895] [Bug #9415] + +Fri Feb 21 16:47:20 2014 Nobuyoshi Nakada + + * string.c (get_actual_encoding): get actual encoding according to + the BOM if exists. + + * string.c (rb_str_inspect): use according encoding, instead of + pseudo encodings, UTF-{16,32}. [ruby-core:59757] [Bug #8940] + Fri Feb 21 13:39:21 2014 Charlie Somerville * compile.c (iseq_build_from_ary_body): Use :blockptr instead of :block diff --git a/encoding.c b/encoding.c index aede0fb08a9e20..9bfda11f380ee6 100644 --- a/encoding.c +++ b/encoding.c @@ -598,6 +598,12 @@ rb_enc_from_index(int index) return enc_table.list[index].enc; } +rb_encoding * +rb_enc_get_from_index(int index) +{ + return must_encindex(index); +} + int rb_enc_registered(const char *name) { diff --git a/string.c b/string.c index cc307866dbfb68..983c2a11661fa3 100644 --- a/string.c +++ b/string.c @@ -121,7 +121,45 @@ VALUE rb_cSymbol; #define STR_HEAP_PTR(str) (RSTRING(str)->as.heap.ptr) #define STR_HEAP_SIZE(str) (RSTRING(str)->as.heap.aux.capa + TERM_LEN(str)) -#define STR_ENC_GET(str) rb_enc_from_index(ENCODING_GET(str)) +#define STR_ENC_GET(str) get_encoding(str) + +rb_encoding *rb_enc_get_from_index(int index); + +static rb_encoding * +get_actual_encoding(const int encidx, VALUE str) +{ + const unsigned char *q; + + switch (encidx) { + case ENCINDEX_UTF_16: + if (RSTRING_LEN(str) < 2) break; + q = (const unsigned char *)RSTRING_PTR(str); + if (q[0] == 0xFE && q[1] == 0xFF) { + return rb_enc_get_from_index(ENCINDEX_UTF_16BE); + } + if (q[0] == 0xFF && q[1] == 0xFE) { + return rb_enc_get_from_index(ENCINDEX_UTF_16LE); + } + return rb_ascii8bit_encoding(); + case ENCINDEX_UTF_32: + if (RSTRING_LEN(str) < 4) break; + q = (const unsigned char *)RSTRING_PTR(str); + if (q[0] == 0 && q[1] == 0 && q[2] == 0xFE && q[3] == 0xFF) { + return rb_enc_get_from_index(ENCINDEX_UTF_32BE); + } + if (q[3] == 0 && q[2] == 0 && q[1] == 0xFE && q[0] == 0xFF) { + return rb_enc_get_from_index(ENCINDEX_UTF_32LE); + } + return rb_ascii8bit_encoding(); + } + return rb_enc_from_index(encidx); +} + +static rb_encoding * +get_encoding(VALUE str) +{ + return get_actual_encoding(ENCODING_GET(str), str); +} static int fstring_cmp(VALUE a, VALUE b); @@ -4750,8 +4788,8 @@ rb_str_buf_cat_escaped_char(VALUE result, unsigned int c, int unicode_p) VALUE rb_str_inspect(VALUE str) { - rb_encoding *enc = STR_ENC_GET(str); - int encidx = rb_enc_to_index(enc); + int encidx = ENCODING_GET(str); + rb_encoding *enc = rb_enc_from_index(encidx), *actenc; const char *p, *pend, *prev; char buf[CHAR_ESC_LEN + 1]; VALUE result = rb_str_buf_new(0); @@ -4766,27 +4804,10 @@ rb_str_inspect(VALUE str) p = RSTRING_PTR(str); pend = RSTRING_END(str); prev = p; - if (encidx == ENCINDEX_UTF_16 && p + 2 <= pend) { - const unsigned char *q = (const unsigned char *)p; - if (q[0] == 0xFE && q[1] == 0xFF) - enc = rb_enc_from_index(ENCINDEX_UTF_16BE); - else if (q[0] == 0xFF && q[1] == 0xFE) - enc = rb_enc_from_index(ENCINDEX_UTF_16LE); - else { - enc = rb_ascii8bit_encoding(); - unicode_p = 0; - } - } - else if (encidx == ENCINDEX_UTF_32 && p + 4 <= pend) { - const unsigned char *q = (const unsigned char *)p; - if (q[0] == 0 && q[1] == 0 && q[2] == 0xFE && q[3] == 0xFF) - enc = rb_enc_from_index(ENCINDEX_UTF_32BE); - else if (q[3] == 0 && q[2] == 0 && q[1] == 0xFE && q[0] == 0xFF) - enc = rb_enc_from_index(ENCINDEX_UTF_32LE); - else { - enc = rb_ascii8bit_encoding(); - unicode_p = 0; - } + actenc = get_actual_encoding(encidx, str); + if (actenc != enc) { + enc = actenc; + if (unicode_p) unicode_p = rb_enc_unicode_p(enc); } while (p < pend) { unsigned int c, cc; diff --git a/test/ruby/test_m17n.rb b/test/ruby/test_m17n.rb index 2e4f67c48afe66..b9b85b21293afb 100644 --- a/test/ruby/test_m17n.rb +++ b/test/ruby/test_m17n.rb @@ -226,24 +226,35 @@ def test_string_inspect_encoding end end - def test_utf_16_32_inspect - str = "\u3042" - %w/UTF-16 UTF-32/.each do |enc| - %w/BE LE/.each do |endian| - s = str.encode(enc + endian) + STR_WITHOUT_BOM = "\u3042".freeze + STR_WITH_BOM = "\uFEFF\u3042".freeze + bug8940 = '[ruby-core:59757] [Bug #8940]' + bug9415 = '[ruby-dev:47895] [Bug #9415]' + %w/UTF-16 UTF-32/.each do |enc| + %w/BE LE/.each do |endian| + bom = "\uFEFF".encode("#{enc}#{endian}").force_encoding(enc) + + define_method("test_utf_16_32_inspect(#{enc}#{endian})") do + s = STR_WITHOUT_BOM.encode(enc + endian) # When a UTF-16/32 string doesn't have a BOM, # inspect as a dummy encoding string. assert_equal(s.dup.force_encoding("ISO-2022-JP").inspect, s.dup.force_encoding(enc).inspect) + assert_normal_exit("#{bom.b.dump}.force_encoding('#{enc}').inspect", bug8940) end - end - str = "\uFEFF\u3042" - %w/UTF-16 UTF-32/.each do |enc| - %w/BE LE/.each do |endian| - s = str.encode(enc + endian) - # When a UTF-16/32 string doesn't have a BOM, - # inspect as a dummy encoding string. + define_method("test_utf_16_32_codepoints(#{enc}#{endian})") do + assert_equal([0xFEFF], bom.codepoints, bug9415) + end + + define_method("test_utf_16_32_ord(#{enc}#{endian})") do + assert_equal(0xFEFF, bom.ord, bug9415) + end + + define_method("test_utf_16_32_inspect(#{enc}#{endian}-BOM)") do + s = STR_WITH_BOM.encode(enc + endian) + # When a UTF-16/32 string has a BOM, + # inspect as a particular encoding string. assert_equal(s.inspect, s.dup.force_encoding(enc).inspect) end diff --git a/version.h b/version.h index dc6ac3919e5477..c91aedde32fcc3 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-21" -#define RUBY_PATCHLEVEL 40 +#define RUBY_PATCHLEVEL 41 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 14a34023570a25f926fb1820ad60d0b614fd76e3 Mon Sep 17 00:00:00 2001 From: naruse Date: Fri, 21 Feb 2014 09:08:45 +0000 Subject: [PATCH 040/343] merge revision(s) 44312,44318: [Backport #9273] * lib/resolv.rb (Resolv::Hosts#lazy_initialize): should not consider encodings in hosts file. [ruby-core:59239] [Bug #9273] * lib/resolv.rb (Resolv::Config.parse_resolv_conf): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45075 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ lib/resolv.rb | 4 ++-- test/resolv/test_addr.rb | 12 ++++++++++++ test/resolv/test_dns.rb | 11 +++++++++++ version.h | 2 +- 5 files changed, 33 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 45f26694185572..26614f3183be92 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Fri Feb 21 17:42:42 2014 Nobuyoshi Nakada + + * lib/resolv.rb (Resolv::Hosts#lazy_initialize): should not + consider encodings in hosts file. [ruby-core:59239] [Bug #9273] + + * lib/resolv.rb (Resolv::Config.parse_resolv_conf): ditto. + Fri Feb 21 16:47:20 2014 Nobuyoshi Nakada * string.c (get_encoding): respect BOM on pseudo encodings. diff --git a/lib/resolv.rb b/lib/resolv.rb index 6d34a67e099666..0c2b68ec27c687 100644 --- a/lib/resolv.rb +++ b/lib/resolv.rb @@ -187,7 +187,7 @@ def lazy_initialize # :nodoc: unless @initialized @name2addr = {} @addr2name = {} - open(@filename) {|f| + open(@filename, 'rb') {|f| f.each {|line| line.sub!(/#.*/, '') addr, hostname, *aliases = line.split(/\s+/) @@ -920,7 +920,7 @@ def Config.parse_resolv_conf(filename) nameserver = [] search = nil ndots = 1 - open(filename) {|f| + open(filename, 'rb') {|f| f.each {|line| line.sub!(/[#;].*/, '') keyword, *args = line.split(/\s+/) diff --git a/test/resolv/test_addr.rb b/test/resolv/test_addr.rb index 84bc8c2d3b2def..d4728e1b716ba2 100644 --- a/test/resolv/test_addr.rb +++ b/test/resolv/test_addr.rb @@ -13,4 +13,16 @@ def test_invalid_ipv4_address end } end + + def test_invalid_byte_comment + bug9273 = '[ruby-core:59239] [Bug #9273]' + Tempfile.open('resolv_test_addr_') do |tmpfile| + tmpfile.print("\xff\x00\x40") + tmpfile.close + hosts = Resolv::Hosts.new(tmpfile.path) + assert_nothing_raised(ArgumentError, bug9273) do + hosts.each_address("") {break} + end + end + end end diff --git a/test/resolv/test_dns.rb b/test/resolv/test_dns.rb index 0d9565ef68ac36..07396fb177de8e 100644 --- a/test/resolv/test_dns.rb +++ b/test/resolv/test_dns.rb @@ -1,6 +1,7 @@ require 'test/unit' require 'resolv' require 'socket' +require 'tempfile' class TestResolvDNS < Test::Unit::TestCase def setup @@ -150,4 +151,14 @@ def test_no_server } end + def test_invalid_byte_comment + bug9273 = '[ruby-core:59239] [Bug #9273]' + Tempfile.open('resolv_test_dns_') do |tmpfile| + tmpfile.print("\xff\x00\x40") + tmpfile.close + assert_nothing_raised(ArgumentError, bug9273) do + Resolv::DNS::Config.parse_resolv_conf(tmpfile.path) + end + end + end end diff --git a/version.h b/version.h index c91aedde32fcc3..c0347b835e2308 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-21" -#define RUBY_PATCHLEVEL 41 +#define RUBY_PATCHLEVEL 42 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From cb6602490b055fba2a1a340ffa1e276c0b9cff95 Mon Sep 17 00:00:00 2001 From: naruse Date: Fri, 21 Feb 2014 13:48:53 +0000 Subject: [PATCH 041/343] merge revision(s) 44790: [Backport #9472] * io.c (rb_io_syswrite): add RB_GC_GUARD [Bug #9472][ruby-core:60407] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45078 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ io.c | 1 + version.h | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 26614f3183be92..a786d6f7e9d481 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sun Feb 2 05:48:42 2014 Eric Wong + + * io.c (rb_io_syswrite): add RB_GC_GUARD + [Bug #9472][ruby-core:60407] + Fri Feb 21 17:42:42 2014 Nobuyoshi Nakada * lib/resolv.rb (Resolv::Hosts#lazy_initialize): should not diff --git a/io.c b/io.c index 5aa720b6a7b651..6e3fd85d2b1238 100644 --- a/io.c +++ b/io.c @@ -4572,6 +4572,7 @@ rb_io_syswrite(VALUE io, VALUE str) } n = rb_write_internal(fptr->fd, RSTRING_PTR(str), RSTRING_LEN(str)); + RB_GC_GUARD(str); if (n == -1) rb_sys_fail_path(fptr->pathv); diff --git a/version.h b/version.h index c0347b835e2308..def8d8b0bc0860 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-21" -#define RUBY_PATCHLEVEL 42 +#define RUBY_PATCHLEVEL 43 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 1d5d057531189c43ed603a7d9105bdfca71e3319 Mon Sep 17 00:00:00 2001 From: naruse Date: Fri, 21 Feb 2014 14:06:17 +0000 Subject: [PATCH 042/343] merge revision(s) 44531: [Backport #9300] * ext/psych/lib/psych/visitors/yaml_tree.rb: dumping strings with quotes should not have changed. [ruby-core:59316] [Bug #9300] * ext/psych/lib/psych.rb: fixed missing require. * test/psych/test_string.rb: test git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45079 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 9 +++++++++ ext/psych/lib/psych.rb | 1 + ext/psych/lib/psych/visitors/yaml_tree.rb | 2 +- test/psych/test_string.rb | 4 ++++ version.h | 2 +- 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index a786d6f7e9d481..b66e879bfcd2fd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Fri Feb 21 23:00:34 2014 Aaron Patterson + + * ext/psych/lib/psych/visitors/yaml_tree.rb: dumping strings with + quotes should not have changed. [ruby-core:59316] [Bug #9300] + + * ext/psych/lib/psych.rb: fixed missing require. + + * test/psych/test_string.rb: test + Sun Feb 2 05:48:42 2014 Eric Wong * io.c (rb_io_syswrite): add RB_GC_GUARD diff --git a/ext/psych/lib/psych.rb b/ext/psych/lib/psych.rb index 2a87f43efe0b1d..45e01c5fd19666 100644 --- a/ext/psych/lib/psych.rb +++ b/ext/psych/lib/psych.rb @@ -14,6 +14,7 @@ require 'psych/json/tree_builder' require 'psych/json/stream' require 'psych/handlers/document_stream' +require 'psych/class_loader' ### # = Overview diff --git a/ext/psych/lib/psych/visitors/yaml_tree.rb b/ext/psych/lib/psych/visitors/yaml_tree.rb index 1cb21376934e6c..f89fcbb8f12c3e 100644 --- a/ext/psych/lib/psych/visitors/yaml_tree.rb +++ b/ext/psych/lib/psych/visitors/yaml_tree.rb @@ -284,7 +284,7 @@ def visit_String o quote = false elsif o =~ /\n/ style = Nodes::Scalar::LITERAL - elsif o =~ /^\W/ + elsif o =~ /^\W[^"]*$/ style = Nodes::Scalar::DOUBLE_QUOTED else unless String === @ss.tokenize(o) diff --git a/test/psych/test_string.rb b/test/psych/test_string.rb index 84326da8d31fb4..01fc0e4bb0b722 100644 --- a/test/psych/test_string.rb +++ b/test/psych/test_string.rb @@ -15,6 +15,10 @@ def initialize end end + def test_no_doublequotes_with_special_characters + assert_equal 2, Psych.dump(%Q{<%= ENV["PATH"] %>}).count('"') + end + def test_doublequotes_when_there_is_a_single yaml = Psych.dump "@123'abc" assert_match(/---\s*"/, yaml) diff --git a/version.h b/version.h index def8d8b0bc0860..a63532d2e804b0 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-21" -#define RUBY_PATCHLEVEL 43 +#define RUBY_PATCHLEVEL 44 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 7463add18fb4fa618bda79659b0da87a430fc0b2 Mon Sep 17 00:00:00 2001 From: naruse Date: Fri, 21 Feb 2014 14:08:26 +0000 Subject: [PATCH 043/343] merge revision(s) 44472: [Backport #9333] * win32/Makefile.sub: remove HAVE_FSEEKO because fseeko removed from win32/win32.c Fixed [Bug #9333]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45080 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ version.h | 2 +- win32/Makefile.sub | 1 - 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index b66e879bfcd2fd..a36360f51a5b1a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Fri Feb 21 23:07:56 2014 Akio Tajima + + * win32/Makefile.sub: remove HAVE_FSEEKO because fseeko removed from win32/win32.c + Fixed [Bug #9333]. + Fri Feb 21 23:00:34 2014 Aaron Patterson * ext/psych/lib/psych/visitors/yaml_tree.rb: dumping strings with diff --git a/version.h b/version.h index a63532d2e804b0..9d7241d82c6326 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-21" -#define RUBY_PATCHLEVEL 44 +#define RUBY_PATCHLEVEL 45 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 diff --git a/win32/Makefile.sub b/win32/Makefile.sub index a04e8024beab68..d6289bc53d381f 100644 --- a/win32/Makefile.sub +++ b/win32/Makefile.sub @@ -677,7 +677,6 @@ $(CONFIG_H): $(MKFILES) $(srcdir)/win32/Makefile.sub $(win_srcdir)/Makefile.sub #define HAVE_GETCWD 1 #define HAVE_TRUNCATE 1 #define HAVE_FTRUNCATE 1 -#define HAVE_FSEEKO 1 #define HAVE_TIMES 1 #define HAVE_FCNTL 1 #define HAVE_LINK 1 From 562f916fbdeb163c57992a9131409d938a5061fe Mon Sep 17 00:00:00 2001 From: naruse Date: Fri, 21 Feb 2014 14:14:26 +0000 Subject: [PATCH 044/343] merge revision(s) 44469: [Backport #9329] * lib/mkmf.rb (RbConfig): expand RUBY_SO_NAME for extensions backward compatibility. [ruby-core:59426] [Bug #9329] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45082 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ lib/mkmf.rb | 2 ++ version.h | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index a36360f51a5b1a..816f468b9fba92 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Fri Feb 21 23:10:12 2014 Nobuyoshi Nakada + + * lib/mkmf.rb (RbConfig): expand RUBY_SO_NAME for extensions + backward compatibility. [ruby-core:59426] [Bug #9329] + Fri Feb 21 23:07:56 2014 Akio Tajima * win32/Makefile.sub: remove HAVE_FSEEKO because fseeko removed from win32/win32.c diff --git a/lib/mkmf.rb b/lib/mkmf.rb index c4e2e5a90041f2..2d44b123d2f293 100644 --- a/lib/mkmf.rb +++ b/lib/mkmf.rb @@ -2508,6 +2508,8 @@ def MAIN_DOES_NOTHING(*refs) $configure_args["--topdir"] ||= $curdir $ruby = arg_config("--ruby", File.join(RbConfig::CONFIG["bindir"], CONFIG["ruby_install_name"])) + RbConfig.expand(CONFIG["RUBY_SO_NAME"]) + # :startdoc: split = Shellwords.method(:shellwords).to_proc diff --git a/version.h b/version.h index 9d7241d82c6326..f02c5385976b74 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-21" -#define RUBY_PATCHLEVEL 45 +#define RUBY_PATCHLEVEL 46 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From b376132317cd2ad99647f41fc6ab03df6b7f8a84 Mon Sep 17 00:00:00 2001 From: naruse Date: Fri, 21 Feb 2014 14:53:48 +0000 Subject: [PATCH 045/343] merge revision(s) 44462,44477: [Backport #9314] * encoding.c (must_encindex, rb_enc_from_index, rb_obj_encoding): mask encoding index and ignore dummy flags. [ruby-core:59354] [Bug #9314] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45083 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ encoding.c | 6 +++--- test/ruby/test_transcode.rb | 11 +++++++++++ version.h | 2 +- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 816f468b9fba92..306c20331831bc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Fri Feb 21 23:51:38 2014 Nobuyoshi Nakada + + * encoding.c (must_encindex, rb_enc_from_index, rb_obj_encoding): mask + encoding index and ignore dummy flags. [ruby-core:59354] [Bug #9314] + Fri Feb 21 23:10:12 2014 Nobuyoshi Nakada * lib/mkmf.rb (RbConfig): expand RUBY_SO_NAME for extensions diff --git a/encoding.c b/encoding.c index 9bfda11f380ee6..f102524379fc22 100644 --- a/encoding.c +++ b/encoding.c @@ -156,7 +156,7 @@ must_encindex(int index) rb_raise(rb_eEncodingError, "encoding index out of bound: %d", index); } - if (ENC_TO_ENCINDEX(enc) != index) { + if (ENC_TO_ENCINDEX(enc) != (int)(index & ENC_INDEX_MASK)) { rb_raise(rb_eEncodingError, "wrong encoding index %d for %s (expected %d)", index, rb_enc_name(enc), ENC_TO_ENCINDEX(enc)); } @@ -592,7 +592,7 @@ rb_enc_from_index(int index) if (!enc_table.list) { rb_enc_init(); } - if (index < 0 || enc_table.count <= index) { + if (index < 0 || enc_table.count <= (index &= ENC_INDEX_MASK)) { return 0; } return enc_table.list[index].enc; @@ -933,7 +933,7 @@ rb_obj_encoding(VALUE obj) if (idx < 0) { rb_raise(rb_eTypeError, "unknown encoding"); } - return rb_enc_from_encoding_index(idx); + return rb_enc_from_encoding_index(idx & ENC_INDEX_MASK); } int diff --git a/test/ruby/test_transcode.rb b/test/ruby/test_transcode.rb index 25c9d24663ce8f..5f3f51a67675ba 100644 --- a/test/ruby/test_transcode.rb +++ b/test/ruby/test_transcode.rb @@ -2080,4 +2080,15 @@ def test_encode_with_invalid_chars assert_equal "\ufffd", str.encode(invalid: :replace), bug8995 end end + + def test_valid_dummy_encoding + bug9314 = '[ruby-core:59354] [Bug #9314]' + assert_separately(%W[- -- #{bug9314}], <<-'end;') + bug = ARGV.shift + result = assert_nothing_raised(TypeError, bug) {break "test".encode(Encoding::UTF_16)} + assert_equal("\xFE\xFF\x00t\x00e\x00s\x00t", result.b, bug) + result = assert_nothing_raised(TypeError, bug) {break "test".encode(Encoding::UTF_32)} + assert_equal("\x00\x00\xFE\xFF\x00\x00\x00t\x00\x00\x00e\x00\x00\x00s\x00\x00\x00t", result.b, bug) + end; + end end diff --git a/version.h b/version.h index f02c5385976b74..b80e09e97564d6 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-21" -#define RUBY_PATCHLEVEL 46 +#define RUBY_PATCHLEVEL 47 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From adfa331bbc65dd82938f0f416b123afb85638520 Mon Sep 17 00:00:00 2001 From: naruse Date: Fri, 21 Feb 2014 15:12:52 +0000 Subject: [PATCH 046/343] merge revision(s) 44616,44622,44623,44626,44632,44636: add timeout to test_do_reply http://fb64b.rubyci.org/~chkbuild/ruby-trunk/log/20140115T073301Z.log.html.gz git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45085 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/rinda/test_rinda.rb | 54 +++++++++++++++++++++++++++++++++++++--- version.h | 6 ++--- 2 files changed, 54 insertions(+), 6 deletions(-) diff --git a/test/rinda/test_rinda.rb b/test/rinda/test_rinda.rb index 448c4fe02fc4c6..f5472d28acfa68 100644 --- a/test/rinda/test_rinda.rb +++ b/test/rinda/test_rinda.rb @@ -4,7 +4,7 @@ require 'drb/eq' require 'rinda/ring' require 'rinda/tuplespace' - +require 'timeout' require 'singleton' module Rinda @@ -559,6 +559,10 @@ def teardown end def test_do_reply + with_timeout(10) {_test_do_reply} + end + + def _test_do_reply called = nil callback = proc { |ts| @@ -571,12 +575,16 @@ def test_do_reply @rs.do_reply - Thread.pass until called + wait_for(10) {called} assert_same @ts, called end def test_do_reply_local + with_timeout(10) {_test_do_reply_local} + end + + def _test_do_reply_local called = nil callback = proc { |ts| @@ -587,7 +595,7 @@ def test_do_reply_local @rs.do_reply - Thread.pass until called + wait_for(10) {called} assert_same @ts, called end @@ -674,6 +682,46 @@ def test_shutdown assert_nil(@rs.do_reply, 'otherwise should hang forever') end + private + + def with_timeout(n) + aoe = Thread.abort_on_exception + Thread.abort_on_exception = true + tl0 = Thread.list + tl = nil + th = Thread.new(Thread.current) do |mth| + sleep n + (tl = Thread.list - tl0).each {|t|t.raise(Timeout::Error)} + mth.raise(Timeout::Error) + end + tl0 << th + rescue Timeout::Error => e + if tl + bt = e.backtrace + tl.each do |t| + begin + t.value + rescue Timeout::Error => e + bt.unshift("") + bt[0, 0] = e.backtrace + end + end + end + raise Timeout::Error, "timeout", bt + ensure + th.kill if th + Thread.abort_on_exception = aoe + end + + def wait_for(n) + t = n + Process.clock_gettime(Process::CLOCK_MONOTONIC, :second) + until yield + if t < Process.clock_gettime(Process::CLOCK_MONOTONIC, :second) + flunk "timeout during waiting call" + end + sleep 0.1 + end + end end class TestRingFinger < Test::Unit::TestCase diff --git a/version.h b/version.h index b80e09e97564d6..aabfd2232bc2ce 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.1" -#define RUBY_RELEASE_DATE "2014-02-21" -#define RUBY_PATCHLEVEL 47 +#define RUBY_RELEASE_DATE "2014-02-22" +#define RUBY_PATCHLEVEL 48 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 -#define RUBY_RELEASE_DAY 21 +#define RUBY_RELEASE_DAY 22 #include "ruby/version.h" From 02cc3d942a7fee753217ffa9382cd8f2ded1a440 Mon Sep 17 00:00:00 2001 From: naruse Date: Fri, 21 Feb 2014 15:42:08 +0000 Subject: [PATCH 047/343] merge revision(s) 44449: [Backport #9416] * parse.y (local_push_gen, local_pop_gen): save cmdarg_stack to isolate command argument state from outer scope. [ruby-core:59342] [Bug #9308] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45086 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ parse.y | 4 ++++ test/ruby/test_syntax.rb | 5 +++++ version.h | 2 +- 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 306c20331831bc..a7883c7a3ee14c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sat Feb 22 00:21:50 2014 Nobuyoshi Nakada + + * parse.y (local_push_gen, local_pop_gen): save cmdarg_stack to + isolate command argument state from outer scope. + [ruby-core:59342] [Bug #9308] + Fri Feb 21 23:51:38 2014 Nobuyoshi Nakada * encoding.c (must_encindex, rb_enc_from_index, rb_obj_encoding): mask diff --git a/parse.y b/parse.y index d04cf456126d25..eb5ed547d335a4 100644 --- a/parse.y +++ b/parse.y @@ -130,6 +130,7 @@ struct local_vars { struct vtable *vars; struct vtable *used; struct local_vars *prev; + stack_type cmdargs; }; #define DVARS_INHERIT ((void*)1) @@ -9642,6 +9643,8 @@ local_push_gen(struct parser_params *parser, int inherit_dvars) local->used = !(inherit_dvars && (ifndef_ripper(compile_for_eval || e_option_supplied(parser))+0)) && RTEST(ruby_verbose) ? vtable_alloc(0) : 0; + local->cmdargs = cmdarg_stack; + cmdarg_stack = 0; lvtbl = local; } @@ -9655,6 +9658,7 @@ local_pop_gen(struct parser_params *parser) } vtable_free(lvtbl->args); vtable_free(lvtbl->vars); + cmdarg_stack = lvtbl->cmdargs; xfree(lvtbl); lvtbl = local; } diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index 04fcd20a56c28b..cac755a3903c48 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -256,6 +256,11 @@ def test_do_block_in_cmdarg_begin assert_valid_syntax("p begin 1.times do 1 end end", __FILE__, bug6419) end + def test_do_block_in_call_args + bug9308 = '[ruby-core:59342] [Bug #9308]' + assert_valid_syntax("bar def foo; self.each do end end", bug9308) + end + def test_reserved_method_no_args bug6403 = '[ruby-dev:45626]' assert_valid_syntax("def self; :foo; end", __FILE__, bug6403) diff --git a/version.h b/version.h index aabfd2232bc2ce..260d1a85b6bcaf 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-22" -#define RUBY_PATCHLEVEL 48 +#define RUBY_PATCHLEVEL 49 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 1976e3ffd9f898f52d39e514f733979ceb4c45f1 Mon Sep 17 00:00:00 2001 From: naruse Date: Fri, 21 Feb 2014 23:32:34 +0000 Subject: [PATCH 048/343] merge revision(s) 44925: [Backport #9492] * configure.in: check if pthread_setname_np is available. * thread_pthread.c: pthread_setname_np is not available on old Darwins. [ruby-core:60524] [Bug #9492] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45090 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ configure.in | 2 +- thread_pthread.c | 2 +- version.h | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index a7883c7a3ee14c..f856ed660109aa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Sat Feb 22 01:35:02 2014 Nobuyoshi Nakada + + * configure.in: check if pthread_setname_np is available. + + * thread_pthread.c: pthread_setname_np is not available on old + Darwins. [ruby-core:60524] [Bug #9492] + Sat Feb 22 00:21:50 2014 Nobuyoshi Nakada * parse.y (local_push_gen, local_pop_gen): save cmdarg_stack to diff --git a/configure.in b/configure.in index a920fd5675a71b..17ed3edea3d2e8 100644 --- a/configure.in +++ b/configure.in @@ -2448,7 +2448,7 @@ if test x"$enable_pthread" = xyes; then pthread_get_stackaddr_np pthread_get_stacksize_np \ thr_stksegment pthread_stackseg_np pthread_getthrds_np \ pthread_cond_init pthread_condattr_setclock pthread_condattr_init \ - pthread_sigmask) + pthread_sigmask pthread_setname_np) if test "${host_os}" = "nacl"; then ac_cv_func_pthread_attr_init=no else diff --git a/thread_pthread.c b/thread_pthread.c index 57daa3b45d06a9..3e58ac5745aeba 100644 --- a/thread_pthread.c +++ b/thread_pthread.c @@ -1423,7 +1423,7 @@ timer_thread_sleep(rb_global_vm_lock_t* unused) #if defined(__linux__) && defined(PR_SET_NAME) # define SET_THREAD_NAME(name) prctl(PR_SET_NAME, name) -#elif defined(__APPLE__) +#elif defined(HAVE_PTHREAD_SETNAME_NP) /* pthread_setname_np() on Darwin does not have target thread argument */ # define SET_THREAD_NAME(name) pthread_setname_np(name) #else diff --git a/version.h b/version.h index 260d1a85b6bcaf..e352ebc6bfa737 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-22" -#define RUBY_PATCHLEVEL 49 +#define RUBY_PATCHLEVEL 50 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From a98f024d5c977ff3de28ed67062c73c4ec57d841 Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 22 Feb 2014 04:21:39 +0000 Subject: [PATCH 049/343] merge revision(s) 44595: [Backport #9342] * ext/thread/thread.c (rb_szqueue_clear): notify SZQUEUE_WAITERS on SizedQueue#clear. [ruby-core:59462] [Bug #9342] * test/thread/test_queue.rb: add test. the patch is from Justin Collins. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45104 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ ext/thread/thread.c | 15 +++++++++++++++ test/thread/test_queue.rb | 22 ++++++++++++++++++++++ version.h | 2 +- 4 files changed, 46 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index f856ed660109aa..9323ed5ae5a684 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Sat Feb 22 13:17:32 2014 Masaki Matsushita + + * ext/thread/thread.c (rb_szqueue_clear): notify SZQUEUE_WAITERS + on SizedQueue#clear. [ruby-core:59462] [Bug #9342] + + * test/thread/test_queue.rb: add test. the patch is from + Justin Collins. + Sat Feb 22 01:35:02 2014 Nobuyoshi Nakada * configure.in: check if pthread_setname_np is available. diff --git a/ext/thread/thread.c b/ext/thread/thread.c index a8f675c55ba309..c409b36da2c0ba 100644 --- a/ext/thread/thread.c +++ b/ext/thread/thread.c @@ -502,6 +502,20 @@ rb_szqueue_pop(int argc, VALUE *argv, VALUE self) return szqueue_do_pop(self, should_block); } +/* + * Document-method: Queue#clear + * + * Removes all objects from the queue. + */ + +static VALUE +rb_szqueue_clear(VALUE self) +{ + rb_ary_clear(GET_QUEUE_QUE(self)); + wakeup_all_threads(GET_SZQUEUE_WAITERS(self)); + return self; +} + /* * Document-method: SizedQueue#num_waiting * @@ -586,6 +600,7 @@ Init_thread(void) rb_define_method(rb_cSizedQueue, "max=", rb_szqueue_max_set, 1); rb_define_method(rb_cSizedQueue, "push", rb_szqueue_push, 1); rb_define_method(rb_cSizedQueue, "pop", rb_szqueue_pop, -1); + rb_define_method(rb_cSizedQueue, "clear", rb_szqueue_clear, 0); rb_define_method(rb_cSizedQueue, "num_waiting", rb_szqueue_num_waiting, 0); /* Alias for #push. */ diff --git a/test/thread/test_queue.rb b/test/thread/test_queue.rb index 2126500bd81d70..c99475d8dc872d 100644 --- a/test/thread/test_queue.rb +++ b/test/thread/test_queue.rb @@ -129,6 +129,28 @@ def test_queue_clear_return_value assert_same q, retval end + def test_sized_queue_clear + # Fill queue, then test that SizedQueue#clear wakes up all waiting threads + sq = SizedQueue.new(2) + 2.times { sq << 1 } + + t1 = Thread.new do + sq << 1 + end + + t2 = Thread.new do + sq << 1 + end + + t3 = Thread.new do + Thread.pass + sq.clear + end + + [t3, t2, t1].each(&:join) + assert_equal sq.length, 2 + end + def test_sized_queue_push_return_value q = SizedQueue.new(1) retval = q.push(1) diff --git a/version.h b/version.h index e352ebc6bfa737..2bb33993f50434 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-22" -#define RUBY_PATCHLEVEL 50 +#define RUBY_PATCHLEVEL 51 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From d382c46a723cb191369707fd18b4bfa5f6709d1b Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 22 Feb 2014 04:35:18 +0000 Subject: [PATCH 050/343] merge revision(s) 44568: [Backport #9399] * iseq.c (iseq_load): keep type_map to get rid of memory leak. based on a patch by Eric Wong at [ruby-core:59699]. [Bug #9399] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45105 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ iseq.c | 8 ++++++++ ruby_atomic.h | 5 +++++ version.h | 2 +- 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 9323ed5ae5a684..5ccf2fc5bdb7ba 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sat Feb 22 13:26:57 2014 Nobuyoshi Nakada + + * iseq.c (iseq_load): keep type_map to get rid of memory leak. + based on a patch by Eric Wong at [ruby-core:59699]. [Bug #9399] + Sat Feb 22 13:17:32 2014 Masaki Matsushita * ext/thread/thread.c (rb_szqueue_clear): notify SZQUEUE_WAITERS diff --git a/iseq.c b/iseq.c index 679bdb7a2de1da..22081a1ee29516 100644 --- a/iseq.c +++ b/iseq.c @@ -483,6 +483,7 @@ iseq_load(VALUE self, VALUE data, VALUE parent, VALUE opt) VALUE type, body, locals, args, exception; st_data_t iseq_type; + static struct st_table *type_map_cache = 0; struct st_table *type_map = 0; rb_iseq_t *iseq; rb_compile_option_t option; @@ -523,7 +524,9 @@ iseq_load(VALUE self, VALUE data, VALUE parent, VALUE opt) iseq->self = iseqval; iseq->local_iseq = iseq; + type_map = type_map_cache; if (type_map == 0) { + struct st_table *cached_map; type_map = st_init_numtable(); st_insert(type_map, ID2SYM(rb_intern("top")), ISEQ_TYPE_TOP); st_insert(type_map, ID2SYM(rb_intern("method")), ISEQ_TYPE_METHOD); @@ -534,6 +537,11 @@ iseq_load(VALUE self, VALUE data, VALUE parent, VALUE opt) st_insert(type_map, ID2SYM(rb_intern("eval")), ISEQ_TYPE_EVAL); st_insert(type_map, ID2SYM(rb_intern("main")), ISEQ_TYPE_MAIN); st_insert(type_map, ID2SYM(rb_intern("defined_guard")), ISEQ_TYPE_DEFINED_GUARD); + cached_map = ATOMIC_PTR_CAS(type_map_cache, (struct st_table *)0, type_map); + if (cached_map) { + st_free_table(type_map); + type_map = cached_map; + } } if (st_lookup(type_map, type, &iseq_type) == 0) { diff --git a/ruby_atomic.h b/ruby_atomic.h index 69efbdc4c4c651..789efdc4eaae2a 100644 --- a/ruby_atomic.h +++ b/ruby_atomic.h @@ -161,5 +161,10 @@ atomic_size_exchange(size_t *ptr, size_t val) # define ATOMIC_PTR_EXCHANGE(var, val) (void *)ATOMIC_SIZE_EXCHANGE(*(size_t *)&(var), (size_t)(val)) # endif #endif +#ifndef ATOMIC_PTR_CAS +# if SIZEOF_VOIDP == SIZEOF_SIZE_T +# define ATOMIC_PTR_CAS(var, oldval, val) (void *)ATOMIC_SIZE_CAS(*(size_t *)&(var), (size_t)(oldval), (size_t)(val)) +# endif +#endif #endif /* RUBY_ATOMIC_H */ diff --git a/version.h b/version.h index 2bb33993f50434..d1b63ae75b591f 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-22" -#define RUBY_PATCHLEVEL 51 +#define RUBY_PATCHLEVEL 52 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 669e9ac5ff2593b175bd6b0b30d482d3e2fbced3 Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 22 Feb 2014 05:05:22 +0000 Subject: [PATCH 051/343] merge revision(s) 44931: [Backport #9452] * vm_insnhelper.c (vm_call_method): should check ci->me->flag of a refining method in case the method is private. [ruby-core:60111] [Bug #9452] * vm_method.c (make_method_entry_refined): set me->flag of a refined method entry to NOEX_PUBLIC in case the original method is private and it is refined as a public method. The original flag is stored in me->def->body.orig_me, so it's OK to make a refined method entry public. [ruby-core:60111] [Bug #9452] * test/ruby/test_refinement.rb: related tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45107 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 14 +++++++++++ test/ruby/test_refinement.rb | 45 ++++++++++++++++++++++++++++++++++++ version.h | 2 +- vm_insnhelper.c | 7 ++---- vm_method.c | 1 + 5 files changed, 63 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5ccf2fc5bdb7ba..08d12fbc7bd0db 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +Sat Feb 22 13:49:30 2014 Shugo Maeda + + * vm_insnhelper.c (vm_call_method): should check ci->me->flag of + a refining method in case the method is private. + [ruby-core:60111] [Bug #9452] + + * vm_method.c (make_method_entry_refined): set me->flag of a refined + method entry to NOEX_PUBLIC in case the original method is private + and it is refined as a public method. The original flag is stored + in me->def->body.orig_me, so it's OK to make a refined method + entry public. [ruby-core:60111] [Bug #9452] + + * test/ruby/test_refinement.rb: related tests. + Sat Feb 22 13:26:57 2014 Nobuyoshi Nakada * iseq.c (iseq_load): keep type_map to get rid of memory leak. diff --git a/test/ruby/test_refinement.rb b/test/ruby/test_refinement.rb index 07a325c1b847e5..d535c474241d5d 100644 --- a/test/ruby/test_refinement.rb +++ b/test/ruby/test_refinement.rb @@ -1107,6 +1107,51 @@ def foo INPUT end + def test_adding_private_method + bug9452 = '[ruby-core:60111] [Bug #9452]' + + assert_in_out_err([], <<-INPUT, ["Success!", "NoMethodError"], [], bug9452) + module R + refine Object do + def m + puts "Success!" + end + + private(:m) + end + end + + using R + + m + 42.m rescue p($!.class) + INPUT + end + + def test_making_private_method_public + bug9452 = '[ruby-core:60111] [Bug #9452]' + + assert_in_out_err([], <<-INPUT, ["Success!", "Success!"], [], bug9452) + class Object + private + def m + end + end + + module R + refine Object do + def m + puts "Success!" + end + end + end + + using R + m + 42.m + INPUT + end + private def eval_using(mod, s) diff --git a/version.h b/version.h index d1b63ae75b591f..0bfd038f5d161b 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-22" -#define RUBY_PATCHLEVEL 52 +#define RUBY_PATCHLEVEL 53 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 diff --git a/vm_insnhelper.c b/vm_insnhelper.c index edf4e46652dc37..1228b3f4df6976 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -1829,7 +1829,7 @@ vm_call_method(rb_thread_t *th, rb_control_frame_t *cfp, rb_call_info_t *ci) ci->me = me; ci->defined_class = defined_class; if (me->def->type != VM_METHOD_TYPE_REFINED) { - goto normal_method_dispatch; + goto start_method_dispatch; } } @@ -1838,11 +1838,8 @@ vm_call_method(rb_thread_t *th, rb_control_frame_t *cfp, rb_call_info_t *ci) ci->me = ci->me->def->body.orig_me; if (UNDEFINED_METHOD_ENTRY_P(ci->me)) { ci->me = 0; - goto start_method_dispatch; - } - else { - goto normal_method_dispatch; } + goto start_method_dispatch; } else { klass = ci->me->klass; diff --git a/vm_method.c b/vm_method.c index fce8add6ef078d..ecded4aa2fcc68 100644 --- a/vm_method.c +++ b/vm_method.c @@ -212,6 +212,7 @@ make_method_entry_refined(rb_method_entry_t *me) *new_def->body.orig_me = *me; rb_vm_check_redefinition_opt_method(me, me->klass); if (me->def) me->def->alias_count++; + me->flag = NOEX_WITH_SAFE(NOEX_PUBLIC); me->def = new_def; } From 95985829574c638cf169e611ff76749602353a50 Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 22 Feb 2014 05:14:42 +0000 Subject: [PATCH 052/343] merge revision(s) 44884: [Backport #9498] * lib/resolv.rb (Resolv::DNS::Message::MessageDecoder): Raise DecodeError if no data before the limit. Reported by Will Bryant. [ruby-core:60557] [Bug #9498] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45109 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ lib/resolv.rb | 3 +++ version.h | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 08d12fbc7bd0db..96988353be026b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sat Feb 22 14:07:04 2014 Tanaka Akira + + * lib/resolv.rb (Resolv::DNS::Message::MessageDecoder): Raise + DecodeError if no data before the limit. + Reported by Will Bryant. [ruby-core:60557] [Bug #9498] + Sat Feb 22 13:49:30 2014 Shugo Maeda * vm_insnhelper.c (vm_call_method): should check ci->me->flag of diff --git a/lib/resolv.rb b/lib/resolv.rb index 0c2b68ec27c687..ed12764a1b56e0 100644 --- a/lib/resolv.rb +++ b/lib/resolv.rb @@ -1520,6 +1520,7 @@ def get_length16 end def get_bytes(len = @limit - @index) + raise DecodeError.new("limit exceeded") if @limit < @index + len d = @data[@index, len] @index += len return d @@ -1547,6 +1548,7 @@ def get_unpack(template) end def get_string + raise DecodeError.new("limit exceeded") if @limit <= @index len = @data[@index].ord raise DecodeError.new("limit exceeded") if @limit < @index + 1 + len d = @data[@index + 1, len] @@ -1570,6 +1572,7 @@ def get_labels(limit=nil) limit = @index if !limit || @index < limit d = [] while true + raise DecodeError.new("limit exceeded") if @limit <= @index case @data[@index].ord when 0 @index += 1 diff --git a/version.h b/version.h index 0bfd038f5d161b..2b6e8e1b919150 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-22" -#define RUBY_PATCHLEVEL 53 +#define RUBY_PATCHLEVEL 54 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 96cfe6614ae723855bec1acbc197480e2168f419 Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 22 Feb 2014 05:20:38 +0000 Subject: [PATCH 053/343] merge revision(s) 44880: [Backport #9477] * lib/resolv.rb: Ignore name servers which cause EAFNOSUPPORT on socket creation. Reported by Bjoern Rennhak. [ruby-core:60442] [Bug #9477] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45110 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ lib/resolv.rb | 16 ++++++++++++---- version.h | 2 +- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 96988353be026b..be680377bc36a3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sat Feb 22 14:18:35 2014 Tanaka Akira + + * lib/resolv.rb: Ignore name servers which cause EAFNOSUPPORT on + socket creation. + Reported by Bjoern Rennhak. [ruby-core:60442] [Bug #9477] + Sat Feb 22 14:07:04 2014 Tanaka Akira * lib/resolv.rb (Resolv::DNS::Message::MessageDecoder): Raise diff --git a/lib/resolv.rb b/lib/resolv.rb index ed12764a1b56e0..ee21c9c8434c16 100644 --- a/lib/resolv.rb +++ b/lib/resolv.rb @@ -522,8 +522,9 @@ def fetch_resource(name, typeclass) msg.rd = 1 msg.add_question(candidate, typeclass) unless sender = senders[[candidate, nameserver, port]] - sender = senders[[candidate, nameserver, port]] = - requester.sender(msg, candidate, nameserver, port) + sender = requester.sender(msg, candidate, nameserver, port) + next if !sender + senders[[candidate, nameserver, port]] = sender end reply, reply_name = requester.request(sender, tout) case reply.rcode @@ -741,7 +742,11 @@ def initialize(*nameserver_port) af = Socket::AF_INET end next if @socks_hash[bind_host] - sock = UDPSocket.new(af) + begin + sock = UDPSocket.new(af) + rescue Errno::EAFNOSUPPORT + next # The kernel doesn't support the address family. + end sock.do_not_reverse_lookup = true sock.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) if defined? Fcntl::F_SETFD DNS.bind_random_port(sock, bind_host) @@ -756,11 +761,12 @@ def recv_reply(readable_socks) end def sender(msg, data, host, port=Port) + sock = @socks_hash[host.index(':') ? "::" : "0.0.0.0"] + return nil if !sock service = [host, port] id = DNS.allocate_request_id(host, port) request = msg.encode request[0,2] = [id].pack('n') - sock = @socks_hash[host.index(':') ? "::" : "0.0.0.0"] return @senders[[service, id]] = Sender.new(request, data, sock, host, port) end @@ -781,6 +787,7 @@ def initialize(msg, data, sock, host, port) attr_reader :data def send + raise "@sock is nil." if @sock.nil? @sock.send(@msg, 0, @host, @port) end end @@ -824,6 +831,7 @@ def close class Sender < Requester::Sender # :nodoc: def send + raise "@sock is nil." if @sock.nil? @sock.send(@msg, 0) end attr_reader :data diff --git a/version.h b/version.h index 2b6e8e1b919150..c82cf8823e2d97 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-22" -#define RUBY_PATCHLEVEL 54 +#define RUBY_PATCHLEVEL 55 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From f5731cb9688c692ec99a71c5dd0f6c6e05376e0f Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 22 Feb 2014 05:39:58 +0000 Subject: [PATCH 054/343] merge revision(s) 44585: [Backport #9268] * lib/net/smtp.rb: [DOC] Remove dead link to RAA by Giorgos Tsiftsis Fixes the following bugs: [Bug #9152] [Bug #9268] [Bug #9394] * lib/open-uri.rb: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45111 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ lib/net/smtp.rb | 5 +++-- lib/open-uri.rb | 2 +- version.h | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index be680377bc36a3..d34a096e4d58bc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sat Feb 22 14:31:23 2014 Zachary Scott + + * lib/net/smtp.rb: [DOC] Remove dead link to RAA by Giorgos Tsiftsis + Fixes the following bugs: [Bug #9152] [Bug #9268] [Bug #9394] + * lib/open-uri.rb: ditto + Sat Feb 22 14:18:35 2014 Tanaka Akira * lib/resolv.rb: Ignore name servers which cause EAFNOSUPPORT on diff --git a/lib/net/smtp.rb b/lib/net/smtp.rb index f49e38b283fa01..5fd4f8e5c5a5b2 100644 --- a/lib/net/smtp.rb +++ b/lib/net/smtp.rb @@ -76,8 +76,9 @@ class SMTPUnsupportedCommand < ProtocolError # # This library does NOT provide functions to compose internet mails. # You must create them by yourself. If you want better mail support, - # try RubyMail or TMail. You can get both libraries from RAA. - # (http://www.ruby-lang.org/en/raa.html) + # try RubyMail or TMail or search for alternatives in + # {RubyGems.org}[https://rubygems.org/] or {The Ruby + # Toolbox}[https://www.ruby-toolbox.com/]. # # FYI: the official documentation on internet mail is: [RFC2822] (http://www.ietf.org/rfc/rfc2822.txt). # diff --git a/lib/open-uri.rb b/lib/open-uri.rb index b1a253841d65a9..86aa0f1887b939 100644 --- a/lib/open-uri.rb +++ b/lib/open-uri.rb @@ -73,7 +73,7 @@ def open(name, *rest, &block) # :doc: # The environment variables such as http_proxy, https_proxy and ftp_proxy # are in effect by default. Here we disable proxy: # -# open("http://www.ruby-lang.org/en/raa.html", :proxy => nil) {|f| +# open("http://www.ruby-lang.org/en/", :proxy => nil) {|f| # # ... # } # diff --git a/version.h b/version.h index c82cf8823e2d97..28cfdff7933651 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-22" -#define RUBY_PATCHLEVEL 55 +#define RUBY_PATCHLEVEL 56 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 361c2fe9bb598e11cf806a8d453652af40366062 Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 22 Feb 2014 05:46:06 +0000 Subject: [PATCH 055/343] merge revision(s) 44586: [Backport #9152] * lib/xmlrpc/client.rb: [DOC] Remove note about SSL package on RAA Since RAA has been deprecated, and the SSL package has been replaced with net/https this statement is entirely false and should be deleted. [Bug #9152] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45112 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ lib/xmlrpc/client.rb | 2 -- version.h | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index d34a096e4d58bc..21c38b1e706a03 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Sat Feb 22 14:45:36 2014 Zachary Scott + + * lib/xmlrpc/client.rb: [DOC] Remove note about SSL package on RAA + Since RAA has been deprecated, and the SSL package has been replaced + with net/https this statement is entirely false and should be + deleted. [Bug #9152] + Sat Feb 22 14:31:23 2014 Zachary Scott * lib/net/smtp.rb: [DOC] Remove dead link to RAA by Giorgos Tsiftsis diff --git a/lib/xmlrpc/client.rb b/lib/xmlrpc/client.rb index a0d2a13557c20e..5ee3961f3018d7 100644 --- a/lib/xmlrpc/client.rb +++ b/lib/xmlrpc/client.rb @@ -77,8 +77,6 @@ class Client # # If +use_ssl+ is set to +true+, communication over SSL is enabled. # - # Note, that you need the SSL package from RAA installed. - # # Parameter +timeout+ is the time to wait for a XML-RPC response, defaults to 30. def initialize(host=nil, path=nil, port=nil, proxy_host=nil, proxy_port=nil, user=nil, password=nil, use_ssl=nil, timeout=nil) diff --git a/version.h b/version.h index 28cfdff7933651..a21924efeb1ff8 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-22" -#define RUBY_PATCHLEVEL 56 +#define RUBY_PATCHLEVEL 57 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 48ccb14404de2f79547be93b3192d1a31971a303 Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 22 Feb 2014 05:56:02 +0000 Subject: [PATCH 056/343] merge revision(s) 44584,44587,44945: [Backport #9243] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ext/openssl/ossl_pkey_dh.c: Fixed typo by Sandor Szテシcs [Bug #9243] * ext/openssl/ossl_pkey_dh.c: Fixed typo by Sandor Sz?cs [Bug #9243] * ext/openssl/ossl_pkey_dh.c: Fixed typo by Sandor Szuecs [Bug #9243] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45113 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ ext/openssl/ossl_pkey_dh.c | 3 +-- version.h | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 21c38b1e706a03..260f0a144f51f4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Sat Feb 22 14:52:55 2014 Zachary Scott + + * ext/openssl/ossl_pkey_dh.c: Fixed typo by Sandor Szuecs [Bug #9243] + Sat Feb 22 14:45:36 2014 Zachary Scott * lib/xmlrpc/client.rb: [DOC] Remove note about SSL package on RAA diff --git a/ext/openssl/ossl_pkey_dh.c b/ext/openssl/ossl_pkey_dh.c index a6ae0063f5b338..011b6f00b4b7b3 100644 --- a/ext/openssl/ossl_pkey_dh.c +++ b/ext/openssl/ossl_pkey_dh.c @@ -621,7 +621,7 @@ Init_ossl_dh() * * === Example of a key exchange * dh1 = OpenSSL::PKey::DH.new(2048) - * params = dh1.public_key.to_der #you may send this publicly to the participating party + * der = dh1.public_key.to_der #you may send this publicly to the participating party * dh2 = OpenSSL::PKey::DH.new(der) * dh2.generate_key! #generate the per-session key pair * symm_key1 = dh1.compute_key(dh2.pub_key) @@ -664,4 +664,3 @@ Init_ossl_dh() { } #endif /* NO_DH */ - diff --git a/version.h b/version.h index a21924efeb1ff8..09566e32997e97 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-22" -#define RUBY_PATCHLEVEL 57 +#define RUBY_PATCHLEVEL 58 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From d3452b572705e11b0be6e715b00597f14ebe4bdb Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 22 Feb 2014 06:01:44 +0000 Subject: [PATCH 057/343] merge revision(s) 44642: [Backport #9093] * lib/resolv.rb (Resolv::DNS::Resource::TXT#data): Return concatenated string. Patch by Ryan Brunner. [ruby-core:58220] [Bug #9093] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45114 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ lib/resolv.rb | 4 ++-- version.h | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 260f0a144f51f4..aea157baa6b63c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sat Feb 22 15:01:21 2014 Tanaka Akira + + * lib/resolv.rb (Resolv::DNS::Resource::TXT#data): Return concatenated + string. + Patch by Ryan Brunner. [ruby-core:58220] [Bug #9093] + Sat Feb 22 14:52:55 2014 Zachary Scott * ext/openssl/ossl_pkey_dh.c: Fixed typo by Sandor Szuecs [Bug #9243] diff --git a/lib/resolv.rb b/lib/resolv.rb index ee21c9c8434c16..6b2fa9d90333e2 100644 --- a/lib/resolv.rb +++ b/lib/resolv.rb @@ -1974,10 +1974,10 @@ def initialize(first_string, *rest_strings) attr_reader :strings ## - # Returns the first string from +strings+. + # Returns the concatenated string from +strings+. def data - @strings[0] + @strings.join("") end def encode_rdata(msg) # :nodoc: diff --git a/version.h b/version.h index 09566e32997e97..57bd213e7ea8df 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-22" -#define RUBY_PATCHLEVEL 58 +#define RUBY_PATCHLEVEL 59 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From b2a6346ccb9b6e32ea97ad8f8a2c494f09e46336 Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 22 Feb 2014 06:04:51 +0000 Subject: [PATCH 058/343] merge revision(s) 44463: [Backport #9210] * variable.c: adding extra example in docs. patched by Steve Klabnik. [Bug #9210] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45115 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ variable.c | 5 +++-- version.h | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index aea157baa6b63c..6ef6b3e9dfcfa0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sat Feb 22 15:03:05 2014 Ayumu AIZAWA + + * variable.c: adding extra example in docs. + patched by Steve Klabnik. [Bug #9210] + Sat Feb 22 15:01:21 2014 Tanaka Akira * lib/resolv.rb (Resolv::DNS::Resource::TXT#data): Return concatenated diff --git a/variable.c b/variable.c index 350bb582db343b..424730dcb9dced 100644 --- a/variable.c +++ b/variable.c @@ -2517,8 +2517,9 @@ cvar_list(void *data) * class Two < One * @@var2 = 2 * end - * One.class_variables #=> [:@@var1] - * Two.class_variables #=> [:@@var2, :@@var1] + * One.class_variables #=> [:@@var1] + * Two.class_variables #=> [:@@var2, :@@var1] + * Two.class_variables(false) #=> [:@@var2] */ VALUE diff --git a/version.h b/version.h index 57bd213e7ea8df..2edc89841cb2f3 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-22" -#define RUBY_PATCHLEVEL 59 +#define RUBY_PATCHLEVEL 60 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From b1073f89179e68b3da6ce45ca35c0af967cf2967 Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 22 Feb 2014 06:06:55 +0000 Subject: [PATCH 059/343] merge revision(s) 44878,44879: [Backport #9483] * ext/ripper/lib/ripper/lexer.rb: [DOC] use lower case version of core classes when referring to return value, since we aren't directly talking about the class. Patch by Jonathan Jackson [Bug #9483] * lib/open-uri.rb: [DOC] use lower case version of core classes, same as commit r44878, based on patch by Jonathan Jackson [Bug #9483] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45116 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 11 +++++++++++ ext/ripper/lib/ripper/lexer.rb | 4 ++-- lib/open-uri.rb | 5 +++-- version.h | 2 +- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6ef6b3e9dfcfa0..703a9d0069f05d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +Sat Feb 22 15:06:32 2014 Zachary Scott + + * lib/open-uri.rb: [DOC] use lower case version of core classes, same + as commit r44878, based on patch by Jonathan Jackson [Bug #9483] + +Sat Feb 22 15:06:32 2014 Zachary Scott + + * ext/ripper/lib/ripper/lexer.rb: [DOC] use lower case version of core + classes when referring to return value, since we aren't directly + talking about the class. Patch by Jonathan Jackson [Bug #9483] + Sat Feb 22 15:03:05 2014 Ayumu AIZAWA * variable.c: adding extra example in docs. diff --git a/ext/ripper/lib/ripper/lexer.rb b/ext/ripper/lib/ripper/lexer.rb index 5c99dfe8fa2961..c0a64d1ee592ac 100644 --- a/ext/ripper/lib/ripper/lexer.rb +++ b/ext/ripper/lib/ripper/lexer.rb @@ -12,7 +12,7 @@ class Ripper - # Tokenizes the Ruby program and returns an Array of String. + # Tokenizes the Ruby program and returns an array of strings. # # p Ripper.tokenize("def m(a) nil end") # # => ["def", " ", "m", "(", "a", ")", " ", "nil", " ", "end"] @@ -21,7 +21,7 @@ def Ripper.tokenize(src, filename = '-', lineno = 1) Lexer.new(src, filename, lineno).tokenize end - # Tokenizes the Ruby program and returns an Array of an Array, + # Tokenizes the Ruby program and returns an array of an array, # which is formatted like [[lineno, column], type, token]. # # require 'ripper' diff --git a/lib/open-uri.rb b/lib/open-uri.rb index 86aa0f1887b939..26eb1a364e12c1 100644 --- a/lib/open-uri.rb +++ b/lib/open-uri.rb @@ -534,8 +534,9 @@ def charset end end - # returns a list of encodings in Content-Encoding field - # as an Array of String. + # Returns a list of encodings in Content-Encoding field as an array of + # strings. + # # The encodings are downcased for canonicalization. def content_encoding vs = @metas['content-encoding'] diff --git a/version.h b/version.h index 2edc89841cb2f3..88cb8dc92bd4d7 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-22" -#define RUBY_PATCHLEVEL 60 +#define RUBY_PATCHLEVEL 61 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From a9a6a643f86c3908e136b95be072df29c889c7a9 Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 22 Feb 2014 06:11:15 +0000 Subject: [PATCH 060/343] merge revision(s) 44696: [Backport #9429] * lib/racc/rdoc/grammar.en.rdoc: [DOC] Correct grammar and typos Patch by Giorgos Tsiftsis [Bug #9429] [ci skip] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++ lib/racc/rdoc/grammar.en.rdoc | 81 ++++++++++++++++------------------- version.h | 2 +- 3 files changed, 43 insertions(+), 45 deletions(-) diff --git a/ChangeLog b/ChangeLog index 703a9d0069f05d..cf8ac26fdadee2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sat Feb 22 15:07:58 2014 Zachary Scott + + * lib/racc/rdoc/grammar.en.rdoc: [DOC] Correct grammar and typos + Patch by Giorgos Tsiftsis [Bug #9429] [ci skip] + Sat Feb 22 15:06:32 2014 Zachary Scott * lib/open-uri.rb: [DOC] use lower case version of core classes, same diff --git a/lib/racc/rdoc/grammar.en.rdoc b/lib/racc/rdoc/grammar.en.rdoc index b667a7cb5ece7d..a154246ee58592 100644 --- a/lib/racc/rdoc/grammar.en.rdoc +++ b/lib/racc/rdoc/grammar.en.rdoc @@ -4,14 +4,12 @@ == Class Block and User Code Block -There's two block on toplevel. -one is 'class' block, another is 'user code' block. 'user code' block MUST -places after 'class' block. +There are two blocks on toplevel. One is 'class' block, another is 'user code' +block. 'user code' block MUST be placed after 'class' block. -== Comment +== Comments -You can insert comment about all places. Two style comment can be used, -Ruby style (#.....) and C style (/*......*/) . +You can insert comments about all places. Two style comments can be used, Ruby style '#.....' and C style '/\*......*\/'. == Class Block @@ -19,19 +17,19 @@ The class block is formed like this: class CLASS_NAME [precedance table] - [token declearations] - [expected number of S/R conflict] + [token declarations] + [expected number of S/R conflicts] [options] [semantic value convertion] [start rule] rule GRAMMARS -CLASS_NAME is a name of parser class. -This is the name of generating parser class. +CLASS_NAME is a name of parser class. This is the name of generating parser +class. -If CLASS_NAME includes '::', Racc outputs module clause. -For example, writing "class M::C" causes creating the code bellow: +If CLASS_NAME includes '::', Racc outputs module clause. For example, writing +"class M::C" causes creating the code bellow: module M class C @@ -42,8 +40,8 @@ For example, writing "class M::C" causes creating the code bellow: == Grammar Block -The grammar block discripts grammar which is able -to be understood by parser. Syntax is: +The grammar block describes grammar which is able to be understood by parser. +Syntax is: (token): (token) (token) (token).... (action) @@ -59,28 +57,27 @@ to be understood by parser. Syntax is: Note that you cannot use '%' string, here document, '%r' regexp in action. -Actions can be omitted. -When it is omitted, '' (empty string) is used. +Actions can be omitted. When it is omitted, '' (empty string) is used. -A return value of action is a value of left side value ($$). -It is value of result, or returned value by "return" statement. +A return value of action is a value of left side value ($$). It is value of +result, or returned value by `return` statement. Here is an example of whole grammar block. rule - goal: definition ruls source { result = val } + goal: definition rules source { result = val } definition: /* none */ { result = [] } | definition startdesig { result[0] = val[1] } | definition - precrule # this line continue from upper line + precrule # this line continues from upper line { result[1] = val[1] } startdesig: START TOKEN -You can use following special local variables in action. +You can use the following special local variables in action: * result ($$) @@ -92,8 +89,7 @@ An array of value of right-hand side (rhs). * _values (...$-2,$-1,$0) -A stack of values. -DO NOT MODIFY this stack unless you know what you are doing. +A stack of values. DO NOT MODIFY this stack unless you know what you are doing. == Operator Precedence @@ -107,9 +103,9 @@ To designate this block: right '=' preclow -`right' is yacc's %right, `left' is yacc's %left. +`right` is yacc's %right, `left` is yacc's %left. -`=' + (symbol) means yacc's %prec: +`=` + (symbol) means yacc's %prec: prechigh nonassoc UMINUS @@ -136,22 +132,22 @@ Racc has bison's "expect" directive. : : -This directive declears "expected" number of shift/reduce conflict. -If "expected" number is equal to real number of conflicts, -racc does not print confliction warning message. +This directive declares "expected" number of shift/reduce conflicts. If +"expected" number is equal to real number of conflicts, Racc does not print +conflict warning message. == Declaring Tokens -By declaring tokens, you can avoid many meanless bugs. -If decleared token does not exist/existing token does not decleared, -Racc output warnings. Declearation syntax is: +By declaring tokens, you can avoid many meaningless bugs. If declared token +does not exist or existing token does not decleared, Racc output warnings. +Declaration syntax is: token TOKEN_NAME AND_IS_THIS ALSO_THIS_IS AGAIN_AND_AGAIN THIS_IS_LAST == Options -You can write options for racc command in your racc file. +You can write options for Racc command in your Racc file. options OPTION OPTION ... @@ -159,19 +155,19 @@ Options are: * omit_action_call -omit empty action call or not. +omits empty action call or not. * result_var -use/does not use local variable "result" +uses local variable "result" or not. -You can use 'no_' prefix to invert its meanings. +You can use 'no_' prefix to invert their meanings. == Converting Token Symbol Token symbols are, as default, - * naked token string in racc file (TOK, XFILE, this_is_token, ...) + * naked token string in Racc file (TOK, XFILE, this_is_token, ...) --> symbol (:TOK, :XFILE, :this_is_token, ...) * quoted string (':', '.', '(', ...) --> same string (':', '.', '(', ...) @@ -185,7 +181,7 @@ Here is an example: end We can use almost all ruby value can be used by token symbol, -except 'false' and 'nil'. These are causes unexpected parse error. +except 'false' and 'nil'. These cause unexpected parse error. If you want to use String as token symbol, special care is required. For example: @@ -202,12 +198,10 @@ For example: start real_target -This statement will not be used forever, I think. - == User Code Block -"User Code Block" is a Ruby source code which is copied to output. -There are three user code block, "header" "inner" and "footer". +"User Code Block" is a Ruby source code which is copied to output. There are +three user code blocks, "header" "inner" and "footer". Format of user code is like this: @@ -221,6 +215,5 @@ Format of user code is like this: : : -If four '-' exist on line head, -racc treat it as beginning of user code block. -A name of user code must be one word. +If four '-' exist on line head, Racc treat it as beginning of user code block. +The name of user code block must be one word. diff --git a/version.h b/version.h index 88cb8dc92bd4d7..e6f197f5b0cec3 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-22" -#define RUBY_PATCHLEVEL 61 +#define RUBY_PATCHLEVEL 62 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From f1161c93846a9be3b0f5995aa05bf950a6a448fc Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 22 Feb 2014 06:16:18 +0000 Subject: [PATCH 061/343] merge revision(s) 44549: [Backport #9387] * range.c (Range#size): [DOC] improve description and add examples. Patch by @skade. [Fixes GH-501] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45118 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ range.c | 5 ++++- version.h | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index cf8ac26fdadee2..46dd38ba571333 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sat Feb 22 15:13:38 2014 Benoit Daloze + + * range.c (Range#size): [DOC] improve description and add examples. + Patch by @skade. [Fixes GH-501] + Sat Feb 22 15:07:58 2014 Zachary Scott * lib/racc/rdoc/grammar.en.rdoc: [DOC] Correct grammar and typos diff --git a/range.c b/range.c index 4526dcba895172..d2d9a707c07fed 100644 --- a/range.c +++ b/range.c @@ -711,9 +711,12 @@ sym_each_i(RB_BLOCK_CALL_FUNC_ARGLIST(v, arg)) * call-seq: * rng.size -> num * - * Returns the number of elements in the range. + * Returns the number of elements in the range. Both the begin and the end of + * the Range must be Numeric, otherwise nil is returned. * * (10..20).size #=> 11 + * ('a'..'z').size #=> nil + * (-Float::INFINITY..Float::INFINITY).size #=> Infinity */ static VALUE diff --git a/version.h b/version.h index e6f197f5b0cec3..5af029549aa023 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-22" -#define RUBY_PATCHLEVEL 62 +#define RUBY_PATCHLEVEL 63 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 64e6dd621aef0cfffefae834a82b0ecb81a363df Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 22 Feb 2014 07:17:22 +0000 Subject: [PATCH 062/343] merge revision(s) 44670,44671,44673,44675: [Backport #8783] thread_pthread.c: timer thread stack size * thread_pthread.c (rb_thread_create_timer_thread): define the stack size for timer thread at compile time. * thread_pthread.c (rb_thread_create_timer_thread): expand timer thread stack size to get rid of segfault on FreeBSD/powerpc64. based on the patch by Steve Wills at [ruby-core:59923]. [ruby-core:56590] [Bug #8783] * thread_pthread.c (rb_thread_create_timer_thread): fix for platforms where PTHREAD_STACK_MIN is a dynamic value and not a compile-time constant. [ruby-dev:47911] [Bug #9436] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45119 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 13 +++++++++++++ thread_pthread.c | 17 ++++++++--------- version.h | 2 +- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 46dd38ba571333..cfda696fb2d01c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +Sat Feb 22 15:56:53 2014 Nobuyoshi Nakada + + * thread_pthread.c (rb_thread_create_timer_thread): fix for platforms + where PTHREAD_STACK_MIN is a dynamic value and not a compile-time + constant. [ruby-dev:47911] [Bug #9436] + +Sat Feb 22 15:56:53 2014 Nobuyoshi Nakada + + * thread_pthread.c (rb_thread_create_timer_thread): expand timer + thread stack size to get rid of segfault on FreeBSD/powerpc64. + based on the patch by Steve Wills at [ruby-core:59923]. + [ruby-core:56590] [Bug #8783] + Sat Feb 22 15:13:38 2014 Benoit Daloze * range.c (Range#size): [DOC] improve description and add examples. diff --git a/thread_pthread.c b/thread_pthread.c index 3e58ac5745aeba..aa8962a315fc5f 100644 --- a/thread_pthread.c +++ b/thread_pthread.c @@ -1479,17 +1479,16 @@ rb_thread_create_timer_thread(void) exit(EXIT_FAILURE); } # ifdef PTHREAD_STACK_MIN - if (PTHREAD_STACK_MIN < 4096 * 3) { + { + const size_t min_size = (4096 * 4); /* Allocate the machine stack for the timer thread - * at least 12KB (3 pages). FreeBSD 8.2 AMD64 causes - * machine stack overflow only with PTHREAD_STACK_MIN. + * at least 16KB (4 pages). FreeBSD 8.2 AMD64 causes + * machine stack overflow only with PTHREAD_STACK_MIN. */ - pthread_attr_setstacksize(&attr, - 4096 * 3 + (THREAD_DEBUG ? BUFSIZ : 0)); - } - else { - pthread_attr_setstacksize(&attr, - PTHREAD_STACK_MIN + (THREAD_DEBUG ? BUFSIZ : 0)); + size_t stack_size = PTHREAD_STACK_MIN; /* may be dynamic, get only once */ + if (stack_size < min_size) stack_size = min_size; + if (THREAD_DEBUG) stack_size += BUFSIZ; + pthread_attr_setstacksize(&attr, stack_size); } # endif #endif diff --git a/version.h b/version.h index 5af029549aa023..6a9765c01c56af 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-22" -#define RUBY_PATCHLEVEL 63 +#define RUBY_PATCHLEVEL 64 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From d439b3b1d9fd12c217d04f94b09027cf6014281b Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 22 Feb 2014 07:19:41 +0000 Subject: [PATCH 063/343] merge revision(s) 45066: [Backport #9545] [Backport #9550] * ext/socket/ancdata.c (bsock_sendmsg_internal): only retry on error (bsock_recvmsg_internal): ditto * test/socket/test_unix.rb: test above for infinite loop git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45120 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ ext/socket/ancdata.c | 18 ++++++++---------- test/socket/test_unix.rb | 23 +++++++++++++++++++++++ version.h | 2 +- 4 files changed, 38 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index cfda696fb2d01c..4d1a6ac9ba57c8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sat Feb 22 16:17:54 2014 Eric Wong + + * ext/socket/ancdata.c (bsock_sendmsg_internal): only retry on error + (bsock_recvmsg_internal): ditto + * test/socket/test_unix.rb: test above for infinite loop + Sat Feb 22 15:56:53 2014 Nobuyoshi Nakada * thread_pthread.c (rb_thread_create_timer_thread): fix for platforms diff --git a/ext/socket/ancdata.c b/ext/socket/ancdata.c index 9a68a0c2893b3e..bbbf985e2834e1 100644 --- a/ext/socket/ancdata.c +++ b/ext/socket/ancdata.c @@ -1280,12 +1280,11 @@ bsock_sendmsg_internal(int argc, VALUE *argv, VALUE sock, int nonblock) ss = rb_sendmsg(fptr->fd, &mh, flags); - if (!nonblock && rb_io_wait_writable(fptr->fd)) { - rb_io_check_closed(fptr); - goto retry; - } - if (ss == -1) { + if (!nonblock && rb_io_wait_writable(fptr->fd)) { + rb_io_check_closed(fptr); + goto retry; + } if (nonblock && (errno == EWOULDBLOCK || errno == EAGAIN)) rb_readwrite_sys_fail(RB_IO_WAIT_WRITABLE, "sendmsg(2) would block"); rb_sys_fail("sendmsg(2)"); @@ -1595,12 +1594,11 @@ bsock_recvmsg_internal(int argc, VALUE *argv, VALUE sock, int nonblock) ss = rb_recvmsg(fptr->fd, &mh, flags); - if (!nonblock && rb_io_wait_readable(fptr->fd)) { - rb_io_check_closed(fptr); - goto retry; - } - if (ss == -1) { + if (!nonblock && rb_io_wait_readable(fptr->fd)) { + rb_io_check_closed(fptr); + goto retry; + } if (nonblock && (errno == EWOULDBLOCK || errno == EAGAIN)) rb_readwrite_sys_fail(RB_IO_WAIT_READABLE, "recvmsg(2) would block"); #if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL) diff --git a/test/socket/test_unix.rb b/test/socket/test_unix.rb index 38d8333f2a0669..f10c5efaf84018 100644 --- a/test/socket/test_unix.rb +++ b/test/socket/test_unix.rb @@ -5,6 +5,7 @@ require "test/unit" require "tempfile" +require "timeout" require "tmpdir" require "thread" require "io/nonblock" @@ -369,6 +370,28 @@ def test_dgram_pair s2.close if s2 end + def test_dgram_pair_sendrecvmsg_errno_set + s1, s2 = to_close = UNIXSocket.pair(Socket::SOCK_DGRAM) + pipe = IO.pipe + to_close.concat(pipe) + set_errno = lambda do + begin + pipe[0].read_nonblock(1) + fail + rescue => e + assert(IO::EAGAINWaitReadable === e) + end + end + Timeout.timeout(10) do + set_errno.call + assert_equal(2, s1.sendmsg("HI")) + set_errno.call + assert_equal("HI", s2.recvmsg[0]) + end + ensure + to_close.each(&:close) if to_close + end + def test_epipe # [ruby-dev:34619] s1, s2 = UNIXSocket.pair s1.shutdown(Socket::SHUT_WR) diff --git a/version.h b/version.h index 6a9765c01c56af..b0527e9a72e022 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-22" -#define RUBY_PATCHLEVEL 64 +#define RUBY_PATCHLEVEL 65 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From cea7808b10bf32b7e21323dd450b1ac6e7a66c90 Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 22 Feb 2014 07:22:12 +0000 Subject: [PATCH 064/343] merge revision(s) 44772: [Backport #9430] benchmark/driver: avoid large alloc in driver process * benchmark/driver: avoid large alloc in driver process [ruby-core:59869] [Bug #9430] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45121 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- benchmark/driver.rb | 2 +- version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/benchmark/driver.rb b/benchmark/driver.rb index 695dc41afff0c9..cbc72cf604f26c 100644 --- a/benchmark/driver.rb +++ b/benchmark/driver.rb @@ -242,7 +242,7 @@ def measure executable, file cmd = "#{executable} #{@ruby_arg} #{file}" m = Benchmark.measure{ - `#{cmd}` + system(cmd, out: File::NULL) } if $? != 0 diff --git a/version.h b/version.h index b0527e9a72e022..54fd73d42b6335 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-22" -#define RUBY_PATCHLEVEL 65 +#define RUBY_PATCHLEVEL 66 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 23d00a8c1bb61fec5d57e557f550b9f4c557884d Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 22 Feb 2014 07:50:05 +0000 Subject: [PATCH 065/343] merge revision(s) 44731,44751: [Backport #8978] * ext/fiddle/closure.c: use sizeof(*pcl) for correct sizeof value. [ruby-core:57599] [Bug #8978]. Thanks mame! * ext/fiddle/closure.c: use sizeof(*pcl) for correct sizeof value. [ruby-core:57599] [Bug #8978]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45122 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 10 ++++++++++ ext/fiddle/closure.c | 4 ++-- version.h | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4d1a6ac9ba57c8..e813fd6bd4c2f4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +Sat Feb 22 16:34:12 2014 Yusuke Endoh + + * ext/fiddle/closure.c: use sizeof(*pcl) for correct sizeof value. + [ruby-core:57599] [Bug #8978]. + +Sat Feb 22 16:34:12 2014 Aaron Patterson + + * ext/fiddle/closure.c: use sizeof(*pcl) for correct sizeof value. + [ruby-core:57599] [Bug #8978]. Thanks mame! + Sat Feb 22 16:17:54 2014 Eric Wong * ext/socket/ancdata.c (bsock_sendmsg_internal): only retry on error diff --git a/ext/fiddle/closure.c b/ext/fiddle/closure.c index 121a08ea19f7da..e0f7e4b12d3475 100644 --- a/ext/fiddle/closure.c +++ b/ext/fiddle/closure.c @@ -27,7 +27,7 @@ dealloc(void * ptr) #if USE_FFI_CLOSURE_ALLOC ffi_closure_free(cls->pcl); #else - munmap(cls->pcl, sizeof(cls->pcl)); + munmap(cls->pcl, sizeof(*cls->pcl)); #endif if (cls->argv) xfree(cls->argv); xfree(cls); @@ -234,7 +234,7 @@ initialize(int rbargc, VALUE argv[], VALUE self) #else result = ffi_prep_closure(pcl, cif, callback, (void *)self); cl->code = (void *)pcl; - i = mprotect(pcl, sizeof(pcl), PROT_READ | PROT_EXEC); + i = mprotect(pcl, sizeof(*pcl), PROT_READ | PROT_EXEC); if (i) { rb_sys_fail("mprotect"); } diff --git a/version.h b/version.h index 54fd73d42b6335..bbc2601900fced 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-22" -#define RUBY_PATCHLEVEL 66 +#define RUBY_PATCHLEVEL 67 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 7329f4043621e69574187fb185939d5638838a7b Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 22 Feb 2014 07:53:33 +0000 Subject: [PATCH 066/343] merge revision(s) 44514: [Backport #9374] * ext/json/generator/depend: add build dependencies for json extension [Bug #9374] [ruby-core:59609] * ext/json/parser/depend: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45123 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ ext/json/generator/depend | 1 + ext/json/parser/depend | 1 + version.h | 2 +- 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index e813fd6bd4c2f4..f0c9ca031324c1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sat Feb 22 16:51:36 2014 Eric Wong + + * ext/json/generator/depend: add build dependencies for json extension + [Bug #9374] [ruby-core:59609] + * ext/json/parser/depend: ditto + Sat Feb 22 16:34:12 2014 Yusuke Endoh * ext/fiddle/closure.c: use sizeof(*pcl) for correct sizeof value. diff --git a/ext/json/generator/depend b/ext/json/generator/depend index 1a042a2501eb2d..593a8fbb543db0 100644 --- a/ext/json/generator/depend +++ b/ext/json/generator/depend @@ -1 +1,2 @@ +$(OBJS): $(ruby_headers) generator.o: generator.c generator.h $(srcdir)/../fbuffer/fbuffer.h diff --git a/ext/json/parser/depend b/ext/json/parser/depend index 498ffa964cdc82..d188844670f0d4 100644 --- a/ext/json/parser/depend +++ b/ext/json/parser/depend @@ -1 +1,2 @@ +$(OBJS): $(ruby_headers) parser.o: parser.c parser.h $(srcdir)/../fbuffer/fbuffer.h diff --git a/version.h b/version.h index bbc2601900fced..bfcb361b41be70 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-22" -#define RUBY_PATCHLEVEL 67 +#define RUBY_PATCHLEVEL 68 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 330dccb9b444ec93660bf9e03fb7fa1b1c8619b8 Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 22 Feb 2014 08:38:43 +0000 Subject: [PATCH 067/343] merge revision(s) 44628: [Backport #9413] * eval.c (rb_mod_s_constants): return its own constants for other than Module itself. [ruby-core:59763] [Bug #9413] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45124 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ eval.c | 4 ++-- test/ruby/test_module.rb | 13 +++++++++++++ version.h | 2 +- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index f0c9ca031324c1..8abc8943b86102 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sat Feb 22 17:33:39 2014 Nobuyoshi Nakada + + * eval.c (rb_mod_s_constants): return its own constants for other + than Module itself. [ruby-core:59763] [Bug #9413] + Sat Feb 22 16:51:36 2014 Eric Wong * ext/json/generator/depend: add build dependencies for json extension diff --git a/eval.c b/eval.c index 3a0206f24ab8c2..841b3671e3b794 100644 --- a/eval.c +++ b/eval.c @@ -380,8 +380,8 @@ rb_mod_s_constants(int argc, VALUE *argv, VALUE mod) VALUE cbase = 0; void *data = 0; - if (argc > 0) { - return rb_mod_constants(argc, argv, rb_cModule); + if (argc > 0 || mod != rb_cModule) { + return rb_mod_constants(argc, argv, mod); } while (cref) { diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb index 4f834f0c1e3fb1..ba6f273159063b 100644 --- a/test/ruby/test_module.rb +++ b/test/ruby/test_module.rb @@ -866,6 +866,19 @@ def test_mod_constants m.instance_eval { remove_const(:Foo) } end + class Bug9413 + class << self + Foo = :foo + end + end + + def test_singleton_constants + bug9413 = '[ruby-core:59763] [Bug #9413]' + c = Bug9413.singleton_class + assert_include(c.constants(true), :Foo, bug9413) + assert_include(c.constants(false), :Foo, bug9413) + end + def test_frozen_class m = Module.new m.freeze diff --git a/version.h b/version.h index bfcb361b41be70..6de4c639a78dd6 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-22" -#define RUBY_PATCHLEVEL 68 +#define RUBY_PATCHLEVEL 69 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 76ddadeb1ad5ba049efdd6463bf6169426127985 Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 22 Feb 2014 08:54:43 +0000 Subject: [PATCH 068/343] merge revision(s) 44637: [Backport #9385] * lib/open-uri.rb: Make proxy disabling working again. Fixed by Christophe Philemotte. [ruby-core:59650] [Bug #9385] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45125 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ lib/open-uri.rb | 2 +- version.h | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8abc8943b86102..3faeda326bb8b6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sat Feb 22 17:46:32 2014 Tanaka Akira + + * lib/open-uri.rb: Make proxy disabling working again. + Fixed by Christophe Philemotte. [ruby-core:59650] [Bug #9385] + Sat Feb 22 17:33:39 2014 Nobuyoshi Nakada * eval.c (rb_mod_s_constants): return its own constants for other diff --git a/lib/open-uri.rb b/lib/open-uri.rb index 26eb1a364e12c1..264c8501cf284e 100644 --- a/lib/open-uri.rb +++ b/lib/open-uri.rb @@ -288,7 +288,7 @@ def OpenURI.open_http(buf, target, proxy, options) # :nodoc: end end - http = klass.new(target_host, target_port) + http = proxy ? klass.new(target_host, target_port) : klass.new(target_host, target_port, nil) if target.class == URI::HTTPS require 'net/https' http.use_ssl = true diff --git a/version.h b/version.h index 6de4c639a78dd6..d3149d7c03f2c5 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-22" -#define RUBY_PATCHLEVEL 69 +#define RUBY_PATCHLEVEL 70 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From d2164fc5f2c8d32aaa9a857ca680c8f6d05ed106 Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 22 Feb 2014 09:24:49 +0000 Subject: [PATCH 069/343] merge revision(s) 45057,45059: [Backport #9533] * hash.c (rb_hash_flatten): fix behavior of flatten(-1). [ruby-dev:47988] [Bug #9533] * test/ruby/test_array.rb: test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ hash.c | 25 ++++++++++++++++++------- test/ruby/test_hash.rb | 4 ++-- version.h | 2 +- 4 files changed, 28 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3faeda326bb8b6..e0be9a55326c6b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Sat Feb 22 18:20:58 2014 Masaki Matsushita + + * hash.c (rb_hash_flatten): fix behavior of flatten(-1). + [ruby-dev:47988] [Bug #9533] + + * test/ruby/test_array.rb: test for above. + Sat Feb 22 17:46:32 2014 Tanaka Akira * lib/open-uri.rb: Make proxy disabling working again. diff --git a/hash.c b/hash.c index 1c285c2b232df2..db510c818ec4af 100644 --- a/hash.c +++ b/hash.c @@ -67,7 +67,7 @@ rb_hash_freeze(VALUE hash) VALUE rb_cHash; static VALUE envtbl; -static ID id_hash, id_yield, id_default; +static ID id_hash, id_yield, id_default, id_flatten_bang; VALUE rb_hash_set_ifnone(VALUE hash, VALUE ifnone) @@ -2399,15 +2399,25 @@ rb_hash_flatten(int argc, VALUE *argv, VALUE hash) { VALUE ary; - ary = rb_ary_new_capa(RHASH_SIZE(hash) * 2); - rb_hash_foreach(hash, flatten_i, ary); if (argc) { - int level = NUM2INT(*argv) - 1; - if (level > 0) { - *argv = INT2FIX(level); - rb_funcall2(ary, rb_intern("flatten!"), argc, argv); + int level = NUM2INT(*argv); + if (level == 0) return rb_hash_to_a(hash); + + ary = rb_ary_new_capa(RHASH_SIZE(hash) * 2); + rb_hash_foreach(hash, flatten_i, ary); + if (level - 1 > 0) { + *argv = INT2FIX(level - 1); + rb_funcall2(ary, id_flatten_bang, argc, argv); } + else if (level < 0) { + rb_funcall2(ary, id_flatten_bang, 0, 0); + } + } + else { + ary = rb_ary_new_capa(RHASH_SIZE(hash) * 2); + rb_hash_foreach(hash, flatten_i, ary); } + return ary; } @@ -3757,6 +3767,7 @@ Init_Hash(void) id_hash = rb_intern("hash"); id_yield = rb_intern("yield"); id_default = rb_intern("default"); + id_flatten_bang = rb_intern("flatten!"); rb_cHash = rb_define_class("Hash", rb_cObject); diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb index c872b11a3c6c97..800241a70389af 100644 --- a/test/ruby/test_hash.rb +++ b/test/ruby/test_hash.rb @@ -973,11 +973,11 @@ def test_flatten a = @cls[1=> "one", 2 => [2,"two"], 3 => [3, ["three"]]] assert_equal([1, "one", 2, [2, "two"], 3, [3, ["three"]]], a.flatten) - assert_equal([1, "one", 2, [2, "two"], 3, [3, ["three"]]], a.flatten(-1)) - assert_equal([1, "one", 2, [2, "two"], 3, [3, ["three"]]], a.flatten(0)) + assert_equal([[1, "one"], [2, [2, "two"]], [3, [3, ["three"]]]], a.flatten(0)) assert_equal([1, "one", 2, [2, "two"], 3, [3, ["three"]]], a.flatten(1)) assert_equal([1, "one", 2, 2, "two", 3, 3, ["three"]], a.flatten(2)) assert_equal([1, "one", 2, 2, "two", 3, 3, "three"], a.flatten(3)) + assert_equal([1, "one", 2, 2, "two", 3, 3, "three"], a.flatten(-1)) assert_raise(TypeError){ a.flatten(Object) } end diff --git a/version.h b/version.h index d3149d7c03f2c5..52c4bf043e235d 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-22" -#define RUBY_PATCHLEVEL 70 +#define RUBY_PATCHLEVEL 71 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 776b8b1fd1932221621b85e0a3176cc69ebb0647 Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 22 Feb 2014 09:53:35 +0000 Subject: [PATCH 070/343] merge revision(s) 45076: [Backport #9535] * class.c (rb_mod_init_copy): do nothing if copying self. [ruby-dev:47989] [Bug #9535] * hash.c (rb_hash_initialize_copy): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45128 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ class.c | 2 +- ext/bigdecimal/bigdecimal.c | 4 +++- ext/json/generator/generator.c | 1 + ext/zlib/zlib.c | 1 + hash.c | 2 ++ test/ruby/test_hash.rb | 6 ++++++ test/ruby/test_module.rb | 11 +++++++++++ version.h | 2 +- 9 files changed, 33 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index e0be9a55326c6b..b61a02d11ee543 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Sat Feb 22 18:48:57 2014 Nobuyoshi Nakada + + * class.c (rb_mod_init_copy): do nothing if copying self. + [ruby-dev:47989] [Bug #9535] + + * hash.c (rb_hash_initialize_copy): ditto. + Sat Feb 22 18:20:58 2014 Masaki Matsushita * hash.c (rb_hash_flatten): fix behavior of flatten(-1). diff --git a/class.c b/class.c index e161e25063ff94..bf9b2bb43e5d63 100644 --- a/class.c +++ b/class.c @@ -321,7 +321,7 @@ rb_mod_init_copy(VALUE clone, VALUE orig) if (RB_TYPE_P(clone, T_CLASS)) { class_init_copy_check(clone, orig); } - rb_obj_init_copy(clone, orig); + if (!OBJ_INIT_COPY(clone, orig)) return clone; if (!FL_TEST(CLASS_OF(clone), FL_SINGLETON)) { RBASIC_SET_CLASS(clone, rb_singleton_class_clone(orig)); rb_singleton_class_attached(RBASIC(clone)->klass, (VALUE)clone); diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c index 8c470fc2b77d82..4120a2346dc948 100644 --- a/ext/bigdecimal/bigdecimal.c +++ b/ext/bigdecimal/bigdecimal.c @@ -2481,7 +2481,9 @@ BigDecimal_initialize_copy(VALUE self, VALUE other) Real *pv = rb_check_typeddata(self, &BigDecimal_data_type); Real *x = rb_check_typeddata(other, &BigDecimal_data_type); - DATA_PTR(self) = VpCopy(pv, x); + if (self != other) { + DATA_PTR(self) = VpCopy(pv, x); + } return self; } diff --git a/ext/json/generator/generator.c b/ext/json/generator/generator.c index ed7bb8288758f2..550e9beef0bd28 100644 --- a/ext/json/generator/generator.c +++ b/ext/json/generator/generator.c @@ -965,6 +965,7 @@ static VALUE cState_init_copy(VALUE obj, VALUE orig) { JSON_Generator_State *objState, *origState; + if (obj == orig) return obj; Data_Get_Struct(obj, JSON_Generator_State, objState); Data_Get_Struct(orig, JSON_Generator_State, origState); if (!objState) rb_raise(rb_eArgError, "unallocated JSON::State"); diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c index 391bec17226f8a..ffdd9a0b7d51d2 100644 --- a/ext/zlib/zlib.c +++ b/ext/zlib/zlib.c @@ -1556,6 +1556,7 @@ rb_deflate_init_copy(VALUE self, VALUE orig) Data_Get_Struct(self, struct zstream, z1); z2 = get_zstream(orig); + if (z1 == z2) return self; err = deflateCopy(&z1->stream, &z2->stream); if (err != Z_OK) { raise_zlib_error(err, 0); diff --git a/hash.c b/hash.c index db510c818ec4af..66cd94bcddc96e 100644 --- a/hash.c +++ b/hash.c @@ -1428,6 +1428,8 @@ rb_hash_initialize_copy(VALUE hash, VALUE hash2) Check_Type(hash2, T_HASH); + if (hash == hash2) return hash; + ntbl = RHASH(hash)->ntbl; if (RHASH(hash2)->ntbl) { if (ntbl) st_free_table(ntbl); diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb index 800241a70389af..0bbdf13a07698f 100644 --- a/test/ruby/test_hash.rb +++ b/test/ruby/test_hash.rb @@ -108,6 +108,12 @@ def test_clear_initialize_copy assert_empty(h) end + def test_self_initialize_copy + h = @cls[1=>2] + h.instance_eval {initialize_copy(h)} + assert_equal(2, h[1]) + end + def test_dup_will_rehash set1 = @cls[] set2 = @cls[set1 => true] diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb index ba6f273159063b..f89071c10f270b 100644 --- a/test/ruby/test_module.rb +++ b/test/ruby/test_module.rb @@ -364,6 +364,17 @@ def test_constants assert_equal([:MIXIN, :USER], User.constants.sort) end + def test_self_initialize_copy + bug9535 = '[ruby-dev:47989] [Bug #9535]' + m = Module.new do + def foo + :ok + end + initialize_copy(self) + end + assert_equal(:ok, Object.new.extend(m).foo, bug9535) + end + def test_dup bug6454 = '[ruby-core:45132]' diff --git a/version.h b/version.h index 52c4bf043e235d..2138e5e758896d 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-22" -#define RUBY_PATCHLEVEL 71 +#define RUBY_PATCHLEVEL 72 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 3aa457ce139a2698a7c1c22e7d928f1325830cf9 Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 22 Feb 2014 10:03:49 +0000 Subject: [PATCH 071/343] merge revision(s) 45084: [Backport #9547] * ext/socket/init.c (wait_connectable): break if the socket is writable to avoid infinite loops on FreeBSD and other platforms which conforms to SUSv3. This problem cannot be reproduced with loopback interfaces, so it's hard to write test code. rsock_connect() and wait_connectable() are overly complicated, so they should be refactored, but I commit this fix as a workaround for the release of Ruby 1.9.3 scheduled on Feb 24. [ruby-core:60940] [Bug #9547] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45129 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 11 +++++++++++ ext/socket/init.c | 8 ++++++-- version.h | 2 +- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index b61a02d11ee543..2fdbeb26d076c4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +Sat Feb 22 18:55:08 2014 Shugo Maeda + + * ext/socket/init.c (wait_connectable): break if the socket is + writable to avoid infinite loops on FreeBSD and other platforms + which conforms to SUSv3. This problem cannot be reproduced with + loopback interfaces, so it's hard to write test code. + rsock_connect() and wait_connectable() are overly complicated, so + they should be refactored, but I commit this fix as a workaround + for the release of Ruby 1.9.3 scheduled on Feb 24. + [ruby-core:60940] [Bug #9547] + Sat Feb 22 18:48:57 2014 Nobuyoshi Nakada * class.c (rb_mod_init_copy): do nothing if copying self. diff --git a/ext/socket/init.c b/ext/socket/init.c index 6d98a66d6e8573..d3b875c78dffce 100644 --- a/ext/socket/init.c +++ b/ext/socket/init.c @@ -323,8 +323,12 @@ wait_connectable(int fd) */ if (ret < 0) break; - if (sockerr == 0) - continue; /* workaround for winsock */ + if (sockerr == 0) { + if (revents & RB_WAITFD_OUT) + break; + else + continue; /* workaround for winsock */ + } /* BSD and Linux use sockerr. */ errno = sockerr; diff --git a/version.h b/version.h index 2138e5e758896d..2a60d15ec871b9 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-22" -#define RUBY_PATCHLEVEL 72 +#define RUBY_PATCHLEVEL 73 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From be2101a641bcb320521ebcd498c147b81ea96b19 Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 22 Feb 2014 13:13:24 +0000 Subject: [PATCH 072/343] merge revision(s) 44412,44413,44414,44420,44421: [Backport #9298] test_method.rb, test_proc.rb: suppress warnings * test/ruby/test_method.rb: suppress warnings in verbose mode. * test/ruby/test_proc.rb: ditto. * proc.c (rb_iseq_min_max_arity): maximum argument is unlimited if having rest keywords argument. [ruby-core:53298] [Bug #8072] * iseq.c (rb_iseq_parameters): push argument type symbol only for unnamed rest keywords argument. * compile.c (iseq_set_arguments): set arg_keyword_check from nd_cflag, which is set by parser. internal ID is used for unnamed keyword rest argument, which should be separated from no keyword check. * iseq.c (rb_iseq_parameters): if no keyword check, keyword rest is present. * parse.y (new_args_tail_gen): set keywords check to nd_cflag, which equals to that keyword rest is not present. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45138 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 23 ++++++++++++++++ compile.c | 2 +- iseq.c | 2 +- parse.y | 7 ++++- proc.c | 2 +- test/ruby/test_keyword.rb | 9 +++++++ test/ruby/test_method.rb | 57 ++++++++++++++++++++++++++++++++++++--- test/ruby/test_proc.rb | 34 ++++++++++++++++++++++- version.h | 2 +- 9 files changed, 129 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2fdbeb26d076c4..b67f54aef6eba2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,26 @@ +Sat Feb 22 21:56:26 2014 Nobuyoshi Nakada + + * compile.c (iseq_set_arguments): set arg_keyword_check from + nd_cflag, which is set by parser. internal ID is used for + unnamed keyword rest argument, which should be separated from no + keyword check. + + * iseq.c (rb_iseq_parameters): if no keyword check, keyword rest is + present. + + * parse.y (new_args_tail_gen): set keywords check to nd_cflag, which + equals to that keyword rest is not present. + +Sat Feb 22 21:56:26 2014 Nobuyoshi Nakada + + * iseq.c (rb_iseq_parameters): push argument type symbol only for + unnamed rest keywords argument. + +Sat Feb 22 21:56:26 2014 Nobuyoshi Nakada + + * proc.c (rb_iseq_min_max_arity): maximum argument is unlimited if + having rest keywords argument. [ruby-core:53298] [Bug #8072] + Sat Feb 22 18:55:08 2014 Shugo Maeda * ext/socket/init.c (wait_connectable): break if the socket is diff --git a/compile.c b/compile.c index 3d6a4627e9f475..e96a9829d4fdb3 100644 --- a/compile.c +++ b/compile.c @@ -1203,7 +1203,7 @@ iseq_set_arguments(rb_iseq_t *iseq, LINK_ANCHOR *optargs, NODE *node_args) node = node->nd_next; i += 1; } - iseq->arg_keyword_check = (args->kw_rest_arg->nd_vid & ID_SCOPE_MASK) == ID_JUNK; + iseq->arg_keyword_check = args->kw_rest_arg->nd_cflag != 0; iseq->arg_keywords = i; iseq->arg_keyword_required = r; iseq->arg_keyword_table = ALLOC_N(ID, i); diff --git a/iseq.c b/iseq.c index 22081a1ee29516..32d996796429f9 100644 --- a/iseq.c +++ b/iseq.c @@ -2023,7 +2023,7 @@ rb_iseq_parameters(const rb_iseq_t *iseq, int is_proc) } rb_ary_push(args, a); } - if (rb_id2str(iseq->local_table[iseq->arg_keyword])) { + if (!iseq->arg_keyword_check) { CONST_ID(keyrest, "keyrest"); rb_ary_push(args, PARAM(iseq->arg_keyword, keyrest)); } diff --git a/parse.y b/parse.y index eb5ed547d335a4..25946dccda974f 100644 --- a/parse.y +++ b/parse.y @@ -9486,6 +9486,7 @@ new_args_tail_gen(struct parser_params *parser, NODE *k, ID kr, ID b) struct rb_args_info *args; NODE *kw_rest_arg = 0; NODE *node; + int check = 0; args = ALLOC(struct rb_args_info); MEMZERO(args, struct rb_args_info, 1); @@ -9493,10 +9494,14 @@ new_args_tail_gen(struct parser_params *parser, NODE *k, ID kr, ID b) args->block_arg = b; args->kw_args = k; - if (k && !kr) kr = internal_id(); + if (k && !kr) { + check = 1; + kr = internal_id(); + } if (kr) { arg_var(kr); kw_rest_arg = NEW_DVAR(kr); + kw_rest_arg->nd_cflag = check; } args->kw_rest_arg = kw_rest_arg; diff --git a/proc.c b/proc.c index e52beaf9d813d4..78851ac54749f1 100644 --- a/proc.c +++ b/proc.c @@ -825,7 +825,7 @@ proc_arity(VALUE self) static inline int rb_iseq_min_max_arity(const rb_iseq_t *iseq, int *max) { - *max = iseq->arg_rest == -1 ? + *max = (iseq->arg_rest == -1 && iseq->arg_keyword == -1) ? iseq->argc + iseq->arg_post_len + iseq->arg_opts - (iseq->arg_opts > 0) : UNLIMITED_ARGUMENTS; return iseq->argc + iseq->arg_post_len; diff --git a/test/ruby/test_keyword.rb b/test/ruby/test_keyword.rb index 7e708454ae580b..03b93dbf0d0b58 100644 --- a/test/ruby/test_keyword.rb +++ b/test/ruby/test_keyword.rb @@ -117,6 +117,15 @@ def test_f9 assert_equal([1, 2, [3, 4], 5, :key, {str: "bar"}, nil], f9(1, 2, 3, 4, 5, str: "bar")) end + def f10(a: 1, **) + a + end + + def test_f10 + assert_equal(42, f10(a: 42)) + assert_equal(1, f10(b: 42)) + end + def test_method_parameters assert_equal([[:key, :str], [:key, :num]], method(:f1).parameters); assert_equal([[:req, :x], [:key, :str], [:key, :num]], method(:f2).parameters); diff --git a/test/ruby/test_method.rb b/test/ruby/test_method.rb index 1652c91d4f1c75..2e3c2ae8b07317 100644 --- a/test/ruby/test_method.rb +++ b/test/ruby/test_method.rb @@ -22,7 +22,14 @@ def mo4(a, *b, &c) end def mo5(a, *b, c) end def mo6(a, *b, c, &d) end def mo7(a, b = nil, *c, d, &e) end - def ma1((a), &b) end + def ma1((a), &b) nil && a end + def mk1(**) end + def mk2(**o) nil && o end + def mk3(a, **o) nil && o end + def mk4(a = nil, **o) nil && o end + def mk5(a, b = nil, **o) nil && o end + def mk6(a, b = nil, c, **o) nil && o end + def mk7(a, b = nil, *c, d, **o) nil && o end class Base def foo() :base end @@ -68,6 +75,13 @@ def test_arity assert_equal(-2, method(:mo4).arity) assert_equal(-3, method(:mo5).arity) assert_equal(-3, method(:mo6).arity) + assert_equal(-1, method(:mk1).arity) + assert_equal(-1, method(:mk2).arity) + assert_equal(-2, method(:mk3).arity) + assert_equal(-1, method(:mk4).arity) + assert_equal(-2, method(:mk5).arity) + assert_equal(-3, method(:mk6).arity) + assert_equal(-3, method(:mk7).arity) end def test_arity_special @@ -293,7 +307,7 @@ def a end end - assert_nothing_raised do + assert_nothing_raised(bug8686) do m.define_singleton_method(:a, m.method(:a)) end end @@ -456,7 +470,14 @@ def test_default_accessibility define_method(:pmo5) {|a, *b, c|} define_method(:pmo6) {|a, *b, c, &d|} define_method(:pmo7) {|a, b = nil, *c, d, &e|} - define_method(:pma1) {|(a), &b|} + define_method(:pma1) {|(a), &b| nil && a} + define_method(:pmk1) {|**|} + define_method(:pmk2) {|**o|} + define_method(:pmk3) {|a, **o|} + define_method(:pmk4) {|a = nil, **o|} + define_method(:pmk5) {|a, b = nil, **o|} + define_method(:pmk6) {|a, b = nil, c, **o|} + define_method(:pmk7) {|a, b = nil, *c, d, **o|} def test_bound_parameters assert_equal([], method(:m0).parameters) @@ -470,6 +491,13 @@ def test_bound_parameters assert_equal([[:req, :a], [:rest, :b], [:req, :c], [:block, :d]], method(:mo6).parameters) assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:block, :e]], method(:mo7).parameters) assert_equal([[:req], [:block, :b]], method(:ma1).parameters) + assert_equal([[:keyrest]], method(:mk1).parameters) + assert_equal([[:keyrest, :o]], method(:mk2).parameters) + assert_equal([[:req, :a], [:keyrest, :o]], method(:mk3).parameters) + assert_equal([[:opt, :a], [:keyrest, :o]], method(:mk4).parameters) + assert_equal([[:req, :a], [:opt, :b], [:keyrest, :o]], method(:mk5).parameters) + assert_equal([[:req, :a], [:opt, :b], [:req, :c], [:keyrest, :o]], method(:mk6).parameters) + assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:keyrest, :o]], method(:mk7).parameters) end def test_unbound_parameters @@ -484,6 +512,13 @@ def test_unbound_parameters assert_equal([[:req, :a], [:rest, :b], [:req, :c], [:block, :d]], self.class.instance_method(:mo6).parameters) assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:block, :e]], self.class.instance_method(:mo7).parameters) assert_equal([[:req], [:block, :b]], self.class.instance_method(:ma1).parameters) + assert_equal([[:keyrest]], self.class.instance_method(:mk1).parameters) + assert_equal([[:keyrest, :o]], self.class.instance_method(:mk2).parameters) + assert_equal([[:req, :a], [:keyrest, :o]], self.class.instance_method(:mk3).parameters) + assert_equal([[:opt, :a], [:keyrest, :o]], self.class.instance_method(:mk4).parameters) + assert_equal([[:req, :a], [:opt, :b], [:keyrest, :o]], self.class.instance_method(:mk5).parameters) + assert_equal([[:req, :a], [:opt, :b], [:req, :c], [:keyrest, :o]], self.class.instance_method(:mk6).parameters) + assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:keyrest, :o]], self.class.instance_method(:mk7).parameters) end def test_bmethod_bound_parameters @@ -498,6 +533,13 @@ def test_bmethod_bound_parameters assert_equal([[:req, :a], [:rest, :b], [:req, :c], [:block, :d]], method(:pmo6).parameters) assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:block, :e]], method(:pmo7).parameters) assert_equal([[:req], [:block, :b]], method(:pma1).parameters) + assert_equal([[:keyrest]], method(:pmk1).parameters) + assert_equal([[:keyrest, :o]], method(:pmk2).parameters) + assert_equal([[:req, :a], [:keyrest, :o]], method(:pmk3).parameters) + assert_equal([[:opt, :a], [:keyrest, :o]], method(:pmk4).parameters) + assert_equal([[:req, :a], [:opt, :b], [:keyrest, :o]], method(:pmk5).parameters) + assert_equal([[:req, :a], [:opt, :b], [:req, :c], [:keyrest, :o]], method(:pmk6).parameters) + assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:keyrest, :o]], method(:pmk7).parameters) end def test_bmethod_unbound_parameters @@ -512,6 +554,14 @@ def test_bmethod_unbound_parameters assert_equal([[:req, :a], [:rest, :b], [:req, :c], [:block, :d]], self.class.instance_method(:pmo6).parameters) assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:block, :e]], self.class.instance_method(:pmo7).parameters) assert_equal([[:req], [:block, :b]], self.class.instance_method(:pma1).parameters) + assert_equal([[:req], [:block, :b]], self.class.instance_method(:pma1).parameters) + assert_equal([[:keyrest]], self.class.instance_method(:pmk1).parameters) + assert_equal([[:keyrest, :o]], self.class.instance_method(:pmk2).parameters) + assert_equal([[:req, :a], [:keyrest, :o]], self.class.instance_method(:pmk3).parameters) + assert_equal([[:opt, :a], [:keyrest, :o]], self.class.instance_method(:pmk4).parameters) + assert_equal([[:req, :a], [:opt, :b], [:keyrest, :o]], self.class.instance_method(:pmk5).parameters) + assert_equal([[:req, :a], [:opt, :b], [:req, :c], [:keyrest, :o]], self.class.instance_method(:pmk6).parameters) + assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:keyrest, :o]], self.class.instance_method(:pmk7).parameters) end def test_public_method_with_zsuper_method @@ -659,6 +709,7 @@ def foo prepend m } assert_raise(NameError, bug7988) {Module.new{prepend m}.instance_method(:bar)} + true || c || bug7836 end def test_gced_bmethod diff --git a/test/ruby/test_proc.rb b/test/ruby/test_proc.rb index b40485f5821752..206e21fb1a8bfd 100644 --- a/test/ruby/test_proc.rb +++ b/test/ruby/test_proc.rb @@ -77,6 +77,13 @@ def test_arity assert_equal(2, proc{|(x, y), z|[x,y]}.arity) assert_equal(1, proc{|(x, y), z=0|[x,y]}.arity) assert_equal(-4, proc{|x, *y, z, a|}.arity) + assert_equal(-1, proc{|**|}.arity) + assert_equal(-1, proc{|**o|}.arity) + assert_equal(-2, proc{|x, **o|}.arity) + assert_equal(-1, proc{|x=0, **o|}.arity) + assert_equal(-2, proc{|x, y=0, **o|}.arity) + assert_equal(-3, proc{|x, y=0, z, **o|}.arity) + assert_equal(-3, proc{|x, y=0, *z, w, **o|}.arity) assert_equal(0, lambda{}.arity) assert_equal(0, lambda{||}.arity) @@ -95,6 +102,13 @@ def test_arity assert_equal(2, lambda{|(x, y), z|[x,y]}.arity) assert_equal(-2, lambda{|(x, y), z=0|[x,y]}.arity) assert_equal(-4, lambda{|x, *y, z, a|}.arity) + assert_equal(-1, lambda{|**|}.arity) + assert_equal(-1, lambda{|**o|}.arity) + assert_equal(-2, lambda{|x, **o|}.arity) + assert_equal(-1, lambda{|x=0, **o|}.arity) + assert_equal(-2, lambda{|x, y=0, **o|}.arity) + assert_equal(-3, lambda{|x, y=0, z, **o|}.arity) + assert_equal(-3, lambda{|x, y=0, *z, w, **o|}.arity) assert_arity(0) {} assert_arity(0) {||} @@ -104,6 +118,10 @@ def test_arity assert_arity(-3) {|x, *y, z|} assert_arity(-1) {|*x|} assert_arity(-1) {|*|} + assert_arity(-1) {|**o|} + assert_arity(-1) {|**|} + assert_arity(-2) {|x, *y, **|} + assert_arity(-3) {|x, *y, z, **|} end def m(x) @@ -1086,6 +1104,13 @@ def pmo5(a, *b, c) end def pmo6(a, *b, c, &d) end def pmo7(a, b = :b, *c, d, &e) end def pma1((a), &b) a; end + def pmk1(**) end + def pmk2(**o) nil && o end + def pmk3(a, **o) nil && o end + def pmk4(a = nil, **o) nil && o end + def pmk5(a, b = nil, **o) nil && o end + def pmk6(a, b = nil, c, **o) nil && o end + def pmk7(a, b = nil, *c, d, **o) nil && o end def test_bound_parameters @@ -1100,6 +1125,13 @@ def test_bound_parameters assert_equal([[:req, :a], [:rest, :b], [:req, :c], [:block, :d]], method(:pmo6).to_proc.parameters) assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:block, :e]], method(:pmo7).to_proc.parameters) assert_equal([[:req], [:block, :b]], method(:pma1).to_proc.parameters) + assert_equal([[:keyrest]], method(:pmk1).to_proc.parameters) + assert_equal([[:keyrest, :o]], method(:pmk2).to_proc.parameters) + assert_equal([[:req, :a], [:keyrest, :o]], method(:pmk3).to_proc.parameters) + assert_equal([[:opt, :a], [:keyrest, :o]], method(:pmk4).to_proc.parameters) + assert_equal([[:req, :a], [:opt, :b], [:keyrest, :o]], method(:pmk5).to_proc.parameters) + assert_equal([[:req, :a], [:opt, :b], [:req, :c], [:keyrest, :o]], method(:pmk6).to_proc.parameters) + assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:keyrest, :o]], method(:pmk7).to_proc.parameters) assert_equal([], "".method(:upcase).to_proc.parameters) assert_equal([[:rest]], "".method(:gsub).to_proc.parameters) @@ -1209,7 +1241,7 @@ def test_overridden_proc end def get_binding if: 1, case: 2, when: 3, begin: 4, end: 5 - a = 0 + a ||= 0 binding end diff --git a/version.h b/version.h index 2a60d15ec871b9..46079c17a3930c 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-22" -#define RUBY_PATCHLEVEL 73 +#define RUBY_PATCHLEVEL 74 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 5f445a6cdc7e10b65035c0dcbd458e70c15b1480 Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 22 Feb 2014 13:27:49 +0000 Subject: [PATCH 073/343] merge revision(s) 45130: [Backport #9554] * ext/io/console/console.c (console_dev): need read access for conout$ because some functions need it. [Bug#9554] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45139 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ ext/io/console/console.c | 2 +- version.h | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index b67f54aef6eba2..9a7196639cb723 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sat Feb 22 22:26:43 2014 NAKAMURA Usaku + + * ext/io/console/console.c (console_dev): need read access for conout$ + because some functions need it. [Bug#9554] + Sat Feb 22 21:56:26 2014 Nobuyoshi Nakada * compile.c (iseq_set_arguments): set arg_keyword_check from diff --git a/ext/io/console/console.c b/ext/io/console/console.c index f3379ffd8d1542..de5ca825583bd0 100644 --- a/ext/io/console/console.c +++ b/ext/io/console/console.c @@ -710,7 +710,7 @@ console_dev(VALUE klass) int fd; #ifdef CONSOLE_DEVICE_FOR_WRITING - fd = rb_cloexec_open(CONSOLE_DEVICE_FOR_WRITING, O_WRONLY, 0); + fd = rb_cloexec_open(CONSOLE_DEVICE_FOR_WRITING, O_RDWR, 0); if (fd < 0) return Qnil; rb_update_max_fd(fd); args[1] = INT2FIX(O_WRONLY); diff --git a/version.h b/version.h index 46079c17a3930c..f7be648b3928a9 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-22" -#define RUBY_PATCHLEVEL 74 +#define RUBY_PATCHLEVEL 75 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 2d9d5c67f25ad85a82e5947ddfef2c67d6614449 Mon Sep 17 00:00:00 2001 From: naruse Date: Mon, 24 Feb 2014 04:24:15 +0000 Subject: [PATCH 074/343] merge revision(s) 44809,44811,44813,44815,44816,44817,44818,44918,45003: [Backport #9482] * ext/psych/yaml/emitter.c: merge libyaml 0.1.5 * ext/psych/yaml/loader.c: ditto * ext/psych/yaml/parser.c: ditto * ext/psych/yaml/reader.c: ditto * ext/psych/yaml/scanner.c: ditto * ext/psych/yaml/writer.c: ditto * ext/psych/yaml/yaml_private.h: ditto * ext/psych/lib/psych.rb: New release of psych. * ext/psych/psych.gemspec: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45160 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 15 ++++++++ ext/psych/lib/psych.rb | 2 +- ext/psych/psych.gemspec | 9 +++-- ext/psych/yaml/api.c | 55 +++++++++++++++++++--------- ext/psych/yaml/config.h | 8 ++--- ext/psych/yaml/emitter.c | 10 +++--- ext/psych/yaml/loader.c | 33 +++++++++++++++-- ext/psych/yaml/parser.c | 12 +++---- ext/psych/yaml/reader.c | 4 +++ ext/psych/yaml/scanner.c | 68 ++++++++++++++++++++--------------- ext/psych/yaml/yaml_private.h | 20 ++++++++++- version.h | 6 ++-- 12 files changed, 167 insertions(+), 75 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9a7196639cb723..def33cbe32aab1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +Mon Feb 24 13:05:48 2014 Aaron Patterson + + * ext/psych/lib/psych.rb: New release of psych. + * ext/psych/psych.gemspec: ditto + +Mon Feb 24 13:05:48 2014 Aaron Patterson + + * ext/psych/yaml/emitter.c: merge libyaml 0.1.5 + * ext/psych/yaml/loader.c: ditto + * ext/psych/yaml/parser.c: ditto + * ext/psych/yaml/reader.c: ditto + * ext/psych/yaml/scanner.c: ditto + * ext/psych/yaml/writer.c: ditto + * ext/psych/yaml/yaml_private.h: ditto + Sat Feb 22 22:26:43 2014 NAKAMURA Usaku * ext/io/console/console.c (console_dev): need read access for conout$ diff --git a/ext/psych/lib/psych.rb b/ext/psych/lib/psych.rb index 45e01c5fd19666..4b422f56449b38 100644 --- a/ext/psych/lib/psych.rb +++ b/ext/psych/lib/psych.rb @@ -217,7 +217,7 @@ module Psych # The version is Psych you're using - VERSION = '2.0.2' + VERSION = '2.0.3' # The version of libyaml Psych is using LIBYAML_VERSION = Psych.libyaml_version.join '.' diff --git a/ext/psych/psych.gemspec b/ext/psych/psych.gemspec index ca751a033dcaed..100b6ff73720ad 100644 --- a/ext/psych/psych.gemspec +++ b/ext/psych/psych.gemspec @@ -2,23 +2,22 @@ Gem::Specification.new do |s| s.name = "psych" - s.version = "2.0.2" + s.version = "2.0.3" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= + s.require_paths = ["lib"] s.authors = ["Aaron Patterson"] - s.date = "2013-11-26" + s.date = "2014-02-04" s.description = "Psych is a YAML parser and emitter. Psych leverages libyaml[http://pyyaml.org/wiki/LibYAML]\nfor its YAML parsing and emitting capabilities. In addition to wrapping\nlibyaml, Psych also knows how to serialize and de-serialize most Ruby objects\nto and from the YAML format." s.email = ["aaron@tenderlovemaking.com"] s.extensions = ["ext/psych/extconf.rb"] - s.extra_rdoc_files = ["CHANGELOG.rdoc", "Manifest.txt", "README.rdoc"] s.files = [".autotest", ".travis.yml", "CHANGELOG.rdoc", "Manifest.txt", "README.rdoc", "Rakefile", "ext/psych/depend", "ext/psych/extconf.rb", "ext/psych/psych.c", "ext/psych/psych.h", "ext/psych/psych_emitter.c", "ext/psych/psych_emitter.h", "ext/psych/psych_parser.c", "ext/psych/psych_parser.h", "ext/psych/psych_to_ruby.c", "ext/psych/psych_to_ruby.h", "ext/psych/psych_yaml_tree.c", "ext/psych/psych_yaml_tree.h", "ext/psych/yaml/LICENSE", "ext/psych/yaml/api.c", "ext/psych/yaml/config.h", "ext/psych/yaml/dumper.c", "ext/psych/yaml/emitter.c", "ext/psych/yaml/loader.c", "ext/psych/yaml/parser.c", "ext/psych/yaml/reader.c", "ext/psych/yaml/scanner.c", "ext/psych/yaml/writer.c", "ext/psych/yaml/yaml.h", "ext/psych/yaml/yaml_private.h", "lib/psych.rb", "lib/psych/class_loader.rb", "lib/psych/coder.rb", "lib/psych/core_ext.rb", "lib/psych/deprecated.rb", "lib/psych/exception.rb", "lib/psych/handler.rb", "lib/psych/handlers/document_stream.rb", "lib/psych/handlers/recorder.rb", "lib/psych/json/ruby_events.rb", "lib/psych/json/stream.rb", "lib/psych/json/tree_builder.rb", "lib/psych/json/yaml_events.rb", "lib/psych/nodes.rb", "lib/psych/nodes/alias.rb", "lib/psych/nodes/document.rb", "lib/psych/nodes/mapping.rb", "lib/psych/nodes/node.rb", "lib/psych/nodes/scalar.rb", "lib/psych/nodes/sequence.rb", "lib/psych/nodes/stream.rb", "lib/psych/omap.rb", "lib/psych/parser.rb", "lib/psych/scalar_scanner.rb", "lib/psych/set.rb", "lib/psych/stream.rb", "lib/psych/streaming.rb", "lib/psych/syntax_error.rb", "lib/psych/tree_builder.rb", "lib/psych/visitors.rb", "lib/psych/visitors/depth_first.rb", "lib/psych/visitors/emitter.rb", "lib/psych/visitors/json_tree.rb", "lib/psych/visitors/to_ruby.rb", "lib/psych/visitors/visitor.rb", "lib/psych/visitors/yaml_tree.rb", "lib/psych/y.rb", "test/psych/handlers/test_recorder.rb", "test/psych/helper.rb", "test/psych/json/test_stream.rb", "test/psych/nodes/test_enumerable.rb", "test/psych/test_alias_and_anchor.rb", "test/psych/test_array.rb", "test/psych/test_boolean.rb", "test/psych/test_class.rb", "test/psych/test_coder.rb", "test/psych/test_date_time.rb", "test/psych/test_deprecated.rb", "test/psych/test_document.rb", "test/psych/test_emitter.rb", "test/psych/test_encoding.rb", "test/psych/test_engine_manager.rb", "test/psych/test_exception.rb", "test/psych/test_hash.rb", "test/psych/test_json_tree.rb", "test/psych/test_merge_keys.rb", "test/psych/test_nil.rb", "test/psych/test_null.rb", "test/psych/test_numeric.rb", "test/psych/test_object.rb", "test/psych/test_object_references.rb", "test/psych/test_omap.rb", "test/psych/test_parser.rb", "test/psych/test_psych.rb", "test/psych/test_safe_load.rb", "test/psych/test_scalar.rb", "test/psych/test_scalar_scanner.rb", "test/psych/test_serialize_subclasses.rb", "test/psych/test_set.rb", "test/psych/test_stream.rb", "test/psych/test_string.rb", "test/psych/test_struct.rb", "test/psych/test_symbol.rb", "test/psych/test_tainted.rb", "test/psych/test_to_yaml_properties.rb", "test/psych/test_tree_builder.rb", "test/psych/test_yaml.rb", "test/psych/test_yamldbm.rb", "test/psych/test_yamlstore.rb", "test/psych/visitors/test_depth_first.rb", "test/psych/visitors/test_emitter.rb", "test/psych/visitors/test_to_ruby.rb", "test/psych/visitors/test_yaml_tree.rb", ".gemtest"] s.homepage = "http://github.com/tenderlove/psych" s.licenses = ["MIT"] s.rdoc_options = ["--main", "README.rdoc"] - s.require_paths = ["lib"] s.required_ruby_version = Gem::Requirement.new(">= 1.9.2") s.rubyforge_project = "psych" - s.rubygems_version = "2.0.2" + s.rubygems_version = "2.2.1" s.summary = "Psych is a YAML parser and emitter" s.test_files = ["test/psych/handlers/test_recorder.rb", "test/psych/json/test_stream.rb", "test/psych/nodes/test_enumerable.rb", "test/psych/test_alias_and_anchor.rb", "test/psych/test_array.rb", "test/psych/test_boolean.rb", "test/psych/test_class.rb", "test/psych/test_coder.rb", "test/psych/test_date_time.rb", "test/psych/test_deprecated.rb", "test/psych/test_document.rb", "test/psych/test_emitter.rb", "test/psych/test_encoding.rb", "test/psych/test_engine_manager.rb", "test/psych/test_exception.rb", "test/psych/test_hash.rb", "test/psych/test_json_tree.rb", "test/psych/test_merge_keys.rb", "test/psych/test_nil.rb", "test/psych/test_null.rb", "test/psych/test_numeric.rb", "test/psych/test_object.rb", "test/psych/test_object_references.rb", "test/psych/test_omap.rb", "test/psych/test_parser.rb", "test/psych/test_psych.rb", "test/psych/test_safe_load.rb", "test/psych/test_scalar.rb", "test/psych/test_scalar_scanner.rb", "test/psych/test_serialize_subclasses.rb", "test/psych/test_set.rb", "test/psych/test_stream.rb", "test/psych/test_string.rb", "test/psych/test_struct.rb", "test/psych/test_symbol.rb", "test/psych/test_tainted.rb", "test/psych/test_to_yaml_properties.rb", "test/psych/test_tree_builder.rb", "test/psych/test_yaml.rb", "test/psych/test_yamldbm.rb", "test/psych/test_yamlstore.rb", "test/psych/visitors/test_depth_first.rb", "test/psych/visitors/test_emitter.rb", "test/psych/visitors/test_to_ruby.rb", "test/psych/visitors/test_yaml_tree.rb"] end diff --git a/ext/psych/yaml/api.c b/ext/psych/yaml/api.c index 0c4732e1520d22..e0b9d979cc0596 100644 --- a/ext/psych/yaml/api.c +++ b/ext/psych/yaml/api.c @@ -395,7 +395,7 @@ yaml_emitter_delete(yaml_emitter_t *emitter) } QUEUE_DEL(emitter, emitter->events); STACK_DEL(emitter, emitter->indents); - while (!STACK_EMPTY(empty, emitter->tag_directives)) { + while (!STACK_EMPTY(emitter, emitter->tag_directives)) { yaml_tag_directive_t tag_directive = POP(emitter, emitter->tag_directives); yaml_free(tag_directive.handle); yaml_free(tag_directive.prefix); @@ -822,6 +822,7 @@ yaml_scalar_event_initialize(yaml_event_t *event, yaml_char_t *anchor_copy = NULL; yaml_char_t *tag_copy = NULL; yaml_char_t *value_copy = NULL; + size_t value_length; assert(event); /* Non-NULL event object is expected. */ assert(value); /* Non-NULL anchor is expected. */ @@ -839,16 +840,19 @@ yaml_scalar_event_initialize(yaml_event_t *event, } if (length < 0) { - length = strlen((char *)value); + value_length = strlen((char *)value); + } + else { + value_length = (size_t)length; } - if (!yaml_check_utf8(value, length)) goto error; - value_copy = yaml_malloc(length+1); + if (!yaml_check_utf8(value, value_length)) goto error; + value_copy = yaml_malloc(value_length+1); if (!value_copy) goto error; - memcpy(value_copy, value, length); - value_copy[length] = '\0'; + memcpy(value_copy, value, value_length); + value_copy[value_length] = '\0'; - SCALAR_EVENT_INIT(*event, anchor_copy, tag_copy, value_copy, length, + SCALAR_EVENT_INIT(*event, anchor_copy, tag_copy, value_copy, value_length, plain_implicit, quoted_implicit, style, mark, mark); return 1; @@ -1202,6 +1206,8 @@ yaml_document_add_scalar(yaml_document_t *document, yaml_char_t *tag_copy = NULL; yaml_char_t *value_copy = NULL; yaml_node_t node; + size_t value_length; + ptrdiff_t ret; assert(document); /* Non-NULL document object is expected. */ assert(value); /* Non-NULL value is expected. */ @@ -1215,19 +1221,26 @@ yaml_document_add_scalar(yaml_document_t *document, if (!tag_copy) goto error; if (length < 0) { - length = strlen((char *)value); + value_length = strlen((char *)value); + } + else { + value_length = (size_t)length; } - if (!yaml_check_utf8(value, length)) goto error; - value_copy = yaml_malloc(length+1); + if (!yaml_check_utf8(value, value_length)) goto error; + value_copy = yaml_malloc(value_length+1); if (!value_copy) goto error; - memcpy(value_copy, value, length); - value_copy[length] = '\0'; + memcpy(value_copy, value, value_length); + value_copy[value_length] = '\0'; - SCALAR_NODE_INIT(node, tag_copy, value_copy, length, style, mark, mark); + SCALAR_NODE_INIT(node, tag_copy, value_copy, value_length, style, mark, mark); if (!PUSH(&context, document->nodes, node)) goto error; - return document->nodes.top - document->nodes.start; + ret = document->nodes.top - document->nodes.start; +#if PTRDIFF_MAX > INT_MAX + if (ret > INT_MAX) goto error; +#endif + return (int)ret; error: yaml_free(tag_copy); @@ -1255,6 +1268,7 @@ yaml_document_add_sequence(yaml_document_t *document, yaml_node_item_t *top; } items = { NULL, NULL, NULL }; yaml_node_t node; + ptrdiff_t ret; assert(document); /* Non-NULL document object is expected. */ @@ -1272,7 +1286,11 @@ yaml_document_add_sequence(yaml_document_t *document, style, mark, mark); if (!PUSH(&context, document->nodes, node)) goto error; - return document->nodes.top - document->nodes.start; + ret = document->nodes.top - document->nodes.start; +#if PTRDIFF_MAX > INT_MAX + if (ret > INT_MAX) goto error; +#endif + return (int)ret; error: STACK_DEL(&context, items); @@ -1300,6 +1318,7 @@ yaml_document_add_mapping(yaml_document_t *document, yaml_node_pair_t *top; } pairs = { NULL, NULL, NULL }; yaml_node_t node; + ptrdiff_t ret; assert(document); /* Non-NULL document object is expected. */ @@ -1317,7 +1336,11 @@ yaml_document_add_mapping(yaml_document_t *document, style, mark, mark); if (!PUSH(&context, document->nodes, node)) goto error; - return document->nodes.top - document->nodes.start; + ret = document->nodes.top - document->nodes.start; +#if PTRDIFF_MAX > INT_MAX + if (ret > INT_MAX) goto error; +#endif + return (int)ret; error: STACK_DEL(&context, pairs); diff --git a/ext/psych/yaml/config.h b/ext/psych/yaml/config.h index 6d6c25b3b104ea..fb62651340416d 100644 --- a/ext/psych/yaml/config.h +++ b/ext/psych/yaml/config.h @@ -1,11 +1,11 @@ #define PACKAGE_NAME "yaml" #define PACKAGE_TARNAME "yaml" -#define PACKAGE_VERSION "0.1.4" -#define PACKAGE_STRING "yaml 0.1.4" +#define PACKAGE_VERSION "0.1.5" +#define PACKAGE_STRING "yaml 0.1.5" #define PACKAGE_BUGREPORT "http://pyyaml.org/newticket?component libyaml" #define PACKAGE_URL "" #define YAML_VERSION_MAJOR 0 #define YAML_VERSION_MINOR 1 -#define YAML_VERSION_PATCH 4 -#define YAML_VERSION_STRING "0.1.4" +#define YAML_VERSION_PATCH 5 +#define YAML_VERSION_STRING "0.1.5" diff --git a/ext/psych/yaml/emitter.c b/ext/psych/yaml/emitter.c index c41a94a79f8837..bf84fafc511a5a 100644 --- a/ext/psych/yaml/emitter.c +++ b/ext/psych/yaml/emitter.c @@ -53,7 +53,7 @@ #define WRITE_BREAK(emitter,string) \ (FLUSH(emitter) \ && (CHECK(string,'\n') ? \ - (PUT_BREAK(emitter), \ + ((void)PUT_BREAK(emitter), \ string.pointer ++, \ 1) : \ (COPY(emitter->buffer,string), \ @@ -1493,7 +1493,7 @@ yaml_emitter_analyze_scalar(yaml_emitter_t *emitter, int break_space = 0; int space_break = 0; - int preceded_by_whitespace = 0; + int preceeded_by_whitespace = 0; int followed_by_whitespace = 0; int previous_space = 0; int previous_break = 0; @@ -1524,7 +1524,7 @@ yaml_emitter_analyze_scalar(yaml_emitter_t *emitter, flow_indicators = 1; } - preceded_by_whitespace = 1; + preceeded_by_whitespace = 1; followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); while (string.pointer != string.end) @@ -1570,7 +1570,7 @@ yaml_emitter_analyze_scalar(yaml_emitter_t *emitter, } } - if (CHECK(string, '#') && preceded_by_whitespace) { + if (CHECK(string, '#') && preceeded_by_whitespace) { flow_indicators = 1; block_indicators = 1; } @@ -1619,7 +1619,7 @@ yaml_emitter_analyze_scalar(yaml_emitter_t *emitter, previous_break = 0; } - preceded_by_whitespace = IS_BLANKZ(string); + preceeded_by_whitespace = IS_BLANKZ(string); MOVE(string); if (string.pointer != string.end) { followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); diff --git a/ext/psych/yaml/loader.c b/ext/psych/yaml/loader.c index 9d3d912663c328..cb3ea930891b90 100644 --- a/ext/psych/yaml/loader.c +++ b/ext/psych/yaml/loader.c @@ -283,9 +283,12 @@ static int yaml_parser_load_scalar(yaml_parser_t *parser, yaml_event_t *first_event) { yaml_node_t node; + ptrdiff_t node_index; int index; yaml_char_t *tag = first_event->data.scalar.tag; + if (!STACK_LIMIT(parser, parser->document->nodes, INT_MAX-1)) goto error; + if (!tag || strcmp((char *)tag, "!") == 0) { yaml_free(tag); tag = yaml_strdup((yaml_char_t *)YAML_DEFAULT_SCALAR_TAG); @@ -298,7 +301,11 @@ yaml_parser_load_scalar(yaml_parser_t *parser, yaml_event_t *first_event) if (!PUSH(parser, parser->document->nodes, node)) goto error; - index = parser->document->nodes.top - parser->document->nodes.start; + node_index = parser->document->nodes.top - parser->document->nodes.start; +#if PTRDIFF_MAX > INT_MAX + if (node_index > INT_MAX) goto error; +#endif + index = (int)node_index; if (!yaml_parser_register_anchor(parser, index, first_event->data.scalar.anchor)) return 0; @@ -327,8 +334,11 @@ yaml_parser_load_sequence(yaml_parser_t *parser, yaml_event_t *first_event) yaml_node_item_t *top; } items = { NULL, NULL, NULL }; int index, item_index; + ptrdiff_t node_index; yaml_char_t *tag = first_event->data.sequence_start.tag; + if (!STACK_LIMIT(parser, parser->document->nodes, INT_MAX-1)) goto error; + if (!tag || strcmp((char *)tag, "!") == 0) { yaml_free(tag); tag = yaml_strdup((yaml_char_t *)YAML_DEFAULT_SEQUENCE_TAG); @@ -343,7 +353,11 @@ yaml_parser_load_sequence(yaml_parser_t *parser, yaml_event_t *first_event) if (!PUSH(parser, parser->document->nodes, node)) goto error; - index = parser->document->nodes.top - parser->document->nodes.start; + node_index = parser->document->nodes.top - parser->document->nodes.start; +#if PTRDIFF_MAX > INT_MAX + if (node_index > INT_MAX) goto error; +#endif + index = (int)node_index; if (!yaml_parser_register_anchor(parser, index, first_event->data.sequence_start.anchor)) return 0; @@ -351,6 +365,9 @@ yaml_parser_load_sequence(yaml_parser_t *parser, yaml_event_t *first_event) if (!yaml_parser_parse(parser, &event)) return 0; while (event.type != YAML_SEQUENCE_END_EVENT) { + if (!STACK_LIMIT(parser, + parser->document->nodes.start[index-1].data.sequence.items, + INT_MAX-1)) return 0; item_index = yaml_parser_load_node(parser, &event); if (!item_index) return 0; if (!PUSH(parser, @@ -384,9 +401,12 @@ yaml_parser_load_mapping(yaml_parser_t *parser, yaml_event_t *first_event) yaml_node_pair_t *top; } pairs = { NULL, NULL, NULL }; int index; + ptrdiff_t node_index; yaml_node_pair_t pair; yaml_char_t *tag = first_event->data.mapping_start.tag; + if (!STACK_LIMIT(parser, parser->document->nodes, INT_MAX-1)) goto error; + if (!tag || strcmp((char *)tag, "!") == 0) { yaml_free(tag); tag = yaml_strdup((yaml_char_t *)YAML_DEFAULT_MAPPING_TAG); @@ -401,7 +421,11 @@ yaml_parser_load_mapping(yaml_parser_t *parser, yaml_event_t *first_event) if (!PUSH(parser, parser->document->nodes, node)) goto error; - index = parser->document->nodes.top - parser->document->nodes.start; + node_index = parser->document->nodes.top - parser->document->nodes.start; +#if PTRDIFF_MAX > INT_MAX + if (node_index > INT_MAX) goto error; +#endif + index = (int)node_index; if (!yaml_parser_register_anchor(parser, index, first_event->data.mapping_start.anchor)) return 0; @@ -409,6 +433,9 @@ yaml_parser_load_mapping(yaml_parser_t *parser, yaml_event_t *first_event) if (!yaml_parser_parse(parser, &event)) return 0; while (event.type != YAML_MAPPING_END_EVENT) { + if (!STACK_LIMIT(parser, + parser->document->nodes.start[index-1].data.mapping.pairs, + INT_MAX-1)) return 0; pair.key = yaml_parser_load_node(parser, &event); if (!pair.key) return 0; if (!yaml_parser_parse(parser, &event)) return 0; diff --git a/ext/psych/yaml/parser.c b/ext/psych/yaml/parser.c index dc5430b09fc27c..32671b252c23f1 100644 --- a/ext/psych/yaml/parser.c +++ b/ext/psych/yaml/parser.c @@ -759,9 +759,8 @@ yaml_parser_parse_block_sequence_entry(yaml_parser_t *parser, else if (token->type == YAML_BLOCK_END_TOKEN) { - yaml_mark_t dummy_mark; /* Used to eliminate a compiler warning. */ parser->state = POP(parser, parser->states); - dummy_mark = POP(parser, parser->marks); + (void)POP(parser, parser->marks); SEQUENCE_END_EVENT_INIT(*event, token->start_mark, token->end_mark); SKIP_TOKEN(parser); return 1; @@ -869,9 +868,8 @@ yaml_parser_parse_block_mapping_key(yaml_parser_t *parser, else if (token->type == YAML_BLOCK_END_TOKEN) { - yaml_mark_t dummy_mark; /* Used to eliminate a compiler warning. */ parser->state = POP(parser, parser->states); - dummy_mark = POP(parser, parser->marks); + (void)POP(parser, parser->marks); MAPPING_END_EVENT_INIT(*event, token->start_mark, token->end_mark); SKIP_TOKEN(parser); return 1; @@ -952,7 +950,6 @@ yaml_parser_parse_flow_sequence_entry(yaml_parser_t *parser, yaml_event_t *event, int first) { yaml_token_t *token; - yaml_mark_t dummy_mark; /* Used to eliminate a compiler warning. */ if (first) { token = PEEK_TOKEN(parser); @@ -997,7 +994,7 @@ yaml_parser_parse_flow_sequence_entry(yaml_parser_t *parser, } parser->state = POP(parser, parser->states); - dummy_mark = POP(parser, parser->marks); + (void)POP(parser, parser->marks); SEQUENCE_END_EVENT_INIT(*event, token->start_mark, token->end_mark); SKIP_TOKEN(parser); return 1; @@ -1104,7 +1101,6 @@ yaml_parser_parse_flow_mapping_key(yaml_parser_t *parser, yaml_event_t *event, int first) { yaml_token_t *token; - yaml_mark_t dummy_mark; /* Used to eliminate a compiler warning. */ if (first) { token = PEEK_TOKEN(parser); @@ -1158,7 +1154,7 @@ yaml_parser_parse_flow_mapping_key(yaml_parser_t *parser, } parser->state = POP(parser, parser->states); - dummy_mark = POP(parser, parser->marks); + (void)POP(parser, parser->marks); MAPPING_END_EVENT_INIT(*event, token->start_mark, token->end_mark); SKIP_TOKEN(parser); return 1; diff --git a/ext/psych/yaml/reader.c b/ext/psych/yaml/reader.c index 4e48add7b8813c..f1a06deb9d3a5b 100644 --- a/ext/psych/yaml/reader.c +++ b/ext/psych/yaml/reader.c @@ -460,6 +460,10 @@ yaml_parser_update_buffer(yaml_parser_t *parser, size_t length) } + if (parser->offset >= PTRDIFF_MAX) + return yaml_parser_set_reader_error(parser, "input is too long", + PTRDIFF_MAX, -1); + return 1; } diff --git a/ext/psych/yaml/scanner.c b/ext/psych/yaml/scanner.c index 31fed0ed94dcda..34308d5d4540d7 100644 --- a/ext/psych/yaml/scanner.c +++ b/ext/psych/yaml/scanner.c @@ -615,11 +615,11 @@ yaml_parser_decrease_flow_level(yaml_parser_t *parser); */ static int -yaml_parser_roll_indent(yaml_parser_t *parser, int column, - int number, yaml_token_type_t type, yaml_mark_t mark); +yaml_parser_roll_indent(yaml_parser_t *parser, ptrdiff_t column, + ptrdiff_t number, yaml_token_type_t type, yaml_mark_t mark); static int -yaml_parser_unroll_indent(yaml_parser_t *parser, int column); +yaml_parser_unroll_indent(yaml_parser_t *parser, ptrdiff_t column); /* * Token fetchers. @@ -1103,7 +1103,7 @@ yaml_parser_save_simple_key(yaml_parser_t *parser) */ int required = (!parser->flow_level - && parser->indent == (int)parser->mark.column); + && parser->indent == (ptrdiff_t)parser->mark.column); /* * A simple key is required only when it is the first token in the current @@ -1176,6 +1176,11 @@ yaml_parser_increase_flow_level(yaml_parser_t *parser) /* Increase the flow level. */ + if (parser->flow_level == INT_MAX) { + parser->error = YAML_MEMORY_ERROR; + return 0; + } + parser->flow_level++; return 1; @@ -1188,11 +1193,9 @@ yaml_parser_increase_flow_level(yaml_parser_t *parser) static int yaml_parser_decrease_flow_level(yaml_parser_t *parser) { - yaml_simple_key_t dummy_key; /* Used to eliminate a compiler warning. */ - if (parser->flow_level) { parser->flow_level --; - dummy_key = POP(parser, parser->simple_keys); + (void)POP(parser, parser->simple_keys); } return 1; @@ -1206,8 +1209,8 @@ yaml_parser_decrease_flow_level(yaml_parser_t *parser) */ static int -yaml_parser_roll_indent(yaml_parser_t *parser, int column, - int number, yaml_token_type_t type, yaml_mark_t mark) +yaml_parser_roll_indent(yaml_parser_t *parser, ptrdiff_t column, + ptrdiff_t number, yaml_token_type_t type, yaml_mark_t mark) { yaml_token_t token; @@ -1226,7 +1229,14 @@ yaml_parser_roll_indent(yaml_parser_t *parser, int column, if (!PUSH(parser, parser->indents, parser->indent)) return 0; - parser->indent = column; +#if PTRDIFF_MAX > INT_MAX + if (column > INT_MAX) { + parser->error = YAML_MEMORY_ERROR; + return 0; + } +#endif + + parser->indent = (int)column; /* Create a token and insert it into the queue. */ @@ -1248,13 +1258,13 @@ yaml_parser_roll_indent(yaml_parser_t *parser, int column, /* * Pop indentation levels from the indents stack until the current level - * becomes less or equal to the column. For each indentation level, append + * becomes less or equal to the column. For each intendation level, append * the BLOCK-END token. */ static int -yaml_parser_unroll_indent(yaml_parser_t *parser, int column) +yaml_parser_unroll_indent(yaml_parser_t *parser, ptrdiff_t column) { yaml_token_t token; @@ -1263,7 +1273,7 @@ yaml_parser_unroll_indent(yaml_parser_t *parser, int column) if (parser->flow_level) return 1; - /* Loop through the indentation levels in the stack. */ + /* Loop through the intendation levels in the stack. */ while (parser->indent > column) { @@ -2574,7 +2584,7 @@ yaml_parser_scan_tag_uri(yaml_parser_t *parser, int directive, /* Resize the string to include the head. */ - while (string.end - string.start <= (int)length) { + while ((size_t)(string.end - string.start) <= length) { if (!yaml_string_extend(&string.start, &string.pointer, &string.end)) { parser->error = YAML_MEMORY_ERROR; goto error; @@ -2769,15 +2779,15 @@ yaml_parser_scan_block_scalar(yaml_parser_t *parser, yaml_token_t *token, if (IS_DIGIT(parser->buffer)) { - /* Check that the indentation is greater than 0. */ + /* Check that the intendation is greater than 0. */ if (CHECK(parser->buffer, '0')) { yaml_parser_set_scanner_error(parser, "while scanning a block scalar", - start_mark, "found an indentation indicator equal to 0"); + start_mark, "found an intendation indicator equal to 0"); goto error; } - /* Get the indentation level and eat the indicator. */ + /* Get the intendation level and eat the indicator. */ increment = AS_DIGIT(parser->buffer); @@ -2791,7 +2801,7 @@ yaml_parser_scan_block_scalar(yaml_parser_t *parser, yaml_token_t *token, { if (CHECK(parser->buffer, '0')) { yaml_parser_set_scanner_error(parser, "while scanning a block scalar", - start_mark, "found an indentation indicator equal to 0"); + start_mark, "found an intendation indicator equal to 0"); goto error; } @@ -2841,7 +2851,7 @@ yaml_parser_scan_block_scalar(yaml_parser_t *parser, yaml_token_t *token, end_mark = parser->mark; - /* Set the indentation level if it was specified. */ + /* Set the intendation level if it was specified. */ if (increment) { indent = parser->indent >= 0 ? parser->indent+increment : increment; @@ -2907,7 +2917,7 @@ yaml_parser_scan_block_scalar(yaml_parser_t *parser, yaml_token_t *token, if (!READ_LINE(parser, leading_break)) goto error; - /* Eat the following indentation spaces and line breaks. */ + /* Eat the following intendation spaces and line breaks. */ if (!yaml_parser_scan_block_scalar_breaks(parser, &indent, &trailing_breaks, start_mark, &end_mark)) goto error; @@ -2942,8 +2952,8 @@ yaml_parser_scan_block_scalar(yaml_parser_t *parser, yaml_token_t *token, } /* - * Scan indentation spaces and line breaks for a block scalar. Determine the - * indentation level if needed. + * Scan intendation spaces and line breaks for a block scalar. Determine the + * intendation level if needed. */ static int @@ -2955,11 +2965,11 @@ yaml_parser_scan_block_scalar_breaks(yaml_parser_t *parser, *end_mark = parser->mark; - /* Eat the indentation spaces and line breaks. */ + /* Eat the intendation spaces and line breaks. */ while (1) { - /* Eat the indentation spaces. */ + /* Eat the intendation spaces. */ if (!CACHE(parser, 1)) return 0; @@ -2972,12 +2982,12 @@ yaml_parser_scan_block_scalar_breaks(yaml_parser_t *parser, if ((int)parser->mark.column > max_indent) max_indent = (int)parser->mark.column; - /* Check for a tab character messing the indentation. */ + /* Check for a tab character messing the intendation. */ if ((!*indent || (int)parser->mark.column < *indent) && IS_TAB(parser->buffer)) { return yaml_parser_set_scanner_error(parser, "while scanning a block scalar", - start_mark, "found a tab character where an indentation space is expected"); + start_mark, "found a tab character where an intendation space is expected"); } /* Have we found a non-empty line? */ @@ -3498,12 +3508,12 @@ yaml_parser_scan_plain_scalar(yaml_parser_t *parser, yaml_token_t *token) { if (IS_BLANK(parser->buffer)) { - /* Check for tab character that abuse indentation. */ + /* Check for tab character that abuse intendation. */ if (leading_blanks && (int)parser->mark.column < indent && IS_TAB(parser->buffer)) { yaml_parser_set_scanner_error(parser, "while scanning a plain scalar", - start_mark, "found a tab character that violates indentation"); + start_mark, "found a tab character that violate intendation"); goto error; } @@ -3536,7 +3546,7 @@ yaml_parser_scan_plain_scalar(yaml_parser_t *parser, yaml_token_t *token) if (!CACHE(parser, 1)) goto error; } - /* Check indentation level. */ + /* Check intendation level. */ if (!parser->flow_level && (int)parser->mark.column < indent) break; diff --git a/ext/psych/yaml/yaml_private.h b/ext/psych/yaml/yaml_private.h index af10c839735237..cd3d3a56c4b4e6 100644 --- a/ext/psych/yaml/yaml_private.h +++ b/ext/psych/yaml/yaml_private.h @@ -10,6 +10,17 @@ #include #include +#include + +#ifndef _MSC_VER +#include +#else +#ifdef _WIN64 +#define PTRDIFF_MAX _I64_MAX +#else +#define PTRDIFF_MAX INT_MAX +#endif +#endif /* * Memory management. @@ -422,7 +433,14 @@ yaml_queue_extend(void **start, void **head, void **tail, void **end); (stack).start = (stack).top = (stack).end = 0) #define STACK_EMPTY(context,stack) \ - ((stack).start == (stack).top) + ((void)(context), \ + ((stack).start == (stack).top)) + +#define STACK_LIMIT(context,stack,size) \ + ((stack).top - (stack).start < (size) ? \ + 1 : \ + ((context)->error = YAML_MEMORY_ERROR, \ + 0)) #define PUSH(context,stack,value) \ (((stack).top != (stack).end \ diff --git a/version.h b/version.h index f7be648b3928a9..f309464de276e4 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.1" -#define RUBY_RELEASE_DATE "2014-02-22" -#define RUBY_PATCHLEVEL 75 +#define RUBY_RELEASE_DATE "2014-02-24" +#define RUBY_PATCHLEVEL 76 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 -#define RUBY_RELEASE_DAY 22 +#define RUBY_RELEASE_DAY 24 #include "ruby/version.h" From 6f2348a0a310aa3f576c5eb665331186b4bb14a4 Mon Sep 17 00:00:00 2001 From: naruse Date: Mon, 24 Feb 2014 06:04:59 +0000 Subject: [PATCH 075/343] merge revision(s) 44425,44460: [Backport #9320] * tool/make-snapshot: support new version scheme. * tool/make-snapshot: needs CXXFLAGS. [ruby-core:59393][Bug #9320] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45162 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ tool/make-snapshot | 31 ++++++++++++++++++++++++------- version.h | 2 +- 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index def33cbe32aab1..8f929ba566c134 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Mon Feb 24 14:56:41 2014 WATANABE Hirofumi + + * tool/make-snapshot: needs CXXFLAGS. [ruby-core:59393][Bug #9320] + +Mon Feb 24 14:56:41 2014 NAKAMURA Usaku + + * tool/make-snapshot: support new version scheme. + Mon Feb 24 13:05:48 2014 Aaron Patterson * ext/psych/lib/psych.rb: New release of psych. diff --git a/tool/make-snapshot b/tool/make-snapshot index 962ac07d9d9196..68ffd3b2fc3422 100755 --- a/tool/make-snapshot +++ b/tool/make-snapshot @@ -116,8 +116,14 @@ def package(rev, destdir) patchlevel = true tag = "p#{$4}" url = SVNURL + "tags/v#{$1}_#{$2}_#{$3}_#{$4}" - when /\./ - url = SVNURL + "branches/ruby_#{rev.tr('.', '_')}" + when /\A(\d+)\.(\d+)\.(\d+)\z/ + if $1 > "2" || $1 == "2" && $2 >= "1" + patchlevel = true + tag = "" + url = SVNURL + "tags/v#{$1}_#{$2}_#{$3}" + else + url = SVNURL + "branches/ruby_#{rev.tr('.', '_')}" + end else warn "#{$0}: unknown version - #{rev}" return @@ -160,14 +166,20 @@ def package(rev, destdir) version ||= (versionhdr = IO.read("#{v}/version.h"))[RUBY_VERSION_PATTERN, 1] version or return if patchlevel - versionhdr ||= IO.read("#{v}/version.h") - patchlevel = versionhdr[/^\#define\s+RUBY_PATCHLEVEL\s+(\d+)/, 1] - tag = (patchlevel ? "p#{patchlevel}" : "r#{revision}") + unless tag.empty? + versionhdr ||= IO.read("#{v}/version.h") + patchlevel = versionhdr[/^\#define\s+RUBY_PATCHLEVEL\s+(\d+)/, 1] + tag = (patchlevel ? "p#{patchlevel}" : "r#{revision}") + end else tag ||= "r#{revision}" end unless v == $exported - n = "ruby-#{version}-#{tag}" + if tag.empty? + n = "ruby-#{version}" + else + n = "ruby-#{version}-#{tag}" + end File.directory?(n) or File.rename v, n v = n end @@ -177,7 +189,11 @@ def package(rev, destdir) Dir.chdir(v) do %w[config.guess config.sub].each do |conf| next if File.exist?("tool/#{conf}") - require File.expand_path("config_files", $tooldir) + begin + require File.expand_path("config_files", $tooldir) + rescue LoadError + abort "Error!!! Copy 'config_files.rb' from 'tool' directory of the recent ruby repository!" + end ConfigFiles.download(conf, "tool") end File.open(clean.add("cross.rb"), "w") do |f| @@ -205,6 +221,7 @@ def package(rev, destdir) f.puts "s,@ARCH_FLAG@,|#_!!_#|,g" f.puts "s,@CFLAGS@,|#_!!_#|,g" f.puts "s,@CPPFLAGS@,|#_!!_#|,g" + f.puts "s,@CXXFLAGS@,|#_!!_#|,g" f.puts "s,@LDFLAGS@,|#_!!_#|,g" f.puts "s,@DLDFLAGS@,|#_!!_#|,g" f.puts "s,@LIBEXT@,|#_!!_#|a,g" diff --git a/version.h b/version.h index f309464de276e4..3931597cac075a 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-24" -#define RUBY_PATCHLEVEL 76 +#define RUBY_PATCHLEVEL 77 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 038540f9319b5b8fb7d4b809f82e1da63c47c0ba Mon Sep 17 00:00:00 2001 From: naruse Date: Mon, 24 Feb 2014 06:33:54 +0000 Subject: [PATCH 076/343] bump version to 2.1.2 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45163 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.h b/version.h index 3931597cac075a..dfd09b9312fd61 100644 --- a/version.h +++ b/version.h @@ -1,4 +1,4 @@ -#define RUBY_VERSION "2.1.1" +#define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-02-24" #define RUBY_PATCHLEVEL 77 From 7a620ac5306bd5cb44fbd5a0ecefed3a63410046 Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 1 Mar 2014 08:25:29 +0000 Subject: [PATCH 077/343] merge revision(s) 44433: [Backport #9299] * proc.c: Having any mandatory keyword argument increases min arity [#9299] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45226 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ proc.c | 2 +- test/ruby/test_proc.rb | 5 +++++ version.h | 8 ++++---- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8f929ba566c134..f2592eb9f6ca2f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sat Mar 1 17:25:12 2014 Marc-Andre Lafortune + + * proc.c: Having any mandatory keyword argument increases min arity + [#9299] + Mon Feb 24 14:56:41 2014 WATANABE Hirofumi * tool/make-snapshot: needs CXXFLAGS. [ruby-core:59393][Bug #9320] diff --git a/proc.c b/proc.c index 78851ac54749f1..9c88ada316ca1e 100644 --- a/proc.c +++ b/proc.c @@ -828,7 +828,7 @@ rb_iseq_min_max_arity(const rb_iseq_t *iseq, int *max) *max = (iseq->arg_rest == -1 && iseq->arg_keyword == -1) ? iseq->argc + iseq->arg_post_len + iseq->arg_opts - (iseq->arg_opts > 0) : UNLIMITED_ARGUMENTS; - return iseq->argc + iseq->arg_post_len; + return iseq->argc + iseq->arg_post_len + (iseq->arg_keyword_required > 0); } static int diff --git a/test/ruby/test_proc.rb b/test/ruby/test_proc.rb index 206e21fb1a8bfd..9e8fb06d6dc942 100644 --- a/test/ruby/test_proc.rb +++ b/test/ruby/test_proc.rb @@ -85,6 +85,11 @@ def test_arity assert_equal(-3, proc{|x, y=0, z, **o|}.arity) assert_equal(-3, proc{|x, y=0, *z, w, **o|}.arity) + assert_equal(2, proc{|x, y=0, z, a:1|}.arity) + assert_equal(3, proc{|x, y=0, z, a:|}.arity) + assert_equal(-4, proc{|x, y, *rest, a:, b:, c:|}.arity) + assert_equal(3, proc{|x, y=0, z, a:, **o|}.arity) + assert_equal(0, lambda{}.arity) assert_equal(0, lambda{||}.arity) assert_equal(1, lambda{|x|}.arity) diff --git a/version.h b/version.h index dfd09b9312fd61..8c8f90068871d2 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.2" -#define RUBY_RELEASE_DATE "2014-02-24" -#define RUBY_PATCHLEVEL 77 +#define RUBY_RELEASE_DATE "2014-03-01" +#define RUBY_PATCHLEVEL 78 #define RUBY_RELEASE_YEAR 2014 -#define RUBY_RELEASE_MONTH 2 -#define RUBY_RELEASE_DAY 24 +#define RUBY_RELEASE_MONTH 3 +#define RUBY_RELEASE_DAY 1 #include "ruby/version.h" From 4b6a0ae306f995d7bec668cf8e046c01defc641b Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 1 Mar 2014 09:02:36 +0000 Subject: [PATCH 078/343] merge revision(s) 44370: [Backport #9576] hash.c: extra states * hash.c (rb_hash_reject): use words "extra states". git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45227 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- hash.c | 2 +- version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hash.c b/hash.c index 66cd94bcddc96e..9a5814aad48b0e 100644 --- a/hash.c +++ b/hash.c @@ -1178,7 +1178,7 @@ rb_hash_reject(VALUE hash) #endif } } -#if HASH_REJECT_COPY_MISC_ATTRIBUTES +#if HASH_REJECT_COPY_EXTRA_STATES result = rb_hash_dup_empty(hash); #else result = rb_hash_new(); diff --git a/version.h b/version.h index 8c8f90068871d2..59c80e38280fb2 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-03-01" -#define RUBY_PATCHLEVEL 78 +#define RUBY_PATCHLEVEL 79 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 3 From b8b43fbdbea07bfa8e0f2d3ca65871d80b7c903e Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 1 Mar 2014 12:01:29 +0000 Subject: [PATCH 079/343] merge revision(s) 44432: [Backport #9299] * proc.c: Having optional keyword arguments makes maximum arity +1, not unlimited [#8072] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45231 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ proc.c | 5 +++-- test/ruby/test_proc.rb | 12 ++++++------ version.h | 2 +- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index f2592eb9f6ca2f..819c6fe4f2a2b1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sat Mar 1 21:00:27 2014 Marc-Andre Lafortune + + * proc.c: Having optional keyword arguments makes maximum arity +1, + not unlimited [#8072] + Sat Mar 1 17:25:12 2014 Marc-Andre Lafortune * proc.c: Having any mandatory keyword argument increases min arity diff --git a/proc.c b/proc.c index 9c88ada316ca1e..e3cecb7bbe898a 100644 --- a/proc.c +++ b/proc.c @@ -825,8 +825,9 @@ proc_arity(VALUE self) static inline int rb_iseq_min_max_arity(const rb_iseq_t *iseq, int *max) { - *max = (iseq->arg_rest == -1 && iseq->arg_keyword == -1) ? - iseq->argc + iseq->arg_post_len + iseq->arg_opts - (iseq->arg_opts > 0) + *max = iseq->arg_rest == -1 ? + iseq->argc + iseq->arg_post_len + iseq->arg_opts - + (iseq->arg_opts > 0) + (iseq->arg_keyword != -1) : UNLIMITED_ARGUMENTS; return iseq->argc + iseq->arg_post_len + (iseq->arg_keyword_required > 0); } diff --git a/test/ruby/test_proc.rb b/test/ruby/test_proc.rb index 9e8fb06d6dc942..1c8a053cca84fe 100644 --- a/test/ruby/test_proc.rb +++ b/test/ruby/test_proc.rb @@ -77,12 +77,12 @@ def test_arity assert_equal(2, proc{|(x, y), z|[x,y]}.arity) assert_equal(1, proc{|(x, y), z=0|[x,y]}.arity) assert_equal(-4, proc{|x, *y, z, a|}.arity) - assert_equal(-1, proc{|**|}.arity) - assert_equal(-1, proc{|**o|}.arity) - assert_equal(-2, proc{|x, **o|}.arity) - assert_equal(-1, proc{|x=0, **o|}.arity) - assert_equal(-2, proc{|x, y=0, **o|}.arity) - assert_equal(-3, proc{|x, y=0, z, **o|}.arity) + assert_equal(0, proc{|**|}.arity) + assert_equal(0, proc{|**o|}.arity) + assert_equal(1, proc{|x, **o|}.arity) + assert_equal(0, proc{|x=0, **o|}.arity) + assert_equal(1, proc{|x, y=0, **o|}.arity) + assert_equal(2, proc{|x, y=0, z, **o|}.arity) assert_equal(-3, proc{|x, y=0, *z, w, **o|}.arity) assert_equal(2, proc{|x, y=0, z, a:1|}.arity) diff --git a/version.h b/version.h index 59c80e38280fb2..746643bda1c329 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-03-01" -#define RUBY_PATCHLEVEL 79 +#define RUBY_PATCHLEVEL 80 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 3 From ab58587f6a3bbd3ca03d0707637712a166441142 Mon Sep 17 00:00:00 2001 From: nagachika Date: Thu, 1 May 2014 11:55:03 +0000 Subject: [PATCH 080/343] merge revision(s) r45225,r45240,r45488: [Backport #9578] [Backport #9630] * ext/readline/readline.c (Init_readline): Use rl_hook_func_t instead of Function to support readline-6.3. (rl_hook_func_t is available since readline-4.2.) Reported by Dmitry Medvinsky. [ruby-core:61141] [Bug #9578] * ext/readline/extconf.rb (rl_hook_func_t): define as Function for very old readline versions. [ruby-core:61209] [Bug #9578] * ext/readline/extconf.rb: fix typo, `$defs` not `$DEFS`. [ruby-core:61756] [Bug #9578] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45772 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 17 +++++++++++++++++ ext/readline/extconf.rb | 8 ++++++++ ext/readline/readline.c | 2 +- version.h | 6 +++--- 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 819c6fe4f2a2b1..c30826342065fc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +Thu May 1 20:47:08 2014 Nobuyoshi Nakada + + * ext/readline/extconf.rb: fix typo, `$defs` not `$DEFS`. + [ruby-core:61756] [Bug #9578] + +Thu May 1 20:47:08 2014 Nobuyoshi Nakada + + * ext/readline/extconf.rb (rl_hook_func_t): define as Function for + very old readline versions. [ruby-core:61209] [Bug #9578] + +Thu May 1 20:47:08 2014 Tanaka Akira + + * ext/readline/readline.c (Init_readline): Use rl_hook_func_t instead + of Function to support readline-6.3. (rl_hook_func_t is available + since readline-4.2.) + Reported by Dmitry Medvinsky. [ruby-core:61141] [Bug #9578] + Sat Mar 1 21:00:27 2014 Marc-Andre Lafortune * proc.c: Having optional keyword arguments makes maximum arity +1, diff --git a/ext/readline/extconf.rb b/ext/readline/extconf.rb index 0b121c1ebe3be8..0477a513c7e028 100644 --- a/ext/readline/extconf.rb +++ b/ext/readline/extconf.rb @@ -19,6 +19,10 @@ def readline.have_func(func) return super(func, headers) end +def readline.have_type(type) + return super(type, headers) +end + dir_config('curses') dir_config('ncurses') dir_config('termcap') @@ -94,4 +98,8 @@ def readline.have_func(func) readline.have_func("rl_redisplay") readline.have_func("rl_insert_text") readline.have_func("rl_delete_text") +unless readline.have_type("rl_hook_func_t") + $defs << "-Drl_hook_func_t=Function" +end + create_makefile("readline") diff --git a/ext/readline/readline.c b/ext/readline/readline.c index 820c6b74bea201..da3b10939c97f3 100644 --- a/ext/readline/readline.c +++ b/ext/readline/readline.c @@ -1974,7 +1974,7 @@ Init_readline() rl_attempted_completion_function = readline_attempted_completion_function; #if defined(HAVE_RL_PRE_INPUT_HOOK) - rl_pre_input_hook = (Function *)readline_pre_input_hook; + rl_pre_input_hook = (rl_hook_func_t *)readline_pre_input_hook; #endif #ifdef HAVE_RL_CATCH_SIGNALS rl_catch_signals = 0; diff --git a/version.h b/version.h index 746643bda1c329..93f816fbee4362 100644 --- a/version.h +++ b/version.h @@ -1,9 +1,9 @@ #define RUBY_VERSION "2.1.2" -#define RUBY_RELEASE_DATE "2014-03-01" -#define RUBY_PATCHLEVEL 80 +#define RUBY_RELEASE_DATE "2014-05-01" +#define RUBY_PATCHLEVEL 81 #define RUBY_RELEASE_YEAR 2014 -#define RUBY_RELEASE_MONTH 3 +#define RUBY_RELEASE_MONTH 5 #define RUBY_RELEASE_DAY 1 #include "ruby/version.h" From f2013ff844a456cdf81d74c4ac9b229d35bcec2a Mon Sep 17 00:00:00 2001 From: nagachika Date: Thu, 1 May 2014 11:59:37 +0000 Subject: [PATCH 081/343] merge revision(s) r45518: [Backport #9578] [Backport #9630] [Backport #9702] * ext/readline/extconf.rb (rl_hook_func_t): check pointer type. [ruby-dev:48089] [Bug #9702] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45773 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ ext/readline/extconf.rb | 2 +- version.h | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index c30826342065fc..cee32095caa3f7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Thu May 1 20:56:56 2014 Nobuyoshi Nakada + + * ext/readline/extconf.rb (rl_hook_func_t): check pointer type. + [ruby-dev:48089] [Bug #9702] + Thu May 1 20:47:08 2014 Nobuyoshi Nakada * ext/readline/extconf.rb: fix typo, `$defs` not `$DEFS`. diff --git a/ext/readline/extconf.rb b/ext/readline/extconf.rb index 0477a513c7e028..8c3bffc26e23be 100644 --- a/ext/readline/extconf.rb +++ b/ext/readline/extconf.rb @@ -98,7 +98,7 @@ def readline.have_type(type) readline.have_func("rl_redisplay") readline.have_func("rl_insert_text") readline.have_func("rl_delete_text") -unless readline.have_type("rl_hook_func_t") +unless readline.have_type("rl_hook_func_t*") $defs << "-Drl_hook_func_t=Function" end diff --git a/version.h b/version.h index 93f816fbee4362..b033e58c7a0000 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-05-01" -#define RUBY_PATCHLEVEL 81 +#define RUBY_PATCHLEVEL 82 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 5 From 49fed34108ed181fa43f6396d9ff19c7243d2bf6 Mon Sep 17 00:00:00 2001 From: nagachika Date: Thu, 1 May 2014 15:23:08 +0000 Subject: [PATCH 082/343] merge revision(s) r45271: [Backport #9592] [Backport #9671] * ext/openssl/ossl.c (ossl_make_error): check NULL for unknown error reasons with old OpenSSL, and insert a colon iff formatted message is not empty. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45778 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ ext/openssl/ossl.c | 5 +++-- version.h | 6 +++--- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index cee32095caa3f7..b03e17ebb4a31d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Fri May 2 00:19:36 2014 Nobuyoshi Nakada + + * ext/openssl/ossl.c (ossl_make_error): check NULL for unknown + error reasons with old OpenSSL, and insert a colon iff formatted + message is not empty. + Thu May 1 20:56:56 2014 Nobuyoshi Nakada * ext/readline/extconf.rb (rl_hook_func_t): check pointer type. diff --git a/ext/openssl/ossl.c b/ext/openssl/ossl.c index 3961d3ea33424c..50f1db7cf790c6 100644 --- a/ext/openssl/ossl.c +++ b/ext/openssl/ossl.c @@ -311,10 +311,11 @@ ossl_make_error(VALUE exc, const char *fmt, va_list args) else msg = ERR_reason_error_string(e); if (NIL_P(str)) { - str = rb_str_new_cstr(msg); + if (msg) str = rb_str_new_cstr(msg); } else { - rb_str_cat2(rb_str_cat2(str, ": "), msg); + if (RSTRING_LEN(str)) rb_str_cat2(str, ": "); + rb_str_cat2(str, msg ? msg : "(null)"); } } if (dOSSL == Qtrue){ /* show all errors on the stack */ diff --git a/version.h b/version.h index b033e58c7a0000..90c452302b850e 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.2" -#define RUBY_RELEASE_DATE "2014-05-01" -#define RUBY_PATCHLEVEL 82 +#define RUBY_RELEASE_DATE "2014-05-02" +#define RUBY_PATCHLEVEL 83 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 5 -#define RUBY_RELEASE_DAY 1 +#define RUBY_RELEASE_DAY 2 #include "ruby/version.h" From 71fdd26db0365546baeb8e046c4192358d8d6b2a Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 4 May 2014 15:17:10 +0000 Subject: [PATCH 083/343] merge revision(s) r45393: [Backport #9668] * gc.c: Fix up default GC params by @csfrancis [fix GH-556] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45810 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ gc.c | 2 +- version.h | 6 +++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index b03e17ebb4a31d..c1c3bee4eda003 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Mon May 5 00:16:35 2014 SHIBATA Hiroshi + + * gc.c: Fix up default GC params by @csfrancis [fix GH-556] + Fri May 2 00:19:36 2014 Nobuyoshi Nakada * ext/openssl/ossl.c (ossl_make_error): check NULL for unknown diff --git a/gc.c b/gc.c index 2762db4529a9ad..58f6701ebc0574 100644 --- a/gc.c +++ b/gc.c @@ -150,8 +150,8 @@ typedef struct { } ruby_gc_params_t; static ruby_gc_params_t gc_params = { - GC_HEAP_FREE_SLOTS, GC_HEAP_INIT_SLOTS, + GC_HEAP_FREE_SLOTS, GC_HEAP_GROWTH_FACTOR, GC_HEAP_GROWTH_MAX_SLOTS, GC_HEAP_OLDOBJECT_LIMIT_FACTOR, diff --git a/version.h b/version.h index 90c452302b850e..3418bbc6a2b335 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.2" -#define RUBY_RELEASE_DATE "2014-05-02" -#define RUBY_PATCHLEVEL 83 +#define RUBY_RELEASE_DATE "2014-05-05" +#define RUBY_PATCHLEVEL 84 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 5 -#define RUBY_RELEASE_DAY 2 +#define RUBY_RELEASE_DAY 5 #include "ruby/version.h" From 7c89c50847c6579a98e825af58bacb007ef15b55 Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 4 May 2014 15:40:57 +0000 Subject: [PATCH 084/343] merge revision(s) r45221: [Backport #9798] * ext/psych/lib/psych/visitors/yaml_tree.rb: support dumping Encoding objects. * ext/psych/lib/psych/visitors/to_ruby.rb: support loading Encoding objects. * test/psych/test_encoding.rb: add test * ext/psych/lib/psych.rb: add version git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45811 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 12 ++++++++++++ ext/psych/lib/psych.rb | 2 +- ext/psych/lib/psych/visitors/to_ruby.rb | 2 ++ ext/psych/lib/psych/visitors/yaml_tree.rb | 5 +++++ test/psych/test_encoding.rb | 5 +++++ version.h | 2 +- 6 files changed, 26 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index c1c3bee4eda003..fc0d3674b562fc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +Mon May 5 00:35:20 2014 Aaron Patterson + + * ext/psych/lib/psych/visitors/yaml_tree.rb: support dumping Encoding + objects. + + * ext/psych/lib/psych/visitors/to_ruby.rb: support loading Encoding + objects. + + * test/psych/test_encoding.rb: add test + + * ext/psych/lib/psych.rb: add version + Mon May 5 00:16:35 2014 SHIBATA Hiroshi * gc.c: Fix up default GC params by @csfrancis [fix GH-556] diff --git a/ext/psych/lib/psych.rb b/ext/psych/lib/psych.rb index 4b422f56449b38..55d68dcd512931 100644 --- a/ext/psych/lib/psych.rb +++ b/ext/psych/lib/psych.rb @@ -217,7 +217,7 @@ module Psych # The version is Psych you're using - VERSION = '2.0.3' + VERSION = '2.0.4' # The version of libyaml Psych is using LIBYAML_VERSION = Psych.libyaml_version.join '.' diff --git a/ext/psych/lib/psych/visitors/to_ruby.rb b/ext/psych/lib/psych/visitors/to_ruby.rb index 1bfffb952f1c5f..5c3baa5b68fd65 100644 --- a/ext/psych/lib/psych/visitors/to_ruby.rb +++ b/ext/psych/lib/psych/visitors/to_ruby.rb @@ -75,6 +75,8 @@ def deserialize o class_loader.date_time require 'date' @ss.parse_time(o.value).to_datetime + when '!ruby/encoding' + ::Encoding.find o.value when "!ruby/object:Complex" class_loader.complex Complex(o.value) diff --git a/ext/psych/lib/psych/visitors/yaml_tree.rb b/ext/psych/lib/psych/visitors/yaml_tree.rb index f89fcbb8f12c3e..ff0fcd204c8a45 100644 --- a/ext/psych/lib/psych/visitors/yaml_tree.rb +++ b/ext/psych/lib/psych/visitors/yaml_tree.rb @@ -157,6 +157,11 @@ def visit_Psych_Omap o @emitter.end_sequence end + def visit_Encoding o + tag = "!ruby/encoding" + @emitter.scalar o.name, nil, tag, false, false, Nodes::Scalar::ANY + end + def visit_Object o tag = Psych.dump_tags[o.class] unless tag diff --git a/test/psych/test_encoding.rb b/test/psych/test_encoding.rb index e370606c77160a..517cae20692de3 100644 --- a/test/psych/test_encoding.rb +++ b/test/psych/test_encoding.rb @@ -31,6 +31,11 @@ def setup @emitter = Psych::Emitter.new @buffer end + def test_dump_load_encoding_object + assert_cycle Encoding::US_ASCII + assert_cycle Encoding::UTF_8 + end + def test_transcode_shiftjis str = "こんにちは!" loaded = Psych.load("--- こんにちは!".encode('SHIFT_JIS')) diff --git a/version.h b/version.h index 3418bbc6a2b335..dcb7935f15f91b 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-05-05" -#define RUBY_PATCHLEVEL 84 +#define RUBY_PATCHLEVEL 85 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 5 From 1dcdd256f7c41b3e8528c8ca520623bdf26e1817 Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 4 May 2014 15:45:33 +0000 Subject: [PATCH 085/343] merge revision(s) r45453,r45455,r45577: [Backport #9798] * ext/psych/lib/psych.rb: Merge psych-2.0.5. bump version to libyaml-0.1.6 for CVE-2014-2525. * ext/psych/yaml/config.h: ditto. * ext/psych/yaml/scanner.c: ditto. * ext/psych/yaml/yaml_private.h: ditto. * ext/psych/psych.gemspec: update gemspec for psych-2.0.5 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45812 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 12 ++++++++++++ ext/psych/lib/psych.rb | 4 ++-- ext/psych/psych.gemspec | 6 +++--- ext/psych/yaml/config.h | 9 ++++----- ext/psych/yaml/scanner.c | 3 +++ ext/psych/yaml/yaml_private.h | 7 +++++-- version.h | 2 +- 7 files changed, 30 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index fc0d3674b562fc..3599ce7b6fe8a7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +Mon May 5 00:42:35 2014 SHIBATA Hiroshi + + * ext/psych/psych.gemspec: update gemspec for psych-2.0.5 + +Mon May 5 00:42:35 2014 SHIBATA Hiroshi + + * ext/psych/lib/psych.rb: Merge psych-2.0.5. bump version to + libyaml-0.1.6 for CVE-2014-2525. + * ext/psych/yaml/config.h: ditto. + * ext/psych/yaml/scanner.c: ditto. + * ext/psych/yaml/yaml_private.h: ditto. + Mon May 5 00:35:20 2014 Aaron Patterson * ext/psych/lib/psych/visitors/yaml_tree.rb: support dumping Encoding diff --git a/ext/psych/lib/psych.rb b/ext/psych/lib/psych.rb index 55d68dcd512931..329514a930a005 100644 --- a/ext/psych/lib/psych.rb +++ b/ext/psych/lib/psych.rb @@ -21,7 +21,7 @@ # # Psych is a YAML parser and emitter. # Psych leverages libyaml [Home page: http://pyyaml.org/wiki/LibYAML] -# or [Git repo: https://github.com/zerotao/libyaml] for its YAML parsing +# or [HG repo: https://bitbucket.org/xi/libyaml] for its YAML parsing # and emitting capabilities. In addition to wrapping libyaml, Psych also # knows how to serialize and de-serialize most Ruby objects to and from # the YAML format. @@ -217,7 +217,7 @@ module Psych # The version is Psych you're using - VERSION = '2.0.4' + VERSION = '2.0.5' # The version of libyaml Psych is using LIBYAML_VERSION = Psych.libyaml_version.join '.' diff --git a/ext/psych/psych.gemspec b/ext/psych/psych.gemspec index 100b6ff73720ad..6d53aef12241fb 100644 --- a/ext/psych/psych.gemspec +++ b/ext/psych/psych.gemspec @@ -2,12 +2,12 @@ Gem::Specification.new do |s| s.name = "psych" - s.version = "2.0.3" + s.version = "2.0.5" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.require_paths = ["lib"] s.authors = ["Aaron Patterson"] - s.date = "2014-02-04" + s.date = "2014-03-27" s.description = "Psych is a YAML parser and emitter. Psych leverages libyaml[http://pyyaml.org/wiki/LibYAML]\nfor its YAML parsing and emitting capabilities. In addition to wrapping\nlibyaml, Psych also knows how to serialize and de-serialize most Ruby objects\nto and from the YAML format." s.email = ["aaron@tenderlovemaking.com"] s.extensions = ["ext/psych/extconf.rb"] @@ -17,7 +17,7 @@ Gem::Specification.new do |s| s.rdoc_options = ["--main", "README.rdoc"] s.required_ruby_version = Gem::Requirement.new(">= 1.9.2") s.rubyforge_project = "psych" - s.rubygems_version = "2.2.1" + s.rubygems_version = "2.2.2" s.summary = "Psych is a YAML parser and emitter" s.test_files = ["test/psych/handlers/test_recorder.rb", "test/psych/json/test_stream.rb", "test/psych/nodes/test_enumerable.rb", "test/psych/test_alias_and_anchor.rb", "test/psych/test_array.rb", "test/psych/test_boolean.rb", "test/psych/test_class.rb", "test/psych/test_coder.rb", "test/psych/test_date_time.rb", "test/psych/test_deprecated.rb", "test/psych/test_document.rb", "test/psych/test_emitter.rb", "test/psych/test_encoding.rb", "test/psych/test_engine_manager.rb", "test/psych/test_exception.rb", "test/psych/test_hash.rb", "test/psych/test_json_tree.rb", "test/psych/test_merge_keys.rb", "test/psych/test_nil.rb", "test/psych/test_null.rb", "test/psych/test_numeric.rb", "test/psych/test_object.rb", "test/psych/test_object_references.rb", "test/psych/test_omap.rb", "test/psych/test_parser.rb", "test/psych/test_psych.rb", "test/psych/test_safe_load.rb", "test/psych/test_scalar.rb", "test/psych/test_scalar_scanner.rb", "test/psych/test_serialize_subclasses.rb", "test/psych/test_set.rb", "test/psych/test_stream.rb", "test/psych/test_string.rb", "test/psych/test_struct.rb", "test/psych/test_symbol.rb", "test/psych/test_tainted.rb", "test/psych/test_to_yaml_properties.rb", "test/psych/test_tree_builder.rb", "test/psych/test_yaml.rb", "test/psych/test_yamldbm.rb", "test/psych/test_yamlstore.rb", "test/psych/visitors/test_depth_first.rb", "test/psych/visitors/test_emitter.rb", "test/psych/visitors/test_to_ruby.rb", "test/psych/visitors/test_yaml_tree.rb"] end diff --git a/ext/psych/yaml/config.h b/ext/psych/yaml/config.h index fb62651340416d..f54c27d339e1c4 100644 --- a/ext/psych/yaml/config.h +++ b/ext/psych/yaml/config.h @@ -1,11 +1,10 @@ - #define PACKAGE_NAME "yaml" #define PACKAGE_TARNAME "yaml" -#define PACKAGE_VERSION "0.1.5" -#define PACKAGE_STRING "yaml 0.1.5" +#define PACKAGE_VERSION "0.1.6" +#define PACKAGE_STRING "yaml 0.1.6" #define PACKAGE_BUGREPORT "http://pyyaml.org/newticket?component libyaml" #define PACKAGE_URL "" #define YAML_VERSION_MAJOR 0 #define YAML_VERSION_MINOR 1 -#define YAML_VERSION_PATCH 5 -#define YAML_VERSION_STRING "0.1.5" +#define YAML_VERSION_PATCH 6 +#define YAML_VERSION_STRING "0.1.6" diff --git a/ext/psych/yaml/scanner.c b/ext/psych/yaml/scanner.c index 34308d5d4540d7..af05766f5cc7b6 100644 --- a/ext/psych/yaml/scanner.c +++ b/ext/psych/yaml/scanner.c @@ -2629,6 +2629,9 @@ yaml_parser_scan_tag_uri(yaml_parser_t *parser, int directive, /* Check if it is a URI-escape sequence. */ if (CHECK(parser->buffer, '%')) { + if (!STRING_EXTEND(parser, string)) + goto error; + if (!yaml_parser_scan_uri_escapes(parser, directive, start_mark, &string)) goto error; } diff --git a/ext/psych/yaml/yaml_private.h b/ext/psych/yaml/yaml_private.h index cd3d3a56c4b4e6..944499c94eb9dc 100644 --- a/ext/psych/yaml/yaml_private.h +++ b/ext/psych/yaml/yaml_private.h @@ -146,9 +146,12 @@ yaml_string_join( (string).start = (string).pointer = (string).end = 0) #define STRING_EXTEND(context,string) \ - (((string).pointer+5 < (string).end) \ + ((((string).pointer+5 < (string).end) \ || yaml_string_extend(&(string).start, \ - &(string).pointer, &(string).end)) + &(string).pointer, &(string).end)) ? \ + 1 : \ + ((context)->error = YAML_MEMORY_ERROR, \ + 0)) #define CLEAR(context,string) \ ((string).pointer = (string).start, \ diff --git a/version.h b/version.h index dcb7935f15f91b..1506ab1693f210 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-05-05" -#define RUBY_PATCHLEVEL 85 +#define RUBY_PATCHLEVEL 86 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 5 From efae6ae3529a7aff557acf13c9a7a51a3d60cd83 Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 4 May 2014 15:55:30 +0000 Subject: [PATCH 086/343] merge revision(s) r45015: [Backport #9657] * ext/bigdecimal/bigdecimal.c (BigDecimal_initialize): Insert GC guard. * ext/bigdecimal/bigdecimal.c (BigDecimal_global_new): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45815 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ ext/bigdecimal/bigdecimal.c | 9 +++++++-- version.h | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3599ce7b6fe8a7..0ff0224b348263 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Mon May 5 00:52:18 2014 Kenta Murata + + * ext/bigdecimal/bigdecimal.c (BigDecimal_initialize): Insert GC guard. + + * ext/bigdecimal/bigdecimal.c (BigDecimal_global_new): ditto. + Mon May 5 00:42:35 2014 SHIBATA Hiroshi * ext/psych/psych.gemspec: update gemspec for psych-2.0.5 diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c index 4120a2346dc948..6425a17db2cd7e 100644 --- a/ext/bigdecimal/bigdecimal.c +++ b/ext/bigdecimal/bigdecimal.c @@ -2456,9 +2456,11 @@ static Real *BigDecimal_new(int argc, VALUE *argv); static VALUE BigDecimal_initialize(int argc, VALUE *argv, VALUE self) { + ENTER(1); Real *pv = rb_check_typeddata(self, &BigDecimal_data_type); - Real *x = BigDecimal_new(argc, argv); + Real *x; + GUARD_OBJ(x, BigDecimal_new(argc, argv)); if (ToValue(x)) { pv = VpCopy(pv, x); } @@ -2539,7 +2541,10 @@ BigDecimal_new(int argc, VALUE *argv) static VALUE BigDecimal_global_new(int argc, VALUE *argv, VALUE self) { - Real *pv = BigDecimal_new(argc, argv); + ENTER(1); + Real *pv; + + GUARD_OBJ(pv, BigDecimal_new(argc, argv)); if (ToValue(pv)) pv = VpCopy(NULL, pv); pv->obj = TypedData_Wrap_Struct(rb_cBigDecimal, &BigDecimal_data_type, pv); return pv->obj; diff --git a/version.h b/version.h index 1506ab1693f210..fe4bbb31ffa8dc 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-05-05" -#define RUBY_PATCHLEVEL 86 +#define RUBY_PATCHLEVEL 87 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 5 From ac0f8d8045fdefd2d9a307cb5c3e8a8398542359 Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 4 May 2014 16:17:08 +0000 Subject: [PATCH 087/343] merge revision(s) r45468: [Backport #9687] * gc.c (gc_before_sweep): cap `malloc_limit' to gc_params.malloc_limit_max. It can grow and grow with such case: `loop{"a" * (1024 ** 2)}' [Bug #9687] This issue is pointed by Tim Robertson. http://www.omniref.com/blog/blog/2014/03/27/ruby-garbage-collection-still-not-ready-for-production/ git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45817 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 10 ++++++++++ gc.c | 2 +- version.h | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0ff0224b348263..89d0b4037cef52 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +Mon May 5 01:13:00 2014 Koichi Sasada + + * gc.c (gc_before_sweep): cap `malloc_limit' to + gc_params.malloc_limit_max. It can grow and grow with such case: + `loop{"a" * (1024 ** 2)}' + [Bug #9687] + + This issue is pointed by Tim Robertson. + http://www.omniref.com/blog/blog/2014/03/27/ruby-garbage-collection-still-not-ready-for-production/ + Mon May 5 00:52:18 2014 Kenta Murata * ext/bigdecimal/bigdecimal.c (BigDecimal_initialize): Insert GC guard. diff --git a/gc.c b/gc.c index 58f6701ebc0574..ebcfd425ce8863 100644 --- a/gc.c +++ b/gc.c @@ -2886,7 +2886,7 @@ gc_before_sweep(rb_objspace_t *objspace) malloc_limit = (size_t)(inc * gc_params.malloc_limit_growth_factor); if (gc_params.malloc_limit_max > 0 && /* ignore max-check if 0 */ malloc_limit > gc_params.malloc_limit_max) { - malloc_limit = inc; + malloc_limit = gc_params.malloc_limit_max; } } else { diff --git a/version.h b/version.h index fe4bbb31ffa8dc..45c012b398f664 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-05-05" -#define RUBY_PATCHLEVEL 87 +#define RUBY_PATCHLEVEL 88 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 5 From cd705d115a8d118cb6b6ab9e0b1c79573973280b Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 4 May 2014 16:26:30 +0000 Subject: [PATCH 088/343] merge revision(s) r45638: [Backport #9518] * gc.c (rb_gc_writebarrier): drop special case for big hash/array [Bug #9518] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45818 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ gc.c | 17 +++-------------- version.h | 2 +- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 89d0b4037cef52..a8631f7986ba96 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Mon May 5 01:20:27 2014 Eric Wong + + * gc.c (rb_gc_writebarrier): drop special case for big hash/array + [Bug #9518] + Mon May 5 01:13:00 2014 Koichi Sasada * gc.c (gc_before_sweep): cap `malloc_limit' to diff --git a/gc.c b/gc.c index ebcfd425ce8863..11b155607bf061 100644 --- a/gc.c +++ b/gc.c @@ -4729,20 +4729,9 @@ rb_gc_writebarrier(VALUE a, VALUE b) rb_objspace_t *objspace = &rb_objspace; if (!rgengc_remembered(objspace, a)) { - int type = BUILTIN_TYPE(a); - /* TODO: 2 << 16 is just a magic number. */ - if ((type == T_ARRAY && RARRAY_LEN(a) >= 2 << 16) || - (type == T_HASH && RHASH_SIZE(a) >= 2 << 16)) { - if (!rgengc_remembered(objspace, b)) { - rgengc_report(2, objspace, "rb_gc_wb: %p (%s) -> %p (%s)\n", (void *)a, obj_type_name(a), (void *)b, obj_type_name(b)); - rgengc_remember(objspace, b); - } - } - else { - rgengc_report(2, objspace, "rb_gc_wb: %p (%s) -> %p (%s)\n", - (void *)a, obj_type_name(a), (void *)b, obj_type_name(b)); - rgengc_remember(objspace, a); - } + rgengc_report(2, objspace, "rb_gc_wb: %p (%s) -> %p (%s)\n", + (void *)a, obj_type_name(a), (void *)b, obj_type_name(b)); + rgengc_remember(objspace, a); } } } diff --git a/version.h b/version.h index 45c012b398f664..f6c311b4f27168 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-05-05" -#define RUBY_PATCHLEVEL 88 +#define RUBY_PATCHLEVEL 89 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 5 From 647b55f64ade31427601fe0eb1d049484d656977 Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 4 May 2014 17:19:20 +0000 Subject: [PATCH 089/343] merge revision(s) r45298,r45311: [Backport #9518] test/ruby/envutil.rb: compare RSS to check memory leak * test/ruby/envutil.rb (Test::Test#assert_no_memory_leak): compare also RSS if available. * test/ruby/memory_status.rb (Memory::Status.parse): read string form of an instance. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45819 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/envutil.rb | 18 +++++++++++++----- test/ruby/memory_status.rb | 17 +++++++++++++++-- version.h | 2 +- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/test/ruby/envutil.rb b/test/ruby/envutil.rb index 079658bfbda6e2..5ebcabe9011555 100644 --- a/test/ruby/envutil.rb +++ b/test/ruby/envutil.rb @@ -373,6 +373,7 @@ def assert_warn(*args) end def assert_no_memory_leak(args, prepare, code, message=nil, limit: 1.5, **opt) + require_relative 'memory_status' token = "\e[7;1m#{$$.to_s}:#{Time.now.strftime('%s.%L')}:#{rand(0x10000).to_s(16)}:\e[m" token_dump = token.dump token_re = Regexp.quote(token) @@ -385,16 +386,23 @@ def assert_no_memory_leak(args, prepare, code, message=nil, limit: 1.5, **opt) ] args.unshift(envs) if envs cmd = [ - 'END {STDERR.puts '"#{token_dump}"'"FINAL=#{Memory::Status.new.size}"}', + 'END {STDERR.puts '"#{token_dump}"'"FINAL=#{Memory::Status.new}"}', prepare, - 'STDERR.puts('"#{token_dump}"'"START=#{$initial_size = Memory::Status.new.size}")', + 'STDERR.puts('"#{token_dump}"'"START=#{$initial_status = Memory::Status.new}")', + '$initial_size = $initial_status.size', code, + 'GC.start', ].join("\n") _, err, status = EnvUtil.invoke_ruby(args, cmd, true, true, **opt) - before = err.sub!(/^#{token_re}START=(\d+)\n/, '') && $1.to_i - after = err.sub!(/^#{token_re}FINAL=(\d+)\n/, '') && $1.to_i + before = err.sub!(/^#{token_re}START=(\{.*\})\n/, '') && Memory::Status.parse($1) + after = err.sub!(/^#{token_re}FINAL=(\{.*\})\n/, '') && Memory::Status.parse($1) assert_equal([true, ""], [status.success?, err], message) - assert_operator(after.fdiv(before), :<, limit, message) + ([:size, :rss] & after.members).each do |n| + b = before[n] + a = after[n] + next unless a > 0 and b > 0 + assert_operator(a.fdiv(b), :<, limit, message(message) {"#{n}: #{b} => #{a}"}) + end end def assert_is_minus_zero(f) diff --git a/test/ruby/memory_status.rb b/test/ruby/memory_status.rb index cb2e9e094c030b..bfbfbd6e880b06 100644 --- a/test/ruby/memory_status.rb +++ b/test/ruby/memory_status.rb @@ -1,5 +1,3 @@ -require_relative "envutil" - module Memory keys = [] vals = [] @@ -110,5 +108,20 @@ class Status def initialize _update end + + def to_s + status = each_pair.map {|n,v| + "#{n}:#{v}" + } + "{#{status.join(",")}}" + end + + def self.parse(str) + status = allocate + str.scan(/(?:\A\{|\G,)(#{members.join('|')}):(\d+)(?=,|\}\z)/) do + status[$1] = $2.to_i + end + status + end end end diff --git a/version.h b/version.h index f6c311b4f27168..43ad9c2507ddf2 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-05-05" -#define RUBY_PATCHLEVEL 89 +#define RUBY_PATCHLEVEL 90 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 5 From acd893d1755cc87542f36131f40c9c3f0aa5bc04 Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 4 May 2014 17:32:44 +0000 Subject: [PATCH 090/343] merge revision(s) r45291,r45299,r45314,r45325: [Backport #9518] * ext/dl/cptr.c (dlptr_free), ext/dl/handle.c (dlhandle_free), ext/fiddle/handle.c (fiddle_handle_free), ext/fiddle/pointer.c (fiddle_ptr_free): fix memory leak. based on the patch Heesob Park at [ruby-dev:48021] [Bug #9599]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45820 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ ext/dl/cptr.c | 1 + ext/dl/handle.c | 1 + ext/fiddle/handle.c | 1 + ext/fiddle/pointer.c | 1 + test/dl/test_cptr.rb | 4 ++++ test/dl/test_handle.rb | 4 ++++ test/fiddle/test_handle.rb | 7 +++++++ test/fiddle/test_pointer.rb | 4 ++++ test/ruby/envutil.rb | 4 ++-- version.h | 2 +- 11 files changed, 33 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index a8631f7986ba96..61817c79f37f10 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Mon May 5 02:21:48 2014 Nobuyoshi Nakada + + * ext/dl/cptr.c (dlptr_free), ext/dl/handle.c (dlhandle_free), + ext/fiddle/handle.c (fiddle_handle_free), + ext/fiddle/pointer.c (fiddle_ptr_free): fix memory leak. + based on the patch Heesob Park at [ruby-dev:48021] [Bug #9599]. + Mon May 5 01:20:27 2014 Eric Wong * gc.c (rb_gc_writebarrier): drop special case for big hash/array diff --git a/ext/dl/cptr.c b/ext/dl/cptr.c index 3f8858c4b37c2e..d34309379bbf58 100644 --- a/ext/dl/cptr.c +++ b/ext/dl/cptr.c @@ -49,6 +49,7 @@ dlptr_free(void *ptr) (*(data->free))(data->ptr); } } + xfree(ptr); } static size_t diff --git a/ext/dl/handle.c b/ext/dl/handle.c index ef182e816fc971..6b90e089eef82d 100644 --- a/ext/dl/handle.c +++ b/ext/dl/handle.c @@ -38,6 +38,7 @@ dlhandle_free(void *ptr) if( dlhandle->ptr && dlhandle->open && dlhandle->enable_close ){ dlclose(dlhandle->ptr); } + xfree(ptr); } static size_t diff --git a/ext/fiddle/handle.c b/ext/fiddle/handle.c index 330dbafe67cf03..36970a22486781 100644 --- a/ext/fiddle/handle.c +++ b/ext/fiddle/handle.c @@ -40,6 +40,7 @@ fiddle_handle_free(void *ptr) if( fiddle_handle->ptr && fiddle_handle->open && fiddle_handle->enable_close ){ dlclose(fiddle_handle->ptr); } + xfree(ptr); } static size_t diff --git a/ext/fiddle/pointer.c b/ext/fiddle/pointer.c index 0129363a8df2de..b763a0c12372b6 100644 --- a/ext/fiddle/pointer.c +++ b/ext/fiddle/pointer.c @@ -56,6 +56,7 @@ fiddle_ptr_free(void *ptr) (*(data->free))(data->ptr); } } + xfree(ptr); } static size_t diff --git a/test/dl/test_cptr.rb b/test/dl/test_cptr.rb index c3793859d714a0..aa74a73fe54fb2 100644 --- a/test/dl/test_cptr.rb +++ b/test/dl/test_cptr.rb @@ -219,4 +219,8 @@ def test_null_pointer assert_raise(DLError) {nullpo[0] = 1} end end + + def test_no_memory_leak + assert_no_memory_leak(%w[-W0 -rdl.so], '', '100_000.times {DL::CPtr.allocate}', rss: true) + end end diff --git a/test/dl/test_handle.rb b/test/dl/test_handle.rb index 83b8af196041f9..6a8964e9a0aebc 100644 --- a/test/dl/test_handle.rb +++ b/test/dl/test_handle.rb @@ -184,4 +184,8 @@ def test_dlerror DL.dlopen("/lib/libc.so.7").sym('strcpy') end if /freebsd/=~ RUBY_PLATFORM end + + def test_no_memory_leak + assert_no_memory_leak(%w[-W0 -rdl.so], '', '100_000.times {DL::Handle.allocate}; GC.start', rss: true) + end end diff --git a/test/fiddle/test_handle.rb b/test/fiddle/test_handle.rb index c598cc33a2cb09..cde3fa816dcef9 100644 --- a/test/fiddle/test_handle.rb +++ b/test/fiddle/test_handle.rb @@ -1,5 +1,6 @@ begin require_relative 'helper' + require_relative '../ruby/envutil' rescue LoadError end @@ -7,6 +8,8 @@ module Fiddle class TestHandle < TestCase include Fiddle + include Test::Unit::Assertions + def test_to_i handle = Fiddle::Handle.new(LIBC_SO) assert_kind_of Integer, handle.to_i @@ -185,5 +188,9 @@ def test_dlerror Socket.gethostbyname("localhost") Fiddle.dlopen("/lib/libc.so.7").sym('strcpy') end if /freebsd/=~ RUBY_PLATFORM + + def test_no_memory_leak + assert_no_memory_leak(%w[-W0 -rfiddle.so], '', '100_000.times {Fiddle::Handle.allocate}; GC.start', rss: true) + end end end if defined?(Fiddle) diff --git a/test/fiddle/test_pointer.rb b/test/fiddle/test_pointer.rb index 1d908f64d9a61b..2ba11b4ed7c808 100644 --- a/test/fiddle/test_pointer.rb +++ b/test/fiddle/test_pointer.rb @@ -230,5 +230,9 @@ def test_null_pointer assert_raise(DLError) {nullpo[0]} assert_raise(DLError) {nullpo[0] = 1} end + + def test_no_memory_leak + assert_no_memory_leak(%w[-W0 -rfiddle.so], '', '100_000.times {Fiddle::Pointer.allocate}', rss: true) + end end end if defined?(Fiddle) diff --git a/test/ruby/envutil.rb b/test/ruby/envutil.rb index 5ebcabe9011555..de66102621cebd 100644 --- a/test/ruby/envutil.rb +++ b/test/ruby/envutil.rb @@ -372,7 +372,7 @@ def assert_warn(*args) assert_warning(*args) {$VERBOSE = false; yield} end - def assert_no_memory_leak(args, prepare, code, message=nil, limit: 1.5, **opt) + def assert_no_memory_leak(args, prepare, code, message=nil, limit: 1.5, rss: false, **opt) require_relative 'memory_status' token = "\e[7;1m#{$$.to_s}:#{Time.now.strftime('%s.%L')}:#{rand(0x10000).to_s(16)}:\e[m" token_dump = token.dump @@ -397,7 +397,7 @@ def assert_no_memory_leak(args, prepare, code, message=nil, limit: 1.5, **opt) before = err.sub!(/^#{token_re}START=(\{.*\})\n/, '') && Memory::Status.parse($1) after = err.sub!(/^#{token_re}FINAL=(\{.*\})\n/, '') && Memory::Status.parse($1) assert_equal([true, ""], [status.success?, err], message) - ([:size, :rss] & after.members).each do |n| + ([:size, (rss && :rss)] & after.members).each do |n| b = before[n] a = after[n] next unless a > 0 and b > 0 diff --git a/version.h b/version.h index 43ad9c2507ddf2..91c96cafa6b0ed 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-05-05" -#define RUBY_PATCHLEVEL 90 +#define RUBY_PATCHLEVEL 91 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 5 From 01cf2127bd3b3ec3be64a10991d6b3287d60a162 Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 4 May 2014 17:44:00 +0000 Subject: [PATCH 091/343] merge revision(s) r45595: [Backport #9743] [Backport #9745] * ext/openssl/ossl_pkey.c (ossl_pkey_verify): as EVP_VerifyFinal() finalizes only a copy of the digest context, the context must be cleaned up after initialization by EVP_MD_CTX_cleanup() or a memory leak will occur. [ruby-core:62038] [Bug #9743] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45821 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ ext/openssl/ossl_pkey.c | 7 +++++-- test/openssl/test_pkey_rsa.rb | 30 ++++++++++++++++++++++++++++++ version.h | 2 +- 4 files changed, 43 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 61817c79f37f10..837c087c65f5ae 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Mon May 5 02:35:20 2014 Nobuyoshi Nakada + + * ext/openssl/ossl_pkey.c (ossl_pkey_verify): as EVP_VerifyFinal() + finalizes only a copy of the digest context, the context must be + cleaned up after initialization by EVP_MD_CTX_cleanup() or a + memory leak will occur. [ruby-core:62038] [Bug #9743] + Mon May 5 02:21:48 2014 Nobuyoshi Nakada * ext/dl/cptr.c (dlptr_free), ext/dl/handle.c (dlhandle_free), diff --git a/ext/openssl/ossl_pkey.c b/ext/openssl/ossl_pkey.c index 0004d9d9b5e941..878b221270afd5 100644 --- a/ext/openssl/ossl_pkey.c +++ b/ext/openssl/ossl_pkey.c @@ -318,13 +318,16 @@ ossl_pkey_verify(VALUE self, VALUE digest, VALUE sig, VALUE data) { EVP_PKEY *pkey; EVP_MD_CTX ctx; + int result; GetPKey(self, pkey); - EVP_VerifyInit(&ctx, GetDigestPtr(digest)); StringValue(sig); StringValue(data); + EVP_VerifyInit(&ctx, GetDigestPtr(digest)); EVP_VerifyUpdate(&ctx, RSTRING_PTR(data), RSTRING_LEN(data)); - switch (EVP_VerifyFinal(&ctx, (unsigned char *)RSTRING_PTR(sig), RSTRING_LENINT(sig), pkey)) { + result = EVP_VerifyFinal(&ctx, (unsigned char *)RSTRING_PTR(sig), RSTRING_LENINT(sig), pkey); + EVP_MD_CTX_cleanup(&ctx); + switch (result) { case 0: return Qfalse; case 1: diff --git a/test/openssl/test_pkey_rsa.rb b/test/openssl/test_pkey_rsa.rb index 1881525c02e900..ce9bd60c2f1519 100644 --- a/test/openssl/test_pkey_rsa.rb +++ b/test/openssl/test_pkey_rsa.rb @@ -75,6 +75,36 @@ def test_sign_verify assert(key.verify(digest, sig, data)) end + def test_sign_verify_memory_leak + bug9743 = '[ruby-core:62038] [Bug #9743]' + assert_no_memory_leak(%w[-ropenssl], <<-PREP, <<-CODE, bug9743, rss: true) + data = 'Sign me!' + digest = OpenSSL::Digest::SHA512.new + pkey = OpenSSL::PKey::RSA.new(2048) + signature = pkey.sign(digest, data) + pub_key = pkey.public_key + PREP + 20_000.times { + pub_key.verify(digest, signature, data) + } + CODE + + assert_no_memory_leak(%w[-ropenssl], <<-PREP, <<-CODE, bug9743, rss: true) + data = 'Sign me!' + digest = OpenSSL::Digest::SHA512.new + pkey = OpenSSL::PKey::RSA.new(2048) + signature = pkey.sign(digest, data) + pub_key = pkey.public_key + PREP + 20_000.times { + begin + pub_key.verify(digest, signature, 1) + rescue TypeError + end + } + CODE + end + def test_digest_state_irrelevant_sign key = OpenSSL::TestUtils::TEST_KEY_RSA1024 digest1 = OpenSSL::Digest::SHA1.new diff --git a/version.h b/version.h index 91c96cafa6b0ed..17a7f7a8e28b52 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-05-05" -#define RUBY_PATCHLEVEL 91 +#define RUBY_PATCHLEVEL 92 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 5 From de94db5d61dddfada92dd07a2c1885d79c74e751 Mon Sep 17 00:00:00 2001 From: nagachika Date: Mon, 5 May 2014 16:16:48 +0000 Subject: [PATCH 092/343] merge revision(s) r45760: [Backport #9796] * gc.c (gc_after_sweep): suppress unnecessary expanding heap. Tomb heap pages are freed pages here, so expanding heap is not required. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45833 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ gc.c | 1 - version.h | 6 +++--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 837c087c65f5ae..603eac564aba86 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Tue May 6 00:54:56 2014 Narihiro Nakamura + + * gc.c (gc_after_sweep): suppress unnecessary expanding heap. + Tomb heap pages are freed pages here, so expanding heap is + not required. + Mon May 5 02:35:20 2014 Nobuyoshi Nakada * ext/openssl/ossl_pkey.c (ossl_pkey_verify): as EVP_VerifyFinal() diff --git a/gc.c b/gc.c index 11b155607bf061..7812d921bfe35c 100644 --- a/gc.c +++ b/gc.c @@ -2972,7 +2972,6 @@ gc_after_sweep(rb_objspace_t *objspace) /* if heap_pages has unused pages, then assign them to increment */ if (heap_pages_increment < heap_tomb->page_length) { heap_pages_increment = heap_tomb->page_length; - heap_pages_expand_sorted(objspace); } #if RGENGC_PROFILE > 0 diff --git a/version.h b/version.h index 17a7f7a8e28b52..a5e4c2bff76211 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.2" -#define RUBY_RELEASE_DATE "2014-05-05" -#define RUBY_PATCHLEVEL 92 +#define RUBY_RELEASE_DATE "2014-05-06" +#define RUBY_PATCHLEVEL 93 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 5 -#define RUBY_RELEASE_DAY 5 +#define RUBY_RELEASE_DAY 6 #include "ruby/version.h" From b494603551d1a6c8fbc56ba90a35451e84af4d2e Mon Sep 17 00:00:00 2001 From: nagachika Date: Wed, 7 May 2014 15:49:11 +0000 Subject: [PATCH 093/343] merge revision(s) r44619: test_gc.rb: relax assertion * test/ruby/test_gc.rb (test_profiler_total_time): GC time may be shorter than the timer resolution. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45866 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_gc.rb | 2 +- version.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/ruby/test_gc.rb b/test/ruby/test_gc.rb index c644aa5d9a2e81..402d560bff8b9c 100644 --- a/test/ruby/test_gc.rb +++ b/test/ruby/test_gc.rb @@ -244,7 +244,7 @@ def test_profiler_total_time GC::Profiler.clear GC.start - assert_operator(GC::Profiler.total_time, :>, 0) + assert_operator(GC::Profiler.total_time, :>=, 0) ensure GC::Profiler.disable end diff --git a/version.h b/version.h index a5e4c2bff76211..3e43f5d2098372 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.2" -#define RUBY_RELEASE_DATE "2014-05-06" -#define RUBY_PATCHLEVEL 93 +#define RUBY_RELEASE_DATE "2014-05-08" +#define RUBY_PATCHLEVEL 94 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 5 -#define RUBY_RELEASE_DAY 6 +#define RUBY_RELEASE_DAY 8 #include "ruby/version.h" From 65b76d92a4792b5960967b63f4c85dc6859bb807 Mon Sep 17 00:00:00 2001 From: nagachika Date: Wed, 7 May 2014 16:21:02 +0000 Subject: [PATCH 094/343] merge revision(s) r45190,r45202,r45204,r45713: [Backport #9586] configure.in: define SET_THREAD_NAME * configure.in (SET_THREAD_NAME): define according to pthread_setname_np variations. * configure.in: correct pthread_setname_np's prototype on NetBSD. [Bug #9586] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45867 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ configure.in | 30 ++++++++++++++++++++++++++++++ thread_pthread.c | 6 ++---- version.h | 2 +- 4 files changed, 38 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 603eac564aba86..1d4751abf476da 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Thu May 8 01:13:10 2014 NARUSE, Yui + + * configure.in: correct pthread_setname_np's prototype on NetBSD. + [Bug #9586] + Tue May 6 00:54:56 2014 Narihiro Nakamura * gc.c (gc_after_sweep): suppress unnecessary expanding heap. diff --git a/configure.in b/configure.in index 17ed3edea3d2e8..1a001e62530db7 100644 --- a/configure.in +++ b/configure.in @@ -2454,6 +2454,36 @@ if test x"$enable_pthread" = xyes; then else AC_CHECK_FUNCS(pthread_attr_init) fi + if test "$ac_cv_func_pthread_setname_np" = yes; then + AC_CACHE_CHECK([arguments of pthread_setname_np], [rb_cv_func_pthread_setname_np_arguments], + [rb_cv_func_pthread_setname_np_arguments= + # Linux,AIX, (pthread_self(), name) + # NetBSD (pthread_self(), name, \"%s\") + # Darwin (name) + for mac in \ + "(pthread_self(), name)" \ + "(pthread_self(), name, \"%s\")" \ + "(name)" \ + ; do + AC_TRY_COMPILE([ + @%:@include + @%:@ifdef HAVE_PTHREAD_NP_H + @%:@include + @%:@endif + @%:@define SET_THREAD_NAME(name) pthread_setname_np${mac} + ], + [if (SET_THREAD_NAME("conftest")) return 1;], + [rb_cv_func_pthread_setname_np_arguments="${mac}" + break]) + done + ] + ) + if test -n "${rb_cv_func_pthread_setname_np_arguments}"; then + AC_DEFINE_UNQUOTED(SET_THREAD_NAME(name), pthread_setname_np${rb_cv_func_pthread_setname_np_arguments}) + else + AC_DEFINE_UNQUOTED(SET_THREAD_NAME(name), (void)0) + fi + fi fi if test x"$ac_cv_header_ucontext_h" = xyes; then if test x"$rb_with_pthread" = xyes; then diff --git a/thread_pthread.c b/thread_pthread.c index aa8962a315fc5f..aa2c49e949ab9d 100644 --- a/thread_pthread.c +++ b/thread_pthread.c @@ -1422,11 +1422,9 @@ timer_thread_sleep(rb_global_vm_lock_t* unused) #endif /* USE_SLEEPY_TIMER_THREAD */ #if defined(__linux__) && defined(PR_SET_NAME) +# undef SET_THREAD_NAME # define SET_THREAD_NAME(name) prctl(PR_SET_NAME, name) -#elif defined(HAVE_PTHREAD_SETNAME_NP) -/* pthread_setname_np() on Darwin does not have target thread argument */ -# define SET_THREAD_NAME(name) pthread_setname_np(name) -#else +#elif !defined(SET_THREAD_NAME) # define SET_THREAD_NAME(name) (void)0 #endif diff --git a/version.h b/version.h index 3e43f5d2098372..a6b86f57e0fea7 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-05-08" -#define RUBY_PATCHLEVEL 94 +#define RUBY_PATCHLEVEL 95 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 5 From 4b1eca7ea0f9eb1ca527ffe79da924e454d4d55f Mon Sep 17 00:00:00 2001 From: nagachika Date: Sat, 10 May 2014 14:25:23 +0000 Subject: [PATCH 095/343] merge revision(s) r45891,r45893,r45895: test_beginendblock.rb, test_signal.rb: run with default handler * test/ruby/test_beginendblock.rb (test_propagate_signaled): run with default handler. * test/ruby/test_signal.rb (test_hup_me): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45905 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_beginendblock.rb | 1 + test/ruby/test_signal.rb | 3 +++ test/ruby/test_thread.rb | 4 +++- version.h | 6 +++--- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/test/ruby/test_beginendblock.rb b/test/ruby/test_beginendblock.rb index 30db5024cc1c89..d9c1f569164297 100644 --- a/test/ruby/test_beginendblock.rb +++ b/test/ruby/test_beginendblock.rb @@ -112,6 +112,7 @@ def test_propagate_signaled ruby = EnvUtil.rubybin out = IO.popen( [ruby, + '-e', 'trap(:INT, "DEFAULT")', '-e', 'STDERR.reopen(STDOUT)', '-e', 'at_exit{Process.kill(:INT, $$); sleep 5 }']) {|f| timeout(10) { diff --git a/test/ruby/test_signal.rb b/test/ruby/test_signal.rb index c7bcc4a375a745..60b886cec9a998 100644 --- a/test/ruby/test_signal.rb +++ b/test/ruby/test_signal.rb @@ -255,9 +255,12 @@ def test_hup_me # that signal will be deliverd synchronously. # This ugly workaround was introduced to don't break # compatibility against silly example codes. + assert_separately([], <<-RUBY) + trap(:HUP, "DEFAULT") assert_raise(SignalException) { Process.kill('HUP', Process.pid) } + RUBY bug8137 = '[ruby-dev:47182] [Bug #8137]' assert_nothing_raised(bug8137) { Timeout.timeout(1) { diff --git a/test/ruby/test_thread.rb b/test/ruby/test_thread.rb index fedab8791ead49..cd84c125bc2a6d 100644 --- a/test/ruby/test_thread.rb +++ b/test/ruby/test_thread.rb @@ -726,7 +726,7 @@ def test_thread_timer_and_interrupt bug5757 = '[ruby-dev:44985]' t0 = Time.now.to_f pid = nil - cmd = 'r,=IO.pipe; Thread.start {Thread.pass until Thread.main.stop?; puts; STDOUT.flush}; r.read' + cmd = 'Signal.trap(:INT, "DEFAULT"); r,=IO.pipe; Thread.start {Thread.pass until Thread.main.stop?; puts; STDOUT.flush}; r.read' opt = {} opt[:new_pgroup] = true if /mswin|mingw/ =~ RUBY_PLATFORM s, _err = EnvUtil.invoke_ruby(['-e', cmd], "", true, true, opt) do |in_p, out_p, err_p, cpid| @@ -746,6 +746,7 @@ def test_thread_timer_and_interrupt def test_thread_join_in_trap assert_separately [], <<-'EOS' + Signal.trap(:INT, "DEFAULT") t0 = Thread.current assert_nothing_raised{ t = Thread.new {Thread.pass until t0.stop?; Process.kill(:INT, $$)} @@ -761,6 +762,7 @@ def test_thread_join_in_trap def test_thread_value_in_trap assert_separately [], <<-'EOS' + Signal.trap(:INT, "DEFAULT") t0 = Thread.current t = Thread.new {Thread.pass until t0.stop?; Process.kill(:INT, $$); :normal_end} diff --git a/version.h b/version.h index a6b86f57e0fea7..2967d547867db0 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.2" -#define RUBY_RELEASE_DATE "2014-05-08" -#define RUBY_PATCHLEVEL 95 +#define RUBY_RELEASE_DATE "2014-05-10" +#define RUBY_PATCHLEVEL 96 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 5 -#define RUBY_RELEASE_DAY 8 +#define RUBY_RELEASE_DAY 10 #include "ruby/version.h" From 78358a72be1ba095a62f287ac376795f8fec78b2 Mon Sep 17 00:00:00 2001 From: nagachika Date: Sat, 10 May 2014 15:01:24 +0000 Subject: [PATCH 096/343] merge revision(s) r45901: envutil.rb: successfully terminated process * test/ruby/envutil.rb (FailDesc): allow successfully terminated process without a signal. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45908 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/envutil.rb | 7 ++++--- version.h | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/test/ruby/envutil.rb b/test/ruby/envutil.rb index de66102621cebd..dc136918e9cd27 100644 --- a/test/ruby/envutil.rb +++ b/test/ruby/envutil.rb @@ -251,9 +251,10 @@ def assert_normal_exit(testsrc, message = '', child_env: nil, **opt) pid = status.pid now = Time.now faildesc = proc do - signo = status.termsig - signame = Signal.signame(signo) - sigdesc = "signal #{signo}" + if signo = status.termsig + signame = Signal.signame(signo) + sigdesc = "signal #{signo}" + end log = EnvUtil.diagnostic_reports(signame, EnvUtil.rubybin, pid, now) if signame sigdesc = "SIG#{signame} (#{sigdesc})" diff --git a/version.h b/version.h index 2967d547867db0..e25f1fbdfa13d9 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.2" -#define RUBY_RELEASE_DATE "2014-05-10" -#define RUBY_PATCHLEVEL 96 +#define RUBY_RELEASE_DATE "2014-05-11" +#define RUBY_PATCHLEVEL 97 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 5 -#define RUBY_RELEASE_DAY 10 +#define RUBY_RELEASE_DAY 11 #include "ruby/version.h" From 3cbfd63479e0a3f4d49ad60c0b7c7000cd3f3c4f Mon Sep 17 00:00:00 2001 From: nagachika Date: Mon, 12 May 2014 13:18:13 +0000 Subject: [PATCH 097/343] merge revision(s) r45360,r45361: [Backport #9651] * vm_eval.c (eval_string_with_cref): Use file path even if scope is given. Related to [ruby-core:56099] [Bug #8662] and r42103. * vm_eval.c (eval_string_with_cref): Unify to use NIL_P. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45927 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 9 +++++++++ test/ruby/test_method.rb | 1 + version.h | 6 +++--- vm_eval.c | 9 +++++---- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1d4751abf476da..a73f739cd26033 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Mon May 12 22:11:47 2014 Shota Fukumori + + * vm_eval.c (eval_string_with_cref): Unify to use NIL_P. + +Mon May 12 22:11:47 2014 Shota Fukumori + + * vm_eval.c (eval_string_with_cref): Use file path even if scope is + given. Related to [ruby-core:56099] [Bug #8662] and r42103. + Thu May 8 01:13:10 2014 NARUSE, Yui * configure.in: correct pthread_setname_np's prototype on NetBSD. diff --git a/test/ruby/test_method.rb b/test/ruby/test_method.rb index 2e3c2ae8b07317..f478e114867663 100644 --- a/test/ruby/test_method.rb +++ b/test/ruby/test_method.rb @@ -660,6 +660,7 @@ def test___dir__ assert_equal(__dir__, eval("__dir__", binding), bug8436) bug8662 = '[ruby-core:56099] [Bug #8662]' assert_equal("arbitrary", eval("__dir__", binding, "arbitrary/file.rb"), bug8662) + assert_equal("arbitrary", Object.new.instance_eval("__dir__", "arbitrary/file.rb"), bug8662) end def test_alias_owner diff --git a/version.h b/version.h index e25f1fbdfa13d9..576a550a88b676 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.2" -#define RUBY_RELEASE_DATE "2014-05-11" -#define RUBY_PATCHLEVEL 97 +#define RUBY_RELEASE_DATE "2014-05-12" +#define RUBY_PATCHLEVEL 98 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 5 -#define RUBY_RELEASE_DAY 11 +#define RUBY_RELEASE_DAY 12 #include "ruby/version.h" diff --git a/vm_eval.c b/vm_eval.c index c7d6f7331399ce..7382b198a7de5f 100644 --- a/vm_eval.c +++ b/vm_eval.c @@ -1218,14 +1218,15 @@ eval_string_with_cref(VALUE self, VALUE src, VALUE scope, NODE *const cref_arg, VALUE absolute_path = Qnil; VALUE fname; + if (file != Qundef) { + absolute_path = file; + } + if (scope != Qnil) { bind = Check_TypedStruct(scope, &ruby_binding_data_type); { envval = bind->env; - if (file != Qundef) { - absolute_path = file; - } - else if (!NIL_P(bind->path)) { + if (NIL_P(absolute_path) && !NIL_P(bind->path)) { file = bind->path; line = bind->first_lineno; absolute_path = rb_current_realfilepath(); From 86f8f5d94e484745b4e406d5410168e7d131d92c Mon Sep 17 00:00:00 2001 From: nagachika Date: Mon, 12 May 2014 13:49:33 +0000 Subject: [PATCH 098/343] merge revision(s) r45758,r45759: [Backport #9759] * vm.c (invoke_block_from_c): add VM_FRAME_FLAG_BMETHOD to record it is bmethod frame. * vm.c (vm_exec): invoke RUBY_EVENT_RETURN event if rollbacked frame is VM_FRAME_FLAG_BMETHOD. [Bug #9759] * test/ruby/test_settracefunc.rb: add a test for TracePoint/set_trace_func. * vm_core.h: rename rb_thread_t::passed_me to rb_thread_t::passed_bmethod_me to clarify the usage. * vm_insnhelper.c (vm_call_bmethod_body): use renamed member. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45928 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 16 ++++++++++++++++ test/ruby/test_settracefunc.rb | 34 ++++++++++++++++++++++++++++++++++ version.h | 2 +- vm.c | 33 +++++++++++++++++++++++++-------- vm_core.h | 10 ++++++---- vm_insnhelper.c | 2 +- 6 files changed, 83 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index a73f739cd26033..0d64bd143e1ac6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +Mon May 12 22:22:43 2014 Koichi Sasada + + * vm.c (invoke_block_from_c): add VM_FRAME_FLAG_BMETHOD to record + it is bmethod frame. + + * vm.c (vm_exec): invoke RUBY_EVENT_RETURN event if rollbacked frame + is VM_FRAME_FLAG_BMETHOD. + [Bug #9759] + + * test/ruby/test_settracefunc.rb: add a test for TracePoint/set_trace_func. + + * vm_core.h: rename rb_thread_t::passed_me to + rb_thread_t::passed_bmethod_me to clarify the usage. + + * vm_insnhelper.c (vm_call_bmethod_body): use renamed member. + Mon May 12 22:11:47 2014 Shota Fukumori * vm_eval.c (eval_string_with_cref): Unify to use NIL_P. diff --git a/test/ruby/test_settracefunc.rb b/test/ruby/test_settracefunc.rb index b106ea5494315c..1fca312c76b893 100644 --- a/test/ruby/test_settracefunc.rb +++ b/test/ruby/test_settracefunc.rb @@ -1066,4 +1066,38 @@ def test_a_return :b_return ], events) end + class C9759 + define_method(:foo){ + raise + } + end + + def test_define_method_on_exception + events = [] + obj = C9759.new + TracePoint.new(:call, :return){|tp| + next unless target_thread? + events << [tp.event, tp.method_id] + }.enable{ + obj.foo rescue nil + } + assert_equal([[:call, :foo], [:return, :foo]], events, 'Bug #9759') + + events = [] + begin + set_trace_func(lambda{|event, file, lineno, mid, binding, klass| + next unless target_thread? + case event + when 'call', 'return' + events << [event, mid] + end + }) + obj.foo rescue nil + set_trace_func(nil) + + assert_equal([['call', :foo], ['return', :foo]], events, 'Bug #9759') + ensure + end + + end end diff --git a/version.h b/version.h index 576a550a88b676..1b6ce0375f1c4b 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-05-12" -#define RUBY_PATCHLEVEL 98 +#define RUBY_PATCHLEVEL 99 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 5 diff --git a/vm.c b/vm.c index 947b1811e500ac..8e40b9f4a69ea2 100644 --- a/vm.c +++ b/vm.c @@ -717,13 +717,24 @@ invoke_block_from_c(rb_thread_t *th, const rb_block_t *block, opt_pc = vm_yield_setup_args(th, iseq, argc, cfp->sp, blockptr, type == VM_FRAME_MAGIC_LAMBDA); - vm_push_frame(th, iseq, type | VM_FRAME_FLAG_FINISH, - self, defined_class, - VM_ENVVAL_PREV_EP_PTR(block->ep), - iseq->iseq_encoded + opt_pc, - cfp->sp + arg_size, iseq->local_size - arg_size, - th->passed_me, iseq->stack_max); - th->passed_me = 0; + if (th->passed_bmethod_me != 0) { + /* bmethod */ + vm_push_frame(th, iseq, type | VM_FRAME_FLAG_FINISH | VM_FRAME_FLAG_BMETHOD, + self, defined_class, + VM_ENVVAL_PREV_EP_PTR(block->ep), + iseq->iseq_encoded + opt_pc, + cfp->sp + arg_size, iseq->local_size - arg_size, + th->passed_bmethod_me, iseq->stack_max); + th->passed_bmethod_me = 0; + } + else { + vm_push_frame(th, iseq, type | VM_FRAME_FLAG_FINISH, + self, defined_class, + VM_ENVVAL_PREV_EP_PTR(block->ep), + iseq->iseq_encoded + opt_pc, + cfp->sp + arg_size, iseq->local_size - arg_size, + 0, iseq->stack_max); + } if (cref) { th->cfp->ep[-1] = (VALUE)cref; @@ -1512,7 +1523,13 @@ vm_exec(rb_thread_t *th) break; case VM_FRAME_MAGIC_BLOCK: case VM_FRAME_MAGIC_LAMBDA: - EXEC_EVENT_HOOK_AND_POP_FRAME(th, RUBY_EVENT_B_RETURN, th->cfp->self, 0, 0, Qnil); + if (VM_FRAME_TYPE_BMETHOD_P(th->cfp)) { + EXEC_EVENT_HOOK(th, RUBY_EVENT_B_RETURN, th->cfp->self, 0, 0, Qnil); + EXEC_EVENT_HOOK_AND_POP_FRAME(th, RUBY_EVENT_RETURN, th->cfp->self, th->cfp->me->called_id, th->cfp->me->klass, Qnil); + } + else { + EXEC_EVENT_HOOK_AND_POP_FRAME(th, RUBY_EVENT_B_RETURN, th->cfp->self, 0, 0, Qnil); + } break; case VM_FRAME_MAGIC_CLASS: EXEC_EVENT_HOOK_AND_POP_FRAME(th, RUBY_EVENT_END, th->cfp->self, 0, 0, Qnil); diff --git a/vm_core.h b/vm_core.h index 08a09da61029e0..befdbfdc26ec7c 100644 --- a/vm_core.h +++ b/vm_core.h @@ -542,7 +542,7 @@ typedef struct rb_thread_struct { const rb_block_t *passed_block; /* for bmethod */ - const rb_method_entry_t *passed_me; + const rb_method_entry_t *passed_bmethod_me; /* for cfunc */ rb_call_info_t *passed_ci; @@ -768,9 +768,11 @@ enum vm_special_object_type { #define VM_FRAME_TYPE(cfp) ((cfp)->flag & VM_FRAME_MAGIC_MASK) /* other frame flag */ -#define VM_FRAME_FLAG_PASSED 0x0100 -#define VM_FRAME_FLAG_FINISH 0x0200 -#define VM_FRAME_TYPE_FINISH_P(cfp) (((cfp)->flag & VM_FRAME_FLAG_FINISH) != 0) +#define VM_FRAME_FLAG_PASSED 0x0100 +#define VM_FRAME_FLAG_FINISH 0x0200 +#define VM_FRAME_FLAG_BMETHOD 0x0400 +#define VM_FRAME_TYPE_FINISH_P(cfp) (((cfp)->flag & VM_FRAME_FLAG_FINISH) != 0) +#define VM_FRAME_TYPE_BMETHOD_P(cfp) (((cfp)->flag & VM_FRAME_FLAG_BMETHOD) != 0) #define RUBYVM_CFUNC_FRAME_P(cfp) \ (VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_CFUNC) diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 1228b3f4df6976..55c051542566cd 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -1587,7 +1587,7 @@ vm_call_bmethod_body(rb_thread_t *th, rb_call_info_t *ci, const VALUE *argv) EXEC_EVENT_HOOK(th, RUBY_EVENT_CALL, ci->recv, ci->me->called_id, ci->me->klass, Qnil); /* control block frame */ - th->passed_me = ci->me; + th->passed_bmethod_me = ci->me; GetProcPtr(ci->me->def->body.proc, proc); val = vm_invoke_proc(th, proc, ci->recv, ci->defined_class, ci->argc, argv, ci->blockptr); From d5cf6c1128d04beb84ac960ec5855f2fb64f3d27 Mon Sep 17 00:00:00 2001 From: nagachika Date: Mon, 12 May 2014 14:04:24 +0000 Subject: [PATCH 099/343] merge revision(s) r45637: [Backport #9726] * parse.y (primary): flush cmdarg flags inside left-paren in a command argument, to allow parenthesed do-block as an argument without arguments parentheses. [ruby-core:61950] [Bug #9726] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45929 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ parse.y | 12 +++++++++--- test/ruby/test_syntax.rb | 5 +++++ version.h | 2 +- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0d64bd143e1ac6..3a928af1f0e890 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Mon May 12 22:53:08 2014 Nobuyoshi Nakada + + * parse.y (primary): flush cmdarg flags inside left-paren in a + command argument, to allow parenthesed do-block as an argument + without arguments parentheses. [ruby-core:61950] [Bug #9726] + Mon May 12 22:22:43 2014 Koichi Sasada * vm.c (invoke_block_from_c): add VM_FRAME_FLAG_BMETHOD to record diff --git a/parse.y b/parse.y index 25946dccda974f..fdc3e0cf9bb37c 100644 --- a/parse.y +++ b/parse.y @@ -2612,12 +2612,18 @@ primary : literal $$ = dispatch1(paren, 0); %*/ } - | tLPAREN_ARG expr {lex_state = EXPR_ENDARG;} rparen + | tLPAREN_ARG { + $1 = cmdarg_stack; + cmdarg_stack = 0; + } + expr {lex_state = EXPR_ENDARG;} rparen + { + cmdarg_stack = $1; /*%%%*/ - $$ = $2; + $$ = $3; /*% - $$ = dispatch1(paren, $2); + $$ = dispatch1(paren, $3); %*/ } | tLPAREN compstmt ')' diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index cac755a3903c48..9fa28a4a8a6991 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -78,6 +78,11 @@ def test_newline_in_block_parameters end end + def test_do_block_in_cmdarg + bug9726 = '[ruby-core:61950] [Bug #9726]' + assert_valid_syntax("tap (proc do end)", __FILE__, bug9726) + end + def test_keyword_rest bug5989 = '[ruby-core:42455]' assert_valid_syntax("def kwrest_test(**a) a; end", __FILE__, bug5989) diff --git a/version.h b/version.h index 1b6ce0375f1c4b..37e46f1e65d6cb 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-05-12" -#define RUBY_PATCHLEVEL 99 +#define RUBY_PATCHLEVEL 100 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 5 From 67f5f1be206c7ecb19aeb4cb1167dcedfb3466bd Mon Sep 17 00:00:00 2001 From: nagachika Date: Thu, 15 May 2014 15:24:05 +0000 Subject: [PATCH 100/343] merge revision(s) r45367,r45387,r45388,r45389: [Backport #9475] * vm_method.c (rb_method_entry_get_without_cache): get rid of infinite recursion at aliases in a subclass and a superclass. return actually defined class for other than singleton class. [ruby-core:60431] [Bug #9475] * vm_method.c (rb_method_entry_get_without_cache): me->klass is 0 for a method aliased in a module. [ruby-core:61636] [Bug #9663] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45955 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 12 ++++++++ test/ruby/test_alias.rb | 62 +++++++++++++++++++++++++++++++++++++++++ version.h | 6 ++-- vm_method.c | 11 ++++++-- 4 files changed, 86 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3a928af1f0e890..f79c205123c24d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +Fri May 16 00:14:25 2014 Kohei Suzuki + + * vm_method.c (rb_method_entry_get_without_cache): me->klass is 0 + for a method aliased in a module. [ruby-core:61636] [Bug #9663] + +Fri May 16 00:14:25 2014 Nobuyoshi Nakada + + * vm_method.c (rb_method_entry_get_without_cache): get rid of + infinite recursion at aliases in a subclass and a superclass. + return actually defined class for other than singleton class. + [ruby-core:60431] [Bug #9475] + Mon May 12 22:53:08 2014 Nobuyoshi Nakada * parse.y (primary): flush cmdarg flags inside left-paren in a diff --git a/test/ruby/test_alias.rb b/test/ruby/test_alias.rb index 956fdb41f05b0d..dec61f6d6315bc 100644 --- a/test/ruby/test_alias.rb +++ b/test/ruby/test_alias.rb @@ -132,4 +132,66 @@ class StringIO GC.verify_internal_consistency } end + + def test_cyclic_zsuper + bug9475 = '[ruby-core:60431] [Bug #9475]' + + a = Module.new do + def foo + "A" + end + end + + b = Class.new do + include a + attr_reader :b + + def foo + @b ||= 0 + raise SystemStackError if (@b += 1) > 1 + # "foo from B" + super + "B" + end + end + + c = Class.new(b) do + alias orig_foo foo + + def foo + # "foo from C" + orig_foo + "C" + end + end + + b.class_eval do + alias orig_foo foo + attr_reader :b2 + + def foo + @b2 ||= 0 + raise SystemStackError if (@b2 += 1) > 1 + # "foo from B (again)" + orig_foo + "B2" + end + end + + assert_nothing_raised(SystemStackError, bug9475) do + assert_equal("ABC", c.new.foo, bug9475) + end + end + + def test_alias_in_module + bug9663 = '[ruby-core:61635] [Bug #9663]' + + assert_separately(['-', bug9663], <<-'end;') + bug = ARGV[0] + + m = Module.new do + alias orig_to_s to_s + end + + o = Object.new.extend(m) + assert_equal(o.to_s, o.orig_to_s, bug) + end; + end end diff --git a/version.h b/version.h index 37e46f1e65d6cb..328cdc5426801c 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.2" -#define RUBY_RELEASE_DATE "2014-05-12" -#define RUBY_PATCHLEVEL 100 +#define RUBY_RELEASE_DATE "2014-05-16" +#define RUBY_PATCHLEVEL 101 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 5 -#define RUBY_RELEASE_DAY 12 +#define RUBY_RELEASE_DAY 16 #include "ruby/version.h" diff --git a/vm_method.c b/vm_method.c index ecded4aa2fcc68..a5fe4ba0a3bcf1 100644 --- a/vm_method.c +++ b/vm_method.c @@ -566,8 +566,15 @@ rb_method_entry_get_without_cache(VALUE klass, ID id, VALUE defined_class; rb_method_entry_t *me = search_method(klass, id, &defined_class); - if (me && RB_TYPE_P(me->klass, T_ICLASS)) - defined_class = me->klass; + if (me && me->klass) { + switch (BUILTIN_TYPE(me->klass)) { + case T_CLASS: + if (RBASIC(klass)->flags & FL_SINGLETON) break; + /* fall through */ + case T_ICLASS: + defined_class = me->klass; + } + } if (ruby_running) { struct cache_entry *ent; From a9006d3af053afd1d93caa5dfb609a4f9b3c41d5 Mon Sep 17 00:00:00 2001 From: nagachika Date: Thu, 15 May 2014 15:28:16 +0000 Subject: [PATCH 101/343] merge revision(s) r45374: [Backport #8405] * lib/csv.rb: Fixed a broken regular expression that was causing CSV to miss escaping some special meaning characters when used in parsing. Reported by David Unric [ruby-core:54986] [Bug #8405] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45956 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ lib/csv.rb | 3 +-- test/csv/test_features.rb | 8 ++++++++ version.h | 2 +- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index f79c205123c24d..95a9f1e420dd1d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Fri May 16 00:27:02 2014 James Edward Gray II + + * lib/csv.rb: Fixed a broken regular expression that was causing + CSV to miss escaping some special meaning characters when used + in parsing. + Reported by David Unric + [ruby-core:54986] [Bug #8405] + Fri May 16 00:14:25 2014 Kohei Suzuki * vm_method.c (rb_method_entry_get_without_cache): me->klass is 0 diff --git a/lib/csv.rb b/lib/csv.rb index e5ecf5c9a8a289..2326792cd74d2b 100644 --- a/lib/csv.rb +++ b/lib/csv.rb @@ -1507,8 +1507,7 @@ def initialize(data, options = Hash.new) # if we can transcode the needed characters # @re_esc = "\\".encode(@encoding) rescue "" - @re_chars = /#{%"[-][\\.^$?*+{}()|# \r\n\t\f\v]".encode(@encoding)}/ - # @re_chars = /#{%"[-][\\.^$?*+{}()|# \r\n\t\f\v]".encode(@encoding, fallback: proc{""})}/ + @re_chars = /#{%"[-\\]\\[\\.^$?*+{}()|# \r\n\t\f\v]".encode(@encoding)}/ init_separators(options) init_parsers(options) diff --git a/test/csv/test_features.rb b/test/csv/test_features.rb index 9324af70962246..1746c0e4e295fd 100755 --- a/test/csv/test_features.rb +++ b/test/csv/test_features.rb @@ -74,6 +74,14 @@ def test_quote_char end end + def test_bug_8405 + TEST_CASES.each do |test_case| + assert_equal( test_case.last.map { |t| t.tr('"', "|") unless t.nil? }, + CSV.parse_line( test_case.first.tr('"', "|"), + quote_char: "|" ) ) + end + end + def test_csv_char_readers %w[col_sep row_sep quote_char].each do |reader| csv = CSV.new("abc,def", reader.to_sym => "|") diff --git a/version.h b/version.h index 328cdc5426801c..58f28382a5dd5f 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-05-16" -#define RUBY_PATCHLEVEL 101 +#define RUBY_PATCHLEVEL 102 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 5 From 4e71ea3a1ae284b6ba2d0ef210666c491f24e1c9 Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 18 May 2014 15:36:58 +0000 Subject: [PATCH 102/343] merge revision(s) r45405,r45408: [Backport #9669] [Backport #9740] * parse.y (lex_state_e, parser_params, f_arglist, parser_yylex): separate EXPR_LABELARG from EXPR_BEG and let newline significant, so that required keyword argument can place at the end of argument list without parentheses. [ruby-core:61658] [Bug #9669] * parse.y (parser_yylex): only a newline after label should be significant. [ruby-core:61658] [Bug #9669] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46005 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 12 ++++++++++++ parse.y | 22 +++++++++++++++++----- test/ruby/test_keyword.rb | 19 +++++++++++++++++++ version.h | 6 +++--- 4 files changed, 51 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 95a9f1e420dd1d..7d45f818ccdeb0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +Mon May 19 00:26:53 2014 Nobuyoshi Nakada + + * parse.y (parser_yylex): only a newline after label should be + significant. [ruby-core:61658] [Bug #9669] + +Mon May 19 00:26:53 2014 Nobuyoshi Nakada + + * parse.y (lex_state_e, parser_params, f_arglist, parser_yylex): + separate EXPR_LABELARG from EXPR_BEG and let newline significant, + so that required keyword argument can place at the end of + argument list without parentheses. [ruby-core:61658] [Bug #9669] + Fri May 16 00:27:02 2014 James Edward Gray II * lib/csv.rb: Fixed a broken regular expression that was causing diff --git a/parse.y b/parse.y index fdc3e0cf9bb37c..2a0e25a2b22f32 100644 --- a/parse.y +++ b/parse.y @@ -74,6 +74,7 @@ enum lex_state_bits { EXPR_DOT_bit, /* right after `.' or `::', no reserved words. */ EXPR_CLASS_bit, /* immediate after `class', no here document. */ EXPR_VALUE_bit, /* alike EXPR_BEG but label is disallowed. */ + EXPR_LABELARG_bit, /* ignore significant, +/- is a sign. */ EXPR_MAX_STATE }; /* examine combinations */ @@ -90,7 +91,8 @@ enum lex_state_e { DEF_EXPR(DOT), DEF_EXPR(CLASS), DEF_EXPR(VALUE), - EXPR_BEG_ANY = (EXPR_BEG | EXPR_VALUE | EXPR_MID | EXPR_CLASS), + DEF_EXPR(LABELARG), + EXPR_BEG_ANY = (EXPR_BEG | EXPR_VALUE | EXPR_MID | EXPR_CLASS | EXPR_LABELARG), EXPR_ARG_ANY = (EXPR_ARG | EXPR_CMDARG), EXPR_END_ANY = (EXPR_END | EXPR_ENDARG | EXPR_ENDFN) }; @@ -244,6 +246,7 @@ struct parser_params { int parser_brace_nest; int parser_compile_for_eval; VALUE parser_cur_mid; + int parser_in_kwarg; int parser_in_defined; char *parser_tokenbuf; int parser_tokidx; @@ -4409,9 +4412,14 @@ f_arglist : '(' f_args rparen lex_state = EXPR_BEG; command_start = TRUE; } - | f_args term + | { + $$ = parser->parser_in_kwarg; + parser->parser_in_kwarg = 1; + } + f_args term { - $$ = $1; + parser->parser_in_kwarg = $1; + $$ = $2; lex_state = EXPR_BEG; command_start = TRUE; } @@ -7012,13 +7020,16 @@ parser_yylex(struct parser_params *parser) #endif /* fall through */ case '\n': - if (IS_lex_state(EXPR_BEG | EXPR_VALUE | EXPR_CLASS | EXPR_FNAME | EXPR_DOT)) { + if (IS_lex_state(EXPR_BEG | EXPR_VALUE | EXPR_CLASS | EXPR_FNAME | EXPR_DOT | EXPR_LABELARG)) { #ifdef RIPPER if (!fallthru) { ripper_dispatch_scan_event(parser, tIGNORED_NL); } fallthru = FALSE; #endif + if (IS_lex_state(EXPR_LABELARG) && parser->parser_in_kwarg) { + goto normal_newline; + } goto retry; } while ((c = nextc())) { @@ -8150,7 +8161,7 @@ parser_yylex(struct parser_params *parser) if (IS_LABEL_POSSIBLE()) { if (IS_LABEL_SUFFIX(0)) { - lex_state = EXPR_BEG; + lex_state = EXPR_LABELARG; nextc(); set_yylval_name(TOK_INTERN(!ENC_SINGLE(mb))); return tLABEL; @@ -10846,6 +10857,7 @@ parser_initialize(struct parser_params *parser) parser->parser_in_single = 0; parser->parser_in_def = 0; parser->parser_in_defined = 0; + parser->parser_in_kwarg = 0; parser->parser_compile_for_eval = 0; parser->parser_cur_mid = 0; parser->parser_tokenbuf = NULL; diff --git a/test/ruby/test_keyword.rb b/test/ruby/test_keyword.rb index 03b93dbf0d0b58..f6b4048d61e82f 100644 --- a/test/ruby/test_keyword.rb +++ b/test/ruby/test_keyword.rb @@ -325,6 +325,25 @@ def test_required_keyword assert_equal([[:keyreq, :a], [:keyrest, :b]], o.method(:bar).parameters, feature7701) assert_raise_with_message(ArgumentError, /missing keyword/, bug8139) {o.bar(c: bug8139)} assert_raise_with_message(ArgumentError, /missing keyword/, bug8139) {o.bar} + + bug9669 = '[ruby-core:61658] [Bug #9669]' + assert_nothing_raised(SyntaxError, bug9669) do + eval(<<-'end;', nil, __FILE__, __LINE__) + def bug9669.foo a: + return a + end + end; + end + assert_equal(42, bug9669.foo(a: 42)) + assert_nothing_raised(SyntaxError, bug9669) do + eval(<<-'end;', nil, __FILE__, __LINE__) + o = { + a: + 1 + } + end; + end + assert_equal({a: 1}, o, bug9669) end def test_block_required_keyword diff --git a/version.h b/version.h index 58f28382a5dd5f..1ec2b99818bb29 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.2" -#define RUBY_RELEASE_DATE "2014-05-16" -#define RUBY_PATCHLEVEL 102 +#define RUBY_RELEASE_DATE "2014-05-19" +#define RUBY_PATCHLEVEL 103 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 5 -#define RUBY_RELEASE_DAY 16 +#define RUBY_RELEASE_DAY 19 #include "ruby/version.h" From 161d6bfe2289596d064693c05402d6ba58932c06 Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 18 May 2014 15:54:39 +0000 Subject: [PATCH 103/343] merge revision(s) r45553,r45554,r45557,r45558,r45561,r45566,r45567: [Backport #9718] * array.c (rb_ary_modify): remember shared array owner if a shared array owner is promoted and a shared array is not promoted. Now, shared array is WB-unprotected so that shared arrays are not promoted. All objects referred from shared array should be marked correctly. [ruby-core:61919] [ruby-trunk - Bug #9718] * test/ruby/test_array.rb: add a test for above. * test/ruby/test_array.rb: remove useless `assert'. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46006 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 17 +++++++++++++++++ array.c | 5 +++++ test/ruby/envutil.rb | 6 +++++- test/ruby/test_array.rb | 26 +++++++++++++++++++++++++- version.h | 2 +- 5 files changed, 53 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7d45f818ccdeb0..631ce9f74fc6cc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +Mon May 19 00:47:00 2014 Koichi Sasada + + * test/ruby/test_array.rb: remove useless `assert'. + +Mon May 19 00:47:00 2014 Koichi Sasada + + * array.c (rb_ary_modify): remember shared array owner if a shared + array owner is promoted and a shared array is not promoted. + + Now, shared array is WB-unprotected so that shared arrays are not + promoted. All objects referred from shared array should be marked + correctly. + + [ruby-core:61919] [ruby-trunk - Bug #9718] + + * test/ruby/test_array.rb: add a test for above. + Mon May 19 00:26:53 2014 Nobuyoshi Nakada * parse.y (parser_yylex): only a newline after label should be diff --git a/array.c b/array.c index ff77a3ed949842..d780f438105afb 100644 --- a/array.c +++ b/array.c @@ -343,6 +343,11 @@ rb_ary_modify(VALUE ary) ARY_SET_CAPA(ary, len); ARY_SET_PTR(ary, ptr); } + + /* TODO: age2 promotion, OBJ_PROMOTED() checks not infant. */ + if (OBJ_PROMOTED(ary) && !OBJ_PROMOTED(shared)) { + rb_gc_writebarrier_remember_promoted(ary); + } } } diff --git a/test/ruby/envutil.rb b/test/ruby/envutil.rb index dc136918e9cd27..618905a75aeb4b 100644 --- a/test/ruby/envutil.rb +++ b/test/ruby/envutil.rb @@ -30,7 +30,9 @@ def rubybin LANG_ENVS = %w"LANG LC_ALL LC_CTYPE" def invoke_ruby(args, stdin_data = "", capture_stdout = false, capture_stderr = false, - encoding: nil, timeout: 10, reprieve: 1, **opt) + encoding: nil, timeout: 10, reprieve: 1, + stdout_filter: nil, stderr_filter: nil, + **opt) in_c, in_p = IO.pipe out_p, out_c = IO.pipe if capture_stdout err_p, err_c = IO.pipe if capture_stderr && capture_stderr != :merge_to_stdout @@ -84,6 +86,8 @@ def invoke_ruby(args, stdin_data = "", capture_stdout = false, capture_stderr = err_p.close if capture_stderr && capture_stderr != :merge_to_stdout Process.wait pid status = $? + stdout = stdout_filter.call(stdout) if stdout_filter + stderr = stderr_filter.call(stderr) if stderr_filter return stdout, stderr, status end ensure diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb index 6ff304acb2b9da..3a76889e23a52a 100644 --- a/test/ruby/test_array.rb +++ b/test/ruby/test_array.rb @@ -2389,7 +2389,7 @@ def test_rotate! assert_equal([], a.rotate!(13)) assert_equal([], a.rotate!(-13)) a = [].freeze - assert_raise_with_message(RuntimeError, /can't modify frozen/) {a.rotate!} + assert_raise_with_message(RuntimeError, /can\'t modify frozen/) {a.rotate!} a = [1,2,3] assert_raise(ArgumentError) { a.rotate!(1, 1) } end @@ -2428,4 +2428,28 @@ def test_bsearch_in_find_any_mode assert_include([4, 7], a.bsearch {|x| (2**100).coerce((1 - x / 4) * (2**100)).first }) end + + def test_shared_marking + reduce = proc do |s| + s.gsub(/(verify_internal_consistency_reachable_i:\sWB\smiss\s\S+\s\(T_ARRAY\)\s->\s)\S+\s\((proc|T_NONE)\)\n + \K(?:\1\S+\s\(\2\)\n)*/x) do + "...(snip #{$&.count("\n")} lines)...\n" + end + end + begin + assert_normal_exit(<<-EOS, '[Bug #9718]', timeout: 5, stdout_filter: reduce) + queue = [] + 50.times do + 10_000.times do + queue << lambda{} + end + GC.start(full_mark: false, immediate_sweep: true) + GC.verify_internal_consistency + queue.shift.call + end + EOS + rescue Timeout::Error => e + skip e.message + end + end end diff --git a/version.h b/version.h index 1ec2b99818bb29..0b78c8d6d93c34 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-05-19" -#define RUBY_PATCHLEVEL 103 +#define RUBY_PATCHLEVEL 104 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 5 From a3d95003e1e29b0073d18f0b8a0da3dff029decd Mon Sep 17 00:00:00 2001 From: nagachika Date: Mon, 19 May 2014 14:31:55 +0000 Subject: [PATCH 104/343] merge revision(s) r46010: envutil.rb: fix argument * test/ruby/envutil.rb (assert_separately): fix missing `message` argument to FailDesc. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46023 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/envutil.rb | 2 +- version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/ruby/envutil.rb b/test/ruby/envutil.rb index 618905a75aeb4b..c89309d8453c60 100644 --- a/test/ruby/envutil.rb +++ b/test/ruby/envutil.rb @@ -342,7 +342,7 @@ class Test::Unit::Runner args.insert((Hash === args.first ? 1 : 0), "--disable=gems", *$:.map {|l| "-I#{l}"}) stdout, stderr, status = EnvUtil.invoke_ruby(args, src, true, true, **opt) abort = status.coredump? || (status.signaled? && ABORT_SIGNALS.include?(status.termsig)) - assert(!abort, FailDesc[status, stderr]) + assert(!abort, FailDesc[status, nil, stderr]) self._assertions += stdout[/^assertions=(\d+)/, 1].to_i begin res = Marshal.load(stdout.unpack("m")[0]) diff --git a/version.h b/version.h index 0b78c8d6d93c34..b6326c895b1e2b 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-05-19" -#define RUBY_PATCHLEVEL 104 +#define RUBY_PATCHLEVEL 105 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 5 From e60ec9551caa0c715b389bf94b46be93d47b7f5c Mon Sep 17 00:00:00 2001 From: nagachika Date: Thu, 22 May 2014 15:24:30 +0000 Subject: [PATCH 105/343] merge revision(s) r45045,r45046,r45530: [Backport #9697] * ext/socket/ipsocket.c (ip_s_getaddress): Don't access freed memory. * ext/socket: Wrap struct addrinfo by struct rb_addrinfo. * ext/socket/socket.c (sock_s_getnameinfo): Save errno for EAI_SYSTEM. Reported by Saravana kumar. [ruby-core:61820] [Bug #9697] Fixed by Heesob Park. [ruby-core:61868] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46054 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 14 +++++++ ext/socket/ipsocket.c | 21 +++++----- ext/socket/raddrinfo.c | 87 ++++++++++++++++++++++++----------------- ext/socket/rubysocket.h | 13 ++++-- ext/socket/socket.c | 38 ++++++++++-------- ext/socket/udpsocket.c | 24 ++++++------ version.h | 6 +-- 7 files changed, 123 insertions(+), 80 deletions(-) diff --git a/ChangeLog b/ChangeLog index 631ce9f74fc6cc..73a86bf0dab329 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +Fri May 23 00:04:13 2014 Tanaka Akira + + * ext/socket/socket.c (sock_s_getnameinfo): Save errno for EAI_SYSTEM. + Reported by Saravana kumar. [ruby-core:61820] [Bug #9697] + Fixed by Heesob Park. [ruby-core:61868] + +Fri May 23 00:04:13 2014 Tanaka Akira + + * ext/socket: Wrap struct addrinfo by struct rb_addrinfo. + +Fri May 23 00:04:13 2014 Tanaka Akira + + * ext/socket/ipsocket.c (ip_s_getaddress): Don't access freed memory. + Mon May 19 00:47:00 2014 Koichi Sasada * test/ruby/test_array.rb: remove useless `assert'. diff --git a/ext/socket/ipsocket.c b/ext/socket/ipsocket.c index 7b198bd154727c..ef5ce763ec3f46 100644 --- a/ext/socket/ipsocket.c +++ b/ext/socket/ipsocket.c @@ -15,7 +15,7 @@ struct inetsock_arg VALUE sock; struct { VALUE host, serv; - struct addrinfo *res; + struct rb_addrinfo *res; } remote, local; int type; int fd; @@ -25,11 +25,11 @@ static VALUE inetsock_cleanup(struct inetsock_arg *arg) { if (arg->remote.res) { - freeaddrinfo(arg->remote.res); + rb_freeaddrinfo(arg->remote.res); arg->remote.res = 0; } if (arg->local.res) { - freeaddrinfo(arg->local.res); + rb_freeaddrinfo(arg->local.res); arg->local.res = 0; } if (arg->fd >= 0) { @@ -57,14 +57,14 @@ init_inetsock_internal(struct inetsock_arg *arg) } arg->fd = fd = -1; - for (res = arg->remote.res; res; res = res->ai_next) { + for (res = arg->remote.res->ai; res; res = res->ai_next) { #if !defined(INET6) && defined(AF_INET6) if (res->ai_family == AF_INET6) continue; #endif lres = NULL; if (arg->local.res) { - for (lres = arg->local.res; lres; lres = lres->ai_next) { + for (lres = arg->local.res->ai; lres; lres = lres->ai_next) { if (lres->ai_family == res->ai_family) break; } @@ -73,7 +73,7 @@ init_inetsock_internal(struct inetsock_arg *arg) continue; /* Use a different family local address if no choice, this * will cause EAFNOSUPPORT. */ - lres = arg->local.res; + lres = arg->local.res->ai; } } status = rsock_socket(res->ai_family,res->ai_socktype,res->ai_protocol); @@ -304,13 +304,14 @@ static VALUE ip_s_getaddress(VALUE obj, VALUE host) { union_sockaddr addr; - struct addrinfo *res = rsock_addrinfo(host, Qnil, SOCK_STREAM, 0); + struct rb_addrinfo *res = rsock_addrinfo(host, Qnil, SOCK_STREAM, 0); + socklen_t len = res->ai->ai_addrlen; /* just take the first one */ - memcpy(&addr, res->ai_addr, res->ai_addrlen); - freeaddrinfo(res); + memcpy(&addr, res->ai->ai_addr, len); + rb_freeaddrinfo(res); - return rsock_make_ipaddr(&addr.addr, res->ai_addrlen); + return rsock_make_ipaddr(&addr.addr, len); } void diff --git a/ext/socket/raddrinfo.c b/ext/socket/raddrinfo.c index 109fcccae84767..619f123dce3b0a 100644 --- a/ext/socket/raddrinfo.c +++ b/ext/socket/raddrinfo.c @@ -174,21 +174,35 @@ nogvl_getaddrinfo(void *arg) int rb_getaddrinfo(const char *node, const char *service, const struct addrinfo *hints, - struct addrinfo **res) + struct rb_addrinfo **res) { + struct addrinfo *ai; + int ret; + #ifdef GETADDRINFO_EMU - return getaddrinfo(node, service, hints, res); + ret = getaddrinfo(node, service, hints, &ai); #else struct getaddrinfo_arg arg; - int ret; MEMZERO(&arg, sizeof arg, 1); arg.node = node; arg.service = service; arg.hints = hints; - arg.res = res; + arg.res = &ai; ret = (int)(VALUE)rb_thread_call_without_gvl(nogvl_getaddrinfo, &arg, RUBY_UBF_IO, 0); - return ret; #endif + + if (ret == 0) { + *res = (struct rb_addrinfo *)xmalloc(sizeof(struct rb_addrinfo)); + (*res)->ai = ai; + } + return ret; +} + +void +rb_freeaddrinfo(struct rb_addrinfo *ai) +{ + freeaddrinfo(ai->ai); + xfree(ai); } #ifndef GETADDRINFO_EMU @@ -345,10 +359,10 @@ port_str(VALUE port, char *pbuf, size_t pbuflen, int *flags_ptr) } } -struct addrinfo* +struct rb_addrinfo* rsock_getaddrinfo(VALUE host, VALUE port, struct addrinfo *hints, int socktype_hack) { - struct addrinfo* res = NULL; + struct rb_addrinfo* res = NULL; char *hostp, *portp; int error; char hbuf[NI_MAXHOST], pbuf[NI_MAXSERV]; @@ -373,7 +387,7 @@ rsock_getaddrinfo(VALUE host, VALUE port, struct addrinfo *hints, int socktype_h return res; } -struct addrinfo* +struct rb_addrinfo* rsock_addrinfo(VALUE host, VALUE port, int socktype, int flags) { struct addrinfo hints; @@ -474,7 +488,7 @@ rsock_unix_sockaddr_len(VALUE path) struct hostent_arg { VALUE host; - struct addrinfo* addr; + struct rb_addrinfo* addr; VALUE (*ipaddr)(struct sockaddr*, socklen_t); }; @@ -482,7 +496,7 @@ static VALUE make_hostent_internal(struct hostent_arg *arg) { VALUE host = arg->host; - struct addrinfo* addr = arg->addr; + struct addrinfo* addr = arg->addr->ai; VALUE (*ipaddr)(struct sockaddr*, socklen_t) = arg->ipaddr; struct addrinfo *ai; @@ -522,14 +536,15 @@ make_hostent_internal(struct hostent_arg *arg) } VALUE -rsock_freeaddrinfo(struct addrinfo *addr) +rsock_freeaddrinfo(VALUE arg) { - freeaddrinfo(addr); + struct rb_addrinfo *addr = (struct rb_addrinfo *)arg; + rb_freeaddrinfo(addr); return Qnil; } VALUE -rsock_make_hostent(VALUE host, struct addrinfo *addr, VALUE (*ipaddr)(struct sockaddr *, socklen_t)) +rsock_make_hostent(VALUE host, struct rb_addrinfo *addr, VALUE (*ipaddr)(struct sockaddr *, socklen_t)) { struct hostent_arg arg; @@ -639,12 +654,13 @@ rsock_addrinfo_new(struct sockaddr *addr, socklen_t len, return a; } -static struct addrinfo * +static struct rb_addrinfo * call_getaddrinfo(VALUE node, VALUE service, VALUE family, VALUE socktype, VALUE protocol, VALUE flags, int socktype_hack) { - struct addrinfo hints, *res; + struct addrinfo hints; + struct rb_addrinfo *res; MEMZERO(&hints, struct addrinfo, 1); hints.ai_family = NIL_P(family) ? PF_UNSPEC : rsock_family_arg(family); @@ -672,21 +688,21 @@ init_addrinfo_getaddrinfo(rb_addrinfo_t *rai, VALUE node, VALUE service, VALUE family, VALUE socktype, VALUE protocol, VALUE flags, VALUE inspectnode, VALUE inspectservice) { - struct addrinfo *res = call_getaddrinfo(node, service, family, socktype, protocol, flags, 1); + struct rb_addrinfo *res = call_getaddrinfo(node, service, family, socktype, protocol, flags, 1); VALUE canonname; - VALUE inspectname = rb_str_equal(node, inspectnode) ? Qnil : make_inspectname(inspectnode, inspectservice, res); + VALUE inspectname = rb_str_equal(node, inspectnode) ? Qnil : make_inspectname(inspectnode, inspectservice, res->ai); canonname = Qnil; - if (res->ai_canonname) { - canonname = rb_tainted_str_new_cstr(res->ai_canonname); + if (res->ai->ai_canonname) { + canonname = rb_tainted_str_new_cstr(res->ai->ai_canonname); OBJ_FREEZE(canonname); } - init_addrinfo(rai, res->ai_addr, res->ai_addrlen, + init_addrinfo(rai, res->ai->ai_addr, res->ai->ai_addrlen, NUM2INT(family), NUM2INT(socktype), NUM2INT(protocol), canonname, inspectname); - freeaddrinfo(res); + rb_freeaddrinfo(res); } static VALUE @@ -742,21 +758,22 @@ addrinfo_firstonly_new(VALUE node, VALUE service, VALUE family, VALUE socktype, VALUE canonname; VALUE inspectname; - struct addrinfo *res = call_getaddrinfo(node, service, family, socktype, protocol, flags, 0); + struct rb_addrinfo *res = call_getaddrinfo(node, service, family, socktype, protocol, flags, 0); - inspectname = make_inspectname(node, service, res); + inspectname = make_inspectname(node, service, res->ai); canonname = Qnil; - if (res->ai_canonname) { - canonname = rb_tainted_str_new_cstr(res->ai_canonname); + if (res->ai->ai_canonname) { + canonname = rb_tainted_str_new_cstr(res->ai->ai_canonname); OBJ_FREEZE(canonname); } - ret = rsock_addrinfo_new(res->ai_addr, res->ai_addrlen, - res->ai_family, res->ai_socktype, res->ai_protocol, + ret = rsock_addrinfo_new(res->ai->ai_addr, res->ai->ai_addrlen, + res->ai->ai_family, res->ai->ai_socktype, + res->ai->ai_protocol, canonname, inspectname); - freeaddrinfo(res); + rb_freeaddrinfo(res); return ret; } @@ -767,12 +784,12 @@ addrinfo_list_new(VALUE node, VALUE service, VALUE family, VALUE socktype, VALUE struct addrinfo *r; VALUE inspectname; - struct addrinfo *res = call_getaddrinfo(node, service, family, socktype, protocol, flags, 0); + struct rb_addrinfo *res = call_getaddrinfo(node, service, family, socktype, protocol, flags, 0); - inspectname = make_inspectname(node, service, res); + inspectname = make_inspectname(node, service, res->ai); ret = rb_ary_new(); - for (r = res; r; r = r->ai_next) { + for (r = res->ai; r; r = r->ai_next) { VALUE addr; VALUE canonname = Qnil; @@ -788,7 +805,7 @@ addrinfo_list_new(VALUE node, VALUE service, VALUE family, VALUE socktype, VALUE rb_ary_push(ret, addr); } - freeaddrinfo(res); + rb_freeaddrinfo(res); return ret; } @@ -1513,7 +1530,7 @@ addrinfo_mload(VALUE self, VALUE ary) default: { VALUE pair = rb_convert_type(v, T_ARRAY, "Array", "to_ary"); - struct addrinfo *res; + struct rb_addrinfo *res; int flags = AI_NUMERICHOST; #ifdef AI_NUMERICSERV flags |= AI_NUMERICSERV; @@ -1522,8 +1539,8 @@ addrinfo_mload(VALUE self, VALUE ary) INT2NUM(pfamily), INT2NUM(socktype), INT2NUM(protocol), INT2NUM(flags), 1); - len = res->ai_addrlen; - memcpy(&ss, res->ai_addr, res->ai_addrlen); + len = res->ai->ai_addrlen; + memcpy(&ss, res->ai->ai_addr, res->ai->ai_addrlen); break; } } diff --git a/ext/socket/rubysocket.h b/ext/socket/rubysocket.h index c74fb326ec16c4..74896ce30a4ad8 100644 --- a/ext/socket/rubysocket.h +++ b/ext/socket/rubysocket.h @@ -278,10 +278,15 @@ int rsock_shutdown_how_arg(VALUE how); int rsock_getfamily(int sockfd); -int rb_getaddrinfo(const char *node, const char *service, const struct addrinfo *hints, struct addrinfo **res); +struct rb_addrinfo { + struct addrinfo *ai; +}; +int rb_getaddrinfo(const char *node, const char *service, const struct addrinfo *hints, struct rb_addrinfo **res); +void rb_freeaddrinfo(struct rb_addrinfo *ai); +VALUE rsock_freeaddrinfo(VALUE arg); int rb_getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags); -struct addrinfo *rsock_addrinfo(VALUE host, VALUE port, int socktype, int flags); -struct addrinfo *rsock_getaddrinfo(VALUE host, VALUE port, struct addrinfo *hints, int socktype_hack); +struct rb_addrinfo *rsock_addrinfo(VALUE host, VALUE port, int socktype, int flags); +struct rb_addrinfo *rsock_getaddrinfo(VALUE host, VALUE port, struct addrinfo *hints, int socktype_hack); VALUE rsock_fd_socket_addrinfo(int fd, struct sockaddr *addr, socklen_t len); VALUE rsock_io_socket_addrinfo(VALUE io, struct sockaddr *addr, socklen_t len); @@ -290,7 +295,7 @@ VALUE rsock_addrinfo_inspect_sockaddr(VALUE rai); VALUE rsock_make_ipaddr(struct sockaddr *addr, socklen_t addrlen); VALUE rsock_ipaddr(struct sockaddr *sockaddr, socklen_t sockaddrlen, int norevlookup); -VALUE rsock_make_hostent(VALUE host, struct addrinfo *addr, VALUE (*ipaddr)(struct sockaddr *, socklen_t)); +VALUE rsock_make_hostent(VALUE host, struct rb_addrinfo *addr, VALUE (*ipaddr)(struct sockaddr *, socklen_t)); VALUE rsock_inspect_sockaddr(struct sockaddr *addr, socklen_t socklen, VALUE ret); socklen_t rsock_sockaddr_len(struct sockaddr *addr); VALUE rsock_sockaddr_obj(struct sockaddr *addr, socklen_t len); diff --git a/ext/socket/socket.c b/ext/socket/socket.c index c7fc5b76cbf348..8bfccbd5598a65 100644 --- a/ext/socket/socket.c +++ b/ext/socket/socket.c @@ -1039,7 +1039,7 @@ sock_gethostname(VALUE obj) #endif static VALUE -make_addrinfo(struct addrinfo *res0, int norevlookup) +make_addrinfo(struct rb_addrinfo *res0, int norevlookup) { VALUE base, ary; struct addrinfo *res; @@ -1048,7 +1048,7 @@ make_addrinfo(struct addrinfo *res0, int norevlookup) rb_raise(rb_eSocket, "host not found"); } base = rb_ary_new(); - for (res = res0; res; res = res->ai_next) { + for (res = res0->ai; res; res = res->ai_next) { ary = rsock_ipaddr(res->ai_addr, res->ai_addrlen, norevlookup); if (res->ai_canonname) { RARRAY_PTR(ary)[2] = rb_str_new2(res->ai_canonname); @@ -1271,7 +1271,8 @@ static VALUE sock_s_getaddrinfo(int argc, VALUE *argv) { VALUE host, port, family, socktype, protocol, flags, ret, revlookup; - struct addrinfo hints, *res; + struct addrinfo hints; + struct rb_addrinfo *res; int norevlookup; rb_scan_args(argc, argv, "25", &host, &port, &family, &socktype, &protocol, &flags, &revlookup); @@ -1294,7 +1295,7 @@ sock_s_getaddrinfo(int argc, VALUE *argv) res = rsock_getaddrinfo(host, port, &hints, 0); ret = make_addrinfo(res, norevlookup); - freeaddrinfo(res); + rb_freeaddrinfo(res); return ret; } @@ -1327,8 +1328,9 @@ sock_s_getnameinfo(int argc, VALUE *argv) char *hptr, *pptr; char hbuf[1024], pbuf[1024]; int fl; - struct addrinfo hints, *res = NULL, *r; - int error; + struct rb_addrinfo *res = NULL; + struct addrinfo hints, *r; + int error, saved_errno; union_sockaddr ss; struct sockaddr *sap; socklen_t salen; @@ -1412,8 +1414,8 @@ sock_s_getnameinfo(int argc, VALUE *argv) hints.ai_family = NIL_P(af) ? PF_UNSPEC : rsock_family_arg(af); error = rb_getaddrinfo(hptr, pptr, &hints, &res); if (error) goto error_exit_addr; - sap = res->ai_addr; - salen = res->ai_addrlen; + sap = res->ai->ai_addr; + salen = res->ai->ai_addrlen; } else { rb_raise(rb_eTypeError, "expecting String or Array"); @@ -1424,7 +1426,7 @@ sock_s_getnameinfo(int argc, VALUE *argv) pbuf, sizeof(pbuf), fl); if (error) goto error_exit_name; if (res) { - for (r = res->ai_next; r; r = r->ai_next) { + for (r = res->ai->ai_next; r; r = r->ai_next) { char hbuf2[1024], pbuf2[1024]; sap = r->ai_addr; @@ -1433,20 +1435,24 @@ sock_s_getnameinfo(int argc, VALUE *argv) pbuf2, sizeof(pbuf2), fl); if (error) goto error_exit_name; if (strcmp(hbuf, hbuf2) != 0|| strcmp(pbuf, pbuf2) != 0) { - freeaddrinfo(res); + rb_freeaddrinfo(res); rb_raise(rb_eSocket, "sockaddr resolved to multiple nodename"); } } - freeaddrinfo(res); + rb_freeaddrinfo(res); } return rb_assoc_new(rb_str_new2(hbuf), rb_str_new2(pbuf)); error_exit_addr: - if (res) freeaddrinfo(res); + saved_errno = errno; + if (res) rb_freeaddrinfo(res); + errno = saved_errno; rsock_raise_socket_error("getaddrinfo", error); error_exit_name: - if (res) freeaddrinfo(res); + saved_errno = errno; + if (res) rb_freeaddrinfo(res); + errno = saved_errno; rsock_raise_socket_error("getnameinfo", error); UNREACHABLE; @@ -1469,10 +1475,10 @@ sock_s_getnameinfo(int argc, VALUE *argv) static VALUE sock_s_pack_sockaddr_in(VALUE self, VALUE port, VALUE host) { - struct addrinfo *res = rsock_addrinfo(host, port, 0, 0); - VALUE addr = rb_str_new((char*)res->ai_addr, res->ai_addrlen); + struct rb_addrinfo *res = rsock_addrinfo(host, port, 0, 0); + VALUE addr = rb_str_new((char*)res->ai->ai_addr, res->ai->ai_addrlen); - freeaddrinfo(res); + rb_freeaddrinfo(res); OBJ_INFECT(addr, port); OBJ_INFECT(addr, host); diff --git a/ext/socket/udpsocket.c b/ext/socket/udpsocket.c index a89c453239085c..761b11a2981c48 100644 --- a/ext/socket/udpsocket.c +++ b/ext/socket/udpsocket.c @@ -44,7 +44,7 @@ udp_init(int argc, VALUE *argv, VALUE sock) struct udp_arg { - struct addrinfo *res; + struct rb_addrinfo *res; int fd; }; @@ -54,7 +54,7 @@ udp_connect_internal(struct udp_arg *arg) int fd = arg->fd; struct addrinfo *res; - for (res = arg->res; res; res = res->ai_next) { + for (res = arg->res->ai; res; res = res->ai_next) { if (rsock_connect(fd, res->ai_addr, res->ai_addrlen, 0) >= 0) { return Qtrue; } @@ -62,8 +62,6 @@ udp_connect_internal(struct udp_arg *arg) return Qfalse; } -VALUE rsock_freeaddrinfo(struct addrinfo *addr); - /* * call-seq: * udpsocket.connect(host, port) => 0 @@ -113,19 +111,20 @@ static VALUE udp_bind(VALUE sock, VALUE host, VALUE port) { rb_io_t *fptr; - struct addrinfo *res0, *res; + struct rb_addrinfo *res0; + struct addrinfo *res; rb_secure(3); res0 = rsock_addrinfo(host, port, SOCK_DGRAM, 0); GetOpenFile(sock, fptr); - for (res = res0; res; res = res->ai_next) { + for (res = res0->ai; res; res = res->ai_next) { if (bind(fptr->fd, res->ai_addr, res->ai_addrlen) < 0) { continue; } - freeaddrinfo(res0); + rb_freeaddrinfo(res0); return INT2FIX(0); } - freeaddrinfo(res0); + rb_freeaddrinfo(res0); rsock_sys_fail_host_port("bind(2)", host, port); @@ -160,7 +159,8 @@ udp_send(int argc, VALUE *argv, VALUE sock) VALUE flags, host, port; rb_io_t *fptr; int n; - struct addrinfo *res0, *res; + struct rb_addrinfo *res0; + struct addrinfo *res; struct rsock_send_arg arg; if (argc == 2 || argc == 3) { @@ -173,21 +173,21 @@ udp_send(int argc, VALUE *argv, VALUE sock) GetOpenFile(sock, fptr); arg.fd = fptr->fd; arg.flags = NUM2INT(flags); - for (res = res0; res; res = res->ai_next) { + for (res = res0->ai; res; res = res->ai_next) { retry: arg.to = res->ai_addr; arg.tolen = res->ai_addrlen; rb_thread_fd_writable(arg.fd); n = (int)BLOCKING_REGION_FD(rsock_sendto_blocking, &arg); if (n >= 0) { - freeaddrinfo(res0); + rb_freeaddrinfo(res0); return INT2FIX(n); } if (rb_io_wait_writable(fptr->fd)) { goto retry; } } - freeaddrinfo(res0); + rb_freeaddrinfo(res0); rsock_sys_fail_host_port("sendto(2)", host, port); return INT2FIX(n); } diff --git a/version.h b/version.h index b6326c895b1e2b..8cd4d86c6d241b 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.2" -#define RUBY_RELEASE_DATE "2014-05-19" -#define RUBY_PATCHLEVEL 105 +#define RUBY_RELEASE_DATE "2014-05-23" +#define RUBY_PATCHLEVEL 106 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 5 -#define RUBY_RELEASE_DAY 19 +#define RUBY_RELEASE_DAY 23 #include "ruby/version.h" From 1c9a3e6eb8cca1e61c1f1d4bb4152321abf9ccb5 Mon Sep 17 00:00:00 2001 From: nagachika Date: Tue, 27 May 2014 15:19:53 +0000 Subject: [PATCH 106/343] merge revision(s) r45520: [Backport #9706] * ext/date/date_core.c (d_lite_cmp): should compare with #<. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46185 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ ext/date/date_core.c | 2 +- test/date/test_switch_hitter.rb | 2 ++ version.h | 6 +++--- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 73a86bf0dab329..cea79dc8b3e19e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Wed May 28 00:18:29 2014 Tadayoshi Funaba + + * ext/date/date_core.c (d_lite_cmp): should compare with #<. + Fri May 23 00:04:13 2014 Tanaka Akira * ext/socket/socket.c (sock_s_getnameinfo): Save errno for EAI_SYSTEM. diff --git a/ext/date/date_core.c b/ext/date/date_core.c index 176c76ef0cbdde..6e5c79a4942605 100644 --- a/ext/date/date_core.c +++ b/ext/date/date_core.c @@ -6306,7 +6306,7 @@ d_lite_cmp(VALUE self, VALUE other) return INT2FIX(1); } } - else if (a_nth < b_nth) { + else if (f_lt_p(a_nth, b_nth)) { return INT2FIX(-1); } else { diff --git a/test/date/test_switch_hitter.rb b/test/date/test_switch_hitter.rb index f18d76b393ac13..08e23015dcff60 100644 --- a/test/date/test_switch_hitter.rb +++ b/test/date/test_switch_hitter.rb @@ -312,6 +312,8 @@ def test_cmp assert_equal(-1, Date.new(2001,2,3) <=> Rational('4903888/2')) assert_equal(0, Date.new(2001,2,3) <=> Rational('4903887/2')) assert_equal(1, Date.new(2001,2,3) <=> Rational('4903886/2')) + + assert_equal(-1, Date.new(-4713,11,1,Date::GREGORIAN) <=> Date.new(-4713,12,1,Date::GREGORIAN)) end def test_eqeqeq diff --git a/version.h b/version.h index 8cd4d86c6d241b..23233f76f0842b 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.2" -#define RUBY_RELEASE_DATE "2014-05-23" -#define RUBY_PATCHLEVEL 106 +#define RUBY_RELEASE_DATE "2014-05-28" +#define RUBY_PATCHLEVEL 107 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 5 -#define RUBY_RELEASE_DAY 23 +#define RUBY_RELEASE_DAY 28 #include "ruby/version.h" From 909291085c87b41d6718c2630ee49210eb9d9684 Mon Sep 17 00:00:00 2001 From: nagachika Date: Tue, 27 May 2014 15:26:28 +0000 Subject: [PATCH 107/343] merge revision(s) r45529: [Backport #8182] * lib/xmlrpc/client.rb (do_rpc): don't check body length. If HTTP content-encoding is used, the length may be different. [Bug #8182] [ruby-core:53811] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46186 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ lib/xmlrpc/client.rb | 2 -- version.h | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index cea79dc8b3e19e..8389ca8a696caa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Wed May 28 00:23:11 2014 NARUSE, Yui + + * lib/xmlrpc/client.rb (do_rpc): don't check body length. + If HTTP content-encoding is used, the length may be different. + [Bug #8182] [ruby-core:53811] + Wed May 28 00:18:29 2014 Tadayoshi Funaba * ext/date/date_core.c (d_lite_cmp): should compare with #<. diff --git a/lib/xmlrpc/client.rb b/lib/xmlrpc/client.rb index 5ee3961f3018d7..95b1ea2d1755ce 100644 --- a/lib/xmlrpc/client.rb +++ b/lib/xmlrpc/client.rb @@ -507,8 +507,6 @@ def do_rpc(request, async=false) expected = resp["Content-Length"] || "" if data.nil? or data.bytesize == 0 raise "Wrong size. Was #{data.bytesize}, should be #{expected}" - elsif expected != "" and expected.to_i != data.bytesize and resp["Transfer-Encoding"].nil? - raise "Wrong size. Was #{data.bytesize}, should be #{expected}" end parse_set_cookies(resp.get_fields("Set-Cookie")) diff --git a/version.h b/version.h index 23233f76f0842b..f6cf5e9385d0cd 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-05-28" -#define RUBY_PATCHLEVEL 107 +#define RUBY_PATCHLEVEL 108 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 5 From cd0a89b0931d51015e4e94b010926f0c75767cee Mon Sep 17 00:00:00 2001 From: nagachika Date: Tue, 27 May 2014 15:36:32 +0000 Subject: [PATCH 108/343] merge revision(s) r45534: [Backport #9709] * string.c (str_buf_cat): should round up the capacity by 4KiB, but not number of rooms. [ruby-core:61886] [Bug #9709] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46187 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ string.c | 2 +- test/ruby/test_string.rb | 11 +++++++++++ version.h | 2 +- 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8389ca8a696caa..fb63027b55f85d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed May 28 00:29:02 2014 Nobuyoshi Nakada + + * string.c (str_buf_cat): should round up the capacity by 4KiB, + but not number of rooms. [ruby-core:61886] [Bug #9709] + Wed May 28 00:23:11 2014 NARUSE, Yui * lib/xmlrpc/client.rb (do_rpc): don't check body length. diff --git a/string.c b/string.c index 983c2a11661fa3..7f29cea2b6fc62 100644 --- a/string.c +++ b/string.c @@ -2098,7 +2098,7 @@ str_buf_cat(VALUE str, const char *ptr, long len) if (capa <= total) { while (total > capa) { if (capa + termlen >= LONG_MAX / 2) { - capa = (total + 4095) / 4096; + capa = (total + 4095) / 4096 * 4096; break; } capa = (capa + termlen) * 2; diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb index 7ce1c0666cf65a..57cea652b17934 100644 --- a/test/ruby/test_string.rb +++ b/test/ruby/test_string.rb @@ -2219,6 +2219,17 @@ def =~(str) assert_equal("foo", "" =~ //) RUBY end + + def test_LSHIFT_neary_long_max + return unless @cls == String + assert_ruby_status([], <<-'end;', '[ruby-core:61886] [Bug #9709]') + begin + a = "a" * 0x4000_0000 + a << "a" * 0x1_0000 + rescue NoMemoryError + end + end; + end end class TestString2 < TestString diff --git a/version.h b/version.h index f6cf5e9385d0cd..062e5404e153c2 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-05-28" -#define RUBY_PATCHLEVEL 108 +#define RUBY_PATCHLEVEL 109 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 5 From 41fd33e5fe22f13fd178c50adaee39ce53a3c155 Mon Sep 17 00:00:00 2001 From: nagachika Date: Tue, 27 May 2014 15:44:36 +0000 Subject: [PATCH 109/343] merge revision(s) r45562: [Backport #9727] * array.c (ary_reject): may be turned into a shared array during the given block. [ruby-dev:48101] [Bug #9727] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46188 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ array.c | 15 +-------------- test/ruby/test_array.rb | 16 ++++++++++++++++ version.h | 2 +- 4 files changed, 23 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index fb63027b55f85d..a4b5b9992fd4a5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed May 28 00:38:37 2014 Nobuyoshi Nakada + + * array.c (ary_reject): may be turned into a shared array during + the given block. [ruby-dev:48101] [Bug #9727] + Wed May 28 00:29:02 2014 Nobuyoshi Nakada * string.c (str_buf_cat): should round up the capacity by 4KiB, diff --git a/array.c b/array.c index d780f438105afb..a57733866ed10d 100644 --- a/array.c +++ b/array.c @@ -903,19 +903,6 @@ rb_ary_push(VALUE ary, VALUE item) return ary; } -static VALUE -rb_ary_push_1(VALUE ary, VALUE item) -{ - long idx = RARRAY_LEN(ary); - - if (idx >= ARY_CAPA(ary)) { - ary_double_capa(ary, idx); - } - RARRAY_ASET(ary, idx, item); - ARY_SET_LEN(ary, idx + 1); - return ary; -} - VALUE rb_ary_cat(VALUE ary, const VALUE *ptr, long len) { @@ -3082,7 +3069,7 @@ ary_reject(VALUE orig, VALUE result) for (i = 0; i < RARRAY_LEN(orig); i++) { VALUE v = RARRAY_AREF(orig, i); if (!RTEST(rb_yield(v))) { - rb_ary_push_1(result, v); + rb_ary_push(result, v); } } return result; diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb index 3a76889e23a52a..235dda0dca2c65 100644 --- a/test/ruby/test_array.rb +++ b/test/ruby/test_array.rb @@ -2011,6 +2011,22 @@ def test_reject assert_equal([1, 3], [0, 1, 2, 3].reject {|x| x % 2 == 0 }) end + def test_reject_with_callcc + respond_to?(:callcc, true) or require 'continuation' + bug9727 = '[ruby-dev:48101] [Bug #9727]' + cont = nil + a = [*1..10].reject do |i| + callcc {|c| cont = c} if !cont and i == 10 + false + end + if a.size < 1000 + a.unshift(:x) + cont.call + end + assert_equal(1000, a.size, bug9727) + assert_equal([:x, *1..10], a.uniq, bug9727) + end + def test_zip assert_equal([[1, :a, "a"], [2, :b, "b"], [3, nil, "c"]], [1, 2, 3].zip([:a, :b], ["a", "b", "c", "d"])) diff --git a/version.h b/version.h index 062e5404e153c2..6dcc86700ac56e 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-05-28" -#define RUBY_PATCHLEVEL 109 +#define RUBY_PATCHLEVEL 110 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 5 From 69eab6991a64b6dff4209f96d719680a875b0d89 Mon Sep 17 00:00:00 2001 From: nagachika Date: Tue, 27 May 2014 16:03:12 +0000 Subject: [PATCH 110/343] merge revision(s) r45179,r45564,r45565,r45584,r45585: [Backport #9721] envutil.rb: move labeled_module and labeled_class * test/ruby/envutil.rb (labeled_module, labeled_class): move from test/ruby/test_module.rb. * proc.c (rb_method_call_with_block, umethod_bind): call with IClass including the module for a module instance method. [ruby-core:61936] [Bug #9721] * vm_insnhelper.c (vm_search_super_method): allow bound UnboundMethod case. * proc.c (umethod_bind): use the ancestor iclass instead of new iclass to get rid of infinite recursion, if the defined module is already included. [ruby-core:62014] [Bug #9721] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46190 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 15 ++++++++++ internal.h | 1 + object.c | 32 +++++++++++++------- proc.c | 18 ++++++++++-- test/ruby/envutil.rb | 16 ++++++++++ test/ruby/test_module.rb | 10 ++----- test/ruby/test_super.rb | 63 +++++++++++++++++++++++++++++++++------- version.h | 2 +- vm_insnhelper.c | 5 ++-- 9 files changed, 127 insertions(+), 35 deletions(-) diff --git a/ChangeLog b/ChangeLog index a4b5b9992fd4a5..26b58e731880cc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +Wed May 28 00:57:06 2014 Nobuyoshi Nakada + + * proc.c (umethod_bind): use the ancestor iclass instead of new + iclass to get rid of infinite recursion, if the defined module + is already included. [ruby-core:62014] [Bug #9721] + +Wed May 28 00:57:06 2014 Nobuyoshi Nakada + + * proc.c (rb_method_call_with_block, umethod_bind): call with + IClass including the module for a module instance method. + [ruby-core:61936] [Bug #9721] + + * vm_insnhelper.c (vm_search_super_method): allow bound + UnboundMethod case. + Wed May 28 00:38:37 2014 Nobuyoshi Nakada * array.c (ary_reject): may be turned into a shared array during diff --git a/internal.h b/internal.h index 40916a59a2394d..9e48c139061640 100644 --- a/internal.h +++ b/internal.h @@ -596,6 +596,7 @@ rb_float_new_inline(double d) /* object.c */ VALUE rb_obj_equal(VALUE obj1, VALUE obj2); +VALUE rb_class_search_ancestor(VALUE klass, VALUE super); struct RBasicRaw { VALUE flags; diff --git a/object.c b/object.c index bb43b4617e5cd1..3885d9bf701c5f 100644 --- a/object.c +++ b/object.c @@ -584,6 +584,8 @@ class_or_module_required(VALUE c) return c; } +static VALUE class_search_ancestor(VALUE cl, VALUE c); + /* * call-seq: * obj.instance_of?(class) -> true or false @@ -644,15 +646,27 @@ rb_obj_is_kind_of(VALUE obj, VALUE c) VALUE cl = CLASS_OF(obj); c = class_or_module_required(c); - c = RCLASS_ORIGIN(c); + return class_search_ancestor(cl, RCLASS_ORIGIN(c)) ? Qtrue : Qfalse; +} + +static VALUE +class_search_ancestor(VALUE cl, VALUE c) +{ while (cl) { if (cl == c || RCLASS_M_TBL_WRAPPER(cl) == RCLASS_M_TBL_WRAPPER(c)) - return Qtrue; + return cl; cl = RCLASS_SUPER(cl); } - return Qfalse; + return 0; } +VALUE +rb_class_search_ancestor(VALUE cl, VALUE c) +{ + cl = class_or_module_required(cl); + c = class_or_module_required(c); + return class_search_ancestor(cl, RCLASS_ORIGIN(c)); +} /* * call-seq: @@ -1548,16 +1562,12 @@ rb_class_inherited_p(VALUE mod, VALUE arg) rb_raise(rb_eTypeError, "compared with non class/module"); } arg = RCLASS_ORIGIN(arg); - while (mod) { - if (RCLASS_M_TBL_WRAPPER(mod) == RCLASS_M_TBL_WRAPPER(arg)) - return Qtrue; - mod = RCLASS_SUPER(mod); + if (class_search_ancestor(mod, arg)) { + return Qtrue; } /* not mod < arg; check if mod > arg */ - while (arg) { - if (RCLASS_M_TBL_WRAPPER(arg) == RCLASS_M_TBL_WRAPPER(start)) - return Qfalse; - arg = RCLASS_SUPER(arg); + if (class_search_ancestor(arg, start)) { + return Qfalse; } return Qnil; } diff --git a/proc.c b/proc.c index e3cecb7bbe898a..cc4e71080c3e5b 100644 --- a/proc.c +++ b/proc.c @@ -1826,6 +1826,7 @@ rb_method_call_with_block(int argc, VALUE *argv, VALUE method, VALUE pass_procva if ((state = EXEC_TAG()) == 0) { rb_thread_t *th = GET_THREAD(); rb_block_t *block = 0; + VALUE defined_class; if (!NIL_P(pass_procval)) { rb_proc_t *pass_proc; @@ -1834,7 +1835,9 @@ rb_method_call_with_block(int argc, VALUE *argv, VALUE method, VALUE pass_procva } th->passed_block = block; - result = rb_vm_call(th, data->recv, data->id, argc, argv, data->me, data->defined_class); + defined_class = data->defined_class; + if (BUILTIN_TYPE(defined_class) == T_MODULE) defined_class = data->rclass; + result = rb_vm_call(th, data->recv, data->id, argc, argv, data->me, defined_class); } POP_TAG(); if (safe >= 0) @@ -1940,6 +1943,7 @@ umethod_bind(VALUE method, VALUE recv) { struct METHOD *data, *bound; VALUE methclass; + VALUE rclass; TypedData_Get_Struct(method, struct METHOD, &method_data_type, data); @@ -1961,8 +1965,18 @@ umethod_bind(VALUE method, VALUE recv) bound->me = ALLOC(rb_method_entry_t); *bound->me = *data->me; if (bound->me->def) bound->me->def->alias_count++; + rclass = CLASS_OF(recv); + if (BUILTIN_TYPE(bound->defined_class) == T_MODULE) { + VALUE ic = rb_class_search_ancestor(rclass, bound->defined_class); + if (ic) { + rclass = ic; + } + else { + rclass = rb_include_class_new(methclass, rclass); + } + } bound->recv = recv; - bound->rclass = CLASS_OF(recv); + bound->rclass = rclass; data->ume = ALLOC(struct unlinked_method_entry_list_entry); return method; diff --git a/test/ruby/envutil.rb b/test/ruby/envutil.rb index c89309d8453c60..fa130898d652fd 100644 --- a/test/ruby/envutil.rb +++ b/test/ruby/envutil.rb @@ -160,6 +160,22 @@ def with_default_internal(enc) end module_function :with_default_internal + def labeled_module(name, &block) + Module.new do + singleton_class.class_eval {define_method(:to_s) {name}; alias inspect to_s} + class_eval(&block) if block + end + end + module_function :labeled_module + + def labeled_class(name, superclass = Object, &block) + Class.new(superclass) do + singleton_class.class_eval {define_method(:to_s) {name}; alias inspect to_s} + class_eval(&block) if block + end + end + module_function :labeled_class + if /darwin/ =~ RUBY_PLATFORM DIAGNOSTIC_REPORTS_PATH = File.expand_path("~/Library/Logs/DiagnosticReports") DIAGNOSTIC_REPORTS_TIMEFORMAT = '%Y-%m-%d-%H%M%S' diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb index f89071c10f270b..ca453fa5eb57bd 100644 --- a/test/ruby/test_module.rb +++ b/test/ruby/test_module.rb @@ -1559,17 +1559,11 @@ def test_prepend_module_ancestors end def labeled_module(name, &block) - Module.new do - singleton_class.class_eval {define_method(:to_s) {name}; alias inspect to_s} - class_eval(&block) if block - end + EnvUtil.labeled_module(name, &block) end def labeled_class(name, superclass = Object, &block) - Class.new(superclass) do - singleton_class.class_eval {define_method(:to_s) {name}; alias inspect to_s} - class_eval(&block) if block - end + EnvUtil.labeled_class(name, superclass, &block) end def test_prepend_instance_methods_false diff --git a/test/ruby/test_super.rb b/test/ruby/test_super.rb index 82d6e19ec4ba1c..e42782191dbd91 100644 --- a/test/ruby/test_super.rb +++ b/test/ruby/test_super.rb @@ -271,12 +271,12 @@ def test_double_include2 end def test_super_in_instance_eval - super_class = Class.new { + super_class = EnvUtil.labeled_class("Super\u{30af 30e9 30b9}") { def foo return [:super, self] end } - sub_class = Class.new(super_class) { + sub_class = EnvUtil.labeled_class("Sub\u{30af 30e9 30b9}", super_class) { def foo x = Object.new x.instance_eval do @@ -285,18 +285,18 @@ def foo end } obj = sub_class.new - assert_raise(TypeError) do + assert_raise_with_message(TypeError, /Sub\u{30af 30e9 30b9}/) do obj.foo end end def test_super_in_instance_eval_with_define_method - super_class = Class.new { + super_class = EnvUtil.labeled_class("Super\u{30af 30e9 30b9}") { def foo return [:super, self] end } - sub_class = Class.new(super_class) { + sub_class = EnvUtil.labeled_class("Sub\u{30af 30e9 30b9}", super_class) { define_method(:foo) do x = Object.new x.instance_eval do @@ -305,18 +305,18 @@ def foo end } obj = sub_class.new - assert_raise(TypeError) do + assert_raise_with_message(TypeError, /Sub\u{30af 30e9 30b9}/) do obj.foo end end def test_super_in_orphan_block - super_class = Class.new { + super_class = EnvUtil.labeled_class("Super\u{30af 30e9 30b9}") { def foo return [:super, self] end } - sub_class = Class.new(super_class) { + sub_class = EnvUtil.labeled_class("Sub\u{30af 30e9 30b9}", super_class) { def foo x = Object.new lambda { super() } @@ -327,12 +327,12 @@ def foo end def test_super_in_orphan_block_with_instance_eval - super_class = Class.new { + super_class = EnvUtil.labeled_class("Super\u{30af 30e9 30b9}") { def foo return [:super, self] end } - sub_class = Class.new(super_class) { + sub_class = EnvUtil.labeled_class("Sub\u{30af 30e9 30b9}", super_class) { def foo x = Object.new x.instance_eval do @@ -341,7 +341,7 @@ def foo end } obj = sub_class.new - assert_raise(TypeError) do + assert_raise_with_message(TypeError, /Sub\u{30af 30e9 30b9}/) do obj.foo.call end end @@ -453,4 +453,45 @@ def foo; super end m.call end end + + def test_super_in_module_unbound_method + bug9721 = '[ruby-core:61936] [Bug #9721]' + + a = Module.new do + def foo(result) + result << "A" + end + end + + b = Module.new do + def foo(result) + result << "B" + super + end + end + + um = b.instance_method(:foo) + + m = um.bind(Object.new.extend(a)) + result = [] + assert_nothing_raised(NoMethodError, bug9721) do + m.call(result) + end + assert_equal(%w[B A], result, bug9721) + + bug9740 = '[ruby-core:62017] [Bug #9740]' + + b.module_eval do + define_method(:foo) do |result| + um.bind(self).call(result) + end + end + + result.clear + o = Object.new.extend(a).extend(b) + assert_nothing_raised(NoMethodError, SystemStackError, bug9740) do + o.foo(result) + end + assert_equal(%w[B A], result, bug9721) + end end diff --git a/version.h b/version.h index 6dcc86700ac56e..6288c7df770858 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-05-28" -#define RUBY_PATCHLEVEL 110 +#define RUBY_PATCHLEVEL 111 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 5 diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 55c051542566cd..8c7071a91ecf7e 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -2002,6 +2002,7 @@ vm_search_super_method(rb_thread_t *th, rb_control_frame_t *reg_cfp, rb_call_inf } if (BUILTIN_TYPE(current_defined_class) != T_MODULE && + BUILTIN_TYPE(current_defined_class) != T_ICLASS && /* bound UnboundMethod */ !FL_TEST(current_defined_class, RMODULE_INCLUDED_INTO_REFINEMENT) && !rb_obj_is_kind_of(ci->recv, current_defined_class)) { VALUE m = RB_TYPE_P(current_defined_class, T_ICLASS) ? @@ -2009,8 +2010,8 @@ vm_search_super_method(rb_thread_t *th, rb_control_frame_t *reg_cfp, rb_call_inf rb_raise(rb_eTypeError, "self has wrong type to call super in this context: " - "%s (expected %s)", - rb_obj_classname(ci->recv), rb_class2name(m)); + "%"PRIsVALUE" (expected %"PRIsVALUE")", + rb_obj_class(ci->recv), m); } switch (vm_search_superclass(GET_CFP(), iseq, sigval, ci)) { From 7ebed66e59efe774ebbd890f2a56c8a54498e22f Mon Sep 17 00:00:00 2001 From: nagachika Date: Tue, 27 May 2014 16:05:13 +0000 Subject: [PATCH 111/343] merge revision(s) r45604: [Backport #9748] * lib/fileutils.rb (FileUtils#copy_entry): update rdoc about preserve option and permissions, following r31123. [ruby-core:62065] [Bug #9748] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46192 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ lib/fileutils.rb | 4 ++-- version.h | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 26b58e731880cc..ff85c30fb91321 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Wed May 28 01:05:06 2014 Nobuyoshi Nakada + + * lib/fileutils.rb (FileUtils#copy_entry): update rdoc about + preserve option and permissions, following r31123. + [ruby-core:62065] [Bug #9748] + Wed May 28 00:57:06 2014 Nobuyoshi Nakada * proc.c (umethod_bind): use the ancestor iclass instead of new diff --git a/lib/fileutils.rb b/lib/fileutils.rb index 3b4e30213e4e79..2491a632a9bc10 100644 --- a/lib/fileutils.rb +++ b/lib/fileutils.rb @@ -455,8 +455,8 @@ def cp_r(src, dest, options = {}) # Both of +src+ and +dest+ must be a path name. # +src+ must exist, +dest+ must not exist. # - # If +preserve+ is true, this method preserves owner, group, permissions - # and modified time. + # If +preserve+ is true, this method preserves owner, group, and + # modified time. Permissions are copied regardless +preserve+. # # If +dereference_root+ is true, this method dereference tree root. # diff --git a/version.h b/version.h index 6288c7df770858..b41bcef92ae82b 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-05-28" -#define RUBY_PATCHLEVEL 111 +#define RUBY_PATCHLEVEL 112 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 5 From fc9677332a1f2ce41912b57886d4733d61d192f1 Mon Sep 17 00:00:00 2001 From: nagachika Date: Wed, 28 May 2014 14:38:54 +0000 Subject: [PATCH 112/343] merge revision(s) r45646: [Backport #9765] * ext/stringio/stringio.c (strio_putc): fix for non-ascii encoding, like as IO#putc. [ruby-dev:48114] [Bug #9765] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46213 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ ext/stringio/stringio.c | 16 ++++++++-------- test/stringio/test_stringio.rb | 16 ++++++++++++++++ version.h | 2 +- 4 files changed, 30 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index ff85c30fb91321..e484264525c0d0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed May 28 23:37:32 2014 Nobuyoshi Nakada + + * ext/stringio/stringio.c (strio_putc): fix for non-ascii + encoding, like as IO#putc. [ruby-dev:48114] [Bug #9765] + Wed May 28 01:05:06 2014 Nobuyoshi Nakada * lib/fileutils.rb (FileUtils#copy_entry): update rdoc about diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c index 3fef619de62213..fb8e7ce3ea8975 100644 --- a/ext/stringio/stringio.c +++ b/ext/stringio/stringio.c @@ -1233,17 +1233,17 @@ static VALUE strio_putc(VALUE self, VALUE ch) { struct StringIO *ptr = writable(self); - int c = NUM2CHR(ch); - long olen; + VALUE str; check_modifiable(ptr); - olen = RSTRING_LEN(ptr->string); - if (ptr->flags & FMODE_APPEND) { - ptr->pos = olen; + if (RB_TYPE_P(ch, T_STRING)) { + str = rb_str_substr(ch, 0, 1); } - strio_extend(ptr, ptr->pos, 1); - RSTRING_PTR(ptr->string)[ptr->pos++] = c; - OBJ_INFECT(ptr->string, self); + else { + char c = NUM2CHR(ch); + str = rb_str_new(&c, 1); + } + strio_write(self, str); return ch; } diff --git a/test/stringio/test_stringio.rb b/test/stringio/test_stringio.rb index f29322b393d95f..c7db91aae19247 100644 --- a/test/stringio/test_stringio.rb +++ b/test/stringio/test_stringio.rb @@ -419,6 +419,22 @@ def test_putc assert_equal("foo123", s) end + def test_putc_nonascii + s = "" + f = StringIO.new(s, "w") + f.putc("\u{3042}") + f.putc(0x3044) + f.close + assert_equal("\u{3042}D", s) + + s = "foo" + f = StringIO.new(s, "a") + f.putc("\u{3042}") + f.putc(0x3044) + f.close + assert_equal("foo\u{3042}D", s) + end + def test_read f = StringIO.new("\u3042\u3044") assert_raise(ArgumentError) { f.read(-1) } diff --git a/version.h b/version.h index b41bcef92ae82b..784d02f3bf4303 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-05-28" -#define RUBY_PATCHLEVEL 112 +#define RUBY_PATCHLEVEL 113 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 5 From b6fe6d591c53fc4b31eeafa4edae76cff5940d3e Mon Sep 17 00:00:00 2001 From: nagachika Date: Wed, 28 May 2014 14:44:07 +0000 Subject: [PATCH 113/343] merge revision(s) r45701: [Backport #9771] * ext/openssl/ossl_asn1.c (ossl_asn1_initialize): SYMID on a value other than Symbol is an undefined behavior. fix up r31699. [ruby-core:62142] [Bug #9771] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46214 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ ext/openssl/ossl_asn1.c | 2 +- version.h | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index e484264525c0d0..d9ccc2ce5ff567 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Wed May 28 23:40:57 2014 Nobuyoshi Nakada + + * ext/openssl/ossl_asn1.c (ossl_asn1_initialize): SYMID on a value + other than Symbol is an undefined behavior. fix up r31699. + [ruby-core:62142] [Bug #9771] + Wed May 28 23:37:32 2014 Nobuyoshi Nakada * ext/stringio/stringio.c (strio_putc): fix for non-ascii diff --git a/ext/openssl/ossl_asn1.c b/ext/openssl/ossl_asn1.c index c2344affa69145..efdfbfc8aa232b 100644 --- a/ext/openssl/ossl_asn1.c +++ b/ext/openssl/ossl_asn1.c @@ -1150,7 +1150,7 @@ ossl_asn1_initialize(int argc, VALUE *argv, VALUE self) } if(!SYMBOL_P(tag_class)) ossl_raise(eASN1Error, "invalid tag class"); - if(SYM2ID(tagging) == sIMPLICIT && NUM2INT(tag) > 31) + if(!NIL_P(tagging) && SYM2ID(tagging) == sIMPLICIT && NUM2INT(tag) > 31) ossl_raise(eASN1Error, "tag number for Universal too large"); } else{ diff --git a/version.h b/version.h index 784d02f3bf4303..9e01dce69bee3c 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-05-28" -#define RUBY_PATCHLEVEL 113 +#define RUBY_PATCHLEVEL 114 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 5 From 60eeeb70df15cc77724b454d40e02d040da8f1f1 Mon Sep 17 00:00:00 2001 From: nagachika Date: Wed, 28 May 2014 14:54:49 +0000 Subject: [PATCH 114/343] merge revision(s) r45716: [Backport #9665] * configure.in (rb_cv_func___builtin_unreachable): try with an external variable not only by a warning, which might not be shown due to the optimization. [ruby-core:61647] [Bug #9665] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46215 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ configure.in | 4 ++-- version.h | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index d9ccc2ce5ff567..443a8c2b2a6a2e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Wed May 28 23:47:22 2014 Nobuyoshi Nakada + + * configure.in (rb_cv_func___builtin_unreachable): try with an + external variable not only by a warning, which might not be + shown due to the optimization. [ruby-core:61647] [Bug #9665] + Wed May 28 23:40:57 2014 Nobuyoshi Nakada * ext/openssl/ossl_asn1.c (ossl_asn1_initialize): SYMID on a value diff --git a/configure.in b/configure.in index 1a001e62530db7..bf337f09ce9c79 100644 --- a/configure.in +++ b/configure.in @@ -1548,8 +1548,8 @@ if test "$GCC" = yes; then AC_CACHE_CHECK(for __builtin_unreachable, rb_cv_func___builtin_unreachable, [RUBY_WERROR_FLAG( - [AC_TRY_LINK([@%:@include ], - [exit(0); __builtin_unreachable();], + [AC_TRY_LINK([volatile int zero;], + [if (zero) __builtin_unreachable();], [rb_cv_func___builtin_unreachable=yes], [rb_cv_func___builtin_unreachable=no]) ]) diff --git a/version.h b/version.h index 9e01dce69bee3c..e2fcf231bb9798 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-05-28" -#define RUBY_PATCHLEVEL 114 +#define RUBY_PATCHLEVEL 115 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 5 From 74d6b68229bd9cd85bc412309aa1a17c9529b374 Mon Sep 17 00:00:00 2001 From: nagachika Date: Thu, 29 May 2014 12:07:33 +0000 Subject: [PATCH 115/343] merge revision(s) r45187,r45205,r45206,r45212,r45213: [Backport #9570] * numeric.c (ruby_num_interval_step_size): check signs and get rid of implementation dependent behavior of negative division. [ruby-core:61106] [Bug #9570] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46226 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ numeric.c | 18 +++++++++++++----- test/ruby/test_numeric.rb | 23 +++++++++++++++++++---- version.h | 6 +++--- 4 files changed, 41 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 443a8c2b2a6a2e..b08393df2f08a1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Thu May 29 20:57:59 2014 Nobuyoshi Nakada + + * numeric.c (ruby_num_interval_step_size): check signs and get rid + of implementation dependent behavior of negative division. + [ruby-core:61106] [Bug #9570] + Wed May 28 23:47:22 2014 Nobuyoshi Nakada * configure.in (rb_cv_func___builtin_unreachable): try with an diff --git a/numeric.c b/numeric.c index 734ab3455ba546..de0e0a2c4d9c6f 100644 --- a/numeric.c +++ b/numeric.c @@ -1799,21 +1799,29 @@ VALUE ruby_num_interval_step_size(VALUE from, VALUE to, VALUE step, int excl) { if (FIXNUM_P(from) && FIXNUM_P(to) && FIXNUM_P(step)) { - long delta, diff, result; + long delta, diff; diff = FIX2LONG(step); + if (!diff) rb_num_zerodiv(); delta = FIX2LONG(to) - FIX2LONG(from); + if (diff < 0) { + diff = -diff; + delta = -delta; + } if (excl) { - delta += (diff > 0 ? -1 : +1); + delta--; + } + if (delta < 0) { + return INT2FIX(0); } - result = delta / diff; - return LONG2FIX(result >= 0 ? result + 1 : 0); + return ULONG2NUM(delta / diff + 1UL); } else if (RB_TYPE_P(from, T_FLOAT) || RB_TYPE_P(to, T_FLOAT) || RB_TYPE_P(step, T_FLOAT)) { double n = ruby_float_step_size(NUM2DBL(from), NUM2DBL(to), NUM2DBL(step), excl); if (isinf(n)) return DBL2NUM(n); - return LONG2FIX(n); + if (POSFIXABLE(n)) return LONG2FIX(n); + return rb_dbl2big(n); } else { VALUE result; diff --git a/test/ruby/test_numeric.rb b/test/ruby/test_numeric.rb index f2c1a51ba20df2..f3fc66337702d7 100644 --- a/test/ruby/test_numeric.rb +++ b/test/ruby/test_numeric.rb @@ -223,6 +223,8 @@ def assert_step(expected, (from, *args), inf: false) end def test_step + i, bignum = 32, 1 << 30 + bignum <<= (i <<= 1) - 32 until bignum.is_a?(Bignum) assert_raise(ArgumentError) { 1.step(10, 1, 0) { } } assert_raise(ArgumentError) { 1.step(10, 1, 0).size } assert_raise(ArgumentError) { 1.step(10, 0) { } } @@ -238,6 +240,17 @@ def test_step assert_nothing_raised { 1.step(by: nil) } assert_nothing_raised { 1.step(by: nil).size } + assert_equal(bignum*2+1, (-bignum).step(bignum, 1).size) + assert_equal(bignum*2, (-bignum).step(bignum-1, 1).size) + + assert_equal(10+1, (0.0).step(10.0, 1.0).size) + + i, bigflo = 1, bignum.to_f + i <<= 1 until (bigflo - i).to_i < bignum + bigflo -= i >> 1 + assert_equal(bigflo.to_i, (0.0).step(bigflo-1.0, 1.0).size) + assert_operator((0.0).step(bignum.to_f, 1.0).size, :>=, bignum) # may loose precision + assert_step [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 10] assert_step [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, to: 10] assert_step [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, to: 10, by: nil] @@ -248,15 +261,17 @@ def test_step assert_step [10, 8, 6, 4, 2], [10, to: 1, by: -2] assert_step [1.0, 3.0, 5.0, 7.0, 9.0], [1.0, 10.0, 2.0] assert_step [1.0, 3.0, 5.0, 7.0, 9.0], [1.0, to: 10.0, by: 2.0] - assert_step [1], [1, 10, 2**32] - assert_step [1], [1, to: 10, by: 2**32] + assert_step [1], [1, 10, bignum] + assert_step [1], [1, to: 10, by: bignum] + assert_step [], [2, 1, 3] + assert_step [], [-2, -1, -3] assert_step [3, 3, 3, 3], [3, by: 0], inf: true - assert_step [10], [10, 1, -(2**32)] + assert_step [10], [10, 1, -bignum] assert_step [], [1, 0, Float::INFINITY] assert_step [], [0, 1, -Float::INFINITY] - assert_step [10], [10, to: 1, by: -(2**32)] + assert_step [10], [10, to: 1, by: -bignum] assert_step [10, 11, 12, 13], [10], inf: true assert_step [10, 9, 8, 7], [10, by: -1], inf: true diff --git a/version.h b/version.h index e2fcf231bb9798..16d53386382a70 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.2" -#define RUBY_RELEASE_DATE "2014-05-28" -#define RUBY_PATCHLEVEL 115 +#define RUBY_RELEASE_DATE "2014-05-29" +#define RUBY_PATCHLEVEL 116 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 5 -#define RUBY_RELEASE_DAY 28 +#define RUBY_RELEASE_DAY 29 #include "ruby/version.h" From fca433e2fdc014b742d22dcbd0d62e4ad83a1cea Mon Sep 17 00:00:00 2001 From: nagachika Date: Thu, 29 May 2014 15:19:03 +0000 Subject: [PATCH 116/343] merge revision(s) r45178,r45180,r45183: [Backport #9568] eval.c: remove unneeded GC guard * eval.c (setup_exception): remove RB_GC_GUARD which is no longer needed since r41598. * eval.c (setup_exception): preserve errinfo across calling #to_s method on the exception. [ruby-core:61091] [Bug #9568] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46236 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ eval.c | 5 ++++- test/ruby/test_exception.rb | 22 ++++++++++++++++++++++ version.h | 6 +++--- 4 files changed, 34 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index b08393df2f08a1..6e6c0543882a5d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Fri May 30 00:13:19 2014 Nobuyoshi Nakada + + * eval.c (setup_exception): preserve errinfo across calling #to_s + method on the exception. [ruby-core:61091] [Bug #9568] + Thu May 29 20:57:59 2014 Nobuyoshi Nakada * numeric.c (ruby_num_interval_step_size): check signs and get rid diff --git a/eval.c b/eval.c index 841b3671e3b794..d4dcaa1111fb36 100644 --- a/eval.c +++ b/eval.c @@ -507,9 +507,12 @@ setup_exception(rb_thread_t *th, int tag, volatile VALUE mesg) !rb_obj_is_kind_of(e, rb_eSystemExit)) { int status; + mesg = e; PUSH_TAG(); if ((status = EXEC_TAG()) == 0) { - RB_GC_GUARD(e) = rb_obj_as_string(e); + th->errinfo = Qnil; + e = rb_obj_as_string(mesg); + th->errinfo = mesg; if (file && line) { warn_printf("Exception `%s' at %s:%d - %"PRIsVALUE"\n", rb_obj_classname(th->errinfo), file, line, e); diff --git a/test/ruby/test_exception.rb b/test/ruby/test_exception.rb index dfa428912e0e68..f358c00f97d5c1 100644 --- a/test/ruby/test_exception.rb +++ b/test/ruby/test_exception.rb @@ -78,6 +78,28 @@ def test_exception_ensure_2 # just duplication? assert(!bad) end + def test_errinfo_in_debug + bug9568 = EnvUtil.labeled_class("[ruby-core:61091] [Bug #9568]", RuntimeError) do + def to_s + require '\0' + rescue LoadError + self.class.to_s + end + end + + err = EnvUtil.verbose_warning do + assert_raise(bug9568) do + $DEBUG, debug = true, $DEBUG + begin + raise bug9568 + ensure + $DEBUG = debug + end + end + end + assert_include(err, bug9568.to_s) + end + def test_break_ensure bad = true while true diff --git a/version.h b/version.h index 16d53386382a70..f6cc9b838a66ea 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.2" -#define RUBY_RELEASE_DATE "2014-05-29" -#define RUBY_PATCHLEVEL 116 +#define RUBY_RELEASE_DATE "2014-05-30" +#define RUBY_PATCHLEVEL 117 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 5 -#define RUBY_RELEASE_DAY 29 +#define RUBY_RELEASE_DAY 30 #include "ruby/version.h" From 5a22835c22c3d95968b418c31cd23a28f978890f Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 1 Jun 2014 16:55:58 +0000 Subject: [PATCH 117/343] merge revision(s) r45350: [Backport #9645] * variable.c (rb_const_set): delete existing entry on redefinition [Bug #9645] * test/ruby/test_const.rb (test_redefinition): test for leak git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46301 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ test/ruby/test_const.rb | 8 ++++++++ variable.c | 2 ++ version.h | 8 ++++---- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6e6c0543882a5d..199f29dd7182d6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Mon Jun 2 01:46:43 2014 Eric Wong + + * variable.c (rb_const_set): delete existing entry on redefinition + [Bug #9645] + * test/ruby/test_const.rb (test_redefinition): test for leak + Fri May 30 00:13:19 2014 Nobuyoshi Nakada * eval.c (setup_exception): preserve errinfo across calling #to_s diff --git a/test/ruby/test_const.rb b/test/ruby/test_const.rb index dab45b7e0870d7..c4a4d93249feed 100644 --- a/test/ruby/test_const.rb +++ b/test/ruby/test_const.rb @@ -1,5 +1,6 @@ # -*- coding: us-ascii -*- require 'test/unit' +require_relative 'envutil' class TestConst < Test::Unit::TestCase TEST1 = 1 @@ -54,5 +55,12 @@ def test_redefinition #{__FILE__}:#{__LINE__-1}: warning: already initialized constant #{c}::X #{__FILE__}:#{__LINE__-3}: warning: previous definition of X was here WARNING + code = <<-PRE +olderr = $stderr.dup +$stderr.reopen(File::NULL, "wb") +350000.times { FOO = :BAR } +$stderr.reopen(olderr) +PRE + assert_no_memory_leak([], '', code, 'redefined constant') end end diff --git a/variable.c b/variable.c index 424730dcb9dced..e53dc8207fd397 100644 --- a/variable.c +++ b/variable.c @@ -2203,6 +2203,8 @@ rb_const_set(VALUE klass, ID id, VALUE val) rb_compile_warn(RSTRING_PTR(ce->file), ce->line, "previous definition of %"PRIsVALUE" was here", name); } + st_delete(RCLASS_CONST_TBL(klass), &id, 0); + xfree(ce); } } } diff --git a/version.h b/version.h index f6cc9b838a66ea..9a5fe47a5c6c7d 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.2" -#define RUBY_RELEASE_DATE "2014-05-30" -#define RUBY_PATCHLEVEL 117 +#define RUBY_RELEASE_DATE "2014-06-02" +#define RUBY_PATCHLEVEL 118 #define RUBY_RELEASE_YEAR 2014 -#define RUBY_RELEASE_MONTH 5 -#define RUBY_RELEASE_DAY 30 +#define RUBY_RELEASE_MONTH 6 +#define RUBY_RELEASE_DAY 2 #include "ruby/version.h" From 5d2ea90418937eb7ad56bf1950e1864c68c6e5cd Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 1 Jun 2014 17:03:53 +0000 Subject: [PATCH 118/343] merge revision(s) r45320,r45321: [Backport #9622] * vm_insnhelper.c (vm_callee_setup_arg): turn a macro into an inline function. * vm_insnhelper.c (vm_callee_setup_arg): disable fastpath if splat argument, since argc may differ for each calls. [ruby-core:61422] [Bug #9622] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46302 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ test/ruby/test_call.rb | 15 +++++++++++++++ version.h | 2 +- vm_insnhelper.c | 36 +++++++++++++++++++++++------------- 4 files changed, 44 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 199f29dd7182d6..45492614752fed 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Mon Jun 2 01:57:59 2014 Nobuyoshi Nakada + + * vm_insnhelper.c (vm_callee_setup_arg): turn a macro into an + inline function. + Mon Jun 2 01:46:43 2014 Eric Wong * variable.c (rb_const_set): delete existing entry on redefinition diff --git a/test/ruby/test_call.rb b/test/ruby/test_call.rb index 8f861d96a18b4a..5b81eb187ad1bd 100644 --- a/test/ruby/test_call.rb +++ b/test/ruby/test_call.rb @@ -16,4 +16,19 @@ def test_call assert_equal([1, 2, 3, 4], aaa(1, 2, 3, 4)) assert_equal([1, 2, 3, 4], aaa(1, *[2, 3, 4])) end + + def test_callinfo + bug9622 = '[ruby-core:61422] [Bug #9622]' + o = Class.new do + def foo(*args) + bar(:foo, *args) + end + def bar(name) + name + end + end.new + e = assert_raise(ArgumentError) {o.foo(100)} + assert_nothing_raised(ArgumentError) {o.foo} + assert_raise_with_message(ArgumentError, e.message, bug9622) {o.foo(100)} + end end diff --git a/version.h b/version.h index 9a5fe47a5c6c7d..bf5f05be35bef3 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-06-02" -#define RUBY_PATCHLEVEL 118 +#define RUBY_PATCHLEVEL 119 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 6 diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 8c7071a91ecf7e..9e1dbe16a93cc1 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -1196,23 +1196,33 @@ static VALUE vm_call_iseq_setup_2(rb_thread_t *th, rb_control_frame_t *cfp, rb_c static inline VALUE vm_call_iseq_setup_normal(rb_thread_t *th, rb_control_frame_t *cfp, rb_call_info_t *ci); static inline VALUE vm_call_iseq_setup_tailcall(rb_thread_t *th, rb_control_frame_t *cfp, rb_call_info_t *ci); -#define VM_CALLEE_SETUP_ARG(th, ci, iseq, argv, is_lambda) \ - if (LIKELY((iseq)->arg_simple & 0x01)) { \ - /* simple check */ \ - if ((ci)->argc != (iseq)->argc) { \ - argument_error((iseq), ((ci)->argc), (iseq)->argc, (iseq)->argc); \ - } \ - (ci)->aux.opt_pc = 0; \ - CI_SET_FASTPATH((ci), UNLIKELY((ci)->flag & VM_CALL_TAILCALL) ? vm_call_iseq_setup_tailcall : vm_call_iseq_setup_normal, !(is_lambda) && !((ci)->me->flag & NOEX_PROTECTED)); \ - } \ - else { \ - (ci)->aux.opt_pc = vm_callee_setup_arg_complex((th), (ci), (iseq), (argv)); \ +static inline void +vm_callee_setup_arg(rb_thread_t *th, rb_call_info_t *ci, const rb_iseq_t *iseq, + VALUE *argv, int is_lambda) +{ + if (LIKELY(iseq->arg_simple & 0x01)) { + /* simple check */ + if (ci->argc != iseq->argc) { + argument_error(iseq, ci->argc, iseq->argc, iseq->argc); + } + ci->aux.opt_pc = 0; + CI_SET_FASTPATH(ci, + (UNLIKELY(ci->flag & VM_CALL_TAILCALL) ? + vm_call_iseq_setup_tailcall : + vm_call_iseq_setup_normal), + (!is_lambda && + !(ci->flag & VM_CALL_ARGS_SPLAT) && /* argc may differ for each calls */ + !(ci->me->flag & NOEX_PROTECTED))); + } + else { + ci->aux.opt_pc = vm_callee_setup_arg_complex(th, ci, iseq, argv); } +} static VALUE vm_call_iseq_setup(rb_thread_t *th, rb_control_frame_t *cfp, rb_call_info_t *ci) { - VM_CALLEE_SETUP_ARG(th, ci, ci->me->def->body.iseq, cfp->sp - ci->argc, 0); + vm_callee_setup_arg(th, ci, ci->me->def->body.iseq, cfp->sp - ci->argc, 0); return vm_call_iseq_setup_2(th, cfp, ci); } @@ -2300,7 +2310,7 @@ vm_yield_setup_args(rb_thread_t * const th, const rb_iseq_t *iseq, ci_entry.flag = 0; ci_entry.argc = argc; ci_entry.blockptr = (rb_block_t *)blockptr; - VM_CALLEE_SETUP_ARG(th, &ci_entry, iseq, argv, 1); + vm_callee_setup_arg(th, &ci_entry, iseq, argv, 1); return ci_entry.aux.opt_pc; } else { From 52950d94d192d5d8907a254705d683f554eb7d91 Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 1 Jun 2014 17:07:21 +0000 Subject: [PATCH 119/343] merge revision(s) r45365: [Backport #9656] dl/extconf.rb: check for -fno-defer-pop option * ext/dl/extconf.rb: check for -fno-defer-pop option, since clang 5.1 no longer support -fno-defer-pop option. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46303 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/dl/extconf.rb | 7 ++++++- version.h | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ext/dl/extconf.rb b/ext/dl/extconf.rb index 4ef46f85fb1415..53e73c3a8b9e43 100644 --- a/ext/dl/extconf.rb +++ b/ext/dl/extconf.rb @@ -1,7 +1,12 @@ require 'mkmf' if RbConfig::CONFIG['GCC'] == 'yes' - (have_macro("__clang__") ? $LDFLAGS : $CFLAGS) << " -fno-defer-pop" + flag = " -fno-defer-pop" + if have_macro("__clang__") + $LDFLAGS << flag if try_ldflags(flag) + else + $CFLAGS << flag + end $CFLAGS << " -fno-omit-frame-pointer" end diff --git a/version.h b/version.h index bf5f05be35bef3..86afe2ed2b8e69 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-06-02" -#define RUBY_PATCHLEVEL 119 +#define RUBY_PATCHLEVEL 120 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 6 From 282462b206b0d6643f272e1e4a4b45f148688b18 Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 1 Jun 2014 17:17:44 +0000 Subject: [PATCH 120/343] merge revision(s) r45364,r45395,r45396,r45403,r45406: [Backport #9652] * time.c (time_mload): freeze and preserve marshal-loaded time zone * test/ruby/test_time.rb: add test for GC on loaded object [Bug #9652] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46304 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ test/ruby/test_time.rb | 15 +++++++++++++++ time.c | 2 ++ version.h | 2 +- 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 45492614752fed..f2b4999c6de13b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Mon Jun 2 02:12:10 2014 Eric Wong + + * time.c (time_mload): freeze and preserve marshal-loaded time zone + * test/ruby/test_time.rb: add test for GC on loaded object + [Bug #9652] + Mon Jun 2 01:57:59 2014 Nobuyoshi Nakada * vm_insnhelper.c (vm_callee_setup_arg): turn a macro into an diff --git a/test/ruby/test_time.rb b/test/ruby/test_time.rb index 744ac4c39f8b6d..d016812e3a5341 100644 --- a/test/ruby/test_time.rb +++ b/test/ruby/test_time.rb @@ -311,6 +311,21 @@ def test_marshal_zone end end + def test_marshal_zone_gc + assert_separately(%w(--disable-gems), <<-'end;', timeout: 30) + ENV["TZ"] = "JST-9" + s = Marshal.dump(Time.now) + t = Marshal.load(s) + n = 0 + done = 100000 + while t.zone.dup == "JST" && n < done + n += 1 + end + assert_equal done, n, "Bug #9652" + assert_equal "JST", t.zone, "Bug #9652" + end; + end + def test_marshal_to_s t1 = Time.new(2011,11,8, 0,42,25, 9*3600) t2 = Time.at(Marshal.load(Marshal.dump(t1))) diff --git a/time.c b/time.c index c01ca743d59a02..d5215edde11825 100644 --- a/time.c +++ b/time.c @@ -4805,7 +4805,9 @@ end_submicro: ; time_fixoff(time); } if (!NIL_P(zone)) { + zone = rb_str_new_frozen(zone); tobj->vtm.zone = RSTRING_PTR(zone); + rb_ivar_set(time, id_zone, zone); } return time; diff --git a/version.h b/version.h index 86afe2ed2b8e69..797a56c0eec097 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-06-02" -#define RUBY_PATCHLEVEL 120 +#define RUBY_PATCHLEVEL 121 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 6 From e373773ab3b798fc80ab0424e27f8e870d25908f Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 1 Jun 2014 17:21:10 +0000 Subject: [PATCH 121/343] merge revision(s) r45471: [Backport #9688] * win32/win32.c (rb_w32_accept, open_ifs_socket, socketpair_internal): reset inherit flag of socket to avoid unintentional inheritance of socket. note that the return value of SetHandleInformation() is not verified intentionally because old Windows may return an error. [Bug #9688] [ruby-core:61754] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46305 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ version.h | 2 +- win32/win32.c | 4 ++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index f2b4999c6de13b..22703a05478947 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Mon Jun 2 02:19:30 2014 NAKAMURA Usaku + + * win32/win32.c (rb_w32_accept, open_ifs_socket, socketpair_internal): + reset inherit flag of socket to avoid unintentional inheritance of + socket. note that the return value of SetHandleInformation() is not + verified intentionally because old Windows may return an error. + [Bug #9688] [ruby-core:61754] + Mon Jun 2 02:12:10 2014 Eric Wong * time.c (time_mload): freeze and preserve marshal-loaded time zone diff --git a/version.h b/version.h index 797a56c0eec097..577266a659eacd 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-06-02" -#define RUBY_PATCHLEVEL 121 +#define RUBY_PATCHLEVEL 122 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 6 diff --git a/win32/win32.c b/win32/win32.c index 2c888ae4c4a192..9fd981ec560aa3 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -3017,6 +3017,7 @@ rb_w32_accept(int s, struct sockaddr *addr, int *addrlen) if (fd != -1) { r = accept(TO_SOCKET(s), addr, addrlen); if (r != INVALID_SOCKET) { + SetHandleInformation((HANDLE)r, HANDLE_FLAG_INHERIT, 0); MTHREAD_ONLY(EnterCriticalSection(&(_pioinfo(fd)->lock))); _set_osfhnd(fd, r); MTHREAD_ONLY(LeaveCriticalSection(&_pioinfo(fd)->lock)); @@ -3557,6 +3558,8 @@ open_ifs_socket(int af, int type, int protocol) } if (out == INVALID_SOCKET) out = WSASocket(af, type, protocol, NULL, 0, 0); + if (out != INVALID_SOCKET) + SetHandleInformation((HANDLE)out, HANDLE_FLAG_INHERIT, 0); } free(proto_buffers); @@ -3790,6 +3793,7 @@ socketpair_internal(int af, int type, int protocol, SOCKET *sv) r = accept(svr, addr, &len); if (r == INVALID_SOCKET) break; + SetHandleInformation((HANDLE)r, HANDLE_FLAG_INHERIT, 0); ret = 0; } while (0); From 16318094451bdcc3964cbdd3774f4d466e20303b Mon Sep 17 00:00:00 2001 From: nagachika Date: Mon, 2 Jun 2014 15:48:24 +0000 Subject: [PATCH 122/343] merge revision(s) r45302: [Backport #9616] * class.c (rb_class_subclass_add): use xmalloc * class.c (rb_module_add_to_subclasses_list): ditto * class.c (rb_class_remove_from_super_subclasses): use xfree * class.c (rb_class_remove_from_module_subclasses): ditto [Bug #9616] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46319 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ class.c | 8 ++++---- version.h | 6 +++--- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 22703a05478947..cd46b559606fff 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Tue Jun 3 00:38:33 2014 Eric Wong + + * class.c (rb_class_subclass_add): use xmalloc + * class.c (rb_module_add_to_subclasses_list): ditto + * class.c (rb_class_remove_from_super_subclasses): use xfree + * class.c (rb_class_remove_from_module_subclasses): ditto + [Bug #9616] + Mon Jun 2 02:19:30 2014 NAKAMURA Usaku * win32/win32.c (rb_w32_accept, open_ifs_socket, socketpair_internal): diff --git a/class.c b/class.c index bf9b2bb43e5d63..e4ccbc9fc15e5b 100644 --- a/class.c +++ b/class.c @@ -42,7 +42,7 @@ rb_class_subclass_add(VALUE super, VALUE klass) rb_subclass_entry_t *entry, *head; if (super && super != Qundef) { - entry = malloc(sizeof(*entry)); + entry = xmalloc(sizeof(*entry)); entry->klass = klass; entry->next = NULL; @@ -62,7 +62,7 @@ rb_module_add_to_subclasses_list(VALUE module, VALUE iclass) { rb_subclass_entry_t *entry, *head; - entry = malloc(sizeof(*entry)); + entry = xmalloc(sizeof(*entry)); entry->klass = iclass; entry->next = NULL; @@ -88,7 +88,7 @@ rb_class_remove_from_super_subclasses(VALUE klass) if (entry->next) { RCLASS_EXT(entry->next->klass)->parent_subclasses = RCLASS_EXT(klass)->parent_subclasses; } - free(entry); + xfree(entry); } RCLASS_EXT(klass)->parent_subclasses = NULL; @@ -107,7 +107,7 @@ rb_class_remove_from_module_subclasses(VALUE klass) RCLASS_EXT(entry->next->klass)->module_subclasses = RCLASS_EXT(klass)->module_subclasses; } - free(entry); + xfree(entry); } RCLASS_EXT(klass)->module_subclasses = NULL; diff --git a/version.h b/version.h index 577266a659eacd..df71180332c6a7 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.2" -#define RUBY_RELEASE_DATE "2014-06-02" -#define RUBY_PATCHLEVEL 122 +#define RUBY_RELEASE_DATE "2014-06-03" +#define RUBY_PATCHLEVEL 123 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 6 -#define RUBY_RELEASE_DAY 2 +#define RUBY_RELEASE_DAY 3 #include "ruby/version.h" From 1b32155cf8542876eb9153c2b6693bd3f5ab697d Mon Sep 17 00:00:00 2001 From: nagachika Date: Fri, 6 Jun 2014 16:23:54 +0000 Subject: [PATCH 123/343] merge revision(s) r45517,r45544,r45924: signal.c: check stack overflow by SP * signal.c (check_stack_overflow): raise SystemStackError if SP register and fault address is in the same page, on x86 linux. [EXPERIMENTAL] * signal.c (check_stack_overflow): Don't use ucontext_t if ucontext.h is not available. Fixes build on Android (x86). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46367 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ signal.c | 32 ++++++++++++++++++++++++++++++-- version.h | 6 +++--- 3 files changed, 39 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index cd46b559606fff..e861bd1b30c94c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sat Jun 7 01:17:16 2014 Tanaka Akira + + * signal.c (check_stack_overflow): Don't use ucontext_t if ucontext.h + is not available. + Fixes build on Android (x86). + Tue Jun 3 00:38:33 2014 Eric Wong * class.c (rb_class_subclass_add): use xmalloc diff --git a/signal.c b/signal.c index 96277e322cd449..d82f4c7e2b2360 100644 --- a/signal.c +++ b/signal.c @@ -628,21 +628,49 @@ rb_get_next_signal(void) #if defined(USE_SIGALTSTACK) || defined(_WIN32) +NORETURN(void ruby_thread_stack_overflow(rb_thread_t *th)); +#if defined(HAVE_UCONTEXT_H) && defined __linux__ && (defined __i386__ || defined __x86_64__) +# define USE_UCONTEXT_REG 1 +#endif +#ifdef USE_UCONTEXT_REG +static void +check_stack_overflow(const uintptr_t addr, const ucontext_t *ctx) +{ +# if defined REG_RSP + const greg_t sp = ctx->uc_mcontext.gregs[REG_RSP]; +# else + const greg_t sp = ctx->uc_mcontext.gregs[REG_ESP]; +# endif + enum {pagesize = 4096}; + const uintptr_t sp_page = (uintptr_t)sp / pagesize; + const uintptr_t fault_page = addr / pagesize; + + /* SP in ucontext is not decremented yet when `push` failed, so + * the fault page can be the next. */ + if (sp_page == fault_page || sp_page == fault_page + 1) { + ruby_thread_stack_overflow(GET_THREAD()); + } +} +#else static void check_stack_overflow(const void *addr) { int ruby_stack_overflowed_p(const rb_thread_t *, const void *); - NORETURN(void ruby_thread_stack_overflow(rb_thread_t *th)); rb_thread_t *th = GET_THREAD(); if (ruby_stack_overflowed_p(th, addr)) { ruby_thread_stack_overflow(th); } } +#endif #ifdef _WIN32 #define CHECK_STACK_OVERFLOW() check_stack_overflow(0) #else #define FAULT_ADDRESS info->si_addr -#define CHECK_STACK_OVERFLOW() check_stack_overflow(FAULT_ADDRESS) +# ifdef USE_UCONTEXT_REG +# define CHECK_STACK_OVERFLOW() check_stack_overflow((uintptr_t)FAULT_ADDRESS, ctx) +#else +# define CHECK_STACK_OVERFLOW() check_stack_overflow(FAULT_ADDRESS) +#endif #define MESSAGE_FAULT_ADDRESS " at %p", FAULT_ADDRESS #endif #else diff --git a/version.h b/version.h index df71180332c6a7..7d87fa57aeb18f 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.2" -#define RUBY_RELEASE_DATE "2014-06-03" -#define RUBY_PATCHLEVEL 123 +#define RUBY_RELEASE_DATE "2014-06-07" +#define RUBY_PATCHLEVEL 124 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 6 -#define RUBY_RELEASE_DAY 3 +#define RUBY_RELEASE_DAY 7 #include "ruby/version.h" From dcdf8e1c858fd427ea8d20d8641c9827654c977a Mon Sep 17 00:00:00 2001 From: nagachika Date: Tue, 10 Jun 2014 15:38:34 +0000 Subject: [PATCH 124/343] * test/ruby/test_string (test_LSHIFT_neary_long_max): extend timeout. this test fails on some CI environment by timeout. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46398 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ test/ruby/test_string.rb | 2 +- version.h | 6 +++--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index e861bd1b30c94c..2805370e9e8fda 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed Jun 11 00:36:05 2014 CHIKANAGA Tomoyuki + + * test/ruby/test_string (test_LSHIFT_neary_long_max): extend timeout. + this test fails on some CI environment by timeout. + Sat Jun 7 01:17:16 2014 Tanaka Akira * signal.c (check_stack_overflow): Don't use ucontext_t if ucontext.h diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb index 57cea652b17934..3f65826ec36daa 100644 --- a/test/ruby/test_string.rb +++ b/test/ruby/test_string.rb @@ -2222,7 +2222,7 @@ def =~(str) def test_LSHIFT_neary_long_max return unless @cls == String - assert_ruby_status([], <<-'end;', '[ruby-core:61886] [Bug #9709]') + assert_ruby_status([], <<-'end;', '[ruby-core:61886] [Bug #9709]', timeout: 20) begin a = "a" * 0x4000_0000 a << "a" * 0x1_0000 diff --git a/version.h b/version.h index 7d87fa57aeb18f..f979b4abc39237 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.2" -#define RUBY_RELEASE_DATE "2014-06-07" -#define RUBY_PATCHLEVEL 124 +#define RUBY_RELEASE_DATE "2014-06-11" +#define RUBY_PATCHLEVEL 125 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 6 -#define RUBY_RELEASE_DAY 7 +#define RUBY_RELEASE_DAY 11 #include "ruby/version.h" From 00e41e7174f2ae3e280c23b8056f24ae1b85b8dc Mon Sep 17 00:00:00 2001 From: nagachika Date: Tue, 10 Jun 2014 17:24:24 +0000 Subject: [PATCH 125/343] merge revision(s) r45207,r45208,r45209,r45210: [Backport #9575] * numeric.c: Create var for rb_intern("<=>") * numeric.c: Fix Numeric#step with 0 unit [Bug #9575] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46401 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ numeric.c | 43 +++++++++++++++++++++++++-------------- test/ruby/test_numeric.rb | 14 +++++++++++++ version.h | 2 +- 4 files changed, 47 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2805370e9e8fda..012c58fa72026e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Wed Jun 11 02:18:34 2014 Marc-Andre Lafortune + + * numeric.c: Fix Numeric#step with 0 unit [Bug #9575] + Wed Jun 11 00:36:05 2014 CHIKANAGA Tomoyuki * test/ruby/test_string (test_LSHIFT_neary_long_max): extend timeout. diff --git a/numeric.c b/numeric.c index de0e0a2c4d9c6f..2de8c699273a99 100644 --- a/numeric.c +++ b/numeric.c @@ -105,7 +105,7 @@ static VALUE fix_uminus(VALUE num); static VALUE fix_mul(VALUE x, VALUE y); static VALUE int_pow(long x, unsigned long y); -static ID id_coerce, id_to_i, id_eq, id_div; +static ID id_coerce, id_to_i, id_eq, id_div, id_cmp; VALUE rb_cNumeric; VALUE rb_cFloat; @@ -1164,7 +1164,7 @@ flo_cmp(VALUE x, VALUE y) if (a > 0.0) return INT2FIX(1); return INT2FIX(-1); } - return rb_num_coerce_cmp(x, y, rb_intern("<=>")); + return rb_num_coerce_cmp(x, y, id_cmp); } return rb_dbl_cmp(a, b); } @@ -1754,6 +1754,9 @@ ruby_float_step_size(double beg, double end, double unit, int excl) if (isinf(unit)) { return unit > 0 ? beg <= end : beg >= end; } + if (unit == 0) { + return INFINITY; + } if (err>0.5) err=0.5; if (excl) { if (n<=0) return 0; @@ -1783,6 +1786,11 @@ ruby_float_step(VALUE from, VALUE to, VALUE step, int excl) /* if unit is infinity, i*unit+beg is NaN */ if (n) rb_yield(DBL2NUM(beg)); } + else if (unit == 0) { + VALUE val = DBL2NUM(beg); + for (;;) + rb_yield(val); + } else { for (i=0; i', 1, INT2FIX(0))) ? '>' : '<'; + ID cmp = '>'; + switch (rb_cmpint(rb_num_coerce_cmp(step, INT2FIX(0), id_cmp), step, INT2FIX(0))) { + case 0: return DBL2NUM(INFINITY); + case -1: cmp = '<'; break; + } if (RTEST(rb_funcall(from, cmp, 1, to))) return INT2FIX(0); result = rb_funcall(rb_funcall(to, '-', 1, from), id_div, 1, step); if (!excl || RTEST(rb_funcall(rb_funcall(from, '+', 1, rb_funcall(result, '*', 1, step)), cmp, 1, to))) { @@ -1859,14 +1873,6 @@ ruby_num_interval_step_size(VALUE from, VALUE to, VALUE step, int excl) } \ } while (0) -#define NUM_STEP_GET_INF(to, desc, inf) do { \ - if (RB_TYPE_P(to, T_FLOAT)) { \ - double f = RFLOAT_VALUE(to); \ - inf = isinf(f) && (signbit(f) ? desc : !desc); \ - } \ - else inf = 0; \ -} while (0) - static VALUE num_step_size(VALUE from, VALUE args, VALUE eobj) { @@ -1942,8 +1948,14 @@ num_step(int argc, VALUE *argv, VALUE from) RETURN_SIZED_ENUMERATOR(from, argc, argv, num_step_size); NUM_STEP_SCAN_ARGS(argc, argv, to, step, hash, desc); - NUM_STEP_GET_INF(to, desc, inf); - + if (RTEST(rb_num_coerce_cmp(step, INT2FIX(0), id_eq))) { + inf = 1; + } + else if (RB_TYPE_P(to, T_FLOAT)) { + double f = RFLOAT_VALUE(to); + inf = isinf(f) && (signbit(f) ? desc : !desc); + } + else inf = 0; if (FIXNUM_P(from) && (inf || FIXNUM_P(to)) && FIXNUM_P(step)) { long i = FIX2LONG(from); @@ -3136,7 +3148,7 @@ fix_cmp(VALUE x, VALUE y) return rb_integer_float_cmp(x, y); } else { - return rb_num_coerce_cmp(x, y, rb_intern("<=>")); + return rb_num_coerce_cmp(x, y, id_cmp); } } @@ -3832,6 +3844,7 @@ Init_Numeric(void) id_to_i = rb_intern("to_i"); id_eq = rb_intern("=="); id_div = rb_intern("div"); + id_cmp = rb_intern("<=>"); rb_eZeroDivError = rb_define_class("ZeroDivisionError", rb_eStandardError); rb_eFloatDomainError = rb_define_class("FloatDomainError", rb_eRangeError); diff --git a/test/ruby/test_numeric.rb b/test/ruby/test_numeric.rb index f3fc66337702d7..f5e97afec066fa 100644 --- a/test/ruby/test_numeric.rb +++ b/test/ruby/test_numeric.rb @@ -267,6 +267,7 @@ def test_step assert_step [], [2, 1, 3] assert_step [], [-2, -1, -3] assert_step [3, 3, 3, 3], [3, by: 0], inf: true + assert_step [3, 3, 3, 3], [3, by: 0, to: 42], inf: true assert_step [10], [10, 1, -bignum] assert_step [], [1, 0, Float::INFINITY] @@ -276,6 +277,19 @@ def test_step assert_step [10, 11, 12, 13], [10], inf: true assert_step [10, 9, 8, 7], [10, by: -1], inf: true assert_step [10, 9, 8, 7], [10, by: -1, to: nil], inf: true + + assert_step [42, 42, 42, 42], [42, by: 0, to: -Float::INFINITY], inf: true + assert_step [42, 42, 42, 42], [42, by: 0, to: 42.5], inf: true + assert_step [4.2, 4.2, 4.2, 4.2], [4.2, by: 0.0], inf: true + assert_step [4.2, 4.2, 4.2, 4.2], [4.2, by: -0.0], inf: true + assert_step [42.0, 42.0, 42.0, 42.0], [42, by: 0.0, to: 44], inf: true + assert_step [42.0, 42.0, 42.0, 42.0], [42, by: 0.0, to: 0], inf: true + assert_step [42.0, 42.0, 42.0, 42.0], [42, by: -0.0, to: 44], inf: true + + assert_step [bignum]*4, [bignum, by: 0], inf: true + assert_step [bignum]*4, [bignum, by: 0.0], inf: true + assert_step [bignum]*4, [bignum, by: 0, to: bignum+1], inf: true + assert_step [bignum]*4, [bignum, by: 0, to: 0], inf: true end def test_num2long diff --git a/version.h b/version.h index f979b4abc39237..64a07ce2bc87f7 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-06-11" -#define RUBY_PATCHLEVEL 125 +#define RUBY_PATCHLEVEL 126 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 6 From 089d93ca1dadd5f16fa54211cf253187bd5c2c98 Mon Sep 17 00:00:00 2001 From: nagachika Date: Tue, 10 Jun 2014 17:35:07 +0000 Subject: [PATCH 126/343] merge revision(s) r45378: [Backport #9658] [Backport #9866] * configure.in: Fix a build problem with clang and --with-opt-dir. If ruby is configured with --with-opt-dir=dir when using clang as compiler, a warning `clang: warning: argument unused during compilation: '-I dir'` is emitted almost every time clang compiles a file. Unfortunately, RUBY_CHECK_PRINTF_PREFIX takes any output from the compiler as fatal error, and the check thus fails due to the warning. This is an attempt to fix the problem by adding a flag -Qunused-arguments to CFLAGS locally in the function to suppress the warning. [ruby-dev:48062] [Bug #9658] [Fixes GH-571] https://github.com/ruby/ruby/pull/571 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46402 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 13 +++++++++++++ configure.in | 5 ++++- version.h | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 012c58fa72026e..29c5b610afb2ee 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +Wed Jun 11 02:27:55 2014 Akinori MUSHA + + * configure.in: Fix a build problem with clang and --with-opt-dir. + If ruby is configured with --with-opt-dir=dir when using clang + as compiler, a warning `clang: warning: argument unused during + compilation: '-I dir'` is emitted almost every time clang + compiles a file. Unfortunately, RUBY_CHECK_PRINTF_PREFIX takes + any output from the compiler as fatal error, and the check thus + fails due to the warning. This is an attempt to fix the problem + by adding a flag -Qunused-arguments to CFLAGS locally in the + function to suppress the warning. [ruby-dev:48062] [Bug #9658] + [Fixes GH-571] https://github.com/ruby/ruby/pull/571 + Wed Jun 11 02:18:34 2014 Marc-Andre Lafortune * numeric.c: Fix Numeric#step with 0 unit [Bug #9575] diff --git a/configure.in b/configure.in index bf337f09ce9c79..08fdf4d35aa703 100644 --- a/configure.in +++ b/configure.in @@ -770,6 +770,8 @@ if test "$GCC:${warnflags+set}:no" = yes::no; then rb_cv_warnflags="$warnflags" warnflags= fi +RUBY_TRY_CFLAGS(-Qunused-arguments, [RUBY_APPEND_OPTIONS(rb_cv_wsuppress_flags, -Qunused-arguments)]) + if test "$GCC" = yes; then # -D_FORTIFY_SOURCE # When defined _FORTIFY_SOURCE, glibc enables some additional sanity @@ -1269,7 +1271,8 @@ RUBY_CHECK_SIZEOF(clock_t, [], [], [@%:@include ]) AC_DEFUN([RUBY_CHECK_PRINTF_PREFIX], [ AC_CACHE_CHECK([for printf prefix for $1], [rb_cv_pri_prefix_]AS_TR_SH($1),[ [rb_cv_pri_prefix_]AS_TR_SH($1)=[NONE] - RUBY_WERROR_FLAG(for pri in $2; do + RUBY_WERROR_FLAG(RUBY_APPEND_OPTIONS(CFLAGS, $rb_cv_wsuppress_flags) + for pri in $2; do AC_TRY_COMPILE( [@%:@include @%:@include diff --git a/version.h b/version.h index 64a07ce2bc87f7..b43f6652987d01 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-06-11" -#define RUBY_PATCHLEVEL 126 +#define RUBY_PATCHLEVEL 127 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 6 From ad5214df98f0f2dc0918c838441f6ace13f05449 Mon Sep 17 00:00:00 2001 From: nagachika Date: Tue, 10 Jun 2014 17:43:49 +0000 Subject: [PATCH 127/343] merge revision(s) r45308,r45316: [Backport #9621] * ext/objspace/objspace_dump.c: Check fptr before trying to dump RFILE object fd. [GH-562] * test/objspace/test_objspace.rb: add test * test/objspace/test_objspace.rb (TestObjSpace#test_dump_uninitialized_file): remove dependency on json library. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46403 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 12 ++++++++++++ ext/objspace/objspace_dump.c | 3 ++- test/objspace/test_objspace.rb | 10 ++++++++++ version.h | 2 +- 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 29c5b610afb2ee..957e75b3dce0b8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +Wed Jun 11 02:43:32 2014 Kazuki Tsujimoto + + * test/objspace/test_objspace.rb (TestObjSpace#test_dump_uninitialized_file): + remove dependency on json library. + +Wed Jun 11 02:43:32 2014 Scott Francis + + * ext/objspace/objspace_dump.c: Check fptr before trying to dump RFILE + object fd. [GH-562] + + * test/objspace/test_objspace.rb: add test + Wed Jun 11 02:27:55 2014 Akinori MUSHA * configure.in: Fix a build problem with clang and --with-opt-dir. diff --git a/ext/objspace/objspace_dump.c b/ext/objspace/objspace_dump.c index 9a694d33aa1cf2..e3ce7e727d6123 100644 --- a/ext/objspace/objspace_dump.c +++ b/ext/objspace/objspace_dump.c @@ -232,7 +232,8 @@ dump_object(VALUE obj, struct dump_config *dc) case T_FILE: fptr = RFILE(obj)->fptr; - dump_append(dc, ", \"fd\":%d", fptr->fd); + if (fptr) + dump_append(dc, ", \"fd\":%d", fptr->fd); break; case T_ZOMBIE: diff --git a/test/objspace/test_objspace.rb b/test/objspace/test_objspace.rb index 42dc55de9f934f..7c4dc0bff9f7a4 100644 --- a/test/objspace/test_objspace.rb +++ b/test/objspace/test_objspace.rb @@ -266,4 +266,14 @@ def dump_my_heap_please File.unlink(output) end end + + def test_dump_uninitialized_file + assert_in_out_err(%[-robjspace], <<-RUBY) do |(output), (error)| + puts ObjectSpace.dump(File.allocate) + RUBY + assert_nil error + assert_match /"type":"FILE"/, output + assert_not_match /"fd":/, output + end + end end diff --git a/version.h b/version.h index b43f6652987d01..3436eac3689440 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-06-11" -#define RUBY_PATCHLEVEL 127 +#define RUBY_PATCHLEVEL 128 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 6 From b92e03c5fd766d6e809486fe31615cdd47e61670 Mon Sep 17 00:00:00 2001 From: nagachika Date: Wed, 11 Jun 2014 14:21:53 +0000 Subject: [PATCH 128/343] merge revision(s) r45224,r45228: [Backport #9838] * gc.c (ruby_gc_set_params): fix building without RGenGC * gc.c (ruby_gc_set_params): simplify condition git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46407 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ gc.c | 2 +- version.h | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 957e75b3dce0b8..d5794579d4d116 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Wed Jun 11 22:58:30 2014 Eric Wong + + * gc.c (ruby_gc_set_params): simplify condition + +Wed Jun 11 22:58:30 2014 Eric Wong + + * gc.c (ruby_gc_set_params): fix building without RGenGC + Wed Jun 11 02:43:32 2014 Kazuki Tsujimoto * test/objspace/test_objspace.rb (TestObjSpace#test_dump_uninitialized_file): diff --git a/gc.c b/gc.c index 7812d921bfe35c..22f7f6db3a445b 100644 --- a/gc.c +++ b/gc.c @@ -5749,7 +5749,7 @@ ruby_gc_set_params(int safe_level) get_envparam_int("RUBY_GC_MALLOC_LIMIT_MAX", &gc_params.malloc_limit_max, 0); get_envparam_double("RUBY_GC_MALLOC_LIMIT_GROWTH_FACTOR", &gc_params.malloc_limit_growth_factor, 1.0); -#ifdef RGENGC_ESTIMATE_OLDMALLOC +#if RGENGC_ESTIMATE_OLDMALLOC if (get_envparam_int("RUBY_GC_OLDMALLOC_LIMIT", &gc_params.oldmalloc_limit_min, 0)) { rb_objspace_t *objspace = &rb_objspace; objspace->rgengc.oldmalloc_increase_limit = gc_params.oldmalloc_limit_min; diff --git a/version.h b/version.h index 3436eac3689440..b1218ca9c3e686 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-06-11" -#define RUBY_PATCHLEVEL 128 +#define RUBY_PATCHLEVEL 129 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 6 From 7fd56bd30fbc0cf3ddef760dd41627d4454adbea Mon Sep 17 00:00:00 2001 From: nagachika Date: Mon, 16 Jun 2014 15:33:10 +0000 Subject: [PATCH 129/343] merge revision(s) r45287,r45288,r45289,r45290: [Backport #9600] process.c: tmp buffer instead of alloca * process.c (OBJ2UID1, OBJ2GID1): separate from OBJ2UID and OBJ2GID respectively, need given buffers. * process.c (OBJ2UID, OBJ2GID): no longer need PREPARE_GETPWNAM and PREPARE_GETGRNAM. * process.c (obj2uid, obj2gid): use tmp buffer instead of alloca to get rid of potential stack overflow. * process.c (obj2uid, obj2gid): now getpwnam_r() and getgrnam_r() may need larger buffers than sysconf values, so retry with expanding the buffer when ERANGE is returned. [ruby-core:61325] [Bug #9600] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46449 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++ process.c | 149 ++++++++++++++++++++++++++++++++++++++++-------------- version.h | 6 +-- 3 files changed, 121 insertions(+), 41 deletions(-) diff --git a/ChangeLog b/ChangeLog index d5794579d4d116..af631ee78683db 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Tue Jun 17 00:26:59 2014 Nobuyoshi Nakada + + * process.c (obj2uid, obj2gid): now getpwnam_r() and getgrnam_r() + may need larger buffers than sysconf values, so retry with + expanding the buffer when ERANGE is returned. + [ruby-core:61325] [Bug #9600] + Wed Jun 11 22:58:30 2014 Eric Wong * gc.c (ruby_gc_set_params): simplify condition diff --git a/process.c b/process.c index e50a047c8634da..982286827d3e2e 100644 --- a/process.c +++ b/process.c @@ -151,20 +151,36 @@ static void check_gid_switch(void); #if defined(HAVE_PWD_H) # if defined(HAVE_GETPWNAM_R) && defined(_SC_GETPW_R_SIZE_MAX) # define USE_GETPWNAM_R 1 +# define GETPW_R_SIZE_INIT sysconf(_SC_GETPW_R_SIZE_MAX) +# define GETPW_R_SIZE_DEFAULT 0x1000 +# define GETPW_R_SIZE_LIMIT 0x10000 # endif # ifdef USE_GETPWNAM_R # define PREPARE_GETPWNAM \ - long getpw_buf_len = sysconf(_SC_GETPW_R_SIZE_MAX); \ - char *getpw_buf = ALLOCA_N(char, (getpw_buf_len < 0 ? (getpw_buf_len = 4096) : getpw_buf_len)); -# define OBJ2UID(id) obj2uid((id), getpw_buf, getpw_buf_len) -static rb_uid_t obj2uid(VALUE id, char *getpw_buf, size_t getpw_buf_len); + VALUE getpw_buf = 0 +# define FINISH_GETPWNAM \ + ALLOCV_END(getpw_buf) +# define OBJ2UID1(id) obj2uid((id), &getpw_buf) +# define OBJ2UID(id) obj2uid0(id) +static rb_uid_t obj2uid(VALUE id, VALUE *getpw_buf); +static inline rb_uid_t +obj2uid0(VALUE id) +{ + rb_uid_t uid; + PREPARE_GETPWNAM; + uid = OBJ2UID1(id); + FINISH_GETPWNAM; + return uid; +} # else # define PREPARE_GETPWNAM /* do nothing */ +# define FINISH_GETPWNAM /* do nothing */ # define OBJ2UID(id) obj2uid((id)) static rb_uid_t obj2uid(VALUE id); # endif #else # define PREPARE_GETPWNAM /* do nothing */ +# define FINISH_GETPWNAM /* do nothing */ # define OBJ2UID(id) NUM2UIDT(id) # ifdef p_uid_from_name # undef p_uid_from_name @@ -175,20 +191,37 @@ static rb_uid_t obj2uid(VALUE id); #if defined(HAVE_GRP_H) # if defined(HAVE_GETGRNAM_R) && defined(_SC_GETGR_R_SIZE_MAX) # define USE_GETGRNAM_R +# define GETGR_R_SIZE_INIT sysconf(_SC_GETGR_R_SIZE_MAX) +# define GETGR_R_SIZE_DEFAULT 0x1000 +# define GETGR_R_SIZE_LIMIT 0x10000 # endif # ifdef USE_GETGRNAM_R # define PREPARE_GETGRNAM \ - long getgr_buf_len = sysconf(_SC_GETGR_R_SIZE_MAX); \ - char *getgr_buf = ALLOCA_N(char, (getgr_buf_len < 0 ? (getgr_buf_len = 4096) : getgr_buf_len)); -# define OBJ2GID(id) obj2gid((id), getgr_buf, getgr_buf_len) -static rb_gid_t obj2gid(VALUE id, char *getgr_buf, size_t getgr_buf_len); + VALUE getgr_buf = 0 +# define FINISH_GETGRNAM \ + ALLOCV_END(getgr_buf) +# define OBJ2GID1(id) obj2gid((id), &getgr_buf) +# define OBJ2GID(id) obj2gid0(id) +static rb_gid_t obj2gid(VALUE id, VALUE *getgr_buf); +static inline rb_gid_t +obj2gid0(VALUE id) +{ + rb_gid_t gid; + PREPARE_GETGRNAM; + gid = OBJ2GID1(id); + FINISH_GETGRNAM; + return gid; +} +static rb_gid_t obj2gid(VALUE id, VALUE *getgr_buf); # else # define PREPARE_GETGRNAM /* do nothing */ +# define FINISH_GETGRNAM /* do nothing */ # define OBJ2GID(id) obj2gid((id)) static rb_gid_t obj2gid(VALUE id); # endif #else # define PREPARE_GETGRNAM /* do nothing */ +# define FINISH_GETGRNAM /* do nothing */ # define OBJ2GID(id) NUM2GIDT(id) # ifdef p_gid_from_name # undef p_gid_from_name @@ -1751,7 +1784,6 @@ rb_execarg_addopt(VALUE execarg_obj, VALUE key, VALUE val) } check_uid_switch(); { - PREPARE_GETPWNAM; eargp->uid = OBJ2UID(val); eargp->uid_given = 1; } @@ -1767,7 +1799,6 @@ rb_execarg_addopt(VALUE execarg_obj, VALUE key, VALUE val) } check_gid_switch(); { - PREPARE_GETGRNAM; eargp->gid = OBJ2GID(val); eargp->gid_given = 1; } @@ -4821,7 +4852,7 @@ check_gid_switch(void) static rb_uid_t obj2uid(VALUE id # ifdef USE_GETPWNAM_R - , char *getpw_buf, size_t getpw_buf_len + , VALUE *getpw_tmp # endif ) { @@ -4836,8 +4867,28 @@ obj2uid(VALUE id struct passwd *pwptr; #ifdef USE_GETPWNAM_R struct passwd pwbuf; - if (getpwnam_r(usrname, &pwbuf, getpw_buf, getpw_buf_len, &pwptr)) - rb_sys_fail("getpwnam_r"); + char *getpw_buf; + long getpw_buf_len; + if (!*getpw_tmp) { + getpw_buf_len = GETPW_R_SIZE_INIT; + if (getpw_buf_len < 0) getpw_buf_len = GETPW_R_SIZE_DEFAULT; + getpw_buf = rb_alloc_tmp_buffer(getpw_tmp, getpw_buf_len); + } + else { + getpw_buf = RSTRING_PTR(*getpw_tmp); + getpw_buf_len = rb_str_capacity(*getpw_tmp); + } + errno = ERANGE; + /* gepwnam_r() on MacOS X doesn't set errno if buffer size is insufficient */ + while (getpwnam_r(usrname, &pwbuf, getpw_buf, getpw_buf_len, &pwptr)) { + if (errno != ERANGE || getpw_buf_len >= GETPW_R_SIZE_LIMIT) { + rb_free_tmp_buffer(getpw_tmp); + rb_sys_fail("getpwnam_r"); + } + rb_str_modify_expand(*getpw_tmp, getpw_buf_len); + getpw_buf = RSTRING_PTR(*getpw_tmp); + getpw_buf_len = rb_str_capacity(*getpw_tmp); + } #else pwptr = getpwnam(usrname); #endif @@ -4870,7 +4921,6 @@ obj2uid(VALUE id static VALUE p_uid_from_name(VALUE self, VALUE id) { - PREPARE_GETPWNAM return UIDT2NUM(OBJ2UID(id)); } # endif @@ -4880,7 +4930,7 @@ p_uid_from_name(VALUE self, VALUE id) static rb_gid_t obj2gid(VALUE id # ifdef USE_GETGRNAM_R - , char *getgr_buf, size_t getgr_buf_len + , VALUE *getgr_tmp # endif ) { @@ -4895,8 +4945,28 @@ obj2gid(VALUE id struct group *grptr; #ifdef USE_GETGRNAM_R struct group grbuf; - if (getgrnam_r(grpname, &grbuf, getgr_buf, getgr_buf_len, &grptr)) - rb_sys_fail("getgrnam_r"); + char *getgr_buf; + long getgr_buf_len; + if (!*getgr_tmp) { + getgr_buf_len = GETGR_R_SIZE_INIT; + if (getgr_buf_len < 0) getgr_buf_len = GETGR_R_SIZE_DEFAULT; + getgr_buf = rb_alloc_tmp_buffer(getgr_tmp, getgr_buf_len); + } + else { + getgr_buf = RSTRING_PTR(*getgr_tmp); + getgr_buf_len = rb_str_capacity(*getgr_tmp); + } + errno = ERANGE; + /* gegrnam_r() on MacOS X doesn't set errno if buffer size is insufficient */ + while (getgrnam_r(grpname, &grbuf, getgr_buf, getgr_buf_len, &grptr)) { + if (errno != ERANGE || getgr_buf_len >= GETGR_R_SIZE_LIMIT) { + rb_free_tmp_buffer(getgr_tmp); + rb_sys_fail("getgrnam_r"); + } + rb_str_modify_expand(*getgr_tmp, getgr_buf_len); + getgr_buf = RSTRING_PTR(*getgr_tmp); + getgr_buf_len = rb_str_capacity(*getgr_tmp); + } #else grptr = getgrnam(grpname); #endif @@ -4929,7 +4999,6 @@ obj2gid(VALUE id static VALUE p_gid_from_name(VALUE self, VALUE id) { - PREPARE_GETGRNAM; return GIDT2NUM(OBJ2GID(id)); } # endif @@ -4948,7 +5017,6 @@ p_gid_from_name(VALUE self, VALUE id) static VALUE p_sys_setuid(VALUE obj, VALUE id) { - PREPARE_GETPWNAM; check_uid_switch(); if (setuid(OBJ2UID(id)) != 0) rb_sys_fail(0); return Qnil; @@ -4971,7 +5039,6 @@ p_sys_setuid(VALUE obj, VALUE id) static VALUE p_sys_setruid(VALUE obj, VALUE id) { - PREPARE_GETPWNAM; check_uid_switch(); if (setruid(OBJ2UID(id)) != 0) rb_sys_fail(0); return Qnil; @@ -4994,7 +5061,6 @@ p_sys_setruid(VALUE obj, VALUE id) static VALUE p_sys_seteuid(VALUE obj, VALUE id) { - PREPARE_GETPWNAM; check_uid_switch(); if (seteuid(OBJ2UID(id)) != 0) rb_sys_fail(0); return Qnil; @@ -5019,9 +5085,13 @@ p_sys_seteuid(VALUE obj, VALUE id) static VALUE p_sys_setreuid(VALUE obj, VALUE rid, VALUE eid) { + rb_uid_t ruid, euid; PREPARE_GETPWNAM; check_uid_switch(); - if (setreuid(OBJ2UID(rid), OBJ2UID(eid)) != 0) rb_sys_fail(0); + ruid = OBJ2UID1(rid); + euid = OBJ2UID1(eid); + FINISH_GETPWNAM; + if (setreuid(ruid, euid) != 0) rb_sys_fail(0); return Qnil; } #else @@ -5044,9 +5114,14 @@ p_sys_setreuid(VALUE obj, VALUE rid, VALUE eid) static VALUE p_sys_setresuid(VALUE obj, VALUE rid, VALUE eid, VALUE sid) { + rb_uid_t ruid, euid, suid; PREPARE_GETPWNAM; check_uid_switch(); - if (setresuid(OBJ2UID(rid), OBJ2UID(eid), OBJ2UID(sid)) != 0) rb_sys_fail(0); + ruid = OBJ2UID1(rid); + euid = OBJ2UID1(eid); + suid = OBJ2UID1(sid); + FINISH_GETPWNAM; + if (setresuid(ruid, euid, suid) != 0) rb_sys_fail(0); return Qnil; } #else @@ -5086,7 +5161,6 @@ static VALUE proc_setuid(VALUE obj, VALUE id) { rb_uid_t uid; - PREPARE_GETPWNAM; check_uid_switch(); @@ -5158,7 +5232,6 @@ static VALUE p_uid_change_privilege(VALUE obj, VALUE id) { rb_uid_t uid; - PREPARE_GETPWNAM; check_uid_switch(); @@ -5328,7 +5401,6 @@ p_uid_change_privilege(VALUE obj, VALUE id) static VALUE p_sys_setgid(VALUE obj, VALUE id) { - PREPARE_GETGRNAM; check_gid_switch(); if (setgid(OBJ2GID(id)) != 0) rb_sys_fail(0); return Qnil; @@ -5351,7 +5423,6 @@ p_sys_setgid(VALUE obj, VALUE id) static VALUE p_sys_setrgid(VALUE obj, VALUE id) { - PREPARE_GETGRNAM; check_gid_switch(); if (setrgid(OBJ2GID(id)) != 0) rb_sys_fail(0); return Qnil; @@ -5374,7 +5445,6 @@ p_sys_setrgid(VALUE obj, VALUE id) static VALUE p_sys_setegid(VALUE obj, VALUE id) { - PREPARE_GETGRNAM; check_gid_switch(); if (setegid(OBJ2GID(id)) != 0) rb_sys_fail(0); return Qnil; @@ -5399,9 +5469,13 @@ p_sys_setegid(VALUE obj, VALUE id) static VALUE p_sys_setregid(VALUE obj, VALUE rid, VALUE eid) { + rb_gid_t rgid, egid; PREPARE_GETGRNAM; check_gid_switch(); - if (setregid(OBJ2GID(rid), OBJ2GID(eid)) != 0) rb_sys_fail(0); + rgid = OBJ2GID(rid); + egid = OBJ2GID(eid); + FINISH_GETGRNAM; + if (setregid(rgid, egid) != 0) rb_sys_fail(0); return Qnil; } #else @@ -5423,9 +5497,14 @@ p_sys_setregid(VALUE obj, VALUE rid, VALUE eid) static VALUE p_sys_setresgid(VALUE obj, VALUE rid, VALUE eid, VALUE sid) { + rb_gid_t rgid, egid, sgid; PREPARE_GETGRNAM; check_gid_switch(); - if (setresgid(OBJ2GID(rid), OBJ2GID(eid), OBJ2GID(sid)) != 0) rb_sys_fail(0); + rgid = OBJ2GID(rid); + egid = OBJ2GID(eid); + sgid = OBJ2GID(sid); + FINISH_GETGRNAM; + if (setresgid(rgid, egid, sgid) != 0) rb_sys_fail(0); return Qnil; } #else @@ -5493,7 +5572,6 @@ static VALUE proc_setgid(VALUE obj, VALUE id) { rb_gid_t gid; - PREPARE_GETGRNAM; check_gid_switch(); @@ -5641,8 +5719,9 @@ proc_setgroups(VALUE obj, VALUE ary) for (i = 0; i < ngroups; i++) { VALUE g = RARRAY_AREF(ary, i); - groups[i] = OBJ2GID(g); + groups[i] = OBJ2GID1(g); } + FINISH_GETGRNAM; if (setgroups(ngroups, groups) == -1) /* ngroups <= maxgroups */ rb_sys_fail(0); @@ -5675,7 +5754,6 @@ proc_setgroups(VALUE obj, VALUE ary) static VALUE proc_initgroups(VALUE obj, VALUE uname, VALUE base_grp) { - PREPARE_GETGRNAM; if (initgroups(StringValuePtr(uname), OBJ2GID(base_grp)) != 0) { rb_sys_fail(0); } @@ -5857,7 +5935,6 @@ static VALUE p_gid_change_privilege(VALUE obj, VALUE id) { rb_gid_t gid; - PREPARE_GETGRNAM; check_gid_switch(); @@ -6067,7 +6144,6 @@ proc_seteuid(rb_uid_t uid) static VALUE proc_seteuid_m(VALUE mod, VALUE euid) { - PREPARE_GETPWNAM; check_uid_switch(); proc_seteuid(OBJ2UID(euid)); return euid; @@ -6133,7 +6209,6 @@ rb_seteuid_core(rb_uid_t euid) static VALUE p_uid_grant_privilege(VALUE obj, VALUE id) { - PREPARE_GETPWNAM; rb_seteuid_core(OBJ2UID(id)); return id; } @@ -6173,7 +6248,6 @@ proc_setegid(VALUE obj, VALUE egid) { #if defined(HAVE_SETRESGID) || defined(HAVE_SETREGID) || defined(HAVE_SETEGID) || defined(HAVE_SETGID) rb_gid_t gid; - PREPARE_GETGRNAM; #endif check_gid_switch(); @@ -6265,7 +6339,6 @@ rb_setegid_core(rb_gid_t egid) static VALUE p_gid_grant_privilege(VALUE obj, VALUE id) { - PREPARE_GETGRNAM; rb_setegid_core(OBJ2GID(id)); return id; } diff --git a/version.h b/version.h index b1218ca9c3e686..edb9e01c3a46a5 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.2" -#define RUBY_RELEASE_DATE "2014-06-11" -#define RUBY_PATCHLEVEL 129 +#define RUBY_RELEASE_DATE "2014-06-17" +#define RUBY_PATCHLEVEL 130 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 6 -#define RUBY_RELEASE_DAY 11 +#define RUBY_RELEASE_DAY 17 #include "ruby/version.h" From 12285fc1094bcbe290a8a12555f175c1eb41c88d Mon Sep 17 00:00:00 2001 From: nagachika Date: Mon, 16 Jun 2014 15:42:56 +0000 Subject: [PATCH 130/343] merge revision(s) r45521,r45523,r45551: [Backport #9699] win32.c: wchar conversion * win32/win32.c (rb_w32_wstr_to_mbstr, rb_w32_mbstr_to_wstr): make WCHAR/mb conversion functions public. * dln.c (dln_load): use wchar version to load a library in non-ascii path on Windows. based on the patch by Bugra Barin in [ruby-core:61845]. [Bug #9699] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46450 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ dln.c | 15 ++++++++++----- ext/-test-/win32/dln/empty/empty.c | 4 ++++ ext/-test-/win32/dln/empty/extconf.rb | 3 +++ include/ruby/win32.h | 2 ++ test/-ext-/win32/test_dln.rb | 22 ++++++++++++++++++++++ version.h | 2 +- win32/win32.c | 12 ++++++------ 8 files changed, 54 insertions(+), 12 deletions(-) create mode 100644 ext/-test-/win32/dln/empty/empty.c create mode 100644 ext/-test-/win32/dln/empty/extconf.rb diff --git a/ChangeLog b/ChangeLog index af631ee78683db..250a5d00870811 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Tue Jun 17 00:37:15 2014 Bugra Barin + + * dln.c (dln_load): use wchar version to load a library in + non-ascii path on Windows. based on the patch by Bugra Barin + in [ruby-core:61845]. [Bug #9699] + Tue Jun 17 00:26:59 2014 Nobuyoshi Nakada * process.c (obj2uid, obj2gid): now getpwnam_r() and getgrnam_r() diff --git a/dln.c b/dln.c index e6b20d54e3e8ef..85ebe27caee3e7 100644 --- a/dln.c +++ b/dln.c @@ -1255,20 +1255,25 @@ dln_load(const char *file) #if defined _WIN32 && !defined __CYGWIN__ HINSTANCE handle; - char winfile[MAXPATHLEN]; + WCHAR *winfile; char message[1024]; void (*init_fct)(); char *buf; - if (strlen(file) >= MAXPATHLEN) dln_loaderror("filename too long"); - /* Load the file as an object one */ init_funcname(&buf, file); - strlcpy(winfile, file, sizeof(winfile)); + /* Convert the file path to wide char */ + winfile = rb_w32_mbstr_to_wstr(CP_UTF8, file, -1, NULL); + if (!winfile) { + dln_memerror(); + } /* Load file */ - if ((handle = LoadLibrary(winfile)) == NULL) { + handle = LoadLibraryW(winfile); + free(winfile); + + if (!handle) { error = dln_strerror(); goto failed; } diff --git a/ext/-test-/win32/dln/empty/empty.c b/ext/-test-/win32/dln/empty/empty.c new file mode 100644 index 00000000000000..c4f94f164423b0 --- /dev/null +++ b/ext/-test-/win32/dln/empty/empty.c @@ -0,0 +1,4 @@ +void +Init_empty(void) +{ +} diff --git a/ext/-test-/win32/dln/empty/extconf.rb b/ext/-test-/win32/dln/empty/extconf.rb new file mode 100644 index 00000000000000..a4efed90c9a3ea --- /dev/null +++ b/ext/-test-/win32/dln/empty/extconf.rb @@ -0,0 +1,3 @@ +if $mingw or $mswin + create_makefile("-test-/win32/dln/empty") +end diff --git a/include/ruby/win32.h b/include/ruby/win32.h index 070bab28f9c0c7..067ac010daeade 100644 --- a/include/ruby/win32.h +++ b/include/ruby/win32.h @@ -772,6 +772,8 @@ int rb_w32_wait_events_blocking(HANDLE *events, int num, DWORD timeout); int rb_w32_time_subtract(struct timeval *rest, const struct timeval *wait); int rb_w32_wrap_io_handle(HANDLE, int); int rb_w32_unwrap_io_handle(int); +WCHAR *rb_w32_mbstr_to_wstr(UINT, const char *, int, long *); +char *rb_w32_wstr_to_mbstr(UINT, const WCHAR *, int, long *); /* == ***CAUTION*** diff --git a/test/-ext-/win32/test_dln.rb b/test/-ext-/win32/test_dln.rb index 7c5fe61f59f75a..c9065e66fb7168 100644 --- a/test/-ext-/win32/test_dln.rb +++ b/test/-ext-/win32/test_dln.rb @@ -1,4 +1,6 @@ require 'test/unit' +require 'tmpdir' +require 'rbconfig' require_relative '../../ruby/envutil' module Bug @@ -8,6 +10,26 @@ def test_check_imported bug = '[Bug #6303]' assert_in_out_err(['-r-test-/win32/dln', '-eexit'], '', [], [], bug, timeout: 10) end + + def test_nonascii_load + bug9699 = '[ruby-core:61845] [Bug #9699]' + so = "-test-/win32/dln/empty." + RbConfig::CONFIG["DLEXT"] + so = $:.find {|d| d = ::File.join(d, so); break d if ::File.exist?(d)} + assert_not_nil(so) + Dir.mkdir(dir = ::File.join(testdir = Dir.mktmpdir("test"), "\u{30c6 30b9 30c8}")) + ::File.copy_stream(so, ::File.join(dir, ::File.basename(so))) + assert_separately(['-', bug9699, testdir, ::File.basename(so)], <<-'end;') + bug, dir, so = *ARGV + assert_nothing_raised(LoadError, bug) do + require ::File.join(dir, "\u{30c6 30b9 30c8}", so) + end + end; + ensure + ::File.unlink(::File.join(dir, ::File.basename(so))) rescue nil + Dir.rmdir(dir) rescue nil + Dir.rmdir(testdir) rescue nil + end + end end end if /mswin|mingw/ =~ RUBY_PLATFORM diff --git a/version.h b/version.h index edb9e01c3a46a5..276892b411bf56 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-06-17" -#define RUBY_PATCHLEVEL 130 +#define RUBY_PATCHLEVEL 131 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 6 diff --git a/win32/win32.c b/win32/win32.c index 9fd981ec560aa3..a2ced890ff4547 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -1197,8 +1197,8 @@ is_batch(const char *cmd) } static UINT filecp(void); -static WCHAR *mbstr_to_wstr(UINT, const char *, int, long *); -static char *wstr_to_mbstr(UINT, const WCHAR *, int, long *); +#define mbstr_to_wstr rb_w32_mbstr_to_wstr +#define wstr_to_mbstr rb_w32_wstr_to_mbstr #define acp_to_wstr(str, plen) mbstr_to_wstr(CP_ACP, str, -1, plen) #define wstr_to_acp(str, plen) wstr_to_mbstr(CP_ACP, str, -1, plen) #define filecp_to_wstr(str, plen) mbstr_to_wstr(filecp(), str, -1, plen) @@ -1952,8 +1952,8 @@ filecp(void) } /* License: Ruby's */ -static char * -wstr_to_mbstr(UINT cp, const WCHAR *wstr, int clen, long *plen) +char * +rb_w32_wstr_to_mbstr(UINT cp, const WCHAR *wstr, int clen, long *plen) { char *ptr; int len = WideCharToMultiByte(cp, 0, wstr, clen, NULL, 0, NULL, NULL); @@ -1968,8 +1968,8 @@ wstr_to_mbstr(UINT cp, const WCHAR *wstr, int clen, long *plen) } /* License: Ruby's */ -static WCHAR * -mbstr_to_wstr(UINT cp, const char *str, int clen, long *plen) +WCHAR * +rb_w32_mbstr_to_wstr(UINT cp, const char *str, int clen, long *plen) { WCHAR *ptr; int len = MultiByteToWideChar(cp, 0, str, clen, NULL, 0); From 5a2f6a4af8a4b1082207979e2913c681ad6ea1bb Mon Sep 17 00:00:00 2001 From: nagachika Date: Mon, 16 Jun 2014 15:59:16 +0000 Subject: [PATCH 131/343] merge revision(s) r45724: [Backport #9776] * compile.c (compile_array_): make copy a first hash not to modify the argument itself. keyword splat should be non-destructive. [ruby-core:62161] [Bug #9776] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46451 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ compile.c | 1 + test/ruby/test_keyword.rb | 13 +++++++++++++ version.h | 2 +- 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 250a5d00870811..5a6f04d9e39227 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Tue Jun 17 00:45:44 2014 Nobuyoshi Nakada + + * compile.c (compile_array_): make copy a first hash not to modify + the argument itself. keyword splat should be non-destructive. + [ruby-core:62161] [Bug #9776] + Tue Jun 17 00:37:15 2014 Bugra Barin * dln.c (dln_load): use wchar version to load a library in diff --git a/compile.c b/compile.c index e96a9829d4fdb3..52656dca8c4b1c 100644 --- a/compile.c +++ b/compile.c @@ -2479,6 +2479,7 @@ compile_array_(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE* node_root, if (i > 0 || !first) ADD_INSN(ret, line, swap); COMPILE(ret, "keyword splat", kw); ADD_SEND(ret, line, ID2SYM(id_core_hash_merge_kwd), nhash); + if (nhash == INT2FIX(1)) ADD_SEND(ret, line, ID2SYM(rb_intern("dup")), INT2FIX(0)); } first = 0; break; diff --git a/test/ruby/test_keyword.rb b/test/ruby/test_keyword.rb index f6b4048d61e82f..2ebc2980202ef5 100644 --- a/test/ruby/test_keyword.rb +++ b/test/ruby/test_keyword.rb @@ -439,6 +439,19 @@ def foo(a, b, c=1, *d, e, f:2, **g) assert_equal([1, 2, 1, [], {:f=>5}, 2, {}], a.new.foo(1, 2, f:5), bug8993) end + def test_splat_keyword_nondestructive + bug9776 = '[ruby-core:62161] [Bug #9776]' + + h = {a: 1} + assert_equal({a:1, b:2}, {**h, b:2}) + assert_equal({a:1}, h, bug9776) + + pr = proc {|**opt| next opt} + assert_equal({a: 1}, pr.call(**h)) + assert_equal({a: 1, b: 2}, pr.call(**h, b: 2)) + assert_equal({a: 1}, h, bug9776) + end + def test_gced_object_in_stack bug8964 = '[ruby-dev:47729] [Bug #8964]' assert_normal_exit %q{ diff --git a/version.h b/version.h index 276892b411bf56..0bb3d1ea730070 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-06-17" -#define RUBY_PATCHLEVEL 131 +#define RUBY_PATCHLEVEL 132 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 6 From 0c5503923bf9a1120d7074281d88249eca372d57 Mon Sep 17 00:00:00 2001 From: nagachika Date: Thu, 19 Jun 2014 15:22:15 +0000 Subject: [PATCH 132/343] merge revision(s) r45954: [Backport #8358] * configure.in: enable SSE2 on mingw. target='i386-pc-mingw32'. [ruby-core:62095] [Bug #8358] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46467 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ configure.in | 2 +- version.h | 6 +++--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5a6f04d9e39227..8702074205e567 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Fri Jun 20 00:20:02 2014 Hiroshi Shirosaki + + * configure.in: enable SSE2 on mingw. target='i386-pc-mingw32'. + [ruby-core:62095] [Bug #8358] + Tue Jun 17 00:45:44 2014 Nobuyoshi Nakada * compile.c (compile_array_): make copy a first hash not to modify diff --git a/configure.in b/configure.in index 08fdf4d35aa703..d885d0f0aeea2b 100644 --- a/configure.in +++ b/configure.in @@ -862,7 +862,7 @@ if test "$GCC" = yes; then [*-darwin*], [ # doesn't seem necessary on Mac OS X ], - [[i[4-6]86*]], [ + [[i[4-6]86*|i386*mingw*]], [ RUBY_TRY_CFLAGS(-msse2 -mfpmath=sse, [ RUBY_APPEND_OPTION(XCFLAGS, -msse2 -mfpmath=sse) ]) diff --git a/version.h b/version.h index 0bb3d1ea730070..791f34a5281d36 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.2" -#define RUBY_RELEASE_DATE "2014-06-17" -#define RUBY_PATCHLEVEL 132 +#define RUBY_RELEASE_DATE "2014-06-20" +#define RUBY_PATCHLEVEL 133 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 6 -#define RUBY_RELEASE_DAY 17 +#define RUBY_RELEASE_DAY 20 #include "ruby/version.h" From ced638cc0f8f8067592b808455e5d17f1dc5d066 Mon Sep 17 00:00:00 2001 From: nagachika Date: Thu, 19 Jun 2014 15:56:56 +0000 Subject: [PATCH 133/343] merge revision(s) r44712,r44715,r44716,r44722,r44725,r44726,r44753: [Backport #9454] [Backport #9828] * thread_pthread.c: get current main thread stack size, which may be expanded than allocated size at initialization, by rlimit(). [ruby-core:60113] [Bug #9454] * thread_pthread.c: rlimit is only available on Linux. At least r44712 breaks FreeBSD. [ruby-core:60113] [Bug #9454] * thread_pthread.c (ruby_init_stack, ruby_stack_overflowed_p): place get_stack above others to get stack boundary information. [ruby-core:60113] [Bug #9454] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46468 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 18 +++++ cont.c | 150 ++++++++++++++++++------------------ gc.c | 18 ++--- test/ruby/test_exception.rb | 11 +++ thread.c | 14 ++-- thread_pthread.c | 73 ++++++++++-------- thread_win32.c | 6 +- version.h | 2 +- vm.c | 8 +- vm_core.h | 16 ++-- 10 files changed, 179 insertions(+), 137 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8702074205e567..19bb9e691ea69e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +Fri Jun 20 00:40:06 2014 Nobuyoshi Nakada + + * thread_pthread.c (ruby_init_stack, ruby_stack_overflowed_p): + place get_stack above others to get stack boundary information. + [ruby-core:60113] [Bug #9454] + +Fri Jun 20 00:40:06 2014 NARUSE, Yui + + * thread_pthread.c: rlimit is only available on Linux. + At least r44712 breaks FreeBSD. + [ruby-core:60113] [Bug #9454] + +Fri Jun 20 00:40:06 2014 Nobuyoshi Nakada + + * thread_pthread.c: get current main thread stack size, which may + be expanded than allocated size at initialization, by rlimit(). + [ruby-core:60113] [Bug #9454] + Fri Jun 20 00:20:02 2014 Hiroshi Shirosaki * configure.in: enable SSE2 on mingw. target='i386-pc-mingw32'. diff --git a/cont.c b/cont.c index fa9e91ee64ac57..3b05f995d4180a 100644 --- a/cont.c +++ b/cont.c @@ -97,16 +97,18 @@ typedef struct rb_context_struct { size_t vm_stack_slen; /* length of stack (head of th->stack) */ size_t vm_stack_clen; /* length of control frames (tail of th->stack) */ #endif - VALUE *machine_stack; - VALUE *machine_stack_src; + struct { + VALUE *stack; + VALUE *stack_src; + size_t stack_size; #ifdef __ia64 - VALUE *machine_register_stack; - VALUE *machine_register_stack_src; - int machine_register_stack_size; + VALUE *register_stack; + VALUE *register_stack_src; + int register_stack_size; #endif + } machine; rb_thread_t saved_thread; rb_jmpbuf_t jmpbuf; - size_t machine_stack_size; rb_ensure_entry_t *ensure_array; rb_ensure_list_t *ensure_list; } rb_context_t; @@ -188,11 +190,11 @@ cont_mark(void *ptr) #endif } - if (cont->machine_stack) { + if (cont->machine.stack) { if (cont->type == CONTINUATION_CONTEXT) { /* cont */ - rb_gc_mark_locations(cont->machine_stack, - cont->machine_stack + cont->machine_stack_size); + rb_gc_mark_locations(cont->machine.stack, + cont->machine.stack + cont->machine.stack_size); } else { /* fiber */ @@ -200,15 +202,15 @@ cont_mark(void *ptr) rb_fiber_t *fib = (rb_fiber_t*)cont; GetThreadPtr(cont->saved_thread.self, th); if ((th->fiber != cont->self) && fib->status == RUNNING) { - rb_gc_mark_locations(cont->machine_stack, - cont->machine_stack + cont->machine_stack_size); + rb_gc_mark_locations(cont->machine.stack, + cont->machine.stack + cont->machine.stack_size); } } } #ifdef __ia64 - if (cont->machine_register_stack) { - rb_gc_mark_locations(cont->machine_register_stack, - cont->machine_register_stack + cont->machine_register_stack_size); + if (cont->machine.register_stack) { + rb_gc_mark_locations(cont->machine.register_stack, + cont->machine.register_stack + cont->machine.register_stack_size); } #endif } @@ -226,7 +228,7 @@ cont_free(void *ptr) if (cont->type == CONTINUATION_CONTEXT) { /* cont */ ruby_xfree(cont->ensure_array); - RUBY_FREE_UNLESS_NULL(cont->machine_stack); + RUBY_FREE_UNLESS_NULL(cont->machine.stack); } else { /* fiber */ @@ -257,10 +259,10 @@ cont_free(void *ptr) } #else /* not FIBER_USE_NATIVE */ ruby_xfree(cont->ensure_array); - RUBY_FREE_UNLESS_NULL(cont->machine_stack); + RUBY_FREE_UNLESS_NULL(cont->machine.stack); #endif #ifdef __ia64 - RUBY_FREE_UNLESS_NULL(cont->machine_register_stack); + RUBY_FREE_UNLESS_NULL(cont->machine.register_stack); #endif RUBY_FREE_UNLESS_NULL(cont->vm_stack); @@ -286,12 +288,12 @@ cont_memsize(const void *ptr) size += n * sizeof(*cont->vm_stack); } - if (cont->machine_stack) { - size += cont->machine_stack_size * sizeof(*cont->machine_stack); + if (cont->machine.stack) { + size += cont->machine.stack_size * sizeof(*cont->machine.stack); } #ifdef __ia64 - if (cont->machine_register_stack) { - size += cont->machine_register_stack_size * sizeof(*cont->machine_register_stack); + if (cont->machine.register_stack) { + size += cont->machine.register_stack_size * sizeof(*cont->machine.register_stack); } #endif } @@ -380,42 +382,42 @@ cont_save_machine_stack(rb_thread_t *th, rb_context_t *cont) { size_t size; - SET_MACHINE_STACK_END(&th->machine_stack_end); + SET_MACHINE_STACK_END(&th->machine.stack_end); #ifdef __ia64 - th->machine_register_stack_end = rb_ia64_bsp(); + th->machine.register_stack_end = rb_ia64_bsp(); #endif - if (th->machine_stack_start > th->machine_stack_end) { - size = cont->machine_stack_size = th->machine_stack_start - th->machine_stack_end; - cont->machine_stack_src = th->machine_stack_end; + if (th->machine.stack_start > th->machine.stack_end) { + size = cont->machine.stack_size = th->machine.stack_start - th->machine.stack_end; + cont->machine.stack_src = th->machine.stack_end; } else { - size = cont->machine_stack_size = th->machine_stack_end - th->machine_stack_start; - cont->machine_stack_src = th->machine_stack_start; + size = cont->machine.stack_size = th->machine.stack_end - th->machine.stack_start; + cont->machine.stack_src = th->machine.stack_start; } - if (cont->machine_stack) { - REALLOC_N(cont->machine_stack, VALUE, size); + if (cont->machine.stack) { + REALLOC_N(cont->machine.stack, VALUE, size); } else { - cont->machine_stack = ALLOC_N(VALUE, size); + cont->machine.stack = ALLOC_N(VALUE, size); } FLUSH_REGISTER_WINDOWS; - MEMCPY(cont->machine_stack, cont->machine_stack_src, VALUE, size); + MEMCPY(cont->machine.stack, cont->machine.stack_src, VALUE, size); #ifdef __ia64 rb_ia64_flushrs(); - size = cont->machine_register_stack_size = th->machine_register_stack_end - th->machine_register_stack_start; - cont->machine_register_stack_src = th->machine_register_stack_start; - if (cont->machine_register_stack) { - REALLOC_N(cont->machine_register_stack, VALUE, size); + size = cont->machine.register_stack_size = th->machine.register_stack_end - th->machine.register_stack_start; + cont->machine.register_stack_src = th->machine.register_stack_start; + if (cont->machine.register_stack) { + REALLOC_N(cont->machine.register_stack, VALUE, size); } else { - cont->machine_register_stack = ALLOC_N(VALUE, size); + cont->machine.register_stack = ALLOC_N(VALUE, size); } - MEMCPY(cont->machine_register_stack, cont->machine_register_stack_src, VALUE, size); + MEMCPY(cont->machine.register_stack, cont->machine.register_stack_src, VALUE, size); #endif } @@ -430,13 +432,13 @@ cont_save_thread(rb_context_t *cont, rb_thread_t *th) { /* save thread context */ cont->saved_thread = *th; - /* saved_thread->machine_stack_(start|end) should be NULL */ + /* saved_thread->machine.stack_(start|end) should be NULL */ /* because it may happen GC afterward */ - cont->saved_thread.machine_stack_start = 0; - cont->saved_thread.machine_stack_end = 0; + cont->saved_thread.machine.stack_start = 0; + cont->saved_thread.machine.stack_end = 0; #ifdef __ia64 - cont->saved_thread.machine_register_stack_start = 0; - cont->saved_thread.machine_register_stack_end = 0; + cont->saved_thread.machine.register_stack_start = 0; + cont->saved_thread.machine.register_stack_end = 0; #endif } @@ -579,7 +581,7 @@ fiber_set_stack_location(void) VALUE *ptr; SET_MACHINE_STACK_END(&ptr); - th->machine_stack_start = (void*)(((VALUE)ptr & RB_PAGE_MASK) + STACK_UPPER((void *)&ptr, 0, RB_PAGE_SIZE)); + th->machine.stack_start = (void*)(((VALUE)ptr & RB_PAGE_MASK) + STACK_UPPER((void *)&ptr, 0, RB_PAGE_SIZE)); } static VOID CALLBACK @@ -654,7 +656,7 @@ fiber_initialize_machine_stack_context(rb_fiber_t *fib, size_t size) rb_raise(rb_eFiberError, "can't create fiber"); } } - sth->machine_stack_maxsize = size; + sth->machine.stack_maxsize = size; #else /* not WIN32 */ ucontext_t *context = &fib->context; char *ptr; @@ -666,11 +668,11 @@ fiber_initialize_machine_stack_context(rb_fiber_t *fib, size_t size) context->uc_stack.ss_sp = ptr; context->uc_stack.ss_size = size; makecontext(context, rb_fiber_start, 0); - sth->machine_stack_start = (VALUE*)(ptr + STACK_DIR_UPPER(0, size)); - sth->machine_stack_maxsize = size - RB_PAGE_SIZE; + sth->machine.stack_start = (VALUE*)(ptr + STACK_DIR_UPPER(0, size)); + sth->machine.stack_maxsize = size - RB_PAGE_SIZE; #endif #ifdef __ia64 - sth->machine_register_stack_maxsize = sth->machine_stack_maxsize; + sth->machine.register_stack_maxsize = sth->machine.stack_maxsize; #endif } @@ -687,29 +689,29 @@ fiber_setcontext(rb_fiber_t *newfib, rb_fiber_t *oldfib) /* restore thread context */ cont_restore_thread(&newfib->cont); - th->machine_stack_maxsize = sth->machine_stack_maxsize; - if (sth->machine_stack_end && (newfib != oldfib)) { - rb_bug("fiber_setcontext: sth->machine_stack_end has non zero value"); + th->machine.stack_maxsize = sth->machine.stack_maxsize; + if (sth->machine.stack_end && (newfib != oldfib)) { + rb_bug("fiber_setcontext: sth->machine.stack_end has non zero value"); } /* save oldfib's machine stack */ if (oldfib->status != TERMINATED) { STACK_GROW_DIR_DETECTION; - SET_MACHINE_STACK_END(&th->machine_stack_end); + SET_MACHINE_STACK_END(&th->machine.stack_end); if (STACK_DIR_UPPER(0, 1)) { - oldfib->cont.machine_stack_size = th->machine_stack_start - th->machine_stack_end; - oldfib->cont.machine_stack = th->machine_stack_end; + oldfib->cont.machine.stack_size = th->machine.stack_start - th->machine.stack_end; + oldfib->cont.machine.stack = th->machine.stack_end; } else { - oldfib->cont.machine_stack_size = th->machine_stack_end - th->machine_stack_start; - oldfib->cont.machine_stack = th->machine_stack_start; + oldfib->cont.machine.stack_size = th->machine.stack_end - th->machine.stack_start; + oldfib->cont.machine.stack = th->machine.stack_start; } } /* exchange machine_stack_start between oldfib and newfib */ - oldfib->cont.saved_thread.machine_stack_start = th->machine_stack_start; - th->machine_stack_start = sth->machine_stack_start; - /* oldfib->machine_stack_end should be NULL */ - oldfib->cont.saved_thread.machine_stack_end = 0; + oldfib->cont.saved_thread.machine.stack_start = th->machine.stack_start; + th->machine.stack_start = sth->machine.stack_start; + /* oldfib->machine.stack_end should be NULL */ + oldfib->cont.saved_thread.machine.stack_end = 0; #ifndef _WIN32 if (!newfib->context.uc_stack.ss_sp && th->root_fiber != newfib->cont.self) { rb_bug("non_root_fiber->context.uc_stac.ss_sp should not be NULL"); @@ -742,16 +744,16 @@ cont_restore_1(rb_context_t *cont) ((_JUMP_BUFFER*)(&buf))->Frame; } #endif - if (cont->machine_stack_src) { + if (cont->machine.stack_src) { FLUSH_REGISTER_WINDOWS; - MEMCPY(cont->machine_stack_src, cont->machine_stack, - VALUE, cont->machine_stack_size); + MEMCPY(cont->machine.stack_src, cont->machine.stack, + VALUE, cont->machine.stack_size); } #ifdef __ia64 - if (cont->machine_register_stack_src) { - MEMCPY(cont->machine_register_stack_src, cont->machine_register_stack, - VALUE, cont->machine_register_stack_size); + if (cont->machine.register_stack_src) { + MEMCPY(cont->machine.register_stack_src, cont->machine.register_stack, + VALUE, cont->machine.register_stack_size); } #endif @@ -786,7 +788,7 @@ register_stack_extend(rb_context_t *cont, VALUE *vp, VALUE *curr_bsp) E(k) = E(l) = E(m) = E(n) = E(o) = E(p) = E(q) = E(r) = E(s) = E(t) = 0; } - if (curr_bsp < cont->machine_register_stack_src+cont->machine_register_stack_size) { + if (curr_bsp < cont->machine.register_stack_src+cont->machine.register_stack_size) { register_stack_extend(cont, vp, (VALUE*)rb_ia64_bsp()); } cont_restore_0(cont, vp); @@ -798,7 +800,7 @@ register_stack_extend(rb_context_t *cont, VALUE *vp, VALUE *curr_bsp) static void cont_restore_0(rb_context_t *cont, VALUE *addr_in_prev_frame) { - if (cont->machine_stack_src) { + if (cont->machine.stack_src) { #ifdef HAVE_ALLOCA #define STACK_PAD_SIZE 1 #else @@ -811,7 +813,7 @@ cont_restore_0(rb_context_t *cont, VALUE *addr_in_prev_frame) /* Stack grows downward */ #endif #if STACK_GROW_DIRECTION <= 0 - volatile VALUE *const end = cont->machine_stack_src; + volatile VALUE *const end = cont->machine.stack_src; if (&space[0] > end) { # ifdef HAVE_ALLOCA volatile VALUE *sp = ALLOCA_N(VALUE, &space[0] - end); @@ -827,7 +829,7 @@ cont_restore_0(rb_context_t *cont, VALUE *addr_in_prev_frame) /* Stack grows upward */ #endif #if STACK_GROW_DIRECTION >= 0 - volatile VALUE *const end = cont->machine_stack_src + cont->machine_stack_size; + volatile VALUE *const end = cont->machine.stack_src + cont->machine.stack_size; if (&space[STACK_PAD_SIZE] < end) { # ifdef HAVE_ALLOCA volatile VALUE *sp = ALLOCA_N(VALUE, end - &space[STACK_PAD_SIZE]); @@ -1258,8 +1260,8 @@ rb_fiber_terminate(rb_fiber_t *fib) terminated_machine_stack.ptr = fib->context.uc_stack.ss_sp; terminated_machine_stack.size = fib->context.uc_stack.ss_size / sizeof(VALUE); fib->context.uc_stack.ss_sp = NULL; - fib->cont.machine_stack = NULL; - fib->cont.machine_stack_size = 0; + fib->cont.machine.stack = NULL; + fib->cont.machine.stack_size = 0; #endif rb_fiber_transfer(return_fiber(), 1, &value); } @@ -1369,7 +1371,7 @@ fiber_store(rb_fiber_t *next_fib) machine_stack_cache_index++; } else { - if (terminated_machine_stack.ptr != fib->cont.machine_stack) { + if (terminated_machine_stack.ptr != fib->cont.machine.stack) { munmap((void*)terminated_machine_stack.ptr, terminated_machine_stack.size * sizeof(VALUE)); } else { @@ -1659,7 +1661,7 @@ Init_Cont(void) #else /* not WIN32 */ pagesize = sysconf(_SC_PAGESIZE); #endif - SET_MACHINE_STACK_END(&th->machine_stack_end); + SET_MACHINE_STACK_END(&th->machine.stack_end); #endif rb_cFiber = rb_define_class("Fiber", rb_cObject); diff --git a/gc.c b/gc.c index 22f7f6db3a445b..76b8eb9b00aa8b 100644 --- a/gc.c +++ b/gc.c @@ -3210,14 +3210,14 @@ init_mark_stack(mark_stack_t *stack) /* Marking */ #ifdef __ia64 -#define SET_STACK_END (SET_MACHINE_STACK_END(&th->machine_stack_end), th->machine_register_stack_end = rb_ia64_bsp()) +#define SET_STACK_END (SET_MACHINE_STACK_END(&th->machine.stack_end), th->machine.register_stack_end = rb_ia64_bsp()) #else -#define SET_STACK_END SET_MACHINE_STACK_END(&th->machine_stack_end) +#define SET_STACK_END SET_MACHINE_STACK_END(&th->machine.stack_end) #endif -#define STACK_START (th->machine_stack_start) -#define STACK_END (th->machine_stack_end) -#define STACK_LEVEL_MAX (th->machine_stack_maxsize/sizeof(VALUE)) +#define STACK_START (th->machine.stack_start) +#define STACK_END (th->machine.stack_end) +#define STACK_LEVEL_MAX (th->machine.stack_maxsize/sizeof(VALUE)) #if STACK_GROW_DIRECTION < 0 # define STACK_LENGTH (size_t)(STACK_START - STACK_END) @@ -3259,8 +3259,8 @@ stack_check(int water_mark) ret = STACK_LENGTH > STACK_LEVEL_MAX - water_mark; #ifdef __ia64 if (!ret) { - ret = (VALUE*)rb_ia64_bsp() - th->machine_register_stack_start > - th->machine_register_stack_maxsize/sizeof(VALUE) - water_mark; + ret = (VALUE*)rb_ia64_bsp() - th->machine.register_stack_start > + th->machine.register_stack_maxsize/sizeof(VALUE) - water_mark; } #endif return ret; @@ -3484,7 +3484,7 @@ mark_current_machine_context(rb_objspace_t *objspace, rb_thread_t *th) rb_gc_mark_locations(stack_start, stack_end); #ifdef __ia64 - rb_gc_mark_locations(th->machine_register_stack_start, th->machine_register_stack_end); + rb_gc_mark_locations(th->machine.register_stack_start, th->machine.register_stack_end); #endif #if defined(__mc68000__) mark_locations_array(objspace, (VALUE*)((char*)STACK_END + 2), @@ -3501,7 +3501,7 @@ rb_gc_mark_machine_stack(rb_thread_t *th) GET_STACK_BOUNDS(stack_start, stack_end, 0); rb_gc_mark_locations(stack_start, stack_end); #ifdef __ia64 - rb_gc_mark_locations(th->machine_register_stack_start, th->machine_register_stack_end); + rb_gc_mark_locations(th->machine.register_stack_start, th->machine.register_stack_end); #endif } diff --git a/test/ruby/test_exception.rb b/test/ruby/test_exception.rb index f358c00f97d5c1..c3314568c13491 100644 --- a/test/ruby/test_exception.rb +++ b/test/ruby/test_exception.rb @@ -510,6 +510,17 @@ def test_machine_stackoverflow rescue SystemStackError end + def test_machine_stackoverflow_by_define_method + bug9454 = '[ruby-core:60113] [Bug #9454]' + assert_separately([], <<-SRC) + assert_raise(SystemStackError, #{bug9454.dump}) { + define_method(:foo) {self.foo} + self.foo + } + SRC + rescue SystemStackError + end + def test_cause msg = "[Feature #8257]" cause = nil diff --git a/thread.c b/thread.c index 0e743c68e0da43..b1dcc5bbdebbd9 100644 --- a/thread.c +++ b/thread.c @@ -121,7 +121,7 @@ static inline void blocking_region_end(rb_thread_t *th, struct rb_blocking_regio #ifdef __ia64 #define RB_GC_SAVE_MACHINE_REGISTER_STACK(th) \ - do{(th)->machine_register_stack_end = rb_ia64_bsp();}while(0) + do{(th)->machine.register_stack_end = rb_ia64_bsp();}while(0) #else #define RB_GC_SAVE_MACHINE_REGISTER_STACK(th) #endif @@ -129,8 +129,8 @@ static inline void blocking_region_end(rb_thread_t *th, struct rb_blocking_regio do { \ FLUSH_REGISTER_WINDOWS; \ RB_GC_SAVE_MACHINE_REGISTER_STACK(th); \ - setjmp((th)->machine_regs); \ - SET_MACHINE_STACK_END(&(th)->machine_stack_end); \ + setjmp((th)->machine.regs); \ + SET_MACHINE_STACK_END(&(th)->machine.stack_end); \ } while (0) #define GVL_UNLOCK_BEGIN() do { \ @@ -465,9 +465,9 @@ thread_cleanup_func_before_exec(void *th_ptr) { rb_thread_t *th = th_ptr; th->status = THREAD_KILLED; - th->machine_stack_start = th->machine_stack_end = 0; + th->machine.stack_start = th->machine.stack_end = 0; #ifdef __ia64 - th->machine_register_stack_start = th->machine_register_stack_end = 0; + th->machine.register_stack_start = th->machine.register_stack_end = 0; #endif } @@ -519,9 +519,9 @@ thread_start_func_2(rb_thread_t *th, VALUE *stack_start, VALUE *register_stack_s ruby_thread_set_native(th); - th->machine_stack_start = stack_start; + th->machine.stack_start = stack_start; #ifdef __ia64 - th->machine_register_stack_start = register_stack_start; + th->machine.register_stack_start = register_stack_start; #endif thread_debug("thread start: %p\n", (void *)th); diff --git a/thread_pthread.c b/thread_pthread.c index aa2c49e949ab9d..581dfecaaa3d27 100644 --- a/thread_pthread.c +++ b/thread_pthread.c @@ -661,6 +661,18 @@ ruby_init_stack(volatile VALUE *addr ) { native_main_thread.id = pthread_self(); +#if MAINSTACKADDR_AVAILABLE + if (native_main_thread.stack_maxsize) return; + { + void* stackaddr; + size_t size; + if (get_main_stack(&stackaddr, &size) == 0) { + native_main_thread.stack_maxsize = size; + native_main_thread.stack_start = stackaddr; + return; + } + } +#endif #ifdef STACK_END_ADDRESS native_main_thread.stack_start = STACK_END_ADDRESS; #else @@ -676,18 +688,6 @@ ruby_init_stack(volatile VALUE *addr (VALUE*)bsp < native_main_thread.register_stack_start) { native_main_thread.register_stack_start = (VALUE*)bsp; } -#endif -#if MAINSTACKADDR_AVAILABLE - if (native_main_thread.stack_maxsize) return; - { - void* stackaddr; - size_t size; - if (get_main_stack(&stackaddr, &size) == 0) { - native_main_thread.stack_maxsize = size; - native_main_thread.stack_start = stackaddr; - return; - } - } #endif { #if defined(HAVE_GETRLIMIT) @@ -749,8 +749,8 @@ native_thread_init_stack(rb_thread_t *th) rb_nativethread_id_t curr = pthread_self(); if (pthread_equal(curr, native_main_thread.id)) { - th->machine_stack_start = native_main_thread.stack_start; - th->machine_stack_maxsize = native_main_thread.stack_maxsize; + th->machine.stack_start = native_main_thread.stack_start; + th->machine.stack_maxsize = native_main_thread.stack_maxsize; } else { #ifdef STACKADDR_AVAILABLE @@ -758,11 +758,11 @@ native_thread_init_stack(rb_thread_t *th) size_t size; if (get_stack(&start, &size) == 0) { - th->machine_stack_start = start; - th->machine_stack_maxsize = size; + th->machine.stack_start = start; + th->machine.stack_maxsize = size; } #elif defined get_stack_of - if (!th->machine_stack_maxsize) { + if (!th->machine.stack_maxsize) { native_mutex_lock(&th->interrupt_lock); native_mutex_unlock(&th->interrupt_lock); } @@ -771,9 +771,9 @@ native_thread_init_stack(rb_thread_t *th) #endif } #ifdef __ia64 - th->machine_register_stack_start = native_main_thread.register_stack_start; - th->machine_stack_maxsize /= 2; - th->machine_register_stack_maxsize = th->machine_stack_maxsize; + th->machine.register_stack_start = native_main_thread.register_stack_start; + th->machine.stack_maxsize /= 2; + th->machine.register_stack_maxsize = th->machine.stack_maxsize; #endif return 0; } @@ -800,7 +800,7 @@ thread_start_func_1(void *th_ptr) native_thread_init(th); /* run */ #if defined USE_NATIVE_THREAD_INIT - thread_start_func_2(th, th->machine_stack_start, rb_ia64_bsp()); + thread_start_func_2(th, th->machine.stack_start, rb_ia64_bsp()); #else thread_start_func_2(th, &stack_start, rb_ia64_bsp()); #endif @@ -922,10 +922,10 @@ native_thread_create(rb_thread_t *th) const size_t stack_size = th->vm->default_params.thread_machine_stack_size; const size_t space = space_size(stack_size); - th->machine_stack_maxsize = stack_size - space; + th->machine.stack_maxsize = stack_size - space; #ifdef __ia64 - th->machine_stack_maxsize /= 2; - th->machine_register_stack_maxsize = th->machine_stack_maxsize; + th->machine.stack_maxsize /= 2; + th->machine.register_stack_maxsize = th->machine.stack_maxsize; #endif #ifdef HAVE_PTHREAD_ATTR_INIT @@ -948,8 +948,8 @@ native_thread_create(rb_thread_t *th) #ifdef get_stack_of if (!err) { get_stack_of(th->thread_id, - &th->machine_stack_start, - &th->machine_stack_maxsize); + &th->machine.stack_start, + &th->machine.stack_maxsize); } native_mutex_unlock(&th->interrupt_lock); #endif @@ -1558,15 +1558,24 @@ ruby_stack_overflowed_p(const rb_thread_t *th, const void *addr) const size_t water_mark = 1024 * 1024; STACK_GROW_DIR_DETECTION; - if (th) { - size = th->machine_stack_maxsize; - base = (char *)th->machine_stack_start - STACK_DIR_UPPER(0, size); - } #ifdef STACKADDR_AVAILABLE - else if (get_stack(&base, &size) == 0) { - STACK_DIR_UPPER((void)(base = (char *)base + size), (void)0); + if (get_stack(&base, &size) == 0) { +# ifdef __APPLE__ + if (pthread_equal(th->thread_id, native_main_thread.id)) { + struct rlimit rlim; + if (getrlimit(RLIMIT_STACK, &rlim) == 0 && rlim.rlim_cur > size) { + size = (size_t)rlim.rlim_cur; + } + } +# endif + base = (char *)base + STACK_DIR_UPPER(+size, -size); } + else #endif + if (th) { + size = th->machine.stack_maxsize; + base = (char *)th->machine.stack_start - STACK_DIR_UPPER(0, size); + } else { return 0; } diff --git a/thread_win32.c b/thread_win32.c index 9f851867c8cbf2..7eb640aa6c68c2 100644 --- a/thread_win32.c +++ b/thread_win32.c @@ -571,8 +571,8 @@ native_thread_init_stack(rb_thread_t *th) size = end - base; space = size / 5; if (space > 1024*1024) space = 1024*1024; - th->machine_stack_start = (VALUE *)end - 1; - th->machine_stack_maxsize = size - space; + th->machine.stack_start = (VALUE *)end - 1; + th->machine.stack_maxsize = size - space; } #ifndef InterlockedExchangePointer @@ -600,7 +600,7 @@ thread_start_func_1(void *th_ptr) thread_debug("thread created (th: %p, thid: %p, event: %p)\n", th, th->thread_id, th->native_thread_data.interrupt_event); - thread_start_func_2(th, th->machine_stack_start, rb_ia64_bsp()); + thread_start_func_2(th, th->machine.stack_start, rb_ia64_bsp()); w32_close_handle(thread_id); thread_debug("thread deleted (th: %p)\n", th); diff --git a/version.h b/version.h index 791f34a5281d36..4a3d77ba658f5f 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-06-20" -#define RUBY_PATCHLEVEL 133 +#define RUBY_PATCHLEVEL 134 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 6 diff --git a/vm.c b/vm.c index 8e40b9f4a69ea2..99acce2fad9959 100644 --- a/vm.c +++ b/vm.c @@ -1983,11 +1983,11 @@ rb_thread_mark(void *ptr) rb_mark_tbl(th->local_storage); - if (GET_THREAD() != th && th->machine_stack_start && th->machine_stack_end) { + if (GET_THREAD() != th && th->machine.stack_start && th->machine.stack_end) { rb_gc_mark_machine_stack(th); - rb_gc_mark_locations((VALUE *)&th->machine_regs, - (VALUE *)(&th->machine_regs) + - sizeof(th->machine_regs) / sizeof(VALUE)); + rb_gc_mark_locations((VALUE *)&th->machine.regs, + (VALUE *)(&th->machine.regs) + + sizeof(th->machine.regs) / sizeof(VALUE)); } rb_vm_trace_mark_event_hooks(&th->event_hooks); diff --git a/vm_core.h b/vm_core.h index befdbfdc26ec7c..fbdd57e8fac655 100644 --- a/vm_core.h +++ b/vm_core.h @@ -617,15 +617,17 @@ typedef struct rb_thread_struct { VALUE (*first_func)(ANYARGS); /* for GC */ - VALUE *machine_stack_start; - VALUE *machine_stack_end; - size_t machine_stack_maxsize; + struct { + VALUE *stack_start; + VALUE *stack_end; + size_t stack_maxsize; #ifdef __ia64 - VALUE *machine_register_stack_start; - VALUE *machine_register_stack_end; - size_t machine_register_stack_maxsize; + VALUE *register_stack_start; + VALUE *register_stack_end; + size_t register_stack_maxsize; #endif - jmp_buf machine_regs; + jmp_buf regs; + } machine; int mark_stack_len; /* statistics data for profiler */ From b3cbe251735465520907cd07b3868e8128182ff7 Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 22 Jun 2014 16:53:59 +0000 Subject: [PATCH 134/343] merge revision(s) r46060: [Backport #9627] * net/protocol.rb (using_each_crlf_line): fix SMTP dot-stuffing for messages not ending with a new-line. [ruby-core:61441] [Bug #9627] [fix GH-616] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46496 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ lib/net/protocol.rb | 8 ++++++-- test/net/protocol/test_protocol.rb | 9 +++++++++ version.h | 6 +++--- 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 19bb9e691ea69e..aa06d67995bfd4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Mon Jun 23 01:53:18 2014 Josh Goebel + + * net/protocol.rb (using_each_crlf_line): fix SMTP dot-stuffing + for messages not ending with a new-line. + [ruby-core:61441] [Bug #9627] [fix GH-616] + Fri Jun 20 00:40:06 2014 Nobuyoshi Nakada * thread_pthread.c (ruby_init_stack, ruby_stack_overflowed_p): diff --git a/lib/net/protocol.rb b/lib/net/protocol.rb index 14a68e11154b6c..25477014fb090d 100644 --- a/lib/net/protocol.rb +++ b/lib/net/protocol.rb @@ -267,7 +267,7 @@ def each_list_item def write_message_0(src) prev = @written_bytes each_crlf_line(src) do |line| - write0 line.sub(/\A\./, '..') + write0 dot_stuff(line) end @written_bytes - prev end @@ -308,11 +308,15 @@ def write_message_by_block(&block) private + def dot_stuff(s) + s.sub(/\A\./, '..') + end + def using_each_crlf_line @wbuf = '' yield if not @wbuf.empty? # unterminated last line - write0 @wbuf.chomp + "\r\n" + write0 dot_stuff(@wbuf.chomp) + "\r\n" elsif @written_bytes == 0 # empty src write0 "\r\n" end diff --git a/test/net/protocol/test_protocol.rb b/test/net/protocol/test_protocol.rb index f6ee4941cfe4ce..4453422552e9c1 100644 --- a/test/net/protocol/test_protocol.rb +++ b/test/net/protocol/test_protocol.rb @@ -3,6 +3,15 @@ require "stringio" class TestProtocol < Test::Unit::TestCase + def test_should_properly_dot_stuff_period_with_no_endline + bug9627 = '[ruby-core:61441] [Bug #9627]' + sio = StringIO.new("") + imio = Net::InternetMessageIO.new(sio) + email = "To: bob@aol.com\nlook, a period with no endline\n." + imio.write_message(email) + assert_equal("To: bob@aol.com\r\nlook, a period with no endline\r\n..\r\n.\r\n", sio.string, bug9627) + end + def test_each_crlf_line assert_output('', '') do sio = StringIO.new("") diff --git a/version.h b/version.h index 4a3d77ba658f5f..281c948cef39f7 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.2" -#define RUBY_RELEASE_DATE "2014-06-20" -#define RUBY_PATCHLEVEL 134 +#define RUBY_RELEASE_DATE "2014-06-23" +#define RUBY_PATCHLEVEL 135 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 6 -#define RUBY_RELEASE_DAY 20 +#define RUBY_RELEASE_DAY 23 #include "ruby/version.h" From 07ac36ada5a486023593d129b54be836923cfa4d Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 22 Jun 2014 17:44:28 +0000 Subject: [PATCH 135/343] merge revision(s) r45899: [Backport #9751] * thread.c (thread_start_func_2): stop if forked in a sub-thread, the thread has become the main thread. [ruby-core:62070] [Bug #9751] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46497 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ test/ruby/test_thread.rb | 21 +++++++++++++++++++++ thread.c | 3 +++ version.h | 2 +- 4 files changed, 31 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index aa06d67995bfd4..e95a2c6e77ab2c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Mon Jun 23 02:36:04 2014 Nobuyoshi Nakada + + * thread.c (thread_start_func_2): stop if forked in a sub-thread, + the thread has become the main thread. + [ruby-core:62070] [Bug #9751] + Mon Jun 23 01:53:18 2014 Josh Goebel * net/protocol.rb (using_each_crlf_line): fix SMTP dot-stuffing diff --git a/test/ruby/test_thread.rb b/test/ruby/test_thread.rb index cd84c125bc2a6d..110bbdd6dead80 100644 --- a/test/ruby/test_thread.rb +++ b/test/ruby/test_thread.rb @@ -969,4 +969,25 @@ def test_blocking_mutex_unlocked_on_fork pid, status = Process.waitpid2(pid) assert_equal(false, status.success?, bug8433) end if Process.respond_to?(:fork) + + def test_fork_in_thread + bug9751 = '[ruby-core:62070] [Bug #9751]' + f = nil + th = Thread.start do + unless f = IO.popen("-") + STDERR.reopen(STDOUT) + exit + end + Process.wait2(f.pid) + end + unless th.join(3) + Process.kill(:QUIT, f.pid) + Process.kill(:KILL, f.pid) unless th.join(1) + end + _, status = th.value + output = f.read + f.close + assert_not_predicate(status, :signaled?, FailDesc[status, bug9751, output]) + assert_predicate(status, :success?, bug9751) + end if Process.respond_to?(:fork) end diff --git a/thread.c b/thread.c index b1dcc5bbdebbd9..f3e60fce41033e 100644 --- a/thread.c +++ b/thread.c @@ -569,6 +569,9 @@ thread_start_func_2(rb_thread_t *th, VALUE *stack_start, VALUE *register_stack_s thread_debug("thread end: %p\n", (void *)th); main_th = th->vm->main_thread; + if (main_th == th) { + ruby_stop(0); + } if (RB_TYPE_P(errinfo, T_OBJECT)) { /* treat with normal error object */ rb_threadptr_raise(main_th, 1, &errinfo); diff --git a/version.h b/version.h index 281c948cef39f7..2eadc6240c658a 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-06-23" -#define RUBY_PATCHLEVEL 135 +#define RUBY_PATCHLEVEL 136 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 6 From 9f982bd59d6e3e5e4c2c5ca20bdef79df4f8b5c0 Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 22 Jun 2014 17:52:26 +0000 Subject: [PATCH 136/343] merge revision(s) r45874: [Backport #9813] * class.c (rb_mod_init_copy): always clear instance variable, constant and method tables first, regardless the source tables. [ruby-dev:48182] [Bug #9813] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46498 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ class.c | 22 +++++++++++++--------- test/ruby/test_module.rb | 19 +++++++++++++++++++ version.h | 2 +- 4 files changed, 39 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index e95a2c6e77ab2c..dfc225455a465e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Mon Jun 23 02:46:14 2014 Nobuyoshi Nakada + + * class.c (rb_mod_init_copy): always clear instance variable, + constant and method tables first, regardless the source tables. + [ruby-dev:48182] [Bug #9813] + Mon Jun 23 02:36:04 2014 Nobuyoshi Nakada * thread.c (thread_start_func_2): stop if forked in a sub-thread, diff --git a/class.c b/class.c index e4ccbc9fc15e5b..de5323a69b2472 100644 --- a/class.c +++ b/class.c @@ -328,12 +328,21 @@ rb_mod_init_copy(VALUE clone, VALUE orig) } RCLASS_SET_SUPER(clone, RCLASS_SUPER(orig)); RCLASS_EXT(clone)->allocator = RCLASS_EXT(orig)->allocator; + if (RCLASS_IV_TBL(clone)) { + st_free_table(RCLASS_IV_TBL(clone)); + RCLASS_IV_TBL(clone) = 0; + } + if (RCLASS_CONST_TBL(clone)) { + rb_free_const_table(RCLASS_CONST_TBL(clone)); + RCLASS_CONST_TBL(clone) = 0; + } + if (RCLASS_M_TBL_WRAPPER(clone)) { + rb_free_m_tbl_wrapper(RCLASS_M_TBL_WRAPPER(clone)); + RCLASS_M_TBL_WRAPPER(clone) = 0; + } if (RCLASS_IV_TBL(orig)) { st_data_t id; - if (RCLASS_IV_TBL(clone)) { - st_free_table(RCLASS_IV_TBL(clone)); - } RCLASS_IV_TBL(clone) = rb_st_copy(clone, RCLASS_IV_TBL(orig)); CONST_ID(id, "__tmp_classpath__"); st_delete(RCLASS_IV_TBL(clone), &id, 0); @@ -344,18 +353,13 @@ rb_mod_init_copy(VALUE clone, VALUE orig) } if (RCLASS_CONST_TBL(orig)) { struct clone_const_arg arg; - if (RCLASS_CONST_TBL(clone)) { - rb_free_const_table(RCLASS_CONST_TBL(clone)); - } + RCLASS_CONST_TBL(clone) = st_init_numtable(); arg.klass = clone; arg.tbl = RCLASS_CONST_TBL(clone); st_foreach(RCLASS_CONST_TBL(orig), clone_const_i, (st_data_t)&arg); } if (RCLASS_M_TBL(orig)) { - if (RCLASS_M_TBL_WRAPPER(clone)) { - rb_free_m_tbl_wrapper(RCLASS_M_TBL_WRAPPER(clone)); - } RCLASS_M_TBL_INIT(clone); st_foreach(RCLASS_M_TBL(orig), clone_method_i, (st_data_t)clone); } diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb index ca453fa5eb57bd..372a2d4ca5d08e 100644 --- a/test/ruby/test_module.rb +++ b/test/ruby/test_module.rb @@ -375,6 +375,25 @@ def foo assert_equal(:ok, Object.new.extend(m).foo, bug9535) end + def test_initialize_copy_empty + bug9813 = '[ruby-dev:48182] [Bug #9813]' + m = Module.new do + def x + end + const_set(:X, 1) + @x = 2 + end + assert_equal([:x], m.instance_methods) + assert_equal([:@x], m.instance_variables) + assert_equal([:X], m.constants) + m.module_eval do + initialize_copy(Module.new) + end + assert_empty(m.instance_methods, bug9813) + assert_empty(m.instance_variables, bug9813) + assert_empty(m.constants, bug9813) + end + def test_dup bug6454 = '[ruby-core:45132]' diff --git a/version.h b/version.h index 2eadc6240c658a..257b88386a95d5 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-06-23" -#define RUBY_PATCHLEVEL 136 +#define RUBY_PATCHLEVEL 137 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 6 From a5b0009c05edc3f9e7e09a085323c7b96ed0b8e0 Mon Sep 17 00:00:00 2001 From: nagachika Date: Mon, 23 Jun 2014 15:02:21 +0000 Subject: [PATCH 137/343] merge revision(s) r46194: [Backport #9835] * signal.c (signal_exec): ignore immediate cmd for SIG_IGN * signal.c (trap_handler): set cmd to true for SIG_IGN * signal.c (trap): handle nil and true values for oldcmd [Bug #9835] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46520 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ signal.c | 14 +++++++++++++- version.h | 2 +- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index dfc225455a465e..349a7a65a256fc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Mon Jun 23 23:56:54 2014 Eric Wong + + * signal.c (signal_exec): ignore immediate cmd for SIG_IGN + * signal.c (trap_handler): set cmd to true for SIG_IGN + * signal.c (trap): handle nil and true values for oldcmd + [Bug #9835] + Mon Jun 23 02:46:14 2014 Nobuyoshi Nakada * class.c (rb_mod_init_copy): always clear instance variable, diff --git a/signal.c b/signal.c index d82f4c7e2b2360..3c6b96737fd825 100644 --- a/signal.c +++ b/signal.c @@ -740,6 +740,15 @@ signal_exec(VALUE cmd, int safe, int sig) volatile unsigned long old_interrupt_mask = cur_th->interrupt_mask; int state; + /* + * workaround the following race: + * 1. signal_enque queues signal for execution + * 2. user calls trap(sig, "IGNORE"), setting SIG_IGN + * 3. rb_signal_exec runs on queued signal + */ + if (IMMEDIATE_P(cmd)) + return; + cur_th->interrupt_mask |= TRAP_INTERRUPT_MASK; TH_PUSH_TAG(cur_th); if ((state = EXEC_TAG()) == 0) { @@ -891,7 +900,7 @@ trap_handler(VALUE *cmd, int sig) if (strncmp(RSTRING_PTR(command), "SIG_IGN", 7) == 0) { sig_ign: func = SIG_IGN; - *cmd = 0; + *cmd = Qtrue; } else if (strncmp(RSTRING_PTR(command), "SIG_DFL", 7) == 0) { sig_dfl: @@ -972,10 +981,13 @@ trap(int sig, sighandler_t func, VALUE command) oldcmd = vm->trap_list[sig].cmd; switch (oldcmd) { case 0: + case Qtrue: if (oldfunc == SIG_IGN) oldcmd = rb_str_new2("IGNORE"); else if (oldfunc == sighandler) oldcmd = rb_str_new2("DEFAULT"); else oldcmd = Qnil; break; + case Qnil: + break; case Qundef: oldcmd = rb_str_new2("EXIT"); break; diff --git a/version.h b/version.h index 257b88386a95d5..631a0eddfbfc27 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-06-23" -#define RUBY_PATCHLEVEL 137 +#define RUBY_PATCHLEVEL 138 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 6 From e9373b36c856ca69e4d989af7a3700ca894df368 Mon Sep 17 00:00:00 2001 From: svn Date: Mon, 23 Jun 2014 15:02:32 +0000 Subject: [PATCH 138/343] * 2014-06-24 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46521 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- version.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/version.h b/version.h index 631a0eddfbfc27..22c0ea81b32f4d 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.2" -#define RUBY_RELEASE_DATE "2014-06-23" +#define RUBY_RELEASE_DATE "2014-06-24" #define RUBY_PATCHLEVEL 138 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 6 -#define RUBY_RELEASE_DAY 23 +#define RUBY_RELEASE_DAY 24 #include "ruby/version.h" From c22cbdc1306dbf0a4019299057fca688aaa9106b Mon Sep 17 00:00:00 2001 From: nagachika Date: Mon, 23 Jun 2014 15:08:11 +0000 Subject: [PATCH 139/343] merge revision(s) r45947,r45951: [Backport #9739] [Backport #9844] * thread_win32.c (rb_w32_stack_overflow_handler): use Structured Exception Handling by Addvectoredexceptionhandler() for machine stack overflow on mingw. This would be equivalent to the handling using __try and __exept on mswin introduced by r43748. Exception Handling by AddVectoredExceptionHandler() for machine This would be equivalent to the handling using __try and __except git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46522 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ eval_intern.h | 9 +++++++++ thread_win32.c | 12 ++++++++++++ version.h | 2 +- 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 349a7a65a256fc..8bd5de4f510c83 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Tue Jun 24 00:06:41 2014 Hiroshi Shirosaki + + * thread_win32.c (rb_w32_stack_overflow_handler): use Structured + Exception Handling by AddVectoredExceptionHandler() for machine + stack overflow on mingw. + This would be equivalent to the handling using __try and __except + on mswin introduced by r43748. + Mon Jun 23 23:56:54 2014 Eric Wong * signal.c (signal_exec): ignore immediate cmd for SIG_IGN diff --git a/eval_intern.h b/eval_intern.h index a0ecb5086bd692..5064fde2576e6a 100644 --- a/eval_intern.h +++ b/eval_intern.h @@ -95,6 +95,15 @@ extern int select_large_fdset(int, fd_set *, fd_set *, fd_set *, struct timeval EXCEPTION_CONTINUE_SEARCH) { \ /* never reaches here */ \ } +#elif defined(__MINGW32__) +LONG WINAPI rb_w32_stack_overflow_handler(struct _EXCEPTION_POINTERS *); +#define SAVE_ROOT_JMPBUF_BEFORE_STMT \ + do { \ + PVOID _handler = AddVectoredExceptionHandler(1, rb_w32_stack_overflow_handler); + +#define SAVE_ROOT_JMPBUF_AFTER_STMT \ + RemoveVectoredExceptionHandler(_handler); \ + } while (0); #else #define SAVE_ROOT_JMPBUF_BEFORE_STMT #define SAVE_ROOT_JMPBUF_AFTER_STMT diff --git a/thread_win32.c b/thread_win32.c index 7eb640aa6c68c2..aea3fc20ac7579 100644 --- a/thread_win32.c +++ b/thread_win32.c @@ -754,6 +754,18 @@ ruby_stack_overflowed_p(const rb_thread_t *th, const void *addr) return rb_thread_raised_p(th, RAISED_STACKOVERFLOW); } +#if defined(__MINGW32__) +LONG WINAPI +rb_w32_stack_overflow_handler(struct _EXCEPTION_POINTERS *exception) +{ + if (exception->ExceptionRecord->ExceptionCode == EXCEPTION_STACK_OVERFLOW) { + rb_thread_raised_set(GET_THREAD(), RAISED_STACKOVERFLOW); + raise(SIGSEGV); + } + return EXCEPTION_CONTINUE_SEARCH; +} +#endif + #ifdef RUBY_ALLOCA_CHKSTK void ruby_alloca_chkstk(size_t len, void *sp) diff --git a/version.h b/version.h index 22c0ea81b32f4d..921abe0f7cef35 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-06-24" -#define RUBY_PATCHLEVEL 138 +#define RUBY_PATCHLEVEL 139 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 6 From 12ac28e2a54a059ebf2eb1ea776d38799f0bc321 Mon Sep 17 00:00:00 2001 From: nagachika Date: Mon, 23 Jun 2014 15:19:51 +0000 Subject: [PATCH 140/343] merge revision(s) r46182: [Backport #9872] * lib/net/ftp.rb (transfercmd): Close TCP server socket even if an exception occur. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46523 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ lib/net/ftp.rb | 31 +++++++++++++++++-------------- version.h | 2 +- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8bd5de4f510c83..0655808fed85c4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Tue Jun 24 00:14:20 2014 Tanaka Akira + + * lib/net/ftp.rb (transfercmd): Close TCP server socket even if an + exception occur. + Tue Jun 24 00:06:41 2014 Hiroshi Shirosaki * thread_win32.c (rb_w32_stack_overflow_handler): use Structured diff --git a/lib/net/ftp.rb b/lib/net/ftp.rb index c22b9636d5d47f..0811b13b2d8a6d 100644 --- a/lib/net/ftp.rb +++ b/lib/net/ftp.rb @@ -420,23 +420,26 @@ def transfercmd(cmd, rest_offset = nil) # :nodoc: end else sock = makeport - if @resume and rest_offset - resp = sendcmd("REST " + rest_offset.to_s) - if resp[0] != ?3 + begin + if @resume and rest_offset + resp = sendcmd("REST " + rest_offset.to_s) + if resp[0] != ?3 + raise FTPReplyError, resp + end + end + resp = sendcmd(cmd) + # skip 2XX for some ftp servers + resp = getresp if resp[0] == ?2 + if resp[0] != ?1 raise FTPReplyError, resp end + conn = BufferedSocket.new(sock.accept) + conn.read_timeout = @read_timeout + sock.shutdown(Socket::SHUT_WR) rescue nil + sock.read rescue nil + ensure + sock.close end - resp = sendcmd(cmd) - # skip 2XX for some ftp servers - resp = getresp if resp[0] == ?2 - if resp[0] != ?1 - raise FTPReplyError, resp - end - conn = BufferedSocket.new(sock.accept) - conn.read_timeout = @read_timeout - sock.shutdown(Socket::SHUT_WR) rescue nil - sock.read rescue nil - sock.close end return conn end diff --git a/version.h b/version.h index 921abe0f7cef35..27e3f843387ee6 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-06-24" -#define RUBY_PATCHLEVEL 139 +#define RUBY_PATCHLEVEL 140 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 6 From 80831f0e1193e432a465be23650f3717f628496d Mon Sep 17 00:00:00 2001 From: nagachika Date: Mon, 23 Jun 2014 15:27:46 +0000 Subject: [PATCH 141/343] merge revision(s) r46313: [Backport #9896] * eval.c (rb_using_refinement): add write-barriers for cref->nd_refinements. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46524 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ eval.c | 4 ++-- version.h | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0655808fed85c4..23f30ff31fcaaa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Tue Jun 24 00:21:58 2014 Koichi Sasada + + * eval.c (rb_using_refinement): add write-barriers for + cref->nd_refinements. + Tue Jun 24 00:14:20 2014 Tanaka Akira * lib/net/ftp.rb (transfercmd): Close TCP server socket even if an diff --git a/eval.c b/eval.c index d4dcaa1111fb36..c077f79ecd88b1 100644 --- a/eval.c +++ b/eval.c @@ -1098,11 +1098,11 @@ rb_using_refinement(NODE *cref, VALUE klass, VALUE module) Check_Type(klass, T_CLASS); Check_Type(module, T_MODULE); if (NIL_P(cref->nd_refinements)) { - cref->nd_refinements = hidden_identity_hash_new(); + RB_OBJ_WRITE(cref, &cref->nd_refinements, hidden_identity_hash_new()); } else { if (cref->flags & NODE_FL_CREF_OMOD_SHARED) { - cref->nd_refinements = rb_hash_dup(cref->nd_refinements); + RB_OBJ_WRITE(cref, &cref->nd_refinements, rb_hash_dup(cref->nd_refinements)); cref->flags &= ~NODE_FL_CREF_OMOD_SHARED; } if (!NIL_P(c = rb_hash_lookup(cref->nd_refinements, klass))) { diff --git a/version.h b/version.h index 27e3f843387ee6..71e632bcfdbe2f 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-06-24" -#define RUBY_PATCHLEVEL 140 +#define RUBY_PATCHLEVEL 141 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 6 From 85a3ceafec987a55946358aa0a135f2860f4dc22 Mon Sep 17 00:00:00 2001 From: nagachika Date: Mon, 23 Jun 2014 16:03:42 +0000 Subject: [PATCH 142/343] merge revision(s) r45540: [Backport #9911] ossl.c: OPENSSL_LIBRARY_VERSION * ext/openssl/ossl.c (Init_openssl): add constant OPENSSL_LIBRARY_VERSION which tells the version running OpenSSL. [EXPERIMENTAL] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46525 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/openssl/ossl.c | 5 +++++ version.h | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ext/openssl/ossl.c b/ext/openssl/ossl.c index 50f1db7cf790c6..5104987c465723 100644 --- a/ext/openssl/ossl.c +++ b/ext/openssl/ossl.c @@ -1082,6 +1082,11 @@ Init_openssl() */ rb_define_const(mOSSL, "OPENSSL_VERSION", rb_str_new2(OPENSSL_VERSION_TEXT)); + /* + * Version of OpenSSL the ruby OpenSSL extension is running with + */ + rb_define_const(mOSSL, "OPENSSL_LIBRARY_VERSION", rb_str_new2(SSLeay_version(SSLEAY_VERSION))); + /* * Version number of OpenSSL the ruby OpenSSL extension was built with * (base 16) diff --git a/version.h b/version.h index 71e632bcfdbe2f..3cd6a6841d6988 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-06-24" -#define RUBY_PATCHLEVEL 141 +#define RUBY_PATCHLEVEL 142 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 6 From 416f0075a20f0514ba9dc1866b6a9b9bc84011b1 Mon Sep 17 00:00:00 2001 From: nagachika Date: Sat, 28 Jun 2014 05:51:57 +0000 Subject: [PATCH 143/343] merge revision(s) r45845,r45846,r45847: [Backport #9486] * parse.y (local_tbl_gen): remove local variables duplicated with arguments. * parse.y (new_bv_gen): no duplicated names, if already added in shadowing_lvar(). [ruby-core:60501] [Bug #9486] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46596 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 +++++ parse.y | 47 ++++++++++++++++++++------------------ test/ruby/test_variable.rb | 12 ++++++++++ version.h | 6 ++--- 4 files changed, 46 insertions(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index 23f30ff31fcaaa..2408ef2dc78243 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sat Jun 28 14:37:17 2014 Nobuyoshi Nakada + + * parse.y (local_tbl_gen): remove local variables duplicated with + arguments. + [ruby-core:60501] [Bug #9486] + Tue Jun 24 00:21:58 2014 Koichi Sasada * eval.c (rb_using_refinement): add write-barriers for diff --git a/parse.y b/parse.y index 2a0e25a2b22f32..3f01a224289080 100644 --- a/parse.y +++ b/parse.y @@ -8751,10 +8751,10 @@ is_private_local_id(ID name) #define LVAR_USED ((ID)1 << (sizeof(ID) * CHAR_BIT - 1)) -static ID -shadowing_lvar_gen(struct parser_params *parser, ID name) +static int +shadowing_lvar_0(struct parser_params *parser, ID name) { - if (is_private_local_id(name)) return name; + if (is_private_local_id(name)) return 1; if (dyna_in_block()) { if (dvar_curr(name)) { yyerror("duplicated argument name"); @@ -8765,6 +8765,7 @@ shadowing_lvar_gen(struct parser_params *parser, ID name) if (lvtbl->used) { vtable_add(lvtbl->used, (ID)ruby_sourceline | LVAR_USED); } + return 0; } } else { @@ -8772,6 +8773,13 @@ shadowing_lvar_gen(struct parser_params *parser, ID name) yyerror("duplicated argument name"); } } + return 1; +} + +static ID +shadowing_lvar_gen(struct parser_params *parser, ID name) +{ + shadowing_lvar_0(parser, name); return name; } @@ -8784,7 +8792,7 @@ new_bv_gen(struct parser_params *parser, ID name) rb_id2name(name)); return; } - shadowing_lvar(name); + if (!shadowing_lvar_0(parser, name)) return; dyna_var(name); } @@ -9686,31 +9694,26 @@ local_pop_gen(struct parser_params *parser) } #ifndef RIPPER -static ID* -vtable_tblcpy(ID *buf, const struct vtable *src) -{ - int i, cnt = vtable_size(src); - - if (cnt > 0) { - buf[0] = cnt; - for (i = 0; i < cnt; i++) { - buf[i] = src->tbl[i]; - } - return buf; - } - return 0; -} - static ID* local_tbl_gen(struct parser_params *parser) { - int cnt = vtable_size(lvtbl->args) + vtable_size(lvtbl->vars); + int cnt_args = vtable_size(lvtbl->args); + int cnt_vars = vtable_size(lvtbl->vars); + int cnt = cnt_args + cnt_vars; + int i, j; ID *buf; if (cnt <= 0) return 0; buf = ALLOC_N(ID, cnt + 1); - vtable_tblcpy(buf+1, lvtbl->args); - vtable_tblcpy(buf+vtable_size(lvtbl->args)+1, lvtbl->vars); + MEMCPY(buf+1, lvtbl->args->tbl, ID, cnt_args); + /* remove IDs duplicated to warn shadowing */ + for (i = 0, j = cnt_args+1; i < cnt_vars; ++i) { + ID id = lvtbl->vars->tbl[i]; + if (!vtable_included(lvtbl->args, id)) { + buf[j++] = id; + } + } + if (--j < cnt) REALLOC_N(buf, ID, (cnt = j) + 1); buf[0] = cnt; return buf; } diff --git a/test/ruby/test_variable.rb b/test/ruby/test_variable.rb index 32b3d6157325e9..b902288fdd043b 100644 --- a/test/ruby/test_variable.rb +++ b/test/ruby/test_variable.rb @@ -83,6 +83,18 @@ def test_local_variables3 end.call end + def test_shadowing_local_variables + bug9486 = '[ruby-core:60501] [Bug #9486]' + x = tap {|x| break local_variables} + assert_equal([:x, :bug9486, :x], x) + end + + def test_shadowing_block_local_variables + bug9486 = '[ruby-core:60501] [Bug #9486]' + x = tap {|;x| break local_variables} + assert_equal([:x, :bug9486, :x], x) + end + def test_global_variable_0 assert_in_out_err(["-e", "$0='t'*1000;print $0"], "", /\At+\z/, []) end diff --git a/version.h b/version.h index 3cd6a6841d6988..66f6087b29f0b6 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.2" -#define RUBY_RELEASE_DATE "2014-06-24" -#define RUBY_PATCHLEVEL 142 +#define RUBY_RELEASE_DATE "2014-06-28" +#define RUBY_PATCHLEVEL 143 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 6 -#define RUBY_RELEASE_DAY 24 +#define RUBY_RELEASE_DAY 28 #include "ruby/version.h" From 108828f680f43343e59d9f4db8b1d761f994e161 Mon Sep 17 00:00:00 2001 From: nagachika Date: Sat, 28 Jun 2014 07:42:19 +0000 Subject: [PATCH 144/343] merge revision(s) r46243,r46244: [Backport #9882] [Backport #9883] * string.c (rb_str_substr): need to reset code range for shared string too, not only copied string. [ruby-core:62842] [Bug #9882] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46599 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ string.c | 2 +- test/ruby/test_string.rb | 5 +++++ version.h | 2 +- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2408ef2dc78243..c6f0928ab66110 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sat Jun 28 16:35:51 2014 Nobuyoshi Nakada + + * string.c (rb_str_substr): need to reset code range for shared + string too, not only copied string. + [ruby-core:62842] [Bug #9882] + Sat Jun 28 14:37:17 2014 Nobuyoshi Nakada * parse.y (local_tbl_gen): remove local variables duplicated with diff --git a/string.c b/string.c index 7f29cea2b6fc62..006a8b4639c06e 100644 --- a/string.c +++ b/string.c @@ -1956,10 +1956,10 @@ rb_str_substr(VALUE str, long beg, long len) } else { str2 = rb_str_new5(str, p, len); - rb_enc_cr_str_copy_for_substr(str2, str); OBJ_INFECT(str2, str); RB_GC_GUARD(str); } + rb_enc_cr_str_copy_for_substr(str2, str); return str2; } diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb index 3f65826ec36daa..e510a4984ccd23 100644 --- a/test/ruby/test_string.rb +++ b/test/ruby/test_string.rb @@ -1179,6 +1179,11 @@ def test_slice assert_equal(S("Bar"), S("FooBar").slice(S("Bar"))) assert_nil(S("FooBar").slice(S("xyzzy"))) assert_nil(S("FooBar").slice(S("plugh"))) + + bug9882 = '[ruby-core:62842] [Bug #9882]' + substr = S("\u{30c6 30b9 30c8 2019}#{bug9882}").slice(4..-1) + assert_equal(S(bug9882).hash, substr.hash, bug9882) + assert_predicate(substr, :ascii_only?, bug9882) end def test_slice! diff --git a/version.h b/version.h index 66f6087b29f0b6..673df1f73c7d9d 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-06-28" -#define RUBY_PATCHLEVEL 143 +#define RUBY_PATCHLEVEL 144 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 6 From b18ab01b09ff875bc68da0e6526f3b4b10f10d1d Mon Sep 17 00:00:00 2001 From: nagachika Date: Sat, 28 Jun 2014 16:41:52 +0000 Subject: [PATCH 145/343] merge revision(s) r46598: [Backport #9991] * lib/webrick/utils.rb (create_listeners): Close socket objects. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46605 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ lib/webrick/utils.rb | 4 +++- version.h | 6 +++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index c6f0928ab66110..b3fc15e68312eb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Sun Jun 29 01:34:06 2014 Tanaka Akira + + * lib/webrick/utils.rb (create_listeners): Close socket objects. + Sat Jun 28 16:35:51 2014 Nobuyoshi Nakada * string.c (rb_str_substr): need to reset code range for shared diff --git a/lib/webrick/utils.rb b/lib/webrick/utils.rb index a6b5cc6a9c2db8..0723fd8a4d5da3 100644 --- a/lib/webrick/utils.rb +++ b/lib/webrick/utils.rb @@ -75,7 +75,9 @@ def create_listeners(address, port, logger=nil) sockets = Socket.tcp_server_sockets(address, port) sockets = sockets.map {|s| s.autoclose = false - TCPServer.for_fd(s.fileno) + ts = TCPServer.for_fd(s.fileno) + s.close + ts } return sockets end diff --git a/version.h b/version.h index 673df1f73c7d9d..22d26c2689fb7b 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.2" -#define RUBY_RELEASE_DATE "2014-06-28" -#define RUBY_PATCHLEVEL 144 +#define RUBY_RELEASE_DATE "2014-06-29" +#define RUBY_PATCHLEVEL 145 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 6 -#define RUBY_RELEASE_DAY 28 +#define RUBY_RELEASE_DAY 29 #include "ruby/version.h" From bdf635bf5be3213770c8a77380a045e2ac1c19af Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 29 Jun 2014 16:13:14 +0000 Subject: [PATCH 146/343] merge revision(s) r44535,r44536: [Backport #9321] * vm.c (rb_vm_pop_cfunc_frame): added. It cares c_return event. The patch base by drkaes (Stefan Kaes). [Bug #9321] * variable.c (rb_mod_const_missing): use rb_vm_pop_cfunc_frame() instead of rb_frame_pop(). * vm_eval.c (raise_method_missing): ditto. * vm_eval.c (rb_iterate): ditto. * internal.h (rb_vm_pop_cfunc_frame): add decl. * test/ruby/test_settracefunc.rb: add tests. provided by drkaes (Stefan Kaes). * vm.c, eval.c, include/ruby/intern.h (rb_frame_pop): move definition of rb_frame_pop() and deprecate it. It doesn't care about `return' events. * vm.c, eval.c, include/ruby/intern.h (rb_frame_pop): git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46608 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 22 +++++++++ eval.c | 7 --- include/ruby/intern.h | 5 +- internal.h | 1 + test/ruby/test_settracefunc.rb | 84 ++++++++++++++++++++++++++++++++++ variable.c | 2 +- version.h | 6 +-- vm.c | 18 ++++++++ vm_eval.c | 13 +++--- 9 files changed, 139 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index b3fc15e68312eb..54f5a0eb930c57 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,25 @@ +Mon Jun 30 00:57:05 2014 Koichi Sasada + + * vm.c (rb_vm_pop_cfunc_frame): added. It cares c_return event. + The patch base by drkaes (Stefan Kaes). + [Bug #9321] + + * variable.c (rb_mod_const_missing): use rb_vm_pop_cfunc_frame() + instead of rb_frame_pop(). + + * vm_eval.c (raise_method_missing): ditto. + + * vm_eval.c (rb_iterate): ditto. + + * internal.h (rb_vm_pop_cfunc_frame): add decl. + + * test/ruby/test_settracefunc.rb: add tests. + provided by drkaes (Stefan Kaes). + + * vm.c, eval.c, include/ruby/intern.h (rb_frame_pop): + move definition of rb_frame_pop() and deprecate it. + It doesn't care about `return' events. + Sun Jun 29 01:34:06 2014 Tanaka Akira * lib/webrick/utils.rb (create_listeners): Close socket objects. diff --git a/eval.c b/eval.c index c077f79ecd88b1..e58496ecce83e3 100644 --- a/eval.c +++ b/eval.c @@ -978,13 +978,6 @@ prev_frame_func(void) return frame_func_id(prev_cfp); } -void -rb_frame_pop(void) -{ - rb_thread_t *th = GET_THREAD(); - th->cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(th->cfp); -} - /* * call-seq: * append_features(mod) -> mod diff --git a/include/ruby/intern.h b/include/ruby/intern.h index 6200e77a63f7f3..46af270bb3fcf7 100644 --- a/include/ruby/intern.h +++ b/include/ruby/intern.h @@ -939,11 +939,14 @@ VALUE rb_mod_remove_cvar(VALUE, VALUE); ID rb_frame_callee(void); VALUE rb_str_succ(VALUE); VALUE rb_time_succ(VALUE); -void rb_frame_pop(void); int rb_frame_method_id_and_class(ID *idp, VALUE *klassp); VALUE rb_make_backtrace(void); VALUE rb_make_exception(int, VALUE*); +/* deprecated */ +DEPRECATED(void rb_frame_pop(void)); + + RUBY_SYMBOL_EXPORT_END #if defined(__cplusplus) diff --git a/internal.h b/internal.h index 9e48c139061640..af8e69517c3148 100644 --- a/internal.h +++ b/internal.h @@ -766,6 +766,7 @@ void rb_vm_inc_const_missing_count(void); void rb_thread_mark(void *th); const void **rb_vm_get_insns_address_table(void); VALUE rb_sourcefilename(void); +void rb_vm_pop_cfunc_frame(void); /* vm_dump.c */ void rb_vm_bugreport(void); diff --git a/test/ruby/test_settracefunc.rb b/test/ruby/test_settracefunc.rb index 1fca312c76b893..79f315edd5e1ed 100644 --- a/test/ruby/test_settracefunc.rb +++ b/test/ruby/test_settracefunc.rb @@ -1066,6 +1066,90 @@ def test_a_return :b_return ], events) end + + def test_const_missing + bug59398 = '[ruby-core:59398]' + events = [] + assert !defined?(MISSING_CONSTANT_59398) + TracePoint.new(:c_call, :c_return, :call, :return){|tp| + next unless tp.defined_class == Module + # rake/ext/module.rb aliases :const_missing and Ruby uses the aliased name + # but this only happens when running the full test suite + events << [tp.event,tp.method_id] if tp.method_id == :const_missing || tp.method_id == :rake_original_const_missing + }.enable{ + MISSING_CONSTANT_59398 rescue nil + } + if events.map{|e|e[1]}.include?(:rake_original_const_missing) + assert_equal([ + [:call, :const_missing], + [:c_call, :rake_original_const_missing], + [:c_return, :rake_original_const_missing], + [:return, :const_missing], + ], events, bug59398) + else + assert_equal([ + [:c_call, :const_missing], + [:c_return, :const_missing] + ], events, bug59398) + end + end + + class AliasedRubyMethod + def foo; 1; end; + alias bar foo + end + def test_aliased_ruby_method + events = [] + aliased = AliasedRubyMethod.new + TracePoint.new(:call, :return){|tp| + events << [tp.event, tp.method_id] + }.enable{ + aliased.bar + } + assert_equal([ + [:call, :foo], + [:return, :foo] + ], events, "should use original method name for tracing ruby methods") + end + class AliasedCMethod < Hash + alias original_size size + def size; original_size; end + end + + def test_aliased_c_method + events = [] + aliased = AliasedCMethod.new + TracePoint.new(:call, :return, :c_call, :c_return){|tp| + events << [tp.event, tp.method_id] + }.enable{ + aliased.size + } + assert_equal([ + [:call, :size], + [:c_call, :original_size], + [:c_return, :original_size], + [:return, :size] + ], events, "should use alias method name for tracing c methods") + end + + def test_method_missing + bug59398 = '[ruby-core:59398]' + events = [] + assert !respond_to?(:missing_method_59398) + TracePoint.new(:c_call, :c_return, :call, :return){|tp| + next unless tp.defined_class == BasicObject + # rake/ext/module.rb aliases :const_missing and Ruby uses the aliased name + # but this only happens when running the full test suite + events << [tp.event,tp.method_id] if tp.method_id == :method_missing + }.enable{ + missing_method_59398 rescue nil + } + assert_equal([ + [:c_call, :method_missing], + [:c_return, :method_missing] + ], events, bug59398) + end + class C9759 define_method(:foo){ raise diff --git a/variable.c b/variable.c index e53dc8207fd397..e0d0eded8299b9 100644 --- a/variable.c +++ b/variable.c @@ -1518,7 +1518,7 @@ const_missing(VALUE klass, ID id) VALUE rb_mod_const_missing(VALUE klass, VALUE name) { - rb_frame_pop(); /* pop frame for "const_missing" */ + rb_vm_pop_cfunc_frame(); uninitialized_constant(klass, rb_to_id(name)); UNREACHABLE; diff --git a/version.h b/version.h index 22d26c2689fb7b..95226f7b2603b7 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.2" -#define RUBY_RELEASE_DATE "2014-06-29" -#define RUBY_PATCHLEVEL 145 +#define RUBY_RELEASE_DATE "2014-06-30" +#define RUBY_PATCHLEVEL 146 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 6 -#define RUBY_RELEASE_DAY 29 +#define RUBY_RELEASE_DAY 30 #include "ruby/version.h" diff --git a/vm.c b/vm.c index 99acce2fad9959..2109e8f19778ba 100644 --- a/vm.c +++ b/vm.c @@ -277,6 +277,24 @@ vm_get_ruby_level_caller_cfp(rb_thread_t *th, rb_control_frame_t *cfp) return 0; } +void +rb_vm_pop_cfunc_frame(void) +{ + rb_thread_t *th = GET_THREAD(); + const rb_method_entry_t *me = th->cfp->me; + EXEC_EVENT_HOOK(th, RUBY_EVENT_C_RETURN, th->cfp->self, me->called_id, me->klass, Qnil); + RUBY_DTRACE_CMETHOD_RETURN_HOOK(th, me->klass, me->called_id); + vm_pop_frame(th); +} + +/* obsolete */ +void +rb_frame_pop(void) +{ + rb_thread_t *th = GET_THREAD(); + vm_pop_frame(th); +} + /* at exit */ void diff --git a/vm_eval.c b/vm_eval.c index 7382b198a7de5f..87d99d096c0637 100644 --- a/vm_eval.c +++ b/vm_eval.c @@ -686,7 +686,7 @@ raise_method_missing(rb_thread_t *th, int argc, const VALUE *argv, VALUE obj, { exc = make_no_method_exception(exc, format, obj, argc, argv); if (!(last_call_status & NOEX_MISSING)) { - th->cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(th->cfp); + rb_vm_pop_cfunc_frame(); } rb_exc_raise(exc); } @@ -1094,13 +1094,12 @@ rb_iterate(VALUE (* it_proc) (VALUE), VALUE data1, #if VMDEBUG printf("skipped frame: %s\n", vm_frametype_name(th->cfp)); #endif - if (UNLIKELY(VM_FRAME_TYPE(th->cfp) == VM_FRAME_MAGIC_CFUNC)) { - const rb_method_entry_t *me = th->cfp->me; - EXEC_EVENT_HOOK(th, RUBY_EVENT_C_RETURN, th->cfp->self, me->called_id, me->klass, Qnil); - RUBY_DTRACE_CMETHOD_RETURN_HOOK(th, me->klass, me->called_id); + if (VM_FRAME_TYPE(th->cfp) != VM_FRAME_MAGIC_CFUNC) { + vm_pop_frame(th); + } + else { /* unlikely path */ + rb_vm_pop_cfunc_frame(); } - - th->cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(th->cfp); } } else{ From 1121fa0e4a2f4ba51fcc677bd4cc057d1afdb68c Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 29 Jun 2014 16:59:36 +0000 Subject: [PATCH 147/343] merge revision(s) r46485: [Backport #9897] * ext/fiddle/extconf.rb: supply 0 to fill RUBY_LIBFFI_MODVERSION with 3-digit. libffi 3.1 returns just 2-digit. [ruby-core:62920] [Bug #9897] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46609 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ ext/fiddle/extconf.rb | 3 ++- version.h | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 54f5a0eb930c57..0a50f3f8ff815c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Mon Jun 30 01:46:19 2014 Nobuyoshi Nakada + + * ext/fiddle/extconf.rb: supply 0 to fill RUBY_LIBFFI_MODVERSION + with 3-digit. libffi 3.1 returns just 2-digit. + [ruby-core:62920] [Bug #9897] + Mon Jun 30 00:57:05 2014 Koichi Sasada * vm.c (rb_vm_pop_cfunc_frame): added. It cares c_return event. diff --git a/ext/fiddle/extconf.rb b/ext/fiddle/extconf.rb index 2190aa907fdab1..466d77e6dd1cec 100644 --- a/ext/fiddle/extconf.rb +++ b/ext/fiddle/extconf.rb @@ -7,7 +7,8 @@ pkg_config("libffi") if ver = pkg_config("libffi", "modversion") ver = ver.gsub(/-rc\d+/, '') # If ver contains rc version, just ignored. - $defs.push(%{-DRUBY_LIBFFI_MODVERSION=#{ '%d%03d%03d' % ver.split('.') }}) + ver = (ver.split('.') + [0,0])[0,3] + $defs.push(%{-DRUBY_LIBFFI_MODVERSION=#{ '%d%03d%03d' % ver }}) end unless have_header('ffi.h') diff --git a/version.h b/version.h index 95226f7b2603b7..a626cc2df2d848 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-06-30" -#define RUBY_PATCHLEVEL 146 +#define RUBY_PATCHLEVEL 147 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 6 From 8a33324477d9ba0b7dd8fd28a6927e89580664e6 Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 29 Jun 2014 17:09:10 +0000 Subject: [PATCH 148/343] merge revision(s) r44505: [Backport #9994] numeric.c: isfinite * numeric.c (flo_is_finite_p): prefer C99 standard isfinite() than deprecated finite(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46610 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- configure.in | 1 + numeric.c | 8 ++++++-- version.h | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/configure.in b/configure.in index d885d0f0aeea2b..303d1f83e3b357 100644 --- a/configure.in +++ b/configure.in @@ -1900,6 +1900,7 @@ AC_CHECK_FUNCS(gettimeofday) # for making ac_cv_func_gettimeofday AC_CHECK_FUNCS(gmtime_r) AC_CHECK_FUNCS(initgroups) AC_CHECK_FUNCS(ioctl) +AC_CHECK_FUNCS(isfinite) AC_CHECK_FUNCS(issetugid) AC_CHECK_FUNCS(killpg) AC_CHECK_FUNCS(lchmod) diff --git a/numeric.c b/numeric.c index 2de8c699273a99..bd538798b2ec9f 100644 --- a/numeric.c +++ b/numeric.c @@ -30,8 +30,12 @@ #include #endif +#if !defined HAVE_ISFINITE && !defined isfinite #if defined HAVE_FINITE && !defined finite && !defined _WIN32 extern int finite(double); +# define HAVE_ISFINITE 1 +# define isfinite(x) finite(x) +#endif #endif /* use IEEE 64bit values if not defined */ @@ -1457,8 +1461,8 @@ flo_is_finite_p(VALUE num) { double value = RFLOAT_VALUE(num); -#if HAVE_FINITE - if (!finite(value)) +#if HAVE_ISFINITE + if (!isfinite(value)) return Qfalse; #else if (isinf(value) || isnan(value)) diff --git a/version.h b/version.h index a626cc2df2d848..84cd797b115aa6 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-06-30" -#define RUBY_PATCHLEVEL 147 +#define RUBY_PATCHLEVEL 148 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 6 From 0caeba64c30e6746870328a0d7da6250b0a3773c Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 29 Jun 2014 17:17:20 +0000 Subject: [PATCH 149/343] merge revision(s) r46098: [Backport #9861] * vsnprintf.c (BSD_vfprintf): fix string width when precision is given. as the result of `memchr` is NULL or its offset from the start cannot exceed the size, the comparison was always false. [ruby-core:62737] [Bug #9861] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46611 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ ext/-test-/printf/printf.c | 20 +++++++++++++++----- test/-ext-/test_printf.rb | 6 ++++++ version.h | 2 +- vsnprintf.c | 2 +- 5 files changed, 30 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0a50f3f8ff815c..897bad263fe7a6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Mon Jun 30 02:10:34 2014 Nobuyoshi Nakada + + * vsnprintf.c (BSD_vfprintf): fix string width when precision is + given. as the result of `memchr` is NULL or its offset from the + start cannot exceed the size, the comparison was always false. + [ruby-core:62737] [Bug #9861] + Mon Jun 30 01:46:19 2014 Nobuyoshi Nakada * ext/fiddle/extconf.rb: supply 0 to fill RUBY_LIBFFI_MODVERSION diff --git a/ext/-test-/printf/printf.c b/ext/-test-/printf/printf.c index fd60b0f5932f46..1ebe80411bd38e 100644 --- a/ext/-test-/printf/printf.c +++ b/ext/-test-/printf/printf.c @@ -42,18 +42,23 @@ utoa(char *p, char *e, unsigned int x) static VALUE printf_test_call(int argc, VALUE *argv, VALUE self) { - VALUE opt, type, num; + VALUE opt, type, num, result; char format[sizeof(int) * 6 + 8], *p = format, cnv; int n; + const char *s; rb_scan_args(argc, argv, "2:", &type, &num, &opt); Check_Type(type, T_STRING); if (RSTRING_LEN(type) != 1) rb_raise(rb_eArgError, "wrong length(%ld)", RSTRING_LEN(type)); switch (cnv = RSTRING_PTR(type)[0]) { - case 'd': case 'x': case 'o': case 'X': break; + case 'd': case 'x': case 'o': case 'X': + n = NUM2INT(num); + break; + case 's': + s = StringValueCStr(num); + break; default: rb_raise(rb_eArgError, "wrong conversion(%c)", cnv); } - n = NUM2INT(num); *p++ = '%'; if (!NIL_P(opt)) { VALUE v; @@ -84,8 +89,13 @@ printf_test_call(int argc, VALUE *argv, VALUE self) } *p++ = cnv; *p++ = '\0'; - return rb_assoc_new(rb_enc_sprintf(rb_usascii_encoding(), format, n), - rb_usascii_str_new_cstr(format)); + if (cnv == 's') { + result = rb_enc_sprintf(rb_usascii_encoding(), format, s); + } + else { + result = rb_enc_sprintf(rb_usascii_encoding(), format, n); + } + return rb_assoc_new(result, rb_usascii_str_new_cstr(format)); } void diff --git a/test/-ext-/test_printf.rb b/test/-ext-/test_printf.rb index 609af7ca7a7469..235865dbdc1198 100644 --- a/test/-ext-/test_printf.rb +++ b/test/-ext-/test_printf.rb @@ -181,4 +181,10 @@ def self.assertions_format_integer(format, type, **opts) zero: zr, width: width, prec: prec)) } + + def test_string_prec + assert_equal("a", Bug::Printf.("s", "a", prec: 3)[0]) + assert_equal(" a", Bug::Printf.("s", "a", width: 3, prec: 3)[0]) + assert_equal("a ", Bug::Printf.("s", "a", minus: true, width: 3, prec: 3)[0]) + end end diff --git a/version.h b/version.h index 84cd797b115aa6..b75d137277f567 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-06-30" -#define RUBY_PATCHLEVEL 148 +#define RUBY_PATCHLEVEL 149 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 6 diff --git a/vsnprintf.c b/vsnprintf.c index 5266927d7fb3b9..f272d73337327f 100644 --- a/vsnprintf.c +++ b/vsnprintf.c @@ -999,7 +999,7 @@ fp_begin: _double = va_arg(ap, double); */ const char *p = (char *)memchr(cp, 0, prec); - if (p != NULL && (p - cp) > prec) + if (p != NULL && (p - cp) < prec) size = (int)(p - cp); else size = prec; From 1ff2d59ebb8146c37501c94696acf125ab2c6eb6 Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 29 Jun 2014 17:21:30 +0000 Subject: [PATCH 150/343] merge revision(s) r45793: [Backport #9608] * complex.c (parse_comp): replace ALLOCA_N with ALLOCV_N/ALLOCV_END [Bug #9608] * rational.c (read_digits): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46612 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ complex.c | 23 +++++++++++++++-------- rational.c | 4 +++- version.h | 2 +- 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 897bad263fe7a6..b4ca625561a2a7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Mon Jun 30 02:18:47 2014 Eric Wong + + * complex.c (parse_comp): replace ALLOCA_N with ALLOCV_N/ALLOCV_END + [Bug #9608] + * rational.c (read_digits): ditto + Mon Jun 30 02:10:34 2014 Nobuyoshi Nakada * vsnprintf.c (BSD_vfprintf): fix string width when precision is diff --git a/complex.c b/complex.c index 3e9d63117afc1e..c36d8907279e3d 100644 --- a/complex.c +++ b/complex.c @@ -1774,19 +1774,26 @@ parse_comp(const char *s, int strict, VALUE *num) { char *buf, *b; + VALUE tmp; + int ret = 1; - buf = ALLOCA_N(char, strlen(s) + 1); + buf = ALLOCV_N(char, tmp, strlen(s) + 1); b = buf; skip_ws(&s); - if (!read_comp(&s, strict, num, &b)) - return 0; - skip_ws(&s); + if (!read_comp(&s, strict, num, &b)) { + ret = 0; + } + else { + skip_ws(&s); - if (strict) - if (*s != '\0') - return 0; - return 1; + if (strict) + if (*s != '\0') + ret = 0; + } + ALLOCV_END(tmp); + + return ret; } static VALUE diff --git a/rational.c b/rational.c index 53bc11c4efcf6a..33d2a2c2d69288 100644 --- a/rational.c +++ b/rational.c @@ -2167,13 +2167,14 @@ read_digits(const char **s, int strict, { char *b, *bb; int us = 1, ret = 1; + VALUE tmp; if (!isdecimal(**s)) { *num = ZERO; return 0; } - bb = b = ALLOCA_N(char, strlen(*s) + 1); + bb = b = ALLOCV_N(char, tmp, strlen(*s) + 1); while (isdecimal(**s) || **s == '_') { if (**s == '_') { @@ -2200,6 +2201,7 @@ read_digits(const char **s, int strict, conv: *b = '\0'; *num = rb_cstr_to_inum(bb, 10, 0); + ALLOCV_END(tmp); return ret; } diff --git a/version.h b/version.h index b75d137277f567..3758fbea4cf46f 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-06-30" -#define RUBY_PATCHLEVEL 149 +#define RUBY_PATCHLEVEL 150 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 6 From 4c5d8bebe80e90236bfe919efe67130e97824868 Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 29 Jun 2014 17:26:54 +0000 Subject: [PATCH 151/343] merge revision(s) r45863,r45871: [Backport #9750] * ext/openssl/lib/openssl/ssl.rb (OpenSSL::SSL::SSLServer#accept): Consider Socket#accept as well as TCPServer#accept. Reported by Sam Stelfox. [ruby-core:62064] [Bug #9750] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46613 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 +++ ext/openssl/lib/openssl/ssl.rb | 5 ++- test/openssl/test_pair.rb | 77 +++++++++++++++++++++++++++------- version.h | 2 +- 4 files changed, 74 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index b4ca625561a2a7..dbf204a654c363 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Mon Jun 30 02:25:00 2014 Tanaka Akira + + * ext/openssl/lib/openssl/ssl.rb (OpenSSL::SSL::SSLServer#accept): + Consider Socket#accept as well as TCPServer#accept. + Reported by Sam Stelfox. [ruby-core:62064] [Bug #9750] + Mon Jun 30 02:18:47 2014 Eric Wong * complex.c (parse_comp): replace ALLOCA_N with ALLOCV_N/ALLOCV_END diff --git a/ext/openssl/lib/openssl/ssl.rb b/ext/openssl/lib/openssl/ssl.rb index 014e1137bc3ed5..86be19054a1606 100644 --- a/ext/openssl/lib/openssl/ssl.rb +++ b/ext/openssl/lib/openssl/ssl.rb @@ -187,7 +187,10 @@ def shutdown(how=Socket::SHUT_RDWR) # Works similar to TCPServer#accept. def accept - sock = @svr.accept + # Socket#accept returns [socket, addrinfo]. + # TCPServer#accept returns a socket. + # The following comma strips addrinfo. + sock, = @svr.accept begin ssl = OpenSSL::SSL::SSLSocket.new(sock, @ctx) ssl.sync_close = true diff --git a/test/openssl/test_pair.rb b/test/openssl/test_pair.rb index 933f61292cf22c..e6af9b8c68f732 100644 --- a/test/openssl/test_pair.rb +++ b/test/openssl/test_pair.rb @@ -5,14 +5,14 @@ require 'socket' require_relative '../ruby/ut_eof' -module SSLPair +module OpenSSL::SSLPairM def server host = "127.0.0.1" port = 0 ctx = OpenSSL::SSL::SSLContext.new() ctx.ciphers = "ADH" ctx.tmp_dh_callback = proc { OpenSSL::TestUtils::TEST_KEY_DH1024 } - tcps = TCPServer.new(host, port) + tcps = create_tcp_server(host, port) ssls = OpenSSL::SSL::SSLServer.new(tcps, ctx) return ssls end @@ -21,7 +21,7 @@ def client(port) host = "127.0.0.1" ctx = OpenSSL::SSL::SSLContext.new() ctx.ciphers = "ADH" - s = TCPSocket.new(host, port) + s = create_tcp_client(host, port) ssl = OpenSSL::SSL::SSLSocket.new(s, ctx) ssl.connect ssl.sync_close = true @@ -35,7 +35,7 @@ def ssl_pair ssls.close ns } - port = ssls.to_io.addr[1] + port = ssls.to_io.local_address.ip_port c = client(port) s = th.value if block_given? @@ -56,10 +56,31 @@ def ssl_pair end end -class OpenSSL::TestEOF1 < Test::Unit::TestCase - include TestEOF - include SSLPair +module OpenSSL::SSLPair + include OpenSSL::SSLPairM + + def create_tcp_server(host, port) + TCPServer.new(host, port) + end + + def create_tcp_client(host, port) + TCPSocket.new(host, port) + end +end + +module OpenSSL::SSLPairLowlevelSocket + include OpenSSL::SSLPairM + + def create_tcp_server(host, port) + Addrinfo.tcp(host, port).listen + end + def create_tcp_client(host, port) + Addrinfo.tcp(host, port).connect + end +end + +module OpenSSL::TestEOF1M def open_file(content) s1, s2 = ssl_pair Thread.new { s2 << content; s2.close } @@ -67,10 +88,7 @@ def open_file(content) end end -class OpenSSL::TestEOF2 < Test::Unit::TestCase - include TestEOF - include SSLPair - +module OpenSSL::TestEOF2M def open_file(content) s1, s2 = ssl_pair Thread.new { s1 << content; s1.close } @@ -78,9 +96,7 @@ def open_file(content) end end -class OpenSSL::TestPair < Test::Unit::TestCase - include SSLPair - +module OpenSSL::TestPairM def test_getc ssl_pair {|s1, s2| s1 << "a" @@ -302,7 +318,40 @@ def test_connect_accept_nonblock sock1.close if sock1 && !sock1.closed? sock2.close if sock2 && !sock2.closed? end +end + +class OpenSSL::TestEOF1 < Test::Unit::TestCase + include TestEOF + include OpenSSL::SSLPair + include OpenSSL::TestEOF1M +end + +class OpenSSL::TestEOF1LowlevelSocket < Test::Unit::TestCase + include TestEOF + include OpenSSL::SSLPairLowlevelSocket + include OpenSSL::TestEOF1M +end + +class OpenSSL::TestEOF2 < Test::Unit::TestCase + include TestEOF + include OpenSSL::SSLPair + include OpenSSL::TestEOF2M +end + +class OpenSSL::TestEOF2LowlevelSocket < Test::Unit::TestCase + include TestEOF + include OpenSSL::SSLPairLowlevelSocket + include OpenSSL::TestEOF2M +end + +class OpenSSL::TestPair < Test::Unit::TestCase + include OpenSSL::SSLPair + include OpenSSL::TestPairM +end +class OpenSSL::TestPairLowlevelSocket < Test::Unit::TestCase + include OpenSSL::SSLPairLowlevelSocket + include OpenSSL::TestPairM end end diff --git a/version.h b/version.h index 3758fbea4cf46f..091fd158ef5629 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-06-30" -#define RUBY_PATCHLEVEL 150 +#define RUBY_PATCHLEVEL 151 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 6 From 7d49e2bfc192126287fea10c2205822a98d128f1 Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 29 Jun 2014 17:34:43 +0000 Subject: [PATCH 152/343] merge revision(s) r45979: [Backport #9847] * io.c (io_setstrbuf): always check if the buffer is modifiable. [ruby-core:62643] [Bug #9847] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46614 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ io.c | 2 +- test/ruby/test_io.rb | 11 +++++------ version.h | 2 +- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index dbf204a654c363..a4f9c270fa3dc0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Mon Jun 30 02:28:10 2014 Nobuyoshi Nakada + + * io.c (io_setstrbuf): always check if the buffer is modifiable. + [ruby-core:62643] [Bug #9847] + Mon Jun 30 02:25:00 2014 Tanaka Akira * ext/openssl/lib/openssl/ssl.rb (OpenSSL::SSL::SSLServer#accept): diff --git a/io.c b/io.c index 6e3fd85d2b1238..6deb44187fc74b 100644 --- a/io.c +++ b/io.c @@ -2290,8 +2290,8 @@ io_setstrbuf(VALUE *str, long len) VALUE s = StringValue(*str); long clen = RSTRING_LEN(s); if (clen >= len) { + rb_str_modify(s); if (clen != len) { - rb_str_modify(s); rb_str_set_len(s, len); } return; diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index a6f2b14abedb72..115a4984746025 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -2790,25 +2790,24 @@ def test_advise_pipe def assert_buffer_not_raise_shared_string_error bug6764 = '[ruby-core:46586]' + bug9847 = '[ruby-core:62643] [Bug #9847]' size = 28 data = [*"a".."z", *"A".."Z"].shuffle.join("") t = Tempfile.new("test_io") t.write(data) t.close - w = Tempfile.new("test_io") + w = [] assert_nothing_raised(RuntimeError, bug6764) do + buf = '' File.open(t.path, "r") do |r| - buf = '' while yield(r, size, buf) - w << buf + w << buf.dup end end end - w.close - assert_equal(data, w.open.read, bug6764) + assert_equal(data, w.join(""), bug9847) ensure t.close! - w.close! end def test_read_buffer_not_raise_shared_string_error diff --git a/version.h b/version.h index 091fd158ef5629..ce0bdf6b2f2ea3 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-06-30" -#define RUBY_PATCHLEVEL 151 +#define RUBY_PATCHLEVEL 152 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 6 From 39d963422fce26165d685537fb1b745d20557f2b Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 29 Jun 2014 17:43:01 +0000 Subject: [PATCH 153/343] merge revision(s) r46075: [Backport #9856] * process.c (proc_getgroups, proc_setgroups): use ALLOCV_N [Bug #9856] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46615 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ process.c | 11 ++++++++--- version.h | 2 +- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index a4f9c270fa3dc0..9f8a05e8e091b9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Mon Jun 30 02:36:08 2014 Eric Wong + + * process.c (proc_getgroups, proc_setgroups): use ALLOCV_N + [Bug #9856] + Mon Jun 30 02:28:10 2014 Nobuyoshi Nakada * io.c (io_setstrbuf): always check if the buffer is modifiable. diff --git a/process.c b/process.c index 982286827d3e2e..2b926701a215d5 100644 --- a/process.c +++ b/process.c @@ -5662,7 +5662,7 @@ maxgroups(void) static VALUE proc_getgroups(VALUE obj) { - VALUE ary; + VALUE ary, tmp; int i, ngroups; rb_gid_t *groups; @@ -5670,7 +5670,7 @@ proc_getgroups(VALUE obj) if (ngroups == -1) rb_sys_fail(0); - groups = ALLOCA_N(rb_gid_t, ngroups); + groups = ALLOCV_N(rb_gid_t, tmp, ngroups); ngroups = getgroups(ngroups, groups); if (ngroups == -1) @@ -5680,6 +5680,8 @@ proc_getgroups(VALUE obj) for (i = 0; i < ngroups; i++) rb_ary_push(ary, GIDT2NUM(groups[i])); + ALLOCV_END(tmp); + return ary; } #else @@ -5706,6 +5708,7 @@ proc_setgroups(VALUE obj, VALUE ary) { int ngroups, i; rb_gid_t *groups; + VALUE tmp; PREPARE_GETGRNAM; Check_Type(ary, T_ARRAY); @@ -5714,7 +5717,7 @@ proc_setgroups(VALUE obj, VALUE ary) if (ngroups > maxgroups()) rb_raise(rb_eArgError, "too many groups, %d max", maxgroups()); - groups = ALLOCA_N(rb_gid_t, ngroups); + groups = ALLOCV_N(rb_gid_t, tmp, ngroups); for (i = 0; i < ngroups; i++) { VALUE g = RARRAY_AREF(ary, i); @@ -5726,6 +5729,8 @@ proc_setgroups(VALUE obj, VALUE ary) if (setgroups(ngroups, groups) == -1) /* ngroups <= maxgroups */ rb_sys_fail(0); + ALLOCV_END(tmp); + return proc_getgroups(obj); } #else diff --git a/version.h b/version.h index ce0bdf6b2f2ea3..b77db0646f72c6 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-06-30" -#define RUBY_PATCHLEVEL 152 +#define RUBY_PATCHLEVEL 153 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 6 From d681d9ce6744f5f7e819abf2cb10e89d4906a840 Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 29 Jun 2014 17:56:19 +0000 Subject: [PATCH 154/343] merge revision(s) r46233: [Backport #9878] * signal.c (ruby_signal): should return either `old.sa_sigaction` or `old.sa_handler`, depending on whether `SA_SIGINFO` is set in `old.sa_flags`, because they may not be a union. [ruby-core:62836] [Bug #9878] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46616 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ signal.c | 5 ++++- version.h | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9f8a05e8e091b9..112bfce643b657 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Mon Jun 30 02:46:44 2014 Rei Odaira + + * signal.c (ruby_signal): should return either `old.sa_sigaction` + or `old.sa_handler`, depending on whether `SA_SIGINFO` is set in + `old.sa_flags`, because they may not be a union. + [ruby-core:62836] [Bug #9878] + Mon Jun 30 02:36:08 2014 Eric Wong * process.c (proc_getgroups, proc_setgroups): use ALLOCV_N diff --git a/signal.c b/signal.c index 3c6b96737fd825..6c587ae851f71f 100644 --- a/signal.c +++ b/signal.c @@ -543,7 +543,10 @@ ruby_signal(int signum, sighandler_t handler) rb_bug_errno("sigaction", errno); } } - return old.sa_handler; + if (old.sa_flags & SA_SIGINFO) + return (sighandler_t)old.sa_sigaction; + else + return old.sa_handler; } sighandler_t diff --git a/version.h b/version.h index b77db0646f72c6..9c679268cc3727 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-06-30" -#define RUBY_PATCHLEVEL 153 +#define RUBY_PATCHLEVEL 154 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 6 From dfba910f74d4f99961ad296a07fcc0617c2960a4 Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 29 Jun 2014 18:01:18 +0000 Subject: [PATCH 155/343] merge revision(s) r46331: [Backport #9885] * lib/net/imap.rb (body_type_1part): Gmail IMAP reports a body type as "MIXED" followed immediately by params [ruby-core:62864] [Bug #9885] Patch by @rayners (David Raynes). [Fixes GH-622] https://github.com/ruby/ruby/pull/622 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46617 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ lib/net/imap.rb | 9 +++++++++ test/net/imap/test_imap_response_parser.rb | 10 ++++++++++ version.h | 2 +- 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 112bfce643b657..836d2a3cad55a8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Mon Jun 30 02:59:08 2014 Shugo Maeda + + * lib/net/imap.rb (body_type_1part): Gmail IMAP reports a body + type as "MIXED" followed immediately by params + [ruby-core:62864] [Bug #9885] + Patch by @rayners (David Raynes). [Fixes GH-622] + https://github.com/ruby/ruby/pull/622 + Mon Jun 30 02:46:44 2014 Rei Odaira * signal.c (ruby_signal): should return either `old.sa_sigaction` diff --git a/lib/net/imap.rb b/lib/net/imap.rb index 55c611b9c66697..1bb0b81eecdff6 100644 --- a/lib/net/imap.rb +++ b/lib/net/imap.rb @@ -2372,6 +2372,8 @@ def body_type_1part return body_type_msg when /\A(?:ATTACHMENT)\z/ni return body_type_attachment + when /\A(?:MIXED)\z/ni + return body_type_mixed else return body_type_basic end @@ -2454,6 +2456,13 @@ def body_type_attachment return BodyTypeAttachment.new(mtype, nil, param) end + def body_type_mixed + mtype = "MULTIPART" + msubtype = case_insensitive_string + param, disposition, language, extension = body_ext_mpart + return BodyTypeBasic.new(mtype, msubtype, param, nil, nil, nil, nil, nil, disposition, language, extension) + end + def body_type_mpart parts = [] while true diff --git a/test/net/imap/test_imap_response_parser.rb b/test/net/imap/test_imap_response_parser.rb index cecc015133063f..c4176f7b6c6312 100644 --- a/test/net/imap/test_imap_response_parser.rb +++ b/test/net/imap/test_imap_response_parser.rb @@ -248,4 +248,14 @@ def test_capability assert_equal("CAPABILITY", response.name) assert_equal("AUTH=PLAIN", response.data.last) end + + def test_mixed_boundry + parser = Net::IMAP::ResponseParser.new + response = parser.parse("* 2688 FETCH (UID 179161 BODYSTRUCTURE ((\"TEXT\" \"PLAIN\" (\"CHARSET\" \"iso-8859-1\") NIL NIL \"QUOTED-PRINTABLE\" 200 4 NIL NIL NIL)(\"MESSAGE\" \"DELIVERY-STATUS\" NIL NIL NIL \"7BIT\" 318 NIL NIL NIL)(\"MESSAGE\" \"RFC822\" NIL NIL NIL \"7BIT\" 2177 (\"Tue, 11 May 2010 18:28:16 -0400\" \"Re: Welcome letter\" ((\"David\" NIL \"info\" \"xxxxxxxx.si\")) ((\"David\" NIL \"info\" \"xxxxxxxx.si\")) ((\"David\" NIL \"info\" \"xxxxxxxx.si\")) ((\"Doretha\" NIL \"doretha.info\" \"xxxxxxxx.si\")) NIL NIL \"\" \"\") (\"MIXED\" (\"BOUNDARY\" \"000e0cd29212e3e06a0486590ae2\") NIL NIL) 37 NIL NIL NIL) \"REPORT\" (\"BOUNDARY\" \"16DuG.4XbaNOvCi.9ggvq.8Ipnyp3\" \"REPORT-TYPE\" \"delivery-status\") NIL NIL))\r\n") + empty_part = response.data.attr['BODYSTRUCTURE'].parts[2] + assert_equal(empty_part.lines, 37) + assert_equal(empty_part.body.media_type, 'MULTIPART') + assert_equal(empty_part.body.subtype, 'MIXED') + assert_equal(empty_part.body.param['BOUNDARY'], '000e0cd29212e3e06a0486590ae2') + end end diff --git a/version.h b/version.h index 9c679268cc3727..c4e00bb93b1829 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-06-30" -#define RUBY_PATCHLEVEL 154 +#define RUBY_PATCHLEVEL 155 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 6 From bdab29b10a0d65a3d6e1928449b5589aa05999b2 Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 29 Jun 2014 18:08:43 +0000 Subject: [PATCH 156/343] merge revision(s) r46457,r46458: [Backport #9949] * lib/net/ftp.rb (gets, readline): read lines without LF properly. [ruby-core:63205] [Bug #9949] * test/net/ftp/test_buffered_socket.rb: related test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46618 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++ lib/net/ftp.rb | 11 +++++--- test/net/ftp/test_buffered_socket.rb | 40 ++++++++++++++++++++++++++++ version.h | 2 +- 4 files changed, 55 insertions(+), 5 deletions(-) create mode 100644 test/net/ftp/test_buffered_socket.rb diff --git a/ChangeLog b/ChangeLog index 836d2a3cad55a8..ecc2b7e83495c8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Mon Jun 30 03:07:22 2014 Shugo Maeda + + * lib/net/ftp.rb (gets, readline): read lines without LF properly. + [ruby-core:63205] [Bug #9949] + + * test/net/ftp/test_buffered_socket.rb: related test. + Mon Jun 30 02:59:08 2014 Shugo Maeda * lib/net/imap.rb (body_type_1part): Gmail IMAP reports a body diff --git a/lib/net/ftp.rb b/lib/net/ftp.rb index 0811b13b2d8a6d..a57372ac3b7124 100644 --- a/lib/net/ftp.rb +++ b/lib/net/ftp.rb @@ -1105,13 +1105,16 @@ def read(len = nil) end def gets - return readuntil("\n") - rescue EOFError - return nil + line = readuntil("\n", true) + return line.empty? ? nil : line end def readline - return readuntil("\n") + line = gets + if line.nil? + raise EOFError, "end of file reached" + end + return line end end # :startdoc: diff --git a/test/net/ftp/test_buffered_socket.rb b/test/net/ftp/test_buffered_socket.rb new file mode 100644 index 00000000000000..f9eefcd988a971 --- /dev/null +++ b/test/net/ftp/test_buffered_socket.rb @@ -0,0 +1,40 @@ +require "net/ftp" +require "test/unit" +require "ostruct" +require "stringio" + +class FTPTest < Test::Unit::TestCase + def test_gets_empty + sock = create_buffered_socket("") + assert_equal(nil, sock.gets) + end + + def test_gets_one_line + sock = create_buffered_socket("foo\n") + assert_equal("foo\n", sock.gets) + end + + def test_gets_one_line_without_term + sock = create_buffered_socket("foo") + assert_equal("foo", sock.gets) + end + + def test_gets_two_lines + sock = create_buffered_socket("foo\nbar\n") + assert_equal("foo\n", sock.gets) + assert_equal("bar\n", sock.gets) + end + + def test_gets_two_lines_without_term + sock = create_buffered_socket("foo\nbar") + assert_equal("foo\n", sock.gets) + assert_equal("bar", sock.gets) + end + + private + + def create_buffered_socket(s) + io = StringIO.new(s) + return Net::FTP::BufferedSocket.new(io) + end +end diff --git a/version.h b/version.h index c4e00bb93b1829..77f1299855c68c 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-06-30" -#define RUBY_PATCHLEVEL 155 +#define RUBY_PATCHLEVEL 156 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 6 From 370e83b789076bbada251c3a6cf8e38932a17883 Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 29 Jun 2014 18:22:39 +0000 Subject: [PATCH 157/343] merge revision(s) r46342: [Backport #9954] * vm.c (core_hash_merge_kwd): should return the result hash, which may be converted from and differ from the given argument. [ruby-core:62921] [Bug #9898] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46619 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ test/ruby/test_keyword.rb | 11 +++++++++++ version.h | 2 +- vm.c | 1 + 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index ecc2b7e83495c8..8de7bfc7d20424 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Mon Jun 30 03:15:59 2014 Nobuyoshi Nakada + + * vm.c (core_hash_merge_kwd): should return the result hash, which + may be converted from and differ from the given argument. + [ruby-core:62921] [Bug #9898] + Mon Jun 30 03:07:22 2014 Shugo Maeda * lib/net/ftp.rb (gets, readline): read lines without LF properly. diff --git a/test/ruby/test_keyword.rb b/test/ruby/test_keyword.rb index 2ebc2980202ef5..eb548b95e252da 100644 --- a/test/ruby/test_keyword.rb +++ b/test/ruby/test_keyword.rb @@ -452,6 +452,17 @@ def test_splat_keyword_nondestructive assert_equal({a: 1}, h, bug9776) end + def test_splat_hash_conversion + bug9898 = '[ruby-core:62921] [Bug #9898]' + + o = Object.new + def o.to_hash() { a: 1 } end + assert_equal({a: 1}, m1(**o) {|x| break x}, bug9898) + o2 = Object.new + def o2.to_hash() { b: 2 } end + assert_equal({a: 1, b: 2}, m1(**o, **o2) {|x| break x}, bug9898) + end + def test_gced_object_in_stack bug8964 = '[ruby-dev:47729] [Bug #8964]' assert_normal_exit %q{ diff --git a/version.h b/version.h index 77f1299855c68c..fa85fbe3b2fb19 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-06-30" -#define RUBY_PATCHLEVEL 156 +#define RUBY_PATCHLEVEL 157 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 6 diff --git a/vm.c b/vm.c index 2109e8f19778ba..f74d4c485d1e88 100644 --- a/vm.c +++ b/vm.c @@ -2339,6 +2339,7 @@ m_core_hash_merge_kwd(int argc, VALUE *argv, VALUE recv) hash = argv[0]; kw = argv[argc-1]; kw = rb_convert_type(kw, T_HASH, "Hash", "to_hash"); + if (argc < 2) hash = kw; rb_hash_foreach(kw, argc < 2 ? kwcheck_i : kwmerge_i, hash); return hash; } From 09cf4529269953847723eac4475bfe07c60b028a Mon Sep 17 00:00:00 2001 From: nagachika Date: Mon, 30 Jun 2014 18:02:23 +0000 Subject: [PATCH 158/343] merge revision(s) r45399,r45400,r46036,r46037: [Backport #416] vm.c: merge code * vm.c (m_core_hash_from_ary, m_core_hash_merge_ary): merge duplicated code. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46628 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_backtrace.rb | 27 +++++++++++++++++ version.h | 8 ++--- vm.c | 58 ++++++++++++++++++++++++++----------- 3 files changed, 72 insertions(+), 21 deletions(-) diff --git a/test/ruby/test_backtrace.rb b/test/ruby/test_backtrace.rb index 6ec13e4cc5f6ad..ed36fe95f63ec7 100644 --- a/test/ruby/test_backtrace.rb +++ b/test/ruby/test_backtrace.rb @@ -214,4 +214,31 @@ def test_thread_backtrace_locations_with_range q << true end end + + def test_core_backtrace_alias + obj = BasicObject.new + e = assert_raise(NameError) do + class << obj + alias foo bar + end + end + assert_not_match(/\Acore#/, e.backtrace_locations[0].base_label) + end + + def test_core_backtrace_undef + obj = BasicObject.new + e = assert_raise(NameError) do + class << obj + undef foo + end + end + assert_not_match(/\Acore#/, e.backtrace_locations[0].base_label) + end + + def test_core_backtrace_hash_merge + e = assert_raise(TypeError) do + {**nil} + end + assert_not_match(/\Acore#/, e.backtrace_locations[0].base_label) + end end diff --git a/version.h b/version.h index fa85fbe3b2fb19..cc54704b1b73e8 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.2" -#define RUBY_RELEASE_DATE "2014-06-30" -#define RUBY_PATCHLEVEL 157 +#define RUBY_RELEASE_DATE "2014-07-01" +#define RUBY_PATCHLEVEL 158 #define RUBY_RELEASE_YEAR 2014 -#define RUBY_RELEASE_MONTH 6 -#define RUBY_RELEASE_DAY 30 +#define RUBY_RELEASE_MONTH 7 +#define RUBY_RELEASE_DAY 1 #include "ruby/version.h" diff --git a/vm.c b/vm.c index f74d4c485d1e88..e8e2257e67156b 100644 --- a/vm.c +++ b/vm.c @@ -2262,46 +2262,62 @@ m_core_set_postexe(VALUE self) return Qnil; } +static VALUE core_hash_merge_ary(VALUE hash, VALUE ary); +static VALUE core_hash_from_ary(VALUE ary); +static VALUE core_hash_merge_kwd(int argc, VALUE *argv); + +static VALUE +core_hash_merge(VALUE hash, long argc, const VALUE *argv) +{ + long i; + + assert(argc % 2 == 0); + for (i=0; i Date: Mon, 30 Jun 2014 18:12:05 +0000 Subject: [PATCH 159/343] merge revision(s) r46360,r46372: [Backport #8625] * io.c (io_setstrbuf, io_read): should not shorten the given buffer until read succeeds. [ruby-core:55951] [Bug #8625] * io.c (read_all): truncate the buffer before appending read data, instead of truncating before reading. [ruby-core:55951] [Bug #8625] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46629 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 11 +++++++++++ io.c | 12 ++++++++---- test/ruby/test_io.rb | 8 ++++++++ test/ruby/test_pipe.rb | 13 +++++++++++++ version.h | 2 +- 5 files changed, 41 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8de7bfc7d20424..fd0f41cf3fbed8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +Tue Jul 1 03:05:22 2014 Nobuyoshi Nakada + + * io.c (read_all): truncate the buffer before appending read data, + instead of truncating before reading. + [ruby-core:55951] [Bug #8625] + +Tue Jul 1 03:05:22 2014 Nobuyoshi Nakada + + * io.c (io_setstrbuf, io_read): should not shorten the given buffer until + read succeeds. [ruby-core:55951] [Bug #8625] + Mon Jun 30 03:15:59 2014 Nobuyoshi Nakada * vm.c (core_hash_merge_kwd): should return the result hash, which diff --git a/io.c b/io.c index 6deb44187fc74b..e5a4d3b40c93b6 100644 --- a/io.c +++ b/io.c @@ -2291,9 +2291,6 @@ io_setstrbuf(VALUE *str, long len) long clen = RSTRING_LEN(s); if (clen >= len) { rb_str_modify(s); - if (clen != len) { - rb_str_set_len(s, len); - } return; } len -= clen; @@ -2320,23 +2317,27 @@ read_all(rb_io_t *fptr, long siz, VALUE str) int cr; if (NEED_READCONV(fptr)) { + int first = !NIL_P(str); SET_BINARY_MODE(fptr); io_setstrbuf(&str,0); make_readconv(fptr, 0); while (1) { VALUE v; if (fptr->cbuf.len) { + if (first) rb_str_set_len(str, first = 0); io_shift_cbuf(fptr, fptr->cbuf.len, &str); } v = fill_cbuf(fptr, 0); if (v != MORE_CHAR_SUSPENDED && v != MORE_CHAR_FINISHED) { if (fptr->cbuf.len) { + if (first) rb_str_set_len(str, first = 0); io_shift_cbuf(fptr, fptr->cbuf.len, &str); } rb_exc_raise(v); } if (v == MORE_CHAR_FINISHED) { clear_readconv(fptr); + if (first) rb_str_set_len(str, first = 0); return io_enc_str(str, fptr); } } @@ -2807,7 +2808,10 @@ io_read(int argc, VALUE *argv, VALUE io) GetOpenFile(io, fptr); rb_io_check_byte_readable(fptr); - if (len == 0) return str; + if (len == 0) { + io_set_read_length(str, 0); + return str; + } READ_CHECK(fptr); #if defined(RUBY_TEST_CRLF_ENVIRONMENT) || defined(_WIN32) diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index 115a4984746025..a7c5b2a39a8cd6 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -1224,6 +1224,14 @@ def test_read_buffer_error t.value assert_equal("", s) end + with_pipe do |r, w| + s = "xxx" + t = Thread.new {r.read(2, s)} + Thread.pass until t.stop? + t.kill + t.value + assert_equal("xxx", s) + end end def test_write_nonblock diff --git a/test/ruby/test_pipe.rb b/test/ruby/test_pipe.rb index 34f231ad8c9e0e..bcea91bebb6239 100644 --- a/test/ruby/test_pipe.rb +++ b/test/ruby/test_pipe.rb @@ -13,4 +13,17 @@ def open_file(content) r.close end end + class WithConversion < self + def open_file(content) + r, w = IO.pipe + w << content + w.close + r.set_encoding("us-ascii:utf-8") + begin + yield r + ensure + r.close + end + end + end end diff --git a/version.h b/version.h index cc54704b1b73e8..535f2e6122bccd 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-07-01" -#define RUBY_PATCHLEVEL 158 +#define RUBY_PATCHLEVEL 159 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 7 From 5ab69337816b10557e5a1658a5fa980c790a4b48 Mon Sep 17 00:00:00 2001 From: nagachika Date: Wed, 2 Jul 2014 16:27:21 +0000 Subject: [PATCH 160/343] merge revision(s) r45858,r45859,r45860,r45861,r46638: [Backport #9811] numeric.c: indent * numeric.c (ruby_num_interval_step_size): adjust indent. * numeric.c (num_step_scan_args): check keyword arguments and fail if they conflict with positional arguments. [ruby-dev:48177] [Bug #9811] * numeric.c (num_step_scan_args): table argument of rb_get_kwargs() is array of IDs, not Symbols. [ruby-dev:48353] [Bug #9811] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46661 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 11 ++++++ numeric.c | 82 +++++++++++++++++++++++---------------- test/ruby/test_numeric.rb | 8 ++++ version.h | 6 +-- 4 files changed, 71 insertions(+), 36 deletions(-) diff --git a/ChangeLog b/ChangeLog index fd0f41cf3fbed8..0807bf46d13bfe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +Thu Jul 3 01:19:50 2014 CHIKANAGA Tomoyuki + + * numeric.c (num_step_scan_args): table argument of rb_get_kwargs() is + array of IDs, not Symbols. [ruby-dev:48353] [Bug #9811] + +Thu Jul 3 01:19:50 2014 Nobuyoshi Nakada + + * numeric.c (num_step_scan_args): check keyword arguments and fail + if they conflict with positional arguments. + [ruby-dev:48177] [Bug #9811] + Tue Jul 1 03:05:22 2014 Nobuyoshi Nakada * io.c (read_all): truncate the buffer before appending read data, diff --git a/numeric.c b/numeric.c index bd538798b2ec9f..4b1319879768d7 100644 --- a/numeric.c +++ b/numeric.c @@ -119,7 +119,7 @@ VALUE rb_cFixnum; VALUE rb_eZeroDivError; VALUE rb_eFloatDomainError; -static VALUE sym_to, sym_by; +static ID id_to, id_by; void rb_num_zerodiv(void) @@ -1841,8 +1841,8 @@ ruby_num_interval_step_size(VALUE from, VALUE to, VALUE step, int excl) VALUE result; ID cmp = '>'; switch (rb_cmpint(rb_num_coerce_cmp(step, INT2FIX(0), id_cmp), step, INT2FIX(0))) { - case 0: return DBL2NUM(INFINITY); - case -1: cmp = '<'; break; + case 0: return DBL2NUM(INFINITY); + case -1: cmp = '<'; break; } if (RTEST(rb_funcall(from, cmp, 1, to))) return INT2FIX(0); result = rb_funcall(rb_funcall(to, '-', 1, from), id_div, 1, step); @@ -1853,39 +1853,55 @@ ruby_num_interval_step_size(VALUE from, VALUE to, VALUE step, int excl) } } -#define NUM_STEP_SCAN_ARGS(argc, argv, to, step, hash, desc) do { \ - argc = rb_scan_args(argc, argv, "02:", &to, &step, &hash); \ - if (!NIL_P(hash)) { \ - step = rb_hash_aref(hash, sym_by); \ - to = rb_hash_aref(hash, sym_to); \ - } \ - else { \ - /* compatibility */ \ - if (argc > 1 && NIL_P(step)) { \ - rb_raise(rb_eTypeError, "step must be numeric"); \ - } \ - if (rb_equal(step, INT2FIX(0))) { \ - rb_raise(rb_eArgError, "step can't be 0"); \ - } \ - } \ - if (NIL_P(step)) { \ - step = INT2FIX(1); \ - } \ - desc = !positive_int_p(step); \ - if (NIL_P(to)) { \ - to = desc ? DBL2NUM(-INFINITY) : DBL2NUM(INFINITY); \ - } \ -} while (0) +static int +num_step_scan_args(int argc, const VALUE *argv, VALUE *to, VALUE *step) +{ + VALUE hash; + int desc; + + argc = rb_scan_args(argc, argv, "02:", to, step, &hash); + if (!NIL_P(hash)) { + ID keys[2]; + VALUE values[2]; + keys[0] = id_to; + keys[1] = id_by; + rb_get_kwargs(hash, keys, 0, 2, values); + if (values[0] != Qundef) { + if (argc > 0) rb_raise(rb_eArgError, "to is given twice"); + *to = values[0]; + } + if (values[1] != Qundef) { + if (argc > 1) rb_raise(rb_eArgError, "step is given twice"); + *step = values[1]; + } + } + else { + /* compatibility */ + if (argc > 1 && NIL_P(*step)) { + rb_raise(rb_eTypeError, "step must be numeric"); + } + if (rb_equal(*step, INT2FIX(0))) { + rb_raise(rb_eArgError, "step can't be 0"); + } + } + if (NIL_P(*step)) { + *step = INT2FIX(1); + } + desc = !positive_int_p(*step); + if (NIL_P(*to)) { + *to = desc ? DBL2NUM(-INFINITY) : DBL2NUM(INFINITY); + } + return desc; +} static VALUE num_step_size(VALUE from, VALUE args, VALUE eobj) { - VALUE to, step, hash; - int desc; + VALUE to, step; int argc = args ? RARRAY_LENINT(args) : 0; VALUE *argv = args ? RARRAY_PTR(args) : 0; - NUM_STEP_SCAN_ARGS(argc, argv, to, step, hash, desc); + num_step_scan_args(argc, argv, &to, &step); return ruby_num_interval_step_size(from, to, step, FALSE); } @@ -1946,12 +1962,12 @@ num_step_size(VALUE from, VALUE args, VALUE eobj) static VALUE num_step(int argc, VALUE *argv, VALUE from) { - VALUE to, step, hash; + VALUE to, step; int desc, inf; RETURN_SIZED_ENUMERATOR(from, argc, argv, num_step_size); - NUM_STEP_SCAN_ARGS(argc, argv, to, step, hash, desc); + desc = num_step_scan_args(argc, argv, &to, &step); if (RTEST(rb_num_coerce_cmp(step, INT2FIX(0), id_eq))) { inf = 1; } @@ -4085,8 +4101,8 @@ Init_Numeric(void) rb_define_method(rb_cFloat, "infinite?", flo_is_infinite_p, 0); rb_define_method(rb_cFloat, "finite?", flo_is_finite_p, 0); - sym_to = ID2SYM(rb_intern("to")); - sym_by = ID2SYM(rb_intern("by")); + id_to = rb_intern("to"); + id_by = rb_intern("by"); } #undef rb_float_value diff --git a/test/ruby/test_numeric.rb b/test/ruby/test_numeric.rb index f5e97afec066fa..287093518b7902 100644 --- a/test/ruby/test_numeric.rb +++ b/test/ruby/test_numeric.rb @@ -240,6 +240,14 @@ def test_step assert_nothing_raised { 1.step(by: nil) } assert_nothing_raised { 1.step(by: nil).size } + bug9811 = '[ruby-dev:48177] [Bug #9811]' + assert_raise(ArgumentError, bug9811) { 1.step(10, foo: nil) {} } + assert_raise(ArgumentError, bug9811) { 1.step(10, foo: nil).size } + assert_raise(ArgumentError, bug9811) { 1.step(10, to: 11) {} } + assert_raise(ArgumentError, bug9811) { 1.step(10, to: 11).size } + assert_raise(ArgumentError, bug9811) { 1.step(10, 1, by: 11) {} } + assert_raise(ArgumentError, bug9811) { 1.step(10, 1, by: 11).size } + assert_equal(bignum*2+1, (-bignum).step(bignum, 1).size) assert_equal(bignum*2, (-bignum).step(bignum-1, 1).size) diff --git a/version.h b/version.h index 535f2e6122bccd..f555f9316ebefb 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.2" -#define RUBY_RELEASE_DATE "2014-07-01" -#define RUBY_PATCHLEVEL 159 +#define RUBY_RELEASE_DATE "2014-07-03" +#define RUBY_PATCHLEVEL 160 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 7 -#define RUBY_RELEASE_DAY 1 +#define RUBY_RELEASE_DAY 3 #include "ruby/version.h" From 2d90c01a1e8e5076d29e292fa6ed607044389f4d Mon Sep 17 00:00:00 2001 From: nagachika Date: Wed, 2 Jul 2014 16:55:39 +0000 Subject: [PATCH 161/343] merge revision(s) r45495: [Backport #9662] * README.EXT: fix typo. [ruby-core:61634] [Bug #9662] * README.EXT.ja: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46662 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- README.EXT | 2 +- README.EXT.ja | 2 +- version.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.EXT b/README.EXT index b1a816c271e0ac..6f7340cedaafd5 100644 --- a/README.EXT +++ b/README.EXT @@ -650,7 +650,7 @@ Here's the example of an initializing function. { /* define DBM class */ cDBM = rb_define_class("DBM", rb_cObject); - /* DBM includes Enumerate module */ + /* DBM includes Enumerable module */ rb_include_module(cDBM, rb_mEnumerable); /* DBM has class method open(): arguments are received as C array */ diff --git a/README.EXT.ja b/README.EXT.ja index b4b59008e090db..5ccc9306d10d59 100644 --- a/README.EXT.ja +++ b/README.EXT.ja @@ -726,7 +726,7 @@ Rubyは拡張ライブラリをロードする時に「Init_ライブラリ名 { /* DBMクラスを定義する */ cDBM = rb_define_class("DBM", rb_cObject); - /* DBMはEnumerateモジュールをインクルードする */ + /* DBMはEnumerableモジュールをインクルードする */ rb_include_module(cDBM, rb_mEnumerable); /* DBMクラスのクラスメソッドopen(): 引数はCの配列で受ける */ diff --git a/version.h b/version.h index f555f9316ebefb..46a11e1f86ed3c 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-07-03" -#define RUBY_PATCHLEVEL 160 +#define RUBY_PATCHLEVEL 161 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 7 From 598fc49d41dbfa392f18f13c4df4357747536c11 Mon Sep 17 00:00:00 2001 From: nagachika Date: Thu, 3 Jul 2014 15:37:51 +0000 Subject: [PATCH 162/343] merge revision(s) r45462,r45463,r45466: [Backport #9684] * struct.c (not_a_member): extract name error and use same error messages. based on the patch by Marcus Stollsteimer at [ruby-core:61721]. [Bug #9684] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46673 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ ext/-test-/struct/extconf.rb | 7 +++++++ ext/-test-/struct/init.c | 11 +++++++++++ ext/-test-/struct/member.c | 18 ++++++++++++++++++ struct.c | 15 +++++++++++---- test/-ext-/struct/test_member.rb | 16 ++++++++++++++++ version.h | 6 +++--- 7 files changed, 72 insertions(+), 7 deletions(-) create mode 100644 ext/-test-/struct/extconf.rb create mode 100644 ext/-test-/struct/init.c create mode 100644 ext/-test-/struct/member.c create mode 100644 test/-ext-/struct/test_member.rb diff --git a/ChangeLog b/ChangeLog index 0807bf46d13bfe..8e37c524944159 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Fri Jul 4 00:25:16 2014 Nobuyoshi Nakada + + * struct.c (not_a_member): extract name error and use same error + messages. based on the patch by Marcus Stollsteimer at [ruby-core:61721]. [Bug #9684] + Thu Jul 3 01:19:50 2014 CHIKANAGA Tomoyuki * numeric.c (num_step_scan_args): table argument of rb_get_kwargs() is diff --git a/ext/-test-/struct/extconf.rb b/ext/-test-/struct/extconf.rb new file mode 100644 index 00000000000000..0e4f9551f2a49b --- /dev/null +++ b/ext/-test-/struct/extconf.rb @@ -0,0 +1,7 @@ +$INCFLAGS << " -I$(topdir) -I$(top_srcdir)" +$srcs = Dir[File.join($srcdir, "*.{#{SRC_EXT.join(%q{,})}}")] +inits = $srcs.map {|s| File.basename(s, ".*")} +inits.delete("init") +inits.map! {|s|"X(#{s})"} +$defs << "-DTEST_INIT_FUNCS(X)=\"#{inits.join(' ')}\"" +create_makefile("-test-/struct") diff --git a/ext/-test-/struct/init.c b/ext/-test-/struct/init.c new file mode 100644 index 00000000000000..459a939e79c165 --- /dev/null +++ b/ext/-test-/struct/init.c @@ -0,0 +1,11 @@ +#include "ruby.h" + +#define init(n) {void Init_##n(VALUE klass); Init_##n(klass);} + +void +Init_struct(void) +{ + VALUE mBug = rb_define_module("Bug"); + VALUE klass = rb_define_class_under(mBug, "Struct", rb_cStruct); + TEST_INIT_FUNCS(init); +} diff --git a/ext/-test-/struct/member.c b/ext/-test-/struct/member.c new file mode 100644 index 00000000000000..1d404039b49d95 --- /dev/null +++ b/ext/-test-/struct/member.c @@ -0,0 +1,18 @@ +#include "ruby.h" + +static VALUE +bug_struct_get(VALUE obj, VALUE name) +{ + ID id = rb_check_id(&name); + + if (!id) { + rb_name_error_str(name, "`%"PRIsVALUE"' is not a struct member", name); + } + return rb_struct_getmember(obj, id); +} + +void +Init_member(VALUE klass) +{ + rb_define_method(klass, "get", bug_struct_get, 1); +} diff --git a/struct.c b/struct.c index 2e026fbc7fdef5..e13473637beb19 100644 --- a/struct.c +++ b/struct.c @@ -86,6 +86,13 @@ rb_struct_members_m(VALUE obj) return rb_struct_s_members_m(rb_obj_class(obj)); } +NORETURN(static void not_a_member(ID id)); +static void +not_a_member(ID id) +{ + rb_name_error(id, "`%"PRIsVALUE"' is not a struct member", QUOTE_ID(id)); +} + VALUE rb_struct_getmember(VALUE obj, ID id) { @@ -100,7 +107,7 @@ rb_struct_getmember(VALUE obj, ID id) return RSTRUCT_GET(obj, i); } } - rb_name_error(id, "%s is not struct member", rb_id2name(id)); + not_a_member(id); UNREACHABLE; } @@ -149,19 +156,19 @@ rb_struct_set(VALUE obj, VALUE val) { VALUE members, slot; long i, len; + ID fid = rb_frame_this_func(); members = rb_struct_members(obj); len = RARRAY_LEN(members); rb_struct_modify(obj); for (i=0; i Date: Thu, 3 Jul 2014 15:41:30 +0000 Subject: [PATCH 163/343] merge revision(s) r45786: [Backport #9738] * lib/rinda/tuplespace.rb: fix document. [ruby-core:62003][Bug #9738] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46674 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/rinda/tuplespace.rb | 2 +- version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/rinda/tuplespace.rb b/lib/rinda/tuplespace.rb index ee2bef17690d86..11532fd161960c 100644 --- a/lib/rinda/tuplespace.rb +++ b/lib/rinda/tuplespace.rb @@ -76,7 +76,7 @@ def expired? # Reset the expiry time according to +sec_or_renewer+. # # +nil+:: it is set to expire in the far future. - # +false+:: it has expired. + # +true+:: it has expired. # Numeric:: it will expire in that many seconds. # # Otherwise the argument refers to some kind of renewer object diff --git a/version.h b/version.h index 932296707f8a94..25222006c0dbf1 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-07-04" -#define RUBY_PATCHLEVEL 162 +#define RUBY_PATCHLEVEL 163 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 7 From 95338ad304dd1de3840f7cd9b291656c2f98e84c Mon Sep 17 00:00:00 2001 From: nagachika Date: Thu, 3 Jul 2014 15:43:12 +0000 Subject: [PATCH 164/343] merge revision(s) r45896: [Backport #9773] * man/ruby.1: remove deadlink. [ruby-core:62145][Bug #9773] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46675 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ man/ruby.1 | 2 -- version.h | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8e37c524944159..3df29306df870c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Fri Jul 4 00:42:57 2014 SHIBATA Hiroshi + + * man/ruby.1: remove deadlink. [ruby-core:62145][Bug #9773] + Fri Jul 4 00:25:16 2014 Nobuyoshi Nakada * struct.c (not_a_member): extract name error and use same error diff --git a/man/ruby.1 b/man/ruby.1 index ec79e1d07b9f03..75dff3c435f2c9 100644 --- a/man/ruby.1 +++ b/man/ruby.1 @@ -493,8 +493,6 @@ The official web site. hosting many open source ruby projects. .It https://www.ruby-toolbox.com Comprehensive catalog of Ruby libraries. -.It https://github.com/languages/Ruby -Ruby projects on Github. .El .Pp .Sh REPORTING BUGS diff --git a/version.h b/version.h index 25222006c0dbf1..dc3d384f6c75d8 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-07-04" -#define RUBY_PATCHLEVEL 163 +#define RUBY_PATCHLEVEL 164 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 7 From aa04a7221dd01cd1e641feedf977e46fdb80b449 Mon Sep 17 00:00:00 2001 From: nagachika Date: Thu, 3 Jul 2014 15:44:54 +0000 Subject: [PATCH 165/343] merge revision(s) r46095: [Backport #9819] * enum.c: [DOC] Use #find in example to clarify alias by @rachellogie Patch submitted via documenting-ruby/ruby#34 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46676 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ enum.c | 4 ++-- version.h | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3df29306df870c..52b99605ccc4e5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Fri Jul 4 00:44:43 2014 Zachary Scott + + * enum.c: [DOC] Use #find in example to clarify alias by @rachellogie + Patch submitted via documenting-ruby/ruby#34 + Fri Jul 4 00:42:57 2014 SHIBATA Hiroshi * man/ruby.1: remove deadlink. [ruby-core:62145][Bug #9773] diff --git a/enum.c b/enum.c index e37ff16c5d3882..9d1d36d0dd9293 100644 --- a/enum.c +++ b/enum.c @@ -203,8 +203,8 @@ find_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, memop)) * * If no block is given, an enumerator is returned instead. * - * (1..10).detect { |i| i % 5 == 0 and i % 7 == 0 } #=> nil - * (1..100).detect { |i| i % 5 == 0 and i % 7 == 0 } #=> 35 + * (1..10).detect { |i| i % 5 == 0 and i % 7 == 0 } #=> nil + * (1..100).find { |i| i % 5 == 0 and i % 7 == 0 } #=> 35 * */ diff --git a/version.h b/version.h index dc3d384f6c75d8..a47e6c9ea53c70 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-07-04" -#define RUBY_PATCHLEVEL 164 +#define RUBY_PATCHLEVEL 165 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 7 From 5fdc9a2e0880c68ae5fae76994591604aa1456f9 Mon Sep 17 00:00:00 2001 From: nagachika Date: Thu, 3 Jul 2014 15:46:17 +0000 Subject: [PATCH 166/343] merge revision(s) r46099: [Backport #9814] * enumerator.c: [DOC] Fix example to show Enumerator#peek behavior Patch by Erik Hollembeak [Bug #9814] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46677 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ enumerator.c | 2 +- version.h | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 52b99605ccc4e5..1fca6753f7f547 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Fri Jul 4 00:46:03 2014 Zachary Scott + + * enumerator.c: [DOC] Fix example to show Enumerator#peek behavior + Patch by Erik Hollembeak [Bug #9814] + Fri Jul 4 00:44:43 2014 Zachary Scott * enum.c: [DOC] Use #find in example to clarify alias by @rachellogie diff --git a/enumerator.c b/enumerator.c index 2e80580dea4e1e..c452b1776a1b57 100644 --- a/enumerator.c +++ b/enumerator.c @@ -838,7 +838,7 @@ enumerator_peek_values_m(VALUE obj) * p e.peek #=> 2 * p e.next #=> 2 * p e.next #=> 3 - * p e.next #raises StopIteration + * p e.peek #raises StopIteration * */ diff --git a/version.h b/version.h index a47e6c9ea53c70..37467665551789 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-07-04" -#define RUBY_PATCHLEVEL 165 +#define RUBY_PATCHLEVEL 166 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 7 From 1fe220dc0b38823890aa579298c754ff75e7eda6 Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 6 Jul 2014 13:57:45 +0000 Subject: [PATCH 167/343] merge revision(s) r45344: [Backport #9543] * lib/gserver.rb: [DOC] Fixed typo in example by @stomar [Bug #9543] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46719 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ lib/gserver.rb | 12 ++++++------ version.h | 6 +++--- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1fca6753f7f547..1aca6db29cc947 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Sun Jul 6 22:56:03 2014 Zachary Scott + + * lib/gserver.rb: [DOC] Fixed typo in example by @stomar [Bug #9543] + Fri Jul 4 00:46:03 2014 Zachary Scott * enumerator.c: [DOC] Fix example to show Enumerator#peek behavior diff --git a/lib/gserver.rb b/lib/gserver.rb index 4d566fcf2ef25d..d7b4a0783efcf5 100644 --- a/lib/gserver.rb +++ b/lib/gserver.rb @@ -37,7 +37,7 @@ # super(port, *args) # end # def serve(io) -# io.puts(Time.now.to_s) +# io.puts(Time.now.to_i) # end # end # @@ -144,7 +144,7 @@ def join attr_reader :port # Host on which to bind, as a String attr_reader :host - # Maximum number of connections to accept at at ime, as a Fixnum + # Maximum number of connections to accept at a time, as a Fixnum attr_reader :maxConnections # IO Device on which log messages should be written attr_accessor :stdlog @@ -156,7 +156,7 @@ def join # Called when a client connects, if auditing is enabled. # - # +client+:: a TCPSocket instances representing the client that connected + # +client+:: a TCPSocket instance representing the client that connected # # Return true to allow this client to connect, false to prevent it. def connecting(client) @@ -192,7 +192,7 @@ def stopping() # Called if #debug is true whenever an unhandled exception is raised. # This implementation simply logs the backtrace. # - # +detail+:: The Exception that was caught + # +detail+:: the Exception that was caught def error(detail) log(detail.backtrace.join("\n")) end @@ -212,9 +212,9 @@ def log(msg) # Create a new server # - # +port+:: the port, as a Fixnum, on which to listen. + # +port+:: the port, as a Fixnum, on which to listen # +host+:: the host to bind to - # +maxConnections+:: The maximum number of simultaneous connections to + # +maxConnections+:: the maximum number of simultaneous connections to # accept # +stdlog+:: IO device on which to log messages # +audit+:: if true, lifecycle callbacks will be called. See #audit diff --git a/version.h b/version.h index 37467665551789..2386dc21777ee1 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.2" -#define RUBY_RELEASE_DATE "2014-07-04" -#define RUBY_PATCHLEVEL 166 +#define RUBY_RELEASE_DATE "2014-07-06" +#define RUBY_PATCHLEVEL 167 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 7 -#define RUBY_RELEASE_DAY 4 +#define RUBY_RELEASE_DAY 6 #include "ruby/version.h" From 068a7dff125f7f1fc440254f5ae5f7d86fca64e7 Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 6 Jul 2014 14:28:18 +0000 Subject: [PATCH 168/343] merge revision(s) r45642,r45643: [Backport #9646] [Backport #9729] * st.c (st_foreach_check): chnage start point of search at check from top to current. [ruby-dev:48047] [Bug #9646] * st.c (st_foreach_check): change start point of search at check git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46721 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ st.c | 16 +++++++++++----- test/ruby/test_hash.rb | 11 +++++++++++ version.h | 2 +- 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1aca6db29cc947..ad28e34316ffe9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sun Jul 6 23:16:30 2014 Masaya Tarui + + * st.c (st_foreach_check): change start point of search at check + from top to current. [ruby-dev:48047] [Bug #9646] + Sun Jul 6 22:56:03 2014 Zachary Scott * lib/gserver.rb: [DOC] Fixed typo in example by @stomar [Bug #9543] diff --git a/st.c b/st.c index 2335fddc849458..d689c81e927403 100644 --- a/st.c +++ b/st.c @@ -393,9 +393,8 @@ find_entry(st_table *table, st_data_t key, st_index_t hash_val, st_index_t bin_p } static inline st_index_t -find_packed_index(st_table *table, st_index_t hash_val, st_data_t key) +find_packed_index_from(st_table *table, st_index_t hash_val, st_data_t key, st_index_t i) { - st_index_t i = 0; while (i < table->real_entries && (PHASH(table, i) != hash_val || !EQUAL(table, key, PKEY(table, i)))) { i++; @@ -403,6 +402,12 @@ find_packed_index(st_table *table, st_index_t hash_val, st_data_t key) return i; } +static inline st_index_t +find_packed_index(st_table *table, st_index_t hash_val, st_data_t key) +{ + return find_packed_index_from(table, hash_val, key, 0); +} + #define collision_check 0 int @@ -962,9 +967,10 @@ st_foreach_check(st_table *table, int (*func)(ANYARGS), st_data_t arg, st_data_t if (PHASH(table, i) == 0 && PKEY(table, i) == never) { break; } - i = find_packed_index(table, hash, key); - if (i == table->real_entries) { - goto deleted; + i = find_packed_index_from(table, hash, key, i); + if (i >= table->real_entries) { + i = find_packed_index(table, hash, key); + if (i >= table->real_entries) goto deleted; } /* fall through */ case ST_CONTINUE: diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb index 0bbdf13a07698f..59000ad5d6144b 100644 --- a/test/ruby/test_hash.rb +++ b/test/ruby/test_hash.rb @@ -1087,6 +1087,17 @@ def test_compare_by_identity assert_predicate(h.dup, :compare_by_identity?, bug8703) end + def test_same_key + bug9646 = '[ruby-dev:48047] [Bug #9646] Infinite loop at Hash#each' + h = @cls[a=[], 1] + a << 1 + h[[]] = 2 + a.clear + cnt = 0 + r = h.each{ break nil if (cnt+=1) > 100 } + assert_not_nil(r,bug9646) + end + class ObjWithHash def initialize(value, hash) @value = value diff --git a/version.h b/version.h index 2386dc21777ee1..80c403cb459029 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-07-06" -#define RUBY_PATCHLEVEL 167 +#define RUBY_PATCHLEVEL 168 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 7 From feea0a9e82a73951c8b75ff7461e731d92919ad7 Mon Sep 17 00:00:00 2001 From: nagachika Date: Fri, 11 Jul 2014 14:08:51 +0000 Subject: [PATCH 169/343] merge revision(s) r46780: [Backport #9499] * lib/matrix.rb: Fix sign for cross_product [#9499] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46789 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ lib/matrix.rb | 6 +++--- test/matrix/test_vector.rb | 5 +++++ version.h | 6 +++--- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index ad28e34316ffe9..92477c2647681b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Fri Jul 11 23:07:09 2014 Marc-Andre Lafortune + + * lib/matrix.rb: Fix sign for cross_product [#9499] + Sun Jul 6 23:16:30 2014 Masaya Tarui * st.c (st_foreach_check): change start point of search at check diff --git a/lib/matrix.rb b/lib/matrix.rb index f82ed659798df7..b20fd9451fafc4 100644 --- a/lib/matrix.rb +++ b/lib/matrix.rb @@ -1764,9 +1764,9 @@ def inner_product(v) # def cross_product(v) Vector.Raise ErrDimensionMismatch unless size == v.size && v.size == 3 - Vector[ v[1]*@elements[2] - v[2]*@elements[1], - v[2]*@elements[0] - v[0]*@elements[2], - v[0]*@elements[1] - v[1]*@elements[0] ] + Vector[ v[2]*@elements[1] - v[1]*@elements[2], + v[0]*@elements[2] - v[2]*@elements[0], + v[1]*@elements[0] - v[0]*@elements[1] ] end # diff --git a/test/matrix/test_vector.rb b/test/matrix/test_vector.rb index 18660df574d82e..ced774c490f85b 100644 --- a/test/matrix/test_vector.rb +++ b/test/matrix/test_vector.rb @@ -146,4 +146,9 @@ def test_rational_magnitude v = Vector[Rational(1,2), 0] assert_equal(0.5, v.norm) end + + def test_cross_product + v = Vector[1, 0, 0].cross_product Vector[0, 1, 0] + assert_equal(Vector[0, 0, 1], v) + end end diff --git a/version.h b/version.h index 80c403cb459029..701b263b76ba37 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.2" -#define RUBY_RELEASE_DATE "2014-07-06" -#define RUBY_PATCHLEVEL 168 +#define RUBY_RELEASE_DATE "2014-07-11" +#define RUBY_PATCHLEVEL 169 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 7 -#define RUBY_RELEASE_DAY 6 +#define RUBY_RELEASE_DAY 11 #include "ruby/version.h" From 5643bc5ae071e94da9719269bdd7ff85c5fcff0e Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 13 Jul 2014 13:51:07 +0000 Subject: [PATCH 170/343] merge revision(s) r45423,r45424: [Backport #9674] * ext/thread/thread.c (undumpable): ConditionVariable and Queue are not dumpable. [ruby-core:61677] [Bug #9674] * marshal.c (w_object): internal objects are not dumpable. [ruby-core:61677] [Bug #9674] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46805 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ ext/thread/thread.c | 9 +++++++++ marshal.c | 5 +++++ test/thread/test_cv.rb | 15 +++++++++++++++ test/thread/test_queue.rb | 20 ++++++++++++++++++++ version.h | 6 +++--- 6 files changed, 57 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 92477c2647681b..37f6e27fc05d5c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sun Jul 13 22:44:05 2014 Nobuyoshi Nakada + + * ext/thread/thread.c (undumpable): ConditionVariable and Queue + are not dumpable. [ruby-core:61677] [Bug #9674] + Fri Jul 11 23:07:09 2014 Marc-Andre Lafortune * lib/matrix.rb: Fix sign for cross_product [#9499] diff --git a/ext/thread/thread.c b/ext/thread/thread.c index c409b36da2c0ba..fa277086789e77 100644 --- a/ext/thread/thread.c +++ b/ext/thread/thread.c @@ -534,6 +534,13 @@ rb_szqueue_num_waiting(VALUE self) #define UNDER_THREAD 1 #endif +static VALUE +undumpable(VALUE obj) +{ + rb_raise(rb_eTypeError, "can't dump %"PRIsVALUE, rb_obj_class(obj)); + UNREACHABLE; +} + void Init_thread(void) { @@ -572,11 +579,13 @@ Init_thread(void) id_sleep = rb_intern("sleep"); rb_define_method(rb_cConditionVariable, "initialize", rb_condvar_initialize, 0); + rb_define_method(rb_cConditionVariable, "marshal_dump", undumpable, 0); rb_define_method(rb_cConditionVariable, "wait", rb_condvar_wait, -1); rb_define_method(rb_cConditionVariable, "signal", rb_condvar_signal, 0); rb_define_method(rb_cConditionVariable, "broadcast", rb_condvar_broadcast, 0); rb_define_method(rb_cQueue, "initialize", rb_queue_initialize, 0); + rb_define_method(rb_cQueue, "marshal_dump", undumpable, 0); rb_define_method(rb_cQueue, "push", rb_queue_push, 1); rb_define_method(rb_cQueue, "pop", rb_queue_pop, -1); rb_define_method(rb_cQueue, "empty?", rb_queue_empty_p, 0); diff --git a/marshal.c b/marshal.c index 2fe272100bc481..a0630cb35ca2ba 100644 --- a/marshal.c +++ b/marshal.c @@ -650,6 +650,11 @@ w_object(VALUE obj, struct dump_arg *arg, int limit) else { VALUE v; + if (!RBASIC_CLASS(obj)) { + rb_raise(rb_eTypeError, "can't dump internal %s", + rb_builtin_type_name(BUILTIN_TYPE(obj))); + } + arg->infection |= (int)FL_TEST(obj, MARSHAL_INFECTION); if (rb_obj_respond_to(obj, s_mdump, TRUE)) { diff --git a/test/thread/test_cv.rb b/test/thread/test_cv.rb index 9a9b407a5b1968..f0d7c6d094a193 100644 --- a/test/thread/test_cv.rb +++ b/test/thread/test_cv.rb @@ -188,4 +188,19 @@ def test_condvar_empty_broadcast assert_nothing_raised(Exception) { mutex.synchronize {condvar.broadcast} } end + + (DumpableCV = ConditionVariable.dup).class_eval {remove_method :marshal_dump} + + def test_dump + bug9674 = '[ruby-core:61677] [Bug #9674]' + condvar = ConditionVariable.new + assert_raise_with_message(TypeError, /#{ConditionVariable}/, bug9674) do + Marshal.dump(condvar) + end + + condvar = DumpableCV.new + assert_raise_with_message(TypeError, /internal Array/, bug9674) do + Marshal.dump(condvar) + end + end end diff --git a/test/thread/test_queue.rb b/test/thread/test_queue.rb index c99475d8dc872d..c9481aa2990571 100644 --- a/test/thread/test_queue.rb +++ b/test/thread/test_queue.rb @@ -207,4 +207,24 @@ def test_queue_thread_raise timeout(1) { th2.join } end end + + (DumpableQueue = Queue.dup).class_eval {remove_method :marshal_dump} + + def test_dump + bug9674 = '[ruby-core:61677] [Bug #9674]' + q = Queue.new + assert_raise_with_message(TypeError, /#{Queue}/, bug9674) do + Marshal.dump(q) + end + + sq = SizedQueue.new(1) + assert_raise_with_message(TypeError, /#{SizedQueue}/, bug9674) do + Marshal.dump(sq) + end + + q = DumpableQueue.new + assert_raise_with_message(TypeError, /internal Array/, bug9674) do + Marshal.dump(q) + end + end end diff --git a/version.h b/version.h index 701b263b76ba37..8588ffcdaf81bb 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.2" -#define RUBY_RELEASE_DATE "2014-07-11" -#define RUBY_PATCHLEVEL 169 +#define RUBY_RELEASE_DATE "2014-07-13" +#define RUBY_PATCHLEVEL 170 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 7 -#define RUBY_RELEASE_DAY 11 +#define RUBY_RELEASE_DAY 13 #include "ruby/version.h" From 5c1a69452b3fcdb0c6353a6ca5bc9292603e05f8 Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 13 Jul 2014 13:59:09 +0000 Subject: [PATCH 171/343] merge revision(s) r46778: [Backport #10019] * pack.c (encodes): fix buffer overrun by tail_lf. Thanks to Mamoru Tasaka and Tomas Hoger. [ruby-core:63604] [Bug #10019] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46806 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ pack.c | 8 +++++--- test/ruby/test_pack.rb | 8 ++++++++ version.h | 2 +- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 37f6e27fc05d5c..9f4fedef2cfe23 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sun Jul 13 22:52:43 2014 Nobuyoshi Nakada + + * pack.c (encodes): fix buffer overrun by tail_lf. Thanks to + Mamoru Tasaka and Tomas Hoger. [ruby-core:63604] [Bug #10019] + Sun Jul 13 22:44:05 2014 Nobuyoshi Nakada * ext/thread/thread.c (undumpable): ConditionVariable and Queue diff --git a/pack.c b/pack.c index 71dd6afcb314bd..400e85c8ccfc26 100644 --- a/pack.c +++ b/pack.c @@ -946,7 +946,8 @@ static const char b64_table[] = static void encodes(VALUE str, const char *s, long len, int type, int tail_lf) { - char buff[4096]; + enum {buff_size = 4096, encoded_unit = 4}; + char buff[buff_size + 1]; /* +1 for tail_lf */ long i = 0; const char *trans = type == 'u' ? uu_table : b64_table; char padding; @@ -959,7 +960,7 @@ encodes(VALUE str, const char *s, long len, int type, int tail_lf) padding = '='; } while (len >= 3) { - while (len >= 3 && sizeof(buff)-i >= 4) { + while (len >= 3 && buff_size-i >= encoded_unit) { buff[i++] = trans[077 & (*s >> 2)]; buff[i++] = trans[077 & (((*s << 4) & 060) | ((s[1] >> 4) & 017))]; buff[i++] = trans[077 & (((s[1] << 2) & 074) | ((s[2] >> 6) & 03))]; @@ -967,7 +968,7 @@ encodes(VALUE str, const char *s, long len, int type, int tail_lf) s += 3; len -= 3; } - if (sizeof(buff)-i < 4) { + if (buff_size-i < encoded_unit) { rb_str_buf_cat(str, buff, i); i = 0; } @@ -987,6 +988,7 @@ encodes(VALUE str, const char *s, long len, int type, int tail_lf) } if (tail_lf) buff[i++] = '\n'; rb_str_buf_cat(str, buff, i); + if ((size_t)i > sizeof(buff)) rb_bug("encodes() buffer overrun"); } static const char hex_table[] = "0123456789ABCDEF"; diff --git a/test/ruby/test_pack.rb b/test/ruby/test_pack.rb index 3f0931bdc0cfb2..4b089f732218d5 100644 --- a/test/ruby/test_pack.rb +++ b/test/ruby/test_pack.rb @@ -550,6 +550,14 @@ def test_pack_unpack_m assert_equal(["\0"], "AA\n".unpack("m")) assert_equal(["\0"], "AA=\n".unpack("m")) assert_equal(["\0\0"], "AAA\n".unpack("m")) + + bug10019 = '[ruby-core:63604] [Bug #10019]' + size = ((4096-4)/4*3+1) + assert_separately(%W[- #{size} #{bug10019}], <<-'end;') + size = ARGV.shift.to_i + bug = ARGV.shift + assert_equal(size, ["a"*size].pack("m#{size+2}").unpack("m")[0].size, bug) + end; end def test_pack_unpack_m0 diff --git a/version.h b/version.h index 8588ffcdaf81bb..2192725495bf3c 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-07-13" -#define RUBY_PATCHLEVEL 170 +#define RUBY_PATCHLEVEL 171 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 7 From aa8380e17af88e98ff6e9498edf8f952b5b15fca Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 13 Jul 2014 14:08:48 +0000 Subject: [PATCH 172/343] merge revision(s) r46416: [Backport #9942] * array.c (rb_ary_permutation): `p` is the array of size `r`, as commented at permute0(). since `n >= r` here, buffer overflow never happened, just reduce unnecessary allocation though. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46807 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ array.c | 2 +- version.h | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9f4fedef2cfe23..50ff5af9801b40 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sun Jul 13 23:02:36 2014 Nobuyoshi Nakada + + * array.c (rb_ary_permutation): `p` is the array of size `r`, as + commented at permute0(). since `n >= r` here, buffer overflow + never happened, just reduce unnecessary allocation though. + Sun Jul 13 22:52:43 2014 Nobuyoshi Nakada * pack.c (encodes): fix buffer overrun by tail_lf. Thanks to diff --git a/array.c b/array.c index a57733866ed10d..425cff20ad0ac1 100644 --- a/array.c +++ b/array.c @@ -4818,7 +4818,7 @@ rb_ary_permutation(int argc, VALUE *argv, VALUE ary) } } else { /* this is the general case */ - volatile VALUE t0 = tmpbuf(n,sizeof(long)); + volatile VALUE t0 = tmpbuf(r,sizeof(long)); long *p = (long*)RSTRING_PTR(t0); volatile VALUE t1 = tmpbuf(n,sizeof(char)); char *used = (char*)RSTRING_PTR(t1); diff --git a/version.h b/version.h index 2192725495bf3c..22ed42eaf80548 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-07-13" -#define RUBY_PATCHLEVEL 171 +#define RUBY_PATCHLEVEL 172 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 7 From 99ea5ebb9e0dc4583477ccde21a8f5e7a517ad2c Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 13 Jul 2014 14:16:37 +0000 Subject: [PATCH 173/343] merge revision(s) r46417,r46418: [Backport #9939] * array.c (yield_indexed_values): extract from permute0(), rpermute0(), and rcombinate0(). * array.c (rb_ary_combination): iterate on a shared copy, and use array of indexes instead of array of chosen objects. [ruby-core:63149] [Bug #9939] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46808 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++ array.c | 77 ++++++++++++++++++----------------------- test/ruby/test_array.rb | 9 +++++ version.h | 2 +- 4 files changed, 48 insertions(+), 45 deletions(-) diff --git a/ChangeLog b/ChangeLog index 50ff5af9801b40..cd79bdc1a1880f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sun Jul 13 23:10:03 2014 Nobuyoshi Nakada + + * array.c (yield_indexed_values): extract from permute0(), + rpermute0(), and rcombinate0(). + Sun Jul 13 23:02:36 2014 Nobuyoshi Nakada * array.c (rb_ary_permutation): `p` is the array of size `r`, as diff --git a/array.c b/array.c index 425cff20ad0ac1..3d2409340c8ea1 100644 --- a/array.c +++ b/array.c @@ -4682,6 +4682,25 @@ rb_ary_cycle(int argc, VALUE *argv, VALUE ary) #define tmpary(n) rb_ary_tmp_new(n) #define tmpary_discard(a) (ary_discard(a), RBASIC_SET_CLASS_RAW(a, rb_cArray)) +/* + * Build a ruby array of the corresponding values and yield it to the + * associated block. + * Return the class of +values+ for reentry check. + */ +static int +yield_indexed_values(const VALUE values, const long r, const long *const p) +{ + const VALUE result = rb_ary_new2(r); + VALUE *const result_array = RARRAY_PTR(result); + const VALUE *const values_array = RARRAY_CONST_PTR(values); + long i; + + for (i = 0; i < r; i++) result_array[i] = values_array[p[i]]; + ARY_SET_LEN(result, r); + rb_yield(result); + return !RBASIC(values)->klass; +} + /* * Recursively compute permutations of +r+ elements of the set * [0..n-1]. @@ -4699,7 +4718,7 @@ rb_ary_cycle(int argc, VALUE *argv, VALUE ary) static void permute0(long n, long r, long *p, long index, char *used, VALUE values) { - long i,j; + long i; for (i = 0; i < n; i++) { if (used[i] == 0) { p[index] = i; @@ -4710,17 +4729,7 @@ permute0(long n, long r, long *p, long index, char *used, VALUE values) used[i] = 0; /* index unused */ } else { - /* We have a complete permutation of array indexes */ - /* Build a ruby array of the corresponding values */ - /* And yield it to the associated block */ - VALUE result = rb_ary_new2(r); - VALUE *result_array = RARRAY_PTR(result); - const VALUE *values_array = RARRAY_PTR(values); - - for (j = 0; j < r; j++) result_array[j] = values_array[p[j]]; - ARY_SET_LEN(result, r); - rb_yield(result); - if (RBASIC(values)->klass) { + if (!yield_indexed_values(values, r, p)) { rb_raise(rb_eRuntimeError, "permute reentered"); } } @@ -4889,21 +4898,19 @@ rb_ary_combination(VALUE ary, VALUE num) } } else { - volatile VALUE t0 = tmpbuf(n+1, sizeof(long)); - long *stack = (long*)RSTRING_PTR(t0); - volatile VALUE cc = tmpary(n); - VALUE *chosen = RARRAY_PTR(cc); + VALUE ary0 = ary_make_shared_copy(ary); /* private defensive copy of ary */ + volatile VALUE t0; + long *stack = ALLOCV_N(long, t0, n+1); long lev = 0; - MEMZERO(stack, long, n); + RBASIC_CLEAR_CLASS(ary0); + MEMZERO(stack+1, long, n); stack[0] = -1; for (;;) { - chosen[lev] = RARRAY_AREF(ary, stack[lev+1]); for (lev++; lev < n; lev++) { - chosen[lev] = RARRAY_AREF(ary, stack[lev+1] = stack[lev]+1); + stack[lev+1] = stack[lev]+1; } - rb_yield(rb_ary_new4(n, chosen)); - if (RBASIC(t0)->klass) { + if (!yield_indexed_values(ary0, n, stack+1)) { rb_raise(rb_eRuntimeError, "combination reentered"); } do { @@ -4912,8 +4919,8 @@ rb_ary_combination(VALUE ary, VALUE num) } while (stack[lev+1]+n == len+lev+1); } done: - tmpbuf_discard(t0); - tmpary_discard(cc); + ALLOCV_END(t0); + RBASIC_SET_CLASS_RAW(ary0, rb_cArray); } return ary; } @@ -4934,24 +4941,14 @@ rb_ary_combination(VALUE ary, VALUE num) static void rpermute0(long n, long r, long *p, long index, VALUE values) { - long i, j; + long i; for (i = 0; i < n; i++) { p[index] = i; if (index < r-1) { /* if not done yet */ rpermute0(n, r, p, index+1, values); /* recurse */ } else { - /* We have a complete permutation of array indexes */ - /* Build a ruby array of the corresponding values */ - /* And yield it to the associated block */ - VALUE result = rb_ary_new2(r); - VALUE *result_array = RARRAY_PTR(result); - const VALUE *values_array = RARRAY_PTR(values); - - for (j = 0; j < r; j++) result_array[j] = values_array[p[j]]; - ARY_SET_LEN(result, r); - rb_yield(result); - if (RBASIC(values)->klass) { + if (!yield_indexed_values(values, r, p)) { rb_raise(rb_eRuntimeError, "repeated permute reentered"); } } @@ -5032,7 +5029,6 @@ rb_ary_repeated_permutation(VALUE ary, VALUE num) static void rcombinate0(long n, long r, long *p, long index, long rest, VALUE values) { - long j; if (rest > 0) { for (; index < n; ++index) { p[r-rest] = index; @@ -5040,14 +5036,7 @@ rcombinate0(long n, long r, long *p, long index, long rest, VALUE values) } } else { - VALUE result = rb_ary_new2(r); - VALUE *result_array = RARRAY_PTR(result); - const VALUE *values_array = RARRAY_PTR(values); - - for (j = 0; j < r; ++j) result_array[j] = values_array[p[j]]; - ARY_SET_LEN(result, r); - rb_yield(result); - if (RBASIC(values)->klass) { + if (!yield_indexed_values(values, r, p)) { rb_raise(rb_eRuntimeError, "repeated combination reentered"); } } diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb index 235dda0dca2c65..6e1316dc07b0c3 100644 --- a/test/ruby/test_array.rb +++ b/test/ruby/test_array.rb @@ -2291,6 +2291,15 @@ def test_combination2 assert_equal(:called, (0..100).to_a.combination(50) { break :called }, "[ruby-core:29240] ... must be yielded even if 100C50 > signed integer") end + def test_combination_clear + bug9939 = '[ruby-core:63149] [Bug #9939]' + assert_separately([], <<-'end;') + 100_000.times {Array.new(1000)} + a = [*0..100] + a.combination(3) {|*,x| a.clear} + end; + end + def test_product2 a = (0..100).to_a assert_raise(RangeError) do diff --git a/version.h b/version.h index 22ed42eaf80548..5e9d05d292526b 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-07-13" -#define RUBY_PATCHLEVEL 172 +#define RUBY_PATCHLEVEL 173 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 7 From 9bc1b8e9a095c7cbf3b4b661dacbd1dbfd4257b2 Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 13 Jul 2014 14:24:26 +0000 Subject: [PATCH 174/343] merge revision(s) r46368,r46371: [Backport #9913] * ext/digest/digest.c (rb_digest_instance_equal): fix #== for non-string arguments. [ruby-core:62967] [Bug #9913] * test/digest/test_digest.rb: add test for above. * ext/digest/digest.c (rb_digest_instance_equal): no need to call `to_s` twice. [Bug #9913] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46809 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 12 ++++++++++++ ext/digest/digest.c | 3 ++- test/digest/test_digest.rb | 3 +++ version.h | 2 +- 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index cd79bdc1a1880f..e91e8175246046 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +Sun Jul 13 23:18:11 2014 Nobuyoshi Nakada + + * ext/digest/digest.c (rb_digest_instance_equal): no need to call + `to_s` twice. [Bug #9913] + +Sun Jul 13 23:18:11 2014 Benoit Daloze + + * ext/digest/digest.c (rb_digest_instance_equal): + fix #== for non-string arguments. [ruby-core:62967] [Bug #9913] + + * test/digest/test_digest.rb: add test for above. + Sun Jul 13 23:10:03 2014 Nobuyoshi Nakada * array.c (yield_indexed_values): extract from permute0(), diff --git a/ext/digest/digest.c b/ext/digest/digest.c index 527d0ed1feb9de..f1592f4725c059 100644 --- a/ext/digest/digest.c +++ b/ext/digest/digest.c @@ -372,7 +372,8 @@ rb_digest_instance_equal(VALUE self, VALUE other) str2 = rb_digest_instance_digest(0, 0, other); } else { str1 = rb_digest_instance_to_s(self); - str2 = other; + str2 = rb_check_string_type(other); + if (NIL_P(str2)) return Qfalse; } /* never blindly assume that subclass methods return strings */ diff --git a/test/digest/test_digest.rb b/test/digest/test_digest.rb index 86f9147428de2f..cf541a4626fd89 100755 --- a/test/digest/test_digest.rb +++ b/test/digest/test_digest.rb @@ -69,6 +69,9 @@ def test_eq assert_equal(md1, md1.clone, self.class::ALGO) + bug9913 = '[ruby-core:62967] [Bug #9913]' + assert_not_equal(md1, nil, bug9913) + md2 = self.class::ALGO.new md2 << "A" diff --git a/version.h b/version.h index 5e9d05d292526b..f480c17b2fca42 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-07-13" -#define RUBY_PATCHLEVEL 173 +#define RUBY_PATCHLEVEL 174 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 7 From 30c0ad5563630200a779d2e9c7e01fae98e94968 Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 13 Jul 2014 14:35:17 +0000 Subject: [PATCH 175/343] merge revision(s) r44516,r46159,r46196: [Backport #8523] test_timeout.rb: shorten waiting times * test/test_timeout.rb (test_timeout): inverted test condition. [Bug #8523] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46810 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ test/ruby/test_thread.rb | 18 ++++++++++++++++++ test/test_timeout.rb | 18 ++++++------------ version.h | 2 +- 4 files changed, 30 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index e91e8175246046..440de8f4321f56 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sun Jul 13 23:28:41 2014 SHIBATA Hiroshi + + * test/test_timeout.rb (test_timeout): inverted test condition. + [Bug #8523] + Sun Jul 13 23:18:11 2014 Nobuyoshi Nakada * ext/digest/digest.c (rb_digest_instance_equal): no need to call diff --git a/test/ruby/test_thread.rb b/test/ruby/test_thread.rb index 110bbdd6dead80..6568b8dfbc3a05 100644 --- a/test/ruby/test_thread.rb +++ b/test/ruby/test_thread.rb @@ -358,6 +358,24 @@ def test_status_and_stop_p c.kill if c end + def test_switch_while_busy_loop + bug1402 = "[ruby-dev:38319] [Bug #1402]" + flag = true + th = Thread.current + waiter = Thread.start { + sleep 0.1 + flag = false + sleep 1 + th.raise(bug1402) + } + assert_nothing_raised(RuntimeError, bug1402) do + nil while flag + end + assert(!flag, bug1402) + ensure + waiter.kill.join + end + def test_safe_level ok = false t = Thread.new do diff --git a/test/test_timeout.rb b/test/test_timeout.rb index e849cc5741282f..e71a09f22ca8d4 100644 --- a/test/test_timeout.rb +++ b/test/test_timeout.rb @@ -6,22 +6,16 @@ class TestTimeout < Test::Unit::TestCase def test_queue q = Queue.new assert_raise(Timeout::Error, "[ruby-dev:32935]") { - timeout(0.1) { q.pop } + timeout(0.01) { q.pop } } end def test_timeout - @flag = true - Thread.start { - sleep 0.1 - @flag = false - } - assert_nothing_raised("[ruby-dev:38319]") do - Timeout.timeout(1) { - nil while @flag + assert_raise(Timeout::Error) do + Timeout.timeout(0.1) { + nil while true } end - assert !@flag, "[ruby-dev:38319]" end def test_cannot_convert_into_time_interval @@ -34,7 +28,7 @@ def test_skip_rescue bug8730 = '[Bug #8730]' e = nil assert_raise_with_message(Timeout::Error, /execution expired/, bug8730) do - timeout 0.1 do + timeout 0.01 do begin sleep 3 rescue Exception => e @@ -48,7 +42,7 @@ def test_rescue_exit exc = Class.new(RuntimeError) e = nil assert_nothing_raised(exc) do - timeout 0.1, exc do + timeout 0.01, exc do begin sleep 3 rescue exc => e diff --git a/version.h b/version.h index f480c17b2fca42..9786a426a7a0e6 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-07-13" -#define RUBY_PATCHLEVEL 174 +#define RUBY_PATCHLEVEL 175 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 7 From f8048f78177a5151ef31f9f0d6176caaface59af Mon Sep 17 00:00:00 2001 From: nagachika Date: Fri, 18 Jul 2014 16:46:45 +0000 Subject: [PATCH 176/343] merge revision(s) r46344: [Backport #9902] * re.c (match_aref): should not ignore name after NUL byte. [ruby-dev:48275] [Bug #9902] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46869 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ re.c | 10 +++------- test/ruby/test_regexp.rb | 16 ++++++++++++++++ version.h | 6 +++--- 4 files changed, 27 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 440de8f4321f56..c9e2caaba6f5ed 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sat Jul 19 01:44:34 2014 Nobuyoshi Nakada + + * re.c (match_aref): should not ignore name after NUL byte. + [ruby-dev:48275] [Bug #9902] + Sun Jul 13 23:28:41 2014 SHIBATA Hiroshi * test/test_timeout.rb (test_timeout): inverted test condition. diff --git a/re.c b/re.c index 49b1a5a9d4b64a..2bd6fe96b8b321 100644 --- a/re.c +++ b/re.c @@ -1754,17 +1754,13 @@ match_aref(int argc, VALUE *argv, VALUE match) switch (TYPE(idx)) { case T_SYMBOL: - p = rb_id2name(SYM2ID(idx)); - goto name_to_backref; - break; + idx = rb_id2str(SYM2ID(idx)); + /* fall through */ case T_STRING: p = StringValuePtr(idx); - - name_to_backref: num = name_to_backref_number(RMATCH_REGS(match), - RMATCH(match)->regexp, p, p + strlen(p)); + RMATCH(match)->regexp, p, p + RSTRING_LEN(idx)); return rb_reg_nth_match(num, match); - break; default: break; diff --git a/test/ruby/test_regexp.rb b/test/ruby/test_regexp.rb index cff2bb6d1f5707..b4b29a6368b929 100644 --- a/test/ruby/test_regexp.rb +++ b/test/ruby/test_regexp.rb @@ -142,6 +142,22 @@ def test_named_capture assert_equal("fbazo", s) end + def test_named_capture_with_nul + bug9902 = '[ruby-dev:48275] [Bug #9902]' + + m = /(?.*)/.match("foo") + assert_raise(IndexError, bug9902) {m["a\0foo"]} + assert_raise(IndexError, bug9902) {m["a\0foo".to_sym]} + + m = Regexp.new("(?.*)").match("xxx") + assert_raise(IndexError, bug9902) {m["foo"]} + assert_raise(IndexError, bug9902) {m["foo".to_sym]} + assert_nothing_raised(IndexError, bug9902) { + assert_equal("xxx", m["foo\0bar"], bug9902) + assert_equal("xxx", m["foo\0bar".to_sym], bug9902) + } + end + def test_assign_named_capture assert_equal("a", eval('/(?.)/ =~ "a"; foo')) assert_equal("a", eval('foo = 1; /(?.)/ =~ "a"; foo')) diff --git a/version.h b/version.h index 9786a426a7a0e6..06a8b6944dd0fe 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.2" -#define RUBY_RELEASE_DATE "2014-07-13" -#define RUBY_PATCHLEVEL 175 +#define RUBY_RELEASE_DATE "2014-07-19" +#define RUBY_PATCHLEVEL 176 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 7 -#define RUBY_RELEASE_DAY 13 +#define RUBY_RELEASE_DAY 19 #include "ruby/version.h" From a5b229bebffbefd39e8a9071cf3e00ed0a9f601f Mon Sep 17 00:00:00 2001 From: nagachika Date: Wed, 23 Jul 2014 13:29:52 +0000 Subject: [PATCH 177/343] merge revision(s) r46899,r46903,r46904: split assertions into algorithms CentOS 7 seems finish MD5 support http://chkbuild005.hsbt.org/chkbuild/ruby-trunk/log/20140722T140010Z.fail.html.gz git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46908 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ test/openssl/test_x509cert.rb | 31 +++++++++++++++++++------------ test/openssl/test_x509req.rb | 30 +++++++++++++++++++----------- version.h | 6 +++--- 4 files changed, 49 insertions(+), 26 deletions(-) diff --git a/ChangeLog b/ChangeLog index c9e2caaba6f5ed..9fff7157b5c4ca 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Wed Jul 23 22:24:26 2014 CHIKANAGA Tomoyuki + + * test/openssl/test_x509cert.rb: split assertions into algorithms. + CentOS 7 seems finish MD5 support + http://chkbuild005.hsbt.org/chkbuild/ruby-trunk/log/20140722T140010Z.fail.html.gz + + * test/openssl/test_x509req.rb: ditto. + Sat Jul 19 01:44:34 2014 Nobuyoshi Nakada * re.c (match_aref): should not ignore name after NUL byte. diff --git a/test/openssl/test_x509cert.rb b/test/openssl/test_x509cert.rb index dd5751eb48b54b..a1922a10499dda 100644 --- a/test/openssl/test_x509cert.rb +++ b/test/openssl/test_x509cert.rb @@ -125,7 +125,7 @@ def test_extension end - def test_sign_and_verify + def test_sign_and_verify_rsa_sha1 cert = issue_cert(@ca, @rsa2048, 1, Time.now, Time.now+3600, [], nil, nil, OpenSSL::Digest::SHA1.new) assert_equal(false, cert.verify(@rsa1024)) @@ -134,7 +134,9 @@ def test_sign_and_verify assert_equal(false, certificate_error_returns_false { cert.verify(@dsa512) }) cert.serial = 2 assert_equal(false, cert.verify(@rsa2048)) + end + def test_sign_and_verify_rsa_md5 cert = issue_cert(@ca, @rsa2048, 1, Time.now, Time.now+3600, [], nil, nil, OpenSSL::Digest::MD5.new) assert_equal(false, cert.verify(@rsa1024)) @@ -144,7 +146,10 @@ def test_sign_and_verify assert_equal(false, certificate_error_returns_false { cert.verify(@dsa512) }) cert.subject = @ee1 assert_equal(false, cert.verify(@rsa2048)) + rescue OpenSSL::X509::CertificateError # RHEL7 disables MD5 + end + def test_sign_and_verify_dsa cert = issue_cert(@ca, @dsa512, 1, Time.now, Time.now+3600, [], nil, nil, OpenSSL::TestUtils::DSA_SIGNATURE_DIGEST.new) assert_equal(false, certificate_error_returns_false { cert.verify(@rsa1024) }) @@ -153,19 +158,21 @@ def test_sign_and_verify assert_equal(true, cert.verify(@dsa512)) cert.not_after = Time.now assert_equal(false, cert.verify(@dsa512)) + end - begin - cert = issue_cert(@ca, @rsa2048, 1, Time.now, Time.now+3600, [], - nil, nil, OpenSSL::Digest::DSS1.new) - assert_equal(false, cert.verify(@rsa1024)) - assert_equal(true, cert.verify(@rsa2048)) - assert_equal(false, certificate_error_returns_false { cert.verify(@dsa256) }) - assert_equal(false, certificate_error_returns_false { cert.verify(@dsa512) }) - cert.subject = @ee1 - assert_equal(false, cert.verify(@rsa2048)) - rescue OpenSSL::X509::CertificateError - end + def test_sign_and_verify_rsa_dss1 + cert = issue_cert(@ca, @rsa2048, 1, Time.now, Time.now+3600, [], + nil, nil, OpenSSL::Digest::DSS1.new) + assert_equal(false, cert.verify(@rsa1024)) + assert_equal(true, cert.verify(@rsa2048)) + assert_equal(false, certificate_error_returns_false { cert.verify(@dsa256) }) + assert_equal(false, certificate_error_returns_false { cert.verify(@dsa512) }) + cert.subject = @ee1 + assert_equal(false, cert.verify(@rsa2048)) + rescue OpenSSL::X509::CertificateError + end + def test_sign_and_verify_dsa_md5 assert_raise(OpenSSL::X509::CertificateError){ issue_cert(@ca, @dsa512, 1, Time.now, Time.now+3600, [], nil, nil, OpenSSL::Digest::MD5.new) diff --git a/test/openssl/test_x509req.rb b/test/openssl/test_x509req.rb index e6c89c5e817eb2..d0b6a5725dda45 100644 --- a/test/openssl/test_x509req.rb +++ b/test/openssl/test_x509req.rb @@ -98,7 +98,7 @@ def test_attr assert_equal(exts, get_ext_req(attrs[1].value)) end - def test_sign_and_verify + def test_sign_and_verify_rsa_sha1 req = issue_csr(0, @dn, @rsa1024, OpenSSL::Digest::SHA1.new) assert_equal(true, req.verify(@rsa1024)) assert_equal(false, req.verify(@rsa2048)) @@ -106,7 +106,9 @@ def test_sign_and_verify assert_equal(false, request_error_returns_false { req.verify(@dsa512) }) req.version = 1 assert_equal(false, req.verify(@rsa1024)) + end + def test_sign_and_verify_rsa_md5 req = issue_csr(0, @dn, @rsa2048, OpenSSL::Digest::MD5.new) assert_equal(false, req.verify(@rsa1024)) assert_equal(true, req.verify(@rsa2048)) @@ -114,7 +116,10 @@ def test_sign_and_verify assert_equal(false, request_error_returns_false { req.verify(@dsa512) }) req.subject = OpenSSL::X509::Name.parse("/C=JP/CN=FooBar") assert_equal(false, req.verify(@rsa2048)) + rescue OpenSSL::X509::RequestError # RHEL7 disables MD5 + end + def test_sign_and_verify_dsa req = issue_csr(0, @dn, @dsa512, OpenSSL::TestUtils::DSA_SIGNATURE_DIGEST.new) assert_equal(false, request_error_returns_false { req.verify(@rsa1024) }) assert_equal(false, request_error_returns_false { req.verify(@rsa2048) }) @@ -122,18 +127,21 @@ def test_sign_and_verify assert_equal(true, req.verify(@dsa512)) req.public_key = @rsa1024.public_key assert_equal(false, req.verify(@dsa512)) + end - begin - req = issue_csr(0, @dn, @rsa1024, OpenSSL::Digest::DSS1.new) - assert_equal(true, req.verify(@rsa1024)) - assert_equal(false, req.verify(@rsa2048)) - assert_equal(false, request_error_returns_false { req.verify(@dsa256) }) - assert_equal(false, request_error_returns_false { req.verify(@dsa512) }) - req.version = 1 - assert_equal(false, req.verify(@rsa1024)) - rescue OpenSSL::X509::RequestError - end + def test_sign_and_verify_rsa_dss1 + req = issue_csr(0, @dn, @rsa1024, OpenSSL::Digest::DSS1.new) + assert_equal(true, req.verify(@rsa1024)) + assert_equal(false, req.verify(@rsa2048)) + assert_equal(false, request_error_returns_false { req.verify(@dsa256) }) + assert_equal(false, request_error_returns_false { req.verify(@dsa512) }) + req.version = 1 + assert_equal(false, req.verify(@rsa1024)) + rescue OpenSSL::X509::RequestError + skip + end + def test_sign_and_verify_dsa_md5 assert_raise(OpenSSL::X509::RequestError){ issue_csr(0, @dn, @dsa512, OpenSSL::Digest::MD5.new) } end diff --git a/version.h b/version.h index 06a8b6944dd0fe..846284466a0ee2 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.2" -#define RUBY_RELEASE_DATE "2014-07-19" -#define RUBY_PATCHLEVEL 176 +#define RUBY_RELEASE_DATE "2014-07-23" +#define RUBY_PATCHLEVEL 177 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 7 -#define RUBY_RELEASE_DAY 19 +#define RUBY_RELEASE_DAY 23 #include "ruby/version.h" From 61754d1a6a1a2db2c74d15df99913ecca77d8a22 Mon Sep 17 00:00:00 2001 From: nagachika Date: Wed, 23 Jul 2014 13:44:14 +0000 Subject: [PATCH 178/343] merge revision(s) r45144: [Backport #9544] * lib/resolv.rb (bind_random_port): Rescue EPERM for FreeBSD which security.mac.portacl.port_high is changed. See mac_portacl(4) for details. Reported by Jakub Szafranski. [ruby-core:60917] [Bug #9544] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46909 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ lib/resolv.rb | 4 +++- version.h | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9fff7157b5c4ca..34ddf96cf7e428 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Wed Jul 23 22:43:50 2014 Tanaka Akira + + * lib/resolv.rb (bind_random_port): Rescue EPERM for FreeBSD which + security.mac.portacl.port_high is changed. + See mac_portacl(4) for details. + Reported by Jakub Szafranski. [ruby-core:60917] [Bug #9544] + Wed Jul 23 22:24:26 2014 CHIKANAGA Tomoyuki * test/openssl/test_x509cert.rb: split assertions into algorithms. diff --git a/lib/resolv.rb b/lib/resolv.rb index 6b2fa9d90333e2..60b2d9091c20e8 100644 --- a/lib/resolv.rb +++ b/lib/resolv.rb @@ -653,7 +653,9 @@ def self.bind_random_port(udpsock, bind_host="0.0.0.0") # :nodoc: begin port = rangerand(1024..65535) udpsock.bind(bind_host, port) - rescue Errno::EADDRINUSE, Errno::EACCES + rescue Errno::EADDRINUSE, # POSIX + Errno::EACCES, # SunOS: See PRIV_SYS_NFS in privileges(5) + Errno::EPERM # FreeBSD: security.mac.portacl.port_high is configurable. See mac_portacl(4). retry end end diff --git a/version.h b/version.h index 846284466a0ee2..79ec624e905bc1 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-07-23" -#define RUBY_PATCHLEVEL 177 +#define RUBY_PATCHLEVEL 178 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 7 From b22467dab119d6cef3e295e09fdc36f495914142 Mon Sep 17 00:00:00 2001 From: nagachika Date: Wed, 23 Jul 2014 14:03:41 +0000 Subject: [PATCH 179/343] merge revision(s) r45720: [Backport #9571] * lib/fileutils.rb (rmdir): rescue Errno::EEXIST in addition to ENOTEMPTY (and ENOENT), because SUSv3 describes that "If the directory is not an empty directory, rmdir() shall fail and set errno to [EEXIST] or [ENOTEMPTY]" and Solaris uses EEXIST. [Bug #9571] [ruby-dev:48017] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46910 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ lib/fileutils.rb | 2 +- version.h | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 34ddf96cf7e428..13f8b1b422c7c1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Wed Jul 23 22:51:34 2014 Naohisa Goto + + * lib/fileutils.rb (rmdir): rescue Errno::EEXIST in addition to + ENOTEMPTY (and ENOENT), because SUSv3 describes that "If the + directory is not an empty directory, rmdir() shall fail and set + errno to [EEXIST] or [ENOTEMPTY]" and Solaris uses EEXIST. + [Bug #9571] [ruby-dev:48017] + Wed Jul 23 22:43:50 2014 Tanaka Akira * lib/resolv.rb (bind_random_port): Rescue EPERM for FreeBSD which diff --git a/lib/fileutils.rb b/lib/fileutils.rb index 2491a632a9bc10..99044e2cd63114 100644 --- a/lib/fileutils.rb +++ b/lib/fileutils.rb @@ -277,7 +277,7 @@ def rmdir(list, options = {}) Dir.rmdir(dir) end end - rescue Errno::ENOTEMPTY, Errno::ENOENT + rescue Errno::ENOTEMPTY, Errno::EEXIST, Errno::ENOENT end end end diff --git a/version.h b/version.h index 79ec624e905bc1..8265445e5e7f2c 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-07-23" -#define RUBY_PATCHLEVEL 178 +#define RUBY_PATCHLEVEL 179 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 7 From 5807ff68f594423f9de51c529f66631ef4d9e860 Mon Sep 17 00:00:00 2001 From: nagachika Date: Wed, 23 Jul 2014 14:05:38 +0000 Subject: [PATCH 180/343] merge revision(s) r45827: [Backport #9618] * ext/pathname/lib/pathname.rb (cleanpath_aggressive): make all separators File::SEPARATOR from File::ALT_SEPARATOR. Reported by Daniel Rikowski. Fixed by Nobuyoshi Nakada. [Bug #9618] * ext/pathname/lib/pathname.rb (cleanpath_conservative): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46911 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 9 +++++++++ ext/pathname/lib/pathname.rb | 2 ++ test/pathname/test_pathname.rb | 8 ++++++++ version.h | 2 +- 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 13f8b1b422c7c1..a80f1114ed0e2e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Wed Jul 23 23:05:19 2014 Tanaka Akira + + * ext/pathname/lib/pathname.rb (cleanpath_aggressive): make all + separators File::SEPARATOR from File::ALT_SEPARATOR. + Reported by Daniel Rikowski. + Fixed by Nobuyoshi Nakada. [Bug #9618] + + * ext/pathname/lib/pathname.rb (cleanpath_conservative): ditto. + Wed Jul 23 22:51:34 2014 Naohisa Goto * lib/fileutils.rb (rmdir): rescue Errno::EEXIST in addition to diff --git a/ext/pathname/lib/pathname.rb b/ext/pathname/lib/pathname.rb index 46fa72b7849062..e7e47ceac64d9f 100644 --- a/ext/pathname/lib/pathname.rb +++ b/ext/pathname/lib/pathname.rb @@ -113,6 +113,7 @@ def cleanpath_aggressive # :nodoc: end end end + pre.tr!(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR if /#{SEPARATOR_PAT}/o =~ File.basename(pre) names.shift while names[0] == '..' end @@ -161,6 +162,7 @@ def cleanpath_conservative # :nodoc: pre, base = r names.unshift base if base != '.' end + pre.tr!(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR if /#{SEPARATOR_PAT}/o =~ File.basename(pre) names.shift while names[0] == '..' end diff --git a/test/pathname/test_pathname.rb b/test/pathname/test_pathname.rb index ec9dfa1d592443..c61e613d9b5259 100644 --- a/test/pathname/test_pathname.rb +++ b/test/pathname/test_pathname.rb @@ -88,6 +88,10 @@ def cleanpath_aggressive(path) defassert(:cleanpath_aggressive, '/', '///a/../..') end + if DOSISH + defassert(:cleanpath_aggressive, 'c:/foo/bar', 'c:\\foo\\bar') + end + def cleanpath_conservative(path) Pathname.new(path).cleanpath(true).to_s end @@ -124,6 +128,10 @@ def cleanpath_conservative(path) defassert(:cleanpath_conservative, '/a', '/../.././../a') defassert(:cleanpath_conservative, 'a/b/../../../../c/../d', 'a/b/../../../../c/../d') + if DOSISH + defassert(:cleanpath_conservative, 'c:/foo/bar', 'c:\\foo\\bar') + end + if DOSISH_UNC defassert(:cleanpath_conservative, '//', '//') else diff --git a/version.h b/version.h index 8265445e5e7f2c..89f618f6e2321b 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-07-23" -#define RUBY_PATCHLEVEL 179 +#define RUBY_PATCHLEVEL 180 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 7 From fa2937a16a92fefeba0b40667a4140fc9f3d57fc Mon Sep 17 00:00:00 2001 From: nagachika Date: Wed, 23 Jul 2014 14:49:07 +0000 Subject: [PATCH 181/343] merge revision(s) r45034,r45037: * test/socket/test_addrinfo.rb: remove unused variables. * test/socket/test_nonblock.rb: ditto. * test/socket/test_socket.rb: ditto. * test/socket/test_unix.rb: ditto. * test/testunit/test_parallel.rb: ditto. * test/webrick/test_filehandler.rb: ditto. * test/xmlrpc/test_features.rb: ditto. * test/zlib/test_zlib.rb: ditto. * test/socket/test_socket.rb: unix socket is required by test case. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46912 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 15 +++++++++++++++ test/socket/test_addrinfo.rb | 4 ++-- test/socket/test_nonblock.rb | 13 ++++++------- test/socket/test_socket.rb | 9 ++++----- test/socket/test_unix.rb | 15 +++++++-------- test/testunit/test_parallel.rb | 1 - test/webrick/test_filehandler.rb | 2 -- test/xmlrpc/test_features.rb | 4 ++-- test/zlib/test_zlib.rb | 5 +---- version.h | 2 +- 10 files changed, 38 insertions(+), 32 deletions(-) diff --git a/ChangeLog b/ChangeLog index a80f1114ed0e2e..226c9556878d09 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +Wed Jul 23 23:11:28 2014 SHIBATA Hiroshi + + * test/socket/test_socket.rb: unix socket is required by test case. + +Wed Jul 23 23:11:28 2014 SHIBATA Hiroshi + + * test/socket/test_addrinfo.rb: remove unused variables. + * test/socket/test_nonblock.rb: ditto. + * test/socket/test_socket.rb: ditto. + * test/socket/test_unix.rb: ditto. + * test/testunit/test_parallel.rb: ditto. + * test/webrick/test_filehandler.rb: ditto. + * test/xmlrpc/test_features.rb: ditto. + * test/zlib/test_zlib.rb: ditto. + Wed Jul 23 23:05:19 2014 Tanaka Akira * ext/pathname/lib/pathname.rb (cleanpath_aggressive): make all diff --git a/test/socket/test_addrinfo.rb b/test/socket/test_addrinfo.rb index 5bd7e2ab84b70d..61b889ed26478a 100644 --- a/test/socket/test_addrinfo.rb +++ b/test/socket/test_addrinfo.rb @@ -140,7 +140,7 @@ def test_socket_connect ai = Addrinfo.new(s1.getsockname) s2 = Socket.new(:INET, :STREAM, 0) s2.connect(ai) - s3, sender_addr = s1.accept + s3, _ = s1.accept s2.send("test-socket-connect", 0) assert_equal("test-socket-connect", s3.recv(100)) ensure @@ -166,7 +166,7 @@ def test_socket_connect_nonblock rescue Errno::EISCONN end end - s3, sender_addr = s1.accept + s3, _ = s1.accept s2.send("test-socket-connect-nonblock", 0) assert_equal("test-socket-connect-nonblock", s3.recv(100)) ensure diff --git a/test/socket/test_nonblock.rb b/test/socket/test_nonblock.rb index e395a0ad319814..882e438deb81c0 100644 --- a/test/socket/test_nonblock.rb +++ b/test/socket/test_nonblock.rb @@ -64,8 +64,8 @@ def test_udp_recvfrom_nonblock mesg, inet_addr = u1.recvfrom_nonblock(100) assert_equal(4, inet_addr.length) assert_equal("aaa", mesg) - af, port, host, addr = inet_addr - u2_port, u2_addr = Socket.unpack_sockaddr_in(u2.getsockname) + _, port, _, _ = inet_addr + u2_port, _ = Socket.unpack_sockaddr_in(u2.getsockname) assert_equal(u2_port, port) assert_raise(IO::WaitReadable) { u1.recvfrom_nonblock(100) } u2.send("", 0, u1.getsockname) @@ -111,8 +111,8 @@ def test_socket_recvfrom_nonblock IO.select [s1] mesg, sockaddr = s1.recvfrom_nonblock(100) assert_equal("aaa", mesg) - port, addr = Socket.unpack_sockaddr_in(sockaddr) - s2_port, s2_addr = Socket.unpack_sockaddr_in(s2.getsockname) + port, _ = Socket.unpack_sockaddr_in(sockaddr) + s2_port, _ = Socket.unpack_sockaddr_in(s2.getsockname) assert_equal(s2_port, port) ensure s1.close if s1 @@ -121,7 +121,7 @@ def test_socket_recvfrom_nonblock def tcp_pair serv = TCPServer.new("127.0.0.1", 0) - af, port, host, addr = serv.addr + _, port, _, addr = serv.addr c = TCPSocket.new(addr, port) s = serv.accept if block_given? @@ -268,7 +268,7 @@ def test_recv_nonblock_error def test_connect_nonblock_error serv = TCPServer.new("127.0.0.1", 0) - af, port, host, addr = serv.addr + _, port, _, _ = serv.addr c = Socket.new(:INET, :STREAM) begin c.connect_nonblock(Socket.sockaddr_in(port, "127.0.0.1")) @@ -284,7 +284,6 @@ def test_accept_nonblock_error serv = Socket.new(:INET, :STREAM) serv.bind(Socket.sockaddr_in(0, "127.0.0.1")) serv.listen(5) - port = serv.local_address.ip_port begin s, _ = serv.accept_nonblock rescue Errno::EWOULDBLOCK diff --git a/test/socket/test_socket.rb b/test/socket/test_socket.rb index 5d2d0aee263853..73801811e1e566 100644 --- a/test/socket/test_socket.rb +++ b/test/socket/test_socket.rb @@ -359,7 +359,6 @@ def test_udp_server # Mac OS X may sets IFDISABLED as FreeBSD does ulSIOCGIFFLAGS = 3223349521 ulSIOCGIFINFO_IN6 = 3224398156 - ulSIOCGIFAFLAG_IN6 = 3240126793 ulIFF_POINTOPOINT = 0x10 ulND6_IFF_IFDISABLED = 8 in6_ondireq = ifr_name @@ -403,7 +402,7 @@ def test_udp_server raise "no response from #{ai.inspect} #{nd6options}ping=#{ping_p}" end msg2, addr = s.recvmsg - msg2, remote_address, local_address = Marshal.load(msg2) + msg2, _, _ = Marshal.load(msg2) assert_equal(msg1, msg2) assert_equal(ai.ip_address, addr.ip_address) } @@ -454,7 +453,7 @@ def test_timestamp Addrinfo.udp("127.0.0.1", 0).bind {|s2| s1.setsockopt(:SOCKET, :TIMESTAMP, true) s2.send "a", 0, s1.local_address - msg, addr, rflags, stamp = s1.recvmsg + msg, _, _, stamp = s1.recvmsg assert_equal("a", msg) assert(stamp.cmsg_is?(:SOCKET, :TIMESTAMP)) } @@ -481,7 +480,7 @@ def test_timestampns return end s2.send "a", 0, s1.local_address - msg, addr, rflags, stamp = s1.recvmsg + msg, _, _, stamp = s1.recvmsg assert_equal("a", msg) assert(stamp.cmsg_is?(:SOCKET, :TIMESTAMPNS)) } @@ -503,7 +502,7 @@ def test_bintime Addrinfo.udp("127.0.0.1", 0).bind {|s2| s1.setsockopt(:SOCKET, :BINTIME, true) s2.send "a", 0, s1.local_address - msg, addr, rflags, stamp = s1.recvmsg + msg, _, _, stamp = s1.recvmsg assert_equal("a", msg) assert(stamp.cmsg_is?(:SOCKET, :BINTIME)) } diff --git a/test/socket/test_unix.rb b/test/socket/test_unix.rb index f10c5efaf84018..a6879bbfe4b28c 100644 --- a/test/socket/test_unix.rb +++ b/test/socket/test_unix.rb @@ -53,7 +53,7 @@ def test_fd_passing_n end assert_equal(1, ret) ret = s2.recvmsg(:scm_rights=>true) - data, srcaddr, flags, *ctls = ret + _, _, _, *ctls = ret recv_io_ary = [] ctls.each {|ctl| next if ctl.level != Socket::SOL_SOCKET || ctl.type != Socket::SCM_RIGHTS @@ -90,7 +90,7 @@ def test_fd_passing_n2 end assert_equal(1, ret) ret = s2.recvmsg(:scm_rights=>true) - data, srcaddr, flags, *ctls = ret + _, _, _, *ctls = ret recv_io_ary = [] ctls.each {|ctl| next if ctl.level != Socket::SOL_SOCKET || ctl.type != Socket::SCM_RIGHTS @@ -422,7 +422,6 @@ def test_unix_socket_pair_with_block end def test_unix_socket_pair_close_on_exec - pair = nil UNIXSocket.pair {|s1, s2| assert(s1.close_on_exec?) assert(s2.close_on_exec?) @@ -465,7 +464,7 @@ def test_getcred_ucred Dir.mktmpdir {|d| sockpath = "#{d}/sock" serv = Socket.unix_server_socket(sockpath) - c = Socket.unix(sockpath) + Socket.unix(sockpath) s, = serv.accept cred = s.getsockopt(:SOCKET, :PEERCRED) inspect = cred.inspect @@ -481,7 +480,7 @@ def test_getcred_xucred Dir.mktmpdir {|d| sockpath = "#{d}/sock" serv = Socket.unix_server_socket(sockpath) - c = Socket.unix(sockpath) + Socket.unix(sockpath) s, = serv.accept cred = s.getsockopt(0, Socket::LOCAL_PEERCRED) inspect = cred.inspect @@ -499,7 +498,7 @@ def test_sendcred_ucred s, = serv.accept s.setsockopt(:SOCKET, :PASSCRED, 1) c.print "a" - msg, cliend_ai, rflags, cred = s.recvmsg + msg, _, _, cred = s.recvmsg inspect = cred.inspect assert_equal("a", msg) assert_match(/ pid=#{$$} /, inspect) @@ -518,7 +517,7 @@ def test_sendcred_sockcred s, = serv.accept s.setsockopt(0, Socket::LOCAL_CREDS, 1) c.print "a" - msg, cliend_ai, rflags, cred = s.recvmsg + msg, _, _, cred = s.recvmsg assert_equal("a", msg) inspect = cred.inspect assert_match(/ uid=#{Process.uid} /, inspect) @@ -537,7 +536,7 @@ def test_sendcred_cmsgcred c = Socket.unix(sockpath) s, = serv.accept c.sendmsg("a", 0, nil, [:SOCKET, Socket::SCM_CREDS, ""]) - msg, cliend_ai, rflags, cred = s.recvmsg + msg, _, _, cred = s.recvmsg assert_equal("a", msg) inspect = cred.inspect assert_match(/ pid=#{$$} /, inspect) diff --git a/test/testunit/test_parallel.rb b/test/testunit/test_parallel.rb index 7dce42f0a94564..f1b903beef73d1 100644 --- a/test/testunit/test_parallel.rb +++ b/test/testunit/test_parallel.rb @@ -90,7 +90,6 @@ def test_p def test_done timeout(10) do @worker_in.puts "run #{TESTS}/ptest_forth.rb test" - i = 0 6.times { @worker_out.gets } buf = @worker_out.gets assert_match(/^done (.+?)$/, buf) diff --git a/test/webrick/test_filehandler.rb b/test/webrick/test_filehandler.rb index 5b96223da80851..10b6add1474d1b 100644 --- a/test/webrick/test_filehandler.rb +++ b/test/webrick/test_filehandler.rb @@ -184,7 +184,6 @@ def test_non_disclosure_name def test_directory_traversal config = { :DocumentRoot => File.dirname(__FILE__), } - this_file = File.basename(__FILE__) TestWEBrick.start_httpserver(config) do |server, addr, port, log| http = Net::HTTP.new(addr, port) req = Net::HTTP::Get.new("/../../") @@ -199,7 +198,6 @@ def test_directory_traversal def test_unwise_in_path if windows? config = { :DocumentRoot => File.dirname(__FILE__), } - this_file = File.basename(__FILE__) TestWEBrick.start_httpserver(config) do |server, addr, port, log| http = Net::HTTP.new(addr, port) req = Net::HTTP::Get.new("/..%5c..") diff --git a/test/xmlrpc/test_features.rb b/test/xmlrpc/test_features.rb index 89c91f2afe42fa..48bb0d4c2154fe 100644 --- a/test/xmlrpc/test_features.rb +++ b/test/xmlrpc/test_features.rb @@ -16,11 +16,11 @@ def test_nil_create XMLRPC::Config.module_eval {remove_const(:ENABLE_NIL_CREATE)} XMLRPC::Config.const_set(:ENABLE_NIL_CREATE, false) - assert_raise(RuntimeError) { str = c.methodCall("test", *@params) } + assert_raise(RuntimeError) { c.methodCall("test", *@params) } XMLRPC::Config.module_eval {remove_const(:ENABLE_NIL_CREATE)} XMLRPC::Config.const_set(:ENABLE_NIL_CREATE, true) - assert_nothing_raised { str = c.methodCall("test", *@params) } + assert_nothing_raised { c.methodCall("test", *@params) } end end diff --git a/test/zlib/test_zlib.rb b/test/zlib/test_zlib.rb index 3122e7769ef7b2..5dd5bcf51d1a65 100644 --- a/test/zlib/test_zlib.rb +++ b/test/zlib/test_zlib.rb @@ -162,7 +162,7 @@ def test_closed_p assert_equal(false, z.closed?) z << "foo" assert_equal(false, z.closed?) - s = z.finish + z.finish assert_equal(false, z.closed?) z.close assert_equal(true, z.closed?) @@ -309,9 +309,6 @@ def test_inflate def test_inflate_partial_input deflated = Zlib::Deflate.deflate "\0" - a = deflated[0...2] - b = deflated[2..-1] - z = Zlib::Inflate.new inflated = "" diff --git a/version.h b/version.h index 89f618f6e2321b..5c22b0d76378d5 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-07-23" -#define RUBY_PATCHLEVEL 180 +#define RUBY_PATCHLEVEL 181 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 7 From 3eb0620c2a901b12e6fb752fd1ae668ed8f2b918 Mon Sep 17 00:00:00 2001 From: nagachika Date: Wed, 23 Jul 2014 14:53:36 +0000 Subject: [PATCH 182/343] merge revision(s) r45953,r45961: [Backport #9767] * lib/test/unit/parallel.rb: fix test-all parallel failure if a test is skipped after raise. DL::TestFunc#test_sinf is skipped after raise on mingw ruby. But it causes Mashal.load failure due to undefined class/module DL::DLError when doing test-all parallel and test-all doesn't complete. We create new MiniTest::Skip object to avoid Mashal.load failure. [ruby-core:62133] [Bug #9767] * test/testunit/test_parallel.rb (TestParallel): add a test. * test/testunit/tests_for_parallel/ptest_forth.rb: ditto. But it causes Marshal.load failure due to undefined class/module complete. We create new MiniTest::Skip object to avoid Marshal.load git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46916 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 15 +++++++++++++++ lib/test/unit/parallel.rb | 5 +++++ test/testunit/test_parallel.rb | 9 +++++---- test/testunit/tests_for_parallel/ptest_forth.rb | 8 ++++++++ version.h | 2 +- 5 files changed, 34 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 226c9556878d09..036e770ba3ca34 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +Wed Jul 23 23:49:59 2014 Hiroshi Shirosaki + + * lib/test/unit/parallel.rb: fix test-all parallel failure if a test + is skipped after raise. + DL::TestFunc#test_sinf is skipped after raise on mingw ruby. + But it causes Marshal.load failure due to undefined class/module + DL::DLError when doing test-all parallel and test-all doesn't + complete. We create new MiniTest::Skip object to avoid Marshal.load + failure. + [ruby-core:62133] [Bug #9767] + + * test/testunit/test_parallel.rb (TestParallel): add a test. + + * test/testunit/tests_for_parallel/ptest_forth.rb: ditto. + Wed Jul 23 23:11:28 2014 SHIBATA Hiroshi * test/socket/test_socket.rb: unix socket is required by test case. diff --git a/lib/test/unit/parallel.rb b/lib/test/unit/parallel.rb index c1ecf292632e9b..92cc7ec44b6559 100644 --- a/lib/test/unit/parallel.rb +++ b/lib/test/unit/parallel.rb @@ -155,6 +155,11 @@ def _report(res, *args) # :nodoc: end def puke(klass, meth, e) # :nodoc: + if e.is_a?(MiniTest::Skip) + new_e = MiniTest::Skip.new(e.message) + new_e.set_backtrace(e.backtrace) + e = new_e + end @partial_report << [klass.name, meth, e.is_a?(MiniTest::Assertion) ? e : ProxyError.new(e)] super end diff --git a/test/testunit/test_parallel.rb b/test/testunit/test_parallel.rb index f1b903beef73d1..6276aac8bd0204 100644 --- a/test/testunit/test_parallel.rb +++ b/test/testunit/test_parallel.rb @@ -90,7 +90,7 @@ def test_p def test_done timeout(10) do @worker_in.puts "run #{TESTS}/ptest_forth.rb test" - 6.times { @worker_out.gets } + 7.times { @worker_out.gets } buf = @worker_out.gets assert_match(/^done (.+?)$/, buf) @@ -98,7 +98,7 @@ def test_done result = Marshal.load($1.chomp.unpack("m")[0]) - assert_equal(4, result[0]) + assert_equal(5, result[0]) assert_equal(2, result[1]) assert_kind_of(Array,result[2]) assert_kind_of(Array,result[3]) @@ -106,7 +106,8 @@ def test_done assert_kind_of(Array,result[2][1]) assert_kind_of(MiniTest::Assertion,result[2][0][2]) assert_kind_of(MiniTest::Skip,result[2][1][2]) - assert_kind_of(Exception, result[2][2][2]) + assert_kind_of(MiniTest::Skip,result[2][2][2]) + assert_kind_of(Exception, result[2][3][2]) assert_equal(result[5], "TestE") end end @@ -156,7 +157,7 @@ def test_ignore_jzero def test_should_run_all_without_any_leaks spawn_runner buf = timeout(10){@test_out.read} - assert_match(/^[SFE\.]{8}$/,buf) + assert_match(/^[SFE\.]{9}$/,buf) end def test_should_retry_failed_on_workers diff --git a/test/testunit/tests_for_parallel/ptest_forth.rb b/test/testunit/tests_for_parallel/ptest_forth.rb index ad5a7f34ce8ea5..46c88da5191a1e 100644 --- a/test/testunit/tests_for_parallel/ptest_forth.rb +++ b/test/testunit/tests_for_parallel/ptest_forth.rb @@ -15,6 +15,14 @@ def test_always_fail assert_equal(0,1) end + def test_skip_after_unknown_error + begin + raise UnknownError, "unknown error" + rescue + skip "after raise" + end + end + def test_unknown_error raise UnknownError, "unknown error" end diff --git a/version.h b/version.h index 5c22b0d76378d5..bb82cc0620081b 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-07-23" -#define RUBY_PATCHLEVEL 181 +#define RUBY_PATCHLEVEL 182 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 7 From cd1f00780b2a412dcb01fcd5abd46df3a547e788 Mon Sep 17 00:00:00 2001 From: nagachika Date: Wed, 30 Jul 2014 15:52:15 +0000 Subject: [PATCH 183/343] merge revision(s) r46419,r46429: [Backport #9940] * vm_trace.c: clear and restore recursive checking thread local data to avoid unexpected throw from TracePoint. [Bug #9940] * test/ruby/test_settracefunc.rb: add a test. * thread.c: adde * rb_threadptr_reset_recursive_data(rb_thread_t *th); * rb_threadptr_restore_recursive_data(rb_thread_t *th, VALUE old); * vm_core.h: ditto. * thread.c: added git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47009 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 14 ++++++++ test/ruby/test_settracefunc.rb | 12 +++++++ thread.c | 58 ++++++++++++++++++++++++---------- version.h | 6 ++-- vm_core.h | 3 ++ vm_trace.c | 2 ++ 6 files changed, 76 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index 036e770ba3ca34..638ec8575ecf50 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +Thu Jul 31 00:44:34 2014 Koichi Sasada + + * vm_trace.c: clear and restore recursive checking thread local data + to avoid unexpected throw from TracePoint. + [Bug #9940] + + * test/ruby/test_settracefunc.rb: add a test. + + * thread.c: added + * rb_threadptr_reset_recursive_data(rb_thread_t *th); + * rb_threadptr_restore_recursive_data(rb_thread_t *th, VALUE old); + + * vm_core.h: ditto. + Wed Jul 23 23:49:59 2014 Hiroshi Shirosaki * lib/test/unit/parallel.rb: fix test-all parallel failure if a test diff --git a/test/ruby/test_settracefunc.rb b/test/ruby/test_settracefunc.rb index 79f315edd5e1ed..818cf0f0b561eb 100644 --- a/test/ruby/test_settracefunc.rb +++ b/test/ruby/test_settracefunc.rb @@ -1182,6 +1182,18 @@ def test_define_method_on_exception assert_equal([['call', :foo], ['return', :foo]], events, 'Bug #9759') ensure end + end + def test_recursive + assert_ruby_status [], %q{ + stack = [] + TracePoint.new(:c_call){|tp| + p 2 + stack << tp.method_id + }.enable{ + p 1 + } + raise if stack != [:p, :hash, :inspect] + }, '[Bug #9940]' end end diff --git a/thread.c b/thread.c index f3e60fce41033e..b51698fc24f899 100644 --- a/thread.c +++ b/thread.c @@ -2746,22 +2746,25 @@ rb_thread_inspect(VALUE thread) return str; } -VALUE -rb_thread_local_aref(VALUE thread, ID id) +static VALUE +threadptr_local_aref(rb_thread_t *th, ID id) { - rb_thread_t *th; st_data_t val; - GetThreadPtr(thread, th); - if (!th->local_storage) { - return Qnil; - } - if (st_lookup(th->local_storage, id, &val)) { + if (th->local_storage && st_lookup(th->local_storage, id, &val)) { return (VALUE)val; } return Qnil; } +VALUE +rb_thread_local_aref(VALUE thread, ID id) +{ + rb_thread_t *th; + GetThreadPtr(thread, th); + return threadptr_local_aref(th, id); +} + /* * call-seq: * thr[sym] -> obj or nil @@ -2830,26 +2833,35 @@ rb_thread_aref(VALUE thread, VALUE key) return rb_thread_local_aref(thread, id); } -VALUE -rb_thread_local_aset(VALUE thread, ID id, VALUE val) +static VALUE +threadptr_local_aset(rb_thread_t *th, ID id, VALUE val) { - rb_thread_t *th; - GetThreadPtr(thread, th); - - if (OBJ_FROZEN(thread)) { - rb_error_frozen("thread locals"); - } if (NIL_P(val)) { if (!th->local_storage) return Qnil; st_delete_wrap(th->local_storage, id); return Qnil; } + else { if (!th->local_storage) { th->local_storage = st_init_numtable(); } st_insert(th->local_storage, id, val); return val; } +} + +VALUE +rb_thread_local_aset(VALUE thread, ID id, VALUE val) +{ + rb_thread_t *th; + GetThreadPtr(thread, th); + + if (OBJ_FROZEN(thread)) { + rb_error_frozen("thread locals"); + } + + return threadptr_local_aset(th, id, val); +} /* * call-seq: @@ -4778,6 +4790,20 @@ recursive_list_access(void) return list; } +VALUE +rb_threadptr_reset_recursive_data(rb_thread_t *th) +{ + VALUE old = threadptr_local_aref(th, recursive_key); + threadptr_local_aset(th, recursive_key, Qnil); + return old; +} + +void +rb_threadptr_restore_recursive_data(rb_thread_t *th, VALUE old) +{ + threadptr_local_aset(th, recursive_key, old); +} + /* * Returns Qtrue iff obj_id (or the pair ) is already * in the recursion list. diff --git a/version.h b/version.h index bb82cc0620081b..025a19fc3de81a 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.2" -#define RUBY_RELEASE_DATE "2014-07-23" -#define RUBY_PATCHLEVEL 182 +#define RUBY_RELEASE_DATE "2014-07-31" +#define RUBY_PATCHLEVEL 183 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 7 -#define RUBY_RELEASE_DAY 23 +#define RUBY_RELEASE_DAY 31 #include "ruby/version.h" diff --git a/vm_core.h b/vm_core.h index fbdd57e8fac655..ed6b6a5dc99746 100644 --- a/vm_core.h +++ b/vm_core.h @@ -1032,6 +1032,9 @@ void rb_threadptr_exec_event_hooks_and_pop_frame(struct rb_trace_arg_struct *tra #define EXEC_EVENT_HOOK_AND_POP_FRAME(th_, flag_, self_, id_, klass_, data_) \ EXEC_EVENT_HOOK_ORIG(th_, flag_, self_, id_, klass_, data_, 1) +VALUE rb_threadptr_reset_recursive_data(rb_thread_t *th); +void rb_threadptr_restore_recursive_data(rb_thread_t *th, VALUE old); + RUBY_SYMBOL_EXPORT_BEGIN int rb_thread_check_trap_pending(void); diff --git a/vm_trace.c b/vm_trace.c index 81452997e94c64..2047d5aec8d44e 100644 --- a/vm_trace.c +++ b/vm_trace.c @@ -335,6 +335,7 @@ rb_threadptr_exec_event_hooks_orig(rb_trace_arg_t *trace_arg, int pop_p) trace_arg->self != rb_mRubyVMFrozenCore /* skip special methods. TODO: remove it. */) { const VALUE errinfo = th->errinfo; const int outer_state = th->state; + const VALUE old_recursive = rb_threadptr_reset_recursive_data(th); int state = 0; th->state = 0; th->errinfo = Qnil; @@ -355,6 +356,7 @@ rb_threadptr_exec_event_hooks_orig(rb_trace_arg_t *trace_arg, int pop_p) terminate: th->trace_arg = 0; th->vm->trace_running--; + rb_threadptr_restore_recursive_data(th, old_recursive); if (state) { if (pop_p) { From d22cfb2fdb900cdbc732a3667b5706130905a21c Mon Sep 17 00:00:00 2001 From: nagachika Date: Wed, 30 Jul 2014 16:21:05 +0000 Subject: [PATCH 184/343] merge revision(s) r46463: [Backport #9957] * vm_core.h: add VM_FRAME_MAGIC_RESCUE to recognize normal block or rescue clause. * vm.c (vm_exec): use VM_FRAME_MAGIC_RESCUE on at rescue/ensure. * test/ruby/test_settracefunc.rb: should not invoke b_return at rescue clause. [Bug #9957] * vm_dump.c (control_frame_dump): check VM_FRAME_MAGIC_RESCUE. * vm_dump.c (vm_stack_dump_each): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47012 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 15 ++++++++++++++ test/ruby/test_settracefunc.rb | 36 ++++++++++++++++++++++++++++++++++ version.h | 2 +- vm.c | 3 ++- vm_core.h | 3 ++- vm_dump.c | 15 +++++++++----- 6 files changed, 66 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 638ec8575ecf50..3782c3f7149e29 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +Thu Jul 31 01:12:55 2014 Koichi Sasada + + * vm_core.h: add VM_FRAME_MAGIC_RESCUE to recognize normal block or + rescue clause. + + * vm.c (vm_exec): use VM_FRAME_MAGIC_RESCUE on at rescue/ensure. + + * test/ruby/test_settracefunc.rb: should not invoke b_return at rescue + clause. + [Bug #9957] + + * vm_dump.c (control_frame_dump): check VM_FRAME_MAGIC_RESCUE. + + * vm_dump.c (vm_stack_dump_each): ditto. + Thu Jul 31 00:44:34 2014 Koichi Sasada * vm_trace.c: clear and restore recursive checking thread local data diff --git a/test/ruby/test_settracefunc.rb b/test/ruby/test_settracefunc.rb index 818cf0f0b561eb..cee9029304ae35 100644 --- a/test/ruby/test_settracefunc.rb +++ b/test/ruby/test_settracefunc.rb @@ -1196,4 +1196,40 @@ def test_recursive raise if stack != [:p, :hash, :inspect] }, '[Bug #9940]' end + + def method_test_rescue_should_not_cause_b_return + begin + raise + rescue + return + end + end + + def method_test_ensure_should_not_cause_b_return + begin + raise + ensure + return + end + end + + def test_rescue_and_ensure_should_not_cause_b_return + curr_thread = Thread.current + trace = TracePoint.new(:b_call, :b_return){ + next if curr_thread != Thread.current + flunk("Should not reach here because there is no block.") + } + + begin + trace.enable + method_test_rescue_should_not_cause_b_return + begin + method_test_ensure_should_not_cause_b_return + rescue + # ignore + end + ensure + trace.disable + end + end end diff --git a/version.h b/version.h index 025a19fc3de81a..6c888dbf657106 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-07-31" -#define RUBY_PATCHLEVEL 183 +#define RUBY_PATCHLEVEL 184 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 7 diff --git a/vm.c b/vm.c index e8e2257e67156b..38c346ffda0abb 100644 --- a/vm.c +++ b/vm.c @@ -1214,6 +1214,7 @@ vm_frametype_name(const rb_control_frame_t *cfp) case VM_FRAME_MAGIC_IFUNC: return "ifunc"; case VM_FRAME_MAGIC_EVAL: return "eval"; case VM_FRAME_MAGIC_LAMBDA: return "lambda"; + case VM_FRAME_MAGIC_RESCUE: return "rescue"; default: rb_bug("unknown frame"); } @@ -1518,7 +1519,7 @@ vm_exec(rb_thread_t *th) /* push block frame */ cfp->sp[0] = err; - vm_push_frame(th, catch_iseq, VM_FRAME_MAGIC_BLOCK, + vm_push_frame(th, catch_iseq, VM_FRAME_MAGIC_RESCUE, cfp->self, cfp->klass, VM_ENVVAL_PREV_EP_PTR(cfp->ep), catch_iseq->iseq_encoded, diff --git a/vm_core.h b/vm_core.h index ed6b6a5dc99746..286c9ab054845b 100644 --- a/vm_core.h +++ b/vm_core.h @@ -764,7 +764,8 @@ enum vm_special_object_type { #define VM_FRAME_MAGIC_IFUNC 0x81 #define VM_FRAME_MAGIC_EVAL 0x91 #define VM_FRAME_MAGIC_LAMBDA 0xa1 -#define VM_FRAME_MAGIC_MASK_BITS 8 +#define VM_FRAME_MAGIC_RESCUE 0xb1 +#define VM_FRAME_MAGIC_MASK_BITS 8 #define VM_FRAME_MAGIC_MASK (~(~0<flag & VM_FRAME_MAGIC_MASK) diff --git a/vm_dump.c b/vm_dump.c index f691e5afeae1fd..6caea9f5a57012 100644 --- a/vm_dump.c +++ b/vm_dump.c @@ -73,6 +73,9 @@ control_frame_dump(rb_thread_t *th, rb_control_frame_t *cfp) case VM_FRAME_MAGIC_EVAL: magic = "EVAL"; break; + case VM_FRAME_MAGIC_RESCUE: + magic = "RESCUE"; + break; case 0: magic = "------"; break; @@ -268,15 +271,17 @@ vm_stack_dump_each(rb_thread_t *th, rb_control_frame_t *cfp) /* stack trace header */ - if (VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_METHOD || - VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_TOP || + if (VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_METHOD|| + VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_TOP || VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_BLOCK || VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_CLASS || - VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_PROC || - VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_LAMBDA || + VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_PROC || + VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_LAMBDA|| VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_CFUNC || VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_IFUNC || - VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_EVAL) { + VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_EVAL || + VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_RESCUE) + { VALUE *ptr = ep - local_size; From e0c00fccc47fbf473768cc84d808c2de06b1e69f Mon Sep 17 00:00:00 2001 From: nagachika Date: Wed, 30 Jul 2014 16:37:33 +0000 Subject: [PATCH 185/343] merge revision(s) r46464: [Backport #9959] * vm.c (invoke_block_from_c): move call/return event timing for bmethod. It can invoke inconsistent call event if this call raises argument error. [Bug #9959] * vm_insnhelper.c (vm_call_bmethod_body): ditto. * test/ruby/test_settracefunc.rb: add a test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47013 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 11 +++++++++++ test/ruby/test_settracefunc.rb | 21 ++++++++++++++++++++- version.h | 2 +- vm.c | 28 ++++++++++++++++++++-------- vm_insnhelper.c | 6 ------ 5 files changed, 52 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3782c3f7149e29..e97de41aefa330 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +Thu Jul 31 01:22:43 2014 Koichi Sasada + + * vm.c (invoke_block_from_c): move call/return event timing for + bmethod. It can invoke inconsistent call event if this call raises + argument error. + [Bug #9959] + + * vm_insnhelper.c (vm_call_bmethod_body): ditto. + + * test/ruby/test_settracefunc.rb: add a test. + Thu Jul 31 01:12:55 2014 Koichi Sasada * vm_core.h: add VM_FRAME_MAGIC_RESCUE to recognize normal block or diff --git a/test/ruby/test_settracefunc.rb b/test/ruby/test_settracefunc.rb index cee9029304ae35..bcdde708608e73 100644 --- a/test/ruby/test_settracefunc.rb +++ b/test/ruby/test_settracefunc.rb @@ -383,7 +383,7 @@ def test_trace_defined_method [["c-return", 3, :set_trace_func, Kernel], ["line", 6, __method__, self.class], - ["call", 6, :foobar, FooBar], + ["call", 1, :foobar, FooBar], ["return", 6, :foobar, FooBar], ["line", 7, __method__, self.class], ["c-call", 7, :set_trace_func, Kernel]].each{|e| @@ -1232,4 +1232,23 @@ def test_rescue_and_ensure_should_not_cause_b_return trace.disable end end + + define_method(:method_test_argument_error_on_bmethod){|correct_key: 1|} + + def test_argument_error_on_bmethod + events = [] + curr_thread = Thread.current + TracePoint.new(:call, :return){|tp| + next if curr_thread != Thread.current + events << [tp.event, tp.method_id] + }.enable do + begin + method_test_argument_error_on_bmethod(wrong_key: 2) + rescue => e + # ignore + end + end + + assert_equal [], events # should be empty. + end end diff --git a/version.h b/version.h index 6c888dbf657106..2b2d7fd5fde8a9 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-07-31" -#define RUBY_PATCHLEVEL 184 +#define RUBY_PATCHLEVEL 185 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 7 diff --git a/vm.c b/vm.c index 38c346ffda0abb..922140e7f8bfc9 100644 --- a/vm.c +++ b/vm.c @@ -717,15 +717,17 @@ invoke_block_from_c(rb_thread_t *th, const rb_block_t *block, const rb_block_t *blockptr, const NODE *cref, VALUE defined_class) { - if (SPECIAL_CONST_P(block->iseq)) + if (SPECIAL_CONST_P(block->iseq)) { return Qnil; + } else if (BUILTIN_TYPE(block->iseq) != T_NODE) { + VALUE ret; const rb_iseq_t *iseq = block->iseq; const rb_control_frame_t *cfp; int i, opt_pc, arg_size = iseq->arg_size; - int type = block_proc_is_lambda(block->proc) ? - VM_FRAME_MAGIC_LAMBDA : VM_FRAME_MAGIC_BLOCK; - + int type = block_proc_is_lambda(block->proc) ? VM_FRAME_MAGIC_LAMBDA : VM_FRAME_MAGIC_BLOCK; + const rb_method_entry_t *me = th->passed_bmethod_me; + th->passed_bmethod_me = 0; cfp = th->cfp; for (i=0; isp, blockptr, type == VM_FRAME_MAGIC_LAMBDA); - if (th->passed_bmethod_me != 0) { + if (me != 0) { /* bmethod */ vm_push_frame(th, iseq, type | VM_FRAME_FLAG_FINISH | VM_FRAME_FLAG_BMETHOD, self, defined_class, VM_ENVVAL_PREV_EP_PTR(block->ep), iseq->iseq_encoded + opt_pc, cfp->sp + arg_size, iseq->local_size - arg_size, - th->passed_bmethod_me, iseq->stack_max); - th->passed_bmethod_me = 0; + me, iseq->stack_max); + + RUBY_DTRACE_METHOD_ENTRY_HOOK(th, me->klass, me->called_id); + EXEC_EVENT_HOOK(th, RUBY_EVENT_CALL, self, me->called_id, me->klass, Qnil); } else { vm_push_frame(th, iseq, type | VM_FRAME_FLAG_FINISH, @@ -758,7 +762,15 @@ invoke_block_from_c(rb_thread_t *th, const rb_block_t *block, th->cfp->ep[-1] = (VALUE)cref; } - return vm_exec(th); + ret = vm_exec(th); + + if (me) { + /* bmethod */ + EXEC_EVENT_HOOK(th, RUBY_EVENT_RETURN, self, me->called_id, me->klass, ret); + RUBY_DTRACE_METHOD_RETURN_HOOK(th, me->klass, me->called_id); + } + + return ret; } else { return vm_yield_with_cfunc(th, block, self, argc, argv, blockptr); diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 9e1dbe16a93cc1..c9c91b0fc76b58 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -1593,17 +1593,11 @@ vm_call_bmethod_body(rb_thread_t *th, rb_call_info_t *ci, const VALUE *argv) rb_proc_t *proc; VALUE val; - RUBY_DTRACE_METHOD_ENTRY_HOOK(th, ci->me->klass, ci->me->called_id); - EXEC_EVENT_HOOK(th, RUBY_EVENT_CALL, ci->recv, ci->me->called_id, ci->me->klass, Qnil); - /* control block frame */ th->passed_bmethod_me = ci->me; GetProcPtr(ci->me->def->body.proc, proc); val = vm_invoke_proc(th, proc, ci->recv, ci->defined_class, ci->argc, argv, ci->blockptr); - EXEC_EVENT_HOOK(th, RUBY_EVENT_RETURN, ci->recv, ci->me->called_id, ci->me->klass, val); - RUBY_DTRACE_METHOD_RETURN_HOOK(th, ci->me->klass, ci->me->called_id); - return val; } From d2c896e07f0c779bb9fe96b61e363929940ab7c1 Mon Sep 17 00:00:00 2001 From: nagachika Date: Wed, 30 Jul 2014 17:05:55 +0000 Subject: [PATCH 186/343] merge revision(s) r46471: [Backport #9964] * compile.c (rb_iseq_compile_node): put start label of block after trace (b_call). [Bug #9964] * test/ruby/test_settracefunc.rb: add a test. added assert_consistent_call_return() method check call/return consistency. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47014 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 11 ++++++++ compile.c | 2 +- test/ruby/test_settracefunc.rb | 48 ++++++++++++++++++++++++++++++++++ version.h | 2 +- 4 files changed, 61 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index e97de41aefa330..a7081f9c656629 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +Thu Jul 31 01:56:11 2014 Koichi Sasada + + * compile.c (rb_iseq_compile_node): put start label of block after + trace (b_call). + [Bug #9964] + + * test/ruby/test_settracefunc.rb: add a test. + + added assert_consistent_call_return() method check call/return + consistency. + Thu Jul 31 01:22:43 2014 Koichi Sasada * vm.c (invoke_block_from_c): move call/return event timing for diff --git a/compile.c b/compile.c index 52656dca8c4b1c..a76c93be73f409 100644 --- a/compile.c +++ b/compile.c @@ -478,8 +478,8 @@ rb_iseq_compile_node(VALUE self, NODE *node) LABEL *start = iseq->compile_data->start_label = NEW_LABEL(0); LABEL *end = iseq->compile_data->end_label = NEW_LABEL(0); - ADD_LABEL(ret, start); ADD_TRACE(ret, FIX2INT(iseq->location.first_lineno), RUBY_EVENT_B_CALL); + ADD_LABEL(ret, start); COMPILE(ret, "block body", node->nd_body); ADD_LABEL(ret, end); ADD_TRACE(ret, nd_line(node), RUBY_EVENT_B_RETURN); diff --git a/test/ruby/test_settracefunc.rb b/test/ruby/test_settracefunc.rb index bcdde708608e73..697b44ccfe0751 100644 --- a/test/ruby/test_settracefunc.rb +++ b/test/ruby/test_settracefunc.rb @@ -1251,4 +1251,52 @@ def test_argument_error_on_bmethod assert_equal [], events # should be empty. end + + def method_prefix event + case event + when :call, :return + :n + when :c_call, :c_return + :c + when :b_call, :b_return + :b + end + end + + def method_label tp + "#{method_prefix(tp.event)}##{tp.method_id}" + end + + def assert_consistent_call_return message='', check_events: nil + check_events ||= %i(a_call a_return) + call_events = [] + return_events = [] + + TracePoint.new(*check_events){|tp| + next unless target_thread? + + case tp.event.to_s + when /call/ + call_events << method_label(tp) + when /return/ + return_events << method_label(tp) + end + }.enable do + yield + end + + assert_equal false, call_events.empty? + assert_equal false, return_events.empty? + assert_equal call_events, return_events.reverse, message + end + + def test_b_call_with_redo + assert_consistent_call_return do + i = 0 + 1.times{ + break if (i+=1) > 10 + redo + } + end + end end diff --git a/version.h b/version.h index 2b2d7fd5fde8a9..d02dd781a34d48 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-07-31" -#define RUBY_PATCHLEVEL 185 +#define RUBY_PATCHLEVEL 186 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 7 From 39da0b90d2bd76974ac080c4b89faf7ef17b7e5e Mon Sep 17 00:00:00 2001 From: nagachika Date: Sat, 2 Aug 2014 15:14:49 +0000 Subject: [PATCH 187/343] merge revision(s) r46649: [Backport #10005] * node.c (dump_node): handle nd_value == (NODE *)-1 to mean this keyword argument is required git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47035 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ node.c | 7 ++++++- version.h | 8 ++++---- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index a7081f9c656629..48d85321a3ce64 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sun Aug 3 00:06:10 2014 Charlie Somerville + + * node.c (dump_node): handle nd_value == (NODE *)-1 to mean this + keyword argument is required + Thu Jul 31 01:56:11 2014 Koichi Sasada * compile.c (rb_iseq_compile_node): put start label of block after diff --git a/node.c b/node.c index 472a959ef954ee..fbefb3cd47faf3 100644 --- a/node.c +++ b/node.c @@ -300,7 +300,12 @@ dump_node(VALUE buf, VALUE indent, int comment, NODE *node) asgn: F_ID(nd_vid, "variable"); LAST_NODE; - F_NODE(nd_value, "rvalue"); + if (node->nd_value == (NODE *)-1) { + F_MSG(nd_value, "rvalue", "(required keyword argument)"); + } + else { + F_NODE(nd_value, "rvalue"); + } break; case NODE_GASGN: diff --git a/version.h b/version.h index d02dd781a34d48..089da87db1dc57 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.2" -#define RUBY_RELEASE_DATE "2014-07-31" -#define RUBY_PATCHLEVEL 186 +#define RUBY_RELEASE_DATE "2014-08-03" +#define RUBY_PATCHLEVEL 187 #define RUBY_RELEASE_YEAR 2014 -#define RUBY_RELEASE_MONTH 7 -#define RUBY_RELEASE_DAY 31 +#define RUBY_RELEASE_MONTH 8 +#define RUBY_RELEASE_DAY 3 #include "ruby/version.h" From 1760861c0d9698a9f73e51c1dd176a6409677271 Mon Sep 17 00:00:00 2001 From: nagachika Date: Sat, 2 Aug 2014 15:25:17 +0000 Subject: [PATCH 188/343] merge revision(s) r44577,r45097,r45330,r45331,r45354,r45356: [Backport #10033] cptr.c: unused variable * ext/dl/cptr.c (rb_dlptr_inspect): remove no longer used variable. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47036 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- bignum.c | 11 +++---- complex.c | 64 ++++----------------------------------- enc/utf_16be.c | 2 ++ enc/utf_16le.c | 2 ++ ext/date/date_core.c | 23 -------------- ext/dl/cptr.c | 1 - ext/json/parser/parser.c | 64 +++++++++++++++++++-------------------- ext/json/parser/prereq.mk | 3 +- gc.c | 4 +-- range.c | 7 ----- rational.c | 36 +--------------------- version.h | 2 +- 12 files changed, 52 insertions(+), 167 deletions(-) diff --git a/bignum.c b/bignum.c index 6c2cda3937692c..b499c0b9730214 100644 --- a/bignum.c +++ b/bignum.c @@ -218,7 +218,7 @@ end */ -#ifdef HAVE_UINT16_T +#if SIZEOF_BDIGIT_DBL == 2 static const int maxpow16_exp[35] = { 15, 10, 7, 6, 6, 5, 5, 5, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, @@ -234,8 +234,7 @@ static const uint16_t maxpow16_num[35] = { U16(0x00006978), U16(0x0000745f), U16(0x00008000), U16(0x00008c61), U16(0x00009988), U16(0x0000a77b), U16(0x0000b640), }; -#endif -#ifdef HAVE_UINT32_T +#elif SIZEOF_BDIGIT_DBL == 4 static const int maxpow32_exp[35] = { 31, 20, 15, 13, 12, 11, 10, 10, 9, 9, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, @@ -251,8 +250,7 @@ static const uint32_t maxpow32_num[35] = { U32(0x2b73a840), U32(0x34e63b41), U32(0x40000000), U32(0x4cfa3cc1), U32(0x5c13d840), U32(0x6d91b519), U32(0x81bf1000), }; -#endif -#ifdef HAVE_UINT64_T +#elif SIZEOF_BDIGIT_DBL == 8 && defined HAVE_UINT64_T static const int maxpow64_exp[35] = { 63, 40, 31, 27, 24, 22, 21, 20, 19, 18, 17, 17, 16, 16, 15, 15, 15, 15, 14, 14, 14, 14, 13, 13, 13, 13, 13, 13, 13, 12, 12, 12, 12, 12, @@ -278,8 +276,7 @@ static const uint64_t maxpow64_num[35] = { U64(0x211e44f7,0xd02c1000), U64(0x2ee56725,0xf06e5c71), U64(0x41c21cb8,0xe1000000), }; -#endif -#ifdef HAVE_UINT128_T +#elif SIZEOF_BDIGIT_DBL == 16 && defined HAVE_UINT128_T static const int maxpow128_exp[35] = { 127, 80, 63, 55, 49, 45, 42, 40, 38, 37, 35, 34, 33, 32, 31, 31, 30, 30, 29, 29, 28, 28, 27, 27, 27, 26, 26, 26, 26, 25, 25, 25, 25, 24, diff --git a/complex.c b/complex.c index c36d8907279e3d..e1d5ff9f2a97a0 100644 --- a/complex.c +++ b/complex.c @@ -18,10 +18,10 @@ VALUE rb_cComplex; -static ID id_abs, id_abs2, id_arg, id_cmp, id_conj, id_convert, - id_denominator, id_divmod, id_eqeq_p, id_expt, id_fdiv, id_floor, - id_idiv, id_imag, id_inspect, id_negate, id_numerator, id_quo, - id_real, id_real_p, id_to_f, id_to_i, id_to_r, id_to_s, +static ID id_abs, id_arg, id_convert, + id_denominator, id_eqeq_p, id_expt, id_fdiv, + id_inspect, id_negate, id_numerator, id_quo, + id_real_p, id_to_f, id_to_i, id_to_r, id_to_s, id_i_real, id_i_imag; #define f_boolcast(x) ((x) ? Qtrue : Qfalse) @@ -75,20 +75,6 @@ f_add(VALUE x, VALUE y) return rb_funcall(x, '+', 1, y); } -inline static VALUE -f_cmp(VALUE x, VALUE y) -{ - if (FIXNUM_P(x) && FIXNUM_P(y)) { - long c = FIX2LONG(x) - FIX2LONG(y); - if (c > 0) - c = 1; - else if (c < 0) - c = -1; - return INT2FIX(c); - } - return rb_funcall(x, id_cmp, 1, y); -} - inline static VALUE f_div(VALUE x, VALUE y) { @@ -105,16 +91,6 @@ f_gt_p(VALUE x, VALUE y) return rb_funcall(x, '>', 1, y); } -inline static VALUE -f_lt_p(VALUE x, VALUE y) -{ - if (FIXNUM_P(x) && FIXNUM_P(y)) - return f_boolcast(FIX2LONG(x) < FIX2LONG(y)); - return rb_funcall(x, '<', 1, y); -} - -binop(mod, '%') - inline static VALUE f_mul(VALUE x, VALUE y) { @@ -152,16 +128,11 @@ f_sub(VALUE x, VALUE y) } fun1(abs) -fun1(abs2) fun1(arg) -fun1(conj) fun1(denominator) -fun1(floor) -fun1(imag) fun1(inspect) fun1(negate) fun1(numerator) -fun1(real) fun1(real_p) inline static VALUE @@ -182,8 +153,6 @@ f_to_f(VALUE x) fun1(to_r) fun1(to_s) -fun2(divmod) - inline static VALUE f_eqeq_p(VALUE x, VALUE y) { @@ -194,7 +163,6 @@ f_eqeq_p(VALUE x, VALUE y) fun2(expt) fun2(fdiv) -fun2(idiv) fun2(quo) inline static VALUE @@ -257,12 +225,6 @@ k_numeric_p(VALUE x) return f_kind_of_p(x, rb_cNumeric); } -inline static VALUE -k_integer_p(VALUE x) -{ - return f_kind_of_p(x, rb_cInteger); -} - inline static VALUE k_fixnum_p(VALUE x) { @@ -456,13 +418,6 @@ nucomp_s_new(int argc, VALUE *argv, VALUE klass) return nucomp_s_canonicalize_internal(klass, real, imag); } -inline static VALUE -f_complex_new1(VALUE klass, VALUE x) -{ - assert(!k_complex_p(x)); - return nucomp_s_canonicalize_internal(klass, x, ZERO); -} - inline static VALUE f_complex_new2(VALUE klass, VALUE x, VALUE y) { @@ -537,7 +492,6 @@ m_log_bang(VALUE x) imp1(sin) imp1(sinh) -imp1(sqrt) static VALUE m_cos(VALUE x) @@ -570,6 +524,8 @@ m_sin(VALUE x) } #if 0 +imp1(sqrt) + static VALUE m_sqrt(VALUE x) { @@ -2098,24 +2054,16 @@ Init_Complex(void) assert(fprintf(stderr, "assert() is now active\n")); id_abs = rb_intern("abs"); - id_abs2 = rb_intern("abs2"); id_arg = rb_intern("arg"); - id_cmp = rb_intern("<=>"); - id_conj = rb_intern("conj"); id_convert = rb_intern("convert"); id_denominator = rb_intern("denominator"); - id_divmod = rb_intern("divmod"); id_eqeq_p = rb_intern("=="); id_expt = rb_intern("**"); id_fdiv = rb_intern("fdiv"); - id_floor = rb_intern("floor"); - id_idiv = rb_intern("div"); - id_imag = rb_intern("imag"); id_inspect = rb_intern("inspect"); id_negate = rb_intern("-@"); id_numerator = rb_intern("numerator"); id_quo = rb_intern("quo"); - id_real = rb_intern("real"); id_real_p = rb_intern("real?"); id_to_f = rb_intern("to_f"); id_to_i = rb_intern("to_i"); diff --git a/enc/utf_16be.c b/enc/utf_16be.c index 8b25d473a7dae8..3af8359caf019c 100644 --- a/enc/utf_16be.c +++ b/enc/utf_16be.c @@ -33,6 +33,7 @@ #define UTF16_IS_SURROGATE_SECOND(c) (((c) & 0xfc) == 0xdc) #define UTF16_IS_SURROGATE(c) (((c) & 0xf8) == 0xd8) +#if 0 static const int EncLen_UTF16[] = { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -51,6 +52,7 @@ static const int EncLen_UTF16[] = { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 }; +#endif static int utf16be_mbc_enc_len(const UChar* p, const OnigUChar* e ARG_UNUSED, diff --git a/enc/utf_16le.c b/enc/utf_16le.c index 8feb7ad7690cc1..453c771cc53973 100644 --- a/enc/utf_16le.c +++ b/enc/utf_16le.c @@ -33,6 +33,7 @@ #define UTF16_IS_SURROGATE_SECOND(c) (((c) & 0xfc) == 0xdc) #define UTF16_IS_SURROGATE(c) (((c) & 0xf8) == 0xd8) +#if 0 static const int EncLen_UTF16[] = { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -51,6 +52,7 @@ static const int EncLen_UTF16[] = { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 }; +#endif static int utf16le_mbc_enc_len(const UChar* p, const OnigUChar* e, diff --git a/ext/date/date_core.c b/ext/date/date_core.c index 6e5c79a4942605..1685d15e615bc7 100644 --- a/ext/date/date_core.c +++ b/ext/date/date_core.c @@ -1723,23 +1723,6 @@ m_real_year(union DateData *x) return ry; } - -#ifdef USE_PACK -inline static int -m_pc(union DateData *x) -{ - if (simple_dat_p(x)) { - get_s_civil(x); - return x->s.pc; - } - else { - get_c_civil(x); - get_c_time(x); - return x->c.pc; - } -} -#endif - inline static int m_mon(union DateData *x) { @@ -1979,12 +1962,6 @@ k_date_p(VALUE x) return f_kind_of_p(x, cDate); } -inline static VALUE -k_datetime_p(VALUE x) -{ - return f_kind_of_p(x, cDateTime); -} - inline static VALUE k_numeric_p(VALUE x) { diff --git a/ext/dl/cptr.c b/ext/dl/cptr.c index d34309379bbf58..7a82c7c3e06a3c 100644 --- a/ext/dl/cptr.c +++ b/ext/dl/cptr.c @@ -389,7 +389,6 @@ static VALUE rb_dlptr_inspect(VALUE self) { struct ptr_data *data; - char str[1024]; TypedData_Get_Struct(self, struct ptr_data, &dlptr_data_type, data); return rb_sprintf("#<%"PRIsVALUE":%p ptr=%p size=%ld free=%p>", diff --git a/ext/json/parser/parser.c b/ext/json/parser/parser.c index df89f2c58b4cae..29335541d4fdae 100644 --- a/ext/json/parser/parser.c +++ b/ext/json/parser/parser.c @@ -89,11 +89,11 @@ static ID i_json_creatable_p, i_json_create, i_create_id, i_create_additions, #line 92 "parser.c" -static const int JSON_object_start = 1; -static const int JSON_object_first_final = 27; -static const int JSON_object_error = 0; +enum {JSON_object_start = 1}; +enum {JSON_object_first_final = 27}; +enum {JSON_object_error = 0}; -static const int JSON_object_en_main = 1; +enum {JSON_object_en_main = 1}; #line 151 "parser.rl" @@ -467,11 +467,11 @@ case 26: #line 470 "parser.c" -static const int JSON_value_start = 1; -static const int JSON_value_first_final = 21; -static const int JSON_value_error = 0; +enum {JSON_value_start = 1}; +enum {JSON_value_first_final = 21}; +enum {JSON_value_error = 0}; -static const int JSON_value_en_main = 1; +enum {JSON_value_en_main = 1}; #line 271 "parser.rl" @@ -776,11 +776,11 @@ case 20: #line 779 "parser.c" -static const int JSON_integer_start = 1; -static const int JSON_integer_first_final = 3; -static const int JSON_integer_error = 0; +enum {JSON_integer_start = 1}; +enum {JSON_integer_first_final = 3}; +enum {JSON_integer_error = 0}; -static const int JSON_integer_en_main = 1; +enum {JSON_integer_en_main = 1}; #line 295 "parser.rl" @@ -875,11 +875,11 @@ case 5: #line 878 "parser.c" -static const int JSON_float_start = 1; -static const int JSON_float_first_final = 8; -static const int JSON_float_error = 0; +enum {JSON_float_start = 1}; +enum {JSON_float_first_final = 8}; +enum {JSON_float_error = 0}; -static const int JSON_float_en_main = 1; +enum {JSON_float_en_main = 1}; #line 329 "parser.rl" @@ -1041,11 +1041,11 @@ case 7: #line 1044 "parser.c" -static const int JSON_array_start = 1; -static const int JSON_array_first_final = 17; -static const int JSON_array_error = 0; +enum {JSON_array_start = 1}; +enum {JSON_array_first_final = 17}; +enum {JSON_array_error = 0}; -static const int JSON_array_en_main = 1; +enum {JSON_array_en_main = 1}; #line 381 "parser.rl" @@ -1373,11 +1373,11 @@ static VALUE json_string_unescape(VALUE result, char *string, char *stringEnd) #line 1376 "parser.c" -static const int JSON_string_start = 1; -static const int JSON_string_first_final = 8; -static const int JSON_string_error = 0; +enum {JSON_string_start = 1}; +enum {JSON_string_first_final = 8}; +enum {JSON_string_error = 0}; -static const int JSON_string_en_main = 1; +enum {JSON_string_en_main = 1}; #line 494 "parser.rl" @@ -1730,11 +1730,11 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self) #line 1733 "parser.c" -static const int JSON_start = 1; -static const int JSON_first_final = 10; -static const int JSON_error = 0; +enum {JSON_start = 1}; +enum {JSON_first_final = 10}; +enum {JSON_error = 0}; -static const int JSON_en_main = 1; +enum {JSON_en_main = 1}; #line 740 "parser.rl" @@ -1904,11 +1904,11 @@ case 9: #line 1907 "parser.c" -static const int JSON_quirks_mode_start = 1; -static const int JSON_quirks_mode_first_final = 10; -static const int JSON_quirks_mode_error = 0; +enum {JSON_quirks_mode_start = 1}; +enum {JSON_quirks_mode_first_final = 10}; +enum {JSON_quirks_mode_error = 0}; -static const int JSON_quirks_mode_en_main = 1; +enum {JSON_quirks_mode_en_main = 1}; #line 778 "parser.rl" diff --git a/ext/json/parser/prereq.mk b/ext/json/parser/prereq.mk index 440ef4017ed3d7..be7bcb43190e01 100644 --- a/ext/json/parser/prereq.mk +++ b/ext/json/parser/prereq.mk @@ -4,6 +4,7 @@ RAGEL = ragel .rl.c: $(RAGEL) -G2 $< - $(BASERUBY) -pli -e '$$_.sub!(/[ \t]+$$/, "")' $@ + $(BASERUBY) -pli -e '$$_.sub!(/[ \t]+$$/, "")' \ + -e '$$_.sub!(/^static const int (JSON_.*=.*);$$/, "enum {\\1};")' $@ parser.c: diff --git a/gc.c b/gc.c index 76b8eb9b00aa8b..5dbf349669ebf4 100644 --- a/gc.c +++ b/gc.c @@ -4505,8 +4505,8 @@ gc_marks(rb_objspace_t *objspace, int full_mark) { /* See the comment about RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR */ const double r = gc_params.oldobject_limit_factor; - objspace->rgengc.remembered_shady_object_limit = objspace->rgengc.remembered_shady_object_count * r; - objspace->rgengc.old_object_limit = objspace->rgengc.old_object_count * r; + objspace->rgengc.remembered_shady_object_limit = (size_t)(objspace->rgengc.remembered_shady_object_count * r); + objspace->rgengc.old_object_limit = (size_t)(objspace->rgengc.old_object_count * r); } } else { /* minor GC */ diff --git a/range.c b/range.c index d2d9a707c07fed..3ca9c2feda4e78 100644 --- a/range.c +++ b/range.c @@ -31,13 +31,6 @@ static ID id_cmp, id_succ, id_beg, id_end, id_excl, id_integer_p, id_div; #define RBOOL(v) ((v) ? Qtrue : Qfalse) #define EXCL(r) RTEST(RANGE_EXCL(r)) -static inline VALUE -SET_EXCL(VALUE r, VALUE v) -{ - v = RBOOL(RTEST(v)); - RANGE_SET_EXCL(r, v); - return v; -} static VALUE range_failed(void) diff --git a/rational.c b/rational.c index 33d2a2c2d69288..7bc72063768d51 100644 --- a/rational.c +++ b/rational.c @@ -31,7 +31,7 @@ VALUE rb_cRational; static ID id_abs, id_cmp, id_convert, id_eqeq_p, id_expt, id_fdiv, - id_floor, id_idiv, id_integer_p, id_negate, id_to_f, + id_idiv, id_integer_p, id_negate, id_to_f, id_to_i, id_truncate, id_i_num, id_i_den; #define f_boolcast(x) ((x) ? Qtrue : Qfalse) @@ -91,14 +91,6 @@ f_div(VALUE x, VALUE y) return rb_funcall(x, '/', 1, y); } -inline static VALUE -f_gt_p(VALUE x, VALUE y) -{ - if (FIXNUM_P(x) && FIXNUM_P(y)) - return f_boolcast(FIX2LONG(x) > FIX2LONG(y)); - return rb_funcall(x, '>', 1, y); -} - inline static VALUE f_lt_p(VALUE x, VALUE y) { @@ -142,7 +134,6 @@ f_sub(VALUE x, VALUE y) } fun1(abs) -fun1(floor) fun1(integer_p) fun1(negate) @@ -161,8 +152,6 @@ f_to_f(VALUE x) return rb_funcall(x, id_to_f, 0); } -fun1(truncate) - inline static VALUE f_eqeq_p(VALUE x, VALUE y) { @@ -474,14 +463,6 @@ f_rational_new_bang1(VALUE klass, VALUE x) return nurat_s_new_internal(klass, x, ONE); } -inline static VALUE -f_rational_new_bang2(VALUE klass, VALUE x, VALUE y) -{ - assert(f_positive_p(y)); - assert(f_nonzero_p(y)); - return nurat_s_new_internal(klass, x, y); -} - #ifdef CANONICALIZATION_FOR_MATHN #define CANON #endif @@ -579,13 +560,6 @@ nurat_s_new(int argc, VALUE *argv, VALUE klass) return nurat_s_canonicalize_internal(klass, num, den); } -inline static VALUE -f_rational_new1(VALUE klass, VALUE x) -{ - assert(!k_rational_p(x)); - return nurat_s_canonicalize_internal(klass, x, ONE); -} - inline static VALUE f_rational_new2(VALUE klass, VALUE x, VALUE y) { @@ -594,13 +568,6 @@ f_rational_new2(VALUE klass, VALUE x, VALUE y) return nurat_s_canonicalize_internal(klass, x, y); } -inline static VALUE -f_rational_new_no_reduce1(VALUE klass, VALUE x) -{ - assert(!k_rational_p(x)); - return nurat_s_canonicalize_internal_no_reduce(klass, x, ONE); -} - inline static VALUE f_rational_new_no_reduce2(VALUE klass, VALUE x, VALUE y) { @@ -2532,7 +2499,6 @@ Init_Rational(void) id_eqeq_p = rb_intern("=="); id_expt = rb_intern("**"); id_fdiv = rb_intern("fdiv"); - id_floor = rb_intern("floor"); id_idiv = rb_intern("div"); id_integer_p = rb_intern("integer?"); id_negate = rb_intern("-@"); diff --git a/version.h b/version.h index 089da87db1dc57..ebc47edb30afae 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-08-03" -#define RUBY_PATCHLEVEL 187 +#define RUBY_PATCHLEVEL 188 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 8 From fe45e6b79c9dcff352327dd5865ed20f528ad83d Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 3 Aug 2014 15:50:33 +0000 Subject: [PATCH 189/343] merge revision(s) r44610,r44617: numeric.c: preserve encoding * numeric.c (coerce_failed): preserve encoding of error message. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47050 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- numeric.c | 24 +++++++++++------------- test/ruby/test_numeric.rb | 14 ++++++++++++++ version.h | 6 +++--- 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/numeric.c b/numeric.c index 4b1319879768d7..b7a4e968efdcd4 100644 --- a/numeric.c +++ b/numeric.c @@ -232,17 +232,19 @@ coerce_body(VALUE *x) return rb_funcall(x[1], id_coerce, 1, x[0]); } +NORETURN(static void coerce_failed(VALUE x, VALUE y)); +static void +coerce_failed(VALUE x, VALUE y) +{ + rb_raise(rb_eTypeError, "%"PRIsVALUE" can't be coerced into %"PRIsVALUE, + (rb_special_const_p(y)? rb_inspect(y) : rb_obj_class(y)), + rb_obj_class(x)); +} + static VALUE coerce_rescue(VALUE *x) { - volatile VALUE v = rb_inspect(x[1]); - - rb_raise(rb_eTypeError, "%s can't be coerced into %s", - rb_special_const_p(x[1])? - RSTRING_PTR(v): - rb_obj_classname(x[1]), - rb_obj_classname(x[0])); - + coerce_failed(x[0], x[1]); return Qnil; /* dummy */ } @@ -3297,11 +3299,7 @@ bit_coerce(VALUE *x, VALUE *y, int err) if (!FIXNUM_P(*x) && !RB_TYPE_P(*x, T_BIGNUM) && !FIXNUM_P(*y) && !RB_TYPE_P(*y, T_BIGNUM)) { if (!err) return FALSE; - rb_raise(rb_eTypeError, - "%s can't be coerced into %s for bitwise arithmetic", - rb_special_const_p(*y) ? - RSTRING_PTR(rb_inspect(*y)) : rb_obj_classname(*y), - rb_obj_classname(*x)); + coerce_failed(*x, *y); } } return TRUE; diff --git a/test/ruby/test_numeric.rb b/test/ruby/test_numeric.rb index 287093518b7902..0e70078bad8996 100644 --- a/test/ruby/test_numeric.rb +++ b/test/ruby/test_numeric.rb @@ -1,4 +1,5 @@ require 'test/unit' +require_relative 'envutil' class TestNumeric < Test::Unit::TestCase class DummyNumeric < Numeric @@ -14,6 +15,19 @@ def test_coerce assert_equal(Float, b.class) assert_raise(TypeError) { -Numeric.new } + + EnvUtil.with_default_external(Encoding::UTF_8) do + assert_raise_with_message(TypeError, /:\u{3042}/) {1+:"\u{3042}"} + assert_raise_with_message(TypeError, /:\u{3042}/) {1&:"\u{3042}"} + assert_raise_with_message(TypeError, /:\u{3042}/) {1|:"\u{3042}"} + assert_raise_with_message(TypeError, /:\u{3042}/) {1^:"\u{3042}"} + end + EnvUtil.with_default_external(Encoding::US_ASCII) do + assert_raise_with_message(TypeError, /:"\\u3042"/) {1+:"\u{3042}"} + assert_raise_with_message(TypeError, /:"\\u3042"/) {1&:"\u{3042}"} + assert_raise_with_message(TypeError, /:"\\u3042"/) {1|:"\u{3042}"} + assert_raise_with_message(TypeError, /:"\\u3042"/) {1^:"\u{3042}"} + end end def test_dummynumeric diff --git a/version.h b/version.h index ebc47edb30afae..c106ac2039c874 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.2" -#define RUBY_RELEASE_DATE "2014-08-03" -#define RUBY_PATCHLEVEL 188 +#define RUBY_RELEASE_DATE "2014-08-04" +#define RUBY_PATCHLEVEL 189 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 8 -#define RUBY_RELEASE_DAY 3 +#define RUBY_RELEASE_DAY 4 #include "ruby/version.h" From 84091a71e50ebe37f2261762fcef97cefe4c93ab Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 3 Aug 2014 16:07:15 +0000 Subject: [PATCH 190/343] merge revision(s) r46465,r46469,r46484: [Backport #9961] * vm.c (rb_vm_rewind_cfp): add new function to rewind specified cfp with invoking RUBY_EVENT_C_RETURN. [Bug #9961] * vm_core.h: ditto. * eval.c (rb_protect): use it. * eval.c (rb_rescue2): ditto. * vm_eval.c (rb_iterate): ditto. * test/ruby/test_settracefunc.rb: add a test. * vm_core.h (rb_name_err_mesg_new): * vm_eval.c (rb_catch_protect): fix same problem of [Bug #9961]. * vm_eval.c (rb_iterate): ditto. * vm_core.h (rb_vm_rewind_cfp): add the prototype declaration. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47051 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 24 +++++++++++++++++ eval.c | 4 +-- test/ruby/test_settracefunc.rb | 49 ++++++++++++++++++++++++++++++++++ version.h | 2 +- vm.c | 17 ++++++++++++ vm_core.h | 1 + vm_eval.c | 18 +++---------- 7 files changed, 98 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 48d85321a3ce64..a0fccf0bf16269 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,27 @@ +Mon Aug 4 00:52:42 2014 Koichi Sasada + + * vm_eval.c (rb_catch_protect): fix same problem of [Bug #9961]. + + * vm_eval.c (rb_iterate): ditto. + +Mon Aug 4 00:52:42 2014 Koichi Sasada + + * vm.c (rb_vm_rewind_cfp): add new function to rewind specified cfp + with invoking RUBY_EVENT_C_RETURN. + [Bug #9961] + + * vm_core.h: ditto. + + * eval.c (rb_protect): use it. + + * eval.c (rb_rescue2): ditto. + + * vm_eval.c (rb_iterate): ditto. + + * test/ruby/test_settracefunc.rb: add a test. + + * vm_core.h (rb_vm_rewind_cfp): add the prototype declaration. + Sun Aug 3 00:06:10 2014 Charlie Somerville * node.c (dump_node): handle nd_value == (NODE *)-1 to mean this diff --git a/eval.c b/eval.c index e58496ecce83e3..7f002270a55d3f 100644 --- a/eval.c +++ b/eval.c @@ -763,7 +763,7 @@ rb_rescue2(VALUE (* b_proc) (ANYARGS), VALUE data1, } } else { - th->cfp = cfp; /* restore */ + rb_vm_rewind_cfp(th, cfp); if (state == TAG_RAISE) { int handle = FALSE; @@ -822,7 +822,7 @@ rb_protect(VALUE (* proc) (VALUE), VALUE data, int * state) SAVE_ROOT_JMPBUF(th, result = (*proc) (data)); } else { - th->cfp = cfp; + rb_vm_rewind_cfp(th, cfp); } MEMCPY(&(th)->root_jmpbuf, &org_jmpbuf, rb_jmpbuf_t, 1); th->protect_tag = protect_tag.prev; diff --git a/test/ruby/test_settracefunc.rb b/test/ruby/test_settracefunc.rb index 697b44ccfe0751..5cb6d4a16e31ad 100644 --- a/test/ruby/test_settracefunc.rb +++ b/test/ruby/test_settracefunc.rb @@ -1290,6 +1290,55 @@ def assert_consistent_call_return message='', check_events: nil assert_equal call_events, return_events.reverse, message end + def test_rb_rescue + events = [] + curr_thread = Thread.current + TracePoint.new(:a_call, :a_return){|tp| + next if curr_thread != Thread.current + events << [tp.event, tp.method_id] + }.enable do + begin + -Numeric.new + rescue => e + # ignore + end + end + + assert_equal [ + [:b_call, :test_rb_rescue], + [:c_call, :new], + [:c_call, :initialize], + [:c_return, :initialize], + [:c_return, :new], + [:c_call, :-@], + [:c_call, :coerce], + [:c_call, :new], + [:c_call, :initialize], + [:c_return, :initialize], + [:c_return, :new], + [:c_call, :exception], + [:c_return, :exception], + [:c_call, :backtrace], + [:c_return, :backtrace], + [:c_return, :coerce], # don't miss it! + [:c_call, :to_s], + [:c_return, :to_s], + [:c_call, :to_s], + [:c_return, :to_s], + [:c_call, :new], + [:c_call, :initialize], + [:c_return, :initialize], + [:c_return, :new], + [:c_call, :exception], + [:c_return, :exception], + [:c_call, :backtrace], + [:c_return, :backtrace], + [:c_return, :-@], + [:c_call, :===], + [:c_return, :===], + [:b_return, :test_rb_rescue]], events + end + def test_b_call_with_redo assert_consistent_call_return do i = 0 diff --git a/version.h b/version.h index c106ac2039c874..b7999fe0ba189a 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-08-04" -#define RUBY_PATCHLEVEL 189 +#define RUBY_PATCHLEVEL 190 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 8 diff --git a/vm.c b/vm.c index 922140e7f8bfc9..c82a00e5a234a5 100644 --- a/vm.c +++ b/vm.c @@ -287,6 +287,23 @@ rb_vm_pop_cfunc_frame(void) vm_pop_frame(th); } +void +rb_vm_rewind_cfp(rb_thread_t *th, rb_control_frame_t *cfp) +{ + /* check skipped frame */ + while (th->cfp != cfp) { +#if VMDEBUG + printf("skipped frame: %s\n", vm_frametype_name(th->cfp)); +#endif + if (VM_FRAME_TYPE(th->cfp) != VM_FRAME_MAGIC_CFUNC) { + vm_pop_frame(th); + } + else { /* unlikely path */ + rb_vm_pop_cfunc_frame(); + } + } +} + /* obsolete */ void rb_frame_pop(void) diff --git a/vm_core.h b/vm_core.h index 286c9ab054845b..3b588bdbcc7e95 100644 --- a/vm_core.h +++ b/vm_core.h @@ -887,6 +887,7 @@ VALUE rb_name_err_mesg_new(VALUE obj, VALUE mesg, VALUE recv, VALUE method); void rb_vm_stack_to_heap(rb_thread_t *th); void ruby_thread_init_stack(rb_thread_t *th); int rb_vm_control_frame_id_and_class(const rb_control_frame_t *cfp, ID *idp, VALUE *klassp); +void rb_vm_rewind_cfp(rb_thread_t *th, rb_control_frame_t *cfp); void rb_gc_mark_machine_stack(rb_thread_t *th); diff --git a/vm_eval.c b/vm_eval.c index 87d99d096c0637..cb0e637942d07a 100644 --- a/vm_eval.c +++ b/vm_eval.c @@ -1089,18 +1089,7 @@ rb_iterate(VALUE (* it_proc) (VALUE), VALUE data1, th->errinfo = Qnil; retval = GET_THROWOBJ_VAL(err); - /* check skipped frame */ - while (th->cfp != cfp) { -#if VMDEBUG - printf("skipped frame: %s\n", vm_frametype_name(th->cfp)); -#endif - if (VM_FRAME_TYPE(th->cfp) != VM_FRAME_MAGIC_CFUNC) { - vm_pop_frame(th); - } - else { /* unlikely path */ - rb_vm_pop_cfunc_frame(); - } - } + rb_vm_rewind_cfp(th, cfp); } else{ /* SDR(); printf("%p, %p\n", cdfp, escape_dfp); */ @@ -1111,10 +1100,11 @@ rb_iterate(VALUE (* it_proc) (VALUE), VALUE data1, VALUE *cep = cfp->ep; if (cep == escape_ep) { + rb_vm_rewind_cfp(th, cfp); + state = 0; th->state = 0; th->errinfo = Qnil; - th->cfp = cfp; goto iter_retry; } } @@ -1858,7 +1848,7 @@ rb_catch_protect(VALUE t, rb_block_call_func *func, VALUE data, int *stateptr) val = (*func)(tag, data, 1, (const VALUE *)&tag, Qnil); } else if (state == TAG_THROW && RNODE(th->errinfo)->u1.value == tag) { - th->cfp = saved_cfp; + rb_vm_rewind_cfp(th, saved_cfp); val = th->tag->retval; th->errinfo = Qnil; state = 0; From 3aefb61f15ca7d09f8465b7cc8036eec81d0830d Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 3 Aug 2014 16:20:58 +0000 Subject: [PATCH 191/343] merge revision(s) r46345,r46346: [Backport #9903] re.c: reduce new strings * re.c (match_aref, rb_reg_regsub): reduce new strings creation for exceptions. * re.c (match_aref, rb_reg_regsub): consider encoding of captured names, encoding-incompatible should not match. [ruby-dev:48278] [Bug #9903] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47052 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ re.c | 34 +++++++++++++++++++--------------- test/ruby/test_regexp.rb | 9 +++++++++ version.h | 2 +- 4 files changed, 35 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index a0fccf0bf16269..40b21f186c2780 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Mon Aug 4 01:11:07 2014 Nobuyoshi Nakada + + * re.c (match_aref, rb_reg_regsub): consider encoding of captured + names, encoding-incompatible should not match. + [ruby-dev:48278] [Bug #9903] + Mon Aug 4 00:52:42 2014 Koichi Sasada * vm_eval.c (rb_catch_protect): fix same problem of [Bug #9961]. diff --git a/re.c b/re.c index 2bd6fe96b8b321..d26b7834668982 100644 --- a/re.c +++ b/re.c @@ -1691,20 +1691,16 @@ match_captures(VALUE match) static int name_to_backref_number(struct re_registers *regs, VALUE regexp, const char* name, const char* name_end) { - int num; - - num = onig_name_to_backref_number(RREGEXP(regexp)->ptr, + return onig_name_to_backref_number(RREGEXP(regexp)->ptr, (const unsigned char* )name, (const unsigned char* )name_end, regs); - if (num >= 1) { - return num; - } - else { - VALUE s = rb_str_new(name, (long )(name_end - name)); - rb_raise(rb_eIndexError, "undefined group name reference: %s", - StringValuePtr(s)); - } +} - UNREACHABLE; +NORETURN(static void name_to_backref_error(VALUE name)); +static void +name_to_backref_error(VALUE name) +{ + rb_raise(rb_eIndexError, "undefined group name reference: % "PRIsVALUE, + name); } /* @@ -1758,8 +1754,11 @@ match_aref(int argc, VALUE *argv, VALUE match) /* fall through */ case T_STRING: p = StringValuePtr(idx); - num = name_to_backref_number(RMATCH_REGS(match), - RMATCH(match)->regexp, p, p + RSTRING_LEN(idx)); + if (!rb_enc_compatible(RREGEXP(RMATCH(match)->regexp)->src, idx) || + (num = name_to_backref_number(RMATCH_REGS(match), RMATCH(match)->regexp, + p, p + RSTRING_LEN(idx))) < 1) { + name_to_backref_error(idx); + } return rb_reg_nth_match(num, match); default: @@ -3369,7 +3368,12 @@ rb_reg_regsub(VALUE str, VALUE src, struct re_registers *regs, VALUE regexp) name_end += c == -1 ? mbclen(name_end, e, str_enc) : clen; } if (name_end < e) { - no = name_to_backref_number(regs, regexp, name, name_end); + VALUE n = rb_str_subseq(str, (long)(name - RSTRING_PTR(str)), + (long)(name_end - name)); + if (!rb_enc_compatible(RREGEXP(regexp)->src, n) || + (no = name_to_backref_number(regs, regexp, name, name_end)) < 1) { + name_to_backref_error(n); + } p = s = name_end + clen; break; } diff --git a/test/ruby/test_regexp.rb b/test/ruby/test_regexp.rb index b4b29a6368b929..bef770b9236306 100644 --- a/test/ruby/test_regexp.rb +++ b/test/ruby/test_regexp.rb @@ -158,6 +158,15 @@ def test_named_capture_with_nul } end + def test_named_capture_nonascii + bug9903 = '[ruby-dev:48278] [Bug #9903]' + + key = "\xb1\xb2".force_encoding(Encoding::EUC_JP) + m = /(?<#{key}>.*)/.match("xxx") + assert_equal("xxx", m[key]) + assert_raise(IndexError, bug9903) {m[key.dup.force_encoding(Encoding::Shift_JIS)]} + end + def test_assign_named_capture assert_equal("a", eval('/(?.)/ =~ "a"; foo')) assert_equal("a", eval('foo = 1; /(?.)/ =~ "a"; foo')) diff --git a/version.h b/version.h index b7999fe0ba189a..bf5c6dc604a5ff 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-08-04" -#define RUBY_PATCHLEVEL 190 +#define RUBY_PATCHLEVEL 191 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 8 From d4132b8ae0e79f3fc21bad0fdba1a79fdd6c48b0 Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 3 Aug 2014 16:24:48 +0000 Subject: [PATCH 192/343] merge revision(s) r46550: [Backport #9977] * hash.c (ruby_setenv): fix memory leak on Windows, free environment strings block after check for the size. [ruby-dev:48323] [Bug #9977] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47053 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ hash.c | 7 +++++-- test/ruby/test_env.rb | 10 ++++++++++ version.h | 2 +- 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 40b21f186c2780..376e29ec623e53 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Mon Aug 4 01:24:09 2014 Nobuyoshi Nakada + + * hash.c (ruby_setenv): fix memory leak on Windows, free + environment strings block after check for the size. + [ruby-dev:48323] [Bug #9977] + Mon Aug 4 01:11:07 2014 Nobuyoshi Nakada * re.c (match_aref, rb_reg_regsub): consider encoding of captured diff --git a/hash.c b/hash.c index 9a5814aad48b0e..723b460701e462 100644 --- a/hash.c +++ b/hash.c @@ -2751,9 +2751,12 @@ ruby_setenv(const char *name, const char *value) int failed = 0; check_envname(name); if (value) { - const char* p = GetEnvironmentStringsA(); + char* p = GetEnvironmentStringsA(); + size_t n; if (!p) goto fail; /* never happen */ - if (strlen(name) + 2 + strlen(value) + getenvsize(p) >= getenvblocksize()) { + n = strlen(name) + 2 + strlen(value) + getenvsize(p); + FreeEnvironmentStringsA(p); + if (n >= getenvblocksize()) { goto fail; /* 2 for '=' & '\0' */ } buf = rb_sprintf("%s=%s", name, value); diff --git a/test/ruby/test_env.rb b/test/ruby/test_env.rb index 17c5d57d2582b2..5eb67174055db9 100644 --- a/test/ruby/test_env.rb +++ b/test/ruby/test_env.rb @@ -1,4 +1,5 @@ require 'test/unit' +require_relative 'envutil' class TestEnv < Test::Unit::TestCase IGNORE_CASE = /bccwin|mswin|mingw/ =~ RUBY_PLATFORM @@ -408,4 +409,13 @@ def test_win32_blocksize keys.each {|k| ENV.delete(k)} end end + + def test_memory_leak_aset + bug9977 = '[ruby-dev:48323] [Bug #9977]' + assert_no_memory_leak([], <<-'end;', "5_000.times {ENV[k] = v}", bug9977) + ENV.clear + k = 'FOO' + v = (ENV[k] = 'bar'*5000 rescue 'bar'*1500) + end; + end end diff --git a/version.h b/version.h index bf5c6dc604a5ff..e314010659e62f 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-08-04" -#define RUBY_PATCHLEVEL 191 +#define RUBY_PATCHLEVEL 192 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 8 From 85c48fdc312a923c1bfe0ed88fa302d6417d9402 Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 3 Aug 2014 16:28:20 +0000 Subject: [PATCH 193/343] merge revision(s) r46557,r46565: [Backport #9978] * hash.c (env_select): fix memory leak and crash on Windows, make keys array first instead of iterating on envrion directly. [ruby-dev:48325] [Bug #9978] keys array first instead of iterating on environ directly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47054 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ hash.c | 20 +++++++++----------- test/ruby/test_env.rb | 16 ++++++++++++++++ version.h | 2 +- 4 files changed, 32 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 376e29ec623e53..9dd1981323169c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Mon Aug 4 01:26:46 2014 Nobuyoshi Nakada + + * hash.c (env_select): fix memory leak and crash on Windows, make + keys array first instead of iterating on environ directly. + [ruby-dev:48325] [Bug #9978] + Mon Aug 4 01:24:09 2014 Nobuyoshi Nakada * hash.c (ruby_setenv): fix memory leak on Windows, free diff --git a/hash.c b/hash.c index 723b460701e462..aae90f0fec24df 100644 --- a/hash.c +++ b/hash.c @@ -3139,23 +3139,21 @@ static VALUE env_select(VALUE ehash) { VALUE result; - char **env; + VALUE keys; + long i; RETURN_SIZED_ENUMERATOR(ehash, 0, 0, rb_env_size); result = rb_hash_new(); - env = GET_ENVIRON(environ); - while (*env) { - char *s = strchr(*env, '='); - if (s) { - VALUE k = env_str_new(*env, s-*env); - VALUE v = env_str_new2(s+1); - if (RTEST(rb_yield_values(2, k, v))) { - rb_hash_aset(result, k, v); + keys = env_keys(); + for (i = 0; i < RARRAY_LEN(keys); ++i) { + VALUE key = RARRAY_AREF(keys, i); + VALUE val = rb_f_getenv(Qnil, key); + if (!NIL_P(val)) { + if (RTEST(rb_yield_values(2, key, val))) { + rb_hash_aset(result, key, val); } } - env++; } - FREE_ENVIRON(environ); return result; } diff --git a/test/ruby/test_env.rb b/test/ruby/test_env.rb index 5eb67174055db9..2b286de04e8fdc 100644 --- a/test/ruby/test_env.rb +++ b/test/ruby/test_env.rb @@ -418,4 +418,20 @@ def test_memory_leak_aset v = (ENV[k] = 'bar'*5000 rescue 'bar'*1500) end; end + + def test_memory_leak_select + bug9978 = '[ruby-dev:48325] [Bug #9978]' + assert_no_memory_leak([], <<-'end;', "5_000.times {ENV.select {break}}", bug9978) + ENV.clear + k = 'FOO' + (ENV[k] = 'bar'*5000 rescue 'bar'*1500) + end; + end + + def test_memory_crash_select + assert_normal_exit(<<-'end;') + 1000.times {ENV["FOO#{i}"] = 'bar'} + ENV.select {ENV.clear} + end; + end end diff --git a/version.h b/version.h index e314010659e62f..9285ccc1e894fa 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-08-04" -#define RUBY_PATCHLEVEL 192 +#define RUBY_PATCHLEVEL 193 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 8 From 856f4d49f15844d3da579e4c5e19dc1c3545ed28 Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 3 Aug 2014 16:31:45 +0000 Subject: [PATCH 194/343] merge revision(s) r46570: [Backport #9983] * hash.c (env_shift): fix memory leak on Windows, free environment strings block always. [ruby-dev:48332] [Bug #9983] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47055 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ hash.c | 5 +++-- test/ruby/test_env.rb | 9 +++++++++ version.h | 2 +- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9dd1981323169c..b55cdf5fec096f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Mon Aug 4 01:29:57 2014 Nobuyoshi Nakada + + * hash.c (env_shift): fix memory leak on Windows, free environment + strings block always. [ruby-dev:48332] [Bug #9983] + Mon Aug 4 01:26:46 2014 Nobuyoshi Nakada * hash.c (env_select): fix memory leak and crash on Windows, make diff --git a/hash.c b/hash.c index aae90f0fec24df..85be2decb7a371 100644 --- a/hash.c +++ b/hash.c @@ -3557,6 +3557,7 @@ static VALUE env_shift(void) { char **env; + VALUE result = Qnil; env = GET_ENVIRON(environ); if (*env) { @@ -3565,11 +3566,11 @@ env_shift(void) VALUE key = env_str_new(*env, s-*env); VALUE val = env_str_new2(getenv(RSTRING_PTR(key))); env_delete(Qnil, key); - return rb_assoc_new(key, val); + result = rb_assoc_new(key, val); } } FREE_ENVIRON(environ); - return Qnil; + return result; } /* diff --git a/test/ruby/test_env.rb b/test/ruby/test_env.rb index 2b286de04e8fdc..2d0d7634fd9b43 100644 --- a/test/ruby/test_env.rb +++ b/test/ruby/test_env.rb @@ -434,4 +434,13 @@ def test_memory_crash_select ENV.select {ENV.clear} end; end + + def test_memory_leak_shift + bug9983 = '[ruby-dev:48332] [Bug #9983]' + assert_no_memory_leak([], <<-'end;', "5_000.times {ENV.shift; ENV[k] = v}", bug9983) + ENV.clear + k = 'FOO' + v = (ENV[k] = 'bar'*5000 rescue 'bar'*1500) + end; + end end diff --git a/version.h b/version.h index 9285ccc1e894fa..8d62f00c540b57 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-08-04" -#define RUBY_PATCHLEVEL 193 +#define RUBY_PATCHLEVEL 194 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 8 From 92d58cacaf93080c997f01075378a60e2bbb3f41 Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 3 Aug 2014 16:43:29 +0000 Subject: [PATCH 195/343] merge revision(s) r46585,r46595,r46822: [Backport #9977] [Backport #9978] [Backport #9983] test_env.rb: rehearsal * test/ruby/test_env.rb (test_memory_leak_{aset,select,shift}): have a rehearsal before the main loop. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47056 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_env.rb | 72 ++++++++++++++++++++++++------------------- version.h | 2 +- 2 files changed, 41 insertions(+), 33 deletions(-) diff --git a/test/ruby/test_env.rb b/test/ruby/test_env.rb index 2d0d7634fd9b43..0ada9606ae9102 100644 --- a/test/ruby/test_env.rb +++ b/test/ruby/test_env.rb @@ -410,37 +410,45 @@ def test_win32_blocksize end end - def test_memory_leak_aset - bug9977 = '[ruby-dev:48323] [Bug #9977]' - assert_no_memory_leak([], <<-'end;', "5_000.times {ENV[k] = v}", bug9977) - ENV.clear - k = 'FOO' - v = (ENV[k] = 'bar'*5000 rescue 'bar'*1500) - end; - end - - def test_memory_leak_select - bug9978 = '[ruby-dev:48325] [Bug #9978]' - assert_no_memory_leak([], <<-'end;', "5_000.times {ENV.select {break}}", bug9978) - ENV.clear - k = 'FOO' - (ENV[k] = 'bar'*5000 rescue 'bar'*1500) - end; - end - - def test_memory_crash_select - assert_normal_exit(<<-'end;') - 1000.times {ENV["FOO#{i}"] = 'bar'} - ENV.select {ENV.clear} - end; - end - - def test_memory_leak_shift - bug9983 = '[ruby-dev:48332] [Bug #9983]' - assert_no_memory_leak([], <<-'end;', "5_000.times {ENV.shift; ENV[k] = v}", bug9983) - ENV.clear - k = 'FOO' - v = (ENV[k] = 'bar'*5000 rescue 'bar'*1500) - end; + if RUBY_PLATFORM =~ /bccwin|mswin|mingw/ + def test_memory_leak_aset + bug9977 = '[ruby-dev:48323] [Bug #9977]' + assert_no_memory_leak([], <<-'end;', "5_000.times(&doit)", bug9977, limit: 2.0) + ENV.clear + k = 'FOO' + v = (ENV[k] = 'bar'*5000 rescue 'bar'*1500) + doit = proc {ENV[k] = v} + 500.times(&doit) + end; + end + + def test_memory_leak_select + bug9978 = '[ruby-dev:48325] [Bug #9978]' + assert_no_memory_leak([], <<-'end;', "5_000.times(&doit)", bug9978, limit: 2.0) + ENV.clear + k = 'FOO' + (ENV[k] = 'bar'*5000 rescue 'bar'*1500) + doit = proc {ENV.select {break}} + 500.times(&doit) + end; + end + + def test_memory_crash_select + assert_normal_exit(<<-'end;') + 1000.times {ENV["FOO#{i}"] = 'bar'} + ENV.select {ENV.clear} + end; + end + + def test_memory_leak_shift + bug9983 = '[ruby-dev:48332] [Bug #9983]' + assert_no_memory_leak([], <<-'end;', "5_000.times(&doit)", bug9983, limit: 2.0) + ENV.clear + k = 'FOO' + v = (ENV[k] = 'bar'*5000 rescue 'bar'*1500) + doit = proc {ENV[k] = v; ENV.shift} + 500.times(&doit) + end; + end end end diff --git a/version.h b/version.h index 8d62f00c540b57..3a1ee2741de0e5 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-08-04" -#define RUBY_PATCHLEVEL 194 +#define RUBY_PATCHLEVEL 195 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 8 From c4e2581392ef828160b760488d52c36464b451e3 Mon Sep 17 00:00:00 2001 From: nagachika Date: Fri, 8 Aug 2014 14:58:32 +0000 Subject: [PATCH 196/343] merge revision(s) r45676,r45677: [Backport #9769] stringio.c: move GC guard * ext/stringio/stringio.c (strio_write): move GC guard after the last using position. * ext/stringio/stringio.c (strio_write): use rb_str_append to reuse coderange bits other than ASCII-8BIT, and keep taintedness. [ruby-dev:48118] [Bug #9769] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47106 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ ext/stringio/stringio.c | 10 ++++++++-- test/stringio/test_stringio.rb | 18 ++++++++++++++++++ version.h | 6 +++--- 4 files changed, 35 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index b55cdf5fec096f..7941d287a9776b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Fri Aug 8 23:36:01 2014 Nobuyoshi Nakada + + * ext/stringio/stringio.c (strio_write): use rb_str_append to + reuse coderange bits other than ASCII-8BIT, and keep + taintedness. [ruby-dev:48118] [Bug #9769] + Mon Aug 4 01:29:57 2014 Nobuyoshi Nakada * hash.c (env_shift): fix memory leak on Windows, free environment diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c index fb8e7ce3ea8975..1a12d298e14a4f 100644 --- a/ext/stringio/stringio.c +++ b/ext/stringio/stringio.c @@ -1170,7 +1170,6 @@ strio_write(VALUE self, VALUE str) long len, olen; rb_encoding *enc, *enc2; - RB_GC_GUARD(str); if (!RB_TYPE_P(str, T_STRING)) str = rb_obj_as_string(str); enc = rb_enc_get(ptr->string); @@ -1186,7 +1185,13 @@ strio_write(VALUE self, VALUE str) ptr->pos = olen; } if (ptr->pos == olen) { - rb_enc_str_buf_cat(ptr->string, RSTRING_PTR(str), len, enc); + if (enc2 == rb_ascii8bit_encoding()) { + rb_enc_str_buf_cat(ptr->string, RSTRING_PTR(str), len, enc); + OBJ_INFECT(ptr->string, str); + } + else { + rb_str_buf_append(ptr->string, str); + } } else { strio_extend(ptr, ptr->pos, len); @@ -1194,6 +1199,7 @@ strio_write(VALUE self, VALUE str) OBJ_INFECT(ptr->string, str); } OBJ_INFECT(ptr->string, self); + RB_GC_GUARD(str); ptr->pos += len; return LONG2NUM(len); } diff --git a/test/stringio/test_stringio.rb b/test/stringio/test_stringio.rb index c7db91aae19247..3fbe2f7ecac729 100644 --- a/test/stringio/test_stringio.rb +++ b/test/stringio/test_stringio.rb @@ -119,6 +119,24 @@ def o.to_s; "baz"; end f.close unless f.closed? end + def test_write_infection + bug9769 = '[ruby-dev:48118] [Bug #9769]' + s = "".untaint + f = StringIO.new(s, "w") + f.print("bar".taint) + f.close + assert_predicate(s, :tainted?, bug9769) + ensure + f.close unless f.closed? + end + + def test_write_encoding + s = "".force_encoding(Encoding::UTF_8) + f = StringIO.new(s) + f.print("\u{3053 3093 306b 3061 306f ff01}".b) + assert_equal(Encoding::UTF_8, s.encoding, "honor the original encoding over ASCII-8BIT") + end + def test_mode_error f = StringIO.new("", "r") assert_raise(IOError) { f.write("foo") } diff --git a/version.h b/version.h index 3a1ee2741de0e5..d89750b948449b 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.2" -#define RUBY_RELEASE_DATE "2014-08-04" -#define RUBY_PATCHLEVEL 195 +#define RUBY_RELEASE_DATE "2014-08-08" +#define RUBY_PATCHLEVEL 196 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 8 -#define RUBY_RELEASE_DAY 4 +#define RUBY_RELEASE_DAY 8 #include "ruby/version.h" From 6ff49bf81f9101d7074c660b4aaa0f963fff55fa Mon Sep 17 00:00:00 2001 From: nagachika Date: Mon, 11 Aug 2014 13:22:31 +0000 Subject: [PATCH 197/343] merge revision(s) r46775: [Backport #10016] * vm_insnhelper.c (vm_callee_setup_keyword_arg): adjust VM stack pointer to get rid of overwriting splat arguments by arguments for `to_hash` conversion. [ruby-core:63593] [Bug #10016] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47138 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ test/ruby/test_keyword.rb | 10 ++++++++++ version.h | 6 +++--- vm_insnhelper.c | 15 ++++++++++++--- 4 files changed, 31 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7941d287a9776b..fd246c78032e83 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Mon Aug 11 22:14:28 2014 Nobuyoshi Nakada + + * vm_insnhelper.c (vm_callee_setup_keyword_arg): adjust VM stack + pointer to get rid of overwriting splat arguments by arguments + for `to_hash` conversion. [ruby-core:63593] [Bug #10016] + Fri Aug 8 23:36:01 2014 Nobuyoshi Nakada * ext/stringio/stringio.c (strio_write): use rb_str_append to diff --git a/test/ruby/test_keyword.rb b/test/ruby/test_keyword.rb index eb548b95e252da..0930cf0f5d0868 100644 --- a/test/ruby/test_keyword.rb +++ b/test/ruby/test_keyword.rb @@ -463,6 +463,16 @@ def o2.to_hash() { b: 2 } end assert_equal({a: 1, b: 2}, m1(**o, **o2) {|x| break x}, bug9898) end + def test_implicit_hash_conversion + bug10016 = '[ruby-core:63593] [Bug #10016]' + + o = Object.new + def o.to_hash() { k: 9 } end + assert_equal([1, 42, [], o, :key, {}, nil], f9(1, o)) + assert_equal([1, 9], m1(1, o) {|a, k: 0| break [a, k]}, bug10016) + assert_equal([1, 9], m1(1, o, &->(a, k: 0) {break [a, k]}), bug10016) + end + def test_gced_object_in_stack bug8964 = '[ruby-dev:47729] [Bug #8964]' assert_normal_exit %q{ diff --git a/version.h b/version.h index d89750b948449b..54f0dd3c505d98 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.2" -#define RUBY_RELEASE_DATE "2014-08-08" -#define RUBY_PATCHLEVEL 196 +#define RUBY_RELEASE_DATE "2014-08-11" +#define RUBY_PATCHLEVEL 197 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 8 -#define RUBY_RELEASE_DAY 8 +#define RUBY_RELEASE_DAY 11 #include "ruby/version.h" diff --git a/vm_insnhelper.c b/vm_insnhelper.c index c9c91b0fc76b58..03493c13c8c719 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -1067,10 +1067,15 @@ vm_caller_setup_args(const rb_thread_t *th, rb_control_frame_t *cfp, rb_call_inf } static inline int -vm_callee_setup_keyword_arg(const rb_iseq_t *iseq, int argc, int m, VALUE *orig_argv, VALUE *kwd) +vm_callee_setup_keyword_arg(rb_thread_t *th, const rb_iseq_t *iseq, int argc, int m, VALUE *orig_argv, VALUE *kwd) { VALUE keyword_hash = 0, orig_hash; int optional = iseq->arg_keywords - iseq->arg_keyword_required; + VALUE *const sp = th->cfp->sp; + const int mark_stack_len = th->mark_stack_len; + + th->cfp->sp += argc; + th->mark_stack_len -= argc; if (argc > m && !NIL_P(orig_hash = rb_check_hash_type(orig_argv[argc-1])) && @@ -1085,10 +1090,14 @@ vm_callee_setup_keyword_arg(const rb_iseq_t *iseq, int argc, int m, VALUE *orig_ rb_get_kwargs(keyword_hash, iseq->arg_keyword_table, iseq->arg_keyword_required, (iseq->arg_keyword_check ? optional : -1-optional), NULL); + if (!keyword_hash) { keyword_hash = rb_hash_new(); } + th->cfp->sp = sp; + th->mark_stack_len = mark_stack_len; + *kwd = keyword_hash; return argc; @@ -1111,7 +1120,7 @@ vm_callee_setup_arg_complex(rb_thread_t *th, rb_call_info_t *ci, const rb_iseq_t /* keyword argument */ if (iseq->arg_keyword != -1) { - argc = vm_callee_setup_keyword_arg(iseq, argc, min, orig_argv, &keyword_hash); + argc = vm_callee_setup_keyword_arg(th, iseq, argc, min, orig_argv, &keyword_hash); } /* mandatory */ @@ -2212,7 +2221,7 @@ vm_yield_setup_block_args(rb_thread_t *th, const rb_iseq_t * iseq, /* keyword argument */ if (iseq->arg_keyword != -1) { - argc = vm_callee_setup_keyword_arg(iseq, argc, min, argv, &keyword_hash); + argc = vm_callee_setup_keyword_arg(th, iseq, argc, min, argv, &keyword_hash); } for (i=argc; i Date: Mon, 11 Aug 2014 13:43:40 +0000 Subject: [PATCH 198/343] merge revision(s) r46382,r46384,r46913: [Backport #9914] * io.c (rb_io_advise): AIX currently does not support a 32-bit call to posix_fadvise() if _LARGE_FILES is defined. Patch by Rei Odaira. [ruby-core:62968] [Bug #9914] * configure.in (posix_fadvise): disable use of posix_fadvise itself on 32-bit AIX. [ruby-core:62968] [Bug #9914] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47139 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 11 +++++++++++ configure.in | 13 ++++++++++++- version.h | 2 +- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index fd246c78032e83..a52d35f287254e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +Mon Aug 11 22:34:47 2014 Nobuyoshi Nakada + + * configure.in (posix_fadvise): disable use of posix_fadvise + itself on 32-bit AIX. [ruby-core:62968] [Bug #9914] + +Mon Aug 11 22:34:47 2014 + + * io.c (rb_io_advise): AIX currently does not support a 32-bit call to + posix_fadvise() if _LARGE_FILES is defined. Patch by Rei Odaira. + [ruby-core:62968] [Bug #9914] + Mon Aug 11 22:14:28 2014 Nobuyoshi Nakada * vm_insnhelper.c (vm_callee_setup_keyword_arg): adjust VM stack diff --git a/configure.in b/configure.in index 303d1f83e3b357..6801a07b574859 100644 --- a/configure.in +++ b/configure.in @@ -1155,7 +1155,18 @@ mv confdefs.h largefile.h mv confdefs1.h confdefs.h cat largefile.h >> confdefs.h -AS_CASE(["$target_os"],[mingw*], [ac_cv_type_off_t=yes;ac_cv_sizeof_off_t=8]) +AS_CASE(["$target_os"], + [mingw*], [ac_cv_type_off_t=yes;ac_cv_sizeof_off_t=8], + [aix*], [ + AS_CASE(["$target_cpu:$ac_cv_sys_large_files"], + [ppc64:*|powerpc64:*], [], + [*:no|*:unknown], [], + [ + # AIX currently does not support a 32-bit call to posix_fadvise() + # if _LARGE_FILES is defined. + ac_cv_posix_fadvise=no + ]) + ]) AC_C_BIGENDIAN AC_C_CONST diff --git a/version.h b/version.h index 54f0dd3c505d98..6d8999bac348de 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-08-11" -#define RUBY_PATCHLEVEL 197 +#define RUBY_PATCHLEVEL 198 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 8 From 5a5ac31458c5fed5502e4a3dd7b05868ff9379fb Mon Sep 17 00:00:00 2001 From: nagachika Date: Mon, 11 Aug 2014 14:53:01 +0000 Subject: [PATCH 199/343] merge revision(s) r46151,r46165: [Backport #9865] * io.c (rb_io_fileno, rb_io_inspect): non-modification does not error on frozen IO. [ruby-dev:48241] [Bug #9865] * io.c (rb_io_autoclose_p): Don't raise on frozen IO. * test/lib/minitest/unit.rb: IO#autoclose? may raise IOError. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47140 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 9 +++++++++ io.c | 10 +++++----- test/ruby/test_io.rb | 17 +++++++++++++++++ version.h | 2 +- 4 files changed, 32 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index a52d35f287254e..d6b1b9de4205e9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Mon Aug 11 23:38:20 2014 Tanaka Akira + + * io.c (rb_io_autoclose_p): Don't raise on frozen IO. + +Mon Aug 11 23:38:20 2014 Nobuyoshi Nakada + + * io.c (rb_io_fileno, rb_io_inspect): non-modification does not + error on frozen IO. [ruby-dev:48241] [Bug #9865] + Mon Aug 11 22:34:47 2014 Nobuyoshi Nakada * configure.in (posix_fadvise): disable use of posix_fadvise diff --git a/io.c b/io.c index e5a4d3b40c93b6..0ce71108fc32ef 100644 --- a/io.c +++ b/io.c @@ -1914,10 +1914,10 @@ rb_io_fdatasync(VALUE io) static VALUE rb_io_fileno(VALUE io) { - rb_io_t *fptr; + rb_io_t *fptr = RFILE(io)->fptr; int fd; - GetOpenFile(io, fptr); + rb_io_check_closed(fptr); fd = fptr->fd; return INT2FIX(fd); } @@ -1969,7 +1969,7 @@ rb_io_inspect(VALUE obj) VALUE result; static const char closed[] = " (closed)"; - fptr = RFILE(rb_io_taint_check(obj))->fptr; + fptr = RFILE(obj)->fptr; if (!fptr) return rb_any_to_s(obj); result = rb_str_new_cstr("#<"); rb_str_append(result, rb_class_name(CLASS_OF(obj))); @@ -7519,8 +7519,8 @@ rb_io_s_for_fd(int argc, VALUE *argv, VALUE klass) static VALUE rb_io_autoclose_p(VALUE io) { - rb_io_t *fptr; - GetOpenFile(io, fptr); + rb_io_t *fptr = RFILE(io)->fptr; + rb_io_check_closed(fptr); return (fptr->mode & FMODE_PREP) ? Qfalse : Qtrue; } diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index a7c5b2a39a8cd6..631f854a855a91 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -1122,6 +1122,8 @@ def test_dup_many def test_inspect with_pipe do |r, w| assert_match(/^#$/, r.inspect) + r.freeze + assert_match(/^#$/, r.inspect) end end @@ -2751,6 +2753,21 @@ def test_std_fileno assert_equal(2, $stderr.fileno) end + def test_frozen_fileno + bug9865 = '[ruby-dev:48241] [Bug #9865]' + with_pipe do |r,w| + fd = r.fileno + assert_equal(fd, r.freeze.fileno, bug9865) + end + end + + def test_frozen_autoclose + with_pipe do |r,w| + fd = r.fileno + assert_equal(true, r.freeze.autoclose?) + end + end + def test_sysread_locktmp bug6099 = '[ruby-dev:45297]' buf = " " * 100 diff --git a/version.h b/version.h index 6d8999bac348de..a2a9a0d960c423 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-08-11" -#define RUBY_PATCHLEVEL 198 +#define RUBY_PATCHLEVEL 199 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 8 From 5712fa573d0e8dd85b21c3bb668048f1985ccf89 Mon Sep 17 00:00:00 2001 From: nagachika Date: Mon, 11 Aug 2014 14:55:58 +0000 Subject: [PATCH 200/343] merge revision(s) r46241: [Backport #9875] * lib/erb.rb (result): [DOC] no longer accepts a Proc, as Kernel.eval does not. [fix GH-619] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ lib/erb.rb | 2 +- version.h | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index d6b1b9de4205e9..3814bd9481cfaf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Mon Aug 11 23:55:32 2014 Mark Lorenz + + * lib/erb.rb (result): [DOC] no longer accepts a Proc, as + Kernel.eval does not. [fix GH-619] + Mon Aug 11 23:38:20 2014 Tanaka Akira * io.c (rb_io_autoclose_p): Don't raise on frozen IO. diff --git a/lib/erb.rb b/lib/erb.rb index 5d32c47774de04..3c3cabe209ad8a 100644 --- a/lib/erb.rb +++ b/lib/erb.rb @@ -837,7 +837,7 @@ def run(b=new_toplevel) # the results of that code. (See ERB::new for details on how this process # can be affected by _safe_level_.) # - # _b_ accepts a Binding or Proc object which is used to set the context of + # _b_ accepts a Binding object which is used to set the context of # code evaluation. # def result(b=new_toplevel) diff --git a/version.h b/version.h index a2a9a0d960c423..7f5b320aea34a8 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-08-11" -#define RUBY_PATCHLEVEL 199 +#define RUBY_PATCHLEVEL 200 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 8 From 9355bcade93e7b58398d3d77fc7223d5818f016a Mon Sep 17 00:00:00 2001 From: nagachika Date: Mon, 18 Aug 2014 14:34:31 +0000 Subject: [PATCH 201/343] merge revision(s) r46408,r46410,r46413,r46414,r46424,r46436,r46437: [Backport #9934] string.c: shrink too big buffer * string.c (rb_str_resize): shrink the buffer even if new length is same but it is enough smaller than the capacity. * file.c (expand_path): shrink expanded path which no longer needs rooms to append. [ruby-core:63114] [Bug #9934] * string.c (rb_str_resize): should consider the capacity instead of the old length, as pointed out by nagachika. * string.c (rb_str_resize): update capa only when buffer get reallocated. http://d.hatena.ne.jp/nagachika/20140613/ruby_trunk_changes_46413_46420#r46413 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47215 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 16 ++++++++++++++++ file.c | 17 ++++++++++++++--- string.c | 11 +++++++---- test/ruby/test_file_exhaustive.rb | 9 +++++++++ version.h | 6 +++--- 5 files changed, 49 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3814bd9481cfaf..7d0912738b3b25 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +Mon Aug 18 23:22:03 2014 Nobuyoshi Nakada + + * string.c (rb_str_resize): update capa only when buffer get + reallocated. + http://d.hatena.ne.jp/nagachika/20140613/ruby_trunk_changes_46413_46420#r46413 + +Mon Aug 18 23:22:03 2014 Nobuyoshi Nakada + + * string.c (rb_str_resize): should consider the capacity instead + of the old length, as pointed out by nagachika. + +Mon Aug 18 23:22:03 2014 Nobuyoshi Nakada + + * file.c (expand_path): shrink expanded path which no longer needs + rooms to append. [ruby-core:63114] [Bug #9934] + Mon Aug 11 23:55:32 2014 Mark Lorenz * lib/erb.rb (result): [DOC] no longer accepts a Proc, as diff --git a/file.c b/file.c index 77facacfcf202a..e9e2dd134030bf 100644 --- a/file.c +++ b/file.c @@ -3397,6 +3397,16 @@ rb_file_expand_path_internal(VALUE fname, VALUE dname, int abs_mode, int long_na #define EXPAND_PATH_BUFFER() rb_usascii_str_new(0, MAXPATHLEN + 2) +static VALUE +str_shrink(VALUE str) +{ + rb_str_resize(str, RSTRING_LEN(str)); + return str; +} + +#define expand_path(fname, dname, abs_mode, long_name, result) \ + str_shrink(rb_file_expand_path_internal(fname, dname, abs_mode, long_name, result)) + #define check_expand_path_args(fname, dname) \ (((fname) = rb_get_path(fname)), \ (void)(NIL_P(dname) ? (dname) : ((dname) = rb_get_path(dname)))) @@ -3411,13 +3421,13 @@ VALUE rb_file_expand_path(VALUE fname, VALUE dname) { check_expand_path_args(fname, dname); - return rb_file_expand_path_internal(fname, dname, 0, 1, EXPAND_PATH_BUFFER()); + return expand_path(fname, dname, 0, 1, EXPAND_PATH_BUFFER()); } VALUE rb_file_expand_path_fast(VALUE fname, VALUE dname) { - return rb_file_expand_path_internal(fname, dname, 0, 0, EXPAND_PATH_BUFFER()); + return expand_path(fname, dname, 0, 0, EXPAND_PATH_BUFFER()); } /* @@ -3465,7 +3475,7 @@ VALUE rb_file_absolute_path(VALUE fname, VALUE dname) { check_expand_path_args(fname, dname); - return rb_file_expand_path_internal(fname, dname, 1, 1, EXPAND_PATH_BUFFER()); + return expand_path(fname, dname, 1, 1, EXPAND_PATH_BUFFER()); } /* @@ -5408,6 +5418,7 @@ is_explicit_relative(const char *path) static VALUE copy_path_class(VALUE path, VALUE orig) { + str_shrink(path); RBASIC_SET_CLASS(path, rb_obj_class(orig)); OBJ_FREEZE(path); return path; diff --git a/string.c b/string.c index 006a8b4639c06e..36f68887786dae 100644 --- a/string.c +++ b/string.c @@ -2034,9 +2034,11 @@ rb_str_resize(VALUE str, long len) independent = str_independent(str); ENC_CODERANGE_CLEAR(str); slen = RSTRING_LEN(str); - if (len != slen) { + { + long capa; const int termlen = TERM_LEN(str); if (STR_EMBED_P(str)) { + if (len == slen) return str; if (len + termlen <= RSTRING_EMBED_LEN_MAX + 1) { STR_SET_EMBED_LEN(str, len); TERM_FILL(RSTRING(str)->as.ary + len, termlen); @@ -2056,14 +2058,15 @@ rb_str_resize(VALUE str, long len) return str; } else if (!independent) { + if (len == slen) return str; str_make_independent_expand(str, len - slen); } - else if (slen < len || slen - len > 1024) { + else if ((capa = RSTRING(str)->as.heap.aux.capa) < len || + (capa - len) > (len < 1024 ? len : 1024)) { REALLOC_N(RSTRING(str)->as.heap.ptr, char, len + termlen); - } - if (!STR_NOCAPA_P(str)) { RSTRING(str)->as.heap.aux.capa = len; } + else if (len == slen) return str; RSTRING(str)->as.heap.len = len; TERM_FILL(RSTRING(str)->as.heap.ptr + len, termlen); /* sentinel */ } diff --git a/test/ruby/test_file_exhaustive.rb b/test/ruby/test_file_exhaustive.rb index 2c945eac626f19..bd69addef65a02 100644 --- a/test/ruby/test_file_exhaustive.rb +++ b/test/ruby/test_file_exhaustive.rb @@ -458,6 +458,15 @@ def test_expand_path end end + def test_expand_path_memsize + bug9934 = '[ruby-core:63114] [Bug #9934]' + require "objspace" + path = File.expand_path("/foo") + assert_operator(ObjectSpace.memsize_of(path), :<=, path.bytesize, bug9934) + path = File.expand_path("/a"*25) + assert_equal(path.bytesize+1, ObjectSpace.memsize_of(path), bug9934) + end + def test_expand_path_encoding drive = (DRIVE ? 'C:' : '') if Encoding.find("filesystem") == Encoding::CP1251 diff --git a/version.h b/version.h index 7f5b320aea34a8..26ad6125a6447e 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.2" -#define RUBY_RELEASE_DATE "2014-08-11" -#define RUBY_PATCHLEVEL 200 +#define RUBY_RELEASE_DATE "2014-08-18" +#define RUBY_PATCHLEVEL 201 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 8 -#define RUBY_RELEASE_DAY 11 +#define RUBY_RELEASE_DAY 18 #include "ruby/version.h" From 661148ad9efac4c2701e0e540323fd487e75d5bf Mon Sep 17 00:00:00 2001 From: nagachika Date: Mon, 18 Aug 2014 14:38:34 +0000 Subject: [PATCH 202/343] merge revision(s) r46481: [Backport #9966] * encoding.c (enc_find): [DOC] never accepted a symbol. [ruby-dev:48308] [Bug #9966] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47216 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ encoding.c | 4 +--- version.h | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7d0912738b3b25..9559168c31c41e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Mon Aug 18 23:38:21 2014 Nobuyoshi Nakada + + * encoding.c (enc_find): [DOC] never accepted a symbol. + [ruby-dev:48308] [Bug #9966] + Mon Aug 18 23:22:03 2014 Nobuyoshi Nakada * string.c (rb_str_resize): update capa only when buffer get diff --git a/encoding.c b/encoding.c index f102524379fc22..9ade26d2917153 100644 --- a/encoding.c +++ b/encoding.c @@ -1142,13 +1142,11 @@ enc_list(VALUE klass) /* * call-seq: * Encoding.find(string) -> enc - * Encoding.find(symbol) -> enc * * Search the encoding with specified name. - * name should be a string or symbol. + * name should be a string. * * Encoding.find("US-ASCII") #=> # - * Encoding.find(:Shift_JIS) #=> # * * Names which this method accept are encoding names and aliases * including following special aliases diff --git a/version.h b/version.h index 26ad6125a6447e..e8289d9140c2ab 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-08-18" -#define RUBY_PATCHLEVEL 201 +#define RUBY_PATCHLEVEL 202 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 8 From c3fd3191fc9801b43daa0125d1df1ced383011b8 Mon Sep 17 00:00:00 2001 From: nagachika Date: Tue, 19 Aug 2014 15:03:26 +0000 Subject: [PATCH 203/343] merge r46831 partially. extracted commits are as follows. https://github.com/k-takata/Onigmo/commit/b9fba1dc63ccb42a86e934011b468e6022fabb74 https://github.com/k-takata/Onigmo/commit/c1fc76b9bd463948ffc5058bc352bf93732f0314 https://github.com/k-takata/Onigmo/commit/a0efc0a200f7108ca3d5ac3039c8f952e0051619 https://github.com/k-takata/Onigmo/commit/c7cda4ed5676167b0d01bb5555724f6164fbdb13 [Bug #8716] * include/ruby/oniguruma.h (ONIG_MAX_CAPTURE_GROUP_NUM, ONIGERR_TOO_MANY_CAPTURE_GROUPS): add cheking the number of capture groups. * regerror.c (onig_error_code_to_format): ditto. * regparse.c (scan_env_add_mem_entry): ditto. * regexec.c (onig_region_copy, match_at): fix: segmation fault occurs when many groups are used. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47223 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 20 ++++++++++++++++++++ include/ruby/oniguruma.h | 2 ++ regerror.c | 2 ++ regexec.c | 37 ++++++++++++++++++++++++++++++++----- regparse.c | 2 ++ version.h | 6 +++--- 6 files changed, 61 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9559168c31c41e..3d91c0684c2add 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,23 @@ +Tue Aug 19 23:31:48 2014 CHIKANAGA Tomoyuki + + merge r46831 partially. extracted commits are as follows. + https://github.com/k-takata/Onigmo/commit/b9fba1dc63ccb42a86e934011b468e6022fabb74 + https://github.com/k-takata/Onigmo/commit/c1fc76b9bd463948ffc5058bc352bf93732f0314 + https://github.com/k-takata/Onigmo/commit/a0efc0a200f7108ca3d5ac3039c8f952e0051619 + https://github.com/k-takata/Onigmo/commit/c7cda4ed5676167b0d01bb5555724f6164fbdb13 + [Bug #8716] + + * include/ruby/oniguruma.h (ONIG_MAX_CAPTURE_GROUP_NUM, + ONIGERR_TOO_MANY_CAPTURE_GROUPS): add cheking the number of capture + groups. + + * regerror.c (onig_error_code_to_format): ditto. + + * regparse.c (scan_env_add_mem_entry): ditto. + + * regexec.c (onig_region_copy, match_at): fix: segmation fault occurs + when many groups are used. + Mon Aug 18 23:38:21 2014 Nobuyoshi Nakada * encoding.c (enc_find): [DOC] never accepted a symbol. diff --git a/include/ruby/oniguruma.h b/include/ruby/oniguruma.h index 6a26ee4aaa6f18..d533a05b6674b5 100644 --- a/include/ruby/oniguruma.h +++ b/include/ruby/oniguruma.h @@ -338,6 +338,7 @@ int onigenc_str_bytelen_null P_((OnigEncoding enc, const OnigUChar* p)); /* config parameters */ #define ONIG_NREGION 10 #define ONIG_MAX_BACKREF_NUM 1000 +#define ONIG_MAX_CAPTURE_GROUP_NUM 32767 #define ONIG_MAX_REPEAT_NUM 100000 #define ONIG_MAX_MULTI_BYTE_RANGES_NUM 10000 /* constants */ @@ -582,6 +583,7 @@ ONIG_EXTERN const OnigSyntaxType* OnigDefaultSyntax; #define ONIGERR_NEVER_ENDING_RECURSION -221 #define ONIGERR_GROUP_NUMBER_OVER_FOR_CAPTURE_HISTORY -222 #define ONIGERR_INVALID_CHAR_PROPERTY_NAME -223 +#define ONIGERR_TOO_MANY_CAPTURE_GROUPS -224 #define ONIGERR_INVALID_CODE_POINT_VALUE -400 #define ONIGERR_INVALID_WIDE_CHAR_VALUE -400 #define ONIGERR_TOO_BIG_WIDE_CHAR_VALUE -401 diff --git a/regerror.c b/regerror.c index 9c94d230180ad2..d32b50d12b62c1 100644 --- a/regerror.c +++ b/regerror.c @@ -133,6 +133,8 @@ onig_error_code_to_format(OnigPosition code) p = "too short multibyte code string"; break; case ONIGERR_TOO_BIG_BACKREF_NUMBER: p = "too big backref number"; break; + case ONIGERR_TOO_MANY_CAPTURE_GROUPS: + p = "too many capture groups are specified"; break; case ONIGERR_INVALID_BACKREF: #ifdef USE_NAMED_GROUP p = "invalid backref number/name"; break; diff --git a/regexec.c b/regexec.c index 997849695e5ab5..973d3eac0004e6 100644 --- a/regexec.c +++ b/regexec.c @@ -444,9 +444,26 @@ onig_region_copy(OnigRegion* to, OnigRegion* from) -#define STACK_INIT(alloc_addr, ptr_num, stack_num) do {\ - if (msa->stack_p) {\ +#define MAX_PTR_NUM 100 + +#define STACK_INIT(alloc_addr, heap_addr, ptr_num, stack_num) do {\ + if (ptr_num > MAX_PTR_NUM) {\ + alloc_addr = (char* )xmalloc(sizeof(OnigStackIndex) * (ptr_num));\ + heap_addr = alloc_addr;\ + if (msa->stack_p) {\ + stk_alloc = (OnigStackType* )(msa->stack_p);\ + stk_base = stk_alloc;\ + stk = stk_base;\ + stk_end = stk_base + msa->stack_n;\ + } else {\ + stk_alloc = (OnigStackType* )xalloca(sizeof(OnigStackType) * (stack_num));\ + stk_base = stk_alloc;\ + stk = stk_base;\ + stk_end = stk_base + (stack_num);\ + }\ + } else if (msa->stack_p) {\ alloc_addr = (char* )xalloca(sizeof(OnigStackIndex) * (ptr_num));\ + heap_addr = NULL;\ stk_alloc = (OnigStackType* )(msa->stack_p);\ stk_base = stk_alloc;\ stk = stk_base;\ @@ -455,6 +472,7 @@ onig_region_copy(OnigRegion* to, OnigRegion* from) else {\ alloc_addr = (char* )xalloca(sizeof(OnigStackIndex) * (ptr_num)\ + sizeof(OnigStackType) * (stack_num));\ + heap_addr = NULL;\ stk_alloc = (OnigStackType* )(alloc_addr + sizeof(OnigStackIndex) * (ptr_num));\ stk_base = stk_alloc;\ stk = stk_base;\ @@ -529,7 +547,11 @@ stack_double(OnigStackType** arg_stk_base, OnigStackType** arg_stk_end, #define STACK_ENSURE(n) do {\ if (stk_end - stk < (n)) {\ int r = stack_double(&stk_base, &stk_end, &stk, stk_alloc, msa);\ - if (r != 0) { STACK_SAVE; return r; } \ + if (r != 0) {\ + STACK_SAVE;\ + if (xmalloc_base) xfree(xmalloc_base);\ + return r;\ + }\ }\ } while(0) @@ -1325,6 +1347,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, UChar *p = reg->p; UChar *pkeep; char *alloca_base; + char *xmalloc_base = NULL; OnigStackType *stk_alloc, *stk_base, *stk, *stk_end; OnigStackType *stkp; /* used as any purpose. */ OnigStackIndex si; @@ -1340,7 +1363,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, /* Stack #0 is used to store the pattern itself and used for (?R), \g<0>, etc. */ n = reg->num_repeat + (reg->num_mem + 1) * 2; - STACK_INIT(alloca_base, n, INIT_MATCH_STACK_SIZE); + STACK_INIT(alloca_base, xmalloc_base, n, INIT_MATCH_STACK_SIZE); pop_level = reg->stack_pop_level; num_mem = reg->num_mem; repeat_stk = (OnigStackIndex* )alloca_base; @@ -1354,7 +1377,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, /* Stack #0 not is used. */ n = reg->num_repeat + reg->num_mem * 2; - STACK_INIT(alloca_base, n, INIT_MATCH_STACK_SIZE); + STACK_INIT(alloca_base, xmalloc_base, n, INIT_MATCH_STACK_SIZE); pop_level = reg->stack_pop_level; num_mem = reg->num_mem; repeat_stk = (OnigStackIndex* )alloca_base; @@ -2916,20 +2939,24 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, finish: STACK_SAVE; + if (xmalloc_base) xfree(xmalloc_base); return best_len; #ifdef ONIG_DEBUG stack_error: STACK_SAVE; + if (xmalloc_base) xfree(xmalloc_base); return ONIGERR_STACK_BUG; #endif bytecode_error: STACK_SAVE; + if (xmalloc_base) xfree(xmalloc_base); return ONIGERR_UNDEFINED_BYTECODE; unexpected_bytecode_error: STACK_SAVE; + if (xmalloc_base) xfree(xmalloc_base); return ONIGERR_UNEXPECTED_BYTECODE; } diff --git a/regparse.c b/regparse.c index 774ee0a9601853..fac79a311b4cf5 100644 --- a/regparse.c +++ b/regparse.c @@ -978,6 +978,8 @@ scan_env_add_mem_entry(ScanEnv* env) Node** p; need = env->num_mem + 1; + if (need > ONIG_MAX_CAPTURE_GROUP_NUM) + return ONIGERR_TOO_MANY_CAPTURE_GROUPS; if (need >= SCANENV_MEMNODES_SIZE) { if (env->mem_alloc <= need) { if (IS_NULL(env->mem_nodes_dynamic)) { diff --git a/version.h b/version.h index e8289d9140c2ab..372698234e4a5c 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.2" -#define RUBY_RELEASE_DATE "2014-08-18" -#define RUBY_PATCHLEVEL 202 +#define RUBY_RELEASE_DATE "2014-08-20" +#define RUBY_PATCHLEVEL 203 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 8 -#define RUBY_RELEASE_DAY 18 +#define RUBY_RELEASE_DAY 20 #include "ruby/version.h" From 447e1c4d199181bc02935e00589c3cc2668a5e1e Mon Sep 17 00:00:00 2001 From: nagachika Date: Wed, 20 Aug 2014 16:41:49 +0000 Subject: [PATCH 204/343] merge revision(s) r45349,r45837,r45838: [Backport #9521] [Backport #9682] * lib/time.rb: [DOC] Fix timezone in example of Time.parse [Bug #9521] Based on patch by @stomar * lib/time.rb (Time.parse): [DOC] Fix an example in the documentation. Reported by Marcus Stollsteimer. [ruby-core:60778] [Bug #9521] and [ruby-core:61718] [Bug #9682] * lib/time.rb (Time.parse): [DOC] Fix an example in the documentation to use EST. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47228 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 12 ++++++++++++ lib/time.rb | 14 +++++++------- version.h | 6 +++--- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3d91c0684c2add..bd9af1507871bc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +Thu Aug 21 01:41:09 2014 Tanaka Akira + + * lib/time.rb (Time.parse): [DOC] Fix an example in the documentation + to use EST. + Reported by Marcus Stollsteimer. + [ruby-core:60778] [Bug #9521] and [ruby-core:61718] [Bug #9682] + +Thu Aug 21 01:41:09 2014 Zachary Scott + + * lib/time.rb: [DOC] Fix timezone in example of Time.parse [Bug #9521] + Based on patch by @stomar + Tue Aug 19 23:31:48 2014 CHIKANAGA Tomoyuki merge r46831 partially. extracted commits are as follows. diff --git a/lib/time.rb b/lib/time.rb index 0b554803340fc3..dd7a513dbaed9b 100644 --- a/lib/time.rb +++ b/lib/time.rb @@ -278,13 +278,13 @@ def make_time(year, mon, day, hour, min, sec, sec_fraction, zone, now) # supplied with those of +now+. For the lower components, the minimum # values (1 or 0) are assumed if broken or missing. For example: # - # # Suppose it is "Thu Nov 29 14:33:20 GMT 2001" now and - # # your time zone is GMT: - # now = Time.parse("Thu Nov 29 14:33:20 GMT 2001") - # Time.parse("16:30", now) #=> 2001-11-29 16:30:00 +0900 - # Time.parse("7/23", now) #=> 2001-07-23 00:00:00 +0900 - # Time.parse("Aug 31", now) #=> 2001-08-31 00:00:00 +0900 - # Time.parse("Aug 2000", now) #=> 2000-08-01 00:00:00 +0900 + # # Suppose it is "Thu Nov 29 14:33:20 2001" now and + # # your time zone is EST which is GMT-5. + # now = Time.parse("Thu Nov 29 14:33:20 2001") + # Time.parse("16:30", now) #=> 2001-11-29 16:30:00 -0500 + # Time.parse("7/23", now) #=> 2001-07-23 00:00:00 -0500 + # Time.parse("Aug 31", now) #=> 2001-08-31 00:00:00 -0500 + # Time.parse("Aug 2000", now) #=> 2000-08-01 00:00:00 -0500 # # Since there are numerous conflicts among locally defined time zone # abbreviations all over the world, this method is not intended to diff --git a/version.h b/version.h index 372698234e4a5c..131c21a9b946a4 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.2" -#define RUBY_RELEASE_DATE "2014-08-20" -#define RUBY_PATCHLEVEL 203 +#define RUBY_RELEASE_DATE "2014-08-21" +#define RUBY_PATCHLEVEL 204 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 8 -#define RUBY_RELEASE_DAY 20 +#define RUBY_RELEASE_DAY 21 #include "ruby/version.h" From ff089f50a11a1196f18135b5ef012fc812fa17f8 Mon Sep 17 00:00:00 2001 From: nagachika Date: Wed, 20 Aug 2014 16:52:33 +0000 Subject: [PATCH 205/343] merge revision(s) r45542,r45543: [Backport #9717] * gc.c (mark_current_machine_context): Call SET_STACK_END. This reverts a hunk of r40703 by ko1. This fixes [ruby-dev:48098] [Bug #9717]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47229 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ gc.c | 4 ++++ version.h | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index bd9af1507871bc..edc1bae3151d45 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Thu Aug 21 01:44:46 2014 Tanaka Akira + + * gc.c (mark_current_machine_context): Call SET_STACK_END. + This reverts a hunk of r40703 by ko1. + This fixes [ruby-dev:48098] [Bug #9717]. + Thu Aug 21 01:41:09 2014 Tanaka Akira * lib/time.rb (Time.parse): [DOC] Fix an example in the documentation diff --git a/gc.c b/gc.c index 5dbf349669ebf4..b2d8bfb83e08c0 100644 --- a/gc.c +++ b/gc.c @@ -3478,6 +3478,10 @@ mark_current_machine_context(rb_objspace_t *objspace, rb_thread_t *th) /* This assumes that all registers are saved into the jmp_buf (and stack) */ rb_setjmp(save_regs_gc_mark.j); + /* SET_STACK_END must be called in this function because + * the stack frame of this function may contain + * callee save registers and they should be marked. */ + SET_STACK_END; GET_STACK_BOUNDS(stack_start, stack_end, 1); mark_locations_array(objspace, save_regs_gc_mark.v, numberof(save_regs_gc_mark.v)); diff --git a/version.h b/version.h index 131c21a9b946a4..6aee6bbc6b6e5c 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-08-21" -#define RUBY_PATCHLEVEL 204 +#define RUBY_PATCHLEVEL 205 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 8 From b4893fc3d159204f567da5337494e224d65f6fbf Mon Sep 17 00:00:00 2001 From: nagachika Date: Fri, 22 Aug 2014 17:37:57 +0000 Subject: [PATCH 206/343] merge revision(s) r46896,r46897,r46898: [Backport #10078] * string.c (rb_str_count): fix wrong single-byte optimization. 7bit ascii can be a trailing byte in Shift_JIS. [ruby-dev:48442] [Bug #10078] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47255 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ string.c | 29 ++++++++++++++++++++--------- test/ruby/test_m17n.rb | 5 +++++ test/ruby/test_m17n_comb.rb | 12 +++++++++--- version.h | 6 +++--- 5 files changed, 43 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index edc1bae3151d45..fb5f4a769dbdfa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sat Aug 23 02:22:02 2014 Nobuyoshi Nakada + + * string.c (rb_str_count): fix wrong single-byte optimization. + 7bit ascii can be a trailing byte in Shift_JIS. + [ruby-dev:48442] [Bug #10078] + Thu Aug 21 01:44:46 2014 Tanaka Akira * gc.c (mark_current_machine_context): Call SET_STACK_END. diff --git a/string.c b/string.c index 36f68887786dae..e6f72bc5e74766 100644 --- a/string.c +++ b/string.c @@ -6059,21 +6059,25 @@ rb_str_count(int argc, VALUE *argv, VALUE str) { char table[TR_TABLE_SIZE]; rb_encoding *enc = 0; - VALUE del = 0, nodel = 0; + VALUE del = 0, nodel = 0, tstr; char *s, *send; int i; int ascompat; rb_check_arity(argc, 1, UNLIMITED_ARGUMENTS); - for (i=0; i Date: Fri, 22 Aug 2014 17:49:32 +0000 Subject: [PATCH 207/343] merge revision(s) r47037: [Backport #10106] * vm_insnhelper.c (vm_call_method): unusable super class should cause method missing when BasicObject is refined but not been using. [ruby-core:64166] [Bug #10106] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47256 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ test/ruby/test_refinement.rb | 15 +++++++++++++++ version.h | 2 +- vm_insnhelper.c | 4 ++++ 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index fb5f4a769dbdfa..c9cc66e4f49b9e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sat Aug 23 02:39:20 2014 Nobuyoshi Nakada + + * vm_insnhelper.c (vm_call_method): unusable super class should cause + method missing when BasicObject is refined but not been using. + [ruby-core:64166] [Bug #10106] + Sat Aug 23 02:22:02 2014 Nobuyoshi Nakada * string.c (rb_str_count): fix wrong single-byte optimization. diff --git a/test/ruby/test_refinement.rb b/test/ruby/test_refinement.rb index d535c474241d5d..77e4789bfc7a37 100644 --- a/test/ruby/test_refinement.rb +++ b/test/ruby/test_refinement.rb @@ -1152,6 +1152,21 @@ def m INPUT end + def test_refine_basic_object + assert_separately([], <<-"end;") + bug10106 = '[ruby-core:64166] [Bug #10106]' + module RefinementBug + refine BasicObject do + def foo + 1 + end + end + end + + assert_raise(NoMethodError, bug10106) {Object.new.foo} + end; + end + private def eval_using(mod, s) diff --git a/version.h b/version.h index 9dfc72dd49da31..16f3b820922d9f 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-08-23" -#define RUBY_PATCHLEVEL 206 +#define RUBY_PATCHLEVEL 207 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 8 diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 03493c13c8c719..f52a8f562d7b6c 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -1791,6 +1791,10 @@ vm_call_method(rb_thread_t *th, rb_control_frame_t *cfp, rb_call_info_t *ci) klass = RCLASS_ORIGIN(klass); zsuper_method_dispatch: klass = RCLASS_SUPER(klass); + if (!klass) { + ci->me = 0; + goto start_method_dispatch; + } ci_temp = *ci; ci = &ci_temp; From 9704c840361094663bf276131ad754a05736eaab Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 24 Aug 2014 15:35:33 +0000 Subject: [PATCH 208/343] merge revision(s) r47090: [Backport #10114] * parse.y (parser_yyerror): preserve source code encoding in syntax error messages. [ruby-core:64228] [Bug #10114] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47267 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ parse.y | 2 +- test/ruby/test_syntax.rb | 6 ++++++ version.h | 6 +++--- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index c9cc66e4f49b9e..034fa785a5b1dd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Mon Aug 25 00:26:12 2014 Nobuyoshi Nakada + + * parse.y (parser_yyerror): preserve source code encoding in + syntax error messages. [ruby-core:64228] [Bug #10114] + Sat Aug 23 02:39:20 2014 Nobuyoshi Nakada * vm_insnhelper.c (vm_call_method): unusable super class should cause diff --git a/parse.y b/parse.y index 3f01a224289080..7f0c3525a0eff4 100644 --- a/parse.y +++ b/parse.y @@ -5269,7 +5269,7 @@ parser_yyerror(struct parser_params *parser, const char *msg) buf = ALLOCA_N(char, len+2); MEMCPY(buf, p, char, len); buf[len] = '\0'; - rb_compile_error_append("%s%s%s", pre, buf, post); + rb_compile_error_with_enc(NULL, 0, (void *)current_enc, "%s%s%s", pre, buf, post); i = (int)(lex_p - p); p2 = buf; pe = buf + len; diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index 9fa28a4a8a6991..2ed57889ba5e05 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -402,6 +402,12 @@ def test_warning_for_cr end end + def test_error_message_encoding + bug10114 = '[ruby-core:64228] [Bug #10114]' + code = "# -*- coding: utf-8 -*-\n" "def n \"\u{2208}\"; end" + assert_syntax_error(code, /def n "\u{2208}"; end/, bug10114) + end + private def not_label(x) @result = x; @not_label ||= nil end diff --git a/version.h b/version.h index 16f3b820922d9f..93d441f8ed1461 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.2" -#define RUBY_RELEASE_DATE "2014-08-23" -#define RUBY_PATCHLEVEL 207 +#define RUBY_RELEASE_DATE "2014-08-25" +#define RUBY_PATCHLEVEL 208 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 8 -#define RUBY_RELEASE_DAY 23 +#define RUBY_RELEASE_DAY 25 #include "ruby/version.h" From a4f174ac302ec6f8b52091a27ddb6aaab5319e23 Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 24 Aug 2014 15:44:20 +0000 Subject: [PATCH 209/343] merge revision(s) r47098: [Backport #10117] * parse.y (parser_yylex): fix invalid char in eval, should raise an syntax error too, as well as directly coded. [ruby-core:64243] [Bug #10117] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47268 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ parse.y | 2 +- test/ruby/test_parse.rb | 5 ++++- version.h | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 034fa785a5b1dd..44e30b830aa714 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Mon Aug 25 00:36:56 2014 Nobuyoshi Nakada + + * parse.y (parser_yylex): fix invalid char in eval, should raise + an syntax error too, as well as directly coded. + [ruby-core:64243] [Bug #10117] + Mon Aug 25 00:26:12 2014 Nobuyoshi Nakada * parse.y (parser_yyerror): preserve source code encoding in diff --git a/parse.y b/parse.y index 7f0c3525a0eff4..cc3a638b3653ba 100644 --- a/parse.y +++ b/parse.y @@ -8090,7 +8090,7 @@ parser_yylex(struct parser_params *parser) default: if (!parser_is_identchar()) { - rb_compile_error(PARSER_ARG "Invalid char `\\x%02X' in expression", c); + compile_error(PARSER_ARG "Invalid char `\\x%02X' in expression", c); goto retry; } diff --git a/test/ruby/test_parse.rb b/test/ruby/test_parse.rb index 863d37909647c8..9ef311b934df18 100644 --- a/test/ruby/test_parse.rb +++ b/test/ruby/test_parse.rb @@ -658,8 +658,11 @@ def test_invalid_class_variable end def test_invalid_char + bug10117 = '[ruby-core:64243] [Bug #10117]' + invalid_char = /Invalid char `\\x01'/ x = 1 - assert_equal(1, eval("\x01x")) + assert_in_out_err(%W"-e \x01x", "", [], invalid_char, bug10117) + assert_syntax_error("\x01x", invalid_char, bug10117) assert_equal(nil, eval("\x04x")) end diff --git a/version.h b/version.h index 93d441f8ed1461..555bc7b60541a7 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-08-25" -#define RUBY_PATCHLEVEL 208 +#define RUBY_PATCHLEVEL 209 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 8 From 6f6a076086f85942bb5eb22a4fda275a25dbe59f Mon Sep 17 00:00:00 2001 From: nagachika Date: Mon, 25 Aug 2014 15:03:42 +0000 Subject: [PATCH 210/343] merge revision(s) r45503,r45504,r45508,r45509,r47275: [Backport #9692] * configure.in (ac_cv_func___builtin_setjmp): gcc 4.9 disallows a variable as the second argument of __builtin_longjmp(). [ruby-core:61800] [Bug #9692] * configure.in (ac_cv_func___builtin_setjmp): __builtin_longjmp() in clang 5.1 uses `void**`, not `jmp_buf`. [Bug #9692] * configure.in (ac_cv_func___builtin_setjmp): __builtin_longjmp() in Apple LLVM 5.1 (LLVM 3.4svn) uses `void**`, not `jmp_buf`. [Bug #9692] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47276 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 12 ++++++++++++ configure.in | 28 +++++++++++++++++++++------- eval_intern.h | 3 ++- version.h | 6 +++--- 4 files changed, 38 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 44e30b830aa714..6cf6df4eb67c49 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +Tue Aug 26 00:02:51 2014 Nobuyoshi Nakada + + * configure.in (ac_cv_func___builtin_setjmp): __builtin_longjmp() + in Apple LLVM 5.1 (LLVM 3.4svn) uses `void**`, not `jmp_buf`. + [Bug #9692] + +Tue Aug 26 00:02:51 2014 Nobuyoshi Nakada + + * configure.in (ac_cv_func___builtin_setjmp): gcc 4.9 disallows a + variable as the second argument of __builtin_longjmp(). + [ruby-core:61800] [Bug #9692] + Mon Aug 25 00:36:56 2014 Nobuyoshi Nakada * parse.y (parser_yylex): fix invalid char in eval, should raise diff --git a/configure.in b/configure.in index 6801a07b574859..dc55f55b3a0a15 100644 --- a/configure.in +++ b/configure.in @@ -2022,13 +2022,25 @@ AC_CACHE_CHECK(for sigsetjmp as a macro or function, ac_cv_func_sigsetjmp, ac_cv_func_sigsetjmp=yes, ac_cv_func_sigsetjmp=no)]) +if test x"${ac_cv_func___builtin_setjmp}" = xyes; then + unset ac_cv_func___builtin_setjmp +fi AC_CACHE_CHECK(for __builtin_setjmp, ac_cv_func___builtin_setjmp, +[ +for cast in "" "(void *)"; do +RUBY_WERROR_FLAG( [AC_TRY_LINK([@%:@include - jmp_buf jb; void t(v) int v; {__builtin_longjmp(jb, v);}], - [__builtin_setjmp(jb);], - [ac_cv_func___builtin_setjmp=yes], + @%:@include + jmp_buf jb; + void t(void) {__builtin_longjmp($cast jb, 1);}], + [ + void (*volatile f)(void) = t; + if (!__builtin_setjmp($cast jb)) printf("%d\n", f != 0); + ], + [ac_cv_func___builtin_setjmp="yes with cast ($cast)"; break], [ac_cv_func___builtin_setjmp=no]) ]) +done]) # we don't use _setjmp if _longjmp doesn't exist. test x$ac_cv_func__longjmp = xno && ac_cv_func__setjmp=no @@ -2046,11 +2058,13 @@ AC_ARG_WITH(setjmp-type, [setjmpex], [ setjmp_prefix= setjmp_suffix=ex], [''], [ unset setjmp_prefix], [ AC_MSG_ERROR(invalid setjmp type: $withval)])], [unset setjmp_prefix]) +setjmp_cast= if test ${setjmp_prefix+set}; then if test "${setjmp_prefix}" && eval test '$ac_cv_func_'${setjmp_prefix}setjmp${setjmp_suffix} = no; then AC_MSG_ERROR(${setjmp_prefix}setjmp${setjmp_suffix} is not available) fi -elif test "$ac_cv_func___builtin_setjmp" = yes; then +elif { AS_CASE("$ac_cv_func___builtin_setjmp", [yes*], [true], [false]); }; then + setjmp_cast=`expr "$ac_cv_func___builtin_setjmp" : "yes with cast (\(.*\))"` setjmp_prefix=__builtin_ setjmp_suffix= elif test "$ac_cv_header_setjmpex_h:$ac_cv_func__setjmpex" = yes:yes; then @@ -2071,9 +2085,9 @@ if test x$setjmp_prefix = xsig; then else unset setjmp_sigmask fi -AC_MSG_RESULT(${setjmp_prefix}setjmp${setjmp_suffix}) -AC_DEFINE_UNQUOTED([RUBY_SETJMP(env)], [${setjmp_prefix}setjmp${setjmp_suffix}(env${setjmp_sigmask+,0})]) -AC_DEFINE_UNQUOTED([RUBY_LONGJMP(env,val)], [${setjmp_prefix}longjmp(env,val)]) +AC_MSG_RESULT(${setjmp_prefix}setjmp${setjmp_suffix}${setjmp_cast:+($setjmp_cast)}) +AC_DEFINE_UNQUOTED([RUBY_SETJMP(env)], [${setjmp_prefix}setjmp${setjmp_suffix}($setjmp_cast(env)${setjmp_sigmask+,0})]) +AC_DEFINE_UNQUOTED([RUBY_LONGJMP(env,val)], [${setjmp_prefix}longjmp($setjmp_cast(env),val)]) AC_DEFINE_UNQUOTED(RUBY_JMP_BUF, ${setjmp_sigmask+${setjmp_prefix}}jmp_buf) # End of setjmp check. diff --git a/eval_intern.h b/eval_intern.h index 5064fde2576e6a..2e00efde032654 100644 --- a/eval_intern.h +++ b/eval_intern.h @@ -154,7 +154,8 @@ NORETURN(static inline void rb_threadptr_tag_jump(rb_thread_t *, int)); static inline void rb_threadptr_tag_jump(rb_thread_t *th, int st) { - ruby_longjmp(th->tag->buf, (th->state = st)); + th->state = st; + ruby_longjmp(th->tag->buf, 1); } /* diff --git a/version.h b/version.h index 555bc7b60541a7..21ebbeb37ad473 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.2" -#define RUBY_RELEASE_DATE "2014-08-25" -#define RUBY_PATCHLEVEL 209 +#define RUBY_RELEASE_DATE "2014-08-26" +#define RUBY_PATCHLEVEL 210 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 8 -#define RUBY_RELEASE_DAY 25 +#define RUBY_RELEASE_DAY 26 #include "ruby/version.h" From fc6dd7dbc7f24ce9b1903a7228942a5da399552a Mon Sep 17 00:00:00 2001 From: nagachika Date: Mon, 25 Aug 2014 15:06:14 +0000 Subject: [PATCH 211/343] merge revision(s) r45512,r45513,r45515: [Backport #9698] configure.in: indent * configure.in (ac_cv_func___builtin_setjmp): adjust indent. * configure.in (ac_cv_func___builtin_setjmp): should not skip flags restoration in RUBY_WERROR_FLAG by `break`. [ruby-dev:48086] [Bug #9698] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47277 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ configure.in | 30 ++++++++++++++++-------------- version.h | 2 +- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6cf6df4eb67c49..7876784187f158 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Tue Aug 26 00:06:05 2014 Nobuyoshi Nakada + + * configure.in (ac_cv_func___builtin_setjmp): should not skip + flags restoration in RUBY_WERROR_FLAG by `break`. + [ruby-dev:48086] [Bug #9698] + Tue Aug 26 00:02:51 2014 Nobuyoshi Nakada * configure.in (ac_cv_func___builtin_setjmp): __builtin_longjmp() diff --git a/configure.in b/configure.in index dc55f55b3a0a15..0d9f0312db8fa6 100644 --- a/configure.in +++ b/configure.in @@ -2026,21 +2026,23 @@ if test x"${ac_cv_func___builtin_setjmp}" = xyes; then unset ac_cv_func___builtin_setjmp fi AC_CACHE_CHECK(for __builtin_setjmp, ac_cv_func___builtin_setjmp, -[ -for cast in "" "(void *)"; do -RUBY_WERROR_FLAG( -[AC_TRY_LINK([@%:@include - @%:@include - jmp_buf jb; - void t(void) {__builtin_longjmp($cast jb, 1);}], [ - void (*volatile f)(void) = t; - if (!__builtin_setjmp($cast jb)) printf("%d\n", f != 0); - ], - [ac_cv_func___builtin_setjmp="yes with cast ($cast)"; break], - [ac_cv_func___builtin_setjmp=no]) -]) -done]) + ac_cv_func___builtin_setjmp=no + for cast in "" "(void **)"; do + RUBY_WERROR_FLAG( + [AC_TRY_LINK([@%:@include + @%:@include + jmp_buf jb; + void t(void) {__builtin_longjmp($cast jb, 1);} + int jump(void) {(void)(__builtin_setjmp($cast jb) ? 1 : 0); return 0;}], + [ + void (*volatile f)(void) = t; + if (!jump()) printf("%d\n", f != 0); + ], + [ac_cv_func___builtin_setjmp="yes with cast ($cast)"]) + ]) + test "$ac_cv_func___builtin_setjmp" = no || break + done]) # we don't use _setjmp if _longjmp doesn't exist. test x$ac_cv_func__longjmp = xno && ac_cv_func__setjmp=no diff --git a/version.h b/version.h index 21ebbeb37ad473..89d03fdfd17265 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-08-26" -#define RUBY_PATCHLEVEL 210 +#define RUBY_PATCHLEVEL 211 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 8 From c901347d1d07a684e904b8aad2992962b17b93c3 Mon Sep 17 00:00:00 2001 From: nagachika Date: Mon, 25 Aug 2014 15:07:33 +0000 Subject: [PATCH 212/343] merge revision(s) r45537: [Backport #9710] * configure.in: get rid of __builtin_setjmp/__builtin_longjmp on x64-mingw, which causes SEGV with callcc. [ruby-core:61887] [Bug #9710] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47278 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ configure.in | 1 + version.h | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 7876784187f158..bc2d4227e22988 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Tue Aug 26 00:07:20 2014 Nobuyoshi Nakada + + * configure.in: get rid of __builtin_setjmp/__builtin_longjmp on + x64-mingw, which causes SEGV with callcc. + [ruby-core:61887] [Bug #9710] + Tue Aug 26 00:06:05 2014 Nobuyoshi Nakada * configure.in (ac_cv_func___builtin_setjmp): should not skip diff --git a/configure.in b/configure.in index 0d9f0312db8fa6..21b55d0854f3ea 100644 --- a/configure.in +++ b/configure.in @@ -1047,6 +1047,7 @@ main() ac_cv_func_clock_gettime=yes ac_cv_func_clock_getres=yes ac_cv_func_malloc_usable_size=no + { test "$target_cpu" = x64 && ac_cv_func___builtin_setjmp=no; } AC_CHECK_TYPE([NET_LUID], [], [], [@%:@include @%:@include ]) diff --git a/version.h b/version.h index 89d03fdfd17265..109a701828c9b8 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-08-26" -#define RUBY_PATCHLEVEL 211 +#define RUBY_PATCHLEVEL 212 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 8 From a1f28fb554dd80995b64b491bc2b7cdcc68604e3 Mon Sep 17 00:00:00 2001 From: nagachika Date: Mon, 25 Aug 2014 15:08:46 +0000 Subject: [PATCH 213/343] merge revision(s) r45885: [Backport #9818] * configure.in (RUBY_SETJMP_TYPE): check for setjmp type after CCDLFLAGS is appended to CFLAGS, since __builtin_setjmp can be affected. [ruby-core:62469] [Bug #9818] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47279 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ configure.in | 6 ++++++ version.h | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index bc2d4227e22988..0292d6dddf969e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Tue Aug 26 00:08:40 2014 Nobuyoshi Nakada + + * configure.in (RUBY_SETJMP_TYPE): check for setjmp type after + CCDLFLAGS is appended to CFLAGS, since __builtin_setjmp can be + affected. [ruby-core:62469] [Bug #9818] + Tue Aug 26 00:07:20 2014 Nobuyoshi Nakada * configure.in: get rid of __builtin_setjmp/__builtin_longjmp on diff --git a/configure.in b/configure.in index 21b55d0854f3ea..b657b1fa3d50d9 100644 --- a/configure.in +++ b/configure.in @@ -2023,6 +2023,7 @@ AC_CACHE_CHECK(for sigsetjmp as a macro or function, ac_cv_func_sigsetjmp, ac_cv_func_sigsetjmp=yes, ac_cv_func_sigsetjmp=no)]) +AC_DEFUN(RUBY_CHECK_BUILTIN_SETJMP, [ if test x"${ac_cv_func___builtin_setjmp}" = xyes; then unset ac_cv_func___builtin_setjmp fi @@ -2044,10 +2045,13 @@ AC_CACHE_CHECK(for __builtin_setjmp, ac_cv_func___builtin_setjmp, ]) test "$ac_cv_func___builtin_setjmp" = no || break done]) +]) # we don't use _setjmp if _longjmp doesn't exist. test x$ac_cv_func__longjmp = xno && ac_cv_func__setjmp=no +AC_DEFUN(RUBY_SETJMP_TYPE, [ +RUBY_CHECK_BUILTIN_SETJMP AC_MSG_CHECKING(for setjmp type) setjmp_suffix= AC_ARG_WITH(setjmp-type, @@ -2092,6 +2096,7 @@ AC_MSG_RESULT(${setjmp_prefix}setjmp${setjmp_suffix}${setjmp_cast:+($setjmp_cast AC_DEFINE_UNQUOTED([RUBY_SETJMP(env)], [${setjmp_prefix}setjmp${setjmp_suffix}($setjmp_cast(env)${setjmp_sigmask+,0})]) AC_DEFINE_UNQUOTED([RUBY_LONGJMP(env,val)], [${setjmp_prefix}longjmp($setjmp_cast(env),val)]) AC_DEFINE_UNQUOTED(RUBY_JMP_BUF, ${setjmp_sigmask+${setjmp_prefix}}jmp_buf) +]) # End of setjmp check. AC_ARG_ENABLE(setreuid, @@ -3369,6 +3374,7 @@ AC_SUBST(DTRACE_OBJ) AC_SUBST(DTRACE_GLOMMED_OBJ) AC_SUBST(LIBRUBY_A_OBJS) +RUBY_SETJMP_TYPE } { # build section diff --git a/version.h b/version.h index 109a701828c9b8..dde51f99701227 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-08-26" -#define RUBY_PATCHLEVEL 212 +#define RUBY_PATCHLEVEL 213 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 8 From 6491d8624f50421918396686b9efa0f1708de1c1 Mon Sep 17 00:00:00 2001 From: nagachika Date: Sat, 30 Aug 2014 16:04:47 +0000 Subject: [PATCH 214/343] merge revision(s) r46441: [Backport #9946] * process.c (open): use UTF-8 version function to support non-ascii path properly. [ruby-core:63185] [Bug #9946] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47324 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ process.c | 6 ++++++ test/ruby/test_process.rb | 10 ++++++++++ version.h | 6 +++--- 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0292d6dddf969e..068165596ba064 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sun Aug 31 00:54:47 2014 Nobuyoshi Nakada + + * process.c (open): use UTF-8 version function to support + non-ascii path properly. [ruby-core:63185] [Bug #9946] + Tue Aug 26 00:08:40 2014 Nobuyoshi Nakada * configure.in (RUBY_SETJMP_TYPE): check for setjmp type after diff --git a/process.c b/process.c index 2b926701a215d5..f1679a0abdabf3 100644 --- a/process.c +++ b/process.c @@ -86,6 +86,12 @@ # include #endif +/* define system APIs */ +#ifdef _WIN32 +#undef open +#define open rb_w32_uopen +#endif + #if defined(HAVE_TIMES) || defined(_WIN32) static VALUE rb_cProcessTms; #endif diff --git a/test/ruby/test_process.rb b/test/ruby/test_process.rb index c77cbabee8f327..f6e44fadadb744 100644 --- a/test/ruby/test_process.rb +++ b/test/ruby/test_process.rb @@ -606,6 +606,16 @@ def test_execopts_redirect } end + def test_execopts_redirect_nonascii_path + bug9946 = '[ruby-core:63185] [Bug #9946]' + with_tmpchdir {|d| + path = "t-\u{30c6 30b9 30c8 f6}.txt" + system(*ECHO["a"], out: path) + assert_file.for(bug9946).exist?(path) + assert_equal("a\n", File.read(path), bug9946) + } + end + def test_execopts_redirect_dup2_child with_tmpchdir {|d| Process.wait spawn(RUBY, "-e", "STDERR.print 'err'; STDOUT.print 'out'", diff --git a/version.h b/version.h index dde51f99701227..328b7a71c54826 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.2" -#define RUBY_RELEASE_DATE "2014-08-26" -#define RUBY_PATCHLEVEL 213 +#define RUBY_RELEASE_DATE "2014-08-31" +#define RUBY_PATCHLEVEL 214 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 8 -#define RUBY_RELEASE_DAY 26 +#define RUBY_RELEASE_DAY 31 #include "ruby/version.h" From 9fa0d8364f2daf64819a01aa11af5b32e456fb0a Mon Sep 17 00:00:00 2001 From: nagachika Date: Sat, 30 Aug 2014 16:09:10 +0000 Subject: [PATCH 215/343] merge revision(s) r47153: [Backport #10127] * ext/win32ole/win32ole.c (ole_create_dcom): use the converted result if the argument can be converted to a string, to get rid of invalid access. Thanks to nobu. [ruby-dev:48467] [Bug #10127] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47325 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ ext/win32ole/win32ole.c | 8 +++----- version.h | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 068165596ba064..153d7f33c4597f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sun Aug 31 01:07:05 2014 Masaki Suketa + + * ext/win32ole/win32ole.c (ole_create_dcom): use the converted + result if the argument can be converted to a string, to get rid + of invalid access. Thanks to nobu. [ruby-dev:48467] [Bug #10127] + Sun Aug 31 00:54:47 2014 Nobuyoshi Nakada * process.c (open): use UTF-8 version function to support diff --git a/ext/win32ole/win32ole.c b/ext/win32ole/win32ole.c index 072638a10b5920..57da91c67ab75d 100644 --- a/ext/win32ole/win32ole.c +++ b/ext/win32ole/win32ole.c @@ -361,7 +361,7 @@ static VALUE typelib_file_from_typelib(VALUE ole); static VALUE typelib_file(VALUE ole); static void ole_const_load(ITypeLib *pTypeLib, VALUE klass, VALUE self); static HRESULT clsid_from_remote(VALUE host, VALUE com, CLSID *pclsid); -static VALUE ole_create_dcom(int argc, VALUE *argv, VALUE self); +static VALUE ole_create_dcom(VALUE self, VALUE ole, VALUE host, VALUE others); static VALUE ole_bind_obj(VALUE moniker, int argc, VALUE *argv, VALUE self); static VALUE fole_s_connect(int argc, VALUE *argv, VALUE self); static VALUE fole_s_const_load(int argc, VALUE *argv, VALUE self); @@ -2636,9 +2636,8 @@ clsid_from_remote(VALUE host, VALUE com, CLSID *pclsid) } static VALUE -ole_create_dcom(int argc, VALUE *argv, VALUE self) +ole_create_dcom(VALUE self, VALUE ole, VALUE host, VALUE others) { - VALUE ole, host, others; HRESULT hr; CLSID clsid; OLECHAR *pbuf; @@ -2656,7 +2655,6 @@ ole_create_dcom(int argc, VALUE *argv, VALUE self) GetProcAddress(gole32, "CoCreateInstanceEx"); if (!gCoCreateInstanceEx) rb_raise(rb_eRuntimeError, "CoCreateInstanceEx is not supported in this environment"); - rb_scan_args(argc, argv, "2*", &ole, &host, &others); pbuf = ole_vstr2wc(ole); hr = CLSIDFromProgID(pbuf, &clsid); @@ -3270,7 +3268,7 @@ fole_initialize(int argc, VALUE *argv, VALUE self) rb_raise(rb_eSecurityError, "Insecure Object Creation - %s", StringValuePtr(svr_name)); } - return ole_create_dcom(argc, argv, self); + return ole_create_dcom(self, svr_name, host, others); } /* get CLSID from OLE server name */ diff --git a/version.h b/version.h index 328b7a71c54826..80085c91cfca42 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-08-31" -#define RUBY_PATCHLEVEL 214 +#define RUBY_PATCHLEVEL 215 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 8 From 478a0180c4713da8b32438e668fb69765423b269 Mon Sep 17 00:00:00 2001 From: nagachika Date: Sat, 30 Aug 2014 16:29:40 +0000 Subject: [PATCH 216/343] merge revision(s) r46387: [Backport #9607] * gc.c: change full GC timing to keep lower memory usage. Extend heap only at (1) after major GC or (2) after several (two times, at current) minor GC Details in https://bugs.ruby-lang.org/issues/9607#note-9 [Bug #9607] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47326 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 12 ++++++++++++ gc.c | 18 ++++++++++++------ version.h | 2 +- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 153d7f33c4597f..63cbc9500605f1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +Sun Aug 31 01:13:21 2014 Koichi Sasada + + * gc.c: change full GC timing to keep lower memory usage. + + Extend heap only at + (1) after major GC + or + (2) after several (two times, at current) minor GC + + Details in https://bugs.ruby-lang.org/issues/9607#note-9 + [Bug #9607] + Sun Aug 31 01:07:05 2014 Masaki Suketa * ext/win32ole/win32ole.c (ole_create_dcom): use the converted diff --git a/gc.c b/gc.c index b2d8bfb83e08c0..cc37327463370c 100644 --- a/gc.c +++ b/gc.c @@ -519,6 +519,9 @@ typedef struct rb_objspace { int parent_object_is_old; int need_major_gc; + + size_t last_major_gc; + size_t remembered_shady_object_count; size_t remembered_shady_object_limit; size_t old_object_count; @@ -2954,14 +2957,17 @@ gc_after_sweep(rb_objspace_t *objspace) (int)heap->total_slots, (int)heap_pages_swept_slots, (int)heap_pages_min_free_slots); if (heap_pages_swept_slots < heap_pages_min_free_slots) { - heap_set_increment(objspace, (heap_pages_min_free_slots - heap_pages_swept_slots) / HEAP_OBJ_LIMIT); - heap_increment(objspace, heap); - #if USE_RGENGC - if (objspace->rgengc.remembered_shady_object_count + objspace->rgengc.old_object_count > (heap_pages_length * HEAP_OBJ_LIMIT) / 2) { - /* if [old]+[remembered shady] > [all object count]/2, then do major GC */ - objspace->rgengc.need_major_gc = GPR_FLAG_MAJOR_BY_RESCAN; + if (objspace->rgengc.during_minor_gc && objspace->profile.count - objspace->rgengc.last_major_gc > 2 /* magic number */) { + objspace->rgengc.need_major_gc = GPR_FLAG_MAJOR_BY_NOFREE; } + else { + heap_set_increment(objspace, (heap_pages_min_free_slots - heap_pages_swept_slots) / HEAP_OBJ_LIMIT); + heap_increment(objspace, heap); + } +#else + heap_set_increment(objspace, (heap_pages_min_free_slots - heap_pages_swept_slots) / HEAP_OBJ_LIMIT); + heap_increment(objspace, heap); #endif } diff --git a/version.h b/version.h index 80085c91cfca42..a68c8cdb546341 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-08-31" -#define RUBY_PATCHLEVEL 215 +#define RUBY_PATCHLEVEL 216 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 8 From 06042f854ff815c6287bce132ed8e23d2a600a93 Mon Sep 17 00:00:00 2001 From: nagachika Date: Mon, 1 Sep 2014 17:16:03 +0000 Subject: [PATCH 217/343] merge revision(s) r45911,r45912,r45917,r45918,r45919: [Backport #9820] * signal.c (rb_f_kill): directly enqueue an ignored signal to self, except for SIGSEGV and SIGBUS. [ruby-dev:48203] [Bug #9820] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47345 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++ signal.c | 66 +++++++++++++++++++++++++++++++++++++-- test/ruby/test_process.rb | 25 ++++++++++++--- test/ruby/test_signal.rb | 11 +++++++ thread.c | 9 ++---- version.h | 8 ++--- 6 files changed, 106 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index 63cbc9500605f1..326fc7ba0c8b2b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Tue Sep 2 02:08:12 2014 Nobuyoshi Nakada + + * signal.c (rb_f_kill): directly enqueue an ignored signal to self, + except for SIGSEGV and SIGBUS. [ruby-dev:48203] [Bug #9820] + Sun Aug 31 01:13:21 2014 Koichi Sasada * gc.c: change full GC timing to keep lower memory usage. diff --git a/signal.c b/signal.c index 6c587ae851f71f..1524885eb5ac72 100644 --- a/signal.c +++ b/signal.c @@ -343,6 +343,9 @@ ruby_default_signal(int sig) raise(sig); } +static int signal_ignored(int sig); +static void signal_enque(int sig); + /* * call-seq: * Process.kill(signal, pid, ...) -> fixnum @@ -429,6 +432,8 @@ rb_f_kill(int argc, VALUE *argv) break; } + if (argc <= 1) return INT2FIX(0); + if (sig < 0) { sig = -sig; for (i=1; imain_thread) ? getpid() : -1; + int wakeup = 0; + for (i=1; imain_thread); } } rb_thread_execute_interrupts(rb_thread_current()); @@ -570,11 +609,32 @@ ruby_nativethread_signal(int signum, sighandler_t handler) #endif #endif -static RETSIGTYPE -sighandler(int sig) +static int +signal_ignored(int sig) +{ +#ifdef POSIX_SIGNAL + struct sigaction old; + (void)VALGRIND_MAKE_MEM_DEFINED(&old, sizeof(old)); + if (sigaction(sig, NULL, &old) < 0) return FALSE; + return old.sa_handler == SIG_IGN; +#else + sighandler_t old = signal(sig, SIG_DFL); + signal(sig, old); + return old == SIG_IGN; +#endif +} + +static void +signal_enque(int sig) { ATOMIC_INC(signal_buff.cnt[sig]); ATOMIC_INC(signal_buff.size); +} + +static RETSIGTYPE +sighandler(int sig) +{ + signal_enque(sig); rb_thread_wakeup_timer_thread(); #if !defined(BSD_SIGNAL) && !defined(POSIX_SIGNAL) ruby_signal(sig, sighandler); diff --git a/test/ruby/test_process.rb b/test/ruby/test_process.rb index f6e44fadadb744..a71a2d6dce5b41 100644 --- a/test/ruby/test_process.rb +++ b/test/ruby/test_process.rb @@ -1192,6 +1192,23 @@ def test_status end def test_status_kill + return unless Process.respond_to?(:kill) + return unless Signal.list.include?("KILL") + + # assume the system supports signal if SIGQUIT is available + expected = Signal.list.include?("QUIT") ? [false, true, false, nil] : [true, false, false, true] + + with_tmpchdir do + write_file("foo", "Process.kill(:KILL, $$); exit(42)") + system(RUBY, "foo") + s = $? + assert_equal(expected, + [s.exited?, s.signaled?, s.stopped?, s.success?], + "[s.exited?, s.signaled?, s.stopped?, s.success?]") + end + end + + def test_status_quit return unless Process.respond_to?(:kill) return unless Signal.list.include?("QUIT") @@ -1206,16 +1223,14 @@ def test_status_kill end t = Time.now s = $? - assert_equal([false, true, false], - [s.exited?, s.signaled?, s.stopped?], - "[s.exited?, s.signaled?, s.stopped?]") + assert_equal([false, true, false, nil], + [s.exited?, s.signaled?, s.stopped?, s.success?], + "[s.exited?, s.signaled?, s.stopped?, s.success?]") assert_send( [["#", "#"], :include?, s.inspect]) - assert_equal(false, s.exited?) - assert_equal(nil, s.success?) EnvUtil.diagnostic_reports("QUIT", RUBY, pid, t) end end diff --git a/test/ruby/test_signal.rb b/test/ruby/test_signal.rb index 60b886cec9a998..e329df9a341252 100644 --- a/test/ruby/test_signal.rb +++ b/test/ruby/test_signal.rb @@ -268,4 +268,15 @@ def test_hup_me } } end if Process.respond_to?(:kill) and Signal.list.key?('HUP') + + def test_ignored_interrupt + bug9820 = '[ruby-dev:48203] [Bug #9820]' + assert_separately(['-', bug9820], <<-'end;') # begin + bug = ARGV.shift + trap(:INT, "IGNORE") + assert_nothing_raised(SignalException, bug) do + Process.kill(:INT, $$) + end + end; + end if Process.respond_to?(:kill) end diff --git a/thread.c b/thread.c index b51698fc24f899..d9df90272e8049 100644 --- a/thread.c +++ b/thread.c @@ -5320,13 +5320,12 @@ ruby_kill(rb_pid_t pid, int sig) { int err; rb_thread_t *th = GET_THREAD(); - rb_vm_t *vm = GET_VM(); /* * When target pid is self, many caller assume signal will be * delivered immediately and synchronously. */ - if ((sig != 0) && (th == vm->main_thread) && (pid == getpid())) { + { GVL_UNLOCK_BEGIN(); native_mutex_lock(&th->interrupt_lock); err = kill(pid, sig); @@ -5334,9 +5333,7 @@ ruby_kill(rb_pid_t pid, int sig) native_mutex_unlock(&th->interrupt_lock); GVL_UNLOCK_END(); } - else { - err = kill(pid, sig); - } - if (err < 0) + if (err < 0) { rb_sys_fail(0); + } } diff --git a/version.h b/version.h index a68c8cdb546341..d00d06a0a35d45 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.2" -#define RUBY_RELEASE_DATE "2014-08-31" -#define RUBY_PATCHLEVEL 216 +#define RUBY_RELEASE_DATE "2014-09-02" +#define RUBY_PATCHLEVEL 217 #define RUBY_RELEASE_YEAR 2014 -#define RUBY_RELEASE_MONTH 8 -#define RUBY_RELEASE_DAY 31 +#define RUBY_RELEASE_MONTH 9 +#define RUBY_RELEASE_DAY 2 #include "ruby/version.h" From 3513d07732e00be85d2b3cb49fa9b72a8ed404ec Mon Sep 17 00:00:00 2001 From: nagachika Date: Mon, 1 Sep 2014 17:34:33 +0000 Subject: [PATCH 218/343] merge revision(s) r46547: [Backport #9976] * hash.c (env_aset, env_has_key, env_assoc, env_has_value), (env_rassoc, env_key): prohibit tainted strings if $SAFE is non-zero. [Bug #9976] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47346 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++ hash.c | 14 +++++--- test/ruby/test_env.rb | 81 +++++++++++++++++++++++++++++++++++++++++++ version.h | 2 +- 4 files changed, 97 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 326fc7ba0c8b2b..4be5d4e6b36ced 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Tue Sep 2 02:21:58 2014 Nobuyoshi Nakada + + * hash.c (env_aset, env_has_key, env_assoc, env_has_value), + (env_rassoc, env_key): prohibit tainted strings if $SAFE is + non-zero. [Bug #9976] + Tue Sep 2 02:08:12 2014 Nobuyoshi Nakada * signal.c (rb_f_kill): directly enqueue an ignored signal to self, diff --git a/hash.c b/hash.c index 85be2decb7a371..376f33f1ac6be0 100644 --- a/hash.c +++ b/hash.c @@ -2876,8 +2876,8 @@ env_aset(VALUE obj, VALUE nm, VALUE val) env_delete(obj, nm); return Qnil; } - StringValue(nm); - StringValue(val); + SafeStringValue(nm); + SafeStringValue(val); name = RSTRING_PTR(nm); value = RSTRING_PTR(val); if (memchr(name, '\0', RSTRING_LEN(nm))) @@ -3372,7 +3372,8 @@ env_has_key(VALUE env, VALUE key) { char *s; - s = StringValuePtr(key); + SafeStringValue(key); + s = RSTRING_PTR(key); if (memchr(s, '\0', RSTRING_LEN(key))) rb_raise(rb_eArgError, "bad environment variable name"); if (getenv(s)) return Qtrue; @@ -3391,7 +3392,8 @@ env_assoc(VALUE env, VALUE key) { char *s, *e; - s = StringValuePtr(key); + SafeStringValue(key); + s = RSTRING_PTR(key); if (memchr(s, '\0', RSTRING_LEN(key))) rb_raise(rb_eArgError, "bad environment variable name"); e = getenv(s); @@ -3413,6 +3415,7 @@ env_has_value(VALUE dmy, VALUE obj) obj = rb_check_string_type(obj); if (NIL_P(obj)) return Qnil; + rb_check_safe_obj(obj); env = GET_ENVIRON(environ); while (*env) { char *s = strchr(*env, '='); @@ -3443,6 +3446,7 @@ env_rassoc(VALUE dmy, VALUE obj) obj = rb_check_string_type(obj); if (NIL_P(obj)) return Qnil; + rb_check_safe_obj(obj); env = GET_ENVIRON(environ); while (*env) { char *s = strchr(*env, '='); @@ -3473,7 +3477,7 @@ env_key(VALUE dmy, VALUE value) char **env; VALUE str; - StringValue(value); + SafeStringValue(value); env = GET_ENVIRON(environ); while (*env) { char *s = strchr(*env, '='); diff --git a/test/ruby/test_env.rb b/test/ruby/test_env.rb index 0ada9606ae9102..ddbdcf24bcabd7 100644 --- a/test/ruby/test_env.rb +++ b/test/ruby/test_env.rb @@ -451,4 +451,85 @@ def test_memory_leak_shift end; end end + + def test_taint_aref + assert_raise(SecurityError) do + proc do + $SAFE = 2 + ENV["FOO".taint] + end.call + end + end + + def test_taint_fetch + assert_raise(SecurityError) do + proc do + $SAFE = 2 + ENV.fetch("FOO".taint) + end.call + end + end + + def test_taint_assoc + assert_raise(SecurityError) do + proc do + $SAFE = 2 + ENV.assoc("FOO".taint) + end.call + end + end + + def test_taint_rassoc + assert_raise(SecurityError) do + proc do + $SAFE = 2 + ENV.rassoc("FOO".taint) + end.call + end + end + + def test_taint_key + assert_raise(SecurityError) do + proc do + $SAFE = 2 + ENV.key("FOO".taint) + end.call + end + end + + def test_taint_key_p + assert_raise(SecurityError) do + proc do + $SAFE = 2 + ENV.key?("FOO".taint) + end.call + end + end + + def test_taint_value_p + assert_raise(SecurityError) do + proc do + $SAFE = 2 + ENV.value?("FOO".taint) + end.call + end + end + + def test_taint_aset_value + assert_raise(SecurityError) do + proc do + $SAFE = 2 + ENV["FOO"] = "BAR".taint + end.call + end + end + + def test_taint_aset_key + assert_raise(SecurityError) do + proc do + $SAFE = 2 + ENV["FOO".taint] = "BAR" + end.call + end + end end diff --git a/version.h b/version.h index d00d06a0a35d45..890a191344ccaa 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-09-02" -#define RUBY_PATCHLEVEL 217 +#define RUBY_PATCHLEVEL 218 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 9 From f28cfce8cdf5ac82f50fe0f2627697d26fd8bd27 Mon Sep 17 00:00:00 2001 From: nagachika Date: Wed, 3 Sep 2014 15:21:34 +0000 Subject: [PATCH 219/343] merge revision(s) r47362: [Backport #9984] * test/openssl/test_pkey_rsa.rb (OpenSSL#test_sign_verify_memory_leak): added timeout into testcase for low performance environment. [Bug #9984][ruby-core:63367] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47375 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ test/openssl/test_pkey_rsa.rb | 4 ++-- version.h | 6 +++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4be5d4e6b36ced..534c47f434b41d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Thu Sep 4 00:21:05 2014 SHIBATA Hiroshi + + * test/openssl/test_pkey_rsa.rb (OpenSSL#test_sign_verify_memory_leak): + added timeout into testcase for low performance environment. + [Bug #9984][ruby-core:63367] + Tue Sep 2 02:21:58 2014 Nobuyoshi Nakada * hash.c (env_aset, env_has_key, env_assoc, env_has_value), diff --git a/test/openssl/test_pkey_rsa.rb b/test/openssl/test_pkey_rsa.rb index ce9bd60c2f1519..df0c6090cb3844 100644 --- a/test/openssl/test_pkey_rsa.rb +++ b/test/openssl/test_pkey_rsa.rb @@ -77,7 +77,7 @@ def test_sign_verify def test_sign_verify_memory_leak bug9743 = '[ruby-core:62038] [Bug #9743]' - assert_no_memory_leak(%w[-ropenssl], <<-PREP, <<-CODE, bug9743, rss: true) + assert_no_memory_leak(%w[-ropenssl], <<-PREP, <<-CODE, bug9743, rss: true, timeout: 30) data = 'Sign me!' digest = OpenSSL::Digest::SHA512.new pkey = OpenSSL::PKey::RSA.new(2048) @@ -89,7 +89,7 @@ def test_sign_verify_memory_leak } CODE - assert_no_memory_leak(%w[-ropenssl], <<-PREP, <<-CODE, bug9743, rss: true) + assert_no_memory_leak(%w[-ropenssl], <<-PREP, <<-CODE, bug9743, rss: true, timeout: 30) data = 'Sign me!' digest = OpenSSL::Digest::SHA512.new pkey = OpenSSL::PKey::RSA.new(2048) diff --git a/version.h b/version.h index 890a191344ccaa..44344f12670862 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.2" -#define RUBY_RELEASE_DATE "2014-09-02" -#define RUBY_PATCHLEVEL 218 +#define RUBY_RELEASE_DATE "2014-09-04" +#define RUBY_PATCHLEVEL 219 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 9 -#define RUBY_RELEASE_DAY 2 +#define RUBY_RELEASE_DAY 4 #include "ruby/version.h" From f909bee147b4f7559149da43a5bbfa1e75a9b902 Mon Sep 17 00:00:00 2001 From: nagachika Date: Wed, 3 Sep 2014 15:25:51 +0000 Subject: [PATCH 220/343] merge revision(s) r46569: [Backport #9982] * sprintf.c (GETASTER): should not use the numbered argument to be formatted, raise ArgumentError instead. [ruby-dev:48330] [Bug #9982] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47376 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ sprintf.c | 5 ++++- test/ruby/test_sprintf.rb | 4 ++++ version.h | 2 +- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 534c47f434b41d..a1719723c895fc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Thu Sep 4 00:23:15 2014 Nobuyoshi Nakada + + * sprintf.c (GETASTER): should not use the numbered argument to be + formatted, raise ArgumentError instead. + [ruby-dev:48330] [Bug #9982] + Thu Sep 4 00:21:05 2014 SHIBATA Hiroshi * test/openssl/test_pkey_rsa.rb (OpenSSL#test_sign_verify_memory_leak): diff --git a/sprintf.c b/sprintf.c index 97b2126422ae0d..59d3dde0178ade 100644 --- a/sprintf.c +++ b/sprintf.c @@ -79,6 +79,9 @@ sign_bits(int base, const char *p) } while (0) #define GETARG() (nextvalue != Qundef ? nextvalue : \ + GETNEXTARG()) + +#define GETNEXTARG() ( \ posarg == -1 ? \ (rb_raise(rb_eArgError, "unnumbered(%d) mixed with numbered", nextarg), 0) : \ posarg == -2 ? \ @@ -125,7 +128,7 @@ sign_bits(int base, const char *p) tmp = GETPOSARG(n); \ } \ else { \ - tmp = GETARG(); \ + tmp = GETNEXTARG(); \ p = t; \ } \ (val) = NUM2INT(tmp); \ diff --git a/test/ruby/test_sprintf.rb b/test/ruby/test_sprintf.rb index 80e69f7fda2f11..eff35c18daac47 100644 --- a/test/ruby/test_sprintf.rb +++ b/test/ruby/test_sprintf.rb @@ -179,6 +179,10 @@ def test_invalid assert_raise(ArgumentError) { sprintf("%!", 1) } assert_raise(ArgumentError) { sprintf("%1$1$d", 1) } assert_raise(ArgumentError) { sprintf("%0%") } + + assert_raise_with_message(ArgumentError, /unnumbered\(1\) mixed with numbered/) { sprintf("%1$*d", 3) } + assert_raise_with_message(ArgumentError, /unnumbered\(1\) mixed with numbered/) { sprintf("%1$.*d", 3) } + verbose, $VERBOSE = $VERBOSE, nil assert_nothing_raised { sprintf("", 1) } ensure diff --git a/version.h b/version.h index 44344f12670862..a4906fd36ed53c 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-09-04" -#define RUBY_PATCHLEVEL 219 +#define RUBY_PATCHLEVEL 220 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 9 From 17fc590e089ad268d634c85cb7bf94a53a96d596 Mon Sep 17 00:00:00 2001 From: nagachika Date: Wed, 3 Sep 2014 15:29:56 +0000 Subject: [PATCH 221/343] merge revision(s) r46876: [Backport #10039] * io.c (rb_io_initialize): [DOC] fix rdoc of append mode. it does not move the pointer at open. [ruby-core:63747] [Bug #10039] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47377 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ io.c | 10 +++++----- version.h | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index a1719723c895fc..4fce1ce2d1536b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Thu Sep 4 00:29:10 2014 Nobuyoshi Nakada + + * io.c (rb_io_initialize): [DOC] fix rdoc of append mode. it does + not move the pointer at open. [ruby-core:63747] [Bug #10039] + Thu Sep 4 00:23:15 2014 Nobuyoshi Nakada * sprintf.c (GETASTER): should not use the numbered argument to be diff --git a/io.c b/io.c index 0ce71108fc32ef..e5b2ac1330a306 100644 --- a/io.c +++ b/io.c @@ -7274,12 +7274,12 @@ rb_io_stdio_file(rb_io_t *fptr) * "w+" Read-write, truncates existing file to zero length * or creates a new file for reading and writing. * - * "a" Write-only, starts at end of file if file exists, - * otherwise creates a new file for writing. + * "a" Write-only, each write call appends data at end of file. + * Creates a new file for writing if file does not exist. * - * "a+" Read-write, starts at end of file if file exists, - * otherwise creates a new file for reading and - * writing. + * "a+" Read-write, each write call appends data at end of file. + * Creates a new file for reading and writing if file does + * not exist. * * The following modes must be used separately, and along with one or more of * the modes seen above. diff --git a/version.h b/version.h index a4906fd36ed53c..827877a05d38dc 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-09-04" -#define RUBY_PATCHLEVEL 220 +#define RUBY_PATCHLEVEL 221 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 9 From aac5c2c7affaa188b84c4f9ccf8b21e83aa21141 Mon Sep 17 00:00:00 2001 From: nagachika Date: Wed, 3 Sep 2014 15:47:46 +0000 Subject: [PATCH 222/343] merge revision(s) r47217: [Backport #10062] * ext/thread/thread.c (get_array): check instance variables are initialized properly. [ruby-core:63826][Bug #10062] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47378 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ ext/thread/thread.c | 18 ++++++++++++++---- test/thread/test_cv.rb | 6 ++++++ test/thread/test_queue.rb | 12 ++++++++++++ version.h | 2 +- 5 files changed, 38 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4fce1ce2d1536b..6a87536bfde810 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Thu Sep 4 00:31:23 2014 Nobuyoshi Nakada + + * ext/thread/thread.c (get_array): check instance variables are + initialized properly. [ruby-core:63826][Bug #10062] + Thu Sep 4 00:29:10 2014 Nobuyoshi Nakada * io.c (rb_io_initialize): [DOC] fix rdoc of append mode. it does diff --git a/ext/thread/thread.c b/ext/thread/thread.c index fa277086789e77..c3d81dc58d8a8b 100644 --- a/ext/thread/thread.c +++ b/ext/thread/thread.c @@ -11,14 +11,24 @@ enum { SZQUEUE_MAX = 3 }; -#define GET_CONDVAR_WAITERS(cv) RSTRUCT_GET((cv), CONDVAR_WAITERS) +#define GET_CONDVAR_WAITERS(cv) get_array((cv), CONDVAR_WAITERS) -#define GET_QUEUE_QUE(q) RSTRUCT_GET((q), QUEUE_QUE) -#define GET_QUEUE_WAITERS(q) RSTRUCT_GET((q), QUEUE_WAITERS) -#define GET_SZQUEUE_WAITERS(q) RSTRUCT_GET((q), SZQUEUE_WAITERS) +#define GET_QUEUE_QUE(q) get_array((q), QUEUE_QUE) +#define GET_QUEUE_WAITERS(q) get_array((q), QUEUE_WAITERS) +#define GET_SZQUEUE_WAITERS(q) get_array((q), SZQUEUE_WAITERS) #define GET_SZQUEUE_MAX(q) RSTRUCT_GET((q), SZQUEUE_MAX) #define GET_SZQUEUE_ULONGMAX(q) NUM2ULONG(GET_SZQUEUE_MAX(q)) +static VALUE +get_array(VALUE obj, int idx) +{ + VALUE ary = RSTRUCT_GET(obj, idx); + if (!RB_TYPE_P(ary, T_ARRAY)) { + rb_raise(rb_eTypeError, "%+"PRIsVALUE" not initialized", obj); + } + return ary; +} + static VALUE ary_buf_new(void) { diff --git a/test/thread/test_cv.rb b/test/thread/test_cv.rb index f0d7c6d094a193..08459a0a04c526 100644 --- a/test/thread/test_cv.rb +++ b/test/thread/test_cv.rb @@ -4,6 +4,12 @@ require_relative '../ruby/envutil' class TestConditionVariable < Test::Unit::TestCase + def test_initialized + assert_raise(TypeError) { + ConditionVariable.allocate.wait(nil) + } + end + def test_condvar_signal_and_wait mutex = Mutex.new condvar = ConditionVariable.new diff --git a/test/thread/test_queue.rb b/test/thread/test_queue.rb index c9481aa2990571..314ee98dab0ddb 100644 --- a/test/thread/test_queue.rb +++ b/test/thread/test_queue.rb @@ -5,6 +5,18 @@ require_relative '../ruby/envutil' class TestQueue < Test::Unit::TestCase + def test_queue_initialized + assert_raise(TypeError) { + Queue.allocate.push(nil) + } + end + + def test_sized_queue_initialized + assert_raise(TypeError) { + SizedQueue.allocate.push(nil) + } + end + def test_queue grind(5, 1000, 15, Queue) end diff --git a/version.h b/version.h index 827877a05d38dc..9949600482904c 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-09-04" -#define RUBY_PATCHLEVEL 221 +#define RUBY_PATCHLEVEL 222 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 9 From 667af1ee3149ba51a5559a3db3d1fc52fda06bed Mon Sep 17 00:00:00 2001 From: nagachika Date: Fri, 5 Sep 2014 15:14:23 +0000 Subject: [PATCH 223/343] merge revision(s) r45046,r45047,r45063,r45087,r45146,r45150,r45151,r45152: [Backport #9525] * ext/socket: Wrap struct addrinfo by struct rb_addrinfo. * ext/socket: Bypass getaddrinfo() if node and serv are numeric. Reporeted by Naotoshi Seo. [ruby-core:60801] [Bug #9525] * ext/socket/extconf.rb: Detect struct sockaddr_in6.sin6_len. * ext/socket/sockport.h (SET_SIN6_LEN): New macro. (INIT_SOCKADDR_IN6): Ditto. * ext/socket/rubysocket.h (struct rb_addrinfo): Add allocated_by_malloc field. * ext/socket/raddrinfo.c (numeric_getaddrinfo): New function. (rb_getaddrinfo): Call numeric_getaddrinfo at first. (rb_freeaddrinfo): Free struct addrinfo properly when it is allocated by numeric_getaddrinfo. * ext/socket/raddrinfo.c (numeric_getaddrinfo): Use xcalloc. Suggested by Eric Wong. https://bugs.ruby-lang.org/issues/9525#note-14 * ext/socket/raddrinfo.c (rb_getaddrinfo): second argument of MEMZERO is type. Coverity Scan found this bug. * include/ruby/win32.h, win32/win32.c (rb_w32_inet_pton): add a wrapper function for inet_pton minimum supported client is Vista, as well as inet_ntop. * ext/socket/option.c (inet_pton): use rb_w32_inet_pton, instead of inet_ntop directly, which is unavailable on older version Windows. * ext/socket/raddrinfo.c (inet_pton): use rb_w32_inet_pton, instead of inet_pton directly, which is unavailable on older version Windows. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47415 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 39 +++++++++++++ ext/socket/extconf.rb | 1 + ext/socket/raddrinfo.c | 120 +++++++++++++++++++++++++++++++++++++--- ext/socket/rubysocket.h | 1 + ext/socket/sockport.h | 15 +++++ include/ruby/win32.h | 4 ++ version.h | 6 +- win32/win32.c | 13 +++++ 8 files changed, 187 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6a87536bfde810..332d9507b3d542 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,42 @@ +Sat Sep 6 00:05:02 2014 Nobuyoshi Nakada + + * include/ruby/win32.h, win32/win32.c (rb_w32_inet_pton): add a + wrapper function for inet_pton minimum supported client is + Vista, as well as inet_ntop. + +Sat Sep 6 00:05:02 2014 Kazuhiro NISHIYAMA + + * ext/socket/raddrinfo.c (rb_getaddrinfo): second argument of + MEMZERO is type. Coverity Scan found this bug. + +Sat Sep 6 00:05:02 2014 Tanaka Akira + + * ext/socket/raddrinfo.c (numeric_getaddrinfo): Use xcalloc. + Suggested by Eric Wong. + https://bugs.ruby-lang.org/issues/9525#note-14 + +Sat Sep 6 00:05:02 2014 Tanaka Akira + + * ext/socket: Bypass getaddrinfo() if node and serv are numeric. + Reporeted by Naotoshi Seo. [ruby-core:60801] [Bug #9525] + + * ext/socket/extconf.rb: Detect struct sockaddr_in6.sin6_len. + + * ext/socket/sockport.h (SET_SIN6_LEN): New macro. + (INIT_SOCKADDR_IN6): Ditto. + + * ext/socket/rubysocket.h (struct rb_addrinfo): Add + allocated_by_malloc field. + + * ext/socket/raddrinfo.c (numeric_getaddrinfo): New function. + (rb_getaddrinfo): Call numeric_getaddrinfo at first. + (rb_freeaddrinfo): Free struct addrinfo properly when it is + allocated by numeric_getaddrinfo. + +Sat Sep 6 00:05:02 2014 Tanaka Akira + + * ext/socket: Wrap struct addrinfo by struct rb_addrinfo. + Thu Sep 4 00:31:23 2014 Nobuyoshi Nakada * ext/thread/thread.c (get_array): check instance variables are diff --git a/ext/socket/extconf.rb b/ext/socket/extconf.rb index f3be5862f0089f..6c61324e383890 100644 --- a/ext/socket/extconf.rb +++ b/ext/socket/extconf.rb @@ -332,6 +332,7 @@ def test_recvmsg_with_msg_peek_creates_fds(headers) have_struct_member("struct sockaddr", "sa_len", headers) # 4.4BSD have_struct_member("struct sockaddr_in", "sin_len", headers) # 4.4BSD +have_struct_member("struct sockaddr_in6", "sin6_len", headers) # 4.4BSD if have_type("struct sockaddr_un", headers) # POSIX have_struct_member("struct sockaddr_un", "sun_len", headers) # 4.4BSD diff --git a/ext/socket/raddrinfo.c b/ext/socket/raddrinfo.c index 619f123dce3b0a..3deadd1aeae539 100644 --- a/ext/socket/raddrinfo.c +++ b/ext/socket/raddrinfo.c @@ -171,6 +171,90 @@ nogvl_getaddrinfo(void *arg) } #endif +static int +numeric_getaddrinfo(const char *node, const char *service, + const struct addrinfo *hints, + struct addrinfo **res) +{ +#ifdef HAVE_INET_PTON +# if defined __MINGW64__ +# define inet_pton(f,s,d) rb_w32_inet_pton(f,s,d) +# endif + + if (node && (!service || strspn(service, "0123456789") == strlen(service))) { + static const struct { + int socktype; + int protocol; + } list[] = { + { SOCK_STREAM, IPPROTO_TCP }, + { SOCK_DGRAM, IPPROTO_UDP }, + { SOCK_RAW, 0 } + }; + struct addrinfo *ai = NULL; + int port = service ? (unsigned short)atoi(service): 0; + int hint_family = hints ? hints->ai_family : PF_UNSPEC; + int hint_socktype = hints ? hints->ai_socktype : 0; + int hint_protocol = hints ? hints->ai_protocol : 0; + char ipv4addr[4]; +#ifdef AF_INET6 + char ipv6addr[16]; + if ((hint_family == PF_UNSPEC || hint_family == PF_INET6) && + strspn(node, "0123456789abcdefABCDEF.:") == strlen(node) && + inet_pton(AF_INET6, node, ipv6addr)) { + int i; + for (i = numberof(list)-1; 0 <= i; i--) { + if ((hint_socktype == 0 || hint_socktype == list[i].socktype) && + (hint_protocol == 0 || list[i].protocol == 0 || hint_protocol == list[i].protocol)) { + struct addrinfo *ai0 = xcalloc(1, sizeof(struct addrinfo)); + struct sockaddr_in6 *sa = xmalloc(sizeof(struct sockaddr_in6)); + INIT_SOCKADDR_IN6(sa, sizeof(struct sockaddr_in6)); + memcpy(&sa->sin6_addr, ipv6addr, sizeof(ipv6addr)); + sa->sin6_port = htons(port); + ai0->ai_family = PF_INET6; + ai0->ai_socktype = list[i].socktype; + ai0->ai_protocol = hint_protocol ? hint_protocol : list[i].protocol; + ai0->ai_addrlen = sizeof(struct sockaddr_in6); + ai0->ai_addr = (struct sockaddr *)sa; + ai0->ai_canonname = NULL; + ai0->ai_next = ai; + ai = ai0; + } + } + } + else +#endif + if ((hint_family == PF_UNSPEC || hint_family == PF_INET) && + strspn(node, "0123456789.") == strlen(node) && + inet_pton(AF_INET, node, ipv4addr)) { + int i; + for (i = numberof(list)-1; 0 <= i; i--) { + if ((hint_socktype == 0 || hint_socktype == list[i].socktype) && + (hint_protocol == 0 || list[i].protocol == 0 || hint_protocol == list[i].protocol)) { + struct addrinfo *ai0 = xcalloc(1, sizeof(struct addrinfo)); + struct sockaddr_in *sa = xmalloc(sizeof(struct sockaddr_in)); + INIT_SOCKADDR_IN(sa, sizeof(struct sockaddr_in)); + memcpy(&sa->sin_addr, ipv4addr, sizeof(ipv4addr)); + sa->sin_port = htons(port); + ai0->ai_family = PF_INET; + ai0->ai_socktype = list[i].socktype; + ai0->ai_protocol = hint_protocol ? hint_protocol : list[i].protocol; + ai0->ai_addrlen = sizeof(struct sockaddr_in); + ai0->ai_addr = (struct sockaddr *)sa; + ai0->ai_canonname = NULL; + ai0->ai_next = ai; + ai = ai0; + } + } + } + if (ai) { + *res = ai; + return 0; + } + } +#endif + return EAI_FAIL; +} + int rb_getaddrinfo(const char *node, const char *service, const struct addrinfo *hints, @@ -178,21 +262,28 @@ rb_getaddrinfo(const char *node, const char *service, { struct addrinfo *ai; int ret; + int allocated_by_malloc = 0; + ret = numeric_getaddrinfo(node, service, hints, &ai); + if (ret == 0) + allocated_by_malloc = 1; + else { #ifdef GETADDRINFO_EMU - ret = getaddrinfo(node, service, hints, &ai); + ret = getaddrinfo(node, service, hints, &ai); #else - struct getaddrinfo_arg arg; - MEMZERO(&arg, sizeof arg, 1); - arg.node = node; - arg.service = service; - arg.hints = hints; - arg.res = &ai; - ret = (int)(VALUE)rb_thread_call_without_gvl(nogvl_getaddrinfo, &arg, RUBY_UBF_IO, 0); + struct getaddrinfo_arg arg; + MEMZERO(&arg, struct getaddrinfo_arg, 1); + arg.node = node; + arg.service = service; + arg.hints = hints; + arg.res = &ai; + ret = (int)(VALUE)rb_thread_call_without_gvl(nogvl_getaddrinfo, &arg, RUBY_UBF_IO, 0); #endif + } if (ret == 0) { *res = (struct rb_addrinfo *)xmalloc(sizeof(struct rb_addrinfo)); + (*res)->allocated_by_malloc = allocated_by_malloc; (*res)->ai = ai; } return ret; @@ -201,7 +292,18 @@ rb_getaddrinfo(const char *node, const char *service, void rb_freeaddrinfo(struct rb_addrinfo *ai) { - freeaddrinfo(ai->ai); + if (!ai->allocated_by_malloc) + freeaddrinfo(ai->ai); + else { + struct addrinfo *ai1, *ai2; + ai1 = ai->ai; + while (ai1) { + ai2 = ai1->ai_next; + xfree(ai1->ai_addr); + xfree(ai1); + ai1 = ai2; + } + } xfree(ai); } diff --git a/ext/socket/rubysocket.h b/ext/socket/rubysocket.h index 74896ce30a4ad8..a4893d9698bd39 100644 --- a/ext/socket/rubysocket.h +++ b/ext/socket/rubysocket.h @@ -280,6 +280,7 @@ int rsock_getfamily(int sockfd); struct rb_addrinfo { struct addrinfo *ai; + int allocated_by_malloc; }; int rb_getaddrinfo(const char *node, const char *service, const struct addrinfo *hints, struct rb_addrinfo **res); void rb_freeaddrinfo(struct rb_addrinfo *ai); diff --git a/ext/socket/sockport.h b/ext/socket/sockport.h index a3c698e8a4b24f..2b58958ae7b5a3 100644 --- a/ext/socket/sockport.h +++ b/ext/socket/sockport.h @@ -29,6 +29,12 @@ # define SET_SIN_LEN(sa, len) SET_SA_LEN((struct sockaddr *)(sa), (len)) #endif +#ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN +# define SET_SIN6_LEN(sa, len) (void)((sa)->sin6_len = (len)) +#else +# define SET_SIN6_LEN(sa, len) SET_SA_LEN((struct sockaddr *)(sa), (len)) +#endif + #define INIT_SOCKADDR(addr, family, len) \ do { \ struct sockaddr *init_sockaddr_ptr = (addr); \ @@ -47,6 +53,15 @@ SET_SIN_LEN(init_sockaddr_ptr, init_sockaddr_len); \ } while (0) +#define INIT_SOCKADDR_IN6(addr, len) \ + do { \ + struct sockaddr_in6 *init_sockaddr_ptr = (addr); \ + socklen_t init_sockaddr_len = (len); \ + memset(init_sockaddr_ptr, 0, init_sockaddr_len); \ + init_sockaddr_ptr->sin6_family = AF_INET6; \ + SET_SIN6_LEN(init_sockaddr_ptr, init_sockaddr_len); \ + } while (0) + /* for strict-aliasing rule */ #ifdef HAVE_TYPE_STRUCT_SOCKADDR_UN diff --git a/include/ruby/win32.h b/include/ruby/win32.h index 067ac010daeade..64fbdf2744da1e 100644 --- a/include/ruby/win32.h +++ b/include/ruby/win32.h @@ -309,6 +309,7 @@ extern char **rb_w32_get_environ(void); extern void rb_w32_free_environ(char **); extern int rb_w32_map_errno(DWORD); extern const char *WSAAPI rb_w32_inet_ntop(int,const void *,char *,size_t); +extern int WSAAPI rb_w32_inet_pton(int,const char *,void *); extern DWORD rb_w32_osver(void); extern int chown(const char *, int, int); @@ -652,6 +653,9 @@ extern char *rb_w32_strerror(int); #undef inet_ntop #define inet_ntop(f,a,n,l) rb_w32_inet_ntop(f,a,n,l) +#undef inet_pton +#define inet_pton(f,s,d) rb_w32_inet_pton(f,s,d) + #undef accept #define accept(s, a, l) rb_w32_accept(s, a, l) diff --git a/version.h b/version.h index 9949600482904c..ad27c5bb849c5c 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.2" -#define RUBY_RELEASE_DATE "2014-09-04" -#define RUBY_PATCHLEVEL 222 +#define RUBY_RELEASE_DATE "2014-09-06" +#define RUBY_PATCHLEVEL 223 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 9 -#define RUBY_RELEASE_DAY 4 +#define RUBY_RELEASE_DAY 6 #include "ruby/version.h" diff --git a/win32/win32.c b/win32/win32.c index a2ced890ff4547..3051a97f569050 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -6962,6 +6962,19 @@ rb_w32_inet_ntop(int af, const void *addr, char *numaddr, size_t numaddr_len) return numaddr; } +/* License: Ruby's */ +int WSAAPI +rb_w32_inet_pton(int af, const char *src, void *dst) +{ + typedef int (WSAAPI inet_pton_t)(int, const char*, void *); + inet_pton_t *pInetPton; + pInetPton = (inet_pton_t *)get_proc_address("ws2_32", "inet_pton", NULL); + if (pInetPton) { + return pInetPton(af, src, dst); + } + return 0; +} + /* License: Ruby's */ char rb_w32_fd_is_text(int fd) From 0f1fb3d6e34cf9d889656e4362dadaeae949403d Mon Sep 17 00:00:00 2001 From: nagachika Date: Fri, 5 Sep 2014 15:41:26 +0000 Subject: [PATCH 224/343] merge revision(s) r44916: [Backport #10043] error.c: Crash Report log * error.c (REPORTBUG_MSG): mention about Crash Report log file on MacOS X. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47416 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- error.c | 7 ++++++- test/ruby/test_rubyoptions.rb | 1 + version.h | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/error.c b/error.c index b9d8d52809d7c6..d533a3bf4b1ef1 100644 --- a/error.c +++ b/error.c @@ -43,12 +43,17 @@ VALUE rb_eEINPROGRESS; extern const char ruby_description[]; -#define REPORTBUG_MSG \ +static const char REPORTBUG_MSG[] = "[NOTE]\n" \ "You may have encountered a bug in the Ruby interpreter" \ " or extension libraries.\n" \ "Bug reports are welcome.\n" \ + "" +#if defined __APPLE__ + "Don't forget to include the above Crash Report log file.\n" +#endif "For details: http://www.ruby-lang.org/bugreport.html\n\n" \ + ; static const char * rb_strerrno(int err) diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb index ba25f8a489da74..b6be5011cd971b 100644 --- a/test/ruby/test_rubyoptions.rb +++ b/test/ruby/test_rubyoptions.rb @@ -527,6 +527,7 @@ module SEGVTest \[NOTE\]\n You\smay\shave\sencountered\sa\sbug\sin\sthe\sRuby\sinterpreter\sor\sextension\slibraries.\n Bug\sreports\sare\swelcome.\n + (?:.*\n)? For\sdetails:\shttp:\/\/.*\.ruby-lang\.org/.*\n \n (?:#{additional}) diff --git a/version.h b/version.h index ad27c5bb849c5c..324daf2d433f95 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-09-06" -#define RUBY_PATCHLEVEL 223 +#define RUBY_PATCHLEVEL 224 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 9 From ea08099e88e6f967e14f35b9afb14b97cdbb351f Mon Sep 17 00:00:00 2001 From: nagachika Date: Fri, 5 Sep 2014 15:55:12 +0000 Subject: [PATCH 225/343] merge revision(s) r46796: [Backport #10008] * configure.in (rb_cv_broken_backtrace): exit with failure normally, no needs to abort. [ruby-core:63678] [Bug #10008] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47418 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ configure.in | 14 +++++++------- version.h | 2 +- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 332d9507b3d542..df925db564a1d9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sat Sep 6 00:47:32 2014 Nobuyoshi Nakada + + * configure.in (rb_cv_broken_backtrace): exit with failure + normally, no needs to abort. [ruby-core:63678] [Bug #10008] + Sat Sep 6 00:05:02 2014 Nobuyoshi Nakada * include/ruby/win32.h, win32/win32.c (rb_w32_inet_pton): add a diff --git a/configure.in b/configure.in index b657b1fa3d50d9..fc01f3b42526b0 100644 --- a/configure.in +++ b/configure.in @@ -2886,24 +2886,25 @@ void sigsegv(int signum, siginfo_t *info, void *ctx){ if (n > 0) { /*fprintf(stdout, "backtrace:%d\n",n);*/ } else { - abort(); + _exit(EXIT_FAILURE); } - _exit(0); + _exit(EXIT_SUCCESS); } int -main() +main(void) { + volatile int *a = NULL; stack_t ss; ss.ss_sp = malloc(SIGSTKSZ); if (ss.ss_sp == NULL) { fprintf(stderr, "cannot allocate memory for sigaltstack\n"); - abort(); + return EXIT_FAILURE; } ss.ss_size = SIGSTKSZ; ss.ss_flags = 0; if (sigaltstack(&ss, NULL) == -1) { fprintf(stderr, "sigaltstack failed\n"); - abort(); + return EXIT_FAILURE; } struct sigaction sa; memset(&sa, 0, sizeof(struct sigaction)); @@ -2912,9 +2913,8 @@ main() sa.sa_flags |= SA_SIGINFO; sa.sa_flags |= SA_ONSTACK; sigaction(SIGSEGV, &sa, NULL); - int *a = NULL; a[0] = 1; - return 0; + return EXIT_SUCCESS; } ], rb_cv_broken_backtrace=no, diff --git a/version.h b/version.h index 324daf2d433f95..6e26c94fd37423 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-09-06" -#define RUBY_PATCHLEVEL 224 +#define RUBY_PATCHLEVEL 225 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 9 From c44e4364990321e47a7b1a546764dc158504edf5 Mon Sep 17 00:00:00 2001 From: nagachika Date: Fri, 5 Sep 2014 15:58:09 +0000 Subject: [PATCH 226/343] merge revision(s) r47327: [Backport #10008] * ext/zlib/zlib.c (gzfile_reset): preserve ZSTREAM_FLAG_GZFILE [Bug #10101] * test/zlib/test_zlib.rb (test_rewind): test each_byte git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47419 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ ext/zlib/zlib.c | 1 + test/zlib/test_zlib.rb | 5 +++++ version.h | 2 +- 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index df925db564a1d9..95af1b3908bdd4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Sat Sep 6 00:57:07 2014 Eric Wong + + * ext/zlib/zlib.c (gzfile_reset): preserve ZSTREAM_FLAG_GZFILE + [Bug #10101] + + * test/zlib/test_zlib.rb (test_rewind): test each_byte + Sat Sep 6 00:47:32 2014 Nobuyoshi Nakada * configure.in (rb_cv_broken_backtrace): exit with failure diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c index ffdd9a0b7d51d2..4d8fde68c9d9f0 100644 --- a/ext/zlib/zlib.c +++ b/ext/zlib/zlib.c @@ -2288,6 +2288,7 @@ static void gzfile_reset(struct gzfile *gz) { zstream_reset(&gz->z); + gz->z.flags |= ZSTREAM_FLAG_GZFILE; gz->crc = crc32(0, Z_NULL, 0); gz->lineno = 0; gz->ungetc = 0; diff --git a/test/zlib/test_zlib.rb b/test/zlib/test_zlib.rb index 5dd5bcf51d1a65..bb76c23a1f55c2 100644 --- a/test/zlib/test_zlib.rb +++ b/test/zlib/test_zlib.rb @@ -697,6 +697,11 @@ def test_rewind assert_equal("foo", f.read) f.rewind assert_equal("foo", f.read) + + f.rewind + bytes = [] + f.each_byte { |b| bytes << b } + assert_equal "foo".bytes.to_a, bytes, '[Bug #10101]' end open(t.path, "rb") do |f| gz = Zlib::GzipReader.new(f) diff --git a/version.h b/version.h index 6e26c94fd37423..6256571e7b93f6 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-09-06" -#define RUBY_PATCHLEVEL 225 +#define RUBY_PATCHLEVEL 226 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 9 From 25552e2ab20d22d55e0d7baa0ff3fc9d38706246 Mon Sep 17 00:00:00 2001 From: zzak Date: Sat, 6 Sep 2014 00:04:18 +0000 Subject: [PATCH 227/343] Backport r47425 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47426 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ .../generator/template/darkfish/js/jquery.js | 22 ++++--------------- 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index 95af1b3908bdd4..0d5adc49d31ddf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Fri Sep 5 17:01:38 2014 Zachary Scott + + * lib/rdoc/generator/template/darkfish/js/jquery.js: Backport + rdoc/rdoc@74f60fcb04fee1778fe2694d1a0ea6513f8e67b7 + Sat Sep 6 00:57:07 2014 Eric Wong * ext/zlib/zlib.c (gzfile_reset): preserve ZSTREAM_FLAG_GZFILE diff --git a/lib/rdoc/generator/template/darkfish/js/jquery.js b/lib/rdoc/generator/template/darkfish/js/jquery.js index 48590ecb96a74f..628ed9b31604ed 100644 --- a/lib/rdoc/generator/template/darkfish/js/jquery.js +++ b/lib/rdoc/generator/template/darkfish/js/jquery.js @@ -1,18 +1,4 @@ -/*! - * jQuery JavaScript Library v1.6.2 - * http://jquery.com/ - * - * Copyright 2011, John Resig - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * Includes Sizzle.js - * http://sizzlejs.com/ - * Copyright 2011, The Dojo Foundation - * Released under the MIT, BSD, and GPL Licenses. - * - * Date: Thu Jun 30 14:16:56 2011 -0400 - */ -(function(a,b){function cv(a){return f.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function cs(a){if(!cg[a]){var b=c.body,d=f("<"+a+">").appendTo(b),e=d.css("display");d.remove();if(e==="none"||e===""){ch||(ch=c.createElement("iframe"),ch.frameBorder=ch.width=ch.height=0),b.appendChild(ch);if(!ci||!ch.createElement)ci=(ch.contentWindow||ch.contentDocument).document,ci.write((c.compatMode==="CSS1Compat"?"":"")+""),ci.close();d=ci.createElement(a),ci.body.appendChild(d),e=f.css(d,"display"),b.removeChild(ch)}cg[a]=e}return cg[a]}function cr(a,b){var c={};f.each(cm.concat.apply([],cm.slice(0,b)),function(){c[this]=a});return c}function cq(){cn=b}function cp(){setTimeout(cq,0);return cn=f.now()}function cf(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function ce(){try{return new a.XMLHttpRequest}catch(b){}}function b$(a,c){a.dataFilter&&(c=a.dataFilter(c,a.dataType));var d=a.dataTypes,e={},g,h,i=d.length,j,k=d[0],l,m,n,o,p;for(g=1;g0){c!=="border"&&f.each(e,function(){c||(d-=parseFloat(f.css(a,"padding"+this))||0),c==="margin"?d+=parseFloat(f.css(a,c+this))||0:d-=parseFloat(f.css(a,"border"+this+"Width"))||0});return d+"px"}d=bx(a,b,b);if(d<0||d==null)d=a.style[b]||0;d=parseFloat(d)||0,c&&f.each(e,function(){d+=parseFloat(f.css(a,"padding"+this))||0,c!=="padding"&&(d+=parseFloat(f.css(a,"border"+this+"Width"))||0),c==="margin"&&(d+=parseFloat(f.css(a,c+this))||0)});return d+"px"}function bm(a,b){b.src?f.ajax({url:b.src,async:!1,dataType:"script"}):f.globalEval((b.text||b.textContent||b.innerHTML||"").replace(be,"/*$0*/")),b.parentNode&&b.parentNode.removeChild(b)}function bl(a){f.nodeName(a,"input")?bk(a):"getElementsByTagName"in a&&f.grep(a.getElementsByTagName("input"),bk)}function bk(a){if(a.type==="checkbox"||a.type==="radio")a.defaultChecked=a.checked}function bj(a){return"getElementsByTagName"in a?a.getElementsByTagName("*"):"querySelectorAll"in a?a.querySelectorAll("*"):[]}function bi(a,b){var c;if(b.nodeType===1){b.clearAttributes&&b.clearAttributes(),b.mergeAttributes&&b.mergeAttributes(a),c=b.nodeName.toLowerCase();if(c==="object")b.outerHTML=a.outerHTML;else if(c!=="input"||a.type!=="checkbox"&&a.type!=="radio"){if(c==="option")b.selected=a.defaultSelected;else if(c==="input"||c==="textarea")b.defaultValue=a.defaultValue}else a.checked&&(b.defaultChecked=b.checked=a.checked),b.value!==a.value&&(b.value=a.value);b.removeAttribute(f.expando)}}function bh(a,b){if(b.nodeType===1&&!!f.hasData(a)){var c=f.expando,d=f.data(a),e=f.data(b,d);if(d=d[c]){var g=d.events;e=e[c]=f.extend({},d);if(g){delete e.handle,e.events={};for(var h in g)for(var i=0,j=g[h].length;i=0===c})}function V(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function N(a,b){return(a&&a!=="*"?a+".":"")+b.replace(z,"`").replace(A,"&")}function M(a){var b,c,d,e,g,h,i,j,k,l,m,n,o,p=[],q=[],r=f._data(this,"events");if(!(a.liveFired===this||!r||!r.live||a.target.disabled||a.button&&a.type==="click")){a.namespace&&(n=new RegExp("(^|\\.)"+a.namespace.split(".").join("\\.(?:.*\\.)?")+"(\\.|$)")),a.liveFired=this;var s=r.live.slice(0);for(i=0;ic)break;a.currentTarget=e.elem,a.data=e.handleObj.data,a.handleObj=e.handleObj,o=e.handleObj.origHandler.apply(e.elem,arguments);if(o===!1||a.isPropagationStopped()){c=e.level,o===!1&&(b=!1);if(a.isImmediatePropagationStopped())break}}return b}}function K(a,c,d){var e=f.extend({},d[0]);e.type=a,e.originalEvent={},e.liveFired=b,f.event.handle.call(c,e),e.isDefaultPrevented()&&d[0].preventDefault()}function E(){return!0}function D(){return!1}function m(a,c,d){var e=c+"defer",g=c+"queue",h=c+"mark",i=f.data(a,e,b,!0);i&&(d==="queue"||!f.data(a,g,b,!0))&&(d==="mark"||!f.data(a,h,b,!0))&&setTimeout(function(){!f.data(a,g,b,!0)&&!f.data(a,h,b,!0)&&(f.removeData(a,e,!0),i.resolve())},0)}function l(a){for(var b in a)if(b!=="toJSON")return!1;return!0}function k(a,c,d){if(d===b&&a.nodeType===1){var e="data-"+c.replace(j,"$1-$2").toLowerCase();d=a.getAttribute(e);if(typeof d=="string"){try{d=d==="true"?!0:d==="false"?!1:d==="null"?null:f.isNaN(d)?i.test(d)?f.parseJSON(d):d:parseFloat(d)}catch(g){}f.data(a,c,d)}else d=b}return d}var c=a.document,d=a.navigator,e=a.location,f=function(){function J(){if(!e.isReady){try{c.documentElement.doScroll("left")}catch(a){setTimeout(J,1);return}e.ready()}}var e=function(a,b){return new e.fn.init(a,b,h)},f=a.jQuery,g=a.$,h,i=/^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,j=/\S/,k=/^\s+/,l=/\s+$/,m=/\d/,n=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,o=/^[\],:{}\s]*$/,p=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,q=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,r=/(?:^|:|,)(?:\s*\[)+/g,s=/(webkit)[ \/]([\w.]+)/,t=/(opera)(?:.*version)?[ \/]([\w.]+)/,u=/(msie) ([\w.]+)/,v=/(mozilla)(?:.*? rv:([\w.]+))?/,w=/-([a-z])/ig,x=function(a,b){return b.toUpperCase()},y=d.userAgent,z,A,B,C=Object.prototype.toString,D=Object.prototype.hasOwnProperty,E=Array.prototype.push,F=Array.prototype.slice,G=String.prototype.trim,H=Array.prototype.indexOf,I={};e.fn=e.prototype={constructor:e,init:function(a,d,f){var g,h,j,k;if(!a)return this;if(a.nodeType){this.context=this[0]=a,this.length=1;return this}if(a==="body"&&!d&&c.body){this.context=c,this[0]=c.body,this.selector=a,this.length=1;return this}if(typeof a=="string"){a.charAt(0)!=="<"||a.charAt(a.length-1)!==">"||a.length<3?g=i.exec(a):g=[null,a,null];if(g&&(g[1]||!d)){if(g[1]){d=d instanceof e?d[0]:d,k=d?d.ownerDocument||d:c,j=n.exec(a),j?e.isPlainObject(d)?(a=[c.createElement(j[1])],e.fn.attr.call(a,d,!0)):a=[k.createElement(j[1])]:(j=e.buildFragment([g[1]],[k]),a=(j.cacheable?e.clone(j.fragment):j.fragment).childNodes);return e.merge(this,a)}h=c.getElementById(g[2]);if(h&&h.parentNode){if(h.id!==g[2])return f.find(a);this.length=1,this[0]=h}this.context=c,this.selector=a;return this}return!d||d.jquery?(d||f).find(a):this.constructor(d).find(a)}if(e.isFunction(a))return f.ready(a);a.selector!==b&&(this.selector=a.selector,this.context=a.context);return e.makeArray(a,this)},selector:"",jquery:"1.6.2",length:0,size:function(){return this.length},toArray:function(){return F.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this[this.length+a]:this[a]},pushStack:function(a,b,c){var d=this.constructor();e.isArray(a)?E.apply(d,a):e.merge(d,a),d.prevObject=this,d.context=this.context,b==="find"?d.selector=this.selector+(this.selector?" ":"")+c:b&&(d.selector=this.selector+"."+b+"("+c+")");return d},each:function(a,b){return e.each(this,a,b)},ready:function(a){e.bindReady(),A.done(a);return this},eq:function(a){return a===-1?this.slice(a):this.slice(a,+a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(F.apply(this,arguments),"slice",F.call(arguments).join(","))},map:function(a){return this.pushStack(e.map(this,function(b,c){return a.call(b,c,b)}))},end:function(){return this.prevObject||this.constructor(null)},push:E,sort:[].sort,splice:[].splice},e.fn.init.prototype=e.fn,e.extend=e.fn.extend=function(){var a,c,d,f,g,h,i=arguments[0]||{},j=1,k=arguments.length,l=!1;typeof i=="boolean"&&(l=i,i=arguments[1]||{},j=2),typeof i!="object"&&!e.isFunction(i)&&(i={}),k===j&&(i=this,--j);for(;j0)return;A.resolveWith(c,[e]),e.fn.trigger&&e(c).trigger("ready").unbind("ready")}},bindReady:function(){if(!A){A=e._Deferred();if(c.readyState==="complete")return setTimeout(e.ready,1);if(c.addEventListener)c.addEventListener("DOMContentLoaded",B,!1),a.addEventListener("load",e.ready,!1);else if(c.attachEvent){c.attachEvent("onreadystatechange",B),a.attachEvent("onload",e.ready);var b=!1;try{b=a.frameElement==null}catch(d){}c.documentElement.doScroll&&b&&J()}}},isFunction:function(a){return e.type(a)==="function"},isArray:Array.isArray||function(a){return e.type(a)==="array"},isWindow:function(a){return a&&typeof a=="object"&&"setInterval"in a},isNaN:function(a){return a==null||!m.test(a)||isNaN(a)},type:function(a){return a==null?String(a):I[C.call(a)]||"object"},isPlainObject:function(a){if(!a||e.type(a)!=="object"||a.nodeType||e.isWindow(a))return!1;if(a.constructor&&!D.call(a,"constructor")&&!D.call(a.constructor.prototype,"isPrototypeOf"))return!1;var c;for(c in a);return c===b||D.call(a,c)},isEmptyObject:function(a){for(var b in a)return!1;return!0},error:function(a){throw a},parseJSON:function(b){if(typeof b!="string"||!b)return null;b=e.trim(b);if(a.JSON&&a.JSON.parse)return a.JSON.parse(b);if(o.test(b.replace(p,"@").replace(q,"]").replace(r,"")))return(new Function("return "+b))();e.error("Invalid JSON: "+b)},parseXML:function(b,c,d){a.DOMParser?(d=new DOMParser,c=d.parseFromString(b,"text/xml")):(c=new ActiveXObject("Microsoft.XMLDOM"),c.async="false",c.loadXML(b)),d=c.documentElement,(!d||!d.nodeName||d.nodeName==="parsererror")&&e.error("Invalid XML: "+b);return c},noop:function(){},globalEval:function(b){b&&j.test(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(w,x)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,c,d){var f,g=0,h=a.length,i=h===b||e.isFunction(a);if(d){if(i){for(f in a)if(c.apply(a[f],d)===!1)break}else for(;g0&&a[0]&&a[j-1]||j===0||e.isArray(a));if(k)for(;i1?h.call(arguments,0):c,--e||g.resolveWith(g,h.call(b,0))}}var b=arguments,c=0,d=b.length,e=d,g=d<=1&&a&&f.isFunction(a.promise)?a:f.Deferred();if(d>1){for(;c
a",d=a.getElementsByTagName("*"),e=a.getElementsByTagName("a")[0];if(!d||!d.length||!e)return{};g=c.createElement("select"),h=g.appendChild(c.createElement("option")),i=a.getElementsByTagName("input")[0],k={leadingWhitespace:a.firstChild.nodeType===3,tbody:!a.getElementsByTagName("tbody").length,htmlSerialize:!!a.getElementsByTagName("link").length,style:/top/.test(e.getAttribute("style")),hrefNormalized:e.getAttribute("href")==="/a",opacity:/^0.55$/.test(e.style.opacity),cssFloat:!!e.style.cssFloat,checkOn:i.value==="on",optSelected:h.selected,getSetAttribute:a.className!=="t",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0},i.checked=!0,k.noCloneChecked=i.cloneNode(!0).checked,g.disabled=!0,k.optDisabled=!h.disabled;try{delete a.test}catch(v){k.deleteExpando=!1}!a.addEventListener&&a.attachEvent&&a.fireEvent&&(a.attachEvent("onclick",function(){k.noCloneEvent=!1}),a.cloneNode(!0).fireEvent("onclick")),i=c.createElement("input"),i.value="t",i.setAttribute("type","radio"),k.radioValue=i.value==="t",i.setAttribute("checked","checked"),a.appendChild(i),l=c.createDocumentFragment(),l.appendChild(a.firstChild),k.checkClone=l.cloneNode(!0).cloneNode(!0).lastChild.checked,a.innerHTML="",a.style.width=a.style.paddingLeft="1px",m=c.getElementsByTagName("body")[0],o=c.createElement(m?"div":"body"),p={visibility:"hidden",width:0,height:0,border:0,margin:0},m&&f.extend(p,{position:"absolute",left:-1e3,top:-1e3});for(t in p)o.style[t]=p[t];o.appendChild(a),n=m||b,n.insertBefore(o,n.firstChild),k.appendChecked=i.checked,k.boxModel=a.offsetWidth===2,"zoom"in a.style&&(a.style.display="inline",a.style.zoom=1,k.inlineBlockNeedsLayout=a.offsetWidth===2,a.style.display="",a.innerHTML="
",k.shrinkWrapBlocks=a.offsetWidth!==2),a.innerHTML="
t
",q=a.getElementsByTagName("td"),u=q[0].offsetHeight===0,q[0].style.display="",q[1].style.display="none",k.reliableHiddenOffsets=u&&q[0].offsetHeight===0,a.innerHTML="",c.defaultView&&c.defaultView.getComputedStyle&&(j=c.createElement("div"),j.style.width="0",j.style.marginRight="0",a.appendChild(j),k.reliableMarginRight=(parseInt((c.defaultView.getComputedStyle(j,null)||{marginRight:0}).marginRight,10)||0)===0),o.innerHTML="",n.removeChild(o);if(a.attachEvent)for(t in{submit:1,change:1,focusin:1})s="on"+t,u=s in a,u||(a.setAttribute(s,"return;"),u=typeof a[s]=="function"),k[t+"Bubbles"]=u;o=l=g=h=m=j=a=i=null;return k}(),f.boxModel=f.support.boxModel;var i=/^(?:\{.*\}|\[.*\])$/,j=/([a-z])([A-Z])/g;f.extend({cache:{},uuid:0,expando:"jQuery"+(f.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){a=a.nodeType?f.cache[a[f.expando]]:a[f.expando];return!!a&&!l(a)},data:function(a,c,d,e){if(!!f.acceptData(a)){var g=f.expando,h=typeof c=="string",i,j=a.nodeType,k=j?f.cache:a,l=j?a[f.expando]:a[f.expando]&&f.expando;if((!l||e&&l&&!k[l][g])&&h&&d===b)return;l||(j?a[f.expando]=l=++f.uuid:l=f.expando),k[l]||(k[l]={},j||(k[l].toJSON=f.noop));if(typeof c=="object"||typeof c=="function")e?k[l][g]=f.extend(k[l][g],c):k[l]=f.extend(k[l],c);i=k[l],e&&(i[g]||(i[g]={}),i=i[g]),d!==b&&(i[f.camelCase(c)]=d);if(c==="events"&&!i[c])return i[g]&&i[g].events;return h?i[f.camelCase(c)]||i[c]:i}},removeData:function(b,c,d){if(!!f.acceptData(b)){var e=f.expando,g=b.nodeType,h=g?f.cache:b,i=g?b[f.expando]:f.expando;if(!h[i])return;if(c){var j=d?h[i][e]:h[i];if(j){delete j[c];if(!l(j))return}}if(d){delete h[i][e];if(!l(h[i]))return}var k=h[i][e];f.support.deleteExpando||h!=a?delete h[i]:h[i]=null,k?(h[i]={},g||(h[i].toJSON=f.noop),h[i][e]=k):g&&(f.support.deleteExpando?delete b[f.expando]:b.removeAttribute?b.removeAttribute(f.expando):b[f.expando]=null)}},_data:function(a,b,c){return f.data(a,b,c,!0)},acceptData:function(a){if(a.nodeName){var b=f.noData[a.nodeName.toLowerCase()];if(b)return b!==!0&&a.getAttribute("classid")===b}return!0}}),f.fn.extend({data:function(a,c){var d=null;if(typeof a=="undefined"){if(this.length){d=f.data(this[0]);if(this[0].nodeType===1){var e=this[0].attributes,g;for(var h=0,i=e.length;h-1)return!0;return!1},val:function(a){var c,d,e=this[0];if(!arguments.length){if(e){c=f.valHooks[e.nodeName.toLowerCase()]||f.valHooks[e.type];if(c&&"get"in c&&(d=c.get(e,"value"))!==b)return d;d=e.value;return typeof d=="string"?d.replace(p,""):d==null?"":d}return b}var g=f.isFunction(a);return this.each(function(d){var e=f(this),h;if(this.nodeType===1){g?h=a.call(this,d,e.val()):h=a,h==null?h="":typeof h=="number"?h+="":f.isArray(h)&&(h=f.map(h,function(a){return a==null?"":a+""})),c=f.valHooks[this.nodeName.toLowerCase()]||f.valHooks[this.type];if(!c||!("set"in c)||c.set(this,h,"value")===b)this.value=h}})}}),f.extend({valHooks:{option:{get:function(a){var b=a.attributes.value;return!b||b.specified?a.value:a.text}},select:{get:function(a){var b,c=a.selectedIndex,d=[],e=a.options,g=a.type==="select-one";if(c<0)return null;for(var h=g?c:0,i=g?c+1:e.length;h=0}),c.length||(a.selectedIndex=-1);return c}}},attrFn:{val:!0,css:!0,html:!0,text:!0,data:!0,width:!0,height:!0,offset:!0},attrFix:{tabindex:"tabIndex"},attr:function(a,c,d,e){var g=a.nodeType;if(!a||g===3||g===8||g===2)return b;if(e&&c in f.attrFn)return f(a)[c](d);if(!("getAttribute"in a))return f.prop(a,c,d);var h,i,j=g!==1||!f.isXMLDoc(a);j&&(c=f.attrFix[c]||c,i=f.attrHooks[c],i||(t.test(c)?i=w:v&&c!=="className"&&(f.nodeName(a,"form")||u.test(c))&&(i=v)));if(d!==b){if(d===null){f.removeAttr(a,c);return b}if(i&&"set"in i&&j&&(h=i.set(a,d,c))!==b)return h;a.setAttribute(c,""+d);return d}if(i&&"get"in i&&j&&(h=i.get(a,c))!==null)return h;h=a.getAttribute(c);return h===null?b:h},removeAttr:function(a,b){var c;a.nodeType===1&&(b=f.attrFix[b]||b,f.support.getSetAttribute?a.removeAttribute(b):(f.attr(a,b,""),a.removeAttributeNode(a.getAttributeNode(b))),t.test(b)&&(c=f.propFix[b]||b)in a&&(a[c]=!1))},attrHooks:{type:{set:function(a,b){if(q.test(a.nodeName)&&a.parentNode)f.error("type property can't be changed");else if(!f.support.radioValue&&b==="radio"&&f.nodeName(a,"input")){var c=a.value;a.setAttribute("type",b),c&&(a.value=c);return b}}},tabIndex:{get:function(a){var c=a.getAttributeNode("tabIndex");return c&&c.specified?parseInt(c.value,10):r.test(a.nodeName)||s.test(a.nodeName)&&a.href?0:b}},value:{get:function(a,b){if(v&&f.nodeName(a,"button"))return v.get(a,b);return b in a?a.value:null},set:function(a,b,c){if(v&&f.nodeName(a,"button"))return v.set(a,b,c);a.value=b}}},propFix:{tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},prop:function(a,c,d){var e=a.nodeType;if(!a||e===3||e===8||e===2)return b;var g,h,i=e!==1||!f.isXMLDoc(a);i&&(c=f.propFix[c]||c,h=f.propHooks[c]);return d!==b?h&&"set"in h&&(g=h.set(a,d,c))!==b?g:a[c]=d:h&&"get"in h&&(g=h.get(a,c))!==b?g:a[c]},propHooks:{}}),w={get:function(a,c){return f.prop(a,c)?c.toLowerCase():b},set:function(a,b,c){var d;b===!1?f.removeAttr(a,c):(d=f.propFix[c]||c,d in a&&(a[d]=!0),a.setAttribute(c,c.toLowerCase()));return c}},f.support.getSetAttribute||(f.attrFix=f.propFix,v=f.attrHooks.name=f.attrHooks.title=f.valHooks.button={get:function(a,c){var d;d=a.getAttributeNode(c);return d&&d.nodeValue!==""?d.nodeValue:b},set:function(a,b,c){var d=a.getAttributeNode(c);if(d){d.nodeValue=b;return b}}},f.each(["width","height"],function(a,b){f.attrHooks[b]=f.extend(f.attrHooks[b],{set:function(a,c){if(c===""){a.setAttribute(b,"auto");return c}}})})),f.support.hrefNormalized||f.each(["href","src","width","height"],function(a,c){f.attrHooks[c]=f.extend(f.attrHooks[c],{get:function(a){var d=a.getAttribute(c,2);return d===null?b:d}})}),f.support.style||(f.attrHooks.style={get:function(a){return a.style.cssText.toLowerCase()||b},set:function(a,b){return a.style.cssText=""+b}}),f.support.optSelected||(f.propHooks.selected=f.extend(f.propHooks.selected,{get:function(a){var b=a.parentNode;b&&(b.selectedIndex,b.parentNode&&b.parentNode.selectedIndex)}})),f.support.checkOn||f.each(["radio","checkbox"],function(){f.valHooks[this]={get:function(a){return a.getAttribute("value")===null?"on":a.value}}}),f.each(["radio","checkbox"],function(){f.valHooks[this]=f.extend(f.valHooks[this],{set:function(a,b){if(f.isArray(b))return a.checked=f.inArray(f(a).val(),b)>=0}})});var x=/\.(.*)$/,y=/^(?:textarea|input|select)$/i,z=/\./g,A=/ /g,B=/[^\w\s.|`]/g,C=function(a){return a.replace(B,"\\$&")};f.event={add:function(a,c,d,e){if(a.nodeType!==3&&a.nodeType!==8){if(d===!1)d=D;else if(!d)return;var g,h;d.handler&&(g=d,d=g.handler),d.guid||(d.guid=f.guid++);var i=f._data(a);if(!i)return;var j=i.events,k=i.handle;j||(i.events=j={}),k||(i.handle=k=function(a){return typeof f!="undefined"&&(!a||f.event.triggered!==a.type)?f.event.handle.apply(k.elem,arguments):b}),k.elem=a,c=c.split(" ");var l,m=0,n;while(l=c[m++]){h=g?f.extend({},g):{handler:d,data:e},l.indexOf(".")>-1?(n=l.split("."),l=n.shift(),h.namespace=n.slice(0).sort().join(".")):(n=[],h.namespace=""),h.type=l,h.guid||(h.guid=d.guid);var o=j[l],p=f.event.special[l]||{};if(!o){o=j[l]=[];if(!p.setup||p.setup.call(a,e,n,k)===!1)a.addEventListener?a.addEventListener(l,k,!1):a.attachEvent&&a.attachEvent("on"+l,k)}p.add&&(p.add.call(a,h),h.handler.guid||(h.handler.guid=d.guid)),o.push(h),f.event.global[l]=!0}a=null}},global:{},remove:function(a,c,d,e){if(a.nodeType!==3&&a.nodeType!==8){d===!1&&(d=D);var g,h,i,j,k=0,l,m,n,o,p,q,r,s=f.hasData(a)&&f._data(a),t=s&&s.events;if(!s||!t)return;c&&c.type&&(d=c.handler,c=c.type);if(!c||typeof c=="string"&&c.charAt(0)==="."){c=c||"";for(h in t)f.event.remove(a,h+c);return}c=c.split(" ");while(h=c[k++]){r=h,q=null,l=h.indexOf(".")<0,m=[],l||(m=h.split("."),h=m.shift(),n=new RegExp("(^|\\.)"+f.map(m.slice(0).sort(),C).join("\\.(?:.*\\.)?")+"(\\.|$)")),p=t[h];if(!p)continue;if(!d){for(j=0;j=0&&(h=h.slice(0,-1),j=!0),h.indexOf(".")>=0&&(i=h.split("."),h=i. -shift(),i.sort());if(!!e&&!f.event.customEvent[h]||!!f.event.global[h]){c=typeof c=="object"?c[f.expando]?c:new f.Event(h,c):new f.Event(h),c.type=h,c.exclusive=j,c.namespace=i.join("."),c.namespace_re=new RegExp("(^|\\.)"+i.join("\\.(?:.*\\.)?")+"(\\.|$)");if(g||!e)c.preventDefault(),c.stopPropagation();if(!e){f.each(f.cache,function(){var a=f.expando,b=this[a];b&&b.events&&b.events[h]&&f.event.trigger(c,d,b.handle.elem)});return}if(e.nodeType===3||e.nodeType===8)return;c.result=b,c.target=e,d=d!=null?f.makeArray(d):[],d.unshift(c);var k=e,l=h.indexOf(":")<0?"on"+h:"";do{var m=f._data(k,"handle");c.currentTarget=k,m&&m.apply(k,d),l&&f.acceptData(k)&&k[l]&&k[l].apply(k,d)===!1&&(c.result=!1,c.preventDefault()),k=k.parentNode||k.ownerDocument||k===c.target.ownerDocument&&a}while(k&&!c.isPropagationStopped());if(!c.isDefaultPrevented()){var n,o=f.event.special[h]||{};if((!o._default||o._default.call(e.ownerDocument,c)===!1)&&(h!=="click"||!f.nodeName(e,"a"))&&f.acceptData(e)){try{l&&e[h]&&(n=e[l],n&&(e[l]=null),f.event.triggered=h,e[h]())}catch(p){}n&&(e[l]=n),f.event.triggered=b}}return c.result}},handle:function(c){c=f.event.fix(c||a.event);var d=((f._data(this,"events")||{})[c.type]||[]).slice(0),e=!c.exclusive&&!c.namespace,g=Array.prototype.slice.call(arguments,0);g[0]=c,c.currentTarget=this;for(var h=0,i=d.length;h-1?f.map(a.options,function(a){return a.selected}).join("-"):"":f.nodeName(a,"select")&&(c=a.selectedIndex);return c},J=function(c){var d=c.target,e,g;if(!!y.test(d.nodeName)&&!d.readOnly){e=f._data(d,"_change_data"),g=I(d),(c.type!=="focusout"||d.type!=="radio")&&f._data(d,"_change_data",g);if(e===b||g===e)return;if(e!=null||g)c.type="change",c.liveFired=b,f.event.trigger(c,arguments[1],d)}};f.event.special.change={filters:{focusout:J,beforedeactivate:J,click:function(a){var b=a.target,c=f.nodeName(b,"input")?b.type:"";(c==="radio"||c==="checkbox"||f.nodeName(b,"select"))&&J.call(this,a)},keydown:function(a){var b=a.target,c=f.nodeName(b,"input")?b.type:"";(a.keyCode===13&&!f.nodeName(b,"textarea")||a.keyCode===32&&(c==="checkbox"||c==="radio")||c==="select-multiple")&&J.call(this,a)},beforeactivate:function(a){var b=a.target;f._data(b,"_change_data",I(b))}},setup:function(a,b){if(this.type==="file")return!1;for(var c in H)f.event.add(this,c+".specialChange",H[c]);return y.test(this.nodeName)},teardown:function(a){f.event.remove(this,".specialChange");return y.test(this.nodeName)}},H=f.event.special.change.filters,H.focus=H.beforeactivate}f.support.focusinBubbles||f.each({focus:"focusin",blur:"focusout"},function(a,b){function e(a){var c=f.event.fix(a);c.type=b,c.originalEvent={},f.event.trigger(c,null,c.target),c.isDefaultPrevented()&&a.preventDefault()}var d=0;f.event.special[b]={setup:function(){d++===0&&c.addEventListener(a,e,!0)},teardown:function(){--d===0&&c.removeEventListener(a,e,!0)}}}),f.each(["bind","one"],function(a,c){f.fn[c]=function(a,d,e){var g;if(typeof a=="object"){for(var h in a)this[c](h,d,a[h],e);return this}if(arguments.length===2||d===!1)e=d,d=b;c==="one"?(g=function(a){f(this).unbind(a,g);return e.apply(this,arguments)},g.guid=e.guid||f.guid++):g=e;if(a==="unload"&&c!=="one")this.one(a,d,e);else for(var i=0,j=this.length;i0?this.bind(b,a,c):this.trigger(b)},f.attrFn&&(f.attrFn[b]=!0)}),function(){function u(a,b,c,d,e,f){for(var g=0,h=d.length;g0){j=i;break}}i=i[a]}d[g]=j}}}function t(a,b,c,d,e,f){for(var g=0,h=d.length;g+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,d=0,e=Object.prototype.toString,g=!1,h=!0,i=/\\/g,j=/\W/;[0,0].sort(function(){h=!1;return 0});var k=function(b,d,f,g){f=f||[],d=d||c;var h=d;if(d.nodeType!==1&&d.nodeType!==9)return[];if(!b||typeof b!="string")return f;var i,j,n,o,q,r,s,t,u=!0,w=k.isXML(d),x=[],y=b;do{a.exec(""),i=a.exec(y);if(i){y=i[3],x.push(i[1]);if(i[2]){o=i[3];break}}}while(i);if(x.length>1&&m.exec(b))if(x.length===2&&l.relative[x[0]])j=v(x[0]+x[1],d);else{j=l.relative[x[0]]?[d]:k(x.shift(),d);while(x.length)b=x.shift(),l.relative[b]&&(b+=x.shift()),j=v(b,j)}else{!g&&x.length>1&&d.nodeType===9&&!w&&l.match.ID.test(x[0])&&!l.match.ID.test(x[x.length-1])&&(q=k.find(x.shift(),d,w),d=q.expr?k.filter(q.expr,q.set)[0]:q.set[0]);if(d){q=g?{expr:x.pop(),set:p(g)}:k.find(x.pop(),x.length===1&&(x[0]==="~"||x[0]==="+")&&d.parentNode?d.parentNode:d,w),j=q.expr?k.filter(q.expr,q.set):q.set,x.length>0?n=p(j):u=!1;while(x.length)r=x.pop(),s=r,l.relative[r]?s=x.pop():r="",s==null&&(s=d),l.relative[r](n,s,w)}else n=x=[]}n||(n=j),n||k.error(r||b);if(e.call(n)==="[object Array]")if(!u)f.push.apply(f,n);else if(d&&d.nodeType===1)for(t=0;n[t]!=null;t++)n[t]&&(n[t]===!0||n[t].nodeType===1&&k.contains(d,n[t]))&&f.push(j[t]);else for(t=0;n[t]!=null;t++)n[t]&&n[t].nodeType===1&&f.push(j[t]);else p(n,f);o&&(k(o,h,f,g),k.uniqueSort(f));return f};k.uniqueSort=function(a){if(r){g=h,a.sort(r);if(g)for(var b=1;b0},k.find=function(a,b,c){var d;if(!a)return[];for(var e=0,f=l.order.length;e":function(a,b){var c,d=typeof b=="string",e=0,f=a.length;if(d&&!j.test(b)){b=b.toLowerCase();for(;e=0)?c||d.push(h):c&&(b[g]=!1));return!1},ID:function(a){return a[1].replace(i,"")},TAG:function(a,b){return a[1].replace(i,"").toLowerCase()},CHILD:function(a){if(a[1]==="nth"){a[2]||k.error(a[0]),a[2]=a[2].replace(/^\+|\s*/g,"");var b=/(-?)(\d*)(?:n([+\-]?\d*))?/.exec(a[2]==="even"&&"2n"||a[2]==="odd"&&"2n+1"||!/\D/.test(a[2])&&"0n+"+a[2]||a[2]);a[2]=b[1]+(b[2]||1)-0,a[3]=b[3]-0}else a[2]&&k.error(a[0]);a[0]=d++;return a},ATTR:function(a,b,c,d,e,f){var g=a[1]=a[1].replace(i,"");!f&&l.attrMap[g]&&(a[1]=l.attrMap[g]),a[4]=(a[4]||a[5]||"").replace(i,""),a[2]==="~="&&(a[4]=" "+a[4]+" ");return a},PSEUDO:function(b,c,d,e,f){if(b[1]==="not")if((a.exec(b[3])||"").length>1||/^\w/.test(b[3]))b[3]=k(b[3],null,null,c);else{var g=k.filter(b[3],c,d,!0^f);d||e.push.apply(e,g);return!1}else if(l.match.POS.test(b[0])||l.match.CHILD.test(b[0]))return!0;return b},POS:function(a){a.unshift(!0);return a}},filters:{enabled:function(a){return a.disabled===!1&&a.type!=="hidden"},disabled:function(a){return a.disabled===!0},checked:function(a){return a.checked===!0},selected:function(a){a.parentNode&&a.parentNode.selectedIndex;return a.selected===!0},parent:function(a){return!!a.firstChild},empty:function(a){return!a.firstChild},has:function(a,b,c){return!!k(c[3],a).length},header:function(a){return/h\d/i.test(a.nodeName)},text:function(a){var b=a.getAttribute("type"),c=a.type;return a.nodeName.toLowerCase()==="input"&&"text"===c&&(b===c||b===null)},radio:function(a){return a.nodeName.toLowerCase()==="input"&&"radio"===a.type},checkbox:function(a){return a.nodeName.toLowerCase()==="input"&&"checkbox"===a.type},file:function(a){return a.nodeName.toLowerCase()==="input"&&"file"===a.type},password:function(a){return a.nodeName.toLowerCase()==="input"&&"password"===a.type},submit:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"submit"===a.type},image:function(a){return a.nodeName.toLowerCase()==="input"&&"image"===a.type},reset:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"reset"===a.type},button:function(a){var b=a.nodeName.toLowerCase();return b==="input"&&"button"===a.type||b==="button"},input:function(a){return/input|select|textarea|button/i.test(a.nodeName)},focus:function(a){return a===a.ownerDocument.activeElement}},setFilters:{first:function(a,b){return b===0},last:function(a,b,c,d){return b===d.length-1},even:function(a,b){return b%2===0},odd:function(a,b){return b%2===1},lt:function(a,b,c){return bc[3]-0},nth:function(a,b,c){return c[3]-0===b},eq:function(a,b,c){return c[3]-0===b}},filter:{PSEUDO:function(a,b,c,d){var e=b[1],f=l.filters[e];if(f)return f(a,c,b,d);if(e==="contains")return(a.textContent||a.innerText||k.getText([a])||"").indexOf(b[3])>=0;if(e==="not"){var g=b[3];for(var h=0,i=g.length;h=0}},ID:function(a,b){return a.nodeType===1&&a.getAttribute("id")===b},TAG:function(a,b){return b==="*"&&a.nodeType===1||a.nodeName.toLowerCase()===b},CLASS:function(a,b){return(" "+(a.className||a.getAttribute("class"))+" ").indexOf(b)>-1},ATTR:function(a,b){var c=b[1],d=l.attrHandle[c]?l.attrHandle[c](a):a[c]!=null?a[c]:a.getAttribute(c),e=d+"",f=b[2],g=b[4];return d==null?f==="!=":f==="="?e===g:f==="*="?e.indexOf(g)>=0:f==="~="?(" "+e+" ").indexOf(g)>=0:g?f==="!="?e!==g:f==="^="?e.indexOf(g)===0:f==="$="?e.substr(e.length-g.length)===g:f==="|="?e===g||e.substr(0,g.length+1)===g+"-":!1:e&&d!==!1},POS:function(a,b,c,d){var e=b[2],f=l.setFilters[e];if(f)return f(a,c,b,d)}}},m=l.match.POS,n=function(a,b){return"\\"+(b-0+1)};for(var o in l.match)l.match[o]=new RegExp(l.match[o].source+/(?![^\[]*\])(?![^\(]*\))/.source),l.leftMatch[o]=new RegExp(/(^(?:.|\r|\n)*?)/.source+l.match[o].source.replace(/\\(\d+)/g,n));var p=function(a,b){a=Array.prototype.slice.call(a,0);if(b){b.push.apply(b,a);return b}return a};try{Array.prototype.slice.call(c.documentElement.childNodes,0)[0].nodeType}catch(q){p=function(a,b){var c=0,d=b||[];if(e.call(a)==="[object Array]")Array.prototype.push.apply(d,a);else if(typeof a.length=="number")for(var f=a.length;c",e.insertBefore(a,e.firstChild),c.getElementById(d)&&(l.find.ID=function(a,c,d){if(typeof c.getElementById!="undefined"&&!d){var e=c.getElementById(a[1]);return e?e.id===a[1]||typeof e.getAttributeNode!="undefined"&&e.getAttributeNode("id").nodeValue===a[1]?[e]:b:[]}},l.filter.ID=function(a,b){var c=typeof a.getAttributeNode!="undefined"&&a.getAttributeNode("id");return a.nodeType===1&&c&&c.nodeValue===b}),e.removeChild(a),e=a=null}(),function(){var a=c.createElement("div");a.appendChild(c.createComment("")),a.getElementsByTagName("*").length>0&&(l.find.TAG=function(a,b){var c=b.getElementsByTagName(a[1]);if(a[1]==="*"){var d=[];for(var e=0;c[e];e++)c[e].nodeType===1&&d.push(c[e]);c=d}return c}),a.innerHTML="",a.firstChild&&typeof a.firstChild.getAttribute!="undefined"&&a.firstChild.getAttribute("href")!=="#"&&(l.attrHandle.href=function(a){return a.getAttribute("href",2)}),a=null}(),c.querySelectorAll&&function(){var a=k,b=c.createElement("div"),d="__sizzle__";b.innerHTML="

";if(!b.querySelectorAll||b.querySelectorAll(".TEST").length!==0){k=function(b,e,f,g){e=e||c;if(!g&&!k.isXML(e)){var h=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(b);if(h&&(e.nodeType===1||e.nodeType===9)){if(h[1])return p(e.getElementsByTagName(b),f);if(h[2]&&l.find.CLASS&&e.getElementsByClassName)return p(e.getElementsByClassName(h[2]),f)}if(e.nodeType===9){if(b==="body"&&e.body)return p([e.body],f);if(h&&h[3]){var i=e.getElementById(h[3]);if(!i||!i.parentNode)return p([],f);if(i.id===h[3])return p([i],f)}try{return p(e.querySelectorAll(b),f)}catch(j){}}else if(e.nodeType===1&&e.nodeName.toLowerCase()!=="object"){var m=e,n=e.getAttribute("id"),o=n||d,q=e.parentNode,r=/^\s*[+~]/.test(b);n?o=o.replace(/'/g,"\\$&"):e.setAttribute("id",o),r&&q&&(e=e.parentNode);try{if(!r||q)return p(e.querySelectorAll("[id='"+o+"'] "+b),f)}catch(s){}finally{n||m.removeAttribute("id")}}}return a(b,e,f,g)};for(var e in a)k[e]=a[e];b=null}}(),function(){var a=c.documentElement,b=a.matchesSelector||a.mozMatchesSelector||a.webkitMatchesSelector||a.msMatchesSelector;if(b){var d=!b.call(c.createElement("div"),"div"),e=!1;try{b.call(c.documentElement,"[test!='']:sizzle")}catch(f){e=!0}k.matchesSelector=function(a,c){c=c.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!k.isXML(a))try{if(e||!l.match.PSEUDO.test(c)&&!/!=/.test(c)){var f=b.call(a,c);if(f||!d||a.document&&a.document.nodeType!==11)return f}}catch(g){}return k(c,null,null,[a]).length>0}}}(),function(){var a=c.createElement("div");a.innerHTML="
";if(!!a.getElementsByClassName&&a.getElementsByClassName("e").length!==0){a.lastChild.className="e";if(a.getElementsByClassName("e").length===1)return;l.order.splice(1,0,"CLASS"),l.find.CLASS=function(a,b,c){if(typeof b.getElementsByClassName!="undefined"&&!c)return b.getElementsByClassName(a[1])},a=null}}(),c.documentElement.contains?k.contains=function(a,b){return a!==b&&(a.contains?a.contains(b):!0)}:c.documentElement.compareDocumentPosition?k.contains=function(a,b){return!!(a.compareDocumentPosition(b)&16)}:k.contains=function(){return!1},k.isXML=function(a){var b=(a?a.ownerDocument||a:0).documentElement;return b?b.nodeName!=="HTML":!1};var v=function(a,b){var c,d=[],e="",f=b.nodeType?[b]:b;while(c=l.match.PSEUDO.exec(a))e+=c[0],a=a.replace(l.match.PSEUDO,"");a=l.relative[a]?a+"*":a;for(var g=0,h=f.length;g0)for(h=g;h0:this.filter(a).length>0)},closest:function(a,b){var c=[],d,e,g=this[0];if(f.isArray(a)){var h,i,j={},k=1;if(g&&a.length){for(d=0,e=a.length;d-1:f(g).is(h))&&c.push({selector:i,elem:g,level:k});g=g.parentNode,k++}}return c}var l=T.test(a)||typeof a!="string"?f(a,b||this.context):0;for(d=0,e=this.length;d-1:f.find.matchesSelector(g,a)){c.push(g);break}g=g.parentNode;if(!g||!g.ownerDocument||g===b||g.nodeType===11)break}}c=c.length>1?f.unique(c):c;return this.pushStack(c,"closest",a)},index:function(a){if(!a||typeof a=="string")return f.inArray(this[0],a?f(a):this.parent().children());return f.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var c=typeof a=="string"?f(a,b):f.makeArray(a&&a.nodeType?[a]:a),d=f.merge(this.get(),c);return this.pushStack(V(c[0])||V(d[0])?d:f.unique(d))},andSelf:function(){return this.add(this.prevObject)}}),f.each({parent:function(a){var b=a.parentNode;return b&&b.nodeType!==11?b:null},parents:function(a){return f.dir(a,"parentNode")},parentsUntil:function(a,b,c){return f.dir(a,"parentNode",c)},next:function(a){return f.nth(a,2,"nextSibling")},prev:function(a){return f.nth(a,2,"previousSibling")},nextAll:function(a){return f.dir(a,"nextSibling")},prevAll:function(a){return f.dir(a,"previousSibling")},nextUntil:function(a,b,c){return f.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return f.dir(a,"previousSibling",c)},siblings:function(a){return f.sibling(a.parentNode.firstChild,a)},children:function(a){return f.sibling(a.firstChild)},contents:function(a){return f.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:f.makeArray(a.childNodes)}},function(a,b){f.fn[a]=function(c,d){var e=f.map(this,b,c),g=S.call(arguments);O.test(a)||(d=c),d&&typeof d=="string"&&(e=f.filter(d,e)),e=this.length>1&&!U[a]?f.unique(e):e,(this.length>1||Q.test(d))&&P.test(a)&&(e=e.reverse());return this.pushStack(e,a,g.join(","))}}),f.extend({filter:function(a,b,c){c&&(a=":not("+a+")");return b.length===1?f.find.matchesSelector(b[0],a)?[b[0]]:[]:f.find.matches(a,b)},dir:function(a,c,d){var e=[],g=a[c];while(g&&g.nodeType!==9&&(d===b||g.nodeType!==1||!f(g).is(d)))g.nodeType===1&&e.push(g),g=g[c];return e},nth:function(a,b,c,d){b=b||1;var e=0;for(;a;a=a[c])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){var c=[];for(;a;a=a.nextSibling)a.nodeType===1&&a!==b&&c.push(a);return c}});var X=/ jQuery\d+="(?:\d+|null)"/g,Y=/^\s+/,Z=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,$=/<([\w:]+)/,_=/",""],legend:[1,"
","
"],thead:[1,"","
"],tr:[2,"","
"],td:[3,"","
"],col:[2,"","
"],area:[1,"",""],_default:[0,"",""]};bf.optgroup=bf.option,bf.tbody=bf.tfoot=bf.colgroup=bf.caption=bf.thead,bf.th=bf.td,f.support.htmlSerialize||(bf._default=[1,"div
","
"]),f.fn.extend({text:function(a){if(f.isFunction(a))return this.each(function(b){var c=f(this);c.text(a.call(this,b,c.text()))});if(typeof a!="object"&&a!==b)return this.empty().append((this[0]&&this[0].ownerDocument||c).createTextNode(a));return f.text(this)},wrapAll:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapAll(a.call(this,b))});if(this[0]){var b=f(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&a.firstChild.nodeType===1)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapInner(a.call(this,b))});return this.each(function(){var b=f(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){return this.each(function(){f(this).wrapAll(a)})},unwrap:function(){return this.parent().each(function(){f.nodeName(this,"body")||f(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this)});if(arguments.length){var a=f(arguments[0]);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,f(arguments[0]).toArray());return a}},remove:function(a,b){for(var c=0,d;(d=this[c])!=null;c++)if(!a||f.filter(a,[d]).length)!b&&d.nodeType===1&&(f.cleanData(d.getElementsByTagName("*")),f.cleanData([d])),d.parentNode&&d.parentNode.removeChild(d);return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++){b.nodeType===1&&f.cleanData(b.getElementsByTagName("*"));while(b.firstChild)b.removeChild(b.firstChild)}return this},clone:function(a,b){a=a==null?!1:a,b=b==null?a:b;return this.map(function(){return f.clone(this,a,b)})},html:function(a){if(a===b)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(X,""):null;if(typeof a=="string"&&!bb.test(a)&&(f.support.leadingWhitespace||!Y.test(a))&&!bf[($.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Z,"<$1>");try{for(var c=0,d=this.length;c1&&l0?this.clone(!0):this).get();f(e[h])[b](j),d=d.concat(j -)}return this.pushStack(d,a,e.selector)}}),f.extend({clone:function(a,b,c){var d=a.cloneNode(!0),e,g,h;if((!f.support.noCloneEvent||!f.support.noCloneChecked)&&(a.nodeType===1||a.nodeType===11)&&!f.isXMLDoc(a)){bi(a,d),e=bj(a),g=bj(d);for(h=0;e[h];++h)bi(e[h],g[h])}if(b){bh(a,d);if(c){e=bj(a),g=bj(d);for(h=0;e[h];++h)bh(e[h],g[h])}}e=g=null;return d},clean:function(a,b,d,e){var g;b=b||c,typeof b.createElement=="undefined"&&(b=b.ownerDocument||b[0]&&b[0].ownerDocument||c);var h=[],i;for(var j=0,k;(k=a[j])!=null;j++){typeof k=="number"&&(k+="");if(!k)continue;if(typeof k=="string")if(!ba.test(k))k=b.createTextNode(k);else{k=k.replace(Z,"<$1>");var l=($.exec(k)||["",""])[1].toLowerCase(),m=bf[l]||bf._default,n=m[0],o=b.createElement("div");o.innerHTML=m[1]+k+m[2];while(n--)o=o.lastChild;if(!f.support.tbody){var p=_.test(k),q=l==="table"&&!p?o.firstChild&&o.firstChild.childNodes:m[1]===""&&!p?o.childNodes:[];for(i=q.length-1;i>=0;--i)f.nodeName(q[i],"tbody")&&!q[i].childNodes.length&&q[i].parentNode.removeChild(q[i])}!f.support.leadingWhitespace&&Y.test(k)&&o.insertBefore(b.createTextNode(Y.exec(k)[0]),o.firstChild),k=o.childNodes}var r;if(!f.support.appendChecked)if(k[0]&&typeof (r=k.length)=="number")for(i=0;i=0)return b+"px"}}}),f.support.opacity||(f.cssHooks.opacity={get:function(a,b){return bo.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle;c.zoom=1;var e=f.isNaN(b)?"":"alpha(opacity="+b*100+")",g=d&&d.filter||c.filter||"";c.filter=bn.test(g)?g.replace(bn,e):g+" "+e}}),f(function(){f.support.reliableMarginRight||(f.cssHooks.marginRight={get:function(a,b){var c;f.swap(a,{display:"inline-block"},function(){b?c=bx(a,"margin-right","marginRight"):c=a.style.marginRight});return c}})}),c.defaultView&&c.defaultView.getComputedStyle&&(by=function(a,c){var d,e,g;c=c.replace(bp,"-$1").toLowerCase();if(!(e=a.ownerDocument.defaultView))return b;if(g=e.getComputedStyle(a,null))d=g.getPropertyValue(c),d===""&&!f.contains(a.ownerDocument.documentElement,a)&&(d=f.style(a,c));return d}),c.documentElement.currentStyle&&(bz=function(a,b){var c,d=a.currentStyle&&a.currentStyle[b],e=a.runtimeStyle&&a.runtimeStyle[b],f=a.style;!bq.test(d)&&br.test(d)&&(c=f.left,e&&(a.runtimeStyle.left=a.currentStyle.left),f.left=b==="fontSize"?"1em":d||0,d=f.pixelLeft+"px",f.left=c,e&&(a.runtimeStyle.left=e));return d===""?"auto":d}),bx=by||bz,f.expr&&f.expr.filters&&(f.expr.filters.hidden=function(a){var b=a.offsetWidth,c=a.offsetHeight;return b===0&&c===0||!f.support.reliableHiddenOffsets&&(a.style.display||f.css(a,"display"))==="none"},f.expr.filters.visible=function(a){return!f.expr.filters.hidden(a)});var bB=/%20/g,bC=/\[\]$/,bD=/\r?\n/g,bE=/#.*$/,bF=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,bG=/^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,bH=/^(?:about|app|app\-storage|.+\-extension|file|widget):$/,bI=/^(?:GET|HEAD)$/,bJ=/^\/\//,bK=/\?/,bL=/)<[^<]*)*<\/script>/gi,bM=/^(?:select|textarea)/i,bN=/\s+/,bO=/([?&])_=[^&]*/,bP=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,bQ=f.fn.load,bR={},bS={},bT,bU;try{bT=e.href}catch(bV){bT=c.createElement("a"),bT.href="",bT=bT.href}bU=bP.exec(bT.toLowerCase())||[],f.fn.extend({load:function(a,c,d){if(typeof a!="string"&&bQ)return bQ.apply(this,arguments);if(!this.length)return this;var e=a.indexOf(" ");if(e>=0){var g=a.slice(e,a.length);a=a.slice(0,e)}var h="GET";c&&(f.isFunction(c)?(d=c,c=b):typeof c=="object"&&(c=f.param(c,f.ajaxSettings.traditional),h="POST"));var i=this;f.ajax({url:a,type:h,dataType:"html",data:c,complete:function(a,b,c){c=a.responseText,a.isResolved()&&(a.done(function(a){c=a}),i.html(g?f("
").append(c.replace(bL,"")).find(g):c)),d&&i.each(d,[c,b,a])}});return this},serialize:function(){return f.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?f.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||bM.test(this.nodeName)||bG.test(this.type))}).map(function(a,b){var c=f(this).val();return c==null?null:f.isArray(c)?f.map(c,function(a,c){return{name:b.name,value:a.replace(bD,"\r\n")}}):{name:b.name,value:c.replace(bD,"\r\n")}}).get()}}),f.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){f.fn[b]=function(a){return this.bind(b,a)}}),f.each(["get","post"],function(a,c){f[c]=function(a,d,e,g){f.isFunction(d)&&(g=g||e,e=d,d=b);return f.ajax({type:c,url:a,data:d,success:e,dataType:g})}}),f.extend({getScript:function(a,c){return f.get(a,b,c,"script")},getJSON:function(a,b,c){return f.get(a,b,c,"json")},ajaxSetup:function(a,b){b?f.extend(!0,a,f.ajaxSettings,b):(b=a,a=f.extend(!0,f.ajaxSettings,b));for(var c in{context:1,url:1})c in b?a[c]=b[c]:c in f.ajaxSettings&&(a[c]=f.ajaxSettings[c]);return a},ajaxSettings:{url:bT,isLocal:bH.test(bU[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":"*/*"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":a.String,"text html":!0,"text json":f.parseJSON,"text xml":f.parseXML}},ajaxPrefilter:bW(bR),ajaxTransport:bW(bS),ajax:function(a,c){function w(a,c,l,m){if(s!==2){s=2,q&&clearTimeout(q),p=b,n=m||"",v.readyState=a?4:0;var o,r,u,w=l?bZ(d,v,l):b,x,y;if(a>=200&&a<300||a===304){if(d.ifModified){if(x=v.getResponseHeader("Last-Modified"))f.lastModified[k]=x;if(y=v.getResponseHeader("Etag"))f.etag[k]=y}if(a===304)c="notmodified",o=!0;else try{r=b$(d,w),c="success",o=!0}catch(z){c="parsererror",u=z}}else{u=c;if(!c||a)c="error",a<0&&(a=0)}v.status=a,v.statusText=c,o?h.resolveWith(e,[r,c,v]):h.rejectWith(e,[v,c,u]),v.statusCode(j),j=b,t&&g.trigger("ajax"+(o?"Success":"Error"),[v,d,o?r:u]),i.resolveWith(e,[v,c]),t&&(g.trigger("ajaxComplete",[v,d]),--f.active||f.event.trigger("ajaxStop"))}}typeof a=="object"&&(c=a,a=b),c=c||{};var d=f.ajaxSetup({},c),e=d.context||d,g=e!==d&&(e.nodeType||e instanceof f)?f(e):f.event,h=f.Deferred(),i=f._Deferred(),j=d.statusCode||{},k,l={},m={},n,o,p,q,r,s=0,t,u,v={readyState:0,setRequestHeader:function(a,b){if(!s){var c=a.toLowerCase();a=m[c]=m[c]||a,l[a]=b}return this},getAllResponseHeaders:function(){return s===2?n:null},getResponseHeader:function(a){var c;if(s===2){if(!o){o={};while(c=bF.exec(n))o[c[1].toLowerCase()]=c[2]}c=o[a.toLowerCase()]}return c===b?null:c},overrideMimeType:function(a){s||(d.mimeType=a);return this},abort:function(a){a=a||"abort",p&&p.abort(a),w(0,a);return this}};h.promise(v),v.success=v.done,v.error=v.fail,v.complete=i.done,v.statusCode=function(a){if(a){var b;if(s<2)for(b in a)j[b]=[j[b],a[b]];else b=a[v.status],v.then(b,b)}return this},d.url=((a||d.url)+"").replace(bE,"").replace(bJ,bU[1]+"//"),d.dataTypes=f.trim(d.dataType||"*").toLowerCase().split(bN),d.crossDomain==null&&(r=bP.exec(d.url.toLowerCase()),d.crossDomain=!(!r||r[1]==bU[1]&&r[2]==bU[2]&&(r[3]||(r[1]==="http:"?80:443))==(bU[3]||(bU[1]==="http:"?80:443)))),d.data&&d.processData&&typeof d.data!="string"&&(d.data=f.param(d.data,d.traditional)),bX(bR,d,c,v);if(s===2)return!1;t=d.global,d.type=d.type.toUpperCase(),d.hasContent=!bI.test(d.type),t&&f.active++===0&&f.event.trigger("ajaxStart");if(!d.hasContent){d.data&&(d.url+=(bK.test(d.url)?"&":"?")+d.data),k=d.url;if(d.cache===!1){var x=f.now(),y=d.url.replace(bO,"$1_="+x);d.url=y+(y===d.url?(bK.test(d.url)?"&":"?")+"_="+x:"")}}(d.data&&d.hasContent&&d.contentType!==!1||c.contentType)&&v.setRequestHeader("Content-Type",d.contentType),d.ifModified&&(k=k||d.url,f.lastModified[k]&&v.setRequestHeader("If-Modified-Since",f.lastModified[k]),f.etag[k]&&v.setRequestHeader("If-None-Match",f.etag[k])),v.setRequestHeader("Accept",d.dataTypes[0]&&d.accepts[d.dataTypes[0]]?d.accepts[d.dataTypes[0]]+(d.dataTypes[0]!=="*"?", */*; q=0.01":""):d.accepts["*"]);for(u in d.headers)v.setRequestHeader(u,d.headers[u]);if(d.beforeSend&&(d.beforeSend.call(e,v,d)===!1||s===2)){v.abort();return!1}for(u in{success:1,error:1,complete:1})v[u](d[u]);p=bX(bS,d,c,v);if(!p)w(-1,"No Transport");else{v.readyState=1,t&&g.trigger("ajaxSend",[v,d]),d.async&&d.timeout>0&&(q=setTimeout(function(){v.abort("timeout")},d.timeout));try{s=1,p.send(l,w)}catch(z){status<2?w(-1,z):f.error(z)}}return v},param:function(a,c){var d=[],e=function(a,b){b=f.isFunction(b)?b():b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};c===b&&(c=f.ajaxSettings.traditional);if(f.isArray(a)||a.jquery&&!f.isPlainObject(a))f.each(a,function(){e(this.name,this.value)});else for(var g in a)bY(g,a[g],c,e);return d.join("&").replace(bB,"+")}}),f.extend({active:0,lastModified:{},etag:{}});var b_=f.now(),ca=/(\=)\?(&|$)|\?\?/i;f.ajaxSetup({jsonp:"callback",jsonpCallback:function(){return f.expando+"_"+b_++}}),f.ajaxPrefilter("json jsonp",function(b,c,d){var e=b.contentType==="application/x-www-form-urlencoded"&&typeof b.data=="string";if(b.dataTypes[0]==="jsonp"||b.jsonp!==!1&&(ca.test(b.url)||e&&ca.test(b.data))){var g,h=b.jsonpCallback=f.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,i=a[h],j=b.url,k=b.data,l="$1"+h+"$2";b.jsonp!==!1&&(j=j.replace(ca,l),b.url===j&&(e&&(k=k.replace(ca,l)),b.data===k&&(j+=(/\?/.test(j)?"&":"?")+b.jsonp+"="+h))),b.url=j,b.data=k,a[h]=function(a){g=[a]},d.always(function(){a[h]=i,g&&f.isFunction(i)&&a[h](g[0])}),b.converters["script json"]=function(){g||f.error(h+" was not called");return g[0]},b.dataTypes[0]="json";return"script"}}),f.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(a){f.globalEval(a);return a}}}),f.ajaxPrefilter("script",function(a){a.cache===b&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),f.ajaxTransport("script",function(a){if(a.crossDomain){var d,e=c.head||c.getElementsByTagName("head")[0]||c.documentElement;return{send:function(f,g){d=c.createElement("script"),d.async="async",a.scriptCharset&&(d.charset=a.scriptCharset),d.src=a.url,d.onload=d.onreadystatechange=function(a,c){if(c||!d.readyState||/loaded|complete/.test(d.readyState))d.onload=d.onreadystatechange=null,e&&d.parentNode&&e.removeChild(d),d=b,c||g(200,"success")},e.insertBefore(d,e.firstChild)},abort:function(){d&&d.onload(0,1)}}}});var cb=a.ActiveXObject?function(){for(var a in cd)cd[a](0,1)}:!1,cc=0,cd;f.ajaxSettings.xhr=a.ActiveXObject?function(){return!this.isLocal&&ce()||cf()}:ce,function(a){f.extend(f.support,{ajax:!!a,cors:!!a&&"withCredentials"in a})}(f.ajaxSettings.xhr()),f.support.ajax&&f.ajaxTransport(function(c){if(!c.crossDomain||f.support.cors){var d;return{send:function(e,g){var h=c.xhr(),i,j;c.username?h.open(c.type,c.url,c.async,c.username,c.password):h.open(c.type,c.url,c.async);if(c.xhrFields)for(j in c.xhrFields)h[j]=c.xhrFields[j];c.mimeType&&h.overrideMimeType&&h.overrideMimeType(c.mimeType),!c.crossDomain&&!e["X-Requested-With"]&&(e["X-Requested-With"]="XMLHttpRequest");try{for(j in e)h.setRequestHeader(j,e[j])}catch(k){}h.send(c.hasContent&&c.data||null),d=function(a,e){var j,k,l,m,n;try{if(d&&(e||h.readyState===4)){d=b,i&&(h.onreadystatechange=f.noop,cb&&delete cd[i]);if(e)h.readyState!==4&&h.abort();else{j=h.status,l=h.getAllResponseHeaders(),m={},n=h.responseXML,n&&n.documentElement&&(m.xml=n),m.text=h.responseText;try{k=h.statusText}catch(o){k=""}!j&&c.isLocal&&!c.crossDomain?j=m.text?200:404:j===1223&&(j=204)}}}catch(p){e||g(-1,p)}m&&g(j,k,m,l)},!c.async||h.readyState===4?d():(i=++cc,cb&&(cd||(cd={},f(a).unload(cb)),cd[i]=d),h.onreadystatechange=d)},abort:function(){d&&d(0,1)}}}});var cg={},ch,ci,cj=/^(?:toggle|show|hide)$/,ck=/^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,cl,cm=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]],cn,co=a.webkitRequestAnimationFrame||a.mozRequestAnimationFrame||a.oRequestAnimationFrame;f.fn.extend({show:function(a,b,c){var d,e;if(a||a===0)return this.animate(cr("show",3),a,b,c);for(var g=0,h=this.length;g=e.duration+this.startTime){this.now=this.end,this.pos=this.state=1,this.update(),e.animatedProperties[this.prop]=!0;for(g in e.animatedProperties)e.animatedProperties[g]!==!0&&(c=!1);if(c){e.overflow!=null&&!f.support.shrinkWrapBlocks&&f.each(["","X","Y"],function(a,b){d.style["overflow"+b]=e.overflow[a]}),e.hide&&f(d).hide();if(e.hide||e.show)for(var i in e.animatedProperties)f.style(d,i,e.orig[i]);e.complete.call(d)}return!1}e.duration==Infinity?this.now=b:(h=b-this.startTime,this.state=h/e.duration,this.pos=f.easing[e.animatedProperties[this.prop]](this.state,h,0,1,e.duration),this.now=this.start+(this.end-this.start)*this.pos),this.update();return!0}},f.extend(f.fx,{tick:function(){for(var a=f.timers,b=0;b
";f.extend(b.style,{position:"absolute",top:0,left:0,margin:0,border:0,width:"1px",height:"1px",visibility:"hidden"}),b.innerHTML=j,a.insertBefore(b,a.firstChild),d=b.firstChild,e=d.firstChild,h=d.nextSibling.firstChild.firstChild,this.doesNotAddBorder=e.offsetTop!==5,this.doesAddBorderForTableAndCells=h.offsetTop===5,e.style.position="fixed",e.style.top="20px",this.supportsFixedPosition=e.offsetTop===20||e.offsetTop===15,e.style.position=e.style.top="",d.style.overflow="hidden",d.style.position="relative",this.subtractsBorderForOverflowNotVisible=e.offsetTop===-5,this.doesNotIncludeMarginInBodyOffset=a.offsetTop!==i,a.removeChild(b),f.offset.initialize=f.noop},bodyOffset:function(a){var b=a.offsetTop,c=a.offsetLeft;f.offset.initialize(),f.offset.doesNotIncludeMarginInBodyOffset&&(b+=parseFloat(f.css(a,"marginTop"))||0,c+=parseFloat(f.css(a,"marginLeft"))||0);return{top:b,left:c}},setOffset:function(a,b,c){var d=f.css(a,"position");d==="static"&&(a.style.position="relative");var e=f(a),g=e.offset(),h=f.css(a,"top"),i=f.css(a,"left"),j=(d==="absolute"||d==="fixed")&&f.inArray("auto",[h,i])>-1,k={},l={},m,n;j?(l=e.position(),m=l.top,n=l.left):(m=parseFloat(h)||0,n=parseFloat(i)||0),f.isFunction(b)&&(b=b.call(a,c,g)),b.top!=null&&(k.top=b.top-g.top+m),b.left!=null&&(k.left=b.left-g.left+n),"using"in b?b.using.call(a,k):e.css(k)}},f.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),c=this.offset(),d=cu.test(b[0].nodeName)?{top:0,left:0}:b.offset();c.top-=parseFloat(f.css(a,"marginTop"))||0,c.left-=parseFloat(f.css(a,"marginLeft"))||0,d.top+=parseFloat(f.css(b[0],"borderTopWidth"))||0,d.left+=parseFloat(f.css(b[0],"borderLeftWidth"))||0;return{top:c.top-d.top,left:c.left-d.left}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||c.body;while(a&&!cu.test(a.nodeName)&&f.css(a,"position")==="static")a=a.offsetParent;return a})}}),f.each(["Left","Top"],function(a,c){var d="scroll"+c;f.fn[d]=function(c){var e,g;if(c===b){e=this[0];if(!e)return null;g=cv(e);return g?"pageXOffset"in g?g[a?"pageYOffset":"pageXOffset"]:f.support.boxModel&&g.document.documentElement[d]||g.document.body[d]:e[d]}return this.each(function(){g=cv(this),g?g.scrollTo(a?f(g).scrollLeft():c,a?c:f(g).scrollTop()):this[d]=c})}}),f.each(["Height","Width"],function(a,c){var d=c.toLowerCase();f.fn["inner"+c]=function(){var a=this[0];return a&&a.style?parseFloat(f.css(a,d,"padding")):null},f.fn["outer"+c]=function(a){var b=this[0];return b&&b.style?parseFloat(f.css(b,d,a?"margin":"border")):null},f.fn[d]=function(a){var e=this[0];if(!e)return a==null?null:this;if(f.isFunction(a))return this.each(function(b){var c=f(this);c[d](a.call(this,b,c[d]()))});if(f.isWindow(e)){var g=e.document.documentElement["client"+c];return e.document.compatMode==="CSS1Compat"&&g||e.document.body["client"+c]||g}if(e.nodeType===9)return Math.max(e.documentElement["client"+c],e.body["scroll"+c],e.documentElement["scroll"+c],e.body["offset"+c],e.documentElement["offset"+c]);if(a===b){var h=f.css(e,d),i=parseFloat(h);return f.isNaN(i)?h:i}return this.css(d,typeof a=="string"?a:a+"px")}}),a.jQuery=a.$=f})(window); \ No newline at end of file +/*! jQuery v1.6.4 http://jquery.com/ | http://jquery.org/license */ +(function(a,b){function cu(a){return f.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function cr(a){if(!cg[a]){var b=c.body,d=f("<"+a+">").appendTo(b),e=d.css("display");d.remove();if(e==="none"||e===""){ch||(ch=c.createElement("iframe"),ch.frameBorder=ch.width=ch.height=0),b.appendChild(ch);if(!ci||!ch.createElement)ci=(ch.contentWindow||ch.contentDocument).document,ci.write((c.compatMode==="CSS1Compat"?"":"")+""),ci.close();d=ci.createElement(a),ci.body.appendChild(d),e=f.css(d,"display"),b.removeChild(ch)}cg[a]=e}return cg[a]}function cq(a,b){var c={};f.each(cm.concat.apply([],cm.slice(0,b)),function(){c[this]=a});return c}function cp(){cn=b}function co(){setTimeout(cp,0);return cn=f.now()}function cf(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function ce(){try{return new a.XMLHttpRequest}catch(b){}}function b$(a,c){a.dataFilter&&(c=a.dataFilter(c,a.dataType));var d=a.dataTypes,e={},g,h,i=d.length,j,k=d[0],l,m,n,o,p;for(g=1;g0){c!=="border"&&f.each(e,function(){c||(d-=parseFloat(f.css(a,"padding"+this))||0),c==="margin"?d+=parseFloat(f.css(a,c+this))||0:d-=parseFloat(f.css(a,"border"+this+"Width"))||0});return d+"px"}d=bv(a,b,b);if(d<0||d==null)d=a.style[b]||0;d=parseFloat(d)||0,c&&f.each(e,function(){d+=parseFloat(f.css(a,"padding"+this))||0,c!=="padding"&&(d+=parseFloat(f.css(a,"border"+this+"Width"))||0),c==="margin"&&(d+=parseFloat(f.css(a,c+this))||0)});return d+"px"}function bl(a,b){b.src?f.ajax({url:b.src,async:!1,dataType:"script"}):f.globalEval((b.text||b.textContent||b.innerHTML||"").replace(bd,"/*$0*/")),b.parentNode&&b.parentNode.removeChild(b)}function bk(a){f.nodeName(a,"input")?bj(a):"getElementsByTagName"in a&&f.grep(a.getElementsByTagName("input"),bj)}function bj(a){if(a.type==="checkbox"||a.type==="radio")a.defaultChecked=a.checked}function bi(a){return"getElementsByTagName"in a?a.getElementsByTagName("*"):"querySelectorAll"in a?a.querySelectorAll("*"):[]}function bh(a,b){var c;if(b.nodeType===1){b.clearAttributes&&b.clearAttributes(),b.mergeAttributes&&b.mergeAttributes(a),c=b.nodeName.toLowerCase();if(c==="object")b.outerHTML=a.outerHTML;else if(c!=="input"||a.type!=="checkbox"&&a.type!=="radio"){if(c==="option")b.selected=a.defaultSelected;else if(c==="input"||c==="textarea")b.defaultValue=a.defaultValue}else a.checked&&(b.defaultChecked=b.checked=a.checked),b.value!==a.value&&(b.value=a.value);b.removeAttribute(f.expando)}}function bg(a,b){if(b.nodeType===1&&!!f.hasData(a)){var c=f.expando,d=f.data(a),e=f.data(b,d);if(d=d[c]){var g=d.events;e=e[c]=f.extend({},d);if(g){delete e.handle,e.events={};for(var h in g)for(var i=0,j=g[h].length;i=0===c})}function U(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function M(a,b){return(a&&a!=="*"?a+".":"")+b.replace(y,"`").replace(z,"&")}function L(a){var b,c,d,e,g,h,i,j,k,l,m,n,o,p=[],q=[],r=f._data(this,"events");if(!(a.liveFired===this||!r||!r.live||a.target.disabled||a.button&&a.type==="click")){a.namespace&&(n=new RegExp("(^|\\.)"+a.namespace.split(".").join("\\.(?:.*\\.)?")+"(\\.|$)")),a.liveFired=this;var s=r.live.slice(0);for(i=0;ic)break;a.currentTarget=e.elem,a.data=e.handleObj.data,a.handleObj=e.handleObj,o=e.handleObj.origHandler.apply(e.elem,arguments);if(o===!1||a.isPropagationStopped()){c=e.level,o===!1&&(b=!1);if(a.isImmediatePropagationStopped())break}}return b}}function J(a,c,d){var e=f.extend({},d[0]);e.type=a,e.originalEvent={},e.liveFired=b,f.event.handle.call(c,e),e.isDefaultPrevented()&&d[0].preventDefault()}function D(){return!0}function C(){return!1}function m(a,c,d){var e=c+"defer",g=c+"queue",h=c+"mark",i=f.data(a,e,b,!0);i&&(d==="queue"||!f.data(a,g,b,!0))&&(d==="mark"||!f.data(a,h,b,!0))&&setTimeout(function(){!f.data(a,g,b,!0)&&!f.data(a,h,b,!0)&&(f.removeData(a,e,!0),i.resolve())},0)}function l(a){for(var b in a)if(b!=="toJSON")return!1;return!0}function k(a,c,d){if(d===b&&a.nodeType===1){var e="data-"+c.replace(j,"-$1").toLowerCase();d=a.getAttribute(e);if(typeof d=="string"){try{d=d==="true"?!0:d==="false"?!1:d==="null"?null:f.isNaN(d)?i.test(d)?f.parseJSON(d):d:parseFloat(d)}catch(g){}f.data(a,c,d)}else d=b}return d}var c=a.document,d=a.navigator,e=a.location,f=function(){function K(){if(!e.isReady){try{c.documentElement.doScroll("left")}catch(a){setTimeout(K,1);return}e.ready()}}var e=function(a,b){return new e.fn.init(a,b,h)},f=a.jQuery,g=a.$,h,i=/^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,j=/\S/,k=/^\s+/,l=/\s+$/,m=/\d/,n=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,o=/^[\],:{}\s]*$/,p=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,q=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,r=/(?:^|:|,)(?:\s*\[)+/g,s=/(webkit)[ \/]([\w.]+)/,t=/(opera)(?:.*version)?[ \/]([\w.]+)/,u=/(msie) ([\w.]+)/,v=/(mozilla)(?:.*? rv:([\w.]+))?/,w=/-([a-z]|[0-9])/ig,x=/^-ms-/,y=function(a,b){return(b+"").toUpperCase()},z=d.userAgent,A,B,C,D=Object.prototype.toString,E=Object.prototype.hasOwnProperty,F=Array.prototype.push,G=Array.prototype.slice,H=String.prototype.trim,I=Array.prototype.indexOf,J={};e.fn=e.prototype={constructor:e,init:function(a,d,f){var g,h,j,k;if(!a)return this;if(a.nodeType){this.context=this[0]=a,this.length=1;return this}if(a==="body"&&!d&&c.body){this.context=c,this[0]=c.body,this.selector=a,this.length=1;return this}if(typeof a=="string"){a.charAt(0)!=="<"||a.charAt(a.length-1)!==">"||a.length<3?g=i.exec(a):g=[null,a,null];if(g&&(g[1]||!d)){if(g[1]){d=d instanceof e?d[0]:d,k=d?d.ownerDocument||d:c,j=n.exec(a),j?e.isPlainObject(d)?(a=[c.createElement(j[1])],e.fn.attr.call(a,d,!0)):a=[k.createElement(j[1])]:(j=e.buildFragment([g[1]],[k]),a=(j.cacheable?e.clone(j.fragment):j.fragment).childNodes);return e.merge(this,a)}h=c.getElementById(g[2]);if(h&&h.parentNode){if(h.id!==g[2])return f.find(a);this.length=1,this[0]=h}this.context=c,this.selector=a;return this}return!d||d.jquery?(d||f).find(a):this.constructor(d).find(a)}if(e.isFunction(a))return f.ready(a);a.selector!==b&&(this.selector=a.selector,this.context=a.context);return e.makeArray(a,this)},selector:"",jquery:"1.6.4",length:0,size:function(){return this.length},toArray:function(){return G.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this[this.length+a]:this[a]},pushStack:function(a,b,c){var d=this.constructor();e.isArray(a)?F.apply(d,a):e.merge(d,a),d.prevObject=this,d.context=this.context,b==="find"?d.selector=this.selector+(this.selector?" ":"")+c:b&&(d.selector=this.selector+"."+b+"("+c+")");return d},each:function(a,b){return e.each(this,a,b)},ready:function(a){e.bindReady(),B.done(a);return this},eq:function(a){return a===-1?this.slice(a):this.slice(a,+a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(G.apply(this,arguments),"slice",G.call(arguments).join(","))},map:function(a){return this.pushStack(e.map(this,function(b,c){return a.call(b,c,b)}))},end:function(){return this.prevObject||this.constructor(null)},push:F,sort:[].sort,splice:[].splice},e.fn.init.prototype=e.fn,e.extend=e.fn.extend=function(){var a,c,d,f,g,h,i=arguments[0]||{},j=1,k=arguments.length,l=!1;typeof i=="boolean"&&(l=i,i=arguments[1]||{},j=2),typeof i!="object"&&!e.isFunction(i)&&(i={}),k===j&&(i=this,--j);for(;j0)return;B.resolveWith(c,[e]),e.fn.trigger&&e(c).trigger("ready").unbind("ready")}},bindReady:function(){if(!B){B=e._Deferred();if(c.readyState==="complete")return setTimeout(e.ready,1);if(c.addEventListener)c.addEventListener("DOMContentLoaded",C,!1),a.addEventListener("load",e.ready,!1);else if(c.attachEvent){c.attachEvent("onreadystatechange",C),a.attachEvent("onload",e.ready);var b=!1;try{b=a.frameElement==null}catch(d){}c.documentElement.doScroll&&b&&K()}}},isFunction:function(a){return e.type(a)==="function"},isArray:Array.isArray||function(a){return e.type(a)==="array"},isWindow:function(a){return a&&typeof a=="object"&&"setInterval"in a},isNaN:function(a){return a==null||!m.test(a)||isNaN(a)},type:function(a){return a==null?String(a):J[D.call(a)]||"object"},isPlainObject:function(a){if(!a||e.type(a)!=="object"||a.nodeType||e.isWindow(a))return!1;try{if(a.constructor&&!E.call(a,"constructor")&&!E.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}var d;for(d in a);return d===b||E.call(a,d)},isEmptyObject:function(a){for(var b in a)return!1;return!0},error:function(a){throw a},parseJSON:function(b){if(typeof b!="string"||!b)return null;b=e.trim(b);if(a.JSON&&a.JSON.parse)return a.JSON.parse(b);if(o.test(b.replace(p,"@").replace(q,"]").replace(r,"")))return(new Function("return "+b))();e.error("Invalid JSON: "+b)},parseXML:function(c){var d,f;try{a.DOMParser?(f=new DOMParser,d=f.parseFromString(c,"text/xml")):(d=new ActiveXObject("Microsoft.XMLDOM"),d.async="false",d.loadXML(c))}catch(g){d=b}(!d||!d.documentElement||d.getElementsByTagName("parsererror").length)&&e.error("Invalid XML: "+c);return d},noop:function(){},globalEval:function(b){b&&j.test(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(x,"ms-").replace(w,y)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,c,d){var f,g=0,h=a.length,i=h===b||e.isFunction(a);if(d){if(i){for(f in a)if(c.apply(a[f],d)===!1)break}else for(;g0&&a[0]&&a[j-1]||j===0||e.isArray(a));if(k)for(;i1?h.call(arguments,0):c,--e||g.resolveWith(g,h.call(b,0))}}var b=arguments,c=0,d=b.length,e=d,g=d<=1&&a&&f.isFunction(a.promise)?a:f.Deferred();if(d>1){for(;c
a",d=a.getElementsByTagName("*"),e=a.getElementsByTagName("a")[0];if(!d||!d.length||!e)return{};g=c.createElement("select"),h=g.appendChild(c.createElement("option")),i=a.getElementsByTagName("input")[0],k={leadingWhitespace:a.firstChild.nodeType===3,tbody:!a.getElementsByTagName("tbody").length,htmlSerialize:!!a.getElementsByTagName("link").length,style:/top/.test(e.getAttribute("style")),hrefNormalized:e.getAttribute("href")==="/a",opacity:/^0.55$/.test(e.style.opacity),cssFloat:!!e.style.cssFloat,checkOn:i.value==="on",optSelected:h.selected,getSetAttribute:a.className!=="t",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0},i.checked=!0,k.noCloneChecked=i.cloneNode(!0).checked,g.disabled=!0,k.optDisabled=!h.disabled;try{delete a.test}catch(v){k.deleteExpando=!1}!a.addEventListener&&a.attachEvent&&a.fireEvent&&(a.attachEvent("onclick",function(){k.noCloneEvent=!1}),a.cloneNode(!0).fireEvent("onclick")),i=c.createElement("input"),i.value="t",i.setAttribute("type","radio"),k.radioValue=i.value==="t",i.setAttribute("checked","checked"),a.appendChild(i),l=c.createDocumentFragment(),l.appendChild(a.firstChild),k.checkClone=l.cloneNode(!0).cloneNode(!0).lastChild.checked,a.innerHTML="",a.style.width=a.style.paddingLeft="1px",m=c.getElementsByTagName("body")[0],o=c.createElement(m?"div":"body"),p={visibility:"hidden",width:0,height:0,border:0,margin:0,background:"none"},m&&f.extend(p,{position:"absolute",left:"-1000px",top:"-1000px"});for(t in p)o.style[t]=p[t];o.appendChild(a),n=m||b,n.insertBefore(o,n.firstChild),k.appendChecked=i.checked,k.boxModel=a.offsetWidth===2,"zoom"in a.style&&(a.style.display="inline",a.style.zoom=1,k.inlineBlockNeedsLayout=a.offsetWidth===2,a.style.display="",a.innerHTML="
",k.shrinkWrapBlocks=a.offsetWidth!==2),a.innerHTML="
t
",q=a.getElementsByTagName("td"),u=q[0].offsetHeight===0,q[0].style.display="",q[1].style.display="none",k.reliableHiddenOffsets=u&&q[0].offsetHeight===0,a.innerHTML="",c.defaultView&&c.defaultView.getComputedStyle&&(j=c.createElement("div"),j.style.width="0",j.style.marginRight="0",a.appendChild(j),k.reliableMarginRight=(parseInt((c.defaultView.getComputedStyle(j,null)||{marginRight:0}).marginRight,10)||0)===0),o.innerHTML="",n.removeChild(o);if(a.attachEvent)for(t in{submit:1,change:1,focusin:1})s="on"+t,u=s in a,u||(a.setAttribute(s,"return;"),u=typeof a[s]=="function"),k[t+"Bubbles"]=u;o=l=g=h=m=j=a=i=null;return k}(),f.boxModel=f.support.boxModel;var i=/^(?:\{.*\}|\[.*\])$/,j=/([A-Z])/g;f.extend({cache:{},uuid:0,expando:"jQuery"+(f.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){a=a.nodeType?f.cache[a[f.expando]]:a[f.expando];return!!a&&!l(a)},data:function(a,c,d,e){if(!!f.acceptData(a)){var g,h,i=f.expando,j=typeof c=="string",k=a.nodeType,l=k?f.cache:a,m=k?a[f.expando]:a[f.expando]&&f.expando;if((!m||e&&m&&l[m]&&!l[m][i])&&j&&d===b)return;m||(k?a[f.expando]=m=++f.uuid:m=f.expando),l[m]||(l[m]={},k||(l[m].toJSON=f.noop));if(typeof c=="object"||typeof c=="function")e?l[m][i]=f.extend(l[m][i],c):l[m]=f.extend(l[m],c);g=l[m],e&&(g[i]||(g[i]={}),g=g[i]),d!==b&&(g[f.camelCase(c)]=d);if(c==="events"&&!g[c])return g[i]&&g[i].events;j?(h=g[c],h==null&&(h=g[f.camelCase(c)])):h=g;return h}},removeData:function(a,b,c){if(!!f.acceptData(a)){var d,e=f.expando,g=a.nodeType,h=g?f.cache:a,i=g?a[f.expando]:f.expando;if(!h[i])return;if(b){d=c?h[i][e]:h[i];if(d){d[b]||(b=f.camelCase(b)),delete d[b];if(!l(d))return}}if(c){delete h[i][e];if(!l(h[i]))return}var j=h[i][e];f.support.deleteExpando||!h.setInterval?delete h[i]:h[i]=null,j?(h[i]={},g||(h[i].toJSON=f.noop),h[i][e]=j):g&&(f.support.deleteExpando?delete a[f.expando]:a.removeAttribute?a.removeAttribute(f.expando):a[f.expando]=null)}},_data:function(a,b,c){return f.data(a,b,c,!0)},acceptData:function(a){if(a.nodeName){var b=f.noData[a.nodeName.toLowerCase()];if(b)return b!==!0&&a.getAttribute("classid")===b}return!0}}),f.fn.extend({data:function(a,c){var d=null;if(typeof a=="undefined"){if(this.length){d=f.data(this[0]);if(this[0].nodeType===1){var e=this[0].attributes,g;for(var h=0,i=e.length;h-1)return!0;return!1},val:function(a){var c,d,e=this[0];if(!arguments.length){if(e){c=f.valHooks[e.nodeName.toLowerCase()]||f.valHooks[e.type];if(c&&"get"in c&&(d=c.get(e,"value"))!==b)return d;d=e.value;return typeof d=="string"?d.replace(p,""):d==null?"":d}return b}var g=f.isFunction(a);return this.each(function(d){var e=f(this),h;if(this.nodeType===1){g?h=a.call(this,d,e.val()):h=a,h==null?h="":typeof h=="number"?h+="":f.isArray(h)&&(h=f.map(h,function(a){return a==null?"":a+""})),c=f.valHooks[this.nodeName.toLowerCase()]||f.valHooks[this.type];if(!c||!("set"in c)||c.set(this,h,"value")===b)this.value=h}})}}),f.extend({valHooks:{option:{get:function(a){var b=a.attributes.value;return!b||b.specified?a.value:a.text}},select:{get:function(a){var b,c=a.selectedIndex,d=[],e=a.options,g=a.type==="select-one";if(c<0)return null;for(var h=g?c:0,i=g?c+1:e.length;h=0}),c.length||(a.selectedIndex=-1);return c}}},attrFn:{val:!0,css:!0,html:!0,text:!0,data:!0,width:!0,height:!0,offset:!0},attrFix:{tabindex:"tabIndex"},attr:function(a,c,d,e){var g=a.nodeType;if(!a||g===3||g===8||g===2)return b;if(e&&c in f.attrFn)return f(a)[c](d);if(!("getAttribute"in a))return f.prop(a,c,d);var h,i,j=g!==1||!f.isXMLDoc(a);j&&(c=f.attrFix[c]||c,i=f.attrHooks[c],i||(t.test(c)?i=v:u&&(i=u)));if(d!==b){if(d===null){f.removeAttr(a,c);return b}if(i&&"set"in i&&j&&(h=i.set(a,d,c))!==b)return h;a.setAttribute(c,""+d);return d}if(i&&"get"in i&&j&&(h=i.get(a,c))!==null)return h;h=a.getAttribute(c);return h===null?b:h},removeAttr:function(a,b){var c;a.nodeType===1&&(b=f.attrFix[b]||b,f.attr(a,b,""),a.removeAttribute(b),t.test(b)&&(c=f.propFix[b]||b)in a&&(a[c]=!1))},attrHooks:{type:{set:function(a,b){if(q.test(a.nodeName)&&a.parentNode)f.error("type property can't be changed");else if(!f.support.radioValue&&b==="radio"&&f.nodeName(a,"input")){var c=a.value;a.setAttribute("type",b),c&&(a.value=c);return b}}},value:{get:function(a,b){if(u&&f.nodeName(a,"button"))return u.get(a,b);return b in a?a.value:null},set:function(a,b,c){if(u&&f.nodeName(a,"button"))return u.set(a,b,c);a.value=b}}},propFix:{tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},prop:function(a,c,d){var e=a.nodeType;if(!a||e===3||e===8||e===2)return b;var g,h,i=e!==1||!f.isXMLDoc(a);i&&(c=f.propFix[c]||c,h=f.propHooks[c]);return d!==b?h&&"set"in h&&(g=h.set(a,d,c))!==b?g:a[c]=d:h&&"get"in h&&(g=h.get(a,c))!==null?g:a[c]},propHooks:{tabIndex:{get:function(a){var c=a.getAttributeNode("tabindex");return c&&c.specified?parseInt(c.value,10):r.test(a.nodeName)||s.test(a.nodeName)&&a.href?0:b}}}}),f.attrHooks.tabIndex=f.propHooks.tabIndex,v={get:function(a,c){var d;return f.prop(a,c)===!0||(d=a.getAttributeNode(c))&&d.nodeValue!==!1?c.toLowerCase():b},set:function(a,b,c){var d;b===!1?f.removeAttr(a,c):(d=f.propFix[c]||c,d in a&&(a[d]=!0),a.setAttribute(c,c.toLowerCase()));return c}},f.support.getSetAttribute||(u=f.valHooks.button={get:function(a,c){var d;d=a.getAttributeNode(c);return d&&d.nodeValue!==""?d.nodeValue:b},set:function(a,b,d){var e=a.getAttributeNode(d);e||(e=c.createAttribute(d),a.setAttributeNode(e));return e.nodeValue=b+""}},f.each(["width","height"],function(a,b){f.attrHooks[b]=f.extend(f.attrHooks[b],{set:function(a,c){if(c===""){a.setAttribute(b,"auto");return c}}})})),f.support.hrefNormalized||f.each(["href","src","width","height"],function(a,c){f.attrHooks[c]=f.extend(f.attrHooks[c],{get:function(a){var d=a.getAttribute(c,2);return d===null?b:d}})}),f.support.style||(f.attrHooks.style={get:function(a){return a.style.cssText.toLowerCase()||b},set:function(a,b){return a.style.cssText=""+b}}),f.support.optSelected||(f.propHooks.selected=f.extend(f.propHooks.selected,{get:function(a){var b=a.parentNode;b&&(b.selectedIndex,b.parentNode&&b.parentNode.selectedIndex);return null}})),f.support.checkOn||f.each(["radio","checkbox"],function(){f.valHooks[this]={get:function(a){return a.getAttribute("value")===null?"on":a.value}}}),f.each(["radio","checkbox"],function(){f.valHooks[this]=f.extend(f.valHooks[this],{set:function(a,b){if(f.isArray(b))return a.checked=f.inArray(f(a).val(),b)>=0}})});var w=/\.(.*)$/,x=/^(?:textarea|input|select)$/i,y=/\./g,z=/ /g,A=/[^\w\s.|`]/g,B=function(a){return a.replace(A,"\\$&")};f.event={add:function(a,c,d,e){if(a.nodeType!==3&&a.nodeType!==8){if(d===!1)d=C;else if(!d)return;var g,h;d.handler&&(g=d,d=g.handler),d.guid||(d.guid=f.guid++);var i=f._data(a);if(!i)return;var j=i.events,k=i.handle;j||(i.events=j={}),k||(i.handle=k=function(a){return typeof f!="undefined"&&(!a||f.event.triggered!==a.type)?f.event.handle.apply(k.elem,arguments):b}),k.elem=a,c=c.split(" ");var l,m=0,n;while(l=c[m++]){h=g?f.extend({},g):{handler:d,data:e},l.indexOf(".")>-1?(n=l.split("."),l=n.shift(),h.namespace=n.slice(0).sort().join(".")):(n=[],h.namespace=""),h.type=l,h.guid||(h.guid=d.guid);var o=j[l],p=f.event.special[l]||{};if(!o){o=j[l]=[];if(!p.setup||p.setup.call(a,e,n,k)===!1)a.addEventListener?a.addEventListener(l,k,!1):a.attachEvent&&a.attachEvent("on"+l,k)}p.add&&(p.add.call(a,h),h.handler.guid||(h.handler.guid=d.guid)),o.push(h),f.event.global[l]=!0}a=null}},global:{},remove:function(a,c,d,e){if(a.nodeType!==3&&a.nodeType!==8){d===!1&&(d=C);var g,h,i,j,k=0,l,m,n,o,p,q,r,s=f.hasData(a)&&f._data(a),t=s&&s.events;if(!s||!t)return;c&&c.type&&(d=c.handler,c=c.type);if(!c||typeof c=="string"&&c.charAt(0)==="."){c=c||"";for(h in t)f.event.remove(a,h+c);return}c=c.split(" ");while(h=c[k++]){r=h,q=null,l=h.indexOf(".")<0,m=[],l||(m=h.split("."),h=m.shift(),n=new RegExp("(^|\\.)"+f.map(m.slice(0).sort(),B).join("\\.(?:.*\\.)?")+"(\\.|$)")),p=t[h];if(!p)continue;if(!d){for(j=0;j=0&&(h=h.slice(0,-1),j=!0),h.indexOf(".")>=0&&(i=h.split("."),h=i.shift(),i.sort());if(!!e&&!f.event.customEvent[h]||!!f.event.global[h]){c=typeof c=="object"?c[f.expando]?c:new f.Event(h,c):new f.Event(h),c.type=h,c.exclusive=j,c.namespace=i.join("."),c.namespace_re=new RegExp("(^|\\.)"+i.join("\\.(?:.*\\.)?")+"(\\.|$)");if(g||!e)c.preventDefault(),c.stopPropagation();if(!e){f.each(f.cache,function(){var a=f.expando,b=this[a];b&&b.events&&b.events[h]&&f.event.trigger(c,d,b.handle.elem)});return}if(e.nodeType===3||e.nodeType===8)return;c.result=b,c.target=e,d=d!=null?f.makeArray(d):[],d.unshift(c);var k=e,l=h.indexOf(":")<0?"on"+h:"";do{var m=f._data(k,"handle");c.currentTarget=k,m&&m.apply(k,d),l&&f.acceptData(k)&&k[l]&&k[l].apply(k,d)===!1&&(c.result=!1,c.preventDefault()),k=k.parentNode||k.ownerDocument||k===c.target.ownerDocument&&a}while(k&&!c.isPropagationStopped());if(!c.isDefaultPrevented()){var n,o=f.event.special[h]||{};if((!o._default||o._default.call(e.ownerDocument,c)===!1)&&(h!=="click"||!f.nodeName(e,"a"))&&f.acceptData(e)){try{l&&e[h]&&(n=e[l],n&&(e[l]=null),f.event.triggered=h,e[h]())}catch(p){}n&&(e[l]=n),f.event.triggered=b}}return c.result}},handle:function(c){c=f.event.fix(c||a.event);var d=((f._data(this,"events")||{})[c.type]||[]).slice(0),e=!c.exclusive&&!c.namespace,g=Array.prototype.slice.call(arguments,0);g[0]=c,c.currentTarget=this;for(var h=0,i=d.length;h-1?f.map(a.options,function(a){return a.selected}).join("-"):"":f.nodeName(a,"select")&&(c=a.selectedIndex);return c},I=function(c){var d=c.target,e,g;if(!!x.test(d.nodeName)&&!d.readOnly){e=f._data(d,"_change_data"),g=H(d),(c.type!=="focusout"||d.type!=="radio")&&f._data(d,"_change_data",g);if(e===b||g===e)return;if(e!=null||g)c.type="change",c.liveFired=b,f.event.trigger(c,arguments[1],d)}};f.event.special.change={filters:{focusout:I,beforedeactivate:I,click:function(a){var b=a.target,c=f.nodeName(b,"input")?b.type:"";(c==="radio"||c==="checkbox"||f.nodeName(b,"select"))&&I.call(this,a)},keydown:function(a){var b=a.target,c=f.nodeName(b,"input")?b.type:"";(a.keyCode===13&&!f.nodeName(b,"textarea")||a.keyCode===32&&(c==="checkbox"||c==="radio")||c==="select-multiple")&&I.call(this,a)},beforeactivate:function(a){var b=a.target;f._data(b,"_change_data",H(b))}},setup:function(a,b){if(this.type==="file")return!1;for(var c in G)f.event.add(this,c+".specialChange",G[c]);return x.test(this.nodeName)},teardown:function(a){f.event.remove(this,".specialChange");return x.test(this.nodeName)}},G=f.event.special.change.filters,G.focus=G.beforeactivate}f.support.focusinBubbles||f.each({focus:"focusin",blur:"focusout"},function(a,b){function e(a){var c=f.event.fix(a);c.type=b,c.originalEvent={},f.event.trigger(c,null,c.target),c.isDefaultPrevented()&&a.preventDefault()}var d=0;f.event.special[b]={setup:function(){d++===0&&c.addEventListener(a,e,!0)},teardown:function(){--d===0&&c.removeEventListener(a,e,!0)}}}),f.each(["bind","one"],function(a,c){f.fn[c]=function(a,d,e){var g;if(typeof a=="object"){for(var h in a)this[c](h,d,a[h],e);return this}if(arguments.length===2||d===!1)e=d,d=b;c==="one"?(g=function(a){f(this).unbind(a,g);return e.apply(this,arguments)},g.guid=e.guid||f.guid++):g=e;if(a==="unload"&&c!=="one")this.one(a,d,e);else for(var i=0,j=this.length;i0?this.bind(b,a,c):this.trigger(b)},f.attrFn&&(f.attrFn[b]=!0)}),function(){function u(a,b,c,d,e,f){for(var g=0,h=d.length;g0){j=i;break}}i=i[a]}d[g]=j}}}function t(a,b,c,d,e,f){for(var g=0,h=d.length;g+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,d=0,e=Object.prototype.toString,g=!1,h=!0,i=/\\/g,j=/\W/;[0,0].sort(function(){h=!1;return 0});var k=function(b,d,f,g){f=f||[],d=d||c;var h=d;if(d.nodeType!==1&&d.nodeType!==9)return[];if(!b||typeof b!="string")return f;var i,j,n,o,q,r,s,t,u=!0,w=k.isXML(d),x=[],y=b;do{a.exec(""),i=a.exec(y);if(i){y=i[3],x.push(i[1]);if(i[2]){o=i[3];break}}}while(i);if(x.length>1&&m.exec(b))if(x.length===2&&l.relative[x[0]])j=v(x[0]+x[1],d);else{j=l.relative[x[0]]?[d]:k(x.shift(),d);while(x.length)b=x.shift(),l.relative[b]&&(b+=x.shift()),j=v(b,j)}else{!g&&x.length>1&&d.nodeType===9&&!w&&l.match.ID.test(x[0])&&!l.match.ID.test(x[x.length-1])&&(q=k.find(x.shift(),d,w),d=q.expr?k.filter(q.expr,q.set)[0]:q.set[0]);if(d){q=g?{expr:x.pop(),set:p(g)}:k.find(x.pop(),x.length===1&&(x[0]==="~"||x[0]==="+")&&d.parentNode?d.parentNode:d,w),j=q.expr?k.filter(q.expr,q.set):q.set,x.length>0?n=p(j):u=!1;while(x.length)r=x.pop(),s=r,l.relative[r]?s=x.pop():r="",s==null&&(s=d),l.relative[r](n,s,w)}else n=x=[]}n||(n=j),n||k.error(r||b);if(e.call(n)==="[object Array]")if(!u)f.push.apply(f,n);else if(d&&d.nodeType===1)for(t=0;n[t]!=null;t++)n[t]&&(n[t]===!0||n[t].nodeType===1&&k.contains(d,n[t]))&&f.push(j[t]);else for(t=0;n[t]!=null;t++)n[t]&&n[t].nodeType===1&&f.push(j[t]);else p(n,f);o&&(k(o,h,f,g),k.uniqueSort(f));return f};k.uniqueSort=function(a){if(r){g=h,a.sort(r);if(g)for(var b=1;b0},k.find=function(a,b,c){var d;if(!a)return[];for(var e=0,f=l.order.length;e":function(a,b){var c,d=typeof b=="string",e=0,f=a.length;if(d&&!j.test(b)){b=b.toLowerCase();for(;e=0)?c||d.push(h):c&&(b[g]=!1));return!1},ID:function(a){return a[1].replace(i,"")},TAG:function(a,b){return a[1].replace(i,"").toLowerCase()},CHILD:function(a){if(a[1]==="nth"){a[2]||k.error(a[0]),a[2]=a[2].replace(/^\+|\s*/g,"");var b=/(-?)(\d*)(?:n([+\-]?\d*))?/.exec(a[2]==="even"&&"2n"||a[2]==="odd"&&"2n+1"||!/\D/.test(a[2])&&"0n+"+a[2]||a[2]);a[2]=b[1]+(b[2]||1)-0,a[3]=b[3]-0}else a[2]&&k.error(a[0]);a[0]=d++;return a},ATTR:function(a,b,c,d,e,f){var g=a[1]=a[1].replace(i,"");!f&&l.attrMap[g]&&(a[1]=l.attrMap[g]),a[4]=(a[4]||a[5]||"").replace(i,""),a[2]==="~="&&(a[4]=" "+a[4]+" ");return a},PSEUDO:function(b,c,d,e,f){if(b[1]==="not")if((a.exec(b[3])||"").length>1||/^\w/.test(b[3]))b[3]=k(b[3],null,null,c);else{var g=k.filter(b[3],c,d,!0^f);d||e.push.apply(e,g);return!1}else if(l.match.POS.test(b[0])||l.match.CHILD.test(b[0]))return!0;return b},POS:function(a){a.unshift(!0);return a}},filters:{enabled:function(a){return a.disabled===!1&&a.type!=="hidden"},disabled:function(a){return a.disabled===!0},checked:function(a){return a.checked===!0},selected:function(a){a.parentNode&&a.parentNode.selectedIndex;return a.selected===!0},parent:function(a){return!!a.firstChild},empty:function(a){return!a.firstChild},has:function(a,b,c){return!!k(c[3],a).length},header:function(a){return/h\d/i.test(a.nodeName)},text:function(a){var b=a.getAttribute("type"),c=a.type;return a.nodeName.toLowerCase()==="input"&&"text"===c&&(b===c||b===null)},radio:function(a){return a.nodeName.toLowerCase()==="input"&&"radio"===a.type},checkbox:function(a){return a.nodeName.toLowerCase()==="input"&&"checkbox"===a.type},file:function(a){return a.nodeName.toLowerCase()==="input"&&"file"===a.type},password:function(a){return a.nodeName.toLowerCase()==="input"&&"password"===a.type},submit:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"submit"===a.type},image:function(a){return a.nodeName.toLowerCase()==="input"&&"image"===a.type},reset:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"reset"===a.type},button:function(a){var b=a.nodeName.toLowerCase();return b==="input"&&"button"===a.type||b==="button"},input:function(a){return/input|select|textarea|button/i.test(a.nodeName)},focus:function(a){return a===a.ownerDocument.activeElement}},setFilters:{first:function(a,b){return b===0},last:function(a,b,c,d){return b===d.length-1},even:function(a,b){return b%2===0},odd:function(a,b){return b%2===1},lt:function(a,b,c){return bc[3]-0},nth:function(a,b,c){return c[3]-0===b},eq:function(a,b,c){return c[3]-0===b}},filter:{PSEUDO:function(a,b,c,d){var e=b[1],f=l.filters[e];if(f)return f(a,c,b,d);if(e==="contains")return(a.textContent||a.innerText||k.getText([a])||"").indexOf(b[3])>=0;if(e==="not"){var g=b[3];for(var h=0,i=g.length;h=0}},ID:function(a,b){return a.nodeType===1&&a.getAttribute("id")===b},TAG:function(a,b){return b==="*"&&a.nodeType===1||a.nodeName.toLowerCase()===b},CLASS:function(a,b){return(" "+(a.className||a.getAttribute("class"))+" ").indexOf(b)>-1},ATTR:function(a,b){var c=b[1],d=l.attrHandle[c]?l.attrHandle[c](a):a[c]!=null?a[c]:a.getAttribute(c),e=d+"",f=b[2],g=b[4];return d==null?f==="!=":f==="="?e===g:f==="*="?e.indexOf(g)>=0:f==="~="?(" "+e+" ").indexOf(g)>=0:g?f==="!="?e!==g:f==="^="?e.indexOf(g)===0:f==="$="?e.substr(e.length-g.length)===g:f==="|="?e===g||e.substr(0,g.length+1)===g+"-":!1:e&&d!==!1},POS:function(a,b,c,d){var e=b[2],f=l.setFilters[e];if(f)return f(a,c,b,d)}}},m=l.match.POS,n=function(a,b){return"\\"+(b-0+1)};for(var o in l.match)l.match[o]=new RegExp(l.match[o].source+/(?![^\[]*\])(?![^\(]*\))/.source),l.leftMatch[o]=new RegExp(/(^(?:.|\r|\n)*?)/.source+l.match[o].source.replace(/\\(\d+)/g,n));var p=function(a,b){a=Array.prototype.slice.call(a,0);if(b){b.push.apply(b,a);return b}return a};try{Array.prototype.slice.call(c.documentElement.childNodes,0)[0].nodeType}catch(q){p=function(a,b){var c=0,d=b||[];if(e.call(a)==="[object Array]")Array.prototype.push.apply(d,a);else if(typeof a.length=="number")for(var f=a.length;c",e.insertBefore(a,e.firstChild),c.getElementById(d)&&(l.find.ID=function(a,c,d){if(typeof c.getElementById!="undefined"&&!d){var e=c.getElementById(a[1]);return e?e.id===a[1]||typeof e.getAttributeNode!="undefined"&&e.getAttributeNode("id").nodeValue===a[1]?[e]:b:[]}},l.filter.ID=function(a,b){var c=typeof a.getAttributeNode!="undefined"&&a.getAttributeNode("id");return a.nodeType===1&&c&&c.nodeValue===b}),e.removeChild(a),e=a=null}(),function(){var a=c.createElement("div");a.appendChild(c.createComment("")),a.getElementsByTagName("*").length>0&&(l.find.TAG=function(a,b){var c=b.getElementsByTagName(a[1]);if(a[1]==="*"){var d=[];for(var e=0;c[e];e++)c[e].nodeType===1&&d.push(c[e]);c=d}return c}),a.innerHTML="",a.firstChild&&typeof a.firstChild.getAttribute!="undefined"&&a.firstChild.getAttribute("href")!=="#"&&(l.attrHandle.href=function(a){return a.getAttribute("href",2)}),a=null}(),c.querySelectorAll&&function(){var a=k,b=c.createElement("div"),d="__sizzle__";b.innerHTML="

";if(!b.querySelectorAll||b.querySelectorAll(".TEST").length!==0){k=function(b,e,f,g){e=e||c;if(!g&&!k.isXML(e)){var h=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(b);if(h&&(e.nodeType===1||e.nodeType===9)){if(h[1])return p(e.getElementsByTagName(b),f);if(h[2]&&l.find.CLASS&&e.getElementsByClassName)return p(e.getElementsByClassName(h[2]),f)}if(e.nodeType===9){if(b==="body"&&e.body)return p([e.body],f);if(h&&h[3]){var i=e.getElementById(h[3]);if(!i||!i.parentNode)return p([],f);if(i.id===h[3])return p([i],f)}try{return p(e.querySelectorAll(b),f)}catch(j){}}else if(e.nodeType===1&&e.nodeName.toLowerCase()!=="object"){var m=e,n=e.getAttribute("id"),o=n||d,q=e.parentNode,r=/^\s*[+~]/.test(b);n?o=o.replace(/'/g,"\\$&"):e.setAttribute("id",o),r&&q&&(e=e.parentNode);try{if(!r||q)return p(e.querySelectorAll("[id='"+o+"'] "+b),f)}catch(s){}finally{n||m.removeAttribute("id")}}}return a(b,e,f,g)};for(var e in a)k[e]=a[e];b=null}}(),function(){var a=c.documentElement,b=a.matchesSelector||a.mozMatchesSelector||a.webkitMatchesSelector||a.msMatchesSelector;if(b){var d=!b.call(c.createElement("div"),"div"),e=!1;try{b.call(c.documentElement,"[test!='']:sizzle")}catch(f){e=!0}k.matchesSelector=function(a,c){c=c.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!k.isXML(a))try{if(e||!l.match.PSEUDO.test(c)&&!/!=/.test(c)){var f=b.call(a,c);if(f||!d||a.document&&a.document.nodeType!==11)return f}}catch(g){}return k(c,null,null,[a]).length>0}}}(),function(){var a=c.createElement("div");a.innerHTML="
";if(!!a.getElementsByClassName&&a.getElementsByClassName("e").length!==0){a.lastChild.className="e";if(a.getElementsByClassName("e").length===1)return;l.order.splice(1,0,"CLASS"),l.find.CLASS=function(a,b,c){if(typeof b.getElementsByClassName!="undefined"&&!c)return b.getElementsByClassName(a[1])},a=null}}(),c.documentElement.contains?k.contains=function(a,b){return a!==b&&(a.contains?a.contains(b):!0)}:c.documentElement.compareDocumentPosition?k.contains=function(a,b){return!!(a.compareDocumentPosition(b)&16)}:k.contains=function(){return!1},k.isXML=function(a){var b=(a?a.ownerDocument||a:0).documentElement;return b?b.nodeName!=="HTML":!1};var v=function(a,b){var c,d=[],e="",f=b.nodeType?[b]:b;while(c=l.match.PSEUDO.exec(a))e+=c[0],a=a.replace(l.match.PSEUDO,"");a=l.relative[a]?a+"*":a;for(var g=0,h=f.length;g0)for(h=g;h0:this.filter(a).length>0)},closest:function(a,b){var c=[],d,e,g=this[0];if(f.isArray(a)){var h,i,j={},k=1;if(g&&a.length){for(d=0,e=a.length;d-1:f(g).is(h))&&c.push({selector:i,elem:g,level:k});g=g.parentNode,k++}}return c}var l=S.test(a)||typeof a!="string"?f(a,b||this.context):0;for(d=0,e=this.length;d-1:f.find.matchesSelector(g,a)){c.push(g);break}g=g.parentNode;if(!g||!g.ownerDocument||g===b||g.nodeType===11)break}}c=c.length>1?f.unique(c):c;return this.pushStack(c,"closest",a)},index:function(a){if(!a)return this[0]&&this[0].parentNode?this.prevAll().length:-1;if(typeof a=="string")return f.inArray(this[0],f(a));return f.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var c=typeof a=="string"?f(a,b):f.makeArray(a&&a.nodeType?[a]:a),d=f.merge(this.get(),c);return this.pushStack(U(c[0])||U(d[0])?d:f.unique(d))},andSelf:function(){return this.add(this.prevObject)}}),f.each({parent:function(a){var b=a.parentNode;return b&&b.nodeType!==11?b:null},parents:function(a){return f.dir(a,"parentNode")},parentsUntil:function(a,b,c){return f.dir(a,"parentNode",c)},next:function(a){return f.nth(a,2,"nextSibling")},prev:function(a){return f.nth(a,2,"previousSibling")},nextAll:function(a){return f.dir(a,"nextSibling")},prevAll:function(a){return f.dir(a,"previousSibling")},nextUntil:function(a,b,c){return f.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return f.dir(a,"previousSibling",c)},siblings:function(a){return f.sibling(a.parentNode.firstChild,a)},children:function(a){return f.sibling(a.firstChild)},contents:function(a){return f.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:f.makeArray(a.childNodes)}},function(a,b){f.fn[a]=function(c,d){var e=f.map(this,b,c),g=R.call(arguments);N.test(a)||(d=c),d&&typeof d=="string"&&(e=f.filter(d,e)),e=this.length>1&&!T[a]?f.unique(e):e,(this.length>1||P.test(d))&&O.test(a)&&(e=e.reverse());return this.pushStack(e,a,g.join(","))}}),f.extend({filter:function(a,b,c){c&&(a=":not("+a+")");return b.length===1?f.find.matchesSelector(b[0],a)?[b[0]]:[]:f.find.matches(a,b)},dir:function(a,c,d){var e=[],g=a[c];while(g&&g.nodeType!==9&&(d===b||g.nodeType!==1||!f(g).is(d)))g.nodeType===1&&e.push(g),g=g[c];return e},nth:function(a,b,c,d){b=b||1;var e=0;for(;a;a=a[c])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){var c=[];for(;a;a=a.nextSibling)a.nodeType===1&&a!==b&&c.push(a);return c}});var W=/ jQuery\d+="(?:\d+|null)"/g,X=/^\s+/,Y=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,Z=/<([\w:]+)/,$=/",""],legend:[1,"
","
"],thead:[1,"","
"],tr:[2,"","
"],td:[3,"","
"],col:[2,"","
"],area:[1,"",""],_default:[0,"",""]};be.optgroup=be.option,be.tbody=be.tfoot=be.colgroup=be.caption=be.thead,be.th=be.td,f.support.htmlSerialize||(be._default=[1,"div
","
"]),f.fn.extend({text:function(a){if(f.isFunction(a))return this.each(function(b){var c=f(this);c.text(a.call(this,b,c.text()))});if(typeof a!="object"&&a!==b)return this.empty().append((this[0]&&this[0].ownerDocument||c).createTextNode(a));return f.text(this)},wrapAll:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapAll(a.call(this,b))});if(this[0]){var b=f(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&a.firstChild.nodeType===1)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapInner(a.call(this,b))});return this.each(function(){var b=f(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){return this.each(function(){f(this).wrapAll(a)})},unwrap:function(){return this.parent().each(function(){f.nodeName(this,"body")||f(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this)});if(arguments.length){var a=f(arguments[0]);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,f(arguments[0]).toArray());return a}},remove:function(a,b){for(var c=0,d;(d=this[c])!=null;c++)if(!a||f.filter(a,[d]).length)!b&&d.nodeType===1&&(f.cleanData(d.getElementsByTagName("*")),f.cleanData([d])),d.parentNode&&d.parentNode.removeChild(d);return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++){b.nodeType===1&&f.cleanData(b.getElementsByTagName("*"));while(b.firstChild)b.removeChild(b.firstChild)}return this},clone:function(a,b){a=a==null?!1:a,b=b==null?a:b;return this.map(function(){return f.clone(this,a,b)})},html:function(a){if(a===b)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(W,""):null;if(typeof a=="string"&&!ba.test(a)&&(f.support.leadingWhitespace||!X.test(a))&&!be[(Z.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Y,"<$1>");try{for(var c=0,d=this.length;c1&&l0?this.clone(!0):this).get();f(e[h])[b](j),d=d.concat(j)}return this.pushStack(d,a,e.selector)}}),f.extend({clone:function(a,b,c){var d=a.cloneNode(!0),e,g,h;if((!f.support.noCloneEvent||!f.support.noCloneChecked)&&(a.nodeType===1||a.nodeType===11)&&!f.isXMLDoc(a)){bh(a,d),e=bi(a),g=bi(d);for(h=0;e[h];++h)g[h]&&bh(e[h],g[h])}if(b){bg(a,d);if(c){e=bi(a),g=bi(d);for(h=0;e[h];++h)bg(e[h],g[h])}}e=g=null;return d},clean:function(a,b,d,e){var g;b=b||c,typeof b.createElement=="undefined"&&(b=b.ownerDocument||b[0]&&b[0].ownerDocument||c);var h=[],i;for(var j=0,k;(k=a[j])!=null;j++){typeof k=="number"&&(k+="");if(!k)continue;if(typeof k=="string")if(!_.test(k))k=b.createTextNode(k);else{k=k.replace(Y,"<$1>");var l=(Z.exec(k)||["",""])[1].toLowerCase(),m=be[l]||be._default,n=m[0],o=b.createElement("div");o.innerHTML=m[1]+k+m[2];while(n--)o=o.lastChild;if(!f.support.tbody){var p=$.test(k),q=l==="table"&&!p?o.firstChild&&o.firstChild.childNodes:m[1]===""&&!p?o.childNodes:[];for(i=q.length-1;i>=0;--i)f.nodeName(q[i],"tbody")&&!q[i].childNodes.length&&q[i].parentNode.removeChild(q[i])}!f.support.leadingWhitespace&&X.test(k)&&o.insertBefore(b.createTextNode(X.exec(k)[0]),o.firstChild),k=o.childNodes}var r;if(!f.support.appendChecked)if(k[0]&&typeof (r=k.length)=="number")for(i=0;i=0)return b+"px"}}}),f.support.opacity||(f.cssHooks.opacity={get:function(a,b){return bn.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle,e=f.isNaN(b)?"":"alpha(opacity="+b*100+")",g=d&&d.filter||c.filter||"";c.zoom=1;if(b>=1&&f.trim(g.replace(bm,""))===""){c.removeAttribute("filter");if(d&&!d.filter)return}c.filter=bm.test(g)?g.replace(bm,e):g+" "+e}}),f(function(){f.support.reliableMarginRight||(f.cssHooks.marginRight={get:function(a,b){var c;f.swap(a,{display:"inline-block"},function(){b?c=bv(a,"margin-right","marginRight"):c=a.style.marginRight});return c}})}),c.defaultView&&c.defaultView.getComputedStyle&&(bw=function(a,c){var d,e,g;c=c.replace(bo,"-$1").toLowerCase();if(!(e=a.ownerDocument.defaultView))return b;if(g=e.getComputedStyle(a,null))d=g.getPropertyValue(c),d===""&&!f.contains(a.ownerDocument.documentElement,a)&&(d=f.style(a,c));return d}),c.documentElement.currentStyle&&(bx=function(a,b){var c,d=a.currentStyle&&a.currentStyle[b],e=a.runtimeStyle&&a.runtimeStyle[b],f=a.style;!bp.test(d)&&bq.test(d)&&(c=f.left,e&&(a.runtimeStyle.left=a.currentStyle.left),f.left=b==="fontSize"?"1em":d||0,d=f.pixelLeft+"px",f.left=c,e&&(a.runtimeStyle.left=e));return d===""?"auto":d}),bv=bw||bx,f.expr&&f.expr.filters&&(f.expr.filters.hidden=function(a){var b=a.offsetWidth,c=a.offsetHeight;return b===0&&c===0||!f.support.reliableHiddenOffsets&&(a.style.display||f.css(a,"display"))==="none"},f.expr.filters.visible=function(a){return!f.expr.filters.hidden(a)});var bz=/%20/g,bA=/\[\]$/,bB=/\r?\n/g,bC=/#.*$/,bD=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,bE=/^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,bF=/^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,bG=/^(?:GET|HEAD)$/,bH=/^\/\//,bI=/\?/,bJ=/)<[^<]*)*<\/script>/gi,bK=/^(?:select|textarea)/i,bL=/\s+/,bM=/([?&])_=[^&]*/,bN=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,bO=f.fn.load,bP={},bQ={},bR,bS,bT=["*/"]+["*"];try{bR=e.href}catch(bU){bR=c.createElement("a"),bR.href="",bR=bR.href}bS=bN.exec(bR.toLowerCase())||[],f.fn.extend({load:function(a,c,d){if(typeof a!="string"&&bO)return bO.apply(this,arguments);if(!this.length)return this;var e=a.indexOf(" ");if(e>=0){var g=a.slice(e,a.length);a=a.slice(0,e)}var h="GET";c&&(f.isFunction(c)?(d=c,c=b):typeof c=="object"&&(c=f.param(c,f.ajaxSettings.traditional),h="POST"));var i=this;f.ajax({url:a,type:h,dataType:"html",data:c,complete:function(a,b,c){c=a.responseText,a.isResolved()&&(a.done(function(a){c=a}),i.html(g?f("
").append(c.replace(bJ,"")).find(g):c)),d&&i.each(d,[c,b,a])}});return this},serialize:function(){return f.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?f.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||bK.test(this.nodeName)||bE.test(this.type))}).map(function(a,b){var c=f(this).val();return c==null?null:f.isArray(c)?f.map(c,function(a,c){return{name:b.name,value:a.replace(bB,"\r\n")}}):{name:b.name,value:c.replace(bB,"\r\n")}}).get()}}),f.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){f.fn[b]=function(a){return this.bind(b,a)}}),f.each(["get","post"],function(a,c){f[c]=function(a,d,e,g){f.isFunction(d)&&(g=g||e,e=d,d=b);return f.ajax({type:c,url:a,data:d,success:e,dataType:g})}}),f.extend({getScript:function(a,c){return f.get(a,b,c,"script")},getJSON:function(a,b,c){return f.get(a,b,c,"json")},ajaxSetup:function(a,b){b?bX(a,f.ajaxSettings):(b=a,a=f.ajaxSettings),bX(a,b);return a},ajaxSettings:{url:bR,isLocal:bF.test(bS[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":bT},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":a.String,"text html":!0,"text json":f.parseJSON,"text xml":f.parseXML},flatOptions:{context:!0,url:!0}},ajaxPrefilter:bV(bP),ajaxTransport:bV(bQ),ajax:function(a,c){function w(a,c,l,m){if(s!==2){s=2,q&&clearTimeout(q),p=b,n=m||"",v.readyState=a>0?4:0;var o,r,u,w=c,x=l?bZ(d,v,l):b,y,z;if(a>=200&&a<300||a===304){if(d.ifModified){if(y=v.getResponseHeader("Last-Modified"))f.lastModified[k]=y;if(z=v.getResponseHeader("Etag"))f.etag[k]=z}if(a===304)w="notmodified",o=!0;else try{r=b$(d,x),w="success",o=!0}catch(A){w="parsererror",u=A}}else{u=w;if(!w||a)w="error",a<0&&(a=0)}v.status=a,v.statusText=""+(c||w),o?h.resolveWith(e,[r,w,v]):h.rejectWith(e,[v,w,u]),v.statusCode(j),j=b,t&&g.trigger("ajax"+(o?"Success":"Error"),[v,d,o?r:u]),i.resolveWith(e,[v,w]),t&&(g.trigger("ajaxComplete",[v,d]),--f.active||f.event.trigger("ajaxStop"))}}typeof a=="object"&&(c=a,a=b),c=c||{};var d=f.ajaxSetup({},c),e=d.context||d,g=e!==d&&(e.nodeType||e instanceof f)?f(e):f.event,h=f.Deferred(),i=f._Deferred(),j=d.statusCode||{},k,l={},m={},n,o,p,q,r,s=0,t,u,v={readyState:0,setRequestHeader:function(a,b){if(!s){var c=a.toLowerCase();a=m[c]=m[c]||a,l[a]=b}return this},getAllResponseHeaders:function(){return s===2?n:null},getResponseHeader:function(a){var c;if(s===2){if(!o){o={};while(c=bD.exec(n))o[c[1].toLowerCase()]=c[2]}c=o[a.toLowerCase()]}return c===b?null:c},overrideMimeType:function(a){s||(d.mimeType=a);return this},abort:function(a){a=a||"abort",p&&p.abort(a),w(0,a);return this}};h.promise(v),v.success=v.done,v.error=v.fail,v.complete=i.done,v.statusCode=function(a){if(a){var b;if(s<2)for(b in a)j[b]=[j[b],a[b]];else b=a[v.status],v.then(b,b)}return this},d.url=((a||d.url)+"").replace(bC,"").replace(bH,bS[1]+"//"),d.dataTypes=f.trim(d.dataType||"*").toLowerCase().split(bL),d.crossDomain==null&&(r=bN.exec(d.url.toLowerCase()),d.crossDomain=!(!r||r[1]==bS[1]&&r[2]==bS[2]&&(r[3]||(r[1]==="http:"?80:443))==(bS[3]||(bS[1]==="http:"?80:443)))),d.data&&d.processData&&typeof d.data!="string"&&(d.data=f.param(d.data,d.traditional)),bW(bP,d,c,v);if(s===2)return!1;t=d.global,d.type=d.type.toUpperCase(),d.hasContent=!bG.test(d.type),t&&f.active++===0&&f.event.trigger("ajaxStart");if(!d.hasContent){d.data&&(d.url+=(bI.test(d.url)?"&":"?")+d.data,delete d.data),k=d.url;if(d.cache===!1){var x=f.now(),y=d.url.replace(bM,"$1_="+x);d.url=y+(y===d.url?(bI.test(d.url)?"&":"?")+"_="+x:"")}}(d.data&&d.hasContent&&d.contentType!==!1||c.contentType)&&v.setRequestHeader("Content-Type",d.contentType),d.ifModified&&(k=k||d.url,f.lastModified[k]&&v.setRequestHeader("If-Modified-Since",f.lastModified[k]),f.etag[k]&&v.setRequestHeader("If-None-Match",f.etag[k])),v.setRequestHeader("Accept",d.dataTypes[0]&&d.accepts[d.dataTypes[0]]?d.accepts[d.dataTypes[0]]+(d.dataTypes[0]!=="*"?", "+bT+"; q=0.01":""):d.accepts["*"]);for(u in d.headers)v.setRequestHeader(u,d.headers[u]);if(d.beforeSend&&(d.beforeSend.call(e,v,d)===!1||s===2)){v.abort();return!1}for(u in{success:1,error:1,complete:1})v[u](d[u]);p=bW(bQ,d,c,v);if(!p)w(-1,"No Transport");else{v.readyState=1,t&&g.trigger("ajaxSend",[v,d]),d.async&&d.timeout>0&&(q=setTimeout(function(){v.abort("timeout")},d.timeout));try{s=1,p.send(l,w)}catch(z){s<2?w(-1,z):f.error(z)}}return v},param:function(a,c){var d=[],e=function(a,b){b=f.isFunction(b)?b():b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};c===b&&(c=f.ajaxSettings.traditional);if(f.isArray(a)||a.jquery&&!f.isPlainObject(a))f.each(a,function(){e(this.name,this.value)});else for(var g in a)bY(g,a[g],c,e);return d.join("&").replace(bz,"+")}}),f.extend({active:0,lastModified:{},etag:{}});var b_=f.now(),ca=/(\=)\?(&|$)|\?\?/i;f.ajaxSetup({jsonp:"callback",jsonpCallback:function(){return f.expando+"_"+b_++}}),f.ajaxPrefilter("json jsonp",function(b,c,d){var e=b.contentType==="application/x-www-form-urlencoded"&&typeof b.data=="string";if(b.dataTypes[0]==="jsonp"||b.jsonp!==!1&&(ca.test(b.url)||e&&ca.test(b.data))){var g,h=b.jsonpCallback=f.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,i=a[h],j=b.url,k=b.data,l="$1"+h+"$2";b.jsonp!==!1&&(j=j.replace(ca,l),b.url===j&&(e&&(k=k.replace(ca,l)),b.data===k&&(j+=(/\?/.test(j)?"&":"?")+b.jsonp+"="+h))),b.url=j,b.data=k,a[h]=function(a){g=[a]},d.always(function(){a[h]=i,g&&f.isFunction(i)&&a[h](g[0])}),b.converters["script json"]=function(){g||f.error(h+" was not called");return g[0]},b.dataTypes[0]="json";return"script"}}),f.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(a){f.globalEval(a);return a}}}),f.ajaxPrefilter("script",function(a){a.cache===b&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),f.ajaxTransport("script",function(a){if(a.crossDomain){var d,e=c.head||c.getElementsByTagName("head")[0]||c.documentElement;return{send:function(f,g){d=c.createElement("script"),d.async="async",a.scriptCharset&&(d.charset=a.scriptCharset),d.src=a.url,d.onload=d.onreadystatechange=function(a,c){if(c||!d.readyState||/loaded|complete/.test(d.readyState))d.onload=d.onreadystatechange=null,e&&d.parentNode&&e.removeChild(d),d=b,c||g(200,"success")},e.insertBefore(d,e.firstChild)},abort:function(){d&&d.onload(0,1)}}}});var cb=a.ActiveXObject?function(){for(var a in cd)cd[a](0,1)}:!1,cc=0,cd;f.ajaxSettings.xhr=a.ActiveXObject?function(){return!this.isLocal&&ce()||cf()}:ce,function(a){f.extend(f.support,{ajax:!!a,cors:!!a&&"withCredentials"in a})}(f.ajaxSettings.xhr()),f.support.ajax&&f.ajaxTransport(function(c){if(!c.crossDomain||f.support.cors){var d;return{send:function(e,g){var h=c.xhr(),i,j;c.username?h.open(c.type,c.url,c.async,c.username,c.password):h.open(c.type,c.url,c.async);if(c.xhrFields)for(j in c.xhrFields)h[j]=c.xhrFields[j];c.mimeType&&h.overrideMimeType&&h.overrideMimeType(c.mimeType),!c.crossDomain&&!e["X-Requested-With"]&&(e["X-Requested-With"]="XMLHttpRequest");try{for(j in e)h.setRequestHeader(j,e[j])}catch(k){}h.send(c.hasContent&&c.data||null),d=function(a,e){var j,k,l,m,n;try{if(d&&(e||h.readyState===4)){d=b,i&&(h.onreadystatechange=f.noop,cb&&delete cd[i]);if(e)h.readyState!==4&&h.abort();else{j=h.status,l=h.getAllResponseHeaders(),m={},n=h.responseXML,n&&n.documentElement&&(m.xml=n),m.text=h.responseText;try{k=h.statusText}catch(o){k=""}!j&&c.isLocal&&!c.crossDomain?j=m.text?200:404:j===1223&&(j=204)}}}catch(p){e||g(-1,p)}m&&g(j,k,m,l)},!c.async||h.readyState===4?d():(i=++cc,cb&&(cd||(cd={},f(a).unload(cb)),cd[i]=d),h.onreadystatechange=d)},abort:function(){d&&d(0,1)}}}});var cg={},ch,ci,cj=/^(?:toggle|show|hide)$/,ck=/^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,cl,cm=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]],cn;f.fn.extend({show:function(a,b,c){var d,e;if(a||a===0)return this.animate(cq("show",3),a,b,c);for(var g=0,h=this.length;g=e.duration+this.startTime){this.now=this.end,this.pos=this.state=1,this.update(),e.animatedProperties[this.prop]=!0;for(g in e.animatedProperties)e.animatedProperties[g]!==!0&&(c=!1);if(c){e.overflow!=null&&!f.support.shrinkWrapBlocks&&f.each(["","X","Y"],function(a,b){d.style["overflow"+b]=e.overflow[a]}),e.hide&&f(d).hide();if(e.hide||e.show)for(var i in e.animatedProperties)f.style(d,i,e.orig[i]);e.complete.call(d)}return!1}e.duration==Infinity?this.now=b:(h=b-this.startTime,this.state=h/e.duration,this.pos=f.easing[e.animatedProperties[this.prop]](this.state,h,0,1,e.duration),this.now=this.start+(this.end-this.start)*this.pos),this.update();return!0}},f.extend(f.fx,{tick:function(){for(var a=f.timers,b=0;b
";f.extend(b.style,{position:"absolute",top:0,left:0,margin:0,border:0,width:"1px",height:"1px",visibility:"hidden"}),b.innerHTML=j,a.insertBefore(b,a.firstChild),d=b.firstChild,e=d.firstChild,h=d.nextSibling.firstChild.firstChild,this.doesNotAddBorder=e.offsetTop!==5,this.doesAddBorderForTableAndCells=h.offsetTop===5,e.style.position="fixed",e.style.top="20px",this.supportsFixedPosition=e.offsetTop===20||e.offsetTop===15,e.style.position=e.style.top="",d.style.overflow="hidden",d.style.position="relative",this.subtractsBorderForOverflowNotVisible=e.offsetTop===-5,this.doesNotIncludeMarginInBodyOffset=a.offsetTop!==i,a.removeChild(b),f.offset.initialize=f.noop},bodyOffset:function(a){var b=a.offsetTop,c=a.offsetLeft;f.offset.initialize(),f.offset.doesNotIncludeMarginInBodyOffset&&(b+=parseFloat(f.css(a,"marginTop"))||0,c+=parseFloat(f.css(a,"marginLeft"))||0);return{top:b,left:c}},setOffset:function(a,b,c){var d=f.css(a,"position");d==="static"&&(a.style.position="relative");var e=f(a),g=e.offset(),h=f.css(a,"top"),i=f.css(a,"left"),j=(d==="absolute"||d==="fixed")&&f.inArray("auto",[h,i])>-1,k={},l={},m,n;j?(l=e.position(),m=l.top,n=l.left):(m=parseFloat(h)||0,n=parseFloat(i)||0),f.isFunction(b)&&(b=b.call(a,c,g)),b.top!=null&&(k.top=b.top-g.top+m),b.left!=null&&(k.left=b.left-g.left+n),"using"in b?b.using.call(a,k):e.css(k)}},f.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),c=this.offset(),d=ct.test(b[0].nodeName)?{top:0,left:0}:b.offset();c.top-=parseFloat(f.css(a,"marginTop"))||0,c.left-=parseFloat(f.css(a,"marginLeft"))||0,d.top+=parseFloat(f.css(b[0],"borderTopWidth"))||0,d.left+=parseFloat(f.css(b[0],"borderLeftWidth"))||0;return{top:c.top-d.top,left:c.left-d.left}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||c.body;while(a&&!ct.test(a.nodeName)&&f.css(a,"position")==="static")a=a.offsetParent;return a})}}),f.each(["Left","Top"],function(a,c){var d="scroll"+c;f.fn[d]=function(c){var e,g;if(c===b){e=this[0];if(!e)return null;g=cu(e);return g?"pageXOffset"in g?g[a?"pageYOffset":"pageXOffset"]:f.support.boxModel&&g.document.documentElement[d]||g.document.body[d]:e[d]}return this.each(function(){g=cu(this),g?g.scrollTo(a?f(g).scrollLeft():c,a?c:f(g).scrollTop()):this[d]=c})}}),f.each(["Height","Width"],function(a,c){var d=c.toLowerCase();f.fn["inner"+c]=function(){var a=this[0];return a&&a.style?parseFloat(f.css(a,d,"padding")):null},f.fn["outer"+c]=function(a){var b=this[0];return b&&b.style?parseFloat(f.css(b,d,a?"margin":"border")):null},f.fn[d]=function(a){var e=this[0];if(!e)return a==null?null:this;if(f.isFunction(a))return this.each(function(b){var c=f(this);c[d](a.call(this,b,c[d]()))});if(f.isWindow(e)){var g=e.document.documentElement["client"+c],h=e.document.body;return e.document.compatMode==="CSS1Compat"&&g||h&&h["client"+c]||g}if(e.nodeType===9)return Math.max(e.documentElement["client"+c],e.body["scroll"+c],e.documentElement["scroll"+c],e.body["offset"+c],e.documentElement["offset"+c]);if(a===b){var i=f.css(e,d),j=parseFloat(i);return f.isNaN(j)?i:j}return this.css(d,typeof a=="string"?a:a+"px")}}),a.jQuery=a.$=f})(window); \ No newline at end of file From 247d8312ecdb99c008286311a39aa934f356577a Mon Sep 17 00:00:00 2001 From: zzak Date: Sat, 6 Sep 2014 00:08:56 +0000 Subject: [PATCH 228/343] Bump patch level from r47426 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47427 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.h b/version.h index 6256571e7b93f6..1690268297b7a9 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-09-06" -#define RUBY_PATCHLEVEL 226 +#define RUBY_PATCHLEVEL 227 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 9 From 8ba979b0eb71513469d6d65608ffa2eaed2ae296 Mon Sep 17 00:00:00 2001 From: nagachika Date: Tue, 9 Sep 2014 17:46:10 +0000 Subject: [PATCH 229/343] merge revision(s) r47190: [Backport #10139] * string.c (setup_fake_str): fake strings should not set class by RBASIC_SET_CLASS() because it insert write barriers to fake (non-RVALUE) structure. It can cause unexpected behaviour. Ruby 2.1 also have a same problem (setup_fake_str() in parse.y). * symbol.c (setup_fake_str): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47480 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ parse.y | 2 +- version.h | 6 +++--- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0d5adc49d31ddf..4678b61a24ac86 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Wed Sep 10 02:33:08 2014 Koichi Sasada + + * parse.y (setup_fake_str): fake strings should not set class by + RBASIC_SET_CLASS() because it insert write barriers to fake + (non-RVALUE) structure. + + It can cause unexpected behaviour. + Fri Sep 5 17:01:38 2014 Zachary Scott * lib/rdoc/generator/template/darkfish/js/jquery.js: Backport diff --git a/parse.y b/parse.y index cc3a638b3653ba..5991376820c8cb 100644 --- a/parse.y +++ b/parse.y @@ -10403,7 +10403,7 @@ static VALUE setup_fake_str(struct RString *fake_str, const char *name, long len) { fake_str->basic.flags = T_STRING|RSTRING_NOEMBED; - RBASIC_SET_CLASS((VALUE)fake_str, rb_cString); + RBASIC_SET_CLASS_RAW((VALUE)fake_str, rb_cString); fake_str->as.heap.len = len; fake_str->as.heap.ptr = (char *)name; fake_str->as.heap.aux.capa = len; diff --git a/version.h b/version.h index 1690268297b7a9..341b57cdbc4fb0 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.2" -#define RUBY_RELEASE_DATE "2014-09-06" -#define RUBY_PATCHLEVEL 227 +#define RUBY_RELEASE_DATE "2014-09-10" +#define RUBY_PATCHLEVEL 228 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 9 -#define RUBY_RELEASE_DAY 6 +#define RUBY_RELEASE_DAY 10 #include "ruby/version.h" From d2f4d58d529d1684897766b20367d0af11d58ea2 Mon Sep 17 00:00:00 2001 From: nagachika Date: Tue, 9 Sep 2014 17:59:51 +0000 Subject: [PATCH 230/343] merge revision(s) r47191: [Backport #10140] * iseq.c (rb_iseq_clone): Should not insert write barrier from non-RVALUE data (to non-RVALUE data, of course). Ruby 2.1 also has a same problem. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47481 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ iseq.c | 2 +- version.h | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4678b61a24ac86..f2b89c44cab075 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Wed Sep 10 02:51:38 2014 Koichi Sasada + + * iseq.c (rb_iseq_clone): Should not insert write barrier from + non-RVALUE data (to non-RVALUE data, of course). + + Ruby 2.1 also has a same problem. + Wed Sep 10 02:33:08 2014 Koichi Sasada * parse.y (setup_fake_str): fake strings should not set class by diff --git a/iseq.c b/iseq.c index 32d996796429f9..700a161f6bc3e6 100644 --- a/iseq.c +++ b/iseq.c @@ -1943,7 +1943,7 @@ rb_iseq_clone(VALUE iseqval, VALUE newcbase) if (iseq0->cref_stack->nd_next) { RB_OBJ_WRITE(iseq1->cref_stack, &iseq1->cref_stack->nd_next, iseq0->cref_stack->nd_next); } - RB_OBJ_WRITE(iseq1, &iseq1->klass, newcbase); + RB_OBJ_WRITE(iseq1->self, &iseq1->klass, newcbase); } return newiseq; diff --git a/version.h b/version.h index 341b57cdbc4fb0..4275f66862dc08 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-09-10" -#define RUBY_PATCHLEVEL 228 +#define RUBY_PATCHLEVEL 229 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 9 From 609961a46d963f6eb736e8b7755ec7b0835862a4 Mon Sep 17 00:00:00 2001 From: nagachika Date: Tue, 9 Sep 2014 18:10:18 +0000 Subject: [PATCH 231/343] merge revision(s) r47196: [Backport #10144] * time.c (time_timespec): fix tv_nsec overflow [Bug #10144] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47482 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ time.c | 4 ++++ version.h | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index f2b89c44cab075..bf3fb8d6600415 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed Sep 10 03:01:31 2014 Eric Wong + + * time.c (time_timespec): fix tv_nsec overflow + [Bug #10144] + Wed Sep 10 02:51:38 2014 Koichi Sasada * iseq.c (rb_iseq_clone): Should not insert write barrier from diff --git a/time.c b/time.c index d5215edde11825..5ad1035c4deb99 100644 --- a/time.c +++ b/time.c @@ -2350,6 +2350,10 @@ time_timespec(VALUE num, int interval) d = modf(RFLOAT_VALUE(num), &f); if (d >= 0) { t.tv_nsec = (int)(d*1e9+0.5); + if (t.tv_nsec >= 1000000000) { + t.tv_nsec -= 1000000000; + f += 1; + } } else if ((t.tv_nsec = (int)(-d*1e9+0.5)) > 0) { t.tv_nsec = 1000000000 - t.tv_nsec; diff --git a/version.h b/version.h index 4275f66862dc08..5a0f256a82aef0 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-09-10" -#define RUBY_PATCHLEVEL 229 +#define RUBY_PATCHLEVEL 230 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 9 From 5545b8b459dc0c9f5ef37c5c968dcca89e237646 Mon Sep 17 00:00:00 2001 From: nagachika Date: Tue, 9 Sep 2014 18:25:50 +0000 Subject: [PATCH 232/343] merge revision(s) r47221: [Backport #10149] * enc/trans/euckr-tbl.rb (EUCKR_TO_UCS_TBL): add missing euro and registered signs. [ruby-core:64452] [Bug #10149] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47485 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ enc/trans/euckr-tbl.rb | 2 ++ test/ruby/enc/test_euc_kr.rb | 8 ++++++++ version.h | 2 +- 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index bf3fb8d6600415..aa7ded7bf36c22 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed Sep 10 03:17:13 2014 Nobuyoshi Nakada + + * enc/trans/euckr-tbl.rb (EUCKR_TO_UCS_TBL): add missing euro and + registered signs. [ruby-core:64452] [Bug #10149] + Wed Sep 10 03:01:31 2014 Eric Wong * time.c (time_timespec): fix tv_nsec overflow diff --git a/enc/trans/euckr-tbl.rb b/enc/trans/euckr-tbl.rb index 773cd90122039a..4ce8521a8a9240 100644 --- a/enc/trans/euckr-tbl.rb +++ b/enc/trans/euckr-tbl.rb @@ -162,6 +162,8 @@ ["A2E3",0x33C2], ["A2E4",0x33D8], ["A2E5",0x2121], + ["A2E6",0x20AC], + ["A2E7",0x00AE], ["A3A1",0xFF01], ["A3A2",0xFF02], ["A3A3",0xFF03], diff --git a/test/ruby/enc/test_euc_kr.rb b/test/ruby/enc/test_euc_kr.rb index 087bc795f7822c..5413fa6062e579 100644 --- a/test/ruby/enc/test_euc_kr.rb +++ b/test/ruby/enc/test_euc_kr.rb @@ -25,4 +25,12 @@ def test_mbc_case_fold def test_left_adjust_char_head assert_equal(s("\xa1\xa1"), s("\xa1\xa1\xa1\xa1").chop) end + + def test_euro_sign + assert_equal("\u{20ac}", s("\xa2\xe6").encode("utf-8")) + end + + def test_registered_mark + assert_equal("\u{00ae}", s("\xa2\xe7").encode("utf-8")) + end end diff --git a/version.h b/version.h index 5a0f256a82aef0..f8b9e15a4b62c4 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-09-10" -#define RUBY_PATCHLEVEL 230 +#define RUBY_PATCHLEVEL 231 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 9 From 8f01a278170f870588eaee2b8afc40f6b58c55be Mon Sep 17 00:00:00 2001 From: nagachika Date: Tue, 9 Sep 2014 18:47:25 +0000 Subject: [PATCH 233/343] merge revision(s) r47288: [Backport #10153] * io.c (io_close): ignore only "closed stream" IOError and NoMethodError, do not swallow other exceptions at the end of block. [ruby-core:64463] [Bug #10153] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47486 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ io.c | 32 ++++++++++++++++++++++++++------ test/ruby/test_io.rb | 9 +++++++++ version.h | 2 +- 4 files changed, 42 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index aa7ded7bf36c22..d28ae9412e73f6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Wed Sep 10 03:29:48 2014 Nobuyoshi Nakada + + * io.c (io_close): ignore only "closed stream" IOError and + NoMethodError, do not swallow other exceptions at the end of + block. [ruby-core:64463] [Bug #10153] + Wed Sep 10 03:17:13 2014 Nobuyoshi Nakada * enc/trans/euckr-tbl.rb (EUCKR_TO_UCS_TBL): add missing euro and diff --git a/io.c b/io.c index e5b2ac1330a306..95229903ca3b4a 100644 --- a/io.c +++ b/io.c @@ -590,6 +590,8 @@ is_socket(int fd, VALUE path) } #endif +static const char closed_stream[] = "closed stream"; + void rb_eof_error(void) { @@ -616,7 +618,7 @@ rb_io_check_closed(rb_io_t *fptr) { rb_io_check_initialized(fptr); if (fptr->fd < 0) { - rb_raise(rb_eIOError, "closed stream"); + rb_raise(rb_eIOError, closed_stream); } } @@ -1075,7 +1077,7 @@ int rb_io_wait_readable(int f) { if (f < 0) { - rb_raise(rb_eIOError, "closed stream"); + rb_raise(rb_eIOError, closed_stream); } switch (errno) { case EINTR: @@ -1101,7 +1103,7 @@ int rb_io_wait_writable(int f) { if (f < 0) { - rb_raise(rb_eIOError, "closed stream"); + rb_raise(rb_eIOError, closed_stream); } switch (errno) { case EINTR: @@ -4062,7 +4064,7 @@ finish_writeconv(rb_io_t *fptr, int noalloc) } if (rb_io_wait_writable(fptr->fd)) { if (fptr->fd < 0) - return noalloc ? Qtrue : rb_exc_new3(rb_eIOError, rb_str_new_cstr("closed stream")); + return noalloc ? Qtrue : rb_exc_new3(rb_eIOError, rb_str_new_cstr(closed_stream)); goto retry; } return noalloc ? Qtrue : INT2NUM(errno); @@ -4344,13 +4346,31 @@ rb_io_close_m(VALUE io) static VALUE io_call_close(VALUE io) { - return rb_funcall(io, rb_intern("close"), 0, 0); + rb_check_funcall(io, rb_intern("close"), 0, 0); + return io; +} + +static VALUE +ignore_closed_stream(VALUE io, VALUE exc) +{ + enum {mesg_len = sizeof(closed_stream)-1}; + VALUE mesg = rb_attr_get(exc, rb_intern("mesg")); + if (!RB_TYPE_P(mesg, T_STRING) || + RSTRING_LEN(mesg) != mesg_len || + memcmp(RSTRING_PTR(mesg), closed_stream, mesg_len)) { + rb_exc_raise(exc); + } + return io; } static VALUE io_close(VALUE io) { - return rb_rescue(io_call_close, io, 0, 0); + VALUE closed = rb_check_funcall(io, rb_intern("closed?"), 0, 0); + if (closed != Qundef && RTEST(closed)) return io; + rb_rescue2(io_call_close, io, ignore_closed_stream, io, + rb_eIOError, (VALUE)0); + return io; } /* diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index 631f854a855a91..cf0ac9803e7dc6 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -2995,4 +2995,13 @@ def test_sysread_unlocktmp_ensure ensure t.kill end + + def test_exception_at_close + bug10153 = '[ruby-core:64463] [Bug #10153] exception in close at the end of block' + assert_raise(Errno::EBADF, bug10153) do + IO.pipe do |r, w| + assert_nothing_raised {IO.open(w.fileno) {}} + end + end + end end diff --git a/version.h b/version.h index f8b9e15a4b62c4..9f450bfa8f6060 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-09-10" -#define RUBY_PATCHLEVEL 231 +#define RUBY_PATCHLEVEL 232 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 9 From 46075e246ee20144f64299f9a5cc6c5af15460e9 Mon Sep 17 00:00:00 2001 From: nagachika Date: Wed, 10 Sep 2014 14:07:46 +0000 Subject: [PATCH 234/343] merge revision(s) r47248: [Backport #10161] * common.mk (Doxyfile): revert r43888, not to require preinstalled ruby. [ruby-core:64488] [Bug #10161] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47518 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ common.mk | 2 +- tool/file2lastrev.rb | 7 ++++++- tool/vcs.rb | 12 +++++++----- version.h | 2 +- 5 files changed, 20 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index d28ae9412e73f6..3516d4f6e64840 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed Sep 10 22:58:25 2014 Nobuyoshi Nakada + + * common.mk (Doxyfile): revert r43888, not to require preinstalled + ruby. [ruby-core:64488] [Bug #10161] + Wed Sep 10 03:29:48 2014 Nobuyoshi Nakada * io.c (io_close): ignore only "closed stream" IOError and diff --git a/common.mk b/common.mk index 0c8b7fc54a3c58..de1b671fdd23a0 100644 --- a/common.mk +++ b/common.mk @@ -204,7 +204,7 @@ $(CAPIOUT)/.timestamp: Doxyfile $(PREP) Doxyfile: $(srcdir)/template/Doxyfile.tmpl $(PREP) $(srcdir)/tool/generic_erb.rb $(RBCONFIG) $(ECHO) generating $@ $(Q) $(MINIRUBY) $(srcdir)/tool/generic_erb.rb -o $@ $(srcdir)/template/Doxyfile.tmpl \ - --srcdir="$(srcdir)" --miniruby="$(BASERUBY)" + --srcdir="$(srcdir)" --miniruby="$(MINIRUBY)" program: showflags $(PROGRAM) wprogram: showflags $(WPROGRAM) diff --git a/tool/file2lastrev.rb b/tool/file2lastrev.rb index 56e1b9f512a836..616c5f7fe446a6 100755 --- a/tool/file2lastrev.rb +++ b/tool/file2lastrev.rb @@ -31,6 +31,9 @@ def self.output=(output) opts.on("--doxygen", "Doxygen format") do self.output = :doxygen end + opts.on("--modified", "modified time") do + self.output = :modified + end opts.on("-q", "--suppress_not_found") do @suppress_not_found = true end @@ -44,7 +47,7 @@ def self.output=(output) abort "#{File.basename(Program)}: #{e.message}" unless @suppress_not_found else begin - last, changed = vcs.get_revisions(ARGV.shift) + last, changed, modified = vcs.get_revisions(ARGV.shift) rescue => e abort "#{File.basename(Program)}: #{e.message}" unless @suppress_not_found exit false @@ -58,6 +61,8 @@ def self.output=(output) puts "#define RUBY_REVISION #{changed.to_i}" when :doxygen puts "r#{changed}/r#{last}" +when :modified + puts modified.strftime('%Y-%m-%dT%H:%M:%S%z') else raise "unknown output format `#{@output}'" end diff --git a/tool/vcs.rb b/tool/vcs.rb index dbde58545ee868..cc744ca5ae8b89 100644 --- a/tool/vcs.rb +++ b/tool/vcs.rb @@ -1,7 +1,5 @@ # vcs -require 'time' - ENV.delete('PWD') unless File.respond_to? :realpath @@ -45,7 +43,11 @@ def get_revisions(path) last, changed, modified, *rest = Dir.chdir(@srcdir) {self.class.get_revisions(path)} last or raise VCS::NotFoundError, "last revision not found" changed or raise VCS::NotFoundError, "changed revision not found" - modified &&= Time.parse(modified) + if modified + /\A(\d+)-(\d+)-(\d+)\D(\d+):(\d+):(\d+(?:\.\d+)?)\s*(?:Z|([-+]\d\d)(\d\d))\z/ =~ modified or + raise "unknown time format - #{modified}" + modified = Time.mktime(*($~[1..6] + [$7 ? "#{$7}:#{$8}" : "+00:00"])) + end return last, changed, modified, *rest end @@ -96,16 +98,16 @@ class GIT < self register(".git") def self.get_revisions(path) - logcmd = %Q[git log -n1 --grep="^ *git-svn-id: .*@[0-9][0-9]* "] + logcmd = %Q[git log -n1 --date=iso --grep="^ *git-svn-id: .*@[0-9][0-9]* "] idpat = /git-svn-id: .*?@(\d+) \S+\Z/ last = `#{logcmd}`[idpat, 1] if path log = `#{logcmd} "#{path}"` changed = log[idpat, 1] - modified = `git log --format=%ai -- #{path}` else changed = last end + modified = log[/^Date:\s+(.*)/, 1] [last, changed, modified] end end diff --git a/version.h b/version.h index 9f450bfa8f6060..3004fba4118a53 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-09-10" -#define RUBY_PATCHLEVEL 232 +#define RUBY_PATCHLEVEL 233 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 9 From 5d913e21d212bec151b506e2e4e28dafc0ad4877 Mon Sep 17 00:00:00 2001 From: nagachika Date: Wed, 10 Sep 2014 14:30:48 +0000 Subject: [PATCH 235/343] merge r46831 partially. extracted commits are as follows. [Bug #9344] https://github.com/k-takata/Onigmo/commit/bdfc1997aa15b6baddaf9a482c6610b32504bd86 * regcomp.c: Merge Onigmo 5.14.1 25a8a69fc05ae3b56a09. this includes Support for Unicode 7.0 [Bug #9092]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47519 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ regparse.c | 21 +++++++-------------- version.h | 2 +- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3516d4f6e64840..5fdbaf86c774c3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Wed Sep 10 23:14:42 2014 NARUSE, Yui + + merge r46831 partially. extracted commits are as follows. [Bug #9344] + https://github.com/k-takata/Onigmo/commit/bdfc1997aa15b6baddaf9a482c6610b32504bd86 + + * regcomp.c: Merge Onigmo 5.14.1 25a8a69fc05ae3b56a09. + this includes Support for Unicode 7.0 [Bug #9092]. + Wed Sep 10 22:58:25 2014 Nobuyoshi Nakada * common.mk (Doxyfile): revert r43888, not to require preinstalled diff --git a/regparse.c b/regparse.c index fac79a311b4cf5..ecf39ad1cf3faf 100644 --- a/regparse.c +++ b/regparse.c @@ -5293,30 +5293,23 @@ set_quantifier(Node* qnode, Node* target, int group, ScanEnv* env) #ifdef USE_WARNING_REDUNDANT_NESTED_REPEAT_OPERATOR if (!IS_QUANTIFIER_BY_NUMBER(qn) && !IS_QUANTIFIER_BY_NUMBER(qnt) && IS_SYNTAX_BV(env->syntax, ONIG_SYN_WARN_REDUNDANT_NESTED_REPEAT)) { - UChar buf[WARN_BUFSIZE]; - switch (ReduceTypeTable[targetq_num][nestq_num]) { case RQ_ASIS: break; case RQ_DEL: - if (onig_verb_warn != onig_null_warn) { - onig_snprintf_with_pattern(buf, WARN_BUFSIZE, env->enc, - env->pattern, env->pattern_end, - (UChar* )"redundant nested repeat operator"); - (*onig_verb_warn)((char* )buf); + if (onig_warn != onig_null_warn) { + onig_syntax_warn(env, "regular expression has redundant nested repeat operator '%s'", + PopularQStr[targetq_num]); } goto warn_exit; break; default: - if (onig_verb_warn != onig_null_warn) { - onig_snprintf_with_pattern(buf, WARN_BUFSIZE, env->enc, - env->pattern, env->pattern_end, - (UChar* )"nested repeat operator %s and %s was replaced with '%s'", - PopularQStr[targetq_num], PopularQStr[nestq_num], - ReduceQStr[ReduceTypeTable[targetq_num][nestq_num]]); - (*onig_verb_warn)((char* )buf); + if (onig_warn != onig_null_warn) { + onig_syntax_warn(env, "nested repeat operator '%s' and '%s' was replaced with '%s' in regular expression", + PopularQStr[targetq_num], PopularQStr[nestq_num], + ReduceQStr[ReduceTypeTable[targetq_num][nestq_num]]); } goto warn_exit; break; diff --git a/version.h b/version.h index 3004fba4118a53..d581b64dffe5ed 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-09-10" -#define RUBY_PATCHLEVEL 233 +#define RUBY_PATCHLEVEL 234 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 9 From 4d238acd886ac75c3040495492b3dc77c2edbf9f Mon Sep 17 00:00:00 2001 From: nagachika Date: Wed, 10 Sep 2014 14:57:42 +0000 Subject: [PATCH 236/343] merge revision(s) r46501,r47372,r47460: [Backport #10191] * object.c (rb_obj_copy_ivar): extract function to copy instance variables only for T_OBJECT from init_copy. * object.c (rb_obj_copy_ivar): allocate no memory for empty instance variables. [ruby-core:64700] [Bug #10191] * test/ruby/test_object.rb: extend timeout. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47520 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 14 ++++++++++++ internal.h | 1 + object.c | 47 ++++++++++++++++++++++++---------------- test/ruby/test_object.rb | 10 +++++++++ version.h | 2 +- 5 files changed, 54 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5fdbaf86c774c3..936e9bf846e074 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +Wed Sep 10 23:36:38 2014 Koichi Sasada + + * test/ruby/test_object.rb: extend timeout. + +Wed Sep 10 23:36:38 2014 Nobuyoshi Nakada + + * object.c (rb_obj_copy_ivar): allocate no memory for empty + instance variables. [ruby-core:64700] [Bug #10191] + +Wed Sep 10 23:36:38 2014 Nobuyoshi Nakada + + * object.c (rb_obj_copy_ivar): extract function to copy instance + variables only for T_OBJECT from init_copy. + Wed Sep 10 23:14:42 2014 NARUSE, Yui merge r46831 partially. extracted commits are as follows. [Bug #9344] diff --git a/internal.h b/internal.h index af8e69517c3148..1f41d23b1b7380 100644 --- a/internal.h +++ b/internal.h @@ -595,6 +595,7 @@ rb_float_new_inline(double d) #define rb_float_new(d) rb_float_new_inline(d) /* object.c */ +void rb_obj_copy_ivar(VALUE dest, VALUE obj); VALUE rb_obj_equal(VALUE obj1, VALUE obj2); VALUE rb_class_search_ancestor(VALUE klass, VALUE super); diff --git a/object.c b/object.c index 3885d9bf701c5f..34eac51a1d1b15 100644 --- a/object.c +++ b/object.c @@ -252,6 +252,33 @@ rb_obj_singleton_class(VALUE obj) return rb_singleton_class(obj); } +void +rb_obj_copy_ivar(VALUE dest, VALUE obj) +{ + if (!(RBASIC(dest)->flags & ROBJECT_EMBED) && ROBJECT_IVPTR(dest)) { + xfree(ROBJECT_IVPTR(dest)); + ROBJECT(dest)->as.heap.ivptr = 0; + ROBJECT(dest)->as.heap.numiv = 0; + ROBJECT(dest)->as.heap.iv_index_tbl = 0; + } + if (RBASIC(obj)->flags & ROBJECT_EMBED) { + MEMCPY(ROBJECT(dest)->as.ary, ROBJECT(obj)->as.ary, VALUE, ROBJECT_EMBED_LEN_MAX); + RBASIC(dest)->flags |= ROBJECT_EMBED; + } + else { + long len = ROBJECT(obj)->as.heap.numiv; + VALUE *ptr = 0; + if (len > 0) { + ptr = ALLOC_N(VALUE, len); + MEMCPY(ptr, ROBJECT(obj)->as.heap.ivptr, VALUE, len); + } + ROBJECT(dest)->as.heap.ivptr = ptr; + ROBJECT(dest)->as.heap.numiv = len; + ROBJECT(dest)->as.heap.iv_index_tbl = ROBJECT(obj)->as.heap.iv_index_tbl; + RBASIC(dest)->flags &= ~ROBJECT_EMBED; + } +} + static void init_copy(VALUE dest, VALUE obj) { @@ -264,25 +291,7 @@ init_copy(VALUE dest, VALUE obj) rb_gc_copy_finalizer(dest, obj); switch (TYPE(obj)) { case T_OBJECT: - if (!(RBASIC(dest)->flags & ROBJECT_EMBED) && ROBJECT_IVPTR(dest)) { - xfree(ROBJECT_IVPTR(dest)); - ROBJECT(dest)->as.heap.ivptr = 0; - ROBJECT(dest)->as.heap.numiv = 0; - ROBJECT(dest)->as.heap.iv_index_tbl = 0; - } - if (RBASIC(obj)->flags & ROBJECT_EMBED) { - MEMCPY(ROBJECT(dest)->as.ary, ROBJECT(obj)->as.ary, VALUE, ROBJECT_EMBED_LEN_MAX); - RBASIC(dest)->flags |= ROBJECT_EMBED; - } - else { - long len = ROBJECT(obj)->as.heap.numiv; - VALUE *ptr = ALLOC_N(VALUE, len); - MEMCPY(ptr, ROBJECT(obj)->as.heap.ivptr, VALUE, len); - ROBJECT(dest)->as.heap.ivptr = ptr; - ROBJECT(dest)->as.heap.numiv = len; - ROBJECT(dest)->as.heap.iv_index_tbl = ROBJECT(obj)->as.heap.iv_index_tbl; - RBASIC(dest)->flags &= ~ROBJECT_EMBED; - } + rb_obj_copy_ivar(dest, obj); break; case T_CLASS: case T_MODULE: diff --git a/test/ruby/test_object.rb b/test/ruby/test_object.rb index 1d6c6e30230ca4..e8ab6135c480ac 100644 --- a/test/ruby/test_object.rb +++ b/test/ruby/test_object.rb @@ -805,4 +805,14 @@ def test_type_error_message assert_raise_with_message(TypeError, "can't convert Array into Integer") {Integer([42])} assert_raise_with_message(TypeError, 'no implicit conversion of Array into Integer') {[].first([42])} end + + def test_copied_ivar_memory_leak + bug10191 = '[ruby-core:64700] [Bug #10191]' + assert_no_memory_leak([], <<-"end;", <<-"end;", bug10191, rss: true, timeout: 60, limit: 2.5) + def (a = Object.new).set; @v = nil; end + num = 500_000 + end; + num.times {a.clone.set} + end; + end end diff --git a/version.h b/version.h index d581b64dffe5ed..1941cc4c37f4ae 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-09-10" -#define RUBY_PATCHLEVEL 234 +#define RUBY_PATCHLEVEL 235 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 9 From 7139427cf313dfc647dd1e6c5a6d1e3829e13280 Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 14 Sep 2014 15:25:34 +0000 Subject: [PATCH 237/343] merge revision(s) r46391,r46395: [Backport #9766] * lib/csv.rb (CSV#<<): honor explicity given encoding. based on the patch by DAISUKE TANIWAKI at [ruby-core:62113]. [Bug #9766] * lib/csv.rb (CSV#<<): honor explicitly given encoding. based on git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47586 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ lib/csv.rb | 17 ++++++++++------- test/csv/test_encodings.rb | 8 ++++++++ version.h | 6 +++--- 4 files changed, 27 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 936e9bf846e074..4c773cf16e56a4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Mon Sep 15 00:02:20 2014 Nobuyoshi Nakada + + * lib/csv.rb (CSV#<<): honor explicitly given encoding. based on + the patch by DAISUKE TANIWAKI at + [ruby-core:62113]. [Bug #9766] + Wed Sep 10 23:36:38 2014 Koichi Sasada * test/ruby/test_object.rb: extend timeout. diff --git a/lib/csv.rb b/lib/csv.rb index 2326792cd74d2b..b8a9b97f1614c1 100644 --- a/lib/csv.rb +++ b/lib/csv.rb @@ -1148,9 +1148,9 @@ def self.generate(*args) io.seek(0, IO::SEEK_END) args.unshift(io) else - encoding = (args[-1] = args[-1].dup).delete(:encoding) if args.last.is_a?(Hash) + encoding = args[-1][:encoding] if args.last.is_a?(Hash) str = "" - str.encode!(encoding) if encoding + str.force_encoding(encoding) if encoding args.unshift(str) end csv = new(*args) # wrap @@ -1515,7 +1515,7 @@ def initialize(data, options = Hash.new) init_headers(options) init_comments(options) - options.delete(:encoding) + @force_encoding = !!(encoding || options.delete(:encoding)) options.delete(:internal_encoding) options.delete(:external_encoding) unless options.empty? @@ -1655,10 +1655,13 @@ def <<(row) output = row.map(&@quote).join(@col_sep) + @row_sep # quote and separate if @io.is_a?(StringIO) and - output.encoding != raw_encoding and - (compatible_encoding = Encoding.compatible?(@io.string, output)) - @io.set_encoding(compatible_encoding) - @io.seek(0, IO::SEEK_END) + output.encoding != (encoding = raw_encoding) + if @force_encoding + output = output.encode(encoding) + elsif (compatible_encoding = Encoding.compatible?(@io.string, output)) + @io.set_encoding(compatible_encoding) + @io.seek(0, IO::SEEK_END) + end end @io << output diff --git a/test/csv/test_encodings.rb b/test/csv/test_encodings.rb index 85ed21a9d69fad..4e2c60545db8d1 100755 --- a/test/csv/test_encodings.rb +++ b/test/csv/test_encodings.rb @@ -257,6 +257,14 @@ def test_encoding_is_upgraded_for_ascii_content_during_writing_as_needed assert_equal("UTF-8", data.to_csv.encoding.name) end + def test_explicit_encoding + bug9766 = '[ruby-core:62113] [Bug #9766]' + s = CSV.generate(encoding: "Windows-31J") do |csv| + csv << ["foo".force_encoding("ISO-8859-1"), "\u3042"] + end + assert_equal(["foo,\u3042\n".encode(Encoding::Windows_31J), Encoding::Windows_31J], [s, s.encoding], bug9766) + end + private def assert_parses(fields, encoding, options = { }) diff --git a/version.h b/version.h index 1941cc4c37f4ae..d58ce41d78bbc3 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.2" -#define RUBY_RELEASE_DATE "2014-09-10" -#define RUBY_PATCHLEVEL 235 +#define RUBY_RELEASE_DATE "2014-09-15" +#define RUBY_PATCHLEVEL 236 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 9 -#define RUBY_RELEASE_DAY 10 +#define RUBY_RELEASE_DAY 15 #include "ruby/version.h" From fa9c5230499f4e613eb0b4449340be3b6edd2cec Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 14 Sep 2014 16:13:47 +0000 Subject: [PATCH 238/343] merge revision(s) r47457: [Backport #8315] * lib/mkmf.rb (MakeMakefile#pkg_config): append --cflags to also $CXXFLAGS, as they are often used by C++ compiler. [ruby-core:54532] [Bug #8315] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47587 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ lib/mkmf.rb | 1 + version.h | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 4c773cf16e56a4..cbc05a30552598 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Mon Sep 15 01:06:35 2014 Nobuyoshi Nakada + + * lib/mkmf.rb (MakeMakefile#pkg_config): append --cflags to also + $CXXFLAGS, as they are often used by C++ compiler. + [ruby-core:54532] [Bug #8315] + Mon Sep 15 00:02:20 2014 Nobuyoshi Nakada * lib/csv.rb (CSV#<<): honor explicitly given encoding. based on diff --git a/lib/mkmf.rb b/lib/mkmf.rb index 2d44b123d2f293..99fe5d4a6aed68 100644 --- a/lib/mkmf.rb +++ b/lib/mkmf.rb @@ -1764,6 +1764,7 @@ def pkg_config(pkg, option=nil) libs = get['libs-only-l'] ldflags = (Shellwords.shellwords(ldflags) - Shellwords.shellwords(libs)).quote.join(" ") $CFLAGS += " " << cflags + $CXXFLAGS += " " << cflags $LDFLAGS = [orig_ldflags, ldflags].join(' ') $libs += " " << libs Logging::message "package configuration for %s\n", pkg diff --git a/version.h b/version.h index d58ce41d78bbc3..76c25a122a32a3 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-09-15" -#define RUBY_PATCHLEVEL 236 +#define RUBY_PATCHLEVEL 237 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 9 From d67632d206ff7a5d2366d94d8badb0b6228487d4 Mon Sep 17 00:00:00 2001 From: nagachika Date: Mon, 15 Sep 2014 02:08:59 +0000 Subject: [PATCH 239/343] merge revision(s) r44459,r44470: [Backport #8315] * lib/mkmf.rb (configuration): Make CXXFLAGS customizable. Patch by Kohei Suzuki (eagletmt). [Fixes GH-492] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47592 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ lib/mkmf.rb | 3 ++- version.h | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index cbc05a30552598..6dd8aa55679caf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Mon Sep 15 11:08:23 2014 Shota Fukumori + + * lib/mkmf.rb (configuration): Make CXXFLAGS customizable. + Patch by Kohei Suzuki (eagletmt). [Fixes GH-492] + Mon Sep 15 01:06:35 2014 Nobuyoshi Nakada * lib/mkmf.rb (MakeMakefile#pkg_config): append --cflags to also diff --git a/lib/mkmf.rb b/lib/mkmf.rb index 99fe5d4a6aed68..b408ed780f8df9 100644 --- a/lib/mkmf.rb +++ b/lib/mkmf.rb @@ -1906,7 +1906,7 @@ def configuration(srcdir) INCFLAGS = -I. #$INCFLAGS DEFS = #{CONFIG['DEFS']} CPPFLAGS = #{extconf_h}#{$CPPFLAGS} -CXXFLAGS = $(CCDLFLAGS) #{CONFIG['CXXFLAGS']} $(ARCH_FLAG) +CXXFLAGS = $(CCDLFLAGS) #$CXXFLAGS $(ARCH_FLAG) ldflags = #{$LDFLAGS} dldflags = #{$DLDFLAGS} #{CONFIG['EXTDLDFLAGS']} ARCH_FLAG = #{$ARCH_FLAG} @@ -2399,6 +2399,7 @@ def init_mkmf(config = CONFIG, rbconfig = RbConfig::CONFIG) $warnflags = config['warnflags'] unless $extmk end $CFLAGS = with_config("cflags", arg_config("CFLAGS", config["CFLAGS"])).dup + $CXXFLAGS = (with_config("cxxflags", arg_config("CXXFLAGS", config["CXXFLAGS"]))||'').dup $ARCH_FLAG = with_config("arch_flag", arg_config("ARCH_FLAG", config["ARCH_FLAG"])).dup $CPPFLAGS = with_config("cppflags", arg_config("CPPFLAGS", config["CPPFLAGS"])).dup $LDFLAGS = with_config("ldflags", arg_config("LDFLAGS", config["LDFLAGS"])).dup diff --git a/version.h b/version.h index 76c25a122a32a3..379782ee44db32 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-09-15" -#define RUBY_PATCHLEVEL 237 +#define RUBY_PATCHLEVEL 238 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 9 From eba7b76c4c238532ddc73f2df907e587d95139f7 Mon Sep 17 00:00:00 2001 From: nagachika Date: Mon, 15 Sep 2014 13:33:17 +0000 Subject: [PATCH 240/343] merge revision(s) r47590: [Backport #10241] * ext/fiddle/lib/fiddle/import.rb (Fiddle::Importer#sizeof): fix typo, SIZEOF_LONG_LON. [Fix GH-714] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47595 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ ext/fiddle/lib/fiddle/import.rb | 2 +- test/fiddle/test_import.rb | 9 +++++++++ version.h | 2 +- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6dd8aa55679caf..88866e64ca4f46 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Mon Sep 15 22:31:33 2014 Sho Hashimoto + + * ext/fiddle/lib/fiddle/import.rb (Fiddle::Importer#sizeof): fix typo, + SIZEOF_LONG_LON. [Fix GH-714] + Mon Sep 15 11:08:23 2014 Shota Fukumori * lib/mkmf.rb (configuration): Make CXXFLAGS customizable. diff --git a/ext/fiddle/lib/fiddle/import.rb b/ext/fiddle/lib/fiddle/import.rb index 8b948e8f2358a0..ec5ee94dcf0807 100644 --- a/ext/fiddle/lib/fiddle/import.rb +++ b/ext/fiddle/lib/fiddle/import.rb @@ -112,7 +112,7 @@ def sizeof(ty) when TYPE_LONG return SIZEOF_LONG when TYPE_LONG_LONG - return SIZEOF_LONG_LON + return SIZEOF_LONG_LONG when TYPE_FLOAT return SIZEOF_FLOAT when TYPE_DOUBLE diff --git a/test/fiddle/test_import.rb b/test/fiddle/test_import.rb index 62985cfcd30c3a..d06477bfa51502 100644 --- a/test/fiddle/test_import.rb +++ b/test/fiddle/test_import.rb @@ -65,6 +65,15 @@ def test_sizeof() assert_equal(LIBC::MyStruct.size(), LIBC.sizeof(LIBC::MyStruct.malloc())) end + Fiddle.constants.grep(/\ATYPE_(?!VOID\z)(.*)/) do + type = $& + size = Fiddle.const_get("SIZEOF_#{$1}") + name = $1.sub(/P\z/,"*").gsub(/_(?!T\z)/, " ").downcase + define_method("test_sizeof_#{name}") do + assert_equal(size, Fiddle::Importer.sizeof(name), type) + end + end + def test_unsigned_result() d = (2 ** 31) + 1 diff --git a/version.h b/version.h index 379782ee44db32..4cf2979696c274 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-09-15" -#define RUBY_PATCHLEVEL 238 +#define RUBY_PATCHLEVEL 239 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 9 From e54ec54d2d9303e9a43b90aef8e009758d51b061 Mon Sep 17 00:00:00 2001 From: nagachika Date: Mon, 15 Sep 2014 14:11:00 +0000 Subject: [PATCH 241/343] merge revision(s) r47591: [Backport #10242] * ext/pathname/lib/pathname.rb (SAME_PATHS): Pathname#relative_path_from uses String#casecmp to compare strings on case-insensitive filesystem platforms (e.g., Windows). This can return nil for strings with different encodings, and the code previously assumed that it always returned a Fixnum. [Fix GH-713] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47596 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ ext/pathname/lib/pathname.rb | 3 ++- test/pathname/test_pathname.rb | 13 +++++++++++++ version.h | 2 +- 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 88866e64ca4f46..35c8464d99569f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Mon Sep 15 22:34:39 2014 Natalie Weizenbaum + + * ext/pathname/lib/pathname.rb (SAME_PATHS): + Pathname#relative_path_from uses String#casecmp to compare strings + on case-insensitive filesystem platforms (e.g., Windows). This can + return nil for strings with different encodings, and the code + previously assumed that it always returned a Fixnum. [Fix GH-713] + Mon Sep 15 22:31:33 2014 Sho Hashimoto * ext/fiddle/lib/fiddle/import.rb (Fiddle::Importer#sizeof): fix typo, diff --git a/ext/pathname/lib/pathname.rb b/ext/pathname/lib/pathname.rb index e7e47ceac64d9f..8bce81ea1046bf 100644 --- a/ext/pathname/lib/pathname.rb +++ b/ext/pathname/lib/pathname.rb @@ -22,7 +22,8 @@ class Pathname end SAME_PATHS = if File::FNM_SYSCASE.nonzero? - proc {|a, b| a.casecmp(b).zero?} + # Avoid #zero? here because #casecmp can return nil. + proc {|a, b| a.casecmp(b) == 0} else proc {|a, b| a == b} end diff --git a/test/pathname/test_pathname.rb b/test/pathname/test_pathname.rb index c61e613d9b5259..557fae35bcf43e 100644 --- a/test/pathname/test_pathname.rb +++ b/test/pathname/test_pathname.rb @@ -1322,4 +1322,17 @@ def test_file_join assert_equal("foo/bar", File.join(Pathname.new("foo"), Pathname.new("bar").taint)) }.call end + + def test_relative_path_from_casefold + assert_separately([], <<-'end;') # do + module File::Constants + remove_const :FNM_SYSCASE + FNM_SYSCASE = FNM_CASEFOLD + end + require 'pathname' + foo = Pathname.new("fo\u{f6}") + bar = Pathname.new("b\u{e4}r".encode("ISO-8859-1")) + assert_instance_of(Pathname, foo.relative_path_from(bar)) + end; + end end diff --git a/version.h b/version.h index 4cf2979696c274..9c7b05d8a053e1 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-09-15" -#define RUBY_PATCHLEVEL 239 +#define RUBY_PATCHLEVEL 240 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 9 From 155b12e673516db1d499af7789a235846eb24a27 Mon Sep 17 00:00:00 2001 From: nagachika Date: Mon, 15 Sep 2014 14:23:13 +0000 Subject: [PATCH 242/343] merge revision(s) r46495,r46499: [Backport #9971] signal.c: no cfunc frame at stack overflow * signal.c (check_stack_overflow): avoid pushing a cfunc frame, trying to fix stack overflow deadlock. * signal.c (check_stack_overflow): drop the last tag too close to the fault page, to get rid of stack overflow deadlock. [Bug #9971] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47597 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ signal.c | 11 +++++++++-- version.h | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 35c8464d99569f..92dc8ea020a51e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Mon Sep 15 23:12:47 2014 Nobuyoshi Nakada + + * signal.c (check_stack_overflow): drop the last tag too close to + the fault page, to get rid of stack overflow deadlock. + [Bug #9971] + Mon Sep 15 22:34:39 2014 Natalie Weizenbaum * ext/pathname/lib/pathname.rb (SAME_PATHS): diff --git a/signal.c b/signal.c index 1524885eb5ac72..82fad956df7ac5 100644 --- a/signal.c +++ b/signal.c @@ -711,7 +711,14 @@ check_stack_overflow(const uintptr_t addr, const ucontext_t *ctx) /* SP in ucontext is not decremented yet when `push` failed, so * the fault page can be the next. */ if (sp_page == fault_page || sp_page == fault_page + 1) { - ruby_thread_stack_overflow(GET_THREAD()); + rb_thread_t *th = ruby_current_thread; + if ((uintptr_t)th->tag->buf / pagesize == sp_page) { + /* drop the last tag if it is close to the fault, + * otherwise it can cause stack overflow again at the same + * place. */ + th->tag = th->tag->prev; + } + ruby_thread_stack_overflow(th); } } #else @@ -719,7 +726,7 @@ static void check_stack_overflow(const void *addr) { int ruby_stack_overflowed_p(const rb_thread_t *, const void *); - rb_thread_t *th = GET_THREAD(); + rb_thread_t *th = ruby_current_thread; if (ruby_stack_overflowed_p(th, addr)) { ruby_thread_stack_overflow(th); } diff --git a/version.h b/version.h index 9c7b05d8a053e1..3a72a30b2f56eb 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-09-15" -#define RUBY_PATCHLEVEL 240 +#define RUBY_PATCHLEVEL 241 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 9 From 95c472c9d2821ca676bd8729924b6b29ff120a96 Mon Sep 17 00:00:00 2001 From: nagachika Date: Thu, 18 Sep 2014 16:55:05 +0000 Subject: [PATCH 243/343] * version.h (RUBY_VERSION): bump RUBY_VERSION to 2.1.3. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47629 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ version.h | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 92dc8ea020a51e..744eec898bfd01 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Fri Sep 19 00:58:34 2014 CHIKANAGA Tomoyuki + + * version.h (RUBY_VERSION): bump RUBY_VERSION to 2.1.3. + Mon Sep 15 23:12:47 2014 Nobuyoshi Nakada * signal.c (check_stack_overflow): drop the last tag too close to diff --git a/version.h b/version.h index 3a72a30b2f56eb..8666e8c411f39f 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ -#define RUBY_VERSION "2.1.2" -#define RUBY_RELEASE_DATE "2014-09-15" -#define RUBY_PATCHLEVEL 241 +#define RUBY_VERSION "2.1.3" +#define RUBY_RELEASE_DATE "2014-09-19" +#define RUBY_PATCHLEVEL 242 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 9 -#define RUBY_RELEASE_DAY 15 +#define RUBY_RELEASE_DAY 19 #include "ruby/version.h" From 265c1680960a55a302f10d042d88c68957cd8664 Mon Sep 17 00:00:00 2001 From: nagachika Date: Tue, 23 Sep 2014 16:58:03 +0000 Subject: [PATCH 244/343] * version.h (RUBY_VERSION): bump RUBY_VERSION to 2.1.4. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47699 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ version.h | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 744eec898bfd01..5c1a5d7e9e2c09 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Wed Sep 24 01:43:13 2014 CHIKANAGA Tomoyuki + + * version.h (RUBY_VERSION): bump RUBY_VERSION to 2.1.4. + Fri Sep 19 00:58:34 2014 CHIKANAGA Tomoyuki * version.h (RUBY_VERSION): bump RUBY_VERSION to 2.1.3. diff --git a/version.h b/version.h index 8666e8c411f39f..c6b60511d3062e 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ -#define RUBY_VERSION "2.1.3" -#define RUBY_RELEASE_DATE "2014-09-19" -#define RUBY_PATCHLEVEL 242 +#define RUBY_VERSION "2.1.4" +#define RUBY_RELEASE_DATE "2014-09-24" +#define RUBY_PATCHLEVEL 243 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 9 -#define RUBY_RELEASE_DAY 19 +#define RUBY_RELEASE_DAY 24 #include "ruby/version.h" From 1ee1a2bddd1547cf02f22a14347744c7a88ca71a Mon Sep 17 00:00:00 2001 From: nagachika Date: Tue, 23 Sep 2014 17:07:16 +0000 Subject: [PATCH 245/343] merge revision(s) r47111,r47212,r47451,r47452,r47680: [Backport #10245] * test/minitest/test_minitest_unit.rb: removed obsoleted condition for Ruby 1.8. * test/ruby/test_time_tz.rb: ditto. * test/ruby/test_time_tz.rb: Fix test error with tzdata-2014g. [ruby-core:65058] [Bug #10245] Reported by Vit Ondruch. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 11 +++ test/minitest/test_minitest_unit.rb | 6 +- test/ruby/test_time_tz.rb | 145 +++++++++++++++++++--------- version.h | 2 +- 4 files changed, 112 insertions(+), 52 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5c1a5d7e9e2c09..d609a002471122 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +Wed Sep 24 02:06:33 2014 Tanaka Akira + + * test/ruby/test_time_tz.rb: Fix test error with tzdata-2014g. + [ruby-core:65058] [Bug #10245] Reported by Vit Ondruch. + +Wed Sep 24 02:06:33 2014 SHIBATA Hiroshi + + * test/minitest/test_minitest_unit.rb: removed obsoleted condition + for Ruby 1.8. + * test/ruby/test_time_tz.rb: ditto. + Wed Sep 24 01:43:13 2014 CHIKANAGA Tomoyuki * version.h (RUBY_VERSION): bump RUBY_VERSION to 2.1.4. diff --git a/test/minitest/test_minitest_unit.rb b/test/minitest/test_minitest_unit.rb index 0f29614e87cfd7..207b12f6392ed6 100644 --- a/test/minitest/test_minitest_unit.rb +++ b/test/minitest/test_minitest_unit.rb @@ -197,11 +197,7 @@ def test_omg; assert true; end end def util_expand_bt bt - if RUBY_VERSION >= '1.9.0' then - bt.map { |f| (f =~ /^\./) ? File.expand_path(f) : f } - else - bt - end + bt.map { |f| (f =~ /^\./) ? File.expand_path(f) : f } end end diff --git a/test/ruby/test_time_tz.rb b/test/ruby/test_time_tz.rb index bb69af87b48a43..533ceb3d8e0031 100644 --- a/test/ruby/test_time_tz.rb +++ b/test/ruby/test_time_tz.rb @@ -2,34 +2,43 @@ class TestTimeTZ < Test::Unit::TestCase has_right_tz = true + has_lisbon_tz = true force_tz_test = ENV["RUBY_FORCE_TIME_TZ_TEST"] == "yes" case RUBY_PLATFORM when /linux/ force_tz_test = true when /darwin|freebsd/ - has_right_tz = false + has_lisbon_tz = false force_tz_test = true end if force_tz_test - def with_tz(tz) - old = ENV["TZ"] - begin - ENV["TZ"] = tz - yield - ensure - ENV["TZ"] = old + module Util + def with_tz(tz) + old = ENV["TZ"] + begin + ENV["TZ"] = tz + yield + ensure + ENV["TZ"] = old + end end end else - def with_tz(tz) - if ENV["TZ"] == tz - yield + module Util + def with_tz(tz) + if ENV["TZ"] == tz + yield + end end end end module Util + def have_tz_offset?(tz) + with_tz(tz) {!Time.now.utc_offset.zero?} + end + def format_gmtoff(gmtoff, colon=false) if gmtoff < 0 expected = "-" @@ -72,14 +81,11 @@ def group_by(e, &block) include Util extend Util - if RUBY_VERSION < "1.9" - def time_to_s(t) - t.strftime("%Y-%m-%d %H:%M:%S ") + format_gmtoff(t.gmtoff) - end - else - def time_to_s(t) - t.to_s - end + has_right_tz &&= have_tz_offset?("right/America/Los_Angeles") + has_lisbon_tz &&= have_tz_offset?("Europe/Lisbon") + + def time_to_s(t) + t.to_s end @@ -153,7 +159,7 @@ def test_europe_lisbon with_tz(tz="Europe/Lisbon") { assert_equal("LMT", Time.new(-0x1_0000_0000_0000_0000).zone) } - end if has_right_tz + end if has_lisbon_tz def test_europe_moscow with_tz(tz="Europe/Moscow") { @@ -200,35 +206,42 @@ def self.gen_test_name(hint) s.sub(/gen_/) { "gen" + "_#{hint}_".gsub(/[^0-9A-Za-z]+/, '_') } end + def self.parse_zdump_line(line) + return nil if /\A\#/ =~ line || /\A\s*\z/ =~ line + if /\A(\S+)\s+ + \S+\s+(\S+)\s+(\d+)\s+(\d\d):(\d\d):(\d\d)\s+(\d+)\s+UTC? + \s+=\s+ + \S+\s+(\S+)\s+(\d+)\s+(\d\d):(\d\d):(\d\d)\s+(\d+)\s+\S+ + \s+isdst=\d+\s+gmtoff=(-?\d+)\n + \z/x !~ line + raise "unexpected zdump line: #{line.inspect}" + end + tz, u_mon, u_day, u_hour, u_min, u_sec, u_year, + l_mon, l_day, l_hour, l_min, l_sec, l_year, gmtoff = $~.captures + u_year = u_year.to_i + u_mon = MON2NUM[u_mon] + u_day = u_day.to_i + u_hour = u_hour.to_i + u_min = u_min.to_i + u_sec = u_sec.to_i + l_year = l_year.to_i + l_mon = MON2NUM[l_mon] + l_day = l_day.to_i + l_hour = l_hour.to_i + l_min = l_min.to_i + l_sec = l_sec.to_i + gmtoff = gmtoff.to_i + [tz, + [u_year, u_mon, u_day, u_hour, u_min, u_sec], + [l_year, l_mon, l_day, l_hour, l_min, l_sec], + gmtoff] + end + def self.gen_zdump_test(data) sample = [] data.each_line {|line| - next if /\A\#/ =~ line || /\A\s*\z/ =~ line - /\A(\S+)\s+ - \S+\s+(\S+)\s+(\d+)\s+(\d\d):(\d\d):(\d\d)\s+(\d+)\s+UTC - \s+=\s+ - \S+\s+(\S+)\s+(\d+)\s+(\d\d):(\d\d):(\d\d)\s+(\d+)\s+\S+ - \s+isdst=\d+\s+gmtoff=(-?\d+)\n - \z/x =~ line - tz, u_mon, u_day, u_hour, u_min, u_sec, u_year, - l_mon, l_day, l_hour, l_min, l_sec, l_year, gmtoff = $~.captures - u_year = u_year.to_i - u_mon = MON2NUM[u_mon] - u_day = u_day.to_i - u_hour = u_hour.to_i - u_min = u_min.to_i - u_sec = u_sec.to_i - l_year = l_year.to_i - l_mon = MON2NUM[l_mon] - l_day = l_day.to_i - l_hour = l_hour.to_i - l_min = l_min.to_i - l_sec = l_sec.to_i - gmtoff = gmtoff.to_i - sample << [tz, - [u_year, u_mon, u_day, u_hour, u_min, u_sec], - [l_year, l_mon, l_day, l_hour, l_min, l_sec], - gmtoff] + s = parse_zdump_line(line) + sample << s if s } sample.each {|tz, u, l, gmtoff| expected_utc = "%04d-%02d-%02d %02d:%02d:%02d UTC" % u @@ -249,6 +262,7 @@ def self.gen_zdump_test(data) } } } + group_by(sample) {|tz, _, _, _| tz }.each {|tz, a| a.each_with_index {|(_, u, l, gmtoff), i| expected = "%04d-%02d-%02d %02d:%02d:%02d %s" % (l+[format_gmtoff(gmtoff)]) @@ -348,6 +362,45 @@ def self.gen_zdump_test(data) #right/Asia/Tokyo Sat Dec 31 23:59:60 2005 UTC = Sun Jan 1 08:59:60 2006 JST isdst=0 gmtoff=32400 right/Europe/Paris Fri Jun 30 23:59:60 1972 UTC = Sat Jul 1 00:59:60 1972 CET isdst=0 gmtoff=3600 right/Europe/Paris Wed Dec 31 23:59:60 2008 UTC = Thu Jan 1 00:59:60 2009 CET isdst=0 gmtoff=3600 +End + + def self.gen_variational_zdump_test(hint, data) + sample = [] + data.each_line {|line| + s = parse_zdump_line(line) + sample << s if s + } + + define_method(gen_test_name(hint)) { + results = [] + sample.each {|tz, u, l, gmtoff| + expected_utc = "%04d-%02d-%02d %02d:%02d:%02d UTC" % u + expected = "%04d-%02d-%02d %02d:%02d:%02d %s" % (l+[format_gmtoff(gmtoff)]) + mesg_utc = "TZ=#{tz} Time.utc(#{u.map {|arg| arg.inspect }.join(', ')})" + mesg = "#{mesg_utc}.localtime" + with_tz(tz) { + t = nil + assert_nothing_raised(mesg) { t = Time.utc(*u) } + assert_equal(expected_utc, time_to_s(t), mesg_utc) + assert_nothing_raised(mesg) { t.localtime } + + results << [ + expected == time_to_s(t), + gmtoff == t.gmtoff, + format_gmtoff(gmtoff) == t.strftime("%z"), + format_gmtoff(gmtoff, true) == t.strftime("%:z"), + format_gmtoff2(gmtoff) == t.strftime("%::z") + ] + } + } + assert_includes(results, [true, true, true, true, true]) + } + end + + # tzdata-2014g fixed the offset for lisbon from -0:36:32 to -0:36:45. + # [ruby-core:65058] [Bug #10245] + gen_variational_zdump_test "lisbon", <<'End' if has_lisbon_tz Europe/Lisbon Mon Jan 1 00:36:31 1912 UTC = Sun Dec 31 23:59:59 1911 LMT isdst=0 gmtoff=-2192 +Europe/Lisbon Mon Jan 1 00:36:44 1912 UT = Sun Dec 31 23:59:59 1911 LMT isdst=0 gmtoff=-2205 End end diff --git a/version.h b/version.h index c6b60511d3062e..3476d73246447b 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.4" #define RUBY_RELEASE_DATE "2014-09-24" -#define RUBY_PATCHLEVEL 243 +#define RUBY_PATCHLEVEL 244 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 9 From 57fd50137177d0eb08d6acc48b460eaf87df746d Mon Sep 17 00:00:00 2001 From: nagachika Date: Tue, 23 Sep 2014 17:18:59 +0000 Subject: [PATCH 246/343] merge revision(s) r47683: [Backport #10281] array.c: GC guard * array.c (rb_ary_splice): prevent replacing array from GC. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47701 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- array.c | 1 + version.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/array.c b/array.c index 3d2409340c8ea1..79f7d3b5373b4e 100644 --- a/array.c +++ b/array.c @@ -1585,6 +1585,7 @@ rb_ary_splice(VALUE ary, long beg, long len, VALUE rpl) MEMMOVE(RARRAY_PTR(ary) + beg, RARRAY_CONST_PTR(rpl), VALUE, rlen); } } + RB_GC_GUARD(rpl); } void diff --git a/version.h b/version.h index 3476d73246447b..ebd55759bbb281 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.4" #define RUBY_RELEASE_DATE "2014-09-24" -#define RUBY_PATCHLEVEL 244 +#define RUBY_PATCHLEVEL 245 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 9 From 514b5e8d6ffd1957c71d659d9763dc600b4cb6d6 Mon Sep 17 00:00:00 2001 From: nagachika Date: Tue, 23 Sep 2014 17:22:03 +0000 Subject: [PATCH 247/343] merge revision(s) r47641,r47642,r47644: [Backport #10262] * win32/win32.c (VCSUP): nothing to do if this worktree is not under any VCS (it means that the worktree may be from the release package). * win32/Makefile.sub (VCSUP): nothing to do if this worktree is not under any VCS (it means that the worktree may be from the release package). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47702 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ version.h | 2 +- win32/Makefile.sub | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index d609a002471122..638994812bd990 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Wed Sep 24 02:21:41 2014 NAKAMURA Usaku + + * win32/Makefile.sub (VCSUP): nothing to do if this worktree is not + under any VCS (it means that the worktree may be from the release + package). + Wed Sep 24 02:06:33 2014 Tanaka Akira * test/ruby/test_time_tz.rb: Fix test error with tzdata-2014g. diff --git a/version.h b/version.h index ebd55759bbb281..7f6a16230da023 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.4" #define RUBY_RELEASE_DATE "2014-09-24" -#define RUBY_PATCHLEVEL 245 +#define RUBY_PATCHLEVEL 246 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 9 diff --git a/win32/Makefile.sub b/win32/Makefile.sub index d6289bc53d381f..e393b46253d8fc 100644 --- a/win32/Makefile.sub +++ b/win32/Makefile.sub @@ -377,6 +377,8 @@ VCSUP = $(VCS) rebase $(GITSVNREBASEOPTIONS) !else if exist($(srcdir)/.git) VCS = git VCSUP = $(VCS) pull $(GITPULLOPTIONS) +!else +VCSUP = rem !endif ruby_pc = $(RUBY_BASE_NAME)-$(MAJOR).$(MINOR).pc From b247743048c50efd3d7203b9513e44c63bbb6c43 Mon Sep 17 00:00:00 2001 From: nagachika Date: Tue, 23 Sep 2014 17:39:48 +0000 Subject: [PATCH 248/343] merge revision(s) r47696,r47697: [Backport #10279] * parse.y (parse_ident): just after a label, new expression should start, cannot be a modifier. [ruby-core:65211] [Bug #10279] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ parse.y | 2 +- test/ruby/test_keyword.rb | 14 ++++++++++++++ version.h | 2 +- 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 638994812bd990..d0d4a03105eb52 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed Sep 24 02:30:55 2014 Nobuyoshi Nakada + + * parse.y (parse_ident): just after a label, new expression should + start, cannot be a modifier. [ruby-core:65211] [Bug #10279] + Wed Sep 24 02:21:41 2014 NAKAMURA Usaku * win32/Makefile.sub (VCSUP): nothing to do if this worktree is not diff --git a/parse.y b/parse.y index 5991376820c8cb..37e3cbdcd6e5da 100644 --- a/parse.y +++ b/parse.y @@ -8195,7 +8195,7 @@ parser_yylex(struct parser_params *parser) return keyword_do_block; return keyword_do; } - if (IS_lex_state_for(state, (EXPR_BEG | EXPR_VALUE))) + if (IS_lex_state_for(state, (EXPR_BEG | EXPR_VALUE | EXPR_LABELARG))) return kw->id[0]; else { if (kw->id[0] != kw->id[1]) diff --git a/test/ruby/test_keyword.rb b/test/ruby/test_keyword.rb index 0930cf0f5d0868..e7bd11b18b0beb 100644 --- a/test/ruby/test_keyword.rb +++ b/test/ruby/test_keyword.rb @@ -325,7 +325,9 @@ def test_required_keyword assert_equal([[:keyreq, :a], [:keyrest, :b]], o.method(:bar).parameters, feature7701) assert_raise_with_message(ArgumentError, /missing keyword/, bug8139) {o.bar(c: bug8139)} assert_raise_with_message(ArgumentError, /missing keyword/, bug8139) {o.bar} + end + def test_required_keyword_with_newline bug9669 = '[ruby-core:61658] [Bug #9669]' assert_nothing_raised(SyntaxError, bug9669) do eval(<<-'end;', nil, __FILE__, __LINE__) @@ -335,6 +337,7 @@ def bug9669.foo a: end; end assert_equal(42, bug9669.foo(a: 42)) + o = nil assert_nothing_raised(SyntaxError, bug9669) do eval(<<-'end;', nil, __FILE__, __LINE__) o = { @@ -346,6 +349,17 @@ def bug9669.foo a: assert_equal({a: 1}, o, bug9669) end + def test_required_keyword_with_reserved + bug10279 = '[ruby-core:65211] [Bug #10279]' + h = nil + assert_nothing_raised(SyntaxError, bug10279) do + break eval(<<-'end;', nil, __FILE__, __LINE__) + h = {a: if true then 42 end} + end; + end + assert_equal({a: 42}, h, bug10279) + end + def test_block_required_keyword feature7701 = '[ruby-core:51454] [Feature #7701] required keyword argument' b = assert_nothing_raised(SyntaxError, feature7701) do diff --git a/version.h b/version.h index 7f6a16230da023..b25ed3f6ba05c2 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.4" #define RUBY_RELEASE_DATE "2014-09-24" -#define RUBY_PATCHLEVEL 246 +#define RUBY_PATCHLEVEL 247 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 9 From 7f6aaba7c0c6ff9abe6c38b4c083a509c2ca1b4c Mon Sep 17 00:00:00 2001 From: nagachika Date: Wed, 15 Oct 2014 14:06:27 +0000 Subject: [PATCH 249/343] merge revision(s) r47820: [Backport #10330] * error.c: update exception tree. [DOC] reported by @hemge via twitter. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47944 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ error.c | 11 +++++++---- version.h | 8 ++++---- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index d0d4a03105eb52..6f77b75fc834a0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed Oct 15 22:46:52 2014 NAKAMURA Usaku + + * error.c: update exception tree. [DOC] + reported by @hemge via twitter. + Wed Sep 24 02:30:55 2014 Nobuyoshi Nakada * parse.y (parse_ident): just after a label, new expression should diff --git a/error.c b/error.c index d533a3bf4b1ef1..e90f9b410a92b9 100644 --- a/error.c +++ b/error.c @@ -1740,14 +1740,18 @@ syserr_eqq(VALUE self, VALUE exc) * * LoadError * * NotImplementedError * * SyntaxError + * * SecurityError * * SignalException * * Interrupt * * StandardError -- default for +rescue+ * * ArgumentError - * * IndexError - * * StopIteration + * * EncodingError + * * FiberError * * IOError * * EOFError + * * IndexError + * * KeyError + * * StopIteration * * LocalJumpError * * NameError * * NoMethodError @@ -1755,14 +1759,13 @@ syserr_eqq(VALUE self, VALUE exc) * * FloatDomainError * * RegexpError * * RuntimeError -- default for +raise+ - * * SecurityError * * SystemCallError * * Errno::* - * * SystemStackError * * ThreadError * * TypeError * * ZeroDivisionError * * SystemExit + * * SystemStackError * * fatal -- impossible to rescue */ diff --git a/version.h b/version.h index b25ed3f6ba05c2..daa270cffccbb2 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.4" -#define RUBY_RELEASE_DATE "2014-09-24" -#define RUBY_PATCHLEVEL 247 +#define RUBY_RELEASE_DATE "2014-10-15" +#define RUBY_PATCHLEVEL 248 #define RUBY_RELEASE_YEAR 2014 -#define RUBY_RELEASE_MONTH 9 -#define RUBY_RELEASE_DAY 24 +#define RUBY_RELEASE_MONTH 10 +#define RUBY_RELEASE_DAY 15 #include "ruby/version.h" From 54af7108b5905d4f5473d1731eb7c2decea6eb7f Mon Sep 17 00:00:00 2001 From: nagachika Date: Wed, 15 Oct 2014 14:08:15 +0000 Subject: [PATCH 250/343] merge revision(s) r47819: [Backport #9914] * configure.in: Fix typo. [Bug #9914] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47945 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ configure.in | 2 +- version.h | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6f77b75fc834a0..cdffa806f153a5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Wed Oct 15 23:08:02 2014 Rei Odaira + + * configure.in: Fix typo. [Bug #9914] + Wed Oct 15 22:46:52 2014 NAKAMURA Usaku * error.c: update exception tree. [DOC] diff --git a/configure.in b/configure.in index fc01f3b42526b0..1f6a044229724b 100644 --- a/configure.in +++ b/configure.in @@ -1165,7 +1165,7 @@ AS_CASE(["$target_os"], [ # AIX currently does not support a 32-bit call to posix_fadvise() # if _LARGE_FILES is defined. - ac_cv_posix_fadvise=no + ac_cv_func_posix_fadvise=no ]) ]) diff --git a/version.h b/version.h index daa270cffccbb2..311e5a266471e1 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.4" #define RUBY_RELEASE_DATE "2014-10-15" -#define RUBY_PATCHLEVEL 248 +#define RUBY_PATCHLEVEL 249 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 10 From 7ec073a8175001073d1d3ad4b78442e3b02e767e Mon Sep 17 00:00:00 2001 From: nagachika Date: Wed, 15 Oct 2014 14:10:21 +0000 Subject: [PATCH 251/343] merge revision(s) r47850: [Backport #10294] * dir.c (dir_s_aref): fix rdoc. `Dir.glob` allows an array but `Dir[]` not. the former accepts an optional parameter `flags`, while the latter accepts arbitrary number of arguments but no `flags`. [ruby-core:65265] [Bug #10294] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47946 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ dir.c | 2 -- version.h | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index cdffa806f153a5..a9586ff9c3a2dd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Wed Oct 15 23:10:07 2014 Nobuyoshi Nakada + + * dir.c (dir_s_aref): fix rdoc. `Dir.glob` allows an array but + `Dir[]` not. the former accepts an optional parameter `flags`, + while the latter accepts arbitrary number of arguments but no + `flags`. [ruby-core:65265] [Bug #10294] + Wed Oct 15 23:08:02 2014 Rei Odaira * configure.in: Fix typo. [Bug #9914] diff --git a/dir.c b/dir.c index 8492ce78d0327b..3188a9eb38c776 100644 --- a/dir.c +++ b/dir.c @@ -1784,11 +1784,9 @@ dir_globs(long argc, const VALUE *argv, int flags) /* * call-seq: - * Dir[ array ] -> array * Dir[ string [, string ...] ] -> array * * Equivalent to calling - * Dir.glob(array,0) and * Dir.glob([string,...],0). * */ diff --git a/version.h b/version.h index 311e5a266471e1..988ccb7b1648c6 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.4" #define RUBY_RELEASE_DATE "2014-10-15" -#define RUBY_PATCHLEVEL 249 +#define RUBY_PATCHLEVEL 250 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 10 From 43979d409f663f142a9eb1319ed1285d2da29a8d Mon Sep 17 00:00:00 2001 From: nagachika Date: Wed, 15 Oct 2014 14:12:22 +0000 Subject: [PATCH 252/343] merge revision(s) r47891: [Backport #10373] proc.c: method body GC guard * proc.c (rb_mod_define_method): guard method body to prevent its method entry from GC. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47947 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- proc.c | 1 + version.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/proc.c b/proc.c index cc4e71080c3e5b..e5b6e5313d905e 100644 --- a/proc.c +++ b/proc.c @@ -1666,6 +1666,7 @@ rb_mod_define_method(int argc, VALUE *argv, VALUE mod) if (noex == NOEX_MODFUNC) { rb_method_entry_set(rb_singleton_class(mod), id, method->me, NOEX_PUBLIC); } + RB_GC_GUARD(body); } else if (rb_obj_is_proc(body)) { rb_proc_t *proc; diff --git a/version.h b/version.h index 988ccb7b1648c6..1ce6b38ab58304 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.4" #define RUBY_RELEASE_DATE "2014-10-15" -#define RUBY_PATCHLEVEL 250 +#define RUBY_PATCHLEVEL 251 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 10 From b93e896d3703fe755b55162fcde4d4733a7ddbd2 Mon Sep 17 00:00:00 2001 From: nagachika Date: Wed, 15 Oct 2014 14:24:14 +0000 Subject: [PATCH 253/343] merge revision(s) r47896: [Backport #10369] * array.c (ary_recycle_hash): add RB_GC_GUARD (rb_ary_diff): remove volatile [Bug #10369] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47949 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ array.c | 3 ++- version.h | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index a9586ff9c3a2dd..23b8d106e4d010 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Wed Oct 15 23:13:43 2014 Eric Wong + + * array.c (ary_recycle_hash): add RB_GC_GUARD + (rb_ary_diff): remove volatile + [Bug #10369] + Wed Oct 15 23:10:07 2014 Nobuyoshi Nakada * dir.c (dir_s_aref): fix rdoc. `Dir.glob` allows an array but diff --git a/array.c b/array.c index 79f7d3b5373b4e..7760e3313e196d 100644 --- a/array.c +++ b/array.c @@ -3949,6 +3949,7 @@ ary_recycle_hash(VALUE hash) RHASH(hash)->ntbl = 0; st_free_table(tbl); } + RB_GC_GUARD(hash); } /* @@ -3972,7 +3973,7 @@ static VALUE rb_ary_diff(VALUE ary1, VALUE ary2) { VALUE ary3; - volatile VALUE hash; + VALUE hash; long i; hash = ary_make_hash(to_ary(ary2)); diff --git a/version.h b/version.h index 1ce6b38ab58304..85ff2c91177be1 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.4" #define RUBY_RELEASE_DATE "2014-10-15" -#define RUBY_PATCHLEVEL 251 +#define RUBY_PATCHLEVEL 252 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 10 From da85f4ee544634c66c32028018bb8042d00cd73b Mon Sep 17 00:00:00 2001 From: nagachika Date: Wed, 15 Oct 2014 14:47:38 +0000 Subject: [PATCH 254/343] merge revision(s) r45715: [Backport #10265] * configure.in: NetBSD's ksh, used by configure, needs escapes. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47952 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ configure.in | 2 +- version.h | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 23b8d106e4d010..9f2063870f8a6f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Wed Oct 15 23:25:24 2014 NARUSE, Yui + + * configure.in: NetBSD's ksh, used by configure, needs escapes. + Wed Oct 15 23:13:43 2014 Eric Wong * array.c (ary_recycle_hash): add RB_GC_GUARD diff --git a/configure.in b/configure.in index 1f6a044229724b..bb1ab8abd84a83 100644 --- a/configure.in +++ b/configure.in @@ -2092,7 +2092,7 @@ if test x$setjmp_prefix = xsig; then else unset setjmp_sigmask fi -AC_MSG_RESULT(${setjmp_prefix}setjmp${setjmp_suffix}${setjmp_cast:+($setjmp_cast)}) +AC_MSG_RESULT(${setjmp_prefix}setjmp${setjmp_suffix}${setjmp_cast:+\($setjmp_cast\)}) AC_DEFINE_UNQUOTED([RUBY_SETJMP(env)], [${setjmp_prefix}setjmp${setjmp_suffix}($setjmp_cast(env)${setjmp_sigmask+,0})]) AC_DEFINE_UNQUOTED([RUBY_LONGJMP(env,val)], [${setjmp_prefix}longjmp($setjmp_cast(env),val)]) AC_DEFINE_UNQUOTED(RUBY_JMP_BUF, ${setjmp_sigmask+${setjmp_prefix}}jmp_buf) diff --git a/version.h b/version.h index 85ff2c91177be1..a34f6bc45bb58f 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.4" #define RUBY_RELEASE_DATE "2014-10-15" -#define RUBY_PATCHLEVEL 252 +#define RUBY_PATCHLEVEL 253 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 10 From 3d22fe530bd605bfe2cbdadd024fcb37fbbcae16 Mon Sep 17 00:00:00 2001 From: nagachika Date: Wed, 15 Oct 2014 14:51:58 +0000 Subject: [PATCH 255/343] merge revision(s) r46783: [Backport #6716] * lib/fileutils.rb: handle ENOENT error with symlink targeted to non-exists file. [ruby-dev:45933] [Bug #6716] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47953 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ lib/fileutils.rb | 12 +++++++++--- test/fileutils/test_fileutils.rb | 6 ++++++ version.h | 2 +- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9f2063870f8a6f..1f65e70b03b0dc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed Oct 15 23:50:33 2014 SHIBATA Hiroshi + + * lib/fileutils.rb: handle ENOENT error with symlink targeted to + non-exists file. [ruby-dev:45933] [Bug #6716] + Wed Oct 15 23:25:24 2014 NARUSE, Yui * configure.in: NetBSD's ksh, used by configure, needs escapes. diff --git a/lib/fileutils.rb b/lib/fileutils.rb index 99044e2cd63114..335d60d4a259b2 100644 --- a/lib/fileutils.rb +++ b/lib/fileutils.rb @@ -854,7 +854,8 @@ def install(src, dest, options = {}) fu_check_options options, OPT_TABLE['install'] fu_output_message "install -c#{options[:preserve] && ' -p'}#{options[:mode] ? (' -m 0%o' % options[:mode]) : ''} #{[src,dest].flatten.join ' '}" if options[:verbose] return if options[:noop] - fu_each_src_dest(src, dest) do |s, d, st| + fu_each_src_dest(src, dest) do |s, d| + st = File.stat(s) unless File.exist?(d) and compare_file(s, d) remove_file d, true copy_file s, d @@ -1252,7 +1253,12 @@ def dereference? end def exist? - lstat! ? true : false + begin + lstat + true + rescue Errno::ENOENT + false + end end def file? @@ -1570,7 +1576,7 @@ def fu_list(arg) #:nodoc: def fu_each_src_dest(src, dest) #:nodoc: fu_each_src_dest0(src, dest) do |s, d| raise ArgumentError, "same file: #{s} and #{d}" if fu_same?(s, d) - yield s, d, File.stat(s) + yield s, d end end private_module_function :fu_each_src_dest diff --git a/test/fileutils/test_fileutils.rb b/test/fileutils/test_fileutils.rb index c5f8734fead116..6aa89c49eff03e 100644 --- a/test/fileutils/test_fileutils.rb +++ b/test/fileutils/test_fileutils.rb @@ -420,6 +420,12 @@ def test_mv_symlink assert_raise(Errno::ELOOP) { mv 'tmp/symlink', 'tmp/symlink' } + # unexist symlink + File.symlink 'xxx', 'tmp/src' + assert_nothing_raised { + mv 'tmp/src', 'tmp/dest' + } + assert_equal true, File.symlink?('tmp/dest') end if have_symlink? def test_mv_pathname diff --git a/version.h b/version.h index a34f6bc45bb58f..7dcdc5f5e7381a 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.4" #define RUBY_RELEASE_DATE "2014-10-15" -#define RUBY_PATCHLEVEL 253 +#define RUBY_PATCHLEVEL 254 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 10 From 4855b79e98bef2c01a80a20751e50ff6104b10ec Mon Sep 17 00:00:00 2001 From: nagachika Date: Wed, 15 Oct 2014 15:05:45 +0000 Subject: [PATCH 256/343] merge r47598 partially. extracted commits are as follows. [Bug #9728] https://github.com/k-takata/Onigmo/commit/15ddec6d18e27fdc1988236764e766fd5892ecf5 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47954 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ regcomp.c | 10 +++++++--- regexec.c | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1f65e70b03b0dc..7d5d1f48a11f2c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed Oct 15 23:58:13 2014 CHIKANAGA Tomoyuki + + merge r47598 partially. extracted commits are as follows. [Bug #9728] + https://github.com/k-takata/Onigmo/commit/15ddec6d18e27fdc1988236764e766fd5892ecf5 + Wed Oct 15 23:50:33 2014 SHIBATA Hiroshi * lib/fileutils.rb: handle ENOENT error with symlink targeted to diff --git a/regcomp.c b/regcomp.c index 705e0faad774ee..15d71f4906fe0c 100644 --- a/regcomp.c +++ b/regcomp.c @@ -4495,6 +4495,9 @@ concat_opt_anc_info(OptAncInfo* to, OptAncInfo* left, OptAncInfo* right, if (right_len == 0) { to->right_anchor |= left->right_anchor; } + else { + to->right_anchor |= (left->right_anchor & ANCHOR_PREC_READ_NOT); + } } static int @@ -5068,7 +5071,8 @@ optimize_node_left(Node* node, NodeOptInfo* opt, OptEnv* env) case ANCHOR_END_BUF: case ANCHOR_SEMI_END_BUF: case ANCHOR_END_LINE: - case ANCHOR_LOOK_BEHIND: /* just for (?<=x).* */ + case ANCHOR_LOOK_BEHIND: /* just for (?<=x).* */ + case ANCHOR_PREC_READ_NOT: /* just for (?!x).* */ add_opt_anc_info(&opt->anc, NANCHOR(node)->type); break; @@ -5091,7 +5095,6 @@ optimize_node_left(Node* node, NodeOptInfo* opt, OptEnv* env) } break; - case ANCHOR_PREC_READ_NOT: case ANCHOR_LOOK_BEHIND_NOT: break; } @@ -5357,7 +5360,8 @@ set_optimize_info_from_tree(Node* node, regex_t* reg, ScanEnv* scan_env) ANCHOR_BEGIN_POSITION | ANCHOR_ANYCHAR_STAR | ANCHOR_ANYCHAR_STAR_ML | ANCHOR_LOOK_BEHIND); - reg->anchor |= opt.anc.right_anchor & (ANCHOR_END_BUF | ANCHOR_SEMI_END_BUF); + reg->anchor |= opt.anc.right_anchor & (ANCHOR_END_BUF | ANCHOR_SEMI_END_BUF | + ANCHOR_PREC_READ_NOT); if (reg->anchor & (ANCHOR_END_BUF | ANCHOR_SEMI_END_BUF)) { reg->anchor_dmin = opt.len.min; diff --git a/regexec.c b/regexec.c index 973d3eac0004e6..6c5ba577606081 100644 --- a/regexec.c +++ b/regexec.c @@ -4184,7 +4184,7 @@ onig_search_gpos(regex_t* reg, const UChar* str, const UChar* end, prev = s; s += enclen(reg->enc, s, end); - if ((reg->anchor & ANCHOR_LOOK_BEHIND) == 0) { + if ((reg->anchor & (ANCHOR_LOOK_BEHIND | ANCHOR_PREC_READ_NOT)) == 0) { while (!ONIGENC_IS_MBC_NEWLINE_EX(reg->enc, prev, str, end, reg->options, 0) && s < range) { prev = s; From 9b9479b1b6742000f2ad1445ed2c1dcf6a897fbd Mon Sep 17 00:00:00 2001 From: svn Date: Wed, 15 Oct 2014 15:05:59 +0000 Subject: [PATCH 257/343] * 2014-10-16 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47955 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- version.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/version.h b/version.h index 7dcdc5f5e7381a..831485e550013c 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.4" -#define RUBY_RELEASE_DATE "2014-10-15" +#define RUBY_RELEASE_DATE "2014-10-16" #define RUBY_PATCHLEVEL 254 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 10 -#define RUBY_RELEASE_DAY 15 +#define RUBY_RELEASE_DAY 16 #include "ruby/version.h" From a732f344366688c17220989dce1cfe3cac156fe2 Mon Sep 17 00:00:00 2001 From: nagachika Date: Wed, 15 Oct 2014 15:18:04 +0000 Subject: [PATCH 258/343] merge revision(s) r47818,r47832: [Backport #9820] * signal.c (rb_f_kill): should not ignore signal unless the default handler is registered. [ruby-dev:48592] [Bug #9820] * signal.c (rb_f_kill): get rid of deadlock as unhandled and discarded signals do not make interrupt_cond signaled. based on the patch by Kazuki Tsujimoto at [ruby-dev:48606]. [Bug #9820] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47956 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 12 ++++++++++++ signal.c | 16 +++++++++++++--- test/ruby/test_signal.rb | 12 ++++++++++++ version.h | 2 +- 4 files changed, 38 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7d5d1f48a11f2c..1f00e4ebf519da 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +Thu Oct 16 00:10:45 2014 Nobuyoshi Nakada + + * signal.c (rb_f_kill): get rid of deadlock as unhandled and + discarded signals do not make interrupt_cond signaled. + based on the patch by Kazuki Tsujimoto at [ruby-dev:48606]. + [Bug #9820] + +Thu Oct 16 00:10:45 2014 Nobuyoshi Nakada + + * signal.c (rb_f_kill): should not ignore signal unless the + default handler is registered. [ruby-dev:48592] [Bug #9820] + Wed Oct 15 23:58:13 2014 CHIKANAGA Tomoyuki merge r47598 partially. extracted commits are as follows. [Bug #9728] diff --git a/signal.c b/signal.c index 82fad956df7ac5..3db044e517a2fd 100644 --- a/signal.c +++ b/signal.c @@ -343,6 +343,7 @@ ruby_default_signal(int sig) raise(sig); } +static RETSIGTYPE sighandler(int sig); static int signal_ignored(int sig); static void signal_enque(int sig); @@ -449,6 +450,7 @@ rb_f_kill(int argc, VALUE *argv) rb_pid_t pid = NUM2PIDT(argv[i]); if ((sig != 0) && (self != -1) && (pid == self)) { + int t; /* * When target pid is self, many caller assume signal will be * delivered immediately and synchronously. @@ -467,7 +469,12 @@ rb_f_kill(int argc, VALUE *argv) ruby_kill(pid, sig); break; default: - if (signal_ignored(sig)) break; + t = signal_ignored(sig); + if (t) { + if (t < 0 && kill(pid, sig)) + rb_sys_fail(0); + break; + } signal_enque(sig); wakeup = 1; } @@ -612,16 +619,19 @@ ruby_nativethread_signal(int signum, sighandler_t handler) static int signal_ignored(int sig) { + sighandler_t func; #ifdef POSIX_SIGNAL struct sigaction old; (void)VALGRIND_MAKE_MEM_DEFINED(&old, sizeof(old)); if (sigaction(sig, NULL, &old) < 0) return FALSE; - return old.sa_handler == SIG_IGN; + func = old.sa_handler; #else sighandler_t old = signal(sig, SIG_DFL); signal(sig, old); - return old == SIG_IGN; + func = old; #endif + if (func == SIG_IGN) return 1; + return func == sighandler ? 0 : -1; } static void diff --git a/test/ruby/test_signal.rb b/test/ruby/test_signal.rb index e329df9a341252..d3e8f864c97fad 100644 --- a/test/ruby/test_signal.rb +++ b/test/ruby/test_signal.rb @@ -278,5 +278,17 @@ def test_ignored_interrupt Process.kill(:INT, $$) end end; + + if trap = Signal.list['TRAP'] + bug9820 = '[ruby-dev:48592] [Bug #9820]' + status = assert_in_out_err(['-e', 'Process.kill(:TRAP, $$)']) + assert_predicate(status, :signaled?, bug9820) + assert_equal(trap, status.termsig, bug9820) + end + + if Signal.list['CONT'] + bug9820 = '[ruby-dev:48606] [Bug #9820]' + assert_ruby_status(['-e', 'Process.kill(:CONT, $$)']) + end end if Process.respond_to?(:kill) end diff --git a/version.h b/version.h index 831485e550013c..27189944d748bc 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.4" #define RUBY_RELEASE_DATE "2014-10-16" -#define RUBY_PATCHLEVEL 254 +#define RUBY_PATCHLEVEL 255 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 10 From 03a93ba48da930f0f35ac83da7853cd89f94a8f4 Mon Sep 17 00:00:00 2001 From: nagachika Date: Wed, 15 Oct 2014 15:28:55 +0000 Subject: [PATCH 259/343] merge revision(s) r47715: [Backport #10282] * object.c (rb_class_real): do not dereference 0 VALUE * test/ruby/test_module.rb (test_inspect_segfault): Test case and bug report by Thomas Stratmann. [ruby-core:65214] [Bug #10282] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47957 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ object.c | 5 ++--- test/ruby/test_module.rb | 24 ++++++++++++++++++++++++ version.h | 2 +- 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1f00e4ebf519da..0ba5dbd6f9a288 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Thu Oct 16 00:20:12 2014 Eric Wong + + * object.c (rb_class_real): do not dereference 0 VALUE + + * test/ruby/test_module.rb (test_inspect_segfault): + Test case and bug report by Thomas Stratmann. + [ruby-core:65214] [Bug #10282] + Thu Oct 16 00:10:45 2014 Nobuyoshi Nakada * signal.c (rb_f_kill): get rid of deadlock as unhandled and diff --git a/object.c b/object.c index 34eac51a1d1b15..0d7e03a95f1bd1 100644 --- a/object.c +++ b/object.c @@ -203,9 +203,8 @@ rb_obj_not_equal(VALUE obj1, VALUE obj2) VALUE rb_class_real(VALUE cl) { - if (cl == 0) - return 0; - while ((RBASIC(cl)->flags & FL_SINGLETON) || BUILTIN_TYPE(cl) == T_ICLASS) { + while (cl && + ((RBASIC(cl)->flags & FL_SINGLETON) || BUILTIN_TYPE(cl) == T_ICLASS)) { cl = RCLASS_SUPER(cl); } return cl; diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb index 372a2d4ca5d08e..050d17a5d3fd1c 100644 --- a/test/ruby/test_module.rb +++ b/test/ruby/test_module.rb @@ -1957,6 +1957,30 @@ def foo; end } end + def test_inspect_segfault + bug_10282 = '[ruby-core:65214] [Bug #10282]' + assert_separately [], <<-RUBY + module ShallowInspect + def shallow_inspect + "foo" + end + end + + module InspectIsShallow + include ShallowInspect + alias_method :inspect, :shallow_inspect + end + + class A + end + + A.prepend InspectIsShallow + + expect = "#" + assert_equal expect, A.new.method(:inspect).inspect, "#{bug_10282}" + RUBY + end + private def assert_top_method_is_private(method) diff --git a/version.h b/version.h index 27189944d748bc..e9dc8dc4c8a063 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.4" #define RUBY_RELEASE_DATE "2014-10-16" -#define RUBY_PATCHLEVEL 255 +#define RUBY_PATCHLEVEL 256 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 10 From c17ee1100763373f069a06adcdb85283e3f16626 Mon Sep 17 00:00:00 2001 From: nagachika Date: Wed, 15 Oct 2014 15:31:03 +0000 Subject: [PATCH 260/343] merge revision(s) r47900: [Backport #10035] * lib/find.rb (Find.find): Call to_path for arguments to obtain strings. [ruby-core:63713] [Bug #10035] Reported by Herwin. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47958 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ lib/find.rb | 1 + version.h | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 0ba5dbd6f9a288..d73611b9be2aa4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Thu Oct 16 00:30:30 2014 Tanaka Akira + + * lib/find.rb (Find.find): Call to_path for arguments to obtain + strings. + [ruby-core:63713] [Bug #10035] Reported by Herwin. + Thu Oct 16 00:20:12 2014 Eric Wong * object.c (rb_class_real): do not dereference 0 VALUE diff --git a/lib/find.rb b/lib/find.rb index 6f3e4282edbe82..d33c8bb16bc3e5 100644 --- a/lib/find.rb +++ b/lib/find.rb @@ -40,6 +40,7 @@ def find(*paths) # :yield: path fs_encoding = Encoding.find("filesystem") paths.collect!{|d| raise Errno::ENOENT unless File.exist?(d); d.dup}.each do |path| + path = path.to_path if path.respond_to? :to_path enc = path.encoding == Encoding::US_ASCII ? fs_encoding : path.encoding ps = [path] while file = ps.shift diff --git a/version.h b/version.h index e9dc8dc4c8a063..8c09c61a656004 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.4" #define RUBY_RELEASE_DATE "2014-10-16" -#define RUBY_PATCHLEVEL 256 +#define RUBY_PATCHLEVEL 257 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 10 From e0a5ccfec19b157f21a1780cc51e652353f9d0fd Mon Sep 17 00:00:00 2001 From: nagachika Date: Thu, 16 Oct 2014 13:06:10 +0000 Subject: [PATCH 261/343] merge revision(s) r47645: [Backport #10263] * vm_eval.c (eval_string_with_cref): fix super from eval with scope. set klass in the current control frame to the class of the receiver in the context to be evaluated, this class/module must match the actual receiver to call super. [ruby-core:65122] [Bug #10263] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47980 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ test/ruby/test_super.rb | 15 +++++++++++++++ version.h | 2 +- vm_eval.c | 3 ++- 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index d73611b9be2aa4..d07547843859a8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Thu Oct 16 22:06:03 2014 Nobuyoshi Nakada + + * vm_eval.c (eval_string_with_cref): fix super from eval with + scope. set klass in the current control frame to the class of + the receiver in the context to be evaluated, this class/module + must match the actual receiver to call super. + [ruby-core:65122] [Bug #10263] + Thu Oct 16 00:30:30 2014 Tanaka Akira * lib/find.rb (Find.find): Call to_path for arguments to obtain diff --git a/test/ruby/test_super.rb b/test/ruby/test_super.rb index e42782191dbd91..6278e4b88a523d 100644 --- a/test/ruby/test_super.rb +++ b/test/ruby/test_super.rb @@ -494,4 +494,19 @@ def foo(result) end assert_equal(%w[B A], result, bug9721) end + + def test_from_eval + bug10263 = '[ruby-core:65122] [Bug #10263a]' + a = Class.new do + def foo + "A" + end + end + b = Class.new(a) do + def foo + binding.eval("super") + end + end + assert_equal("A", b.new.foo, bug10263) + end end diff --git a/version.h b/version.h index 8c09c61a656004..07096cb19dea11 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.4" #define RUBY_RELEASE_DATE "2014-10-16" -#define RUBY_PATCHLEVEL 257 +#define RUBY_PATCHLEVEL 258 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 10 diff --git a/vm_eval.c b/vm_eval.c index cb0e637942d07a..dc0b05375b77fd 100644 --- a/vm_eval.c +++ b/vm_eval.c @@ -1211,7 +1211,7 @@ eval_string_with_cref(VALUE self, VALUE src, VALUE scope, NODE *const cref_arg, absolute_path = file; } - if (scope != Qnil) { + if (!NIL_P(scope)) { bind = Check_TypedStruct(scope, &ruby_binding_data_type); { envval = bind->env; @@ -1261,6 +1261,7 @@ eval_string_with_cref(VALUE self, VALUE src, VALUE scope, NODE *const cref_arg, COPY_CREF(cref, orig_cref); } vm_set_eval_stack(th, iseqval, cref, base_block); + th->cfp->klass = CLASS_OF(base_block->self); RB_GC_GUARD(crefval); if (0) { /* for debug */ From 10a4543f715747b92e578e2b8d869a96e53040f0 Mon Sep 17 00:00:00 2001 From: nagachika Date: Thu, 16 Oct 2014 13:19:07 +0000 Subject: [PATCH 262/343] merge revision(s) r47716: [Backport #10285] * ext/stringio/stringio.c (strio_write): ASCII-8BIT StringIO should be writable any encoding strings, without conversion. [ruby-core:65240] [Bug #10285] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47982 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ ext/stringio/stringio.c | 5 +++-- test/stringio/test_stringio.rb | 12 ++++++++++++ version.h | 2 +- 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index d07547843859a8..7e81db44b6a57b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Thu Oct 16 22:10:11 2014 Nobuyoshi Nakada + + * ext/stringio/stringio.c (strio_write): ASCII-8BIT StringIO + should be writable any encoding strings, without conversion. + [ruby-core:65240] [Bug #10285] + Thu Oct 16 22:06:03 2014 Nobuyoshi Nakada * vm_eval.c (eval_string_with_cref): fix super from eval with diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c index 1a12d298e14a4f..55563c3a69e009 100644 --- a/ext/stringio/stringio.c +++ b/ext/stringio/stringio.c @@ -1169,12 +1169,13 @@ strio_write(VALUE self, VALUE str) struct StringIO *ptr = writable(self); long len, olen; rb_encoding *enc, *enc2; + rb_encoding *const ascii8bit = rb_ascii8bit_encoding(); if (!RB_TYPE_P(str, T_STRING)) str = rb_obj_as_string(str); enc = rb_enc_get(ptr->string); enc2 = rb_enc_get(str); - if (enc != enc2 && enc != rb_ascii8bit_encoding()) { + if (enc != enc2 && enc != ascii8bit) { str = rb_str_conv_enc(str, enc2, enc); } len = RSTRING_LEN(str); @@ -1185,7 +1186,7 @@ strio_write(VALUE self, VALUE str) ptr->pos = olen; } if (ptr->pos == olen) { - if (enc2 == rb_ascii8bit_encoding()) { + if (enc == ascii8bit || enc2 == ascii8bit) { rb_enc_str_buf_cat(ptr->string, RSTRING_PTR(str), len, enc); OBJ_INFECT(ptr->string, str); } diff --git a/test/stringio/test_stringio.rb b/test/stringio/test_stringio.rb index 3fbe2f7ecac729..07d89d16e10743 100644 --- a/test/stringio/test_stringio.rb +++ b/test/stringio/test_stringio.rb @@ -137,6 +137,18 @@ def test_write_encoding assert_equal(Encoding::UTF_8, s.encoding, "honor the original encoding over ASCII-8BIT") end + def test_set_encoding + bug10285 = '[ruby-core:65240] [Bug #10285]' + f = StringIO.new() + f.set_encoding(Encoding::ASCII_8BIT) + f.write("quz \x83 mat".b) + s = "foo \x97 bar".force_encoding(Encoding::WINDOWS_1252) + assert_nothing_raised(Encoding::CompatibilityError, bug10285) { + f.write(s) + } + assert_equal(Encoding::ASCII_8BIT, f.string.encoding, bug10285) + end + def test_mode_error f = StringIO.new("", "r") assert_raise(IOError) { f.write("foo") } diff --git a/version.h b/version.h index 07096cb19dea11..eb2fb41212560b 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.4" #define RUBY_RELEASE_DATE "2014-10-16" -#define RUBY_PATCHLEVEL 258 +#define RUBY_PATCHLEVEL 259 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 10 From b090826d2affbafd84f3cf36b695188c13556534 Mon Sep 17 00:00:00 2001 From: nagachika Date: Sat, 18 Oct 2014 18:21:39 +0000 Subject: [PATCH 263/343] merge revision(s) r47973: [Backport #10392] * parse.y (parser_here_document): do not append already appended and disposed code fragment. [ruby-dev:48647] [Bug #10392] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@48003 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ parse.y | 5 ++++- test/ripper/test_scanner_events.rb | 4 ++++ version.h | 6 +++--- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7e81db44b6a57b..edd09d24f54ace 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sun Oct 19 03:13:38 2014 Nobuyoshi Nakada + + * parse.y (parser_here_document): do not append already appended + and disposed code fragment. [ruby-dev:48647] [Bug #10392] + Thu Oct 16 22:10:11 2014 Nobuyoshi Nakada * ext/stringio/stringio.c (strio_write): ASCII-8BIT StringIO diff --git a/parse.y b/parse.y index 37e3cbdcd6e5da..5c62e36d23cfd7 100644 --- a/parse.y +++ b/parse.y @@ -6547,7 +6547,10 @@ parser_here_document(struct parser_params *parser, NODE *here) if (pend < lex_pend) rb_str_cat(str, "\n", 1); lex_goto_eol(parser); if (nextc() == -1) { - if (str) dispose_string(str); + if (str) { + dispose_string(str); + str = 0; + } goto error; } } while (!whole_match_p(eos, len, indent)); diff --git a/test/ripper/test_scanner_events.rb b/test/ripper/test_scanner_events.rb index 2474588f764547..d444bb1042a068 100644 --- a/test/ripper/test_scanner_events.rb +++ b/test/ripper/test_scanner_events.rb @@ -708,6 +708,10 @@ def test_tstring_content_HEREDOC assert_equal ["there\n""heredoc", "\n"], scan('tstring_content', "<<""EOS\n""there\n""heredoc\#@foo\nEOS"), bug7255 + bug10392 = '[ruby-dev:48647] [Bug #10392]' + assert_equal [" E\n\n"], + scan('tstring_content', "<<""'E'\n E\n\n"), + bug10392 end def test_heredoc_end diff --git a/version.h b/version.h index eb2fb41212560b..ec4ffa5829c37c 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.4" -#define RUBY_RELEASE_DATE "2014-10-16" -#define RUBY_PATCHLEVEL 259 +#define RUBY_RELEASE_DATE "2014-10-19" +#define RUBY_PATCHLEVEL 260 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 10 -#define RUBY_RELEASE_DAY 16 +#define RUBY_RELEASE_DAY 19 #include "ruby/version.h" From 3e6dbba4e2eabbd639711054233c8325375cdf75 Mon Sep 17 00:00:00 2001 From: nagachika Date: Sat, 18 Oct 2014 18:35:31 +0000 Subject: [PATCH 264/343] merge revision(s) r48000: [Backport #10368] * vm_core.h, vm.c, proc.c: fix GC mark miss on bindings. [ruby-dev:48616] [Bug #10368] * test/ruby/test_eval.rb: add a test code. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@48004 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ proc.c | 36 ++++++++---------------------------- test/ruby/test_eval.rb | 15 +++++++++++++++ version.h | 2 +- vm.c | 37 ++++++++++++++++++++++++++++++++++++- vm_core.h | 3 +++ 6 files changed, 70 insertions(+), 30 deletions(-) diff --git a/ChangeLog b/ChangeLog index edd09d24f54ace..af9338fea46b98 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Sun Oct 19 03:22:53 2014 Kazuki Tsujimoto + + * vm_core.h, vm.c, proc.c: fix GC mark miss on bindings. + [ruby-dev:48616] [Bug #10368] + + * test/ruby/test_eval.rb: add a test code. + Sun Oct 19 03:13:38 2014 Nobuyoshi Nakada * parse.y (parser_here_document): do not append already appended diff --git a/proc.c b/proc.c index e5b6e5313d905e..66ffa4c0410f27 100644 --- a/proc.c +++ b/proc.c @@ -262,6 +262,7 @@ binding_mark(void *ptr) bind = ptr; RUBY_MARK_UNLESS_NULL(bind->env); RUBY_MARK_UNLESS_NULL(bind->path); + RUBY_MARK_UNLESS_NULL(bind->blockprocval); } RUBY_MARK_LEAVE("binding"); } @@ -282,8 +283,8 @@ const rb_data_type_t ruby_binding_data_type = { NULL, NULL, RUBY_TYPED_FREE_IMMEDIATELY }; -static VALUE -binding_alloc(VALUE klass) +VALUE +rb_binding_alloc(VALUE klass) { VALUE obj; rb_binding_t *bind; @@ -295,12 +296,13 @@ binding_alloc(VALUE klass) static VALUE binding_dup(VALUE self) { - VALUE bindval = binding_alloc(rb_cBinding); + VALUE bindval = rb_binding_alloc(rb_cBinding); rb_binding_t *src, *dst; GetBindingPtr(self, src); GetBindingPtr(bindval, dst); dst->env = src->env; dst->path = src->path; + dst->blockprocval = src->blockprocval; dst->first_lineno = src->first_lineno; return bindval; } @@ -317,30 +319,7 @@ binding_clone(VALUE self) VALUE rb_binding_new_with_cfp(rb_thread_t *th, const rb_control_frame_t *src_cfp) { - rb_control_frame_t *cfp = rb_vm_get_binding_creatable_next_cfp(th, src_cfp); - rb_control_frame_t *ruby_level_cfp = rb_vm_get_ruby_level_next_cfp(th, src_cfp); - VALUE bindval, envval; - rb_binding_t *bind; - - if (cfp == 0 || ruby_level_cfp == 0) { - rb_raise(rb_eRuntimeError, "Can't create Binding Object on top of Fiber."); - } - - while (1) { - envval = rb_vm_make_env_object(th, cfp); - if (cfp == ruby_level_cfp) { - break; - } - cfp = rb_vm_get_binding_creatable_next_cfp(th, RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp)); - } - - bindval = binding_alloc(rb_cBinding); - GetBindingPtr(bindval, bind); - bind->env = envval; - bind->path = ruby_level_cfp->iseq->location.path; - bind->first_lineno = rb_vm_get_sourceline(ruby_level_cfp); - - return bindval; + return rb_vm_make_binding(th, src_cfp); } VALUE @@ -2409,9 +2388,10 @@ proc_binding(VALUE self) } } - bindval = binding_alloc(rb_cBinding); + bindval = rb_binding_alloc(rb_cBinding); GetBindingPtr(bindval, bind); bind->env = proc->envval; + bind->blockprocval = proc->blockprocval; if (RUBY_VM_NORMAL_ISEQ_P(proc->block.iseq)) { bind->path = proc->block.iseq->location.path; bind->first_lineno = FIX2INT(rb_iseq_first_lineno(proc->block.iseq->self)); diff --git a/test/ruby/test_eval.rb b/test/ruby/test_eval.rb index 2700aa33f383e9..28d797e2c8b181 100644 --- a/test/ruby/test_eval.rb +++ b/test/ruby/test_eval.rb @@ -484,4 +484,19 @@ def test_eval_location_fstring assert_same a, b end + + def test_gced_binding_block + assert_normal_exit %q{ + def m + binding + end + GC.stress = true + b = nil + tap do + b = m {} + end + 0.times.to_a + b.eval('yield') + }, '[Bug #10368]' + end end diff --git a/version.h b/version.h index ec4ffa5829c37c..8c8d4ca7460dff 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.4" #define RUBY_RELEASE_DATE "2014-10-19" -#define RUBY_PATCHLEVEL 260 +#define RUBY_PATCHLEVEL 261 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 10 diff --git a/vm.c b/vm.c index c82a00e5a234a5..212f7b01401f68 100644 --- a/vm.c +++ b/vm.c @@ -688,6 +688,39 @@ rb_vm_make_proc(rb_thread_t *th, const rb_block_t *block, VALUE klass) return procval; } +/* Binding */ + +VALUE +rb_vm_make_binding(rb_thread_t *th, const rb_control_frame_t *src_cfp) +{ + rb_control_frame_t *cfp = rb_vm_get_binding_creatable_next_cfp(th, src_cfp); + rb_control_frame_t *ruby_level_cfp = rb_vm_get_ruby_level_next_cfp(th, src_cfp); + VALUE bindval, envval; + rb_binding_t *bind; + VALUE blockprocval = 0; + + if (cfp == 0 || ruby_level_cfp == 0) { + rb_raise(rb_eRuntimeError, "Can't create Binding Object on top of Fiber."); + } + + while (1) { + envval = vm_make_env_object(th, cfp, &blockprocval); + if (cfp == ruby_level_cfp) { + break; + } + cfp = rb_vm_get_binding_creatable_next_cfp(th, RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp)); + } + + bindval = rb_binding_alloc(rb_cBinding); + GetBindingPtr(bindval, bind); + bind->env = envval; + bind->path = ruby_level_cfp->iseq->location.path; + bind->blockprocval = blockprocval; + bind->first_lineno = rb_vm_get_sourceline(ruby_level_cfp); + + return bindval; +} + VALUE * rb_binding_add_dynavars(rb_binding_t *bind, int dyncount, const ID *dynvars) { @@ -699,6 +732,7 @@ rb_binding_add_dynavars(rb_binding_t *bind, int dyncount, const ID *dynvars) NODE *node = 0; ID minibuf[4], *dyns = minibuf; VALUE idtmp = 0; + VALUE blockprocval = 0; if (dyncount < 0) return 0; @@ -719,7 +753,8 @@ rb_binding_add_dynavars(rb_binding_t *bind, int dyncount, const ID *dynvars) ALLOCV_END(idtmp); vm_set_eval_stack(th, iseqval, 0, base_block); - bind->env = rb_vm_make_env_object(th, th->cfp); + bind->env = vm_make_env_object(th, th->cfp, &blockprocval); + bind->blockprocval = blockprocval; vm_pop_frame(th); GetEnvPtr(bind->env, env); diff --git a/vm_core.h b/vm_core.h index 3b588bdbcc7e95..73127e65eab41d 100644 --- a/vm_core.h +++ b/vm_core.h @@ -726,6 +726,7 @@ extern const rb_data_type_t ruby_binding_data_type; typedef struct { VALUE env; VALUE path; + VALUE blockprocval; /* for GC mark */ unsigned short first_lineno; } rb_binding_t; @@ -842,6 +843,7 @@ rb_block_t *rb_vm_control_frame_block_ptr(rb_control_frame_t *cfp); /* VM related object allocate functions */ VALUE rb_thread_alloc(VALUE klass); VALUE rb_proc_alloc(VALUE klass); +VALUE rb_binding_alloc(VALUE klass); /* for debug */ extern void rb_vmdebug_stack_dump_raw(rb_thread_t *, rb_control_frame_t *); @@ -862,6 +864,7 @@ int rb_thread_method_id_and_class(rb_thread_t *th, ID *idp, VALUE *klassp); VALUE rb_vm_invoke_proc(rb_thread_t *th, rb_proc_t *proc, int argc, const VALUE *argv, const rb_block_t *blockptr); VALUE rb_vm_make_proc(rb_thread_t *th, const rb_block_t *block, VALUE klass); +VALUE rb_vm_make_binding(rb_thread_t *th, const rb_control_frame_t *src_cfp); VALUE rb_vm_make_env_object(rb_thread_t *th, rb_control_frame_t *cfp); VALUE rb_binding_new_with_cfp(rb_thread_t *th, const rb_control_frame_t *src_cfp); VALUE *rb_binding_add_dynavars(rb_binding_t *bind, int dyncount, const ID *dynvars); From c8137d676a79c7ac36079f3ea36dc3ae9df69a6e Mon Sep 17 00:00:00 2001 From: nagachika Date: Wed, 22 Oct 2014 14:14:52 +0000 Subject: [PATCH 265/343] merge revision(s) r45274,r45278,r45280,r48097: [Backport #9424] [Backport #9640] * lib/openssl/ssl.rb: Explicitly whitelist the default SSL/TLS ciphers. Forbid SSLv2 and SSLv3, disable compression by default. Reported by Jeff Hodges. [ruby-core:59829] [Bug #9424] * test/openssl/test_ssl.rb: Reuse TLS default options from OpenSSL::SSL::SSLContext::DEFAULT_PARAMS. * ext/openssl/lib/openssl/ssl.rb (DEFAULT_PARAMS): override options even if OpenSSL::SSL::OP_NO_SSLv3 is not defined. this is pointed out by Stephen Touset. [ruby-core:65711] [Bug #9424] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@48098 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 19 ++++++++++++++ ext/openssl/lib/openssl/ssl.rb | 47 +++++++++++++++++++++++++++++++--- test/openssl/test_ssl.rb | 6 +---- version.h | 6 ++--- 4 files changed, 66 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index af9338fea46b98..721c897a356543 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +Wed Oct 22 23:02:49 2014 CHIKANAGA Tomoyuki + + * ext/openssl/lib/openssl/ssl.rb (DEFAULT_PARAMS): override + options even if OpenSSL::SSL::OP_NO_SSLv3 is not defined. + this is pointed out by Stephen Touset. [ruby-core:65711] [Bug #9424] + +Wed Oct 22 23:02:49 2014 Martin Bosslet + + * test/openssl/test_ssl.rb: Reuse TLS default options from + OpenSSL::SSL::SSLContext::DEFAULT_PARAMS. + +Wed Oct 22 23:02:49 2014 Martin Bosslet + + * lib/openssl/ssl.rb: Explicitly whitelist the default + SSL/TLS ciphers. Forbid SSLv2 and SSLv3, disable + compression by default. + Reported by Jeff Hodges. + [ruby-core:59829] [Bug #9424] + Sun Oct 19 03:22:53 2014 Kazuki Tsujimoto * vm_core.h, vm.c, proc.c: fix GC mark miss on bindings. diff --git a/ext/openssl/lib/openssl/ssl.rb b/ext/openssl/lib/openssl/ssl.rb index 86be19054a1606..43025e76220cf1 100644 --- a/ext/openssl/lib/openssl/ssl.rb +++ b/ext/openssl/lib/openssl/ssl.rb @@ -23,10 +23,49 @@ class SSLContext DEFAULT_PARAMS = { :ssl_version => "SSLv23", :verify_mode => OpenSSL::SSL::VERIFY_PEER, - :ciphers => "ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW", - :options => defined?(OpenSSL::SSL::OP_DONT_INSERT_EMPTY_FRAGMENTS) ? - OpenSSL::SSL::OP_ALL & ~OpenSSL::SSL::OP_DONT_INSERT_EMPTY_FRAGMENTS : - OpenSSL::SSL::OP_ALL, + :ciphers => %w{ + ECDHE-ECDSA-AES128-GCM-SHA256 + ECDHE-RSA-AES128-GCM-SHA256 + ECDHE-ECDSA-AES256-GCM-SHA384 + ECDHE-RSA-AES256-GCM-SHA384 + DHE-RSA-AES128-GCM-SHA256 + DHE-DSS-AES128-GCM-SHA256 + DHE-RSA-AES256-GCM-SHA384 + DHE-DSS-AES256-GCM-SHA384 + ECDHE-ECDSA-AES128-SHA256 + ECDHE-RSA-AES128-SHA256 + ECDHE-ECDSA-AES128-SHA + ECDHE-RSA-AES128-SHA + ECDHE-ECDSA-AES256-SHA384 + ECDHE-RSA-AES256-SHA384 + ECDHE-ECDSA-AES256-SHA + ECDHE-RSA-AES256-SHA + DHE-RSA-AES128-SHA256 + DHE-RSA-AES256-SHA256 + DHE-RSA-AES128-SHA + DHE-RSA-AES256-SHA + DHE-DSS-AES128-SHA256 + DHE-DSS-AES256-SHA256 + DHE-DSS-AES128-SHA + DHE-DSS-AES256-SHA + AES128-GCM-SHA256 + AES256-GCM-SHA384 + AES128-SHA256 + AES256-SHA256 + AES128-SHA + AES256-SHA + ECDHE-ECDSA-RC4-SHA + ECDHE-RSA-RC4-SHA + RC4-SHA + }.join(":"), + :options => -> { + opts = OpenSSL::SSL::OP_ALL + opts &= ~OpenSSL::SSL::OP_DONT_INSERT_EMPTY_FRAGMENTS if defined?(OpenSSL::SSL::OP_DONT_INSERT_EMPTY_FRAGMENTS) + opts |= OpenSSL::SSL::OP_NO_COMPRESSION if defined?(OpenSSL::SSL::OP_NO_COMPRESSION) + opts |= OpenSSL::SSL::OP_NO_SSLv2 if defined?(OpenSSL::SSL::OP_NO_SSLv2) + opts |= OpenSSL::SSL::OP_NO_SSLv3 if defined?(OpenSSL::SSL::OP_NO_SSLv3) + opts + }.call } DEFAULT_CERT_STORE = OpenSSL::X509::Store.new diff --git a/test/openssl/test_ssl.rb b/test/openssl/test_ssl.rb index a13f0e1a9c49a7..b743819518f7b5 100644 --- a/test/openssl/test_ssl.rb +++ b/test/openssl/test_ssl.rb @@ -4,10 +4,6 @@ class OpenSSL::TestSSL < OpenSSL::SSLTestCase - TLS_DEFAULT_OPS = defined?(OpenSSL::SSL::OP_DONT_INSERT_EMPTY_FRAGMENTS) ? - OpenSSL::SSL::OP_ALL & ~OpenSSL::SSL::OP_DONT_INSERT_EMPTY_FRAGMENTS : - OpenSSL::SSL::OP_ALL - def test_ctx_setup ctx = OpenSSL::SSL::SSLContext.new assert_equal(ctx.setup, true) @@ -276,7 +272,7 @@ def test_sslctx_set_params ctx = OpenSSL::SSL::SSLContext.new ctx.set_params assert_equal(OpenSSL::SSL::VERIFY_PEER, ctx.verify_mode) - assert_equal(TLS_DEFAULT_OPS, ctx.options) + assert_equal(OpenSSL::SSL::SSLContext::DEFAULT_PARAMS[:options], ctx.options) ciphers = ctx.ciphers ciphers_versions = ciphers.collect{|_, v, _, _| v } ciphers_names = ciphers.collect{|v, _, _, _| v } diff --git a/version.h b/version.h index 8c8d4ca7460dff..0edb9dc42a0386 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.4" -#define RUBY_RELEASE_DATE "2014-10-19" -#define RUBY_PATCHLEVEL 261 +#define RUBY_RELEASE_DATE "2014-10-22" +#define RUBY_PATCHLEVEL 262 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 10 -#define RUBY_RELEASE_DAY 19 +#define RUBY_RELEASE_DAY 22 #include "ruby/version.h" From c4e838d011ac61ad30b2fa7c568caa11b34ee958 Mon Sep 17 00:00:00 2001 From: nagachika Date: Sat, 25 Oct 2014 18:29:00 +0000 Subject: [PATCH 266/343] merge revision(s) r48102: [Backport #10413] * class.c (unknown_keyword_error): delete expected keywords directly from raw table, so that the given block is not called. [ruby-core:65837] [Bug #10413] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@48137 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ class.c | 4 +++- test/ruby/test_keyword.rb | 15 +++++++++++++++ version.h | 6 +++--- 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 721c897a356543..e10d55e624f768 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sun Oct 26 03:21:30 2014 Nobuyoshi Nakada + + * class.c (unknown_keyword_error): delete expected keywords + directly from raw table, so that the given block is not called. + [ruby-core:65837] [Bug #10413] + Wed Oct 22 23:02:49 2014 CHIKANAGA Tomoyuki * ext/openssl/lib/openssl/ssl.rb (DEFAULT_PARAMS): override diff --git a/class.c b/class.c index de5323a69b2472..8f11f45b535c65 100644 --- a/class.c +++ b/class.c @@ -1876,10 +1876,12 @@ NORETURN(static void unknown_keyword_error(VALUE hash, const ID *table, int keyw static void unknown_keyword_error(VALUE hash, const ID *table, int keywords) { + st_table *tbl = rb_hash_tbl_raw(hash); VALUE keys; int i; for (i = 0; i < keywords; i++) { - rb_hash_delete(hash, ID2SYM(table[i])); + st_data_t key = ID2SYM(table[i]); + st_delete(tbl, &key, NULL); } keys = rb_funcall(hash, rb_intern("keys"), 0, 0); if (!RB_TYPE_P(keys, T_ARRAY)) rb_raise(rb_eArgError, "unknown keyword"); diff --git a/test/ruby/test_keyword.rb b/test/ruby/test_keyword.rb index e7bd11b18b0beb..13bac278f2e3f2 100644 --- a/test/ruby/test_keyword.rb +++ b/test/ruby/test_keyword.rb @@ -505,4 +505,19 @@ def m(a: []) tap { prc.call } }, bug8964 end + + def test_unknown_keyword_with_block + bug10413 = '[ruby-core:65837] [Bug #10413]' + class << (o = Object.new) + def bar(k2: 'v2') + end + + def foo + bar(k1: 1) + end + end + assert_raise_with_message(ArgumentError, /unknown keyword: k1/, bug10413) { + o.foo {raise "unreachable"} + } + end end diff --git a/version.h b/version.h index 0edb9dc42a0386..9c6d9abedebd1b 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.4" -#define RUBY_RELEASE_DATE "2014-10-22" -#define RUBY_PATCHLEVEL 262 +#define RUBY_RELEASE_DATE "2014-10-26" +#define RUBY_PATCHLEVEL 263 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 10 -#define RUBY_RELEASE_DAY 22 +#define RUBY_RELEASE_DAY 26 #include "ruby/version.h" From eca3835c65f6e63b92dd5387257322323ab43563 Mon Sep 17 00:00:00 2001 From: nagachika Date: Sat, 25 Oct 2014 18:42:44 +0000 Subject: [PATCH 267/343] merge revision(s) r48111,r48118,r48120: [Backport #10421] * vm_method.c (rb_method_entry_make): warn redefinition only for already defined methods, but not for undefined methods. [ruby-dev:48691] [Bug #10421] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@48138 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ test/ruby/test_object.rb | 9 +++++++++ version.h | 2 +- vm_method.c | 3 ++- 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index e10d55e624f768..ba03421dea746c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sun Oct 26 03:31:46 2014 Nobuyoshi Nakada + + * vm_method.c (rb_method_entry_make): warn redefinition only for + already defined methods, but not for undefined methods. + [ruby-dev:48691] [Bug #10421] + Sun Oct 26 03:21:30 2014 Nobuyoshi Nakada * class.c (unknown_keyword_error): delete expected keywords diff --git a/test/ruby/test_object.rb b/test/ruby/test_object.rb index e8ab6135c480ac..596bddf1e59ce0 100644 --- a/test/ruby/test_object.rb +++ b/test/ruby/test_object.rb @@ -298,6 +298,15 @@ def (Object.new).object_id; end $VERBOSE = false def (Object.new).__send__; end INPUT + + bug10421 = '[ruby-dev:48691] [Bug #10421]' + assert_in_out_err([], <<-INPUT, ["1"], [], bug10421) + $VERBOSE = false + class C < BasicObject + def object_id; 1; end + end + puts C.new.object_id + INPUT end def test_remove_method diff --git a/version.h b/version.h index 9c6d9abedebd1b..b6f5a953ef85e9 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.4" #define RUBY_RELEASE_DATE "2014-10-26" -#define RUBY_PATCHLEVEL 263 +#define RUBY_PATCHLEVEL 264 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 10 diff --git a/vm_method.c b/vm_method.c index a5fe4ba0a3bcf1..2270359029f756 100644 --- a/vm_method.c +++ b/vm_method.c @@ -181,6 +181,7 @@ rb_free_method_entry(rb_method_entry_t *me) xfree(me); } +static inline rb_method_entry_t *search_method(VALUE klass, ID id, VALUE *defined_class_ptr); static int rb_method_definition_eq(const rb_method_definition_t *d1, const rb_method_definition_t *d2); static inline rb_method_entry_t * @@ -355,7 +356,7 @@ rb_method_entry_make(VALUE klass, ID mid, rb_method_type_t type, } /* check mid */ if (mid == object_id || mid == id__send__) { - if (type == VM_METHOD_TYPE_ISEQ) { + if (type == VM_METHOD_TYPE_ISEQ && search_method(klass, mid, 0)) { rb_warn("redefining `%s' may cause serious problems", rb_id2name(mid)); } } From d86ba46a65734423c05cb399c61f096db4f82712 Mon Sep 17 00:00:00 2001 From: nagachika Date: Mon, 27 Oct 2014 11:23:17 +0000 Subject: [PATCH 268/343] merge revision(s) r48161: * lib/rexml/entity.rb: keep the entity size within the limitation. reported by Willis Vandevanter and patched by nahi. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@48163 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ lib/rexml/entity.rb | 6 ++++++ test/rexml/test_document.rb | 27 +++++++++++++++++++++++++++ test/rexml/test_entity.rb | 16 ++++++++++++++++ version.h | 6 +++--- 5 files changed, 58 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index ba03421dea746c..19dbbd025e014c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Mon Oct 27 20:20:14 2014 NAKAMURA Usaku + + * lib/rexml/entity.rb: keep the entity size within the limitation. + reported by Willis Vandevanter and + patched by nahi. + Sun Oct 26 03:31:46 2014 Nobuyoshi Nakada * vm_method.c (rb_method_entry_make): warn redefinition only for diff --git a/lib/rexml/entity.rb b/lib/rexml/entity.rb index 39f3900075d00a..f447202394db2d 100644 --- a/lib/rexml/entity.rb +++ b/lib/rexml/entity.rb @@ -138,8 +138,14 @@ def value matches = @value.scan(PEREFERENCE_RE) rv = @value.clone if @parent + sum = 0 matches.each do |entity_reference| entity_value = @parent.entity( entity_reference[0] ) + if sum + entity_value.bytesize > Security.entity_expansion_text_limit + raise "entity expansion has grown too large" + else + sum += entity_value.bytesize + end rv.gsub!( /%#{entity_reference.join};/um, entity_value ) end end diff --git a/test/rexml/test_document.rb b/test/rexml/test_document.rb index cec9452373882b..efdcf66b82eda2 100644 --- a/test/rexml/test_document.rb +++ b/test/rexml/test_document.rb @@ -45,6 +45,20 @@ def test_new &a; +EOF + + XML_WITH_NESTED_PARAMETER_ENTITY = < + + + + + + + +]> + EOF XML_WITH_4_ENTITY_EXPANSION = < diff --git a/version.h b/version.h index df0266845d5f7d..7e0b9cc1c855f3 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.5" #define RUBY_RELEASE_DATE "2014-11-05" -#define RUBY_PATCHLEVEL 269 +#define RUBY_PATCHLEVEL 270 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 11 From 5218027786a3a521f73edab3a96dca65a8da5241 Mon Sep 17 00:00:00 2001 From: nagachika Date: Thu, 6 Nov 2014 13:46:46 +0000 Subject: [PATCH 274/343] merge revision(s) 48288: [Backport #9681] * compile.c (compile_data_alloc): add padding when strict alignment is required for memory access. Currently, the padding is enabled only when the CPU is 32-bit SPARC and the compiler is GCC. [Bug #9681] [ruby-core:61715] * compile.c (STRICT_ALIGNMENT): defined if strict alignment is required * compile.c (ALIGNMENT_SIZE, ALIGNMENT_SIZE_MASK, PADDING_SIZE_MAX): new macros for alignemnt word size, bit mask, max size of padding. * compile.c (calc_padding): new function to calculate padding size. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@48302 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 14 ++++++++++++ compile.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- version.h | 6 ++--- 3 files changed, 80 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9b5d8d35b00a77..a5da0bea2930c7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +Thu Nov 6 22:36:55 2014 Naohisa Goto + + * compile.c (compile_data_alloc): add padding when strict alignment + is required for memory access. Currently, the padding is enabled + only when the CPU is 32-bit SPARC and the compiler is GCC. + [Bug #9681] [ruby-core:61715] + + * compile.c (STRICT_ALIGNMENT): defined if strict alignment is required + + * compile.c (ALIGNMENT_SIZE, ALIGNMENT_SIZE_MASK, PADDING_SIZE_MAX): + new macros for alignemnt word size, bit mask, max size of padding. + + * compile.c (calc_padding): new function to calculate padding size. + Wed Nov 5 00:18:22 2014 Nobuyoshi Nakada * configure.in (__builtin_setjmp): disable with gcc/clang earlier diff --git a/compile.c b/compile.c index a76c93be73f409..099c280f75d0c1 100644 --- a/compile.c +++ b/compile.c @@ -583,18 +583,72 @@ rb_iseq_translate_threaded_code(rb_iseq_t *iseq) /* definition of data structure for compiler */ /*********************************************/ +/* + * On 32-bit SPARC, GCC by default generates SPARC V7 code that may require + * 8-byte word alignment. On the other hand, Oracle Solaris Studio seems to + * generate SPARCV8PLUS code with unaligned memory accesss instructions. + * That is why the STRICT_ALIGNMENT is defined only with GCC. + */ +#if defined(__sparc) && SIZEOF_VOIDP == 4 && defined(__GNUC__) + #define STRICT_ALIGNMENT +#endif + +#ifdef STRICT_ALIGNMENT + #if defined(HAVE_TRUE_LONG_LONG) && SIZEOF_LONG_LONG > SIZEOF_VALUE + #define ALIGNMENT_SIZE SIZEOF_LONG_LONG + #else + #define ALIGNMENT_SIZE SIZEOF_VALUE + #endif + #define PADDING_SIZE_MAX ((size_t)((ALIGNMENT_SIZE) - 1)) + #define ALIGNMENT_SIZE_MASK PADDING_SIZE_MAX + /* Note: ALIGNMENT_SIZE == (2 ** N) is expected. */ +#else + #define PADDING_SIZE_MAX 0 +#endif /* STRICT_ALIGNMENT */ + +#ifdef STRICT_ALIGNMENT +/* calculate padding size for aligned memory access */ +static size_t +calc_padding(void *ptr, size_t size) +{ + size_t mis; + size_t padding = 0; + + mis = (size_t)ptr & ALIGNMENT_SIZE_MASK; + if (mis > 0) { + padding = ALIGNMENT_SIZE - mis; + } +/* + * On 32-bit sparc or equivalents, when a single VALUE is requested + * and padding == sizeof(VALUE), it is clear that no padding is needed. + */ +#if ALIGNMENT_SIZE > SIZEOF_VALUE + if (size == sizeof(VALUE) && padding == sizeof(VALUE)) { + padding = 0; + } +#endif + + return padding; +} +#endif /* STRICT_ALIGNMENT */ + static void * compile_data_alloc(rb_iseq_t *iseq, size_t size) { void *ptr = 0; struct iseq_compile_data_storage *storage = iseq->compile_data->storage_current; +#ifdef STRICT_ALIGNMENT + size_t padding = calc_padding((void *)&storage->buff[storage->pos], size); +#else + const size_t padding = 0; /* expected to be optimized by compiler */ +#endif /* STRICT_ALIGNMENT */ - if (storage->pos + size > storage->size) { + if (storage->pos + size + padding > storage->size) { unsigned long alloc_size = storage->size * 2; retry: - if (alloc_size < size) { + if (alloc_size < size + PADDING_SIZE_MAX) { alloc_size *= 2; goto retry; } @@ -606,8 +660,15 @@ compile_data_alloc(rb_iseq_t *iseq, size_t size) storage->pos = 0; storage->size = alloc_size; storage->buff = (char *)(&storage->buff + 1); +#ifdef STRICT_ALIGNMENT + padding = calc_padding((void *)&storage->buff[storage->pos], size); +#endif /* STRICT_ALIGNMENT */ } +#ifdef STRICT_ALIGNMENT + storage->pos += (int)padding; +#endif /* STRICT_ALIGNMENT */ + ptr = (void *)&storage->buff[storage->pos]; storage->pos += size; return ptr; diff --git a/version.h b/version.h index 7e0b9cc1c855f3..a5249a75d99073 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.5" -#define RUBY_RELEASE_DATE "2014-11-05" -#define RUBY_PATCHLEVEL 270 +#define RUBY_RELEASE_DATE "2014-11-06" +#define RUBY_PATCHLEVEL 271 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 11 -#define RUBY_RELEASE_DAY 5 +#define RUBY_RELEASE_DAY 6 #include "ruby/version.h" From 562c93f5a7c87b373c5deebeb8f39cf3bc539bf3 Mon Sep 17 00:00:00 2001 From: nagachika Date: Thu, 6 Nov 2014 14:19:59 +0000 Subject: [PATCH 275/343] merge revision(s) r47860: [Backport #10350] * bignum.c (absint_numwords_generic): set an array element after definition of a variable to fix compile error with older version of fcc (Fujitsu C Compiler) 5.6 on Solaris 10 on Sparc. [Bug #10350] [ruby-dev:48608] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@48303 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ bignum.c | 4 +++- version.h | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index a5da0bea2930c7..c93aafe75bbd3d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Thu Nov 6 22:57:43 2014 Naohisa Goto + + * bignum.c (absint_numwords_generic): set an array element after + definition of a variable to fix compile error with older version + of fcc (Fujitsu C Compiler) 5.6 on Solaris 10 on Sparc. + [Bug #10350] [ruby-dev:48608] + Thu Nov 6 22:36:55 2014 Naohisa Goto * compile.c (compile_data_alloc): add padding when strict alignment diff --git a/bignum.c b/bignum.c index 55ee4ce48e51ff..27d8d8a6a766e0 100644 --- a/bignum.c +++ b/bignum.c @@ -3294,7 +3294,7 @@ absint_numwords_generic(size_t numbytes, int nlz_bits_in_msbyte, size_t word_num static const BDIGIT char_bit[1] = { CHAR_BIT }; BDIGIT numbytes_bary[bdigit_roomof(sizeof(numbytes))]; BDIGIT val_numbits_bary[bdigit_roomof(sizeof(numbytes) + 1)]; - BDIGIT nlz_bits_in_msbyte_bary[1] = { nlz_bits_in_msbyte }; + BDIGIT nlz_bits_in_msbyte_bary[1]; BDIGIT word_numbits_bary[bdigit_roomof(sizeof(word_numbits))]; BDIGIT div_bary[numberof(val_numbits_bary) + BIGDIVREM_EXTRA_WORDS]; BDIGIT mod_bary[numberof(word_numbits_bary)]; @@ -3304,6 +3304,8 @@ absint_numwords_generic(size_t numbytes, int nlz_bits_in_msbyte, size_t word_num int sign; size_t numwords; + nlz_bits_in_msbyte_bary[0] = nlz_bits_in_msbyte; + /* * val_numbits = numbytes * CHAR_BIT - nlz_bits_in_msbyte * div, mod = val_numbits.divmod(word_numbits) diff --git a/version.h b/version.h index a5249a75d99073..5fd1f5dc9fb26f 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.5" #define RUBY_RELEASE_DATE "2014-11-06" -#define RUBY_PATCHLEVEL 271 +#define RUBY_PATCHLEVEL 272 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 11 From e6561ee1e532187f7324229dd5ba73e0aabb1134 Mon Sep 17 00:00:00 2001 From: nagachika Date: Thu, 13 Nov 2014 13:36:20 +0000 Subject: [PATCH 276/343] merge revision(s) r48402: * lib/rexml/document.rb: add REXML::Document#document. reported by Tomas Hoger and patched by nahi. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@48404 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 ++++ lib/rexml/document.rb | 4 +++ lib/rexml/entity.rb | 1 + test/rexml/test_document.rb | 53 ++++++++++++++++++++++++++++++++++++- version.h | 6 ++--- 5 files changed, 65 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index c93aafe75bbd3d..fe76d3d1fb1a83 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Thu Nov 13 22:32:34 2014 CHIKANAGA Tomoyuki + + * lib/rexml/document.rb: add REXML::Document#document. + reported by Tomas Hoger and patched by nahi. + Thu Nov 6 22:57:43 2014 Naohisa Goto * bignum.c (absint_numwords_generic): set an array element after diff --git a/lib/rexml/document.rb b/lib/rexml/document.rb index 1e18263ddaa677..f92eb62d95ff7c 100644 --- a/lib/rexml/document.rb +++ b/lib/rexml/document.rb @@ -278,6 +278,10 @@ def record_entity_expansion end end + def document + self + end + private def build( source ) Parsers::TreeParser.new( source, self ).parse diff --git a/lib/rexml/entity.rb b/lib/rexml/entity.rb index f447202394db2d..3a35ec6b9477a6 100644 --- a/lib/rexml/entity.rb +++ b/lib/rexml/entity.rb @@ -157,6 +157,7 @@ def value # This is a set of entity constants -- the ones defined in the XML # specification. These are +gt+, +lt+, +amp+, +quot+ and +apos+. + # CAUTION: these entities does not have parent and document module EntityConst # +>+ GT = Entity.new( 'gt', '>' ) diff --git a/test/rexml/test_document.rb b/test/rexml/test_document.rb index efdcf66b82eda2..c5ac057e14e547 100644 --- a/test/rexml/test_document.rb +++ b/test/rexml/test_document.rb @@ -47,7 +47,23 @@ def test_new EOF - XML_WITH_NESTED_PARAMETER_ENTITY = < + + + + + + + +]> + +&a; + +EOF + + XML_WITH_NESTED_PARAMETER_ENTITY = < @@ -59,6 +75,20 @@ def test_new ]> +EOF + + XML_WITH_NESTED_EMPTY_PARAMETER_ENTITY = < + + + + + + + +]> + EOF XML_WITH_4_ENTITY_EXPANSION = < Date: Thu, 27 Nov 2014 11:36:32 +0000 Subject: [PATCH 277/343] ChangeLog: fix a typo. [ruby-core:66328] [Backport #10521] https://github.com/ruby/ruby/pull/760 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@48610 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 2 +- version.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index fe76d3d1fb1a83..b2f2fe88a04c8e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -41,7 +41,7 @@ Tue Oct 28 22:30:21 2014 NARUSE, Yui * configure.in: remove apple-gcc4.2 from CC candidates. -火 10 28 22:19:44 2014 CHIKANAGA Tomoyuki +Tue Oct 28 22:19:44 2014 CHIKANAGA Tomoyuki * version.h (RUBY_VERSION): bump RUBY_VERSION to 2.1.5. diff --git a/version.h b/version.h index fbb3fa97366e6e..6d828168a293b4 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.5" -#define RUBY_RELEASE_DATE "2014-11-13" -#define RUBY_PATCHLEVEL 273 +#define RUBY_RELEASE_DATE "2014-11-27" +#define RUBY_PATCHLEVEL 274 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 11 -#define RUBY_RELEASE_DAY 13 +#define RUBY_RELEASE_DAY 27 #include "ruby/version.h" From 033162b9773a5b43c5b38b9b688d81e9dd2c78e2 Mon Sep 17 00:00:00 2001 From: nagachika Date: Tue, 30 Dec 2014 14:56:51 +0000 Subject: [PATCH 278/343] * lib/rubygems/*: upgrade to RubyGems 2.2.3. [Backport #10515] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@49074 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 +++ lib/rubygems.rb | 2 +- .../ssl_certs/AddTrustExternalCARoot-2048.pem | 25 +++++++++++++++ .../ssl_certs/AddTrustExternalCARoot.pem | 32 +++++++++++++++++++ 4 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 lib/rubygems/ssl_certs/AddTrustExternalCARoot-2048.pem create mode 100644 lib/rubygems/ssl_certs/AddTrustExternalCARoot.pem diff --git a/ChangeLog b/ChangeLog index b2f2fe88a04c8e..4af880ee3ad0e7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Tue Dec 30 23:46:26 2014 CHIKANAGA Tomoyuki + + * lib/rubygems/*: upgrade to RubyGems 2.2.3. [Backport #10515] + Thu Nov 13 22:32:34 2014 CHIKANAGA Tomoyuki * lib/rexml/document.rb: add REXML::Document#document. diff --git a/lib/rubygems.rb b/lib/rubygems.rb index 456273ed19d763..ea1893046f6259 100644 --- a/lib/rubygems.rb +++ b/lib/rubygems.rb @@ -8,7 +8,7 @@ require 'rbconfig' module Gem - VERSION = '2.2.2' + VERSION = '2.2.3' end # Must be first since it unloads the prelude from 1.9.2 diff --git a/lib/rubygems/ssl_certs/AddTrustExternalCARoot-2048.pem b/lib/rubygems/ssl_certs/AddTrustExternalCARoot-2048.pem new file mode 100644 index 00000000000000..20585f1c01e187 --- /dev/null +++ b/lib/rubygems/ssl_certs/AddTrustExternalCARoot-2048.pem @@ -0,0 +1,25 @@ +-----BEGIN CERTIFICATE----- +MIIENjCCAx6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBvMQswCQYDVQQGEwJTRTEU +MBIGA1UEChMLQWRkVHJ1c3QgQUIxJjAkBgNVBAsTHUFkZFRydXN0IEV4dGVybmFs +IFRUUCBOZXR3b3JrMSIwIAYDVQQDExlBZGRUcnVzdCBFeHRlcm5hbCBDQSBSb290 +MB4XDTAwMDUzMDEwNDgzOFoXDTIwMDUzMDEwNDgzOFowbzELMAkGA1UEBhMCU0Ux +FDASBgNVBAoTC0FkZFRydXN0IEFCMSYwJAYDVQQLEx1BZGRUcnVzdCBFeHRlcm5h +bCBUVFAgTmV0d29yazEiMCAGA1UEAxMZQWRkVHJ1c3QgRXh0ZXJuYWwgQ0EgUm9v +dDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALf3GjPm8gAELTngTlvt +H7xsD821+iO2zt6bETOXpClMfZOfvUq8k+0DGuOPz+VtUFrWlymUWoCwSXrbLpX9 +uMq/NzgtHj6RQa1wVsfwTz/oMp50ysiQVOnGXw94nZpAPA6sYapeFI+eh6FqUNzX +mk6vBbOmcZSccbNQYArHE504B4YCqOmoaSYYkKtMsE8jqzpPhNjfzp/haW+710LX +a0Tkx63ubUFfclpxCDezeWWkWaCUN/cALw3CknLa0Dhy2xSoRcRdKn23tNbE7qzN +E0S3ySvdQwAl+mG5aWpYIxG3pzOPVnVZ9c0p10a3CitlttNCbxWyuHv77+ldU9U0 +WicCAwEAAaOB3DCB2TAdBgNVHQ4EFgQUrb2YejS0Jvf6xCZU7wO94CTLVBowCwYD +VR0PBAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wgZkGA1UdIwSBkTCBjoAUrb2YejS0 +Jvf6xCZU7wO94CTLVBqhc6RxMG8xCzAJBgNVBAYTAlNFMRQwEgYDVQQKEwtBZGRU +cnVzdCBBQjEmMCQGA1UECxMdQWRkVHJ1c3QgRXh0ZXJuYWwgVFRQIE5ldHdvcmsx +IjAgBgNVBAMTGUFkZFRydXN0IEV4dGVybmFsIENBIFJvb3SCAQEwDQYJKoZIhvcN +AQEFBQADggEBALCb4IUlwtYj4g+WBpKdQZic2YR5gdkeWxQHIzZlj7DYd7usQWxH +YINRsPkyPef89iYTx4AWpb9a/IfPeHmJIZriTAcKhjW88t5RxNKWt9x+Tu5w/Rw5 +6wwCURQtjr0W4MHfRnXnJK3s9EK0hZNwEGe6nQY1ShjTK3rMUUKhemPR5ruhxSvC +Nr4TDea9Y355e6cJDUCrat2PisP29owaQgVR1EX1n6diIWgVIEM8med8vSTYqZEX +c4g/VhsxOBi0cQ+azcgOno4uG+GMmIPLHzHxREzGBHNJdmAPx/i9F4BrLunMTA5a +mnkPIAou1Z5jJh5VkpTYghdae9C8x49OhgQ= +-----END CERTIFICATE----- diff --git a/lib/rubygems/ssl_certs/AddTrustExternalCARoot.pem b/lib/rubygems/ssl_certs/AddTrustExternalCARoot.pem new file mode 100644 index 00000000000000..6fbdf52b17a73a --- /dev/null +++ b/lib/rubygems/ssl_certs/AddTrustExternalCARoot.pem @@ -0,0 +1,32 @@ +-----BEGIN CERTIFICATE----- +MIIFdDCCBFygAwIBAgIQJ2buVutJ846r13Ci/ITeIjANBgkqhkiG9w0BAQwFADBv +MQswCQYDVQQGEwJTRTEUMBIGA1UEChMLQWRkVHJ1c3QgQUIxJjAkBgNVBAsTHUFk +ZFRydXN0IEV4dGVybmFsIFRUUCBOZXR3b3JrMSIwIAYDVQQDExlBZGRUcnVzdCBF +eHRlcm5hbCBDQSBSb290MB4XDTAwMDUzMDEwNDgzOFoXDTIwMDUzMDEwNDgzOFow +gYUxCzAJBgNVBAYTAkdCMRswGQYDVQQIExJHcmVhdGVyIE1hbmNoZXN0ZXIxEDAO +BgNVBAcTB1NhbGZvcmQxGjAYBgNVBAoTEUNPTU9ETyBDQSBMaW1pdGVkMSswKQYD +VQQDEyJDT01PRE8gUlNBIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIICIjANBgkq +hkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAkehUktIKVrGsDSTdxc9EZ3SZKzejfSNw +AHG8U9/E+ioSj0t/EFa9n3Byt2F/yUsPF6c947AEYe7/EZfH9IY+Cvo+XPmT5jR6 +2RRr55yzhaCCenavcZDX7P0N+pxs+t+wgvQUfvm+xKYvT3+Zf7X8Z0NyvQwA1onr +ayzT7Y+YHBSrfuXjbvzYqOSSJNpDa2K4Vf3qwbxstovzDo2a5JtsaZn4eEgwRdWt +4Q08RWD8MpZRJ7xnw8outmvqRsfHIKCxH2XeSAi6pE6p8oNGN4Tr6MyBSENnTnIq +m1y9TBsoilwie7SrmNnu4FGDwwlGTm0+mfqVF9p8M1dBPI1R7Qu2XK8sYxrfV8g/ +vOldxJuvRZnio1oktLqpVj3Pb6r/SVi+8Kj/9Lit6Tf7urj0Czr56ENCHonYhMsT +8dm74YlguIwoVqwUHZwK53Hrzw7dPamWoUi9PPevtQ0iTMARgexWO/bTouJbt7IE +IlKVgJNp6I5MZfGRAy1wdALqi2cVKWlSArvX31BqVUa/oKMoYX9w0MOiqiwhqkfO +KJwGRXa/ghgntNWutMtQ5mv0TIZxMOmm3xaG4Nj/QN370EKIf6MzOi5cHkERgWPO +GHFrK+ymircxXDpqR+DDeVnWIBqv8mqYqnK8V0rSS527EPywTEHl7R09XiidnMy/ +s1Hap0flhFMCAwEAAaOB9DCB8TAfBgNVHSMEGDAWgBStvZh6NLQm9/rEJlTvA73g +JMtUGjAdBgNVHQ4EFgQUu69+Aj36pvE8hI6t7jiY7NkyMtQwDgYDVR0PAQH/BAQD +AgGGMA8GA1UdEwEB/wQFMAMBAf8wEQYDVR0gBAowCDAGBgRVHSAAMEQGA1UdHwQ9 +MDswOaA3oDWGM2h0dHA6Ly9jcmwudXNlcnRydXN0LmNvbS9BZGRUcnVzdEV4dGVy +bmFsQ0FSb290LmNybDA1BggrBgEFBQcBAQQpMCcwJQYIKwYBBQUHMAGGGWh0dHA6 +Ly9vY3NwLnVzZXJ0cnVzdC5jb20wDQYJKoZIhvcNAQEMBQADggEBAGS/g/FfmoXQ +zbihKVcN6Fr30ek+8nYEbvFScLsePP9NDXRqzIGCJdPDoCpdTPW6i6FtxFQJdcfj +Jw5dhHk3QBN39bSsHNA7qxcS1u80GH4r6XnTq1dFDK8o+tDb5VCViLvfhVdpfZLY +Uspzgb8c8+a4bmYRBbMelC1/kZWSWfFMzqORcUx8Rww7Cxn2obFshj5cqsQugsv5 +B5a6SE2Q8pTIqXOi6wZ7I53eovNNVZ96YUWYGGjHXkBrI/V5eu+MtWuLt29G9Hvx +PUsE2JOAWVrgQSQdso8VYFhH2+9uRv0V9dlfmrPb2LjkQLPNlzmuhbsdjrzch5vR +pu/xO28QOG8= +-----END CERTIFICATE----- From 67e62b9216f812ebed238e01cb6a41a550323e46 Mon Sep 17 00:00:00 2001 From: svn Date: Tue, 30 Dec 2014 14:57:10 +0000 Subject: [PATCH 279/343] * 2014-12-30 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@49075 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- version.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/version.h b/version.h index 6d828168a293b4..9a7c502444cdb3 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.5" -#define RUBY_RELEASE_DATE "2014-11-27" +#define RUBY_RELEASE_DATE "2014-12-30" #define RUBY_PATCHLEVEL 274 #define RUBY_RELEASE_YEAR 2014 -#define RUBY_RELEASE_MONTH 11 -#define RUBY_RELEASE_DAY 27 +#define RUBY_RELEASE_MONTH 12 +#define RUBY_RELEASE_DAY 30 #include "ruby/version.h" From c6aaa9821f55e5a176bb78f816de7a05bd86206d Mon Sep 17 00:00:00 2001 From: nagachika Date: Tue, 30 Dec 2014 15:37:19 +0000 Subject: [PATCH 280/343] merge revision(s) r47079: [Backport #9129] [Backport #10531] * lib/net/http.rb (Net::HTTP.proxy_uri): use initializer instead of parser to handle IPv6 address. [Bug #9129] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@49076 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ lib/net/http.rb | 4 +++- version.h | 6 +++--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4af880ee3ad0e7..380b6deaf5c096 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed Dec 31 00:00:09 2014 NARUSE, Yui + + * lib/net/http.rb (Net::HTTP.proxy_uri): use initializer instead + of parser to handle IPv6 address. [Bug #9129] + Tue Dec 30 23:46:26 2014 CHIKANAGA Tomoyuki * lib/rubygems/*: upgrade to RubyGems 2.2.3. [Backport #10515] diff --git a/lib/net/http.rb b/lib/net/http.rb index a1b8d691bb2871..954644fb007c4b 100644 --- a/lib/net/http.rb +++ b/lib/net/http.rb @@ -1026,7 +1026,9 @@ def proxy_from_env? # The proxy URI determined from the environment for this connection. def proxy_uri # :nodoc: - @proxy_uri ||= URI("http://#{address}:#{port}").find_proxy + @proxy_uri ||= URI::HTTP.new( + "http".freeze, nil, address, port, nil, nil, nil, nil, nil + ).find_proxy end # The address of the proxy server, if one is configured. diff --git a/version.h b/version.h index 9a7c502444cdb3..56fc6921885f9a 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.5" -#define RUBY_RELEASE_DATE "2014-12-30" -#define RUBY_PATCHLEVEL 274 +#define RUBY_RELEASE_DATE "2014-12-31" +#define RUBY_PATCHLEVEL 275 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 12 -#define RUBY_RELEASE_DAY 30 +#define RUBY_RELEASE_DAY 31 #include "ruby/version.h" From 50a611e8c367517702ceefca09267cdb8caa3eb0 Mon Sep 17 00:00:00 2001 From: nagachika Date: Mon, 5 Jan 2015 15:01:18 +0000 Subject: [PATCH 281/343] * test/ruby/test_string.rb(test_LSHIFT_neary_long_max): increase timeout for Arch Linux CI environment. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@49150 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ test/ruby/test_string.rb | 2 +- version.h | 10 +++++----- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 380b6deaf5c096..b0537c0f555033 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Mon Jan 5 23:58:50 2015 CHIKANAGA Tomoyuki + + * test/ruby/test_string.rb(test_LSHIFT_neary_long_max): + increase timeout for Arch Linux CI environment. + Wed Dec 31 00:00:09 2014 NARUSE, Yui * lib/net/http.rb (Net::HTTP.proxy_uri): use initializer instead diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb index e510a4984ccd23..4942621392500c 100644 --- a/test/ruby/test_string.rb +++ b/test/ruby/test_string.rb @@ -2227,7 +2227,7 @@ def =~(str) def test_LSHIFT_neary_long_max return unless @cls == String - assert_ruby_status([], <<-'end;', '[ruby-core:61886] [Bug #9709]', timeout: 20) + assert_ruby_status([], <<-'end;', '[ruby-core:61886] [Bug #9709]', timeout: 60) begin a = "a" * 0x4000_0000 a << "a" * 0x1_0000 diff --git a/version.h b/version.h index 56fc6921885f9a..966b6f9d83c455 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.5" -#define RUBY_RELEASE_DATE "2014-12-31" -#define RUBY_PATCHLEVEL 275 +#define RUBY_RELEASE_DATE "2015-01-05" +#define RUBY_PATCHLEVEL 276 -#define RUBY_RELEASE_YEAR 2014 -#define RUBY_RELEASE_MONTH 12 -#define RUBY_RELEASE_DAY 31 +#define RUBY_RELEASE_YEAR 2015 +#define RUBY_RELEASE_MONTH 1 +#define RUBY_RELEASE_DAY 5 #include "ruby/version.h" From 63f9fa6e292920be991116c270d7170f98449684 Mon Sep 17 00:00:00 2001 From: svn Date: Mon, 5 Jan 2015 15:01:32 +0000 Subject: [PATCH 282/343] * 2015-01-06 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@49151 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- version.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/version.h b/version.h index 966b6f9d83c455..377a7bfe42b074 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.5" -#define RUBY_RELEASE_DATE "2015-01-05" +#define RUBY_RELEASE_DATE "2015-01-06" #define RUBY_PATCHLEVEL 276 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 1 -#define RUBY_RELEASE_DAY 5 +#define RUBY_RELEASE_DAY 6 #include "ruby/version.h" From 79d041dbdeeb95db9ef061c343b524463b5f5235 Mon Sep 17 00:00:00 2001 From: nagachika Date: Mon, 5 Jan 2015 15:17:58 +0000 Subject: [PATCH 283/343] merge revision(s) r49148: [Backport #9917] * test/ruby/test_io.rb: added timeout for AIX environment. [ruby-core:62983][Bug #9917] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@49158 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ test/ruby/test_io.rb | 2 +- version.h | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index b0537c0f555033..db219f176120d1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Tue Jan 6 00:04:38 2015 SHIBATA Hiroshi + + * test/ruby/test_io.rb: added timeout for AIX environment. + [ruby-core:62983][Bug #9917] + Mon Jan 5 23:58:50 2015 CHIKANAGA Tomoyuki * test/ruby/test_string.rb(test_LSHIFT_neary_long_max): diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index cf0ac9803e7dc6..77ab97317a6e4c 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -2896,7 +2896,7 @@ def test_io_select_with_many_files } IO.select(tempfiles) - }, bug8080 + }, bug8080, timeout: 30 end def test_read_32bit_boundary diff --git a/version.h b/version.h index 377a7bfe42b074..bd1af211d8d03e 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.5" #define RUBY_RELEASE_DATE "2015-01-06" -#define RUBY_PATCHLEVEL 276 +#define RUBY_PATCHLEVEL 277 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 1 From e8402690742a2af5d7d0fa71943ac354c9833ae9 Mon Sep 17 00:00:00 2001 From: nagachika Date: Wed, 7 Jan 2015 13:38:02 +0000 Subject: [PATCH 284/343] merge revision r48961 partially. * tool/config_files.rb: use config.guess in gcc repo. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@49172 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ tool/config_files.rb | 2 +- version.h | 6 +++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index db219f176120d1..672db57d9c48b4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Wed Jan 7 22:34:52 2015 NARUSE, Yui + + * tool/config_files.rb: use config.guess in gcc repo. + Tue Jan 6 00:04:38 2015 SHIBATA Hiroshi * test/ruby/test_io.rb: added timeout for AIX environment. diff --git a/tool/config_files.rb b/tool/config_files.rb index 676c355e059f94..9c2a4c7dabeb19 100644 --- a/tool/config_files.rb +++ b/tool/config_files.rb @@ -1,6 +1,6 @@ require 'open-uri' -ConfigFiles = "http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=%s;hb=HEAD" +ConfigFiles = "http://gcc.gnu.org/git/?p=gcc.git;a=blob_plain;f=%s;hb=HEAD" def ConfigFiles.download(name, dir = nil) data = URI(self % name).read file = dir ? File.join(dir, name) : name diff --git a/version.h b/version.h index bd1af211d8d03e..5e2f957306aa65 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.5" -#define RUBY_RELEASE_DATE "2015-01-06" -#define RUBY_PATCHLEVEL 277 +#define RUBY_RELEASE_DATE "2015-01-07" +#define RUBY_PATCHLEVEL 278 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 1 -#define RUBY_RELEASE_DAY 6 +#define RUBY_RELEASE_DAY 7 #include "ruby/version.h" From 12ef4f02289dfada188581578d6388d06654c0c5 Mon Sep 17 00:00:00 2001 From: nagachika Date: Tue, 20 Jan 2015 20:31:03 +0000 Subject: [PATCH 285/343] merge revision(s) r44876,r47130,r48988,r48997: [Backport #10640] [Backport #10679] configure.in: use C99 * configure.in: ISO9899:1999 is necessary for strtoll() on FreeBSD 10, (and may be possibly other platforms). * configure.in (NET_LUID): include also ifdef.h as a workaround of a bug in mingw-w64 header. [ruby-core:67103] [Bug #10640] * configure.in (NET_LUID): include winsock2.h instead of windows.h. patch by Jon Forums in [ruby-core:67125]. [Bug #10640] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@49356 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 10 ++++++++++ configure.in | 19 +++++++++++-------- version.h | 6 +++--- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 672db57d9c48b4..36e6de0b4be69b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +Wed Jan 21 04:36:27 2015 Nobuyoshi Nakada + + * configure.in (NET_LUID): include winsock2.h instead of windows.h. + patch by Jon Forums in [ruby-core:67125]. [Bug #10640] + +Wed Jan 21 04:36:27 2015 Nobuyoshi Nakada + + * configure.in (NET_LUID): include also ifdef.h as a workaround of + a bug in mingw-w64 header. [ruby-core:67103] [Bug #10640] + Wed Jan 7 22:34:52 2015 NARUSE, Yui * tool/config_files.rb: use config.guess in gcc repo. diff --git a/configure.in b/configure.in index 5968bbdb14a487..6f8d9072e7093a 100644 --- a/configure.in +++ b/configure.in @@ -816,10 +816,13 @@ if test "$GCC" = yes; then ], [ # ANSI (no XCFLAGS because this is C only) - RUBY_TRY_CFLAGS(-ansi -std=iso9899:199409, [ - RUBY_APPEND_OPTION(warnflags, -ansi -std=iso9899:199409) - RUBY_APPEND_OPTION(strict_warnflags, -ansi -std=iso9899:199409) - ]) + for ansi_options in -std=iso9899:1999 "-ansi -std=iso9899:199409"; do + RUBY_TRY_CFLAGS(${ansi_options}, [ + RUBY_APPEND_OPTIONS(warnflags, ${ansi_options}) + RUBY_APPEND_OPTIONS(strict_warnflags, ${ansi_options}) + ], [ansi_options=]) + test "x${ansi_options}" = x || break + done ]) # suppress annoying -Wstrict-overflow warnings @@ -1054,8 +1057,8 @@ main() ac_cv_func_malloc_usable_size=no { test "$target_cpu" = x64 && ac_cv_func___builtin_setjmp=no; } AC_CHECK_TYPE([NET_LUID], [], [], - [@%:@include - @%:@include ]) + [@%:@include + @%:@include ]) if test x"$ac_cv_type_NET_LUID" = xyes; then AC_DEFINE(HAVE_TYPE_NET_LUID, 1) fi @@ -2699,7 +2702,7 @@ if test "$with_dln_a_out" != yes; then RPATHFLAG=' +b %1$-s' fi rb_cv_dlopen=yes], - [solaris*], [ if test "$GCC" = yes; then + [solaris*], [ if test "$GCC" = yes; then : ${LDSHARED='$(CC) -shared'} if test "$rb_cv_prog_gnu_ld" = yes; then LDFLAGS="$LDFLAGS -Wl,-E" @@ -2818,7 +2821,7 @@ if test "$with_dln_a_out" != yes; then [os2-emx*], [ LDFLAGS="$LDFLAGS -Zomf" ], [nacl], [ LDSHARED='$(CC) -shared' ], - [ : ${LDSHARED='$(LD)'}]) + [ : ${LDSHARED='$(LD)'}]) AC_MSG_RESULT($rb_cv_dlopen) fi if test "${LDSHAREDXX}" = ""; then diff --git a/version.h b/version.h index 5e2f957306aa65..3cae860019c766 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.5" -#define RUBY_RELEASE_DATE "2015-01-07" -#define RUBY_PATCHLEVEL 278 +#define RUBY_RELEASE_DATE "2015-01-21" +#define RUBY_PATCHLEVEL 279 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 1 -#define RUBY_RELEASE_DAY 7 +#define RUBY_RELEASE_DAY 21 #include "ruby/version.h" From 8715551b9c187f86e16764a6de1af62763eb37f0 Mon Sep 17 00:00:00 2001 From: nagachika Date: Wed, 21 Jan 2015 15:38:57 +0000 Subject: [PATCH 286/343] merge revision(s) r48186: [Backport #10448] * load.c (rb_f_load): path name needs to be transcoded to OS path encoding. [ruby-list:49994] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@49366 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ load.c | 8 +++++--- test/ruby/test_require.rb | 22 ++++++++++++++++++++++ version.h | 6 +++--- 4 files changed, 35 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 36e6de0b4be69b..71a2015981bb41 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Thu Jan 22 00:25:15 2015 Nobuyoshi Nakada + + * load.c (rb_f_load): path name needs to be transcoded to OS path + encoding. [ruby-list:49994] + Wed Jan 21 04:36:27 2015 Nobuyoshi Nakada * configure.in (NET_LUID): include winsock2.h instead of windows.h. diff --git a/load.c b/load.c index f31b7aeaca961b..e5014c165faef0 100644 --- a/load.c +++ b/load.c @@ -683,7 +683,7 @@ rb_load_protect(VALUE fname, int wrap, int *state) static VALUE rb_f_load(int argc, VALUE *argv) { - VALUE fname, wrap, path; + VALUE fname, wrap, path, orig_fname; rb_scan_args(argc, argv, "11", &fname, &wrap); @@ -693,10 +693,12 @@ rb_f_load(int argc, VALUE *argv) rb_sourceline()); } - path = rb_find_file(FilePathValue(fname)); + orig_fname = FilePathValue(fname); + fname = rb_str_encode_ospath(orig_fname); + path = rb_find_file(fname); if (!path) { if (!rb_file_load_ok(RSTRING_PTR(fname))) - load_failed(fname); + load_failed(orig_fname); path = fname; } rb_load_internal(path, RTEST(wrap)); diff --git a/test/ruby/test_require.rb b/test/ruby/test_require.rb index 3bd327c8517607..2bdad8f981ca4d 100644 --- a/test/ruby/test_require.rb +++ b/test/ruby/test_require.rb @@ -307,6 +307,28 @@ def test_load2 # [ruby-core:25039] } end + def test_load_ospath + bug = '[ruby-list:49994] path in ospath' + base = "test_load\u{3042 3044 3046 3048 304a}".encode(Encoding::Windows_31J) + path = nil + Tempfile.create([base, ".rb"]) do |t| + path = t.path + + assert_raise_with_message(LoadError, /#{base}/) { + load(File.join(File.dirname(path), base)) + } + + t.puts "warn 'ok'" + t.close + assert_include(path, base) + assert_warn("ok\n", bug) { + assert_nothing_raised(LoadError, bug) { + load(path) + } + } + end + end + def test_tainted_loadpath Tempfile.create(["test_ruby_test_require", ".rb"]) {|t| abs_dir, file = File.split(t.path) diff --git a/version.h b/version.h index 3cae860019c766..535e5d9192106e 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.5" -#define RUBY_RELEASE_DATE "2015-01-21" -#define RUBY_PATCHLEVEL 279 +#define RUBY_RELEASE_DATE "2015-01-22" +#define RUBY_PATCHLEVEL 280 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 1 -#define RUBY_RELEASE_DAY 21 +#define RUBY_RELEASE_DAY 22 #include "ruby/version.h" From f3ac23e422c1cd68b9be355b82c495047786c268 Mon Sep 17 00:00:00 2001 From: nagachika Date: Wed, 21 Jan 2015 15:50:58 +0000 Subject: [PATCH 287/343] merge revision(s) r45375,r48260,r48320,r48746: [Backport #10526] * complax.c: [DOC] Document number conversion of `nil` by @skade [fix GH-570] [ci skip] * object.c, rational.c: ditto. * object.c: fix document of Kernel.Stirng by @suzukaze [fix GH-743][ci skip] * object.c (Module#const_defined?): [DOC] Revise the documentation. Patch by Xavier Noria. [Fixes GH-754] https://github.com/ruby/ruby/pull/754 * object.c: [DOC] Revise documentation by Marcus Stollsteimer at [ruby-core:66368]. [Bug #10526] * #inspect: be more specific about generated string, remove obsolete example. * #nil?: use code examples instead of different call-seq's. * #tap: clarify what is yielded. * Integer(): be more specific about to_int and to_i, remove reference to Ruby 1.8. * Array(): fix error. * Class: fix variable name style and indentation in example. * improve consistency, fix typos and formatting. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@49367 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 26 ++++++++ complex.c | 2 + object.c | 182 +++++++++++++++++++++++++++++------------------------ rational.c | 2 + version.h | 2 +- 5 files changed, 130 insertions(+), 84 deletions(-) diff --git a/ChangeLog b/ChangeLog index 71a2015981bb41..131e7f16af72cf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,29 @@ +Thu Jan 22 00:49:52 2015 Nobuyoshi Nakada + + * object.c: [DOC] Revise documentation by Marcus Stollsteimer at + [ruby-core:66368]. [Bug #10526] + + * #inspect: be more specific about generated string, remove + obsolete example. + * #nil?: use code examples instead of different call-seq's. + * #tap: clarify what is yielded. + * Integer(): be more specific about to_int and to_i, remove + reference to Ruby 1.8. + * Array(): fix error. + * Class: fix variable name style and indentation in example. + * improve consistency, fix typos and formatting. + +Thu Jan 22 00:49:52 2015 Benoit Daloze + + * object.c (Module#const_defined?): [DOC] Revise the documentation. + Patch by Xavier Noria. + [Fixes GH-754] https://github.com/ruby/ruby/pull/754 + +Thu Jan 22 00:49:52 2015 SHIBATA Hiroshi + + * object.c: fix document of Kernel.Stirng by @suzukaze + [fix GH-743][ci skip] + Thu Jan 22 00:25:15 2015 Nobuyoshi Nakada * load.c (rb_f_load): path name needs to be transcoded to OS path diff --git a/complex.c b/complex.c index e1d5ff9f2a97a0..67b45dd6ae097f 100644 --- a/complex.c +++ b/complex.c @@ -433,6 +433,8 @@ f_complex_new2(VALUE klass, VALUE x, VALUE y) * * Complex(1, 2) #=> (1+2i) * Complex('1+2i') #=> (1+2i) + * Complex(nil) #=> TypeError + * Complex(1, nil) #=> TypeError * * Syntax of string form: * diff --git a/object.c b/object.c index 0d7e03a95f1bd1..d7b37e56b38680 100644 --- a/object.c +++ b/object.c @@ -154,7 +154,7 @@ rb_obj_equal(VALUE obj1, VALUE obj2) * capacity of a Fixnum will be truncated before being used. * * The hash value for an object may not be identical across invocations or - * implementations of ruby. If you need a stable identifier across ruby + * implementations of Ruby. If you need a stable identifier across Ruby * invocations and implementations you will need to generate one with a custom * method. */ @@ -233,7 +233,7 @@ rb_obj_class(VALUE obj) * obj.singleton_class -> class * * Returns the singleton class of obj. This method creates - * a new singleton class if obj does not have it. + * a new singleton class if obj does not have one. * * If obj is nil, true, or * false, it returns NilClass, TrueClass, or FalseClass, @@ -314,9 +314,9 @@ init_copy(VALUE dest, VALUE obj) * obj.clone -> an_object * * Produces a shallow copy of obj---the instance variables of - * obj are copied, but not the objects they reference. Copies - * the frozen and tainted state of obj. See also the discussion - * under Object#dup. + * obj are copied, but not the objects they reference. + * clone copies the frozen and tainted state of obj. + * See also the discussion under Object#dup. * * class Klass * attr_accessor :str @@ -364,8 +364,8 @@ rb_obj_clone(VALUE obj) * obj.dup -> an_object * * Produces a shallow copy of obj---the instance variables of - * obj are copied, but not the objects they reference. dup - * copies the tainted state of obj. + * obj are copied, but not the objects they reference. + * dup copies the tainted state of obj. * * This method may have class-specific behavior. If so, that * behavior will be documented under the #+initialize_copy+ method of @@ -379,7 +379,7 @@ rb_obj_clone(VALUE obj) * typically uses the class of the descendant object to create the new * instance. * - * When using #dup any modules that the object has been extended with will not + * When using #dup, any modules that the object has been extended with will not * be copied. * * class Klass @@ -445,7 +445,7 @@ rb_obj_init_dup_clone(VALUE obj, VALUE orig) * Returns a string representing obj. The default * to_s prints the object's class and an encoding of the * object id. As a special case, the top-level object that is the - * initial execution context of Ruby programs returns ``main.'' + * initial execution context of Ruby programs returns ``main''. */ VALUE @@ -462,7 +462,7 @@ rb_any_to_s(VALUE obj) /* * If the default external encoding is ASCII compatible, the encoding of - * inspected result must be compatible with it. + * the inspected result must be compatible with it. * If the default external encoding is ASCII incompatible, * the result must be ASCII only. */ @@ -531,9 +531,10 @@ inspect_obj(VALUE obj, VALUE str, int recur) * obj.inspect -> string * * Returns a string containing a human-readable representation of obj. - * By default, show the class name and the list of the instance variables and + * The default inspect shows the object's class name, + * an encoding of the object id, and a list of the instance variables and * their values (by calling #inspect on each of them). - * User defined classes should override this method to make better + * User defined classes should override this method to provide a better * representation of obj. When overriding this method, it should * return a string whose encoding is compatible with the default external * encoding. @@ -551,13 +552,6 @@ inspect_obj(VALUE obj, VALUE str, int recur) * end * end * Bar.new.inspect #=> "#" - * - * class Baz - * def to_s - * "baz" - * end - * end - * Baz.new.inspect #=> "#" */ static VALUE @@ -680,14 +674,14 @@ rb_class_search_ancestor(VALUE cl, VALUE c) * call-seq: * obj.tap{|x|...} -> obj * - * Yields x to the block, and then returns x. + * Yields self to the block, and then returns self. * The primary purpose of this method is to "tap into" a method chain, * in order to perform operations on intermediate results within the chain. * * (1..10) .tap {|x| puts "original: #{x.inspect}"} * .to_a .tap {|x| puts "array: #{x.inspect}"} * .select {|x| x%2==0} .tap {|x| puts "evens: #{x.inspect}"} - * .map { |x| x*x } .tap {|x| puts "squares: #{x.inspect}"} + * .map {|x| x*x} .tap {|x| puts "squares: #{x.inspect}"} * */ @@ -721,7 +715,7 @@ rb_obj_tap(VALUE obj) * class Baz < Bar * end * - * produces: + * produces: * * New subclass: Bar * New subclass: Baz @@ -743,7 +737,7 @@ rb_obj_tap(VALUE obj) * def some_instance_method() end * end * - * produces: + * produces: * * Adding :some_instance_method * @@ -769,7 +763,7 @@ rb_obj_tap(VALUE obj) * remove_method :some_instance_method * end * - * produces: + * produces: * * Removing :some_instance_method * @@ -957,13 +951,13 @@ rb_obj_tainted(VALUE obj) * * Objects that are marked as tainted will be restricted from various built-in * methods. This is to prevent insecure data, such as command-line arguments - * or strings read from Kernel#gets, from inadvertently compromising the users + * or strings read from Kernel#gets, from inadvertently compromising the user's * system. * - * To check whether an object is tainted, use #tainted? + * To check whether an object is tainted, use #tainted?. * * You should only untaint a tainted object if your code has inspected it and - * determined that it is safe. To do so use #untaint + * determined that it is safe. To do so use #untaint. * * In $SAFE level 3, all newly created objects are tainted and you can't untaint * objects. @@ -1249,7 +1243,7 @@ true_and(VALUE obj, VALUE obj2) * call-seq: * true | obj -> true * - * Or---Returns true. As anObject is an argument to + * Or---Returns true. As obj is an argument to * a method call, it is always evaluated; there is no short-circuit * evaluation in this case. * @@ -1373,10 +1367,12 @@ rb_true(VALUE obj) /* * call-seq: - * nil.nil? -> true - * .nil? -> false + * obj.nil? -> true or false * * Only the object nil responds true to nil?. + * + * Object.new.nil? #=> false + * nil.nil? #=> true */ @@ -1453,7 +1449,7 @@ rb_obj_cmp(VALUE obj1, VALUE obj2) * Instance methods appear as methods in a class when the module is * included, module methods do not. Conversely, module methods may be * called without creating an encapsulating object, while instance - * methods may not. (See Module#module_function) + * methods may not. (See Module#module_function.) * * In the descriptions that follow, the parameter sym refers * to a symbol, which is either a quoted string or a @@ -1476,7 +1472,7 @@ rb_obj_cmp(VALUE obj1, VALUE obj2) * call-seq: * mod.to_s -> string * - * Return a string representing this module or class. For basic + * Returns a string representing this module or class. For basic * classes and modules, this is the name. For singletons, we * show information on the thing we're attached to as well. */ @@ -1536,7 +1532,7 @@ rb_mod_freeze(VALUE mod) * call-seq: * mod === obj -> true or false * - * Case Equality---Returns true if anObject is an + * Case Equality---Returns true if obj is an * instance of mod or one of mod's descendants. Of * limited use for modules, but can be used in case * statements to classify objects by class. @@ -1556,7 +1552,7 @@ rb_mod_eqq(VALUE mod, VALUE arg) * is the same as other. Returns * nil if there's no relationship between the two. * (Think of the relationship in terms of the class definition: - * "class Amod is a subclass of other. Returns * nil if there's no relationship between the two. * (Think of the relationship in terms of the class definition: - * "class Anil if there's no relationship between the two. * (Think of the relationship in terms of the class definition: - * "class AA"). + * "class AA".) * */ @@ -1628,7 +1624,7 @@ rb_mod_ge(VALUE mod, VALUE arg) * Returns true if mod is an ancestor of other. Returns * nil if there's no relationship between the two. * (Think of the relationship in terms of the class definition: - * "class AA"). + * "class AA".) * */ @@ -1875,7 +1871,7 @@ rb_class_new_instance(int argc, VALUE *argv, VALUE klass) * class Bar < Foo; end * Bar.superclass #=> Foo * - * returns nil when the given class hasn't a parent class: + * Returns nil when the given class does not have a parent class: * * BasicObject.superclass #=> nil * @@ -2050,9 +2046,9 @@ rb_mod_attr_accessor(int argc, VALUE *argv, VALUE klass) * mod.const_get(sym, inherit=true) -> obj * mod.const_get(str, inherit=true) -> obj * - * Checks for a constant with the given name in mod + * Checks for a constant with the given name in mod. * If +inherit+ is set, the lookup will also search - * the ancestors (and +Object+ if mod is a +Module+.) + * the ancestors (and +Object+ if mod is a +Module+). * * The value of the constant is returned if a definition is found, * otherwise a +NameError+ is raised. @@ -2078,7 +2074,7 @@ rb_mod_attr_accessor(int argc, VALUE *argv, VALUE klass) * Object.const_get 'Foo::Baz::VAL' # => 10 * Object.const_get 'Foo::Baz::VAL', false # => NameError * - * If neither +sym+ nor +str+ is not a valid constant name a NameError will be + * If the argument is not a valid constant name a +NameError+ will be * raised with a warning "wrong constant name". * * Object.const_get 'foobar' #=> NameError: wrong constant name foobar @@ -2190,7 +2186,7 @@ rb_mod_const_get(int argc, VALUE *argv, VALUE mod) * Math.const_set("HIGH_SCHOOL_PI", 22.0/7.0) #=> 3.14285714285714 * Math::HIGH_SCHOOL_PI - Math::PI #=> 0.00126448926734968 * - * If neither +sym+ nor +str+ is not a valid constant name a NameError will be + * If +sym+ or +str+ is not a valid constant name a +NameError+ will be * raised with a warning "wrong constant name". * * Object.const_set('foobar', 42) #=> NameError: wrong constant name foobar @@ -2210,20 +2206,39 @@ rb_mod_const_set(VALUE mod, VALUE name, VALUE value) * mod.const_defined?(sym, inherit=true) -> true or false * mod.const_defined?(str, inherit=true) -> true or false * - * Checks for a constant with the given name in mod - * If +inherit+ is set, the lookup will also search - * the ancestors (and +Object+ if mod is a +Module+.) + * Says whether _mod_ or its ancestors have a constant with the given name: * - * Returns whether or not a definition is found: + * Float.const_defined?(:EPSILON) #=> true, found in Float itself + * Float.const_defined?("String") #=> true, found in Object (ancestor) + * BasicObject.const_defined?(:Hash) #=> false * - * Math.const_defined? "PI" #=> true - * IO.const_defined? :SYNC #=> true - * IO.const_defined? :SYNC, false #=> false + * If _mod_ is a +Module+, additionally +Object+ and its ancestors are checked: * - * If neither +sym+ nor +str+ is not a valid constant name a NameError will be - * raised with a warning "wrong constant name". + * Math.const_defined?(:String) #=> true, found in Object + * + * In each of the checked classes or modules, if the constant is not present + * but there is an autoload for it, +true+ is returned directly without + * autoloading: + * + * module Admin + * autoload :User, 'admin/user' + * end + * Admin.const_defined?(:User) #=> true + * + * If the constant is not found the callback +const_missing+ is *not* called + * and the method returns +false+. + * + * If +inherit+ is false, the lookup only checks the constants in the receiver: * - * Hash.const_defined? 'foobar' #=> NameError: wrong constant name foobar + * IO.const_defined?(:SYNC) #=> true, found in File::Constants (ancestor) + * IO.const_defined?(:SYNC, false) #=> false, not found in IO itself + * + * In this case, the same logic for autoloading applies. + * + * If the argument is not a valid constant name a +NameError+ is raised with the + * message "wrong constant name _name_": + * + * Hash.const_defined? 'foobar' #=> NameError: wrong constant name foobar * */ @@ -2373,10 +2388,10 @@ rb_obj_ivar_get(VALUE obj, VALUE iv) * obj.instance_variable_set(symbol, obj) -> obj * obj.instance_variable_set(string, obj) -> obj * - * Sets the instance variable names by symbol to - * object, thereby frustrating the efforts of the class's + * Sets the instance variable named by symbol to the given + * object, thereby frustrating the efforts of the class's * author to attempt to provide proper encapsulation. The variable - * did not have to exist prior to this call. + * does not have to exist prior to this call. * If the instance variable name is passed as a string, that string * is converted to a symbol. * @@ -2446,7 +2461,7 @@ rb_obj_ivar_defined(VALUE obj, VALUE iv) * * Returns the value of the given class variable (or throws a * NameError exception). The @@ part of the - * variable name should be included for regular class variables + * variable name should be included for regular class variables. * String arguments are converted to symbols. * * class Fred @@ -2482,8 +2497,8 @@ rb_mod_cvar_get(VALUE obj, VALUE iv) * obj.class_variable_set(symbol, obj) -> obj * obj.class_variable_set(string, obj) -> obj * - * Sets the class variable names by symbol to - * object. + * Sets the class variable named by symbol to the given + * object. * If the class variable name is passed as a string, that string * is converted to a symbol. * @@ -2740,24 +2755,26 @@ rb_Integer(VALUE val) /* * call-seq: - * Integer(arg,base=0) -> integer + * Integer(arg, base=0) -> integer * * Converts arg to a Fixnum or Bignum. * Numeric types are converted directly (with floating point numbers - * being truncated). base (0, or between 2 and 36) is a base for + * being truncated). base (0, or between 2 and 36) is a base for * integer string representation. If arg is a String, - * when base is omitted or equals to zero, radix indicators + * when base is omitted or equals zero, radix indicators * (0, 0b, and 0x) are honored. * In any case, strings should be strictly conformed to numeric * representation. This behavior is different from that of - * String#to_i. Non string values will be converted using - * to_int, and to_i. + * String#to_i. Non string values will be converted by first + * trying to_int, then to_i. Passing nil + * raises a TypeError. * * Integer(123.999) #=> 123 * Integer("0x1a") #=> 26 * Integer(Time.new) #=> 1204973019 * Integer("0930", 10) #=> 930 * Integer("111", 2) #=> 7 + * Integer(nil) #=> TypeError */ static VALUE @@ -2923,8 +2940,8 @@ rb_Float(VALUE val) * Float(arg) -> float * * Returns arg converted to a float. Numeric types are converted - * directly, the rest are converted using arg.to_f. As of Ruby - * 1.8, converting nil generates a TypeError. + * directly, the rest are converted using arg.to_f. + * Converting nil generates a TypeError. * * Float(1) #=> 1.0 * Float("123.456") #=> 123.456 @@ -2996,8 +3013,9 @@ rb_String(VALUE val) * call-seq: * String(arg) -> string * - * Converts arg to a String by calling its - * to_s method. + * Returns arg as a String. + * + * First tries to call its to_str method, then its to_s method. * * String(self) #=> "main" * String(self.class) #=> "Object" @@ -3030,7 +3048,7 @@ rb_Array(VALUE val) * * Returns +arg+ as an Array. * - * First tries to call Array#to_ary on +arg+, then Array#to_a. + * First tries to call to_ary on +arg+, then to_a. * * Array(1..5) #=> [1, 2, 3, 4, 5] */ @@ -3085,7 +3103,7 @@ rb_f_hash(VALUE obj, VALUE arg) * Typically, you create a new class by using: * * class Name - * # some class describing the class behavior + * # some code describing the class behavior * end * * When a new class is created, an object of type Class is initialized and @@ -3097,19 +3115,17 @@ rb_f_hash(VALUE obj, VALUE arg) * Class: * * class Class - * alias oldNew new - * def new(*args) - * print "Creating a new ", self.name, "\n" - * oldNew(*args) - * end - * end - * - * - * class Name - * end + * alias old_new new + * def new(*args) + * print "Creating a new ", self.name, "\n" + * old_new(*args) + * end + * end * + * class Name + * end * - * n = Name.new + * n = Name.new * * produces: * @@ -3117,7 +3133,7 @@ rb_f_hash(VALUE obj, VALUE arg) * * Classes, modules, and objects are interrelated. In the diagram * that follows, the vertical arrows represent inheritance, and the - * parentheses meta-classes. All metaclasses are instances + * parentheses metaclasses. All metaclasses are instances * of the class `Class'. * +---------+ +-... * | | | @@ -3178,7 +3194,7 @@ rb_f_hash(VALUE obj, VALUE arg) * * BasicObject does not include Kernel (for methods like +puts+) and * BasicObject is outside of the namespace of the standard library so common - * classes will not be found without a using a full class path. + * classes will not be found without using a full class path. * * A variety of strategies can be used to provide useful portions of the * standard library to subclasses of BasicObject. A subclass could @@ -3216,7 +3232,7 @@ rb_f_hash(VALUE obj, VALUE arg) * * Object is the default root of all Ruby objects. Object inherits from * BasicObject which allows creating alternate object hierarchies. Methods - * on object are available to all classes unless explicitly overridden. + * on Object are available to all classes unless explicitly overridden. * * Object mixes in the Kernel module, making the built-in kernel functions * globally accessible. Although the instance methods of Object are defined diff --git a/rational.c b/rational.c index 7bc72063768d51..d8bee601e09937 100644 --- a/rational.c +++ b/rational.c @@ -584,6 +584,8 @@ f_rational_new_no_reduce2(VALUE klass, VALUE x, VALUE y) * * Rational(1, 2) #=> (1/2) * Rational('1/2') #=> (1/2) + * Rational(nil) #=> TypeError + * Rational(1, nil) #=> TypeError * * Syntax of string form: * diff --git a/version.h b/version.h index 535e5d9192106e..26416efee6a9b2 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.5" #define RUBY_RELEASE_DATE "2015-01-22" -#define RUBY_PATCHLEVEL 280 +#define RUBY_PATCHLEVEL 281 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 1 From 83c5b533e36761141ed4dbd9db28e74520cb0ffd Mon Sep 17 00:00:00 2001 From: nagachika Date: Wed, 21 Jan 2015 15:59:11 +0000 Subject: [PATCH 288/343] merge revision(s) r48484: [Backport #10524] * parse.y (symbol_list): fix the node type of literal symbol list with no interpolation. [ruby-core:66343] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@49368 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ parse.y | 8 +++++++- test/ruby/test_literal.rb | 10 ++++++++++ version.h | 2 +- 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 131e7f16af72cf..c8ed9f20537c76 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Thu Jan 22 00:54:00 2015 Nobuyoshi Nakada + + * parse.y (symbol_list): fix the node type of literal symbol list + with no interpolation. [ruby-core:66343] + Thu Jan 22 00:49:52 2015 Nobuyoshi Nakada * object.c: [DOC] Revise documentation by Marcus Stollsteimer at diff --git a/parse.y b/parse.y index 5c62e36d23cfd7..577dc37d83897f 100644 --- a/parse.y +++ b/parse.y @@ -4033,7 +4033,13 @@ symbol_list : /* none */ { /*%%%*/ $2 = evstr2dstr($2); - nd_set_type($2, NODE_DSYM); + if (nd_type($2) == NODE_DSTR) { + nd_set_type($2, NODE_DSYM); + } + else { + nd_set_type($2, NODE_LIT); + $2->nd_lit = rb_str_intern($2->nd_lit); + } $$ = list_append($1, $2); /*% $$ = dispatch2(symbols_add, $1, $2); diff --git a/test/ruby/test_literal.rb b/test/ruby/test_literal.rb index e4c35e03d9226f..5fa326acfec25c 100644 --- a/test/ruby/test_literal.rb +++ b/test/ruby/test_literal.rb @@ -434,4 +434,14 @@ def test_float } end + def test_symbol_list + assert_equal([:foo, :bar], %i[foo bar]) + assert_equal([:"\"foo"], %i["foo]) + + x = 10 + assert_equal([:foo, :b10], %I[foo b#{x}]) + assert_equal([:"\"foo10"], %I["foo#{x}]) + + assert_ruby_status(["--disable-gems", "--dump=parsetree"], "%I[foo bar]") + end end diff --git a/version.h b/version.h index 26416efee6a9b2..8d2b26dc295e42 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.5" #define RUBY_RELEASE_DATE "2015-01-22" -#define RUBY_PATCHLEVEL 281 +#define RUBY_PATCHLEVEL 282 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 1 From 4b0a168d7b82d7b9e50f61fe8d7a336dc8d84316 Mon Sep 17 00:00:00 2001 From: nagachika Date: Wed, 21 Jan 2015 16:09:59 +0000 Subject: [PATCH 289/343] merge revision(s) r48744,r48752: [Backport #10579] * eval.c (rb_frame_last_func): return the most recent frame method name. * thread.c (recursive_list_access): use the last method name, instead of the current method name which can be unset in some cases, not to use a symbol by the invalid ID. [ruby-core:66742] [Bug #10579] * thread.c (exec_recursive): use the same last method name as recursive_push in the error message when recursive_pop failed. [ruby-core:66742] [Bug #10579] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@49369 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 16 ++++++++++++++++ eval.c | 13 +++++++++++++ test/ruby/test_objectspace.rb | 7 +++++++ thread.c | 30 ++++++++++++++++++------------ version.h | 2 +- 5 files changed, 55 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index c8ed9f20537c76..5c67c20dba386f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +Thu Jan 22 01:02:16 2015 Nobuyoshi Nakada + + * thread.c (exec_recursive): use the same last method name as + recursive_push in the error message when recursive_pop failed. + [ruby-core:66742] [Bug #10579] + +Thu Jan 22 01:02:16 2015 Nobuyoshi Nakada + + * eval.c (rb_frame_last_func): return the most recent frame method + name. + + * thread.c (recursive_list_access): use the last method name, + instead of the current method name which can be unset in some + cases, not to use a symbol by the invalid ID. + [ruby-core:66742] [Bug #10579] + Thu Jan 22 00:54:00 2015 Nobuyoshi Nakada * parse.y (symbol_list): fix the node type of literal symbol list diff --git a/eval.c b/eval.c index 7f002270a55d3f..ed1eacead1969b 100644 --- a/eval.c +++ b/eval.c @@ -978,6 +978,19 @@ prev_frame_func(void) return frame_func_id(prev_cfp); } +ID +rb_frame_last_func(void) +{ + rb_thread_t *th = GET_THREAD(); + rb_control_frame_t *cfp = th->cfp; + ID mid; + + while (!(mid = frame_func_id(cfp)) && + (cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp), + !RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(th, cfp))); + return mid; +} + /* * call-seq: * append_features(mod) -> mod diff --git a/test/ruby/test_objectspace.rb b/test/ruby/test_objectspace.rb index a4198f8ed426a8..6eb7c8b2059313 100644 --- a/test/ruby/test_objectspace.rb +++ b/test/ruby/test_objectspace.rb @@ -98,4 +98,11 @@ def test_each_object } End end + + def test_each_object_recursive_key + assert_normal_exit(<<-'end;', '[ruby-core:66742] [Bug #10579]') + h = {["foo"]=>nil} + p Thread.current[:__recursive_key__] + end; + end end diff --git a/thread.c b/thread.c index d9df90272e8049..b24d29e087386d 100644 --- a/thread.c +++ b/thread.c @@ -4763,6 +4763,8 @@ ident_hash_new(void) return hash; } +ID rb_frame_last_func(void); + /* * Returns the current "recursive list" used to detect recursion. * This list is a hash table, unique for the current thread and for @@ -4770,10 +4772,9 @@ ident_hash_new(void) */ static VALUE -recursive_list_access(void) +recursive_list_access(VALUE sym) { volatile VALUE hash = rb_thread_local_aref(rb_thread_current(), recursive_key); - VALUE sym = ID2SYM(rb_frame_this_func()); VALUE list; if (NIL_P(hash) || !RB_TYPE_P(hash, T_HASH)) { hash = ident_hash_new(); @@ -4875,25 +4876,23 @@ recursive_push(VALUE list, VALUE obj, VALUE paired_obj) * Assumes the recursion list is valid. */ -static void +static int recursive_pop(VALUE list, VALUE obj, VALUE paired_obj) { if (paired_obj) { VALUE pair_list = rb_hash_lookup2(list, obj, Qundef); if (pair_list == Qundef) { - VALUE symname = rb_inspect(ID2SYM(rb_frame_this_func())); - VALUE thrname = rb_inspect(rb_thread_current()); - rb_raise(rb_eTypeError, "invalid inspect_tbl pair_list for %s in %s", - StringValuePtr(symname), StringValuePtr(thrname)); + return 0; } if (RB_TYPE_P(pair_list, T_HASH)) { rb_hash_delete(pair_list, paired_obj); if (!RHASH_EMPTY_P(pair_list)) { - return; /* keep hash until is empty */ + return 1; /* keep hash until is empty */ } } } rb_hash_delete(list, obj); + return 1; } struct exec_recursive_params { @@ -4927,9 +4926,11 @@ static VALUE exec_recursive(VALUE (*func) (VALUE, VALUE, int), VALUE obj, VALUE pairid, VALUE arg, int outer) { VALUE result = Qundef; + const ID mid = rb_frame_last_func(); + const VALUE sym = mid ? ID2SYM(mid) : ID2SYM(idNULL); struct exec_recursive_params p; int outermost; - p.list = recursive_list_access(); + p.list = recursive_list_access(sym); p.objid = rb_obj_id(obj); p.obj = obj; p.pairid = pairid; @@ -4951,8 +4952,8 @@ exec_recursive(VALUE (*func) (VALUE, VALUE, int), VALUE obj, VALUE pairid, VALUE recursive_push(p.list, ID2SYM(recursive_key), 0); recursive_push(p.list, p.objid, p.pairid); result = rb_catch_protect(p.list, exec_recursive_i, (VALUE)&p, &state); - recursive_pop(p.list, p.objid, p.pairid); - recursive_pop(p.list, ID2SYM(recursive_key), 0); + if (!recursive_pop(p.list, p.objid, p.pairid)) goto invalid; + if (!recursive_pop(p.list, ID2SYM(recursive_key), 0)) goto invalid; if (state) JUMP_TAG(state); if (result == p.list) { result = (*func)(obj, arg, TRUE); @@ -4965,7 +4966,12 @@ exec_recursive(VALUE (*func) (VALUE, VALUE, int), VALUE obj, VALUE pairid, VALUE result = (*func)(obj, arg, FALSE); } POP_TAG(); - recursive_pop(p.list, p.objid, p.pairid); + if (!recursive_pop(p.list, p.objid, p.pairid)) { + invalid: + rb_raise(rb_eTypeError, "invalid inspect_tbl pair_list " + "for %+"PRIsVALUE" in %+"PRIsVALUE, + sym, rb_thread_current()); + } if (state) JUMP_TAG(state); } } diff --git a/version.h b/version.h index 8d2b26dc295e42..6b50071fe7e4ee 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.5" #define RUBY_RELEASE_DATE "2015-01-22" -#define RUBY_PATCHLEVEL 282 +#define RUBY_PATCHLEVEL 283 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 1 From bdfd5fd1ab5895efcf933e45af8ef1815ad54a13 Mon Sep 17 00:00:00 2001 From: nagachika Date: Wed, 21 Jan 2015 16:15:13 +0000 Subject: [PATCH 290/343] merge revision(s) r48884,r48885: [Backport #10615] * signal.c (ruby_signal): since SIGKILL is not supported by MSVCRT, should be treated before calling signal(3). [Bug #10615] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@49370 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ signal.c | 11 +++++++++++ version.h | 2 +- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 5c67c20dba386f..6cdb7903b932b1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Thu Jan 22 01:14:12 2015 NAKAMURA Usaku + + * signal.c (ruby_signal): since SIGKILL is not supported by MSVCRT, + should be treated before calling signal(3). + [Bug #10615] + Thu Jan 22 01:02:16 2015 Nobuyoshi Nakada * thread.c (exec_recursive): use the same last method name as diff --git a/signal.c b/signal.c index 3db044e517a2fd..c858428fa8b40e 100644 --- a/signal.c +++ b/signal.c @@ -601,6 +601,17 @@ posix_signal(int signum, sighandler_t handler) return ruby_signal(signum, handler); } +#elif defined _WIN32 +static inline sighandler_t +ruby_signal(int signum, sighandler_t handler) +{ + if (signum == SIGKILL) { + errno = EINVAL; + return SIG_ERR; + } + return signal(signum, handler); +} + #else /* !POSIX_SIGNAL */ #define ruby_signal(sig,handler) (/* rb_trap_accept_nativethreads[(sig)] = 0,*/ signal((sig),(handler))) #if 0 /* def HAVE_NATIVETHREAD */ diff --git a/version.h b/version.h index 6b50071fe7e4ee..d717be542a1b3b 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.5" #define RUBY_RELEASE_DATE "2015-01-22" -#define RUBY_PATCHLEVEL 283 +#define RUBY_PATCHLEVEL 284 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 1 From 2558571db146e6463501db9b006436d8e22ba6f3 Mon Sep 17 00:00:00 2001 From: nagachika Date: Thu, 22 Jan 2015 11:51:16 +0000 Subject: [PATCH 291/343] merge revision(s) r48923: [Backport #10633] * ext/openssl/ossl_cipher.c (ossl_cipher_update_long): update huge data gradually not to exceed INT_MAX. workaround of OpenSSL API limitation. [ruby-core:67043] [Bug #10633] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@49383 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ ext/openssl/ossl_cipher.c | 44 ++++++++++++++++++++++++++++++++------- version.h | 2 +- 3 files changed, 44 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6cdb7903b932b1..5ada4e4ebd2145 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Thu Jan 22 20:40:36 2015 Nobuyoshi Nakada + + * ext/openssl/ossl_cipher.c (ossl_cipher_update_long): update huge + data gradually not to exceed INT_MAX. workaround of OpenSSL API + limitation. [ruby-core:67043] [Bug #10633] + Thu Jan 22 01:14:12 2015 NAKAMURA Usaku * signal.c (ruby_signal): since SIGKILL is not supported by MSVCRT, diff --git a/ext/openssl/ossl_cipher.c b/ext/openssl/ossl_cipher.c index df6fd108878b40..0fa740e1cb3638 100644 --- a/ext/openssl/ossl_cipher.c +++ b/ext/openssl/ossl_cipher.c @@ -329,6 +329,33 @@ ossl_cipher_pkcs5_keyivgen(int argc, VALUE *argv, VALUE self) return Qnil; } +static int +ossl_cipher_update_long(EVP_CIPHER_CTX *ctx, unsigned char *out, long *out_len_ptr, + const unsigned char *in, long in_len) +{ + int out_part_len; + long out_len = 0; +#define UPDATE_LENGTH_LIMIT INT_MAX + +#if SIZEOF_LONG > UPDATE_LENGTH_LIMIT + if (in_len > UPDATE_LENGTH_LIMIT) { + const int in_part_len = (UPDATE_LENGTH_LIMIT / 2 + 1) & ~1; + do { + if (!EVP_CipherUpdate(ctx, out ? (out + out_len) : 0, + &out_part_len, in, in_part_len)) + return 0; + out_len += out_part_len; + in += in_part_len; + } while ((in_len -= in_part_len) > UPDATE_LENGTH_LIMIT); + } +#endif + if (!EVP_CipherUpdate(ctx, out ? (out + out_len) : 0, + &out_part_len, in, (int)in_len)) + return 0; + if (out_len_ptr) *out_len_ptr = out_len += out_part_len; + return 1; +} + /* * call-seq: * cipher.update(data [, buffer]) -> string or buffer @@ -347,17 +374,21 @@ ossl_cipher_update(int argc, VALUE *argv, VALUE self) { EVP_CIPHER_CTX *ctx; unsigned char *in; - int in_len, out_len; + long in_len, out_len; VALUE data, str; rb_scan_args(argc, argv, "11", &data, &str); StringValue(data); in = (unsigned char *)RSTRING_PTR(data); - if ((in_len = RSTRING_LENINT(data)) == 0) + if ((in_len = RSTRING_LEN(data)) == 0) ossl_raise(rb_eArgError, "data must not be empty"); GetCipher(self, ctx); out_len = in_len+EVP_CIPHER_CTX_block_size(ctx); + if (out_len <= 0) { + ossl_raise(rb_eRangeError, + "data too big to make output buffer: %ld bytes", in_len); + } if (NIL_P(str)) { str = rb_str_new(0, out_len); @@ -366,7 +397,7 @@ ossl_cipher_update(int argc, VALUE *argv, VALUE self) rb_str_resize(str, out_len); } - if (!EVP_CipherUpdate(ctx, (unsigned char *)RSTRING_PTR(str), &out_len, in, in_len)) + if (!ossl_cipher_update_long(ctx, (unsigned char *)RSTRING_PTR(str), &out_len, in, in_len)) ossl_raise(eCipherError, NULL); assert(out_len < RSTRING_LEN(str)); rb_str_set_len(str, out_len); @@ -506,17 +537,16 @@ ossl_cipher_set_auth_data(VALUE self, VALUE data) { EVP_CIPHER_CTX *ctx; unsigned char *in; - int in_len; - int out_len; + long in_len, out_len; StringValue(data); in = (unsigned char *) RSTRING_PTR(data); - in_len = RSTRING_LENINT(data); + in_len = RSTRING_LEN(data); GetCipher(self, ctx); - if (!EVP_CipherUpdate(ctx, NULL, &out_len, in, in_len)) + if (!ossl_cipher_update_long(ctx, NULL, &out_len, in, in_len)) ossl_raise(eCipherError, "couldn't set additional authenticated data"); return data; diff --git a/version.h b/version.h index d717be542a1b3b..70a7666bf85d82 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.5" #define RUBY_RELEASE_DATE "2015-01-22" -#define RUBY_PATCHLEVEL 284 +#define RUBY_PATCHLEVEL 285 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 1 From 3fb0936a985d6aa56ce73025572ad06aa5f337e8 Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 1 Feb 2015 17:58:02 +0000 Subject: [PATCH 292/343] merge revision(s) r49463: [Backport #10814] signal.c: SIGBUS by stack overflow on Funtoo * signal.c (sigbus): seems that Funtoo Linux also delivers SIGBUS at stack overflow. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@49467 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- signal.c | 3 ++- version.h | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/signal.c b/signal.c index c858428fa8b40e..346d68d7587f16 100644 --- a/signal.c +++ b/signal.c @@ -780,7 +780,8 @@ sigbus(int sig SIGINFO_ARG) * and it's delivered as SIGBUS instead of SIGSEGV to userland. It's crazy * wrong IMHO. but anyway we have to care it. Sigh. */ -#if defined __APPLE__ + /* Seems Linux also delivers SIGBUS. */ +#if defined __APPLE__ || defined __linux__ CHECK_STACK_OVERFLOW(); #endif rb_bug("Bus Error" MESSAGE_FAULT_ADDRESS); diff --git a/version.h b/version.h index 70a7666bf85d82..184a96175d8d73 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.5" -#define RUBY_RELEASE_DATE "2015-01-22" -#define RUBY_PATCHLEVEL 285 +#define RUBY_RELEASE_DATE "2015-02-02" +#define RUBY_PATCHLEVEL 286 #define RUBY_RELEASE_YEAR 2015 -#define RUBY_RELEASE_MONTH 1 -#define RUBY_RELEASE_DAY 22 +#define RUBY_RELEASE_MONTH 2 +#define RUBY_RELEASE_DAY 2 #include "ruby/version.h" From baa85be5519976b13c2bf1cc295bea0623165aa6 Mon Sep 17 00:00:00 2001 From: nagachika Date: Mon, 2 Feb 2015 13:39:29 +0000 Subject: [PATCH 293/343] merge revision(s) r48886: [Backport #10210] * configure.in (rb_cv_binary_elf): get rid of -e option of cat which is not available on BusyBox, use tr instead. [ruby-core:64824] [Bug #10210] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@49470 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ configure.in | 4 ++-- version.h | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5ada4e4ebd2145..50e3627c06d2bd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Mon Feb 2 22:38:53 2015 Nobuyoshi Nakada + + * configure.in (rb_cv_binary_elf): get rid of -e option of cat + which is not available on BusyBox, use tr instead. + [ruby-core:64824] [Bug #10210] + Thu Jan 22 20:40:36 2015 Nobuyoshi Nakada * ext/openssl/ossl_cipher.c (ossl_cipher_update_long): update huge diff --git a/configure.in b/configure.in index 6f8d9072e7093a..cc8849eb459946 100644 --- a/configure.in +++ b/configure.in @@ -2620,8 +2620,8 @@ AC_ARG_WITH(dln-a-out, AC_CACHE_CHECK(whether ELF binaries are produced, rb_cv_binary_elf, [AC_TRY_LINK([],[], [ -AS_CASE(["`head -1 conftest$EXEEXT | cat -e`"], -['^?ELF'*], [rb_cv_binary_elf=yes], [rb_cv_binary_elf=no])], +AS_CASE(["`head -1 conftest$EXEEXT | tr -dc '\177ELF' | tr '\177' .`"], +[.ELF*], [rb_cv_binary_elf=yes], [rb_cv_binary_elf=no])], rb_cv_binary_elf=no)]) if test "$rb_cv_binary_elf" = yes; then diff --git a/version.h b/version.h index 184a96175d8d73..9150cbf0aab4ff 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.5" #define RUBY_RELEASE_DATE "2015-02-02" -#define RUBY_PATCHLEVEL 286 +#define RUBY_PATCHLEVEL 287 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 2 From 00a360a93dc9ac5e32cfa56600b2a10ea42c685a Mon Sep 17 00:00:00 2001 From: nagachika Date: Mon, 2 Feb 2015 13:45:35 +0000 Subject: [PATCH 294/343] merge revision(s) r48534: [Backport #10412] * lib/resolv.rb: fall back if canonicalization fails. Thanks Vit Ondruch for the patch! [ruby-core:65836] * test/resolv/test_dns.rb: test for patch git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@49471 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ lib/resolv.rb | 4 ++++ test/resolv/test_dns.rb | 14 ++++++++++++++ version.h | 2 +- 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 50e3627c06d2bd..c65f261f438f0d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Mon Feb 2 22:43:42 2015 Aaron Patterson + + * lib/resolv.rb: fall back if canonicalization fails. + Thanks Vit Ondruch for the patch! [ruby-core:65836] + + * test/resolv/test_dns.rb: test for patch + Mon Feb 2 22:38:53 2015 Nobuyoshi Nakada * configure.in (rb_cv_binary_elf): get rid of -e option of cat diff --git a/lib/resolv.rb b/lib/resolv.rb index 60b2d9091c20e8..47457027b19db7 100644 --- a/lib/resolv.rb +++ b/lib/resolv.rb @@ -1070,6 +1070,10 @@ def generate_candidates(name) candidates = [] end candidates.concat(@search.map {|domain| Name.new(name.to_a + domain)}) + fname = Name.create("#{name}.") + if !candidates.include?(fname) + candidates << fname + end end return candidates end diff --git a/test/resolv/test_dns.rb b/test/resolv/test_dns.rb index 07396fb177de8e..4d83d88a17448c 100644 --- a/test/resolv/test_dns.rb +++ b/test/resolv/test_dns.rb @@ -23,6 +23,20 @@ def with_udp(host, port) end end + # [ruby-core:65836] + def test_resolve_with_2_ndots + conf = Resolv::DNS::Config.new :nameserver => ['127.0.0.1'], :ndots => 2 + assert conf.single? + + candidates = [] + conf.resolv('example.com') { |candidate, *args| + candidates << candidate + raise Resolv::DNS::Config::NXDomain + } + n = Resolv::DNS::Name.create 'example.com.' + assert_equal n, candidates.last + end + def test_query_ipv4_address begin OpenSSL diff --git a/version.h b/version.h index 9150cbf0aab4ff..edd7a0e80ba922 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.5" #define RUBY_RELEASE_DATE "2015-02-02" -#define RUBY_PATCHLEVEL 287 +#define RUBY_PATCHLEVEL 288 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 2 From 997f821a58a7295436e64443ab4bd1d550cd6919 Mon Sep 17 00:00:00 2001 From: nagachika Date: Mon, 2 Feb 2015 13:54:38 +0000 Subject: [PATCH 295/343] merge revision(s) r48160: [Backport #10432] * proc.c (method_proc): the receiver of binding from method should be same as the receiver of the method. [ruby-core:65917] [Bug #10432] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@49472 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ proc.c | 10 ++++++++++ test/ruby/test_proc.rb | 5 ++++- version.h | 2 +- 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index c65f261f438f0d..a248fe72e3d2de 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Mon Feb 2 22:47:35 2015 Nobuyoshi Nakada + + * proc.c (method_proc): the receiver of binding from method should + be same as the receiver of the method. + [ruby-core:65917] [Bug #10432] + Mon Feb 2 22:43:42 2015 Aaron Patterson * lib/resolv.rb: fall back if canonicalization fails. diff --git a/proc.c b/proc.c index 66ffa4c0410f27..a13452329de747 100644 --- a/proc.c +++ b/proc.c @@ -2317,7 +2317,10 @@ static VALUE method_proc(VALUE method) { VALUE procval; + struct METHOD *meth; rb_proc_t *proc; + rb_env_t *env; + /* * class Method * def to_proc @@ -2327,9 +2330,16 @@ method_proc(VALUE method) * end * end */ + TypedData_Get_Struct(method, struct METHOD, &method_data_type, meth); procval = rb_iterate(mlambda, 0, bmcall, method); GetProcPtr(procval, proc); proc->is_from_method = 1; + proc->block.self = meth->recv; + proc->block.klass = meth->defined_class; + GetEnvPtr(proc->envval, env); + env->block.self = meth->recv; + env->block.klass = meth->defined_class; + env->block.iseq = method_get_iseq(meth->me->def); return procval; } diff --git a/test/ruby/test_proc.rb b/test/ruby/test_proc.rb index 1c8a053cca84fe..06f137fdd1ca46 100644 --- a/test/ruby/test_proc.rb +++ b/test/ruby/test_proc.rb @@ -202,7 +202,10 @@ def m_block_given? def test_method_to_proc b = block() assert_equal "OK", b.call - assert_instance_of(Binding, b.binding, '[ruby-core:25589]') + b = b.binding + assert_instance_of(Binding, b, '[ruby-core:25589]') + bug10432 = '[ruby-core:65919] [Bug #10432]' + assert_same(self, b.eval("self"), bug10432) end def test_block_given_method diff --git a/version.h b/version.h index edd7a0e80ba922..7a63fe718178c0 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.5" #define RUBY_RELEASE_DATE "2015-02-02" -#define RUBY_PATCHLEVEL 288 +#define RUBY_PATCHLEVEL 289 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 2 From b366c72ae1523f7dc25766d6191f77cb96a0f844 Mon Sep 17 00:00:00 2001 From: nagachika Date: Mon, 2 Feb 2015 13:58:21 +0000 Subject: [PATCH 296/343] merge revision(s) r48360,r48364: [Backport #10493] * ext/etc/etc.c (etc_getlogin): set login name encoding properly. [ruby-core:66163] [Bug #10493] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@49473 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ ext/etc/etc.c | 11 +++++++++-- test/etc/test_etc.rb | 4 +++- version.h | 2 +- win32/win32.c | 10 +++++++--- 5 files changed, 25 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index a248fe72e3d2de..889bb6d939d173 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Mon Feb 2 22:57:30 2015 Nobuyoshi Nakada + + * ext/etc/etc.c (etc_getlogin): set login name encoding properly. + [ruby-core:66163] [Bug #10493] + Mon Feb 2 22:47:35 2015 Nobuyoshi Nakada * proc.c (method_proc): the receiver of binding from method should diff --git a/ext/etc/etc.c b/ext/etc/etc.c index 18d425a8bfd7b2..3d195e44c64928 100644 --- a/ext/etc/etc.c +++ b/ext/etc/etc.c @@ -67,8 +67,15 @@ etc_getlogin(VALUE obj) login = getenv("USER"); #endif - if (login) - return rb_tainted_str_new2(login); + if (login) { +#ifdef _WIN32 + rb_encoding *extenc = rb_utf8_encoding(); +#else + rb_encoding *extenc = rb_locale_encoding(); +#endif + return rb_external_str_new_with_enc(login, strlen(login), extenc); + } + return Qnil; } diff --git a/test/etc/test_etc.rb b/test/etc/test_etc.rb index c105122af12481..946be9bdf664db 100644 --- a/test/etc/test_etc.rb +++ b/test/etc/test_etc.rb @@ -4,7 +4,9 @@ class TestEtc < Test::Unit::TestCase def test_getlogin s = Etc.getlogin - assert(s.is_a?(String) || s == nil, "getlogin must return a String or nil") + return if s == nil + assert(s.is_a?(String), "getlogin must return a String or nil") + assert_predicate(s, :valid_encoding?, "login name should be a valid string") end def test_passwd diff --git a/version.h b/version.h index 7a63fe718178c0..152362f25662e9 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.5" #define RUBY_RELEASE_DATE "2015-02-02" -#define RUBY_PATCHLEVEL 289 +#define RUBY_PATCHLEVEL 290 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 2 diff --git a/win32/win32.c b/win32/win32.c index 3051a97f569050..1653bd1aedad94 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -543,11 +543,15 @@ init_env(void) if (!GetEnvironmentVariableW(L"USERNAME", env, numberof(env)) && !GetUserNameW(env, (len = numberof(env), &len))) { NTLoginName = ""; - return; } - set_env_val(L"USER"); + else { + set_env_val(L"USER"); + NTLoginName = rb_w32_wstr_to_mbstr(CP_UTF8, env, -1, NULL); + } + } + else { + NTLoginName = rb_w32_wstr_to_mbstr(CP_UTF8, env, -1, NULL); } - NTLoginName = strdup(rb_w32_getenv("USER")); if (!GetEnvironmentVariableW(TMPDIR, env, numberof(env)) && !GetEnvironmentVariableW(L"TMP", env, numberof(env)) && From 095d964e156e73d1827d1213ab30cef602ce9c10 Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 8 Feb 2015 16:50:24 +0000 Subject: [PATCH 297/343] merge revision(s) r49525: [Backport #10839] test_cipher.rb: OpenSSL 1.0.2 * test/openssl/test_cipher.rb (OpenSSL::TestCipher#test_ciphers): OpenSSL 1.0.2 does not allow wrap mode. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@49548 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/openssl/test_cipher.rb | 7 ++++++- version.h | 6 +++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/test/openssl/test_cipher.rb b/test/openssl/test_cipher.rb index 156fa2a9c96d5b..c87eacce1dfdc4 100644 --- a/test/openssl/test_cipher.rb +++ b/test/openssl/test_cipher.rb @@ -104,7 +104,12 @@ def test_ctr_if_exists def test_ciphers OpenSSL::Cipher.ciphers.each{|name| next if /netbsd/ =~ RUBY_PLATFORM && /idea|rc5/i =~ name - assert(OpenSSL::Cipher::Cipher.new(name).is_a?(OpenSSL::Cipher::Cipher)) + begin + assert_kind_of(OpenSSL::Cipher::Cipher, OpenSSL::Cipher::Cipher.new(name)) + rescue OpenSSL::Cipher::CipherError => e + next if /wrap\z/ =~ name and e.message == 'wrap mode not allowed' + raise + end } end diff --git a/version.h b/version.h index 152362f25662e9..19fdbec1839191 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.5" -#define RUBY_RELEASE_DATE "2015-02-02" -#define RUBY_PATCHLEVEL 290 +#define RUBY_RELEASE_DATE "2015-02-09" +#define RUBY_PATCHLEVEL 291 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 2 -#define RUBY_RELEASE_DAY 2 +#define RUBY_RELEASE_DAY 9 #include "ruby/version.h" From 40705c2be1d0fee20f7cce0e0105aabd075b99ed Mon Sep 17 00:00:00 2001 From: nagachika Date: Fri, 13 Feb 2015 14:16:02 +0000 Subject: [PATCH 298/343] merge revision(s) r49575,r49579: [Backport #10839] test_cipher.rb: show cipher name * test/openssl/test_cipher.rb (test_ciphers): show wrap mode cipher name, which does not end with "wrap". http://rubyci.blob.core.windows.net/fedora21/ruby-trunk/log/20150212T061502Z.fail.html.gz git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@49588 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/openssl/test_cipher.rb | 2 +- version.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/openssl/test_cipher.rb b/test/openssl/test_cipher.rb index c87eacce1dfdc4..101a75a15baaab 100644 --- a/test/openssl/test_cipher.rb +++ b/test/openssl/test_cipher.rb @@ -107,7 +107,7 @@ def test_ciphers begin assert_kind_of(OpenSSL::Cipher::Cipher, OpenSSL::Cipher::Cipher.new(name)) rescue OpenSSL::Cipher::CipherError => e - next if /wrap\z/ =~ name and e.message == 'wrap mode not allowed' + next if /wrap/ =~ name and e.message == 'wrap mode not allowed' raise end } diff --git a/version.h b/version.h index 19fdbec1839191..da9550e92c8a3b 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.5" -#define RUBY_RELEASE_DATE "2015-02-09" -#define RUBY_PATCHLEVEL 291 +#define RUBY_RELEASE_DATE "2015-02-13" +#define RUBY_PATCHLEVEL 292 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 2 -#define RUBY_RELEASE_DAY 9 +#define RUBY_RELEASE_DAY 13 #include "ruby/version.h" From 8e210f995f37222facee57555996c205fb4fe390 Mon Sep 17 00:00:00 2001 From: nagachika Date: Sat, 14 Feb 2015 22:36:43 +0000 Subject: [PATCH 299/343] merge revision(s) r49543,r49557: [Backport #10854] * ext/socket/getaddrinfo.c (get_addr): reject too long hostname to get rid of GHOST vulnerability on very old platforms. * ext/socket/raddrinfo.c (make_hostent_internal): ditto, paranoic check for the canonnical name. check for the canonical name. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@49600 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ ext/socket/getaddrinfo.c | 1 + ext/socket/raddrinfo.c | 3 ++- version.h | 6 +++--- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 889bb6d939d173..5ec30c24e7de76 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Sun Feb 15 07:29:12 2015 Nobuyoshi Nakada + + * ext/socket/getaddrinfo.c (get_addr): reject too long hostname to + get rid of GHOST vulnerability on very old platforms. + + * ext/socket/raddrinfo.c (make_hostent_internal): ditto, paranoic + check for the canonical name. + Mon Feb 2 22:57:30 2015 Nobuyoshi Nakada * ext/etc/etc.c (etc_getlogin): set login name encoding properly. diff --git a/ext/socket/getaddrinfo.c b/ext/socket/getaddrinfo.c index a17d12b70559f4..68f610e807fb15 100644 --- a/ext/socket/getaddrinfo.c +++ b/ext/socket/getaddrinfo.c @@ -593,6 +593,7 @@ get_addr(const char *hostname, int af, struct addrinfo **res, struct addrinfo *p } else hp = getipnodebyname(hostname, af, AI_ADDRCONFIG, &h_error); #else + if (strlen(hostname) >= NI_MAXHOST) ERR(EAI_NODATA); hp = gethostbyname((char*)hostname); h_error = h_errno; #endif diff --git a/ext/socket/raddrinfo.c b/ext/socket/raddrinfo.c index 3deadd1aeae539..e4cb9c379fcfc3 100644 --- a/ext/socket/raddrinfo.c +++ b/ext/socket/raddrinfo.c @@ -617,7 +617,8 @@ make_hostent_internal(struct hostent_arg *arg) } rb_ary_push(ary, rb_str_new2(hostp)); - if (addr->ai_canonname && (h = gethostbyname(addr->ai_canonname))) { + if (addr->ai_canonname && strlen(addr->ai_canonname) < NI_MAXHOST && + (h = gethostbyname(addr->ai_canonname))) { names = rb_ary_new(); if (h->h_aliases != NULL) { for (pch = h->h_aliases; *pch; pch++) { diff --git a/version.h b/version.h index da9550e92c8a3b..6240106b4300e9 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.5" -#define RUBY_RELEASE_DATE "2015-02-13" -#define RUBY_PATCHLEVEL 292 +#define RUBY_RELEASE_DATE "2015-02-15" +#define RUBY_PATCHLEVEL 293 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 2 -#define RUBY_RELEASE_DAY 13 +#define RUBY_RELEASE_DAY 15 #include "ruby/version.h" From 4c2b74cb53a566a5e3d6e0f3a751ceb60eb0549b Mon Sep 17 00:00:00 2001 From: nagachika Date: Tue, 17 Feb 2015 14:11:22 +0000 Subject: [PATCH 300/343] merge revision(s) r49620: [Backport #10857] * lib/resolv.rb (Resolv::DNS::Resource#==, #hash): elements returned by Kernel#instance_variables are Symbols now. [ruby-core:68128] [Bug #10857] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@49628 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ lib/resolv.rb | 6 +++--- test/resolv/test_resource.rb | 21 +++++++++++++++++++++ version.h | 6 +++--- 4 files changed, 33 insertions(+), 6 deletions(-) create mode 100644 test/resolv/test_resource.rb diff --git a/ChangeLog b/ChangeLog index 5ec30c24e7de76..e9b8eb10ab9f9f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Tue Feb 17 22:59:31 2015 Nobuyoshi Nakada + + * lib/resolv.rb (Resolv::DNS::Resource#==, #hash): elements + returned by Kernel#instance_variables are Symbols now. + [ruby-core:68128] [Bug #10857] + Sun Feb 15 07:29:12 2015 Nobuyoshi Nakada * ext/socket/getaddrinfo.c (get_addr): reject too long hostname to diff --git a/lib/resolv.rb b/lib/resolv.rb index 47457027b19db7..1d2c3f7899d56d 100644 --- a/lib/resolv.rb +++ b/lib/resolv.rb @@ -1666,10 +1666,10 @@ def ==(other) # :nodoc: return false unless self.class == other.class s_ivars = self.instance_variables s_ivars.sort! - s_ivars.delete "@ttl" + s_ivars.delete :@ttl o_ivars = other.instance_variables o_ivars.sort! - o_ivars.delete "@ttl" + o_ivars.delete :@ttl return s_ivars == o_ivars && s_ivars.collect {|name| self.instance_variable_get name} == o_ivars.collect {|name| other.instance_variable_get name} @@ -1682,7 +1682,7 @@ def eql?(other) # :nodoc: def hash # :nodoc: h = 0 vars = self.instance_variables - vars.delete "@ttl" + vars.delete :@ttl vars.each {|name| h ^= self.instance_variable_get(name).hash } diff --git a/test/resolv/test_resource.rb b/test/resolv/test_resource.rb new file mode 100644 index 00000000000000..7ec17e33e79f7c --- /dev/null +++ b/test/resolv/test_resource.rb @@ -0,0 +1,21 @@ +require 'test/unit' +require 'resolv' + +class TestResolvResource < Test::Unit::TestCase + def setup + address = "192.168.0.1" + @name1 = Resolv::DNS::Resource::IN::A.new(address) + @name1.instance_variable_set(:@ttl, 100) + @name2 = Resolv::DNS::Resource::IN::A.new(address) + end + + def test_equality + bug10857 = '[ruby-core:68128] [Bug #10857]' + assert_equal(@name1, @name2, bug10857) + end + + def test_hash + bug10857 = '[ruby-core:68128] [Bug #10857]' + assert_equal(@name1.hash, @name2.hash, bug10857) + end +end diff --git a/version.h b/version.h index 6240106b4300e9..73351a9db8486d 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.5" -#define RUBY_RELEASE_DATE "2015-02-15" -#define RUBY_PATCHLEVEL 293 +#define RUBY_RELEASE_DATE "2015-02-17" +#define RUBY_PATCHLEVEL 294 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 2 -#define RUBY_RELEASE_DAY 15 +#define RUBY_RELEASE_DAY 17 #include "ruby/version.h" From 6a3397749a6a9784862e7e72c715c9d4862789db Mon Sep 17 00:00:00 2001 From: nagachika Date: Tue, 17 Feb 2015 15:18:40 +0000 Subject: [PATCH 301/343] merge revision(s) r49223: [Backport #10732] * lib/rdoc/text.rb (expand_tabs): get rid of infinite loop with CR. should check if substitution occurred too. [ruby-dev:48813] [Bug #10732] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@49629 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ lib/rdoc/text.rb | 4 ++-- test/rdoc/test_rdoc_text.rb | 3 +++ version.h | 6 +++--- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index e9b8eb10ab9f9f..d2131a6e642f27 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Wed Feb 18 00:18:12 2015 Nobuyoshi Nakada + + * lib/rdoc/text.rb (expand_tabs): get rid of infinite loop with + CR. should check if substitution occurred too. + [ruby-dev:48813] [Bug #10732] + Tue Feb 17 22:59:31 2015 Nobuyoshi Nakada * lib/resolv.rb (Resolv::DNS::Resource#==, #hash): elements diff --git a/lib/rdoc/text.rb b/lib/rdoc/text.rb index 0fda72e3ae4358..ef525003583a82 100644 --- a/lib/rdoc/text.rb +++ b/lib/rdoc/text.rb @@ -68,11 +68,11 @@ def expand_tabs text expanded = [] text.each_line do |line| - line.gsub!(/^((?:.{8})*?)([^\t\r\n]{0,7})\t/) do + nil while line.gsub!(/(?:\G|\r)((?:.{8})*?)([^\t\r\n]{0,7})\t/) do r = "#{$1}#{$2}#{' ' * (8 - $2.size)}" r.force_encoding text.encoding if Object.const_defined? :Encoding r - end until line !~ /\t/ + end expanded << line end diff --git a/test/rdoc/test_rdoc_text.rb b/test/rdoc/test_rdoc_text.rb index b0c464a659dd6a..a69989d15d6ab5 100644 --- a/test/rdoc/test_rdoc_text.rb +++ b/test/rdoc/test_rdoc_text.rb @@ -56,6 +56,9 @@ def test_expand_tabs assert_equal('. .', expand_tabs(".\t\t."), 'dot tab tab dot') + + assert_equal('a a', + Timeout.timeout(1) {expand_tabs("\ra\ta")}, "carriage return") end def test_expand_tabs_encoding diff --git a/version.h b/version.h index 73351a9db8486d..f5d6c64a9a6ec0 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.5" -#define RUBY_RELEASE_DATE "2015-02-17" -#define RUBY_PATCHLEVEL 294 +#define RUBY_RELEASE_DATE "2015-02-18" +#define RUBY_PATCHLEVEL 295 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 2 -#define RUBY_RELEASE_DAY 17 +#define RUBY_RELEASE_DAY 18 #include "ruby/version.h" From e6e559c0bb196d608965e52c195773dddb302221 Mon Sep 17 00:00:00 2001 From: nagachika Date: Tue, 17 Feb 2015 15:21:12 +0000 Subject: [PATCH 302/343] merge revision(s) r48417: [Backport #10509] * vm_eval.c (rb_yield_splat): add missing GC guard [Bug #10509] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@49630 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ version.h | 2 +- vm_eval.c | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index d2131a6e642f27..b768b3f86e890c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed Feb 18 00:20:36 2015 Eric Wong + + * vm_eval.c (rb_yield_splat): add missing GC guard + [Bug #10509] + Wed Feb 18 00:18:12 2015 Nobuyoshi Nakada * lib/rdoc/text.rb (expand_tabs): get rid of infinite loop with diff --git a/version.h b/version.h index f5d6c64a9a6ec0..495a27d724fa53 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.5" #define RUBY_RELEASE_DATE "2015-02-18" -#define RUBY_PATCHLEVEL 295 +#define RUBY_PATCHLEVEL 296 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 2 diff --git a/vm_eval.c b/vm_eval.c index dc0b05375b77fd..5e79bedd9778b1 100644 --- a/vm_eval.c +++ b/vm_eval.c @@ -986,6 +986,7 @@ rb_yield_splat(VALUE values) rb_raise(rb_eArgError, "not an array"); } v = rb_yield_0(RARRAY_LENINT(tmp), RARRAY_CONST_PTR(tmp)); + RB_GC_GUARD(tmp); return v; } From fd87a8aebba9f0f7ec4afc2bf7aba5b9d623a23b Mon Sep 17 00:00:00 2001 From: nagachika Date: Tue, 17 Feb 2015 17:08:26 +0000 Subject: [PATCH 303/343] merge revision(s) r48563,r46261,r48581: [Backport #10533] * lib/net/http.rb: Do not attempt SSL session resumption when the session is expired. [Bug #10533] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@49631 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ lib/net/http.rb | 5 ++++- test/net/http/test_https.rb | 33 +++++++++++++++++++++++++++++++++ version.h | 2 +- 4 files changed, 43 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index b768b3f86e890c..99e13b7a2bc979 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed Feb 18 00:27:57 2015 Eric Hodel + + * lib/net/http.rb: Do not attempt SSL session resumption when the + session is expired. [Bug #10533] + Wed Feb 18 00:20:36 2015 Eric Wong * vm_eval.c (rb_yield_splat): add missing GC guard diff --git a/lib/net/http.rb b/lib/net/http.rb index 954644fb007c4b..943371df017d7c 100644 --- a/lib/net/http.rb +++ b/lib/net/http.rb @@ -914,7 +914,10 @@ def connect @socket.write(buf) HTTPResponse.read_new(@socket).value end - s.session = @ssl_session if @ssl_session + if @ssl_session and + Time.now < @ssl_session.time + @ssl_session.timeout + s.session = @ssl_session if @ssl_session + end # Server Name Indication (SNI) RFC 3546 s.hostname = @address if s.respond_to? :hostname= Timeout.timeout(@open_timeout, Net::OpenTimeout) { s.connect } diff --git a/test/net/http/test_https.rb b/test/net/http/test_https.rb index 0a448dd95dbd4a..06a70fde83e963 100644 --- a/test/net/http/test_https.rb +++ b/test/net/http/test_https.rb @@ -73,12 +73,45 @@ def test_session_reuse http.get("/") http.finish # three times due to possible bug in OpenSSL 0.9.8 + sid = http.instance_variable_get(:@ssl_session).id + http.start http.get("/") socket = http.instance_variable_get(:@socket).io assert socket.session_reused? + + assert_equal sid, http.instance_variable_get(:@ssl_session).id + + http.finish + rescue SystemCallError + skip $! + end + + def test_session_reuse_but_expire + http = Net::HTTP.new("localhost", config("port")) + http.use_ssl = true + http.verify_callback = Proc.new do |preverify_ok, store_ctx| + store_ctx.current_cert.to_der == config('ssl_certificate').to_der + end + + http.ssl_timeout = -1 + http.start + http.get("/") + http.finish + + sid = http.instance_variable_get(:@ssl_session).id + + http.start + http.get("/") + + socket = http.instance_variable_get(:@socket).io + assert_equal false, socket.session_reused? + + assert_not_equal sid, http.instance_variable_get(:@ssl_session).id + + http.finish rescue SystemCallError skip $! end diff --git a/version.h b/version.h index 495a27d724fa53..d60131c2ceb32f 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.5" #define RUBY_RELEASE_DATE "2015-02-18" -#define RUBY_PATCHLEVEL 296 +#define RUBY_PATCHLEVEL 297 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 2 From 1386c9fd3e9f4b10534be6ba23b3d7a43c129588 Mon Sep 17 00:00:00 2001 From: nagachika Date: Thu, 19 Feb 2015 10:11:00 +0000 Subject: [PATCH 304/343] merge revision(s) r49034: [Backport #10662] * ext/tk/lib/tkextlib/tcllib/plotchart.rb: fix to invoke correct function of tcllib. Patch by @zalt50 [fix GH-787] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@49651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ ext/tk/lib/tkextlib/tcllib/plotchart.rb | 4 ++-- version.h | 6 +++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 99e13b7a2bc979..32ea8c8465b283 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Thu Feb 19 19:10:53 2015 SHIBATA Hiroshi + + * ext/tk/lib/tkextlib/tcllib/plotchart.rb: fix to invoke correct function + of tcllib. Patch by @zalt50 [fix GH-787] + Wed Feb 18 00:27:57 2015 Eric Hodel * lib/net/http.rb: Do not attempt SSL session resumption when the diff --git a/ext/tk/lib/tkextlib/tcllib/plotchart.rb b/ext/tk/lib/tkextlib/tcllib/plotchart.rb index 2f3d79d4279238..cd52a0ed4bb7fa 100644 --- a/ext/tk/lib/tkextlib/tcllib/plotchart.rb +++ b/ext/tk/lib/tkextlib/tcllib/plotchart.rb @@ -142,7 +142,7 @@ def self.polar_to_pixel(w, rad, phi) end def self.pixel_to_coords(w, x, y) - list(tk_call_without_enc('::Plotchart::coordsToPixel', w.path, x, y)) + list(tk_call_without_enc('::Plotchart::pixelToCoords', w.path, x, y)) end def self.determine_scale(*args) # (xmin, xmax, inverted=false) @@ -311,7 +311,7 @@ def polar_to_pixel(rad, phi) end def pixel_to_coords(x, y) - list(tk_call_without_enc('::Plotchart::coordsToPixel', @path, x, y)) + list(tk_call_without_enc('::Plotchart::pixelToCoords', @path, x, y)) end def determine_scale(xmax, ymax) diff --git a/version.h b/version.h index d60131c2ceb32f..5e68af13f550e4 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.5" -#define RUBY_RELEASE_DATE "2015-02-18" -#define RUBY_PATCHLEVEL 297 +#define RUBY_RELEASE_DATE "2015-02-19" +#define RUBY_PATCHLEVEL 298 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 2 -#define RUBY_RELEASE_DAY 18 +#define RUBY_RELEASE_DAY 19 #include "ruby/version.h" From 13112e53367035c28600baf4ac416cadb5e60759 Mon Sep 17 00:00:00 2001 From: nagachika Date: Thu, 19 Feb 2015 10:44:51 +0000 Subject: [PATCH 305/343] merge revision(s) r48948: [Backport #10591] * lib/net/http/response.rb (Net::HTTPResponse): require one or more spaces [Bug #10591]. by leriksen https://github.com/ruby/ruby/pull/782 fix GH-782 NOTE: graph.facebook.com returns without SP Reason-Phrase. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@49652 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++ lib/net/http/response.rb | 2 +- test/net/http/test_httpresponse.rb | 59 ++++++++++++++++++++++++++++++ version.h | 2 +- 4 files changed, 69 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 32ea8c8465b283..8e7eb3ab775053 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Thu Feb 19 19:14:34 2015 NARUSE, Yui + + * lib/net/http/response.rb (Net::HTTPResponse): require one or more + spaces [Bug #10591]. + by leriksen + https://github.com/ruby/ruby/pull/782 fix GH-782 + NOTE: graph.facebook.com returns without SP Reason-Phrase. + Thu Feb 19 19:10:53 2015 SHIBATA Hiroshi * ext/tk/lib/tkextlib/tcllib/plotchart.rb: fix to invoke correct function diff --git a/lib/net/http/response.rb b/lib/net/http/response.rb index da3e4b4c8cc7ae..9aaa0b32080c12 100644 --- a/lib/net/http/response.rb +++ b/lib/net/http/response.rb @@ -37,7 +37,7 @@ def read_new(sock) #:nodoc: internal use only def read_status_line(sock) str = sock.readline - m = /\AHTTP(?:\/(\d+\.\d+))?\s+(\d\d\d)\s*(.*)\z/in.match(str) or + m = /\AHTTP(?:\/(\d+\.\d+))?\s+(\d\d\d)(?:\s+(.*))?\z/in.match(str) or raise Net::HTTPBadResponse, "wrong status line: #{str.dump}" m.captures end diff --git a/test/net/http/test_httpresponse.rb b/test/net/http/test_httpresponse.rb index 974f8296cc08e2..0193a153e467db 100644 --- a/test/net/http/test_httpresponse.rb +++ b/test/net/http/test_httpresponse.rb @@ -244,6 +244,65 @@ def test_uri_equals refute_same uri, response.uri end + def test_ensure_zero_space_does_not_regress + io = dummy_io(< Date: Fri, 27 Feb 2015 17:21:43 +0000 Subject: [PATCH 306/343] merge revision(s) r49071,r49072,r49073,r49078: [Backport #10550] * lib/resolv.rb (Resolv::DNS::Name): names with different dots should be different. * lib/resolv.rb (Resolv::DNS::Name#==): DNS is case-insensitive, so the comparison should be case-insensitive as well. [ruby-core:66498] [Bug #10550] * lib/resolv.rb (Resolv::DNS::Name#==): Compare an array of Label:Str objects. Label#Str#== is case-insensitive. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@49775 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 16 ++++++++++++++++ lib/resolv.rb | 3 ++- test/resolv/test_dns.rb | 13 +++++++++++++ version.h | 6 +++--- 4 files changed, 34 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8e7eb3ab775053..f9c6239e694b55 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +Sat Feb 28 02:13:17 2015 Tanaka Akira + + * lib/resolv.rb (Resolv::DNS::Name#==): Compare an array of Label:Str + objects. Label#Str#== is case-insensitive. + +Sat Feb 28 02:13:17 2015 Ben Miller + + * lib/resolv.rb (Resolv::DNS::Name#==): DNS is case-insensitive, so the + comparison should be case-insensitive as well. + [ruby-core:66498] [Bug #10550] + +Sat Feb 28 02:13:17 2015 Nobuyoshi Nakada + + * lib/resolv.rb (Resolv::DNS::Name): names with different dots + should be different. + Thu Feb 19 19:14:34 2015 NARUSE, Yui * lib/net/http/response.rb (Net::HTTPResponse): require one or more diff --git a/lib/resolv.rb b/lib/resolv.rb index 1d2c3f7899d56d..55aa9638ba6969 100644 --- a/lib/resolv.rb +++ b/lib/resolv.rb @@ -1240,7 +1240,8 @@ def absolute? def ==(other) # :nodoc: return false unless Name === other - return @labels.join == other.to_a.join && @absolute == other.absolute? + return false unless @absolute == other.absolute? + return @labels == other.to_a end alias eql? == # :nodoc: diff --git a/test/resolv/test_dns.rb b/test/resolv/test_dns.rb index 4d83d88a17448c..e91d127f350c10 100644 --- a/test/resolv/test_dns.rb +++ b/test/resolv/test_dns.rb @@ -175,4 +175,17 @@ def test_invalid_byte_comment end end end + + def test_dots_diffences + name1 = Resolv::DNS::Name.create("example.org") + name2 = Resolv::DNS::Name.create("ex.ampl.eo.rg") + assert_not_equal(name1, name2, "different dots") + end + + def test_case_insensitive_name + bug10550 = '[ruby-core:66498] [Bug #10550]' + lower = Resolv::DNS::Name.create("ruby-lang.org") + upper = Resolv::DNS::Name.create("Ruby-Lang.org") + assert_equal(lower, upper, bug10550) + end end diff --git a/version.h b/version.h index 693da97b1401be..507800ef724fe4 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.5" -#define RUBY_RELEASE_DATE "2015-02-19" -#define RUBY_PATCHLEVEL 299 +#define RUBY_RELEASE_DATE "2015-02-28" +#define RUBY_PATCHLEVEL 300 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 2 -#define RUBY_RELEASE_DAY 19 +#define RUBY_RELEASE_DAY 28 #include "ruby/version.h" From 089dbf1edd726b4871a6370ba85dedc2e0285a5e Mon Sep 17 00:00:00 2001 From: nagachika Date: Sat, 28 Feb 2015 15:59:54 +0000 Subject: [PATCH 307/343] merge revision(s) r49202: [Backport #10668] * ext/zlib/zlib.c: fix document of method signatures. [Bug #10668][ruby-core:67186][ci skip] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@49783 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ ext/zlib/zlib.c | 2 +- version.h | 8 ++++---- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index f9c6239e694b55..1d8e065bba46eb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sun Mar 1 00:58:30 2015 SHIBATA Hiroshi + + * ext/zlib/zlib.c: fix document of method signatures. + [Bug #10668][ruby-core:67186][ci skip] + Sat Feb 28 02:13:17 2015 Tanaka Akira * lib/resolv.rb (Resolv::DNS::Name#==): Compare an array of Label:Str diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c index 4d8fde68c9d9f0..9dbc193f54bf72 100644 --- a/ext/zlib/zlib.c +++ b/ext/zlib/zlib.c @@ -461,7 +461,7 @@ rb_zlib_adler32_combine(VALUE klass, VALUE adler1, VALUE adler2, VALUE len2) /* * Document-method: Zlib.crc32 * - * call-seq: Zlib.crc32(string, adler) + * call-seq: Zlib.crc32(string, crc) * * Calculates CRC checksum for +string+, and returns updated value of +crc+. If * +string+ is omitted, it returns the CRC initial value. If +crc+ is omitted, it diff --git a/version.h b/version.h index 507800ef724fe4..ff5e8b9e21a2b8 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.5" -#define RUBY_RELEASE_DATE "2015-02-28" -#define RUBY_PATCHLEVEL 300 +#define RUBY_RELEASE_DATE "2015-03-01" +#define RUBY_PATCHLEVEL 301 #define RUBY_RELEASE_YEAR 2015 -#define RUBY_RELEASE_MONTH 2 -#define RUBY_RELEASE_DAY 28 +#define RUBY_RELEASE_MONTH 3 +#define RUBY_RELEASE_DAY 1 #include "ruby/version.h" From 4ad3a5c32c25ff5ea58d45f44be6f76aca81cb87 Mon Sep 17 00:00:00 2001 From: nagachika Date: Sat, 28 Feb 2015 16:03:10 +0000 Subject: [PATCH 308/343] merge revision(s) r49104,r49105: [Backport #10692] * test/net/http/test_http.rb (_test_send_request__HEAD): Added failing test for send_request with HEAD method. * lib/net/http.rb (Net::HTTP#send_request): there is no response body with HEAD request. Patch by @rodrigosaito [fix GH-520] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@49784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 10 ++++++++++ lib/net/http.rb | 3 ++- test/net/http/test_http.rb | 11 +++++++++++ version.h | 2 +- 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1d8e065bba46eb..2a9b1b737490a7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +Sun Mar 1 01:01:21 2015 SHIBATA Hiroshi + + * lib/net/http.rb (Net::HTTP#send_request): there is no response body + with HEAD request. Patch by @rodrigosaito [fix GH-520] + +Sun Mar 1 01:01:21 2015 SHIBATA Hiroshi + + * test/net/http/test_http.rb (_test_send_request__HEAD): Added + failing test for send_request with HEAD method. + Sun Mar 1 00:58:30 2015 SHIBATA Hiroshi * ext/zlib/zlib.c: fix document of method signatures. diff --git a/lib/net/http.rb b/lib/net/http.rb index 943371df017d7c..bd0a4d6b5fec6b 100644 --- a/lib/net/http.rb +++ b/lib/net/http.rb @@ -1350,7 +1350,8 @@ def request_put(path, data, initheader = nil, &block) #:nodoc: # puts response.body # def send_request(name, path, data = nil, header = nil) - r = HTTPGenericRequest.new(name,(data ? true : false),true,path,header) + has_response_body = name != 'HEAD' + r = HTTPGenericRequest.new(name,(data ? true : false),has_response_body,path,header) request r, data end diff --git a/test/net/http/test_http.rb b/test/net/http/test_http.rb index 6c847dba7e7cd6..60d9d761504f59 100644 --- a/test/net/http/test_http.rb +++ b/test/net/http/test_http.rb @@ -574,6 +574,7 @@ def _test_request__uri_host(http) def test_send_request start {|http| _test_send_request__GET http + _test_send_request__HEAD http _test_send_request__POST http } end @@ -588,6 +589,16 @@ def _test_send_request__GET(http) assert_equal $test_net_http_data, res.body end + def _test_send_request__HEAD(http) + res = http.send_request('HEAD', '/') + assert_kind_of Net::HTTPResponse, res + unless self.is_a?(TestNetHTTP_v1_2_chunked) + assert_not_nil res['content-length'] + assert_equal $test_net_http_data.size, res['content-length'].to_i + end + assert_nil res.body + end + def _test_send_request__POST(http) data = 'aaabbb cc ddddddddddd lkjoiu4j3qlkuoa' res = http.send_request('POST', '/', data, 'content-type' => 'application/x-www-form-urlencoded') diff --git a/version.h b/version.h index ff5e8b9e21a2b8..bb795a2b68bab7 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.5" #define RUBY_RELEASE_DATE "2015-03-01" -#define RUBY_PATCHLEVEL 301 +#define RUBY_PATCHLEVEL 302 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 3 From 8e73157dd03c5dd4848da16edbb59c44b07b2d4c Mon Sep 17 00:00:00 2001 From: nagachika Date: Sat, 28 Feb 2015 16:15:49 +0000 Subject: [PATCH 309/343] merge revision(s) r49175: [Backport #10712] * lib/resolv.rb: consider ENETUNREACH as ResolvTimeout [ruby-core:67411] [Bug #10712] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@49785 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ lib/resolv.rb | 4 ++-- version.h | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2a9b1b737490a7..464021cb6c02b1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sun Mar 1 01:14:59 2015 Eric Wong + + * lib/resolv.rb: consider ENETUNREACH as ResolvTimeout + [ruby-core:67411] [Bug #10712] + Sun Mar 1 01:01:21 2015 SHIBATA Hiroshi * lib/net/http.rb (Net::HTTP#send_request): there is no response body diff --git a/lib/resolv.rb b/lib/resolv.rb index 55aa9638ba6969..74618bfaab37ee 100644 --- a/lib/resolv.rb +++ b/lib/resolv.rb @@ -671,8 +671,8 @@ def request(sender, tout) timelimit = start + tout begin sender.send - rescue Errno::EHOSTUNREACH - # multi-homed IPv6 may generate this + rescue Errno::EHOSTUNREACH, # multi-homed IPv6 may generate this + Errno::ENETUNREACH raise ResolvTimeout end while true diff --git a/version.h b/version.h index bb795a2b68bab7..1f3a340e367015 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.5" #define RUBY_RELEASE_DATE "2015-03-01" -#define RUBY_PATCHLEVEL 302 +#define RUBY_PATCHLEVEL 303 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 3 From c839def7cc34f858777b15d2d84cb45b585d9699 Mon Sep 17 00:00:00 2001 From: nagachika Date: Sat, 28 Feb 2015 17:28:57 +0000 Subject: [PATCH 310/343] merge revision(s) r49182,r49183: [Backport #10706] vm_method.c: fix change refined new method visibility * vm_method.c (rb_export_method): bail out if the original method is undefined when the method is refined. [ruby-core:67387] [Bug #10706] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@49786 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ test/ruby/test_refinement.rb | 14 ++++++++++++++ version.h | 2 +- vm_method.c | 4 +++- 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 464021cb6c02b1..9332f21943ff7a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sun Mar 1 01:17:24 2015 Seiei Higa + + * vm_method.c (rb_export_method): bail out if the original method + is undefined when the method is refined. + [ruby-core:67387] [Bug #10706] + Sun Mar 1 01:14:59 2015 Eric Wong * lib/resolv.rb: consider ENETUNREACH as ResolvTimeout diff --git a/test/ruby/test_refinement.rb b/test/ruby/test_refinement.rb index 77e4789bfc7a37..65137f0e3afc3c 100644 --- a/test/ruby/test_refinement.rb +++ b/test/ruby/test_refinement.rb @@ -1167,6 +1167,20 @@ def foo end; end + def test_change_refined_new_method_visibility + assert_separately([], <<-"end;") + bug10706 = '[ruby-core:67387] [Bug #10706]' + module RefinementBug + refine Object do + def foo + end + end + end + + assert_raise(NameError, bug10706) {private(:foo)} + end; + end + private def eval_using(mod, s) diff --git a/version.h b/version.h index 1f3a340e367015..02f9f18a281f7f 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.5" #define RUBY_RELEASE_DATE "2015-03-01" -#define RUBY_PATCHLEVEL 303 +#define RUBY_PATCHLEVEL 304 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 3 diff --git a/vm_method.c b/vm_method.c index 2270359029f756..08946b9862d51e 100644 --- a/vm_method.c +++ b/vm_method.c @@ -811,7 +811,9 @@ rb_export_method(VALUE klass, ID name, rb_method_flag_t noex) me = search_method(rb_cObject, name, &defined_class); } - if (UNDEFINED_METHOD_ENTRY_P(me)) { + if (UNDEFINED_METHOD_ENTRY_P(me) || + (me->def->type == VM_METHOD_TYPE_REFINED && + UNDEFINED_METHOD_ENTRY_P(me->def->body.orig_me))) { rb_print_undef(klass, name, 0); } From f50f70259ded4e1be9c197dd04d7da9518e8ca68 Mon Sep 17 00:00:00 2001 From: nagachika Date: Sat, 28 Feb 2015 18:13:42 +0000 Subject: [PATCH 311/343] merge revision(s) r49221: [Backport #10731] * vm_method.c (rb_alias): raise a NameError when creating alias to a refined method if the original method of the refined method is not defined. [ruby-core:67523] [Bug #10731] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@49787 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ test/ruby/test_refinement.rb | 25 +++++++++++++++++++++++++ version.h | 2 +- vm_method.c | 4 +++- 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9332f21943ff7a..3c60c9cfec117c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sun Mar 1 02:30:23 2015 Seiei Higa + + * vm_method.c (rb_alias): raise a NameError when creating alias to + a refined method if the original method of the refined method is + not defined. [ruby-core:67523] [Bug #10731] + Sun Mar 1 01:17:24 2015 Seiei Higa * vm_method.c (rb_export_method): bail out if the original method diff --git a/test/ruby/test_refinement.rb b/test/ruby/test_refinement.rb index 65137f0e3afc3c..98bf9c60274ccd 100644 --- a/test/ruby/test_refinement.rb +++ b/test/ruby/test_refinement.rb @@ -1181,6 +1181,31 @@ def foo end; end + def test_alias_refined_method + assert_separately([], <<-"end;") + bug10731 = '[ruby-core:67523] [Bug #10731]' + + class C + end + + module RefinementBug + refine C do + def foo + end + + def bar + end + end + end + + assert_raise(NameError, bug10731) do + class C + alias foo bar + end + end + end; + end + private def eval_using(mod, s) diff --git a/version.h b/version.h index 02f9f18a281f7f..d70d742f46a913 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.5" #define RUBY_RELEASE_DATE "2015-03-01" -#define RUBY_PATCHLEVEL 304 +#define RUBY_PATCHLEVEL 305 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 3 diff --git a/vm_method.c b/vm_method.c index 08946b9862d51e..3748e9267995f9 100644 --- a/vm_method.c +++ b/vm_method.c @@ -1259,7 +1259,9 @@ rb_alias(VALUE klass, ID name, ID def) again: orig_me = search_method(klass, def, &defined_class); - if (UNDEFINED_METHOD_ENTRY_P(orig_me)) { + if (UNDEFINED_METHOD_ENTRY_P(orig_me) || + (orig_me->def->type == VM_METHOD_TYPE_REFINED && + UNDEFINED_METHOD_ENTRY_P(orig_me->def->body.orig_me))) { if ((!RB_TYPE_P(klass, T_MODULE)) || (orig_me = search_method(rb_cObject, def, 0), UNDEFINED_METHOD_ENTRY_P(orig_me))) { From 3457be5f12b950953f10b5685316fa86a9ac466c Mon Sep 17 00:00:00 2001 From: nagachika Date: Mon, 2 Mar 2015 17:43:19 +0000 Subject: [PATCH 312/343] merge revision(s) r49797: [Backport #10923] * ext/io/wait/wait.c (io_nread): wrap return value with INT2FIX Thanks to Yura Sokolov [ruby-core:68369] [Bug#10923] * test/io/wait/test_io_wait.rb (test_nread_buffered): fix broken test git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@49812 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ ext/io/wait/wait.c | 2 +- test/io/wait/test_io_wait.rb | 2 +- version.h | 6 +++--- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3c60c9cfec117c..f06e6aab0c719c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Tue Mar 3 02:42:27 2015 Eric Wong + + * ext/io/wait/wait.c (io_nread): wrap return value with INT2FIX + Thanks to Yura Sokolov + [ruby-core:68369] [Bug#10923] + * test/io/wait/test_io_wait.rb (test_nread_buffered): + fix broken test + Sun Mar 1 02:30:23 2015 Seiei Higa * vm_method.c (rb_alias): raise a NameError when creating alias to diff --git a/ext/io/wait/wait.c b/ext/io/wait/wait.c index d8bb55fc475fe0..ce8cfbbeb49fb9 100644 --- a/ext/io/wait/wait.c +++ b/ext/io/wait/wait.c @@ -62,7 +62,7 @@ io_nread(VALUE io) GetOpenFile(io, fptr); rb_io_check_readable(fptr); len = rb_io_read_pending(fptr); - if (len > 0) return len; + if (len > 0) return INT2FIX(len); if (!FIONREAD_POSSIBLE_P(fptr->fd)) return INT2FIX(0); if (ioctl(fptr->fd, FIONREAD, &n)) return INT2FIX(0); if (n > 0) return ioctl_arg2num(n); diff --git a/test/io/wait/test_io_wait.rb b/test/io/wait/test_io_wait.rb index 46097e00c69dcd..6d8b0442ae2000 100644 --- a/test/io/wait/test_io_wait.rb +++ b/test/io/wait/test_io_wait.rb @@ -31,7 +31,7 @@ def test_nread def test_nread_buffered @w.syswrite ".\n!" - assert_equal ".\n", @r.read(2) + assert_equal ".\n", @r.gets assert_equal 1, @r.nread end diff --git a/version.h b/version.h index d70d742f46a913..83954470ca6207 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.5" -#define RUBY_RELEASE_DATE "2015-03-01" -#define RUBY_PATCHLEVEL 305 +#define RUBY_RELEASE_DATE "2015-03-03" +#define RUBY_PATCHLEVEL 306 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 3 -#define RUBY_RELEASE_DAY 1 +#define RUBY_RELEASE_DAY 3 #include "ruby/version.h" From 2d5f7e5e17ef2a05b4218d7a889453897afa72be Mon Sep 17 00:00:00 2001 From: nagachika Date: Mon, 9 Mar 2015 13:00:13 +0000 Subject: [PATCH 313/343] merge revision(s) r48666: [Backport #10875] * lib/uri/generic.rb (URI::Generic.build): use hostname= to detect and wrap IPv6 hosts. Build is accepting URI components and users may not expect that a host component needs to be wrapped with square brackets since it's not providing a URI. Note: initialize with arg_check => true does not wrap IPv6 hosts. by Joe Rafaniello https://github.com/ruby/ruby/pull/765 fix GH-765 * test/uri/test_generic.rb: Add more tests git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@49907 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 13 +++++++++++++ lib/uri/generic.rb | 2 +- test/uri/test_generic.rb | 20 +++++++++++++++++--- version.h | 6 +++--- 4 files changed, 34 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index f06e6aab0c719c..30ae55d9d3a479 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +Mon Mar 9 21:52:41 2015 NARUSE, Yui + + * lib/uri/generic.rb (URI::Generic.build): + use hostname= to detect and wrap IPv6 hosts. + Build is accepting URI components and users may not expect + that a host component needs to be wrapped with square brackets + since it's not providing a URI. + Note: initialize with arg_check => true does not wrap IPv6 hosts. + by Joe Rafaniello + https://github.com/ruby/ruby/pull/765 fix GH-765 + + * test/uri/test_generic.rb: Add more tests + Tue Mar 3 02:42:27 2015 Eric Wong * ext/io/wait/wait.c (io_nread): wrap return value with INT2FIX diff --git a/lib/uri/generic.rb b/lib/uri/generic.rb index 88c96fe90a8f94..d7a55dcbd81eed 100644 --- a/lib/uri/generic.rb +++ b/lib/uri/generic.rb @@ -192,7 +192,7 @@ def initialize(scheme, if arg_check self.scheme = scheme self.userinfo = userinfo - self.host = host + self.hostname = host self.port = port self.path = path self.query = query diff --git a/test/uri/test_generic.rb b/test/uri/test_generic.rb index b5b1fc1c2637c3..c9e3576a8036a5 100644 --- a/test/uri/test_generic.rb +++ b/test/uri/test_generic.rb @@ -741,12 +741,26 @@ def test_ipv6 end def test_build - URI::Generic.build(['http', nil, 'example.com', 80, nil, '/foo', nil, nil, nil]) + u = URI::Generic.build(['http', nil, 'example.com', 80, nil, '/foo', nil, nil, nil]) + assert_equal('http://example.com:80/foo', u.to_s) + + u = URI::Generic.build(:scheme => "http", :host => "::1", :path => "/bar/baz") + assert_equal("http://[::1]/bar/baz", u.to_s) + assert_equal("[::1]", u.host) + assert_equal("::1", u.hostname) + + u = URI::Generic.build(:scheme => "http", :host => "[::1]", :path => "/bar/baz") + assert_equal("http://[::1]/bar/baz", u.to_s) + assert_equal("[::1]", u.host) + assert_equal("::1", u.hostname) end def test_build2 - URI::Generic.build2(path: "/foo bar/baz") - URI::Generic.build2(['http', nil, 'example.com', 80, nil, '/foo bar' , nil, nil, nil]) + u = URI::Generic.build2(path: "/foo bar/baz") + assert_equal('/foo%20bar/baz', u.to_s) + + u = URI::Generic.build2(['http', nil, 'example.com', 80, nil, '/foo bar' , nil, nil, nil]) + assert_equal('http://example.com:80/foo%20bar', u.to_s) end # 192.0.2.0/24 is TEST-NET. [RFC3330] diff --git a/version.h b/version.h index 83954470ca6207..d9600bb35bfdfa 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.5" -#define RUBY_RELEASE_DATE "2015-03-03" -#define RUBY_PATCHLEVEL 306 +#define RUBY_RELEASE_DATE "2015-03-09" +#define RUBY_PATCHLEVEL 307 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 3 -#define RUBY_RELEASE_DAY 3 +#define RUBY_RELEASE_DAY 9 #include "ruby/version.h" From cac1786add3304434e5b6ab1b9cfda5df0f8fcd0 Mon Sep 17 00:00:00 2001 From: nagachika Date: Mon, 9 Mar 2015 13:29:44 +0000 Subject: [PATCH 314/343] merge revision(s) r49689: [Backport #10953] * common.mk: use ruby organization for rubyspec. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@49908 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ common.mk | 2 +- version.h | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 30ae55d9d3a479..0461046995920f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Mon Mar 9 22:27:47 2015 SHIBATA Hiroshi + + * common.mk: use ruby organization for rubyspec. + Mon Mar 9 21:52:41 2015 NARUSE, Yui * lib/uri/generic.rb (URI::Generic.build): diff --git a/common.mk b/common.mk index de1b671fdd23a0..6508c4c023651e 100644 --- a/common.mk +++ b/common.mk @@ -14,7 +14,7 @@ RUBYLIB = $(PATH_SEPARATOR) RUBYOPT = - RUN_OPTS = --disable-gems -SPEC_GIT_BASE = git://github.com/nurse +SPEC_GIT_BASE = git://github.com/ruby MSPEC_GIT_URL = $(SPEC_GIT_BASE)/mspec.git RUBYSPEC_GIT_URL = $(SPEC_GIT_BASE)/rubyspec.git diff --git a/version.h b/version.h index d9600bb35bfdfa..6e6bf8635a3b34 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.5" #define RUBY_RELEASE_DATE "2015-03-09" -#define RUBY_PATCHLEVEL 307 +#define RUBY_PATCHLEVEL 308 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 3 From 9ee867c44f70452c9871c69d4b6f2328d3d5cc70 Mon Sep 17 00:00:00 2001 From: nagachika Date: Mon, 9 Mar 2015 13:39:18 +0000 Subject: [PATCH 315/343] merge revision(s) r49752,r49753: [Backport #10953] * spec/default.mspec: remove specific version number. https://github.com/ruby/rubyspec/commit/7a909e925c1baa9c700bd44af9241aef6e596714 * spec/default.mspec: use default configuration file name. https://github.com/ruby/rubyspec/commit/cc69f337b06362e5607ffa3e3ad40ef7494960cf git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@49909 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 10 ++++++++++ spec/default.mspec | 2 +- version.h | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0461046995920f..6e166c3e8603de 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +Mon Mar 9 22:30:50 2015 SHIBATA Hiroshi + + * spec/default.mspec: use default configuration file name. + https://github.com/ruby/rubyspec/commit/cc69f337b06362e5607ffa3e3ad40ef7494960cf + +Mon Mar 9 22:30:50 2015 SHIBATA Hiroshi + + * spec/default.mspec: remove specific version number. + https://github.com/ruby/rubyspec/commit/7a909e925c1baa9c700bd44af9241aef6e596714 + Mon Mar 9 22:27:47 2015 SHIBATA Hiroshi * common.mk: use ruby organization for rubyspec. diff --git a/spec/default.mspec b/spec/default.mspec index c4b75f614aa3a3..e45526c7aceec0 100644 --- a/spec/default.mspec +++ b/spec/default.mspec @@ -1,4 +1,4 @@ -load File.dirname(__FILE__) + '/rubyspec/ruby.1.9.mspec' +load File.dirname(__FILE__) + '/rubyspec/default.mspec' class MSpecScript builddir = Dir.pwd srcdir = ENV['SRCDIR'] diff --git a/version.h b/version.h index 6e6bf8635a3b34..8dd256b6b49750 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.5" #define RUBY_RELEASE_DATE "2015-03-09" -#define RUBY_PATCHLEVEL 308 +#define RUBY_PATCHLEVEL 309 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 3 From 38117a85b32bdfd8fc96687254fd0b759edaadbf Mon Sep 17 00:00:00 2001 From: nagachika Date: Mon, 9 Mar 2015 17:28:14 +0000 Subject: [PATCH 316/343] merge revision(s) r48854: [Backport #10494] * test/lib/test/unit.rb: Also rescue EINVAL for older Linux that raises it in popen. [Bug #10494] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@49910 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/test/unit.rb | 2 +- version.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/test/unit.rb b/lib/test/unit.rb index 13a993fc6cd4d3..09036e5b938dc3 100644 --- a/lib/test/unit.rb +++ b/lib/test/unit.rb @@ -394,7 +394,7 @@ def terminal_width begin require 'io/console' width = $stdout.winsize[1] - rescue LoadError, NoMethodError, Errno::ENOTTY, Errno::EBADF + rescue LoadError, NoMethodError, Errno::ENOTTY, Errno::EBADF, Errno::EINVAL width = ENV["COLUMNS"].to_i.nonzero? || 80 end width -= 1 if /mswin|mingw/ =~ RUBY_PLATFORM diff --git a/version.h b/version.h index 8dd256b6b49750..1c24050b64e8c7 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.5" -#define RUBY_RELEASE_DATE "2015-03-09" -#define RUBY_PATCHLEVEL 309 +#define RUBY_RELEASE_DATE "2015-03-10" +#define RUBY_PATCHLEVEL 310 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 3 -#define RUBY_RELEASE_DAY 9 +#define RUBY_RELEASE_DAY 10 #include "ruby/version.h" From 51e8c8199cf6068496fa495a00d36fb7e674ce77 Mon Sep 17 00:00:00 2001 From: nagachika Date: Mon, 9 Mar 2015 17:38:28 +0000 Subject: [PATCH 317/343] merge revision(s) r48747,r48772: [Backport #10582] * string.c: [DOC] Add missing documentation around String#chomp. Patch by @stderr [ci skip][fix GH-780] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@49911 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ string.c | 21 ++++++++++++--------- version.h | 2 +- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6e166c3e8603de..6f7a3303a43df3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Tue Mar 10 02:37:55 2015 SHIBATA Hiroshi + + * string.c: [DOC] Add missing documentation around String#chomp. + Patch by @stderr [ci skip][fix GH-780] + Mon Mar 9 22:30:50 2015 SHIBATA Hiroshi * spec/default.mspec: use default configuration file name. diff --git a/string.c b/string.c index e6f72bc5e74766..a9b0b8bcc010db 100644 --- a/string.c +++ b/string.c @@ -7058,15 +7058,18 @@ rb_str_chomp_bang(int argc, VALUE *argv, VALUE str) * from the end of str (if present). If $/ has not been * changed from the default Ruby record separator, then chomp also * removes carriage return characters (that is it will remove \n, - * \r, and \r\n). - * - * "hello".chomp #=> "hello" - * "hello\n".chomp #=> "hello" - * "hello\r\n".chomp #=> "hello" - * "hello\n\r".chomp #=> "hello\n" - * "hello\r".chomp #=> "hello" - * "hello \n there".chomp #=> "hello \n there" - * "hello".chomp("llo") #=> "he" + * \r, and \r\n). If $/ is an empty string, + * it will remove all trailing newlines from the string. + * + * "hello".chomp #=> "hello" + * "hello\n".chomp #=> "hello" + * "hello\r\n".chomp #=> "hello" + * "hello\n\r".chomp #=> "hello\n" + * "hello\r".chomp #=> "hello" + * "hello \n there".chomp #=> "hello \n there" + * "hello".chomp("llo") #=> "he" + * "hello\r\n\r\n".chomp('') #=> "hello" + * "hello\r\n\r\r\n".chomp('') #=> "hello\r\n\r" */ static VALUE diff --git a/version.h b/version.h index 1c24050b64e8c7..1eae7300357190 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.5" #define RUBY_RELEASE_DATE "2015-03-10" -#define RUBY_PATCHLEVEL 310 +#define RUBY_PATCHLEVEL 311 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 3 From db0f86030891ee91fb2e2b116dcc05bb3bcc019e Mon Sep 17 00:00:00 2001 From: nagachika Date: Mon, 9 Mar 2015 17:40:36 +0000 Subject: [PATCH 318/343] merge revision(s) r49428: [Backport #10694] * thread.c: Improve documentation for Thread#value [Bug #10694][ruby-core:67324][ci skip] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@49912 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ thread.c | 6 +++++- version.h | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6f7a3303a43df3..5a51c7227238ae 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Tue Mar 10 02:40:11 2015 SHIBATA Hiroshi + + * thread.c: Improve documentation for Thread#value + [Bug #10694][ruby-core:67324][ci skip] + Tue Mar 10 02:37:55 2015 SHIBATA Hiroshi * string.c: [DOC] Add missing documentation around String#chomp. diff --git a/thread.c b/thread.c index b24d29e087386d..605ac60c0820c8 100644 --- a/thread.c +++ b/thread.c @@ -916,10 +916,14 @@ thread_join_m(int argc, VALUE *argv, VALUE self) * call-seq: * thr.value -> obj * - * Waits for +thr+ to complete, using #join, and returns its value. + * Waits for +thr+ to complete, using #join, and returns its value or raises + * the exception which terminated the thread. * * a = Thread.new { 2 + 2 } * a.value #=> 4 + * + * b = Thread.new { raise 'something went wrong' } + * b.value #=> RuntimeError: something went wrong */ static VALUE diff --git a/version.h b/version.h index 1eae7300357190..2798b80d5d2c35 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.5" #define RUBY_RELEASE_DATE "2015-03-10" -#define RUBY_PATCHLEVEL 311 +#define RUBY_PATCHLEVEL 312 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 3 From 5d3b8d0d5491096a10ae332db759b01c89a10f9d Mon Sep 17 00:00:00 2001 From: nagachika Date: Tue, 17 Mar 2015 15:55:50 +0000 Subject: [PATCH 319/343] merge revision(s) r49322: [Backport #10753] * vm_method.c (check_definition): Module#public_method_defined?, Module#private_method_defined?, Module#protected_method_defined? should not use refinements. [ruby-core:67656] [Bug #10753] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@49991 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 +++ test/ruby/test_refinement.rb | 75 ++++++++++++++++++++++++++++++++++++ version.h | 6 +-- vm_method.c | 2 +- 4 files changed, 85 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5a51c7227238ae..6efce93db29ea3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Wed Mar 18 00:32:08 2015 Seiei Higa + + * vm_method.c (check_definition): Module#public_method_defined?, + Module#private_method_defined?, Module#protected_method_defined? + should not use refinements. [ruby-core:67656] [Bug #10753] + Tue Mar 10 02:40:11 2015 SHIBATA Hiroshi * thread.c: Improve documentation for Thread#value diff --git a/test/ruby/test_refinement.rb b/test/ruby/test_refinement.rb index 98bf9c60274ccd..f34a7deb54f126 100644 --- a/test/ruby/test_refinement.rb +++ b/test/ruby/test_refinement.rb @@ -1206,6 +1206,81 @@ class C end; end + def test_refined_method_defined + assert_separately([], <<-"end;") + bug10753 = '[ruby-core:67656] [Bug #10753]' + + c = Class.new do + def refined_public; end + def refined_protected; end + def refined_private; end + + public :refined_public + protected :refined_protected + private :refined_private + end + + m = Module.new do + refine(c) do + def refined_public; end + def refined_protected; end + def refined_private; end + + public :refined_public + protected :refined_protected + private :refined_private + end + end + + using m + + assert_equal(true, c.public_method_defined?(:refined_public), bug10753) + assert_equal(false, c.public_method_defined?(:refined_protected), bug10753) + assert_equal(false, c.public_method_defined?(:refined_private), bug10753) + + assert_equal(false, c.protected_method_defined?(:refined_public), bug10753) + assert_equal(true, c.protected_method_defined?(:refined_protected), bug10753) + assert_equal(false, c.protected_method_defined?(:refined_private), bug10753) + + assert_equal(false, c.private_method_defined?(:refined_public), bug10753) + assert_equal(false, c.private_method_defined?(:refined_protected), bug10753) + assert_equal(true, c.private_method_defined?(:refined_private), bug10753) + end; + end + + def test_undefined_refined_method_defined + assert_separately([], <<-"end;") + bug10753 = '[ruby-core:67656] [Bug #10753]' + + c = Class.new + + m = Module.new do + refine(c) do + def undefined_refined_public; end + def undefined_refined_protected; end + def undefined_refined_private; end + public :undefined_refined_public + protected :undefined_refined_protected + private :undefined_refined_private + end + end + + using m + + assert_equal(false, c.public_method_defined?(:undefined_refined_public), bug10753) + assert_equal(false, c.public_method_defined?(:undefined_refined_protected), bug10753) + assert_equal(false, c.public_method_defined?(:undefined_refined_private), bug10753) + + assert_equal(false, c.protected_method_defined?(:undefined_refined_public), bug10753) + assert_equal(false, c.protected_method_defined?(:undefined_refined_protected), bug10753) + assert_equal(false, c.protected_method_defined?(:undefined_refined_private), bug10753) + + assert_equal(false, c.private_method_defined?(:undefined_refined_public), bug10753) + assert_equal(false, c.private_method_defined?(:undefined_refined_protected), bug10753) + assert_equal(false, c.private_method_defined?(:undefined_refined_private), bug10753) + end; + end + private def eval_using(mod, s) diff --git a/version.h b/version.h index 2798b80d5d2c35..6173b28f3489e3 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.5" -#define RUBY_RELEASE_DATE "2015-03-10" -#define RUBY_PATCHLEVEL 312 +#define RUBY_RELEASE_DATE "2015-03-18" +#define RUBY_PATCHLEVEL 313 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 3 -#define RUBY_RELEASE_DAY 10 +#define RUBY_RELEASE_DAY 18 #include "ruby/version.h" diff --git a/vm_method.c b/vm_method.c index 3748e9267995f9..c084d52e84e582 100644 --- a/vm_method.c +++ b/vm_method.c @@ -1044,7 +1044,7 @@ check_definition(VALUE mod, VALUE mid, rb_method_flag_t noex) const rb_method_entry_t *me; ID id = rb_check_id(&mid); if (!id) return Qfalse; - me = rb_method_entry(mod, id, 0); + me = rb_method_entry_without_refinements(mod, id, 0); if (me) { if (VISI_CHECK(me->flag, noex)) return Qtrue; From c4b21f736ebb339fc46760f800851a7eed444c47 Mon Sep 17 00:00:00 2001 From: nagachika Date: Tue, 17 Mar 2015 16:12:28 +0000 Subject: [PATCH 320/343] merge revision(s) r49222,r49480,r49493: [Backport #10765] method.h: UNDEFINED_REFINED_METHOD_P * method.h (UNDEFINED_REFINED_METHOD_P): macro to tell if refined original method is defined. * vm_method.c (remove_method): When remove refined method, raise a NameError if the method is not defined in refined class. But if the method is defined in refined class, it should keep refined method and remove original method. Patch by Seiei Higa. [ruby-core:67722] [Bug #10765] * class.c (method_entry_i, class_instance_method_list, rb_obj_singleton_methods): should not include methods of superclasses if recur is false. [ruby-dev:48854] [Bug #10826] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@49992 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 18 +++++++++ class.c | 38 +++++++++++------- method.h | 3 ++ test/ruby/test_refinement.rb | 77 ++++++++++++++++++++++++++++++++++++ version.h | 2 +- vm_method.c | 17 ++++---- 6 files changed, 133 insertions(+), 22 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6efce93db29ea3..edd2b63423fe1c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +Wed Mar 18 00:58:43 2015 Shugo Maeda + + * class.c (method_entry_i, class_instance_method_list, + rb_obj_singleton_methods): should not include methods of + superclasses if recur is false. [ruby-dev:48854] [Bug #10826] + +Wed Mar 18 00:58:43 2015 Shugo Maeda + + * vm_method.c (remove_method): When remove refined + method, raise a NameError if the method is not + defined in refined class. + + But if the method is defined in refined class, + it should keep refined method and remove original + method. + + Patch by Seiei Higa. [ruby-core:67722] [Bug #10765] + Wed Mar 18 00:32:08 2015 Seiei Higa * vm_method.c (check_definition): Module#public_method_defined?, diff --git a/class.c b/class.c index 8f11f45b535c65..664a31348aa870 100644 --- a/class.c +++ b/class.c @@ -1116,25 +1116,32 @@ ins_methods_pub_i(st_data_t name, st_data_t type, st_data_t ary) return ins_methods_push((ID)name, (long)type, (VALUE)ary, NOEX_PUBLIC); } +struct method_entry_arg { + st_table *list; + int recur; +}; + static int method_entry_i(st_data_t key, st_data_t value, st_data_t data) { const rb_method_entry_t *me = (const rb_method_entry_t *)value; - st_table *list = (st_table *)data; + struct method_entry_arg *arg = (struct method_entry_arg *)data; long type; if (me && me->def->type == VM_METHOD_TYPE_REFINED) { + VALUE klass = me->klass; me = rb_resolve_refined_method(Qnil, me, NULL); if (!me) return ST_CONTINUE; + if (!arg->recur && me->klass != klass) return ST_CONTINUE; } - if (!st_lookup(list, key, 0)) { + if (!st_lookup(arg->list, key, 0)) { if (UNDEFINED_METHOD_ENTRY_P(me)) { type = -1; /* none */ } else { type = VISI(me->flag); } - st_add_direct(list, key, type); + st_add_direct(arg->list, key, type); } return ST_CONTINUE; } @@ -1144,7 +1151,7 @@ class_instance_method_list(int argc, VALUE *argv, VALUE mod, int obj, int (*func { VALUE ary; int recur, prepended = 0; - st_table *list; + struct method_entry_arg me_arg; if (argc == 0) { recur = TRUE; @@ -1160,16 +1167,17 @@ class_instance_method_list(int argc, VALUE *argv, VALUE mod, int obj, int (*func prepended = 1; } - list = st_init_numtable(); + me_arg.list = st_init_numtable(); + me_arg.recur = recur; for (; mod; mod = RCLASS_SUPER(mod)) { - if (RCLASS_M_TBL(mod)) st_foreach(RCLASS_M_TBL(mod), method_entry_i, (st_data_t)list); + if (RCLASS_M_TBL(mod)) st_foreach(RCLASS_M_TBL(mod), method_entry_i, (st_data_t)&me_arg); if (BUILTIN_TYPE(mod) == T_ICLASS && !prepended) continue; if (obj && FL_TEST(mod, FL_SINGLETON)) continue; if (!recur) break; } ary = rb_ary_new(); - st_foreach(list, func, ary); - st_free_table(list); + st_foreach(me_arg.list, func, ary); + st_free_table(me_arg.list); return ary; } @@ -1391,7 +1399,8 @@ VALUE rb_obj_singleton_methods(int argc, VALUE *argv, VALUE obj) { VALUE recur, ary, klass, origin; - st_table *list, *mtbl; + struct method_entry_arg me_arg; + st_table *mtbl; if (argc == 0) { recur = Qtrue; @@ -1401,22 +1410,23 @@ rb_obj_singleton_methods(int argc, VALUE *argv, VALUE obj) } klass = CLASS_OF(obj); origin = RCLASS_ORIGIN(klass); - list = st_init_numtable(); + me_arg.list = st_init_numtable(); + me_arg.recur = recur; if (klass && FL_TEST(klass, FL_SINGLETON)) { if ((mtbl = RCLASS_M_TBL(origin)) != 0) - st_foreach(mtbl, method_entry_i, (st_data_t)list); + st_foreach(mtbl, method_entry_i, (st_data_t)&me_arg); klass = RCLASS_SUPER(klass); } if (RTEST(recur)) { while (klass && (FL_TEST(klass, FL_SINGLETON) || RB_TYPE_P(klass, T_ICLASS))) { if (klass != origin && (mtbl = RCLASS_M_TBL(klass)) != 0) - st_foreach(mtbl, method_entry_i, (st_data_t)list); + st_foreach(mtbl, method_entry_i, (st_data_t)&me_arg); klass = RCLASS_SUPER(klass); } } ary = rb_ary_new(); - st_foreach(list, ins_methods_i, ary); - st_free_table(list); + st_foreach(me_arg.list, ins_methods_i, ary); + st_free_table(me_arg.list); return ary; } diff --git a/method.h b/method.h index c93e4c39c1e1b6..f5d40f9c8fa6c1 100644 --- a/method.h +++ b/method.h @@ -108,6 +108,9 @@ struct unlinked_method_entry_list_entry { }; #define UNDEFINED_METHOD_ENTRY_P(me) (!(me) || !(me)->def || (me)->def->type == VM_METHOD_TYPE_UNDEF) +#define UNDEFINED_REFINED_METHOD_P(def) \ + ((def)->type == VM_METHOD_TYPE_REFINED && \ + UNDEFINED_METHOD_ENTRY_P((def)->body.orig_me)) void rb_add_method_cfunc(VALUE klass, ID mid, VALUE (*func)(ANYARGS), int argc, rb_method_flag_t noex); rb_method_entry_t *rb_add_method(VALUE klass, ID mid, rb_method_type_t type, void *option, rb_method_flag_t noex); diff --git a/test/ruby/test_refinement.rb b/test/ruby/test_refinement.rb index f34a7deb54f126..dc2d31c867b471 100644 --- a/test/ruby/test_refinement.rb +++ b/test/ruby/test_refinement.rb @@ -1281,6 +1281,83 @@ def undefined_refined_private; end end; end + def test_remove_refined_method + assert_separately([], <<-"end;") + bug10765 = '[ruby-core:67722] [Bug #10765]' + + class C + def foo + "C#foo" + end + end + + module RefinementBug + refine C do + def foo + "RefinementBug#foo" + end + end + end + + using RefinementBug + + class C + remove_method :foo + end + + assert_equal("RefinementBug#foo", C.new.foo, bug10765) + end; + end + + def test_remove_undefined_refined_method + assert_separately([], <<-"end;") + bug10765 = '[ruby-core:67722] [Bug #10765]' + + class C + end + + module RefinementBug + refine C do + def foo + end + end + end + + using RefinementBug + + assert_raise(NameError, bug10765) { + class C + remove_method :foo + end + } + end; + end + + module NotIncludeSuperclassMethod + class X + def foo + end + end + + class Y < X + end + + module Bar + refine Y do + def foo + end + end + end + end + + def test_instance_methods_not_include_superclass_method + bug10826 = '[ruby-dev:48854] [Bug #10826]' + assert_not_include(NotIncludeSuperclassMethod::Y.instance_methods(false), + :foo, bug10826) + assert_include(NotIncludeSuperclassMethod::Y.instance_methods(true), + :foo, bug10826) + end + private def eval_using(mod, s) diff --git a/version.h b/version.h index 6173b28f3489e3..4b61d4a6758904 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.5" #define RUBY_RELEASE_DATE "2015-03-18" -#define RUBY_PATCHLEVEL 313 +#define RUBY_PATCHLEVEL 314 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 3 diff --git a/vm_method.c b/vm_method.c index c084d52e84e582..84b4e867340829 100644 --- a/vm_method.c +++ b/vm_method.c @@ -732,10 +732,12 @@ remove_method(VALUE klass, ID mid) if (!st_lookup(RCLASS_M_TBL(klass), mid, &data) || !(me = (rb_method_entry_t *)data) || - (!me->def || me->def->type == VM_METHOD_TYPE_UNDEF)) { + (!me->def || me->def->type == VM_METHOD_TYPE_UNDEF) || + UNDEFINED_REFINED_METHOD_P(me->def)) { rb_name_error(mid, "method `%s' not defined in %s", rb_id2name(mid), rb_class2name(klass)); } + key = (st_data_t)mid; st_delete(RCLASS_M_TBL(klass), &key, &data); @@ -743,6 +745,10 @@ remove_method(VALUE klass, ID mid) rb_clear_method_cache_by_class(klass); rb_unlink_method_entry(me); + if (me->def->type == VM_METHOD_TYPE_REFINED) { + rb_add_refined_method_entry(klass, mid); + } + CALL_METHOD_HOOK(self, removed, mid); } @@ -812,8 +818,7 @@ rb_export_method(VALUE klass, ID name, rb_method_flag_t noex) } if (UNDEFINED_METHOD_ENTRY_P(me) || - (me->def->type == VM_METHOD_TYPE_REFINED && - UNDEFINED_METHOD_ENTRY_P(me->def->body.orig_me))) { + UNDEFINED_REFINED_METHOD_P(me->def)) { rb_print_undef(klass, name, 0); } @@ -912,8 +917,7 @@ rb_undef(VALUE klass, ID id) me = search_method(klass, id, 0); if (UNDEFINED_METHOD_ENTRY_P(me) || - (me->def->type == VM_METHOD_TYPE_REFINED && - UNDEFINED_METHOD_ENTRY_P(me->def->body.orig_me))) { + UNDEFINED_REFINED_METHOD_P(me->def)) { const char *s0 = " class"; VALUE c = klass; @@ -1260,8 +1264,7 @@ rb_alias(VALUE klass, ID name, ID def) orig_me = search_method(klass, def, &defined_class); if (UNDEFINED_METHOD_ENTRY_P(orig_me) || - (orig_me->def->type == VM_METHOD_TYPE_REFINED && - UNDEFINED_METHOD_ENTRY_P(orig_me->def->body.orig_me))) { + UNDEFINED_REFINED_METHOD_P(orig_me->def)) { if ((!RB_TYPE_P(klass, T_MODULE)) || (orig_me = search_method(rb_cObject, def, 0), UNDEFINED_METHOD_ENTRY_P(orig_me))) { From 8aca3e79eeafd71f524bbd2b5aef1ac8feab35b1 Mon Sep 17 00:00:00 2001 From: nagachika Date: Tue, 17 Mar 2015 16:56:55 +0000 Subject: [PATCH 321/343] merge revision(s) r49482,r49487: [Backport #10821] * lib/mkmf.rb (try_cppflags, try_cflags, try_ldflags): get rid of interference by modifying global variables in have_devel? method. [ruby-core:67962] [Bug #10821] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@49993 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ lib/mkmf.rb | 12 +++--------- test/mkmf/base.rb | 13 ++++++++++++- test/mkmf/test_flags.rb | 21 +++++++++++++++++++++ version.h | 2 +- 5 files changed, 43 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index edd2b63423fe1c..ffab9b25507edc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Wed Mar 18 01:45:12 2015 Nobuyoshi Nakada + + * lib/mkmf.rb (try_cppflags, try_cflags, try_ldflags): get rid of + interference by modifying global variables in have_devel? method. + [ruby-core:67962] [Bug #10821] + Wed Mar 18 00:58:43 2015 Shugo Maeda * class.c (method_entry_i, class_instance_method_list, diff --git a/lib/mkmf.rb b/lib/mkmf.rb index b408ed780f8df9..f5c462b58e636e 100644 --- a/lib/mkmf.rb +++ b/lib/mkmf.rb @@ -610,9 +610,7 @@ def with_cppflags(flags) end def try_cppflags(flags) - with_cppflags(flags) do - try_header("int main() {return 0;}") - end + try_header(MAIN_DOES_NOTHING, flags) end def with_cflags(flags) @@ -624,9 +622,7 @@ def with_cflags(flags) end def try_cflags(flags) - with_cflags(flags) do - try_compile("int main() {return 0;}") - end + try_compile(MAIN_DOES_NOTHING, flags) end def with_ldflags(flags) @@ -638,9 +634,7 @@ def with_ldflags(flags) end def try_ldflags(flags) - with_ldflags(flags) do - try_link("int main() {return 0;}") - end + try_link(MAIN_DOES_NOTHING, flags) end def try_static_assert(expr, headers = nil, opt = "", &b) diff --git a/test/mkmf/base.rb b/test/mkmf/base.rb index ab1a0f04b7ee49..92825eecf7c47e 100644 --- a/test/mkmf/base.rb +++ b/test/mkmf/base.rb @@ -3,6 +3,7 @@ require 'test/unit' require 'mkmf' require 'tmpdir' +require_relative '../ruby/envutil' $extout = '$(topdir)/'+RbConfig::CONFIG["EXTOUT"] RbConfig::CONFIG['topdir'] = CONFIG['topdir'] = File.expand_path(CONFIG['topdir']) @@ -49,7 +50,9 @@ def write(s) @buffer << s if @out end end +end +module TestMkmf::Base attr_reader :stdout def mkmflog(msg) @@ -84,7 +87,7 @@ def setup @tmpdir = Dir.mktmpdir @curdir = Dir.pwd @mkmfobj = Object.new - @stdout = Capture.new + @stdout = TestMkmf::Capture.new Dir.chdir(@tmpdir) @quiet, Logging.quiet = Logging.quiet, true init_mkmf @@ -127,3 +130,11 @@ def config_value(name) nil end end + +class TestMkmf + include TestMkmf::Base + + def assert_separately(args, src, *rest) + super(args + ["-r#{__FILE__}"], "extend TestMkmf::Base; setup\n#{src}", *rest) + end +end diff --git a/test/mkmf/test_flags.rb b/test/mkmf/test_flags.rb index 3bb278071a56b3..e49d474dc904f4 100644 --- a/test/mkmf/test_flags.rb +++ b/test/mkmf/test_flags.rb @@ -31,5 +31,26 @@ def test_valid_warnflags $warnflags = warnflags $extmk = val end + + def test_try_ldflag_invalid_opt + assert_separately([], <<-'end;') #do + assert(!try_ldflags("nosuch.c"), TestMkmf::MKMFLOG) + assert(have_devel?, TestMkmf::MKMFLOG) + end; + end + + def test_try_cflag_invalid_opt + assert_separately([], <<-'end;') #do + assert(!try_cflags("nosuch.c"), TestMkmf::MKMFLOG) + assert(have_devel?, TestMkmf::MKMFLOG) + end; + end + + def test_try_cppflag_invalid_opt + assert_separately([], <<-'end;') #do + assert(!try_cppflags("nosuch.c"), TestMkmf::MKMFLOG) + assert(have_devel?, TestMkmf::MKMFLOG) + end; + end end end diff --git a/version.h b/version.h index 4b61d4a6758904..ef20e30e1df537 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.5" #define RUBY_RELEASE_DATE "2015-03-18" -#define RUBY_PATCHLEVEL 314 +#define RUBY_PATCHLEVEL 315 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 3 From 838f246282511b4b64b70d1427716edcc739da0d Mon Sep 17 00:00:00 2001 From: nagachika Date: Tue, 17 Mar 2015 16:59:08 +0000 Subject: [PATCH 322/343] merge revision(s) r49490,r49494: [Backport #10825] * ext/sdbm/_sdbm.c: include ruby/ruby.h for PRIdPTRDIFF when a macro `DEBUG` is defined. based on the patch by Owen Rodley in [ruby-core:67987]. [Bug #10825] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@49994 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ ext/sdbm/_sdbm.c | 5 ++--- version.h | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index ffab9b25507edc..48d41f565d5f94 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Wed Mar 18 01:58:18 2015 Nobuyoshi Nakada + + * ext/sdbm/_sdbm.c: include ruby/ruby.h for PRIdPTRDIFF when a + macro `DEBUG` is defined. based on the patch by Owen Rodley in + [ruby-core:67987]. [Bug #10825] + Wed Mar 18 01:45:12 2015 Nobuyoshi Nakada * lib/mkmf.rb (try_cppflags, try_cflags, try_ldflags): get rid of diff --git a/ext/sdbm/_sdbm.c b/ext/sdbm/_sdbm.c index 847eb2aaf6b2cf..d810befbce4ee5 100644 --- a/ext/sdbm/_sdbm.c +++ b/ext/sdbm/_sdbm.c @@ -7,8 +7,7 @@ * core routines */ -#include "ruby/config.h" -#include "ruby/defines.h" +#include "ruby/ruby.h" #ifdef HAVE_UNISTD_H #include @@ -803,7 +802,7 @@ delpair(char *pag, datum key) } #else #ifdef MEMMOVE - memmove(dst, src, m); + memmove(dst-m, src-m, m); #else while (m--) *--dst = *--src; diff --git a/version.h b/version.h index ef20e30e1df537..e30626de50fdeb 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.5" #define RUBY_RELEASE_DATE "2015-03-18" -#define RUBY_PATCHLEVEL 315 +#define RUBY_PATCHLEVEL 316 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 3 From 585287338ed2eb6f1443d838911632eff243a998 Mon Sep 17 00:00:00 2001 From: nagachika Date: Tue, 17 Mar 2015 17:34:01 +0000 Subject: [PATCH 323/343] merge revision(s) r49685,r49687: [Backport #10885] * vm_insnhelper.c (rb_vm_rewrite_cref_stack): copy nd_refinements of orignal crefs. It fixes segmentation fault when calling refined method in duplicate module. [ruby-dev:48878] [Bug #10885] * vm_core.h, class.c: change accordingly. * test/ruby/test_refinement.rb: add a test for above. of original crefs. It fixes segmentation fault when calling git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@49995 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 10 ++++++++++ class.c | 21 +-------------------- test/ruby/test_refinement.rb | 28 ++++++++++++++++++++++++++++ version.h | 2 +- vm_core.h | 2 ++ vm_insnhelper.c | 21 +++++++++++++++++++++ 6 files changed, 63 insertions(+), 21 deletions(-) diff --git a/ChangeLog b/ChangeLog index 48d41f565d5f94..b8ea6d6761250e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +Wed Mar 18 02:03:02 2015 Kazuki Tsujimoto + + * vm_insnhelper.c (rb_vm_rewrite_cref_stack): copy nd_refinements + of original crefs. It fixes segmentation fault when calling + refined method in duplicate module. [ruby-dev:48878] [Bug #10885] + + * vm_core.h, class.c: change accordingly. + + * test/ruby/test_refinement.rb: add a test for above. + Wed Mar 18 01:58:18 2015 Nobuyoshi Nakada * ext/sdbm/_sdbm.c: include ruby/ruby.h for PRIdPTRDIFF when a diff --git a/class.c b/class.c index 664a31348aa870..da58a6c3bfa95f 100644 --- a/class.c +++ b/class.c @@ -232,25 +232,6 @@ rb_class_new(VALUE super) return rb_class_boot(super); } -static void -rewrite_cref_stack(NODE *node, VALUE old_klass, VALUE new_klass, NODE **new_cref_ptr) -{ - NODE *new_node; - while (node) { - if (node->nd_clss == old_klass) { - new_node = NEW_CREF(new_klass); - RB_OBJ_WRITE(new_node, &new_node->nd_next, node->nd_next); - *new_cref_ptr = new_node; - return; - } - new_node = NEW_CREF(node->nd_clss); - node = node->nd_next; - *new_cref_ptr = new_node; - new_cref_ptr = &new_node->nd_next; - } - *new_cref_ptr = NULL; -} - static void clone_method(VALUE klass, ID mid, const rb_method_entry_t *me) { @@ -260,7 +241,7 @@ clone_method(VALUE klass, ID mid, const rb_method_entry_t *me) NODE *new_cref; newiseqval = rb_iseq_clone(me->def->body.iseq->self, klass); GetISeqPtr(newiseqval, iseq); - rewrite_cref_stack(me->def->body.iseq->cref_stack, me->klass, klass, &new_cref); + rb_vm_rewrite_cref_stack(me->def->body.iseq->cref_stack, me->klass, klass, &new_cref); RB_OBJ_WRITE(iseq->self, &iseq->cref_stack, new_cref); rb_add_method(klass, mid, VM_METHOD_TYPE_ISEQ, iseq, me->flag); RB_GC_GUARD(newiseqval); diff --git a/test/ruby/test_refinement.rb b/test/ruby/test_refinement.rb index dc2d31c867b471..d9b166317b2034 100644 --- a/test/ruby/test_refinement.rb +++ b/test/ruby/test_refinement.rb @@ -1358,6 +1358,34 @@ def test_instance_methods_not_include_superclass_method :foo, bug10826) end + def test_call_refined_method_in_duplicate_module + bug10885 = '[ruby-dev:48878]' + assert_in_out_err([], <<-INPUT, [], [], bug10885) + module M + refine Object do + def raise + # do nothing + end + end + + class << self + using M + def m0 + raise + end + end + + using M + def M.m1 + raise + end + end + + M.dup.m0 + M.dup.m1 + INPUT + end + private def eval_using(mod, s) diff --git a/version.h b/version.h index e30626de50fdeb..c00f2be55c5a90 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.5" #define RUBY_RELEASE_DATE "2015-03-18" -#define RUBY_PATCHLEVEL 316 +#define RUBY_PATCHLEVEL 317 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 3 diff --git a/vm_core.h b/vm_core.h index 73127e65eab41d..34a53f07fa8024 100644 --- a/vm_core.h +++ b/vm_core.h @@ -896,6 +896,8 @@ void rb_gc_mark_machine_stack(rb_thread_t *th); int rb_autoloading_value(VALUE mod, ID id, VALUE* value); +void rb_vm_rewrite_cref_stack(NODE *node, VALUE old_klass, VALUE new_klass, NODE **new_cref_ptr); + #define sysstack_error GET_VM()->special_exceptions[ruby_error_sysstack] #define RUBY_CONST_ASSERT(expr) (1/!!(expr)) /* expr must be a compile-time constant */ diff --git a/vm_insnhelper.c b/vm_insnhelper.c index f52a8f562d7b6c..20dc63f1e05d89 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -278,6 +278,27 @@ rb_vm_get_cref(const rb_iseq_t *iseq, const VALUE *ep) return cref; } +void +rb_vm_rewrite_cref_stack(NODE *node, VALUE old_klass, VALUE new_klass, NODE **new_cref_ptr) +{ + NODE *new_node; + while (node) { + if (node->nd_clss == old_klass) { + new_node = NEW_CREF(new_klass); + COPY_CREF_OMOD(new_node, node); + RB_OBJ_WRITE(new_node, &new_node->nd_next, node->nd_next); + *new_cref_ptr = new_node; + return; + } + new_node = NEW_CREF(node->nd_clss); + COPY_CREF_OMOD(new_node, node); + node = node->nd_next; + *new_cref_ptr = new_node; + new_cref_ptr = &new_node->nd_next; + } + *new_cref_ptr = NULL; +} + static NODE * vm_cref_push(rb_thread_t *th, VALUE klass, int noex, rb_block_t *blockptr) { From 7cd92ce49a6d5474361190248e7caed176fae743 Mon Sep 17 00:00:00 2001 From: nagachika Date: Tue, 17 Mar 2015 17:40:51 +0000 Subject: [PATCH 324/343] merge revision(s) r48585,r48587: [Backport #10546] * win32/win32.c (constat_reset): do nothing on non-standard console emurators. [ruby-core:66471] [Bug #10546] console emulators. [ruby-core:66471] [Bug #10546] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@49996 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ version.h | 2 +- win32/win32.c | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index b8ea6d6761250e..d8e23a31a55bbd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed Mar 18 02:40:18 2015 Nobuyoshi Nakada + + * win32/win32.c (constat_reset): do nothing on non-standard + console emulators. [ruby-core:66471] [Bug #10546] + Wed Mar 18 02:03:02 2015 Kazuki Tsujimoto * vm_insnhelper.c (rb_vm_rewrite_cref_stack): copy nd_refinements diff --git a/version.h b/version.h index c00f2be55c5a90..1bc2c420fa390a 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.5" #define RUBY_RELEASE_DATE "2015-03-18" -#define RUBY_PATCHLEVEL 317 +#define RUBY_PATCHLEVEL 318 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 3 diff --git a/win32/win32.c b/win32/win32.c index 1653bd1aedad94..b9f52a92944253 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -5924,7 +5924,7 @@ constat_reset(HANDLE h) { st_data_t data; struct constat *p; - if (!conlist) return; + if (!conlist || conlist == conlist_disabled) return; if (!st_lookup(conlist, (st_data_t)h, &data)) return; p = (struct constat *)data; p->vt100.state = constat_init; From c7edfc37fff5a1b6636e6582a882419cc32942c9 Mon Sep 17 00:00:00 2001 From: nagachika Date: Tue, 17 Mar 2015 17:42:46 +0000 Subject: [PATCH 325/343] merge revision(s) r48690: [Backport #10563] * win32/win32.c (w32_spawn): `v2` is used not only for `shell` but also `cmd`, so must not free before using `cmd`. [ruby-core:66648] [Bug #10563] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@49997 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ version.h | 2 +- win32/win32.c | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index d8e23a31a55bbd..6b6b5cece36b34 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Wed Mar 18 02:42:37 2015 NAKAMURA Usaku + + * win32/win32.c (w32_spawn): `v2` is used not only for `shell` but also + `cmd`, so must not free before using `cmd`. + [ruby-core:66648] [Bug #10563] + Wed Mar 18 02:40:18 2015 Nobuyoshi Nakada * win32/win32.c (constat_reset): do nothing on non-standard diff --git a/version.h b/version.h index 1bc2c420fa390a..b5e5cc26ff9c47 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.5" #define RUBY_RELEASE_DATE "2015-03-18" -#define RUBY_PATCHLEVEL 318 +#define RUBY_PATCHLEVEL 319 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 3 diff --git a/win32/win32.c b/win32/win32.c index b9f52a92944253..1f56f43d6bc247 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -1320,9 +1320,9 @@ w32_spawn(int mode, const char *cmd, const char *prog, UINT cp) } if (!e && shell && !(wshell = mbstr_to_wstr(cp, shell, -1, NULL))) e = E2BIG; - if (v2) ALLOCV_END(v2); if (cmd_sep) *cmd_sep = sep; if (!e && cmd && !(wcmd = mbstr_to_wstr(cp, cmd, -1, NULL))) e = E2BIG; + if (v2) ALLOCV_END(v2); if (v) ALLOCV_END(v); if (!e) { From 410699b90e2bb1d2ac2c0d49c204d2576d8335a1 Mon Sep 17 00:00:00 2001 From: nagachika Date: Sat, 21 Mar 2015 19:35:06 +0000 Subject: [PATCH 326/343] merge revision(s) r44681: [Backport #9440] * ext/thread/thread.c (Init_thread): ConditionVariable and Queue are not able to copy. [ruby-core:59961] [Bug #9440] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@50044 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ ext/thread/thread.c | 2 ++ test/thread/test_cv.rb | 8 ++++++++ test/thread/test_queue.rb | 8 ++++++++ version.h | 6 +++--- 5 files changed, 26 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6b6b5cece36b34..ea9d12236a2b37 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sun Mar 22 04:15:39 2015 Nobuyoshi Nakada + + * ext/thread/thread.c (Init_thread): ConditionVariable and Queue + are not able to copy. [ruby-core:59961] [Bug #9440] + Wed Mar 18 02:42:37 2015 NAKAMURA Usaku * win32/win32.c (w32_spawn): `v2` is used not only for `shell` but also diff --git a/ext/thread/thread.c b/ext/thread/thread.c index c3d81dc58d8a8b..c54396b927a54f 100644 --- a/ext/thread/thread.c +++ b/ext/thread/thread.c @@ -590,12 +590,14 @@ Init_thread(void) rb_define_method(rb_cConditionVariable, "initialize", rb_condvar_initialize, 0); rb_define_method(rb_cConditionVariable, "marshal_dump", undumpable, 0); + rb_undef_method(rb_cConditionVariable, "initialize_copy"); rb_define_method(rb_cConditionVariable, "wait", rb_condvar_wait, -1); rb_define_method(rb_cConditionVariable, "signal", rb_condvar_signal, 0); rb_define_method(rb_cConditionVariable, "broadcast", rb_condvar_broadcast, 0); rb_define_method(rb_cQueue, "initialize", rb_queue_initialize, 0); rb_define_method(rb_cQueue, "marshal_dump", undumpable, 0); + rb_undef_method(rb_cQueue, "initialize_copy"); rb_define_method(rb_cQueue, "push", rb_queue_push, 1); rb_define_method(rb_cQueue, "pop", rb_queue_pop, -1); rb_define_method(rb_cQueue, "empty?", rb_queue_empty_p, 0); diff --git a/test/thread/test_cv.rb b/test/thread/test_cv.rb index 08459a0a04c526..53f3261390e24e 100644 --- a/test/thread/test_cv.rb +++ b/test/thread/test_cv.rb @@ -195,6 +195,14 @@ def test_condvar_empty_broadcast assert_nothing_raised(Exception) { mutex.synchronize {condvar.broadcast} } end + def test_dup + bug9440 = '[ruby-core:59961] [Bug #9440]' + condvar = ConditionVariable.new + assert_raise(NoMethodError, bug9440) do + condvar.dup + end + end + (DumpableCV = ConditionVariable.dup).class_eval {remove_method :marshal_dump} def test_dump diff --git a/test/thread/test_queue.rb b/test/thread/test_queue.rb index 314ee98dab0ddb..c33cb6dc8adfd9 100644 --- a/test/thread/test_queue.rb +++ b/test/thread/test_queue.rb @@ -220,6 +220,14 @@ def test_queue_thread_raise end end + def test_dup + bug9440 = '[ruby-core:59961] [Bug #9440]' + q = Queue.new + assert_raise(NoMethodError, bug9440) do + q.dup + end + end + (DumpableQueue = Queue.dup).class_eval {remove_method :marshal_dump} def test_dump diff --git a/version.h b/version.h index b5e5cc26ff9c47..43a6135df12e7d 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.5" -#define RUBY_RELEASE_DATE "2015-03-18" -#define RUBY_PATCHLEVEL 319 +#define RUBY_RELEASE_DATE "2015-03-22" +#define RUBY_PATCHLEVEL 320 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 3 -#define RUBY_RELEASE_DAY 18 +#define RUBY_RELEASE_DAY 22 #include "ruby/version.h" From 5727caf689097592fedf0a33420e1b8136c50c1a Mon Sep 17 00:00:00 2001 From: nagachika Date: Mon, 23 Mar 2015 20:11:27 +0000 Subject: [PATCH 327/343] merge revision(s) r47129,r48844: [Backport #10120] configure.in: remove SSE options git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@50067 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- configure.in | 16 ---------------- test/ruby/test_sprintf.rb | 5 +++-- version.h | 6 +++--- 3 files changed, 6 insertions(+), 21 deletions(-) diff --git a/configure.in b/configure.in index cc8849eb459946..96331a808a1b9f 100644 --- a/configure.in +++ b/configure.in @@ -863,22 +863,6 @@ if test "$GCC" = yes; then for oflag in -fno-fast-math; do RUBY_TRY_CFLAGS($oflag, [RUBY_APPEND_OPTION(optflags, $oflag)]) done - AS_CASE(["$target"], - [*-darwin*], [ - # doesn't seem necessary on Mac OS X - ], - [[i[4-6]86*|i386*mingw*]], [ - RUBY_TRY_CFLAGS(-msse2 -mfpmath=sse, [ - RUBY_APPEND_OPTION(XCFLAGS, -msse2 -mfpmath=sse) - ]) - AS_CASE(["$XCFLAGS"], - [[*-msse2*]], [ - RUBY_TRY_CFLAGS(-mstackrealign, [ - RUBY_APPEND_OPTION(XCFLAGS, -mstackrealign) - ]) - ]) - ] - ) fi AC_ARG_WITH(opt-dir, diff --git a/test/ruby/test_sprintf.rb b/test/ruby/test_sprintf.rb index eff35c18daac47..9fc3fd059fbe44 100644 --- a/test/ruby/test_sprintf.rb +++ b/test/ruby/test_sprintf.rb @@ -194,8 +194,9 @@ def test_float sprintf("%20.0f", 36893488147419107329.0)) assert_equal(" Inf", sprintf("% 0e", 1.0/0.0), "moved from btest/knownbug") assert_equal(" -0.", sprintf("%#10.0f", -0.5), "[ruby-dev:42552]") - assert_equal("0x1p+2", sprintf('%.0a', Float('0x1.fp+1')), "[ruby-dev:42551]") - assert_equal("-0x1.0p+2", sprintf('%.1a', Float('-0x1.ffp+1')), "[ruby-dev:42551]") + # out of spec + #assert_equal("0x1p+2", sprintf('%.0a', Float('0x1.fp+1')), "[ruby-dev:42551]") + #assert_equal("-0x1.0p+2", sprintf('%.1a', Float('-0x1.ffp+1')), "[ruby-dev:42551]") end def test_float_hex diff --git a/version.h b/version.h index 43a6135df12e7d..4dc33a2aac1f19 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.5" -#define RUBY_RELEASE_DATE "2015-03-22" -#define RUBY_PATCHLEVEL 320 +#define RUBY_RELEASE_DATE "2015-03-24" +#define RUBY_PATCHLEVEL 321 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 3 -#define RUBY_RELEASE_DAY 22 +#define RUBY_RELEASE_DAY 24 #include "ruby/version.h" From 6a2b4ced6ad48ee7db0afdf564dcbb6cd3bfbd76 Mon Sep 17 00:00:00 2001 From: nagachika Date: Mon, 30 Mar 2015 14:41:15 +0000 Subject: [PATCH 328/343] merge revision(s) r46254,r48982,r48984: [Backport #10649] test/io/console/test_io_console.rb: Close FDs. * ext/io/console/console.c (console_dev): id_console is not a constant name, use rb_const_remove() to get rid of NameError. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@50126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ ext/io/console/console.c | 2 +- test/io/console/test_io_console.rb | 35 ++++++++++++++++++++++++------ version.h | 6 ++--- 4 files changed, 37 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index ea9d12236a2b37..f483fee5ac84e8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Mon Mar 30 23:30:57 2015 Nobuyoshi Nakada + + * ext/io/console/console.c (console_dev): id_console is not a + constant name, use rb_const_remove() to get rid of NameError. + Sun Mar 22 04:15:39 2015 Nobuyoshi Nakada * ext/thread/thread.c (Init_thread): ConditionVariable and Queue diff --git a/ext/io/console/console.c b/ext/io/console/console.c index de5ca825583bd0..85b6750c9fbf77 100644 --- a/ext/io/console/console.c +++ b/ext/io/console/console.c @@ -689,7 +689,7 @@ console_dev(VALUE klass) if ((fptr = RFILE(con)->fptr) && GetReadFD(fptr) != -1) return con; } - rb_mod_remove_const(klass, ID2SYM(id_console)); + rb_const_remove(klass, id_console); } { VALUE args[2]; diff --git a/test/io/console/test_io_console.rb b/test/io/console/test_io_console.rb index a9de376a2b5b9c..baa44cfbef6d07 100644 --- a/test/io/console/test_io_console.rb +++ b/test/io/console/test_io_console.rb @@ -217,18 +217,22 @@ def test_winsize end if IO.console + def test_close + IO.console.close + assert_kind_of(IO, IO.console) + assert_nothing_raised(IOError) {IO.console.fileno} + end + def test_sync assert(IO.console.sync, "console should be unbuffered") end else + def test_close + assert_equal(["true"], run_pty("IO.console.close; p IO.console.fileno >= 0")) + end + def test_sync - r, w, pid = PTY.spawn(EnvUtil.rubybin, "-rio/console", "-e", "p IO.console.class") - rescue RuntimeError - skip $! - else - con = r.gets.chomp - Process.wait(pid) - assert_match("File", con) + assert_equal(["true"], run_pty("p IO.console.sync")) end end @@ -243,6 +247,23 @@ def helper m.close if m s.close if s end + + def run_pty(src) + r, w, pid = PTY.spawn(EnvUtil.rubybin, "-rio/console", "-e", src) + rescue RuntimeError + skip $! + else + result = r.readlines(&:chomp) + Process.wait(pid) + if block_given? + yield result + else + result + end + ensure + r.close if r + w.close if w + end end if defined?(PTY) and defined?(IO::console) class TestIO_Console < Test::Unit::TestCase diff --git a/version.h b/version.h index 4dc33a2aac1f19..8ec02875c83db3 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.5" -#define RUBY_RELEASE_DATE "2015-03-24" -#define RUBY_PATCHLEVEL 321 +#define RUBY_RELEASE_DATE "2015-03-30" +#define RUBY_PATCHLEVEL 322 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 3 -#define RUBY_RELEASE_DAY 24 +#define RUBY_RELEASE_DAY 30 #include "ruby/version.h" From 85f3339697f48cdc292374d3ae6b079d67c22274 Mon Sep 17 00:00:00 2001 From: nagachika Date: Mon, 30 Mar 2015 14:43:44 +0000 Subject: [PATCH 329/343] merge revision(s) r48878: [Backport #9591] io-console.gemspec: bump up * ext/io/console/io-console.gemspec: bump up to 0.4.3. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@50127 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/io/console/io-console.gemspec | 2 +- version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/io/console/io-console.gemspec b/ext/io/console/io-console.gemspec index f71e1b9b8f3906..309b9bd85b7bcb 100644 --- a/ext/io/console/io-console.gemspec +++ b/ext/io/console/io-console.gemspec @@ -1,5 +1,5 @@ # -*- ruby -*- -_VERSION = "0.4.2" +_VERSION = "0.4.3" date = %w$Date:: $[1] Gem::Specification.new do |s| diff --git a/version.h b/version.h index 8ec02875c83db3..a4fb874f77ce88 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.5" #define RUBY_RELEASE_DATE "2015-03-30" -#define RUBY_PATCHLEVEL 322 +#define RUBY_PATCHLEVEL 323 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 3 From 0eded3c0c3f22e28842be23bdebb8eda92401e8a Mon Sep 17 00:00:00 2001 From: nagachika Date: Mon, 30 Mar 2015 15:29:28 +0000 Subject: [PATCH 330/343] merge revision(s) r49964: [Backport #10957] * parse.y (primary): empty parentheses at cmdarg can be null. [ruby-core:68477] [Bug #10957] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@50128 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ parse.y | 4 ++-- test/ruby/test_syntax.rb | 6 ++++++ version.h | 6 +++--- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index f483fee5ac84e8..307277b9de5a30 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Tue Mar 31 00:18:12 2015 Nobuyoshi Nakada + + * parse.y (primary): empty parentheses at cmdarg can be null. + [ruby-core:68477] [Bug #10957] + Mon Mar 30 23:30:57 2015 Nobuyoshi Nakada * ext/io/console/console.c (console_dev): id_console is not a diff --git a/parse.y b/parse.y index 577dc37d83897f..277998ce152ad9 100644 --- a/parse.y +++ b/parse.y @@ -2046,7 +2046,7 @@ arg : lhs '=' arg value_expr($1); value_expr($3); $$ = NEW_DOT2($1, $3); - if (nd_type($1) == NODE_LIT && FIXNUM_P($1->nd_lit) && + if ($1 && nd_type($1) == NODE_LIT && FIXNUM_P($1->nd_lit) && nd_type($3) == NODE_LIT && FIXNUM_P($3->nd_lit)) { deferred_nodes = list_append(deferred_nodes, $$); } @@ -2060,7 +2060,7 @@ arg : lhs '=' arg value_expr($1); value_expr($3); $$ = NEW_DOT3($1, $3); - if (nd_type($1) == NODE_LIT && FIXNUM_P($1->nd_lit) && + if ($1 && nd_type($1) == NODE_LIT && FIXNUM_P($1->nd_lit) && nd_type($3) == NODE_LIT && FIXNUM_P($3->nd_lit)) { deferred_nodes = list_append(deferred_nodes, $$); } diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index 2ed57889ba5e05..c94a8c68e1286e 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -408,6 +408,12 @@ def test_error_message_encoding assert_syntax_error(code, /def n "\u{2208}"; end/, bug10114) end + def test_null_range_cmdarg + bug10957 = '[ruby-core:68477] [Bug #10957]' + assert_ruby_status(['-c', '-e', 'p ()..0'], "", bug10957) + assert_ruby_status(['-c', '-e', 'p ()...0'], "", bug10957) + end + private def not_label(x) @result = x; @not_label ||= nil end diff --git a/version.h b/version.h index a4fb874f77ce88..24636f4cc5d270 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.5" -#define RUBY_RELEASE_DATE "2015-03-30" -#define RUBY_PATCHLEVEL 323 +#define RUBY_RELEASE_DATE "2015-03-31" +#define RUBY_PATCHLEVEL 324 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 3 -#define RUBY_RELEASE_DAY 30 +#define RUBY_RELEASE_DAY 31 #include "ruby/version.h" From d8edc3e477bd0ccee0d52014cefc00b1ba2c081d Mon Sep 17 00:00:00 2001 From: nagachika Date: Mon, 30 Mar 2015 15:32:43 +0000 Subject: [PATCH 331/343] merge revision(s) r49157: [Backport #10384] * test/fiddle/test_handle.rb (test_NEXT): use -test-/dln/empty which is always a shared object and is not used by others. [ruby-dev:48629] [Bug #10384] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@50129 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ test/fiddle/test_handle.rb | 10 +++++----- version.h | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 307277b9de5a30..eb464582717ff5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Tue Mar 31 00:32:04 2015 Nobuyoshi Nakada + + * test/fiddle/test_handle.rb (test_NEXT): use -test-/dln/empty + which is always a shared object and is not used by others. + [ruby-dev:48629] [Bug #10384] + Tue Mar 31 00:18:12 2015 Nobuyoshi Nakada * parse.y (primary): empty parentheses at cmdarg can be null. diff --git a/test/fiddle/test_handle.rb b/test/fiddle/test_handle.rb index cde3fa816dcef9..0bb6c823e395a9 100644 --- a/test/fiddle/test_handle.rb +++ b/test/fiddle/test_handle.rb @@ -37,9 +37,9 @@ def test_static_sym assert_equal Fiddle::Handle.sym('dlopen'), Fiddle::Handle['dlopen'] rescue # NetBSD - require 'objspace' - refute_nil Fiddle::Handle.sym('Init_objspace') - assert_equal Fiddle::Handle.sym('Init_objspace'), Fiddle::Handle['Init_objspace'] + require '-test-/dln/empty' + refute_nil Fiddle::Handle.sym('Init_empty') + assert_equal Fiddle::Handle.sym('Init_empty'), Fiddle::Handle['Init_empty'] end end @@ -166,9 +166,9 @@ def test_NEXT # interface, below, should be used, since getpid() is a function and not a # data object.) # --- FreeBSD 8.0 dlsym(3) - require 'objspace' + require '-test-/dln/empty' handle = Handle::NEXT - refute_nil handle['Init_objspace'] + refute_nil handle['Init_empty'] end end unless /mswin|mingw/ =~ RUBY_PLATFORM diff --git a/version.h b/version.h index 24636f4cc5d270..0c24a018ad8dfe 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.5" #define RUBY_RELEASE_DATE "2015-03-31" -#define RUBY_PATCHLEVEL 324 +#define RUBY_PATCHLEVEL 325 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 3 From 1b18735b4bda48b7705ae3fe5a63511ed75c9d58 Mon Sep 17 00:00:00 2001 From: nagachika Date: Mon, 30 Mar 2015 15:35:08 +0000 Subject: [PATCH 332/343] merge revision(s) r49192: [Backport #10716] * configure.in (RUBY_SETJMP_TYPE): Remove superfluous semicolon which causes a syntax error with autoconf 2.63. [ruby-core:67429] [Bug #10716] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@50130 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ configure.in | 2 +- version.h | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index eb464582717ff5..5ba2f5d0d9783d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Tue Mar 31 00:34:39 2015 Vit Ondruch + + * configure.in (RUBY_SETJMP_TYPE): Remove superfluous semicolon + which causes a syntax error with autoconf 2.63. + [ruby-core:67429] [Bug #10716] + Tue Mar 31 00:32:04 2015 Nobuyoshi Nakada * test/fiddle/test_handle.rb (test_NEXT): use -test-/dln/empty diff --git a/configure.in b/configure.in index 96331a808a1b9f..73f96b682bba8f 100644 --- a/configure.in +++ b/configure.in @@ -2062,7 +2062,7 @@ if test ${setjmp_prefix+set}; then if test "${setjmp_prefix}" && eval test '$ac_cv_func_'${setjmp_prefix}setjmp${setjmp_suffix} = no; then AC_MSG_ERROR(${setjmp_prefix}setjmp${setjmp_suffix} is not available) fi -elif { AS_CASE("$ac_cv_func___builtin_setjmp", [yes*], [true], [false]); }; then +elif { AS_CASE("$ac_cv_func___builtin_setjmp", [yes*], [true], [false]) }; then setjmp_cast=`expr "$ac_cv_func___builtin_setjmp" : "yes with cast (\(.*\))"` setjmp_prefix=__builtin_ setjmp_suffix= diff --git a/version.h b/version.h index 0c24a018ad8dfe..29a1d4b627c150 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.5" #define RUBY_RELEASE_DATE "2015-03-31" -#define RUBY_PATCHLEVEL 325 +#define RUBY_PATCHLEVEL 326 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 3 From ed22c21a8f4e0c98045efb6de245fba79ec7e961 Mon Sep 17 00:00:00 2001 From: nagachika Date: Mon, 30 Mar 2015 15:45:35 +0000 Subject: [PATCH 333/343] merge revision(s) r49184: [Backport #10707] * vm_method.c (rb_method_entry): if no super class, no original method entry. [ruby-core:67389] [Bug #10707] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@50131 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ test/ruby/test_refinement.rb | 13 +++++++++++++ version.h | 2 +- vm_method.c | 7 ++++++- 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5ba2f5d0d9783d..953dc96790baf4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Tue Mar 31 00:38:14 2015 Seiei Higa + + * vm_method.c (rb_method_entry): if no super class, no original + method entry. [ruby-core:67389] [Bug #10707] + Tue Mar 31 00:34:39 2015 Vit Ondruch * configure.in (RUBY_SETJMP_TYPE): Remove superfluous semicolon diff --git a/test/ruby/test_refinement.rb b/test/ruby/test_refinement.rb index d9b166317b2034..4ed0423abdd0fe 100644 --- a/test/ruby/test_refinement.rb +++ b/test/ruby/test_refinement.rb @@ -1165,6 +1165,19 @@ def foo assert_raise(NoMethodError, bug10106) {Object.new.foo} end; + + assert_separately([], <<-"end;") + bug10707 = '[ruby-core:67389] [Bug #10707]' + module RefinementBug + refine BasicObject do + def foo + end + end + end + + assert(methods, bug10707) + assert_raise(NameError, bug10707) {method(:foo)} + end; end def test_change_refined_new_method_visibility diff --git a/version.h b/version.h index 29a1d4b627c150..94b9d22f16dd80 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.5" #define RUBY_RELEASE_DATE "2015-03-31" -#define RUBY_PATCHLEVEL 326 +#define RUBY_PATCHLEVEL 327 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 3 diff --git a/vm_method.c b/vm_method.c index 84b4e867340829..a8b524d2bc8019 100644 --- a/vm_method.c +++ b/vm_method.c @@ -639,12 +639,17 @@ get_original_method_entry(VALUE refinements, const rb_method_entry_t *me, VALUE *defined_class_ptr) { + VALUE super; + if (me->def->body.orig_me) { return me->def->body.orig_me; } + else if (!(super = RCLASS_SUPER(me->klass))) { + return 0; + } else { rb_method_entry_t *tmp_me; - tmp_me = rb_method_entry(RCLASS_SUPER(me->klass), me->called_id, + tmp_me = rb_method_entry(super, me->called_id, defined_class_ptr); return rb_resolve_refined_method(refinements, tmp_me, defined_class_ptr); From 4d683d0566a16c3a7bc0d91bb92a36358613cf63 Mon Sep 17 00:00:00 2001 From: nagachika Date: Mon, 30 Mar 2015 15:49:32 +0000 Subject: [PATCH 334/343] merge revision(s) r48999,r49484: [Backport #10646] * gc.c (wmap_final_func): fix memory size shortage when realloc wmap. Fix SEGV during finilize of WeakRef on Solaris (though the SEGV could occur on all OS/platforms). [ruby-dev:48779] [Bug #10646] Fix SEGV during finalize of WeakRef on Solaris (though the SEGV git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@50132 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ gc.c | 2 +- version.h | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 953dc96790baf4..3745a2d304f7fe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Tue Mar 31 00:49:23 2015 Naohisa Goto + + * gc.c (wmap_final_func): fix memory size shortage when realloc wmap. + Fix SEGV during finalize of WeakRef on Solaris (though the SEGV + could occur on all OS/platforms). [ruby-dev:48779] [Bug #10646] + Tue Mar 31 00:38:14 2015 Seiei Higa * vm_method.c (rb_method_entry): if no super class, no original diff --git a/gc.c b/gc.c index cc37327463370c..f9048e031ad9fe 100644 --- a/gc.c +++ b/gc.c @@ -6413,7 +6413,7 @@ wmap_final_func(st_data_t *key, st_data_t *value, st_data_t arg, int existing) return ST_DELETE; } if (j < i) { - ptr = ruby_sized_xrealloc2(ptr, j, sizeof(VALUE), i); + ptr = ruby_sized_xrealloc2(ptr, j + 1, sizeof(VALUE), i); ptr[0] = j; *value = (st_data_t)ptr; } diff --git a/version.h b/version.h index 94b9d22f16dd80..bd5dbad4aaec58 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.5" #define RUBY_RELEASE_DATE "2015-03-31" -#define RUBY_PATCHLEVEL 327 +#define RUBY_PATCHLEVEL 328 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 3 From ab4c4d3e2b293cb40ca6a5f2a233ae3b5747e184 Mon Sep 17 00:00:00 2001 From: nagachika Date: Tue, 31 Mar 2015 13:47:40 +0000 Subject: [PATCH 335/343] merge revision(s) r48987,r48989: [Backport #10646] test_io_console.rb: chomp results * test/io/console/test_io_console.rb (run_pty): IO#readlines ignores the given block. need map to chomp the results. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@50140 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/io/console/test_io_console.rb | 5 +++-- version.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/test/io/console/test_io_console.rb b/test/io/console/test_io_console.rb index baa44cfbef6d07..91e1c8b1624ca4 100644 --- a/test/io/console/test_io_console.rb +++ b/test/io/console/test_io_console.rb @@ -248,12 +248,13 @@ def helper s.close if s end - def run_pty(src) + def run_pty(src, n = 1) r, w, pid = PTY.spawn(EnvUtil.rubybin, "-rio/console", "-e", src) rescue RuntimeError skip $! else - result = r.readlines(&:chomp) + result = [] + n.times {result << r.gets.chomp} Process.wait(pid) if block_given? yield result diff --git a/version.h b/version.h index bd5dbad4aaec58..1a570a8e5b5479 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.5" #define RUBY_RELEASE_DATE "2015-03-31" -#define RUBY_PATCHLEVEL 328 +#define RUBY_PATCHLEVEL 329 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 3 From 485267354273fc2ca2c9b1f22e39c5f1f414f4ca Mon Sep 17 00:00:00 2001 From: usa Date: Mon, 13 Apr 2015 07:41:24 +0000 Subject: [PATCH 336/343] merge revision(s) 50265: [Backport #10957] * parse.y (arg): fix segfault by null caused by syntax error. [ruby-core:68851] [Bug #10957] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@50283 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ parse.y | 4 ++-- test/ruby/test_syntax.rb | 2 ++ version.h | 8 ++++---- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3745a2d304f7fe..013ef036cea506 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Mon Apr 13 16:39:57 2015 Nobuyoshi Nakada + + * parse.y (arg): fix segfault by null caused by syntax error. + [ruby-core:68851] [Bug #10957] + Tue Mar 31 00:49:23 2015 Naohisa Goto * gc.c (wmap_final_func): fix memory size shortage when realloc wmap. diff --git a/parse.y b/parse.y index 277998ce152ad9..d091a0e6ef4a9d 100644 --- a/parse.y +++ b/parse.y @@ -2047,7 +2047,7 @@ arg : lhs '=' arg value_expr($3); $$ = NEW_DOT2($1, $3); if ($1 && nd_type($1) == NODE_LIT && FIXNUM_P($1->nd_lit) && - nd_type($3) == NODE_LIT && FIXNUM_P($3->nd_lit)) { + $3 && nd_type($3) == NODE_LIT && FIXNUM_P($3->nd_lit)) { deferred_nodes = list_append(deferred_nodes, $$); } /*% @@ -2061,7 +2061,7 @@ arg : lhs '=' arg value_expr($3); $$ = NEW_DOT3($1, $3); if ($1 && nd_type($1) == NODE_LIT && FIXNUM_P($1->nd_lit) && - nd_type($3) == NODE_LIT && FIXNUM_P($3->nd_lit)) { + $3 && nd_type($3) == NODE_LIT && FIXNUM_P($3->nd_lit)) { deferred_nodes = list_append(deferred_nodes, $$); } /*% diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index c94a8c68e1286e..692763ef98cb7b 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -412,6 +412,8 @@ def test_null_range_cmdarg bug10957 = '[ruby-core:68477] [Bug #10957]' assert_ruby_status(['-c', '-e', 'p ()..0'], "", bug10957) assert_ruby_status(['-c', '-e', 'p ()...0'], "", bug10957) + assert_syntax_error('0..%w.', /unterminated string/, bug10957) + assert_syntax_error('0...%w.', /unterminated string/, bug10957) end private diff --git a/version.h b/version.h index 1a570a8e5b5479..59a5249cee87cd 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.5" -#define RUBY_RELEASE_DATE "2015-03-31" -#define RUBY_PATCHLEVEL 329 +#define RUBY_RELEASE_DATE "2015-04-13" +#define RUBY_PATCHLEVEL 330 #define RUBY_RELEASE_YEAR 2015 -#define RUBY_RELEASE_MONTH 3 -#define RUBY_RELEASE_DAY 31 +#define RUBY_RELEASE_MONTH 4 +#define RUBY_RELEASE_DAY 13 #include "ruby/version.h" From 602edc0c11bc1f40cadee87c5df2ade81ef44d2c Mon Sep 17 00:00:00 2001 From: usa Date: Mon, 13 Apr 2015 07:48:58 +0000 Subject: [PATCH 337/343] merge revision(s) 49867: [Backport #10847] [Backport #10970] * vm_eval.c (vm_call_super): search next super class from the original class, to get rid of infinite recursion with prepending. a patch by Seiei Higa at [ruby-core:68434]. [ruby-core:68093] [Bug #10847] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@50284 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ test/ruby/test_module.rb | 11 +++++++++++ version.h | 2 +- vm_eval.c | 3 ++- 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 013ef036cea506..fa3d583b949ca7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Mon Apr 13 16:48:14 2015 Nobuyoshi Nakada + + * vm_eval.c (vm_call_super): search next super class from the + original class, to get rid of infinite recursion with + prepending. a patch by Seiei Higa at + [ruby-core:68434]. [ruby-core:68093] [Bug #10847] + Mon Apr 13 16:39:57 2015 Nobuyoshi Nakada * parse.y (arg): fix segfault by null caused by syntax error. diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb index 050d17a5d3fd1c..9910e261d536cd 100644 --- a/test/ruby/test_module.rb +++ b/test/ruby/test_module.rb @@ -1708,6 +1708,17 @@ def hello assert_equal('hello!', foo.new.hello, bug9236) end + def test_prepend_call_super + assert_separately([], <<-'end;') #do + bug10847 = '[ruby-core:68093] [Bug #10847]' + module M; end + Float.prepend M + assert_nothing_raised(SystemStackError, bug10847) do + 0.3.numerator + end + end; + end + def test_class_variables m = Module.new m.class_variable_set(:@@foo, 1) diff --git a/version.h b/version.h index 59a5249cee87cd..1145958c753653 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.5" #define RUBY_RELEASE_DATE "2015-04-13" -#define RUBY_PATCHLEVEL 330 +#define RUBY_PATCHLEVEL 331 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 4 diff --git a/vm_eval.c b/vm_eval.c index 5e79bedd9778b1..da6338419fdfa5 100644 --- a/vm_eval.c +++ b/vm_eval.c @@ -260,7 +260,8 @@ vm_call_super(rb_thread_t *th, int argc, const VALUE *argv) rb_bug("vm_call_super: should not be reached"); } - klass = RCLASS_SUPER(cfp->klass); + klass = RCLASS_ORIGIN(cfp->klass); + klass = RCLASS_SUPER(klass); id = cfp->me->def->original_id; me = rb_method_entry(klass, id, &klass); if (!me) { From 4f0e238f2854a9f3e5a1f3cbb0c8d32e66dc15d8 Mon Sep 17 00:00:00 2001 From: usa Date: Mon, 13 Apr 2015 07:52:40 +0000 Subject: [PATCH 338/343] merge revision(s) 49875: [Backport #10946] * class.c (rb_prepend_module): need a WB for klass -> origin. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@50285 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ class.c | 2 +- version.h | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index fa3d583b949ca7..99ed7617a5fb59 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Mon Apr 13 16:52:14 2015 Koichi Sasada + + * class.c (rb_prepend_module): need a WB for klass -> origin. + Mon Apr 13 16:48:14 2015 Nobuyoshi Nakada * vm_eval.c (vm_call_super): search next super class from the diff --git a/class.c b/class.c index da58a6c3bfa95f..ae190eec093e93 100644 --- a/class.c +++ b/class.c @@ -936,7 +936,7 @@ rb_prepend_module(VALUE klass, VALUE module) OBJ_WB_UNPROTECT(origin); /* TODO: conservertive shading. Need more survery. */ RCLASS_SET_SUPER(origin, RCLASS_SUPER(klass)); RCLASS_SET_SUPER(klass, origin); - RCLASS_ORIGIN(klass) = origin; + RB_OBJ_WRITE(klass, &RCLASS_ORIGIN(klass), origin); RCLASS_M_TBL_WRAPPER(origin) = RCLASS_M_TBL_WRAPPER(klass); RCLASS_M_TBL_INIT(klass); st_foreach(RCLASS_M_TBL(origin), move_refined_method, diff --git a/version.h b/version.h index 1145958c753653..8092f0d7335e85 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.5" #define RUBY_RELEASE_DATE "2015-04-13" -#define RUBY_PATCHLEVEL 331 +#define RUBY_PATCHLEVEL 332 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 4 From 99fdb0a71b54fbea4ded06b99cb8c003c1d9552e Mon Sep 17 00:00:00 2001 From: usa Date: Mon, 13 Apr 2015 08:02:39 +0000 Subject: [PATCH 339/343] merge revision(s) 49452: [Backport #10813] * thread_pthread.c (reserve_stack): fix intermittent SIGBUS on Linux, by reserving the stack virtual address space at process start up so that it will not clash with the heap space. [Fix GH-822] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@50289 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ thread_pthread.c | 37 +++++++++++++++++++++++++++++++++++++ version.h | 2 +- 3 files changed, 45 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 99ed7617a5fb59..883e725bf4192e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Mon Apr 13 17:02:25 2015 Scott Francis + + * thread_pthread.c (reserve_stack): fix intermittent SIGBUS on + Linux, by reserving the stack virtual address space at process + start up so that it will not clash with the heap space. + [Fix GH-822] + Mon Apr 13 16:52:14 2015 Koichi Sasada * class.c (rb_prepend_module): need a WB for klass -> origin. diff --git a/thread_pthread.c b/thread_pthread.c index 581dfecaaa3d27..f3cd8702f8e9b1 100644 --- a/thread_pthread.c +++ b/thread_pthread.c @@ -648,6 +648,42 @@ space_size(size_t stack_size) } } +#ifdef __linux__ +static __attribute__((noinline)) void +reserve_stack(volatile char *limit, size_t size) +{ +# ifdef C_ALLOCA +# error needs alloca() +# endif + struct rlimit rl; + volatile char buf[0x100]; + STACK_GROW_DIR_DETECTION; + + if (!getrlimit(RLIMIT_STACK, &rl) && rl.rlim_cur == RLIM_INFINITY) + return; + + size -= sizeof(buf); /* margin */ + if (IS_STACK_DIR_UPPER()) { + const volatile char *end = buf + sizeof(buf); + limit += size; + if (limit > end) { + size = limit - end; + limit = alloca(size); + limit[size-1] = 0; + } + } + else { + limit -= size; + if (buf > limit) { + limit = alloca(buf - limit); + limit[0] = 0; + } + } +} +#else +# define reserve_stack(limit, size) ((void)(limit), (void)(size)) +#endif + #undef ruby_init_stack /* Set stack bottom of Ruby implementation. * @@ -669,6 +705,7 @@ ruby_init_stack(volatile VALUE *addr if (get_main_stack(&stackaddr, &size) == 0) { native_main_thread.stack_maxsize = size; native_main_thread.stack_start = stackaddr; + reserve_stack(stackaddr, size); return; } } diff --git a/version.h b/version.h index 8092f0d7335e85..dbf58ed46d96f8 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.5" #define RUBY_RELEASE_DATE "2015-04-13" -#define RUBY_PATCHLEVEL 332 +#define RUBY_PATCHLEVEL 333 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 4 From 9462778d8170079235701403000277ec404506ba Mon Sep 17 00:00:00 2001 From: usa Date: Mon, 13 Apr 2015 08:10:10 +0000 Subject: [PATCH 340/343] merge revision(s) 49634,49658,49663: [Backport #10865] * win32/win32.c (wrename): return EXDEV if moving a directory to another drive, since MoveFileExW does not set proper error code. [ruby-core:68162] [Bug #10865] * win32/win32.c (different_device_p): compare by volume serial numbers, not by path names. numbers, not by path names. [ruby-core:68162] [Bug #10865] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@50290 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 11 +++++++++++ version.h | 2 +- win32/win32.c | 35 +++++++++++++++++++++++++++++++++-- 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 883e725bf4192e..f724d98b775766 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +Mon Apr 13 17:09:06 2015 Nobuyoshi Nakada + + * win32/win32.c (different_device_p): compare by volume serial + numbers, not by path names. [ruby-core:68162] [Bug #10865] + +Mon Apr 13 17:09:06 2015 Nobuyoshi Nakada + + * win32/win32.c (wrename): return EXDEV if moving a directory to + another drive, since MoveFileExW does not set proper error code. + [ruby-core:68162] [Bug #10865] + Mon Apr 13 17:02:25 2015 Scott Francis * thread_pthread.c (reserve_stack): fix intermittent SIGBUS on diff --git a/version.h b/version.h index dbf58ed46d96f8..58f16b63f9af8d 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.5" #define RUBY_RELEASE_DATE "2015-04-13" -#define RUBY_PATCHLEVEL 333 +#define RUBY_PATCHLEVEL 334 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 4 diff --git a/win32/win32.c b/win32/win32.c index 1f56f43d6bc247..ed5bfa778e70d4 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -4673,6 +4673,31 @@ rb_w32_getenv(const char *name) return w32_getenv(name, CP_ACP); } +/* License: Ruby's */ +static DWORD +get_volume_serial_number(const WCHAR *path) +{ + const DWORD share_mode = FILE_SHARE_READ | FILE_SHARE_WRITE; + const DWORD creation = OPEN_EXISTING; + const DWORD flags = FILE_FLAG_BACKUP_SEMANTICS; + BY_HANDLE_FILE_INFORMATION st = {0}; + HANDLE h = CreateFileW(path, 0, share_mode, NULL, creation, flags, NULL); + BOOL ret; + + if (h == INVALID_HANDLE_VALUE) return 0; + ret = GetFileInformationByHandle(h, &st); + CloseHandle(h); + if (!ret) return 0; + return st.dwVolumeSerialNumber; +} + +/* License: Ruby's */ +static int +different_device_p(const WCHAR *oldpath, const WCHAR *newpath) +{ + return get_volume_serial_number(oldpath) != get_volume_serial_number(newpath); +} + /* License: Artistic or GPL */ static int wrename(const WCHAR *oldpath, const WCHAR *newpath) @@ -4696,8 +4721,14 @@ wrename(const WCHAR *oldpath, const WCHAR *newpath) if (!MoveFileExW(oldpath, newpath, MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED)) res = -1; - if (res) - errno = map_errno(GetLastError()); + if (res) { + DWORD e = GetLastError(); + if ((e == ERROR_ACCESS_DENIED) && (oldatts & FILE_ATTRIBUTE_DIRECTORY) && + different_device_p(oldpath, newpath)) + errno = EXDEV; + else + errno = map_errno(e); + } else SetFileAttributesW(newpath, oldatts); }); From e3252606afe73a7085ce8b92bd0c0a5eccd918d4 Mon Sep 17 00:00:00 2001 From: usa Date: Mon, 13 Apr 2015 13:20:40 +0000 Subject: [PATCH 341/343] merge revision(s) 50292: [Backport #9644] * ext/openssl/lib/openssl/ssl.rb: stricter hostname verification following RFC 6125. with the patch provided by Tony Arcieri and Hiroshi Nakamura [ruby-core:61545] [Bug #9644] * test/openssl/test_ssl.rb: add tests for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@50296 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 ++ ext/openssl/lib/openssl/ssl.rb | 62 +++++++++++++- test/openssl/test_ssl.rb | 150 +++++++++++++++++++++++++++++++++ version.h | 2 +- 4 files changed, 216 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index f724d98b775766..54a4bbbd3fb4bb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Mon Apr 13 22:17:59 2015 CHIKANAGA Tomoyuki + + * ext/openssl/lib/openssl/ssl.rb: stricter hostname verification + following RFC 6125. with the patch provided by Tony Arcieri and + Hiroshi Nakamura [ruby-core:61545] [Bug #9644] + * test/openssl/test_ssl.rb: add tests for above. + Mon Apr 13 17:09:06 2015 Nobuyoshi Nakada * win32/win32.c (different_device_p): compare by volume serial diff --git a/ext/openssl/lib/openssl/ssl.rb b/ext/openssl/lib/openssl/ssl.rb index 43025e76220cf1..b91dce312a89d4 100644 --- a/ext/openssl/lib/openssl/ssl.rb +++ b/ext/openssl/lib/openssl/ssl.rb @@ -143,8 +143,7 @@ def verify_certificate_identity(cert, hostname) case san.tag when 2 # dNSName in GeneralName (RFC5280) should_verify_common_name = false - reg = Regexp.escape(san.value).gsub(/\\\*/, "[^.]+") - return true if /\A#{reg}\z/i =~ hostname + return true if verify_hostname(hostname, san.value) when 7 # iPAddress in GeneralName (RFC5280) should_verify_common_name = false # follows GENERAL_NAME_print() in x509v3/v3_alt.c @@ -159,8 +158,7 @@ def verify_certificate_identity(cert, hostname) if should_verify_common_name cert.subject.to_a.each{|oid, value| if oid == "CN" - reg = Regexp.escape(value).gsub(/\\\*/, "[^.]+") - return true if /\A#{reg}\z/i =~ hostname + return true if verify_hostname(hostname, value) end } end @@ -168,11 +166,67 @@ def verify_certificate_identity(cert, hostname) end module_function :verify_certificate_identity + def verify_hostname(hostname, san) # :nodoc: + # RFC 5280, IA5String is limited to the set of ASCII characters + return false unless san.ascii_only? + return false unless hostname.ascii_only? + + # See RFC 6125, section 6.4.1 + # Matching is case-insensitive. + san_parts = san.downcase.split(".") + + # TODO: this behavior should probably be more strict + return san == hostname if san_parts.size < 2 + + # Matching is case-insensitive. + host_parts = hostname.downcase.split(".") + + # RFC 6125, section 6.4.3, subitem 2. + # If the wildcard character is the only character of the left-most + # label in the presented identifier, the client SHOULD NOT compare + # against anything but the left-most label of the reference + # identifier (e.g., *.example.com would match foo.example.com but + # not bar.foo.example.com or example.com). + return false unless san_parts.size == host_parts.size + + # RFC 6125, section 6.4.3, subitem 1. + # The client SHOULD NOT attempt to match a presented identifier in + # which the wildcard character comprises a label other than the + # left-most label (e.g., do not match bar.*.example.net). + return false unless verify_wildcard(host_parts.shift, san_parts.shift) + + san_parts.join(".") == host_parts.join(".") + end + module_function :verify_hostname + + def verify_wildcard(domain_component, san_component) # :nodoc: + parts = san_component.split("*", -1) + + return false if parts.size > 2 + return san_component == domain_component if parts.size == 1 + + # RFC 6125, section 6.4.3, subitem 3. + # The client SHOULD NOT attempt to match a presented identifier + # where the wildcard character is embedded within an A-label or + # U-label of an internationalized domain name. + return false if domain_component.start_with?("xn--") && san_component != "*" + + parts[0].length + parts[1].length < domain_component.length && + domain_component.start_with?(parts[0]) && + domain_component.end_with?(parts[1]) + end + module_function :verify_wildcard + class SSLSocket include Buffering include SocketForwarder include Nonblock + ## + # Perform hostname verification after an SSL connection is established + # + # This method MUST be called after calling #connect to ensure that the + # hostname of a remote peer has been verified. def post_connection_check(hostname) unless OpenSSL::SSL.verify_certificate_identity(peer_cert, hostname) raise SSLError, "hostname \"#{hostname}\" does not match the server certificate" diff --git a/test/openssl/test_ssl.rb b/test/openssl/test_ssl.rb index b743819518f7b5..68a2543485fda3 100644 --- a/test/openssl/test_ssl.rb +++ b/test/openssl/test_ssl.rb @@ -359,6 +359,156 @@ def test_verify_certificate_identity end end + def test_verify_hostname + assert_equal(true, OpenSSL::SSL.verify_hostname("www.example.com", "*.example.com")) + assert_equal(false, OpenSSL::SSL.verify_hostname("www.subdomain.example.com", "*.example.com")) + end + + def test_verify_wildcard + assert_equal(false, OpenSSL::SSL.verify_wildcard("foo", "x*")) + assert_equal(true, OpenSSL::SSL.verify_wildcard("foo", "foo")) + assert_equal(true, OpenSSL::SSL.verify_wildcard("foo", "f*")) + assert_equal(true, OpenSSL::SSL.verify_wildcard("foo", "*")) + assert_equal(false, OpenSSL::SSL.verify_wildcard("abc*bcd", "abcd")) + assert_equal(false, OpenSSL::SSL.verify_wildcard("xn--qdk4b9b", "x*")) + assert_equal(false, OpenSSL::SSL.verify_wildcard("xn--qdk4b9b", "*--qdk4b9b")) + assert_equal(true, OpenSSL::SSL.verify_wildcard("xn--qdk4b9b", "xn--qdk4b9b")) + end + + # Comments in this test is excerpted from http://tools.ietf.org/html/rfc6125#page-27 + def test_post_connection_check_wildcard_san + # case-insensitive ASCII comparison + # RFC 6125, section 6.4.1 + # + # "..matching of the reference identifier against the presented identifier + # is performed by comparing the set of domain name labels using a + # case-insensitive ASCII comparison, as clarified by [DNS-CASE] (e.g., + # "WWW.Example.Com" would be lower-cased to "www.example.com" for + # comparison purposes) + assert_equal(true, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_san('DNS:*.example.com'), 'www.example.com')) + assert_equal(true, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_san('DNS:*.Example.COM'), 'www.example.com')) + assert_equal(true, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_san('DNS:*.example.com'), 'WWW.Example.COM')) + # 1. The client SHOULD NOT attempt to match a presented identifier in + # which the wildcard character comprises a label other than the + # left-most label (e.g., do not match bar.*.example.net). + assert_equal(false, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_san('DNS:www.*.com'), 'www.example.com')) + # 2. If the wildcard character is the only character of the left-most + # label in the presented identifier, the client SHOULD NOT compare + # against anything but the left-most label of the reference + # identifier (e.g., *.example.com would match foo.example.com but + # not bar.foo.example.com or example.com). + assert_equal(true, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_san('DNS:*.example.com'), 'foo.example.com')) + assert_equal(false, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_san('DNS:*.example.com'), 'bar.foo.example.com')) + # 3. The client MAY match a presented identifier in which the wildcard + # character is not the only character of the label (e.g., + # baz*.example.net and *baz.example.net and b*z.example.net would + # be taken to match baz1.example.net and foobaz.example.net and + # buzz.example.net, respectively). ... + assert_equal(true, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_san('DNS:baz*.example.com'), 'baz1.example.com')) + assert_equal(true, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_san('DNS:*baz.example.com'), 'foobaz.example.com')) + assert_equal(true, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_san('DNS:b*z.example.com'), 'buzz.example.com')) + # Section 6.4.3 of RFC6125 states that client should NOT match identifier + # where wildcard is other than left-most label. + # + # Also implicitly mentions the wildcard character only in singular form, + # and discourages matching against more than one wildcard. + # + # See RFC 6125, section 7.2, subitem 2. + assert_equal(false, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_san('DNS:*b*.example.com'), 'abc.example.com')) + assert_equal(false, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_san('DNS:*b*.example.com'), 'ab.example.com')) + assert_equal(false, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_san('DNS:*b*.example.com'), 'bc.example.com')) + # ... However, the client SHOULD NOT + # attempt to match a presented identifier where the wildcard + # character is embedded within an A-label or U-label [IDNA-DEFS] of + # an internationalized domain name [IDNA-PROTO]. + assert_equal(true, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_san('DNS:xn*.example.com'), 'xn1ca.example.com')) + # part of A-label + assert_equal(false, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_san('DNS:xn--*.example.com'), 'xn--1ca.example.com')) + # part of U-label + # dNSName in RFC5280 is an IA5String so U-label should NOT be allowed + # regardless of wildcard. + # + # See Section 7.2 of RFC 5280: + # IA5String is limited to the set of ASCII characters. + assert_equal(false, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_san('DNS:á*.example.com'), 'á1.example.com')) + end + + def test_post_connection_check_wildcard_cn + assert_equal(true, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_name('*.example.com'), 'www.example.com')) + assert_equal(true, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_name('*.Example.COM'), 'www.example.com')) + assert_equal(true, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_name('*.example.com'), 'WWW.Example.COM')) + assert_equal(false, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_name('www.*.com'), 'www.example.com')) + assert_equal(true, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_name('*.example.com'), 'foo.example.com')) + assert_equal(false, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_name('*.example.com'), 'bar.foo.example.com')) + assert_equal(true, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_name('baz*.example.com'), 'baz1.example.com')) + assert_equal(true, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_name('*baz.example.com'), 'foobaz.example.com')) + assert_equal(true, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_name('b*z.example.com'), 'buzz.example.com')) + # Section 6.4.3 of RFC6125 states that client should NOT match identifier + # where wildcard is other than left-most label. + # + # Also implicitly mentions the wildcard character only in singular form, + # and discourages matching against more than one wildcard. + # + # See RFC 6125, section 7.2, subitem 2. + assert_equal(false, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_name('*b*.example.com'), 'abc.example.com')) + assert_equal(false, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_name('*b*.example.com'), 'ab.example.com')) + assert_equal(false, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_name('*b*.example.com'), 'bc.example.com')) + assert_equal(true, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_name('xn*.example.com'), 'xn1ca.example.com')) + assert_equal(false, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_name('xn--*.example.com'), 'xn--1ca.example.com')) + # part of U-label + # Subject in RFC5280 states case-insensitive ASCII comparison. + # + # See Section 7.2 of RFC 5280: + # IA5String is limited to the set of ASCII characters. + assert_equal(false, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_name('á*.example.com'), 'á1.example.com')) + end + + def create_cert_with_san(san) + ef = OpenSSL::X509::ExtensionFactory.new + cert = OpenSSL::X509::Certificate.new + cert.subject = OpenSSL::X509::Name.parse("/DC=some/DC=site/CN=Some Site") + ext = ef.create_ext('subjectAltName', san) + cert.add_extension(ext) + cert + end + + def create_cert_with_name(name) + cert = OpenSSL::X509::Certificate.new + cert.subject = OpenSSL::X509::Name.new([['DC', 'some'], ['DC', 'site'], ['CN', name]]) + cert + end + + # Create NULL byte SAN certificate def create_null_byte_SAN_certificate(critical = false) ef = OpenSSL::X509::ExtensionFactory.new diff --git a/version.h b/version.h index 58f16b63f9af8d..da52321bbfcd47 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.5" #define RUBY_RELEASE_DATE "2015-04-13" -#define RUBY_PATCHLEVEL 334 +#define RUBY_PATCHLEVEL 335 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 4 From 2067e39ebaa0389b2d824a1c3dc0ffe1f7a6dba7 Mon Sep 17 00:00:00 2001 From: usa Date: Mon, 13 Apr 2015 13:23:14 +0000 Subject: [PATCH 342/343] * version.h: bump to 2.1.6. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@50297 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- version.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/version.h b/version.h index da52321bbfcd47..440a724e0d4644 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ -#define RUBY_VERSION "2.1.5" +#define RUBY_VERSION "2.1.6" #define RUBY_RELEASE_DATE "2015-04-13" -#define RUBY_PATCHLEVEL 335 +#define RUBY_PATCHLEVEL 336 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 4 From b432a4f043db5cc67459a2a4af081e8026f67153 Mon Sep 17 00:00:00 2001 From: Dirkjan Bussink Date: Tue, 14 Apr 2015 22:29:40 -0700 Subject: [PATCH 343/343] Add config.guess and config.sub to remove runtime download dependency --- tool/config.guess | 1421 +++++++++++++++++++++++++++++++++++ tool/config.sub | 1807 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 3228 insertions(+) create mode 100755 tool/config.guess create mode 100755 tool/config.sub diff --git a/tool/config.guess b/tool/config.guess new file mode 100755 index 00000000000000..dbfb9786cb6f9b --- /dev/null +++ b/tool/config.guess @@ -0,0 +1,1421 @@ +#! /bin/sh +# Attempt to guess a canonical system name. +# Copyright 1992-2015 Free Software Foundation, Inc. + +timestamp='2015-01-01' + +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, see . +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that +# program. This Exception is an additional permission under section 7 +# of the GNU General Public License, version 3 ("GPLv3"). +# +# Originally written by Per Bothner; maintained since 2000 by Ben Elliston. +# +# You can get the latest version of this script from: +# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD +# +# Please send patches to . + + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] + +Output the configuration name of the system \`$me' is run on. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.guess ($timestamp) + +Originally written by Per Bothner. +Copyright 1992-2015 Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" >&2 + exit 1 ;; + * ) + break ;; + esac +done + +if test $# != 0; then + echo "$me: too many arguments$help" >&2 + exit 1 +fi + +trap 'exit 1' 1 2 15 + +# CC_FOR_BUILD -- compiler used by this script. Note that the use of a +# compiler to aid in system detection is discouraged as it requires +# temporary files to be created and, as you can see below, it is a +# headache to deal with in a portable fashion. + +# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still +# use `HOST_CC' if defined, but it is deprecated. + +# Portable tmp directory creation inspired by the Autoconf team. + +set_cc_for_build=' +trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; +trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; +: ${TMPDIR=/tmp} ; + { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || + { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || + { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || + { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; +dummy=$tmp/dummy ; +tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; +case $CC_FOR_BUILD,$HOST_CC,$CC in + ,,) echo "int x;" > $dummy.c ; + for c in cc gcc c89 c99 ; do + if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then + CC_FOR_BUILD="$c"; break ; + fi ; + done ; + if test x"$CC_FOR_BUILD" = x ; then + CC_FOR_BUILD=no_compiler_found ; + fi + ;; + ,,*) CC_FOR_BUILD=$CC ;; + ,*,*) CC_FOR_BUILD=$HOST_CC ;; +esac ; set_cc_for_build= ;' + +# This is needed to find uname on a Pyramid OSx when run in the BSD universe. +# (ghazi@noc.rutgers.edu 1994-08-24) +if (test -f /.attbin/uname) >/dev/null 2>&1 ; then + PATH=$PATH:/.attbin ; export PATH +fi + +UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown +UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown + +case "${UNAME_SYSTEM}" in +Linux|GNU|GNU/*) + # If the system lacks a compiler, then just pick glibc. + # We could probably try harder. + LIBC=gnu + + eval $set_cc_for_build + cat <<-EOF > $dummy.c + #include + #if defined(__UCLIBC__) + LIBC=uclibc + #elif defined(__dietlibc__) + LIBC=dietlibc + #else + LIBC=gnu + #endif + EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` + ;; +esac + +# Note: order is significant - the case branches are not exclusive. + +case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in + *:NetBSD:*:*) + # NetBSD (nbsd) targets should (where applicable) match one or + # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, + # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently + # switched to ELF, *-*-netbsd* would select the old + # object file format. This provides both forward + # compatibility and a consistent mechanism for selecting the + # object file format. + # + # Note: NetBSD doesn't particularly care about the vendor + # portion of the name. We always set it to "unknown". + sysctl="sysctl -n hw.machine_arch" + UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ + /usr/sbin/$sysctl 2>/dev/null || echo unknown)` + case "${UNAME_MACHINE_ARCH}" in + armeb) machine=armeb-unknown ;; + arm*) machine=arm-unknown ;; + sh3el) machine=shl-unknown ;; + sh3eb) machine=sh-unknown ;; + sh5el) machine=sh5le-unknown ;; + *) machine=${UNAME_MACHINE_ARCH}-unknown ;; + esac + # The Operating System including object format, if it has switched + # to ELF recently, or will in the future. + case "${UNAME_MACHINE_ARCH}" in + arm*|i386|m68k|ns32k|sh3*|sparc|vax) + eval $set_cc_for_build + if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ELF__ + then + # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). + # Return netbsd for either. FIX? + os=netbsd + else + os=netbsdelf + fi + ;; + *) + os=netbsd + ;; + esac + # The OS release + # Debian GNU/NetBSD machines have a different userland, and + # thus, need a distinct triplet. However, they do not need + # kernel version information, so it can be replaced with a + # suitable tag, in the style of linux-gnu. + case "${UNAME_VERSION}" in + Debian*) + release='-gnu' + ;; + *) + release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + ;; + esac + # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: + # contains redundant information, the shorter form: + # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. + echo "${machine}-${os}${release}" + exit ;; + *:Bitrig:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` + echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} + exit ;; + *:OpenBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` + echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} + exit ;; + *:ekkoBSD:*:*) + echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} + exit ;; + *:SolidBSD:*:*) + echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} + exit ;; + macppc:MirBSD:*:*) + echo powerpc-unknown-mirbsd${UNAME_RELEASE} + exit ;; + *:MirBSD:*:*) + echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} + exit ;; + alpha:OSF1:*:*) + case $UNAME_RELEASE in + *4.0) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` + ;; + *5.*) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` + ;; + esac + # According to Compaq, /usr/sbin/psrinfo has been available on + # OSF/1 and Tru64 systems produced since 1995. I hope that + # covers most systems running today. This code pipes the CPU + # types through head -n 1, so we only detect the type of CPU 0. + ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` + case "$ALPHA_CPU_TYPE" in + "EV4 (21064)") + UNAME_MACHINE="alpha" ;; + "EV4.5 (21064)") + UNAME_MACHINE="alpha" ;; + "LCA4 (21066/21068)") + UNAME_MACHINE="alpha" ;; + "EV5 (21164)") + UNAME_MACHINE="alphaev5" ;; + "EV5.6 (21164A)") + UNAME_MACHINE="alphaev56" ;; + "EV5.6 (21164PC)") + UNAME_MACHINE="alphapca56" ;; + "EV5.7 (21164PC)") + UNAME_MACHINE="alphapca57" ;; + "EV6 (21264)") + UNAME_MACHINE="alphaev6" ;; + "EV6.7 (21264A)") + UNAME_MACHINE="alphaev67" ;; + "EV6.8CB (21264C)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8AL (21264B)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8CX (21264D)") + UNAME_MACHINE="alphaev68" ;; + "EV6.9A (21264/EV69A)") + UNAME_MACHINE="alphaev69" ;; + "EV7 (21364)") + UNAME_MACHINE="alphaev7" ;; + "EV7.9 (21364A)") + UNAME_MACHINE="alphaev79" ;; + esac + # A Pn.n version is a patched version. + # A Vn.n version is a released version. + # A Tn.n version is a released field test version. + # A Xn.n version is an unreleased experimental baselevel. + # 1.2 uses "1.2" for uname -r. + echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + # Reset EXIT trap before exiting to avoid spurious non-zero exit code. + exitcode=$? + trap '' 0 + exit $exitcode ;; + Alpha\ *:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # Should we change UNAME_MACHINE based on the output of uname instead + # of the specific Alpha model? + echo alpha-pc-interix + exit ;; + 21064:Windows_NT:50:3) + echo alpha-dec-winnt3.5 + exit ;; + Amiga*:UNIX_System_V:4.0:*) + echo m68k-unknown-sysv4 + exit ;; + *:[Aa]miga[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-amigaos + exit ;; + *:[Mm]orph[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-morphos + exit ;; + *:OS/390:*:*) + echo i370-ibm-openedition + exit ;; + *:z/VM:*:*) + echo s390-ibm-zvmoe + exit ;; + *:OS400:*:*) + echo powerpc-ibm-os400 + exit ;; + arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) + echo arm-acorn-riscix${UNAME_RELEASE} + exit ;; + arm*:riscos:*:*|arm*:RISCOS:*:*) + echo arm-unknown-riscos + exit ;; + SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) + echo hppa1.1-hitachi-hiuxmpp + exit ;; + Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) + # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. + if test "`(/bin/universe) 2>/dev/null`" = att ; then + echo pyramid-pyramid-sysv3 + else + echo pyramid-pyramid-bsd + fi + exit ;; + NILE*:*:*:dcosx) + echo pyramid-pyramid-svr4 + exit ;; + DRS?6000:unix:4.0:6*) + echo sparc-icl-nx6 + exit ;; + DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) + case `/usr/bin/uname -p` in + sparc) echo sparc-icl-nx7; exit ;; + esac ;; + s390x:SunOS:*:*) + echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4H:SunOS:5.*:*) + echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) + echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) + echo i386-pc-auroraux${UNAME_RELEASE} + exit ;; + i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) + eval $set_cc_for_build + SUN_ARCH="i386" + # If there is a compiler, see if it is configured for 64-bit objects. + # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. + # This test works for both compilers. + if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then + if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + SUN_ARCH="x86_64" + fi + fi + echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:6*:*) + # According to config.sub, this is the proper way to canonicalize + # SunOS6. Hard to guess exactly what SunOS6 will be like, but + # it's likely to be more like Solaris than SunOS4. + echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:*:*) + case "`/usr/bin/arch -k`" in + Series*|S4*) + UNAME_RELEASE=`uname -v` + ;; + esac + # Japanese Language versions have a version number like `4.1.3-JL'. + echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` + exit ;; + sun3*:SunOS:*:*) + echo m68k-sun-sunos${UNAME_RELEASE} + exit ;; + sun*:*:4.2BSD:*) + UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` + test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 + case "`/bin/arch`" in + sun3) + echo m68k-sun-sunos${UNAME_RELEASE} + ;; + sun4) + echo sparc-sun-sunos${UNAME_RELEASE} + ;; + esac + exit ;; + aushp:SunOS:*:*) + echo sparc-auspex-sunos${UNAME_RELEASE} + exit ;; + # The situation for MiNT is a little confusing. The machine name + # can be virtually everything (everything which is not + # "atarist" or "atariste" at least should have a processor + # > m68000). The system name ranges from "MiNT" over "FreeMiNT" + # to the lowercase version "mint" (or "freemint"). Finally + # the system name "TOS" denotes a system which is actually not + # MiNT. But MiNT is downward compatible to TOS, so this should + # be no problem. + atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) + echo m68k-milan-mint${UNAME_RELEASE} + exit ;; + hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) + echo m68k-hades-mint${UNAME_RELEASE} + exit ;; + *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) + echo m68k-unknown-mint${UNAME_RELEASE} + exit ;; + m68k:machten:*:*) + echo m68k-apple-machten${UNAME_RELEASE} + exit ;; + powerpc:machten:*:*) + echo powerpc-apple-machten${UNAME_RELEASE} + exit ;; + RISC*:Mach:*:*) + echo mips-dec-mach_bsd4.3 + exit ;; + RISC*:ULTRIX:*:*) + echo mips-dec-ultrix${UNAME_RELEASE} + exit ;; + VAX*:ULTRIX*:*:*) + echo vax-dec-ultrix${UNAME_RELEASE} + exit ;; + 2020:CLIX:*:* | 2430:CLIX:*:*) + echo clipper-intergraph-clix${UNAME_RELEASE} + exit ;; + mips:*:*:UMIPS | mips:*:*:RISCos) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c +#ifdef __cplusplus +#include /* for printf() prototype */ + int main (int argc, char *argv[]) { +#else + int main (argc, argv) int argc; char *argv[]; { +#endif + #if defined (host_mips) && defined (MIPSEB) + #if defined (SYSTYPE_SYSV) + printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_SVR4) + printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) + printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + #endif + #endif + exit (-1); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && + dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && + SYSTEM_NAME=`$dummy $dummyarg` && + { echo "$SYSTEM_NAME"; exit; } + echo mips-mips-riscos${UNAME_RELEASE} + exit ;; + Motorola:PowerMAX_OS:*:*) + echo powerpc-motorola-powermax + exit ;; + Motorola:*:4.3:PL8-*) + echo powerpc-harris-powermax + exit ;; + Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) + echo powerpc-harris-powermax + exit ;; + Night_Hawk:Power_UNIX:*:*) + echo powerpc-harris-powerunix + exit ;; + m88k:CX/UX:7*:*) + echo m88k-harris-cxux7 + exit ;; + m88k:*:4*:R4*) + echo m88k-motorola-sysv4 + exit ;; + m88k:*:3*:R3*) + echo m88k-motorola-sysv3 + exit ;; + AViiON:dgux:*:*) + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` + if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] + then + if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ + [ ${TARGET_BINARY_INTERFACE}x = x ] + then + echo m88k-dg-dgux${UNAME_RELEASE} + else + echo m88k-dg-dguxbcs${UNAME_RELEASE} + fi + else + echo i586-dg-dgux${UNAME_RELEASE} + fi + exit ;; + M88*:DolphinOS:*:*) # DolphinOS (SVR3) + echo m88k-dolphin-sysv3 + exit ;; + M88*:*:R3*:*) + # Delta 88k system running SVR3 + echo m88k-motorola-sysv3 + exit ;; + XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) + echo m88k-tektronix-sysv3 + exit ;; + Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) + echo m68k-tektronix-bsd + exit ;; + *:IRIX*:*:*) + echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` + exit ;; + ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. + echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id + exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + i*86:AIX:*:*) + echo i386-ibm-aix + exit ;; + ia64:AIX:*:*) + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} + exit ;; + *:AIX:2:3) + if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + + main() + { + if (!__power_pc()) + exit(1); + puts("powerpc-ibm-aix3.2.5"); + exit(0); + } +EOF + if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` + then + echo "$SYSTEM_NAME" + else + echo rs6000-ibm-aix3.2.5 + fi + elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then + echo rs6000-ibm-aix3.2.4 + else + echo rs6000-ibm-aix3.2 + fi + exit ;; + *:AIX:*:[4567]) + IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` + if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then + IBM_ARCH=rs6000 + else + IBM_ARCH=powerpc + fi + if [ -x /usr/bin/lslpp ] ; then + IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | + awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${IBM_ARCH}-ibm-aix${IBM_REV} + exit ;; + *:AIX:*:*) + echo rs6000-ibm-aix + exit ;; + ibmrt:4.4BSD:*|romp-ibm:BSD:*) + echo romp-ibm-bsd4.4 + exit ;; + ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and + echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to + exit ;; # report: romp-ibm BSD 4.3 + *:BOSX:*:*) + echo rs6000-bull-bosx + exit ;; + DPX/2?00:B.O.S.:*:*) + echo m68k-bull-sysv3 + exit ;; + 9000/[34]??:4.3bsd:1.*:*) + echo m68k-hp-bsd + exit ;; + hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) + echo m68k-hp-bsd4.4 + exit ;; + 9000/[34678]??:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + case "${UNAME_MACHINE}" in + 9000/31? ) HP_ARCH=m68000 ;; + 9000/[34]?? ) HP_ARCH=m68k ;; + 9000/[678][0-9][0-9]) + if [ -x /usr/bin/getconf ]; then + sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` + case "${sc_cpu_version}" in + 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 + 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 + 532) # CPU_PA_RISC2_0 + case "${sc_kernel_bits}" in + 32) HP_ARCH="hppa2.0n" ;; + 64) HP_ARCH="hppa2.0w" ;; + '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 + esac ;; + esac + fi + if [ "${HP_ARCH}" = "" ]; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + + #define _HPUX_SOURCE + #include + #include + + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); + + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } +EOF + (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` + test -z "$HP_ARCH" && HP_ARCH=hppa + fi ;; + esac + if [ ${HP_ARCH} = "hppa2.0w" ] + then + eval $set_cc_for_build + + # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating + # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler + # generating 64-bit code. GNU and HP use different nomenclature: + # + # $ CC_FOR_BUILD=cc ./config.guess + # => hppa2.0w-hp-hpux11.23 + # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess + # => hppa64-hp-hpux11.23 + + if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | + grep -q __LP64__ + then + HP_ARCH="hppa2.0w" + else + HP_ARCH="hppa64" + fi + fi + echo ${HP_ARCH}-hp-hpux${HPUX_REV} + exit ;; + ia64:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + echo ia64-hp-hpux${HPUX_REV} + exit ;; + 3050*:HI-UX:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + int + main () + { + long cpu = sysconf (_SC_CPU_VERSION); + /* The order matters, because CPU_IS_HP_MC68K erroneously returns + true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct + results, however. */ + if (CPU_IS_PA_RISC (cpu)) + { + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; + case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; + default: puts ("hppa-hitachi-hiuxwe2"); break; + } + } + else if (CPU_IS_HP_MC68K (cpu)) + puts ("m68k-hitachi-hiuxwe2"); + else puts ("unknown-hitachi-hiuxwe2"); + exit (0); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && + { echo "$SYSTEM_NAME"; exit; } + echo unknown-hitachi-hiuxwe2 + exit ;; + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) + echo hppa1.1-hp-bsd + exit ;; + 9000/8??:4.3bsd:*:*) + echo hppa1.0-hp-bsd + exit ;; + *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) + echo hppa1.0-hp-mpeix + exit ;; + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) + echo hppa1.1-hp-osf + exit ;; + hp8??:OSF1:*:*) + echo hppa1.0-hp-osf + exit ;; + i*86:OSF1:*:*) + if [ -x /usr/sbin/sysversion ] ; then + echo ${UNAME_MACHINE}-unknown-osf1mk + else + echo ${UNAME_MACHINE}-unknown-osf1 + fi + exit ;; + parisc*:Lites*:*:*) + echo hppa1.1-hp-lites + exit ;; + C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) + echo c1-convex-bsd + exit ;; + C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit ;; + C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) + echo c34-convex-bsd + exit ;; + C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) + echo c38-convex-bsd + exit ;; + C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) + echo c4-convex-bsd + exit ;; + CRAY*Y-MP:*:*:*) + echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*[A-Z]90:*:*:*) + echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ + -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ + -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*TS:*:*:*) + echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*T3E:*:*:*) + echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*SV1:*:*:*) + echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + *:UNICOS/mp:*:*) + echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) + FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; + 5000:UNIX_System_V:4.*:*) + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` + echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; + i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) + echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} + exit ;; + sparc*:BSD/OS:*:*) + echo sparc-unknown-bsdi${UNAME_RELEASE} + exit ;; + *:BSD/OS:*:*) + echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} + exit ;; + *:FreeBSD:*:*) + UNAME_PROCESSOR=`/usr/bin/uname -p` + case ${UNAME_PROCESSOR} in + amd64) + echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + *) + echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + esac + exit ;; + i*:CYGWIN*:*) + echo ${UNAME_MACHINE}-pc-cygwin + exit ;; + *:MINGW64*:*) + echo ${UNAME_MACHINE}-pc-mingw64 + exit ;; + *:MINGW*:*) + echo ${UNAME_MACHINE}-pc-mingw32 + exit ;; + *:MSYS*:*) + echo ${UNAME_MACHINE}-pc-msys + exit ;; + i*:windows32*:*) + # uname -m includes "-pc" on this system. + echo ${UNAME_MACHINE}-mingw32 + exit ;; + i*:PW*:*) + echo ${UNAME_MACHINE}-pc-pw32 + exit ;; + *:Interix*:*) + case ${UNAME_MACHINE} in + x86) + echo i586-pc-interix${UNAME_RELEASE} + exit ;; + authenticamd | genuineintel | EM64T) + echo x86_64-unknown-interix${UNAME_RELEASE} + exit ;; + IA64) + echo ia64-unknown-interix${UNAME_RELEASE} + exit ;; + esac ;; + [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) + echo i${UNAME_MACHINE}-pc-mks + exit ;; + 8664:Windows_NT:*) + echo x86_64-pc-mks + exit ;; + i*:Windows_NT*:* | Pentium*:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we + # UNAME_MACHINE based on the output of uname instead of i386? + echo i586-pc-interix + exit ;; + i*:UWIN*:*) + echo ${UNAME_MACHINE}-pc-uwin + exit ;; + amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) + echo x86_64-unknown-cygwin + exit ;; + p*:CYGWIN*:*) + echo powerpcle-unknown-cygwin + exit ;; + prep*:SunOS:5.*:*) + echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + *:GNU:*:*) + # the GNU system + echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + exit ;; + *:GNU/*:*:*) + # other systems with GNU libc and userland + echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} + exit ;; + i*86:Minix:*:*) + echo ${UNAME_MACHINE}-pc-minix + exit ;; + aarch64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + aarch64_be:Linux:*:*) + UNAME_MACHINE=aarch64_be + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + alpha:Linux:*:*) + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + EV5) UNAME_MACHINE=alphaev5 ;; + EV56) UNAME_MACHINE=alphaev56 ;; + PCA56) UNAME_MACHINE=alphapca56 ;; + PCA57) UNAME_MACHINE=alphapca56 ;; + EV6) UNAME_MACHINE=alphaev6 ;; + EV67) UNAME_MACHINE=alphaev67 ;; + EV68*) UNAME_MACHINE=alphaev68 ;; + esac + objdump --private-headers /bin/sh | grep -q ld.so.1 + if test "$?" = 0 ; then LIBC="gnulibc1" ; fi + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + arc:Linux:*:* | arceb:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + arm*:Linux:*:*) + eval $set_cc_for_build + if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_EABI__ + then + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + else + if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_PCS_VFP + then + echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi + else + echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf + fi + fi + exit ;; + avr32*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + cris:Linux:*:*) + echo ${UNAME_MACHINE}-axis-linux-${LIBC} + exit ;; + crisv32:Linux:*:*) + echo ${UNAME_MACHINE}-axis-linux-${LIBC} + exit ;; + frv:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + hexagon:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + i*86:Linux:*:*) + echo ${UNAME_MACHINE}-pc-linux-${LIBC} + exit ;; + ia64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + m32r*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + m68*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + mips:Linux:*:* | mips64:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef ${UNAME_MACHINE} + #undef ${UNAME_MACHINE}el + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=${UNAME_MACHINE}el + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=${UNAME_MACHINE} + #else + CPU= + #endif + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` + test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } + ;; + openrisc*:Linux:*:*) + echo or1k-unknown-linux-${LIBC} + exit ;; + or32:Linux:*:* | or1k*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + padre:Linux:*:*) + echo sparc-unknown-linux-${LIBC} + exit ;; + parisc64:Linux:*:* | hppa64:Linux:*:*) + echo hppa64-unknown-linux-${LIBC} + exit ;; + parisc:Linux:*:* | hppa:Linux:*:*) + # Look for CPU level + case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in + PA7*) echo hppa1.1-unknown-linux-${LIBC} ;; + PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; + *) echo hppa-unknown-linux-${LIBC} ;; + esac + exit ;; + ppc64:Linux:*:*) + echo powerpc64-unknown-linux-${LIBC} + exit ;; + ppc:Linux:*:*) + echo powerpc-unknown-linux-${LIBC} + exit ;; + ppc64le:Linux:*:*) + echo powerpc64le-unknown-linux-${LIBC} + exit ;; + ppcle:Linux:*:*) + echo powerpcle-unknown-linux-${LIBC} + exit ;; + s390:Linux:*:* | s390x:Linux:*:*) + echo ${UNAME_MACHINE}-ibm-linux-${LIBC} + exit ;; + sh64*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + sh*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + sparc:Linux:*:* | sparc64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + tile*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + vax:Linux:*:*) + echo ${UNAME_MACHINE}-dec-linux-${LIBC} + exit ;; + x86_64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + xtensa*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + i*86:DYNIX/ptx:4*:*) + # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. + # earlier versions are messed up and put the nodename in both + # sysname and nodename. + echo i386-sequent-sysv4 + exit ;; + i*86:UNIX_SV:4.2MP:2.*) + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, + # I just have to hope. -- rms. + # Use sysv4.2uw... so that sysv4* matches it. + echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} + exit ;; + i*86:OS/2:*:*) + # If we were able to find `uname', then EMX Unix compatibility + # is probably installed. + echo ${UNAME_MACHINE}-pc-os2-emx + exit ;; + i*86:XTS-300:*:STOP) + echo ${UNAME_MACHINE}-unknown-stop + exit ;; + i*86:atheos:*:*) + echo ${UNAME_MACHINE}-unknown-atheos + exit ;; + i*86:syllable:*:*) + echo ${UNAME_MACHINE}-pc-syllable + exit ;; + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) + echo i386-unknown-lynxos${UNAME_RELEASE} + exit ;; + i*86:*DOS:*:*) + echo ${UNAME_MACHINE}-pc-msdosdjgpp + exit ;; + i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) + UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` + if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then + echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} + else + echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} + fi + exit ;; + i*86:*:5:[678]*) + # UnixWare 7.x, OpenUNIX and OpenServer 6. + case `/bin/uname -X | grep "^Machine"` in + *486*) UNAME_MACHINE=i486 ;; + *Pentium) UNAME_MACHINE=i586 ;; + *Pent*|*Celeron) UNAME_MACHINE=i686 ;; + esac + echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + exit ;; + i*86:*:3.2:*) + if test -f /usr/options/cb.name; then + UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then + UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` + (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 + (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ + && UNAME_MACHINE=i586 + (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ + && UNAME_MACHINE=i686 + (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ + && UNAME_MACHINE=i686 + echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + else + echo ${UNAME_MACHINE}-pc-sysv32 + fi + exit ;; + pc:*:*:*) + # Left here for compatibility: + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i586. + # Note: whatever this is, it MUST be the same as what config.sub + # prints for the "djgpp" host, or else GDB configury will decide that + # this is a cross-build. + echo i586-pc-msdosdjgpp + exit ;; + Intel:Mach:3*:*) + echo i386-pc-mach3 + exit ;; + paragon:*:*:*) + echo i860-intel-osf1 + exit ;; + i860:*:4.*:*) # i860-SVR4 + if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then + echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + else # Add other i860-SVR4 vendors below as they are discovered. + echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + fi + exit ;; + mini*:CTIX:SYS*5:*) + # "miniframe" + echo m68010-convergent-sysv + exit ;; + mc68k:UNIX:SYSTEM5:3.51m) + echo m68k-convergent-sysv + exit ;; + M680?0:D-NIX:5.3:*) + echo m68k-diab-dnix + exit ;; + M68*:*:R3V[5678]*:*) + test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; + 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) + OS_REL='' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4; exit; } ;; + NCR*:*:4.2:* | MPRAS*:*:4.2:*) + OS_REL='.3' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) + echo m68k-unknown-lynxos${UNAME_RELEASE} + exit ;; + mc68030:UNIX_System_V:4.*:*) + echo m68k-atari-sysv4 + exit ;; + TSUNAMI:LynxOS:2.*:*) + echo sparc-unknown-lynxos${UNAME_RELEASE} + exit ;; + rs6000:LynxOS:2.*:*) + echo rs6000-unknown-lynxos${UNAME_RELEASE} + exit ;; + PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) + echo powerpc-unknown-lynxos${UNAME_RELEASE} + exit ;; + SM[BE]S:UNIX_SV:*:*) + echo mips-dde-sysv${UNAME_RELEASE} + exit ;; + RM*:ReliantUNIX-*:*:*) + echo mips-sni-sysv4 + exit ;; + RM*:SINIX-*:*:*) + echo mips-sni-sysv4 + exit ;; + *:SINIX-*:*:*) + if uname -p 2>/dev/null >/dev/null ; then + UNAME_MACHINE=`(uname -p) 2>/dev/null` + echo ${UNAME_MACHINE}-sni-sysv4 + else + echo ns32k-sni-sysv + fi + exit ;; + PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says + echo i586-unisys-sysv4 + exit ;; + *:UNIX_System_V:4*:FTX*) + # From Gerald Hewes . + # How about differentiating between stratus architectures? -djm + echo hppa1.1-stratus-sysv4 + exit ;; + *:*:*:FTX*) + # From seanf@swdc.stratus.com. + echo i860-stratus-sysv4 + exit ;; + i*86:VOS:*:*) + # From Paul.Green@stratus.com. + echo ${UNAME_MACHINE}-stratus-vos + exit ;; + *:VOS:*:*) + # From Paul.Green@stratus.com. + echo hppa1.1-stratus-vos + exit ;; + mc68*:A/UX:*:*) + echo m68k-apple-aux${UNAME_RELEASE} + exit ;; + news*:NEWS-OS:6*:*) + echo mips-sony-newsos6 + exit ;; + R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) + if [ -d /usr/nec ]; then + echo mips-nec-sysv${UNAME_RELEASE} + else + echo mips-unknown-sysv${UNAME_RELEASE} + fi + exit ;; + BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. + echo powerpc-be-beos + exit ;; + BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. + echo powerpc-apple-beos + exit ;; + BePC:BeOS:*:*) # BeOS running on Intel PC compatible. + echo i586-pc-beos + exit ;; + BePC:Haiku:*:*) # Haiku running on Intel PC compatible. + echo i586-pc-haiku + exit ;; + x86_64:Haiku:*:*) + echo x86_64-unknown-haiku + exit ;; + SX-4:SUPER-UX:*:*) + echo sx4-nec-superux${UNAME_RELEASE} + exit ;; + SX-5:SUPER-UX:*:*) + echo sx5-nec-superux${UNAME_RELEASE} + exit ;; + SX-6:SUPER-UX:*:*) + echo sx6-nec-superux${UNAME_RELEASE} + exit ;; + SX-7:SUPER-UX:*:*) + echo sx7-nec-superux${UNAME_RELEASE} + exit ;; + SX-8:SUPER-UX:*:*) + echo sx8-nec-superux${UNAME_RELEASE} + exit ;; + SX-8R:SUPER-UX:*:*) + echo sx8r-nec-superux${UNAME_RELEASE} + exit ;; + Power*:Rhapsody:*:*) + echo powerpc-apple-rhapsody${UNAME_RELEASE} + exit ;; + *:Rhapsody:*:*) + echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} + exit ;; + *:Darwin:*:*) + UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown + eval $set_cc_for_build + if test "$UNAME_PROCESSOR" = unknown ; then + UNAME_PROCESSOR=powerpc + fi + if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then + if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then + if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + case $UNAME_PROCESSOR in + i386) UNAME_PROCESSOR=x86_64 ;; + powerpc) UNAME_PROCESSOR=powerpc64 ;; + esac + fi + fi + elif test "$UNAME_PROCESSOR" = i386 ; then + # Avoid executing cc on OS X 10.9, as it ships with a stub + # that puts up a graphical alert prompting to install + # developer tools. Any system running Mac OS X 10.7 or + # later (Darwin 11 and later) is required to have a 64-bit + # processor. This is not true of the ARM version of Darwin + # that Apple uses in portable devices. + UNAME_PROCESSOR=x86_64 + fi + echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} + exit ;; + *:procnto*:*:* | *:QNX:[0123456789]*:*) + UNAME_PROCESSOR=`uname -p` + if test "$UNAME_PROCESSOR" = "x86"; then + UNAME_PROCESSOR=i386 + UNAME_MACHINE=pc + fi + echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} + exit ;; + *:QNX:*:4*) + echo i386-pc-qnx + exit ;; + NEO-?:NONSTOP_KERNEL:*:*) + echo neo-tandem-nsk${UNAME_RELEASE} + exit ;; + NSE-*:NONSTOP_KERNEL:*:*) + echo nse-tandem-nsk${UNAME_RELEASE} + exit ;; + NSR-?:NONSTOP_KERNEL:*:*) + echo nsr-tandem-nsk${UNAME_RELEASE} + exit ;; + *:NonStop-UX:*:*) + echo mips-compaq-nonstopux + exit ;; + BS2000:POSIX*:*:*) + echo bs2000-siemens-sysv + exit ;; + DS/*:UNIX_System_V:*:*) + echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} + exit ;; + *:Plan9:*:*) + # "uname -m" is not consistent, so use $cputype instead. 386 + # is converted to i386 for consistency with other x86 + # operating systems. + if test "$cputype" = "386"; then + UNAME_MACHINE=i386 + else + UNAME_MACHINE="$cputype" + fi + echo ${UNAME_MACHINE}-unknown-plan9 + exit ;; + *:TOPS-10:*:*) + echo pdp10-unknown-tops10 + exit ;; + *:TENEX:*:*) + echo pdp10-unknown-tenex + exit ;; + KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) + echo pdp10-dec-tops20 + exit ;; + XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) + echo pdp10-xkl-tops20 + exit ;; + *:TOPS-20:*:*) + echo pdp10-unknown-tops20 + exit ;; + *:ITS:*:*) + echo pdp10-unknown-its + exit ;; + SEI:*:*:SEIUX) + echo mips-sei-seiux${UNAME_RELEASE} + exit ;; + *:DragonFly:*:*) + echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + exit ;; + *:*VMS:*:*) + UNAME_MACHINE=`(uname -p) 2>/dev/null` + case "${UNAME_MACHINE}" in + A*) echo alpha-dec-vms ; exit ;; + I*) echo ia64-dec-vms ; exit ;; + V*) echo vax-dec-vms ; exit ;; + esac ;; + *:XENIX:*:SysV) + echo i386-pc-xenix + exit ;; + i*86:skyos:*:*) + echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' + exit ;; + i*86:rdos:*:*) + echo ${UNAME_MACHINE}-pc-rdos + exit ;; + i*86:AROS:*:*) + echo ${UNAME_MACHINE}-pc-aros + exit ;; + x86_64:VMkernel:*:*) + echo ${UNAME_MACHINE}-unknown-esx + exit ;; +esac + +cat >&2 < in order to provide the needed +information to handle your system. + +config.guess timestamp = $timestamp + +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null` + +hostinfo = `(hostinfo) 2>/dev/null` +/bin/universe = `(/bin/universe) 2>/dev/null` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` +/bin/arch = `(/bin/arch) 2>/dev/null` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` + +UNAME_MACHINE = ${UNAME_MACHINE} +UNAME_RELEASE = ${UNAME_RELEASE} +UNAME_SYSTEM = ${UNAME_SYSTEM} +UNAME_VERSION = ${UNAME_VERSION} +EOF + +exit 1 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/tool/config.sub b/tool/config.sub new file mode 100755 index 00000000000000..6d2e94c8bf9ea6 --- /dev/null +++ b/tool/config.sub @@ -0,0 +1,1807 @@ +#! /bin/sh +# Configuration validation subroutine script. +# Copyright 1992-2015 Free Software Foundation, Inc. + +timestamp='2015-01-01' + +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, see . +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that +# program. This Exception is an additional permission under section 7 +# of the GNU General Public License, version 3 ("GPLv3"). + + +# Please send patches to . +# +# Configuration subroutine to validate and canonicalize a configuration type. +# Supply the specified configuration type as an argument. +# If it is invalid, we print an error message on stderr and exit with code 1. +# Otherwise, we print the canonical config type on stdout and succeed. + +# You can get the latest version of this script from: +# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD + +# This file is supposed to be the same for all GNU packages +# and recognize all the CPU types, system types and aliases +# that are meaningful with *any* GNU software. +# Each package is responsible for reporting which valid configurations +# it does not support. The user should be able to distinguish +# a failure to support a valid configuration from a meaningless +# configuration. + +# The goal of this file is to map all the various variations of a given +# machine specification into a single specification in the form: +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or in some cases, the newer four-part form: +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# It is wrong to echo any other type of specification. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] CPU-MFR-OPSYS + $0 [OPTION] ALIAS + +Canonicalize a configuration name. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.sub ($timestamp) + +Copyright 1992-2015 Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" + exit 1 ;; + + *local*) + # First pass through any local machine types. + echo $1 + exit ;; + + * ) + break ;; + esac +done + +case $# in + 0) echo "$me: missing argument$help" >&2 + exit 1;; + 1) ;; + *) echo "$me: too many arguments$help" >&2 + exit 1;; +esac + +# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). +# Here we must recognize all the valid KERNEL-OS combinations. +maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` +case $maybe_os in + nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ + linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ + knetbsd*-gnu* | netbsd*-gnu* | \ + kopensolaris*-gnu* | \ + storm-chaos* | os2-emx* | rtmk-nova*) + os=-$maybe_os + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` + ;; + android-linux) + os=-linux-android + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown + ;; + *) + basic_machine=`echo $1 | sed 's/-[^-]*$//'` + if [ $basic_machine != $1 ] + then os=`echo $1 | sed 's/.*-/-/'` + else os=; fi + ;; +esac + +### Let's recognize common machines as not being operating systems so +### that things like config.sub decstation-3100 work. We also +### recognize some manufacturers as not being operating systems, so we +### can provide default operating systems below. +case $os in + -sun*os*) + # Prevent following clause from handling this invalid input. + ;; + -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ + -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ + -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ + -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ + -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ + -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ + -apple | -axis | -knuth | -cray | -microblaze*) + os= + basic_machine=$1 + ;; + -bluegene*) + os=-cnk + ;; + -sim | -cisco | -oki | -wec | -winbond) + os= + basic_machine=$1 + ;; + -scout) + ;; + -wrs) + os=-vxworks + basic_machine=$1 + ;; + -chorusos*) + os=-chorusos + basic_machine=$1 + ;; + -chorusrdb) + os=-chorusrdb + basic_machine=$1 + ;; + -hiux*) + os=-hiuxwe2 + ;; + -sco6) + os=-sco5v6 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco5) + os=-sco3.2v5 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco4) + os=-sco3.2v4 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2.[4-9]*) + os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2v[4-9]*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco5v6*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco*) + os=-sco3.2v2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -udk*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -isc) + os=-isc2.2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -clix*) + basic_machine=clipper-intergraph + ;; + -isc*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -lynx*178) + os=-lynxos178 + ;; + -lynx*5) + os=-lynxos5 + ;; + -lynx*) + os=-lynxos + ;; + -ptx*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` + ;; + -windowsnt*) + os=`echo $os | sed -e 's/windowsnt/winnt/'` + ;; + -psos*) + os=-psos + ;; + -mint | -mint[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; +esac + +# Decode aliases for certain CPU-COMPANY combinations. +case $basic_machine in + # Recognize the basic CPU types without company name. + # Some are omitted here because they have special meanings below. + 1750a | 580 \ + | a29k \ + | aarch64 | aarch64_be \ + | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ + | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ + | am33_2.0 \ + | arc | arceb \ + | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ + | avr | avr32 \ + | be32 | be64 \ + | bfin \ + | c4x | c8051 | clipper \ + | d10v | d30v | dlx | dsp16xx \ + | epiphany \ + | fido | fr30 | frv | ft32 \ + | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | hexagon \ + | i370 | i860 | i960 | ia64 \ + | ip2k | iq2000 \ + | k1om \ + | le32 | le64 \ + | lm32 \ + | m32c | m32r | m32rle | m68000 | m68k | m88k \ + | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ + | mips | mipsbe | mipseb | mipsel | mipsle \ + | mips16 \ + | mips64 | mips64el \ + | mips64octeon | mips64octeonel \ + | mips64orion | mips64orionel \ + | mips64r5900 | mips64r5900el \ + | mips64vr | mips64vrel \ + | mips64vr4100 | mips64vr4100el \ + | mips64vr4300 | mips64vr4300el \ + | mips64vr5000 | mips64vr5000el \ + | mips64vr5900 | mips64vr5900el \ + | mipsisa32 | mipsisa32el \ + | mipsisa32r2 | mipsisa32r2el \ + | mipsisa32r6 | mipsisa32r6el \ + | mipsisa64 | mipsisa64el \ + | mipsisa64r2 | mipsisa64r2el \ + | mipsisa64r6 | mipsisa64r6el \ + | mipsisa64sb1 | mipsisa64sb1el \ + | mipsisa64sr71k | mipsisa64sr71kel \ + | mipsr5900 | mipsr5900el \ + | mipstx39 | mipstx39el \ + | mn10200 | mn10300 \ + | moxie \ + | mt \ + | msp430 \ + | nds32 | nds32le | nds32be \ + | nios | nios2 | nios2eb | nios2el \ + | ns16k | ns32k \ + | open8 | or1k | or1knd | or32 \ + | pdp10 | pdp11 | pj | pjl \ + | powerpc | powerpc64 | powerpc64le | powerpcle \ + | pyramid \ + | riscv32 | riscv64 \ + | rl78 | rx \ + | score \ + | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ + | sh64 | sh64le \ + | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ + | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ + | spu \ + | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ + | ubicom32 \ + | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ + | visium \ + | we32k \ + | x86 | xc16x | xstormy16 | xtensa \ + | z8k | z80) + basic_machine=$basic_machine-unknown + ;; + c54x) + basic_machine=tic54x-unknown + ;; + c55x) + basic_machine=tic55x-unknown + ;; + c6x) + basic_machine=tic6x-unknown + ;; + leon|leon[3-9]) + basic_machine=sparc-$basic_machine + ;; + m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) + basic_machine=$basic_machine-unknown + os=-none + ;; + m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) + ;; + ms1) + basic_machine=mt-unknown + ;; + + strongarm | thumb | xscale) + basic_machine=arm-unknown + ;; + xgate) + basic_machine=$basic_machine-unknown + os=-none + ;; + xscaleeb) + basic_machine=armeb-unknown + ;; + + xscaleel) + basic_machine=armel-unknown + ;; + + # We use `pc' rather than `unknown' + # because (1) that's what they normally are, and + # (2) the word "unknown" tends to confuse beginning users. + i*86 | x86_64) + basic_machine=$basic_machine-pc + ;; + # Object if more than one company name word. + *-*-*) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; + # Recognize the basic CPU types with company name. + 580-* \ + | a29k-* \ + | aarch64-* | aarch64_be-* \ + | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ + | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ + | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ + | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ + | avr-* | avr32-* \ + | be32-* | be64-* \ + | bfin-* | bs2000-* \ + | c[123]* | c30-* | [cjt]90-* | c4x-* \ + | c8051-* | clipper-* | craynv-* | cydra-* \ + | d10v-* | d30v-* | dlx-* \ + | elxsi-* \ + | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ + | h8300-* | h8500-* \ + | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ + | hexagon-* \ + | i*86-* | i860-* | i960-* | ia64-* \ + | ip2k-* | iq2000-* \ + | k1om-* \ + | le32-* | le64-* \ + | lm32-* \ + | m32c-* | m32r-* | m32rle-* \ + | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ + | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ + | microblaze-* | microblazeel-* \ + | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ + | mips16-* \ + | mips64-* | mips64el-* \ + | mips64octeon-* | mips64octeonel-* \ + | mips64orion-* | mips64orionel-* \ + | mips64r5900-* | mips64r5900el-* \ + | mips64vr-* | mips64vrel-* \ + | mips64vr4100-* | mips64vr4100el-* \ + | mips64vr4300-* | mips64vr4300el-* \ + | mips64vr5000-* | mips64vr5000el-* \ + | mips64vr5900-* | mips64vr5900el-* \ + | mipsisa32-* | mipsisa32el-* \ + | mipsisa32r2-* | mipsisa32r2el-* \ + | mipsisa32r6-* | mipsisa32r6el-* \ + | mipsisa64-* | mipsisa64el-* \ + | mipsisa64r2-* | mipsisa64r2el-* \ + | mipsisa64r6-* | mipsisa64r6el-* \ + | mipsisa64sb1-* | mipsisa64sb1el-* \ + | mipsisa64sr71k-* | mipsisa64sr71kel-* \ + | mipsr5900-* | mipsr5900el-* \ + | mipstx39-* | mipstx39el-* \ + | mmix-* \ + | mt-* \ + | msp430-* \ + | nds32-* | nds32le-* | nds32be-* \ + | nios-* | nios2-* | nios2eb-* | nios2el-* \ + | none-* | np1-* | ns16k-* | ns32k-* \ + | open8-* \ + | or1k*-* \ + | orion-* \ + | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ + | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ + | pyramid-* \ + | rl78-* | romp-* | rs6000-* | rx-* \ + | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ + | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ + | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ + | sparclite-* \ + | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ + | tahoe-* \ + | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ + | tile*-* \ + | tron-* \ + | ubicom32-* \ + | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ + | vax-* \ + | visium-* \ + | we32k-* \ + | x86-* | x86_64-* | xc16x-* | xps100-* \ + | xstormy16-* | xtensa*-* \ + | ymp-* \ + | z8k-* | z80-*) + ;; + # Recognize the basic CPU types without company name, with glob match. + xtensa*) + basic_machine=$basic_machine-unknown + ;; + # Recognize the various machine names and aliases which stand + # for a CPU type and a company and sometimes even an OS. + 386bsd) + basic_machine=i386-unknown + os=-bsd + ;; + 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) + basic_machine=m68000-att + ;; + 3b*) + basic_machine=we32k-att + ;; + a29khif) + basic_machine=a29k-amd + os=-udi + ;; + abacus) + basic_machine=abacus-unknown + ;; + adobe68k) + basic_machine=m68010-adobe + os=-scout + ;; + alliant | fx80) + basic_machine=fx80-alliant + ;; + altos | altos3068) + basic_machine=m68k-altos + ;; + am29k) + basic_machine=a29k-none + os=-bsd + ;; + amd64) + basic_machine=x86_64-pc + ;; + amd64-*) + basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + amdahl) + basic_machine=580-amdahl + os=-sysv + ;; + amiga | amiga-*) + basic_machine=m68k-unknown + ;; + amigaos | amigados) + basic_machine=m68k-unknown + os=-amigaos + ;; + amigaunix | amix) + basic_machine=m68k-unknown + os=-sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + os=-sysv + ;; + apollo68bsd) + basic_machine=m68k-apollo + os=-bsd + ;; + aros) + basic_machine=i386-pc + os=-aros + ;; + aux) + basic_machine=m68k-apple + os=-aux + ;; + balance) + basic_machine=ns32k-sequent + os=-dynix + ;; + blackfin) + basic_machine=bfin-unknown + os=-linux + ;; + blackfin-*) + basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` + os=-linux + ;; + bluegene*) + basic_machine=powerpc-ibm + os=-cnk + ;; + c54x-*) + basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + c55x-*) + basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + c6x-*) + basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + c90) + basic_machine=c90-cray + os=-unicos + ;; + cegcc) + basic_machine=arm-unknown + os=-cegcc + ;; + convex-c1) + basic_machine=c1-convex + os=-bsd + ;; + convex-c2) + basic_machine=c2-convex + os=-bsd + ;; + convex-c32) + basic_machine=c32-convex + os=-bsd + ;; + convex-c34) + basic_machine=c34-convex + os=-bsd + ;; + convex-c38) + basic_machine=c38-convex + os=-bsd + ;; + cray | j90) + basic_machine=j90-cray + os=-unicos + ;; + craynv) + basic_machine=craynv-cray + os=-unicosmp + ;; + cr16 | cr16-*) + basic_machine=cr16-unknown + os=-elf + ;; + crds | unos) + basic_machine=m68k-crds + ;; + crisv32 | crisv32-* | etraxfs*) + basic_machine=crisv32-axis + ;; + cris | cris-* | etrax*) + basic_machine=cris-axis + ;; + crx) + basic_machine=crx-unknown + os=-elf + ;; + da30 | da30-*) + basic_machine=m68k-da30 + ;; + decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) + basic_machine=mips-dec + ;; + decsystem10* | dec10*) + basic_machine=pdp10-dec + os=-tops10 + ;; + decsystem20* | dec20*) + basic_machine=pdp10-dec + os=-tops20 + ;; + delta | 3300 | motorola-3300 | motorola-delta \ + | 3300-motorola | delta-motorola) + basic_machine=m68k-motorola + ;; + delta88) + basic_machine=m88k-motorola + os=-sysv3 + ;; + dicos) + basic_machine=i686-pc + os=-dicos + ;; + djgpp) + basic_machine=i586-pc + os=-msdosdjgpp + ;; + dpx20 | dpx20-*) + basic_machine=rs6000-bull + os=-bosx + ;; + dpx2* | dpx2*-bull) + basic_machine=m68k-bull + os=-sysv3 + ;; + ebmon29k) + basic_machine=a29k-amd + os=-ebmon + ;; + elxsi) + basic_machine=elxsi-elxsi + os=-bsd + ;; + encore | umax | mmax) + basic_machine=ns32k-encore + ;; + es1800 | OSE68k | ose68k | ose | OSE) + basic_machine=m68k-ericsson + os=-ose + ;; + fx2800) + basic_machine=i860-alliant + ;; + genix) + basic_machine=ns32k-ns + ;; + gmicro) + basic_machine=tron-gmicro + os=-sysv + ;; + go32) + basic_machine=i386-pc + os=-go32 + ;; + h3050r* | hiux*) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + h8300hms) + basic_machine=h8300-hitachi + os=-hms + ;; + h8300xray) + basic_machine=h8300-hitachi + os=-xray + ;; + h8500hms) + basic_machine=h8500-hitachi + os=-hms + ;; + harris) + basic_machine=m88k-harris + os=-sysv3 + ;; + hp300-*) + basic_machine=m68k-hp + ;; + hp300bsd) + basic_machine=m68k-hp + os=-bsd + ;; + hp300hpux) + basic_machine=m68k-hp + os=-hpux + ;; + hp3k9[0-9][0-9] | hp9[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k2[0-9][0-9] | hp9k31[0-9]) + basic_machine=m68000-hp + ;; + hp9k3[2-9][0-9]) + basic_machine=m68k-hp + ;; + hp9k6[0-9][0-9] | hp6[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k7[0-79][0-9] | hp7[0-79][0-9]) + basic_machine=hppa1.1-hp + ;; + hp9k78[0-9] | hp78[0-9]) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][13679] | hp8[0-9][13679]) + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][0-9] | hp8[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hppa-next) + os=-nextstep3 + ;; + hppaosf) + basic_machine=hppa1.1-hp + os=-osf + ;; + hppro) + basic_machine=hppa1.1-hp + os=-proelf + ;; + i370-ibm* | ibm*) + basic_machine=i370-ibm + ;; + i*86v32) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv32 + ;; + i*86v4*) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv4 + ;; + i*86v) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv + ;; + i*86sol2) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-solaris2 + ;; + i386mach) + basic_machine=i386-mach + os=-mach + ;; + i386-vsta | vsta) + basic_machine=i386-unknown + os=-vsta + ;; + iris | iris4d) + basic_machine=mips-sgi + case $os in + -irix*) + ;; + *) + os=-irix4 + ;; + esac + ;; + isi68 | isi) + basic_machine=m68k-isi + os=-sysv + ;; + leon-*|leon[3-9]-*) + basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'` + ;; + m68knommu) + basic_machine=m68k-unknown + os=-linux + ;; + m68knommu-*) + basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` + os=-linux + ;; + m88k-omron*) + basic_machine=m88k-omron + ;; + magnum | m3230) + basic_machine=mips-mips + os=-sysv + ;; + merlin) + basic_machine=ns32k-utek + os=-sysv + ;; + microblaze*) + basic_machine=microblaze-xilinx + ;; + mingw64) + basic_machine=x86_64-pc + os=-mingw64 + ;; + mingw32) + basic_machine=i686-pc + os=-mingw32 + ;; + mingw32ce) + basic_machine=arm-unknown + os=-mingw32ce + ;; + miniframe) + basic_machine=m68000-convergent + ;; + *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; + mips3*-*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` + ;; + mips3*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown + ;; + monitor) + basic_machine=m68k-rom68k + os=-coff + ;; + morphos) + basic_machine=powerpc-unknown + os=-morphos + ;; + moxiebox) + basic_machine=moxie-unknown + os=-moxiebox + ;; + msdos) + basic_machine=i386-pc + os=-msdos + ;; + ms1-*) + basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` + ;; + msys) + basic_machine=i686-pc + os=-msys + ;; + mvs) + basic_machine=i370-ibm + os=-mvs + ;; + nacl) + basic_machine=le32-unknown + os=-nacl + ;; + ncr3000) + basic_machine=i486-ncr + os=-sysv4 + ;; + netbsd386) + basic_machine=i386-unknown + os=-netbsd + ;; + netwinder) + basic_machine=armv4l-rebel + os=-linux + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + os=-newsos + ;; + news1000) + basic_machine=m68030-sony + os=-newsos + ;; + news-3600 | risc-news) + basic_machine=mips-sony + os=-newsos + ;; + necv70) + basic_machine=v70-nec + os=-sysv + ;; + next | m*-next ) + basic_machine=m68k-next + case $os in + -nextstep* ) + ;; + -ns2*) + os=-nextstep2 + ;; + *) + os=-nextstep3 + ;; + esac + ;; + nh3000) + basic_machine=m68k-harris + os=-cxux + ;; + nh[45]000) + basic_machine=m88k-harris + os=-cxux + ;; + nindy960) + basic_machine=i960-intel + os=-nindy + ;; + mon960) + basic_machine=i960-intel + os=-mon960 + ;; + nonstopux) + basic_machine=mips-compaq + os=-nonstopux + ;; + np1) + basic_machine=np1-gould + ;; + neo-tandem) + basic_machine=neo-tandem + ;; + nse-tandem) + basic_machine=nse-tandem + ;; + nsr-tandem) + basic_machine=nsr-tandem + ;; + op50n-* | op60c-*) + basic_machine=hppa1.1-oki + os=-proelf + ;; + openrisc | openrisc-*) + basic_machine=or32-unknown + ;; + os400) + basic_machine=powerpc-ibm + os=-os400 + ;; + OSE68000 | ose68000) + basic_machine=m68000-ericsson + os=-ose + ;; + os68k) + basic_machine=m68k-none + os=-os68k + ;; + pa-hitachi) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + paragon) + basic_machine=i860-intel + os=-osf + ;; + parisc) + basic_machine=hppa-unknown + os=-linux + ;; + parisc-*) + basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` + os=-linux + ;; + pbd) + basic_machine=sparc-tti + ;; + pbb) + basic_machine=m68k-tti + ;; + pc532 | pc532-*) + basic_machine=ns32k-pc532 + ;; + pc98) + basic_machine=i386-pc + ;; + pc98-*) + basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentium | p5 | k5 | k6 | nexgen | viac3) + basic_machine=i586-pc + ;; + pentiumpro | p6 | 6x86 | athlon | athlon_*) + basic_machine=i686-pc + ;; + pentiumii | pentium2 | pentiumiii | pentium3) + basic_machine=i686-pc + ;; + pentium4) + basic_machine=i786-pc + ;; + pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) + basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumpro-* | p6-* | 6x86-* | athlon-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentium4-*) + basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pn) + basic_machine=pn-gould + ;; + power) basic_machine=power-ibm + ;; + ppc | ppcbe) basic_machine=powerpc-unknown + ;; + ppc-* | ppcbe-*) + basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppcle | powerpclittle | ppc-le | powerpc-little) + basic_machine=powerpcle-unknown + ;; + ppcle-* | powerpclittle-*) + basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64) basic_machine=powerpc64-unknown + ;; + ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64le | powerpc64little | ppc64-le | powerpc64-little) + basic_machine=powerpc64le-unknown + ;; + ppc64le-* | powerpc64little-*) + basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ps2) + basic_machine=i386-ibm + ;; + pw32) + basic_machine=i586-unknown + os=-pw32 + ;; + rdos | rdos64) + basic_machine=x86_64-pc + os=-rdos + ;; + rdos32) + basic_machine=i386-pc + os=-rdos + ;; + rom68k) + basic_machine=m68k-rom68k + os=-coff + ;; + rm[46]00) + basic_machine=mips-siemens + ;; + rtpc | rtpc-*) + basic_machine=romp-ibm + ;; + s390 | s390-*) + basic_machine=s390-ibm + ;; + s390x | s390x-*) + basic_machine=s390x-ibm + ;; + sa29200) + basic_machine=a29k-amd + os=-udi + ;; + sb1) + basic_machine=mipsisa64sb1-unknown + ;; + sb1el) + basic_machine=mipsisa64sb1el-unknown + ;; + sde) + basic_machine=mipsisa32-sde + os=-elf + ;; + sei) + basic_machine=mips-sei + os=-seiux + ;; + sequent) + basic_machine=i386-sequent + ;; + sh) + basic_machine=sh-hitachi + os=-hms + ;; + sh5el) + basic_machine=sh5le-unknown + ;; + sh64) + basic_machine=sh64-unknown + ;; + sparclite-wrs | simso-wrs) + basic_machine=sparclite-wrs + os=-vxworks + ;; + sps7) + basic_machine=m68k-bull + os=-sysv2 + ;; + spur) + basic_machine=spur-unknown + ;; + st2000) + basic_machine=m68k-tandem + ;; + stratus) + basic_machine=i860-stratus + os=-sysv4 + ;; + strongarm-* | thumb-*) + basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + sun2) + basic_machine=m68000-sun + ;; + sun2os3) + basic_machine=m68000-sun + os=-sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + os=-sunos4 + ;; + sun3os3) + basic_machine=m68k-sun + os=-sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + os=-sunos4 + ;; + sun4os3) + basic_machine=sparc-sun + os=-sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + os=-sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + os=-solaris2 + ;; + sun3 | sun3-*) + basic_machine=m68k-sun + ;; + sun4) + basic_machine=sparc-sun + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + ;; + sv1) + basic_machine=sv1-cray + os=-unicos + ;; + symmetry) + basic_machine=i386-sequent + os=-dynix + ;; + t3e) + basic_machine=alphaev5-cray + os=-unicos + ;; + t90) + basic_machine=t90-cray + os=-unicos + ;; + tile*) + basic_machine=$basic_machine-unknown + os=-linux-gnu + ;; + tx39) + basic_machine=mipstx39-unknown + ;; + tx39el) + basic_machine=mipstx39el-unknown + ;; + toad1) + basic_machine=pdp10-xkl + os=-tops20 + ;; + tower | tower-32) + basic_machine=m68k-ncr + ;; + tpf) + basic_machine=s390x-ibm + os=-tpf + ;; + udi29k) + basic_machine=a29k-amd + os=-udi + ;; + ultra3) + basic_machine=a29k-nyu + os=-sym1 + ;; + v810 | necv810) + basic_machine=v810-nec + os=-none + ;; + vaxv) + basic_machine=vax-dec + os=-sysv + ;; + vms) + basic_machine=vax-dec + os=-vms + ;; + vpp*|vx|vx-*) + basic_machine=f301-fujitsu + ;; + vxworks960) + basic_machine=i960-wrs + os=-vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + os=-vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + os=-vxworks + ;; + w65*) + basic_machine=w65-wdc + os=-none + ;; + w89k-*) + basic_machine=hppa1.1-winbond + os=-proelf + ;; + xbox) + basic_machine=i686-pc + os=-mingw32 + ;; + xps | xps100) + basic_machine=xps100-honeywell + ;; + xscale-* | xscalee[bl]-*) + basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` + ;; + ymp) + basic_machine=ymp-cray + os=-unicos + ;; + z8k-*-coff) + basic_machine=z8k-unknown + os=-sim + ;; + z80-*-coff) + basic_machine=z80-unknown + os=-sim + ;; + none) + basic_machine=none-none + os=-none + ;; + +# Here we handle the default manufacturer of certain CPU types. It is in +# some cases the only manufacturer, in others, it is the most popular. + w89k) + basic_machine=hppa1.1-winbond + ;; + op50n) + basic_machine=hppa1.1-oki + ;; + op60c) + basic_machine=hppa1.1-oki + ;; + romp) + basic_machine=romp-ibm + ;; + mmix) + basic_machine=mmix-knuth + ;; + rs6000) + basic_machine=rs6000-ibm + ;; + vax) + basic_machine=vax-dec + ;; + pdp10) + # there are many clones, so DEC is not a safe bet + basic_machine=pdp10-unknown + ;; + pdp11) + basic_machine=pdp11-dec + ;; + we32k) + basic_machine=we32k-att + ;; + sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) + basic_machine=sh-unknown + ;; + sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) + basic_machine=sparc-sun + ;; + cydra) + basic_machine=cydra-cydrome + ;; + orion) + basic_machine=orion-highlevel + ;; + orion105) + basic_machine=clipper-highlevel + ;; + mac | mpw | mac-mpw) + basic_machine=m68k-apple + ;; + pmac | pmac-mpw) + basic_machine=powerpc-apple + ;; + *-unknown) + # Make sure to match an already-canonicalized machine name. + ;; + *) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; +esac + +# Here we canonicalize certain aliases for manufacturers. +case $basic_machine in + *-digital*) + basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` + ;; + *-commodore*) + basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + ;; + *) + ;; +esac + +# Decode manufacturer-specific aliases for certain operating systems. + +if [ x"$os" != x"" ] +then +case $os in + # First match some system type aliases + # that might get confused with valid system types. + # -solaris* is a basic system type, with this one exception. + -auroraux) + os=-auroraux + ;; + -solaris1 | -solaris1.*) + os=`echo $os | sed -e 's|solaris1|sunos4|'` + ;; + -solaris) + os=-solaris2 + ;; + -svr4*) + os=-sysv4 + ;; + -unixware*) + os=-sysv4.2uw + ;; + -gnu/linux*) + os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` + ;; + # First accept the basic system types. + # The portable systems comes first. + # Each alternative MUST END IN A *, to match a version number. + # -sysv* is not here because it comes later, after sysvr4. + -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* | -plan9* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ + | -aos* | -aros* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ + | -bitrig* | -openbsd* | -solidbsd* \ + | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ + | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ + | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ + | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ + | -chorusos* | -chorusrdb* | -cegcc* \ + | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ + | -linux-newlib* | -linux-musl* | -linux-uclibc* \ + | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \ + | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ + | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ + | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ + | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ + | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ + | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ + | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* | -tirtos*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; + -qnx*) + case $basic_machine in + x86-* | i*86-*) + ;; + *) + os=-nto$os + ;; + esac + ;; + -nto-qnx*) + ;; + -nto*) + os=`echo $os | sed -e 's|nto|nto-qnx|'` + ;; + -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ + | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ + | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) + ;; + -mac*) + os=`echo $os | sed -e 's|mac|macos|'` + ;; + -linux-dietlibc) + os=-linux-dietlibc + ;; + -linux*) + os=`echo $os | sed -e 's|linux|linux-gnu|'` + ;; + -sunos5*) + os=`echo $os | sed -e 's|sunos5|solaris2|'` + ;; + -sunos6*) + os=`echo $os | sed -e 's|sunos6|solaris3|'` + ;; + -opened*) + os=-openedition + ;; + -os400*) + os=-os400 + ;; + -wince*) + os=-wince + ;; + -osfrose*) + os=-osfrose + ;; + -osf*) + os=-osf + ;; + -utek*) + os=-bsd + ;; + -dynix*) + os=-bsd + ;; + -acis*) + os=-aos + ;; + -atheos*) + os=-atheos + ;; + -syllable*) + os=-syllable + ;; + -386bsd) + os=-bsd + ;; + -ctix* | -uts*) + os=-sysv + ;; + -nova*) + os=-rtmk-nova + ;; + -ns2 ) + os=-nextstep2 + ;; + -nsk*) + os=-nsk + ;; + # Preserve the version number of sinix5. + -sinix5.*) + os=`echo $os | sed -e 's|sinix|sysv|'` + ;; + -sinix*) + os=-sysv4 + ;; + -tpf*) + os=-tpf + ;; + -triton*) + os=-sysv3 + ;; + -oss*) + os=-sysv3 + ;; + -svr4) + os=-sysv4 + ;; + -svr3) + os=-sysv3 + ;; + -sysvr4) + os=-sysv4 + ;; + # This must come after -sysvr4. + -sysv*) + ;; + -ose*) + os=-ose + ;; + -es1800*) + os=-ose + ;; + -xenix) + os=-xenix + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + os=-mint + ;; + -aros*) + os=-aros + ;; + -zvmoe) + os=-zvmoe + ;; + -dicos*) + os=-dicos + ;; + -nacl*) + ;; + -none) + ;; + *) + # Get rid of the `-' at the beginning of $os. + os=`echo $os | sed 's/[^-]*-//'` + echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 + exit 1 + ;; +esac +else + +# Here we handle the default operating systems that come with various machines. +# The value should be what the vendor currently ships out the door with their +# machine or put another way, the most popular os provided with the machine. + +# Note that if you're going to try to match "-MANUFACTURER" here (say, +# "-sun"), then you have to tell the case statement up towards the top +# that MANUFACTURER isn't an operating system. Otherwise, code above +# will signal an error saying that MANUFACTURER isn't an operating +# system, and we'll never get to this point. + +case $basic_machine in + score-*) + os=-elf + ;; + spu-*) + os=-elf + ;; + *-acorn) + os=-riscix1.2 + ;; + arm*-rebel) + os=-linux + ;; + arm*-semi) + os=-aout + ;; + c4x-* | tic4x-*) + os=-coff + ;; + c8051-*) + os=-elf + ;; + hexagon-*) + os=-elf + ;; + tic54x-*) + os=-coff + ;; + tic55x-*) + os=-coff + ;; + tic6x-*) + os=-coff + ;; + # This must come before the *-dec entry. + pdp10-*) + os=-tops20 + ;; + pdp11-*) + os=-none + ;; + *-dec | vax-*) + os=-ultrix4.2 + ;; + m68*-apollo) + os=-domain + ;; + i386-sun) + os=-sunos4.0.2 + ;; + m68000-sun) + os=-sunos3 + ;; + m68*-cisco) + os=-aout + ;; + mep-*) + os=-elf + ;; + mips*-cisco) + os=-elf + ;; + mips*-*) + os=-elf + ;; + or32-*) + os=-coff + ;; + *-tti) # must be before sparc entry or we get the wrong os. + os=-sysv3 + ;; + sparc-* | *-sun) + os=-sunos4.1.1 + ;; + *-be) + os=-beos + ;; + *-haiku) + os=-haiku + ;; + *-ibm) + os=-aix + ;; + *-knuth) + os=-mmixware + ;; + *-wec) + os=-proelf + ;; + *-winbond) + os=-proelf + ;; + *-oki) + os=-proelf + ;; + *-hp) + os=-hpux + ;; + *-hitachi) + os=-hiux + ;; + i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) + os=-sysv + ;; + *-cbm) + os=-amigaos + ;; + *-dg) + os=-dgux + ;; + *-dolphin) + os=-sysv3 + ;; + m68k-ccur) + os=-rtu + ;; + m88k-omron*) + os=-luna + ;; + *-next ) + os=-nextstep + ;; + *-sequent) + os=-ptx + ;; + *-crds) + os=-unos + ;; + *-ns) + os=-genix + ;; + i370-*) + os=-mvs + ;; + *-next) + os=-nextstep3 + ;; + *-gould) + os=-sysv + ;; + *-highlevel) + os=-bsd + ;; + *-encore) + os=-bsd + ;; + *-sgi) + os=-irix + ;; + *-siemens) + os=-sysv4 + ;; + *-masscomp) + os=-rtu + ;; + f30[01]-fujitsu | f700-fujitsu) + os=-uxpv + ;; + *-rom68k) + os=-coff + ;; + *-*bug) + os=-coff + ;; + *-apple) + os=-macos + ;; + *-atari*) + os=-mint + ;; + *) + os=-none + ;; +esac +fi + +# Here we handle the case where we know the os, and the CPU type, but not the +# manufacturer. We pick the logical manufacturer. +vendor=unknown +case $basic_machine in + *-unknown) + case $os in + -riscix*) + vendor=acorn + ;; + -sunos*) + vendor=sun + ;; + -cnk*|-aix*) + vendor=ibm + ;; + -beos*) + vendor=be + ;; + -hpux*) + vendor=hp + ;; + -mpeix*) + vendor=hp + ;; + -hiux*) + vendor=hitachi + ;; + -unos*) + vendor=crds + ;; + -dgux*) + vendor=dg + ;; + -luna*) + vendor=omron + ;; + -genix*) + vendor=ns + ;; + -mvs* | -opened*) + vendor=ibm + ;; + -os400*) + vendor=ibm + ;; + -ptx*) + vendor=sequent + ;; + -tpf*) + vendor=ibm + ;; + -vxsim* | -vxworks* | -windiss*) + vendor=wrs + ;; + -aux*) + vendor=apple + ;; + -hms*) + vendor=hitachi + ;; + -mpw* | -macos*) + vendor=apple + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + vendor=atari + ;; + -vos*) + vendor=stratus + ;; + esac + basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` + ;; +esac + +echo $basic_machine$os +exit + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: