From d57ce99b7d187eb3af7749a056edeea443da93f6 Mon Sep 17 00:00:00 2001 From: git Date: Thu, 11 Jul 2019 03:37:22 +0900 Subject: [PATCH 001/452] * 2019-07-11 --- version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.h b/version.h index 0122ecb254d970..f8a9d734049469 100644 --- a/version.h +++ b/version.h @@ -6,7 +6,7 @@ #define RUBY_RELEASE_YEAR 2019 #define RUBY_RELEASE_MONTH 7 -#define RUBY_RELEASE_DAY 10 +#define RUBY_RELEASE_DAY 11 #include "ruby/version.h" From 50d85436f8f194aa78cd0e819471fe20767a5993 Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Thu, 11 Jul 2019 09:18:41 +0900 Subject: [PATCH 002/452] WEBrick::HTTPResponse create tempfile if required. WEBrick::HTTPProxyServer implementes HTTP proxy using WEBrick and Net::HTTP. WEBrick accepts HTTP/1.0 clients and Net::HTTP uses always HTTP/1.1. However HTTP/1.1 supports chunked transfer coding HTTP/1.0 doesn't. Chunked transfer coding doesn't require that content-length before the content is sent. But non-chunked transfer coding require content-length before the content is sent. So, when HTTP/1.0 clients connects WEBrick::HTTPProxyServer and origin server returns chunked response, WEBrick::HTTPProxyServer needs to store whole content to know the length of it. This patch do it using tempfile. --- lib/webrick/httpresponse.rb | 41 ++++++++++++++++++++++++++++++++-- test/webrick/test_httpproxy.rb | 40 +++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+), 2 deletions(-) diff --git a/lib/webrick/httpresponse.rb b/lib/webrick/httpresponse.rb index f206a05ce9efbb..62d8056cf70b38 100644 --- a/lib/webrick/httpresponse.rb +++ b/lib/webrick/httpresponse.rb @@ -113,6 +113,7 @@ def initialize(config) @chunked = false @filename = nil @sent_size = 0 + @bodytempfile = nil end ## @@ -253,7 +254,10 @@ def setup_header() # :nodoc: elsif %r{^multipart/byteranges} =~ @header['content-type'] @header.delete('content-length') elsif @header['content-length'].nil? - unless @body.is_a?(IO) + if @body.respond_to? :readpartial + elsif @body.respond_to? :call + make_body_tempfile + else @header['content-length'] = (@body ? @body.bytesize : 0).to_s end end @@ -282,6 +286,33 @@ def setup_header() # :nodoc: end end + def make_body_tempfile # :nodoc: + return if @bodytempfile + bodytempfile = Tempfile.create("webrick") + if @body.nil? + # nothing + elsif @body.respond_to? :readpartial + IO.copy_stream(@body, bodytempfile) + @body.close + elsif @body.respond_to? :call + @body.call(bodytempfile) + else + bodytempfile.write @body + end + bodytempfile.rewind + @body = @bodytempfile = bodytempfile + @header['content-length'] = bodytempfile.stat.size.to_s + end + + def remove_body_tempfile # :nodoc: + if @bodytempfile + @bodytempfile.close + File.unlink @bodytempfile.path + @bodytempfile = nil + end + end + + ## # Sends the headers on +socket+ @@ -445,6 +476,7 @@ def send_body_io(socket) ensure @body.close end + remove_body_tempfile end def send_body_string(socket) @@ -477,7 +509,12 @@ def send_body_proc(socket) socket.write("0#{CRLF}#{CRLF}") else size = @header['content-length'].to_i - @body.call(socket) + if @bodytempfile + @bodytempfile.rewind + IO.copy_stream(@bodytempfile, socket) + else + @body.call(socket) + end @sent_size = size end end diff --git a/test/webrick/test_httpproxy.rb b/test/webrick/test_httpproxy.rb index a9f6f7d61046ef..8bc8a1240a4f70 100644 --- a/test/webrick/test_httpproxy.rb +++ b/test/webrick/test_httpproxy.rb @@ -215,6 +215,46 @@ def test_big_bodies end end + def test_http10_proxy_chunked + # Testing HTTP/1.0 client request and HTTP/1.1 chunked response + # from origin server. + # +------+ + # V | + # client -------> proxy ---+ + # GET GET + # HTTP/1.0 HTTP/1.1 + # non-chunked chunked + # + proxy_handler_called = request_handler_called = 0 + config = { + :ServerName => "localhost.localdomain", + :ProxyContentHandler => Proc.new{|req, res| proxy_handler_called += 1 }, + :RequestCallback => Proc.new{|req, res| request_handler_called += 1 } + } + log_tester = lambda {|log, access_log| + log.reject! {|str| + %r{WARN chunked is set for an HTTP/1\.0 request\. \(ignored\)} =~ str + } + assert_equal([], log) + } + TestWEBrick.start_httpproxy(config, log_tester){|server, addr, port, log| + body = nil + server.mount_proc("/"){|req, res| + body = "#{req.request_method} #{req.path} #{req.body}" + res.chunked = true + res.body = -> (socket) { body.each_char {|c| socket.write c } } + } + http = Net::HTTP.new(addr, port, addr, port) + + # Don't use Net::HTTP because it uses HTTP/1.1. + TCPSocket.open(addr, port) {|s| + s.write "GET / HTTP/1.0\r\nHost: localhost.localdomain\r\n\r\n" + response = s.read + assert_equal(body, response[/.*\z/]) + } + } + end + def make_certificate(key, cn) subject = OpenSSL::X509::Name.parse("/DC=org/DC=ruby-lang/CN=#{cn}") exts = [ From 26d674fdc73cec3777d1a719b42ccbe54c18a966 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 11 Jul 2019 11:58:35 +0900 Subject: [PATCH 003/452] Suppress warning on x64-mingw --- gc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gc.c b/gc.c index 2268dd78b77e5f..4e1e4ee9d67a9c 100644 --- a/gc.c +++ b/gc.c @@ -9390,7 +9390,7 @@ rb_memerror(void) if (0) { // Print out pid, sleep, so you can attach debugger to see what went wrong: - fprintf(stderr, "rb_memerror pid=%d\n", getpid()); + fprintf(stderr, "rb_memerror pid=%"PRI_PIDT_PREFIX"d\n", getpid()); sleep(60); } From d34303ad109b93445b01d0420c9a5bfeffafac38 Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Thu, 11 Jul 2019 13:04:07 +0900 Subject: [PATCH 004/452] remove an unused variable. --- test/webrick/test_httpproxy.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/test/webrick/test_httpproxy.rb b/test/webrick/test_httpproxy.rb index 8bc8a1240a4f70..8149d783001b60 100644 --- a/test/webrick/test_httpproxy.rb +++ b/test/webrick/test_httpproxy.rb @@ -244,7 +244,6 @@ def test_http10_proxy_chunked res.chunked = true res.body = -> (socket) { body.each_char {|c| socket.write c } } } - http = Net::HTTP.new(addr, port, addr, port) # Don't use Net::HTTP because it uses HTTP/1.1. TCPSocket.open(addr, port) {|s| From d77b84ca82e1cef10ef06776a207151ef864b3ca Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 11 Jul 2019 14:05:34 +0900 Subject: [PATCH 005/452] $LOAD_PATH.resolve_feature_path Moved from RubyVM. [Feature #15903] --- load.c | 1 + test/ruby/test_require.rb | 6 +++--- vm.c | 4 ---- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/load.c b/load.c index 7661616976ea8f..4eb3f7f50b0331 100644 --- a/load.c +++ b/load.c @@ -1238,6 +1238,7 @@ Init_load(void) vm->expanded_load_path = rb_ary_tmp_new(0); vm->load_path_snapshot = rb_ary_tmp_new(0); vm->load_path_check_cache = 0; + rb_define_singleton_method(vm->load_path, "resolve_feature_path", rb_resolve_feature_path, 1); rb_define_virtual_variable("$\"", get_loaded_features, 0); rb_define_virtual_variable("$LOADED_FEATURES", get_loaded_features, 0); diff --git a/test/ruby/test_require.rb b/test/ruby/test_require.rb index afd5d20558f953..56dfd95096b308 100644 --- a/test/ruby/test_require.rb +++ b/test/ruby/test_require.rb @@ -898,7 +898,7 @@ def test_symlink_load_path } end - if defined?(RubyVM.resolve_feature_path) + if defined?($LOAD_PATH.resolve_feature_path) def test_resolve_feature_path paths, loaded = $:.dup, $".dup Dir.mktmpdir do |tmp| @@ -907,9 +907,9 @@ def test_resolve_feature_path path = File.realpath(file.path) dir, base = File.split(path) $:.unshift(dir) - assert_equal([:rb, path], RubyVM.resolve_feature_path(base)) + assert_equal([:rb, path], $LOAD_PATH.resolve_feature_path(base)) $".push(path) - assert_equal([:rb, path], RubyVM.resolve_feature_path(base)) + assert_equal([:rb, path], $LOAD_PATH.resolve_feature_path(base)) end end ensure diff --git a/vm.c b/vm.c index 7ad6bdd2649cce..09e727ff7fb6b4 100644 --- a/vm.c +++ b/vm.c @@ -2949,8 +2949,6 @@ static VALUE usage_analysis_register_stop(VALUE self); * #=> [:rb, "/path/to/set.rb"] */ -VALUE rb_resolve_feature_path(VALUE klass, VALUE fname); - void Init_VM(void) { @@ -3255,8 +3253,6 @@ Init_VM(void) /* vm_backtrace.c */ Init_vm_backtrace(); - - rb_define_singleton_method(rb_cRubyVM, "resolve_feature_path", rb_resolve_feature_path, 1); } void From 4e038a7e64a9d52eed59b8f05647d4e58d265ec3 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 11 Jul 2019 14:29:35 +0900 Subject: [PATCH 006/452] Revert "parse.y: Deprecate flip-flops" This reverts commit bae638ad5b782c44c80efe33834cb9039279af46. [Feature #5400] --- parse.y | 6 ++---- spec/ruby/language/if_spec.rb | 12 ------------ test/ruby/test_syntax.rb | 2 -- 3 files changed, 2 insertions(+), 18 deletions(-) diff --git a/parse.y b/parse.y index e75c0b42340edc..7445e4ae495ba4 100644 --- a/parse.y +++ b/parse.y @@ -10930,10 +10930,8 @@ cond0(struct parser_params *p, NODE *node, int method_op, const YYLTYPE *loc) case NODE_DOT3: node->nd_beg = range_op(p, node->nd_beg, loc); node->nd_end = range_op(p, node->nd_end, loc); - if (nd_type(node) == NODE_DOT2 || nd_type(node) == NODE_DOT3) { - nd_set_type(node, nd_type(node) == NODE_DOT2 ? NODE_FLIP2 : NODE_FLIP3); - parser_warn(p, node, "flip-flop is deprecated"); - } + if (nd_type(node) == NODE_DOT2) nd_set_type(node,NODE_FLIP2); + else if (nd_type(node) == NODE_DOT3) nd_set_type(node, NODE_FLIP3); if (!method_op && !e_option_supplied(p)) { int b = literal_node(node->nd_beg); int e = literal_node(node->nd_end); diff --git a/spec/ruby/language/if_spec.rb b/spec/ruby/language/if_spec.rb index 4d809019c9e405..e2201f462622be 100644 --- a/spec/ruby/language/if_spec.rb +++ b/spec/ruby/language/if_spec.rb @@ -308,18 +308,6 @@ 6.times(&b) ScratchPad.recorded.should == [4, 5, 4, 5] end - - ruby_version_is "2.6" do - it 'is deprecated' do - i = 4 - - -> do - eval "ScratchPad << 'it works' if (i == 4)..(i == 7)" - end.should complain(/flip-flop is deprecated/) - - ScratchPad.recorded.should == ['it works'] - end - end end end diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index 18546efe63a64f..c5c3737b305e54 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -1027,9 +1027,7 @@ def test_warning_literal_in_condition eval('1 if !//') end assert_warn('') do - verbose_bak, $VERBOSE = $VERBOSE, nil eval('1 if !(true..false)') - $VERBOSE = verbose_bak end assert_warning('') do eval('1 if !1') From 71ead0787283b469f5e834cb1868a8caa78702f1 Mon Sep 17 00:00:00 2001 From: aycabta Date: Thu, 11 Jul 2019 17:21:00 +0900 Subject: [PATCH 007/452] Add arg check to Reline.dig_perfect_match_proc= --- lib/reline.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/reline.rb b/lib/reline.rb index c27e4a380d63fd..bf8967c561794b 100644 --- a/lib/reline.rb +++ b/lib/reline.rb @@ -208,6 +208,7 @@ def self.dig_perfect_match_proc @@dig_perfect_match_proc end def self.dig_perfect_match_proc=(p) + raise ArgumentError unless p.is_a?(Proc) @@dig_perfect_match_proc = p end From cd069df36596d9bf7a6db8aaa0dcefdafb233a91 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 11 Jul 2019 19:45:03 +0900 Subject: [PATCH 008/452] File::Stat uses Time#inspect --- spec/ruby/core/file/stat/inspect_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/ruby/core/file/stat/inspect_spec.rb b/spec/ruby/core/file/stat/inspect_spec.rb index b0a0658dc0a51f..1613b427d028a5 100644 --- a/spec/ruby/core/file/stat/inspect_spec.rb +++ b/spec/ruby/core/file/stat/inspect_spec.rb @@ -15,10 +15,10 @@ st = File.stat(@file) expected = "#" st.inspect.should == expected From 3e7d002118a92fad5934e11c75be6768a1476c1b Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 11 Jul 2019 19:20:53 +0900 Subject: [PATCH 009/452] Check exception flag as a bool [Bug #15987] --- complex.c | 8 +------- ext/bigdecimal/bigdecimal.c | 12 ++++++++++++ ext/bigdecimal/extconf.rb | 1 + internal.h | 4 ++++ io.c | 36 ++++++++++++++++-------------------- object.c | 29 +++++++++++++++++++++-------- rational.c | 8 +------- test/ruby/test_complex.rb | 6 ++++++ test/ruby/test_float.rb | 6 ++++++ test/ruby/test_integer.rb | 6 ++++++ test/ruby/test_io.rb | 12 ++++++++++++ test/ruby/test_rational.rb | 6 ++++++ 12 files changed, 92 insertions(+), 42 deletions(-) diff --git a/complex.c b/complex.c index 848d3ac8a938c6..42b32d42791759 100644 --- a/complex.c +++ b/complex.c @@ -477,13 +477,7 @@ nucomp_f_complex(int argc, VALUE *argv, VALUE klass) a2 = Qundef; } if (!NIL_P(opts)) { - static ID kwds[1]; - VALUE exception; - if (!kwds[0]) { - kwds[0] = idException; - } - rb_get_kwargs(opts, kwds, 0, 1, &exception); - raise = (exception != Qfalse); + raise = rb_opts_exception_p(opts, raise); } return nucomp_convert(rb_cComplex, a1, a2, raise); } diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c index da1b24a6311a93..430707a4d64246 100644 --- a/ext/bigdecimal/bigdecimal.c +++ b/ext/bigdecimal/bigdecimal.c @@ -2560,6 +2560,10 @@ BigDecimal_clone(VALUE self) return self; } +#ifdef HAVE_RB_OPTS_EXCEPTION_P +int rb_opts_exception_p(VALUE opts, int default_value); +#define opts_exception_p(opts) rb_opts_exception_p((opts), 1) +#else static int opts_exception_p(VALUE opts) { @@ -2569,8 +2573,16 @@ opts_exception_p(VALUE opts) kwds[0] = rb_intern_const("exception"); } rb_get_kwargs(opts, kwds, 0, 1, &exception); + switch (exception) { + case Qtrue: case Qfalse: + break; + default: + rb_raise(rb_eArgError, "true or false is expected as exception: %+"PRIsVALUE, + flagname, obj); + } return exception != Qfalse; } +#endif static Real * BigDecimal_new(int argc, VALUE *argv) diff --git a/ext/bigdecimal/extconf.rb b/ext/bigdecimal/extconf.rb index a6a36304cc7173..7a7af10a2de1f3 100644 --- a/ext/bigdecimal/extconf.rb +++ b/ext/bigdecimal/extconf.rb @@ -27,6 +27,7 @@ have_func("rb_rational_den", "ruby.h") have_func("rb_array_const_ptr", "ruby.h") have_func("rb_sym2str", "ruby.h") +have_func("rb_opts_exception_p", "ruby.h") if File.file?(File.expand_path('../lib/bigdecimal.rb', __FILE__)) bigdecimal_rb = "$(srcdir)/lib/bigdecimal.rb" diff --git a/internal.h b/internal.h index f2c9e9a814c5d5..4f9c5b1475aa80 100644 --- a/internal.h +++ b/internal.h @@ -1891,6 +1891,7 @@ VALUE rb_immutable_obj_clone(int, VALUE *, VALUE); VALUE rb_obj_not_equal(VALUE obj1, VALUE obj2); VALUE rb_convert_type_with_id(VALUE,int,const char*,ID); VALUE rb_check_convert_type_with_id(VALUE,int,const char*,ID); +int rb_bool_expected(VALUE, const char *); struct RBasicRaw { VALUE flags; @@ -2349,6 +2350,9 @@ void rb_write_error_str(VALUE mesg); /* numeric.c (export) */ VALUE rb_int_positive_pow(long x, unsigned long y); +/* object.c (export) */ +int rb_opts_exception_p(VALUE opts, int default_value); + /* process.c (export) */ int rb_exec_async_signal_safe(const struct rb_execarg *e, char *errmsg, size_t errmsg_buflen); rb_pid_t rb_fork_async_signal_safe(int *status, int (*chfunc)(void*, char *, size_t), void *charg, VALUE fds, char *errmsg, size_t errmsg_buflen); diff --git a/io.c b/io.c index 5e04da806bd34d..65da68e19a2907 100644 --- a/io.c +++ b/io.c @@ -171,7 +171,6 @@ VALUE rb_default_rs; static VALUE argf; -#define id_exception idException static ID id_write, id_read, id_getc, id_flush, id_readpartial, id_set_encoding; static VALUE sym_mode, sym_perm, sym_flags, sym_extenc, sym_intenc, sym_encoding, sym_open_args; static VALUE sym_textmode, sym_binmode, sym_autoclose; @@ -2793,18 +2792,10 @@ read_internal_locktmp(VALUE str, struct io_internal_read_struct *iis) return (long)rb_str_locktmp_ensure(str, read_internal_call, (VALUE)iis); } -static int -no_exception_p(VALUE opts) -{ - VALUE except; - ID id = id_exception; - - rb_get_kwargs(opts, &id, 0, 1, &except); - return except == Qfalse; -} +#define no_exception_p(opts) !rb_opts_exception_p((opts), TRUE) static VALUE -io_getpartial(int argc, VALUE *argv, VALUE io, VALUE opts, int nonblock) +io_getpartial(int argc, VALUE *argv, VALUE io, int no_exception, int nonblock) { rb_io_t *fptr; VALUE length, str; @@ -2846,7 +2837,7 @@ io_getpartial(int argc, VALUE *argv, VALUE io, VALUE opts, int nonblock) if (!nonblock && fptr_wait_readable(fptr)) goto again; if (nonblock && (e == EWOULDBLOCK || e == EAGAIN)) { - if (no_exception_p(opts)) + if (no_exception) return sym_wait_readable; else rb_readwrite_syserr_fail(RB_IO_WAIT_READABLE, @@ -2940,9 +2931,9 @@ io_readpartial(int argc, VALUE *argv, VALUE io) } static VALUE -io_nonblock_eof(VALUE opts) +io_nonblock_eof(int no_exception) { - if (!no_exception_p(opts)) { + if (!no_exception) { rb_eof_error(); } return Qnil; @@ -2963,6 +2954,8 @@ io_read_nonblock(VALUE io, VALUE length, VALUE str, VALUE ex) shrinkable = io_setstrbuf(&str, len); OBJ_TAINT(str); + rb_bool_expected(ex, "exception"); + GetOpenFile(io, fptr); rb_io_check_byte_readable(fptr); @@ -2981,7 +2974,7 @@ io_read_nonblock(VALUE io, VALUE length, VALUE str, VALUE ex) if (n < 0) { int e = errno; if ((e == EWOULDBLOCK || e == EAGAIN)) { - if (ex == Qfalse) return sym_wait_readable; + if (!ex) return sym_wait_readable; rb_readwrite_syserr_fail(RB_IO_WAIT_READABLE, e, "read would block"); } @@ -2991,7 +2984,7 @@ io_read_nonblock(VALUE io, VALUE length, VALUE str, VALUE ex) io_set_read_length(str, n, shrinkable); if (n == 0) { - if (ex == Qfalse) return Qnil; + if (!ex) return Qnil; rb_eof_error(); } @@ -3007,6 +3000,7 @@ io_write_nonblock(VALUE io, VALUE str, VALUE ex) if (!RB_TYPE_P(str, T_STRING)) str = rb_obj_as_string(str); + rb_bool_expected(ex, "exception"); io = GetWriteIO(io); GetOpenFile(io, fptr); @@ -3022,7 +3016,7 @@ io_write_nonblock(VALUE io, VALUE str, VALUE ex) if (n < 0) { int e = errno; if (e == EWOULDBLOCK || e == EAGAIN) { - if (ex == Qfalse) { + if (!ex) { return sym_wait_writable; } else { @@ -12193,12 +12187,14 @@ static VALUE argf_getpartial(int argc, VALUE *argv, VALUE argf, VALUE opts, int nonblock) { VALUE tmp, str, length; + int no_exception; rb_scan_args(argc, argv, "11", &length, &str); if (!NIL_P(str)) { StringValue(str); argv[1] = str; } + no_exception = no_exception_p(opts); if (!next_argv()) { if (!NIL_P(str)) { @@ -12215,16 +12211,16 @@ argf_getpartial(int argc, VALUE *argv, VALUE argf, VALUE opts, int nonblock) RUBY_METHOD_FUNC(0), Qnil, rb_eEOFError, (VALUE)0); } else { - tmp = io_getpartial(argc, argv, ARGF.current_file, opts, nonblock); + tmp = io_getpartial(argc, argv, ARGF.current_file, no_exception, nonblock); } if (NIL_P(tmp)) { if (ARGF.next_p == -1) { - return io_nonblock_eof(opts); + return io_nonblock_eof(no_exception); } argf_close(argf); ARGF.next_p = 1; if (RARRAY_LEN(ARGF.argv) == 0) { - return io_nonblock_eof(opts); + return io_nonblock_eof(no_exception); } if (NIL_P(str)) str = rb_str_new(NULL, 0); diff --git a/object.c b/object.c index 3fc1ed9df33a73..6b7a8f29525596 100644 --- a/object.c +++ b/object.c @@ -3330,18 +3330,31 @@ rb_Integer(VALUE val) return rb_convert_to_integer(val, 0, TRUE); } -static int -opts_exception_p(VALUE opts) +int +rb_bool_expected(VALUE obj, const char *flagname) { - static ID kwds[1]; - VALUE exception; - if (!kwds[0]) { - kwds[0] = idException; + switch (obj) { + case Qtrue: case Qfalse: + break; + default: + rb_raise(rb_eArgError, "true or false is expected as %s: %+"PRIsVALUE, + flagname, obj); } - rb_get_kwargs(opts, kwds, 0, 1, &exception); - return exception != Qfalse; + return obj != Qfalse; +} + +int +rb_opts_exception_p(VALUE opts, int default_value) +{ + static ID kwds[1] = {idException}; + VALUE exception; + if (rb_get_kwargs(opts, kwds, 0, 1, &exception)) + return rb_bool_expected(exception, "exception"); + return default_value; } +#define opts_exception_p(opts) rb_opts_exception_p((opts), TRUE) + /* * call-seq: * Integer(arg, base=0, exception: true) -> integer or nil diff --git a/rational.c b/rational.c index 207c4c46b3378e..e137ac23e70907 100644 --- a/rational.c +++ b/rational.c @@ -574,13 +574,7 @@ nurat_f_rational(int argc, VALUE *argv, VALUE klass) a2 = Qundef; } if (!NIL_P(opts)) { - static ID kwds[1]; - VALUE exception; - if (!kwds[0]) { - kwds[0] = idException; - } - rb_get_kwargs(opts, kwds, 0, 1, &exception); - raise = (exception != Qfalse); + raise = rb_opts_exception_p(opts, raise); } return nurat_convert(rb_cRational, a1, a2, raise); } diff --git a/test/ruby/test_complex.rb b/test/ruby/test_complex.rb index 60a46d737d876e..2a72f3bcb9ee68 100644 --- a/test/ruby/test_complex.rb +++ b/test/ruby/test_complex.rb @@ -868,6 +868,12 @@ def test_parse end + def test_Complex_with_invalid_exception + assert_raise(ArgumentError) { + Complex("0", exception: 1) + } + end + def test_Complex_without_exception assert_nothing_raised(ArgumentError){ assert_equal(nil, Complex('5x', exception: false)) diff --git a/test/ruby/test_float.rb b/test/ruby/test_float.rb index 34534406946f96..02bafb0303cd3c 100644 --- a/test/ruby/test_float.rb +++ b/test/ruby/test_float.rb @@ -802,6 +802,12 @@ def test_invalid_str assert_raise(ArgumentError, bug4310) {under_gc_stress {Float('a'*10000)}} end + def test_Float_with_invalid_exception + assert_raise(ArgumentError) { + Float("0", exception: 1) + } + end + def test_Float_with_exception_keyword assert_raise(ArgumentError) { Float(".", exception: true) diff --git a/test/ruby/test_integer.rb b/test/ruby/test_integer.rb index 2334cab50a6d2c..84730b2a5d0fee 100644 --- a/test/ruby/test_integer.rb +++ b/test/ruby/test_integer.rb @@ -192,6 +192,12 @@ def to_int; raise "conversion failed"; end end; end + def test_Integer_with_exception_keyword + assert_raise(ArgumentError) { + Integer("0", exception: 1) + } + end + def test_Integer_with_exception_keyword assert_nothing_raised(ArgumentError) { assert_equal(nil, Integer("1z", exception: false)) diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index 4f66685f9bf011..3c5dc7671a8812 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -1509,6 +1509,12 @@ def test_read_nonblock_error } end if have_nonblock? + def test_read_nonblock_invalid_exception + with_pipe {|r, w| + assert_raise(ArgumentError) {r.read_nonblock(4096, exception: 1)} + } + end if have_nonblock? + def test_read_nonblock_no_exceptions skip '[ruby-core:90895] MJIT worker may leave fd open in a forked child' if RubyVM::MJIT.enabled? # TODO: consider acquiring GVL from MJIT worker. with_pipe {|r, w| @@ -1545,6 +1551,12 @@ def test_write_nonblock_error } end if have_nonblock? + def test_write_nonblock_invalid_exception + with_pipe {|r, w| + assert_raise(ArgumentError) {w.write_nonblock(4096, exception: 1)} + } + end if have_nonblock? + def test_write_nonblock_no_exceptions with_pipe {|r, w| loop { diff --git a/test/ruby/test_rational.rb b/test/ruby/test_rational.rb index a8cdf22a497e97..301890b6207f16 100644 --- a/test/ruby/test_rational.rb +++ b/test/ruby/test_rational.rb @@ -808,6 +808,12 @@ def test_parse_zero_denominator assert_raise(ZeroDivisionError) {Rational("1/0")} end + def test_Rational_with_invalid_exception + assert_raise(ArgumentError) { + Rational("1/1", exception: 1) + } + end + def test_Rational_without_exception assert_nothing_raised(ArgumentError) { assert_equal(nil, Rational("5/3x", exception: false)) From 4018eee4311a610dfaa2b2dca02c6f026b71eab7 Mon Sep 17 00:00:00 2001 From: git Date: Thu, 11 Jul 2019 20:14:57 +0900 Subject: [PATCH 010/452] * expand tabs. --- io.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/io.c b/io.c index 65da68e19a2907..3e3a0ed4489f42 100644 --- a/io.c +++ b/io.c @@ -2984,7 +2984,7 @@ io_read_nonblock(VALUE io, VALUE length, VALUE str, VALUE ex) io_set_read_length(str, n, shrinkable); if (n == 0) { - if (!ex) return Qnil; + if (!ex) return Qnil; rb_eof_error(); } @@ -3016,7 +3016,7 @@ io_write_nonblock(VALUE io, VALUE str, VALUE ex) if (n < 0) { int e = errno; if (e == EWOULDBLOCK || e == EAGAIN) { - if (!ex) { + if (!ex) { return sym_wait_writable; } else { @@ -12215,12 +12215,12 @@ argf_getpartial(int argc, VALUE *argv, VALUE argf, VALUE opts, int nonblock) } if (NIL_P(tmp)) { if (ARGF.next_p == -1) { - return io_nonblock_eof(no_exception); + return io_nonblock_eof(no_exception); } argf_close(argf); ARGF.next_p = 1; if (RARRAY_LEN(ARGF.argv) == 0) { - return io_nonblock_eof(no_exception); + return io_nonblock_eof(no_exception); } if (NIL_P(str)) str = rb_str_new(NULL, 0); From c2723e59c2a66a3d2fc8849b3b25c04c9333230a Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 11 Jul 2019 20:19:53 +0900 Subject: [PATCH 011/452] Removed wrong argument in the fallback function [Bug #15987] --- ext/bigdecimal/bigdecimal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c index 430707a4d64246..b9bdfd1462dc81 100644 --- a/ext/bigdecimal/bigdecimal.c +++ b/ext/bigdecimal/bigdecimal.c @@ -2578,7 +2578,7 @@ opts_exception_p(VALUE opts) break; default: rb_raise(rb_eArgError, "true or false is expected as exception: %+"PRIsVALUE, - flagname, obj); + obj); } return exception != Qfalse; } From f74e23af32525b5f2db1729586c930e2becdae30 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 11 Jul 2019 20:21:50 +0900 Subject: [PATCH 012/452] Fixed argument in the fallback function [Bug #15987] --- ext/bigdecimal/bigdecimal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c index b9bdfd1462dc81..b7b6ebb559f6ae 100644 --- a/ext/bigdecimal/bigdecimal.c +++ b/ext/bigdecimal/bigdecimal.c @@ -2578,7 +2578,7 @@ opts_exception_p(VALUE opts) break; default: rb_raise(rb_eArgError, "true or false is expected as exception: %+"PRIsVALUE, - obj); + exception); } return exception != Qfalse; } From 8745fa2ff0fbff67031bdecfdeea684b15515a2c Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 11 Jul 2019 21:05:25 +0900 Subject: [PATCH 013/452] Default to true when no exception flag [Bug #15987] --- ext/bigdecimal/bigdecimal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c index b7b6ebb559f6ae..652f341fb970a9 100644 --- a/ext/bigdecimal/bigdecimal.c +++ b/ext/bigdecimal/bigdecimal.c @@ -2572,7 +2572,7 @@ opts_exception_p(VALUE opts) if (!kwds[0]) { kwds[0] = rb_intern_const("exception"); } - rb_get_kwargs(opts, kwds, 0, 1, &exception); + if (!rb_get_kwargs(opts, kwds, 0, 1, &exception)) return 1; switch (exception) { case Qtrue: case Qfalse: break; From 012e954b472d2e47b03647ac0c8f745416d7db58 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Sun, 2 Jun 2019 13:48:47 +1200 Subject: [PATCH 014/452] Improved fiber benchmarks. Increase number of iterations. --- benchmark/fiber_chain.rb | 40 -------------------------------- benchmark/fiber_chain.yml | 36 ++++++++++++++++++++++++++++ benchmark/vm2_fiber_allocate.yml | 8 +++++++ benchmark/vm2_fiber_count.yml | 8 +++++++ benchmark/vm2_fiber_reuse.yml | 14 +++++++++++ benchmark/vm2_fiber_switch.yml | 2 +- bootstraptest/test_fiber.rb | 39 +++++++++++++++++++++++++++++++ bootstraptest/test_thread.rb | 21 ----------------- 8 files changed, 106 insertions(+), 62 deletions(-) delete mode 100755 benchmark/fiber_chain.rb create mode 100755 benchmark/fiber_chain.yml create mode 100644 benchmark/vm2_fiber_allocate.yml create mode 100644 benchmark/vm2_fiber_count.yml create mode 100644 benchmark/vm2_fiber_reuse.yml create mode 100644 bootstraptest/test_fiber.rb diff --git a/benchmark/fiber_chain.rb b/benchmark/fiber_chain.rb deleted file mode 100755 index 7e0a7f9d45cb4b..00000000000000 --- a/benchmark/fiber_chain.rb +++ /dev/null @@ -1,40 +0,0 @@ -# Check performance of fiber creation and transfer. - -def make_link(previous) - Fiber.new do - while message = previous.resume - Fiber.yield(message) - end - end -end - -def make_chain(length, &block) - chain = Fiber.new(&block) - - (length - 1).times do - chain = make_link(chain) - end - - return chain -end - -def run_benchmark(length, repeats, message = :hello) - chain = nil - - chain = make_chain(length) do - while true - Fiber.yield(message) - end - end - - repeats.times do - abort "invalid result" unless chain.resume == message - end -end - -n = (ARGV[0] || 1000).to_i -m = (ARGV[1] || 1000).to_i - -5.times do - run_benchmark(n, m) -end diff --git a/benchmark/fiber_chain.yml b/benchmark/fiber_chain.yml new file mode 100755 index 00000000000000..e526551da4762d --- /dev/null +++ b/benchmark/fiber_chain.yml @@ -0,0 +1,36 @@ +prelude: | + def make_link(previous) + Fiber.new do + while message = previous.resume + Fiber.yield(message) + end + end + end + + def make_chain(length = 1000, &block) + chain = Fiber.new(&block) + + (length - 1).times do + chain = make_link(chain) + end + + return chain + end + + message = "Hello World!" + + chain = make_chain do + while true + Fiber.yield(message) + end + end +benchmark: + make_chain: | + make_chain(100) do + while true + Fiber.yield(message) + end + end + resume_chain: | + chain.resume +loop_count: 5000 diff --git a/benchmark/vm2_fiber_allocate.yml b/benchmark/vm2_fiber_allocate.yml new file mode 100644 index 00000000000000..f29705f6942015 --- /dev/null +++ b/benchmark/vm2_fiber_allocate.yml @@ -0,0 +1,8 @@ +prelude: | + # Disable GC to see raw throughput: + GC.disable +benchmark: + vm2_fiber_allocate: | + fiber = Fiber.new{Fiber.yield} + fiber.resume +loop_count: 100000 diff --git a/benchmark/vm2_fiber_count.yml b/benchmark/vm2_fiber_count.yml new file mode 100644 index 00000000000000..2005772e8466cb --- /dev/null +++ b/benchmark/vm2_fiber_count.yml @@ -0,0 +1,8 @@ +prelude: | + fibers = [] +benchmark: + vm2_fiber_count: | + fiber = Fiber.new{Fiber.yield} + fibers << fiber + fiber.resume +loop_count: 100000 diff --git a/benchmark/vm2_fiber_reuse.yml b/benchmark/vm2_fiber_reuse.yml new file mode 100644 index 00000000000000..5dbdd5dfc517bd --- /dev/null +++ b/benchmark/vm2_fiber_reuse.yml @@ -0,0 +1,14 @@ +prelude: | + GC.disable + fibers = [] +benchmark: + vm2_fiber_reuse: | + 1024.times do + fiber = Fiber.new{Fiber.yield} + fibers << fiber + fiber.resume + end + + fibers.clear + GC.start +loop_count: 200 diff --git a/benchmark/vm2_fiber_switch.yml b/benchmark/vm2_fiber_switch.yml index f3e4c91283df37..fbf7283c298818 100644 --- a/benchmark/vm2_fiber_switch.yml +++ b/benchmark/vm2_fiber_switch.yml @@ -6,4 +6,4 @@ prelude: | benchmark: vm2_fiber_switch: | fib.resume -loop_count: 6000000 +loop_count: 20000000 diff --git a/bootstraptest/test_fiber.rb b/bootstraptest/test_fiber.rb new file mode 100644 index 00000000000000..35e1bf68515502 --- /dev/null +++ b/bootstraptest/test_fiber.rb @@ -0,0 +1,39 @@ +show_limit %q{ + fibers = [] + begin + fiber = Fiber.new{Fiber.yield} + fiber.resume + fibers << fiber + + raise Exception, "skipping" if fibers.count >= 10_000 + rescue Exception => error + puts "Fiber count: #{fibers.count} (#{error})" + break + end while true +} + +assert_equal %q{ok}, %q{ + Fiber.new{ + }.resume + :ok +} + +assert_equal %q{ok}, %q{ + 10_000.times.collect{Fiber.new{}} + :ok +} + +assert_equal %q{ok}, %q{ + fibers = 100.times.collect{Fiber.new{Fiber.yield}} + fibers.each(&:resume) + fibers.each(&:resume) + :ok +} + +assert_normal_exit %q{ + at_exit { Fiber.new{}.resume } +} + +assert_normal_exit %q{ + Fiber.new(&Object.method(:class_eval)).resume("foo") +}, '[ruby-dev:34128]' diff --git a/bootstraptest/test_thread.rb b/bootstraptest/test_thread.rb index 03fb441441a8e0..3ff55bab11159b 100644 --- a/bootstraptest/test_thread.rb +++ b/bootstraptest/test_thread.rb @@ -9,19 +9,6 @@ break end while true } -show_limit %q{ - fibers = [] - begin - fiber = Fiber.new{Fiber.yield} - fiber.resume - fibers << fiber - - raise Exception, "skipping" if fibers.count >= 10_000 - rescue Exception => error - puts "Fiber count: #{fibers.count} (#{error})" - break - end while true -} assert_equal %q{ok}, %q{ Thread.new{ }.join @@ -323,10 +310,6 @@ def m m }, '[ruby-dev:34492]' -assert_normal_exit %q{ - at_exit { Fiber.new{}.resume } -} - assert_normal_exit %q{ g = enum_for(:local_variables) loop { g.next } @@ -352,10 +335,6 @@ def m loop { g.next } }, '[ruby-dev:34128]' -assert_normal_exit %q{ - Fiber.new(&Object.method(:class_eval)).resume("foo") -}, '[ruby-dev:34128]' - assert_normal_exit %q{ Thread.new("foo", &Object.method(:class_eval)).join }, '[ruby-dev:34128]' From 5c8061a9e2a34df975846d724273cb5be7d74a7c Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Sun, 7 Jul 2019 22:58:55 +1200 Subject: [PATCH 015/452] Make `stack_check` slightly easier to use in debugger. --- gc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gc.c b/gc.c index 4e1e4ee9d67a9c..a5e11f8032f87e 100644 --- a/gc.c +++ b/gc.c @@ -4385,11 +4385,12 @@ ruby_stack_length(VALUE **p) static int stack_check(rb_execution_context_t *ec, int water_mark) { - int ret; SET_STACK_END; - ret = STACK_LENGTH > STACK_LEVEL_MAX - water_mark; - return ret; + size_t length = STACK_LENGTH; + size_t maximum_length = STACK_LEVEL_MAX - water_mark; + + return length > maximum_length; } #else #define stack_check(ec, water_mark) FALSE From a2adcd40df96acd1218cc60dc1810e83dbc124d8 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Mon, 3 Jun 2019 21:35:03 +1200 Subject: [PATCH 016/452] Add note about `STACK_GROW_DIR_DETECTION`. --- gc.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gc.h b/gc.h index f3b433f0c4e5fa..07c08577e83c44 100644 --- a/gc.h +++ b/gc.h @@ -81,6 +81,14 @@ int ruby_get_stack_grow_direction(volatile VALUE *addr); # define STACK_UPPER(x, a, b) (stack_growup_p(x) ? (a) : (b)) #endif +/* + STACK_GROW_DIR_DETECTION is used with STACK_DIR_UPPER. + + On most normal systems, stacks grow from high address to lower address. In + this case, STACK_DIR_UPPER(a, b) will return (b), but on exotic systems where + the stack grows UP (from low address to high address), it will return (a). +*/ + #if STACK_GROW_DIRECTION #define STACK_GROW_DIR_DETECTION #define STACK_DIR_UPPER(a,b) STACK_UPPER(0, (a), (b)) From b9ad62ea13bfaf0cad2ffc48d724b342ee55c7c8 Mon Sep 17 00:00:00 2001 From: git Date: Fri, 12 Jul 2019 15:02:25 +0900 Subject: [PATCH 017/452] * remove trailing spaces. --- gc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gc.h b/gc.h index 07c08577e83c44..018ad0e6250f7a 100644 --- a/gc.h +++ b/gc.h @@ -83,7 +83,7 @@ int ruby_get_stack_grow_direction(volatile VALUE *addr); /* STACK_GROW_DIR_DETECTION is used with STACK_DIR_UPPER. - + On most normal systems, stacks grow from high address to lower address. In this case, STACK_DIR_UPPER(a, b) will return (b), but on exotic systems where the stack grows UP (from low address to high address), it will return (a). From a9ff21a282845f81527b18607d246be90ea6701e Mon Sep 17 00:00:00 2001 From: git Date: Fri, 12 Jul 2019 15:02:29 +0900 Subject: [PATCH 018/452] * 2019-07-12 --- version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.h b/version.h index f8a9d734049469..b983a367ae2f5b 100644 --- a/version.h +++ b/version.h @@ -6,7 +6,7 @@ #define RUBY_RELEASE_YEAR 2019 #define RUBY_RELEASE_MONTH 7 -#define RUBY_RELEASE_DAY 11 +#define RUBY_RELEASE_DAY 12 #include "ruby/version.h" From 00b34b05921da35a97d78d17133ff94abd0ae22b Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 12 Jul 2019 17:52:12 +0900 Subject: [PATCH 019/452] Fixed duplicate test name --- test/ruby/test_integer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/ruby/test_integer.rb b/test/ruby/test_integer.rb index 84730b2a5d0fee..9a4f560ed5d16c 100644 --- a/test/ruby/test_integer.rb +++ b/test/ruby/test_integer.rb @@ -192,7 +192,7 @@ def to_int; raise "conversion failed"; end end; end - def test_Integer_with_exception_keyword + def test_Integer_with_invalid_exception assert_raise(ArgumentError) { Integer("0", exception: 1) } From ae599db22fa46d3c04329e09294ff0a31d7ebfbb Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 12 Jul 2019 17:57:28 +0900 Subject: [PATCH 020/452] * remove trailing spaces. --- benchmark/fiber_chain.yml | 4 ++-- benchmark/vm2_fiber_reuse.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/benchmark/fiber_chain.yml b/benchmark/fiber_chain.yml index e526551da4762d..a36c759f8efa8e 100755 --- a/benchmark/fiber_chain.yml +++ b/benchmark/fiber_chain.yml @@ -16,9 +16,9 @@ prelude: | return chain end - + message = "Hello World!" - + chain = make_chain do while true Fiber.yield(message) diff --git a/benchmark/vm2_fiber_reuse.yml b/benchmark/vm2_fiber_reuse.yml index 5dbdd5dfc517bd..017065063800ca 100644 --- a/benchmark/vm2_fiber_reuse.yml +++ b/benchmark/vm2_fiber_reuse.yml @@ -8,7 +8,7 @@ benchmark: fibers << fiber fiber.resume end - + fibers.clear GC.start loop_count: 200 From 1ee17782e108222d07a1c6b58cf1c7521d188b32 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 10 Jul 2019 17:15:18 +0900 Subject: [PATCH 021/452] Removed binary line --- ext/json/json.gemspec | Bin 5421 -> 5300 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/ext/json/json.gemspec b/ext/json/json.gemspec index 470330f203c68eae6159e6a5c303f0361b897ed0..d8a0dc5e92448e43b70257b974a7c498a3aaa5d8 100644 GIT binary patch delta 10 RcmZ3hwMBD+)W*rPL;x791W^D0 delta 82 zcmdm@xmIg}l!~%KaY<>Cl|oi=ex8Dno{^q`LQ!c_r9w_-5*JKv@_%OW$$Oc(7#Svi dWRw$ONUbQ*2dUQwGLrN2()5awHcHMG0RTVn8sY!| From 10d7419eb43969de209c1bbcd56b052679cfa8d1 Mon Sep 17 00:00:00 2001 From: git Date: Sat, 13 Jul 2019 06:10:07 +0900 Subject: [PATCH 022/452] * 2019-07-13 --- version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.h b/version.h index b983a367ae2f5b..4d0dd833d43a96 100644 --- a/version.h +++ b/version.h @@ -6,7 +6,7 @@ #define RUBY_RELEASE_YEAR 2019 #define RUBY_RELEASE_MONTH 7 -#define RUBY_RELEASE_DAY 12 +#define RUBY_RELEASE_DAY 13 #include "ruby/version.h" From cbe623f1c787ff2117045c7c4f03a294dfdb9370 Mon Sep 17 00:00:00 2001 From: Masatoshi SEKI Date: Sat, 13 Jul 2019 07:22:55 +0900 Subject: [PATCH 023/452] change default value of load_limit (ignore load_limit) --- lib/drb/drb.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/drb/drb.rb b/lib/drb/drb.rb index de57362f24211a..caffd5df25da82 100644 --- a/lib/drb/drb.rb +++ b/lib/drb/drb.rb @@ -1279,7 +1279,7 @@ class DRbServer @@idconv = DRbIdConv.new @@secondary_server = nil @@argc_limit = 256 - @@load_limit = 256 * 102400 + @@load_limit = 0xffffffff @@verbose = false @@safe_level = 0 From 143581cf4e8dec363b9636fdcd215153d94673c5 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 12 Jul 2019 07:23:00 +0900 Subject: [PATCH 024/452] Removed stub lines from gemspec files --- ext/openssl/openssl.gemspec | 2 -- ext/stringio/stringio.gemspec | 2 -- lib/racc/racc.gemspec | 2 -- 3 files changed, 6 deletions(-) diff --git a/ext/openssl/openssl.gemspec b/ext/openssl/openssl.gemspec index e29cfcd709cf9a..720cb7fe33573e 100644 --- a/ext/openssl/openssl.gemspec +++ b/ext/openssl/openssl.gemspec @@ -1,6 +1,4 @@ # -*- encoding: utf-8 -*- -# stub: openssl 2.1.2 ruby lib -# stub: ext/openssl/extconf.rb Gem::Specification.new do |s| s.name = "openssl".freeze diff --git a/ext/stringio/stringio.gemspec b/ext/stringio/stringio.gemspec index 77c9e79b7e9d6d..75fe8b9d76239c 100644 --- a/ext/stringio/stringio.gemspec +++ b/ext/stringio/stringio.gemspec @@ -1,7 +1,5 @@ # -*- encoding: utf-8 -*- # frozen_string_literal: true -# stub: stringio 0.0.0 ruby lib -# stub: extconf.rb source_version = ["", "ext/stringio/"].find do |dir| begin diff --git a/lib/racc/racc.gemspec b/lib/racc/racc.gemspec index ae18fc16b1dcba..73496269b3e1b9 100644 --- a/lib/racc/racc.gemspec +++ b/lib/racc/racc.gemspec @@ -1,6 +1,4 @@ # -*- encoding: utf-8 -*- -# stub: racc 1.4.16.pre.1 ruby lib -# stub: ext/racc/extconf.rb Gem::Specification.new do |s| s.name = "racc".freeze From fd9f26df005824f5b1f1f41adaf63f2ff57062a7 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 10 Jul 2019 17:16:01 +0900 Subject: [PATCH 025/452] Drop fossil rubygems support --- ext/json/json.gemspec | 16 ++-------------- ext/openssl/openssl.gemspec | 28 +++++----------------------- lib/racc/racc.gemspec | 24 ++++-------------------- 3 files changed, 11 insertions(+), 57 deletions(-) diff --git a/ext/json/json.gemspec b/ext/json/json.gemspec index d8a0dc5e92448e..f1d1d1c96df0bf 100644 --- a/ext/json/json.gemspec +++ b/ext/json/json.gemspec @@ -21,18 +21,6 @@ Gem::Specification.new do |s| s.summary = "JSON Implementation for Ruby".freeze s.test_files = ["./tests/test_helper.rb".freeze] - if s.respond_to? :specification_version then - s.specification_version = 4 - - if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then - s.add_development_dependency(%q.freeze, [">= 0"]) - s.add_development_dependency(%q.freeze, ["~> 2.0"]) - else - s.add_dependency(%q.freeze, [">= 0"]) - s.add_dependency(%q.freeze, ["~> 2.0"]) - end - else - s.add_dependency(%q.freeze, [">= 0"]) - s.add_dependency(%q.freeze, ["~> 2.0"]) - end + s.add_development_dependency(%q.freeze, [">= 0"]) + s.add_development_dependency(%q.freeze, ["~> 2.0"]) end diff --git a/ext/openssl/openssl.gemspec b/ext/openssl/openssl.gemspec index 720cb7fe33573e..47e6c18bfb2c42 100644 --- a/ext/openssl/openssl.gemspec +++ b/ext/openssl/openssl.gemspec @@ -21,27 +21,9 @@ Gem::Specification.new do |s| s.rubygems_version = "3.0.0.beta1".freeze s.summary = "OpenSSL provides SSL, TLS and general purpose cryptography.".freeze - if s.respond_to? :specification_version then - s.specification_version = 4 - - if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then - s.add_runtime_dependency(%q.freeze, [">= 0"]) - s.add_development_dependency(%q.freeze, [">= 0"]) - s.add_development_dependency(%q.freeze, [">= 0"]) - s.add_development_dependency(%q.freeze, ["~> 3.0"]) - s.add_development_dependency(%q.freeze, [">= 0"]) - else - s.add_dependency(%q.freeze, [">= 0"]) - s.add_dependency(%q.freeze, [">= 0"]) - s.add_dependency(%q.freeze, [">= 0"]) - s.add_dependency(%q.freeze, ["~> 3.0"]) - s.add_dependency(%q.freeze, [">= 0"]) - end - else - s.add_dependency(%q.freeze, [">= 0"]) - s.add_dependency(%q.freeze, [">= 0"]) - s.add_dependency(%q.freeze, [">= 0"]) - s.add_dependency(%q.freeze, ["~> 3.0"]) - s.add_dependency(%q.freeze, [">= 0"]) - end + s.add_runtime_dependency(%q.freeze, [">= 0"]) + s.add_development_dependency(%q.freeze, [">= 0"]) + s.add_development_dependency(%q.freeze, [">= 0"]) + s.add_development_dependency(%q.freeze, ["~> 3.0"]) + s.add_development_dependency(%q.freeze, [">= 0"]) end diff --git a/lib/racc/racc.gemspec b/lib/racc/racc.gemspec index 73496269b3e1b9..23f11851f85746 100644 --- a/lib/racc/racc.gemspec +++ b/lib/racc/racc.gemspec @@ -20,24 +20,8 @@ Gem::Specification.new do |s| s.rubygems_version = "3.1.0.pre1".freeze s.summary = "Racc is a LALR(1) parser generator".freeze - if s.respond_to? :specification_version then - s.specification_version = 4 - - if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then - s.add_development_dependency(%q.freeze, [">= 0.4.1"]) - s.add_development_dependency(%q.freeze, ["~> 4.7"]) - s.add_development_dependency(%q.freeze, [">= 4.0", "< 7"]) - s.add_development_dependency(%q.freeze, ["~> 3.18"]) - else - s.add_dependency(%q.freeze, [">= 0.4.1"]) - s.add_dependency(%q.freeze, ["~> 4.7"]) - s.add_dependency(%q.freeze, [">= 4.0", "< 7"]) - s.add_dependency(%q.freeze, ["~> 3.18"]) - end - else - s.add_dependency(%q.freeze, [">= 0.4.1"]) - s.add_dependency(%q.freeze, ["~> 4.7"]) - s.add_dependency(%q.freeze, [">= 4.0", "< 7"]) - s.add_dependency(%q.freeze, ["~> 3.18"]) - end + s.add_development_dependency(%q.freeze, [">= 0.4.1"]) + s.add_development_dependency(%q.freeze, ["~> 4.7"]) + s.add_development_dependency(%q.freeze, [">= 4.0", "< 7"]) + s.add_development_dependency(%q.freeze, ["~> 3.18"]) end From 331eccf3fea016f074f08f8215a9120e0a30468c Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 12 Jul 2019 07:25:06 +0900 Subject: [PATCH 026/452] Removed useless `freeze`s from gemspec files --- ext/bigdecimal/bigdecimal.gemspec | 2 +- ext/json/json.gemspec | 36 ++++++++++++++-------------- ext/openssl/openssl.gemspec | 40 +++++++++++++++---------------- lib/racc/racc.gemspec | 38 ++++++++++++++--------------- 4 files changed, 58 insertions(+), 58 deletions(-) diff --git a/ext/bigdecimal/bigdecimal.gemspec b/ext/bigdecimal/bigdecimal.gemspec index c7a27fe1c37697..c483cfb43ce6a6 100644 --- a/ext/bigdecimal/bigdecimal.gemspec +++ b/ext/bigdecimal/bigdecimal.gemspec @@ -35,7 +35,7 @@ Gem::Specification.new do |s| sample/pi.rb ] - s.required_ruby_version = Gem::Requirement.new(">= 2.3.0".freeze) + s.required_ruby_version = Gem::Requirement.new(">= 2.3.0") s.add_development_dependency "rake", "~> 10.0" s.add_development_dependency "rake-compiler", ">= 0.9" diff --git a/ext/json/json.gemspec b/ext/json/json.gemspec index f1d1d1c96df0bf..1cb236d2bcca9e 100644 --- a/ext/json/json.gemspec +++ b/ext/json/json.gemspec @@ -1,26 +1,26 @@ # -*- encoding: utf-8 -*- Gem::Specification.new do |s| - s.name = "json".freeze + s.name = "json" s.version = "2.2.0" - s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version= - s.require_paths = ["lib".freeze] - s.authors = ["Florian Frank".freeze] + s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= + s.require_paths = ["lib"] + s.authors = ["Florian Frank"] s.date = "2019-02-21" - s.description = "This is a JSON implementation as a Ruby extension in C.".freeze - s.email = "flori@ping.de".freeze - s.extensions = ["ext/json/ext/generator/extconf.rb".freeze, "ext/json/ext/parser/extconf.rb".freeze, "ext/json/extconf.rb".freeze] - s.extra_rdoc_files = ["README.md".freeze] - s.files = ["./tests/test_helper.rb".freeze, ".gitignore".freeze, ".travis.yml".freeze, "CHANGES.md".freeze, "Gemfile".freeze, "README-json-jruby.md".freeze, "README.md".freeze, "Rakefile".freeze, "VERSION".freeze, "diagrams/.keep".freeze, "ext/json/ext/fbuffer/fbuffer.h".freeze, "ext/json/ext/generator/depend".freeze, "ext/json/ext/generator/extconf.rb".freeze, "ext/json/ext/generator/generator.c".freeze, "ext/json/ext/generator/generator.h".freeze, "ext/json/ext/parser/depend".freeze, "ext/json/ext/parser/extconf.rb".freeze, "ext/json/ext/parser/parser.c".freeze, "ext/json/ext/parser/parser.h".freeze, "ext/json/ext/parser/parser.rl".freeze, "ext/json/extconf.rb".freeze, "install.rb".freeze, "java/src/json/ext/ByteListTranscoder.java".freeze, "java/src/json/ext/Generator.java".freeze, "java/src/json/ext/GeneratorMethods.java".freeze, "java/src/json/ext/GeneratorService.java".freeze, "java/src/json/ext/GeneratorState.java".freeze, "java/src/json/ext/OptionsReader.java".freeze, "java/src/json/ext/Parser.java".freeze, "java/src/json/ext/Parser.rl".freeze, "java/src/json/ext/ParserService.java".freeze, "java/src/json/ext/RuntimeInfo.java".freeze, "java/src/json/ext/StringDecoder.java".freeze, "java/src/json/ext/StringEncoder.java".freeze, "java/src/json/ext/Utils.java".freeze, "json-java.gemspec".freeze, "json.gemspec".freeze, "json_pure.gemspec".freeze, "lib/json.rb".freeze, "lib/json/add/bigdecimal.rb".freeze, "lib/json/add/complex.rb".freeze, "lib/json/add/core.rb".freeze, "lib/json/add/date.rb".freeze, "lib/json/add/date_time.rb".freeze, "lib/json/add/exception.rb".freeze, "lib/json/add/ostruct.rb".freeze, "lib/json/add/range.rb".freeze, "lib/json/add/rational.rb".freeze, "lib/json/add/regexp.rb".freeze, "lib/json/add/set.rb".freeze, "lib/json/add/struct.rb".freeze, "lib/json/add/symbol.rb".freeze, "lib/json/add/time.rb".freeze, "lib/json/common.rb".freeze, "lib/json/ext.rb".freeze, "lib/json/ext/.keep".freeze, "lib/json/generic_object.rb".freeze, "lib/json/pure.rb".freeze, "lib/json/pure/generator.rb".freeze, "lib/json/pure/parser.rb".freeze, "lib/json/version.rb".freeze, "references/rfc7159.txt".freeze, "tests/fixtures/fail10.json".freeze, "tests/fixtures/fail11.json".freeze, "tests/fixtures/fail12.json".freeze, "tests/fixtures/fail13.json".freeze, "tests/fixtures/fail14.json".freeze, "tests/fixtures/fail18.json".freeze, "tests/fixtures/fail19.json".freeze, "tests/fixtures/fail2.json".freeze, "tests/fixtures/fail20.json".freeze, "tests/fixtures/fail21.json".freeze, "tests/fixtures/fail22.json".freeze, "tests/fixtures/fail23.json".freeze, "tests/fixtures/fail24.json".freeze, "tests/fixtures/fail25.json".freeze, "tests/fixtures/fail27.json".freeze, "tests/fixtures/fail28.json".freeze, "tests/fixtures/fail3.json".freeze, "tests/fixtures/fail4.json".freeze, "tests/fixtures/fail5.json".freeze, "tests/fixtures/fail6.json".freeze, "tests/fixtures/fail7.json".freeze, "tests/fixtures/fail8.json".freeze, "tests/fixtures/fail9.json".freeze, "tests/fixtures/obsolete_fail1.json".freeze, "tests/fixtures/pass1.json".freeze, "tests/fixtures/pass15.json".freeze, "tests/fixtures/pass16.json".freeze, "tests/fixtures/pass17.json".freeze, "tests/fixtures/pass2.json".freeze, "tests/fixtures/pass26.json".freeze, "tests/fixtures/pass3.json".freeze, "tests/json_addition_test.rb".freeze, "tests/json_common_interface_test.rb".freeze, "tests/json_encoding_test.rb".freeze, "tests/json_ext_parser_test.rb".freeze, "tests/json_fixtures_test.rb".freeze, "tests/json_generator_test.rb".freeze, "tests/json_generic_object_test.rb".freeze, "tests/json_parser_test.rb".freeze, "tests/json_string_matching_test.rb".freeze, "tests/test_helper.rb".freeze, "tools/diff.sh".freeze, "tools/fuzz.rb".freeze, "tools/server.rb".freeze] - s.homepage = "http://flori.github.com/json".freeze - s.licenses = ["Ruby".freeze] - s.rdoc_options = ["--title".freeze, "JSON implemention for Ruby".freeze, "--main".freeze, "README.md".freeze] - s.required_ruby_version = Gem::Requirement.new(">= 1.9".freeze) - s.rubygems_version = "3.0.2".freeze - s.summary = "JSON Implementation for Ruby".freeze - s.test_files = ["./tests/test_helper.rb".freeze] + s.description = "This is a JSON implementation as a Ruby extension in C." + s.email = "flori@ping.de" + s.extensions = ["ext/json/ext/generator/extconf.rb", "ext/json/ext/parser/extconf.rb", "ext/json/extconf.rb"] + s.extra_rdoc_files = ["README.md"] + s.files = ["./tests/test_helper.rb", ".gitignore", ".travis.yml", "CHANGES.md", "Gemfile", "README-json-jruby.md", "README.md", "Rakefile", "VERSION", "diagrams/.keep", "ext/json/ext/fbuffer/fbuffer.h", "ext/json/ext/generator/depend", "ext/json/ext/generator/extconf.rb", "ext/json/ext/generator/generator.c", "ext/json/ext/generator/generator.h", "ext/json/ext/parser/depend", "ext/json/ext/parser/extconf.rb", "ext/json/ext/parser/parser.c", "ext/json/ext/parser/parser.h", "ext/json/ext/parser/parser.rl", "ext/json/extconf.rb", "install.rb", "java/src/json/ext/ByteListTranscoder.java", "java/src/json/ext/Generator.java", "java/src/json/ext/GeneratorMethods.java", "java/src/json/ext/GeneratorService.java", "java/src/json/ext/GeneratorState.java", "java/src/json/ext/OptionsReader.java", "java/src/json/ext/Parser.java", "java/src/json/ext/Parser.rl", "java/src/json/ext/ParserService.java", "java/src/json/ext/RuntimeInfo.java", "java/src/json/ext/StringDecoder.java", "java/src/json/ext/StringEncoder.java", "java/src/json/ext/Utils.java", "json-java.gemspec", "json.gemspec", "json_pure.gemspec", "lib/json.rb", "lib/json/add/bigdecimal.rb", "lib/json/add/complex.rb", "lib/json/add/core.rb", "lib/json/add/date.rb", "lib/json/add/date_time.rb", "lib/json/add/exception.rb", "lib/json/add/ostruct.rb", "lib/json/add/range.rb", "lib/json/add/rational.rb", "lib/json/add/regexp.rb", "lib/json/add/set.rb", "lib/json/add/struct.rb", "lib/json/add/symbol.rb", "lib/json/add/time.rb", "lib/json/common.rb", "lib/json/ext.rb", "lib/json/ext/.keep", "lib/json/generic_object.rb", "lib/json/pure.rb", "lib/json/pure/generator.rb", "lib/json/pure/parser.rb", "lib/json/version.rb", "references/rfc7159.txt", "tests/fixtures/fail10.json", "tests/fixtures/fail11.json", "tests/fixtures/fail12.json", "tests/fixtures/fail13.json", "tests/fixtures/fail14.json", "tests/fixtures/fail18.json", "tests/fixtures/fail19.json", "tests/fixtures/fail2.json", "tests/fixtures/fail20.json", "tests/fixtures/fail21.json", "tests/fixtures/fail22.json", "tests/fixtures/fail23.json", "tests/fixtures/fail24.json", "tests/fixtures/fail25.json", "tests/fixtures/fail27.json", "tests/fixtures/fail28.json", "tests/fixtures/fail3.json", "tests/fixtures/fail4.json", "tests/fixtures/fail5.json", "tests/fixtures/fail6.json", "tests/fixtures/fail7.json", "tests/fixtures/fail8.json", "tests/fixtures/fail9.json", "tests/fixtures/obsolete_fail1.json", "tests/fixtures/pass1.json", "tests/fixtures/pass15.json", "tests/fixtures/pass16.json", "tests/fixtures/pass17.json", "tests/fixtures/pass2.json", "tests/fixtures/pass26.json", "tests/fixtures/pass3.json", "tests/json_addition_test.rb", "tests/json_common_interface_test.rb", "tests/json_encoding_test.rb", "tests/json_ext_parser_test.rb", "tests/json_fixtures_test.rb", "tests/json_generator_test.rb", "tests/json_generic_object_test.rb", "tests/json_parser_test.rb", "tests/json_string_matching_test.rb", "tests/test_helper.rb", "tools/diff.sh", "tools/fuzz.rb", "tools/server.rb"] + s.homepage = "http://flori.github.com/json" + s.licenses = ["Ruby"] + s.rdoc_options = ["--title", "JSON implemention for Ruby", "--main", "README.md"] + s.required_ruby_version = Gem::Requirement.new(">= 1.9") + s.rubygems_version = "3.0.2" + s.summary = "JSON Implementation for Ruby" + s.test_files = ["./tests/test_helper.rb"] - s.add_development_dependency(%q.freeze, [">= 0"]) - s.add_development_dependency(%q.freeze, ["~> 2.0"]) + s.add_development_dependency("rake", [">= 0"]) + s.add_development_dependency("test-unit", ["~> 2.0"]) end diff --git a/ext/openssl/openssl.gemspec b/ext/openssl/openssl.gemspec index 47e6c18bfb2c42..295379fb6c3cfa 100644 --- a/ext/openssl/openssl.gemspec +++ b/ext/openssl/openssl.gemspec @@ -1,29 +1,29 @@ # -*- encoding: utf-8 -*- Gem::Specification.new do |s| - s.name = "openssl".freeze + s.name = "openssl" s.version = "2.1.2" - s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version= + s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.metadata = { "msys2_mingw_dependencies" => "openssl" } if s.respond_to? :metadata= - s.require_paths = ["lib".freeze] - s.authors = ["Martin Bosslet".freeze, "SHIBATA Hiroshi".freeze, "Zachary Scott".freeze, "Kazuki Yamaguchi".freeze] + s.require_paths = ["lib"] + s.authors = ["Martin Bosslet", "SHIBATA Hiroshi", "Zachary Scott", "Kazuki Yamaguchi"] s.date = "2018-10-17" - s.description = "It wraps the OpenSSL library.".freeze - s.email = ["ruby-core@ruby-lang.org".freeze] - s.extensions = ["ext/openssl/extconf.rb".freeze] - s.extra_rdoc_files = ["README.md".freeze, "CONTRIBUTING.md".freeze, "History.md".freeze] - s.files = ["BSDL".freeze, "CONTRIBUTING.md".freeze, "History.md".freeze, "LICENSE.txt".freeze, "README.md".freeze, "ext/openssl/deprecation.rb".freeze, "ext/openssl/extconf.rb".freeze, "ext/openssl/openssl_missing.c".freeze, "ext/openssl/openssl_missing.h".freeze, "ext/openssl/ossl.c".freeze, "ext/openssl/ossl.h".freeze, "ext/openssl/ossl_asn1.c".freeze, "ext/openssl/ossl_asn1.h".freeze, "ext/openssl/ossl_bio.c".freeze, "ext/openssl/ossl_bio.h".freeze, "ext/openssl/ossl_bn.c".freeze, "ext/openssl/ossl_bn.h".freeze, "ext/openssl/ossl_cipher.c".freeze, "ext/openssl/ossl_cipher.h".freeze, "ext/openssl/ossl_config.c".freeze, "ext/openssl/ossl_config.h".freeze, "ext/openssl/ossl_digest.c".freeze, "ext/openssl/ossl_digest.h".freeze, "ext/openssl/ossl_engine.c".freeze, "ext/openssl/ossl_engine.h".freeze, "ext/openssl/ossl_hmac.c".freeze, "ext/openssl/ossl_hmac.h".freeze, "ext/openssl/ossl_kdf.c".freeze, "ext/openssl/ossl_kdf.h".freeze, "ext/openssl/ossl_ns_spki.c".freeze, "ext/openssl/ossl_ns_spki.h".freeze, "ext/openssl/ossl_ocsp.c".freeze, "ext/openssl/ossl_ocsp.h".freeze, "ext/openssl/ossl_pkcs12.c".freeze, "ext/openssl/ossl_pkcs12.h".freeze, "ext/openssl/ossl_pkcs7.c".freeze, "ext/openssl/ossl_pkcs7.h".freeze, "ext/openssl/ossl_pkey.c".freeze, "ext/openssl/ossl_pkey.h".freeze, "ext/openssl/ossl_pkey_dh.c".freeze, "ext/openssl/ossl_pkey_dsa.c".freeze, "ext/openssl/ossl_pkey_ec.c".freeze, "ext/openssl/ossl_pkey_rsa.c".freeze, "ext/openssl/ossl_rand.c".freeze, "ext/openssl/ossl_rand.h".freeze, "ext/openssl/ossl_ssl.c".freeze, "ext/openssl/ossl_ssl.h".freeze, "ext/openssl/ossl_ssl_session.c".freeze, "ext/openssl/ossl_version.h".freeze, "ext/openssl/ossl_x509.c".freeze, "ext/openssl/ossl_x509.h".freeze, "ext/openssl/ossl_x509attr.c".freeze, "ext/openssl/ossl_x509cert.c".freeze, "ext/openssl/ossl_x509crl.c".freeze, "ext/openssl/ossl_x509ext.c".freeze, "ext/openssl/ossl_x509name.c".freeze, "ext/openssl/ossl_x509req.c".freeze, "ext/openssl/ossl_x509revoked.c".freeze, "ext/openssl/ossl_x509store.c".freeze, "ext/openssl/ruby_missing.h".freeze, "lib/openssl.rb".freeze, "lib/openssl/bn.rb".freeze, "lib/openssl/buffering.rb".freeze, "lib/openssl/cipher.rb".freeze, "lib/openssl/config.rb".freeze, "lib/openssl/digest.rb".freeze, "lib/openssl/pkcs5.rb".freeze, "lib/openssl/pkey.rb".freeze, "lib/openssl/ssl.rb".freeze, "lib/openssl/x509.rb".freeze] - s.homepage = "https://github.com/ruby/openssl".freeze - s.licenses = ["Ruby".freeze] - s.rdoc_options = ["--main".freeze, "README.md".freeze] - s.required_ruby_version = Gem::Requirement.new(">= 2.3.0".freeze) - s.rubygems_version = "3.0.0.beta1".freeze - s.summary = "OpenSSL provides SSL, TLS and general purpose cryptography.".freeze + s.description = "It wraps the OpenSSL library." + s.email = ["ruby-core@ruby-lang.org"] + s.extensions = ["ext/openssl/extconf.rb"] + s.extra_rdoc_files = ["README.md", "CONTRIBUTING.md", "History.md"] + s.files = ["BSDL", "CONTRIBUTING.md", "History.md", "LICENSE.txt", "README.md", "ext/openssl/deprecation.rb", "ext/openssl/extconf.rb", "ext/openssl/openssl_missing.c", "ext/openssl/openssl_missing.h", "ext/openssl/ossl.c", "ext/openssl/ossl.h", "ext/openssl/ossl_asn1.c", "ext/openssl/ossl_asn1.h", "ext/openssl/ossl_bio.c", "ext/openssl/ossl_bio.h", "ext/openssl/ossl_bn.c", "ext/openssl/ossl_bn.h", "ext/openssl/ossl_cipher.c", "ext/openssl/ossl_cipher.h", "ext/openssl/ossl_config.c", "ext/openssl/ossl_config.h", "ext/openssl/ossl_digest.c", "ext/openssl/ossl_digest.h", "ext/openssl/ossl_engine.c", "ext/openssl/ossl_engine.h", "ext/openssl/ossl_hmac.c", "ext/openssl/ossl_hmac.h", "ext/openssl/ossl_kdf.c", "ext/openssl/ossl_kdf.h", "ext/openssl/ossl_ns_spki.c", "ext/openssl/ossl_ns_spki.h", "ext/openssl/ossl_ocsp.c", "ext/openssl/ossl_ocsp.h", "ext/openssl/ossl_pkcs12.c", "ext/openssl/ossl_pkcs12.h", "ext/openssl/ossl_pkcs7.c", "ext/openssl/ossl_pkcs7.h", "ext/openssl/ossl_pkey.c", "ext/openssl/ossl_pkey.h", "ext/openssl/ossl_pkey_dh.c", "ext/openssl/ossl_pkey_dsa.c", "ext/openssl/ossl_pkey_ec.c", "ext/openssl/ossl_pkey_rsa.c", "ext/openssl/ossl_rand.c", "ext/openssl/ossl_rand.h", "ext/openssl/ossl_ssl.c", "ext/openssl/ossl_ssl.h", "ext/openssl/ossl_ssl_session.c", "ext/openssl/ossl_version.h", "ext/openssl/ossl_x509.c", "ext/openssl/ossl_x509.h", "ext/openssl/ossl_x509attr.c", "ext/openssl/ossl_x509cert.c", "ext/openssl/ossl_x509crl.c", "ext/openssl/ossl_x509ext.c", "ext/openssl/ossl_x509name.c", "ext/openssl/ossl_x509req.c", "ext/openssl/ossl_x509revoked.c", "ext/openssl/ossl_x509store.c", "ext/openssl/ruby_missing.h", "lib/openssl.rb", "lib/openssl/bn.rb", "lib/openssl/buffering.rb", "lib/openssl/cipher.rb", "lib/openssl/config.rb", "lib/openssl/digest.rb", "lib/openssl/pkcs5.rb", "lib/openssl/pkey.rb", "lib/openssl/ssl.rb", "lib/openssl/x509.rb"] + s.homepage = "https://github.com/ruby/openssl" + s.licenses = ["Ruby"] + s.rdoc_options = ["--main", "README.md"] + s.required_ruby_version = Gem::Requirement.new(">= 2.3.0") + s.rubygems_version = "3.0.0.beta1" + s.summary = "OpenSSL provides SSL, TLS and general purpose cryptography." - s.add_runtime_dependency(%q.freeze, [">= 0"]) - s.add_development_dependency(%q.freeze, [">= 0"]) - s.add_development_dependency(%q.freeze, [">= 0"]) - s.add_development_dependency(%q.freeze, ["~> 3.0"]) - s.add_development_dependency(%q.freeze, [">= 0"]) + s.add_runtime_dependency("ipaddr", [">= 0"]) + s.add_development_dependency("rake", [">= 0"]) + s.add_development_dependency("rake-compiler", [">= 0"]) + s.add_development_dependency("test-unit", ["~> 3.0"]) + s.add_development_dependency("rdoc", [">= 0"]) end diff --git a/lib/racc/racc.gemspec b/lib/racc/racc.gemspec index 23f11851f85746..8e8a0b8bae7ae2 100644 --- a/lib/racc/racc.gemspec +++ b/lib/racc/racc.gemspec @@ -1,27 +1,27 @@ # -*- encoding: utf-8 -*- Gem::Specification.new do |s| - s.name = "racc".freeze + s.name = "racc" s.version = "1.4.16.pre.1" - s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version= - s.require_paths = ["lib".freeze] - s.authors = ["Aaron Patterson".freeze] + 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 = "2019-06-20" - s.description = "Racc is a LALR(1) parser generator.\n It is written in Ruby itself, and generates Ruby program.\n\n NOTE: Ruby 1.8.x comes with Racc runtime module. You\n can run your parsers generated by racc 1.4.x out of the\n box.".freeze - s.email = ["aaron@tenderlovemaking.com".freeze] - s.executables = ["racc".freeze, "racc2y".freeze, "y2racc".freeze] - s.extensions = ["ext/racc/extconf.rb".freeze] - s.extra_rdoc_files = ["Manifest.txt".freeze, "README.ja.rdoc".freeze, "README.rdoc".freeze, "rdoc/en/NEWS.en.rdoc".freeze, "rdoc/en/grammar.en.rdoc".freeze, "rdoc/ja/NEWS.ja.rdoc".freeze, "rdoc/ja/debug.ja.rdoc".freeze, "rdoc/ja/grammar.ja.rdoc".freeze, "rdoc/ja/parser.ja.rdoc".freeze, "README.ja.rdoc".freeze, "README.rdoc".freeze] - s.files = ["COPYING".freeze, "ChangeLog".freeze, "DEPENDS".freeze, "Manifest.txt".freeze, "README.ja.rdoc".freeze, "README.rdoc".freeze, "Rakefile".freeze, "TODO".freeze, "bin/racc".freeze, "bin/racc2y".freeze, "bin/y2racc".freeze, "ext/racc/MANIFEST".freeze, "ext/racc/com/headius/racc/Cparse.java".freeze, "ext/racc/cparse.c".freeze, "ext/racc/depend".freeze, "ext/racc/extconf.rb".freeze, "fastcache/extconf.rb".freeze, "fastcache/fastcache.c".freeze, "lib/racc.rb".freeze, "lib/racc/compat.rb".freeze, "lib/racc/debugflags.rb".freeze, "lib/racc/exception.rb".freeze, "lib/racc/grammar.rb".freeze, "lib/racc/grammarfileparser.rb".freeze, "lib/racc/info.rb".freeze, "lib/racc/iset.rb".freeze, "lib/racc/logfilegenerator.rb".freeze, "lib/racc/parser-text.rb".freeze, "lib/racc/parser.rb".freeze, "lib/racc/parserfilegenerator.rb".freeze, "lib/racc/pre-setup".freeze, "lib/racc/sourcetext.rb".freeze, "lib/racc/state.rb".freeze, "lib/racc/statetransitiontable.rb".freeze, "lib/racc/static.rb".freeze, "misc/dist.sh".freeze, "rdoc/en/NEWS.en.rdoc".freeze, "rdoc/en/grammar.en.rdoc".freeze, "rdoc/ja/NEWS.ja.rdoc".freeze, "rdoc/ja/command.ja.html".freeze, "rdoc/ja/debug.ja.rdoc".freeze, "rdoc/ja/grammar.ja.rdoc".freeze, "rdoc/ja/index.ja.html".freeze, "rdoc/ja/parser.ja.rdoc".freeze, "rdoc/ja/usage.ja.html".freeze, "sample/array.y".freeze, "sample/array2.y".freeze, "sample/calc-ja.y".freeze, "sample/calc.y".freeze, "sample/conflict.y".freeze, "sample/hash.y".freeze, "sample/lalr.y".freeze, "sample/lists.y".freeze, "sample/syntax.y".freeze, "sample/yyerr.y".freeze, "setup.rb".freeze, "tasks/doc.rb".freeze, "tasks/email.rb".freeze, "test/assets/cadenza.y".freeze, "test/assets/cast.y".freeze, "test/assets/chk.y".freeze, "test/assets/conf.y".freeze, "test/assets/csspool.y".freeze, "test/assets/digraph.y".freeze, "test/assets/echk.y".freeze, "test/assets/edtf.y".freeze, "test/assets/err.y".freeze, "test/assets/error_recovery.y".freeze, "test/assets/expect.y".freeze, "test/assets/firstline.y".freeze, "test/assets/huia.y".freeze, "test/assets/ichk.y".freeze, "test/assets/intp.y".freeze, "test/assets/journey.y".freeze, "test/assets/liquor.y".freeze, "test/assets/machete.y".freeze, "test/assets/macruby.y".freeze, "test/assets/mailp.y".freeze, "test/assets/mediacloth.y".freeze, "test/assets/mof.y".freeze, "test/assets/namae.y".freeze, "test/assets/nasl.y".freeze, "test/assets/newsyn.y".freeze, "test/assets/noend.y".freeze, "test/assets/nokogiri-css.y".freeze, "test/assets/nonass.y".freeze, "test/assets/normal.y".freeze, "test/assets/norule.y".freeze, "test/assets/nullbug1.y".freeze, "test/assets/nullbug2.y".freeze, "test/assets/opal.y".freeze, "test/assets/opt.y".freeze, "test/assets/percent.y".freeze, "test/assets/php_serialization.y".freeze, "test/assets/recv.y".freeze, "test/assets/riml.y".freeze, "test/assets/rrconf.y".freeze, "test/assets/ruby18.y".freeze, "test/assets/ruby19.y".freeze, "test/assets/ruby20.y".freeze, "test/assets/ruby21.y".freeze, "test/assets/ruby22.y".freeze, "test/assets/scan.y".freeze, "test/assets/syntax.y".freeze, "test/assets/tp_plus.y".freeze, "test/assets/twowaysql.y".freeze, "test/assets/unterm.y".freeze, "test/assets/useless.y".freeze, "test/assets/yyerr.y".freeze, "test/bench.y".freeze, "test/helper.rb".freeze, "test/infini.y".freeze, "test/regress/cadenza".freeze, "test/regress/cast".freeze, "test/regress/csspool".freeze, "test/regress/edtf".freeze, "test/regress/huia".freeze, "test/regress/journey".freeze, "test/regress/liquor".freeze, "test/regress/machete".freeze, "test/regress/mediacloth".freeze, "test/regress/mof".freeze, "test/regress/namae".freeze, "test/regress/nasl".freeze, "test/regress/nokogiri-css".freeze, "test/regress/opal".freeze, "test/regress/php_serialization".freeze, "test/regress/riml".freeze, "test/regress/ruby18".freeze, "test/regress/ruby22".freeze, "test/regress/tp_plus".freeze, "test/regress/twowaysql".freeze, "test/scandata/brace".freeze, "test/scandata/gvar".freeze, "test/scandata/normal".freeze, "test/scandata/percent".freeze, "test/scandata/slash".freeze, "test/src.intp".freeze, "test/start.y".freeze, "test/test_chk_y.rb".freeze, "test/test_grammar_file_parser.rb".freeze, "test/test_racc_command.rb".freeze, "test/test_scan_y.rb".freeze, "test/testscanner.rb".freeze, "web/racc.en.rhtml".freeze, "web/racc.ja.rhtml".freeze] - s.homepage = "http://i.loveruby.net/en/projects/racc/".freeze - s.licenses = ["MIT".freeze] - s.rdoc_options = ["--main".freeze, "README.rdoc".freeze] - s.rubygems_version = "3.1.0.pre1".freeze - s.summary = "Racc is a LALR(1) parser generator".freeze + s.description = "Racc is a LALR(1) parser generator.\n It is written in Ruby itself, and generates Ruby program.\n\n NOTE: Ruby 1.8.x comes with Racc runtime module. You\n can run your parsers generated by racc 1.4.x out of the\n box." + s.email = ["aaron@tenderlovemaking.com"] + s.executables = ["racc", "racc2y", "y2racc"] + s.extensions = ["ext/racc/extconf.rb"] + s.extra_rdoc_files = ["Manifest.txt", "README.ja.rdoc", "README.rdoc", "rdoc/en/NEWS.en.rdoc", "rdoc/en/grammar.en.rdoc", "rdoc/ja/NEWS.ja.rdoc", "rdoc/ja/debug.ja.rdoc", "rdoc/ja/grammar.ja.rdoc", "rdoc/ja/parser.ja.rdoc", "README.ja.rdoc", "README.rdoc"] + s.files = ["COPYING", "ChangeLog", "DEPENDS", "Manifest.txt", "README.ja.rdoc", "README.rdoc", "Rakefile", "TODO", "bin/racc", "bin/racc2y", "bin/y2racc", "ext/racc/MANIFEST", "ext/racc/com/headius/racc/Cparse.java", "ext/racc/cparse.c", "ext/racc/depend", "ext/racc/extconf.rb", "fastcache/extconf.rb", "fastcache/fastcache.c", "lib/racc.rb", "lib/racc/compat.rb", "lib/racc/debugflags.rb", "lib/racc/exception.rb", "lib/racc/grammar.rb", "lib/racc/grammarfileparser.rb", "lib/racc/info.rb", "lib/racc/iset.rb", "lib/racc/logfilegenerator.rb", "lib/racc/parser-text.rb", "lib/racc/parser.rb", "lib/racc/parserfilegenerator.rb", "lib/racc/pre-setup", "lib/racc/sourcetext.rb", "lib/racc/state.rb", "lib/racc/statetransitiontable.rb", "lib/racc/static.rb", "misc/dist.sh", "rdoc/en/NEWS.en.rdoc", "rdoc/en/grammar.en.rdoc", "rdoc/ja/NEWS.ja.rdoc", "rdoc/ja/command.ja.html", "rdoc/ja/debug.ja.rdoc", "rdoc/ja/grammar.ja.rdoc", "rdoc/ja/index.ja.html", "rdoc/ja/parser.ja.rdoc", "rdoc/ja/usage.ja.html", "sample/array.y", "sample/array2.y", "sample/calc-ja.y", "sample/calc.y", "sample/conflict.y", "sample/hash.y", "sample/lalr.y", "sample/lists.y", "sample/syntax.y", "sample/yyerr.y", "setup.rb", "tasks/doc.rb", "tasks/email.rb", "test/assets/cadenza.y", "test/assets/cast.y", "test/assets/chk.y", "test/assets/conf.y", "test/assets/csspool.y", "test/assets/digraph.y", "test/assets/echk.y", "test/assets/edtf.y", "test/assets/err.y", "test/assets/error_recovery.y", "test/assets/expect.y", "test/assets/firstline.y", "test/assets/huia.y", "test/assets/ichk.y", "test/assets/intp.y", "test/assets/journey.y", "test/assets/liquor.y", "test/assets/machete.y", "test/assets/macruby.y", "test/assets/mailp.y", "test/assets/mediacloth.y", "test/assets/mof.y", "test/assets/namae.y", "test/assets/nasl.y", "test/assets/newsyn.y", "test/assets/noend.y", "test/assets/nokogiri-css.y", "test/assets/nonass.y", "test/assets/normal.y", "test/assets/norule.y", "test/assets/nullbug1.y", "test/assets/nullbug2.y", "test/assets/opal.y", "test/assets/opt.y", "test/assets/percent.y", "test/assets/php_serialization.y", "test/assets/recv.y", "test/assets/riml.y", "test/assets/rrconf.y", "test/assets/ruby18.y", "test/assets/ruby19.y", "test/assets/ruby20.y", "test/assets/ruby21.y", "test/assets/ruby22.y", "test/assets/scan.y", "test/assets/syntax.y", "test/assets/tp_plus.y", "test/assets/twowaysql.y", "test/assets/unterm.y", "test/assets/useless.y", "test/assets/yyerr.y", "test/bench.y", "test/helper.rb", "test/infini.y", "test/regress/cadenza", "test/regress/cast", "test/regress/csspool", "test/regress/edtf", "test/regress/huia", "test/regress/journey", "test/regress/liquor", "test/regress/machete", "test/regress/mediacloth", "test/regress/mof", "test/regress/namae", "test/regress/nasl", "test/regress/nokogiri-css", "test/regress/opal", "test/regress/php_serialization", "test/regress/riml", "test/regress/ruby18", "test/regress/ruby22", "test/regress/tp_plus", "test/regress/twowaysql", "test/scandata/brace", "test/scandata/gvar", "test/scandata/normal", "test/scandata/percent", "test/scandata/slash", "test/src.intp", "test/start.y", "test/test_chk_y.rb", "test/test_grammar_file_parser.rb", "test/test_racc_command.rb", "test/test_scan_y.rb", "test/testscanner.rb", "web/racc.en.rhtml", "web/racc.ja.rhtml"] + s.homepage = "http://i.loveruby.net/en/projects/racc/" + s.licenses = ["MIT"] + s.rdoc_options = ["--main", "README.rdoc"] + s.rubygems_version = "3.1.0.pre1" + s.summary = "Racc is a LALR(1) parser generator" - s.add_development_dependency(%q.freeze, [">= 0.4.1"]) - s.add_development_dependency(%q.freeze, ["~> 4.7"]) - s.add_development_dependency(%q.freeze, [">= 4.0", "< 7"]) - s.add_development_dependency(%q.freeze, ["~> 3.18"]) + s.add_development_dependency("rake-compiler", [">= 0.4.1"]) + s.add_development_dependency("minitest", ["~> 4.7"]) + s.add_development_dependency("rdoc", [">= 4.0", "< 7"]) + s.add_development_dependency("hoe", ["~> 3.18"]) end From e2bee86dc4ec60c8834b976b83491358c4cb5f00 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sat, 13 Jul 2019 09:48:12 +0900 Subject: [PATCH 027/452] Relaxed delta of nanosec from Float time --- test/ruby/test_time.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/ruby/test_time.rb b/test/ruby/test_time.rb index 7269bdc3ff98bf..43ede8878bce70 100644 --- a/test/ruby/test_time.rb +++ b/test/ruby/test_time.rb @@ -173,7 +173,7 @@ def test_at assert_equal(10000, Time.at(0.00001).nsec) assert_equal(3000, Time.at(0.000003).nsec) assert_equal(200, Time.at(0.0000002r).nsec) - assert_equal(199, Time.at(0.0000002).nsec) + assert_in_delta(200, Time.at(0.0000002).nsec, 1, "should be within FP error") assert_equal(10, Time.at(0.00000001).nsec) assert_equal(1, Time.at(0.000000001).nsec) From 43677a2c58c82ddd630eb5267d1683e1c651c529 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Sat, 13 Jul 2019 15:07:19 +0200 Subject: [PATCH 028/452] Document the long form of global variables and mention aliases on the same line * The longer forms are self-explanatory and I believe more often used. * Same for ARGV and ARGF, describe them there and mention $* and $< just refer to them. --- doc/globals.rdoc | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/doc/globals.rdoc b/doc/globals.rdoc index c4aacd470791f9..b2dbcee1c72970 100644 --- a/doc/globals.rdoc +++ b/doc/globals.rdoc @@ -1,6 +1,6 @@ # -*- mode: rdoc; coding: utf-8; fill-column: 74; -*- -== Pre-defined variables +== Pre-defined global variables $!:: The exception information message set by 'raise'. $@:: Array of backtrace of the last exception thrown. @@ -11,46 +11,40 @@ $+:: The highest group matched by the last successful match. $1:: The Nth group of the last successful match. May be > 1. $~:: The information about the last match in the current scope. $=:: This variable is no longer effective. Deprecated. -$/:: The input record separator, newline by default. +$/:: The input record separator, newline by default. Aliased to $-0. $\:: The output record separator for the print and IO#write. Default is nil. $,:: The output field separator for the print and Array#join. Non-nil $, will be deprecated. -$;:: The default separator for String#split. Non-nil $; will be deprecated. +$;:: The default separator for String#split. Non-nil $; will be deprecated. Aliased to $-F. $.:: The current input line number of the last file that was read. -$<:: The virtual concatenation file of the files given on command line (or from $stdin if no files were given). +$<:: The same as ARGF. $>:: The default output for print, printf. $stdout by default. $_:: The last input line of string by gets or readline. $0:: Contains the name of the script being executed. May be assignable. -$*:: Command line arguments given for the script sans args. +$*:: The same as ARGV. $$:: The process number of the Ruby running this script. $?:: The status of the last executed child process. This value is thread-local. -$::: Load path for scripts and binary modules by load or require. -$":: The array contains the module names loaded by require. +$LOAD_PATH:: Load path for scripts and binary modules by load or require. + Aliased to $: and $-I. +$LOADED_FEATURES:: The array contains the module names loaded by require. + Aliased to $". $DEBUG:: The debug flag, which is set by the -d switch. Enabling debug output prints each exception raised to $stderr (but not its backtrace). Setting this to a true value enables debug output as if -d were given on the command line. Setting this to a false - value disables debug output. -$LOADED_FEATURES:: The alias to the $". -$FILENAME:: Current input file from $<. Same as $<.filename. -$LOAD_PATH:: The alias to the $:. + value disables debug output. Aliased to $-d. +$FILENAME:: Current input filename from ARGF. Same as ARGF.filename. $stderr:: The current standard error output. $stdin:: The current standard input. $stdout:: The current standard output. $VERBOSE:: The verbose flag, which is set by the -w or -v switch. Setting this to a true value enables warnings as if -w or -v were given on the command line. Setting this to nil disables warnings, - including from Kernel#warn. -$-0:: The alias to $/. + including from Kernel#warn. Aliased to $-v and $-w. $-a:: True if option -a is set. Read-only variable. -$-d:: The alias of $DEBUG. See $DEBUG above for further discussion. -$-F:: The alias to $;. $-i:: In in-place-edit mode, this variable holds the extension, otherwise nil. -$-I:: The alias to $:. $-l:: True if option -l is set. Read-only variable. $-p:: True if option -p is set. Read-only variable. -$-v:: An alias of $VERBOSE. See $VERBOSE above for further discussion. -$-w:: An alias of $VERBOSE. See $VERBOSE above for further discussion. == Pre-defined global constants @@ -61,10 +55,9 @@ STDIN:: The standard input. The default value for $stdin. STDOUT:: The standard output. The default value for $stdout. STDERR:: The standard error output. The default value for $stderr. ENV:: The hash contains current environment variables. -ARGF:: The alias to the $<. -ARGV:: The alias to the $*. +ARGF:: The virtual concatenation of the files given on command line (or from $stdin if no files were given). +ARGV:: An Array of command line arguments given for the script. DATA:: The file object of the script, pointing just after __END__. RUBY_VERSION:: The ruby version string (VERSION was deprecated). RUBY_RELEASE_DATE:: The release date string. RUBY_PLATFORM:: The platform identifier. - From b0f6f33094606e50296cb525184708454420e860 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Sat, 13 Jul 2019 15:16:26 +0200 Subject: [PATCH 029/452] Document a few more RUBY_* constants --- doc/globals.rdoc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/globals.rdoc b/doc/globals.rdoc index b2dbcee1c72970..96030ea5501832 100644 --- a/doc/globals.rdoc +++ b/doc/globals.rdoc @@ -58,6 +58,9 @@ ENV:: The hash contains current environment variables. ARGF:: The virtual concatenation of the files given on command line (or from $stdin if no files were given). ARGV:: An Array of command line arguments given for the script. DATA:: The file object of the script, pointing just after __END__. -RUBY_VERSION:: The ruby version string (VERSION was deprecated). +RUBY_VERSION:: The Ruby language version. RUBY_RELEASE_DATE:: The release date string. RUBY_PLATFORM:: The platform identifier. +RUBY_ENGINE:: The name of the Ruby implementation. +RUBY_ENGINE_VERSION:: The version of the Ruby implementation. +RUBY_DESCRIPTION:: The same as `ruby --version`, a String describing various aspects of the Ruby implementation. From 4a935bc6f66fda448fb430c7627a2f175dcd0650 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Sat, 13 Jul 2019 15:23:49 +0200 Subject: [PATCH 030/452] Document $LOAD_PATH.resolve_feature_path in globals.rdoc * RDoc does not seem to support documenting singleton object methods, and making $LOAD_PATH a class as a workaround is too weird. --- doc/globals.rdoc | 5 ++++- load.c | 3 +-- vm.c | 12 ------------ 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/doc/globals.rdoc b/doc/globals.rdoc index 96030ea5501832..284f3d764ea638 100644 --- a/doc/globals.rdoc +++ b/doc/globals.rdoc @@ -25,7 +25,10 @@ $$:: The process number of the Ruby running this script. $?:: The status of the last executed child process. This value is thread-local. $LOAD_PATH:: Load path for scripts and binary modules by load or require. - Aliased to $: and $-I. + Aliased to $: and $-I. Has a singleton method + $LOAD_PATH.resolve_feature_path(feature) that returns + [:rb or :so, path], which resolves the feature to the path the + original Kernel#require method would load. $LOADED_FEATURES:: The array contains the module names loaded by require. Aliased to $". $DEBUG:: The debug flag, which is set by the -d switch. Enabling debug diff --git a/load.c b/load.c index 4eb3f7f50b0331..539b29f89be624 100644 --- a/load.c +++ b/load.c @@ -945,14 +945,13 @@ load_ext(VALUE path) return (VALUE)dln_load(RSTRING_PTR(path)); } -/* Method is documented in vm.c */ - static int no_feature_p(const char *feature, const char *ext, int rb, int expanded, const char **fn) { return 0; } +// Documented in doc/globals.rdoc VALUE rb_resolve_feature_path(VALUE klass, VALUE fname) { diff --git a/vm.c b/vm.c index 09e727ff7fb6b4..b5412d1a6d5929 100644 --- a/vm.c +++ b/vm.c @@ -2937,18 +2937,6 @@ static VALUE usage_analysis_operand_stop(VALUE self); static VALUE usage_analysis_register_stop(VALUE self); #endif -/* - * Document-method: RubyVM::resolve_feature_path - * call-seq: - * RubyVM.resolve_feature_path(feature) -> [:rb or :so, path] - * - * Identifies the file that will be loaded by "require(feature)". - * This API is experimental and just for internal use. - * - * RubyVM.resolve_feature_path("set") - * #=> [:rb, "/path/to/set.rb"] - */ - void Init_VM(void) { From 0a5463f7645f6366e2239268de5bc56c0dfea9d1 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Sat, 13 Jul 2019 15:26:47 +0200 Subject: [PATCH 031/452] Add $LOAD_PATH.resolve_feature_path in NEWS --- NEWS | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NEWS b/NEWS index 92f373c05a1655..a917007ad121eb 100644 --- a/NEWS +++ b/NEWS @@ -153,6 +153,10 @@ Time:: * Added Time#floor method. [Feature #15653] +$LOAD_PATH:: + + * Added $LOAD_PATH.resolve_feature_path. [Feature #15903] [Feature #15230] + === Stdlib updates (outstanding ones only) Bundler:: From b1ee7148f8f9007d7154bf147daecc8c70dc44a3 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Sat, 13 Jul 2019 15:35:16 +0200 Subject: [PATCH 032/452] Improve documentation of $LOAD_PATH --- doc/globals.rdoc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/globals.rdoc b/doc/globals.rdoc index 284f3d764ea638..b1e0369481a433 100644 --- a/doc/globals.rdoc +++ b/doc/globals.rdoc @@ -24,11 +24,11 @@ $*:: The same as ARGV. $$:: The process number of the Ruby running this script. $?:: The status of the last executed child process. This value is thread-local. -$LOAD_PATH:: Load path for scripts and binary modules by load or require. - Aliased to $: and $-I. Has a singleton method - $LOAD_PATH.resolve_feature_path(feature) that returns - [:rb or :so, path], which resolves the feature to the path the - original Kernel#require method would load. +$LOAD_PATH:: Load path for searching Ruby scripts and extension libraries used + by Kernel#load and Kernel#require. Aliased to $: and $-I. + Has a singleton method $LOAD_PATH.resolve_feature_path(feature) + that returns [:rb or :so, path], which resolves the feature to + the path the original Kernel#require method would load. $LOADED_FEATURES:: The array contains the module names loaded by require. Aliased to $". $DEBUG:: The debug flag, which is set by the -d switch. Enabling debug From 237b3e00c72bff89b97d04d0a15200949ac1ee56 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Sat, 13 Jul 2019 15:39:54 +0200 Subject: [PATCH 033/452] Document $~ before dependent global variables --- doc/globals.rdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/globals.rdoc b/doc/globals.rdoc index b1e0369481a433..8729ff21349a5f 100644 --- a/doc/globals.rdoc +++ b/doc/globals.rdoc @@ -4,12 +4,12 @@ $!:: The exception information message set by 'raise'. $@:: Array of backtrace of the last exception thrown. +$~:: The information about the last match in the current scope (thread-local and frame-local). $&:: The string matched by the last successful match. $`:: The string to the left of the last successful match. $':: The string to the right of the last successful match. $+:: The highest group matched by the last successful match. $1:: The Nth group of the last successful match. May be > 1. -$~:: The information about the last match in the current scope. $=:: This variable is no longer effective. Deprecated. $/:: The input record separator, newline by default. Aliased to $-0. $\:: The output record separator for the print and IO#write. Default is nil. From 6ef73c14725b90ae1fb0ec017564d560d05d8c01 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Sat, 13 Jul 2019 15:47:37 +0200 Subject: [PATCH 034/452] Improve documentation in doc/globals.rdoc --- doc/globals.rdoc | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/doc/globals.rdoc b/doc/globals.rdoc index 8729ff21349a5f..083b2a18cb5cfe 100644 --- a/doc/globals.rdoc +++ b/doc/globals.rdoc @@ -2,8 +2,8 @@ == Pre-defined global variables -$!:: The exception information message set by 'raise'. -$@:: Array of backtrace of the last exception thrown. +$!:: The Exception object set by Kernel#raise. +$@:: The same as $!.backtrace. $~:: The information about the last match in the current scope (thread-local and frame-local). $&:: The string matched by the last successful match. $`:: The string to the left of the last successful match. @@ -12,18 +12,17 @@ $+:: The highest group matched by the last successful match. $1:: The Nth group of the last successful match. May be > 1. $=:: This variable is no longer effective. Deprecated. $/:: The input record separator, newline by default. Aliased to $-0. -$\:: The output record separator for the print and IO#write. Default is nil. -$,:: The output field separator for the print and Array#join. Non-nil $, will be deprecated. +$\:: The output record separator for Kernel#print and IO#write. Default is nil. +$,:: The output field separator for Kernel#print and Array#join. Non-nil $, will be deprecated. $;:: The default separator for String#split. Non-nil $; will be deprecated. Aliased to $-F. $.:: The current input line number of the last file that was read. $<:: The same as ARGF. -$>:: The default output for print, printf. $stdout by default. +$>:: The default output stream for Kernel#print and Kernel#printf. $stdout by default. $_:: The last input line of string by gets or readline. $0:: Contains the name of the script being executed. May be assignable. $*:: The same as ARGV. -$$:: The process number of the Ruby running this script. -$?:: The status of the last executed child process. This value is - thread-local. +$$:: The process number of the Ruby running this script. Same as Process.pid. +$?:: The status of the last executed child process (thread-local). $LOAD_PATH:: Load path for searching Ruby scripts and extension libraries used by Kernel#load and Kernel#require. Aliased to $: and $-I. Has a singleton method $LOAD_PATH.resolve_feature_path(feature) From 1a4f7c9bfae484bd9806efc8d1d8074b23e382bf Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sat, 13 Jul 2019 23:32:18 +0900 Subject: [PATCH 035/452] [DOC] Markup code in globals.rdoc Look forward to further improvements in RDoc to automatically mark up global variables and global constants. --- doc/globals.rdoc | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/doc/globals.rdoc b/doc/globals.rdoc index 083b2a18cb5cfe..201fe7b387e43c 100644 --- a/doc/globals.rdoc +++ b/doc/globals.rdoc @@ -3,7 +3,7 @@ == Pre-defined global variables $!:: The Exception object set by Kernel#raise. -$@:: The same as $!.backtrace. +$@:: The same as $!.backtrace. $~:: The information about the last match in the current scope (thread-local and frame-local). $&:: The string matched by the last successful match. $`:: The string to the left of the last successful match. @@ -12,7 +12,7 @@ $+:: The highest group matched by the last successful match. $1:: The Nth group of the last successful match. May be > 1. $=:: This variable is no longer effective. Deprecated. $/:: The input record separator, newline by default. Aliased to $-0. -$\:: The output record separator for Kernel#print and IO#write. Default is nil. +$\:: The output record separator for Kernel#print and IO#write. Default is +nil+. $,:: The output field separator for Kernel#print and Array#join. Non-nil $, will be deprecated. $;:: The default separator for String#split. Non-nil $; will be deprecated. Aliased to $-F. $.:: The current input line number of the last file that was read. @@ -25,8 +25,8 @@ $$:: The process number of the Ruby running this script. Same as Process.pid. $?:: The status of the last executed child process (thread-local). $LOAD_PATH:: Load path for searching Ruby scripts and extension libraries used by Kernel#load and Kernel#require. Aliased to $: and $-I. - Has a singleton method $LOAD_PATH.resolve_feature_path(feature) - that returns [:rb or :so, path], which resolves the feature to + Has a singleton method $LOAD_PATH.resolve_feature_path(feature) + that returns [+:rb+ or +:so+, path], which resolves the feature to the path the original Kernel#require method would load. $LOADED_FEATURES:: The array contains the module names loaded by require. Aliased to $". @@ -41,28 +41,28 @@ $stdin:: The current standard input. $stdout:: The current standard output. $VERBOSE:: The verbose flag, which is set by the -w or -v switch. Setting this to a true value enables warnings as if -w or -v were given - on the command line. Setting this to nil disables warnings, + on the command line. Setting this to +nil+ disables warnings, including from Kernel#warn. Aliased to $-v and $-w. $-a:: True if option -a is set. Read-only variable. -$-i:: In in-place-edit mode, this variable holds the extension, otherwise nil. +$-i:: In in-place-edit mode, this variable holds the extension, otherwise +nil+. $-l:: True if option -l is set. Read-only variable. $-p:: True if option -p is set. Read-only variable. == Pre-defined global constants TRUE:: The typical true value. -FALSE:: The false itself. -NIL:: The nil itself. +FALSE:: The +false+ itself. +NIL:: The +nil+ itself. STDIN:: The standard input. The default value for $stdin. STDOUT:: The standard output. The default value for $stdout. STDERR:: The standard error output. The default value for $stderr. ENV:: The hash contains current environment variables. ARGF:: The virtual concatenation of the files given on command line (or from $stdin if no files were given). ARGV:: An Array of command line arguments given for the script. -DATA:: The file object of the script, pointing just after __END__. +DATA:: The file object of the script, pointing just after __END__. RUBY_VERSION:: The Ruby language version. RUBY_RELEASE_DATE:: The release date string. RUBY_PLATFORM:: The platform identifier. RUBY_ENGINE:: The name of the Ruby implementation. RUBY_ENGINE_VERSION:: The version of the Ruby implementation. -RUBY_DESCRIPTION:: The same as `ruby --version`, a String describing various aspects of the Ruby implementation. +RUBY_DESCRIPTION:: The same as ruby --version, a String describing various aspects of the Ruby implementation. From dcb8c41a1e2146cc67c638ec391436e1ab2323d2 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 14 Jul 2019 00:50:12 +0900 Subject: [PATCH 036/452] Added depend files --- ext/-test-/arith_seq/extract/depend | 12 +++++++++ ext/-test-/bug-3571/depend | 13 +++++++++ ext/-test-/bug-5832/depend | 13 +++++++++ ext/-test-/bug_reporter/depend | 13 +++++++++ ext/-test-/fatal/depend | 13 +++++++++ ext/-test-/funcall/depend | 13 +++++++++ ext/-test-/hash/depend | 24 +++++++++++++++++ ext/-test-/iseq_load/depend | 13 +++++++++ ext/-test-/iter/depend | 35 +++++++++++++++++++++++++ ext/-test-/load/protect/depend | 13 +++++++++ ext/-test-/marshal/compat/depend | 13 +++++++++ ext/-test-/marshal/internal_ivar/depend | 13 +++++++++ ext/-test-/marshal/usr/depend | 13 +++++++++ ext/-test-/memory_status/depend | 13 +++++++++ ext/-test-/method/depend | 24 +++++++++++++++++ ext/-test-/notimplement/depend | 13 +++++++++ ext/-test-/num2int/depend | 13 +++++++++ ext/-test-/path_to_class/depend | 13 +++++++++ ext/-test-/popen_deadlock/depend | 13 +++++++++ ext/-test-/proc/depend | 35 +++++++++++++++++++++++++ ext/-test-/recursion/depend | 13 +++++++++ ext/-test-/regexp/depend | 25 ++++++++++++++++++ ext/-test-/scan_args/depend | 13 +++++++++ ext/-test-/st/foreach/depend | 13 +++++++++ ext/-test-/st/numhash/depend | 13 +++++++++ ext/-test-/st/update/depend | 13 +++++++++ ext/-test-/symbol/depend | 24 +++++++++++++++++ ext/-test-/typeddata/depend | 13 +++++++++ ext/bigdecimal/util/depend | 13 +++++++++ ext/json/depend | 2 ++ ext/rubyvm/depend | 2 ++ ext/win32/depend | 2 ++ ext/win32/resolv/depend | 16 +++++++++++ template/depend.tmpl | 2 ++ 34 files changed, 489 insertions(+) create mode 100644 ext/-test-/arith_seq/extract/depend create mode 100644 ext/-test-/bug-3571/depend create mode 100644 ext/-test-/bug-5832/depend create mode 100644 ext/-test-/bug_reporter/depend create mode 100644 ext/-test-/fatal/depend create mode 100644 ext/-test-/funcall/depend create mode 100644 ext/-test-/hash/depend create mode 100644 ext/-test-/iseq_load/depend create mode 100644 ext/-test-/iter/depend create mode 100644 ext/-test-/load/protect/depend create mode 100644 ext/-test-/marshal/compat/depend create mode 100644 ext/-test-/marshal/internal_ivar/depend create mode 100644 ext/-test-/marshal/usr/depend create mode 100644 ext/-test-/memory_status/depend create mode 100644 ext/-test-/method/depend create mode 100644 ext/-test-/notimplement/depend create mode 100644 ext/-test-/num2int/depend create mode 100644 ext/-test-/path_to_class/depend create mode 100644 ext/-test-/popen_deadlock/depend create mode 100644 ext/-test-/proc/depend create mode 100644 ext/-test-/recursion/depend create mode 100644 ext/-test-/regexp/depend create mode 100644 ext/-test-/scan_args/depend create mode 100644 ext/-test-/st/foreach/depend create mode 100644 ext/-test-/st/numhash/depend create mode 100644 ext/-test-/st/update/depend create mode 100644 ext/-test-/symbol/depend create mode 100644 ext/-test-/typeddata/depend create mode 100644 ext/bigdecimal/util/depend create mode 100644 ext/json/depend create mode 100644 ext/rubyvm/depend create mode 100644 ext/win32/depend create mode 100644 ext/win32/resolv/depend create mode 100644 template/depend.tmpl diff --git a/ext/-test-/arith_seq/extract/depend b/ext/-test-/arith_seq/extract/depend new file mode 100644 index 00000000000000..5af2e6a4a2bc5d --- /dev/null +++ b/ext/-test-/arith_seq/extract/depend @@ -0,0 +1,12 @@ +# AUTOGENERATED DEPENDENCIES START +extract.o: $(RUBY_EXTCONF_H) +extract.o: $(arch_hdrdir)/ruby/config.h +extract.o: $(hdrdir)/ruby/backward.h +extract.o: $(hdrdir)/ruby/defines.h +extract.o: $(hdrdir)/ruby/intern.h +extract.o: $(hdrdir)/ruby/missing.h +extract.o: $(hdrdir)/ruby/ruby.h +extract.o: $(hdrdir)/ruby/st.h +extract.o: $(hdrdir)/ruby/subst.h +extract.o: extract.c +# AUTOGENERATED DEPENDENCIES END diff --git a/ext/-test-/bug-3571/depend b/ext/-test-/bug-3571/depend new file mode 100644 index 00000000000000..6f4ff481982dde --- /dev/null +++ b/ext/-test-/bug-3571/depend @@ -0,0 +1,13 @@ +# AUTOGENERATED DEPENDENCIES START +bug.o: $(RUBY_EXTCONF_H) +bug.o: $(arch_hdrdir)/ruby/config.h +bug.o: $(hdrdir)/ruby.h +bug.o: $(hdrdir)/ruby/backward.h +bug.o: $(hdrdir)/ruby/defines.h +bug.o: $(hdrdir)/ruby/intern.h +bug.o: $(hdrdir)/ruby/missing.h +bug.o: $(hdrdir)/ruby/ruby.h +bug.o: $(hdrdir)/ruby/st.h +bug.o: $(hdrdir)/ruby/subst.h +bug.o: bug.c +# AUTOGENERATED DEPENDENCIES END diff --git a/ext/-test-/bug-5832/depend b/ext/-test-/bug-5832/depend new file mode 100644 index 00000000000000..6f4ff481982dde --- /dev/null +++ b/ext/-test-/bug-5832/depend @@ -0,0 +1,13 @@ +# AUTOGENERATED DEPENDENCIES START +bug.o: $(RUBY_EXTCONF_H) +bug.o: $(arch_hdrdir)/ruby/config.h +bug.o: $(hdrdir)/ruby.h +bug.o: $(hdrdir)/ruby/backward.h +bug.o: $(hdrdir)/ruby/defines.h +bug.o: $(hdrdir)/ruby/intern.h +bug.o: $(hdrdir)/ruby/missing.h +bug.o: $(hdrdir)/ruby/ruby.h +bug.o: $(hdrdir)/ruby/st.h +bug.o: $(hdrdir)/ruby/subst.h +bug.o: bug.c +# AUTOGENERATED DEPENDENCIES END diff --git a/ext/-test-/bug_reporter/depend b/ext/-test-/bug_reporter/depend new file mode 100644 index 00000000000000..bfd4c721f1aaf1 --- /dev/null +++ b/ext/-test-/bug_reporter/depend @@ -0,0 +1,13 @@ +# AUTOGENERATED DEPENDENCIES START +bug_reporter.o: $(RUBY_EXTCONF_H) +bug_reporter.o: $(arch_hdrdir)/ruby/config.h +bug_reporter.o: $(hdrdir)/ruby.h +bug_reporter.o: $(hdrdir)/ruby/backward.h +bug_reporter.o: $(hdrdir)/ruby/defines.h +bug_reporter.o: $(hdrdir)/ruby/intern.h +bug_reporter.o: $(hdrdir)/ruby/missing.h +bug_reporter.o: $(hdrdir)/ruby/ruby.h +bug_reporter.o: $(hdrdir)/ruby/st.h +bug_reporter.o: $(hdrdir)/ruby/subst.h +bug_reporter.o: bug_reporter.c +# AUTOGENERATED DEPENDENCIES END diff --git a/ext/-test-/fatal/depend b/ext/-test-/fatal/depend new file mode 100644 index 00000000000000..af8d2156e2796a --- /dev/null +++ b/ext/-test-/fatal/depend @@ -0,0 +1,13 @@ +# AUTOGENERATED DEPENDENCIES START +rb_fatal.o: $(RUBY_EXTCONF_H) +rb_fatal.o: $(arch_hdrdir)/ruby/config.h +rb_fatal.o: $(hdrdir)/ruby.h +rb_fatal.o: $(hdrdir)/ruby/backward.h +rb_fatal.o: $(hdrdir)/ruby/defines.h +rb_fatal.o: $(hdrdir)/ruby/intern.h +rb_fatal.o: $(hdrdir)/ruby/missing.h +rb_fatal.o: $(hdrdir)/ruby/ruby.h +rb_fatal.o: $(hdrdir)/ruby/st.h +rb_fatal.o: $(hdrdir)/ruby/subst.h +rb_fatal.o: rb_fatal.c +# AUTOGENERATED DEPENDENCIES END diff --git a/ext/-test-/funcall/depend b/ext/-test-/funcall/depend new file mode 100644 index 00000000000000..6a7d16a15d4721 --- /dev/null +++ b/ext/-test-/funcall/depend @@ -0,0 +1,13 @@ +# AUTOGENERATED DEPENDENCIES START +funcall.o: $(RUBY_EXTCONF_H) +funcall.o: $(arch_hdrdir)/ruby/config.h +funcall.o: $(hdrdir)/ruby.h +funcall.o: $(hdrdir)/ruby/backward.h +funcall.o: $(hdrdir)/ruby/defines.h +funcall.o: $(hdrdir)/ruby/intern.h +funcall.o: $(hdrdir)/ruby/missing.h +funcall.o: $(hdrdir)/ruby/ruby.h +funcall.o: $(hdrdir)/ruby/st.h +funcall.o: $(hdrdir)/ruby/subst.h +funcall.o: funcall.c +# AUTOGENERATED DEPENDENCIES END diff --git a/ext/-test-/hash/depend b/ext/-test-/hash/depend new file mode 100644 index 00000000000000..dd183c9f44c00d --- /dev/null +++ b/ext/-test-/hash/depend @@ -0,0 +1,24 @@ +# AUTOGENERATED DEPENDENCIES START +delete.o: $(RUBY_EXTCONF_H) +delete.o: $(arch_hdrdir)/ruby/config.h +delete.o: $(hdrdir)/ruby.h +delete.o: $(hdrdir)/ruby/backward.h +delete.o: $(hdrdir)/ruby/defines.h +delete.o: $(hdrdir)/ruby/intern.h +delete.o: $(hdrdir)/ruby/missing.h +delete.o: $(hdrdir)/ruby/ruby.h +delete.o: $(hdrdir)/ruby/st.h +delete.o: $(hdrdir)/ruby/subst.h +delete.o: delete.c +init.o: $(RUBY_EXTCONF_H) +init.o: $(arch_hdrdir)/ruby/config.h +init.o: $(hdrdir)/ruby.h +init.o: $(hdrdir)/ruby/backward.h +init.o: $(hdrdir)/ruby/defines.h +init.o: $(hdrdir)/ruby/intern.h +init.o: $(hdrdir)/ruby/missing.h +init.o: $(hdrdir)/ruby/ruby.h +init.o: $(hdrdir)/ruby/st.h +init.o: $(hdrdir)/ruby/subst.h +init.o: init.c +# AUTOGENERATED DEPENDENCIES END diff --git a/ext/-test-/iseq_load/depend b/ext/-test-/iseq_load/depend new file mode 100644 index 00000000000000..3d2ef945ff396a --- /dev/null +++ b/ext/-test-/iseq_load/depend @@ -0,0 +1,13 @@ +# AUTOGENERATED DEPENDENCIES START +iseq_load.o: $(RUBY_EXTCONF_H) +iseq_load.o: $(arch_hdrdir)/ruby/config.h +iseq_load.o: $(hdrdir)/ruby.h +iseq_load.o: $(hdrdir)/ruby/backward.h +iseq_load.o: $(hdrdir)/ruby/defines.h +iseq_load.o: $(hdrdir)/ruby/intern.h +iseq_load.o: $(hdrdir)/ruby/missing.h +iseq_load.o: $(hdrdir)/ruby/ruby.h +iseq_load.o: $(hdrdir)/ruby/st.h +iseq_load.o: $(hdrdir)/ruby/subst.h +iseq_load.o: iseq_load.c +# AUTOGENERATED DEPENDENCIES END diff --git a/ext/-test-/iter/depend b/ext/-test-/iter/depend new file mode 100644 index 00000000000000..9e960e2426e6d9 --- /dev/null +++ b/ext/-test-/iter/depend @@ -0,0 +1,35 @@ +# AUTOGENERATED DEPENDENCIES START +break.o: $(RUBY_EXTCONF_H) +break.o: $(arch_hdrdir)/ruby/config.h +break.o: $(hdrdir)/ruby.h +break.o: $(hdrdir)/ruby/backward.h +break.o: $(hdrdir)/ruby/defines.h +break.o: $(hdrdir)/ruby/intern.h +break.o: $(hdrdir)/ruby/missing.h +break.o: $(hdrdir)/ruby/ruby.h +break.o: $(hdrdir)/ruby/st.h +break.o: $(hdrdir)/ruby/subst.h +break.o: break.c +init.o: $(RUBY_EXTCONF_H) +init.o: $(arch_hdrdir)/ruby/config.h +init.o: $(hdrdir)/ruby.h +init.o: $(hdrdir)/ruby/backward.h +init.o: $(hdrdir)/ruby/defines.h +init.o: $(hdrdir)/ruby/intern.h +init.o: $(hdrdir)/ruby/missing.h +init.o: $(hdrdir)/ruby/ruby.h +init.o: $(hdrdir)/ruby/st.h +init.o: $(hdrdir)/ruby/subst.h +init.o: init.c +yield.o: $(RUBY_EXTCONF_H) +yield.o: $(arch_hdrdir)/ruby/config.h +yield.o: $(hdrdir)/ruby.h +yield.o: $(hdrdir)/ruby/backward.h +yield.o: $(hdrdir)/ruby/defines.h +yield.o: $(hdrdir)/ruby/intern.h +yield.o: $(hdrdir)/ruby/missing.h +yield.o: $(hdrdir)/ruby/ruby.h +yield.o: $(hdrdir)/ruby/st.h +yield.o: $(hdrdir)/ruby/subst.h +yield.o: yield.c +# AUTOGENERATED DEPENDENCIES END diff --git a/ext/-test-/load/protect/depend b/ext/-test-/load/protect/depend new file mode 100644 index 00000000000000..a69bf948ce9f6f --- /dev/null +++ b/ext/-test-/load/protect/depend @@ -0,0 +1,13 @@ +# AUTOGENERATED DEPENDENCIES START +protect.o: $(RUBY_EXTCONF_H) +protect.o: $(arch_hdrdir)/ruby/config.h +protect.o: $(hdrdir)/ruby.h +protect.o: $(hdrdir)/ruby/backward.h +protect.o: $(hdrdir)/ruby/defines.h +protect.o: $(hdrdir)/ruby/intern.h +protect.o: $(hdrdir)/ruby/missing.h +protect.o: $(hdrdir)/ruby/ruby.h +protect.o: $(hdrdir)/ruby/st.h +protect.o: $(hdrdir)/ruby/subst.h +protect.o: protect.c +# AUTOGENERATED DEPENDENCIES END diff --git a/ext/-test-/marshal/compat/depend b/ext/-test-/marshal/compat/depend new file mode 100644 index 00000000000000..e0d13b18c9bc57 --- /dev/null +++ b/ext/-test-/marshal/compat/depend @@ -0,0 +1,13 @@ +# AUTOGENERATED DEPENDENCIES START +usrcompat.o: $(RUBY_EXTCONF_H) +usrcompat.o: $(arch_hdrdir)/ruby/config.h +usrcompat.o: $(hdrdir)/ruby.h +usrcompat.o: $(hdrdir)/ruby/backward.h +usrcompat.o: $(hdrdir)/ruby/defines.h +usrcompat.o: $(hdrdir)/ruby/intern.h +usrcompat.o: $(hdrdir)/ruby/missing.h +usrcompat.o: $(hdrdir)/ruby/ruby.h +usrcompat.o: $(hdrdir)/ruby/st.h +usrcompat.o: $(hdrdir)/ruby/subst.h +usrcompat.o: usrcompat.c +# AUTOGENERATED DEPENDENCIES END diff --git a/ext/-test-/marshal/internal_ivar/depend b/ext/-test-/marshal/internal_ivar/depend new file mode 100644 index 00000000000000..1ca625528cef23 --- /dev/null +++ b/ext/-test-/marshal/internal_ivar/depend @@ -0,0 +1,13 @@ +# AUTOGENERATED DEPENDENCIES START +internal_ivar.o: $(RUBY_EXTCONF_H) +internal_ivar.o: $(arch_hdrdir)/ruby/config.h +internal_ivar.o: $(hdrdir)/ruby.h +internal_ivar.o: $(hdrdir)/ruby/backward.h +internal_ivar.o: $(hdrdir)/ruby/defines.h +internal_ivar.o: $(hdrdir)/ruby/intern.h +internal_ivar.o: $(hdrdir)/ruby/missing.h +internal_ivar.o: $(hdrdir)/ruby/ruby.h +internal_ivar.o: $(hdrdir)/ruby/st.h +internal_ivar.o: $(hdrdir)/ruby/subst.h +internal_ivar.o: internal_ivar.c +# AUTOGENERATED DEPENDENCIES END diff --git a/ext/-test-/marshal/usr/depend b/ext/-test-/marshal/usr/depend new file mode 100644 index 00000000000000..13602229800439 --- /dev/null +++ b/ext/-test-/marshal/usr/depend @@ -0,0 +1,13 @@ +# AUTOGENERATED DEPENDENCIES START +usrmarshal.o: $(RUBY_EXTCONF_H) +usrmarshal.o: $(arch_hdrdir)/ruby/config.h +usrmarshal.o: $(hdrdir)/ruby.h +usrmarshal.o: $(hdrdir)/ruby/backward.h +usrmarshal.o: $(hdrdir)/ruby/defines.h +usrmarshal.o: $(hdrdir)/ruby/intern.h +usrmarshal.o: $(hdrdir)/ruby/missing.h +usrmarshal.o: $(hdrdir)/ruby/ruby.h +usrmarshal.o: $(hdrdir)/ruby/st.h +usrmarshal.o: $(hdrdir)/ruby/subst.h +usrmarshal.o: usrmarshal.c +# AUTOGENERATED DEPENDENCIES END diff --git a/ext/-test-/memory_status/depend b/ext/-test-/memory_status/depend new file mode 100644 index 00000000000000..8254b08f244dcd --- /dev/null +++ b/ext/-test-/memory_status/depend @@ -0,0 +1,13 @@ +# AUTOGENERATED DEPENDENCIES START +memory_status.o: $(RUBY_EXTCONF_H) +memory_status.o: $(arch_hdrdir)/ruby/config.h +memory_status.o: $(hdrdir)/ruby.h +memory_status.o: $(hdrdir)/ruby/backward.h +memory_status.o: $(hdrdir)/ruby/defines.h +memory_status.o: $(hdrdir)/ruby/intern.h +memory_status.o: $(hdrdir)/ruby/missing.h +memory_status.o: $(hdrdir)/ruby/ruby.h +memory_status.o: $(hdrdir)/ruby/st.h +memory_status.o: $(hdrdir)/ruby/subst.h +memory_status.o: memory_status.c +# AUTOGENERATED DEPENDENCIES END diff --git a/ext/-test-/method/depend b/ext/-test-/method/depend new file mode 100644 index 00000000000000..5bc370ecb84442 --- /dev/null +++ b/ext/-test-/method/depend @@ -0,0 +1,24 @@ +# AUTOGENERATED DEPENDENCIES START +arity.o: $(RUBY_EXTCONF_H) +arity.o: $(arch_hdrdir)/ruby/config.h +arity.o: $(hdrdir)/ruby.h +arity.o: $(hdrdir)/ruby/backward.h +arity.o: $(hdrdir)/ruby/defines.h +arity.o: $(hdrdir)/ruby/intern.h +arity.o: $(hdrdir)/ruby/missing.h +arity.o: $(hdrdir)/ruby/ruby.h +arity.o: $(hdrdir)/ruby/st.h +arity.o: $(hdrdir)/ruby/subst.h +arity.o: arity.c +init.o: $(RUBY_EXTCONF_H) +init.o: $(arch_hdrdir)/ruby/config.h +init.o: $(hdrdir)/ruby.h +init.o: $(hdrdir)/ruby/backward.h +init.o: $(hdrdir)/ruby/defines.h +init.o: $(hdrdir)/ruby/intern.h +init.o: $(hdrdir)/ruby/missing.h +init.o: $(hdrdir)/ruby/ruby.h +init.o: $(hdrdir)/ruby/st.h +init.o: $(hdrdir)/ruby/subst.h +init.o: init.c +# AUTOGENERATED DEPENDENCIES END diff --git a/ext/-test-/notimplement/depend b/ext/-test-/notimplement/depend new file mode 100644 index 00000000000000..6f4ff481982dde --- /dev/null +++ b/ext/-test-/notimplement/depend @@ -0,0 +1,13 @@ +# AUTOGENERATED DEPENDENCIES START +bug.o: $(RUBY_EXTCONF_H) +bug.o: $(arch_hdrdir)/ruby/config.h +bug.o: $(hdrdir)/ruby.h +bug.o: $(hdrdir)/ruby/backward.h +bug.o: $(hdrdir)/ruby/defines.h +bug.o: $(hdrdir)/ruby/intern.h +bug.o: $(hdrdir)/ruby/missing.h +bug.o: $(hdrdir)/ruby/ruby.h +bug.o: $(hdrdir)/ruby/st.h +bug.o: $(hdrdir)/ruby/subst.h +bug.o: bug.c +# AUTOGENERATED DEPENDENCIES END diff --git a/ext/-test-/num2int/depend b/ext/-test-/num2int/depend new file mode 100644 index 00000000000000..bb6c9b3c7702ce --- /dev/null +++ b/ext/-test-/num2int/depend @@ -0,0 +1,13 @@ +# AUTOGENERATED DEPENDENCIES START +num2int.o: $(RUBY_EXTCONF_H) +num2int.o: $(arch_hdrdir)/ruby/config.h +num2int.o: $(hdrdir)/ruby.h +num2int.o: $(hdrdir)/ruby/backward.h +num2int.o: $(hdrdir)/ruby/defines.h +num2int.o: $(hdrdir)/ruby/intern.h +num2int.o: $(hdrdir)/ruby/missing.h +num2int.o: $(hdrdir)/ruby/ruby.h +num2int.o: $(hdrdir)/ruby/st.h +num2int.o: $(hdrdir)/ruby/subst.h +num2int.o: num2int.c +# AUTOGENERATED DEPENDENCIES END diff --git a/ext/-test-/path_to_class/depend b/ext/-test-/path_to_class/depend new file mode 100644 index 00000000000000..55dce316ec8a54 --- /dev/null +++ b/ext/-test-/path_to_class/depend @@ -0,0 +1,13 @@ +# AUTOGENERATED DEPENDENCIES START +path_to_class.o: $(RUBY_EXTCONF_H) +path_to_class.o: $(arch_hdrdir)/ruby/config.h +path_to_class.o: $(hdrdir)/ruby.h +path_to_class.o: $(hdrdir)/ruby/backward.h +path_to_class.o: $(hdrdir)/ruby/defines.h +path_to_class.o: $(hdrdir)/ruby/intern.h +path_to_class.o: $(hdrdir)/ruby/missing.h +path_to_class.o: $(hdrdir)/ruby/ruby.h +path_to_class.o: $(hdrdir)/ruby/st.h +path_to_class.o: $(hdrdir)/ruby/subst.h +path_to_class.o: path_to_class.c +# AUTOGENERATED DEPENDENCIES END diff --git a/ext/-test-/popen_deadlock/depend b/ext/-test-/popen_deadlock/depend new file mode 100644 index 00000000000000..12b31f247c85dd --- /dev/null +++ b/ext/-test-/popen_deadlock/depend @@ -0,0 +1,13 @@ +# AUTOGENERATED DEPENDENCIES START +infinite_loop_dlsym.o: $(RUBY_EXTCONF_H) +infinite_loop_dlsym.o: $(arch_hdrdir)/ruby/config.h +infinite_loop_dlsym.o: $(hdrdir)/ruby/backward.h +infinite_loop_dlsym.o: $(hdrdir)/ruby/defines.h +infinite_loop_dlsym.o: $(hdrdir)/ruby/intern.h +infinite_loop_dlsym.o: $(hdrdir)/ruby/missing.h +infinite_loop_dlsym.o: $(hdrdir)/ruby/ruby.h +infinite_loop_dlsym.o: $(hdrdir)/ruby/st.h +infinite_loop_dlsym.o: $(hdrdir)/ruby/subst.h +infinite_loop_dlsym.o: $(hdrdir)/ruby/thread.h +infinite_loop_dlsym.o: infinite_loop_dlsym.c +# AUTOGENERATED DEPENDENCIES END diff --git a/ext/-test-/proc/depend b/ext/-test-/proc/depend new file mode 100644 index 00000000000000..db48627643db56 --- /dev/null +++ b/ext/-test-/proc/depend @@ -0,0 +1,35 @@ +# AUTOGENERATED DEPENDENCIES START +init.o: $(RUBY_EXTCONF_H) +init.o: $(arch_hdrdir)/ruby/config.h +init.o: $(hdrdir)/ruby.h +init.o: $(hdrdir)/ruby/backward.h +init.o: $(hdrdir)/ruby/defines.h +init.o: $(hdrdir)/ruby/intern.h +init.o: $(hdrdir)/ruby/missing.h +init.o: $(hdrdir)/ruby/ruby.h +init.o: $(hdrdir)/ruby/st.h +init.o: $(hdrdir)/ruby/subst.h +init.o: init.c +receiver.o: $(RUBY_EXTCONF_H) +receiver.o: $(arch_hdrdir)/ruby/config.h +receiver.o: $(hdrdir)/ruby.h +receiver.o: $(hdrdir)/ruby/backward.h +receiver.o: $(hdrdir)/ruby/defines.h +receiver.o: $(hdrdir)/ruby/intern.h +receiver.o: $(hdrdir)/ruby/missing.h +receiver.o: $(hdrdir)/ruby/ruby.h +receiver.o: $(hdrdir)/ruby/st.h +receiver.o: $(hdrdir)/ruby/subst.h +receiver.o: receiver.c +super.o: $(RUBY_EXTCONF_H) +super.o: $(arch_hdrdir)/ruby/config.h +super.o: $(hdrdir)/ruby.h +super.o: $(hdrdir)/ruby/backward.h +super.o: $(hdrdir)/ruby/defines.h +super.o: $(hdrdir)/ruby/intern.h +super.o: $(hdrdir)/ruby/missing.h +super.o: $(hdrdir)/ruby/ruby.h +super.o: $(hdrdir)/ruby/st.h +super.o: $(hdrdir)/ruby/subst.h +super.o: super.c +# AUTOGENERATED DEPENDENCIES END diff --git a/ext/-test-/recursion/depend b/ext/-test-/recursion/depend new file mode 100644 index 00000000000000..30ba450d009728 --- /dev/null +++ b/ext/-test-/recursion/depend @@ -0,0 +1,13 @@ +# AUTOGENERATED DEPENDENCIES START +recursion.o: $(RUBY_EXTCONF_H) +recursion.o: $(arch_hdrdir)/ruby/config.h +recursion.o: $(hdrdir)/ruby.h +recursion.o: $(hdrdir)/ruby/backward.h +recursion.o: $(hdrdir)/ruby/defines.h +recursion.o: $(hdrdir)/ruby/intern.h +recursion.o: $(hdrdir)/ruby/missing.h +recursion.o: $(hdrdir)/ruby/ruby.h +recursion.o: $(hdrdir)/ruby/st.h +recursion.o: $(hdrdir)/ruby/subst.h +recursion.o: recursion.c +# AUTOGENERATED DEPENDENCIES END diff --git a/ext/-test-/regexp/depend b/ext/-test-/regexp/depend new file mode 100644 index 00000000000000..bbea37e53be777 --- /dev/null +++ b/ext/-test-/regexp/depend @@ -0,0 +1,25 @@ +# AUTOGENERATED DEPENDENCIES START +init.o: $(RUBY_EXTCONF_H) +init.o: $(arch_hdrdir)/ruby/config.h +init.o: $(hdrdir)/ruby.h +init.o: $(hdrdir)/ruby/backward.h +init.o: $(hdrdir)/ruby/defines.h +init.o: $(hdrdir)/ruby/intern.h +init.o: $(hdrdir)/ruby/missing.h +init.o: $(hdrdir)/ruby/ruby.h +init.o: $(hdrdir)/ruby/st.h +init.o: $(hdrdir)/ruby/subst.h +init.o: init.c +parse_depth_limit.o: $(RUBY_EXTCONF_H) +parse_depth_limit.o: $(arch_hdrdir)/ruby/config.h +parse_depth_limit.o: $(hdrdir)/ruby.h +parse_depth_limit.o: $(hdrdir)/ruby/backward.h +parse_depth_limit.o: $(hdrdir)/ruby/defines.h +parse_depth_limit.o: $(hdrdir)/ruby/intern.h +parse_depth_limit.o: $(hdrdir)/ruby/missing.h +parse_depth_limit.o: $(hdrdir)/ruby/onigmo.h +parse_depth_limit.o: $(hdrdir)/ruby/ruby.h +parse_depth_limit.o: $(hdrdir)/ruby/st.h +parse_depth_limit.o: $(hdrdir)/ruby/subst.h +parse_depth_limit.o: parse_depth_limit.c +# AUTOGENERATED DEPENDENCIES END diff --git a/ext/-test-/scan_args/depend b/ext/-test-/scan_args/depend new file mode 100644 index 00000000000000..6e6bd23927a822 --- /dev/null +++ b/ext/-test-/scan_args/depend @@ -0,0 +1,13 @@ +# AUTOGENERATED DEPENDENCIES START +scan_args.o: $(RUBY_EXTCONF_H) +scan_args.o: $(arch_hdrdir)/ruby/config.h +scan_args.o: $(hdrdir)/ruby.h +scan_args.o: $(hdrdir)/ruby/backward.h +scan_args.o: $(hdrdir)/ruby/defines.h +scan_args.o: $(hdrdir)/ruby/intern.h +scan_args.o: $(hdrdir)/ruby/missing.h +scan_args.o: $(hdrdir)/ruby/ruby.h +scan_args.o: $(hdrdir)/ruby/st.h +scan_args.o: $(hdrdir)/ruby/subst.h +scan_args.o: scan_args.c +# AUTOGENERATED DEPENDENCIES END diff --git a/ext/-test-/st/foreach/depend b/ext/-test-/st/foreach/depend new file mode 100644 index 00000000000000..f649c3b2a6efe8 --- /dev/null +++ b/ext/-test-/st/foreach/depend @@ -0,0 +1,13 @@ +# AUTOGENERATED DEPENDENCIES START +foreach.o: $(RUBY_EXTCONF_H) +foreach.o: $(arch_hdrdir)/ruby/config.h +foreach.o: $(hdrdir)/ruby.h +foreach.o: $(hdrdir)/ruby/backward.h +foreach.o: $(hdrdir)/ruby/defines.h +foreach.o: $(hdrdir)/ruby/intern.h +foreach.o: $(hdrdir)/ruby/missing.h +foreach.o: $(hdrdir)/ruby/ruby.h +foreach.o: $(hdrdir)/ruby/st.h +foreach.o: $(hdrdir)/ruby/subst.h +foreach.o: foreach.c +# AUTOGENERATED DEPENDENCIES END diff --git a/ext/-test-/st/numhash/depend b/ext/-test-/st/numhash/depend new file mode 100644 index 00000000000000..5eb6faa45c5d81 --- /dev/null +++ b/ext/-test-/st/numhash/depend @@ -0,0 +1,13 @@ +# AUTOGENERATED DEPENDENCIES START +numhash.o: $(RUBY_EXTCONF_H) +numhash.o: $(arch_hdrdir)/ruby/config.h +numhash.o: $(hdrdir)/ruby.h +numhash.o: $(hdrdir)/ruby/backward.h +numhash.o: $(hdrdir)/ruby/defines.h +numhash.o: $(hdrdir)/ruby/intern.h +numhash.o: $(hdrdir)/ruby/missing.h +numhash.o: $(hdrdir)/ruby/ruby.h +numhash.o: $(hdrdir)/ruby/st.h +numhash.o: $(hdrdir)/ruby/subst.h +numhash.o: numhash.c +# AUTOGENERATED DEPENDENCIES END diff --git a/ext/-test-/st/update/depend b/ext/-test-/st/update/depend new file mode 100644 index 00000000000000..b5abfc1173c68a --- /dev/null +++ b/ext/-test-/st/update/depend @@ -0,0 +1,13 @@ +# AUTOGENERATED DEPENDENCIES START +update.o: $(RUBY_EXTCONF_H) +update.o: $(arch_hdrdir)/ruby/config.h +update.o: $(hdrdir)/ruby.h +update.o: $(hdrdir)/ruby/backward.h +update.o: $(hdrdir)/ruby/defines.h +update.o: $(hdrdir)/ruby/intern.h +update.o: $(hdrdir)/ruby/missing.h +update.o: $(hdrdir)/ruby/ruby.h +update.o: $(hdrdir)/ruby/st.h +update.o: $(hdrdir)/ruby/subst.h +update.o: update.c +# AUTOGENERATED DEPENDENCIES END diff --git a/ext/-test-/symbol/depend b/ext/-test-/symbol/depend new file mode 100644 index 00000000000000..e7bba43501b7d3 --- /dev/null +++ b/ext/-test-/symbol/depend @@ -0,0 +1,24 @@ +# AUTOGENERATED DEPENDENCIES START +init.o: $(RUBY_EXTCONF_H) +init.o: $(arch_hdrdir)/ruby/config.h +init.o: $(hdrdir)/ruby.h +init.o: $(hdrdir)/ruby/backward.h +init.o: $(hdrdir)/ruby/defines.h +init.o: $(hdrdir)/ruby/intern.h +init.o: $(hdrdir)/ruby/missing.h +init.o: $(hdrdir)/ruby/ruby.h +init.o: $(hdrdir)/ruby/st.h +init.o: $(hdrdir)/ruby/subst.h +init.o: init.c +type.o: $(RUBY_EXTCONF_H) +type.o: $(arch_hdrdir)/ruby/config.h +type.o: $(hdrdir)/ruby.h +type.o: $(hdrdir)/ruby/backward.h +type.o: $(hdrdir)/ruby/defines.h +type.o: $(hdrdir)/ruby/intern.h +type.o: $(hdrdir)/ruby/missing.h +type.o: $(hdrdir)/ruby/ruby.h +type.o: $(hdrdir)/ruby/st.h +type.o: $(hdrdir)/ruby/subst.h +type.o: type.c +# AUTOGENERATED DEPENDENCIES END diff --git a/ext/-test-/typeddata/depend b/ext/-test-/typeddata/depend new file mode 100644 index 00000000000000..4d3c9f0d072dd9 --- /dev/null +++ b/ext/-test-/typeddata/depend @@ -0,0 +1,13 @@ +# AUTOGENERATED DEPENDENCIES START +typeddata.o: $(RUBY_EXTCONF_H) +typeddata.o: $(arch_hdrdir)/ruby/config.h +typeddata.o: $(hdrdir)/ruby.h +typeddata.o: $(hdrdir)/ruby/backward.h +typeddata.o: $(hdrdir)/ruby/defines.h +typeddata.o: $(hdrdir)/ruby/intern.h +typeddata.o: $(hdrdir)/ruby/missing.h +typeddata.o: $(hdrdir)/ruby/ruby.h +typeddata.o: $(hdrdir)/ruby/st.h +typeddata.o: $(hdrdir)/ruby/subst.h +typeddata.o: typeddata.c +# AUTOGENERATED DEPENDENCIES END diff --git a/ext/bigdecimal/util/depend b/ext/bigdecimal/util/depend new file mode 100644 index 00000000000000..4cc7b931217e70 --- /dev/null +++ b/ext/bigdecimal/util/depend @@ -0,0 +1,13 @@ +# AUTOGENERATED DEPENDENCIES START +util.o: $(RUBY_EXTCONF_H) +util.o: $(arch_hdrdir)/ruby/config.h +util.o: $(hdrdir)/ruby.h +util.o: $(hdrdir)/ruby/backward.h +util.o: $(hdrdir)/ruby/defines.h +util.o: $(hdrdir)/ruby/intern.h +util.o: $(hdrdir)/ruby/missing.h +util.o: $(hdrdir)/ruby/ruby.h +util.o: $(hdrdir)/ruby/st.h +util.o: $(hdrdir)/ruby/subst.h +util.o: util.c +# AUTOGENERATED DEPENDENCIES END diff --git a/ext/json/depend b/ext/json/depend new file mode 100644 index 00000000000000..0301ce074c26bf --- /dev/null +++ b/ext/json/depend @@ -0,0 +1,2 @@ +# AUTOGENERATED DEPENDENCIES START +# AUTOGENERATED DEPENDENCIES END diff --git a/ext/rubyvm/depend b/ext/rubyvm/depend new file mode 100644 index 00000000000000..0301ce074c26bf --- /dev/null +++ b/ext/rubyvm/depend @@ -0,0 +1,2 @@ +# AUTOGENERATED DEPENDENCIES START +# AUTOGENERATED DEPENDENCIES END diff --git a/ext/win32/depend b/ext/win32/depend new file mode 100644 index 00000000000000..0301ce074c26bf --- /dev/null +++ b/ext/win32/depend @@ -0,0 +1,2 @@ +# AUTOGENERATED DEPENDENCIES START +# AUTOGENERATED DEPENDENCIES END diff --git a/ext/win32/resolv/depend b/ext/win32/resolv/depend new file mode 100644 index 00000000000000..4c2fa286bc7de0 --- /dev/null +++ b/ext/win32/resolv/depend @@ -0,0 +1,16 @@ +# AUTOGENERATED DEPENDENCIES START +resolv.o: $(RUBY_EXTCONF_H) +resolv.o: $(arch_hdrdir)/ruby/config.h +resolv.o: $(hdrdir)/ruby.h +resolv.o: $(hdrdir)/ruby/backward.h +resolv.o: $(hdrdir)/ruby/defines.h +resolv.o: $(hdrdir)/ruby/encoding.h +resolv.o: $(hdrdir)/ruby/intern.h +resolv.o: $(hdrdir)/ruby/missing.h +resolv.o: $(hdrdir)/ruby/onigmo.h +resolv.o: $(hdrdir)/ruby/oniguruma.h +resolv.o: $(hdrdir)/ruby/ruby.h +resolv.o: $(hdrdir)/ruby/st.h +resolv.o: $(hdrdir)/ruby/subst.h +resolv.o: resolv.c +# AUTOGENERATED DEPENDENCIES END diff --git a/template/depend.tmpl b/template/depend.tmpl new file mode 100644 index 00000000000000..0301ce074c26bf --- /dev/null +++ b/template/depend.tmpl @@ -0,0 +1,2 @@ +# AUTOGENERATED DEPENDENCIES START +# AUTOGENERATED DEPENDENCIES END From 69a66e8a8b492610eba77123de44e97d25012a41 Mon Sep 17 00:00:00 2001 From: git Date: Sun, 14 Jul 2019 01:32:27 +0900 Subject: [PATCH 037/452] * 2019-07-14 --- version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.h b/version.h index 4d0dd833d43a96..0a845f1ead3740 100644 --- a/version.h +++ b/version.h @@ -6,7 +6,7 @@ #define RUBY_RELEASE_YEAR 2019 #define RUBY_RELEASE_MONTH 7 -#define RUBY_RELEASE_DAY 13 +#define RUBY_RELEASE_DAY 14 #include "ruby/version.h" From ac2866005b96baf986072f86ecd3dfd887f2bda3 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 14 Jul 2019 01:41:55 +0900 Subject: [PATCH 038/452] Add empty depend file if extconf.rb only exists --- .travis.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.travis.yml b/.travis.yml index c4ee4d7069bc98..03f110702ecbb2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -345,6 +345,17 @@ env: before_install: install: before_script: + - |- + ruby -e 'new = [] + Dir.glob("ext/**/extconf.rb") {|ex| + unless File.exist?(dep = File.dirname(ex)+"/depend") + puts "Adding "+dep + File.copy_stream("template/depend.tmpl", dep) + new << dep + end + } + exec("git", "add", *new) unless new.empty?' + - git diff --cached - "> config.status" - "> .rbconfig.time" - sed -f tool/prereq.status template/Makefile.in common.mk > Makefile From 369ff79394765ce198ac7cee872a8c739d895aaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20D=C3=BCrst?= Date: Sun, 14 Jul 2019 10:58:50 +0900 Subject: [PATCH 039/452] add encoding conversion from/to CESU-8 Add encoding conversion (transcoding) from UTF-8 to CESU-8 and back. CESU-8 is an encoding similar to UTF-8, but encodes codepoints above U+FFFF as two surrogates, these surrogates again being encoded as if they were UTF-8 codepoints. This preserves the same binary sorting order as in UTF-16. It is also somewhat similar (although not exactly identical) to an encoding used internally by Java. This completes issue #15995. enc/trans/cesu_8.trans: Add encoding conversion from/to CESU-8 test/ruby/test_transcode.rb: Add tests for above --- enc/trans/cesu_8.trans | 85 +++++++++++++++++++++++++++++++++++++ test/ruby/test_transcode.rb | 22 ++++++++++ 2 files changed, 107 insertions(+) create mode 100644 enc/trans/cesu_8.trans diff --git a/enc/trans/cesu_8.trans b/enc/trans/cesu_8.trans new file mode 100644 index 00000000000000..4e17b1ddbb51a3 --- /dev/null +++ b/enc/trans/cesu_8.trans @@ -0,0 +1,85 @@ +#include "transcode_data.h" + +<% + map = {} + map["{00-7f}"] = :nomap + map["{c2-df}{80-bf}"] = :nomap + map["e0{a0-bf}{80-bf}"] = :nomap + map["{e1-ec}{80-bf}{80-bf}"] = :nomap + map["ed{80-9f}{80-bf}"] = :nomap + map["{ee-ef}{80-bf}{80-bf}"] = :nomap + map["ed{a0-af}{80-bf}ed{b0-bf}{80-bf}"] = :func_so # surrogate pairs + transcode_generate_node(ActionMap.parse(map), "from_CESU_8") + + map = {} + map["{00-7f}"] = :nomap + map["{c2-df}{80-bf}"] = :nomap + map["e0{a0-bf}{80-bf}"] = :nomap + map["{e1-ec}{80-bf}{80-bf}"] = :nomap + map["ed{80-9f}{80-bf}"] = :nomap + map["{ee-ef}{80-bf}{80-bf}"] = :nomap + map["f0{90-bf}{80-bf}{80-bf}"] = :func_so # planes 1-3 + map["{f1-f3}{80-bf}{80-bf}{80-bf}"] = :func_so # planes 4-15 + map["f4{80-8f}{80-bf}{80-bf}"] = :func_so # plane 16 + transcode_generate_node(ActionMap.parse(map), "to_CESU_8") +%> + +<%= transcode_generated_code %> + +static ssize_t +fun_so_from_cesu_8(void *statep, const unsigned char *s, size_t l, unsigned char *o, size_t osize) +{ + unsigned int scalar = ( ((s[1]&0x0F)<<16) | ((s[2]&0x3F)<<10) + | ((s[4]&0x0F)<< 6) | (s[5]&0x3F) + ) + 0x10000; + o[0] = 0xF0 | (scalar>>18); + o[1] = 0x80 | ((scalar>>12)&0x3F); + o[2] = 0x80 | ((scalar>> 6)&0x3F); + o[3] = 0x80 | ( scalar &0x3F); + return 4; +} + +static ssize_t +fun_so_to_cesu_8(void *statep, const unsigned char *s, size_t l, unsigned char *o, size_t osize) +{ + unsigned int scalar = ((s[0]&0x07)<<18) | ((s[1]&0x3F)<<12) + | ((s[2]&0x3F)<< 6) | (s[3]&0x3F); + scalar -= 0x10000; + o[0] = 0xED; + o[1] = 0xA0 | (scalar>>16); + o[2] = 0x80 | ((scalar>>10)&0x3F); + o[3] = 0xED; + o[4] = 0xB0 | ((scalar>> 6)&0x0F); + o[5] = 0x80 | (scalar &0x3F); + return 6; +} + +static const rb_transcoder +rb_from_CESU_8 = { + "CESU-8", "UTF-8", from_CESU_8, + TRANSCODE_TABLE_INFO, + 1, /* input_unit_length */ + 6, /* max_input */ + 4, /* max_output */ + asciicompat_decoder, /* asciicompat_type */ + 0, NULL, NULL, /* state_size, state_init, state_fini */ + NULL, NULL, NULL, fun_so_from_cesu_8 +}; + +static const rb_transcoder +rb_to_CESU_8 = { + "UTF-8", "CESU-8", to_CESU_8, + TRANSCODE_TABLE_INFO, + 1, /* input_unit_length */ + 4, /* max_input */ + 6, /* max_output */ + asciicompat_encoder, /* asciicompat_type */ + 0, NULL, NULL, /* state_size, state_init, state_fini */ + NULL, NULL, NULL, fun_so_to_cesu_8 +}; + +TRANS_INIT(cesu_8) +{ + rb_register_transcoder(&rb_from_CESU_8); + rb_register_transcoder(&rb_to_CESU_8); +} diff --git a/test/ruby/test_transcode.rb b/test/ruby/test_transcode.rb index 44d238ffd25d22..f405877dd521a5 100644 --- a/test/ruby/test_transcode.rb +++ b/test/ruby/test_transcode.rb @@ -2116,6 +2116,28 @@ def test_EBCDIC check_both_ways("D\u00FCrst", "\xC4\xDC\x99\xA2\xA3", 'IBM037') # Dürst end + def test_CESU_8 + check_both_ways("aijrszAIJRSZ09", "aijrszAIJRSZ09", 'CESU-8') # single bytes + + # check NULL explicitly + # this is different in CESU-8 and in Java modified UTF-8 strings + check_both_ways("\0", "\0", 'CESU-8') + + # U+0080 U+00FC U+00FF U+0100 U+0400 U+0700 U+07FF + two_byte_chars = "\xC2\x80\x20\xC3\xBC\x20\xC3\xBF\x20\xC4\x80\x20\xD0\x80\x20\xDC\x80\x20\xDF\xBF" + check_both_ways(two_byte_chars, two_byte_chars, 'CESU-8') + + # U+0800 U+2200 U+4E00 U+D7FF U+E000 U+FFFF + three_byte_chars = "\xE0\xA0\x80\x20\xE2\x88\x80\x20\xE4\xB8\x80\x20\xED\x9F\xBF\x20\xEE\x80\x80\x20\xEF\xBF\xBF" + check_both_ways(three_byte_chars, three_byte_chars, 'CESU-8') + + # characters outside BMP (double surrogates in CESU-8) + # U+10000 U+20000 U+50000 U+10FFFF + utf8 = "\xF0\x90\x80\x80 \xF0\xA0\x80\x80 \xF1\x90\x80\x80 \xF4\x8F\xBF\xBF" + cesu = "\xED\xA0\x80\xED\xB0\x80 \xED\xA1\x80\xED\xB0\x80 \xED\xA4\x80\xED\xB0\x80 \xED\xAF\xBF\xED\xBF\xBF" + check_both_ways(utf8, cesu, 'CESU-8') + end + def test_nothing_changed a = "James".force_encoding("US-ASCII") b = a.encode("Shift_JIS") From 4402c669785e7343cd65e4e90e436a3f8a3e00b5 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Sun, 14 Jul 2019 12:53:39 +0900 Subject: [PATCH 040/452] Refactor mjit_worker command line with C99 Mostly non-constatnt array initializer, and mixed declarations and code. --- mjit_worker.c | 52 +++++++++++++++++---------------------------------- 1 file changed, 17 insertions(+), 35 deletions(-) diff --git a/mjit_worker.c b/mjit_worker.c index 6bbcfdf8f86c0b..9f8a5f0bbd22ba 100644 --- a/mjit_worker.c +++ b/mjit_worker.c @@ -609,7 +609,6 @@ static int exec_process(const char *path, char *const argv[]) { int stat, exit_code = -2; - pid_t pid; rb_vm_t *vm = WAITPID_USE_SIGCHLD ? GET_VM() : 0; rb_nativethread_cond_t cond; @@ -618,7 +617,7 @@ exec_process(const char *path, char *const argv[]) rb_native_mutex_lock(&vm->waitpid_lock); } - pid = start_process(path, argv); + pid_t pid = start_process(path, argv); for (;pid > 0;) { pid_t r = vm ? ruby_waitpid_locked(vm, pid, &stat, 0, &cond) : waitpid(pid, &stat, 0); @@ -670,10 +669,8 @@ remove_so_file(const char *so_file, struct rb_mjit_unit *unit) static bool compile_c_to_so(const char *c_file, const char *so_file) { - int exit_code; const char *files[] = { NULL, NULL, NULL, NULL, NULL, NULL, "-link", libruby_pathflag, NULL }; - char **args; - char *p, *obj_file; + char *p; // files[0] = "-Fe*.dll" files[0] = p = alloca(sizeof(char) * (rb_strlen_lit("-Fe") + strlen(so_file) + 1)); @@ -684,7 +681,7 @@ compile_c_to_so(const char *c_file, const char *so_file) // files[1] = "-Fo*.obj" // We don't need .obj file, but it's somehow created to cwd without -Fo and we want to control the output directory. files[1] = p = alloca(sizeof(char) * (rb_strlen_lit("-Fo") + strlen(so_file) - rb_strlen_lit(DLEXT) + rb_strlen_lit(".obj") + 1)); - obj_file = p = append_lit(p, "-Fo"); + char *obj_file = p = append_lit(p, "-Fo"); p = append_str2(p, so_file, strlen(so_file) - rb_strlen_lit(DLEXT)); p = append_lit(p, ".obj"); *p = '\0'; @@ -714,12 +711,12 @@ compile_c_to_so(const char *c_file, const char *so_file) p = append_lit(p, ".pdb"); *p = '\0'; - args = form_args(5, CC_LDSHARED_ARGS, CC_CODEFLAG_ARGS, - files, CC_LIBS, CC_DLDFLAGS_ARGS); + char **args = form_args(5, CC_LDSHARED_ARGS, CC_CODEFLAG_ARGS, + files, CC_LIBS, CC_DLDFLAGS_ARGS); if (args == NULL) return false; - exit_code = exec_process(cc_path, args); + int exit_code = exec_process(cc_path, args); free(args); if (exit_code == 0) { @@ -745,7 +742,6 @@ compile_c_to_so(const char *c_file, const char *so_file) static void make_pch(void) { - int exit_code; const char *rest_args[] = { # ifdef __clang__ "-emit-pch", @@ -753,16 +749,12 @@ make_pch(void) // -nodefaultlibs is a linker flag, but it may affect cc1 behavior on Gentoo, which should NOT be changed on pch: // https://gitweb.gentoo.org/proj/gcc-patches.git/tree/7.3.0/gentoo/13_all_default-ssp-fix.patch GCC_NOSTDLIB_FLAGS - "-o", NULL, NULL, + "-o", pch_file, header_file, NULL, }; - char **args; - int len = sizeof(rest_args) / sizeof(const char *); - rest_args[len - 2] = header_file; - rest_args[len - 3] = pch_file; verbose(2, "Creating precompiled header"); - args = form_args(3, cc_common_args, CC_CODEFLAG_ARGS, rest_args); + char **args = form_args(3, cc_common_args, CC_CODEFLAG_ARGS, rest_args); if (args == NULL) { mjit_warning("making precompiled header failed on forming args"); CRITICAL_SECTION_START(3, "in make_pch"); @@ -771,7 +763,7 @@ make_pch(void) return; } - exit_code = exec_process(cc_path, args); + int exit_code = exec_process(cc_path, args); free(args); CRITICAL_SECTION_START(3, "in make_pch"); @@ -791,26 +783,19 @@ make_pch(void) static bool compile_c_to_o(const char *c_file, const char *o_file) { - int exit_code; const char *files[] = { - "-o", NULL, NULL, + "-o", o_file, c_file, # ifdef __clang__ - "-include-pch", NULL, + "-include-pch", pch_file, # endif "-c", NULL }; - char **args; - files[1] = o_file; - files[2] = c_file; -# ifdef __clang__ - files[4] = pch_file; -# endif - args = form_args(5, cc_common_args, CC_CODEFLAG_ARGS, files, CC_LIBS, CC_DLDFLAGS_ARGS); + char **args = form_args(5, cc_common_args, CC_CODEFLAG_ARGS, files, CC_LIBS, CC_DLDFLAGS_ARGS); if (args == NULL) return false; - exit_code = exec_process(cc_path, args); + int exit_code = exec_process(cc_path, args); free(args); if (exit_code != 0) @@ -822,23 +807,20 @@ compile_c_to_o(const char *c_file, const char *o_file) static bool link_o_to_so(const char **o_files, const char *so_file) { - int exit_code; const char *options[] = { - "-o", NULL, + "-o", so_file, # ifdef _WIN32 libruby_pathflag, # endif NULL }; - char **args; - options[1] = so_file; - args = form_args(6, CC_LDSHARED_ARGS, CC_CODEFLAG_ARGS, - options, o_files, CC_LIBS, CC_DLDFLAGS_ARGS); + char **args = form_args(6, CC_LDSHARED_ARGS, CC_CODEFLAG_ARGS, + options, o_files, CC_LIBS, CC_DLDFLAGS_ARGS); if (args == NULL) return false; - exit_code = exec_process(cc_path, args); + int exit_code = exec_process(cc_path, args); free(args); if (exit_code != 0) From 18603e9046c0baa23560268e16ead6bbc27726c2 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Sun, 14 Jul 2019 12:55:57 +0900 Subject: [PATCH 041/452] Update dependencies for 369ff79394765ce198ac7cee872a8c739d895aaa Just copy-pasting diff from https://travis-ci.org/ruby/ruby/jobs/558407687 --- enc/depend | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/enc/depend b/enc/depend index 092d09b055ca04..bf298ff7857e08 100644 --- a/enc/depend +++ b/enc/depend @@ -447,6 +447,16 @@ enc/trans/big5.$(OBJEXT): intern.h enc/trans/big5.$(OBJEXT): missing.h enc/trans/big5.$(OBJEXT): st.h enc/trans/big5.$(OBJEXT): subst.h +enc/trans/cesu_8.$(OBJEXT): $(hdrdir)/ruby/ruby.h +enc/trans/cesu_8.$(OBJEXT): $(top_srcdir)/transcode_data.h +enc/trans/cesu_8.$(OBJEXT): backward.h +enc/trans/cesu_8.$(OBJEXT): config.h +enc/trans/cesu_8.$(OBJEXT): defines.h +enc/trans/cesu_8.$(OBJEXT): enc/trans/cesu_8.c +enc/trans/cesu_8.$(OBJEXT): intern.h +enc/trans/cesu_8.$(OBJEXT): missing.h +enc/trans/cesu_8.$(OBJEXT): st.h +enc/trans/cesu_8.$(OBJEXT): subst.h enc/trans/chinese.$(OBJEXT): $(hdrdir)/ruby/ruby.h enc/trans/chinese.$(OBJEXT): $(top_srcdir)/transcode_data.h enc/trans/chinese.$(OBJEXT): backward.h From 315d3adf0f9660568bdca01fd6ddd196c92973d2 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Sun, 14 Jul 2019 13:49:39 +0900 Subject: [PATCH 042/452] Avoid io_tell whose return value is not used In this case, flush_before_seek is enough. This change will suppress a warning of Coverity Scan. --- io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/io.c b/io.c index 3e3a0ed4489f42..e4d9f3c4ec2df7 100644 --- a/io.c +++ b/io.c @@ -7275,7 +7275,7 @@ io_reopen(VALUE io, VALUE nfile) rb_sys_fail(0); } else { - io_tell(fptr); + flush_before_seek(fptr); } if (orig->mode & FMODE_READABLE) { pos = io_tell(orig); From 1d46642487d5340cf6c1f17b36ff0f64b0c1595c Mon Sep 17 00:00:00 2001 From: git Date: Sun, 14 Jul 2019 13:57:57 +0900 Subject: [PATCH 043/452] * expand tabs. --- io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/io.c b/io.c index e4d9f3c4ec2df7..154b45e95011aa 100644 --- a/io.c +++ b/io.c @@ -7275,7 +7275,7 @@ io_reopen(VALUE io, VALUE nfile) rb_sys_fail(0); } else { - flush_before_seek(fptr); + flush_before_seek(fptr); } if (orig->mode & FMODE_READABLE) { pos = io_tell(orig); From ba94404f7021fae41a827e080be6d5dd0bbac8e4 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Sun, 14 Jul 2019 14:03:44 +0900 Subject: [PATCH 044/452] Add /* fall through */ comments to suppress some Coverity Scan warnings --- marshal.c | 7 ++++--- sprintf.c | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/marshal.c b/marshal.c index 3396d897dd96a8..8f4a0aeb80f492 100644 --- a/marshal.c +++ b/marshal.c @@ -370,12 +370,12 @@ load_mantissa(double d, const char *buf, long len) do { m = 0; switch (len) { - default: m = *buf++ & 0xff; + default: m = *buf++ & 0xff; /* fall through */ #if MANT_BITS > 24 - case 3: m = (m << 8) | (*buf++ & 0xff); + case 3: m = (m << 8) | (*buf++ & 0xff); /* fall through */ #endif #if MANT_BITS > 16 - case 2: m = (m << 8) | (*buf++ & 0xff); + case 2: m = (m << 8) | (*buf++ & 0xff); /* fall through */ #endif #if MANT_BITS > 8 case 1: m = (m << 8) | (*buf++ & 0xff); @@ -1799,6 +1799,7 @@ r_object0(struct load_arg *arg, int *ivp, VALUE extmod) case 'L': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'X': case 'Y': if (bs & 1) --dst; + /* fall through */ default: bs = 0; break; } } diff --git a/sprintf.c b/sprintf.c index 53abbddca73175..471d65544752d3 100644 --- a/sprintf.c +++ b/sprintf.c @@ -677,6 +677,7 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt) case '\n': case '\0': p--; + /* fall through */ case '%': if (flags != FNONE) { rb_raise(rb_eArgError, "invalid format character - %%"); From ff5b149435f6ae167df6cc8a17ad49b4c92209f1 Mon Sep 17 00:00:00 2001 From: git Date: Sun, 14 Jul 2019 14:04:34 +0900 Subject: [PATCH 045/452] * expand tabs. --- marshal.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/marshal.c b/marshal.c index 8f4a0aeb80f492..7cd4756fd09b5e 100644 --- a/marshal.c +++ b/marshal.c @@ -370,12 +370,12 @@ load_mantissa(double d, const char *buf, long len) do { m = 0; switch (len) { - default: m = *buf++ & 0xff; /* fall through */ + default: m = *buf++ & 0xff; /* fall through */ #if MANT_BITS > 24 - case 3: m = (m << 8) | (*buf++ & 0xff); /* fall through */ + case 3: m = (m << 8) | (*buf++ & 0xff); /* fall through */ #endif #if MANT_BITS > 16 - case 2: m = (m << 8) | (*buf++ & 0xff); /* fall through */ + case 2: m = (m << 8) | (*buf++ & 0xff); /* fall through */ #endif #if MANT_BITS > 8 case 1: m = (m << 8) | (*buf++ & 0xff); From 34b3ef29b60f1351130f2ccc8adf3d174861233c Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Sun, 14 Jul 2019 14:09:32 +0900 Subject: [PATCH 046/452] Drop obsoleted mjit_cancel_ivar debug_counter ivar_cancel label is handling mjit_cancel_ivar_inline instead. --- tool/ruby_vm/views/_mjit_compile_ivar.erb | 1 - 1 file changed, 1 deletion(-) diff --git a/tool/ruby_vm/views/_mjit_compile_ivar.erb b/tool/ruby_vm/views/_mjit_compile_ivar.erb index cf0026945b6e36..3d5e0e8f547528 100644 --- a/tool/ruby_vm/views/_mjit_compile_ivar.erb +++ b/tool/ruby_vm/views/_mjit_compile_ivar.erb @@ -42,7 +42,6 @@ fprintf(f, " else {\n"); fprintf(f, " reg_cfp->pc = original_body_iseq + %d;\n", pos); fprintf(f, " reg_cfp->sp = vm_base_ptr(reg_cfp) + %d;\n", b->stack_size); - fprintf(f, " RB_DEBUG_COUNTER_INC(mjit_cancel_ivar);\n"); fprintf(f, " goto ivar_cancel;\n"); fprintf(f, " }\n"); From 219643c075d9f5641307853cae052383bb289a11 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Sun, 14 Jul 2019 14:27:45 +0900 Subject: [PATCH 047/452] Add a /* fall through */ comment --- time.c | 1 + 1 file changed, 1 insertion(+) diff --git a/time.c b/time.c index 3ed694fe232226..8d1bfd3452b489 100644 --- a/time.c +++ b/time.c @@ -2087,6 +2087,7 @@ utc_offset_arg(VALUE arg) if (s[6] != ':') goto invalid_utc_offset; if (!ISDIGIT(s[7]) || !ISDIGIT(s[8])) goto invalid_utc_offset; n += (s[7] * 10 + s[8] - '0' * 11); + /* fall through */ case 6: if (s[0] != '+' && s[0] != '-') goto invalid_utc_offset; if (!ISDIGIT(s[1]) || !ISDIGIT(s[2])) goto invalid_utc_offset; From 421dd3114579f90ecced6cf221828a730357b50f Mon Sep 17 00:00:00 2001 From: Kazuhiro NISHIYAMA Date: Sun, 14 Jul 2019 14:33:28 +0900 Subject: [PATCH 048/452] [DOC] Fix experimental marker [ci skip] --- doc/NEWS-2.6.0 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/NEWS-2.6.0 b/doc/NEWS-2.6.0 index 47430ea9152351..ee0a8c3ff90f74 100644 --- a/doc/NEWS-2.6.0 +++ b/doc/NEWS-2.6.0 @@ -288,8 +288,8 @@ RubyVM::AbstractSyntaxTree:: * RubyVM::AbstractSyntaxTree.parse_file parses a given file and returns AST nodes. [experimental] - * RubyVM::AbstractSyntaxTree.of returns AST nodes of the given proc or method. - experimental:: + * RubyVM::AbstractSyntaxTree.of returns AST nodes of the given proc or + method. [experimental] RubyVM:: From 4f351111b811a7437f8356172a6cc59d8fb37022 Mon Sep 17 00:00:00 2001 From: Kazuhiro NISHIYAMA Date: Sun, 14 Jul 2019 14:40:38 +0900 Subject: [PATCH 049/452] NEWS: warning of flip-flop is reverted [ci skip] --- NEWS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS b/NEWS index a917007ad121eb..ef84aa3daa5e3d 100644 --- a/NEWS +++ b/NEWS @@ -60,6 +60,8 @@ sufficient information, see the ChangeLog file or Redmine .bar(1, 2) .display +* The flip-flop syntax deprecation is reverted. [Feature #5400] + === Core classes updates (outstanding ones only) Complex:: From 6da539be3ec9e9ba7a45877108d095dcb349cabe Mon Sep 17 00:00:00 2001 From: Kazuhiro NISHIYAMA Date: Sun, 14 Jul 2019 14:52:31 +0900 Subject: [PATCH 050/452] Fix typos [ci skip] --- doc/NEWS-2.6.0 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/NEWS-2.6.0 b/doc/NEWS-2.6.0 index ee0a8c3ff90f74..e44ee67c60f31b 100644 --- a/doc/NEWS-2.6.0 +++ b/doc/NEWS-2.6.0 @@ -97,7 +97,7 @@ Enumerable:: * Enumerable#to_h now accepts a block that maps elements to new key/value pairs. [Feature #15143] - Aliased methods:: + Aliased method:: * Enumerable#filter is a new alias for Enumerable#select. [Feature #13784] @@ -116,7 +116,7 @@ Enumerator::Chain:: Enumerator::Lazy:: - Aliased methods:: + Aliased method:: * Enumerator::Lazy#filter is a new alias for Enumerator::Lazy#select. [Feature #13784] @@ -165,7 +165,7 @@ IO:: Kernel:: - Aliased methods:: + Aliased method:: * Kernel#then is a new alias for Kernel#yield_self. [Feature #14594] @@ -534,7 +534,7 @@ RubyGems:: Set:: - Aliased methods:: + Aliased method:: * Set#filter! is a new alias for Set#select!. [Feature #13784] From dda2c860d97ce3149361b143c9ccc5ed1a2f1af2 Mon Sep 17 00:00:00 2001 From: Kazuhiro NISHIYAMA Date: Sun, 14 Jul 2019 14:59:34 +0900 Subject: [PATCH 051/452] [DOC] Fix link to feature [ci skip] --- doc/NEWS-2.6.0 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/NEWS-2.6.0 b/doc/NEWS-2.6.0 index e44ee67c60f31b..18eaa1a403b9bd 100644 --- a/doc/NEWS-2.6.0 +++ b/doc/NEWS-2.6.0 @@ -340,8 +340,8 @@ TracePoint:: Modified methods:: - * TracePoint#enable accepts new keywords "target:" and "target_line:". - Feature #15289:: + * TracePoint#enable accepts new keywords "target:" and + "target_line:". [Feature #15289] === Stdlib updates (outstanding ones only) From 357f295a0e97a105e51d0b3a4b5c062c55dffe92 Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Sun, 14 Jul 2019 15:01:39 +0900 Subject: [PATCH 052/452] Describe lambda-ness of Proc more. --- proc.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 65 insertions(+), 4 deletions(-) diff --git a/proc.c b/proc.c index 1a3f3372959ec0..7f4f2d46b67f23 100644 --- a/proc.c +++ b/proc.c @@ -172,8 +172,10 @@ proc_clone(VALUE self) * call-seq: * prc.lambda? -> true or false * - * Returns +true+ for a Proc object for which argument handling is rigid. - * Such procs are typically generated by +lambda+. + * Returns +true+ if a Proc object is lambda. + * +false+ if non-lambda. + * + * The lambda-ness affects argument handling and the behavior of +return+ and +break+. * * A Proc object generated by +proc+ ignores extra arguments. * @@ -3370,9 +3372,11 @@ rb_method_compose_to_right(VALUE self, VALUE g) * Procs are coming in two flavors: lambda and non-lambda (regular procs). * Differences are: * - * * In lambdas, +return+ means exit from this lambda; - * * In regular procs, +return+ means exit from embracing method + * * In lambdas, +return+ and +break+ means exit from this lambda; + * * In non-lambda procs, +return+ means exit from embracing method * (and will throw +LocalJumpError+ if invoked outside the method); + * * In non-lambda procs, +break+ means exit from the method which the block given for. + * (and will throw +LocalJumpError+ if invoked after the method returns); * * In lambdas, arguments are treated in the same way as in methods: strict, * with +ArgumentError+ for mismatching argument number, * and no additional argument processing; @@ -3383,6 +3387,40 @@ rb_method_compose_to_right(VALUE self, VALUE g) * * Examples: * + * # +return+ in non-lambda proc, +b+, exits +m2+. + * # (The block +{ return }+ is given for +m1+ and embraced by +m2+.) + * $a = []; def m1(&b) b.call; $a << :m1 end; def m2() m1 { return }; $a << :m2 end; m2; p $a + * #=> [] + * + * # +break+ in non-lambda proc, +b+, exits +m1+. + * # (The block +{ break }+ is given for +m1+ and embraced by +m2+.) + * $a = []; def m1(&b) b.call; $a << :m1 end; def m2() m1 { break }; $a << :m2 end; m2; p $a + * #=> [:m2] + * + * # +next+ in non-lambda proc, +b+, exits the block. + * # (The block +{ next }+ is given for +m1+ and embraced by +m2+.) + * $a = []; def m1(&b) b.call; $a << :m1 end; def m2() m1 { next }; $a << :m2 end; m2; p $a + * #=> [:m1, :m2] + * + * # Using +proc+ method changes the behavior as follows because + * # The block is given for +proc+ method and embraced by +m2+. + * $a = []; def m1(&b) b.call; $a << :m1 end; def m2() m1(&proc { return }); $a << :m2 end; m2; p $a + * #=> [] + * $a = []; def m1(&b) b.call; $a << :m1 end; def m2() m1(&proc { break }); $a << :m2 end; m2; p $a + * # break from proc-closure (LocalJumpError) + * $a = []; def m1(&b) b.call; $a << :m1 end; def m2() m1(&proc { next }); $a << :m2 end; m2; p $a + * #=> [:m1, :m2] + * + * # +return+, +break+ and +next+ in the subby lambda exits the block. + * # (+lambda+ method behaves same.) + * # (The block is given for stubby lambda syntax and embraced by +m2+.) + * $a = []; def m1(&b) b.call; $a << :m1 end; def m2() m1(&-> { return }); $a << :m2 end; m2; p $a + * #=> [:m1, :m2] + * $a = []; def m1(&b) b.call; $a << :m1 end; def m2() m1(&-> { break }); $a << :m2 end; m2; p $a + * #=> [:m1, :m2] + * $a = []; def m1(&b) b.call; $a << :m1 end; def m2() m1(&-> { next }); $a << :m2 end; m2; p $a + * #=> [:m1, :m2] + * * p = proc {|x, y| "x=#{x}, y=#{y}" } * p.call(1, 2) #=> "x=1, y=2" * p.call([1, 2]) #=> "x=1, y=2", array deconstructed @@ -3487,6 +3525,29 @@ rb_method_compose_to_right(VALUE self, VALUE g) * {test: 1}.to_proc.call(:test) #=> 1 * %i[test many keys].map(&{test: 1}) #=> [1, nil, nil] * + * == Orphaned Proc + * + * +return+ and +break+ in a block exit a method. + * If a Proc object is generated from the block and the Proc object + * survives until the method is returned, +return+ and +break+ cannot work. + * In such case, +return+ and +break+ raises LocalJumpError. + * A Proc object in such situation is called as orphaned Proc object. + * + * Note that the method to exit is different for +return+ and +break+. + * There is a situation that orphaned for +break+ but not orphaned for +return+. + * + * def m1(&b) b.call end; def m2(); m1 { return } end; m2 # ok + * def m1(&b) b.call end; def m2(); m1 { break } end; m2 # ok + * + * def m1(&b) b end; def m2(); m1 { return }.call end; m2 # ok + * def m1(&b) b end; def m2(); m1 { break }.call end; m2 # LocalJumpError + * + * def m1(&b) b end; def m2(); m1 { return } end; m2.call # LocalJumpError + * def m1(&b) b end; def m2(); m1 { break } end; m2.call # LocalJumpError + * + * Since +return+ and +break+ exists the block itself in lambdas, + * lambdas cannot be orphaned. + * */ From 7504d676c8ee245bb3b117e743fb3921a3ab56f7 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Sun, 14 Jul 2019 14:17:06 +0900 Subject: [PATCH 053/452] Do not use hard-coded file path of default gems upstream. --- tool/sync_default_gems.rb | 132 +++++++++++++++++++------------------- 1 file changed, 67 insertions(+), 65 deletions(-) diff --git a/tool/sync_default_gems.rb b/tool/sync_default_gems.rb index 1746a4247241c6..3626bc094e6776 100644 --- a/tool/sync_default_gems.rb +++ b/tool/sync_default_gems.rb @@ -84,138 +84,140 @@ def sync_default_gems(gem) puts "Sync #{$repositories[gem.to_sym]}" + upstream = File.join("..", "..", $repositories[gem.to_sym]) + case gem when "rubygems" `rm -rf lib/rubygems* test/rubygems` - `cp -r ../../rubygems/rubygems/lib/rubygems* ./lib` - `cp -r ../../rubygems/rubygems/test/rubygems ./test` + `cp -r #{upstream}/lib/rubygems* ./lib` + `cp -r #{upstream}/test/rubygems ./test` when "bundler" `rm -rf lib/bundler* libexec/bundler libexec/bundle spec/bundler man/bundle* man/gemfile*` - `cp -r ../../bundler/bundler/lib/bundler* ./lib` - `cp -r ../../bundler/bundler/exe/bundle* ./libexec` - `cp ../../bundler/bundler/bundler.gemspec ./lib/bundler` - `cp -r ../../bundler/bundler/spec spec/bundler` - `cp -r ../../bundler/bundler/man/*.{1,5,1\.txt,5\.txt,ronn} ./man` + `cp -r #{upstream}/lib/bundler* ./lib` + `cp -r #{upstream}/exe/bundle* ./libexec` + `cp #{upstream}/bundler.gemspec ./lib/bundler` + `cp -r #{upstream}/spec spec/bundler` + `cp -r #{upstream}/man/*.{1,5,1\.txt,5\.txt,ronn} ./man` `rm -rf spec/bundler/support/artifice/vcr_cassettes` when "rdoc" `rm -rf lib/rdoc* test/rdoc libexec/rdoc libexec/ri` - `cp -rf ../rdoc/lib/rdoc* ./lib` - `cp -rf ../rdoc/test test/rdoc` - `cp ../rdoc/rdoc.gemspec ./lib/rdoc` - `cp -rf ../rdoc/exe/rdoc ./libexec` - `cp -rf ../rdoc/exe/ri ./libexec` + `cp -rf #{upstream}/lib/rdoc* ./lib` + `cp -rf #{upstream}/test test/rdoc` + `cp #{upstream}/rdoc.gemspec ./lib/rdoc` + `cp -rf #{upstream}/exe/rdoc ./libexec` + `cp -rf #{upstream}/exe/ri ./libexec` `rm -f lib/rdoc/markdown.kpeg lib/rdoc/markdown/literals.kpeg lib/rdoc/rd/block_parser.ry lib/rdoc/rd/inline_parser.ry` `git checkout lib/rdoc/.document` when "reline" `rm -rf lib/reline* test/reline` - `cp -rf ../reline/lib/reline* ./lib` - `cp -rf ../reline/test test/reline` - `cp ../reline/reline.gemspec ./lib/reline` + `cp -rf #{upstream}/lib/reline* ./lib` + `cp -rf #{upstream}/test test/reline` + `cp #{upstream}/reline.gemspec ./lib/reline` when "json" `rm -rf ext/json test/json` - `cp -rf ../../flori/json/ext/json/ext ext/json` - `cp -rf ../../flori/json/tests test/json` - `cp -rf ../../flori/json/lib ext/json` + `cp -rf .#{upstream}/ext/json/ext ext/json` + `cp -rf .#{upstream}/tests test/json` + `cp -rf .#{upstream}/lib ext/json` `rm -rf ext/json/lib/json/pure*` - `cp ../../flori/json/json.gemspec ext/json` + `cp .#{upstream}/json.gemspec ext/json` `rm -r ext/json/lib/json/ext` `git checkout ext/json/extconf.rb ext/json/parser/prereq.mk ext/json/generator/depend ext/json/parser/depend` when "psych" `rm -rf ext/psych test/psych` - `cp -rf ../psych/ext/psych ./ext` - `cp -rf ../psych/lib ./ext/psych` - `cp -rf ../psych/test/psych ./test` + `cp -rf .#{upstream}/ext/psych ./ext` + `cp -rf .#{upstream}/lib ./ext/psych` + `cp -rf .#{upstream}/test/psych ./test` `rm -rf ext/psych/lib/org ext/psych/lib/psych.jar ext/psych/lib/psych_jars.rb` `rm -rf ext/psych/lib/psych.{bundle,so} ext/psych/lib/{2.0,2.1,2.2,2.3,2.4}` `rm -f ext/psych/yaml/LICENSE` - `cp ../psych/psych.gemspec ext/psych/` + `cp .#{upstream}/psych.gemspec ext/psych/` `git checkout ext/psych/depend` when "fiddle" `rm -rf ext/fiddle test/fiddle` - `cp -rf ../fiddle/ext/fiddle ext` - `cp -rf ../fiddle/lib ext/fiddle` - `cp -rf ../fiddle/test/fiddle test` - `cp -f ../fiddle/fiddle.gemspec ext/fiddle` + `cp -rf #{upstream}/ext/fiddle ext` + `cp -rf #{upstream}/lib ext/fiddle` + `cp -rf #{upstream}/test/fiddle test` + `cp -f #{upstream}/fiddle.gemspec ext/fiddle` `git checkout ext/fiddle/depend` `rm -rf ext/fiddle/lib/fiddle.{bundle,so}` when "stringio" `rm -rf ext/stringio test/stringio` - `cp -rf ../stringio/ext/stringio ext` - `cp -rf ../stringio/test/stringio test` - `cp -f ../stringio/stringio.gemspec ext/stringio` + `cp -rf #{upstream}/ext/stringio ext` + `cp -rf #{upstream}/test/stringio test` + `cp -f #{upstream}/stringio.gemspec ext/stringio` `git checkout ext/stringio/depend ext/stringio/README.md` when "ioconsole" `rm -rf ext/io/console test/io/console` - `cp -rf ../io-console/ext/io/console ext/io` - `cp -rf ../io-console/test/io/console test/io` + `cp -rf #{upstream}/ext/io/console ext/io` + `cp -rf #{upstream}/test/io/console test/io` `mkdir -p ext/io/console/lib` - `cp -rf ../io-console/lib/io/console ext/io/console/lib` - `cp -f ../io-console/io-console.gemspec ext/io/console` + `cp -rf #{upstream}/lib/io/console ext/io/console/lib` + `cp -f #{upstream}/io-console.gemspec ext/io/console` `git checkout ext/io/console/depend` when "dbm" `rm -rf ext/dbm test/dbm` - `cp -rf ../dbm/ext/dbm ext` - `cp -rf ../dbm/test/dbm test` - `cp -f ../dbm/dbm.gemspec ext/dbm` + `cp -rf #{upstream}/ext/dbm ext` + `cp -rf #{upstream}/test/dbm test` + `cp -f #{upstream}/dbm.gemspec ext/dbm` `git checkout ext/dbm/depend` when "gdbm" `rm -rf ext/gdbm test/gdbm` - `cp -rf ../gdbm/ext/gdbm ext` - `cp -rf ../gdbm/test/gdbm test` - `cp -f ../gdbm/gdbm.gemspec ext/gdbm` + `cp -rf #{upstream}/ext/gdbm ext` + `cp -rf #{upstream}/test/gdbm test` + `cp -f #{upstream}/gdbm.gemspec ext/gdbm` `git checkout ext/gdbm/depend ext/gdbm/README` when "sdbm" `rm -rf ext/sdbm test/sdbm` - `cp -rf ../sdbm/ext/sdbm ext` - `cp -rf ../sdbm/test/sdbm test` - `cp -f ../sdbm/sdbm.gemspec ext/sdbm` + `cp -rf #{upstream}/ext/sdbm ext` + `cp -rf #{upstream}/test/sdbm test` + `cp -f #{upstream}/sdbm.gemspec ext/sdbm` `git checkout ext/sdbm/depend` when "etc" `rm -rf ext/etc test/etc` - `cp -rf ../etc/ext/etc ext` - `cp -rf ../etc/test/etc test` - `cp -f ../etc/etc.gemspec ext/etc` + `cp -rf #{upstream}/ext/etc ext` + `cp -rf #{upstream}/test/etc test` + `cp -f #{upstream}/etc.gemspec ext/etc` `git checkout ext/etc/depend` when "date" `rm -rf ext/date test/date` - `cp -rf ../date/ext/date ext` - `cp -rf ../date/lib ext/date` - `cp -rf ../date/test/date test` - `cp -f ../date/date.gemspec ext/date` + `cp -rf #{upstream}/ext/date ext` + `cp -rf #{upstream}/lib ext/date` + `cp -rf #{upstream}/test/date test` + `cp -f #{upstream}/date.gemspec ext/date` `git checkout ext/date/depend` `rm -f ext/date/lib/date_core.bundle` when "zlib" `rm -rf ext/zlib test/zlib` - `cp -rf ../zlib/ext/zlib ext` - `cp -rf ../zlib/test/zlib test` - `cp -f ../zlib/zlib.gemspec ext/zlib` + `cp -rf #{upstream}/ext/zlib ext` + `cp -rf #{upstream}/test/zlib test` + `cp -f #{upstream}/zlib.gemspec ext/zlib` `git checkout ext/zlib/depend` when "fcntl" `rm -rf ext/fcntl` - `cp -rf ../fcntl/ext/fcntl ext` - `cp -f ../fcntl/fcntl.gemspec ext/fcntl` + `cp -rf #{upstream}/ext/fcntl ext` + `cp -f #{upstream}/fcntl.gemspec ext/fcntl` `git checkout ext/fcntl/depend` when "thwait" `rm -rf lib/thwait*` - `cp -rf ../thwait/lib/* lib` - `cp -rf ../thwait/thwait.gemspec lib/thwait` + `cp -rf #{upstream}/lib/* lib` + `cp -rf #{upstream}/thwait.gemspec lib/thwait` when "e2mmap" `rm -rf lib/e2mmap*` - `cp -rf ../e2mmap/lib/* lib` - `cp -rf ../e2mmap/e2mmap.gemspec lib` + `cp -rf #{upstream}/lib/* lib` + `cp -rf #{upstream}/e2mmap.gemspec lib` when "strscan" `rm -rf ext/strscan test/strscan` - `cp -rf ../strscan/ext/strscan ext` - `cp -rf ../strscan/test/strscan test` - `cp -f ../strscan/strscan.gemspec ext/strscan` + `cp -rf #{upstream}/ext/strscan ext` + `cp -rf #{upstream}/test/strscan test` + `cp -f #{upstream}/strscan.gemspec ext/strscan` `rm -f ext/strscan/regenc.h ext/strscan/regint.h` `git checkout ext/strscan/depend` when "racc" `rm -rf lib/racc* ext/racc test/racc` - `cp -rf ../racc/lib/racc* lib` + `cp -rf #{upstream}/lib/racc* lib` `mkdir -p ext/racc/cparse` - `cp -rf ../racc/ext/racc/cparse/* ext/racc/cparse` - `cp -rf ../racc/test test/racc` + `cp -rf #{upstream}/ext/racc/cparse/* ext/racc/cparse` + `cp -rf #{upstream}/test test/racc` `git checkout ext/racc/cparse/README` when "rexml", "rss", "matrix", "irb", "csv", "shell", "logger", "ostruct", "scanf", "webrick", "fileutils", "forwardable", "prime", "tracer", "ipaddr", "cmath", "mutex_m", "sync" sync_lib gem From 7d24a7ed7bae3adec131920d98c0b321e9d3e286 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Sun, 14 Jul 2019 14:29:38 +0900 Subject: [PATCH 054/452] Use FileUtils.rm_rf instead of rm command directly. --- tool/sync_default_gems.rb | 64 ++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 31 deletions(-) diff --git a/tool/sync_default_gems.rb b/tool/sync_default_gems.rb index 3626bc094e6776..52453eee9c691c 100644 --- a/tool/sync_default_gems.rb +++ b/tool/sync_default_gems.rb @@ -40,6 +40,8 @@ # * https://github.com/ruby/racc # +require 'fileutils' + $repositories = { rubygems: 'rubygems/rubygems', bundler: 'bundler/bundler', @@ -88,66 +90,66 @@ def sync_default_gems(gem) case gem when "rubygems" - `rm -rf lib/rubygems* test/rubygems` + FileUtils.rm_rf(%w[lib/rubygems* test/rubygems]) `cp -r #{upstream}/lib/rubygems* ./lib` `cp -r #{upstream}/test/rubygems ./test` when "bundler" - `rm -rf lib/bundler* libexec/bundler libexec/bundle spec/bundler man/bundle* man/gemfile*` + FileUtils.rm_rf(%w[lib/bundler* libexec/bundler libexec/bundle spec/bundler man/bundle* man/gemfile*]) `cp -r #{upstream}/lib/bundler* ./lib` `cp -r #{upstream}/exe/bundle* ./libexec` `cp #{upstream}/bundler.gemspec ./lib/bundler` `cp -r #{upstream}/spec spec/bundler` `cp -r #{upstream}/man/*.{1,5,1\.txt,5\.txt,ronn} ./man` - `rm -rf spec/bundler/support/artifice/vcr_cassettes` + FileUtils.rm_rf(%w[spec/bundler/support/artifice/vcr_cassettes]) when "rdoc" - `rm -rf lib/rdoc* test/rdoc libexec/rdoc libexec/ri` + FileUtils.rm_rf(%w[lib/rdoc* test/rdoc libexec/rdoc libexec/ri]) `cp -rf #{upstream}/lib/rdoc* ./lib` `cp -rf #{upstream}/test test/rdoc` `cp #{upstream}/rdoc.gemspec ./lib/rdoc` `cp -rf #{upstream}/exe/rdoc ./libexec` `cp -rf #{upstream}/exe/ri ./libexec` - `rm -f lib/rdoc/markdown.kpeg lib/rdoc/markdown/literals.kpeg lib/rdoc/rd/block_parser.ry lib/rdoc/rd/inline_parser.ry` + FileUtils.rm_rf(%w[lib/rdoc/markdown.kpeg lib/rdoc/markdown/literals.kpeg lib/rdoc/rd/block_parser.ry lib/rdoc/rd/inline_parser.ry]) `git checkout lib/rdoc/.document` when "reline" - `rm -rf lib/reline* test/reline` + FileUtils.rm_rf(%w[lib/reline* test/reline]) `cp -rf #{upstream}/lib/reline* ./lib` `cp -rf #{upstream}/test test/reline` `cp #{upstream}/reline.gemspec ./lib/reline` when "json" - `rm -rf ext/json test/json` + FileUtils.rm_rf(%w[ext/json test/json]) `cp -rf .#{upstream}/ext/json/ext ext/json` `cp -rf .#{upstream}/tests test/json` `cp -rf .#{upstream}/lib ext/json` - `rm -rf ext/json/lib/json/pure*` + FileUtils.rm_rf(%[ext/json/lib/json/pure*]) `cp .#{upstream}/json.gemspec ext/json` - `rm -r ext/json/lib/json/ext` + FileUtils.rm_rf(%w[ext/json/lib/json/ext]) `git checkout ext/json/extconf.rb ext/json/parser/prereq.mk ext/json/generator/depend ext/json/parser/depend` when "psych" - `rm -rf ext/psych test/psych` + FileUtils.rm_rf(%w[ext/psych test/psych]) `cp -rf .#{upstream}/ext/psych ./ext` `cp -rf .#{upstream}/lib ./ext/psych` `cp -rf .#{upstream}/test/psych ./test` - `rm -rf ext/psych/lib/org ext/psych/lib/psych.jar ext/psych/lib/psych_jars.rb` - `rm -rf ext/psych/lib/psych.{bundle,so} ext/psych/lib/{2.0,2.1,2.2,2.3,2.4}` - `rm -f ext/psych/yaml/LICENSE` + FileUtils.rm_rf(%w[ext/psych/lib/org ext/psych/lib/psych.jar ext/psych/lib/psych_jars.rb]) + FileUtils.rm_rf(%w[ext/psych/lib/psych.{bundle,so} ext/psych/lib/2.*]) + FileUtils.rm_rf(["ext/psych/yaml/LICENSE"]) `cp .#{upstream}/psych.gemspec ext/psych/` `git checkout ext/psych/depend` when "fiddle" - `rm -rf ext/fiddle test/fiddle` + FileUtils.rm_rf(%w[ext/fiddle test/fiddle]) `cp -rf #{upstream}/ext/fiddle ext` `cp -rf #{upstream}/lib ext/fiddle` `cp -rf #{upstream}/test/fiddle test` `cp -f #{upstream}/fiddle.gemspec ext/fiddle` `git checkout ext/fiddle/depend` - `rm -rf ext/fiddle/lib/fiddle.{bundle,so}` + FileUtils.rm_rf(%w[ext/fiddle/lib/fiddle.{bundle,so}]) when "stringio" - `rm -rf ext/stringio test/stringio` + FileUtils.rm_rf(%w[ext/stringio test/stringio]) `cp -rf #{upstream}/ext/stringio ext` `cp -rf #{upstream}/test/stringio test` `cp -f #{upstream}/stringio.gemspec ext/stringio` `git checkout ext/stringio/depend ext/stringio/README.md` when "ioconsole" - `rm -rf ext/io/console test/io/console` + FileUtils.rm_rf(%w[ext/io/console test/io/console]) `cp -rf #{upstream}/ext/io/console ext/io` `cp -rf #{upstream}/test/io/console test/io` `mkdir -p ext/io/console/lib` @@ -155,65 +157,65 @@ def sync_default_gems(gem) `cp -f #{upstream}/io-console.gemspec ext/io/console` `git checkout ext/io/console/depend` when "dbm" - `rm -rf ext/dbm test/dbm` + FileUtils.rm_rf(%w[ext/dbm test/dbm]) `cp -rf #{upstream}/ext/dbm ext` `cp -rf #{upstream}/test/dbm test` `cp -f #{upstream}/dbm.gemspec ext/dbm` `git checkout ext/dbm/depend` when "gdbm" - `rm -rf ext/gdbm test/gdbm` + FileUtils.rm_rf(%w[ext/gdbm test/gdbm]) `cp -rf #{upstream}/ext/gdbm ext` `cp -rf #{upstream}/test/gdbm test` `cp -f #{upstream}/gdbm.gemspec ext/gdbm` `git checkout ext/gdbm/depend ext/gdbm/README` when "sdbm" - `rm -rf ext/sdbm test/sdbm` + FileUtils.rm_rf(%w[ext/sdbm test/sdbm]) `cp -rf #{upstream}/ext/sdbm ext` `cp -rf #{upstream}/test/sdbm test` `cp -f #{upstream}/sdbm.gemspec ext/sdbm` `git checkout ext/sdbm/depend` when "etc" - `rm -rf ext/etc test/etc` + FileUtils.rm_rf(%w[ext/etc test/etc]) `cp -rf #{upstream}/ext/etc ext` `cp -rf #{upstream}/test/etc test` `cp -f #{upstream}/etc.gemspec ext/etc` `git checkout ext/etc/depend` when "date" - `rm -rf ext/date test/date` + FileUtils.rm_rf(%w[ext/date test/date]) `cp -rf #{upstream}/ext/date ext` `cp -rf #{upstream}/lib ext/date` `cp -rf #{upstream}/test/date test` `cp -f #{upstream}/date.gemspec ext/date` `git checkout ext/date/depend` - `rm -f ext/date/lib/date_core.bundle` + FileUtils.rm_rf(["ext/date/lib/date_core.bundle"]) when "zlib" - `rm -rf ext/zlib test/zlib` + FileUtils.rm_rf(%w[ext/zlib test/zlib]) `cp -rf #{upstream}/ext/zlib ext` `cp -rf #{upstream}/test/zlib test` `cp -f #{upstream}/zlib.gemspec ext/zlib` `git checkout ext/zlib/depend` when "fcntl" - `rm -rf ext/fcntl` + FileUtils.rm_rf(%w[ext/fcntl]) `cp -rf #{upstream}/ext/fcntl ext` `cp -f #{upstream}/fcntl.gemspec ext/fcntl` `git checkout ext/fcntl/depend` when "thwait" - `rm -rf lib/thwait*` + FileUtils.rm_rf(%w[lib/thwait*]) `cp -rf #{upstream}/lib/* lib` `cp -rf #{upstream}/thwait.gemspec lib/thwait` when "e2mmap" - `rm -rf lib/e2mmap*` + FileUtils.rm_rf(%w[lib/e2mmap*]) `cp -rf #{upstream}/lib/* lib` `cp -rf #{upstream}/e2mmap.gemspec lib` when "strscan" - `rm -rf ext/strscan test/strscan` + FileUtils.rm_rf(%w[ext/strscan test/strscan]) `cp -rf #{upstream}/ext/strscan ext` `cp -rf #{upstream}/test/strscan test` `cp -f #{upstream}/strscan.gemspec ext/strscan` - `rm -f ext/strscan/regenc.h ext/strscan/regint.h` + FileUtils.rm_rf(%w["ext/strscan/regenc.h ext/strscan/regint.h"]) `git checkout ext/strscan/depend` when "racc" - `rm -rf lib/racc* ext/racc test/racc` + FileUtils.rm_rf(%w[lib/racc* ext/racc test/racc]) `cp -rf #{upstream}/lib/racc* lib` `mkdir -p ext/racc/cparse` `cp -rf #{upstream}/ext/racc/cparse/* ext/racc/cparse` @@ -229,7 +231,7 @@ def sync_lib(repo) unless File.directory?("../#{repo}") abort "Expected '../#{repo}' (#{File.expand_path("../#{repo}")}) to be a directory, but it wasn't." end - `rm -rf lib/#{repo}.rb lib/#{repo}/* test/test_#{repo}.rb` + FileUtils.rm_rf(["lib/#{repo}.rb", "lib/#{repo}/*", "test/test_#{repo}.rb"]) `cp -rf ../#{repo}/lib/* lib` tests = if File.directory?("test/#{repo}") "test/#{repo}" From d25f355c655704d483ca402d0ac2644adb5733b0 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Sun, 14 Jul 2019 15:07:17 +0900 Subject: [PATCH 055/452] Fixup dccb0e1ec94e7b9c13c715939ae7e0ccc4ffb23e --- tool/sync_default_gems.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tool/sync_default_gems.rb b/tool/sync_default_gems.rb index 52453eee9c691c..f9585357167aa4 100644 --- a/tool/sync_default_gems.rb +++ b/tool/sync_default_gems.rb @@ -117,22 +117,22 @@ def sync_default_gems(gem) `cp #{upstream}/reline.gemspec ./lib/reline` when "json" FileUtils.rm_rf(%w[ext/json test/json]) - `cp -rf .#{upstream}/ext/json/ext ext/json` - `cp -rf .#{upstream}/tests test/json` - `cp -rf .#{upstream}/lib ext/json` + `cp -rf #{upstream}/ext/json/ext ext/json` + `cp -rf #{upstream}/tests test/json` + `cp -rf #{upstream}/lib ext/json` FileUtils.rm_rf(%[ext/json/lib/json/pure*]) - `cp .#{upstream}/json.gemspec ext/json` + `cp #{upstream}/json.gemspec ext/json` FileUtils.rm_rf(%w[ext/json/lib/json/ext]) `git checkout ext/json/extconf.rb ext/json/parser/prereq.mk ext/json/generator/depend ext/json/parser/depend` when "psych" FileUtils.rm_rf(%w[ext/psych test/psych]) - `cp -rf .#{upstream}/ext/psych ./ext` - `cp -rf .#{upstream}/lib ./ext/psych` - `cp -rf .#{upstream}/test/psych ./test` + `cp -rf #{upstream}/ext/psych ./ext` + `cp -rf #{upstream}/lib ./ext/psych` + `cp -rf #{upstream}/test/psych ./test` FileUtils.rm_rf(%w[ext/psych/lib/org ext/psych/lib/psych.jar ext/psych/lib/psych_jars.rb]) FileUtils.rm_rf(%w[ext/psych/lib/psych.{bundle,so} ext/psych/lib/2.*]) FileUtils.rm_rf(["ext/psych/yaml/LICENSE"]) - `cp .#{upstream}/psych.gemspec ext/psych/` + `cp #{upstream}/psych.gemspec ext/psych/` `git checkout ext/psych/depend` when "fiddle" FileUtils.rm_rf(%w[ext/fiddle test/fiddle]) From e91ff4dbaf0bdbf7185b485b43cd9393419efd11 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Sun, 14 Jul 2019 15:20:25 +0900 Subject: [PATCH 056/452] Use FileUtils.cp_r instead of cp command directoly. --- tool/sync_default_gems.rb | 136 +++++++++++++++++++------------------- 1 file changed, 68 insertions(+), 68 deletions(-) diff --git a/tool/sync_default_gems.rb b/tool/sync_default_gems.rb index f9585357167aa4..f00e24d87e6f4e 100644 --- a/tool/sync_default_gems.rb +++ b/tool/sync_default_gems.rb @@ -91,135 +91,135 @@ def sync_default_gems(gem) case gem when "rubygems" FileUtils.rm_rf(%w[lib/rubygems* test/rubygems]) - `cp -r #{upstream}/lib/rubygems* ./lib` - `cp -r #{upstream}/test/rubygems ./test` + FileUtils.cp_r(Dir.glob("#{upstream}/lib/rubygems*"), "lib") + FileUtils.cp_r("#{upstream}/test/rubygems", "test") when "bundler" FileUtils.rm_rf(%w[lib/bundler* libexec/bundler libexec/bundle spec/bundler man/bundle* man/gemfile*]) - `cp -r #{upstream}/lib/bundler* ./lib` - `cp -r #{upstream}/exe/bundle* ./libexec` - `cp #{upstream}/bundler.gemspec ./lib/bundler` - `cp -r #{upstream}/spec spec/bundler` - `cp -r #{upstream}/man/*.{1,5,1\.txt,5\.txt,ronn} ./man` + FileUtils.cp_r(Dir.glob("#{upstream}/lib/bundler*"), "lib") + FileUtils.cp_r(Dir.glob("#{upstream}/exe/bundle*"), "libexec") + FileUtils.cp_r("#{upstream}/bundler.gemspec", "lib/bundler") + FileUtils.cp_r("#{upstream}/spec", "spec/bundler") + FileUtils.cp_r(Dir.glob("#{upstream}/man/*.{1,5,1\.txt,5\.txt,ronn}"), "man") FileUtils.rm_rf(%w[spec/bundler/support/artifice/vcr_cassettes]) when "rdoc" FileUtils.rm_rf(%w[lib/rdoc* test/rdoc libexec/rdoc libexec/ri]) - `cp -rf #{upstream}/lib/rdoc* ./lib` - `cp -rf #{upstream}/test test/rdoc` - `cp #{upstream}/rdoc.gemspec ./lib/rdoc` - `cp -rf #{upstream}/exe/rdoc ./libexec` - `cp -rf #{upstream}/exe/ri ./libexec` + FileUtils.cp_r(Dir.glob("#{upstream}/lib/rdoc*"), "lib") + FileUtils.cp_r("#{upstream}/test", "test/rdoc") + FileUtils.cp_r("#{upstream}/rdoc.gemspec", "lib/rdoc") + FileUtils.cp_r("#{upstream}/exe/rdoc", "libexec") + FileUtils.cp_r("#{upstream}/exe/ri", "libexec") FileUtils.rm_rf(%w[lib/rdoc/markdown.kpeg lib/rdoc/markdown/literals.kpeg lib/rdoc/rd/block_parser.ry lib/rdoc/rd/inline_parser.ry]) `git checkout lib/rdoc/.document` when "reline" FileUtils.rm_rf(%w[lib/reline* test/reline]) - `cp -rf #{upstream}/lib/reline* ./lib` - `cp -rf #{upstream}/test test/reline` - `cp #{upstream}/reline.gemspec ./lib/reline` + FileUtils.cp_r(Dir.glob("#{upstream}/lib/reline*"), "lib") + FileUtils.cp_r("#{upstream}/test", "test/reline") + FileUtils.cp_r("#{upstream}/reline.gemspec", "lib/reline") when "json" FileUtils.rm_rf(%w[ext/json test/json]) - `cp -rf #{upstream}/ext/json/ext ext/json` - `cp -rf #{upstream}/tests test/json` - `cp -rf #{upstream}/lib ext/json` + FileUtils.cp_r("#{upstream}/ext/json/ext", "ext/json") + FileUtils.cp_r("#{upstream}/tests", "test/json") + FileUtils.cp_r("#{upstream}/lib", "ext/json") FileUtils.rm_rf(%[ext/json/lib/json/pure*]) - `cp #{upstream}/json.gemspec ext/json` + FileUtils.cp_r("#{upstream}/json.gemspec", "ext/json") FileUtils.rm_rf(%w[ext/json/lib/json/ext]) `git checkout ext/json/extconf.rb ext/json/parser/prereq.mk ext/json/generator/depend ext/json/parser/depend` when "psych" FileUtils.rm_rf(%w[ext/psych test/psych]) - `cp -rf #{upstream}/ext/psych ./ext` - `cp -rf #{upstream}/lib ./ext/psych` - `cp -rf #{upstream}/test/psych ./test` + FileUtils.cp_r("#{upstream}/ext/psych", "ext") + FileUtils.cp_r("#{upstream}/lib", "ext/psych") + FileUtils.cp_r("#{upstream}/test/psych", "test") FileUtils.rm_rf(%w[ext/psych/lib/org ext/psych/lib/psych.jar ext/psych/lib/psych_jars.rb]) FileUtils.rm_rf(%w[ext/psych/lib/psych.{bundle,so} ext/psych/lib/2.*]) FileUtils.rm_rf(["ext/psych/yaml/LICENSE"]) - `cp #{upstream}/psych.gemspec ext/psych/` + FileUtils.cp_r("#{upstream}/psych.gemspec", "ext/psych") `git checkout ext/psych/depend` when "fiddle" FileUtils.rm_rf(%w[ext/fiddle test/fiddle]) - `cp -rf #{upstream}/ext/fiddle ext` - `cp -rf #{upstream}/lib ext/fiddle` - `cp -rf #{upstream}/test/fiddle test` - `cp -f #{upstream}/fiddle.gemspec ext/fiddle` + FileUtils.cp_r("#{upstream}/ext/fiddle", "ext") + FileUtils.cp_r("#{upstream}/lib", "ext/fiddle") + FileUtils.cp_r("#{upstream}/test/fiddle", "test") + FileUtils.cp_r("#{upstream}/fiddle.gemspec", "ext/fiddle") `git checkout ext/fiddle/depend` FileUtils.rm_rf(%w[ext/fiddle/lib/fiddle.{bundle,so}]) when "stringio" FileUtils.rm_rf(%w[ext/stringio test/stringio]) - `cp -rf #{upstream}/ext/stringio ext` - `cp -rf #{upstream}/test/stringio test` - `cp -f #{upstream}/stringio.gemspec ext/stringio` + FileUtils.cp_r("#{upstream}/ext/stringio", "ext") + FileUtils.cp_r("#{upstream}/test/stringio", "test") + FileUtils.cp_r("#{upstream}/stringio.gemspec", "ext/stringio") `git checkout ext/stringio/depend ext/stringio/README.md` when "ioconsole" FileUtils.rm_rf(%w[ext/io/console test/io/console]) - `cp -rf #{upstream}/ext/io/console ext/io` - `cp -rf #{upstream}/test/io/console test/io` + FileUtils.cp_r("#{upstream}/ext/io/console", "ext/io") + FileUtils.cp_r("#{upstream}/test/io/console", "test/io") `mkdir -p ext/io/console/lib` - `cp -rf #{upstream}/lib/io/console ext/io/console/lib` - `cp -f #{upstream}/io-console.gemspec ext/io/console` + FileUtils.cp_r("#{upstream}/lib/io/console", "ext/io/console/lib") + FileUtils.cp_r("#{upstream}/io-console.gemspec", "ext/io/console") `git checkout ext/io/console/depend` when "dbm" FileUtils.rm_rf(%w[ext/dbm test/dbm]) - `cp -rf #{upstream}/ext/dbm ext` - `cp -rf #{upstream}/test/dbm test` - `cp -f #{upstream}/dbm.gemspec ext/dbm` + FileUtils.cp_r("#{upstream}/ext/dbm", "ext") + FileUtils.cp_r("#{upstream}/test/dbm", "test") + FileUtils.cp_r("#{upstream}/dbm.gemspec", "ext/dbm") `git checkout ext/dbm/depend` when "gdbm" FileUtils.rm_rf(%w[ext/gdbm test/gdbm]) - `cp -rf #{upstream}/ext/gdbm ext` - `cp -rf #{upstream}/test/gdbm test` - `cp -f #{upstream}/gdbm.gemspec ext/gdbm` + FileUtils.cp_r("#{upstream}/ext/gdbm", "ext") + FileUtils.cp_r("#{upstream}/test/gdbm", "test") + FileUtils.cp_r("#{upstream}/gdbm.gemspec", "ext/gdbm") `git checkout ext/gdbm/depend ext/gdbm/README` when "sdbm" FileUtils.rm_rf(%w[ext/sdbm test/sdbm]) - `cp -rf #{upstream}/ext/sdbm ext` - `cp -rf #{upstream}/test/sdbm test` - `cp -f #{upstream}/sdbm.gemspec ext/sdbm` + FileUtils.cp_r("#{upstream}/ext/sdbm", "ext") + FileUtils.cp_r("#{upstream}/test/sdbm", "test") + FileUtils.cp_r("#{upstream}/sdbm.gemspec", "ext/sdbm") `git checkout ext/sdbm/depend` when "etc" FileUtils.rm_rf(%w[ext/etc test/etc]) - `cp -rf #{upstream}/ext/etc ext` - `cp -rf #{upstream}/test/etc test` - `cp -f #{upstream}/etc.gemspec ext/etc` + FileUtils.cp_r("#{upstream}/ext/etc", "ext") + FileUtils.cp_r("#{upstream}/test/etc", "test") + FileUtils.cp_r("#{upstream}/etc.gemspec", "ext/etc") `git checkout ext/etc/depend` when "date" FileUtils.rm_rf(%w[ext/date test/date]) - `cp -rf #{upstream}/ext/date ext` - `cp -rf #{upstream}/lib ext/date` - `cp -rf #{upstream}/test/date test` - `cp -f #{upstream}/date.gemspec ext/date` + FileUtils.cp_r("#{upstream}/ext/date", "ext") + FileUtils.cp_r("#{upstream}/lib", "ext/date") + FileUtils.cp_r("#{upstream}/test/date", "test") + FileUtils.cp_r("#{upstream}/date.gemspec", "ext/date") `git checkout ext/date/depend` FileUtils.rm_rf(["ext/date/lib/date_core.bundle"]) when "zlib" FileUtils.rm_rf(%w[ext/zlib test/zlib]) - `cp -rf #{upstream}/ext/zlib ext` - `cp -rf #{upstream}/test/zlib test` - `cp -f #{upstream}/zlib.gemspec ext/zlib` + FileUtils.cp_r("#{upstream}/ext/zlib", "ext") + FileUtils.cp_r("#{upstream}/test/zlib", "test") + FileUtils.cp_r("#{upstream}/zlib.gemspec", "ext/zlib") `git checkout ext/zlib/depend` when "fcntl" FileUtils.rm_rf(%w[ext/fcntl]) - `cp -rf #{upstream}/ext/fcntl ext` - `cp -f #{upstream}/fcntl.gemspec ext/fcntl` + FileUtils.cp_r("#{upstream}/ext/fcntl", "ext") + FileUtils.cp_r("#{upstream}/fcntl.gemspec", "ext/fcntl") `git checkout ext/fcntl/depend` when "thwait" FileUtils.rm_rf(%w[lib/thwait*]) - `cp -rf #{upstream}/lib/* lib` - `cp -rf #{upstream}/thwait.gemspec lib/thwait` + FileUtils.cp_r(Dir.glob("#{upstream}/lib/*"), "lib") + FileUtils.cp_r("#{upstream}/thwait.gemspec", "lib/thwait") when "e2mmap" FileUtils.rm_rf(%w[lib/e2mmap*]) - `cp -rf #{upstream}/lib/* lib` - `cp -rf #{upstream}/e2mmap.gemspec lib` + FileUtils.cp_r(Dir.glob("#{upstream}/lib/*"), "lib") + FileUtils.cp_r("#{upstream}/e2mmap.gemspec", "lib") when "strscan" FileUtils.rm_rf(%w[ext/strscan test/strscan]) - `cp -rf #{upstream}/ext/strscan ext` - `cp -rf #{upstream}/test/strscan test` - `cp -f #{upstream}/strscan.gemspec ext/strscan` + FileUtils.cp_r("#{upstream}/ext/strscan", "ext") + FileUtils.cp_r("#{upstream}/test/strscan", "test") + FileUtils.cp_r("#{upstream}/strscan.gemspec", "ext/strscan") FileUtils.rm_rf(%w["ext/strscan/regenc.h ext/strscan/regint.h"]) `git checkout ext/strscan/depend` when "racc" FileUtils.rm_rf(%w[lib/racc* ext/racc test/racc]) - `cp -rf #{upstream}/lib/racc* lib` + FileUtils.cp_r(Dir.glob("#{upstream}/lib/racc*"), "lib") `mkdir -p ext/racc/cparse` - `cp -rf #{upstream}/ext/racc/cparse/* ext/racc/cparse` - `cp -rf #{upstream}/test test/racc` + FileUtils.cp_r(Dir.glob("#{upstream}/ext/racc/cparse/*"), "ext/racc/cparse") + FileUtils.cp_r("#{upstream}/test", "test/racc") `git checkout ext/racc/cparse/README` when "rexml", "rss", "matrix", "irb", "csv", "shell", "logger", "ostruct", "scanf", "webrick", "fileutils", "forwardable", "prime", "tracer", "ipaddr", "cmath", "mutex_m", "sync" sync_lib gem @@ -232,19 +232,19 @@ def sync_lib(repo) abort "Expected '../#{repo}' (#{File.expand_path("../#{repo}")}) to be a directory, but it wasn't." end FileUtils.rm_rf(["lib/#{repo}.rb", "lib/#{repo}/*", "test/test_#{repo}.rb"]) - `cp -rf ../#{repo}/lib/* lib` + FileUtils.cp_r(Dir.glob("../#{repo}/lib/*"), "lib") tests = if File.directory?("test/#{repo}") "test/#{repo}" else "test/test_#{repo}.rb" end - `cp -rf ../#{repo}/#{tests} test` + FileUtils.cp_r("../#{repo}/#{tests}", "test") gemspec = if File.directory?("lib/#{repo}") "lib/#{repo}/#{repo}.gemspec" else "lib/#{repo}.gemspec" end - `cp -f ../#{repo}/#{repo}.gemspec #{gemspec}` + FileUtils.cp_r("../#{repo}/#{repo}.gemspec", "#{gemspec}") end def update_default_gems(gem) From a73f45247652d563e4043af8d14964b9d911fe81 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Sun, 14 Jul 2019 15:21:27 +0900 Subject: [PATCH 057/452] Use FileUtils.mkdir_p instead of mkdir command directoly. --- tool/sync_default_gems.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tool/sync_default_gems.rb b/tool/sync_default_gems.rb index f00e24d87e6f4e..f21f0696422c03 100644 --- a/tool/sync_default_gems.rb +++ b/tool/sync_default_gems.rb @@ -152,7 +152,7 @@ def sync_default_gems(gem) FileUtils.rm_rf(%w[ext/io/console test/io/console]) FileUtils.cp_r("#{upstream}/ext/io/console", "ext/io") FileUtils.cp_r("#{upstream}/test/io/console", "test/io") - `mkdir -p ext/io/console/lib` + FileUtils.mkdir_p("ext/io/console/lib") FileUtils.cp_r("#{upstream}/lib/io/console", "ext/io/console/lib") FileUtils.cp_r("#{upstream}/io-console.gemspec", "ext/io/console") `git checkout ext/io/console/depend` @@ -217,7 +217,7 @@ def sync_default_gems(gem) when "racc" FileUtils.rm_rf(%w[lib/racc* ext/racc test/racc]) FileUtils.cp_r(Dir.glob("#{upstream}/lib/racc*"), "lib") - `mkdir -p ext/racc/cparse` + FileUtils.mkdir_p("ext/racc/cparse") FileUtils.cp_r(Dir.glob("#{upstream}/ext/racc/cparse/*"), "ext/racc/cparse") FileUtils.cp_r("#{upstream}/test", "test/racc") `git checkout ext/racc/cparse/README` @@ -251,7 +251,7 @@ def update_default_gems(gem) author, repository = $repositories[gem.to_sym].split('/') unless File.exist?("../../#{author}/#{repository}") - `mkdir -p ../../#{author}` + FileUtils.mkdir_p("../../#{author}") `git clone git@github.com:#{author}/#{repository}.git ../../#{author}/#{repository}` end From 4ce935cd5dde69b39bb98b8948d41e3afba81e33 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Sun, 14 Jul 2019 15:22:12 +0900 Subject: [PATCH 058/452] Removed FileUtils for file manipulations with module inclusion. --- tool/sync_default_gems.rb | 205 +++++++++++++++++++------------------- 1 file changed, 103 insertions(+), 102 deletions(-) diff --git a/tool/sync_default_gems.rb b/tool/sync_default_gems.rb index f21f0696422c03..34cdfaedeec296 100644 --- a/tool/sync_default_gems.rb +++ b/tool/sync_default_gems.rb @@ -41,6 +41,7 @@ # require 'fileutils' +include FileUtils $repositories = { rubygems: 'rubygems/rubygems', @@ -90,136 +91,136 @@ def sync_default_gems(gem) case gem when "rubygems" - FileUtils.rm_rf(%w[lib/rubygems* test/rubygems]) - FileUtils.cp_r(Dir.glob("#{upstream}/lib/rubygems*"), "lib") - FileUtils.cp_r("#{upstream}/test/rubygems", "test") + rm_rf(%w[lib/rubygems* test/rubygems]) + cp_r(Dir.glob("#{upstream}/lib/rubygems*"), "lib") + cp_r("#{upstream}/test/rubygems", "test") when "bundler" - FileUtils.rm_rf(%w[lib/bundler* libexec/bundler libexec/bundle spec/bundler man/bundle* man/gemfile*]) - FileUtils.cp_r(Dir.glob("#{upstream}/lib/bundler*"), "lib") - FileUtils.cp_r(Dir.glob("#{upstream}/exe/bundle*"), "libexec") - FileUtils.cp_r("#{upstream}/bundler.gemspec", "lib/bundler") - FileUtils.cp_r("#{upstream}/spec", "spec/bundler") - FileUtils.cp_r(Dir.glob("#{upstream}/man/*.{1,5,1\.txt,5\.txt,ronn}"), "man") - FileUtils.rm_rf(%w[spec/bundler/support/artifice/vcr_cassettes]) + rm_rf(%w[lib/bundler* libexec/bundler libexec/bundle spec/bundler man/bundle* man/gemfile*]) + cp_r(Dir.glob("#{upstream}/lib/bundler*"), "lib") + cp_r(Dir.glob("#{upstream}/exe/bundle*"), "libexec") + cp_r("#{upstream}/bundler.gemspec", "lib/bundler") + cp_r("#{upstream}/spec", "spec/bundler") + cp_r(Dir.glob("#{upstream}/man/*.{1,5,1\.txt,5\.txt,ronn}"), "man") + rm_rf(%w[spec/bundler/support/artifice/vcr_cassettes]) when "rdoc" - FileUtils.rm_rf(%w[lib/rdoc* test/rdoc libexec/rdoc libexec/ri]) - FileUtils.cp_r(Dir.glob("#{upstream}/lib/rdoc*"), "lib") - FileUtils.cp_r("#{upstream}/test", "test/rdoc") - FileUtils.cp_r("#{upstream}/rdoc.gemspec", "lib/rdoc") - FileUtils.cp_r("#{upstream}/exe/rdoc", "libexec") - FileUtils.cp_r("#{upstream}/exe/ri", "libexec") - FileUtils.rm_rf(%w[lib/rdoc/markdown.kpeg lib/rdoc/markdown/literals.kpeg lib/rdoc/rd/block_parser.ry lib/rdoc/rd/inline_parser.ry]) + rm_rf(%w[lib/rdoc* test/rdoc libexec/rdoc libexec/ri]) + cp_r(Dir.glob("#{upstream}/lib/rdoc*"), "lib") + cp_r("#{upstream}/test", "test/rdoc") + cp_r("#{upstream}/rdoc.gemspec", "lib/rdoc") + cp_r("#{upstream}/exe/rdoc", "libexec") + cp_r("#{upstream}/exe/ri", "libexec") + rm_rf(%w[lib/rdoc/markdown.kpeg lib/rdoc/markdown/literals.kpeg lib/rdoc/rd/block_parser.ry lib/rdoc/rd/inline_parser.ry]) `git checkout lib/rdoc/.document` when "reline" - FileUtils.rm_rf(%w[lib/reline* test/reline]) - FileUtils.cp_r(Dir.glob("#{upstream}/lib/reline*"), "lib") - FileUtils.cp_r("#{upstream}/test", "test/reline") - FileUtils.cp_r("#{upstream}/reline.gemspec", "lib/reline") + rm_rf(%w[lib/reline* test/reline]) + cp_r(Dir.glob("#{upstream}/lib/reline*"), "lib") + cp_r("#{upstream}/test", "test/reline") + cp_r("#{upstream}/reline.gemspec", "lib/reline") when "json" - FileUtils.rm_rf(%w[ext/json test/json]) - FileUtils.cp_r("#{upstream}/ext/json/ext", "ext/json") - FileUtils.cp_r("#{upstream}/tests", "test/json") - FileUtils.cp_r("#{upstream}/lib", "ext/json") - FileUtils.rm_rf(%[ext/json/lib/json/pure*]) - FileUtils.cp_r("#{upstream}/json.gemspec", "ext/json") - FileUtils.rm_rf(%w[ext/json/lib/json/ext]) + rm_rf(%w[ext/json test/json]) + cp_r("#{upstream}/ext/json/ext", "ext/json") + cp_r("#{upstream}/tests", "test/json") + cp_r("#{upstream}/lib", "ext/json") + rm_rf(%[ext/json/lib/json/pure*]) + cp_r("#{upstream}/json.gemspec", "ext/json") + rm_rf(%w[ext/json/lib/json/ext]) `git checkout ext/json/extconf.rb ext/json/parser/prereq.mk ext/json/generator/depend ext/json/parser/depend` when "psych" - FileUtils.rm_rf(%w[ext/psych test/psych]) - FileUtils.cp_r("#{upstream}/ext/psych", "ext") - FileUtils.cp_r("#{upstream}/lib", "ext/psych") - FileUtils.cp_r("#{upstream}/test/psych", "test") - FileUtils.rm_rf(%w[ext/psych/lib/org ext/psych/lib/psych.jar ext/psych/lib/psych_jars.rb]) - FileUtils.rm_rf(%w[ext/psych/lib/psych.{bundle,so} ext/psych/lib/2.*]) - FileUtils.rm_rf(["ext/psych/yaml/LICENSE"]) - FileUtils.cp_r("#{upstream}/psych.gemspec", "ext/psych") + rm_rf(%w[ext/psych test/psych]) + cp_r("#{upstream}/ext/psych", "ext") + cp_r("#{upstream}/lib", "ext/psych") + cp_r("#{upstream}/test/psych", "test") + rm_rf(%w[ext/psych/lib/org ext/psych/lib/psych.jar ext/psych/lib/psych_jars.rb]) + rm_rf(%w[ext/psych/lib/psych.{bundle,so} ext/psych/lib/2.*]) + rm_rf(["ext/psych/yaml/LICENSE"]) + cp_r("#{upstream}/psych.gemspec", "ext/psych") `git checkout ext/psych/depend` when "fiddle" - FileUtils.rm_rf(%w[ext/fiddle test/fiddle]) - FileUtils.cp_r("#{upstream}/ext/fiddle", "ext") - FileUtils.cp_r("#{upstream}/lib", "ext/fiddle") - FileUtils.cp_r("#{upstream}/test/fiddle", "test") - FileUtils.cp_r("#{upstream}/fiddle.gemspec", "ext/fiddle") + rm_rf(%w[ext/fiddle test/fiddle]) + cp_r("#{upstream}/ext/fiddle", "ext") + cp_r("#{upstream}/lib", "ext/fiddle") + cp_r("#{upstream}/test/fiddle", "test") + cp_r("#{upstream}/fiddle.gemspec", "ext/fiddle") `git checkout ext/fiddle/depend` - FileUtils.rm_rf(%w[ext/fiddle/lib/fiddle.{bundle,so}]) + rm_rf(%w[ext/fiddle/lib/fiddle.{bundle,so}]) when "stringio" - FileUtils.rm_rf(%w[ext/stringio test/stringio]) - FileUtils.cp_r("#{upstream}/ext/stringio", "ext") - FileUtils.cp_r("#{upstream}/test/stringio", "test") - FileUtils.cp_r("#{upstream}/stringio.gemspec", "ext/stringio") + rm_rf(%w[ext/stringio test/stringio]) + cp_r("#{upstream}/ext/stringio", "ext") + cp_r("#{upstream}/test/stringio", "test") + cp_r("#{upstream}/stringio.gemspec", "ext/stringio") `git checkout ext/stringio/depend ext/stringio/README.md` when "ioconsole" - FileUtils.rm_rf(%w[ext/io/console test/io/console]) - FileUtils.cp_r("#{upstream}/ext/io/console", "ext/io") - FileUtils.cp_r("#{upstream}/test/io/console", "test/io") - FileUtils.mkdir_p("ext/io/console/lib") - FileUtils.cp_r("#{upstream}/lib/io/console", "ext/io/console/lib") - FileUtils.cp_r("#{upstream}/io-console.gemspec", "ext/io/console") + rm_rf(%w[ext/io/console test/io/console]) + cp_r("#{upstream}/ext/io/console", "ext/io") + cp_r("#{upstream}/test/io/console", "test/io") + mkdir_p("ext/io/console/lib") + cp_r("#{upstream}/lib/io/console", "ext/io/console/lib") + cp_r("#{upstream}/io-console.gemspec", "ext/io/console") `git checkout ext/io/console/depend` when "dbm" - FileUtils.rm_rf(%w[ext/dbm test/dbm]) - FileUtils.cp_r("#{upstream}/ext/dbm", "ext") - FileUtils.cp_r("#{upstream}/test/dbm", "test") - FileUtils.cp_r("#{upstream}/dbm.gemspec", "ext/dbm") + rm_rf(%w[ext/dbm test/dbm]) + cp_r("#{upstream}/ext/dbm", "ext") + cp_r("#{upstream}/test/dbm", "test") + cp_r("#{upstream}/dbm.gemspec", "ext/dbm") `git checkout ext/dbm/depend` when "gdbm" - FileUtils.rm_rf(%w[ext/gdbm test/gdbm]) - FileUtils.cp_r("#{upstream}/ext/gdbm", "ext") - FileUtils.cp_r("#{upstream}/test/gdbm", "test") - FileUtils.cp_r("#{upstream}/gdbm.gemspec", "ext/gdbm") + rm_rf(%w[ext/gdbm test/gdbm]) + cp_r("#{upstream}/ext/gdbm", "ext") + cp_r("#{upstream}/test/gdbm", "test") + cp_r("#{upstream}/gdbm.gemspec", "ext/gdbm") `git checkout ext/gdbm/depend ext/gdbm/README` when "sdbm" - FileUtils.rm_rf(%w[ext/sdbm test/sdbm]) - FileUtils.cp_r("#{upstream}/ext/sdbm", "ext") - FileUtils.cp_r("#{upstream}/test/sdbm", "test") - FileUtils.cp_r("#{upstream}/sdbm.gemspec", "ext/sdbm") + rm_rf(%w[ext/sdbm test/sdbm]) + cp_r("#{upstream}/ext/sdbm", "ext") + cp_r("#{upstream}/test/sdbm", "test") + cp_r("#{upstream}/sdbm.gemspec", "ext/sdbm") `git checkout ext/sdbm/depend` when "etc" - FileUtils.rm_rf(%w[ext/etc test/etc]) - FileUtils.cp_r("#{upstream}/ext/etc", "ext") - FileUtils.cp_r("#{upstream}/test/etc", "test") - FileUtils.cp_r("#{upstream}/etc.gemspec", "ext/etc") + rm_rf(%w[ext/etc test/etc]) + cp_r("#{upstream}/ext/etc", "ext") + cp_r("#{upstream}/test/etc", "test") + cp_r("#{upstream}/etc.gemspec", "ext/etc") `git checkout ext/etc/depend` when "date" - FileUtils.rm_rf(%w[ext/date test/date]) - FileUtils.cp_r("#{upstream}/ext/date", "ext") - FileUtils.cp_r("#{upstream}/lib", "ext/date") - FileUtils.cp_r("#{upstream}/test/date", "test") - FileUtils.cp_r("#{upstream}/date.gemspec", "ext/date") + rm_rf(%w[ext/date test/date]) + cp_r("#{upstream}/ext/date", "ext") + cp_r("#{upstream}/lib", "ext/date") + cp_r("#{upstream}/test/date", "test") + cp_r("#{upstream}/date.gemspec", "ext/date") `git checkout ext/date/depend` - FileUtils.rm_rf(["ext/date/lib/date_core.bundle"]) + rm_rf(["ext/date/lib/date_core.bundle"]) when "zlib" - FileUtils.rm_rf(%w[ext/zlib test/zlib]) - FileUtils.cp_r("#{upstream}/ext/zlib", "ext") - FileUtils.cp_r("#{upstream}/test/zlib", "test") - FileUtils.cp_r("#{upstream}/zlib.gemspec", "ext/zlib") + rm_rf(%w[ext/zlib test/zlib]) + cp_r("#{upstream}/ext/zlib", "ext") + cp_r("#{upstream}/test/zlib", "test") + cp_r("#{upstream}/zlib.gemspec", "ext/zlib") `git checkout ext/zlib/depend` when "fcntl" - FileUtils.rm_rf(%w[ext/fcntl]) - FileUtils.cp_r("#{upstream}/ext/fcntl", "ext") - FileUtils.cp_r("#{upstream}/fcntl.gemspec", "ext/fcntl") + rm_rf(%w[ext/fcntl]) + cp_r("#{upstream}/ext/fcntl", "ext") + cp_r("#{upstream}/fcntl.gemspec", "ext/fcntl") `git checkout ext/fcntl/depend` when "thwait" - FileUtils.rm_rf(%w[lib/thwait*]) - FileUtils.cp_r(Dir.glob("#{upstream}/lib/*"), "lib") - FileUtils.cp_r("#{upstream}/thwait.gemspec", "lib/thwait") + rm_rf(%w[lib/thwait*]) + cp_r(Dir.glob("#{upstream}/lib/*"), "lib") + cp_r("#{upstream}/thwait.gemspec", "lib/thwait") when "e2mmap" - FileUtils.rm_rf(%w[lib/e2mmap*]) - FileUtils.cp_r(Dir.glob("#{upstream}/lib/*"), "lib") - FileUtils.cp_r("#{upstream}/e2mmap.gemspec", "lib") + rm_rf(%w[lib/e2mmap*]) + cp_r(Dir.glob("#{upstream}/lib/*"), "lib") + cp_r("#{upstream}/e2mmap.gemspec", "lib") when "strscan" - FileUtils.rm_rf(%w[ext/strscan test/strscan]) - FileUtils.cp_r("#{upstream}/ext/strscan", "ext") - FileUtils.cp_r("#{upstream}/test/strscan", "test") - FileUtils.cp_r("#{upstream}/strscan.gemspec", "ext/strscan") - FileUtils.rm_rf(%w["ext/strscan/regenc.h ext/strscan/regint.h"]) + rm_rf(%w[ext/strscan test/strscan]) + cp_r("#{upstream}/ext/strscan", "ext") + cp_r("#{upstream}/test/strscan", "test") + cp_r("#{upstream}/strscan.gemspec", "ext/strscan") + rm_rf(%w["ext/strscan/regenc.h ext/strscan/regint.h"]) `git checkout ext/strscan/depend` when "racc" - FileUtils.rm_rf(%w[lib/racc* ext/racc test/racc]) - FileUtils.cp_r(Dir.glob("#{upstream}/lib/racc*"), "lib") - FileUtils.mkdir_p("ext/racc/cparse") - FileUtils.cp_r(Dir.glob("#{upstream}/ext/racc/cparse/*"), "ext/racc/cparse") - FileUtils.cp_r("#{upstream}/test", "test/racc") + rm_rf(%w[lib/racc* ext/racc test/racc]) + cp_r(Dir.glob("#{upstream}/lib/racc*"), "lib") + mkdir_p("ext/racc/cparse") + cp_r(Dir.glob("#{upstream}/ext/racc/cparse/*"), "ext/racc/cparse") + cp_r("#{upstream}/test", "test/racc") `git checkout ext/racc/cparse/README` when "rexml", "rss", "matrix", "irb", "csv", "shell", "logger", "ostruct", "scanf", "webrick", "fileutils", "forwardable", "prime", "tracer", "ipaddr", "cmath", "mutex_m", "sync" sync_lib gem @@ -231,27 +232,27 @@ def sync_lib(repo) unless File.directory?("../#{repo}") abort "Expected '../#{repo}' (#{File.expand_path("../#{repo}")}) to be a directory, but it wasn't." end - FileUtils.rm_rf(["lib/#{repo}.rb", "lib/#{repo}/*", "test/test_#{repo}.rb"]) - FileUtils.cp_r(Dir.glob("../#{repo}/lib/*"), "lib") + rm_rf(["lib/#{repo}.rb", "lib/#{repo}/*", "test/test_#{repo}.rb"]) + cp_r(Dir.glob("../#{repo}/lib/*"), "lib") tests = if File.directory?("test/#{repo}") "test/#{repo}" else "test/test_#{repo}.rb" end - FileUtils.cp_r("../#{repo}/#{tests}", "test") + cp_r("../#{repo}/#{tests}", "test") gemspec = if File.directory?("lib/#{repo}") "lib/#{repo}/#{repo}.gemspec" else "lib/#{repo}.gemspec" end - FileUtils.cp_r("../#{repo}/#{repo}.gemspec", "#{gemspec}") + cp_r("../#{repo}/#{repo}.gemspec", "#{gemspec}") end def update_default_gems(gem) author, repository = $repositories[gem.to_sym].split('/') unless File.exist?("../../#{author}/#{repository}") - FileUtils.mkdir_p("../../#{author}") + mkdir_p("../../#{author}") `git clone git@github.com:#{author}/#{repository}.git ../../#{author}/#{repository}` end From 47b04557b01dc109ccafc33db8e80148f07457a9 Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Sun, 14 Jul 2019 15:42:55 +0900 Subject: [PATCH 059/452] Method#inspect with source location. Method#inspect shows with source location. [Feature #14145] --- proc.c | 12 ++++++++++++ test/ruby/test_method.rb | 16 ++++++++-------- test/ruby/test_module.rb | 2 +- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/proc.c b/proc.c index 7f4f2d46b67f23..217d228a8a31db 100644 --- a/proc.c +++ b/proc.c @@ -2743,6 +2743,18 @@ method_inspect(VALUE method) if (data->me->def->type == VM_METHOD_TYPE_NOTIMPLEMENTED) { rb_str_buf_cat2(str, " (not-implemented)"); } + + // parameter information + // TODO + + { // source location + VALUE loc = rb_method_location(method); + if (!NIL_P(loc)) { + rb_str_catf(str, " %"PRIsVALUE":%"PRIsVALUE, + RARRAY_AREF(loc, 0), RARRAY_AREF(loc, 1)); + } + } + rb_str_buf_cat2(str, ">"); return str; diff --git a/test/ruby/test_method.rb b/test/ruby/test_method.rb index 4e20534dfaeabd..ba425a4517cf2a 100644 --- a/test/ruby/test_method.rb +++ b/test/ruby/test_method.rb @@ -432,29 +432,29 @@ def m.bar; :bar; end def test_inspect o = Object.new - def o.foo; end + def o.foo; end; line_no = __LINE__ m = o.method(:foo) - assert_equal("#", m.inspect) + assert_equal("#", m.inspect) m = o.method(:foo) - assert_equal("#", m.unbind.inspect) + assert_match("#", m.inspect) + assert_equal("#", m.inspect) m = c.instance_method(:foo) - assert_equal("#", m.inspect) + assert_equal("#", m.inspect) c2 = Class.new(c) c2.class_eval { private :foo } m2 = c2.new.method(:foo) - assert_equal("#", m2.inspect) + assert_equal("#", m2.inspect) bug7806 = '[ruby-core:52048] [Bug #7806]' c3 = Class.new(c) c3.class_eval { alias bar foo } m3 = c3.new.method(:bar) - assert_equal("#", m3.inspect, bug7806) + assert_equal("#", m3.inspect, bug7806) m.taint assert_predicate(m.inspect, :tainted?, "inspect result should be infected") diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb index 604edf5f5970e0..37045ad0d90d59 100644 --- a/test/ruby/test_module.rb +++ b/test/ruby/test_module.rb @@ -2313,7 +2313,7 @@ class A A.prepend InspectIsShallow - expect = "#" + expect = "#" assert_equal expect, A.new.method(:inspect).inspect, "#{bug_10282}" RUBY end From 3163a07878dfcefe7914067e58de78049b056624 Mon Sep 17 00:00:00 2001 From: Luke Gruber Date: Sat, 8 Jun 2019 14:55:41 -0400 Subject: [PATCH 060/452] fix issue with 'SIGINT' handling in LineEditor#reset @old_trap is the string "DEFAULT" and not a callable object (Proc) if there are no other signal handlers for SIGINT signal to chain. --- lib/reline/line_editor.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb index f4b72cdd8d9f3f..2f60c76aeef225 100644 --- a/lib/reline/line_editor.rb +++ b/lib/reline/line_editor.rb @@ -67,7 +67,7 @@ def reset(prompt = '', encoding = Encoding.default_external) @old_trap = Signal.trap('SIGINT') { scroll_down(@highest_in_all - @first_line_started_from) Reline::IOGate.move_cursor_column(0) - @old_trap.() + @old_trap.call if @old_trap.respond_to?(:call) # can also be string, ex: "DEFAULT" } end From f2d99fd8209058e75d5d1c56d179509c06486107 Mon Sep 17 00:00:00 2001 From: Kazuhiro NISHIYAMA Date: Sun, 14 Jul 2019 15:41:45 +0900 Subject: [PATCH 061/452] [DOC] Fix indent [ci skip] --- doc/NEWS-2.6.0 | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/doc/NEWS-2.6.0 b/doc/NEWS-2.6.0 index 18eaa1a403b9bd..4ad4b0864f1880 100644 --- a/doc/NEWS-2.6.0 +++ b/doc/NEWS-2.6.0 @@ -352,24 +352,24 @@ BigDecimal:: Modified methods:: - * BigDecimal() accepts the new keyword "exception:" similar to Float(). + * BigDecimal() accepts the new keyword "exception:" similar to Float(). Note for the differences among recent versions:: - You should want to know the differences among recent versions of bigdecimal. - Please select the suitable version of bigdecimal according to the following - information. + You should want to know the differences among recent versions of bigdecimal. + Please select the suitable version of bigdecimal according to the following + information. - * 1.3.5 has BigDecimal.new without "exception:" keyword. You can see the - deprecation warning of BigDecimal.new when you specify "-w" option. - BigDecimal(), BigDecimal.new, and Object#to_d methods are the same. + * 1.3.5 has BigDecimal.new without "exception:" keyword. You can see the + deprecation warning of BigDecimal.new when you specify "-w" option. + BigDecimal(), BigDecimal.new, and Object#to_d methods are the same. - * 1.4.0 has BigDecimal.new with "exception:" keyword. You always see the - deprecation warning of BigDecimal.new. Object#to_d method is different - from BigDecimal() and BigDecimal.new. + * 1.4.0 has BigDecimal.new with "exception:" keyword. You always see the + deprecation warning of BigDecimal.new. Object#to_d method is different + from BigDecimal() and BigDecimal.new. - * 2.0.0 will be released soon after releasing Ruby 2.6.0. This version - will not have the BigDecimal.new method. + * 2.0.0 will be released soon after releasing Ruby 2.6.0. This version + will not have the BigDecimal.new method. Bundler:: From 2618db3011edb07fffb9250137ea3a3a6c87cec4 Mon Sep 17 00:00:00 2001 From: Kazuhiro NISHIYAMA Date: Sun, 14 Jul 2019 16:00:34 +0900 Subject: [PATCH 062/452] [DOC] Fix typos [ci skip] --- doc/NEWS-2.6.0 | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/doc/NEWS-2.6.0 b/doc/NEWS-2.6.0 index 4ad4b0864f1880..2303a5bd41f4a8 100644 --- a/doc/NEWS-2.6.0 +++ b/doc/NEWS-2.6.0 @@ -56,7 +56,7 @@ Array:: * Added Array#union and Array#difference instance methods. [Feature #14097] - Modified methods:: + Modified method:: * Array#to_h now accepts a block that maps elements to new key/value pairs. [Feature #15143] @@ -67,7 +67,7 @@ Array:: Binding:: - New methods:: + New method:: * Added Binding#source_location. [Feature #14230] @@ -87,13 +87,13 @@ Dir:: Enumerable:: - New methods:: + New method:: * Enumerable#chain returns an enumerator object that iterates over the elements of the receiver and then those of each argument in sequence. [Feature #15144] - Modified methods:: + Modified method:: * Enumerable#to_h now accepts a block that maps elements to new key/value pairs. [Feature #15143] @@ -130,7 +130,7 @@ Enumerator:: ENV:: - Modified methods:: + Modified method:: * ENV.to_h now accepts a block that maps names and values to new keys and values. [Feature #15143] @@ -158,7 +158,7 @@ Hash:: IO:: - New options:: + New option:: * Added new mode character 'x' to open files for exclusive access. [Feature #11258] @@ -209,20 +209,20 @@ Module:: NameError:: - New options:: + New option:: * NameError.new accepts a +:receiver+ option to set receiver in Ruby code. [Feature #14313] NilClass:: - New methods:: + New method:: * NilClass#=~ is added for compatibility. [Feature #15231] NoMethodError:: - New options:: + New option:: * NoMethodError.new accepts a +:receiver+ option to set receiver in Ruby code. [Feature #14313] @@ -236,7 +236,7 @@ Numeric:: OpenStruct:: - Modified methods:: + Modified method:: * OpenStruct#to_h now accepts a block that maps keys and values to new keys and values. [Feature #15143] @@ -252,13 +252,13 @@ Proc:: Random:: - New methods:: + New method:: * Added Random.bytes. [Feature #4938] Range:: - New methods:: + New method:: * Added Range#% instance method. [Feature #14697] @@ -293,7 +293,7 @@ RubyVM::AbstractSyntaxTree:: RubyVM:: - New methods:: + New method:: * RubyVM.resolve_feature_path identifies the file that will be loaded by "require(feature)". [experimental] [Feature #15230] @@ -308,7 +308,7 @@ String:: Struct:: - Modified methods:: + Modified method:: * Struct#to_h now accepts a block that maps keys and values to new keys and values. [Feature #15143] @@ -338,7 +338,7 @@ TracePoint:: * TracePoint#eval_script [Feature #15287] - Modified methods:: + Modified method:: * TracePoint#enable accepts new keywords "target:" and "target_line:". [Feature #15289] @@ -350,7 +350,7 @@ BigDecimal:: Update to version 1.4.0. This version includes several compatibility issues, see Compatibility issues section below for details. - Modified methods:: + Modified method:: * BigDecimal() accepts the new keyword "exception:" similar to Float(). From 95de69df9906cde96d30aa2fbc6f5ed4891fdb9f Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Sun, 14 Jul 2019 15:23:15 +0900 Subject: [PATCH 063/452] io.c (rb_file_open_internal): initialize all the fields Just for case. This will suppress the warning of Coverity Scan. --- io.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/io.c b/io.c index 154b45e95011aa..f78c09ba40d0d6 100644 --- a/io.c +++ b/io.c @@ -6228,6 +6228,8 @@ rb_file_open_internal(VALUE io, VALUE filename, const char *modestr) if (p) { parse_mode_enc(p+1, rb_usascii_encoding(), &convconfig.enc, &convconfig.enc2, &fmode); + convconfig.ecflags = 0; + convconfig.ecopts = Qnil; } else { rb_encoding *e; From 73fab16e76d3879d2a099e2ce949b6b03f227d86 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Sun, 14 Jul 2019 16:17:49 +0900 Subject: [PATCH 064/452] compile.c (defined_expr): return void instead of int It always returned 1. --- compile.c | 47 ++++++++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/compile.c b/compile.c index bf61a06c00e582..4f01569d1ae556 100644 --- a/compile.c +++ b/compile.c @@ -4442,11 +4442,11 @@ compile_cpath(LINK_ANCHOR *const ret, rb_iseq_t *iseq, const NODE *cpath) } #define private_recv_p(node) (nd_type((node)->nd_recv) == NODE_SELF) -static int +static void defined_expr(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, LABEL **lfinish, VALUE needstr); -static int +static void defined_expr0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, LABEL **lfinish, VALUE needstr) { @@ -4501,25 +4501,25 @@ defined_expr0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, ADD_INSN(ret, line, putnil); ADD_INSN3(ret, line, defined, INT2FIX(DEFINED_IVAR), ID2SYM(node->nd_vid), needstr); - return 1; + return; case NODE_GVAR: ADD_INSN(ret, line, putnil); ADD_INSN3(ret, line, defined, INT2FIX(DEFINED_GVAR), ID2SYM(node->nd_entry->id), needstr); - return 1; + return; case NODE_CVAR: ADD_INSN(ret, line, putnil); ADD_INSN3(ret, line, defined, INT2FIX(DEFINED_CVAR), ID2SYM(node->nd_vid), needstr); - return 1; + return; case NODE_CONST: ADD_INSN(ret, line, putnil); ADD_INSN3(ret, line, defined, INT2FIX(DEFINED_CONST), ID2SYM(node->nd_vid), needstr); - return 1; + return; case NODE_COLON2: if (!lfinish[1]) { lfinish[1] = NEW_LABEL(line); @@ -4532,12 +4532,12 @@ defined_expr0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, (rb_is_const_id(node->nd_mid) ? INT2FIX(DEFINED_CONST) : INT2FIX(DEFINED_METHOD)), ID2SYM(node->nd_mid), needstr); - return 1; + return; case NODE_COLON3: ADD_INSN1(ret, line, putobject, rb_cObject); ADD_INSN3(ret, line, defined, INT2FIX(DEFINED_CONST), ID2SYM(node->nd_mid), needstr); - return 1; + return; /* method dispatch */ case NODE_CALL: @@ -4570,14 +4570,14 @@ defined_expr0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, ADD_INSN3(ret, line, defined, INT2FIX(DEFINED_FUNC), ID2SYM(node->nd_mid), needstr); } - return 1; + return; } case NODE_YIELD: ADD_INSN(ret, line, putnil); ADD_INSN3(ret, line, defined, INT2FIX(DEFINED_YIELD), 0, needstr); - return 1; + return; case NODE_BACK_REF: case NODE_NTH_REF: @@ -4585,14 +4585,14 @@ defined_expr0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, ADD_INSN3(ret, line, defined, INT2FIX(DEFINED_REF), INT2FIX((node->nd_nth << 1) | (type == NODE_BACK_REF)), needstr); - return 1; + return; case NODE_SUPER: case NODE_ZSUPER: ADD_INSN(ret, line, putnil); ADD_INSN3(ret, line, defined, INT2FIX(DEFINED_ZSUPER), 0, needstr); - return 1; + return; case NODE_OP_ASGN1: case NODE_OP_ASGN2: @@ -4610,17 +4610,15 @@ defined_expr0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, break; } - if (expr_type) { - if (needstr != Qfalse) { - VALUE str = rb_iseq_defined_string(expr_type); - ADD_INSN1(ret, line, putobject, str); - } - else { - ADD_INSN1(ret, line, putobject, Qtrue); - } - return 1; + assert(expr_type != DEFINED_NOT_DEFINED); + + if (needstr != Qfalse) { + VALUE str = rb_iseq_defined_string(expr_type); + ADD_INSN1(ret, line, putobject, str); + } + else { + ADD_INSN1(ret, line, putobject, Qtrue); } - return 0; } static VALUE @@ -4631,12 +4629,12 @@ build_defined_rescue_iseq(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *u return Qnil; } -static int +static void defined_expr(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, LABEL **lfinish, VALUE needstr) { LINK_ELEMENT *lcur = ret->last; - int done = defined_expr0(iseq, ret, node, lfinish, needstr); + defined_expr0(iseq, ret, node, lfinish, needstr); if (lfinish[1]) { int line = nd_line(node); LABEL *lstart = NEW_LABEL(line); @@ -4652,7 +4650,6 @@ defined_expr(rb_iseq_t *iseq, LINK_ANCHOR *const ret, ADD_LABEL(ret, lend); ADD_CATCH_ENTRY(CATCH_TYPE_RESCUE, lstart, lend, rescue, lfinish[1]); } - return done; } static int From 83153bbb149f5c827c4ce537722d3169d24b9de9 Mon Sep 17 00:00:00 2001 From: git Date: Sun, 14 Jul 2019 16:18:48 +0900 Subject: [PATCH 065/452] * expand tabs. --- compile.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/compile.c b/compile.c index 4f01569d1ae556..2bee4b8dd8c031 100644 --- a/compile.c +++ b/compile.c @@ -4501,25 +4501,25 @@ defined_expr0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, ADD_INSN(ret, line, putnil); ADD_INSN3(ret, line, defined, INT2FIX(DEFINED_IVAR), ID2SYM(node->nd_vid), needstr); - return; + return; case NODE_GVAR: ADD_INSN(ret, line, putnil); ADD_INSN3(ret, line, defined, INT2FIX(DEFINED_GVAR), ID2SYM(node->nd_entry->id), needstr); - return; + return; case NODE_CVAR: ADD_INSN(ret, line, putnil); ADD_INSN3(ret, line, defined, INT2FIX(DEFINED_CVAR), ID2SYM(node->nd_vid), needstr); - return; + return; case NODE_CONST: ADD_INSN(ret, line, putnil); ADD_INSN3(ret, line, defined, INT2FIX(DEFINED_CONST), ID2SYM(node->nd_vid), needstr); - return; + return; case NODE_COLON2: if (!lfinish[1]) { lfinish[1] = NEW_LABEL(line); @@ -4532,12 +4532,12 @@ defined_expr0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, (rb_is_const_id(node->nd_mid) ? INT2FIX(DEFINED_CONST) : INT2FIX(DEFINED_METHOD)), ID2SYM(node->nd_mid), needstr); - return; + return; case NODE_COLON3: ADD_INSN1(ret, line, putobject, rb_cObject); ADD_INSN3(ret, line, defined, INT2FIX(DEFINED_CONST), ID2SYM(node->nd_mid), needstr); - return; + return; /* method dispatch */ case NODE_CALL: @@ -4570,14 +4570,14 @@ defined_expr0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, ADD_INSN3(ret, line, defined, INT2FIX(DEFINED_FUNC), ID2SYM(node->nd_mid), needstr); } - return; + return; } case NODE_YIELD: ADD_INSN(ret, line, putnil); ADD_INSN3(ret, line, defined, INT2FIX(DEFINED_YIELD), 0, needstr); - return; + return; case NODE_BACK_REF: case NODE_NTH_REF: @@ -4585,14 +4585,14 @@ defined_expr0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, ADD_INSN3(ret, line, defined, INT2FIX(DEFINED_REF), INT2FIX((node->nd_nth << 1) | (type == NODE_BACK_REF)), needstr); - return; + return; case NODE_SUPER: case NODE_ZSUPER: ADD_INSN(ret, line, putnil); ADD_INSN3(ret, line, defined, INT2FIX(DEFINED_ZSUPER), 0, needstr); - return; + return; case NODE_OP_ASGN1: case NODE_OP_ASGN2: From 10de5f149acc620e12be5943e4e29f4f555b7551 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 14 Jul 2019 16:31:36 +0900 Subject: [PATCH 066/452] Calculate float complex division per each part Arguments to f_complex_new2 should not be Complex, or violate the assertion. --- complex.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/complex.c b/complex.c index 42b32d42791759..313e5641860cf5 100644 --- a/complex.c +++ b/complex.c @@ -817,25 +817,19 @@ f_divide(VALUE self, VALUE other, if (f_gt_p(f_abs(bdat->real), f_abs(bdat->imag))) { r = (*func)(bdat->imag, bdat->real); n = f_mul(bdat->real, f_add(ONE, f_mul(r, r))); - if (flo) - return f_complex_new2(CLASS_OF(self), - (*func)(self, n), - (*func)(f_negate(f_mul(self, r)), n)); x = (*func)(f_add(adat->real, f_mul(adat->imag, r)), n); y = (*func)(f_sub(adat->imag, f_mul(adat->real, r)), n); } else { r = (*func)(bdat->real, bdat->imag); n = f_mul(bdat->imag, f_add(ONE, f_mul(r, r))); - if (flo) - return f_complex_new2(CLASS_OF(self), - (*func)(f_mul(self, r), n), - (*func)(f_negate(self), n)); x = (*func)(f_add(f_mul(adat->real, r), adat->imag), n); y = (*func)(f_sub(f_mul(adat->imag, r), adat->real), n); } - x = rb_rational_canonicalize(x); - y = rb_rational_canonicalize(y); + if (!flo) { + x = rb_rational_canonicalize(x); + y = rb_rational_canonicalize(y); + } return f_complex_new2(CLASS_OF(self), x, y); } if (k_numeric_p(other) && f_real_p(other)) { From 934e6b2aeb495686f7fe0d8b1c69d863e6fca072 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Sun, 14 Jul 2019 17:15:44 +0900 Subject: [PATCH 067/452] Prefer `rb_error_arity` to `rb_check_arity` when it can be used --- eval.c | 3 +-- file.c | 13 +++++++------ numeric.c | 3 +-- string.c | 2 +- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/eval.c b/eval.c index fa3ec22af58827..75648f1d8d07dc 100644 --- a/eval.c +++ b/eval.c @@ -790,8 +790,7 @@ make_exception(int argc, const VALUE *argv, int isstr) } break; default: - rb_check_arity(argc, 0, 3); - break; + rb_error_arity(argc, 0, 3); } if (argc > 0) { if (!rb_obj_is_kind_of(mesg, rb_eException)) diff --git a/file.c b/file.c index 50d1765d0203e3..15970cb0d37c20 100644 --- a/file.c +++ b/file.c @@ -3219,15 +3219,16 @@ rb_file_s_umask(int argc, VALUE *argv) { mode_t omask = 0; - if (argc == 0) { + switch (argc) { + case 0: omask = umask(0); umask(omask); - } - else if (argc == 1) { + break; + case 1: omask = umask(NUM2MODET(argv[0])); - } - else { - rb_check_arity(argc, 0, 1); + break; + default: + rb_error_arity(argc, 0, 1); } return MODET2NUM(omask); } diff --git a/numeric.c b/numeric.c index 1fce19ac0bcf69..90eabc29e08f16 100644 --- a/numeric.c +++ b/numeric.c @@ -3418,8 +3418,7 @@ int_chr(int argc, VALUE *argv, VALUE num) case 1: break; default: - rb_check_arity(argc, 0, 1); - break; + rb_error_arity(argc, 0, 1); } enc = rb_to_encoding(argv[0]); if (!enc) enc = rb_ascii8bit_encoding(); diff --git a/string.c b/string.c index 8d7d2ad7b9d50c..f76a417d450b48 100644 --- a/string.c +++ b/string.c @@ -5186,7 +5186,7 @@ str_gsub(int argc, VALUE *argv, VALUE str, int bang) tainted = OBJ_TAINTED_RAW(repl); break; default: - rb_check_arity(argc, 1, 2); + rb_error_arity(argc, 1, 2); } pat = get_pat_quoted(argv[0], 1); From 9987296b8b5b7c02fca92761e498764dfeb584cf Mon Sep 17 00:00:00 2001 From: git Date: Sun, 14 Jul 2019 17:16:35 +0900 Subject: [PATCH 068/452] * expand tabs. --- eval.c | 2 +- file.c | 2 +- numeric.c | 2 +- string.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/eval.c b/eval.c index 75648f1d8d07dc..138006e0db6b87 100644 --- a/eval.c +++ b/eval.c @@ -790,7 +790,7 @@ make_exception(int argc, const VALUE *argv, int isstr) } break; default: - rb_error_arity(argc, 0, 3); + rb_error_arity(argc, 0, 3); } if (argc > 0) { if (!rb_obj_is_kind_of(mesg, rb_eException)) diff --git a/file.c b/file.c index 15970cb0d37c20..f8df0f6e437497 100644 --- a/file.c +++ b/file.c @@ -3228,7 +3228,7 @@ rb_file_s_umask(int argc, VALUE *argv) omask = umask(NUM2MODET(argv[0])); break; default: - rb_error_arity(argc, 0, 1); + rb_error_arity(argc, 0, 1); } return MODET2NUM(omask); } diff --git a/numeric.c b/numeric.c index 90eabc29e08f16..78c4c335423e5c 100644 --- a/numeric.c +++ b/numeric.c @@ -3418,7 +3418,7 @@ int_chr(int argc, VALUE *argv, VALUE num) case 1: break; default: - rb_error_arity(argc, 0, 1); + rb_error_arity(argc, 0, 1); } enc = rb_to_encoding(argv[0]); if (!enc) enc = rb_ascii8bit_encoding(); diff --git a/string.c b/string.c index f76a417d450b48..64bb6093c6dadd 100644 --- a/string.c +++ b/string.c @@ -5186,7 +5186,7 @@ str_gsub(int argc, VALUE *argv, VALUE str, int bang) tainted = OBJ_TAINTED_RAW(repl); break; default: - rb_error_arity(argc, 1, 2); + rb_error_arity(argc, 1, 2); } pat = get_pat_quoted(argv[0], 1); From 05aac90a1bcfeb180f5e78ea8b00a4d1b04d5eed Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Sun, 14 Jul 2019 17:18:17 +0900 Subject: [PATCH 069/452] Warn open-uri's "open" method at Kernel. Use URI.open instead. Thanks for the patch by jeremyevans0 (Jeremy Evans) [Misc #15893]. --- lib/open-uri.rb | 27 +++++--- test/open-uri/test_open-uri.rb | 110 ++++++++++++++++++--------------- test/open-uri/test_ssl.rb | 12 ++-- 3 files changed, 85 insertions(+), 64 deletions(-) diff --git a/lib/open-uri.rb b/lib/open-uri.rb index 38f074ef599841..3aeed06ed451c1 100644 --- a/lib/open-uri.rb +++ b/lib/open-uri.rb @@ -10,6 +10,21 @@ class << self alias open_uri_original_open open # :nodoc: end + def open(name, *rest, &block) # :nodoc: + if (name.respond_to?(:open) && !name.respond_to?(:to_path)) || + (name.respond_to?(:to_str) && + %r{\A[A-Za-z][A-Za-z0-9+\-\.]*://} =~ name && + (uri = URI.parse(name)).respond_to?(:open)) + warn('calling URI.open via Kernel#open is deprecated, call URI.open directly', uplevel: 1) + URI.open(name, *rest, &block) + else + open_uri_original_open(name, *rest, &block) + end + end + module_function :open +end + +module URI # Allows the opening of various resources including URIs. # # If the first argument responds to the 'open' method, 'open' is called on @@ -26,7 +41,7 @@ class << self # # We can accept URIs and strings that begin with http://, https:// and # ftp://. In these cases, the opened file object is extended by OpenURI::Meta. - def open(name, *rest, &block) # :doc: + def self.open(name, *rest, &block) if name.respond_to?(:open) name.open(*rest, &block) elsif name.respond_to?(:to_str) && @@ -35,16 +50,10 @@ def open(name, *rest, &block) # :doc: uri.open(*rest, &block) else open_uri_original_open(name, *rest, &block) + # After Kernel#open override is removed: + #super end end - module_function :open -end - -module URI #:nodoc: - # alias for Kernel.open defined in open-uri. - def self.open(name, *rest, &block) - Kernel.open(name, *rest, &block) - end end # OpenURI is an easy-to-use wrapper for Net::HTTP, Net::HTTPS and Net::FTP. diff --git a/test/open-uri/test_open-uri.rb b/test/open-uri/test_open-uri.rb index 030148390202e1..39cf4201a2c969 100644 --- a/test/open-uri/test_open-uri.rb +++ b/test/open-uri/test_open-uri.rb @@ -68,6 +68,18 @@ def teardown @proxies.each_with_index {|k, i| ENV[k] = @old_proxies[i] } end + def test_deprecated_kernel_open + with_http {|srv, dr, url| + srv.mount_proc("/foo200", lambda { |req, res| res.body = "foo200" } ) + assert_warning(/calling URI.open via Kernel#open is deprecated, call URI.open directly/) { + open("#{url}/foo200") {|f| + assert_equal("200", f.status[0]) + assert_equal("foo200", f.read) + } + } + } + end + def test_200_uri_open with_http {|srv, dr, url| srv.mount_proc("/urifoo200", lambda { |req, res| res.body = "urifoo200" } ) @@ -81,7 +93,7 @@ def test_200_uri_open def test_200 with_http {|srv, dr, url| srv.mount_proc("/foo200", lambda { |req, res| res.body = "foo200" } ) - open("#{url}/foo200") {|f| + URI.open("#{url}/foo200") {|f| assert_equal("200", f.status[0]) assert_equal("foo200", f.read) } @@ -92,7 +104,7 @@ def test_200big with_http {|srv, dr, url| content = "foo200big"*10240 srv.mount_proc("/foo200big", lambda { |req, res| res.body = content } ) - open("#{url}/foo200big") {|f| + URI.open("#{url}/foo200big") {|f| assert_equal("200", f.status[0]) assert_equal(content, f.read) } @@ -105,7 +117,7 @@ def test_404 assert_match(%r{ERROR `/not-exist' not found}, server_log[0]) } with_http(log_tester) {|srv, dr, url, server_thread, server_log| - exc = assert_raise(OpenURI::HTTPError) { open("#{url}/not-exist") {} } + exc = assert_raise(OpenURI::HTTPError) { URI.open("#{url}/not-exist") {} } assert_equal("404", exc.io.status[0]) } end @@ -114,7 +126,7 @@ def test_open_uri with_http {|srv, dr, url| srv.mount_proc("/foo_ou", lambda { |req, res| res.body = "foo_ou" } ) u = URI("#{url}/foo_ou") - open(u) {|f| + URI.open(u) {|f| assert_equal("200", f.status[0]) assert_equal("foo_ou", f.read) } @@ -122,7 +134,7 @@ def test_open_uri end def test_open_too_many_arg - assert_raise(ArgumentError) { open("http://192.0.2.1/tma", "r", 0666, :extra) {} } + assert_raise(ArgumentError) { URI.open("http://192.0.2.1/tma", "r", 0666, :extra) {} } end def test_read_timeout @@ -169,28 +181,28 @@ def test_open_timeout end def test_invalid_option - assert_raise(ArgumentError) { open("http://127.0.0.1/", :invalid_option=>true) {} } + assert_raise(ArgumentError) { URI.open("http://127.0.0.1/", :invalid_option=>true) {} } end def test_mode with_http {|srv, dr, url| srv.mount_proc("/mode", lambda { |req, res| res.body = "mode" } ) - open("#{url}/mode", "r") {|f| + URI.open("#{url}/mode", "r") {|f| assert_equal("200", f.status[0]) assert_equal("mode", f.read) } - open("#{url}/mode", "r", 0600) {|f| + URI.open("#{url}/mode", "r", 0600) {|f| assert_equal("200", f.status[0]) assert_equal("mode", f.read) } - assert_raise(ArgumentError) { open("#{url}/mode", "a") {} } - open("#{url}/mode", "r:us-ascii") {|f| + assert_raise(ArgumentError) { URI.open("#{url}/mode", "a") {} } + URI.open("#{url}/mode", "r:us-ascii") {|f| assert_equal(Encoding::US_ASCII, f.read.encoding) } - open("#{url}/mode", "r:utf-8") {|f| + URI.open("#{url}/mode", "r:utf-8") {|f| assert_equal(Encoding::UTF_8, f.read.encoding) } - assert_raise(ArgumentError) { open("#{url}/mode", "r:invalid-encoding") {} } + assert_raise(ArgumentError) { URI.open("#{url}/mode", "r:invalid-encoding") {} } } end @@ -198,7 +210,7 @@ def test_without_block with_http {|srv, dr, url| srv.mount_proc("/without_block", lambda { |req, res| res.body = "without_block" } ) begin - f = open("#{url}/without_block") + f = URI.open("#{url}/without_block") assert_equal("200", f.status[0]) assert_equal("without_block", f.read) ensure @@ -211,7 +223,7 @@ def test_close_in_block_small with_http {|srv, dr, url| srv.mount_proc("/close200", lambda { |req, res| res.body = "close200" } ) assert_nothing_raised { - open("#{url}/close200") {|f| + URI.open("#{url}/close200") {|f| f.close } } @@ -223,7 +235,7 @@ def test_close_in_block_big content = "close200big"*10240 srv.mount_proc("/close200big", lambda { |req, res| res.body = content } ) assert_nothing_raised { - open("#{url}/close200big") {|f| + URI.open("#{url}/close200big") {|f| f.close } } @@ -235,7 +247,7 @@ def test_header myheader2 = nil with_http {|srv, dr, url| srv.mount_proc("/h/") {|req, res| myheader2 = req['myheader']; res.body = "foo" } - open("#{url}/h/", 'MyHeader'=>myheader1) {|f| + URI.open("#{url}/h/", 'MyHeader'=>myheader1) {|f| assert_equal("foo", f.read) assert_equal(myheader1, myheader2) } @@ -244,13 +256,13 @@ def test_header def test_multi_proxy_opt assert_raise(ArgumentError) { - open("http://127.0.0.1/", :proxy_http_basic_authentication=>true, :proxy=>true) {} + URI.open("http://127.0.0.1/", :proxy_http_basic_authentication=>true, :proxy=>true) {} } end def test_non_http_proxy assert_raise(RuntimeError) { - open("http://127.0.0.1/", :proxy=>URI("ftp://127.0.0.1/")) {} + URI.open("http://127.0.0.1/", :proxy=>URI("ftp://127.0.0.1/")) {} } end @@ -273,28 +285,28 @@ def test_proxy begin proxy_thread = proxy.start srv.mount_proc("/proxy", lambda { |req, res| res.body = "proxy" } ) - open("#{url}/proxy", :proxy=>proxy_url) {|f| + URI.open("#{url}/proxy", :proxy=>proxy_url) {|f| assert_equal("200", f.status[0]) assert_equal("proxy", f.read) } assert_match(/#{Regexp.quote url}/, proxy_auth_log); proxy_auth_log.clear - open("#{url}/proxy", :proxy=>URI(proxy_url)) {|f| + URI.open("#{url}/proxy", :proxy=>URI(proxy_url)) {|f| assert_equal("200", f.status[0]) assert_equal("proxy", f.read) } assert_match(/#{Regexp.quote url}/, proxy_auth_log); proxy_auth_log.clear - open("#{url}/proxy", :proxy=>nil) {|f| + URI.open("#{url}/proxy", :proxy=>nil) {|f| assert_equal("200", f.status[0]) assert_equal("proxy", f.read) } assert_equal("", proxy_auth_log); proxy_auth_log.clear assert_raise(ArgumentError) { - open("#{url}/proxy", :proxy=>:invalid) {} + URI.open("#{url}/proxy", :proxy=>:invalid) {} } assert_equal("", proxy_auth_log); proxy_auth_log.clear with_env("http_proxy"=>proxy_url) { # should not use proxy for 127.0.0.0/8. - open("#{url}/proxy") {|f| + URI.open("#{url}/proxy") {|f| assert_equal("200", f.status[0]) assert_equal("proxy", f.read) } @@ -330,7 +342,7 @@ def test_proxy_http_basic_authentication_failure begin th = proxy.start srv.mount_proc("/proxy", lambda { |req, res| res.body = "proxy" } ) - exc = assert_raise(OpenURI::HTTPError) { open("#{url}/proxy", :proxy=>proxy_url) {} } + exc = assert_raise(OpenURI::HTTPError) { URI.open("#{url}/proxy", :proxy=>proxy_url) {} } assert_equal("407", exc.io.status[0]) assert_match(/#{Regexp.quote url}/, proxy_auth_log); proxy_auth_log.clear ensure @@ -363,14 +375,14 @@ def test_proxy_http_basic_authentication_success begin th = proxy.start srv.mount_proc("/proxy", lambda { |req, res| res.body = "proxy" } ) - open("#{url}/proxy", + URI.open("#{url}/proxy", :proxy_http_basic_authentication=>[proxy_url, "user", "pass"]) {|f| assert_equal("200", f.status[0]) assert_equal("proxy", f.read) } assert_match(/#{Regexp.quote url}/, proxy_auth_log); proxy_auth_log.clear assert_raise(ArgumentError) { - open("#{url}/proxy", + URI.open("#{url}/proxy", :proxy_http_basic_authentication=>[true, "user", "pass"]) {} } assert_equal("", proxy_auth_log); proxy_auth_log.clear @@ -404,7 +416,7 @@ def test_authenticated_proxy_http_basic_authentication_success begin th = proxy.start srv.mount_proc("/proxy", lambda { |req, res| res.body = "proxy" } ) - open("#{url}/proxy", :proxy => proxy_url) {|f| + URI.open("#{url}/proxy", :proxy => proxy_url) {|f| assert_equal("200", f.status[0]) assert_equal("proxy", f.read) } @@ -423,12 +435,12 @@ def test_redirect srv.mount_proc("/r1/") {|req, res| res.status = 301; res["location"] = "#{url}/r2"; res.body = "r1" } srv.mount_proc("/r2/") {|req, res| res.body = "r2" } srv.mount_proc("/to-file/") {|req, res| res.status = 301; res["location"] = "file:///foo" } - open("#{url}/r1/") {|f| + URI.open("#{url}/r1/") {|f| assert_equal("#{url}/r2", f.base_uri.to_s) assert_equal("r2", f.read) } - assert_raise(OpenURI::HTTPRedirect) { open("#{url}/r1/", :redirect=>false) {} } - assert_raise(RuntimeError) { open("#{url}/to-file/") {} } + assert_raise(OpenURI::HTTPRedirect) { URI.open("#{url}/r1/", :redirect=>false) {} } + assert_raise(RuntimeError) { URI.open("#{url}/to-file/") {} } } end @@ -436,7 +448,7 @@ def test_redirect_loop with_http {|srv, dr, url| srv.mount_proc("/r1/") {|req, res| res.status = 301; res["location"] = "#{url}/r2"; res.body = "r1" } srv.mount_proc("/r2/") {|req, res| res.status = 301; res["location"] = "#{url}/r1"; res.body = "r2" } - assert_raise(RuntimeError) { open("#{url}/r1/") {} } + assert_raise(RuntimeError) { URI.open("#{url}/r1/") {} } } end @@ -515,7 +527,7 @@ def setup_redirect_auth(srv, url) def test_redirect_auth_success with_http {|srv, dr, url| setup_redirect_auth(srv, url) - open("#{url}/r2/", :http_basic_authentication=>['user', 'pass']) {|f| + URI.open("#{url}/r2/", :http_basic_authentication=>['user', 'pass']) {|f| assert_equal("r2", f.read) } } @@ -528,7 +540,7 @@ def test_redirect_auth_failure_r2 } with_http(log_tester) {|srv, dr, url, server_thread, server_log| setup_redirect_auth(srv, url) - exc = assert_raise(OpenURI::HTTPError) { open("#{url}/r2/") {} } + exc = assert_raise(OpenURI::HTTPError) { URI.open("#{url}/r2/") {} } assert_equal("401", exc.io.status[0]) } end @@ -540,13 +552,13 @@ def test_redirect_auth_failure_r1 } with_http(log_tester) {|srv, dr, url, server_thread, server_log| setup_redirect_auth(srv, url) - exc = assert_raise(OpenURI::HTTPError) { open("#{url}/r1/", :http_basic_authentication=>['user', 'pass']) {} } + exc = assert_raise(OpenURI::HTTPError) { URI.open("#{url}/r1/", :http_basic_authentication=>['user', 'pass']) {} } assert_equal("401", exc.io.status[0]) } end def test_userinfo - assert_raise(ArgumentError) { open("http://user:pass@127.0.0.1/") {} } + assert_raise(ArgumentError) { URI.open("http://user:pass@127.0.0.1/") {} } end def test_progress @@ -555,7 +567,7 @@ def test_progress srv.mount_proc("/data/") {|req, res| res.body = content } length = [] progress = [] - open("#{url}/data/", + URI.open("#{url}/data/", :content_length_proc => lambda {|n| length << n }, :progress_proc => lambda {|n| progress << n } ) {|f| @@ -575,7 +587,7 @@ def test_progress_chunked srv.mount_proc("/data/") {|req, res| res.body = content; res.chunked = true } length = [] progress = [] - open("#{url}/data/", + URI.open("#{url}/data/", :content_length_proc => lambda {|n| length << n }, :progress_proc => lambda {|n| progress << n } ) {|f| @@ -605,25 +617,25 @@ def test_encoding srv.mount_proc("/u8/") {|req, res| res.body = content_u8; res['content-type'] = 'text/plain; charset=utf-8' } srv.mount_proc("/ej/") {|req, res| res.body = content_ej; res['content-type'] = 'TEXT/PLAIN; charset=EUC-JP' } srv.mount_proc("/nc/") {|req, res| res.body = "aa"; res['content-type'] = 'Text/Plain' } - open("#{url}/u8/") {|f| + URI.open("#{url}/u8/") {|f| assert_equal(content_u8, f.read) assert_equal("text/plain", f.content_type) assert_equal("utf-8", f.charset) } - open("#{url}/ej/") {|f| + URI.open("#{url}/ej/") {|f| assert_equal(content_ej, f.read) assert_equal("text/plain", f.content_type) assert_equal("euc-jp", f.charset) assert_equal(Encoding::EUC_JP, f.read.encoding) } - open("#{url}/ej/", 'r:utf-8') {|f| + URI.open("#{url}/ej/", 'r:utf-8') {|f| # override charset with encoding option assert_equal(content_ej.dup.force_encoding('utf-8'), f.read) assert_equal("text/plain", f.content_type) assert_equal("euc-jp", f.charset) assert_equal(Encoding::UTF_8, f.read.encoding) } - open("#{url}/ej/", :encoding=>'utf-8') {|f| + URI.open("#{url}/ej/", :encoding=>'utf-8') {|f| # override charset with encoding option assert_equal(content_ej.dup.force_encoding('utf-8'), f.read) assert_equal("text/plain", f.content_type) @@ -631,9 +643,9 @@ def test_encoding assert_equal(Encoding::UTF_8, f.read.encoding) } assert_raise(ArgumentError) { - open("#{url}/ej/", 'r:utf-8', :encoding=>'utf-8') {|f| } + URI.open("#{url}/ej/", 'r:utf-8', :encoding=>'utf-8') {|f| } } - open("#{url}/nc/") {|f| + URI.open("#{url}/nc/") {|f| assert_equal("aa", f.read) assert_equal("text/plain", f.content_type) assert_equal("iso-8859-1", f.charset) @@ -646,7 +658,7 @@ def test_quoted_attvalue with_http {|srv, dr, url| content_u8 = "\u3042" srv.mount_proc("/qu8/") {|req, res| res.body = content_u8; res['content-type'] = 'text/plain; charset="utf\-8"' } - open("#{url}/qu8/") {|f| + URI.open("#{url}/qu8/") {|f| assert_equal(content_u8, f.read) assert_equal("text/plain", f.content_type) assert_equal("utf-8", f.charset) @@ -657,7 +669,7 @@ def test_quoted_attvalue def test_last_modified with_http {|srv, dr, url| srv.mount_proc("/data/") {|req, res| res.body = "foo"; res['last-modified'] = 'Fri, 07 Aug 2009 06:05:04 GMT' } - open("#{url}/data/") {|f| + URI.open("#{url}/data/") {|f| assert_equal("foo", f.read) assert_equal(Time.utc(2009,8,7,6,5,4), f.last_modified) } @@ -671,15 +683,15 @@ def test_content_encoding srv.mount_proc("/data/") {|req, res| res.body = content_gz; res['content-encoding'] = 'gzip' } srv.mount_proc("/data2/") {|req, res| res.body = content_gz; res['content-encoding'] = 'gzip'; res.chunked = true } srv.mount_proc("/noce/") {|req, res| res.body = content_gz } - open("#{url}/data/") {|f| + URI.open("#{url}/data/") {|f| assert_equal [], f.content_encoding assert_equal(content, f.read) } - open("#{url}/data2/") {|f| + URI.open("#{url}/data2/") {|f| assert_equal [], f.content_encoding assert_equal(content, f.read) } - open("#{url}/noce/") {|f| + URI.open("#{url}/noce/") {|f| assert_equal [], f.content_encoding assert_equal(content_gz, f.read.force_encoding("ascii-8bit")) } @@ -693,7 +705,7 @@ def test_multiple_cookies res.cookies << "name2=value2; blabla" res.body = "foo" } - open("#{url}/mcookie/") {|f| + URI.open("#{url}/mcookie/") {|f| assert_equal("foo", f.read) assert_equal(["name1=value1; blabla", "name2=value2; blabla"], f.metas['set-cookie'].sort) diff --git a/test/open-uri/test_ssl.rb b/test/open-uri/test_ssl.rb index 337139604f220e..4f645d83b9e091 100644 --- a/test/open-uri/test_ssl.rb +++ b/test/open-uri/test_ssl.rb @@ -67,7 +67,7 @@ def teardown def setup_validation(srv, dr) cacert_filename = "#{dr}/cacert.pem" - open(cacert_filename, "w") {|f| f << CA_CERT } + URI.open(cacert_filename, "w") {|f| f << CA_CERT } srv.mount_proc("/data", lambda { |req, res| res.body = "ddd" } ) cacert_filename end @@ -75,7 +75,7 @@ def setup_validation(srv, dr) def test_validation_success with_https {|srv, dr, url| cacert_filename = setup_validation(srv, dr) - open("#{url}/data", :ssl_ca_cert => cacert_filename) {|f| + URI.open("#{url}/data", :ssl_ca_cert => cacert_filename) {|f| assert_equal("200", f.status[0]) assert_equal("ddd", f.read) } @@ -85,7 +85,7 @@ def test_validation_success def test_validation_noverify with_https {|srv, dr, url| setup_validation(srv, dr) - open("#{url}/data", :ssl_verify_mode => OpenSSL::SSL::VERIFY_NONE) {|f| + URI.open("#{url}/data", :ssl_verify_mode => OpenSSL::SSL::VERIFY_NONE) {|f| assert_equal("200", f.status[0]) assert_equal("ddd", f.read) } @@ -103,7 +103,7 @@ def test_validation_failure end with_https(log_tester) {|srv, dr, url, server_thread, server_log| setup_validation(srv, dr) - assert_raise(OpenSSL::SSL::SSLError) { open("#{url}/data") {} } + assert_raise(OpenSSL::SSL::SSLError) { URI.open("#{url}/data") {} } } end @@ -149,7 +149,7 @@ def test_proxy_cacert_file } with_https_proxy(proxy_log_tester) {|srv, dr, url_, cacert_filename, cacert_directory, proxy_host, proxy_port| url = url_ - open("#{url}/proxy", :proxy=>"http://#{proxy_host}:#{proxy_port}/", :ssl_ca_cert => cacert_filename) {|f| + URI.open("#{url}/proxy", :proxy=>"http://#{proxy_host}:#{proxy_port}/", :ssl_ca_cert => cacert_filename) {|f| assert_equal("200", f.status[0]) assert_equal("proxy", f.read) } @@ -165,7 +165,7 @@ def test_proxy_cacert_dir } with_https_proxy(proxy_log_tester) {|srv, dr, url_, cacert_filename, cacert_directory, proxy_host, proxy_port| url = url_ - open("#{url}/proxy", :proxy=>"http://#{proxy_host}:#{proxy_port}/", :ssl_ca_cert => cacert_directory) {|f| + URI.open("#{url}/proxy", :proxy=>"http://#{proxy_host}:#{proxy_port}/", :ssl_ca_cert => cacert_directory) {|f| assert_equal("200", f.status[0]) assert_equal("proxy", f.read) } From 6bca4437dea5da28b8b7e5f1cb87561f2772a03d Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Sun, 14 Jul 2019 17:22:13 +0900 Subject: [PATCH 070/452] Describe warning of open-uri. --- NEWS | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/NEWS b/NEWS index ef84aa3daa5e3d..3ecd269790ab0d 100644 --- a/NEWS +++ b/NEWS @@ -198,6 +198,11 @@ Net::IMAP:: * Add Server Name Indication (SNI) support. [Feature #15594] +open-uri:: + + * Warn open-uri's "open" method at Kernel. + Use URI.open instead. + Racc:: * Merge 1.4.15 from upstream repository and added cli of racc. From 61577fa53bd1ce949912c3b1281668e0ccbcda37 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Sun, 14 Jul 2019 17:32:49 +0900 Subject: [PATCH 071/452] Add a /* fall through */ comment --- load.c | 1 + 1 file changed, 1 insertion(+) diff --git a/load.c b/load.c index 539b29f89be624..9fad2bd1dbe222 100644 --- a/load.c +++ b/load.c @@ -923,6 +923,7 @@ search_required(VALUE fname, volatile VALUE *path, int safe_level, feature_func if (loading) *path = rb_filesystem_str_new_cstr(loading); return ft; } + /* fall through */ case 1: ext = strrchr(ftptr = RSTRING_PTR(tmp), '.'); if (rb_feature_p(ftptr, ext, !--type, TRUE, &loading) && !loading) From 4d9504fe13c6470d9da74540f92a247e8c1d9b99 Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Sun, 14 Jul 2019 17:39:21 +0900 Subject: [PATCH 072/452] Delegates 3 arguments for Pathname.glob. Thanks for the patch by pocke (Masataka Kuwabara) [Feature #14405]. --- ext/pathname/pathname.c | 4 ++-- test/pathname/test_pathname.rb | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/ext/pathname/pathname.c b/ext/pathname/pathname.c index 9cf6c3203915c2..70f82583a1b42b 100644 --- a/ext/pathname/pathname.c +++ b/ext/pathname/pathname.c @@ -1092,10 +1092,10 @@ s_glob_i(RB_BLOCK_CALL_FUNC_ARGLIST(elt, klass)) static VALUE path_s_glob(int argc, VALUE *argv, VALUE klass) { - VALUE args[2]; + VALUE args[3]; int n; - n = rb_scan_args(argc, argv, "11", &args[0], &args[1]); + n = rb_scan_args(argc, argv, "12", &args[0], &args[1], &args[2]); if (rb_block_given_p()) { return rb_block_call(rb_cDir, id_glob, n, args, s_glob_i, klass); } diff --git a/test/pathname/test_pathname.rb b/test/pathname/test_pathname.rb index 8e6681232b5923..076a73e50bce81 100644 --- a/test/pathname/test_pathname.rb +++ b/test/pathname/test_pathname.rb @@ -1251,6 +1251,17 @@ def test_s_glob } end + def test_s_glob_3args + with_tmpchdir('rubytest-pathname') {|dir| + open("f", "w") {|f| f.write "abc" } + Dir.chdir("/") { + assert_equal( + [Pathname("."), Pathname(".."), Pathname("f")], + Pathname.glob("*", File::FNM_DOTMATCH, base: dir).sort) + } + } + end + def test_s_getwd wd = Pathname.getwd assert_kind_of(Pathname, wd) From 5786df12f5c07510f9f15e984c564179afae33c0 Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Sun, 14 Jul 2019 17:44:33 +0900 Subject: [PATCH 073/452] Describe about Pathname.glob. --- NEWS | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/NEWS b/NEWS index 3ecd269790ab0d..82ce541bbc0d0d 100644 --- a/NEWS +++ b/NEWS @@ -203,6 +203,11 @@ open-uri:: * Warn open-uri's "open" method at Kernel. Use URI.open instead. +Pathname: + + * Delegates 3 arguments from Pathname.glob to Dir.glob to + accept base: keyword. + Racc:: * Merge 1.4.15 from upstream repository and added cli of racc. From 32f013514460574eed03aa678f87ed7ca9600872 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 14 Jul 2019 13:05:16 +0900 Subject: [PATCH 074/452] Split RUBY_ASSERT and so on under include/ruby --- common.mk | 38 +++++++++++++++++++++++++++++++ ext/coverage/depend | 1 + ext/objspace/depend | 1 + include/ruby/assert.h | 49 ++++++++++++++++++++++++++++++++++++++++ ruby_assert.h | 52 +------------------------------------------ 5 files changed, 90 insertions(+), 51 deletions(-) mode change 100755 => 100644 common.mk create mode 100644 include/ruby/assert.h diff --git a/common.mk b/common.mk old mode 100755 new mode 100644 index 8f123e54c69942..b94be35d47cf80 --- a/common.mk +++ b/common.mk @@ -1533,6 +1533,7 @@ addr2line.$(OBJEXT): {$(VPATH)}missing.h array.$(OBJEXT): $(hdrdir)/ruby.h array.$(OBJEXT): $(hdrdir)/ruby/ruby.h array.$(OBJEXT): {$(VPATH)}array.c +array.$(OBJEXT): {$(VPATH)}assert.h array.$(OBJEXT): {$(VPATH)}config.h array.$(OBJEXT): {$(VPATH)}debug_counter.h array.$(OBJEXT): {$(VPATH)}defines.h @@ -1558,6 +1559,7 @@ ast.$(OBJEXT): $(CCAN_DIR)/list/list.h ast.$(OBJEXT): $(CCAN_DIR)/str/str.h ast.$(OBJEXT): $(hdrdir)/ruby.h ast.$(OBJEXT): $(hdrdir)/ruby/ruby.h +ast.$(OBJEXT): {$(VPATH)}assert.h ast.$(OBJEXT): {$(VPATH)}ast.c ast.$(OBJEXT): {$(VPATH)}config.h ast.$(OBJEXT): {$(VPATH)}defines.h @@ -1582,6 +1584,7 @@ ast.$(OBJEXT): {$(VPATH)}vm_core.h ast.$(OBJEXT): {$(VPATH)}vm_opts.h bignum.$(OBJEXT): $(hdrdir)/ruby.h bignum.$(OBJEXT): $(hdrdir)/ruby/ruby.h +bignum.$(OBJEXT): {$(VPATH)}assert.h bignum.$(OBJEXT): {$(VPATH)}bignum.c bignum.$(OBJEXT): {$(VPATH)}config.h bignum.$(OBJEXT): {$(VPATH)}defines.h @@ -1604,6 +1607,7 @@ class.$(OBJEXT): $(CCAN_DIR)/list/list.h class.$(OBJEXT): $(CCAN_DIR)/str/str.h class.$(OBJEXT): $(hdrdir)/ruby.h class.$(OBJEXT): $(hdrdir)/ruby/ruby.h +class.$(OBJEXT): {$(VPATH)}assert.h class.$(OBJEXT): {$(VPATH)}class.c class.$(OBJEXT): {$(VPATH)}config.h class.$(OBJEXT): {$(VPATH)}constant.h @@ -1643,6 +1647,7 @@ compile.$(OBJEXT): $(CCAN_DIR)/list/list.h compile.$(OBJEXT): $(CCAN_DIR)/str/str.h compile.$(OBJEXT): $(hdrdir)/ruby.h compile.$(OBJEXT): $(hdrdir)/ruby/ruby.h +compile.$(OBJEXT): {$(VPATH)}assert.h compile.$(OBJEXT): {$(VPATH)}compile.c compile.$(OBJEXT): {$(VPATH)}config.h compile.$(OBJEXT): {$(VPATH)}defines.h @@ -1680,6 +1685,7 @@ compile.$(OBJEXT): {$(VPATH)}vm_debug.h compile.$(OBJEXT): {$(VPATH)}vm_opts.h complex.$(OBJEXT): $(hdrdir)/ruby.h complex.$(OBJEXT): $(hdrdir)/ruby/ruby.h +complex.$(OBJEXT): {$(VPATH)}assert.h complex.$(OBJEXT): {$(VPATH)}complex.c complex.$(OBJEXT): {$(VPATH)}config.h complex.$(OBJEXT): {$(VPATH)}defines.h @@ -1701,6 +1707,7 @@ cont.$(OBJEXT): $(CCAN_DIR)/str/str.h cont.$(OBJEXT): $(hdrdir)/ruby.h cont.$(OBJEXT): $(hdrdir)/ruby/ruby.h cont.$(OBJEXT): {$(VPATH)}$(COROUTINE_H) +cont.$(OBJEXT): {$(VPATH)}assert.h cont.$(OBJEXT): {$(VPATH)}config.h cont.$(OBJEXT): {$(VPATH)}cont.c cont.$(OBJEXT): {$(VPATH)}debug_counter.h @@ -1733,6 +1740,7 @@ debug.$(OBJEXT): $(CCAN_DIR)/list/list.h debug.$(OBJEXT): $(CCAN_DIR)/str/str.h debug.$(OBJEXT): $(hdrdir)/ruby.h debug.$(OBJEXT): $(hdrdir)/ruby/ruby.h +debug.$(OBJEXT): {$(VPATH)}assert.h debug.$(OBJEXT): {$(VPATH)}config.h debug.$(OBJEXT): {$(VPATH)}debug.c debug.$(OBJEXT): {$(VPATH)}defines.h @@ -1867,6 +1875,7 @@ enc/utf_8.$(OBJEXT): {$(VPATH)}oniguruma.h enc/utf_8.$(OBJEXT): {$(VPATH)}regenc.h encoding.$(OBJEXT): $(hdrdir)/ruby.h encoding.$(OBJEXT): $(hdrdir)/ruby/ruby.h +encoding.$(OBJEXT): {$(VPATH)}assert.h encoding.$(OBJEXT): {$(VPATH)}config.h encoding.$(OBJEXT): {$(VPATH)}defines.h encoding.$(OBJEXT): {$(VPATH)}encindex.h @@ -1922,6 +1931,7 @@ error.$(OBJEXT): $(CCAN_DIR)/list/list.h error.$(OBJEXT): $(CCAN_DIR)/str/str.h error.$(OBJEXT): $(hdrdir)/ruby.h error.$(OBJEXT): $(hdrdir)/ruby/ruby.h +error.$(OBJEXT): {$(VPATH)}assert.h error.$(OBJEXT): {$(VPATH)}config.h error.$(OBJEXT): {$(VPATH)}defines.h error.$(OBJEXT): {$(VPATH)}encoding.h @@ -1951,6 +1961,7 @@ eval.$(OBJEXT): $(CCAN_DIR)/list/list.h eval.$(OBJEXT): $(CCAN_DIR)/str/str.h eval.$(OBJEXT): $(hdrdir)/ruby.h eval.$(OBJEXT): $(hdrdir)/ruby/ruby.h +eval.$(OBJEXT): {$(VPATH)}assert.h eval.$(OBJEXT): {$(VPATH)}config.h eval.$(OBJEXT): {$(VPATH)}debug_counter.h eval.$(OBJEXT): {$(VPATH)}defines.h @@ -2012,6 +2023,7 @@ gc.$(OBJEXT): $(CCAN_DIR)/list/list.h gc.$(OBJEXT): $(CCAN_DIR)/str/str.h gc.$(OBJEXT): $(hdrdir)/ruby.h gc.$(OBJEXT): $(hdrdir)/ruby/ruby.h +gc.$(OBJEXT): {$(VPATH)}assert.h gc.$(OBJEXT): {$(VPATH)}config.h gc.$(OBJEXT): {$(VPATH)}constant.h gc.$(OBJEXT): {$(VPATH)}debug.h @@ -2057,6 +2069,7 @@ golf_prelude.$(OBJEXT): $(CCAN_DIR)/list/list.h golf_prelude.$(OBJEXT): $(CCAN_DIR)/str/str.h golf_prelude.$(OBJEXT): $(hdrdir)/ruby.h golf_prelude.$(OBJEXT): $(hdrdir)/ruby/ruby.h +golf_prelude.$(OBJEXT): {$(VPATH)}assert.h golf_prelude.$(OBJEXT): {$(VPATH)}config.h golf_prelude.$(OBJEXT): {$(VPATH)}defines.h golf_prelude.$(OBJEXT): {$(VPATH)}encoding.h @@ -2096,6 +2109,7 @@ goruby.$(OBJEXT): {$(VPATH)}subst.h goruby.$(OBJEXT): {$(VPATH)}vm_debug.h hash.$(OBJEXT): $(hdrdir)/ruby.h hash.$(OBJEXT): $(hdrdir)/ruby/ruby.h +hash.$(OBJEXT): {$(VPATH)}assert.h hash.$(OBJEXT): {$(VPATH)}config.h hash.$(OBJEXT): {$(VPATH)}debug_counter.h hash.$(OBJEXT): {$(VPATH)}defines.h @@ -2137,6 +2151,7 @@ io.$(OBJEXT): $(CCAN_DIR)/list/list.h io.$(OBJEXT): $(CCAN_DIR)/str/str.h io.$(OBJEXT): $(hdrdir)/ruby.h io.$(OBJEXT): $(hdrdir)/ruby/ruby.h +io.$(OBJEXT): {$(VPATH)}assert.h io.$(OBJEXT): {$(VPATH)}config.h io.$(OBJEXT): {$(VPATH)}defines.h io.$(OBJEXT): {$(VPATH)}dln.h @@ -2168,6 +2183,7 @@ iseq.$(OBJEXT): $(CCAN_DIR)/list/list.h iseq.$(OBJEXT): $(CCAN_DIR)/str/str.h iseq.$(OBJEXT): $(hdrdir)/ruby.h iseq.$(OBJEXT): $(hdrdir)/ruby/ruby.h +iseq.$(OBJEXT): {$(VPATH)}assert.h iseq.$(OBJEXT): {$(VPATH)}config.h iseq.$(OBJEXT): {$(VPATH)}debug_counter.h iseq.$(OBJEXT): {$(VPATH)}defines.h @@ -2207,6 +2223,7 @@ load.$(OBJEXT): $(CCAN_DIR)/list/list.h load.$(OBJEXT): $(CCAN_DIR)/str/str.h load.$(OBJEXT): $(hdrdir)/ruby.h load.$(OBJEXT): $(hdrdir)/ruby/ruby.h +load.$(OBJEXT): {$(VPATH)}assert.h load.$(OBJEXT): {$(VPATH)}config.h load.$(OBJEXT): {$(VPATH)}defines.h load.$(OBJEXT): {$(VPATH)}dln.h @@ -2323,6 +2340,7 @@ mjit.$(OBJEXT): $(CCAN_DIR)/list/list.h mjit.$(OBJEXT): $(CCAN_DIR)/str/str.h mjit.$(OBJEXT): $(hdrdir)/ruby.h mjit.$(OBJEXT): $(hdrdir)/ruby/ruby.h +mjit.$(OBJEXT): {$(VPATH)}assert.h mjit.$(OBJEXT): {$(VPATH)}config.h mjit.$(OBJEXT): {$(VPATH)}constant.h mjit.$(OBJEXT): {$(VPATH)}debug.h @@ -2357,6 +2375,7 @@ mjit_compile.$(OBJEXT): $(CCAN_DIR)/list/list.h mjit_compile.$(OBJEXT): $(CCAN_DIR)/str/str.h mjit_compile.$(OBJEXT): $(hdrdir)/ruby.h mjit_compile.$(OBJEXT): $(hdrdir)/ruby/ruby.h +mjit_compile.$(OBJEXT): {$(VPATH)}assert.h mjit_compile.$(OBJEXT): {$(VPATH)}config.h mjit_compile.$(OBJEXT): {$(VPATH)}debug_counter.h mjit_compile.$(OBJEXT): {$(VPATH)}defines.h @@ -2389,6 +2408,7 @@ node.$(OBJEXT): $(CCAN_DIR)/list/list.h node.$(OBJEXT): $(CCAN_DIR)/str/str.h node.$(OBJEXT): $(hdrdir)/ruby.h node.$(OBJEXT): $(hdrdir)/ruby/ruby.h +node.$(OBJEXT): {$(VPATH)}assert.h node.$(OBJEXT): {$(VPATH)}config.h node.$(OBJEXT): {$(VPATH)}defines.h node.$(OBJEXT): {$(VPATH)}encoding.h @@ -2492,6 +2512,7 @@ prelude.$(OBJEXT): $(CCAN_DIR)/list/list.h prelude.$(OBJEXT): $(CCAN_DIR)/str/str.h prelude.$(OBJEXT): $(hdrdir)/ruby.h prelude.$(OBJEXT): $(hdrdir)/ruby/ruby.h +prelude.$(OBJEXT): {$(VPATH)}assert.h prelude.$(OBJEXT): {$(VPATH)}config.h prelude.$(OBJEXT): {$(VPATH)}defines.h prelude.$(OBJEXT): {$(VPATH)}encoding.h @@ -2523,6 +2544,7 @@ proc.$(OBJEXT): $(CCAN_DIR)/list/list.h proc.$(OBJEXT): $(CCAN_DIR)/str/str.h proc.$(OBJEXT): $(hdrdir)/ruby.h proc.$(OBJEXT): $(hdrdir)/ruby/ruby.h +proc.$(OBJEXT): {$(VPATH)}assert.h proc.$(OBJEXT): {$(VPATH)}config.h proc.$(OBJEXT): {$(VPATH)}defines.h proc.$(OBJEXT): {$(VPATH)}encoding.h @@ -2554,6 +2576,7 @@ process.$(OBJEXT): $(CCAN_DIR)/list/list.h process.$(OBJEXT): $(CCAN_DIR)/str/str.h process.$(OBJEXT): $(hdrdir)/ruby.h process.$(OBJEXT): $(hdrdir)/ruby/ruby.h +process.$(OBJEXT): {$(VPATH)}assert.h process.$(OBJEXT): {$(VPATH)}config.h process.$(OBJEXT): {$(VPATH)}defines.h process.$(OBJEXT): {$(VPATH)}dln.h @@ -2615,6 +2638,7 @@ range.$(OBJEXT): {$(VPATH)}st.h range.$(OBJEXT): {$(VPATH)}subst.h rational.$(OBJEXT): $(hdrdir)/ruby.h rational.$(OBJEXT): $(hdrdir)/ruby/ruby.h +rational.$(OBJEXT): {$(VPATH)}assert.h rational.$(OBJEXT): {$(VPATH)}config.h rational.$(OBJEXT): {$(VPATH)}defines.h rational.$(OBJEXT): {$(VPATH)}encoding.h @@ -2733,6 +2757,7 @@ ruby.$(OBJEXT): $(CCAN_DIR)/str/str.h ruby.$(OBJEXT): $(hdrdir)/ruby.h ruby.$(OBJEXT): $(hdrdir)/ruby/ruby.h ruby.$(OBJEXT): $(hdrdir)/ruby/version.h +ruby.$(OBJEXT): {$(VPATH)}assert.h ruby.$(OBJEXT): {$(VPATH)}config.h ruby.$(OBJEXT): {$(VPATH)}debug_counter.h ruby.$(OBJEXT): {$(VPATH)}defines.h @@ -2767,6 +2792,7 @@ safe.$(OBJEXT): $(CCAN_DIR)/list/list.h safe.$(OBJEXT): $(CCAN_DIR)/str/str.h safe.$(OBJEXT): $(hdrdir)/ruby.h safe.$(OBJEXT): $(hdrdir)/ruby/ruby.h +safe.$(OBJEXT): {$(VPATH)}assert.h safe.$(OBJEXT): {$(VPATH)}config.h safe.$(OBJEXT): {$(VPATH)}defines.h safe.$(OBJEXT): {$(VPATH)}encoding.h @@ -2805,6 +2831,7 @@ signal.$(OBJEXT): $(CCAN_DIR)/list/list.h signal.$(OBJEXT): $(CCAN_DIR)/str/str.h signal.$(OBJEXT): $(hdrdir)/ruby.h signal.$(OBJEXT): $(hdrdir)/ruby/ruby.h +signal.$(OBJEXT): {$(VPATH)}assert.h signal.$(OBJEXT): {$(VPATH)}config.h signal.$(OBJEXT): {$(VPATH)}debug_counter.h signal.$(OBJEXT): {$(VPATH)}defines.h @@ -2882,6 +2909,7 @@ strftime.$(OBJEXT): {$(VPATH)}subst.h strftime.$(OBJEXT): {$(VPATH)}timev.h string.$(OBJEXT): $(hdrdir)/ruby.h string.$(OBJEXT): $(hdrdir)/ruby/ruby.h +string.$(OBJEXT): {$(VPATH)}assert.h string.$(OBJEXT): {$(VPATH)}config.h string.$(OBJEXT): {$(VPATH)}crypt.h string.$(OBJEXT): {$(VPATH)}debug_counter.h @@ -2917,6 +2945,7 @@ struct.$(OBJEXT): $(CCAN_DIR)/list/list.h struct.$(OBJEXT): $(CCAN_DIR)/str/str.h struct.$(OBJEXT): $(hdrdir)/ruby.h struct.$(OBJEXT): $(hdrdir)/ruby/ruby.h +struct.$(OBJEXT): {$(VPATH)}assert.h struct.$(OBJEXT): {$(VPATH)}config.h struct.$(OBJEXT): {$(VPATH)}defines.h struct.$(OBJEXT): {$(VPATH)}encoding.h @@ -2942,6 +2971,7 @@ struct.$(OBJEXT): {$(VPATH)}vm_debug.h struct.$(OBJEXT): {$(VPATH)}vm_opts.h symbol.$(OBJEXT): $(hdrdir)/ruby.h symbol.$(OBJEXT): $(hdrdir)/ruby/ruby.h +symbol.$(OBJEXT): {$(VPATH)}assert.h symbol.$(OBJEXT): {$(VPATH)}config.h symbol.$(OBJEXT): {$(VPATH)}defines.h symbol.$(OBJEXT): {$(VPATH)}encoding.h @@ -2969,6 +2999,7 @@ thread.$(OBJEXT): $(CCAN_DIR)/list/list.h thread.$(OBJEXT): $(CCAN_DIR)/str/str.h thread.$(OBJEXT): $(hdrdir)/ruby.h thread.$(OBJEXT): $(hdrdir)/ruby/ruby.h +thread.$(OBJEXT): {$(VPATH)}assert.h thread.$(OBJEXT): {$(VPATH)}config.h thread.$(OBJEXT): {$(VPATH)}debug.h thread.$(OBJEXT): {$(VPATH)}debug_counter.h @@ -3035,6 +3066,7 @@ transcode.$(OBJEXT): {$(VPATH)}transcode.c transcode.$(OBJEXT): {$(VPATH)}transcode_data.h transient_heap.$(OBJEXT): $(hdrdir)/ruby.h transient_heap.$(OBJEXT): $(hdrdir)/ruby/ruby.h +transient_heap.$(OBJEXT): {$(VPATH)}assert.h transient_heap.$(OBJEXT): {$(VPATH)}config.h transient_heap.$(OBJEXT): {$(VPATH)}debug.h transient_heap.$(OBJEXT): {$(VPATH)}debug_counter.h @@ -3072,6 +3104,7 @@ variable.$(OBJEXT): $(CCAN_DIR)/list/list.h variable.$(OBJEXT): $(CCAN_DIR)/str/str.h variable.$(OBJEXT): $(hdrdir)/ruby.h variable.$(OBJEXT): $(hdrdir)/ruby/ruby.h +variable.$(OBJEXT): {$(VPATH)}assert.h variable.$(OBJEXT): {$(VPATH)}config.h variable.$(OBJEXT): {$(VPATH)}constant.h variable.$(OBJEXT): {$(VPATH)}debug_counter.h @@ -3107,6 +3140,7 @@ version.$(OBJEXT): $(hdrdir)/ruby/ruby.h version.$(OBJEXT): $(hdrdir)/ruby/version.h version.$(OBJEXT): $(top_srcdir)/revision.h version.$(OBJEXT): $(top_srcdir)/version.h +version.$(OBJEXT): {$(VPATH)}assert.h version.$(OBJEXT): {$(VPATH)}config.h version.$(OBJEXT): {$(VPATH)}debug_counter.h version.$(OBJEXT): {$(VPATH)}defines.h @@ -3132,6 +3166,7 @@ vm.$(OBJEXT): $(CCAN_DIR)/list/list.h vm.$(OBJEXT): $(CCAN_DIR)/str/str.h vm.$(OBJEXT): $(hdrdir)/ruby.h vm.$(OBJEXT): $(hdrdir)/ruby/ruby.h +vm.$(OBJEXT): {$(VPATH)}assert.h vm.$(OBJEXT): {$(VPATH)}config.h vm.$(OBJEXT): {$(VPATH)}constant.h vm.$(OBJEXT): {$(VPATH)}debug_counter.h @@ -3185,6 +3220,7 @@ vm_backtrace.$(OBJEXT): $(CCAN_DIR)/list/list.h vm_backtrace.$(OBJEXT): $(CCAN_DIR)/str/str.h vm_backtrace.$(OBJEXT): $(hdrdir)/ruby.h vm_backtrace.$(OBJEXT): $(hdrdir)/ruby/ruby.h +vm_backtrace.$(OBJEXT): {$(VPATH)}assert.h vm_backtrace.$(OBJEXT): {$(VPATH)}config.h vm_backtrace.$(OBJEXT): {$(VPATH)}debug.h vm_backtrace.$(OBJEXT): {$(VPATH)}defines.h @@ -3217,6 +3253,7 @@ vm_dump.$(OBJEXT): $(CCAN_DIR)/str/str.h vm_dump.$(OBJEXT): $(hdrdir)/ruby.h vm_dump.$(OBJEXT): $(hdrdir)/ruby/ruby.h vm_dump.$(OBJEXT): {$(VPATH)}addr2line.h +vm_dump.$(OBJEXT): {$(VPATH)}assert.h vm_dump.$(OBJEXT): {$(VPATH)}config.h vm_dump.$(OBJEXT): {$(VPATH)}defines.h vm_dump.$(OBJEXT): {$(VPATH)}encoding.h @@ -3247,6 +3284,7 @@ vm_trace.$(OBJEXT): $(CCAN_DIR)/list/list.h vm_trace.$(OBJEXT): $(CCAN_DIR)/str/str.h vm_trace.$(OBJEXT): $(hdrdir)/ruby.h vm_trace.$(OBJEXT): $(hdrdir)/ruby/ruby.h +vm_trace.$(OBJEXT): {$(VPATH)}assert.h vm_trace.$(OBJEXT): {$(VPATH)}config.h vm_trace.$(OBJEXT): {$(VPATH)}debug.h vm_trace.$(OBJEXT): {$(VPATH)}debug_counter.h diff --git a/ext/coverage/depend b/ext/coverage/depend index 6ae027aec81bd0..ad8c071fbe3003 100644 --- a/ext/coverage/depend +++ b/ext/coverage/depend @@ -14,6 +14,7 @@ $(OBJS): $(HDRS) $(ruby_headers) \ coverage.o: $(RUBY_EXTCONF_H) coverage.o: $(arch_hdrdir)/ruby/config.h coverage.o: $(hdrdir)/ruby.h +coverage.o: $(hdrdir)/ruby/assert.h coverage.o: $(hdrdir)/ruby/backward.h coverage.o: $(hdrdir)/ruby/defines.h coverage.o: $(hdrdir)/ruby/encoding.h diff --git a/ext/objspace/depend b/ext/objspace/depend index 060b863d04ddfe..32157bee2fe023 100644 --- a/ext/objspace/depend +++ b/ext/objspace/depend @@ -42,6 +42,7 @@ objspace.o: {$(VPATH)}id.h objspace_dump.o: $(RUBY_EXTCONF_H) objspace_dump.o: $(arch_hdrdir)/ruby/config.h objspace_dump.o: $(hdrdir)/ruby.h +objspace_dump.o: $(hdrdir)/ruby/assert.h objspace_dump.o: $(hdrdir)/ruby/backward.h objspace_dump.o: $(hdrdir)/ruby/debug.h objspace_dump.o: $(hdrdir)/ruby/defines.h diff --git a/include/ruby/assert.h b/include/ruby/assert.h new file mode 100644 index 00000000000000..5ef866ac9e6a65 --- /dev/null +++ b/include/ruby/assert.h @@ -0,0 +1,49 @@ +#ifndef RUBY_ASSERT_H +#define RUBY_ASSERT_H + +#if defined(__cplusplus) +extern "C" { +#if 0 +} /* satisfy cc-mode */ +#endif +#endif + +NORETURN(void rb_assert_failure(const char *, int, const char *, const char *)); +#ifdef RUBY_FUNCTION_NAME_STRING +# define RUBY_ASSERT_FAIL(expr) \ + rb_assert_failure(__FILE__, __LINE__, RUBY_FUNCTION_NAME_STRING, expr) +#else +# define RUBY_ASSERT_FAIL(expr) \ + rb_assert_failure(__FILE__, __LINE__, NULL, expr) +#endif +#define RUBY_ASSERT_MESG(expr, mesg) \ + ((expr) ? (void)0 : RUBY_ASSERT_FAIL(mesg)) +#ifdef HAVE_BUILTIN___BUILTIN_CHOOSE_EXPR_CONSTANT_P +# define RUBY_ASSERT_MESG_WHEN(cond, expr, mesg) \ + __builtin_choose_expr( \ + __builtin_constant_p(cond), \ + __builtin_choose_expr(cond, RUBY_ASSERT_MESG(expr, mesg), (void)0), \ + RUBY_ASSERT_MESG(!(cond) || (expr), mesg)) +#else +# define RUBY_ASSERT_MESG_WHEN(cond, expr, mesg) \ + RUBY_ASSERT_MESG(!(cond) || (expr), mesg) +#endif +#define RUBY_ASSERT(expr) RUBY_ASSERT_MESG_WHEN(!RUBY_NDEBUG+0, expr, #expr) +#define RUBY_ASSERT_WHEN(cond, expr) RUBY_ASSERT_MESG_WHEN(cond, expr, #expr) + +#ifndef RUBY_NDEBUG +# ifdef NDEBUG +# define RUBY_NDEBUG 1 +# else +# define RUBY_NDEBUG 0 +# endif +#endif + +#if defined(__cplusplus) +#if 0 +{ /* satisfy cc-mode */ +#endif +} /* extern "C" { */ +#endif + +#endif diff --git a/ruby_assert.h b/ruby_assert.h index 185d2e5f5fe405..139256fed8cb76 100644 --- a/ruby_assert.h +++ b/ruby_assert.h @@ -1,37 +1,4 @@ -#ifndef RUBY_ASSERT_H -#define RUBY_ASSERT_H - -#include "ruby/ruby.h" - -#if defined(__cplusplus) -extern "C" { -#if 0 -} /* satisfy cc-mode */ -#endif -#endif - -NORETURN(void rb_assert_failure(const char *, int, const char *, const char *)); -#ifdef RUBY_FUNCTION_NAME_STRING -# define RUBY_ASSERT_FAIL(expr) \ - rb_assert_failure(__FILE__, __LINE__, RUBY_FUNCTION_NAME_STRING, expr) -#else -# define RUBY_ASSERT_FAIL(expr) \ - rb_assert_failure(__FILE__, __LINE__, NULL, expr) -#endif -#define RUBY_ASSERT_MESG(expr, mesg) \ - ((expr) ? (void)0 : RUBY_ASSERT_FAIL(mesg)) -#ifdef HAVE_BUILTIN___BUILTIN_CHOOSE_EXPR_CONSTANT_P -# define RUBY_ASSERT_MESG_WHEN(cond, expr, mesg) \ - __builtin_choose_expr( \ - __builtin_constant_p(cond), \ - __builtin_choose_expr(cond, RUBY_ASSERT_MESG(expr, mesg), (void)0), \ - RUBY_ASSERT_MESG(!(cond) || (expr), mesg)) -#else -# define RUBY_ASSERT_MESG_WHEN(cond, expr, mesg) \ - RUBY_ASSERT_MESG(!(cond) || (expr), mesg) -#endif -#define RUBY_ASSERT(expr) RUBY_ASSERT_MESG_WHEN(!RUBY_NDEBUG+0, expr, #expr) -#define RUBY_ASSERT_WHEN(cond, expr) RUBY_ASSERT_MESG_WHEN(cond, expr, #expr) +#include "ruby/assert.h" #if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L) /* C89 compilers are required to support strings of only 509 chars. */ @@ -41,20 +8,3 @@ NORETURN(void rb_assert_failure(const char *, int, const char *, const char *)); #undef assert #define assert RUBY_ASSERT #endif - -#ifndef RUBY_NDEBUG -# ifdef NDEBUG -# define RUBY_NDEBUG 1 -# else -# define RUBY_NDEBUG 0 -# endif -#endif - -#if defined(__cplusplus) -#if 0 -{ /* satisfy cc-mode */ -#endif -} /* extern "C" { */ -#endif - -#endif From 73904abb951ad60483124fa620b5561015906a79 Mon Sep 17 00:00:00 2001 From: git Date: Sun, 14 Jul 2019 17:45:52 +0900 Subject: [PATCH 075/452] * expand tabs. --- include/ruby/assert.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/ruby/assert.h b/include/ruby/assert.h index 5ef866ac9e6a65..aef36b8d483cfd 100644 --- a/include/ruby/assert.h +++ b/include/ruby/assert.h @@ -21,9 +21,9 @@ NORETURN(void rb_assert_failure(const char *, int, const char *, const char *)); #ifdef HAVE_BUILTIN___BUILTIN_CHOOSE_EXPR_CONSTANT_P # define RUBY_ASSERT_MESG_WHEN(cond, expr, mesg) \ __builtin_choose_expr( \ - __builtin_constant_p(cond), \ - __builtin_choose_expr(cond, RUBY_ASSERT_MESG(expr, mesg), (void)0), \ - RUBY_ASSERT_MESG(!(cond) || (expr), mesg)) + __builtin_constant_p(cond), \ + __builtin_choose_expr(cond, RUBY_ASSERT_MESG(expr, mesg), (void)0), \ + RUBY_ASSERT_MESG(!(cond) || (expr), mesg)) #else # define RUBY_ASSERT_MESG_WHEN(cond, expr, mesg) \ RUBY_ASSERT_MESG(!(cond) || (expr), mesg) From b67b07bd5bd94433051b5e0a5db800f8b22361b4 Mon Sep 17 00:00:00 2001 From: Maxime Lapointe Date: Thu, 30 May 2019 16:46:18 -0400 Subject: [PATCH 076/452] Fix links to headings A previous change made the header's id be fully referenced (for the sidebar I believe) but this broke links to them. This fixes the issue. --- lib/rdoc/markup/to_html_crossref.rb | 2 +- test/rdoc/test_rdoc_markup_to_html_crossref.rb | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/rdoc/markup/to_html_crossref.rb b/lib/rdoc/markup/to_html_crossref.rb index 2fbddeb83b5012..4a1350a73c0a99 100644 --- a/lib/rdoc/markup/to_html_crossref.rb +++ b/lib/rdoc/markup/to_html_crossref.rb @@ -153,7 +153,7 @@ def link name, text, code = true ref.sections.any? { |section| label == section.title } then path << "##{label}" else - path << "#label-#{label}" + path << "##{ref.aref}-label-#{label}" end if label "#{text}" diff --git a/test/rdoc/test_rdoc_markup_to_html_crossref.rb b/test/rdoc/test_rdoc_markup_to_html_crossref.rb index 598bae3d3f5f0e..3d80980791a342 100644 --- a/test/rdoc/test_rdoc_markup_to_html_crossref.rb +++ b/test/rdoc/test_rdoc_markup_to_html_crossref.rb @@ -19,7 +19,7 @@ def test_convert_CROSSREF def test_convert_CROSSREF_label result = @to.convert 'C1@foo' - assert_equal para("foo at C1"), result + assert_equal para("foo at C1"), result result = @to.convert 'C1#m@foo' assert_equal para("foo at C1#m"), @@ -28,12 +28,12 @@ def test_convert_CROSSREF_label def test_convert_CROSSREF_label_period result = @to.convert 'C1@foo.' - assert_equal para("foo at C1."), result + assert_equal para("foo at C1."), result end def test_convert_CROSSREF_label_space result = @to.convert 'C1@foo+bar' - assert_equal para("foo bar at C1"), + assert_equal para("foo bar at C1"), result end @@ -104,7 +104,7 @@ def test_convert_RDOCLINK_rdoc_ref_method_percent_label def test_convert_RDOCLINK_rdoc_ref_label result = @to.convert 'rdoc-ref:C1@foo' - assert_equal para("foo at C1"), result, + assert_equal para("foo at C1"), result, 'rdoc-ref:C1@foo' end From 47e571c9510a6d6e3f7d98a8a8800f391694bd19 Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Sun, 14 Jul 2019 17:48:11 +0900 Subject: [PATCH 077/452] complement '.rb' on `test-all TESTS=test_xxx` for test-all rule, we can specify a file with TESTS option like `TESTS=test_xxx.rb`. However, we can eliminate last '.rb' suffix so this patch try with '.rb' suffix if the given path is not available. --- tool/lib/test/unit.rb | 54 +++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 22 deletions(-) diff --git a/tool/lib/test/unit.rb b/tool/lib/test/unit.rb index 3df6774d61f6a3..5a980603a5d505 100644 --- a/tool/lib/test/unit.rb +++ b/tool/lib/test/unit.rb @@ -871,31 +871,41 @@ def non_options(files, options) end files.map! {|f| f = f.tr(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR - ((paths if /\A\.\.?(?:\z|\/)/ !~ f) || [nil]).any? do |prefix| - if prefix - path = f.empty? ? prefix : "#{prefix}/#{f}" - else - next if f.empty? - path = f - end - if f.end_with?(File::SEPARATOR) or !f.include?(File::SEPARATOR) or File.directory?(path) - match = (Dir["#{path}/**/#{@@testfile_prefix}_*.rb"] + Dir["#{path}/**/*_#{@@testfile_suffix}.rb"]).uniq - else - match = Dir[path] + while true + ret = ((paths if /\A\.\.?(?:\z|\/)/ !~ f) || [nil]).any? do |prefix| + if prefix + path = f.empty? ? prefix : "#{prefix}/#{f}" + else + next if f.empty? + path = f + end + if f.end_with?(File::SEPARATOR) or !f.include?(File::SEPARATOR) or File.directory?(path) + match = (Dir["#{path}/**/#{@@testfile_prefix}_*.rb"] + Dir["#{path}/**/*_#{@@testfile_suffix}.rb"]).uniq + else + match = Dir[path] + end + if !match.empty? + if reject + match.reject! {|n| + n = n[(prefix.length+1)..-1] if prefix + reject_pat =~ n + } + end + break match + elsif !reject or reject_pat !~ f and File.exist? path + break path + end end - if !match.empty? - if reject - match.reject! {|n| - n = n[(prefix.length+1)..-1] if prefix - reject_pat =~ n - } + if !ret + if /\.rb\z/ =~ f + raise ArgumentError, "file not found: #{f}" + else + f = "#{f}.rb" end - break match - elsif !reject or reject_pat !~ f and File.exist? path - break path + else + break ret end - end or - raise ArgumentError, "file not found: #{f}" + end } files.flatten! super(files, options) From db1c30b37fb0a837724cf5813e8684edc2639222 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Sun, 14 Jul 2019 17:53:45 +0900 Subject: [PATCH 078/452] addr2line.c (main_exe_path): avoid SEGV when /proc is not available readlink would return -1 if /proc is not mounted. Coverity Scan found this issue. --- addr2line.c | 1 + 1 file changed, 1 insertion(+) diff --git a/addr2line.c b/addr2line.c index 1871a521572e4b..45cae6a1324443 100644 --- a/addr2line.c +++ b/addr2line.c @@ -2050,6 +2050,7 @@ main_exe_path(void) { # define PROC_SELF_EXE "/proc/self/exe" ssize_t len = readlink(PROC_SELF_EXE, binary_filename, PATH_MAX); + if (len < 0) return 0; binary_filename[len] = 0; return len; } From db64093f512d93eb300131f52b7ddbd2d11f0aec Mon Sep 17 00:00:00 2001 From: Kazuhiro NISHIYAMA Date: Sun, 14 Jul 2019 17:54:22 +0900 Subject: [PATCH 079/452] [DOC] Fix a typo [ci skip] --- NEWS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 82ce541bbc0d0d..f422e68c88b1c1 100644 --- a/NEWS +++ b/NEWS @@ -77,7 +77,7 @@ Encoding:: Enumerable:: - New method:: + New methods:: * Added Enumerable#filter_map. [Feature #15323] From 715955ff27206351dcf509eb3c60e0927ad9a708 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 14 Jul 2019 13:06:22 +0900 Subject: [PATCH 080/452] Include ruby/assert.h in ruby/ruby.h so that assertions can be there --- common.mk | 38 ++++++++++++++++++++++++- enc/depend | 24 ++++++++++++++++ ext/-test-/arith_seq/extract/depend | 1 + ext/-test-/array/resize/depend | 1 + ext/-test-/bignum/depend | 7 +++++ ext/-test-/bug-3571/depend | 1 + ext/-test-/bug-5832/depend | 1 + ext/-test-/bug_reporter/depend | 1 + ext/-test-/class/depend | 2 ++ ext/-test-/debug/depend | 3 ++ ext/-test-/exception/depend | 4 +++ ext/-test-/fatal/depend | 1 + ext/-test-/file/depend | 3 ++ ext/-test-/funcall/depend | 1 + ext/-test-/gvl/call_without_gvl/depend | 1 + ext/-test-/hash/depend | 2 ++ ext/-test-/integer/depend | 3 ++ ext/-test-/iseq_load/depend | 1 + ext/-test-/iter/depend | 3 ++ ext/-test-/load/protect/depend | 1 + ext/-test-/marshal/compat/depend | 1 + ext/-test-/marshal/internal_ivar/depend | 1 + ext/-test-/marshal/usr/depend | 1 + ext/-test-/memory_status/depend | 1 + ext/-test-/method/depend | 2 ++ ext/-test-/notimplement/depend | 1 + ext/-test-/num2int/depend | 1 + ext/-test-/path_to_class/depend | 1 + ext/-test-/popen_deadlock/depend | 1 + ext/-test-/proc/depend | 3 ++ ext/-test-/rational/depend | 1 + ext/-test-/recursion/depend | 1 + ext/-test-/regexp/depend | 2 ++ ext/-test-/scan_args/depend | 1 + ext/-test-/st/foreach/depend | 1 + ext/-test-/st/numhash/depend | 1 + ext/-test-/st/update/depend | 1 + ext/-test-/string/depend | 15 ++++++++++ ext/-test-/struct/depend | 4 +++ ext/-test-/symbol/depend | 2 ++ ext/-test-/thread_fd_close/depend | 1 + ext/-test-/time/depend | 3 ++ ext/-test-/tracepoint/depend | 2 ++ ext/-test-/typeddata/depend | 1 + ext/-test-/vm/depend | 1 + ext/-test-/wait_for_single_fd/depend | 1 + ext/bigdecimal/depend | 1 + ext/bigdecimal/util/depend | 1 + ext/cgi/escape/depend | 1 + ext/continuation/depend | 1 + ext/date/depend | 4 +++ ext/dbm/depend | 1 + ext/digest/bubblebabble/depend | 1 + ext/digest/depend | 1 + ext/digest/md5/depend | 1 + ext/digest/rmd160/depend | 1 + ext/digest/sha1/depend | 1 + ext/digest/sha2/depend | 1 + ext/etc/depend | 1 + ext/fcntl/depend | 1 + ext/fiddle/depend | 6 ++++ ext/gdbm/depend | 1 + ext/io/console/depend | 1 + ext/io/nonblock/depend | 1 + ext/io/wait/depend | 1 + ext/json/generator/depend | 1 + ext/json/parser/depend | 1 + ext/nkf/depend | 1 + ext/objspace/depend | 2 ++ ext/openssl/depend | 31 ++++++++++++++++++++ ext/pathname/depend | 1 + ext/psych/depend | 5 ++++ ext/pty/depend | 1 + ext/racc/cparse/depend | 1 + ext/rbconfig/sizeof/depend | 2 ++ ext/readline/depend | 1 + ext/ripper/depend | 1 + ext/sdbm/depend | 2 ++ ext/socket/depend | 15 ++++++++++ ext/stringio/depend | 1 + ext/strscan/depend | 1 + ext/syslog/depend | 1 + ext/win32/resolv/depend | 1 + ext/zlib/depend | 1 + include/ruby/ruby.h | 1 + 85 files changed, 247 insertions(+), 1 deletion(-) diff --git a/common.mk b/common.mk index b94be35d47cf80..e7f9d2a2e22753 100644 --- a/common.mk +++ b/common.mk @@ -894,7 +894,7 @@ CCAN_DIR = {$(VPATH)}ccan RUBY_H_INCLUDES = {$(VPATH)}ruby.h {$(VPATH)}config.h {$(VPATH)}defines.h \ {$(VPATH)}intern.h {$(VPATH)}missing.h {$(VPATH)}st.h \ - {$(VPATH)}subst.h + {$(VPATH)}assert.h {$(VPATH)}subst.h ### @@ -1633,6 +1633,7 @@ class.$(OBJEXT): {$(VPATH)}vm_core.h class.$(OBJEXT): {$(VPATH)}vm_debug.h class.$(OBJEXT): {$(VPATH)}vm_opts.h compar.$(OBJEXT): $(hdrdir)/ruby/ruby.h +compar.$(OBJEXT): {$(VPATH)}assert.h compar.$(OBJEXT): {$(VPATH)}compar.c compar.$(OBJEXT): {$(VPATH)}config.h compar.$(OBJEXT): {$(VPATH)}defines.h @@ -1783,6 +1784,7 @@ debug_counter.$(OBJEXT): {$(VPATH)}st.h debug_counter.$(OBJEXT): {$(VPATH)}subst.h dir.$(OBJEXT): $(hdrdir)/ruby.h dir.$(OBJEXT): $(hdrdir)/ruby/ruby.h +dir.$(OBJEXT): {$(VPATH)}assert.h dir.$(OBJEXT): {$(VPATH)}config.h dir.$(OBJEXT): {$(VPATH)}defines.h dir.$(OBJEXT): {$(VPATH)}dir.c @@ -1801,6 +1803,7 @@ dir.$(OBJEXT): {$(VPATH)}thread.h dir.$(OBJEXT): {$(VPATH)}util.h dln.$(OBJEXT): $(hdrdir)/ruby.h dln.$(OBJEXT): $(hdrdir)/ruby/ruby.h +dln.$(OBJEXT): {$(VPATH)}assert.h dln.$(OBJEXT): {$(VPATH)}config.h dln.$(OBJEXT): {$(VPATH)}defines.h dln.$(OBJEXT): {$(VPATH)}dln.c @@ -1811,6 +1814,7 @@ dln.$(OBJEXT): {$(VPATH)}missing.h dln.$(OBJEXT): {$(VPATH)}st.h dln.$(OBJEXT): {$(VPATH)}subst.h dln_find.$(OBJEXT): $(hdrdir)/ruby/ruby.h +dln_find.$(OBJEXT): {$(VPATH)}assert.h dln_find.$(OBJEXT): {$(VPATH)}config.h dln_find.$(OBJEXT): {$(VPATH)}defines.h dln_find.$(OBJEXT): {$(VPATH)}dln.h @@ -1820,6 +1824,7 @@ dln_find.$(OBJEXT): {$(VPATH)}missing.h dln_find.$(OBJEXT): {$(VPATH)}st.h dln_find.$(OBJEXT): {$(VPATH)}subst.h dmydln.$(OBJEXT): $(hdrdir)/ruby/ruby.h +dmydln.$(OBJEXT): {$(VPATH)}assert.h dmydln.$(OBJEXT): {$(VPATH)}config.h dmydln.$(OBJEXT): {$(VPATH)}defines.h dmydln.$(OBJEXT): {$(VPATH)}dmydln.c @@ -1894,6 +1899,7 @@ encoding.$(OBJEXT): {$(VPATH)}subst.h encoding.$(OBJEXT): {$(VPATH)}util.h enum.$(OBJEXT): $(hdrdir)/ruby.h enum.$(OBJEXT): $(hdrdir)/ruby/ruby.h +enum.$(OBJEXT): {$(VPATH)}assert.h enum.$(OBJEXT): {$(VPATH)}config.h enum.$(OBJEXT): {$(VPATH)}defines.h enum.$(OBJEXT): {$(VPATH)}encoding.h @@ -1912,6 +1918,7 @@ enum.$(OBJEXT): {$(VPATH)}transient_heap.h enum.$(OBJEXT): {$(VPATH)}util.h enumerator.$(OBJEXT): $(hdrdir)/ruby.h enumerator.$(OBJEXT): $(hdrdir)/ruby/ruby.h +enumerator.$(OBJEXT): {$(VPATH)}assert.h enumerator.$(OBJEXT): {$(VPATH)}config.h enumerator.$(OBJEXT): {$(VPATH)}defines.h enumerator.$(OBJEXT): {$(VPATH)}encoding.h @@ -2000,6 +2007,7 @@ explicit_bzero.$(OBJEXT): {$(VPATH)}explicit_bzero.c explicit_bzero.$(OBJEXT): {$(VPATH)}missing.h file.$(OBJEXT): $(hdrdir)/ruby.h file.$(OBJEXT): $(hdrdir)/ruby/ruby.h +file.$(OBJEXT): {$(VPATH)}assert.h file.$(OBJEXT): {$(VPATH)}config.h file.$(OBJEXT): {$(VPATH)}defines.h file.$(OBJEXT): {$(VPATH)}dln.h @@ -2096,6 +2104,7 @@ golf_prelude.$(OBJEXT): {$(VPATH)}vm_debug.h golf_prelude.$(OBJEXT): {$(VPATH)}vm_opts.h goruby.$(OBJEXT): $(hdrdir)/ruby.h goruby.$(OBJEXT): $(hdrdir)/ruby/ruby.h +goruby.$(OBJEXT): {$(VPATH)}assert.h goruby.$(OBJEXT): {$(VPATH)}backward.h goruby.$(OBJEXT): {$(VPATH)}config.h goruby.$(OBJEXT): {$(VPATH)}defines.h @@ -2133,6 +2142,7 @@ hash.$(OBJEXT): {$(VPATH)}transient_heap.h hash.$(OBJEXT): {$(VPATH)}util.h inits.$(OBJEXT): $(hdrdir)/ruby.h inits.$(OBJEXT): $(hdrdir)/ruby/ruby.h +inits.$(OBJEXT): {$(VPATH)}assert.h inits.$(OBJEXT): {$(VPATH)}config.h inits.$(OBJEXT): {$(VPATH)}defines.h inits.$(OBJEXT): {$(VPATH)}encoding.h @@ -2255,6 +2265,7 @@ load.$(OBJEXT): {$(VPATH)}vm_opts.h loadpath.$(OBJEXT): $(hdrdir)/ruby/ruby.h loadpath.$(OBJEXT): $(hdrdir)/ruby/version.h loadpath.$(OBJEXT): $(top_srcdir)/version.h +loadpath.$(OBJEXT): {$(VPATH)}assert.h loadpath.$(OBJEXT): {$(VPATH)}config.h loadpath.$(OBJEXT): {$(VPATH)}defines.h loadpath.$(OBJEXT): {$(VPATH)}intern.h @@ -2265,6 +2276,7 @@ loadpath.$(OBJEXT): {$(VPATH)}subst.h loadpath.$(OBJEXT): {$(VPATH)}verconf.h localeinit.$(OBJEXT): $(hdrdir)/ruby.h localeinit.$(OBJEXT): $(hdrdir)/ruby/ruby.h +localeinit.$(OBJEXT): {$(VPATH)}assert.h localeinit.$(OBJEXT): {$(VPATH)}config.h localeinit.$(OBJEXT): {$(VPATH)}defines.h localeinit.$(OBJEXT): {$(VPATH)}encindex.h @@ -2280,6 +2292,7 @@ localeinit.$(OBJEXT): {$(VPATH)}st.h localeinit.$(OBJEXT): {$(VPATH)}subst.h main.$(OBJEXT): $(hdrdir)/ruby.h main.$(OBJEXT): $(hdrdir)/ruby/ruby.h +main.$(OBJEXT): {$(VPATH)}assert.h main.$(OBJEXT): {$(VPATH)}backward.h main.$(OBJEXT): {$(VPATH)}config.h main.$(OBJEXT): {$(VPATH)}defines.h @@ -2292,6 +2305,7 @@ main.$(OBJEXT): {$(VPATH)}subst.h main.$(OBJEXT): {$(VPATH)}vm_debug.h marshal.$(OBJEXT): $(hdrdir)/ruby.h marshal.$(OBJEXT): $(hdrdir)/ruby/ruby.h +marshal.$(OBJEXT): {$(VPATH)}assert.h marshal.$(OBJEXT): {$(VPATH)}config.h marshal.$(OBJEXT): {$(VPATH)}defines.h marshal.$(OBJEXT): {$(VPATH)}encindex.h @@ -2309,6 +2323,7 @@ marshal.$(OBJEXT): {$(VPATH)}subst.h marshal.$(OBJEXT): {$(VPATH)}util.h math.$(OBJEXT): $(hdrdir)/ruby.h math.$(OBJEXT): $(hdrdir)/ruby/ruby.h +math.$(OBJEXT): {$(VPATH)}assert.h math.$(OBJEXT): {$(VPATH)}config.h math.$(OBJEXT): {$(VPATH)}defines.h math.$(OBJEXT): {$(VPATH)}encoding.h @@ -2322,6 +2337,7 @@ math.$(OBJEXT): {$(VPATH)}oniguruma.h math.$(OBJEXT): {$(VPATH)}st.h math.$(OBJEXT): {$(VPATH)}subst.h miniinit.$(OBJEXT): $(hdrdir)/ruby/ruby.h +miniinit.$(OBJEXT): {$(VPATH)}assert.h miniinit.$(OBJEXT): {$(VPATH)}config.h miniinit.$(OBJEXT): {$(VPATH)}defines.h miniinit.$(OBJEXT): {$(VPATH)}encoding.h @@ -2433,6 +2449,7 @@ node.$(OBJEXT): {$(VPATH)}vm_debug.h node.$(OBJEXT): {$(VPATH)}vm_opts.h numeric.$(OBJEXT): $(hdrdir)/ruby.h numeric.$(OBJEXT): $(hdrdir)/ruby/ruby.h +numeric.$(OBJEXT): {$(VPATH)}assert.h numeric.$(OBJEXT): {$(VPATH)}config.h numeric.$(OBJEXT): {$(VPATH)}defines.h numeric.$(OBJEXT): {$(VPATH)}encoding.h @@ -2449,6 +2466,7 @@ numeric.$(OBJEXT): {$(VPATH)}subst.h numeric.$(OBJEXT): {$(VPATH)}util.h object.$(OBJEXT): $(hdrdir)/ruby.h object.$(OBJEXT): $(hdrdir)/ruby/ruby.h +object.$(OBJEXT): {$(VPATH)}assert.h object.$(OBJEXT): {$(VPATH)}config.h object.$(OBJEXT): {$(VPATH)}constant.h object.$(OBJEXT): {$(VPATH)}defines.h @@ -2468,6 +2486,7 @@ object.$(OBJEXT): {$(VPATH)}subst.h object.$(OBJEXT): {$(VPATH)}util.h pack.$(OBJEXT): $(hdrdir)/ruby.h pack.$(OBJEXT): $(hdrdir)/ruby/ruby.h +pack.$(OBJEXT): {$(VPATH)}assert.h pack.$(OBJEXT): {$(VPATH)}config.h pack.$(OBJEXT): {$(VPATH)}defines.h pack.$(OBJEXT): {$(VPATH)}encoding.h @@ -2482,6 +2501,7 @@ pack.$(OBJEXT): {$(VPATH)}st.h pack.$(OBJEXT): {$(VPATH)}subst.h parse.$(OBJEXT): $(hdrdir)/ruby.h parse.$(OBJEXT): $(hdrdir)/ruby/ruby.h +parse.$(OBJEXT): {$(VPATH)}assert.h parse.$(OBJEXT): {$(VPATH)}config.h parse.$(OBJEXT): {$(VPATH)}defines.h parse.$(OBJEXT): {$(VPATH)}defs/keywords @@ -2605,6 +2625,7 @@ process.$(OBJEXT): {$(VPATH)}vm_debug.h process.$(OBJEXT): {$(VPATH)}vm_opts.h random.$(OBJEXT): $(hdrdir)/ruby.h random.$(OBJEXT): $(hdrdir)/ruby/ruby.h +random.$(OBJEXT): {$(VPATH)}assert.h random.$(OBJEXT): {$(VPATH)}config.h random.$(OBJEXT): {$(VPATH)}defines.h random.$(OBJEXT): {$(VPATH)}encoding.h @@ -2623,6 +2644,7 @@ random.$(OBJEXT): {$(VPATH)}st.h random.$(OBJEXT): {$(VPATH)}subst.h range.$(OBJEXT): $(hdrdir)/ruby.h range.$(OBJEXT): $(hdrdir)/ruby/ruby.h +range.$(OBJEXT): {$(VPATH)}assert.h range.$(OBJEXT): {$(VPATH)}config.h range.$(OBJEXT): {$(VPATH)}defines.h range.$(OBJEXT): {$(VPATH)}encoding.h @@ -2655,6 +2677,7 @@ rational.$(OBJEXT): {$(VPATH)}st.h rational.$(OBJEXT): {$(VPATH)}subst.h re.$(OBJEXT): $(hdrdir)/ruby.h re.$(OBJEXT): $(hdrdir)/ruby/ruby.h +re.$(OBJEXT): {$(VPATH)}assert.h re.$(OBJEXT): {$(VPATH)}config.h re.$(OBJEXT): {$(VPATH)}defines.h re.$(OBJEXT): {$(VPATH)}encindex.h @@ -2674,6 +2697,7 @@ re.$(OBJEXT): {$(VPATH)}st.h re.$(OBJEXT): {$(VPATH)}subst.h re.$(OBJEXT): {$(VPATH)}util.h regcomp.$(OBJEXT): $(hdrdir)/ruby/ruby.h +regcomp.$(OBJEXT): {$(VPATH)}assert.h regcomp.$(OBJEXT): {$(VPATH)}config.h regcomp.$(OBJEXT): {$(VPATH)}defines.h regcomp.$(OBJEXT): {$(VPATH)}intern.h @@ -2687,6 +2711,7 @@ regcomp.$(OBJEXT): {$(VPATH)}regparse.h regcomp.$(OBJEXT): {$(VPATH)}st.h regcomp.$(OBJEXT): {$(VPATH)}subst.h regenc.$(OBJEXT): $(hdrdir)/ruby/ruby.h +regenc.$(OBJEXT): {$(VPATH)}assert.h regenc.$(OBJEXT): {$(VPATH)}config.h regenc.$(OBJEXT): {$(VPATH)}defines.h regenc.$(OBJEXT): {$(VPATH)}intern.h @@ -2699,6 +2724,7 @@ regenc.$(OBJEXT): {$(VPATH)}regint.h regenc.$(OBJEXT): {$(VPATH)}st.h regenc.$(OBJEXT): {$(VPATH)}subst.h regerror.$(OBJEXT): $(hdrdir)/ruby/ruby.h +regerror.$(OBJEXT): {$(VPATH)}assert.h regerror.$(OBJEXT): {$(VPATH)}config.h regerror.$(OBJEXT): {$(VPATH)}defines.h regerror.$(OBJEXT): {$(VPATH)}intern.h @@ -2711,6 +2737,7 @@ regerror.$(OBJEXT): {$(VPATH)}regint.h regerror.$(OBJEXT): {$(VPATH)}st.h regerror.$(OBJEXT): {$(VPATH)}subst.h regexec.$(OBJEXT): $(hdrdir)/ruby/ruby.h +regexec.$(OBJEXT): {$(VPATH)}assert.h regexec.$(OBJEXT): {$(VPATH)}config.h regexec.$(OBJEXT): {$(VPATH)}defines.h regexec.$(OBJEXT): {$(VPATH)}intern.h @@ -2723,6 +2750,7 @@ regexec.$(OBJEXT): {$(VPATH)}regint.h regexec.$(OBJEXT): {$(VPATH)}st.h regexec.$(OBJEXT): {$(VPATH)}subst.h regparse.$(OBJEXT): $(hdrdir)/ruby/ruby.h +regparse.$(OBJEXT): {$(VPATH)}assert.h regparse.$(OBJEXT): {$(VPATH)}config.h regparse.$(OBJEXT): {$(VPATH)}defines.h regparse.$(OBJEXT): {$(VPATH)}intern.h @@ -2736,6 +2764,7 @@ regparse.$(OBJEXT): {$(VPATH)}regparse.h regparse.$(OBJEXT): {$(VPATH)}st.h regparse.$(OBJEXT): {$(VPATH)}subst.h regsyntax.$(OBJEXT): $(hdrdir)/ruby/ruby.h +regsyntax.$(OBJEXT): {$(VPATH)}assert.h regsyntax.$(OBJEXT): {$(VPATH)}config.h regsyntax.$(OBJEXT): {$(VPATH)}defines.h regsyntax.$(OBJEXT): {$(VPATH)}intern.h @@ -2817,6 +2846,7 @@ safe.$(OBJEXT): {$(VPATH)}vm_debug.h safe.$(OBJEXT): {$(VPATH)}vm_opts.h setproctitle.$(OBJEXT): $(hdrdir)/ruby.h setproctitle.$(OBJEXT): $(hdrdir)/ruby/ruby.h +setproctitle.$(OBJEXT): {$(VPATH)}assert.h setproctitle.$(OBJEXT): {$(VPATH)}config.h setproctitle.$(OBJEXT): {$(VPATH)}defines.h setproctitle.$(OBJEXT): {$(VPATH)}intern.h @@ -2858,6 +2888,7 @@ signal.$(OBJEXT): {$(VPATH)}vm_debug.h signal.$(OBJEXT): {$(VPATH)}vm_opts.h sprintf.$(OBJEXT): $(hdrdir)/ruby.h sprintf.$(OBJEXT): $(hdrdir)/ruby/ruby.h +sprintf.$(OBJEXT): {$(VPATH)}assert.h sprintf.$(OBJEXT): {$(VPATH)}config.h sprintf.$(OBJEXT): {$(VPATH)}defines.h sprintf.$(OBJEXT): {$(VPATH)}encoding.h @@ -2880,6 +2911,7 @@ st.$(OBJEXT): $(CCAN_DIR)/list/list.h st.$(OBJEXT): $(CCAN_DIR)/str/str.h st.$(OBJEXT): $(hdrdir)/ruby.h st.$(OBJEXT): $(hdrdir)/ruby/ruby.h +st.$(OBJEXT): {$(VPATH)}assert.h st.$(OBJEXT): {$(VPATH)}config.h st.$(OBJEXT): {$(VPATH)}defines.h st.$(OBJEXT): {$(VPATH)}encoding.h @@ -2894,6 +2926,7 @@ st.$(OBJEXT): {$(VPATH)}st.h st.$(OBJEXT): {$(VPATH)}subst.h strftime.$(OBJEXT): $(hdrdir)/ruby.h strftime.$(OBJEXT): $(hdrdir)/ruby/ruby.h +strftime.$(OBJEXT): {$(VPATH)}assert.h strftime.$(OBJEXT): {$(VPATH)}config.h strftime.$(OBJEXT): {$(VPATH)}defines.h strftime.$(OBJEXT): {$(VPATH)}encoding.h @@ -3035,6 +3068,7 @@ thread.$(OBJEXT): {$(VPATH)}vm_debug.h thread.$(OBJEXT): {$(VPATH)}vm_opts.h time.$(OBJEXT): $(hdrdir)/ruby.h time.$(OBJEXT): $(hdrdir)/ruby/ruby.h +time.$(OBJEXT): {$(VPATH)}assert.h time.$(OBJEXT): {$(VPATH)}config.h time.$(OBJEXT): {$(VPATH)}defines.h time.$(OBJEXT): {$(VPATH)}encoding.h @@ -3051,6 +3085,7 @@ time.$(OBJEXT): {$(VPATH)}time.c time.$(OBJEXT): {$(VPATH)}timev.h transcode.$(OBJEXT): $(hdrdir)/ruby.h transcode.$(OBJEXT): $(hdrdir)/ruby/ruby.h +transcode.$(OBJEXT): {$(VPATH)}assert.h transcode.$(OBJEXT): {$(VPATH)}config.h transcode.$(OBJEXT): {$(VPATH)}defines.h transcode.$(OBJEXT): {$(VPATH)}encoding.h @@ -3084,6 +3119,7 @@ transient_heap.$(OBJEXT): {$(VPATH)}transient_heap.h transient_heap.$(OBJEXT): {$(VPATH)}vm_debug.h util.$(OBJEXT): $(hdrdir)/ruby.h util.$(OBJEXT): $(hdrdir)/ruby/ruby.h +util.$(OBJEXT): {$(VPATH)}assert.h util.$(OBJEXT): {$(VPATH)}config.h util.$(OBJEXT): {$(VPATH)}defines.h util.$(OBJEXT): {$(VPATH)}dtoa.c diff --git a/enc/depend b/enc/depend index bf298ff7857e08..8bb49eb696dbb0 100644 --- a/enc/depend +++ b/enc/depend @@ -223,6 +223,7 @@ enc/emacs_mule.$(OBJEXT): subst.h enc/encdb.$(OBJEXT): $(hdrdir)/ruby.h enc/encdb.$(OBJEXT): $(hdrdir)/ruby/ruby.h enc/encdb.$(OBJEXT): $(top_srcdir)/internal.h +enc/encdb.$(OBJEXT): assert.h enc/encdb.$(OBJEXT): backward.h enc/encdb.$(OBJEXT): config.h enc/encdb.$(OBJEXT): defines.h @@ -274,6 +275,7 @@ enc/gb18030.$(OBJEXT): onigmo.h enc/gb18030.$(OBJEXT): oniguruma.h enc/gb2312.$(OBJEXT): $(hdrdir)/ruby/ruby.h enc/gb2312.$(OBJEXT): $(top_srcdir)/regenc.h +enc/gb2312.$(OBJEXT): assert.h enc/gb2312.$(OBJEXT): backward.h enc/gb2312.$(OBJEXT): config.h enc/gb2312.$(OBJEXT): defines.h @@ -439,6 +441,7 @@ enc/shift_jis.$(OBJEXT): st.h enc/shift_jis.$(OBJEXT): subst.h enc/trans/big5.$(OBJEXT): $(hdrdir)/ruby/ruby.h enc/trans/big5.$(OBJEXT): $(top_srcdir)/transcode_data.h +enc/trans/big5.$(OBJEXT): assert.h enc/trans/big5.$(OBJEXT): backward.h enc/trans/big5.$(OBJEXT): config.h enc/trans/big5.$(OBJEXT): defines.h @@ -449,6 +452,7 @@ enc/trans/big5.$(OBJEXT): st.h enc/trans/big5.$(OBJEXT): subst.h enc/trans/cesu_8.$(OBJEXT): $(hdrdir)/ruby/ruby.h enc/trans/cesu_8.$(OBJEXT): $(top_srcdir)/transcode_data.h +enc/trans/cesu_8.$(OBJEXT): assert.h enc/trans/cesu_8.$(OBJEXT): backward.h enc/trans/cesu_8.$(OBJEXT): config.h enc/trans/cesu_8.$(OBJEXT): defines.h @@ -459,6 +463,7 @@ enc/trans/cesu_8.$(OBJEXT): st.h enc/trans/cesu_8.$(OBJEXT): subst.h enc/trans/chinese.$(OBJEXT): $(hdrdir)/ruby/ruby.h enc/trans/chinese.$(OBJEXT): $(top_srcdir)/transcode_data.h +enc/trans/chinese.$(OBJEXT): assert.h enc/trans/chinese.$(OBJEXT): backward.h enc/trans/chinese.$(OBJEXT): config.h enc/trans/chinese.$(OBJEXT): defines.h @@ -469,6 +474,7 @@ enc/trans/chinese.$(OBJEXT): st.h enc/trans/chinese.$(OBJEXT): subst.h enc/trans/ebcdic.$(OBJEXT): $(hdrdir)/ruby/ruby.h enc/trans/ebcdic.$(OBJEXT): $(top_srcdir)/transcode_data.h +enc/trans/ebcdic.$(OBJEXT): assert.h enc/trans/ebcdic.$(OBJEXT): backward.h enc/trans/ebcdic.$(OBJEXT): config.h enc/trans/ebcdic.$(OBJEXT): defines.h @@ -479,6 +485,7 @@ enc/trans/ebcdic.$(OBJEXT): st.h enc/trans/ebcdic.$(OBJEXT): subst.h enc/trans/emoji.$(OBJEXT): $(hdrdir)/ruby/ruby.h enc/trans/emoji.$(OBJEXT): $(top_srcdir)/transcode_data.h +enc/trans/emoji.$(OBJEXT): assert.h enc/trans/emoji.$(OBJEXT): backward.h enc/trans/emoji.$(OBJEXT): config.h enc/trans/emoji.$(OBJEXT): defines.h @@ -489,6 +496,7 @@ enc/trans/emoji.$(OBJEXT): st.h enc/trans/emoji.$(OBJEXT): subst.h enc/trans/emoji_iso2022_kddi.$(OBJEXT): $(hdrdir)/ruby/ruby.h enc/trans/emoji_iso2022_kddi.$(OBJEXT): $(top_srcdir)/transcode_data.h +enc/trans/emoji_iso2022_kddi.$(OBJEXT): assert.h enc/trans/emoji_iso2022_kddi.$(OBJEXT): backward.h enc/trans/emoji_iso2022_kddi.$(OBJEXT): config.h enc/trans/emoji_iso2022_kddi.$(OBJEXT): defines.h @@ -499,6 +507,7 @@ enc/trans/emoji_iso2022_kddi.$(OBJEXT): st.h enc/trans/emoji_iso2022_kddi.$(OBJEXT): subst.h enc/trans/emoji_sjis_docomo.$(OBJEXT): $(hdrdir)/ruby/ruby.h enc/trans/emoji_sjis_docomo.$(OBJEXT): $(top_srcdir)/transcode_data.h +enc/trans/emoji_sjis_docomo.$(OBJEXT): assert.h enc/trans/emoji_sjis_docomo.$(OBJEXT): backward.h enc/trans/emoji_sjis_docomo.$(OBJEXT): config.h enc/trans/emoji_sjis_docomo.$(OBJEXT): defines.h @@ -509,6 +518,7 @@ enc/trans/emoji_sjis_docomo.$(OBJEXT): st.h enc/trans/emoji_sjis_docomo.$(OBJEXT): subst.h enc/trans/emoji_sjis_kddi.$(OBJEXT): $(hdrdir)/ruby/ruby.h enc/trans/emoji_sjis_kddi.$(OBJEXT): $(top_srcdir)/transcode_data.h +enc/trans/emoji_sjis_kddi.$(OBJEXT): assert.h enc/trans/emoji_sjis_kddi.$(OBJEXT): backward.h enc/trans/emoji_sjis_kddi.$(OBJEXT): config.h enc/trans/emoji_sjis_kddi.$(OBJEXT): defines.h @@ -519,6 +529,7 @@ enc/trans/emoji_sjis_kddi.$(OBJEXT): st.h enc/trans/emoji_sjis_kddi.$(OBJEXT): subst.h enc/trans/emoji_sjis_softbank.$(OBJEXT): $(hdrdir)/ruby/ruby.h enc/trans/emoji_sjis_softbank.$(OBJEXT): $(top_srcdir)/transcode_data.h +enc/trans/emoji_sjis_softbank.$(OBJEXT): assert.h enc/trans/emoji_sjis_softbank.$(OBJEXT): backward.h enc/trans/emoji_sjis_softbank.$(OBJEXT): config.h enc/trans/emoji_sjis_softbank.$(OBJEXT): defines.h @@ -529,6 +540,7 @@ enc/trans/emoji_sjis_softbank.$(OBJEXT): st.h enc/trans/emoji_sjis_softbank.$(OBJEXT): subst.h enc/trans/escape.$(OBJEXT): $(hdrdir)/ruby/ruby.h enc/trans/escape.$(OBJEXT): $(top_srcdir)/transcode_data.h +enc/trans/escape.$(OBJEXT): assert.h enc/trans/escape.$(OBJEXT): backward.h enc/trans/escape.$(OBJEXT): config.h enc/trans/escape.$(OBJEXT): defines.h @@ -539,6 +551,7 @@ enc/trans/escape.$(OBJEXT): st.h enc/trans/escape.$(OBJEXT): subst.h enc/trans/gb18030.$(OBJEXT): $(hdrdir)/ruby/ruby.h enc/trans/gb18030.$(OBJEXT): $(top_srcdir)/transcode_data.h +enc/trans/gb18030.$(OBJEXT): assert.h enc/trans/gb18030.$(OBJEXT): backward.h enc/trans/gb18030.$(OBJEXT): config.h enc/trans/gb18030.$(OBJEXT): defines.h @@ -549,6 +562,7 @@ enc/trans/gb18030.$(OBJEXT): st.h enc/trans/gb18030.$(OBJEXT): subst.h enc/trans/gbk.$(OBJEXT): $(hdrdir)/ruby/ruby.h enc/trans/gbk.$(OBJEXT): $(top_srcdir)/transcode_data.h +enc/trans/gbk.$(OBJEXT): assert.h enc/trans/gbk.$(OBJEXT): backward.h enc/trans/gbk.$(OBJEXT): config.h enc/trans/gbk.$(OBJEXT): defines.h @@ -559,6 +573,7 @@ enc/trans/gbk.$(OBJEXT): st.h enc/trans/gbk.$(OBJEXT): subst.h enc/trans/iso2022.$(OBJEXT): $(hdrdir)/ruby/ruby.h enc/trans/iso2022.$(OBJEXT): $(top_srcdir)/transcode_data.h +enc/trans/iso2022.$(OBJEXT): assert.h enc/trans/iso2022.$(OBJEXT): backward.h enc/trans/iso2022.$(OBJEXT): config.h enc/trans/iso2022.$(OBJEXT): defines.h @@ -569,6 +584,7 @@ enc/trans/iso2022.$(OBJEXT): st.h enc/trans/iso2022.$(OBJEXT): subst.h enc/trans/japanese.$(OBJEXT): $(hdrdir)/ruby/ruby.h enc/trans/japanese.$(OBJEXT): $(top_srcdir)/transcode_data.h +enc/trans/japanese.$(OBJEXT): assert.h enc/trans/japanese.$(OBJEXT): backward.h enc/trans/japanese.$(OBJEXT): config.h enc/trans/japanese.$(OBJEXT): defines.h @@ -579,6 +595,7 @@ enc/trans/japanese.$(OBJEXT): st.h enc/trans/japanese.$(OBJEXT): subst.h enc/trans/japanese_euc.$(OBJEXT): $(hdrdir)/ruby/ruby.h enc/trans/japanese_euc.$(OBJEXT): $(top_srcdir)/transcode_data.h +enc/trans/japanese_euc.$(OBJEXT): assert.h enc/trans/japanese_euc.$(OBJEXT): backward.h enc/trans/japanese_euc.$(OBJEXT): config.h enc/trans/japanese_euc.$(OBJEXT): defines.h @@ -589,6 +606,7 @@ enc/trans/japanese_euc.$(OBJEXT): st.h enc/trans/japanese_euc.$(OBJEXT): subst.h enc/trans/japanese_sjis.$(OBJEXT): $(hdrdir)/ruby/ruby.h enc/trans/japanese_sjis.$(OBJEXT): $(top_srcdir)/transcode_data.h +enc/trans/japanese_sjis.$(OBJEXT): assert.h enc/trans/japanese_sjis.$(OBJEXT): backward.h enc/trans/japanese_sjis.$(OBJEXT): config.h enc/trans/japanese_sjis.$(OBJEXT): defines.h @@ -599,6 +617,7 @@ enc/trans/japanese_sjis.$(OBJEXT): st.h enc/trans/japanese_sjis.$(OBJEXT): subst.h enc/trans/korean.$(OBJEXT): $(hdrdir)/ruby/ruby.h enc/trans/korean.$(OBJEXT): $(top_srcdir)/transcode_data.h +enc/trans/korean.$(OBJEXT): assert.h enc/trans/korean.$(OBJEXT): backward.h enc/trans/korean.$(OBJEXT): config.h enc/trans/korean.$(OBJEXT): defines.h @@ -609,6 +628,7 @@ enc/trans/korean.$(OBJEXT): st.h enc/trans/korean.$(OBJEXT): subst.h enc/trans/newline.$(OBJEXT): $(hdrdir)/ruby/ruby.h enc/trans/newline.$(OBJEXT): $(top_srcdir)/transcode_data.h +enc/trans/newline.$(OBJEXT): assert.h enc/trans/newline.$(OBJEXT): config.h enc/trans/newline.$(OBJEXT): defines.h enc/trans/newline.$(OBJEXT): enc/trans/newline.c @@ -618,6 +638,7 @@ enc/trans/newline.$(OBJEXT): st.h enc/trans/newline.$(OBJEXT): subst.h enc/trans/single_byte.$(OBJEXT): $(hdrdir)/ruby/ruby.h enc/trans/single_byte.$(OBJEXT): $(top_srcdir)/transcode_data.h +enc/trans/single_byte.$(OBJEXT): assert.h enc/trans/single_byte.$(OBJEXT): backward.h enc/trans/single_byte.$(OBJEXT): config.h enc/trans/single_byte.$(OBJEXT): defines.h @@ -630,6 +651,7 @@ enc/trans/transdb.$(OBJEXT): enc/trans/transdb.c enc/trans/transdb.$(OBJEXT): transdb.h enc/trans/utf8_mac.$(OBJEXT): $(hdrdir)/ruby/ruby.h enc/trans/utf8_mac.$(OBJEXT): $(top_srcdir)/transcode_data.h +enc/trans/utf8_mac.$(OBJEXT): assert.h enc/trans/utf8_mac.$(OBJEXT): backward.h enc/trans/utf8_mac.$(OBJEXT): config.h enc/trans/utf8_mac.$(OBJEXT): defines.h @@ -640,6 +662,7 @@ enc/trans/utf8_mac.$(OBJEXT): st.h enc/trans/utf8_mac.$(OBJEXT): subst.h enc/trans/utf_16_32.$(OBJEXT): $(hdrdir)/ruby/ruby.h enc/trans/utf_16_32.$(OBJEXT): $(top_srcdir)/transcode_data.h +enc/trans/utf_16_32.$(OBJEXT): assert.h enc/trans/utf_16_32.$(OBJEXT): backward.h enc/trans/utf_16_32.$(OBJEXT): config.h enc/trans/utf_16_32.$(OBJEXT): defines.h @@ -653,6 +676,7 @@ enc/unicode.$(OBJEXT): $(UNICODE_HDR_DIR)/name2ctype.h enc/unicode.$(OBJEXT): $(hdrdir)/ruby/ruby.h enc/unicode.$(OBJEXT): $(top_srcdir)/regenc.h enc/unicode.$(OBJEXT): $(top_srcdir)/regint.h +enc/unicode.$(OBJEXT): assert.h enc/unicode.$(OBJEXT): config.h enc/unicode.$(OBJEXT): defines.h enc/unicode.$(OBJEXT): enc/unicode.c diff --git a/ext/-test-/arith_seq/extract/depend b/ext/-test-/arith_seq/extract/depend index 5af2e6a4a2bc5d..bb0719941fb7c5 100644 --- a/ext/-test-/arith_seq/extract/depend +++ b/ext/-test-/arith_seq/extract/depend @@ -1,6 +1,7 @@ # AUTOGENERATED DEPENDENCIES START extract.o: $(RUBY_EXTCONF_H) extract.o: $(arch_hdrdir)/ruby/config.h +extract.o: $(hdrdir)/ruby/assert.h extract.o: $(hdrdir)/ruby/backward.h extract.o: $(hdrdir)/ruby/defines.h extract.o: $(hdrdir)/ruby/intern.h diff --git a/ext/-test-/array/resize/depend b/ext/-test-/array/resize/depend index 177c527db28426..a03cc47d513c4a 100644 --- a/ext/-test-/array/resize/depend +++ b/ext/-test-/array/resize/depend @@ -1,6 +1,7 @@ # AUTOGENERATED DEPENDENCIES START resize.o: $(RUBY_EXTCONF_H) resize.o: $(arch_hdrdir)/ruby/config.h +resize.o: $(hdrdir)/ruby/assert.h resize.o: $(hdrdir)/ruby/backward.h resize.o: $(hdrdir)/ruby/defines.h resize.o: $(hdrdir)/ruby/intern.h diff --git a/ext/-test-/bignum/depend b/ext/-test-/bignum/depend index d7720f0acf2379..ee3e612803765e 100644 --- a/ext/-test-/bignum/depend +++ b/ext/-test-/bignum/depend @@ -8,6 +8,7 @@ str2big.o: str2big.c big2str.o: $(RUBY_EXTCONF_H) big2str.o: $(arch_hdrdir)/ruby/config.h big2str.o: $(hdrdir)/ruby.h +big2str.o: $(hdrdir)/ruby/assert.h big2str.o: $(hdrdir)/ruby/backward.h big2str.o: $(hdrdir)/ruby/defines.h big2str.o: $(hdrdir)/ruby/encoding.h @@ -24,6 +25,7 @@ big2str.o: big2str.c bigzero.o: $(RUBY_EXTCONF_H) bigzero.o: $(arch_hdrdir)/ruby/config.h bigzero.o: $(hdrdir)/ruby.h +bigzero.o: $(hdrdir)/ruby/assert.h bigzero.o: $(hdrdir)/ruby/backward.h bigzero.o: $(hdrdir)/ruby/defines.h bigzero.o: $(hdrdir)/ruby/encoding.h @@ -40,6 +42,7 @@ bigzero.o: bigzero.c div.o: $(RUBY_EXTCONF_H) div.o: $(arch_hdrdir)/ruby/config.h div.o: $(hdrdir)/ruby.h +div.o: $(hdrdir)/ruby/assert.h div.o: $(hdrdir)/ruby/backward.h div.o: $(hdrdir)/ruby/defines.h div.o: $(hdrdir)/ruby/encoding.h @@ -56,6 +59,7 @@ div.o: div.c init.o: $(RUBY_EXTCONF_H) init.o: $(arch_hdrdir)/ruby/config.h init.o: $(hdrdir)/ruby.h +init.o: $(hdrdir)/ruby/assert.h init.o: $(hdrdir)/ruby/backward.h init.o: $(hdrdir)/ruby/defines.h init.o: $(hdrdir)/ruby/intern.h @@ -67,6 +71,7 @@ init.o: init.c intpack.o: $(RUBY_EXTCONF_H) intpack.o: $(arch_hdrdir)/ruby/config.h intpack.o: $(hdrdir)/ruby.h +intpack.o: $(hdrdir)/ruby/assert.h intpack.o: $(hdrdir)/ruby/backward.h intpack.o: $(hdrdir)/ruby/defines.h intpack.o: $(hdrdir)/ruby/encoding.h @@ -83,6 +88,7 @@ intpack.o: intpack.c mul.o: $(RUBY_EXTCONF_H) mul.o: $(arch_hdrdir)/ruby/config.h mul.o: $(hdrdir)/ruby.h +mul.o: $(hdrdir)/ruby/assert.h mul.o: $(hdrdir)/ruby/backward.h mul.o: $(hdrdir)/ruby/defines.h mul.o: $(hdrdir)/ruby/encoding.h @@ -99,6 +105,7 @@ mul.o: mul.c str2big.o: $(RUBY_EXTCONF_H) str2big.o: $(arch_hdrdir)/ruby/config.h str2big.o: $(hdrdir)/ruby.h +str2big.o: $(hdrdir)/ruby/assert.h str2big.o: $(hdrdir)/ruby/backward.h str2big.o: $(hdrdir)/ruby/defines.h str2big.o: $(hdrdir)/ruby/encoding.h diff --git a/ext/-test-/bug-3571/depend b/ext/-test-/bug-3571/depend index 6f4ff481982dde..74911f0af46cfb 100644 --- a/ext/-test-/bug-3571/depend +++ b/ext/-test-/bug-3571/depend @@ -2,6 +2,7 @@ bug.o: $(RUBY_EXTCONF_H) bug.o: $(arch_hdrdir)/ruby/config.h bug.o: $(hdrdir)/ruby.h +bug.o: $(hdrdir)/ruby/assert.h bug.o: $(hdrdir)/ruby/backward.h bug.o: $(hdrdir)/ruby/defines.h bug.o: $(hdrdir)/ruby/intern.h diff --git a/ext/-test-/bug-5832/depend b/ext/-test-/bug-5832/depend index 6f4ff481982dde..74911f0af46cfb 100644 --- a/ext/-test-/bug-5832/depend +++ b/ext/-test-/bug-5832/depend @@ -2,6 +2,7 @@ bug.o: $(RUBY_EXTCONF_H) bug.o: $(arch_hdrdir)/ruby/config.h bug.o: $(hdrdir)/ruby.h +bug.o: $(hdrdir)/ruby/assert.h bug.o: $(hdrdir)/ruby/backward.h bug.o: $(hdrdir)/ruby/defines.h bug.o: $(hdrdir)/ruby/intern.h diff --git a/ext/-test-/bug_reporter/depend b/ext/-test-/bug_reporter/depend index bfd4c721f1aaf1..62bac03566b51f 100644 --- a/ext/-test-/bug_reporter/depend +++ b/ext/-test-/bug_reporter/depend @@ -2,6 +2,7 @@ bug_reporter.o: $(RUBY_EXTCONF_H) bug_reporter.o: $(arch_hdrdir)/ruby/config.h bug_reporter.o: $(hdrdir)/ruby.h +bug_reporter.o: $(hdrdir)/ruby/assert.h bug_reporter.o: $(hdrdir)/ruby/backward.h bug_reporter.o: $(hdrdir)/ruby/defines.h bug_reporter.o: $(hdrdir)/ruby/intern.h diff --git a/ext/-test-/class/depend b/ext/-test-/class/depend index 916314592ed0c1..451256cc75c211 100644 --- a/ext/-test-/class/depend +++ b/ext/-test-/class/depend @@ -1,6 +1,7 @@ # AUTOGENERATED DEPENDENCIES START class2name.o: $(RUBY_EXTCONF_H) class2name.o: $(arch_hdrdir)/ruby/config.h +class2name.o: $(hdrdir)/ruby/assert.h class2name.o: $(hdrdir)/ruby/backward.h class2name.o: $(hdrdir)/ruby/defines.h class2name.o: $(hdrdir)/ruby/intern.h @@ -12,6 +13,7 @@ class2name.o: class2name.c init.o: $(RUBY_EXTCONF_H) init.o: $(arch_hdrdir)/ruby/config.h init.o: $(hdrdir)/ruby.h +init.o: $(hdrdir)/ruby/assert.h init.o: $(hdrdir)/ruby/backward.h init.o: $(hdrdir)/ruby/defines.h init.o: $(hdrdir)/ruby/intern.h diff --git a/ext/-test-/debug/depend b/ext/-test-/debug/depend index 3f4fe7509dec1a..662ed875108728 100644 --- a/ext/-test-/debug/depend +++ b/ext/-test-/debug/depend @@ -2,6 +2,7 @@ init.o: $(RUBY_EXTCONF_H) init.o: $(arch_hdrdir)/ruby/config.h init.o: $(hdrdir)/ruby.h +init.o: $(hdrdir)/ruby/assert.h init.o: $(hdrdir)/ruby/backward.h init.o: $(hdrdir)/ruby/defines.h init.o: $(hdrdir)/ruby/intern.h @@ -12,6 +13,7 @@ init.o: $(hdrdir)/ruby/subst.h init.o: init.c inspector.o: $(RUBY_EXTCONF_H) inspector.o: $(arch_hdrdir)/ruby/config.h +inspector.o: $(hdrdir)/ruby/assert.h inspector.o: $(hdrdir)/ruby/backward.h inspector.o: $(hdrdir)/ruby/debug.h inspector.o: $(hdrdir)/ruby/defines.h @@ -23,6 +25,7 @@ inspector.o: $(hdrdir)/ruby/subst.h inspector.o: inspector.c profile_frames.o: $(RUBY_EXTCONF_H) profile_frames.o: $(arch_hdrdir)/ruby/config.h +profile_frames.o: $(hdrdir)/ruby/assert.h profile_frames.o: $(hdrdir)/ruby/backward.h profile_frames.o: $(hdrdir)/ruby/debug.h profile_frames.o: $(hdrdir)/ruby/defines.h diff --git a/ext/-test-/exception/depend b/ext/-test-/exception/depend index cea0f9b2b512b6..d0958de9b83673 100644 --- a/ext/-test-/exception/depend +++ b/ext/-test-/exception/depend @@ -1,6 +1,7 @@ # AUTOGENERATED DEPENDENCIES START dataerror.o: $(RUBY_EXTCONF_H) dataerror.o: $(arch_hdrdir)/ruby/config.h +dataerror.o: $(hdrdir)/ruby/assert.h dataerror.o: $(hdrdir)/ruby/backward.h dataerror.o: $(hdrdir)/ruby/defines.h dataerror.o: $(hdrdir)/ruby/intern.h @@ -12,6 +13,7 @@ dataerror.o: dataerror.c enc_raise.o: $(RUBY_EXTCONF_H) enc_raise.o: $(arch_hdrdir)/ruby/config.h enc_raise.o: $(hdrdir)/ruby.h +enc_raise.o: $(hdrdir)/ruby/assert.h enc_raise.o: $(hdrdir)/ruby/backward.h enc_raise.o: $(hdrdir)/ruby/defines.h enc_raise.o: $(hdrdir)/ruby/encoding.h @@ -26,6 +28,7 @@ enc_raise.o: enc_raise.c ensured.o: $(RUBY_EXTCONF_H) ensured.o: $(arch_hdrdir)/ruby/config.h ensured.o: $(hdrdir)/ruby.h +ensured.o: $(hdrdir)/ruby/assert.h ensured.o: $(hdrdir)/ruby/backward.h ensured.o: $(hdrdir)/ruby/defines.h ensured.o: $(hdrdir)/ruby/intern.h @@ -37,6 +40,7 @@ ensured.o: ensured.c init.o: $(RUBY_EXTCONF_H) init.o: $(arch_hdrdir)/ruby/config.h init.o: $(hdrdir)/ruby.h +init.o: $(hdrdir)/ruby/assert.h init.o: $(hdrdir)/ruby/backward.h init.o: $(hdrdir)/ruby/defines.h init.o: $(hdrdir)/ruby/intern.h diff --git a/ext/-test-/fatal/depend b/ext/-test-/fatal/depend index af8d2156e2796a..c74360fdf99e0a 100644 --- a/ext/-test-/fatal/depend +++ b/ext/-test-/fatal/depend @@ -2,6 +2,7 @@ rb_fatal.o: $(RUBY_EXTCONF_H) rb_fatal.o: $(arch_hdrdir)/ruby/config.h rb_fatal.o: $(hdrdir)/ruby.h +rb_fatal.o: $(hdrdir)/ruby/assert.h rb_fatal.o: $(hdrdir)/ruby/backward.h rb_fatal.o: $(hdrdir)/ruby/defines.h rb_fatal.o: $(hdrdir)/ruby/intern.h diff --git a/ext/-test-/file/depend b/ext/-test-/file/depend index c92ad1d84e75bc..afdf116a9d5edf 100644 --- a/ext/-test-/file/depend +++ b/ext/-test-/file/depend @@ -1,6 +1,7 @@ # AUTOGENERATED DEPENDENCIES START fs.o: $(RUBY_EXTCONF_H) fs.o: $(arch_hdrdir)/ruby/config.h +fs.o: $(hdrdir)/ruby/assert.h fs.o: $(hdrdir)/ruby/backward.h fs.o: $(hdrdir)/ruby/defines.h fs.o: $(hdrdir)/ruby/encoding.h @@ -16,6 +17,7 @@ fs.o: fs.c init.o: $(RUBY_EXTCONF_H) init.o: $(arch_hdrdir)/ruby/config.h init.o: $(hdrdir)/ruby.h +init.o: $(hdrdir)/ruby/assert.h init.o: $(hdrdir)/ruby/backward.h init.o: $(hdrdir)/ruby/defines.h init.o: $(hdrdir)/ruby/intern.h @@ -26,6 +28,7 @@ init.o: $(hdrdir)/ruby/subst.h init.o: init.c stat.o: $(RUBY_EXTCONF_H) stat.o: $(arch_hdrdir)/ruby/config.h +stat.o: $(hdrdir)/ruby/assert.h stat.o: $(hdrdir)/ruby/backward.h stat.o: $(hdrdir)/ruby/defines.h stat.o: $(hdrdir)/ruby/encoding.h diff --git a/ext/-test-/funcall/depend b/ext/-test-/funcall/depend index 6a7d16a15d4721..a5f43a8046b33e 100644 --- a/ext/-test-/funcall/depend +++ b/ext/-test-/funcall/depend @@ -2,6 +2,7 @@ funcall.o: $(RUBY_EXTCONF_H) funcall.o: $(arch_hdrdir)/ruby/config.h funcall.o: $(hdrdir)/ruby.h +funcall.o: $(hdrdir)/ruby/assert.h funcall.o: $(hdrdir)/ruby/backward.h funcall.o: $(hdrdir)/ruby/defines.h funcall.o: $(hdrdir)/ruby/intern.h diff --git a/ext/-test-/gvl/call_without_gvl/depend b/ext/-test-/gvl/call_without_gvl/depend index 1f7443898d0593..3d4253b97761f9 100644 --- a/ext/-test-/gvl/call_without_gvl/depend +++ b/ext/-test-/gvl/call_without_gvl/depend @@ -1,6 +1,7 @@ # AUTOGENERATED DEPENDENCIES START call_without_gvl.o: $(RUBY_EXTCONF_H) call_without_gvl.o: $(arch_hdrdir)/ruby/config.h +call_without_gvl.o: $(hdrdir)/ruby/assert.h call_without_gvl.o: $(hdrdir)/ruby/backward.h call_without_gvl.o: $(hdrdir)/ruby/defines.h call_without_gvl.o: $(hdrdir)/ruby/intern.h diff --git a/ext/-test-/hash/depend b/ext/-test-/hash/depend index dd183c9f44c00d..5e2b8056c82101 100644 --- a/ext/-test-/hash/depend +++ b/ext/-test-/hash/depend @@ -2,6 +2,7 @@ delete.o: $(RUBY_EXTCONF_H) delete.o: $(arch_hdrdir)/ruby/config.h delete.o: $(hdrdir)/ruby.h +delete.o: $(hdrdir)/ruby/assert.h delete.o: $(hdrdir)/ruby/backward.h delete.o: $(hdrdir)/ruby/defines.h delete.o: $(hdrdir)/ruby/intern.h @@ -13,6 +14,7 @@ delete.o: delete.c init.o: $(RUBY_EXTCONF_H) init.o: $(arch_hdrdir)/ruby/config.h init.o: $(hdrdir)/ruby.h +init.o: $(hdrdir)/ruby/assert.h init.o: $(hdrdir)/ruby/backward.h init.o: $(hdrdir)/ruby/defines.h init.o: $(hdrdir)/ruby/intern.h diff --git a/ext/-test-/integer/depend b/ext/-test-/integer/depend index 6e0a60cf0edfbd..abd612ada82b6d 100644 --- a/ext/-test-/integer/depend +++ b/ext/-test-/integer/depend @@ -2,6 +2,7 @@ core_ext.o: $(RUBY_EXTCONF_H) core_ext.o: $(arch_hdrdir)/ruby/config.h core_ext.o: $(hdrdir)/ruby.h +core_ext.o: $(hdrdir)/ruby/assert.h core_ext.o: $(hdrdir)/ruby/backward.h core_ext.o: $(hdrdir)/ruby/defines.h core_ext.o: $(hdrdir)/ruby/encoding.h @@ -18,6 +19,7 @@ core_ext.o: core_ext.c init.o: $(RUBY_EXTCONF_H) init.o: $(arch_hdrdir)/ruby/config.h init.o: $(hdrdir)/ruby.h +init.o: $(hdrdir)/ruby/assert.h init.o: $(hdrdir)/ruby/backward.h init.o: $(hdrdir)/ruby/defines.h init.o: $(hdrdir)/ruby/intern.h @@ -29,6 +31,7 @@ init.o: init.c my_integer.o: $(RUBY_EXTCONF_H) my_integer.o: $(arch_hdrdir)/ruby/config.h my_integer.o: $(hdrdir)/ruby.h +my_integer.o: $(hdrdir)/ruby/assert.h my_integer.o: $(hdrdir)/ruby/backward.h my_integer.o: $(hdrdir)/ruby/defines.h my_integer.o: $(hdrdir)/ruby/intern.h diff --git a/ext/-test-/iseq_load/depend b/ext/-test-/iseq_load/depend index 3d2ef945ff396a..ac549546ecef56 100644 --- a/ext/-test-/iseq_load/depend +++ b/ext/-test-/iseq_load/depend @@ -2,6 +2,7 @@ iseq_load.o: $(RUBY_EXTCONF_H) iseq_load.o: $(arch_hdrdir)/ruby/config.h iseq_load.o: $(hdrdir)/ruby.h +iseq_load.o: $(hdrdir)/ruby/assert.h iseq_load.o: $(hdrdir)/ruby/backward.h iseq_load.o: $(hdrdir)/ruby/defines.h iseq_load.o: $(hdrdir)/ruby/intern.h diff --git a/ext/-test-/iter/depend b/ext/-test-/iter/depend index 9e960e2426e6d9..5e754950c1098f 100644 --- a/ext/-test-/iter/depend +++ b/ext/-test-/iter/depend @@ -2,6 +2,7 @@ break.o: $(RUBY_EXTCONF_H) break.o: $(arch_hdrdir)/ruby/config.h break.o: $(hdrdir)/ruby.h +break.o: $(hdrdir)/ruby/assert.h break.o: $(hdrdir)/ruby/backward.h break.o: $(hdrdir)/ruby/defines.h break.o: $(hdrdir)/ruby/intern.h @@ -13,6 +14,7 @@ break.o: break.c init.o: $(RUBY_EXTCONF_H) init.o: $(arch_hdrdir)/ruby/config.h init.o: $(hdrdir)/ruby.h +init.o: $(hdrdir)/ruby/assert.h init.o: $(hdrdir)/ruby/backward.h init.o: $(hdrdir)/ruby/defines.h init.o: $(hdrdir)/ruby/intern.h @@ -24,6 +26,7 @@ init.o: init.c yield.o: $(RUBY_EXTCONF_H) yield.o: $(arch_hdrdir)/ruby/config.h yield.o: $(hdrdir)/ruby.h +yield.o: $(hdrdir)/ruby/assert.h yield.o: $(hdrdir)/ruby/backward.h yield.o: $(hdrdir)/ruby/defines.h yield.o: $(hdrdir)/ruby/intern.h diff --git a/ext/-test-/load/protect/depend b/ext/-test-/load/protect/depend index a69bf948ce9f6f..b62393f1cb0141 100644 --- a/ext/-test-/load/protect/depend +++ b/ext/-test-/load/protect/depend @@ -2,6 +2,7 @@ protect.o: $(RUBY_EXTCONF_H) protect.o: $(arch_hdrdir)/ruby/config.h protect.o: $(hdrdir)/ruby.h +protect.o: $(hdrdir)/ruby/assert.h protect.o: $(hdrdir)/ruby/backward.h protect.o: $(hdrdir)/ruby/defines.h protect.o: $(hdrdir)/ruby/intern.h diff --git a/ext/-test-/marshal/compat/depend b/ext/-test-/marshal/compat/depend index e0d13b18c9bc57..f15950696092c7 100644 --- a/ext/-test-/marshal/compat/depend +++ b/ext/-test-/marshal/compat/depend @@ -2,6 +2,7 @@ usrcompat.o: $(RUBY_EXTCONF_H) usrcompat.o: $(arch_hdrdir)/ruby/config.h usrcompat.o: $(hdrdir)/ruby.h +usrcompat.o: $(hdrdir)/ruby/assert.h usrcompat.o: $(hdrdir)/ruby/backward.h usrcompat.o: $(hdrdir)/ruby/defines.h usrcompat.o: $(hdrdir)/ruby/intern.h diff --git a/ext/-test-/marshal/internal_ivar/depend b/ext/-test-/marshal/internal_ivar/depend index 1ca625528cef23..f280347c0130a1 100644 --- a/ext/-test-/marshal/internal_ivar/depend +++ b/ext/-test-/marshal/internal_ivar/depend @@ -2,6 +2,7 @@ internal_ivar.o: $(RUBY_EXTCONF_H) internal_ivar.o: $(arch_hdrdir)/ruby/config.h internal_ivar.o: $(hdrdir)/ruby.h +internal_ivar.o: $(hdrdir)/ruby/assert.h internal_ivar.o: $(hdrdir)/ruby/backward.h internal_ivar.o: $(hdrdir)/ruby/defines.h internal_ivar.o: $(hdrdir)/ruby/intern.h diff --git a/ext/-test-/marshal/usr/depend b/ext/-test-/marshal/usr/depend index 13602229800439..21c0c2d744c125 100644 --- a/ext/-test-/marshal/usr/depend +++ b/ext/-test-/marshal/usr/depend @@ -2,6 +2,7 @@ usrmarshal.o: $(RUBY_EXTCONF_H) usrmarshal.o: $(arch_hdrdir)/ruby/config.h usrmarshal.o: $(hdrdir)/ruby.h +usrmarshal.o: $(hdrdir)/ruby/assert.h usrmarshal.o: $(hdrdir)/ruby/backward.h usrmarshal.o: $(hdrdir)/ruby/defines.h usrmarshal.o: $(hdrdir)/ruby/intern.h diff --git a/ext/-test-/memory_status/depend b/ext/-test-/memory_status/depend index 8254b08f244dcd..657ef59c356fee 100644 --- a/ext/-test-/memory_status/depend +++ b/ext/-test-/memory_status/depend @@ -2,6 +2,7 @@ memory_status.o: $(RUBY_EXTCONF_H) memory_status.o: $(arch_hdrdir)/ruby/config.h memory_status.o: $(hdrdir)/ruby.h +memory_status.o: $(hdrdir)/ruby/assert.h memory_status.o: $(hdrdir)/ruby/backward.h memory_status.o: $(hdrdir)/ruby/defines.h memory_status.o: $(hdrdir)/ruby/intern.h diff --git a/ext/-test-/method/depend b/ext/-test-/method/depend index 5bc370ecb84442..028d97e1a98e1b 100644 --- a/ext/-test-/method/depend +++ b/ext/-test-/method/depend @@ -2,6 +2,7 @@ arity.o: $(RUBY_EXTCONF_H) arity.o: $(arch_hdrdir)/ruby/config.h arity.o: $(hdrdir)/ruby.h +arity.o: $(hdrdir)/ruby/assert.h arity.o: $(hdrdir)/ruby/backward.h arity.o: $(hdrdir)/ruby/defines.h arity.o: $(hdrdir)/ruby/intern.h @@ -13,6 +14,7 @@ arity.o: arity.c init.o: $(RUBY_EXTCONF_H) init.o: $(arch_hdrdir)/ruby/config.h init.o: $(hdrdir)/ruby.h +init.o: $(hdrdir)/ruby/assert.h init.o: $(hdrdir)/ruby/backward.h init.o: $(hdrdir)/ruby/defines.h init.o: $(hdrdir)/ruby/intern.h diff --git a/ext/-test-/notimplement/depend b/ext/-test-/notimplement/depend index 6f4ff481982dde..74911f0af46cfb 100644 --- a/ext/-test-/notimplement/depend +++ b/ext/-test-/notimplement/depend @@ -2,6 +2,7 @@ bug.o: $(RUBY_EXTCONF_H) bug.o: $(arch_hdrdir)/ruby/config.h bug.o: $(hdrdir)/ruby.h +bug.o: $(hdrdir)/ruby/assert.h bug.o: $(hdrdir)/ruby/backward.h bug.o: $(hdrdir)/ruby/defines.h bug.o: $(hdrdir)/ruby/intern.h diff --git a/ext/-test-/num2int/depend b/ext/-test-/num2int/depend index bb6c9b3c7702ce..76b69de8519753 100644 --- a/ext/-test-/num2int/depend +++ b/ext/-test-/num2int/depend @@ -2,6 +2,7 @@ num2int.o: $(RUBY_EXTCONF_H) num2int.o: $(arch_hdrdir)/ruby/config.h num2int.o: $(hdrdir)/ruby.h +num2int.o: $(hdrdir)/ruby/assert.h num2int.o: $(hdrdir)/ruby/backward.h num2int.o: $(hdrdir)/ruby/defines.h num2int.o: $(hdrdir)/ruby/intern.h diff --git a/ext/-test-/path_to_class/depend b/ext/-test-/path_to_class/depend index 55dce316ec8a54..9a7f7d01766c31 100644 --- a/ext/-test-/path_to_class/depend +++ b/ext/-test-/path_to_class/depend @@ -2,6 +2,7 @@ path_to_class.o: $(RUBY_EXTCONF_H) path_to_class.o: $(arch_hdrdir)/ruby/config.h path_to_class.o: $(hdrdir)/ruby.h +path_to_class.o: $(hdrdir)/ruby/assert.h path_to_class.o: $(hdrdir)/ruby/backward.h path_to_class.o: $(hdrdir)/ruby/defines.h path_to_class.o: $(hdrdir)/ruby/intern.h diff --git a/ext/-test-/popen_deadlock/depend b/ext/-test-/popen_deadlock/depend index 12b31f247c85dd..4c3f3853fdd984 100644 --- a/ext/-test-/popen_deadlock/depend +++ b/ext/-test-/popen_deadlock/depend @@ -1,6 +1,7 @@ # AUTOGENERATED DEPENDENCIES START infinite_loop_dlsym.o: $(RUBY_EXTCONF_H) infinite_loop_dlsym.o: $(arch_hdrdir)/ruby/config.h +infinite_loop_dlsym.o: $(hdrdir)/ruby/assert.h infinite_loop_dlsym.o: $(hdrdir)/ruby/backward.h infinite_loop_dlsym.o: $(hdrdir)/ruby/defines.h infinite_loop_dlsym.o: $(hdrdir)/ruby/intern.h diff --git a/ext/-test-/proc/depend b/ext/-test-/proc/depend index db48627643db56..5946e4ca0d9912 100644 --- a/ext/-test-/proc/depend +++ b/ext/-test-/proc/depend @@ -2,6 +2,7 @@ init.o: $(RUBY_EXTCONF_H) init.o: $(arch_hdrdir)/ruby/config.h init.o: $(hdrdir)/ruby.h +init.o: $(hdrdir)/ruby/assert.h init.o: $(hdrdir)/ruby/backward.h init.o: $(hdrdir)/ruby/defines.h init.o: $(hdrdir)/ruby/intern.h @@ -13,6 +14,7 @@ init.o: init.c receiver.o: $(RUBY_EXTCONF_H) receiver.o: $(arch_hdrdir)/ruby/config.h receiver.o: $(hdrdir)/ruby.h +receiver.o: $(hdrdir)/ruby/assert.h receiver.o: $(hdrdir)/ruby/backward.h receiver.o: $(hdrdir)/ruby/defines.h receiver.o: $(hdrdir)/ruby/intern.h @@ -24,6 +26,7 @@ receiver.o: receiver.c super.o: $(RUBY_EXTCONF_H) super.o: $(arch_hdrdir)/ruby/config.h super.o: $(hdrdir)/ruby.h +super.o: $(hdrdir)/ruby/assert.h super.o: $(hdrdir)/ruby/backward.h super.o: $(hdrdir)/ruby/defines.h super.o: $(hdrdir)/ruby/intern.h diff --git a/ext/-test-/rational/depend b/ext/-test-/rational/depend index 3913376523154f..4ec2e25e18eccc 100644 --- a/ext/-test-/rational/depend +++ b/ext/-test-/rational/depend @@ -6,6 +6,7 @@ rat.o: rat.c $(top_srcdir)/internal.h rat.o: $(RUBY_EXTCONF_H) rat.o: $(arch_hdrdir)/ruby/config.h rat.o: $(hdrdir)/ruby.h +rat.o: $(hdrdir)/ruby/assert.h rat.o: $(hdrdir)/ruby/backward.h rat.o: $(hdrdir)/ruby/defines.h rat.o: $(hdrdir)/ruby/encoding.h diff --git a/ext/-test-/recursion/depend b/ext/-test-/recursion/depend index 30ba450d009728..bf8005724aa931 100644 --- a/ext/-test-/recursion/depend +++ b/ext/-test-/recursion/depend @@ -2,6 +2,7 @@ recursion.o: $(RUBY_EXTCONF_H) recursion.o: $(arch_hdrdir)/ruby/config.h recursion.o: $(hdrdir)/ruby.h +recursion.o: $(hdrdir)/ruby/assert.h recursion.o: $(hdrdir)/ruby/backward.h recursion.o: $(hdrdir)/ruby/defines.h recursion.o: $(hdrdir)/ruby/intern.h diff --git a/ext/-test-/regexp/depend b/ext/-test-/regexp/depend index bbea37e53be777..7c88e1235cefcc 100644 --- a/ext/-test-/regexp/depend +++ b/ext/-test-/regexp/depend @@ -2,6 +2,7 @@ init.o: $(RUBY_EXTCONF_H) init.o: $(arch_hdrdir)/ruby/config.h init.o: $(hdrdir)/ruby.h +init.o: $(hdrdir)/ruby/assert.h init.o: $(hdrdir)/ruby/backward.h init.o: $(hdrdir)/ruby/defines.h init.o: $(hdrdir)/ruby/intern.h @@ -13,6 +14,7 @@ init.o: init.c parse_depth_limit.o: $(RUBY_EXTCONF_H) parse_depth_limit.o: $(arch_hdrdir)/ruby/config.h parse_depth_limit.o: $(hdrdir)/ruby.h +parse_depth_limit.o: $(hdrdir)/ruby/assert.h parse_depth_limit.o: $(hdrdir)/ruby/backward.h parse_depth_limit.o: $(hdrdir)/ruby/defines.h parse_depth_limit.o: $(hdrdir)/ruby/intern.h diff --git a/ext/-test-/scan_args/depend b/ext/-test-/scan_args/depend index 6e6bd23927a822..c230961ae32175 100644 --- a/ext/-test-/scan_args/depend +++ b/ext/-test-/scan_args/depend @@ -2,6 +2,7 @@ scan_args.o: $(RUBY_EXTCONF_H) scan_args.o: $(arch_hdrdir)/ruby/config.h scan_args.o: $(hdrdir)/ruby.h +scan_args.o: $(hdrdir)/ruby/assert.h scan_args.o: $(hdrdir)/ruby/backward.h scan_args.o: $(hdrdir)/ruby/defines.h scan_args.o: $(hdrdir)/ruby/intern.h diff --git a/ext/-test-/st/foreach/depend b/ext/-test-/st/foreach/depend index f649c3b2a6efe8..42d3909f495dfc 100644 --- a/ext/-test-/st/foreach/depend +++ b/ext/-test-/st/foreach/depend @@ -2,6 +2,7 @@ foreach.o: $(RUBY_EXTCONF_H) foreach.o: $(arch_hdrdir)/ruby/config.h foreach.o: $(hdrdir)/ruby.h +foreach.o: $(hdrdir)/ruby/assert.h foreach.o: $(hdrdir)/ruby/backward.h foreach.o: $(hdrdir)/ruby/defines.h foreach.o: $(hdrdir)/ruby/intern.h diff --git a/ext/-test-/st/numhash/depend b/ext/-test-/st/numhash/depend index 5eb6faa45c5d81..98dcef881b106f 100644 --- a/ext/-test-/st/numhash/depend +++ b/ext/-test-/st/numhash/depend @@ -2,6 +2,7 @@ numhash.o: $(RUBY_EXTCONF_H) numhash.o: $(arch_hdrdir)/ruby/config.h numhash.o: $(hdrdir)/ruby.h +numhash.o: $(hdrdir)/ruby/assert.h numhash.o: $(hdrdir)/ruby/backward.h numhash.o: $(hdrdir)/ruby/defines.h numhash.o: $(hdrdir)/ruby/intern.h diff --git a/ext/-test-/st/update/depend b/ext/-test-/st/update/depend index b5abfc1173c68a..241e6f9e6da127 100644 --- a/ext/-test-/st/update/depend +++ b/ext/-test-/st/update/depend @@ -2,6 +2,7 @@ update.o: $(RUBY_EXTCONF_H) update.o: $(arch_hdrdir)/ruby/config.h update.o: $(hdrdir)/ruby.h +update.o: $(hdrdir)/ruby/assert.h update.o: $(hdrdir)/ruby/backward.h update.o: $(hdrdir)/ruby/defines.h update.o: $(hdrdir)/ruby/intern.h diff --git a/ext/-test-/string/depend b/ext/-test-/string/depend index eb22abe83c9e8d..337ec60b43cc4a 100644 --- a/ext/-test-/string/depend +++ b/ext/-test-/string/depend @@ -2,6 +2,7 @@ capacity.o: $(RUBY_EXTCONF_H) capacity.o: $(arch_hdrdir)/ruby/config.h capacity.o: $(hdrdir)/ruby.h +capacity.o: $(hdrdir)/ruby/assert.h capacity.o: $(hdrdir)/ruby/backward.h capacity.o: $(hdrdir)/ruby/defines.h capacity.o: $(hdrdir)/ruby/encoding.h @@ -17,6 +18,7 @@ capacity.o: $(top_srcdir)/internal.h capacity.o: capacity.c coderange.o: $(RUBY_EXTCONF_H) coderange.o: $(arch_hdrdir)/ruby/config.h +coderange.o: $(hdrdir)/ruby/assert.h coderange.o: $(hdrdir)/ruby/backward.h coderange.o: $(hdrdir)/ruby/defines.h coderange.o: $(hdrdir)/ruby/encoding.h @@ -31,6 +33,7 @@ coderange.o: coderange.c cstr.o: $(RUBY_EXTCONF_H) cstr.o: $(arch_hdrdir)/ruby/config.h cstr.o: $(hdrdir)/ruby.h +cstr.o: $(hdrdir)/ruby/assert.h cstr.o: $(hdrdir)/ruby/backward.h cstr.o: $(hdrdir)/ruby/defines.h cstr.o: $(hdrdir)/ruby/encoding.h @@ -47,6 +50,7 @@ cstr.o: cstr.c ellipsize.o: $(RUBY_EXTCONF_H) ellipsize.o: $(arch_hdrdir)/ruby/config.h ellipsize.o: $(hdrdir)/ruby.h +ellipsize.o: $(hdrdir)/ruby/assert.h ellipsize.o: $(hdrdir)/ruby/backward.h ellipsize.o: $(hdrdir)/ruby/defines.h ellipsize.o: $(hdrdir)/ruby/intern.h @@ -58,6 +62,7 @@ ellipsize.o: ellipsize.c enc_associate.o: $(RUBY_EXTCONF_H) enc_associate.o: $(arch_hdrdir)/ruby/config.h enc_associate.o: $(hdrdir)/ruby.h +enc_associate.o: $(hdrdir)/ruby/assert.h enc_associate.o: $(hdrdir)/ruby/backward.h enc_associate.o: $(hdrdir)/ruby/defines.h enc_associate.o: $(hdrdir)/ruby/encoding.h @@ -71,6 +76,7 @@ enc_associate.o: $(hdrdir)/ruby/subst.h enc_associate.o: enc_associate.c enc_str_buf_cat.o: $(RUBY_EXTCONF_H) enc_str_buf_cat.o: $(arch_hdrdir)/ruby/config.h +enc_str_buf_cat.o: $(hdrdir)/ruby/assert.h enc_str_buf_cat.o: $(hdrdir)/ruby/backward.h enc_str_buf_cat.o: $(hdrdir)/ruby/defines.h enc_str_buf_cat.o: $(hdrdir)/ruby/encoding.h @@ -85,6 +91,7 @@ enc_str_buf_cat.o: enc_str_buf_cat.c fstring.o: $(RUBY_EXTCONF_H) fstring.o: $(arch_hdrdir)/ruby/config.h fstring.o: $(hdrdir)/ruby.h +fstring.o: $(hdrdir)/ruby/assert.h fstring.o: $(hdrdir)/ruby/backward.h fstring.o: $(hdrdir)/ruby/defines.h fstring.o: $(hdrdir)/ruby/intern.h @@ -96,6 +103,7 @@ fstring.o: fstring.c init.o: $(RUBY_EXTCONF_H) init.o: $(arch_hdrdir)/ruby/config.h init.o: $(hdrdir)/ruby.h +init.o: $(hdrdir)/ruby/assert.h init.o: $(hdrdir)/ruby/backward.h init.o: $(hdrdir)/ruby/defines.h init.o: $(hdrdir)/ruby/intern.h @@ -107,6 +115,7 @@ init.o: init.c modify.o: $(RUBY_EXTCONF_H) modify.o: $(arch_hdrdir)/ruby/config.h modify.o: $(hdrdir)/ruby.h +modify.o: $(hdrdir)/ruby/assert.h modify.o: $(hdrdir)/ruby/backward.h modify.o: $(hdrdir)/ruby/defines.h modify.o: $(hdrdir)/ruby/intern.h @@ -118,6 +127,7 @@ modify.o: modify.c new.o: $(RUBY_EXTCONF_H) new.o: $(arch_hdrdir)/ruby/config.h new.o: $(hdrdir)/ruby.h +new.o: $(hdrdir)/ruby/assert.h new.o: $(hdrdir)/ruby/backward.h new.o: $(hdrdir)/ruby/defines.h new.o: $(hdrdir)/ruby/encoding.h @@ -134,6 +144,7 @@ new.o: new.c nofree.o: $(RUBY_EXTCONF_H) nofree.o: $(arch_hdrdir)/ruby/config.h nofree.o: $(hdrdir)/ruby.h +nofree.o: $(hdrdir)/ruby/assert.h nofree.o: $(hdrdir)/ruby/backward.h nofree.o: $(hdrdir)/ruby/defines.h nofree.o: $(hdrdir)/ruby/intern.h @@ -145,6 +156,7 @@ nofree.o: nofree.c normalize.o: $(RUBY_EXTCONF_H) normalize.o: $(arch_hdrdir)/ruby/config.h normalize.o: $(hdrdir)/ruby.h +normalize.o: $(hdrdir)/ruby/assert.h normalize.o: $(hdrdir)/ruby/backward.h normalize.o: $(hdrdir)/ruby/defines.h normalize.o: $(hdrdir)/ruby/encoding.h @@ -161,6 +173,7 @@ normalize.o: normalize.c qsort.o: $(RUBY_EXTCONF_H) qsort.o: $(arch_hdrdir)/ruby/config.h qsort.o: $(hdrdir)/ruby.h +qsort.o: $(hdrdir)/ruby/assert.h qsort.o: $(hdrdir)/ruby/backward.h qsort.o: $(hdrdir)/ruby/defines.h qsort.o: $(hdrdir)/ruby/encoding.h @@ -176,6 +189,7 @@ qsort.o: qsort.c rb_str_dup.o: $(RUBY_EXTCONF_H) rb_str_dup.o: $(arch_hdrdir)/ruby/config.h rb_str_dup.o: $(hdrdir)/ruby.h +rb_str_dup.o: $(hdrdir)/ruby/assert.h rb_str_dup.o: $(hdrdir)/ruby/backward.h rb_str_dup.o: $(hdrdir)/ruby/defines.h rb_str_dup.o: $(hdrdir)/ruby/intern.h @@ -187,6 +201,7 @@ rb_str_dup.o: rb_str_dup.c set_len.o: $(RUBY_EXTCONF_H) set_len.o: $(arch_hdrdir)/ruby/config.h set_len.o: $(hdrdir)/ruby.h +set_len.o: $(hdrdir)/ruby/assert.h set_len.o: $(hdrdir)/ruby/backward.h set_len.o: $(hdrdir)/ruby/defines.h set_len.o: $(hdrdir)/ruby/intern.h diff --git a/ext/-test-/struct/depend b/ext/-test-/struct/depend index ddf00c32aa1118..552daf0ac58d53 100644 --- a/ext/-test-/struct/depend +++ b/ext/-test-/struct/depend @@ -2,6 +2,7 @@ duplicate.o: $(RUBY_EXTCONF_H) duplicate.o: $(arch_hdrdir)/ruby/config.h duplicate.o: $(hdrdir)/ruby.h +duplicate.o: $(hdrdir)/ruby/assert.h duplicate.o: $(hdrdir)/ruby/backward.h duplicate.o: $(hdrdir)/ruby/defines.h duplicate.o: $(hdrdir)/ruby/intern.h @@ -13,6 +14,7 @@ duplicate.o: duplicate.c init.o: $(RUBY_EXTCONF_H) init.o: $(arch_hdrdir)/ruby/config.h init.o: $(hdrdir)/ruby.h +init.o: $(hdrdir)/ruby/assert.h init.o: $(hdrdir)/ruby/backward.h init.o: $(hdrdir)/ruby/defines.h init.o: $(hdrdir)/ruby/intern.h @@ -24,6 +26,7 @@ init.o: init.c len.o: $(RUBY_EXTCONF_H) len.o: $(arch_hdrdir)/ruby/config.h len.o: $(hdrdir)/ruby.h +len.o: $(hdrdir)/ruby/assert.h len.o: $(hdrdir)/ruby/backward.h len.o: $(hdrdir)/ruby/defines.h len.o: $(hdrdir)/ruby/intern.h @@ -35,6 +38,7 @@ len.o: len.c member.o: $(RUBY_EXTCONF_H) member.o: $(arch_hdrdir)/ruby/config.h member.o: $(hdrdir)/ruby.h +member.o: $(hdrdir)/ruby/assert.h member.o: $(hdrdir)/ruby/backward.h member.o: $(hdrdir)/ruby/defines.h member.o: $(hdrdir)/ruby/intern.h diff --git a/ext/-test-/symbol/depend b/ext/-test-/symbol/depend index e7bba43501b7d3..bccb4afc1595e9 100644 --- a/ext/-test-/symbol/depend +++ b/ext/-test-/symbol/depend @@ -2,6 +2,7 @@ init.o: $(RUBY_EXTCONF_H) init.o: $(arch_hdrdir)/ruby/config.h init.o: $(hdrdir)/ruby.h +init.o: $(hdrdir)/ruby/assert.h init.o: $(hdrdir)/ruby/backward.h init.o: $(hdrdir)/ruby/defines.h init.o: $(hdrdir)/ruby/intern.h @@ -13,6 +14,7 @@ init.o: init.c type.o: $(RUBY_EXTCONF_H) type.o: $(arch_hdrdir)/ruby/config.h type.o: $(hdrdir)/ruby.h +type.o: $(hdrdir)/ruby/assert.h type.o: $(hdrdir)/ruby/backward.h type.o: $(hdrdir)/ruby/defines.h type.o: $(hdrdir)/ruby/intern.h diff --git a/ext/-test-/thread_fd_close/depend b/ext/-test-/thread_fd_close/depend index 7bc04c3db38b0c..94b03dfd6e4fe1 100644 --- a/ext/-test-/thread_fd_close/depend +++ b/ext/-test-/thread_fd_close/depend @@ -1,6 +1,7 @@ # AUTOGENERATED DEPENDENCIES START thread_fd_close.o: $(RUBY_EXTCONF_H) thread_fd_close.o: $(arch_hdrdir)/ruby/config.h +thread_fd_close.o: $(hdrdir)/ruby/assert.h thread_fd_close.o: $(hdrdir)/ruby/backward.h thread_fd_close.o: $(hdrdir)/ruby/defines.h thread_fd_close.o: $(hdrdir)/ruby/encoding.h diff --git a/ext/-test-/time/depend b/ext/-test-/time/depend index 3197693a88ca6e..2f4b8d1f134a3b 100644 --- a/ext/-test-/time/depend +++ b/ext/-test-/time/depend @@ -2,6 +2,7 @@ init.o: $(RUBY_EXTCONF_H) init.o: $(arch_hdrdir)/ruby/config.h init.o: $(hdrdir)/ruby.h +init.o: $(hdrdir)/ruby/assert.h init.o: $(hdrdir)/ruby/backward.h init.o: $(hdrdir)/ruby/defines.h init.o: $(hdrdir)/ruby/intern.h @@ -13,6 +14,7 @@ init.o: init.c leap_second.o: $(RUBY_EXTCONF_H) leap_second.o: $(arch_hdrdir)/ruby/config.h leap_second.o: $(hdrdir)/ruby.h +leap_second.o: $(hdrdir)/ruby/assert.h leap_second.o: $(hdrdir)/ruby/backward.h leap_second.o: $(hdrdir)/ruby/defines.h leap_second.o: $(hdrdir)/ruby/intern.h @@ -24,6 +26,7 @@ leap_second.o: leap_second.c new.o: $(RUBY_EXTCONF_H) new.o: $(arch_hdrdir)/ruby/config.h new.o: $(hdrdir)/ruby.h +new.o: $(hdrdir)/ruby/assert.h new.o: $(hdrdir)/ruby/backward.h new.o: $(hdrdir)/ruby/defines.h new.o: $(hdrdir)/ruby/intern.h diff --git a/ext/-test-/tracepoint/depend b/ext/-test-/tracepoint/depend index 5b2b2f73698002..b811df4472c216 100644 --- a/ext/-test-/tracepoint/depend +++ b/ext/-test-/tracepoint/depend @@ -1,6 +1,7 @@ # AUTOGENERATED DEPENDENCIES START gc_hook.o: $(RUBY_EXTCONF_H) gc_hook.o: $(arch_hdrdir)/ruby/config.h +gc_hook.o: $(hdrdir)/ruby/assert.h gc_hook.o: $(hdrdir)/ruby/backward.h gc_hook.o: $(hdrdir)/ruby/debug.h gc_hook.o: $(hdrdir)/ruby/defines.h @@ -12,6 +13,7 @@ gc_hook.o: $(hdrdir)/ruby/subst.h gc_hook.o: gc_hook.c tracepoint.o: $(RUBY_EXTCONF_H) tracepoint.o: $(arch_hdrdir)/ruby/config.h +tracepoint.o: $(hdrdir)/ruby/assert.h tracepoint.o: $(hdrdir)/ruby/backward.h tracepoint.o: $(hdrdir)/ruby/debug.h tracepoint.o: $(hdrdir)/ruby/defines.h diff --git a/ext/-test-/typeddata/depend b/ext/-test-/typeddata/depend index 4d3c9f0d072dd9..e0dd0653a82cbe 100644 --- a/ext/-test-/typeddata/depend +++ b/ext/-test-/typeddata/depend @@ -2,6 +2,7 @@ typeddata.o: $(RUBY_EXTCONF_H) typeddata.o: $(arch_hdrdir)/ruby/config.h typeddata.o: $(hdrdir)/ruby.h +typeddata.o: $(hdrdir)/ruby/assert.h typeddata.o: $(hdrdir)/ruby/backward.h typeddata.o: $(hdrdir)/ruby/defines.h typeddata.o: $(hdrdir)/ruby/intern.h diff --git a/ext/-test-/vm/depend b/ext/-test-/vm/depend index dd56dd0e0d7cd9..0f85d69bb050ca 100644 --- a/ext/-test-/vm/depend +++ b/ext/-test-/vm/depend @@ -1,6 +1,7 @@ # AUTOGENERATED DEPENDENCIES START at_exit.o: $(RUBY_EXTCONF_H) at_exit.o: $(arch_hdrdir)/ruby/config.h +at_exit.o: $(hdrdir)/ruby/assert.h at_exit.o: $(hdrdir)/ruby/backward.h at_exit.o: $(hdrdir)/ruby/defines.h at_exit.o: $(hdrdir)/ruby/intern.h diff --git a/ext/-test-/wait_for_single_fd/depend b/ext/-test-/wait_for_single_fd/depend index edd2f88dcfe73d..8549fca7817459 100644 --- a/ext/-test-/wait_for_single_fd/depend +++ b/ext/-test-/wait_for_single_fd/depend @@ -1,6 +1,7 @@ # AUTOGENERATED DEPENDENCIES START wait_for_single_fd.o: $(RUBY_EXTCONF_H) wait_for_single_fd.o: $(arch_hdrdir)/ruby/config.h +wait_for_single_fd.o: $(hdrdir)/ruby/assert.h wait_for_single_fd.o: $(hdrdir)/ruby/backward.h wait_for_single_fd.o: $(hdrdir)/ruby/defines.h wait_for_single_fd.o: $(hdrdir)/ruby/encoding.h diff --git a/ext/bigdecimal/depend b/ext/bigdecimal/depend index 943bd6c38c6a6e..ffd61b89607544 100644 --- a/ext/bigdecimal/depend +++ b/ext/bigdecimal/depend @@ -4,6 +4,7 @@ Makefile: $(BIGDECIMAL_RB) # AUTOGENERATED DEPENDENCIES START bigdecimal.o: $(RUBY_EXTCONF_H) bigdecimal.o: $(arch_hdrdir)/ruby/config.h +bigdecimal.o: $(hdrdir)/ruby/assert.h bigdecimal.o: $(hdrdir)/ruby/defines.h bigdecimal.o: $(hdrdir)/ruby/intern.h bigdecimal.o: $(hdrdir)/ruby/missing.h diff --git a/ext/bigdecimal/util/depend b/ext/bigdecimal/util/depend index 4cc7b931217e70..96b6a7fea0f9d1 100644 --- a/ext/bigdecimal/util/depend +++ b/ext/bigdecimal/util/depend @@ -2,6 +2,7 @@ util.o: $(RUBY_EXTCONF_H) util.o: $(arch_hdrdir)/ruby/config.h util.o: $(hdrdir)/ruby.h +util.o: $(hdrdir)/ruby/assert.h util.o: $(hdrdir)/ruby/backward.h util.o: $(hdrdir)/ruby/defines.h util.o: $(hdrdir)/ruby/intern.h diff --git a/ext/cgi/escape/depend b/ext/cgi/escape/depend index b48562a670237c..8d4736616f5de6 100644 --- a/ext/cgi/escape/depend +++ b/ext/cgi/escape/depend @@ -2,6 +2,7 @@ escape.o: $(RUBY_EXTCONF_H) escape.o: $(arch_hdrdir)/ruby/config.h escape.o: $(hdrdir)/ruby.h +escape.o: $(hdrdir)/ruby/assert.h escape.o: $(hdrdir)/ruby/backward.h escape.o: $(hdrdir)/ruby/defines.h escape.o: $(hdrdir)/ruby/encoding.h diff --git a/ext/continuation/depend b/ext/continuation/depend index 9e47f27f3a87b6..08844aa6bb542a 100644 --- a/ext/continuation/depend +++ b/ext/continuation/depend @@ -1,6 +1,7 @@ # AUTOGENERATED DEPENDENCIES START continuation.o: $(RUBY_EXTCONF_H) continuation.o: $(arch_hdrdir)/ruby/config.h +continuation.o: $(hdrdir)/ruby/assert.h continuation.o: $(hdrdir)/ruby/backward.h continuation.o: $(hdrdir)/ruby/defines.h continuation.o: $(hdrdir)/ruby/intern.h diff --git a/ext/date/depend b/ext/date/depend index 91ef04c61fa107..28847bef137001 100644 --- a/ext/date/depend +++ b/ext/date/depend @@ -2,6 +2,7 @@ date_core.o: $(RUBY_EXTCONF_H) date_core.o: $(arch_hdrdir)/ruby/config.h date_core.o: $(hdrdir)/ruby.h +date_core.o: $(hdrdir)/ruby/assert.h date_core.o: $(hdrdir)/ruby/backward.h date_core.o: $(hdrdir)/ruby/defines.h date_core.o: $(hdrdir)/ruby/encoding.h @@ -18,6 +19,7 @@ date_core.o: date_tmx.h date_parse.o: $(RUBY_EXTCONF_H) date_parse.o: $(arch_hdrdir)/ruby/config.h date_parse.o: $(hdrdir)/ruby.h +date_parse.o: $(hdrdir)/ruby/assert.h date_parse.o: $(hdrdir)/ruby/backward.h date_parse.o: $(hdrdir)/ruby/defines.h date_parse.o: $(hdrdir)/ruby/encoding.h @@ -35,6 +37,7 @@ date_parse.o: zonetab.h date_parse.o: zonetab.list date_strftime.o: $(RUBY_EXTCONF_H) date_strftime.o: $(arch_hdrdir)/ruby/config.h +date_strftime.o: $(hdrdir)/ruby/assert.h date_strftime.o: $(hdrdir)/ruby/backward.h date_strftime.o: $(hdrdir)/ruby/defines.h date_strftime.o: $(hdrdir)/ruby/intern.h @@ -47,6 +50,7 @@ date_strftime.o: date_tmx.h date_strptime.o: $(RUBY_EXTCONF_H) date_strptime.o: $(arch_hdrdir)/ruby/config.h date_strptime.o: $(hdrdir)/ruby.h +date_strptime.o: $(hdrdir)/ruby/assert.h date_strptime.o: $(hdrdir)/ruby/backward.h date_strptime.o: $(hdrdir)/ruby/defines.h date_strptime.o: $(hdrdir)/ruby/encoding.h diff --git a/ext/dbm/depend b/ext/dbm/depend index c32b7901b74b3c..192527a8eb2ce2 100644 --- a/ext/dbm/depend +++ b/ext/dbm/depend @@ -2,6 +2,7 @@ dbm.o: $(RUBY_EXTCONF_H) dbm.o: $(arch_hdrdir)/ruby/config.h dbm.o: $(hdrdir)/ruby.h +dbm.o: $(hdrdir)/ruby/assert.h dbm.o: $(hdrdir)/ruby/backward.h dbm.o: $(hdrdir)/ruby/defines.h dbm.o: $(hdrdir)/ruby/intern.h diff --git a/ext/digest/bubblebabble/depend b/ext/digest/bubblebabble/depend index a43313f1423b95..e7e2a8889da4f5 100644 --- a/ext/digest/bubblebabble/depend +++ b/ext/digest/bubblebabble/depend @@ -2,6 +2,7 @@ bubblebabble.o: $(RUBY_EXTCONF_H) bubblebabble.o: $(arch_hdrdir)/ruby/config.h bubblebabble.o: $(hdrdir)/ruby.h +bubblebabble.o: $(hdrdir)/ruby/assert.h bubblebabble.o: $(hdrdir)/ruby/backward.h bubblebabble.o: $(hdrdir)/ruby/defines.h bubblebabble.o: $(hdrdir)/ruby/intern.h diff --git a/ext/digest/depend b/ext/digest/depend index 0ee72b88124395..87c39c8b8d32d7 100644 --- a/ext/digest/depend +++ b/ext/digest/depend @@ -2,6 +2,7 @@ digest.o: $(RUBY_EXTCONF_H) digest.o: $(arch_hdrdir)/ruby/config.h digest.o: $(hdrdir)/ruby.h +digest.o: $(hdrdir)/ruby/assert.h digest.o: $(hdrdir)/ruby/backward.h digest.o: $(hdrdir)/ruby/defines.h digest.o: $(hdrdir)/ruby/intern.h diff --git a/ext/digest/md5/depend b/ext/digest/md5/depend index d43101d1f107ca..abfd8de6a5c0a7 100644 --- a/ext/digest/md5/depend +++ b/ext/digest/md5/depend @@ -5,6 +5,7 @@ md5init.o: $(LOCAL_HDRS) md5init.o: $(RUBY_EXTCONF_H) md5init.o: $(arch_hdrdir)/ruby/config.h md5init.o: $(hdrdir)/ruby.h +md5init.o: $(hdrdir)/ruby/assert.h md5init.o: $(hdrdir)/ruby/backward.h md5init.o: $(hdrdir)/ruby/defines.h md5init.o: $(hdrdir)/ruby/intern.h diff --git a/ext/digest/rmd160/depend b/ext/digest/rmd160/depend index 4582922cf003fa..07c406a7d2db8f 100644 --- a/ext/digest/rmd160/depend +++ b/ext/digest/rmd160/depend @@ -5,6 +5,7 @@ rmd160init.o: $(LOCAL_HDRS) rmd160init.o: $(RUBY_EXTCONF_H) rmd160init.o: $(arch_hdrdir)/ruby/config.h rmd160init.o: $(hdrdir)/ruby.h +rmd160init.o: $(hdrdir)/ruby/assert.h rmd160init.o: $(hdrdir)/ruby/backward.h rmd160init.o: $(hdrdir)/ruby/defines.h rmd160init.o: $(hdrdir)/ruby/intern.h diff --git a/ext/digest/sha1/depend b/ext/digest/sha1/depend index c89f99f547eca6..bc9e216eed948c 100644 --- a/ext/digest/sha1/depend +++ b/ext/digest/sha1/depend @@ -5,6 +5,7 @@ sha1init.o: $(LOCAL_HDRS) sha1init.o: $(RUBY_EXTCONF_H) sha1init.o: $(arch_hdrdir)/ruby/config.h sha1init.o: $(hdrdir)/ruby.h +sha1init.o: $(hdrdir)/ruby/assert.h sha1init.o: $(hdrdir)/ruby/backward.h sha1init.o: $(hdrdir)/ruby/defines.h sha1init.o: $(hdrdir)/ruby/intern.h diff --git a/ext/digest/sha2/depend b/ext/digest/sha2/depend index 42453269ea0414..8946d44f319e05 100644 --- a/ext/digest/sha2/depend +++ b/ext/digest/sha2/depend @@ -5,6 +5,7 @@ sha2init.o: $(LOCAL_HDRS) sha2init.o: $(RUBY_EXTCONF_H) sha2init.o: $(arch_hdrdir)/ruby/config.h sha2init.o: $(hdrdir)/ruby.h +sha2init.o: $(hdrdir)/ruby/assert.h sha2init.o: $(hdrdir)/ruby/backward.h sha2init.o: $(hdrdir)/ruby/defines.h sha2init.o: $(hdrdir)/ruby/intern.h diff --git a/ext/etc/depend b/ext/etc/depend index 0e7a6c836667db..99e812c7e45fee 100644 --- a/ext/etc/depend +++ b/ext/etc/depend @@ -6,6 +6,7 @@ constdefs.h : $(srcdir)/mkconstants.rb etc.o: $(RUBY_EXTCONF_H) etc.o: $(arch_hdrdir)/ruby/config.h etc.o: $(hdrdir)/ruby.h +etc.o: $(hdrdir)/ruby/assert.h etc.o: $(hdrdir)/ruby/backward.h etc.o: $(hdrdir)/ruby/defines.h etc.o: $(hdrdir)/ruby/encoding.h diff --git a/ext/fcntl/depend b/ext/fcntl/depend index 961c0ab60f4c68..60d6be6b89a318 100644 --- a/ext/fcntl/depend +++ b/ext/fcntl/depend @@ -2,6 +2,7 @@ fcntl.o: $(RUBY_EXTCONF_H) fcntl.o: $(arch_hdrdir)/ruby/config.h fcntl.o: $(hdrdir)/ruby.h +fcntl.o: $(hdrdir)/ruby/assert.h fcntl.o: $(hdrdir)/ruby/backward.h fcntl.o: $(hdrdir)/ruby/defines.h fcntl.o: $(hdrdir)/ruby/intern.h diff --git a/ext/fiddle/depend b/ext/fiddle/depend index 954906b87a248a..3cf275a227ffa0 100644 --- a/ext/fiddle/depend +++ b/ext/fiddle/depend @@ -55,6 +55,7 @@ realclean: realclean-$(LIBFFI_CLEAN) closure.o: $(RUBY_EXTCONF_H) closure.o: $(arch_hdrdir)/ruby/config.h closure.o: $(hdrdir)/ruby.h +closure.o: $(hdrdir)/ruby/assert.h closure.o: $(hdrdir)/ruby/backward.h closure.o: $(hdrdir)/ruby/defines.h closure.o: $(hdrdir)/ruby/encoding.h @@ -76,6 +77,7 @@ closure.o: function.h conversions.o: $(RUBY_EXTCONF_H) conversions.o: $(arch_hdrdir)/ruby/config.h conversions.o: $(hdrdir)/ruby.h +conversions.o: $(hdrdir)/ruby/assert.h conversions.o: $(hdrdir)/ruby/backward.h conversions.o: $(hdrdir)/ruby/defines.h conversions.o: $(hdrdir)/ruby/intern.h @@ -91,6 +93,7 @@ conversions.o: function.h fiddle.o: $(RUBY_EXTCONF_H) fiddle.o: $(arch_hdrdir)/ruby/config.h fiddle.o: $(hdrdir)/ruby.h +fiddle.o: $(hdrdir)/ruby/assert.h fiddle.o: $(hdrdir)/ruby/backward.h fiddle.o: $(hdrdir)/ruby/defines.h fiddle.o: $(hdrdir)/ruby/intern.h @@ -106,6 +109,7 @@ fiddle.o: function.h function.o: $(RUBY_EXTCONF_H) function.o: $(arch_hdrdir)/ruby/config.h function.o: $(hdrdir)/ruby.h +function.o: $(hdrdir)/ruby/assert.h function.o: $(hdrdir)/ruby/backward.h function.o: $(hdrdir)/ruby/defines.h function.o: $(hdrdir)/ruby/intern.h @@ -122,6 +126,7 @@ function.o: function.h handle.o: $(RUBY_EXTCONF_H) handle.o: $(arch_hdrdir)/ruby/config.h handle.o: $(hdrdir)/ruby.h +handle.o: $(hdrdir)/ruby/assert.h handle.o: $(hdrdir)/ruby/backward.h handle.o: $(hdrdir)/ruby/defines.h handle.o: $(hdrdir)/ruby/intern.h @@ -137,6 +142,7 @@ handle.o: handle.c pointer.o: $(RUBY_EXTCONF_H) pointer.o: $(arch_hdrdir)/ruby/config.h pointer.o: $(hdrdir)/ruby.h +pointer.o: $(hdrdir)/ruby/assert.h pointer.o: $(hdrdir)/ruby/backward.h pointer.o: $(hdrdir)/ruby/defines.h pointer.o: $(hdrdir)/ruby/encoding.h diff --git a/ext/gdbm/depend b/ext/gdbm/depend index f6a5548509eedf..33635bc0993672 100644 --- a/ext/gdbm/depend +++ b/ext/gdbm/depend @@ -2,6 +2,7 @@ gdbm.o: $(RUBY_EXTCONF_H) gdbm.o: $(arch_hdrdir)/ruby/config.h gdbm.o: $(hdrdir)/ruby.h +gdbm.o: $(hdrdir)/ruby/assert.h gdbm.o: $(hdrdir)/ruby/backward.h gdbm.o: $(hdrdir)/ruby/defines.h gdbm.o: $(hdrdir)/ruby/intern.h diff --git a/ext/io/console/depend b/ext/io/console/depend index bcfee065efd5ec..f279368901042b 100644 --- a/ext/io/console/depend +++ b/ext/io/console/depend @@ -2,6 +2,7 @@ console.o: $(RUBY_EXTCONF_H) console.o: $(arch_hdrdir)/ruby/config.h console.o: $(hdrdir)/ruby.h +console.o: $(hdrdir)/ruby/assert.h console.o: $(hdrdir)/ruby/backward.h console.o: $(hdrdir)/ruby/defines.h console.o: $(hdrdir)/ruby/encoding.h diff --git a/ext/io/nonblock/depend b/ext/io/nonblock/depend index 60cfa466a8cc84..bea4a15e231187 100644 --- a/ext/io/nonblock/depend +++ b/ext/io/nonblock/depend @@ -2,6 +2,7 @@ nonblock.o: $(RUBY_EXTCONF_H) nonblock.o: $(arch_hdrdir)/ruby/config.h nonblock.o: $(hdrdir)/ruby.h +nonblock.o: $(hdrdir)/ruby/assert.h nonblock.o: $(hdrdir)/ruby/backward.h nonblock.o: $(hdrdir)/ruby/defines.h nonblock.o: $(hdrdir)/ruby/encoding.h diff --git a/ext/io/wait/depend b/ext/io/wait/depend index 0edd946df514cd..bbf1266aba9f3e 100644 --- a/ext/io/wait/depend +++ b/ext/io/wait/depend @@ -2,6 +2,7 @@ wait.o: $(RUBY_EXTCONF_H) wait.o: $(arch_hdrdir)/ruby/config.h wait.o: $(hdrdir)/ruby.h +wait.o: $(hdrdir)/ruby/assert.h wait.o: $(hdrdir)/ruby/backward.h wait.o: $(hdrdir)/ruby/defines.h wait.o: $(hdrdir)/ruby/encoding.h diff --git a/ext/json/generator/depend b/ext/json/generator/depend index 3621948f28fe97..3f04c0d62578fa 100644 --- a/ext/json/generator/depend +++ b/ext/json/generator/depend @@ -5,6 +5,7 @@ generator.o: generator.c generator.h $(srcdir)/../fbuffer/fbuffer.h generator.o: $(RUBY_EXTCONF_H) generator.o: $(arch_hdrdir)/ruby/config.h generator.o: $(hdrdir)/ruby.h +generator.o: $(hdrdir)/ruby/assert.h generator.o: $(hdrdir)/ruby/backward.h generator.o: $(hdrdir)/ruby/defines.h generator.o: $(hdrdir)/ruby/encoding.h diff --git a/ext/json/parser/depend b/ext/json/parser/depend index de97409488dbf6..d0c9c2d2a61162 100644 --- a/ext/json/parser/depend +++ b/ext/json/parser/depend @@ -5,6 +5,7 @@ parser.o: parser.c parser.h $(srcdir)/../fbuffer/fbuffer.h parser.o: $(RUBY_EXTCONF_H) parser.o: $(arch_hdrdir)/ruby/config.h parser.o: $(hdrdir)/ruby.h +parser.o: $(hdrdir)/ruby/assert.h parser.o: $(hdrdir)/ruby/backward.h parser.o: $(hdrdir)/ruby/defines.h parser.o: $(hdrdir)/ruby/encoding.h diff --git a/ext/nkf/depend b/ext/nkf/depend index 4ea8544a95eb0f..82580ff7fe3074 100644 --- a/ext/nkf/depend +++ b/ext/nkf/depend @@ -5,6 +5,7 @@ nkf.o: nkf.c # AUTOGENERATED DEPENDENCIES START nkf.o: $(RUBY_EXTCONF_H) nkf.o: $(arch_hdrdir)/ruby/config.h +nkf.o: $(hdrdir)/ruby/assert.h nkf.o: $(hdrdir)/ruby/backward.h nkf.o: $(hdrdir)/ruby/defines.h nkf.o: $(hdrdir)/ruby/encoding.h diff --git a/ext/objspace/depend b/ext/objspace/depend index 32157bee2fe023..84e944f22843d6 100644 --- a/ext/objspace/depend +++ b/ext/objspace/depend @@ -2,6 +2,7 @@ object_tracing.o: $(RUBY_EXTCONF_H) object_tracing.o: $(arch_hdrdir)/ruby/config.h object_tracing.o: $(hdrdir)/ruby.h +object_tracing.o: $(hdrdir)/ruby/assert.h object_tracing.o: $(hdrdir)/ruby/backward.h object_tracing.o: $(hdrdir)/ruby/debug.h object_tracing.o: $(hdrdir)/ruby/defines.h @@ -20,6 +21,7 @@ object_tracing.o: objspace.h objspace.o: $(RUBY_EXTCONF_H) objspace.o: $(arch_hdrdir)/ruby/config.h objspace.o: $(hdrdir)/ruby.h +objspace.o: $(hdrdir)/ruby/assert.h objspace.o: $(hdrdir)/ruby/backward.h objspace.o: $(hdrdir)/ruby/defines.h objspace.o: $(hdrdir)/ruby/encoding.h diff --git a/ext/openssl/depend b/ext/openssl/depend index aa03c1ab2983e8..68cf357294fe91 100644 --- a/ext/openssl/depend +++ b/ext/openssl/depend @@ -6,6 +6,7 @@ openssl_missing.o: openssl_missing.h ossl.o: $(RUBY_EXTCONF_H) ossl.o: $(arch_hdrdir)/ruby/config.h ossl.o: $(hdrdir)/ruby.h +ossl.o: $(hdrdir)/ruby/assert.h ossl.o: $(hdrdir)/ruby/backward.h ossl.o: $(hdrdir)/ruby/defines.h ossl.o: $(hdrdir)/ruby/encoding.h @@ -44,6 +45,7 @@ ossl.o: ruby_missing.h ossl_asn1.o: $(RUBY_EXTCONF_H) ossl_asn1.o: $(arch_hdrdir)/ruby/config.h ossl_asn1.o: $(hdrdir)/ruby.h +ossl_asn1.o: $(hdrdir)/ruby/assert.h ossl_asn1.o: $(hdrdir)/ruby/backward.h ossl_asn1.o: $(hdrdir)/ruby/defines.h ossl_asn1.o: $(hdrdir)/ruby/encoding.h @@ -81,6 +83,7 @@ ossl_asn1.o: ruby_missing.h ossl_bio.o: $(RUBY_EXTCONF_H) ossl_bio.o: $(arch_hdrdir)/ruby/config.h ossl_bio.o: $(hdrdir)/ruby.h +ossl_bio.o: $(hdrdir)/ruby/assert.h ossl_bio.o: $(hdrdir)/ruby/backward.h ossl_bio.o: $(hdrdir)/ruby/defines.h ossl_bio.o: $(hdrdir)/ruby/encoding.h @@ -118,6 +121,7 @@ ossl_bio.o: ruby_missing.h ossl_bn.o: $(RUBY_EXTCONF_H) ossl_bn.o: $(arch_hdrdir)/ruby/config.h ossl_bn.o: $(hdrdir)/ruby.h +ossl_bn.o: $(hdrdir)/ruby/assert.h ossl_bn.o: $(hdrdir)/ruby/backward.h ossl_bn.o: $(hdrdir)/ruby/defines.h ossl_bn.o: $(hdrdir)/ruby/encoding.h @@ -155,6 +159,7 @@ ossl_bn.o: ruby_missing.h ossl_cipher.o: $(RUBY_EXTCONF_H) ossl_cipher.o: $(arch_hdrdir)/ruby/config.h ossl_cipher.o: $(hdrdir)/ruby.h +ossl_cipher.o: $(hdrdir)/ruby/assert.h ossl_cipher.o: $(hdrdir)/ruby/backward.h ossl_cipher.o: $(hdrdir)/ruby/defines.h ossl_cipher.o: $(hdrdir)/ruby/encoding.h @@ -192,6 +197,7 @@ ossl_cipher.o: ruby_missing.h ossl_config.o: $(RUBY_EXTCONF_H) ossl_config.o: $(arch_hdrdir)/ruby/config.h ossl_config.o: $(hdrdir)/ruby.h +ossl_config.o: $(hdrdir)/ruby/assert.h ossl_config.o: $(hdrdir)/ruby/backward.h ossl_config.o: $(hdrdir)/ruby/defines.h ossl_config.o: $(hdrdir)/ruby/encoding.h @@ -229,6 +235,7 @@ ossl_config.o: ruby_missing.h ossl_digest.o: $(RUBY_EXTCONF_H) ossl_digest.o: $(arch_hdrdir)/ruby/config.h ossl_digest.o: $(hdrdir)/ruby.h +ossl_digest.o: $(hdrdir)/ruby/assert.h ossl_digest.o: $(hdrdir)/ruby/backward.h ossl_digest.o: $(hdrdir)/ruby/defines.h ossl_digest.o: $(hdrdir)/ruby/encoding.h @@ -266,6 +273,7 @@ ossl_digest.o: ruby_missing.h ossl_engine.o: $(RUBY_EXTCONF_H) ossl_engine.o: $(arch_hdrdir)/ruby/config.h ossl_engine.o: $(hdrdir)/ruby.h +ossl_engine.o: $(hdrdir)/ruby/assert.h ossl_engine.o: $(hdrdir)/ruby/backward.h ossl_engine.o: $(hdrdir)/ruby/defines.h ossl_engine.o: $(hdrdir)/ruby/encoding.h @@ -303,6 +311,7 @@ ossl_engine.o: ruby_missing.h ossl_hmac.o: $(RUBY_EXTCONF_H) ossl_hmac.o: $(arch_hdrdir)/ruby/config.h ossl_hmac.o: $(hdrdir)/ruby.h +ossl_hmac.o: $(hdrdir)/ruby/assert.h ossl_hmac.o: $(hdrdir)/ruby/backward.h ossl_hmac.o: $(hdrdir)/ruby/defines.h ossl_hmac.o: $(hdrdir)/ruby/encoding.h @@ -340,6 +349,7 @@ ossl_hmac.o: ruby_missing.h ossl_kdf.o: $(RUBY_EXTCONF_H) ossl_kdf.o: $(arch_hdrdir)/ruby/config.h ossl_kdf.o: $(hdrdir)/ruby.h +ossl_kdf.o: $(hdrdir)/ruby/assert.h ossl_kdf.o: $(hdrdir)/ruby/backward.h ossl_kdf.o: $(hdrdir)/ruby/defines.h ossl_kdf.o: $(hdrdir)/ruby/encoding.h @@ -377,6 +387,7 @@ ossl_kdf.o: ruby_missing.h ossl_ns_spki.o: $(RUBY_EXTCONF_H) ossl_ns_spki.o: $(arch_hdrdir)/ruby/config.h ossl_ns_spki.o: $(hdrdir)/ruby.h +ossl_ns_spki.o: $(hdrdir)/ruby/assert.h ossl_ns_spki.o: $(hdrdir)/ruby/backward.h ossl_ns_spki.o: $(hdrdir)/ruby/defines.h ossl_ns_spki.o: $(hdrdir)/ruby/encoding.h @@ -414,6 +425,7 @@ ossl_ns_spki.o: ruby_missing.h ossl_ocsp.o: $(RUBY_EXTCONF_H) ossl_ocsp.o: $(arch_hdrdir)/ruby/config.h ossl_ocsp.o: $(hdrdir)/ruby.h +ossl_ocsp.o: $(hdrdir)/ruby/assert.h ossl_ocsp.o: $(hdrdir)/ruby/backward.h ossl_ocsp.o: $(hdrdir)/ruby/defines.h ossl_ocsp.o: $(hdrdir)/ruby/encoding.h @@ -451,6 +463,7 @@ ossl_ocsp.o: ruby_missing.h ossl_pkcs12.o: $(RUBY_EXTCONF_H) ossl_pkcs12.o: $(arch_hdrdir)/ruby/config.h ossl_pkcs12.o: $(hdrdir)/ruby.h +ossl_pkcs12.o: $(hdrdir)/ruby/assert.h ossl_pkcs12.o: $(hdrdir)/ruby/backward.h ossl_pkcs12.o: $(hdrdir)/ruby/defines.h ossl_pkcs12.o: $(hdrdir)/ruby/encoding.h @@ -488,6 +501,7 @@ ossl_pkcs12.o: ruby_missing.h ossl_pkcs7.o: $(RUBY_EXTCONF_H) ossl_pkcs7.o: $(arch_hdrdir)/ruby/config.h ossl_pkcs7.o: $(hdrdir)/ruby.h +ossl_pkcs7.o: $(hdrdir)/ruby/assert.h ossl_pkcs7.o: $(hdrdir)/ruby/backward.h ossl_pkcs7.o: $(hdrdir)/ruby/defines.h ossl_pkcs7.o: $(hdrdir)/ruby/encoding.h @@ -525,6 +539,7 @@ ossl_pkcs7.o: ruby_missing.h ossl_pkey.o: $(RUBY_EXTCONF_H) ossl_pkey.o: $(arch_hdrdir)/ruby/config.h ossl_pkey.o: $(hdrdir)/ruby.h +ossl_pkey.o: $(hdrdir)/ruby/assert.h ossl_pkey.o: $(hdrdir)/ruby/backward.h ossl_pkey.o: $(hdrdir)/ruby/defines.h ossl_pkey.o: $(hdrdir)/ruby/encoding.h @@ -562,6 +577,7 @@ ossl_pkey.o: ruby_missing.h ossl_pkey_dh.o: $(RUBY_EXTCONF_H) ossl_pkey_dh.o: $(arch_hdrdir)/ruby/config.h ossl_pkey_dh.o: $(hdrdir)/ruby.h +ossl_pkey_dh.o: $(hdrdir)/ruby/assert.h ossl_pkey_dh.o: $(hdrdir)/ruby/backward.h ossl_pkey_dh.o: $(hdrdir)/ruby/defines.h ossl_pkey_dh.o: $(hdrdir)/ruby/encoding.h @@ -599,6 +615,7 @@ ossl_pkey_dh.o: ruby_missing.h ossl_pkey_dsa.o: $(RUBY_EXTCONF_H) ossl_pkey_dsa.o: $(arch_hdrdir)/ruby/config.h ossl_pkey_dsa.o: $(hdrdir)/ruby.h +ossl_pkey_dsa.o: $(hdrdir)/ruby/assert.h ossl_pkey_dsa.o: $(hdrdir)/ruby/backward.h ossl_pkey_dsa.o: $(hdrdir)/ruby/defines.h ossl_pkey_dsa.o: $(hdrdir)/ruby/encoding.h @@ -636,6 +653,7 @@ ossl_pkey_dsa.o: ruby_missing.h ossl_pkey_ec.o: $(RUBY_EXTCONF_H) ossl_pkey_ec.o: $(arch_hdrdir)/ruby/config.h ossl_pkey_ec.o: $(hdrdir)/ruby.h +ossl_pkey_ec.o: $(hdrdir)/ruby/assert.h ossl_pkey_ec.o: $(hdrdir)/ruby/backward.h ossl_pkey_ec.o: $(hdrdir)/ruby/defines.h ossl_pkey_ec.o: $(hdrdir)/ruby/encoding.h @@ -673,6 +691,7 @@ ossl_pkey_ec.o: ruby_missing.h ossl_pkey_rsa.o: $(RUBY_EXTCONF_H) ossl_pkey_rsa.o: $(arch_hdrdir)/ruby/config.h ossl_pkey_rsa.o: $(hdrdir)/ruby.h +ossl_pkey_rsa.o: $(hdrdir)/ruby/assert.h ossl_pkey_rsa.o: $(hdrdir)/ruby/backward.h ossl_pkey_rsa.o: $(hdrdir)/ruby/defines.h ossl_pkey_rsa.o: $(hdrdir)/ruby/encoding.h @@ -710,6 +729,7 @@ ossl_pkey_rsa.o: ruby_missing.h ossl_rand.o: $(RUBY_EXTCONF_H) ossl_rand.o: $(arch_hdrdir)/ruby/config.h ossl_rand.o: $(hdrdir)/ruby.h +ossl_rand.o: $(hdrdir)/ruby/assert.h ossl_rand.o: $(hdrdir)/ruby/backward.h ossl_rand.o: $(hdrdir)/ruby/defines.h ossl_rand.o: $(hdrdir)/ruby/encoding.h @@ -747,6 +767,7 @@ ossl_rand.o: ruby_missing.h ossl_ssl.o: $(RUBY_EXTCONF_H) ossl_ssl.o: $(arch_hdrdir)/ruby/config.h ossl_ssl.o: $(hdrdir)/ruby.h +ossl_ssl.o: $(hdrdir)/ruby/assert.h ossl_ssl.o: $(hdrdir)/ruby/backward.h ossl_ssl.o: $(hdrdir)/ruby/defines.h ossl_ssl.o: $(hdrdir)/ruby/encoding.h @@ -784,6 +805,7 @@ ossl_ssl.o: ruby_missing.h ossl_ssl_session.o: $(RUBY_EXTCONF_H) ossl_ssl_session.o: $(arch_hdrdir)/ruby/config.h ossl_ssl_session.o: $(hdrdir)/ruby.h +ossl_ssl_session.o: $(hdrdir)/ruby/assert.h ossl_ssl_session.o: $(hdrdir)/ruby/backward.h ossl_ssl_session.o: $(hdrdir)/ruby/defines.h ossl_ssl_session.o: $(hdrdir)/ruby/encoding.h @@ -821,6 +843,7 @@ ossl_ssl_session.o: ruby_missing.h ossl_x509.o: $(RUBY_EXTCONF_H) ossl_x509.o: $(arch_hdrdir)/ruby/config.h ossl_x509.o: $(hdrdir)/ruby.h +ossl_x509.o: $(hdrdir)/ruby/assert.h ossl_x509.o: $(hdrdir)/ruby/backward.h ossl_x509.o: $(hdrdir)/ruby/defines.h ossl_x509.o: $(hdrdir)/ruby/encoding.h @@ -858,6 +881,7 @@ ossl_x509.o: ruby_missing.h ossl_x509attr.o: $(RUBY_EXTCONF_H) ossl_x509attr.o: $(arch_hdrdir)/ruby/config.h ossl_x509attr.o: $(hdrdir)/ruby.h +ossl_x509attr.o: $(hdrdir)/ruby/assert.h ossl_x509attr.o: $(hdrdir)/ruby/backward.h ossl_x509attr.o: $(hdrdir)/ruby/defines.h ossl_x509attr.o: $(hdrdir)/ruby/encoding.h @@ -895,6 +919,7 @@ ossl_x509attr.o: ruby_missing.h ossl_x509cert.o: $(RUBY_EXTCONF_H) ossl_x509cert.o: $(arch_hdrdir)/ruby/config.h ossl_x509cert.o: $(hdrdir)/ruby.h +ossl_x509cert.o: $(hdrdir)/ruby/assert.h ossl_x509cert.o: $(hdrdir)/ruby/backward.h ossl_x509cert.o: $(hdrdir)/ruby/defines.h ossl_x509cert.o: $(hdrdir)/ruby/encoding.h @@ -932,6 +957,7 @@ ossl_x509cert.o: ruby_missing.h ossl_x509crl.o: $(RUBY_EXTCONF_H) ossl_x509crl.o: $(arch_hdrdir)/ruby/config.h ossl_x509crl.o: $(hdrdir)/ruby.h +ossl_x509crl.o: $(hdrdir)/ruby/assert.h ossl_x509crl.o: $(hdrdir)/ruby/backward.h ossl_x509crl.o: $(hdrdir)/ruby/defines.h ossl_x509crl.o: $(hdrdir)/ruby/encoding.h @@ -969,6 +995,7 @@ ossl_x509crl.o: ruby_missing.h ossl_x509ext.o: $(RUBY_EXTCONF_H) ossl_x509ext.o: $(arch_hdrdir)/ruby/config.h ossl_x509ext.o: $(hdrdir)/ruby.h +ossl_x509ext.o: $(hdrdir)/ruby/assert.h ossl_x509ext.o: $(hdrdir)/ruby/backward.h ossl_x509ext.o: $(hdrdir)/ruby/defines.h ossl_x509ext.o: $(hdrdir)/ruby/encoding.h @@ -1006,6 +1033,7 @@ ossl_x509ext.o: ruby_missing.h ossl_x509name.o: $(RUBY_EXTCONF_H) ossl_x509name.o: $(arch_hdrdir)/ruby/config.h ossl_x509name.o: $(hdrdir)/ruby.h +ossl_x509name.o: $(hdrdir)/ruby/assert.h ossl_x509name.o: $(hdrdir)/ruby/backward.h ossl_x509name.o: $(hdrdir)/ruby/defines.h ossl_x509name.o: $(hdrdir)/ruby/encoding.h @@ -1043,6 +1071,7 @@ ossl_x509name.o: ruby_missing.h ossl_x509req.o: $(RUBY_EXTCONF_H) ossl_x509req.o: $(arch_hdrdir)/ruby/config.h ossl_x509req.o: $(hdrdir)/ruby.h +ossl_x509req.o: $(hdrdir)/ruby/assert.h ossl_x509req.o: $(hdrdir)/ruby/backward.h ossl_x509req.o: $(hdrdir)/ruby/defines.h ossl_x509req.o: $(hdrdir)/ruby/encoding.h @@ -1080,6 +1109,7 @@ ossl_x509req.o: ruby_missing.h ossl_x509revoked.o: $(RUBY_EXTCONF_H) ossl_x509revoked.o: $(arch_hdrdir)/ruby/config.h ossl_x509revoked.o: $(hdrdir)/ruby.h +ossl_x509revoked.o: $(hdrdir)/ruby/assert.h ossl_x509revoked.o: $(hdrdir)/ruby/backward.h ossl_x509revoked.o: $(hdrdir)/ruby/defines.h ossl_x509revoked.o: $(hdrdir)/ruby/encoding.h @@ -1117,6 +1147,7 @@ ossl_x509revoked.o: ruby_missing.h ossl_x509store.o: $(RUBY_EXTCONF_H) ossl_x509store.o: $(arch_hdrdir)/ruby/config.h ossl_x509store.o: $(hdrdir)/ruby.h +ossl_x509store.o: $(hdrdir)/ruby/assert.h ossl_x509store.o: $(hdrdir)/ruby/backward.h ossl_x509store.o: $(hdrdir)/ruby/defines.h ossl_x509store.o: $(hdrdir)/ruby/encoding.h diff --git a/ext/pathname/depend b/ext/pathname/depend index 1e14d190c256d5..1e13dd5f372a15 100644 --- a/ext/pathname/depend +++ b/ext/pathname/depend @@ -2,6 +2,7 @@ pathname.o: $(RUBY_EXTCONF_H) pathname.o: $(arch_hdrdir)/ruby/config.h pathname.o: $(hdrdir)/ruby.h +pathname.o: $(hdrdir)/ruby/assert.h pathname.o: $(hdrdir)/ruby/backward.h pathname.o: $(hdrdir)/ruby/defines.h pathname.o: $(hdrdir)/ruby/encoding.h diff --git a/ext/psych/depend b/ext/psych/depend index b720b4b22344ea..9f7d3a81da8ede 100644 --- a/ext/psych/depend +++ b/ext/psych/depend @@ -2,6 +2,7 @@ psych.o: $(RUBY_EXTCONF_H) psych.o: $(arch_hdrdir)/ruby/config.h psych.o: $(hdrdir)/ruby.h +psych.o: $(hdrdir)/ruby/assert.h psych.o: $(hdrdir)/ruby/backward.h psych.o: $(hdrdir)/ruby/defines.h psych.o: $(hdrdir)/ruby/encoding.h @@ -21,6 +22,7 @@ psych.o: psych_yaml_tree.h psych_emitter.o: $(RUBY_EXTCONF_H) psych_emitter.o: $(arch_hdrdir)/ruby/config.h psych_emitter.o: $(hdrdir)/ruby.h +psych_emitter.o: $(hdrdir)/ruby/assert.h psych_emitter.o: $(hdrdir)/ruby/backward.h psych_emitter.o: $(hdrdir)/ruby/defines.h psych_emitter.o: $(hdrdir)/ruby/encoding.h @@ -40,6 +42,7 @@ psych_emitter.o: psych_yaml_tree.h psych_parser.o: $(RUBY_EXTCONF_H) psych_parser.o: $(arch_hdrdir)/ruby/config.h psych_parser.o: $(hdrdir)/ruby.h +psych_parser.o: $(hdrdir)/ruby/assert.h psych_parser.o: $(hdrdir)/ruby/backward.h psych_parser.o: $(hdrdir)/ruby/defines.h psych_parser.o: $(hdrdir)/ruby/encoding.h @@ -59,6 +62,7 @@ psych_parser.o: psych_yaml_tree.h psych_to_ruby.o: $(RUBY_EXTCONF_H) psych_to_ruby.o: $(arch_hdrdir)/ruby/config.h psych_to_ruby.o: $(hdrdir)/ruby.h +psych_to_ruby.o: $(hdrdir)/ruby/assert.h psych_to_ruby.o: $(hdrdir)/ruby/backward.h psych_to_ruby.o: $(hdrdir)/ruby/defines.h psych_to_ruby.o: $(hdrdir)/ruby/encoding.h @@ -78,6 +82,7 @@ psych_to_ruby.o: psych_yaml_tree.h psych_yaml_tree.o: $(RUBY_EXTCONF_H) psych_yaml_tree.o: $(arch_hdrdir)/ruby/config.h psych_yaml_tree.o: $(hdrdir)/ruby.h +psych_yaml_tree.o: $(hdrdir)/ruby/assert.h psych_yaml_tree.o: $(hdrdir)/ruby/backward.h psych_yaml_tree.o: $(hdrdir)/ruby/defines.h psych_yaml_tree.o: $(hdrdir)/ruby/encoding.h diff --git a/ext/pty/depend b/ext/pty/depend index 0470c7caf2be2b..1e89dc824c3f4a 100644 --- a/ext/pty/depend +++ b/ext/pty/depend @@ -2,6 +2,7 @@ pty.o: $(RUBY_EXTCONF_H) pty.o: $(arch_hdrdir)/ruby/config.h pty.o: $(hdrdir)/ruby.h +pty.o: $(hdrdir)/ruby/assert.h pty.o: $(hdrdir)/ruby/backward.h pty.o: $(hdrdir)/ruby/defines.h pty.o: $(hdrdir)/ruby/encoding.h diff --git a/ext/racc/cparse/depend b/ext/racc/cparse/depend index 8d8a3a7d269d44..a156b323431bf6 100644 --- a/ext/racc/cparse/depend +++ b/ext/racc/cparse/depend @@ -2,6 +2,7 @@ cparse.o: $(RUBY_EXTCONF_H) cparse.o: $(arch_hdrdir)/ruby/config.h cparse.o: $(hdrdir)/ruby.h +cparse.o: $(hdrdir)/ruby/assert.h cparse.o: $(hdrdir)/ruby/backward.h cparse.o: $(hdrdir)/ruby/defines.h cparse.o: $(hdrdir)/ruby/intern.h diff --git a/ext/rbconfig/sizeof/depend b/ext/rbconfig/sizeof/depend index 143cbb0ee5d98e..9433dd4156a59a 100644 --- a/ext/rbconfig/sizeof/depend +++ b/ext/rbconfig/sizeof/depend @@ -16,6 +16,7 @@ sizes.c: $(top_srcdir)/tool/generic_erb.rb \ # AUTOGENERATED DEPENDENCIES START limits.o: $(RUBY_EXTCONF_H) limits.o: $(arch_hdrdir)/ruby/config.h +limits.o: $(hdrdir)/ruby/assert.h limits.o: $(hdrdir)/ruby/backward.h limits.o: $(hdrdir)/ruby/defines.h limits.o: $(hdrdir)/ruby/intern.h @@ -26,6 +27,7 @@ limits.o: $(hdrdir)/ruby/subst.h limits.o: limits.c sizes.o: $(RUBY_EXTCONF_H) sizes.o: $(arch_hdrdir)/ruby/config.h +sizes.o: $(hdrdir)/ruby/assert.h sizes.o: $(hdrdir)/ruby/backward.h sizes.o: $(hdrdir)/ruby/defines.h sizes.o: $(hdrdir)/ruby/intern.h diff --git a/ext/readline/depend b/ext/readline/depend index eb0eb83e921dd1..7ebc6119c5a878 100644 --- a/ext/readline/depend +++ b/ext/readline/depend @@ -2,6 +2,7 @@ readline.o: $(RUBY_EXTCONF_H) readline.o: $(arch_hdrdir)/ruby/config.h readline.o: $(hdrdir)/ruby.h +readline.o: $(hdrdir)/ruby/assert.h readline.o: $(hdrdir)/ruby/backward.h readline.o: $(hdrdir)/ruby/defines.h readline.o: $(hdrdir)/ruby/encoding.h diff --git a/ext/ripper/depend b/ext/ripper/depend index f6f9b98c534c38..fd53a8dc4332ac 100644 --- a/ext/ripper/depend +++ b/ext/ripper/depend @@ -51,6 +51,7 @@ ripper.E: ripper.c ripper.o: $(RUBY_EXTCONF_H) ripper.o: $(arch_hdrdir)/ruby/config.h ripper.o: $(hdrdir)/ruby.h +ripper.o: $(hdrdir)/ruby/assert.h ripper.o: $(hdrdir)/ruby/backward.h ripper.o: $(hdrdir)/ruby/defines.h ripper.o: $(hdrdir)/ruby/encoding.h diff --git a/ext/sdbm/depend b/ext/sdbm/depend index 547bfdaa89fa20..d475eccceff376 100644 --- a/ext/sdbm/depend +++ b/ext/sdbm/depend @@ -1,6 +1,7 @@ # AUTOGENERATED DEPENDENCIES START _sdbm.o: $(RUBY_EXTCONF_H) _sdbm.o: $(arch_hdrdir)/ruby/config.h +_sdbm.o: $(hdrdir)/ruby/assert.h _sdbm.o: $(hdrdir)/ruby/backward.h _sdbm.o: $(hdrdir)/ruby/defines.h _sdbm.o: $(hdrdir)/ruby/intern.h @@ -13,6 +14,7 @@ _sdbm.o: sdbm.h init.o: $(RUBY_EXTCONF_H) init.o: $(arch_hdrdir)/ruby/config.h init.o: $(hdrdir)/ruby.h +init.o: $(hdrdir)/ruby/assert.h init.o: $(hdrdir)/ruby/backward.h init.o: $(hdrdir)/ruby/defines.h init.o: $(hdrdir)/ruby/intern.h diff --git a/ext/socket/depend b/ext/socket/depend index 7d9c9b605396f9..e958b3dc5d9519 100644 --- a/ext/socket/depend +++ b/ext/socket/depend @@ -13,6 +13,7 @@ constdefs.c: constdefs.h ancdata.o: $(RUBY_EXTCONF_H) ancdata.o: $(arch_hdrdir)/ruby/config.h ancdata.o: $(hdrdir)/ruby.h +ancdata.o: $(hdrdir)/ruby/assert.h ancdata.o: $(hdrdir)/ruby/backward.h ancdata.o: $(hdrdir)/ruby/defines.h ancdata.o: $(hdrdir)/ruby/encoding.h @@ -34,6 +35,7 @@ ancdata.o: sockport.h basicsocket.o: $(RUBY_EXTCONF_H) basicsocket.o: $(arch_hdrdir)/ruby/config.h basicsocket.o: $(hdrdir)/ruby.h +basicsocket.o: $(hdrdir)/ruby/assert.h basicsocket.o: $(hdrdir)/ruby/backward.h basicsocket.o: $(hdrdir)/ruby/defines.h basicsocket.o: $(hdrdir)/ruby/encoding.h @@ -55,6 +57,7 @@ basicsocket.o: sockport.h constants.o: $(RUBY_EXTCONF_H) constants.o: $(arch_hdrdir)/ruby/config.h constants.o: $(hdrdir)/ruby.h +constants.o: $(hdrdir)/ruby/assert.h constants.o: $(hdrdir)/ruby/backward.h constants.o: $(hdrdir)/ruby/defines.h constants.o: $(hdrdir)/ruby/encoding.h @@ -77,6 +80,7 @@ constants.o: sockport.h ifaddr.o: $(RUBY_EXTCONF_H) ifaddr.o: $(arch_hdrdir)/ruby/config.h ifaddr.o: $(hdrdir)/ruby.h +ifaddr.o: $(hdrdir)/ruby/assert.h ifaddr.o: $(hdrdir)/ruby/backward.h ifaddr.o: $(hdrdir)/ruby/defines.h ifaddr.o: $(hdrdir)/ruby/encoding.h @@ -98,6 +102,7 @@ ifaddr.o: sockport.h init.o: $(RUBY_EXTCONF_H) init.o: $(arch_hdrdir)/ruby/config.h init.o: $(hdrdir)/ruby.h +init.o: $(hdrdir)/ruby/assert.h init.o: $(hdrdir)/ruby/backward.h init.o: $(hdrdir)/ruby/defines.h init.o: $(hdrdir)/ruby/encoding.h @@ -119,6 +124,7 @@ init.o: sockport.h ipsocket.o: $(RUBY_EXTCONF_H) ipsocket.o: $(arch_hdrdir)/ruby/config.h ipsocket.o: $(hdrdir)/ruby.h +ipsocket.o: $(hdrdir)/ruby/assert.h ipsocket.o: $(hdrdir)/ruby/backward.h ipsocket.o: $(hdrdir)/ruby/defines.h ipsocket.o: $(hdrdir)/ruby/encoding.h @@ -140,6 +146,7 @@ ipsocket.o: sockport.h option.o: $(RUBY_EXTCONF_H) option.o: $(arch_hdrdir)/ruby/config.h option.o: $(hdrdir)/ruby.h +option.o: $(hdrdir)/ruby/assert.h option.o: $(hdrdir)/ruby/backward.h option.o: $(hdrdir)/ruby/defines.h option.o: $(hdrdir)/ruby/encoding.h @@ -161,6 +168,7 @@ option.o: sockport.h raddrinfo.o: $(RUBY_EXTCONF_H) raddrinfo.o: $(arch_hdrdir)/ruby/config.h raddrinfo.o: $(hdrdir)/ruby.h +raddrinfo.o: $(hdrdir)/ruby/assert.h raddrinfo.o: $(hdrdir)/ruby/backward.h raddrinfo.o: $(hdrdir)/ruby/defines.h raddrinfo.o: $(hdrdir)/ruby/encoding.h @@ -182,6 +190,7 @@ raddrinfo.o: sockport.h socket.o: $(RUBY_EXTCONF_H) socket.o: $(arch_hdrdir)/ruby/config.h socket.o: $(hdrdir)/ruby.h +socket.o: $(hdrdir)/ruby/assert.h socket.o: $(hdrdir)/ruby/backward.h socket.o: $(hdrdir)/ruby/defines.h socket.o: $(hdrdir)/ruby/encoding.h @@ -203,6 +212,7 @@ socket.o: sockport.h sockssocket.o: $(RUBY_EXTCONF_H) sockssocket.o: $(arch_hdrdir)/ruby/config.h sockssocket.o: $(hdrdir)/ruby.h +sockssocket.o: $(hdrdir)/ruby/assert.h sockssocket.o: $(hdrdir)/ruby/backward.h sockssocket.o: $(hdrdir)/ruby/defines.h sockssocket.o: $(hdrdir)/ruby/encoding.h @@ -224,6 +234,7 @@ sockssocket.o: sockssocket.c tcpserver.o: $(RUBY_EXTCONF_H) tcpserver.o: $(arch_hdrdir)/ruby/config.h tcpserver.o: $(hdrdir)/ruby.h +tcpserver.o: $(hdrdir)/ruby/assert.h tcpserver.o: $(hdrdir)/ruby/backward.h tcpserver.o: $(hdrdir)/ruby/defines.h tcpserver.o: $(hdrdir)/ruby/encoding.h @@ -245,6 +256,7 @@ tcpserver.o: tcpserver.c tcpsocket.o: $(RUBY_EXTCONF_H) tcpsocket.o: $(arch_hdrdir)/ruby/config.h tcpsocket.o: $(hdrdir)/ruby.h +tcpsocket.o: $(hdrdir)/ruby/assert.h tcpsocket.o: $(hdrdir)/ruby/backward.h tcpsocket.o: $(hdrdir)/ruby/defines.h tcpsocket.o: $(hdrdir)/ruby/encoding.h @@ -266,6 +278,7 @@ tcpsocket.o: tcpsocket.c udpsocket.o: $(RUBY_EXTCONF_H) udpsocket.o: $(arch_hdrdir)/ruby/config.h udpsocket.o: $(hdrdir)/ruby.h +udpsocket.o: $(hdrdir)/ruby/assert.h udpsocket.o: $(hdrdir)/ruby/backward.h udpsocket.o: $(hdrdir)/ruby/defines.h udpsocket.o: $(hdrdir)/ruby/encoding.h @@ -287,6 +300,7 @@ udpsocket.o: udpsocket.c unixserver.o: $(RUBY_EXTCONF_H) unixserver.o: $(arch_hdrdir)/ruby/config.h unixserver.o: $(hdrdir)/ruby.h +unixserver.o: $(hdrdir)/ruby/assert.h unixserver.o: $(hdrdir)/ruby/backward.h unixserver.o: $(hdrdir)/ruby/defines.h unixserver.o: $(hdrdir)/ruby/encoding.h @@ -308,6 +322,7 @@ unixserver.o: unixserver.c unixsocket.o: $(RUBY_EXTCONF_H) unixsocket.o: $(arch_hdrdir)/ruby/config.h unixsocket.o: $(hdrdir)/ruby.h +unixsocket.o: $(hdrdir)/ruby/assert.h unixsocket.o: $(hdrdir)/ruby/backward.h unixsocket.o: $(hdrdir)/ruby/defines.h unixsocket.o: $(hdrdir)/ruby/encoding.h diff --git a/ext/stringio/depend b/ext/stringio/depend index f8adb09556ad47..02d468b30604bc 100644 --- a/ext/stringio/depend +++ b/ext/stringio/depend @@ -2,6 +2,7 @@ stringio.o: $(RUBY_EXTCONF_H) stringio.o: $(arch_hdrdir)/ruby/config.h stringio.o: $(hdrdir)/ruby.h +stringio.o: $(hdrdir)/ruby/assert.h stringio.o: $(hdrdir)/ruby/backward.h stringio.o: $(hdrdir)/ruby/defines.h stringio.o: $(hdrdir)/ruby/encoding.h diff --git a/ext/strscan/depend b/ext/strscan/depend index 1c396b00cf1df3..2d0441ff8ed817 100644 --- a/ext/strscan/depend +++ b/ext/strscan/depend @@ -1,6 +1,7 @@ # AUTOGENERATED DEPENDENCIES START strscan.o: $(RUBY_EXTCONF_H) strscan.o: $(arch_hdrdir)/ruby/config.h +strscan.o: $(hdrdir)/ruby/assert.h strscan.o: $(hdrdir)/ruby/backward.h strscan.o: $(hdrdir)/ruby/defines.h strscan.o: $(hdrdir)/ruby/encoding.h diff --git a/ext/syslog/depend b/ext/syslog/depend index ee2ad79052f981..a3f7db83716646 100644 --- a/ext/syslog/depend +++ b/ext/syslog/depend @@ -1,6 +1,7 @@ # AUTOGENERATED DEPENDENCIES START syslog.o: $(RUBY_EXTCONF_H) syslog.o: $(arch_hdrdir)/ruby/config.h +syslog.o: $(hdrdir)/ruby/assert.h syslog.o: $(hdrdir)/ruby/backward.h syslog.o: $(hdrdir)/ruby/defines.h syslog.o: $(hdrdir)/ruby/intern.h diff --git a/ext/win32/resolv/depend b/ext/win32/resolv/depend index 4c2fa286bc7de0..a6d24c3738bff4 100644 --- a/ext/win32/resolv/depend +++ b/ext/win32/resolv/depend @@ -2,6 +2,7 @@ resolv.o: $(RUBY_EXTCONF_H) resolv.o: $(arch_hdrdir)/ruby/config.h resolv.o: $(hdrdir)/ruby.h +resolv.o: $(hdrdir)/ruby/assert.h resolv.o: $(hdrdir)/ruby/backward.h resolv.o: $(hdrdir)/ruby/defines.h resolv.o: $(hdrdir)/ruby/encoding.h diff --git a/ext/zlib/depend b/ext/zlib/depend index 37a57d5baaa16c..5ab5684fb08ab1 100644 --- a/ext/zlib/depend +++ b/ext/zlib/depend @@ -2,6 +2,7 @@ zlib.o: $(RUBY_EXTCONF_H) zlib.o: $(arch_hdrdir)/ruby/config.h zlib.o: $(hdrdir)/ruby.h +zlib.o: $(hdrdir)/ruby/assert.h zlib.o: $(hdrdir)/ruby/backward.h zlib.o: $(hdrdir)/ruby/defines.h zlib.o: $(hdrdir)/ruby/encoding.h diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h index 281c3ff98ed5d8..863102228b892b 100644 --- a/include/ruby/ruby.h +++ b/include/ruby/ruby.h @@ -27,6 +27,7 @@ extern "C" { #endif #include "defines.h" +#include "ruby/assert.h" /* For MinGW, we need __declspec(dllimport) for RUBY_EXTERN on MJIT. mswin's RUBY_EXTERN already has that. See also: win32/Makefile.sub */ From 08c2a9dc599021668e11dee2f099a204122eab90 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 14 Jul 2019 14:44:59 +0900 Subject: [PATCH 081/452] Introduce RUBY_DEBUG flag macro When RUBY_DEBUG is turned on, all RUBY_ASSERT() macros will be enabled regardless RUBY_NDEBUG. --- include/ruby/assert.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/ruby/assert.h b/include/ruby/assert.h index aef36b8d483cfd..f8930a7bba2dde 100644 --- a/include/ruby/assert.h +++ b/include/ruby/assert.h @@ -28,9 +28,12 @@ NORETURN(void rb_assert_failure(const char *, int, const char *, const char *)); # define RUBY_ASSERT_MESG_WHEN(cond, expr, mesg) \ RUBY_ASSERT_MESG(!(cond) || (expr), mesg) #endif -#define RUBY_ASSERT(expr) RUBY_ASSERT_MESG_WHEN(!RUBY_NDEBUG+0, expr, #expr) +#define RUBY_ASSERT(expr) RUBY_ASSERT_MESG_WHEN(RUBY_DEBUG+(!RUBY_NDEBUG+0), expr, #expr) #define RUBY_ASSERT_WHEN(cond, expr) RUBY_ASSERT_MESG_WHEN(cond, expr, #expr) +#ifndef RUBY_DEBUG +# define RUBY_DEBUG 0 +#endif #ifndef RUBY_NDEBUG # ifdef NDEBUG # define RUBY_NDEBUG 1 From 043e3d2cdc02a3571e3e2c3b9252a65d3c049740 Mon Sep 17 00:00:00 2001 From: Kazuhiro NISHIYAMA Date: Sun, 14 Jul 2019 17:58:25 +0900 Subject: [PATCH 082/452] [DOC] Add missing headings [ci skip] --- NEWS | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NEWS b/NEWS index f422e68c88b1c1..ed34fe82f56d90 100644 --- a/NEWS +++ b/NEWS @@ -151,12 +151,16 @@ Regexp / String:: Time:: + New methods:: + * Added Time#ceil method. [Feature #15772] * Added Time#floor method. [Feature #15653] $LOAD_PATH:: + New method:: + * Added $LOAD_PATH.resolve_feature_path. [Feature #15903] [Feature #15230] === Stdlib updates (outstanding ones only) From d30d404bc4b848f84959799b543de4bdbd8eef2b Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Sun, 14 Jul 2019 18:04:14 +0900 Subject: [PATCH 083/452] MJIT Support for getblockparamproxy --- test/ruby/test_jit.rb | 14 ++++++++++++-- tool/ruby_vm/views/_mjit_compile_insn_body.erb | 3 +++ tool/ruby_vm/views/mjit_compile.inc.erb | 1 - vm.c | 3 +-- vm_insnhelper.h | 2 ++ 5 files changed, 18 insertions(+), 5 deletions(-) diff --git a/test/ruby/test_jit.rb b/test/ruby/test_jit.rb index 0cfc980aac2656..727043fd007115 100644 --- a/test/ruby/test_jit.rb +++ b/test/ruby/test_jit.rb @@ -18,7 +18,6 @@ class TestJIT < Test::Unit::TestCase # trace_* insns are not compiled for now... TEST_PENDING_INSNS = RubyVM::INSTRUCTION_NAMES.select { |n| n.start_with?('trace_') }.map(&:to_sym) + [ # not supported yet - :getblockparamproxy, :defineclass, :opt_call_c_function, @@ -94,7 +93,18 @@ def foo(&b) end def test_compile_insn_getblockparamproxy - skip "support this in mjit_compile" + assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: '4', success_count: 3, insns: %i[getblockparamproxy]) + begin; + def bar(&b) + b.call + end + + def foo(&b) + bar(&b) * bar(&b) + end + + print foo { 2 } + end; end def test_compile_insn_getspecial diff --git a/tool/ruby_vm/views/_mjit_compile_insn_body.erb b/tool/ruby_vm/views/_mjit_compile_insn_body.erb index 7035779221a0e1..a2a750fbdc3f39 100644 --- a/tool/ruby_vm/views/_mjit_compile_insn_body.erb +++ b/tool/ruby_vm/views/_mjit_compile_insn_body.erb @@ -81,6 +81,9 @@ fprintf(f, " reg_cfp->pc = original_body_iseq + %d;\n", pos); fprintf(f, " RB_DEBUG_COUNTER_INC(mjit_cancel_opt_insn);\n"); fprintf(f, " goto cancel;\n"); +% when /\A(?.+\b)INSN_LABEL\((?[^)]+)\)(?.+)\z/m +% prefix, name, suffix = Regexp.last_match[:prefix], Regexp.last_match[:name], Regexp.last_match[:suffix] + fprintf(f, " <%= prefix.gsub(/\t/, ' ' * 8) %>INSN_LABEL(<%= name %>_%d)<%= suffix.sub(/\n/, '\n') %>", pos); % else % if insn.handles_sp? % # If insn.handles_sp? is true, cfp->sp might be changed inside insns (like vm_caller_setup_arg_block) diff --git a/tool/ruby_vm/views/mjit_compile.inc.erb b/tool/ruby_vm/views/mjit_compile.inc.erb index 1812dabf4abbd4..d9092a756d1b23 100644 --- a/tool/ruby_vm/views/mjit_compile.inc.erb +++ b/tool/ruby_vm/views/mjit_compile.inc.erb @@ -16,7 +16,6 @@ } -%> % % unsupported_insns = [ -% 'getblockparamproxy', # TODO: support this % 'defineclass', # low priority % 'opt_call_c_function', # low priority % ] diff --git a/vm.c b/vm.c index b5412d1a6d5929..939c0fc6fffc3b 100644 --- a/vm.c +++ b/vm.c @@ -323,8 +323,6 @@ extern VALUE rb_vm_invoke_bmethod(rb_execution_context_t *ec, rb_proc_t *proc, V const rb_callable_method_entry_t *me); static VALUE vm_invoke_proc(rb_execution_context_t *ec, rb_proc_t *proc, VALUE self, int argc, const VALUE *argv, VALUE block_handler); -static VALUE rb_block_param_proxy; - #include "mjit.h" #include "vm_insnhelper.h" #include "vm_exec.h" @@ -352,6 +350,7 @@ rb_next_class_serial(void) VALUE rb_cRubyVM; VALUE rb_cThread; VALUE rb_mRubyVMFrozenCore; +VALUE rb_block_param_proxy; #define ruby_vm_redefined_flag GET_VM()->redefined_flag VALUE ruby_vm_const_missing_count = 0; diff --git a/vm_insnhelper.h b/vm_insnhelper.h index 98aee9d46c9b18..59c82e5d76f791 100644 --- a/vm_insnhelper.h +++ b/vm_insnhelper.h @@ -14,6 +14,8 @@ RUBY_SYMBOL_EXPORT_BEGIN +RUBY_EXTERN VALUE rb_block_param_proxy; + RUBY_EXTERN VALUE ruby_vm_const_missing_count; RUBY_EXTERN rb_serial_t ruby_vm_global_method_state; RUBY_EXTERN rb_serial_t ruby_vm_global_constant_state; From 2553608c3b8dde72e8255e2306b5208813fff461 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 14 Jul 2019 17:59:24 +0900 Subject: [PATCH 084/452] Removed binop macro which has not been used --- complex.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/complex.c b/complex.c index 313e5641860cf5..44fd65756c423b 100644 --- a/complex.c +++ b/complex.c @@ -45,13 +45,6 @@ static ID id_abs, id_arg, #define f_boolcast(x) ((x) ? Qtrue : Qfalse) -#define binop(n,op) \ -inline static VALUE \ -f_##n(VALUE x, VALUE y)\ -{\ - return rb_funcall(x, (op), 1, y);\ -} - #define fun1(n) \ inline static VALUE \ f_##n(VALUE x)\ From 45dfd4c09d399124ddc7abd1ae24e1e64019b333 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Sun, 14 Jul 2019 18:08:47 +0900 Subject: [PATCH 085/452] Make export declaration place more consistent --- vm_core.h | 1 + vm_insnhelper.h | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/vm_core.h b/vm_core.h index 4993ef83eda78b..8ebdadb08a0e77 100644 --- a/vm_core.h +++ b/vm_core.h @@ -1034,6 +1034,7 @@ VALUE rb_iseq_coverage(const rb_iseq_t *iseq); RUBY_EXTERN VALUE rb_cISeq; RUBY_EXTERN VALUE rb_cRubyVM; RUBY_EXTERN VALUE rb_mRubyVMFrozenCore; +RUBY_EXTERN VALUE rb_block_param_proxy; RUBY_SYMBOL_EXPORT_END #define GetProcPtr(obj, ptr) \ diff --git a/vm_insnhelper.h b/vm_insnhelper.h index 59c82e5d76f791..98aee9d46c9b18 100644 --- a/vm_insnhelper.h +++ b/vm_insnhelper.h @@ -14,8 +14,6 @@ RUBY_SYMBOL_EXPORT_BEGIN -RUBY_EXTERN VALUE rb_block_param_proxy; - RUBY_EXTERN VALUE ruby_vm_const_missing_count; RUBY_EXTERN rb_serial_t ruby_vm_global_method_state; RUBY_EXTERN rb_serial_t ruby_vm_global_constant_state; From a7dd6763bd1dac7952ace46be58083dbea332a0a Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Sun, 14 Jul 2019 20:17:03 +0900 Subject: [PATCH 086/452] Increase fetchDepth to prevent checkout failure like https://dev.azure.com/rubylang/ruby/_build/results?buildId=1637 --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 1db7c120dc2ba2..7714121c739795 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -22,7 +22,7 @@ jobs: sudo apt-get build-dep ruby2.3 displayName: "Install dependencies" - checkout: self - fetchDepth: 10 + fetchDepth: 20 - script: | autoconf ./configure From 41e09ca4becff3d573a5c8049624c664311492ae Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Sun, 14 Jul 2019 20:23:29 +0900 Subject: [PATCH 087/452] addr2line.c (binary_filename): extend the buffer for NUL terminator --- addr2line.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addr2line.c b/addr2line.c index 45cae6a1324443..f6befce53e33d2 100644 --- a/addr2line.c +++ b/addr2line.c @@ -187,7 +187,7 @@ struct debug_section_definition { }; /* Avoid consuming stack as this module may be used from signal handler */ -static char binary_filename[PATH_MAX]; +static char binary_filename[PATH_MAX + 1]; static unsigned long uleb128(char **p) From 0df4a813ca8f9cb4d081c45ad91be3dd17bb06f1 Mon Sep 17 00:00:00 2001 From: Kazuhiro NISHIYAMA Date: Sun, 14 Jul 2019 20:33:41 +0900 Subject: [PATCH 088/452] NEWS: RubyVM.resolve_feature_path moved [ci skip] --- NEWS | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/NEWS b/NEWS index ed34fe82f56d90..390c7935928ef5 100644 --- a/NEWS +++ b/NEWS @@ -149,6 +149,13 @@ Regexp / String:: * Update Unicode version to 12.1.0, adding support for U+32FF SQUARE ERA NAME REIWA. [Feature #15195] +RubyVM:: + + Removed method:: + + * RubyVM.resolve_feature_path moved to + $LOAD_PATH.resolve_feature_path. [Feature #15903] [Feature #15230] + Time:: New methods:: From 1464f7a149264b02637fdd444f8a431f1692981a Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 14 Jul 2019 18:01:24 +0900 Subject: [PATCH 089/452] Expand f_abs to use particular functions directly --- complex.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/complex.c b/complex.c index 44fd65756c423b..c3e2fcc56d090b 100644 --- a/complex.c +++ b/complex.c @@ -152,7 +152,24 @@ f_sub(VALUE x, VALUE y) return rb_funcall(x, '-', 1, y); } -fun1(abs) +inline static VALUE +f_abs(VALUE x) +{ + if (RB_INTEGER_TYPE_P(x)) { + return rb_int_abs(x); + } + else if (RB_FLOAT_TYPE_P(x)) { + return rb_float_abs(x); + } + else if (RB_TYPE_P(x, T_RATIONAL)) { + return rb_rational_abs(x); + } + else if (RB_TYPE_P(x, T_COMPLEX)) { + return rb_complex_abs(x); + } + return rb_funcall(x, id_abs, 0); +} + fun1(arg) fun1(denominator) From 5bd83909b961546ff6203ad088bfffeb8c19fceb Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 14 Jul 2019 18:02:02 +0900 Subject: [PATCH 090/452] Expand f_arg to use particular functions directly --- complex.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/complex.c b/complex.c index c3e2fcc56d090b..bcdc4865953502 100644 --- a/complex.c +++ b/complex.c @@ -170,7 +170,27 @@ f_abs(VALUE x) return rb_funcall(x, id_abs, 0); } -fun1(arg) +static VALUE numeric_arg(VALUE self); +static VALUE float_arg(VALUE self); + +inline static VALUE +f_arg(VALUE x) +{ + if (RB_INTEGER_TYPE_P(x)) { + return numeric_arg(x); + } + else if (RB_FLOAT_TYPE_P(x)) { + return float_arg(x); + } + else if (RB_TYPE_P(x, T_RATIONAL)) { + return numeric_arg(x); + } + else if (RB_TYPE_P(x, T_COMPLEX)) { + return rb_complex_arg(x); + } + return rb_funcall(x, id_arg, 0); +} + fun1(denominator) inline static VALUE From 4900a10689036211da79c8189ff7eba11c8c81ee Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Sun, 14 Jul 2019 20:46:51 +0900 Subject: [PATCH 091/452] socket: use frozen string buffer when releasing GVL Thanks for the patch by normalperson (Eric Wong) [Bug #14204]. --- ext/socket/ancdata.c | 7 +++++-- internal.h | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ext/socket/ancdata.c b/ext/socket/ancdata.c index f5451c9569093c..69c766e6fd53f4 100644 --- a/ext/socket/ancdata.c +++ b/ext/socket/ancdata.c @@ -1137,6 +1137,7 @@ bsock_sendmsg_internal(VALUE sock, VALUE data, VALUE vflags, rb_io_t *fptr; struct msghdr mh; struct iovec iov; + VALUE tmp; int controls_num; #if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL) VALUE controls_str = 0; @@ -1151,6 +1152,7 @@ bsock_sendmsg_internal(VALUE sock, VALUE data, VALUE vflags, #endif StringValue(data); + tmp = rb_str_tmp_frozen_acquire(data); if (!RB_TYPE_P(controls, T_ARRAY)) { controls = rb_ary_new(); @@ -1261,8 +1263,8 @@ bsock_sendmsg_internal(VALUE sock, VALUE data, VALUE vflags, } mh.msg_iovlen = 1; mh.msg_iov = &iov; - iov.iov_base = RSTRING_PTR(data); - iov.iov_len = RSTRING_LEN(data); + iov.iov_base = RSTRING_PTR(tmp); + iov.iov_len = RSTRING_LEN(tmp); #if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL) if (controls_str) { mh.msg_control = RSTRING_PTR(controls_str); @@ -1295,6 +1297,7 @@ bsock_sendmsg_internal(VALUE sock, VALUE data, VALUE vflags, #if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL) RB_GC_GUARD(controls_str); #endif + rb_str_tmp_frozen_release(data, tmp); return SSIZET2NUM(ss); } diff --git a/internal.h b/internal.h index 4f9c5b1475aa80..0539d49f5baff0 100644 --- a/internal.h +++ b/internal.h @@ -2080,8 +2080,6 @@ VALUE rb_id_quote_unprintable(ID); char *rb_str_fill_terminator(VALUE str, const int termlen); void rb_str_change_terminator_length(VALUE str, const int oldtermlen, const int termlen); VALUE rb_str_locktmp_ensure(VALUE str, VALUE (*func)(VALUE), VALUE arg); -VALUE rb_str_tmp_frozen_acquire(VALUE str); -void rb_str_tmp_frozen_release(VALUE str, VALUE tmp); VALUE rb_str_chomp_string(VALUE str, VALUE chomp); #ifdef RUBY_ENCODING_H VALUE rb_external_str_with_enc(VALUE str, rb_encoding *eenc); @@ -2376,6 +2374,8 @@ VALUE rb_gcd_gmp(VALUE x, VALUE y); int rb_grantpt(int fd); /* string.c (export) */ +VALUE rb_str_tmp_frozen_acquire(VALUE str); +void rb_str_tmp_frozen_release(VALUE str, VALUE tmp); #ifdef RUBY_ENCODING_H /* internal use */ VALUE rb_setup_fake_str(struct RString *fake_str, const char *name, long len, rb_encoding *enc); From e8700b596b907ed0db80ccd398d9dfe1f0fe6dd1 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 14 Jul 2019 20:52:49 +0900 Subject: [PATCH 092/452] Check the result of String#-@ --- test/ruby/test_string.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb index 26de52dedbffb9..611bb797bc979a 100644 --- a/test/ruby/test_string.rb +++ b/test/ruby/test_string.rb @@ -3177,18 +3177,20 @@ def test_uplus_minus def test_uminus_no_freeze_not_bare str = @cls.new("foo") - -str + assert_instance_of(@cls, -str) assert_equal(false, str.frozen?) str = @cls.new("foo") str.instance_variable_set(:@iv, 1) - -str + assert_instance_of(@cls, -str) assert_equal(false, str.frozen?) + assert_equal(1, str.instance_variable_get(:@iv)) str = @cls.new("foo") str.taint - -str + assert_instance_of(@cls, -str) assert_equal(false, str.frozen?) + assert_predicate(str, :tainted?) end def test_ord From 20a3fb3c4b7c564ee7809ac1ed036b4874e47e26 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Sun, 14 Jul 2019 21:34:32 +0900 Subject: [PATCH 093/452] Add a /* fall through */ comment --- parse.y | 1 + 1 file changed, 1 insertion(+) diff --git a/parse.y b/parse.y index 7445e4ae495ba4..e1cd2014de2074 100644 --- a/parse.y +++ b/parse.y @@ -8428,6 +8428,7 @@ parse_gvar(struct parser_params *p, const enum lex_state_e last_state) set_yylval_noname(); return tGVAR; } + /* fall through */ case '0': tokadd(p, '$'); } From d8cc41c43be65dd4b17e7a6e38f5a7fdf2b247d6 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Sun, 14 Jul 2019 21:48:22 +0900 Subject: [PATCH 094/452] Fix a wrong buffer size to avoid stack corruption [Bug #15986] --- mjit_worker.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mjit_worker.c b/mjit_worker.c index 9f8a5f0bbd22ba..44123e28e1bf2f 100644 --- a/mjit_worker.c +++ b/mjit_worker.c @@ -1049,8 +1049,8 @@ convert_unit_to_func(struct rb_mjit_unit *unit) if (FIXNUM_P(unit->iseq->body->location.first_lineno)) // FIX2INT may fallback to rb_num2long(), which is a method call and dangerous in MJIT worker. So using only FIX2LONG. iseq_lineno = FIX2LONG(unit->iseq->body->location.first_lineno); - char *iseq_label = alloca(RSTRING_LEN(unit->iseq->body->location.label)); - char *iseq_path = alloca(RSTRING_LEN(rb_iseq_path(unit->iseq))); + char *iseq_label = alloca(RSTRING_LEN(unit->iseq->body->location.label) + 1); + char *iseq_path = alloca(RSTRING_LEN(rb_iseq_path(unit->iseq)) + 1); strcpy(iseq_label, RSTRING_PTR(unit->iseq->body->location.label)); strcpy(iseq_path, RSTRING_PTR(rb_iseq_path(unit->iseq))); From be082e28003543eff5ff07cf5261dbf7b6278a50 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Sun, 14 Jul 2019 16:56:39 +0900 Subject: [PATCH 095/452] Try to sync with commit history for default gems. --- tool/sync_default_gems.rb | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/tool/sync_default_gems.rb b/tool/sync_default_gems.rb index 34cdfaedeec296..9d3089250a651e 100644 --- a/tool/sync_default_gems.rb +++ b/tool/sync_default_gems.rb @@ -228,6 +228,17 @@ def sync_default_gems(gem) end end +def sync_default_gems_with_commits(gem, range) + puts "Sync #{$repositories[gem.to_sym]} with commit history." + + IO.popen(%W"git remote") do |f| + unless f.read.split.include?(gem) + `git remote add #{gem} git@github.com:#{$repositories[gem.to_sym]}.git` + `git fetch #{gem}` + end + end +end + def sync_lib(repo) unless File.directory?("../#{repo}") abort "Expected '../#{repo}' (#{File.expand_path("../#{repo}")}) to be a directory, but it wasn't." @@ -278,5 +289,9 @@ def update_default_gems(gem) when "all" $repositories.keys.each{|gem| sync_default_gems(gem.to_s)} else - sync_default_gems(ARGV[0]) + if ARGV[1] + sync_default_gems_with_commits(ARGV[0], ARGV[1]) + else + sync_default_gems(ARGV[0]) + end end From 265e94a7fa96c918c4278ae58bf6e5cdb018906d Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Sun, 14 Jul 2019 17:15:06 +0900 Subject: [PATCH 096/452] Added chrry-pick feature from upstream repository. --- tool/sync_default_gems.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tool/sync_default_gems.rb b/tool/sync_default_gems.rb index 9d3089250a651e..9b882bb264b8fb 100644 --- a/tool/sync_default_gems.rb +++ b/tool/sync_default_gems.rb @@ -237,6 +237,17 @@ def sync_default_gems_with_commits(gem, range) `git fetch #{gem}` end end + + IO.popen(%W"git log --format=%H #{range}") do |commits| + commits.read.split.reverse.each do |commit| + puts "Pick #{commit} from #{$repositories[gem.to_sym]}." + `git cherry-pick #{commit}` + unless $?.success? + puts "Failed to pick #{commit}." + break + end + end + end end def sync_lib(repo) From 46491af74ca2266aae0157b79a44898a2f4b728d Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Sun, 14 Jul 2019 21:31:16 +0900 Subject: [PATCH 097/452] Modified commit message with upstream repository name. --- tool/sync_default_gems.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tool/sync_default_gems.rb b/tool/sync_default_gems.rb index 9b882bb264b8fb..7f5e597f24609a 100644 --- a/tool/sync_default_gems.rb +++ b/tool/sync_default_gems.rb @@ -246,6 +246,8 @@ def sync_default_gems_with_commits(gem, range) puts "Failed to pick #{commit}." break end + + `git filter-branch --msg-filter 'echo "[#{$repositories[gem.to_sym]}]" && echo && cat' -- HEAD~1..HEAD` end end end From c8e1be6f1fed7f4f54d5ac1f7ae1ebe2c0f60dbe Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Sun, 14 Jul 2019 17:53:14 +0900 Subject: [PATCH 098/452] Skip merge commit with rubygems and bundler. --- tool/sync_default_gems.rb | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tool/sync_default_gems.rb b/tool/sync_default_gems.rb index 7f5e597f24609a..5c9ee9a85651af 100644 --- a/tool/sync_default_gems.rb +++ b/tool/sync_default_gems.rb @@ -238,12 +238,18 @@ def sync_default_gems_with_commits(gem, range) end end - IO.popen(%W"git log --format=%H #{range}") do |commits| - commits.read.split.reverse.each do |commit| - puts "Pick #{commit} from #{$repositories[gem.to_sym]}." - `git cherry-pick #{commit}` + IO.popen(%W"git log --format=%H,%s #{range}") do |f| + commits = f.read.split("\n").reverse.map{|commit| commit.split(',')} + commits.each do |sha, subject| + puts "Pick #{sha} from #{$repositories[gem.to_sym]}." + if subject =~ /^Merge/ + puts "Skip #{sha}. Because It was merge commit" + next + end + + `git cherry-pick #{sha}` unless $?.success? - puts "Failed to pick #{commit}." + puts "Failed to pick #{sha}" break end From 8e6a68c18edeb8dfef494862093539d987b6ad6a Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Sun, 14 Jul 2019 21:49:10 +0900 Subject: [PATCH 099/452] Use force flag for filter-branch. --- tool/sync_default_gems.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tool/sync_default_gems.rb b/tool/sync_default_gems.rb index 5c9ee9a85651af..27d8dbf32aef3d 100644 --- a/tool/sync_default_gems.rb +++ b/tool/sync_default_gems.rb @@ -253,7 +253,7 @@ def sync_default_gems_with_commits(gem, range) break end - `git filter-branch --msg-filter 'echo "[#{$repositories[gem.to_sym]}]" && echo && cat' -- HEAD~1..HEAD` + `git filter-branch -f --msg-filter 'echo "[#{$repositories[gem.to_sym]}]" && echo && cat' -- HEAD~1..HEAD` end end end From a3493521a55e32081520be805a764fd2ad43fe7b Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Sun, 14 Jul 2019 21:52:49 +0900 Subject: [PATCH 100/452] abort sync commit history when it failed to modify commit message. --- tool/sync_default_gems.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tool/sync_default_gems.rb b/tool/sync_default_gems.rb index 27d8dbf32aef3d..897fa79b94831f 100644 --- a/tool/sync_default_gems.rb +++ b/tool/sync_default_gems.rb @@ -254,6 +254,10 @@ def sync_default_gems_with_commits(gem, range) end `git filter-branch -f --msg-filter 'echo "[#{$repositories[gem.to_sym]}]" && echo && cat' -- HEAD~1..HEAD` + unless $?.success? + puts "Failed to modify commit message of #{sha}" + break + end end end end From 085d0e5ccb7cecb1f761c1d3c72caeeedafc7d04 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Sun, 14 Jul 2019 21:56:39 +0900 Subject: [PATCH 101/452] ruby.c (name_match_p): remove unnecessary condition It always returns immediately when len was decremented to zero. So len is always positive. This change will suppress Coverity Scan warning. --- ruby.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ruby.c b/ruby.c index c32055a203610e..2610cf2387b2d7 100644 --- a/ruby.c +++ b/ruby.c @@ -834,7 +834,7 @@ static int name_match_p(const char *name, const char *str, size_t len) { if (len == 0) return 0; - do { + while (1) { while (TOLOWER(*str) == *name) { if (!--len || !*++str) return 1; ++name; @@ -844,8 +844,7 @@ name_match_p(const char *name, const char *str, size_t len) if (*name != '-' && *name != '_') return 0; ++name; ++str; - } while (len > 0); - return !*name; + } } #define NAME_MATCH_P(name, str, len) \ From b7ec77f3614d7a89a47466f240d53abc0f967d19 Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Sun, 14 Jul 2019 22:04:27 +0900 Subject: [PATCH 102/452] fix typos. --- proc.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/proc.c b/proc.c index 217d228a8a31db..2d931e77f06d71 100644 --- a/proc.c +++ b/proc.c @@ -3423,7 +3423,7 @@ rb_method_compose_to_right(VALUE self, VALUE g) * $a = []; def m1(&b) b.call; $a << :m1 end; def m2() m1(&proc { next }); $a << :m2 end; m2; p $a * #=> [:m1, :m2] * - * # +return+, +break+ and +next+ in the subby lambda exits the block. + * # +return+, +break+ and +next+ in the stubby lambda exits the block. * # (+lambda+ method behaves same.) * # (The block is given for stubby lambda syntax and embraced by +m2+.) * $a = []; def m1(&b) b.call; $a << :m1 end; def m2() m1(&-> { return }); $a << :m2 end; m2; p $a @@ -3510,18 +3510,19 @@ rb_method_compose_to_right(VALUE self, VALUE g) * a proc by the & operator, and therefore con be * consumed by iterators. * - * class Greater - * def initialize(greating) - * @greating = greating + + * class Greeter + * def initialize(greeting) + * @greeting = greeting * end * * def to_proc - * proc {|name| "#{@greating}, #{name}!" } + * proc {|name| "#{@greeting}, #{name}!" } * end * end * - * hi = Greater.new("Hi") - * hey = Greater.new("Hey") + * hi = Greeter.new("Hi") + * hey = Greeter.new("Hey") * ["Bob", "Jane"].map(&hi) #=> ["Hi, Bob!", "Hi, Jane!"] * ["Bob", "Jane"].map(&hey) #=> ["Hey, Bob!", "Hey, Jane!"] * @@ -3557,7 +3558,7 @@ rb_method_compose_to_right(VALUE self, VALUE g) * def m1(&b) b end; def m2(); m1 { return } end; m2.call # LocalJumpError * def m1(&b) b end; def m2(); m1 { break } end; m2.call # LocalJumpError * - * Since +return+ and +break+ exists the block itself in lambdas, + * Since +return+ and +break+ exits the block itself in lambdas, * lambdas cannot be orphaned. * */ From 7ac7685fa7a266e74102ac8ed067035ebfebe6e6 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Sun, 14 Jul 2019 22:12:33 +0900 Subject: [PATCH 103/452] Simplify link_o_to_so arguments by C99 compound literal for array and non-constant array initializer --- mjit_worker.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/mjit_worker.c b/mjit_worker.c index 44123e28e1bf2f..c5df0b7fadde67 100644 --- a/mjit_worker.c +++ b/mjit_worker.c @@ -1079,9 +1079,7 @@ convert_unit_to_func(struct rb_mjit_unit *unit) #else // splitting .c -> .o step and .o -> .so step, to cache .o files in the future if ((success = compile_c_to_o(c_file, o_file)) != false) { - const char *o_files[2] = { NULL, NULL }; - o_files[0] = o_file; - success = link_o_to_so(o_files, so_file); + success = link_o_to_so((const char *[]){ o_file, NULL }, so_file); // Always set o_file for compaction. The value is also used for lazy deletion. unit->o_file = strdup(o_file); From 5d606b5174a8842a6cf6397ee9c9e07736d6af8f Mon Sep 17 00:00:00 2001 From: Kazuhiro NISHIYAMA Date: Sun, 14 Jul 2019 21:56:45 +0900 Subject: [PATCH 104/452] doc/globals.rdoc: Add TOPLEVEL_BINDING [ci skip] --- doc/globals.rdoc | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/globals.rdoc b/doc/globals.rdoc index 201fe7b387e43c..6e5ec68aafe4f0 100644 --- a/doc/globals.rdoc +++ b/doc/globals.rdoc @@ -60,6 +60,7 @@ ENV:: The hash contains current environment variables. ARGF:: The virtual concatenation of the files given on command line (or from $stdin if no files were given). ARGV:: An Array of command line arguments given for the script. DATA:: The file object of the script, pointing just after __END__. +TOPLEVEL_BINDING:: The Binding of the top level scope. RUBY_VERSION:: The Ruby language version. RUBY_RELEASE_DATE:: The release date string. RUBY_PLATFORM:: The platform identifier. From 9a402cf61f5ab86944c52466ae2e4db95bcc5f90 Mon Sep 17 00:00:00 2001 From: Kazuhiro NISHIYAMA Date: Sun, 14 Jul 2019 21:57:44 +0900 Subject: [PATCH 105/452] doc/globals.rdoc: Add RUBY_COPYRIGHT [ci skip] --- doc/globals.rdoc | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/globals.rdoc b/doc/globals.rdoc index 6e5ec68aafe4f0..6ec7d9a0a700fa 100644 --- a/doc/globals.rdoc +++ b/doc/globals.rdoc @@ -64,6 +64,7 @@ TOPLEVEL_BINDING:: The Binding of the top level scope. RUBY_VERSION:: The Ruby language version. RUBY_RELEASE_DATE:: The release date string. RUBY_PLATFORM:: The platform identifier. +RUBY_COPYRIGHT:: The copyright string for ruby. RUBY_ENGINE:: The name of the Ruby implementation. RUBY_ENGINE_VERSION:: The version of the Ruby implementation. RUBY_DESCRIPTION:: The same as ruby --version, a String describing various aspects of the Ruby implementation. From ab31e13e7513ffb08af41b0fc5f779c8d4a78fc2 Mon Sep 17 00:00:00 2001 From: Kazuhiro NISHIYAMA Date: Sun, 14 Jul 2019 22:03:52 +0900 Subject: [PATCH 106/452] doc/globals.rdoc: Add RUBY_PATCHLEVEL [ci skip] --- doc/globals.rdoc | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/globals.rdoc b/doc/globals.rdoc index 6ec7d9a0a700fa..f880ed005e0454 100644 --- a/doc/globals.rdoc +++ b/doc/globals.rdoc @@ -64,6 +64,7 @@ TOPLEVEL_BINDING:: The Binding of the top level scope. RUBY_VERSION:: The Ruby language version. RUBY_RELEASE_DATE:: The release date string. RUBY_PLATFORM:: The platform identifier. +RUBY_PATCHLEVEL:: The patchlevel for this ruby. If this is a development build of ruby the patchlevel will be -1. RUBY_COPYRIGHT:: The copyright string for ruby. RUBY_ENGINE:: The name of the Ruby implementation. RUBY_ENGINE_VERSION:: The version of the Ruby implementation. From d0f113f6c169a618c41a857d2536c89b86c58d75 Mon Sep 17 00:00:00 2001 From: Kazuhiro NISHIYAMA Date: Sun, 14 Jul 2019 22:05:22 +0900 Subject: [PATCH 107/452] doc/globals.rdoc: Add RUBY_REVISION [ci skip] --- doc/globals.rdoc | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/globals.rdoc b/doc/globals.rdoc index f880ed005e0454..d3c3553d4da535 100644 --- a/doc/globals.rdoc +++ b/doc/globals.rdoc @@ -65,6 +65,7 @@ RUBY_VERSION:: The Ruby language version. RUBY_RELEASE_DATE:: The release date string. RUBY_PLATFORM:: The platform identifier. RUBY_PATCHLEVEL:: The patchlevel for this ruby. If this is a development build of ruby the patchlevel will be -1. +RUBY_REVISION:: The GIT commit hash for this ruby. RUBY_COPYRIGHT:: The copyright string for ruby. RUBY_ENGINE:: The name of the Ruby implementation. RUBY_ENGINE_VERSION:: The version of the Ruby implementation. From 49362ddac60bb9d348cbcd8b7c003f52f5ffa1f5 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Sun, 14 Jul 2019 22:20:47 +0900 Subject: [PATCH 108/452] Add a /* fall through */ comment --- vm_insnhelper.c | 1 + 1 file changed, 1 insertion(+) diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 93b1ebfe7ac39b..c5584d4d4053d8 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -737,6 +737,7 @@ cref_replace_with_duplicated_cref_each_frame(const VALUE *vptr, int can_be_svar, if (can_be_svar) { return cref_replace_with_duplicated_cref_each_frame((const VALUE *)&((struct vm_svar *)v)->cref_or_me, FALSE, v); } + /* fall through */ case imemo_ment: rb_bug("cref_replace_with_duplicated_cref_each_frame: unreachable"); default: From 36f2d9bac2c0e6dacc0488448c05dfde6ef2b23a Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Sun, 14 Jul 2019 22:46:34 +0900 Subject: [PATCH 109/452] numeric.c (fix_cmp): remove a unreachable return statement --- numeric.c | 1 - 1 file changed, 1 deletion(-) diff --git a/numeric.c b/numeric.c index 78c4c335423e5c..9bf5e0a2053afa 100644 --- a/numeric.c +++ b/numeric.c @@ -4196,7 +4196,6 @@ fix_cmp(VALUE x, VALUE y) else { return rb_num_coerce_cmp(x, y, id_cmp); } - return rb_num_coerce_cmp(x, y, id_cmp); } VALUE From 0bf829c17b92c608bc374f03a63b89a940d61955 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Sun, 14 Jul 2019 23:02:23 +0900 Subject: [PATCH 110/452] transcode.c (rb_trans_conv): remove unnecessary assignments This change will suppress Coverity Scan warnings --- transcode.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/transcode.c b/transcode.c index 5f9e4e96004e5e..0f72a2d735ee8c 100644 --- a/transcode.c +++ b/transcode.c @@ -1194,7 +1194,6 @@ rb_trans_conv(rb_econv_t *ec, if (ec->elems[0].last_result == econv_after_output) ec->elems[0].last_result = econv_source_buffer_empty; - needreport_index = -1; for (i = ec->num_trans-1; 0 <= i; i--) { switch (ec->elems[i].last_result) { case econv_invalid_byte_sequence: @@ -1203,7 +1202,6 @@ rb_trans_conv(rb_econv_t *ec, case econv_after_output: case econv_finished: sweep_start = i+1; - needreport_index = i; goto found_needreport; case econv_destination_buffer_full: From 85497744305fcd7ff2b7768867f68c8fac03c8a0 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Sun, 14 Jul 2019 22:05:39 +0900 Subject: [PATCH 111/452] Tweak upstream information of upstream commit. --- tool/sync_default_gems.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tool/sync_default_gems.rb b/tool/sync_default_gems.rb index 897fa79b94831f..93031ac849e95d 100644 --- a/tool/sync_default_gems.rb +++ b/tool/sync_default_gems.rb @@ -253,7 +253,9 @@ def sync_default_gems_with_commits(gem, range) break end - `git filter-branch -f --msg-filter 'echo "[#{$repositories[gem.to_sym]}]" && echo && cat' -- HEAD~1..HEAD` + prefix = "[#{($repositories[gem.to_sym])}]".gsub(/\//, '\/') + suffix = "https://github.com/#{($repositories[gem.to_sym])}/commit/#{sha[0,10]}" + `git filter-branch -f --msg-filter 'sed "1s/^/#{prefix} /" && echo && echo #{suffix}' -- HEAD~1..HEAD` unless $?.success? puts "Failed to modify commit message of #{sha}" break From 864e2a95d90d547fe83c847c01daa1c3ba4503de Mon Sep 17 00:00:00 2001 From: Kouhei Sutou Date: Mon, 15 Apr 2019 11:05:20 +0900 Subject: [PATCH 112/452] [ruby/csv] Bump version https://github.com/ruby/csv/commit/312f844693 --- lib/csv/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/csv/version.rb b/lib/csv/version.rb index b2b0ad743a93d1..22a6df4be93f3d 100644 --- a/lib/csv/version.rb +++ b/lib/csv/version.rb @@ -2,5 +2,5 @@ class CSV # The version of the installed library. - VERSION = "3.0.9" + VERSION = "3.1.0" end From 9171f833054cd47842e12fc0fd3cc1df704a9192 Mon Sep 17 00:00:00 2001 From: Kazuhiro NISHIYAMA Date: Mon, 15 Apr 2019 12:12:26 +0900 Subject: [PATCH 113/452] [ruby/csv] Refactor range in delete_suffix (#85) https://github.com/ruby/csv/commit/7ff57a50e8 --- lib/csv/delete_suffix.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/csv/delete_suffix.rb b/lib/csv/delete_suffix.rb index e0b40c7aab4e8a..d4577189970198 100644 --- a/lib/csv/delete_suffix.rb +++ b/lib/csv/delete_suffix.rb @@ -7,7 +7,7 @@ module DeleteSuffix refine String do def delete_suffix(suffix) if end_with?(suffix) - self[0..(-(suffix.size + 1))] + self[0...-suffix.size] else self end From 8392592a0a33bb9103a7aa968389fe50e304e062 Mon Sep 17 00:00:00 2001 From: Kouhei Sutou Date: Wed, 17 Apr 2019 22:02:40 +0900 Subject: [PATCH 114/452] [ruby/csv] Don't raise on eof? GitHub: fix #86 Reported by krororo. Thanks!!! https://github.com/ruby/csv/commit/5a8d9d9297 --- lib/csv.rb | 11 +++++++++++ test/csv/parse/test_invalid.rb | 3 +++ 2 files changed, 14 insertions(+) diff --git a/lib/csv.rb b/lib/csv.rb index 1239554ad62ad2..ff317d899579af 100644 --- a/lib/csv.rb +++ b/lib/csv.rb @@ -955,6 +955,8 @@ def initialize(data, strip: strip, } @parser = nil + @parser_enumerator = nil + @eof_error = nil @writer_options = { encoding: @encoding, @@ -1156,9 +1158,13 @@ def to_io end def eof? + return false if @eof_error begin parser_enumerator.peek false + rescue MalformedCSVError => error + @eof_error = error + false rescue StopIteration true end @@ -1169,6 +1175,7 @@ def eof? def rewind @parser = nil @parser_enumerator = nil + @eof_error = nil @writer.rewind if @writer @io.rewind end @@ -1264,6 +1271,10 @@ def header_row? # The data source must be open for reading. # def shift + if @eof_error + eof_error, @eof_error = @eof_error, nil + raise eof_error + end begin parser_enumerator.next rescue StopIteration diff --git a/test/csv/parse/test_invalid.rb b/test/csv/parse/test_invalid.rb index b84707c2cc13a9..9dfd0813801d16 100644 --- a/test/csv/parse/test_invalid.rb +++ b/test/csv/parse/test_invalid.rb @@ -25,12 +25,15 @@ def test_ignore_invalid_line csv.shift) assert_equal(CSV::Row.new(headers, ["aaa", "bbb", "ccc"]), csv.shift) + assert_equal(false, csv.eof?) error = assert_raise(CSV::MalformedCSVError) do csv.shift end assert_equal("Illegal quoting in line 3.", error.message) + assert_equal(false, csv.eof?) assert_equal(CSV::Row.new(headers, ["ggg", "hhh", "iii"]), csv.shift) + assert_equal(true, csv.eof?) end end From c8b82998d4fbbb8988b0f2458327697918a9e1a2 Mon Sep 17 00:00:00 2001 From: Kouhei Sutou Date: Wed, 17 Apr 2019 22:05:12 +0900 Subject: [PATCH 115/452] [ruby/csv] Bump version https://github.com/ruby/csv/commit/3976985008 --- lib/csv/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/csv/version.rb b/lib/csv/version.rb index 22a6df4be93f3d..ce55373f02974d 100644 --- a/lib/csv/version.rb +++ b/lib/csv/version.rb @@ -2,5 +2,5 @@ class CSV # The version of the installed library. - VERSION = "3.1.0" + VERSION = "3.1.1" end From fe40841bfb031d278daea5b05fb13084f887fec5 Mon Sep 17 00:00:00 2001 From: hayashiyoshino Date: Fri, 19 Apr 2019 20:59:38 +0900 Subject: [PATCH 116/452] [ruby/csv] add document of strip (#88) * add document of strip * modify typo https://github.com/ruby/csv/commit/de0257dc31 --- lib/csv.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/csv.rb b/lib/csv.rb index ff317d899579af..086f0351e66843 100644 --- a/lib/csv.rb +++ b/lib/csv.rb @@ -888,7 +888,11 @@ def self.table(path, **options) # :write_converters:: TODO # :write_nil_value:: TODO # :write_empty_value:: TODO - # :strip:: TODO + # :strip:: When set to a +true+ value, CSV will + # strip "\t\r\n\f\v" around the values. + # If you specify a string instead of + # +true+, CSV will strip string. The + # length of string must be 1. # # See CSV::DEFAULT_OPTIONS for the default settings. # From 75620c804ea47de040016ccf9766c016f2934df2 Mon Sep 17 00:00:00 2001 From: Masafumi Koba <473530+ybiquitous@users.noreply.github.com> Date: Sat, 20 Apr 2019 00:42:40 +0900 Subject: [PATCH 117/452] [ruby/csv] Add options doc: :write_converters, :write_nil_value, :write_empty_value (#87) https://github.com/ruby/csv/commit/5923ee08b7 --- lib/csv.rb | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/csv.rb b/lib/csv.rb index 086f0351e66843..44fbd212b02933 100644 --- a/lib/csv.rb +++ b/lib/csv.rb @@ -885,9 +885,19 @@ def self.table(path, **options) # blank string field is replaced by # the set object. # :quote_empty:: TODO - # :write_converters:: TODO - # :write_nil_value:: TODO - # :write_empty_value:: TODO + # :write_converters:: Converts values on each line with the + # specified Proc object(s), + # which receive a String value + # and return a String or +nil+ + # value. + # When an array is specified, each + # converter will be applied in order. + # :write_nil_value:: When a String value, +nil+ + # value(s) on each line will be replaced + # with the specified value. + # :write_empty_value:: When a String or +nil+ value, + # empty value(s) on each line will be + # replaced with the specified value. # :strip:: When set to a +true+ value, CSV will # strip "\t\r\n\f\v" around the values. # If you specify a string instead of From 8c0edbd79d59789b9543d00322d6bde72f86bfda Mon Sep 17 00:00:00 2001 From: kawa_tech <49791334+kaerunote@users.noreply.github.com> Date: Sat, 20 Apr 2019 16:37:52 +0900 Subject: [PATCH 118/452] [ruby/csv] add options doc :quote_empty (#89) https://github.com/ruby/csv/commit/5ca8d79f60 --- lib/csv.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/csv.rb b/lib/csv.rb index 44fbd212b02933..aaa0c4823148f2 100644 --- a/lib/csv.rb +++ b/lib/csv.rb @@ -884,7 +884,10 @@ def self.table(path, **options) # :empty_value:: When set an object, any values of a # blank string field is replaced by # the set object. - # :quote_empty:: TODO + # :quote_empty:: When set to a +true+ value, CSV will + # quote empty values with double quotes. + # When +false+, CSV will emit an + # empty string for an empty field value. # :write_converters:: Converts values on each line with the # specified Proc object(s), # which receive a String value From 198281a71d95c1a48445dc6e913bc1bd62350054 Mon Sep 17 00:00:00 2001 From: Kouhei Sutou Date: Tue, 23 Apr 2019 05:54:44 +0900 Subject: [PATCH 119/452] [ruby/csv] Fix a bug that strip: true removes newlines https://github.com/ruby/csv/commit/5540d35a30 --- lib/csv/parser.rb | 2 +- test/csv/parse/test_strip.rb | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/lib/csv/parser.rb b/lib/csv/parser.rb index 85252203e42eb0..2ef2a28ff3e118 100644 --- a/lib/csv/parser.rb +++ b/lib/csv/parser.rb @@ -429,7 +429,7 @@ def prepare_strip end @need_robust_parsing = true elsif @strip - strip_values = " \t\r\n\f\v" + strip_values = " \t\f\v" @escaped_strip = strip_values.encode(@encoding) if @quote_character @strip_value = Regexp.new("[#{strip_values}]+".encode(@encoding)) diff --git a/test/csv/parse/test_strip.rb b/test/csv/parse/test_strip.rb index 160407bd94f22b..0255bb9a302034 100644 --- a/test/csv/parse/test_strip.rb +++ b/test/csv/parse/test_strip.rb @@ -45,4 +45,34 @@ def test_no_quote strip: %Q{"}, quote_char: nil)) end + + def test_do_not_strip_cr + assert_equal([ + ["a", "b "], + ["a", "b "], + ], + CSV.parse(%Q{"a" ,"b " \r} + + %Q{"a" ,"b " \r}, + strip: true)) + end + + def test_do_not_strip_lf + assert_equal([ + ["a", "b "], + ["a", "b "], + ], + CSV.parse(%Q{"a" ,"b " \n} + + %Q{"a" ,"b " \n}, + strip: true)) + end + + def test_do_not_strip_crlf + assert_equal([ + ["a", "b "], + ["a", "b "], + ], + CSV.parse(%Q{"a" ,"b " \r\n} + + %Q{"a" ,"b " \r\n}, + strip: true)) + end end From 3fd086ed565e6156db5e64a5c42469db331a6237 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Sun, 14 Jul 2019 23:04:16 +0900 Subject: [PATCH 120/452] string.c (str_succ): remove a unnecessary assignment This change will suppress Coverity Scan warnings --- string.c | 1 - 1 file changed, 1 deletion(-) diff --git a/string.c b/string.c index 64bb6093c6dadd..aadc7253979e94 100644 --- a/string.c +++ b/string.c @@ -4142,7 +4142,6 @@ str_succ(VALUE str) if (neighbor == NEIGHBOR_NOT_CHAR && last_alnum) { if (ISALPHA(*last_alnum) ? ISDIGIT(*s) : ISDIGIT(*last_alnum) ? ISALPHA(*s) : 0) { - s = last_alnum; break; } } From 43c337dfc18676e95f9fb9b1d6bf3beb3ec6b306 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Sun, 14 Jul 2019 23:04:48 +0900 Subject: [PATCH 121/452] string.c (str_succ): refactoring Use more communicative variable name --- string.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/string.c b/string.c index aadc7253979e94..fcaf280baa1050 100644 --- a/string.c +++ b/string.c @@ -4125,7 +4125,7 @@ str_succ(VALUE str) { rb_encoding *enc; char *sbeg, *s, *e, *last_alnum = 0; - int c = -1; + int found_alnum = 0; long l, slen; char carry[ONIGENC_CODE_TO_MBC_MAXLEN] = "\1"; long carry_pos = 0, carry_len = 1; @@ -4158,11 +4158,11 @@ str_succ(VALUE str) last_alnum = s; break; } - c = 1; + found_alnum = 1; carry_pos = s - sbeg; carry_len = l; } - if (c == -1) { /* str contains no alnum */ + if (!found_alnum) { /* str contains no alnum */ s = e; while ((s = rb_enc_prev_char(sbeg, s, e, enc)) != 0) { enum neighbor_char neighbor; From 80da68db1e770c877782cdf571d96fd89e7774dd Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Sun, 14 Jul 2019 23:36:23 +0900 Subject: [PATCH 122/452] Add a /* fall through */ comment --- ext/openssl/ossl_ssl.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ext/openssl/ossl_ssl.c b/ext/openssl/ossl_ssl.c index 7996f227b6e49a..f25dc959b14107 100644 --- a/ext/openssl/ossl_ssl.c +++ b/ext/openssl/ossl_ssl.c @@ -1871,6 +1871,7 @@ ossl_ssl_read_internal(int argc, VALUE *argv, VALUE self, int nonblock) rb_eof_error(); } } + /* fall through */ default: ossl_raise(eSSLError, "SSL_read"); } From b4975693ed1ac46be081e02d82a6dfb7aea0e1c0 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Mon, 15 Jul 2019 00:07:32 +0900 Subject: [PATCH 123/452] process.c (p_sys_setregid, p_sys_setresgid): remove unused tmp buffer To suppress Coverity Scan warning --- process.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/process.c b/process.c index 530bf2673eff3b..c732fd2cd6b021 100644 --- a/process.c +++ b/process.c @@ -6099,11 +6099,9 @@ static VALUE p_sys_setregid(VALUE obj, VALUE rid, VALUE eid) { rb_gid_t rgid, egid; - PREPARE_GETGRNAM; check_gid_switch(); rgid = OBJ2GID(rid); egid = OBJ2GID(eid); - FINISH_GETGRNAM; if (setregid(rgid, egid) != 0) rb_sys_fail(0); return Qnil; } @@ -6127,12 +6125,10 @@ static VALUE p_sys_setresgid(VALUE obj, VALUE rid, VALUE eid, VALUE sid) { rb_gid_t rgid, egid, sgid; - PREPARE_GETGRNAM; check_gid_switch(); rgid = OBJ2GID(rid); egid = OBJ2GID(eid); sgid = OBJ2GID(sid); - FINISH_GETGRNAM; if (setresgid(rgid, egid, sgid) != 0) rb_sys_fail(0); return Qnil; } From 721fc849370d88b87703b00ed1442295c1a94027 Mon Sep 17 00:00:00 2001 From: git Date: Mon, 15 Jul 2019 00:08:33 +0900 Subject: [PATCH 124/452] * 2019-07-15 --- version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.h b/version.h index 0a845f1ead3740..ff89d70166dd30 100644 --- a/version.h +++ b/version.h @@ -6,7 +6,7 @@ #define RUBY_RELEASE_YEAR 2019 #define RUBY_RELEASE_MONTH 7 -#define RUBY_RELEASE_DAY 14 +#define RUBY_RELEASE_DAY 15 #include "ruby/version.h" From 517c8a532425a28ee2641fc100a91a691b501fe8 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Mon, 15 Jul 2019 00:08:34 +0900 Subject: [PATCH 125/452] dir.c (dir_each_entry): remove unnecessary check I guess that this check was to detect re-entrance (maybe callcc?). But currently it does not work as intended. --- dir.c | 1 - 1 file changed, 1 deletion(-) diff --git a/dir.c b/dir.c index 1dbedb763fbac2..18c10f2139821f 100644 --- a/dir.c +++ b/dir.c @@ -858,7 +858,6 @@ dir_each_entry(VALUE dir, VALUE (*each)(VALUE, VALUE), VALUE arg, int children_o #endif path = rb_external_str_new_with_enc(name, namlen, dirp->enc); (*each)(arg, path); - if (dirp->dir == NULL) dir_closed(); } return dir; } From 09187c64b8dcea6a6ed6134e939a2e0ca88a2bd6 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Mon, 15 Jul 2019 00:10:39 +0900 Subject: [PATCH 126/452] Add a /* fall through */ comment --- compile.c | 1 + 1 file changed, 1 insertion(+) diff --git a/compile.c b/compile.c index 2bee4b8dd8c031..28691fba8c4199 100644 --- a/compile.c +++ b/compile.c @@ -6919,6 +6919,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in break; case NODE_BLOCK_PASS: boff = 1; + /* fall through */ default: INIT_ANCHOR(args); argc = setup_args(iseq, args, node->nd_args->nd_head, &flag, NULL); From 312d72000a5b49064670c1a7f4c2ad5e167d292b Mon Sep 17 00:00:00 2001 From: poloka Date: Wed, 26 Dec 2018 13:06:23 -0600 Subject: [PATCH 127/452] [ruby/rdoc] Correction to include regexp_handling in list of loaded files https://github.com/ruby/rdoc/commit/1940b2318c --- lib/rdoc/rdoc.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rdoc/rdoc.gemspec b/lib/rdoc/rdoc.gemspec index 9c6fbe1970f242..99bf3a63f58f29 100644 --- a/lib/rdoc/rdoc.gemspec +++ b/lib/rdoc/rdoc.gemspec @@ -32,7 +32,7 @@ RDoc includes the +rdoc+ and +ri+ tools for generating and displaying documentat s.executables = ["rdoc", "ri"] s.require_paths = ["lib"] # for ruby core repository. It was generated by `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } - s.files = [".document", ".gitignore", ".travis.yml", "CONTRIBUTING.rdoc", "CVE-2013-0256.rdoc", "ExampleMarkdown.md", "ExampleRDoc.rdoc", "Gemfile", "History.rdoc", "LEGAL.rdoc", "LICENSE.rdoc", "README.rdoc", "RI.rdoc", "Rakefile", "TODO.rdoc", "appveyor.yml", "bin/console", "bin/setup", "exe/rdoc", "exe/ri", "lib/rdoc.rb", "lib/rdoc/alias.rb", "lib/rdoc/anon_class.rb", "lib/rdoc/any_method.rb", "lib/rdoc/attr.rb", "lib/rdoc/class_module.rb", "lib/rdoc/code_object.rb", "lib/rdoc/code_objects.rb", "lib/rdoc/comment.rb", "lib/rdoc/constant.rb", "lib/rdoc/context.rb", "lib/rdoc/context/section.rb", "lib/rdoc/cross_reference.rb", "lib/rdoc/encoding.rb", "lib/rdoc/erb_partial.rb", "lib/rdoc/erbio.rb", "lib/rdoc/extend.rb", "lib/rdoc/generator.rb", "lib/rdoc/generator/darkfish.rb", "lib/rdoc/generator/json_index.rb", "lib/rdoc/generator/markup.rb", "lib/rdoc/generator/pot.rb", "lib/rdoc/generator/pot/message_extractor.rb", "lib/rdoc/generator/pot/po.rb", "lib/rdoc/generator/pot/po_entry.rb", "lib/rdoc/generator/ri.rb", "lib/rdoc/generator/template/darkfish/.document", "lib/rdoc/generator/template/darkfish/_footer.rhtml", "lib/rdoc/generator/template/darkfish/_head.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_navigation.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml", "lib/rdoc/generator/template/darkfish/class.rhtml", "lib/rdoc/generator/template/darkfish/css/fonts.css", "lib/rdoc/generator/template/darkfish/css/rdoc.css", "lib/rdoc/generator/template/darkfish/fonts/Lato-Light.ttf", "lib/rdoc/generator/template/darkfish/fonts/Lato-LightItalic.ttf", "lib/rdoc/generator/template/darkfish/fonts/Lato-Regular.ttf", "lib/rdoc/generator/template/darkfish/fonts/Lato-RegularItalic.ttf", "lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Bold.ttf", "lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Regular.ttf", "lib/rdoc/generator/template/darkfish/images/add.png", "lib/rdoc/generator/template/darkfish/images/arrow_up.png", "lib/rdoc/generator/template/darkfish/images/brick.png", "lib/rdoc/generator/template/darkfish/images/brick_link.png", "lib/rdoc/generator/template/darkfish/images/bug.png", "lib/rdoc/generator/template/darkfish/images/bullet_black.png", "lib/rdoc/generator/template/darkfish/images/bullet_toggle_minus.png", "lib/rdoc/generator/template/darkfish/images/bullet_toggle_plus.png", "lib/rdoc/generator/template/darkfish/images/date.png", "lib/rdoc/generator/template/darkfish/images/delete.png", "lib/rdoc/generator/template/darkfish/images/find.png", "lib/rdoc/generator/template/darkfish/images/loadingAnimation.gif", "lib/rdoc/generator/template/darkfish/images/macFFBgHack.png", "lib/rdoc/generator/template/darkfish/images/package.png", "lib/rdoc/generator/template/darkfish/images/page_green.png", "lib/rdoc/generator/template/darkfish/images/page_white_text.png", "lib/rdoc/generator/template/darkfish/images/page_white_width.png", "lib/rdoc/generator/template/darkfish/images/plugin.png", "lib/rdoc/generator/template/darkfish/images/ruby.png", "lib/rdoc/generator/template/darkfish/images/tag_blue.png", "lib/rdoc/generator/template/darkfish/images/tag_green.png", "lib/rdoc/generator/template/darkfish/images/transparent.png", "lib/rdoc/generator/template/darkfish/images/wrench.png", "lib/rdoc/generator/template/darkfish/images/wrench_orange.png", "lib/rdoc/generator/template/darkfish/images/zoom.png", "lib/rdoc/generator/template/darkfish/index.rhtml", "lib/rdoc/generator/template/darkfish/js/darkfish.js", "lib/rdoc/generator/template/darkfish/js/jquery.js", "lib/rdoc/generator/template/darkfish/js/search.js", "lib/rdoc/generator/template/darkfish/page.rhtml", "lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml", "lib/rdoc/generator/template/darkfish/servlet_root.rhtml", "lib/rdoc/generator/template/darkfish/table_of_contents.rhtml", "lib/rdoc/generator/template/json_index/.document", "lib/rdoc/generator/template/json_index/js/navigation.js", "lib/rdoc/generator/template/json_index/js/searcher.js", "lib/rdoc/ghost_method.rb", "lib/rdoc/i18n.rb", "lib/rdoc/i18n/locale.rb", "lib/rdoc/i18n/text.rb", "lib/rdoc/include.rb", "lib/rdoc/known_classes.rb", "lib/rdoc/markdown.kpeg", "lib/rdoc/markdown/entities.rb", "lib/rdoc/markdown/literals.kpeg", "lib/rdoc/markup.rb", "lib/rdoc/markup/attr_changer.rb", "lib/rdoc/markup/attr_span.rb", "lib/rdoc/markup/attribute_manager.rb", "lib/rdoc/markup/attributes.rb", "lib/rdoc/markup/blank_line.rb", "lib/rdoc/markup/block_quote.rb", "lib/rdoc/markup/document.rb", "lib/rdoc/markup/formatter.rb", "lib/rdoc/markup/formatter_test_case.rb", "lib/rdoc/markup/hard_break.rb", "lib/rdoc/markup/heading.rb", "lib/rdoc/markup/include.rb", "lib/rdoc/markup/indented_paragraph.rb", "lib/rdoc/markup/list.rb", "lib/rdoc/markup/list_item.rb", "lib/rdoc/markup/paragraph.rb", "lib/rdoc/markup/parser.rb", "lib/rdoc/markup/pre_process.rb", "lib/rdoc/markup/raw.rb", "lib/rdoc/markup/rule.rb", "lib/rdoc/markup/text_formatter_test_case.rb", "lib/rdoc/markup/to_ansi.rb", "lib/rdoc/markup/to_bs.rb", "lib/rdoc/markup/to_html.rb", "lib/rdoc/markup/to_html_crossref.rb", "lib/rdoc/markup/to_html_snippet.rb", "lib/rdoc/markup/to_joined_paragraph.rb", "lib/rdoc/markup/to_label.rb", "lib/rdoc/markup/to_markdown.rb", "lib/rdoc/markup/to_rdoc.rb", "lib/rdoc/markup/to_table_of_contents.rb", "lib/rdoc/markup/to_test.rb", "lib/rdoc/markup/to_tt_only.rb", "lib/rdoc/markup/verbatim.rb", "lib/rdoc/meta_method.rb", "lib/rdoc/method_attr.rb", "lib/rdoc/mixin.rb", "lib/rdoc/normal_class.rb", "lib/rdoc/normal_module.rb", "lib/rdoc/options.rb", "lib/rdoc/parser.rb", "lib/rdoc/parser/c.rb", "lib/rdoc/parser/changelog.rb", "lib/rdoc/parser/markdown.rb", "lib/rdoc/parser/rd.rb", "lib/rdoc/parser/ripper_state_lex.rb", "lib/rdoc/parser/ruby.rb", "lib/rdoc/parser/ruby_tools.rb", "lib/rdoc/parser/simple.rb", "lib/rdoc/parser/text.rb", "lib/rdoc/rd.rb", "lib/rdoc/rd/block_parser.ry", "lib/rdoc/rd/inline.rb", "lib/rdoc/rd/inline_parser.ry", "lib/rdoc/rdoc.rb", "lib/rdoc/require.rb", "lib/rdoc/ri.rb", "lib/rdoc/ri/driver.rb", "lib/rdoc/ri/formatter.rb", "lib/rdoc/ri/paths.rb", "lib/rdoc/ri/store.rb", "lib/rdoc/ri/task.rb", "lib/rdoc/rubygems_hook.rb", "lib/rdoc/servlet.rb", "lib/rdoc/single_class.rb", "lib/rdoc/stats.rb", "lib/rdoc/stats/normal.rb", "lib/rdoc/stats/quiet.rb", "lib/rdoc/stats/verbose.rb", "lib/rdoc/store.rb", "lib/rdoc/task.rb", "lib/rdoc/text.rb", "lib/rdoc/token_stream.rb", "lib/rdoc/tom_doc.rb", "lib/rdoc/top_level.rb", "lib/rdoc/version.rb", "rdoc.gemspec"] + s.files = [".document", ".gitignore", ".travis.yml", "CONTRIBUTING.rdoc", "CVE-2013-0256.rdoc", "ExampleMarkdown.md", "ExampleRDoc.rdoc", "Gemfile", "History.rdoc", "LEGAL.rdoc", "LICENSE.rdoc", "README.rdoc", "RI.rdoc", "Rakefile", "TODO.rdoc", "appveyor.yml", "bin/console", "bin/setup", "exe/rdoc", "exe/ri", "lib/rdoc.rb", "lib/rdoc/alias.rb", "lib/rdoc/anon_class.rb", "lib/rdoc/any_method.rb", "lib/rdoc/attr.rb", "lib/rdoc/class_module.rb", "lib/rdoc/code_object.rb", "lib/rdoc/code_objects.rb", "lib/rdoc/comment.rb", "lib/rdoc/constant.rb", "lib/rdoc/context.rb", "lib/rdoc/context/section.rb", "lib/rdoc/cross_reference.rb", "lib/rdoc/encoding.rb", "lib/rdoc/erb_partial.rb", "lib/rdoc/erbio.rb", "lib/rdoc/extend.rb", "lib/rdoc/generator.rb", "lib/rdoc/generator/darkfish.rb", "lib/rdoc/generator/json_index.rb", "lib/rdoc/generator/markup.rb", "lib/rdoc/generator/pot.rb", "lib/rdoc/generator/pot/message_extractor.rb", "lib/rdoc/generator/pot/po.rb", "lib/rdoc/generator/pot/po_entry.rb", "lib/rdoc/generator/ri.rb", "lib/rdoc/generator/template/darkfish/.document", "lib/rdoc/generator/template/darkfish/_footer.rhtml", "lib/rdoc/generator/template/darkfish/_head.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_navigation.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml", "lib/rdoc/generator/template/darkfish/class.rhtml", "lib/rdoc/generator/template/darkfish/css/fonts.css", "lib/rdoc/generator/template/darkfish/css/rdoc.css", "lib/rdoc/generator/template/darkfish/fonts/Lato-Light.ttf", "lib/rdoc/generator/template/darkfish/fonts/Lato-LightItalic.ttf", "lib/rdoc/generator/template/darkfish/fonts/Lato-Regular.ttf", "lib/rdoc/generator/template/darkfish/fonts/Lato-RegularItalic.ttf", "lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Bold.ttf", "lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Regular.ttf", "lib/rdoc/generator/template/darkfish/images/add.png", "lib/rdoc/generator/template/darkfish/images/arrow_up.png", "lib/rdoc/generator/template/darkfish/images/brick.png", "lib/rdoc/generator/template/darkfish/images/brick_link.png", "lib/rdoc/generator/template/darkfish/images/bug.png", "lib/rdoc/generator/template/darkfish/images/bullet_black.png", "lib/rdoc/generator/template/darkfish/images/bullet_toggle_minus.png", "lib/rdoc/generator/template/darkfish/images/bullet_toggle_plus.png", "lib/rdoc/generator/template/darkfish/images/date.png", "lib/rdoc/generator/template/darkfish/images/delete.png", "lib/rdoc/generator/template/darkfish/images/find.png", "lib/rdoc/generator/template/darkfish/images/loadingAnimation.gif", "lib/rdoc/generator/template/darkfish/images/macFFBgHack.png", "lib/rdoc/generator/template/darkfish/images/package.png", "lib/rdoc/generator/template/darkfish/images/page_green.png", "lib/rdoc/generator/template/darkfish/images/page_white_text.png", "lib/rdoc/generator/template/darkfish/images/page_white_width.png", "lib/rdoc/generator/template/darkfish/images/plugin.png", "lib/rdoc/generator/template/darkfish/images/ruby.png", "lib/rdoc/generator/template/darkfish/images/tag_blue.png", "lib/rdoc/generator/template/darkfish/images/tag_green.png", "lib/rdoc/generator/template/darkfish/images/transparent.png", "lib/rdoc/generator/template/darkfish/images/wrench.png", "lib/rdoc/generator/template/darkfish/images/wrench_orange.png", "lib/rdoc/generator/template/darkfish/images/zoom.png", "lib/rdoc/generator/template/darkfish/index.rhtml", "lib/rdoc/generator/template/darkfish/js/darkfish.js", "lib/rdoc/generator/template/darkfish/js/jquery.js", "lib/rdoc/generator/template/darkfish/js/search.js", "lib/rdoc/generator/template/darkfish/page.rhtml", "lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml", "lib/rdoc/generator/template/darkfish/servlet_root.rhtml", "lib/rdoc/generator/template/darkfish/table_of_contents.rhtml", "lib/rdoc/generator/template/json_index/.document", "lib/rdoc/generator/template/json_index/js/navigation.js", "lib/rdoc/generator/template/json_index/js/searcher.js", "lib/rdoc/ghost_method.rb", "lib/rdoc/i18n.rb", "lib/rdoc/i18n/locale.rb", "lib/rdoc/i18n/text.rb", "lib/rdoc/include.rb", "lib/rdoc/known_classes.rb", "lib/rdoc/markdown.kpeg", "lib/rdoc/markdown/entities.rb", "lib/rdoc/markdown/literals.kpeg", "lib/rdoc/markup.rb", "lib/rdoc/markup/attr_changer.rb", "lib/rdoc/markup/attr_span.rb", "lib/rdoc/markup/attribute_manager.rb", "lib/rdoc/markup/attributes.rb", "lib/rdoc/markup/blank_line.rb", "lib/rdoc/markup/block_quote.rb", "lib/rdoc/markup/document.rb", "lib/rdoc/markup/formatter.rb", "lib/rdoc/markup/formatter_test_case.rb", "lib/rdoc/markup/hard_break.rb", "lib/rdoc/markup/heading.rb", "lib/rdoc/markup/include.rb", "lib/rdoc/markup/indented_paragraph.rb", "lib/rdoc/markup/list.rb", "lib/rdoc/markup/list_item.rb", "lib/rdoc/markup/paragraph.rb", "lib/rdoc/markup/parser.rb", "lib/rdoc/markup/pre_process.rb", "lib/rdoc/markup/raw.rb", "lib/rdoc/markup/regexp_handling.rb", "lib/rdoc/markup/rule.rb", "lib/rdoc/markup/text_formatter_test_case.rb", "lib/rdoc/markup/to_ansi.rb", "lib/rdoc/markup/to_bs.rb", "lib/rdoc/markup/to_html.rb", "lib/rdoc/markup/to_html_crossref.rb", "lib/rdoc/markup/to_html_snippet.rb", "lib/rdoc/markup/to_joined_paragraph.rb", "lib/rdoc/markup/to_label.rb", "lib/rdoc/markup/to_markdown.rb", "lib/rdoc/markup/to_rdoc.rb", "lib/rdoc/markup/to_table_of_contents.rb", "lib/rdoc/markup/to_test.rb", "lib/rdoc/markup/to_tt_only.rb", "lib/rdoc/markup/verbatim.rb", "lib/rdoc/meta_method.rb", "lib/rdoc/method_attr.rb", "lib/rdoc/mixin.rb", "lib/rdoc/normal_class.rb", "lib/rdoc/normal_module.rb", "lib/rdoc/options.rb", "lib/rdoc/parser.rb", "lib/rdoc/parser/c.rb", "lib/rdoc/parser/changelog.rb", "lib/rdoc/parser/markdown.rb", "lib/rdoc/parser/rd.rb", "lib/rdoc/parser/ripper_state_lex.rb", "lib/rdoc/parser/ruby.rb", "lib/rdoc/parser/ruby_tools.rb", "lib/rdoc/parser/simple.rb", "lib/rdoc/parser/text.rb", "lib/rdoc/rd.rb", "lib/rdoc/rd/block_parser.ry", "lib/rdoc/rd/inline.rb", "lib/rdoc/rd/inline_parser.ry", "lib/rdoc/rdoc.rb", "lib/rdoc/require.rb", "lib/rdoc/ri.rb", "lib/rdoc/ri/driver.rb", "lib/rdoc/ri/formatter.rb", "lib/rdoc/ri/paths.rb", "lib/rdoc/ri/store.rb", "lib/rdoc/ri/task.rb", "lib/rdoc/rubygems_hook.rb", "lib/rdoc/servlet.rb", "lib/rdoc/single_class.rb", "lib/rdoc/stats.rb", "lib/rdoc/stats/normal.rb", "lib/rdoc/stats/quiet.rb", "lib/rdoc/stats/verbose.rb", "lib/rdoc/store.rb", "lib/rdoc/task.rb", "lib/rdoc/text.rb", "lib/rdoc/token_stream.rb", "lib/rdoc/tom_doc.rb", "lib/rdoc/top_level.rb", "lib/rdoc/version.rb", "rdoc.gemspec"] # files from .gitignore s.files << "lib/rdoc/rd/block_parser.rb" << "lib/rdoc/rd/inline_parser.rb" << "lib/rdoc/markdown.rb" << "lib/rdoc/markdown/literals.rb" From 83171b0ee8dc8000819259bde764ea9ca3489290 Mon Sep 17 00:00:00 2001 From: aycabta Date: Thu, 27 Dec 2018 07:09:56 +0900 Subject: [PATCH 128/452] [ruby/rdoc] Bump version to 6.1.1 https://github.com/ruby/rdoc/commit/55c0627fe0 --- lib/rdoc/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rdoc/version.rb b/lib/rdoc/version.rb index 9f66c50a5f4757..d9c4aa154d56b3 100644 --- a/lib/rdoc/version.rb +++ b/lib/rdoc/version.rb @@ -3,6 +3,6 @@ module RDoc ## # RDoc version you are using - VERSION = '6.1.0' + VERSION = '6.1.1' end From 9806da50f49843c6983e3110a23ab7822c2e089d Mon Sep 17 00:00:00 2001 From: Masataka Pocke Kuwabara Date: Thu, 13 Jun 2019 16:09:02 +0900 Subject: [PATCH 129/452] Suppress warnings --- lib/irb/ext/history.rb | 3 ++- lib/irb/ext/save-history.rb | 2 +- lib/irb/ext/use-loader.rb | 3 +++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/irb/ext/history.rb b/lib/irb/ext/history.rb index 62363b13f436f6..43c3e4dbf36ac6 100644 --- a/lib/irb/ext/history.rb +++ b/lib/irb/ext/history.rb @@ -22,7 +22,7 @@ class Context def set_last_value(value) _set_last_value(value) - if @eval_history + if defined?(@eval_history) && @eval_history @eval_history_values.push @line_no, @last_value @workspace.evaluate self, "__ = IRB.CurrentContext.instance_eval{@eval_history_values}" end @@ -30,6 +30,7 @@ def set_last_value(value) @last_value end + remove_method :eval_history= if method_defined?(:eval_history=) # The command result history limit. attr_reader :eval_history # Sets command result history limit. diff --git a/lib/irb/ext/save-history.rb b/lib/irb/ext/save-history.rb index 8ee5d269e65f1b..9aeb5dee0cbc7f 100644 --- a/lib/irb/ext/save-history.rb +++ b/lib/irb/ext/save-history.rb @@ -27,7 +27,7 @@ def save_history IRB.conf[:SAVE_HISTORY] end - remove_method :save_history= if respond_to?(:save_history=) + remove_method :save_history= if method_defined?(:save_history=) # Sets IRB.conf[:SAVE_HISTORY] to the given +val+ and calls # #init_save_history with this context. # diff --git a/lib/irb/ext/use-loader.rb b/lib/irb/ext/use-loader.rb index cc7170667175d8..cb10e8a254a019 100644 --- a/lib/irb/ext/use-loader.rb +++ b/lib/irb/ext/use-loader.rb @@ -20,10 +20,12 @@ class Object module IRB module ExtendCommandBundle + remove_method :irb_load if method_defined?(:irb_load) # Loads the given file similarly to Kernel#load, see IrbLoader#irb_load def irb_load(*opts, &b) ExtendCommand::Load.execute(irb_context, *opts, &b) end + remove_method :irb_require if method_defined?(:irb_require) # Loads the given file similarly to Kernel#require def irb_require(*opts, &b) ExtendCommand::Require.execute(irb_context, *opts, &b) @@ -44,6 +46,7 @@ def use_loader alias use_loader? use_loader + remove_method :use_loader= if method_defined?(:use_loader=) # Sets IRB.conf[:USE_LOADER] # # See #use_loader for more information. From 073cc52dcc5f0945e56877c703688517f58c6a65 Mon Sep 17 00:00:00 2001 From: manga_osyo Date: Sun, 23 Jun 2019 13:29:09 +0900 Subject: [PATCH 130/452] Add `class Reline::History` and test. --- lib/reline.rb | 62 +--------- lib/reline/history.rb | 60 ++++++++++ test/test_history.rb | 273 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 335 insertions(+), 60 deletions(-) create mode 100644 lib/reline/history.rb create mode 100644 test/test_history.rb diff --git a/lib/reline.rb b/lib/reline.rb index bf8967c561794b..5bb47d5d3f4147 100644 --- a/lib/reline.rb +++ b/lib/reline.rb @@ -5,6 +5,7 @@ require 'reline/key_actor' require 'reline/key_stroke' require 'reline/line_editor' +require 'reline/history' module Reline Key = Struct.new('Key', :char, :combined_char, :with_meta) @@ -26,66 +27,7 @@ module Reline @@line_editor = Reline::LineEditor.new(@@config) @@ambiguous_width = nil - HISTORY = Class.new(Array) { - def initialize(config) - @config = config - end - - def to_s - 'HISTORY' - end - - def delete_at(index) - index = check_index(index) - super(index) - end - - def [](index) - index = check_index(index) - super(index) - end - - def []=(index, val) - index = check_index(index) - super(index, String.new(val, encoding: Encoding::default_external)) - end - - def concat(*val) - val.each do |v| - push(*v) - end - end - - def push(*val) - diff = size + val.size - @config.history_size - if diff > 0 - if diff <= size - shift(diff) - else - diff -= size - clear - val.shift(diff) - end - end - super(*(val.map{ |v| String.new(v, encoding: Encoding::default_external) })) - end - - def <<(val) - shift if size + 1 > @config.history_size - super(String.new(val, encoding: Encoding::default_external)) - end - - private def check_index(index) - index += size if index < 0 - raise RangeError.new("index=<#{index}>") if index < -@config.history_size or @config.history_size < index - raise IndexError.new("index=<#{index}>") if index < 0 or size <= index - index - end - - private def set_config(config) - @config = config - end - }.new(@@config) + HISTORY = History.new(@@config) @@completion_append_character = nil def self.completion_append_character diff --git a/lib/reline/history.rb b/lib/reline/history.rb new file mode 100644 index 00000000000000..d988230941cd71 --- /dev/null +++ b/lib/reline/history.rb @@ -0,0 +1,60 @@ +class Reline::History < Array + def initialize(config) + @config = config + end + + def to_s + 'HISTORY' + end + + def delete_at(index) + index = check_index(index) + super(index) + end + + def [](index) + index = check_index(index) + super(index) + end + + def []=(index, val) + index = check_index(index) + super(index, String.new(val, encoding: Encoding::default_external)) + end + + def concat(*val) + val.each do |v| + push(*v) + end + end + + def push(*val) + diff = size + val.size - @config.history_size + if diff > 0 + if diff <= size + shift(diff) + else + diff -= size + clear + val.shift(diff) + end + end + super(*(val.map{ |v| String.new(v, encoding: Encoding::default_external) })) + end + + def <<(val) + shift if size + 1 > @config.history_size + super(String.new(val, encoding: Encoding::default_external)) + end + + private def check_index(index) + index += size if index < 0 + raise RangeError.new("index=<#{index}>") if index < -@config.history_size or @config.history_size < index + raise IndexError.new("index=<#{index}>") if index < 0 or size <= index + index + end + + private def set_config(config) + @config = config + end +end diff --git a/test/test_history.rb b/test/test_history.rb new file mode 100644 index 00000000000000..b38d9a3433aff7 --- /dev/null +++ b/test/test_history.rb @@ -0,0 +1,273 @@ +require_relative 'helper' +require "reline/history" + +class Reline::KeyStroke::Test < Reline::TestCase + def test_ancestors + assert_equal(Reline::History.ancestors.include?(Array), true) + end + + def test_to_s + history = history_new + expected = "HISTORY" + assert_equal(expected, history.to_s) + end + + def test_get + history, lines = lines = history_new_and_push_history(5) + lines.each_with_index do |s, i| + assert_external_string_equal(s, history[i]) + end + end + + def test_get__negative + history, lines = lines = history_new_and_push_history(5) + (1..5).each do |i| + assert_equal(lines[-i], history[-i]) + end + end + + def test_get__out_of_range + history, _ = history_new_and_push_history(5) + invalid_indexes = [5, 6, 100, -6, -7, -100] + invalid_indexes.each do |i| + assert_raise(IndexError, "i=<#{i}>") do + history[i] + end + end + + invalid_indexes = [100_000_000_000_000_000_000, + -100_000_000_000_000_000_000] + invalid_indexes.each do |i| + assert_raise(RangeError, "i=<#{i}>") do + history[i] + end + end + end + + def test_set + begin + history, _ = history_new_and_push_history(5) + 5.times do |i| + expected = "set: #{i}" + history[i] = expected + assert_external_string_equal(expected, history[i]) + end + rescue NotImplementedError + end + end + + def test_set__out_of_range + history = history_new + assert_raise(IndexError, NotImplementedError, "index=<0>") do + history[0] = "set: 0" + end + + history, _ = history_new_and_push_history(5) + invalid_indexes = [5, 6, 100, -6, -7, -100] + invalid_indexes.each do |i| + assert_raise(IndexError, NotImplementedError, "index=<#{i}>") do + history[i] = "set: #{i}" + end + end + + invalid_indexes = [100_000_000_000_000_000_000, + -100_000_000_000_000_000_000] + invalid_indexes.each do |i| + assert_raise(RangeError, NotImplementedError, "index=<#{i}>") do + history[i] = "set: #{i}" + end + end + end + + def test_push + history = history_new + 5.times do |i| + s = i.to_s + assert_equal(history, history.push(s)) + assert_external_string_equal(s, history[i]) + end + assert_equal(5, history.length) + end + + def test_push__operator + history = history_new + 5.times do |i| + s = i.to_s + assert_equal(history, history << s) + assert_external_string_equal(s, history[i]) + end + assert_equal(5, history.length) + end + + def test_push__plural + history = history_new + assert_equal(history, history.push("0", "1", "2", "3", "4")) + (0..4).each do |i| + assert_external_string_equal(i.to_s, history[i]) + end + assert_equal(5, history.length) + + assert_equal(history, history.push("5", "6", "7", "8", "9")) + (5..9).each do |i| + assert_external_string_equal(i.to_s, history[i]) + end + assert_equal(10, history.length) + end + + def test_pop + history = history_new + begin + assert_equal(nil, history.pop) + + history, lines = lines = history_new_and_push_history(5) + (1..5).each do |i| + assert_external_string_equal(lines[-i], history.pop) + assert_equal(lines.length - i, history.length) + end + + assert_equal(nil, history.pop) + rescue NotImplementedError + end + end + + def test_shift + history = history_new + begin + assert_equal(nil, history.shift) + + history, lines = lines = history_new_and_push_history(5) + (0..4).each do |i| + assert_external_string_equal(lines[i], history.shift) + assert_equal(lines.length - (i + 1), history.length) + end + + assert_equal(nil, history.shift) + rescue NotImplementedError + end + end + + def test_each + history = history_new + e = history.each do |s| + assert(false) # not reachable + end + assert_equal(history, e) + history, lines = lines = history_new_and_push_history(5) + i = 0 + e = history.each do |s| + assert_external_string_equal(history[i], s) + assert_external_string_equal(lines[i], s) + i += 1 + end + assert_equal(history, e) + end + + def test_each__enumerator + history = history_new + e = history.each + assert_instance_of(Enumerator, e) + end + + def test_length + history = history_new + assert_equal(0, history.length) + push_history(history, 1) + assert_equal(1, history.length) + push_history(history, 4) + assert_equal(5, history.length) + history.clear + assert_equal(0, history.length) + end + + def test_empty_p + history = history_new + 2.times do + assert(history.empty?) + history.push("s") + assert_equal(false, history.empty?) + history.clear + assert(history.empty?) + end + end + + def test_delete_at + begin + history, lines = lines = history_new_and_push_history(5) + (0..4).each do |i| + assert_external_string_equal(lines[i], history.delete_at(0)) + end + assert(history.empty?) + + history, lines = lines = history_new_and_push_history(5) + (1..5).each do |i| + assert_external_string_equal(lines[lines.length - i], history.delete_at(-1)) + end + assert(history.empty?) + + history, lines = lines = history_new_and_push_history(5) + assert_external_string_equal(lines[0], history.delete_at(0)) + assert_external_string_equal(lines[4], history.delete_at(3)) + assert_external_string_equal(lines[1], history.delete_at(0)) + assert_external_string_equal(lines[3], history.delete_at(1)) + assert_external_string_equal(lines[2], history.delete_at(0)) + assert(history.empty?) + rescue NotImplementedError + end + end + + def test_delete_at__out_of_range + history = history_new + assert_raise(IndexError, NotImplementedError, "index=<0>") do + history.delete_at(0) + end + + history, _ = history_new_and_push_history(5) + invalid_indexes = [5, 6, 100, -6, -7, -100] + invalid_indexes.each do |i| + assert_raise(IndexError, NotImplementedError, "index=<#{i}>") do + history.delete_at(i) + end + end + + invalid_indexes = [100_000_000_000_000_000_000, + -100_000_000_000_000_000_000] + invalid_indexes.each do |i| + assert_raise(RangeError, NotImplementedError, "index=<#{i}>") do + history.delete_at(i) + end + end + end + + private + + def history_new(history_size: 10) + Reline::History.new(Struct.new(:history_size).new(history_size)) + end + + def push_history(history, num) + lines = [] + num.times do |i| + s = "a" + i.times do + s = s.succ + end + lines.push("#{i + 1}:#{s}") + end + history.push(*lines) + return history, lines + end + + def history_new_and_push_history(num) + history = history_new(history_size: 100) + return push_history(history, num) + end + + def assert_external_string_equal(expected, actual) + assert_equal(expected, actual) + assert_equal(get_default_internal_encoding, actual.encoding) + end + + def get_default_internal_encoding + return Encoding.default_internal || Encoding.find("locale") + end +end From e6f188ea031db9bd7ac0d2931242eebc83b5aac7 Mon Sep 17 00:00:00 2001 From: manga_osyo Date: Tue, 25 Jun 2019 22:08:15 +0900 Subject: [PATCH 131/452] Rename to Reline::History::Test. --- test/test_history.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_history.rb b/test/test_history.rb index b38d9a3433aff7..260b6e85280c62 100644 --- a/test/test_history.rb +++ b/test/test_history.rb @@ -1,7 +1,7 @@ require_relative 'helper' require "reline/history" -class Reline::KeyStroke::Test < Reline::TestCase +class Reline::History::Test < Reline::TestCase def test_ancestors assert_equal(Reline::History.ancestors.include?(Array), true) end From deb5e582308950cdceb510807f498a7733dc076f Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Mon, 15 Jul 2019 00:19:41 +0900 Subject: [PATCH 132/452] ext/stringio/stringio.c (strio_read): "binray" is always zero here Remove unused conditional expression to suppress Coverity Scan warnings. --- ext/stringio/stringio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c index bfe1700c5a9820..b02fb113ba4055 100644 --- a/ext/stringio/stringio.c +++ b/ext/stringio/stringio.c @@ -1409,7 +1409,7 @@ strio_read(int argc, VALUE *argv, VALUE self) case 0: len = RSTRING_LEN(ptr->string); if (len <= ptr->pos) { - rb_encoding *enc = binary ? rb_ascii8bit_encoding() : get_enc(ptr); + rb_encoding *enc = get_enc(ptr); if (NIL_P(str)) { str = rb_str_new(0, 0); } From 9e3971c3ade4a2fd5c5d3123f9437fa3af352655 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Mon, 15 Jul 2019 00:29:56 +0900 Subject: [PATCH 133/452] Add a /* fall through */ comment --- parse.y | 1 + 1 file changed, 1 insertion(+) diff --git a/parse.y b/parse.y index e1cd2014de2074..e006ababaf5289 100644 --- a/parse.y +++ b/parse.y @@ -9896,6 +9896,7 @@ new_regexp(struct parser_params *p, NODE *node, int options, const YYLTYPE *loc) default: add_mark_object(p, lit = STR_NEW0()); node = NEW_NODE(NODE_DSTR, lit, 1, NEW_LIST(node, loc), loc); + /* fall through */ case NODE_DSTR: nd_set_type(node, NODE_DREGX); nd_set_loc(node, loc); From 970c12551efed86074d9c3440f82551795cbde6a Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Mon, 15 Jul 2019 00:30:35 +0900 Subject: [PATCH 134/452] Add a /* fall through */ comment --- compile.c | 1 + 1 file changed, 1 insertion(+) diff --git a/compile.c b/compile.c index 28691fba8c4199..e136db37527c06 100644 --- a/compile.c +++ b/compile.c @@ -9363,6 +9363,7 @@ ibf_load_code(const struct ibf_load *load, const rb_iseq_t *iseq, const struct r } case TS_ISE: FL_SET(iseq, ISEQ_MARKABLE_ISEQ); + /* fall through */ case TS_IC: code[code_index] = (VALUE)&is_entries[(int)op]; break; From 3201062adf7f98f645b659852bd9fa6f566cb1dd Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Mon, 15 Jul 2019 00:31:07 +0900 Subject: [PATCH 135/452] Add a /* fall through */ comment --- compile.c | 1 + 1 file changed, 1 insertion(+) diff --git a/compile.c b/compile.c index e136db37527c06..9cba0b5d7ea133 100644 --- a/compile.c +++ b/compile.c @@ -2163,6 +2163,7 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *const anchor) case TS_ISE: /* inline storage entry */ /* Treated as an IC, but may contain a markable VALUE */ FL_SET(iseq, ISEQ_MARKABLE_ISEQ); + /* fall through */ case TS_IC: /* inline cache */ { unsigned int ic_index = FIX2UINT(operands[j]); From 4403130193ac895820d9ccc8ec2ab13de37bfea6 Mon Sep 17 00:00:00 2001 From: Marcus Stollsteimer Date: Fri, 4 Jan 2019 00:00:06 +0100 Subject: [PATCH 136/452] [ruby/matrix] Add missing `lib/matrix/' files to file list in gemspec https://github.com/ruby/matrix/commit/2bbb9be233 --- lib/matrix/matrix.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matrix/matrix.gemspec b/lib/matrix/matrix.gemspec index 71f03718562456..c94e8b7cf28d69 100644 --- a/lib/matrix/matrix.gemspec +++ b/lib/matrix/matrix.gemspec @@ -11,7 +11,7 @@ Gem::Specification.new do |spec| spec.homepage = "https://github.com/ruby/matrix" spec.license = "BSD-2-Clause" - spec.files = [".gitignore", ".travis.yml", "Gemfile", "LICENSE.txt", "README.md", "Rakefile", "bin/console", "bin/setup", "lib/matrix.rb", "matrix.gemspec"] + spec.files = [".gitignore", ".travis.yml", "Gemfile", "LICENSE.txt", "README.md", "Rakefile", "bin/console", "bin/setup", "lib/matrix.rb", "lib/matrix/eigenvalue_decomposition.rb", "lib/matrix/lup_decomposition.rb", "matrix.gemspec"] spec.bindir = "exe" spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] From 423feb53a20f323d6b7e27e132e68b70b888ffe9 Mon Sep 17 00:00:00 2001 From: Marcus Stollsteimer Date: Fri, 4 Jan 2019 00:07:34 +0100 Subject: [PATCH 137/452] [ruby/matrix] Add Matrix::VERSION constant Add Matrix::VERSION for the gem version, use it in the gemspec, and make it also available for library users. https://github.com/ruby/matrix/commit/65c2bb1fa1 --- lib/matrix.rb | 2 ++ lib/matrix/matrix.gemspec | 11 +++++++++-- lib/matrix/version.rb | 5 +++++ 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 lib/matrix/version.rb diff --git a/lib/matrix.rb b/lib/matrix.rb index 34602f5c40310f..b8139b547f4c2f 100644 --- a/lib/matrix.rb +++ b/lib/matrix.rb @@ -14,6 +14,8 @@ require "e2mmap" +require_relative "matrix/version" + module ExceptionForMatrix # :nodoc: extend Exception2MessageMapper def_e2message(TypeError, "wrong argument type %s (expected %s)") diff --git a/lib/matrix/matrix.gemspec b/lib/matrix/matrix.gemspec index c94e8b7cf28d69..75f6b69a98f452 100644 --- a/lib/matrix/matrix.gemspec +++ b/lib/matrix/matrix.gemspec @@ -1,8 +1,15 @@ # frozen_string_literal: true +begin + require_relative "lib/matrix/version" +rescue LoadError + # for Ruby core repository + require_relative "version" +end + Gem::Specification.new do |spec| spec.name = "matrix" - spec.version = "0.1.0" + spec.version = Matrix::VERSION spec.authors = ["Marc-Andre Lafortune"] spec.email = ["ruby-core@marc-andre.ca"] @@ -11,7 +18,7 @@ Gem::Specification.new do |spec| spec.homepage = "https://github.com/ruby/matrix" spec.license = "BSD-2-Clause" - spec.files = [".gitignore", ".travis.yml", "Gemfile", "LICENSE.txt", "README.md", "Rakefile", "bin/console", "bin/setup", "lib/matrix.rb", "lib/matrix/eigenvalue_decomposition.rb", "lib/matrix/lup_decomposition.rb", "matrix.gemspec"] + spec.files = [".gitignore", ".travis.yml", "Gemfile", "LICENSE.txt", "README.md", "Rakefile", "bin/console", "bin/setup", "lib/matrix.rb", "lib/matrix/eigenvalue_decomposition.rb", "lib/matrix/lup_decomposition.rb", "lib/matrix/version.rb", "matrix.gemspec"] spec.bindir = "exe" spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] diff --git a/lib/matrix/version.rb b/lib/matrix/version.rb new file mode 100644 index 00000000000000..f88bf38d9672c7 --- /dev/null +++ b/lib/matrix/version.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +class Matrix + VERSION = "0.1.0" +end From 04e6b90d5be8f13344066de0d64ba11020e2c094 Mon Sep 17 00:00:00 2001 From: manga_osyo Date: Sat, 29 Jun 2019 23:51:24 +0900 Subject: [PATCH 138/452] Remove unused method. --- lib/reline/history.rb | 4 ---- test/reline/test_key_actor_emacs.rb | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/reline/history.rb b/lib/reline/history.rb index d988230941cd71..155b543c19fadf 100644 --- a/lib/reline/history.rb +++ b/lib/reline/history.rb @@ -53,8 +53,4 @@ def <<(val) raise IndexError.new("index=<#{index}>") if index < 0 or size <= index index end - - private def set_config(config) - @config = config - end end diff --git a/test/reline/test_key_actor_emacs.rb b/test/reline/test_key_actor_emacs.rb index 04edf6b31f482b..7dd81caaf0b444 100644 --- a/test/reline/test_key_actor_emacs.rb +++ b/test/reline/test_key_actor_emacs.rb @@ -5,7 +5,7 @@ def setup Reline.send(:test_mode) @prompt = '> ' @config = Reline::Config.new # Emacs mode is default - Reline::HISTORY.send(:set_config, @config) + Reline::HISTORY.instance_variable_set(:@config, @config) @encoding = (RELINE_TEST_ENCODING rescue Encoding.default_external) @line_editor = Reline::LineEditor.new(@config) @line_editor.reset(@prompt, @encoding) From cd7b99bbfccd69b6cd75421b738bcda36f920e0d Mon Sep 17 00:00:00 2001 From: aycabta Date: Mon, 15 Jul 2019 00:15:01 +0900 Subject: [PATCH 139/452] Version 0.0.1 --- lib/reline/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/reline/version.rb b/lib/reline/version.rb index 58a69a09a0b892..ece9b444e9643f 100644 --- a/lib/reline/version.rb +++ b/lib/reline/version.rb @@ -1,3 +1,3 @@ module Reline - VERSION = '0.0.0' + VERSION = '0.0.1' end From d0b1a8d5fb56a20198c69d77d9ce65740d0ddcc2 Mon Sep 17 00:00:00 2001 From: aycabta Date: Mon, 15 Jul 2019 00:42:45 +0900 Subject: [PATCH 140/452] Need reline-0.0.1 or later for some features --- lib/irb/irb.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/irb/irb.gemspec b/lib/irb/irb.gemspec index 12633bf15ce1f1..1c2c4e6dd89e44 100644 --- a/lib/irb/irb.gemspec +++ b/lib/irb/irb.gemspec @@ -21,7 +21,7 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - spec.add_dependency "reline" + spec.add_dependency "reline", ">= 0.0.1" spec.add_development_dependency "bundler" spec.add_development_dependency "rake" end From 82b058ff6067269c04265844c7df08a2971b0335 Mon Sep 17 00:00:00 2001 From: aycabta Date: Mon, 15 Jul 2019 00:43:16 +0900 Subject: [PATCH 141/452] Version 1.1.0.pre.2 --- lib/irb/version.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/irb/version.rb b/lib/irb/version.rb index d4172f5155698f..e8e4d1f4e8149b 100644 --- a/lib/irb/version.rb +++ b/lib/irb/version.rb @@ -11,7 +11,7 @@ # module IRB # :nodoc: - VERSION = "1.1.0.pre.1" + VERSION = "1.1.0.pre.2" @RELEASE_VERSION = VERSION - @LAST_UPDATE_DATE = "2019-05-31" + @LAST_UPDATE_DATE = "2019-07-15" end From 6d573691058b353840c504d16cc2df1eb0bb517c Mon Sep 17 00:00:00 2001 From: aycabta Date: Mon, 15 Jul 2019 01:07:37 +0900 Subject: [PATCH 142/452] Auto indent in IRB is enabled by default --- lib/irb.rb | 6 +++--- lib/irb/context.rb | 8 ++++---- lib/irb/init.rb | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/irb.rb b/lib/irb.rb index caccb2bd305377..e0e4b1a155a872 100644 --- a/lib/irb.rb +++ b/lib/irb.rb @@ -110,9 +110,9 @@ # # === Auto indentation # -# To enable auto-indent mode in irb, add the following to your +.irbrc+: +# To disable auto-indent mode in irb, add the following to your +.irbrc+: # -# IRB.conf[:AUTO_INDENT] = true +# IRB.conf[:AUTO_INDENT] = false # # === Autocompletion # @@ -141,7 +141,7 @@ # This example can be used in your +.irbrc+ # # IRB.conf[:PROMPT][:MY_PROMPT] = { # name of prompt mode -# :AUTO_INDENT => true, # enables auto-indent mode +# :AUTO_INDENT => false, # disables auto-indent mode # :PROMPT_I => ">> ", # simple prompt # :PROMPT_S => nil, # prompt for continuated strings # :PROMPT_C => nil, # prompt for continuated statement diff --git a/lib/irb/context.rb b/lib/irb/context.rb index b7b2230856415a..9544a8aa1aac12 100644 --- a/lib/irb/context.rb +++ b/lib/irb/context.rb @@ -194,17 +194,17 @@ def main # Can be either the default IRB.conf[:AUTO_INDENT], or the # mode set by #prompt_mode= # - # To enable auto-indentation in irb: + # To disable auto-indentation in irb: # - # IRB.conf[:AUTO_INDENT] = true + # IRB.conf[:AUTO_INDENT] = false # # or # - # irb_context.auto_indent_mode = true + # irb_context.auto_indent_mode = false # # or # - # IRB.CurrentContext.auto_indent_mode = true + # IRB.CurrentContext.auto_indent_mode = false # # See IRB@Configuration for more information. attr_accessor :auto_indent_mode diff --git a/lib/irb/init.rb b/lib/irb/init.rb index 50a4d7b3bbfa57..5069b7bbf7cfc3 100644 --- a/lib/irb/init.rb +++ b/lib/irb/init.rb @@ -105,7 +105,7 @@ def IRB.init_config(ap_path) } @CONF[:PROMPT_MODE] = (STDIN.tty? ? :DEFAULT : :NULL) - @CONF[:AUTO_INDENT] = false + @CONF[:AUTO_INDENT] = true @CONF[:CONTEXT_MODE] = 3 # use binding in function on TOPLEVEL_BINDING @CONF[:SINGLE_IRB] = false From 078e50c5e9c53d935bdea6ca3ae156c0edcea467 Mon Sep 17 00:00:00 2001 From: aycabta Date: Mon, 15 Jul 2019 01:16:18 +0900 Subject: [PATCH 143/452] Save history in IRB is enabled by default --- lib/irb.rb | 9 ++++----- lib/irb/init.rb | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/irb.rb b/lib/irb.rb index e0e4b1a155a872..2b00de9f628ed2 100644 --- a/lib/irb.rb +++ b/lib/irb.rb @@ -122,13 +122,12 @@ # # === History # -# By default, irb disables history and will not store any commands you used. +# By default, irb will store the last 1000 commands you used in +# ~/.irb_history. # -# If you want to enable history, add the following to your +.irbrc+: +# If you want to disable history, add the following to your +.irbrc+: # -# IRB.conf[:SAVE_HISTORY] = 1000 -# -# This will now store the last 1000 commands in ~/.irb_history. +# IRB.conf[:SAVE_HISTORY] = nil # # See IRB::Context#save_history= for more information. # diff --git a/lib/irb/init.rb b/lib/irb/init.rb index 5069b7bbf7cfc3..8a9215f5f9f6ee 100644 --- a/lib/irb/init.rb +++ b/lib/irb/init.rb @@ -54,7 +54,7 @@ def IRB.init_config(ap_path) @CONF[:VERBOSE] = nil @CONF[:EVAL_HISTORY] = nil - @CONF[:SAVE_HISTORY] = nil + @CONF[:SAVE_HISTORY] = 1000 @CONF[:BACK_TRACE_LIMIT] = 16 From 10d7b39d5d3141073221d4e53a8e81b7808a11b6 Mon Sep 17 00:00:00 2001 From: aycabta Date: Mon, 15 Jul 2019 02:58:28 +0900 Subject: [PATCH 144/452] Check wether prompt_i is nil --- lib/irb.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/irb.rb b/lib/irb.rb index 2b00de9f628ed2..f9c27782b9e7ad 100644 --- a/lib/irb.rb +++ b/lib/irb.rb @@ -463,7 +463,8 @@ def eval_input end if @context.auto_indent_mode and !@context.io.respond_to?(:auto_indent) unless ltype - ind = prompt(@context.prompt_i, ltype, indent, line_no)[/.*\z/].size + + prompt_i = @context.prompt_i.nil? ? "" : @context.prompt_i + ind = prompt(prompt_i, ltype, indent, line_no)[/.*\z/].size + indent * 2 - p.size ind += 2 if continue @context.io.prompt = p + " " * ind if ind > 0 From 0ee105f3f0a3b409bc08e6a1336c898038c1088f Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Mon, 15 Jul 2019 06:08:55 +0900 Subject: [PATCH 145/452] Mention SPECOPTS variable in make help --- common.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common.mk b/common.mk index e7f9d2a2e22753..5430fe6d7211ed 100644 --- a/common.mk +++ b/common.mk @@ -1502,7 +1502,7 @@ help: PHONY " exam: equals make check" \ " test: ruby core tests" \ " test-all: all ruby tests [TESTOPTS=-j4 TESTS=]" \ - " test-spec: run the Ruby spec suite" \ + " test-spec: run the Ruby spec suite [SPECOPTS=]" \ " test-rubyspec: same as test-spec" \ " test-bundler: run the Bundler spec" \ " test-bundled-gems: run the test suite of bundled gems" \ From 364f43ab7fc5920247fc73423c1428208cf78a4a Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Mon, 15 Jul 2019 06:11:40 +0900 Subject: [PATCH 146/452] Reduce the number of make help entries We've added some more things recently. It seems not worth having almost the same two entries there anymore. --- common.mk | 2 -- 1 file changed, 2 deletions(-) diff --git a/common.mk b/common.mk index 5430fe6d7211ed..a2ee72b2548824 100644 --- a/common.mk +++ b/common.mk @@ -1503,14 +1503,12 @@ help: PHONY " test: ruby core tests" \ " test-all: all ruby tests [TESTOPTS=-j4 TESTS=]" \ " test-spec: run the Ruby spec suite [SPECOPTS=]" \ - " test-rubyspec: same as test-spec" \ " test-bundler: run the Bundler spec" \ " test-bundled-gems: run the test suite of bundled gems" \ " sync-default-gems: sync default gems from upstream [GEM=]" \ " up: update local copy and autogenerated files" \ " benchmark: benchmark this ruby and COMPARE_RUBY." \ " gcbench: gc benchmark [GCBENCH_ITEM=]" \ - " gcbench-rdoc: gc benchmark with GCBENCH_ITEM=rdoc" \ " install: install all ruby distributions" \ " install-nodoc: install without rdoc" \ " install-cross: install cross compiling stuff" \ From e8b6f6303999fd39d367d3eb114193faad13bbca Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Mon, 15 Jul 2019 06:17:29 +0900 Subject: [PATCH 147/452] Drop `make change` and tool/change_maker.rb because we're not writing ChangeLog anymore. --- common.mk | 4 ---- tool/change_maker.rb | 47 -------------------------------------------- 2 files changed, 51 deletions(-) delete mode 100755 tool/change_maker.rb diff --git a/common.mk b/common.mk index a2ee72b2548824..3ea288248945ac 100644 --- a/common.mk +++ b/common.mk @@ -1459,9 +1459,6 @@ info-libruby_so: PHONY info-arch: PHONY @echo arch=$(arch) -change: PHONY - $(BASERUBY) -C "$(srcdir)" ./tool/change_maker.rb $(CHANGES) > change.log - exam: check love: sudo-precheck up all test exam install @@ -1514,7 +1511,6 @@ help: PHONY " install-cross: install cross compiling stuff" \ " clean: clean for tarball" \ " distclean: clean for repository" \ - " change: make change log template" \ " golf: for golfers" \ " goruby: same as golf" \ $(HELP_EXTRA_TASKS) \ diff --git a/tool/change_maker.rb b/tool/change_maker.rb deleted file mode 100755 index 395bd349902476..00000000000000 --- a/tool/change_maker.rb +++ /dev/null @@ -1,47 +0,0 @@ -#! ./miniruby - -# Used by "make change" to generate a list of files for a Changelog entry. -# Run it via "make change" in the Ruby root directory. - -$:.unshift(File.expand_path("../../lib", __FILE__)) -require File.expand_path("../vcs", __FILE__) - -def diff2index(cmd, *argv) - lines = [] - path = nil - output = `#{cmd} #{argv.join(" ")}` - if defined? Encoding::BINARY - output.force_encoding Encoding::BINARY - end - output.each_line do |line| - case line - when /^Index: (\S*)/, /^diff --git [a-z]\/(\S*) [a-z]\/\1/ - path = $1 - when /^@@\s*-[,\d]+ +\+(\d+)[,\d]*\s*@@(?: +([A-Za-z_][A-Za-z_0-9 ]*[A-Za-z_0-9]))?/ - line = $1.to_i - ent = "\t* #{path}" - ent << " (#{$2})" if $2 - lines << "#{ent}:" - end - end - lines.uniq! - lines.empty? ? nil : lines -end - -vcs = begin - VCS.detect(".") -rescue VCS::NotFoundError - nil -end - -case vcs -when VCS::SVN - cmd = "svn diff --diff-cmd=diff -x-pU0" - change = diff2index(cmd, ARGV) -when VCS::GIT - cmd = "git diff -U0" - change = diff2index(cmd, ARGV) || diff2index(cmd, "--cached", ARGV) -else - abort "does not seem to be under a vcs" -end -puts change if change From ea711285737faac6471fc22f0b8f9e9365e7e6ed Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Mon, 15 Jul 2019 06:22:22 +0900 Subject: [PATCH 148/452] Unify documentations of `make benchmark` --- common.mk | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/common.mk b/common.mk index 3ea288248945ac..3ada59b7d1e19a 100644 --- a/common.mk +++ b/common.mk @@ -1169,11 +1169,7 @@ ITEM = ARGS = $$(find $(srcdir)/benchmark -maxdepth 1 -name '*$(ITEM)*.yml' -o -name '*$(ITEM)*.rb' | sort) OPTS = -# You can pass several options through OPTS environment variable. -# $ make benchmark ARGS="--help" displays more detail. -# for example, -# $ make benchmark COMPARE_RUBY="ruby-trunk" OPTS="-e ruby-2.2.2" -# This command compares trunk and built-ruby and 2.2.2 +# See benchmark/README.md for details. benchmark: miniruby$(EXEEXT) update-benchmark-driver PHONY $(BASERUBY) -rrubygems -I$(srcdir)/benchmark/lib $(srcdir)/benchmark/benchmark-driver/exe/benchmark-driver \ --executables="compare-ruby::$(COMPARE_RUBY) -I$(EXTOUT)/common --disable-gem" \ From d37da601289d13396b1e986b81d51b05bcfdddd5 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Mon, 15 Jul 2019 06:42:55 +0900 Subject: [PATCH 149/452] time.c (time_mdump): use another buffer for year_extend ruby_marshal_write_long may write 9 bytes, but buf has only 8 bytes. So the buffer cannot be reused. This issue was found by Coverity Scan. --- time.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/time.c b/time.c index 8d1bfd3452b489..fe1ef787560ba0 100644 --- a/time.c +++ b/time.c @@ -5090,15 +5090,15 @@ time_mdump(VALUE time) * binary (like as Fixnum and Bignum). */ size_t ysize = rb_absint_size(year_extend, NULL); - char *p; + char *p, buf_year_extend[9]; if (ysize > LONG_MAX || - (i = ruby_marshal_write_long((long)ysize, buf)) < 0) { + (i = ruby_marshal_write_long((long)ysize, buf_year_extend)) < 0) { rb_raise(rb_eArgError, "year too %s to marshal: %"PRIsVALUE" UTC", (year == 1900 ? "small" : "big"), vtm.year); } rb_str_resize(str, sizeof(buf) + i + ysize); p = RSTRING_PTR(str) + sizeof(buf); - memcpy(p, buf, i); + memcpy(p, buf_year_extend, i); p += i; rb_integer_pack(year_extend, p, ysize, 1, 0, INTEGER_PACK_LITTLE_ENDIAN); } From 4b7a04a5b8a583e7e818155a73069a9e58a1a246 Mon Sep 17 00:00:00 2001 From: aycabta Date: Mon, 15 Jul 2019 07:51:57 +0900 Subject: [PATCH 150/452] Support multiline irb_history A history line ends with "\" to escape newline if it's a continuous line. --- lib/irb/ext/save-history.rb | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/irb/ext/save-history.rb b/lib/irb/ext/save-history.rb index 9aeb5dee0cbc7f..4ef6dbbd4e77f2 100644 --- a/lib/irb/ext/save-history.rb +++ b/lib/irb/ext/save-history.rb @@ -73,7 +73,16 @@ def load_history history_file = IRB.rc_file("_history") unless history_file if File.exist?(history_file) open(history_file) do |f| - f.each {|l| history << l.chomp} + f.each { |l| + l = l.chomp + $stderr.puts l.inspect + if history.last&.end_with?("\\") + history.last.delete_suffix!("\\") + history.last << "\n" << l + else + history << l + end + } end end end @@ -98,7 +107,14 @@ def save_history end open(history_file, 'w', 0600 ) do |f| - hist = history.to_a + hist = history.to_a.map { |l| + split_lines = l.split("\n") + if split_lines.size == 1 + l + else + split_lines.join("\\\n") + end + } f.puts(hist[-num..-1] || hist) end end From 266f6cd8a1dbf93ab5a99d3508f7f1cb5d348be1 Mon Sep 17 00:00:00 2001 From: aycabta Date: Mon, 15 Jul 2019 07:54:47 +0900 Subject: [PATCH 151/452] Remove debug print --- lib/irb/ext/save-history.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/irb/ext/save-history.rb b/lib/irb/ext/save-history.rb index 4ef6dbbd4e77f2..f7247898ab3dc7 100644 --- a/lib/irb/ext/save-history.rb +++ b/lib/irb/ext/save-history.rb @@ -75,7 +75,6 @@ def load_history open(history_file) do |f| f.each { |l| l = l.chomp - $stderr.puts l.inspect if history.last&.end_with?("\\") history.last.delete_suffix!("\\") history.last << "\n" << l From 772dae8bef36e3111b8e03fc6297cc99a959ae4b Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Mon, 15 Jul 2019 07:56:53 +0900 Subject: [PATCH 152/452] Add a /* fall through */ comment --- compile.c | 1 + 1 file changed, 1 insertion(+) diff --git a/compile.c b/compile.c index 9cba0b5d7ea133..c2f14a9350c28a 100644 --- a/compile.c +++ b/compile.c @@ -4483,6 +4483,7 @@ defined_expr0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, ADD_INSNL(ret, line, branchunless, lfinish[1]); } while ((vals = vals->nd_next) != NULL); } + /* fall through */ case NODE_STR: case NODE_LIT: case NODE_ZARRAY: From c9a59f491d0851c30e2f371eafcec486ce8ba27b Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Mon, 15 Jul 2019 07:59:11 +0900 Subject: [PATCH 153/452] Add a /* fall through */ comment --- compile.c | 1 + 1 file changed, 1 insertion(+) diff --git a/compile.c b/compile.c index c2f14a9350c28a..ddb081526cbc2f 100644 --- a/compile.c +++ b/compile.c @@ -3135,6 +3135,7 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal break; case BIN(leave): piobj = iobj; + /* fall through */ default: next = NULL; break; From 2b78a93bcfdc8884646cae88dffe06da6bdb6213 Mon Sep 17 00:00:00 2001 From: aycabta Date: Mon, 15 Jul 2019 07:58:15 +0900 Subject: [PATCH 154/452] Add lib/irb/color.rb to destribution file list --- lib/irb/irb.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/irb/irb.gemspec b/lib/irb/irb.gemspec index 1c2c4e6dd89e44..35e40efae04919 100644 --- a/lib/irb/irb.gemspec +++ b/lib/irb/irb.gemspec @@ -16,7 +16,7 @@ Gem::Specification.new do |spec| spec.homepage = "https://github.com/ruby/irb" spec.license = "BSD-2-Clause" - spec.files = ["LICENSE.txt", "README.md", "exe/irb", "irb.gemspec", "lib/irb.rb", "lib/irb/cmd/chws.rb", "lib/irb/cmd/fork.rb", "lib/irb/cmd/help.rb", "lib/irb/cmd/load.rb", "lib/irb/cmd/nop.rb", "lib/irb/cmd/pushws.rb", "lib/irb/cmd/subirb.rb", "lib/irb/completion.rb", "lib/irb/context.rb", "lib/irb/ext/change-ws.rb", "lib/irb/ext/history.rb", "lib/irb/ext/loader.rb", "lib/irb/ext/multi-irb.rb", "lib/irb/ext/save-history.rb", "lib/irb/ext/tracer.rb", "lib/irb/ext/use-loader.rb", "lib/irb/ext/workspaces.rb", "lib/irb/extend-command.rb", "lib/irb/frame.rb", "lib/irb/help.rb", "lib/irb/init.rb", "lib/irb/input-method.rb", "lib/irb/inspector.rb", "lib/irb/lc/.document", "lib/irb/lc/error.rb", "lib/irb/lc/help-message", "lib/irb/lc/ja/encoding_aliases.rb", "lib/irb/lc/ja/error.rb", "lib/irb/lc/ja/help-message", "lib/irb/locale.rb", "lib/irb/magic-file.rb", "lib/irb/notifier.rb", "lib/irb/output-method.rb", "lib/irb/ruby-lex.rb", "lib/irb/ruby-token.rb", "lib/irb/slex.rb", "lib/irb/src_encoding.rb", "lib/irb/version.rb", "lib/irb/workspace.rb", "lib/irb/ws-for-case-2.rb", "lib/irb/xmp.rb"] + spec.files = ["LICENSE.txt", "README.md", "exe/irb", "irb.gemspec", "lib/irb.rb", "lib/irb/cmd/chws.rb", "lib/irb/cmd/fork.rb", "lib/irb/cmd/help.rb", "lib/irb/cmd/load.rb", "lib/irb/cmd/nop.rb", "lib/irb/cmd/pushws.rb", "lib/irb/cmd/subirb.rb", "lib/irb/completion.rb", "lib/irb/context.rb", "lib/irb/color.rb", "lib/irb/ext/change-ws.rb", "lib/irb/ext/history.rb", "lib/irb/ext/loader.rb", "lib/irb/ext/multi-irb.rb", "lib/irb/ext/save-history.rb", "lib/irb/ext/tracer.rb", "lib/irb/ext/use-loader.rb", "lib/irb/ext/workspaces.rb", "lib/irb/extend-command.rb", "lib/irb/frame.rb", "lib/irb/help.rb", "lib/irb/init.rb", "lib/irb/input-method.rb", "lib/irb/inspector.rb", "lib/irb/lc/.document", "lib/irb/lc/error.rb", "lib/irb/lc/help-message", "lib/irb/lc/ja/encoding_aliases.rb", "lib/irb/lc/ja/error.rb", "lib/irb/lc/ja/help-message", "lib/irb/locale.rb", "lib/irb/magic-file.rb", "lib/irb/notifier.rb", "lib/irb/output-method.rb", "lib/irb/ruby-lex.rb", "lib/irb/ruby-token.rb", "lib/irb/slex.rb", "lib/irb/src_encoding.rb", "lib/irb/version.rb", "lib/irb/workspace.rb", "lib/irb/ws-for-case-2.rb", "lib/irb/xmp.rb"] spec.bindir = "exe" spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] From 13cb9e6bd2c88d04fc9b21b8f8c1d192c67cd5a2 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Mon, 15 Jul 2019 08:18:30 +0900 Subject: [PATCH 155/452] common.mk: remove "make exam" from help Currently it is completely the same as "make check". I think it is not worth mentioning now. --- common.mk | 1 - 1 file changed, 1 deletion(-) diff --git a/common.mk b/common.mk index 3ada59b7d1e19a..8c00cfa68e2bd9 100644 --- a/common.mk +++ b/common.mk @@ -1492,7 +1492,6 @@ help: PHONY " gdb: runs test.rb by miniruby under gdb" \ " gdb-ruby: runs test.rb by ruby under gdb" \ " check: equals make test test-all test-spec" \ - " exam: equals make check" \ " test: ruby core tests" \ " test-all: all ruby tests [TESTOPTS=-j4 TESTS=]" \ " test-spec: run the Ruby spec suite [SPECOPTS=]" \ From 1f99274ccf31ba1f2a4b3ac20a9c6cdc5ae81152 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Mon, 15 Jul 2019 08:19:49 +0900 Subject: [PATCH 156/452] Added the bundled gems target to make help. --- common.mk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/common.mk b/common.mk index 8c00cfa68e2bd9..6ccc14af985366 100644 --- a/common.mk +++ b/common.mk @@ -1497,6 +1497,8 @@ help: PHONY " test-spec: run the Ruby spec suite [SPECOPTS=]" \ " test-bundler: run the Bundler spec" \ " test-bundled-gems: run the test suite of bundled gems" \ + " update-gems: download files of the bundled gems" \ + " update-bundled_gems: update the latest version of bundled gems" \ " sync-default-gems: sync default gems from upstream [GEM=]" \ " up: update local copy and autogenerated files" \ " benchmark: benchmark this ruby and COMPARE_RUBY." \ From 9da969cae73b88a9e7acd761f184bd5275febdf7 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Mon, 15 Jul 2019 08:32:45 +0900 Subject: [PATCH 157/452] Revert "Dummy Makefile.in for CIs" This reverts commit c55de95ff1c4ea6313c2863037703a0e5f0d0f4f. Probably this is not needed for CI anymore. --- Makefile.in | 1 - 1 file changed, 1 deletion(-) delete mode 100644 Makefile.in diff --git a/Makefile.in b/Makefile.in deleted file mode 100644 index 87cafdcb1a6366..00000000000000 --- a/Makefile.in +++ /dev/null @@ -1 +0,0 @@ -# moved under template, remove after CIs succeed From 17ccda54131e3e8f59fc5bc5be044aef78e2854c Mon Sep 17 00:00:00 2001 From: aycabta Date: Mon, 15 Jul 2019 08:32:50 +0900 Subject: [PATCH 158/452] Use #to_a for Readline::HISTORY directly --- lib/irb/ext/save-history.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/irb/ext/save-history.rb b/lib/irb/ext/save-history.rb index f7247898ab3dc7..dfde9d6fae4da6 100644 --- a/lib/irb/ext/save-history.rb +++ b/lib/irb/ext/save-history.rb @@ -106,7 +106,7 @@ def save_history end open(history_file, 'w', 0600 ) do |f| - hist = history.to_a.map { |l| + hist = history.map { |l| split_lines = l.split("\n") if split_lines.size == 1 l From 02c4ed4a7f44a80d50c2d3e27f451b20c4360899 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Mon, 15 Jul 2019 08:36:51 +0900 Subject: [PATCH 159/452] Stop consuming 2 entries for goruby similar to 364f43ab7fc5920247fc73423c1428208cf78a4a and 13cb9e6bd2c88d04fc9b21b8f8c1d192c67cd5a2 --- common.mk | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/common.mk b/common.mk index 6ccc14af985366..ddc4aedcf7ffa6 100644 --- a/common.mk +++ b/common.mk @@ -1508,8 +1508,7 @@ help: PHONY " install-cross: install cross compiling stuff" \ " clean: clean for tarball" \ " distclean: clean for repository" \ - " golf: for golfers" \ - " goruby: same as golf" \ + " golf: build goruby for golfers" \ $(HELP_EXTRA_TASKS) \ "see DeveloperHowto for more detail: " \ " https://bugs.ruby-lang.org/projects/ruby/wiki/DeveloperHowto" \ From 0a417248a0ba6e4e5093f916dbf9b31e22f24078 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Mon, 15 Jul 2019 08:38:07 +0900 Subject: [PATCH 160/452] Fix unaligned help output 1f99274ccf31ba1f2a4b3ac20a9c6cdc5ae81152 was indenting details with a hard tab, but other lines are using spaces. --- common.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common.mk b/common.mk index ddc4aedcf7ffa6..ee8f9295952bee 100644 --- a/common.mk +++ b/common.mk @@ -1497,7 +1497,7 @@ help: PHONY " test-spec: run the Ruby spec suite [SPECOPTS=]" \ " test-bundler: run the Bundler spec" \ " test-bundled-gems: run the test suite of bundled gems" \ - " update-gems: download files of the bundled gems" \ + " update-gems: download files of the bundled gems" \ " update-bundled_gems: update the latest version of bundled gems" \ " sync-default-gems: sync default gems from upstream [GEM=]" \ " up: update local copy and autogenerated files" \ From a1975790731e1e9081e41e05b43516065b7d950a Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Mon, 15 Jul 2019 08:36:57 +0900 Subject: [PATCH 161/452] addr2line.c: clarify the type of integer expression to suppress Coverity Scan warning. This expression converted uint8_t to int, and then int to unsigned long. Now it directly converts uint8_t to unsigned long. --- addr2line.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addr2line.c b/addr2line.c index f6befce53e33d2..9e7df4e7fb0d93 100644 --- a/addr2line.c +++ b/addr2line.c @@ -432,7 +432,7 @@ parse_debug_line_cu(int num_traces, void **traces, char **debug_line, /*basic_block = 1; */ break; case DW_LNS_const_add_pc: - a = ((255 - header.opcode_base) / header.line_range) * + a = ((255UL - header.opcode_base) / header.line_range) * header.minimum_instruction_length; addr += a; break; From ff3704031a6c23ae2020576c4fecbdc6b1c91246 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Mon, 15 Jul 2019 09:26:57 +0900 Subject: [PATCH 162/452] Insert a newline before `=end` For a certain editor which cannot handle here-document properly. --- tool/rbinstall.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tool/rbinstall.rb b/tool/rbinstall.rb index 427d69f0f66901..9046249bfb1054 100755 --- a/tool/rbinstall.rb +++ b/tool/rbinstall.rb @@ -469,7 +469,8 @@ def CONFIG.[](name, mandatory = false) # -*- ruby -*- _=_\\ =begin -#{prolog_script}=end +#{prolog_script.chomp} +=end EOS installer = Struct.new(:ruby_shebang, :ruby_bin, :ruby_install_name, :stub, :trans) From 00a97d94122c256f4abe9375d19eaeb0f2eca201 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Mon, 15 Jul 2019 09:35:45 +0900 Subject: [PATCH 163/452] Always call va_end in form_args() This issue is detected by Coverity Scan. --- mjit_worker.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mjit_worker.c b/mjit_worker.c index c5df0b7fadde67..2ee9a5310e36bc 100644 --- a/mjit_worker.c +++ b/mjit_worker.c @@ -528,7 +528,8 @@ form_args(int num, ...) n = args_len(args); if ((tmp = (char **)realloc(res, sizeof(char *) * (len + n + 1))) == NULL) { free(res); - return NULL; + res = NULL; + break; } res = tmp; MEMCPY(res + len, args, char *, n + 1); From 8f7884761e30c453287d73de6ea733d565635ebc Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Mon, 15 Jul 2019 09:36:52 +0900 Subject: [PATCH 164/452] The default charset of text/* media type is UTF-8. Thanks for the patch gareth (Gareth Adams). [Bug #15933] ------- Combines two small, but very related changes 1: Treat HTTPS the same as HTTP Previously, OpenURI followed guidance in RFC2616/3.7.1: > When no explicit charset parameter is provided by the sender, media > subtypes of the "text" type are defined to have a default charset > value of "ISO-8859-1" when received via HTTP. However this RFC was written before TLS was established and OpenURI was never updated to treat HTTPS traffic the same way. So, HTTPS documents received a different default to HTTP documents. This commit removes the scheme check so that all text/* documents processed by OpenURI are treated the same way. In theory this processing gets applied to FTP URIs too, but there's no mechanism in OpenURI for FTP documents to have Content-Type metadata appended to them, so this ends up being a no-op. 2: Change default charset for text/* to UTF-8 Replaces the default ISO-8859-1 charset previously defined in RFC2616 (now obsoleted) with a UTF-8 charset as defined in RFC6838. Fixes: https://bugs.ruby-lang.org/issues/15933 --- NEWS | 5 ++++- lib/open-uri.rb | 9 ++++----- test/open-uri/test_open-uri.rb | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/NEWS b/NEWS index 390c7935928ef5..31f48984b5f740 100644 --- a/NEWS +++ b/NEWS @@ -212,7 +212,10 @@ Net::IMAP:: open-uri:: * Warn open-uri's "open" method at Kernel. - Use URI.open instead. + Use URI.open instead. [Misc #15893] + + * The default charset of text/* media type is UTF-8 instead of ISO-8859-1. + [Bug #15933] Pathname: diff --git a/lib/open-uri.rb b/lib/open-uri.rb index 3aeed06ed451c1..d9517e4b9e3b33 100644 --- a/lib/open-uri.rb +++ b/lib/open-uri.rb @@ -552,17 +552,16 @@ def content_type # It can be used to guess charset. # # If charset parameter and block is not given, - # nil is returned except text type in HTTP. - # In that case, "iso-8859-1" is returned as defined by RFC2616 3.7.1. + # nil is returned except text type. + # In that case, "utf-8" is returned as defined by RFC6838 4.2.1 def charset type, *parameters = content_type_parse if pair = parameters.assoc('charset') pair.last.downcase elsif block_given? yield - elsif type && %r{\Atext/} =~ type && - @base_uri && /\Ahttp\z/i =~ @base_uri.scheme - "iso-8859-1" # RFC2616 3.7.1 + elsif type && %r{\Atext/} =~ type + "utf-8" # RFC6838 4.2.1 else nil end diff --git a/test/open-uri/test_open-uri.rb b/test/open-uri/test_open-uri.rb index 39cf4201a2c969..0c7d77c3050d83 100644 --- a/test/open-uri/test_open-uri.rb +++ b/test/open-uri/test_open-uri.rb @@ -648,7 +648,7 @@ def test_encoding URI.open("#{url}/nc/") {|f| assert_equal("aa", f.read) assert_equal("text/plain", f.content_type) - assert_equal("iso-8859-1", f.charset) + assert_equal("utf-8", f.charset) assert_equal("unknown", f.charset { "unknown" }) } } From 0a711b0edff6eaf978cfc17cdd6a7cc6c17c6686 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Mon, 15 Jul 2019 08:34:24 +0900 Subject: [PATCH 165/452] Put vcs .rb to under the lib direcotory. Because it's the common library for tool files. --- tool/file2lastrev.rb | 2 +- tool/{ => lib}/vcs.rb | 0 tool/make-snapshot | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename tool/{ => lib}/vcs.rb (100%) diff --git a/tool/file2lastrev.rb b/tool/file2lastrev.rb index e39e7422d3e66a..68c660efaad347 100755 --- a/tool/file2lastrev.rb +++ b/tool/file2lastrev.rb @@ -7,7 +7,7 @@ # this file run with BASERUBY, which may be older than 1.9, so no # require_relative -require File.expand_path('../vcs', __FILE__) +require File.expand_path('../lib/vcs', __FILE__) Program = $0 diff --git a/tool/vcs.rb b/tool/lib/vcs.rb similarity index 100% rename from tool/vcs.rb rename to tool/lib/vcs.rb diff --git a/tool/make-snapshot b/tool/make-snapshot index fa234f5ca6a104..d6530b3842c722 100755 --- a/tool/make-snapshot +++ b/tool/make-snapshot @@ -7,7 +7,7 @@ require 'fileutils' require 'shellwords' require 'tmpdir' require 'pathname' -require File.expand_path("../vcs", __FILE__) +require File.expand_path("../lib/vcs", __FILE__) require File.expand_path("../colorize", __FILE__) STDOUT.sync = true From e8ddbc0239b9dfa32787e93c6942f085e5c42b49 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Mon, 15 Jul 2019 08:54:34 +0900 Subject: [PATCH 166/452] Put colorize to library directory. Same as 66299e7ca83d379d13abaa5411f3e0419334cabb --- tool/extlibs.rb | 2 +- tool/generic_erb.rb | 2 +- tool/leaked-globals | 2 +- tool/{ => lib}/colorize.rb | 0 tool/lib/test/unit.rb | 2 +- tool/make-snapshot | 2 +- tool/pure_parser.rb | 2 +- 7 files changed, 6 insertions(+), 6 deletions(-) rename tool/{ => lib}/colorize.rb (100%) diff --git a/tool/extlibs.rb b/tool/extlibs.rb index efae167bfa49d6..f021a2bf01a55b 100755 --- a/tool/extlibs.rb +++ b/tool/extlibs.rb @@ -5,7 +5,7 @@ require 'digest' require_relative 'downloader' -require_relative 'colorize' +require_relative 'lib/colorize' class ExtLibs def initialize diff --git a/tool/generic_erb.rb b/tool/generic_erb.rb index 3904b570c4a812..3184cbb9f82dfb 100644 --- a/tool/generic_erb.rb +++ b/tool/generic_erb.rb @@ -7,7 +7,7 @@ require 'optparse' $:.unshift(File.dirname(__FILE__)) require 'vpath' -require 'colorize' +require_relative 'lib/colorize' vpath = VPath.new timestamp = nil diff --git a/tool/leaked-globals b/tool/leaked-globals index 48e8ec74c71545..de17038704708b 100755 --- a/tool/leaked-globals +++ b/tool/leaked-globals @@ -1,5 +1,5 @@ #!/usr/bin/ruby -require_relative 'colorize' +require_relative 'lib/colorize' until ARGV.empty? case ARGV[0] diff --git a/tool/colorize.rb b/tool/lib/colorize.rb similarity index 100% rename from tool/colorize.rb rename to tool/lib/colorize.rb diff --git a/tool/lib/test/unit.rb b/tool/lib/test/unit.rb index 5a980603a5d505..d237a9a0e95bad 100644 --- a/tool/lib/test/unit.rb +++ b/tool/lib/test/unit.rb @@ -6,7 +6,7 @@ require 'minitest/unit' require 'test/unit/assertions' require_relative '../envutil' -require_relative '../../../tool/colorize' +require_relative '../colorize' require 'test/unit/testcase' require 'optparse' diff --git a/tool/make-snapshot b/tool/make-snapshot index d6530b3842c722..ad5fd879f38f38 100755 --- a/tool/make-snapshot +++ b/tool/make-snapshot @@ -8,7 +8,7 @@ require 'shellwords' require 'tmpdir' require 'pathname' require File.expand_path("../lib/vcs", __FILE__) -require File.expand_path("../colorize", __FILE__) +require File.expand_path("../lib/colorize", __FILE__) STDOUT.sync = true $srcdir ||= nil diff --git a/tool/pure_parser.rb b/tool/pure_parser.rb index 20d71079a08a37..4d5e86e543d009 100755 --- a/tool/pure_parser.rb +++ b/tool/pure_parser.rb @@ -1,6 +1,6 @@ #!/usr/bin/ruby -pi BEGIN { - require_relative 'colorize' + require_relative 'lib/colorize' colorize = Colorize.new file = ARGV.shift From 08b340d2f68daf6bbaba9be77ee7c17150bd7adb Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Mon, 15 Jul 2019 09:39:22 +0900 Subject: [PATCH 167/452] Separate the assertions of ruby core tests from test/unit/assertions. --- tool/lib/test/unit/assertions.rb | 207 +----------------------- tool/lib/test/unit/core_assertions.rb | 216 ++++++++++++++++++++++++++ 2 files changed, 218 insertions(+), 205 deletions(-) create mode 100644 tool/lib/test/unit/core_assertions.rb diff --git a/tool/lib/test/unit/assertions.rb b/tool/lib/test/unit/assertions.rb index 169a3dcc7e0b3e..0c68a93b02a94d 100644 --- a/tool/lib/test/unit/assertions.rb +++ b/tool/lib/test/unit/assertions.rb @@ -1,15 +1,12 @@ # frozen_string_literal: true require 'minitest/unit' +require 'test/unit/core_assertions' require 'pp' module Test module Unit module Assertions - include MiniTest::Assertions - - def mu_pp(obj) #:nodoc: - obj.pretty_inspect.chomp - end + include Test::Unit::CoreAssertions MINI_DIR = File.join(File.dirname(File.dirname(File.expand_path(__FILE__))), "minitest") #:nodoc: @@ -554,80 +551,6 @@ def assert_normal_exit(testsrc, message = '', child_env: nil, **opt) assert !status.signaled?, FailDesc[status, message, out] end - FailDesc = proc do |status, message = "", out = ""| - pid = status.pid - now = Time.now - faildesc = proc do - if signo = status.termsig - signame = Signal.signame(signo) - sigdesc = "signal #{signo}" - end - log = EnvUtil.diagnostic_reports(signame, pid, now) - if signame - sigdesc = "SIG#{signame} (#{sigdesc})" - end - if status.coredump? - sigdesc = "#{sigdesc} (core dumped)" - end - full_message = ''.dup - message = message.call if Proc === message - if message and !message.empty? - full_message << message << "\n" - end - full_message << "pid #{pid}" - full_message << " exit #{status.exitstatus}" if status.exited? - full_message << " killed by #{sigdesc}" if sigdesc - if out and !out.empty? - full_message << "\n" << out.b.gsub(/^/, '| ') - full_message.sub!(/(? marshal_error - ignore_stderr = nil - end - if res - if bt = res.backtrace - bt.each do |l| - l.sub!(/\A-:(\d+)/){"#{file}:#{line + $1.to_i}"} - end - bt.concat(caller) - else - res.set_backtrace(caller) - end - raise res unless SystemExit === res - end - - # really is it succeed? - unless ignore_stderr - # the body of assert_separately must not output anything to detect error - assert(stderr.empty?, FailDesc[status, "assert_separately failed with error message", stderr]) - end - assert(status.success?, FailDesc[status, "assert_separately failed", stderr]) - raise marshal_error if marshal_error - end - def assert_warning(pat, msg = nil) result = nil stderr = EnvUtil.with_default_internal(pat.encoding) { @@ -799,10 +671,6 @@ def assert_is_minus_zero(f) assert(1.0/f == -Float::INFINITY, "#{f} is not -0.0") end - def assert_file - AssertFile - end - # pattern_list is an array which contains regexp and :*. # :* means any sequence. # @@ -878,77 +746,6 @@ def assert_join_threads(threads, message = nil) end end - class << (AssertFile = Struct.new(:failure_message).new) - include Assertions - def assert_file_predicate(predicate, *args) - if /\Anot_/ =~ predicate - predicate = $' - neg = " not" - end - result = File.__send__(predicate, *args) - result = !result if neg - mesg = "Expected file ".dup << args.shift.inspect - mesg << "#{neg} to be #{predicate}" - mesg << mu_pp(args).sub(/\A\[(.*)\]\z/m, '(\1)') unless args.empty? - mesg << " #{failure_message}" if failure_message - assert(result, mesg) - end - alias method_missing assert_file_predicate - - def for(message) - clone.tap {|a| a.failure_message = message} - end - end - - class AllFailures - attr_reader :failures - - def initialize - @count = 0 - @failures = {} - end - - def for(key) - @count += 1 - yield - rescue Exception => e - @failures[key] = [@count, e] - end - - def foreach(*keys) - keys.each do |key| - @count += 1 - begin - yield key - rescue Exception => e - @failures[key] = [@count, e] - end - end - end - - def message - i = 0 - total = @count.to_s - fmt = "%#{total.size}d" - @failures.map {|k, (n, v)| - v = v.message - "\n#{i+=1}. [#{fmt%n}/#{total}] Assertion for #{k.inspect}\n#{v.b.gsub(/^/, ' | ').force_encoding(v.encoding)}" - }.join("\n") - end - - def pass? - @failures.empty? - end - end - - def assert_all_assertions(msg = nil) - all = AllFailures.new - yield all - ensure - assert(all.pass?, message(msg) {all.message.chomp(".")}) - end - alias all_assertions assert_all_assertions - def assert_all_assertions_foreach(msg = nil, *keys, &block) all = AllFailures.new all.foreach(*keys, &block) diff --git a/tool/lib/test/unit/core_assertions.rb b/tool/lib/test/unit/core_assertions.rb new file mode 100644 index 00000000000000..21be860176b5f0 --- /dev/null +++ b/tool/lib/test/unit/core_assertions.rb @@ -0,0 +1,216 @@ +# frozen_string_literal: true + +require_relative '../../envutil' + +module Test + module Unit + module CoreAssertions + include MiniTest::Assertions + + def mu_pp(obj) #:nodoc: + obj.pretty_inspect.chomp + end + + def assert_file + AssertFile + end + + FailDesc = proc do |status, message = "", out = ""| + pid = status.pid + now = Time.now + faildesc = proc do + if signo = status.termsig + signame = Signal.signame(signo) + sigdesc = "signal #{signo}" + end + log = EnvUtil.diagnostic_reports(signame, pid, now) + if signame + sigdesc = "SIG#{signame} (#{sigdesc})" + end + if status.coredump? + sigdesc = "#{sigdesc} (core dumped)" + end + full_message = ''.dup + message = message.call if Proc === message + if message and !message.empty? + full_message << message << "\n" + end + full_message << "pid #{pid}" + full_message << " exit #{status.exitstatus}" if status.exited? + full_message << " killed by #{sigdesc}" if sigdesc + if out and !out.empty? + full_message << "\n" << out.b.gsub(/^/, '| ') + full_message.sub!(/(? marshal_error + ignore_stderr = nil + end + if res + if bt = res.backtrace + bt.each do |l| + l.sub!(/\A-:(\d+)/){"#{file}:#{line + $1.to_i}"} + end + bt.concat(caller) + else + res.set_backtrace(caller) + end + raise res unless SystemExit === res + end + + # really is it succeed? + unless ignore_stderr + # the body of assert_separately must not output anything to detect error + assert(stderr.empty?, FailDesc[status, "assert_separately failed with error message", stderr]) + end + assert(status.success?, FailDesc[status, "assert_separately failed", stderr]) + raise marshal_error if marshal_error + end + + class << (AssertFile = Struct.new(:failure_message).new) + include CoreAssertions + def assert_file_predicate(predicate, *args) + if /\Anot_/ =~ predicate + predicate = $' + neg = " not" + end + result = File.__send__(predicate, *args) + result = !result if neg + mesg = "Expected file ".dup << args.shift.inspect + mesg << "#{neg} to be #{predicate}" + mesg << mu_pp(args).sub(/\A\[(.*)\]\z/m, '(\1)') unless args.empty? + mesg << " #{failure_message}" if failure_message + assert(result, mesg) + end + alias method_missing assert_file_predicate + + def for(message) + clone.tap {|a| a.failure_message = message} + end + end + + class AllFailures + attr_reader :failures + + def initialize + @count = 0 + @failures = {} + end + + def for(key) + @count += 1 + yield + rescue Exception => e + @failures[key] = [@count, e] + end + + def foreach(*keys) + keys.each do |key| + @count += 1 + begin + yield key + rescue Exception => e + @failures[key] = [@count, e] + end + end + end + + def message + i = 0 + total = @count.to_s + fmt = "%#{total.size}d" + @failures.map {|k, (n, v)| + v = v.message + "\n#{i+=1}. [#{fmt%n}/#{total}] Assertion for #{k.inspect}\n#{v.b.gsub(/^/, ' | ').force_encoding(v.encoding)}" + }.join("\n") + end + + def pass? + @failures.empty? + end + end + + def assert_all_assertions(msg = nil) + all = AllFailures.new + yield all + ensure + assert(all.pass?, message(msg) {all.message.chomp(".")}) + end + alias all_assertions assert_all_assertions + + end + end +end From 223854ebe858a96560faac239f4c0e40d1af3943 Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Mon, 15 Jul 2019 09:58:26 +0900 Subject: [PATCH 168/452] catch up e8ddbc0239. --- ext/extmk.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/extmk.rb b/ext/extmk.rb index 1389dc41178fda..6045750fd21f94 100755 --- a/ext/extmk.rb +++ b/ext/extmk.rb @@ -688,8 +688,8 @@ def mf.macro(name, values, max = 70) submakeopts << 'UPDATE_LIBRARIES="$(UPDATE_LIBRARIES)"' submakeopts << 'SHOWFLAGS=' mf.macro "SUBMAKEOPTS", submakeopts - mf.macro "NOTE_MESG", %w[$(RUBY) $(top_srcdir)/tool/colorize.rb skip] - mf.macro "NOTE_NAME", %w[$(RUBY) $(top_srcdir)/tool/colorize.rb fail] + mf.macro "NOTE_MESG", %w[$(RUBY) $(top_srcdir)/tool/lib/colorize.rb skip] + mf.macro "NOTE_NAME", %w[$(RUBY) $(top_srcdir)/tool/lib/colorize.rb fail] mf.puts targets = %w[all install static install-so install-rb clean distclean realclean] targets.each do |tgt| From eed9db39e51f08fa84cbc20ffc7496f93828c06d Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Mon, 15 Jul 2019 10:11:07 +0900 Subject: [PATCH 169/452] Followed up e8ddbc0239. --- defs/gmake.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/defs/gmake.mk b/defs/gmake.mk index ea02d75e7a86a8..4a3d1c857c90ce 100644 --- a/defs/gmake.mk +++ b/defs/gmake.mk @@ -282,5 +282,5 @@ clean-srcs-extra:: ifneq ($(filter $(VCS),git),) update-src:: - @$(BASERUBY) $(srcdir)/tool/colorize.rb pass "Latest commit hash = $(shell $(filter-out svn,$(VCS)) -C $(srcdir) rev-parse --short=10 HEAD)" + @$(BASERUBY) $(srcdir)/tool/lib/colorize.rb pass "Latest commit hash = $(shell $(filter-out svn,$(VCS)) -C $(srcdir) rev-parse --short=10 HEAD)" endif From 0af897ab59dfa3d06724f898f17bbf8a1970abd1 Mon Sep 17 00:00:00 2001 From: aycabta Date: Mon, 15 Jul 2019 10:20:07 +0900 Subject: [PATCH 170/452] Simplify history saving code --- lib/irb/ext/save-history.rb | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/lib/irb/ext/save-history.rb b/lib/irb/ext/save-history.rb index dfde9d6fae4da6..57ba7c1c53cfba 100644 --- a/lib/irb/ext/save-history.rb +++ b/lib/irb/ext/save-history.rb @@ -106,14 +106,7 @@ def save_history end open(history_file, 'w', 0600 ) do |f| - hist = history.map { |l| - split_lines = l.split("\n") - if split_lines.size == 1 - l - else - split_lines.join("\\\n") - end - } + hist = history.map{ |l| l.split("\n").join("\\\n") } f.puts(hist[-num..-1] || hist) end end From f6f09cbc76c3e47aec23898e024ff5bb5f061bc4 Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Mon, 15 Jul 2019 10:19:25 +0900 Subject: [PATCH 171/452] introduce RUBY_ASSERT_ALWAYS(expr). RUBY_ASSERT_ALWAYS(expr) ignores NDEBUG (we cannot remove this assertion). --- array.c | 2 +- include/ruby/assert.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/array.c b/array.c index 31f078610d06ad..c693b007554a1d 100644 --- a/array.c +++ b/array.c @@ -1125,7 +1125,7 @@ ary_take_first_or_last(int argc, const VALUE *argv, VALUE ary, enum ary_take_pos /* the case optional argument is omitted should be handled in * callers of this function. if another arity case is added, * this arity check needs to rewrite. */ - RUBY_ASSERT_WHEN(TRUE, argc == 1); + RUBY_ASSERT_ALWAYS(argc == 1); n = NUM2LONG(argv[0]); len = RARRAY_LEN(ary); diff --git a/include/ruby/assert.h b/include/ruby/assert.h index f8930a7bba2dde..a5ee396f6b85a6 100644 --- a/include/ruby/assert.h +++ b/include/ruby/assert.h @@ -30,6 +30,7 @@ NORETURN(void rb_assert_failure(const char *, int, const char *, const char *)); #endif #define RUBY_ASSERT(expr) RUBY_ASSERT_MESG_WHEN(RUBY_DEBUG+(!RUBY_NDEBUG+0), expr, #expr) #define RUBY_ASSERT_WHEN(cond, expr) RUBY_ASSERT_MESG_WHEN(cond, expr, #expr) +#define RUBY_ASSERT_ALWAYS(expr) RUBY_ASSERT_MESG_WHEN(TRUE, expr, #expr) #ifndef RUBY_DEBUG # define RUBY_DEBUG 0 From b78964883037470f25755db740c09e835eadb5c9 Mon Sep 17 00:00:00 2001 From: Kazuhiro NISHIYAMA Date: Mon, 15 Jul 2019 10:26:50 +0900 Subject: [PATCH 172/452] Change PROMPT_S of simple-prompt When input `"` or `/` with simple-prompt, Before: `"` or `/` (prompt disappeared and indent is changed) After: `"> "` or `/> /` (indent is unchanged since `>> `) --- lib/irb/init.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/irb/init.rb b/lib/irb/init.rb index 8a9215f5f9f6ee..d7ee885665440c 100644 --- a/lib/irb/init.rb +++ b/lib/irb/init.rb @@ -83,7 +83,7 @@ def IRB.init_config(ap_path) :SIMPLE => { :PROMPT_I => ">> ", :PROMPT_N => ">> ", - :PROMPT_S => nil, + :PROMPT_S => "%l> ", :PROMPT_C => "?> ", :RETURN => "=> %s\n" }, From a191009a266e97453971f9b24f750861855aaa7b Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Mon, 15 Jul 2019 10:29:39 +0900 Subject: [PATCH 173/452] Simplify start_process by exploiting C99 Having a block for mixing a declaration was confusing. Also I moved `dev_null` and `pid` to limit their scope. --- mjit_worker.c | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/mjit_worker.c b/mjit_worker.c index 2ee9a5310e36bc..27af15b2a893ab 100644 --- a/mjit_worker.c +++ b/mjit_worker.c @@ -548,36 +548,32 @@ COMPILER_WARNING_IGNORED(-Wdeprecated-declarations) static pid_t start_process(const char *abspath, char *const *argv) { - pid_t pid; - // Not calling non-async-signal-safe functions between vfork - // and execv for safety - int dev_null = rb_cloexec_open(ruby_null_device, O_WRONLY, 0); - if (mjit_opts.verbose >= 2) { - int i; const char *arg; - fprintf(stderr, "Starting process: %s", abspath); - for (i = 0; (arg = argv[i]) != NULL; i++) + for (int i = 0; (arg = argv[i]) != NULL; i++) fprintf(stderr, " %s", arg); fprintf(stderr, "\n"); } + + // Not calling non-async-signal-safe functions between vfork + // and execv for safety + int dev_null = rb_cloexec_open(ruby_null_device, O_WRONLY, 0); + pid_t pid; #ifdef _WIN32 - { - extern HANDLE rb_w32_start_process(const char *abspath, char *const *argv, int out_fd); - int out_fd = 0; - if (mjit_opts.verbose <= 1) { - // Discard cl.exe's outputs like: - // _ruby_mjit_p12u3.c - // Creating library C:.../_ruby_mjit_p12u3.lib and object C:.../_ruby_mjit_p12u3.exp - out_fd = dev_null; - } + extern HANDLE rb_w32_start_process(const char *abspath, char *const *argv, int out_fd); + int out_fd = 0; + if (mjit_opts.verbose <= 1) { + // Discard cl.exe's outputs like: + // _ruby_mjit_p12u3.c + // Creating library C:.../_ruby_mjit_p12u3.lib and object C:.../_ruby_mjit_p12u3.exp + out_fd = dev_null; + } - pid = (pid_t)rb_w32_start_process(abspath, argv, out_fd); - if (pid == 0) { - verbose(1, "MJIT: Failed to create process: %s", dlerror()); - return -1; - } + pid = (pid_t)rb_w32_start_process(abspath, argv, out_fd); + if (pid == 0) { + verbose(1, "MJIT: Failed to create process: %s", dlerror()); + return -1; } #else if ((pid = vfork()) == 0) { /* TODO: reuse some function in process.c */ From dd4f128ac5fa26e3d8c4d003c770e69f9ed9a91e Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Mon, 15 Jul 2019 10:38:59 +0900 Subject: [PATCH 174/452] Handle failure of opening a null device This issue is detected by Coverity Scan. --- mjit_worker.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mjit_worker.c b/mjit_worker.c index 27af15b2a893ab..aeb9446e449e7a 100644 --- a/mjit_worker.c +++ b/mjit_worker.c @@ -548,6 +548,13 @@ COMPILER_WARNING_IGNORED(-Wdeprecated-declarations) static pid_t start_process(const char *abspath, char *const *argv) { + // Not calling non-async-signal-safe functions between vfork + // and execv for safety + int dev_null = rb_cloexec_open(ruby_null_device, O_WRONLY, 0); + if (dev_null < 0) { + verbose(1, "MJIT: Failed to open a null device: %s", strerror(errno)); + return -1; + } if (mjit_opts.verbose >= 2) { const char *arg; fprintf(stderr, "Starting process: %s", abspath); @@ -556,9 +563,6 @@ start_process(const char *abspath, char *const *argv) fprintf(stderr, "\n"); } - // Not calling non-async-signal-safe functions between vfork - // and execv for safety - int dev_null = rb_cloexec_open(ruby_null_device, O_WRONLY, 0); pid_t pid; #ifdef _WIN32 extern HANDLE rb_w32_start_process(const char *abspath, char *const *argv, int out_fd); From f326b4f4af4963e252d24c4f7d7099fc607db859 Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Mon, 15 Jul 2019 10:39:28 +0900 Subject: [PATCH 175/452] simplify around GC_ASSERT() --- gc.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/gc.c b/gc.c index a5e11f8032f87e..f1e9ecf47c0fae 100644 --- a/gc.c +++ b/gc.c @@ -236,11 +236,8 @@ int ruby_rgengc_debug; #define RGENGC_CHECK_MODE 0 #endif -#if RGENGC_CHECK_MODE > 0 +// Note: using RUBY_ASSERT_WHEN() extend a macro in expr (info by nobu). #define GC_ASSERT(expr) RUBY_ASSERT_MESG_WHEN(RGENGC_CHECK_MODE > 0, expr, #expr) -#else -#define GC_ASSERT(expr) ((void)0) -#endif /* RGENGC_OLD_NEWOBJ_CHECK * 0: disable all assertions @@ -1946,8 +1943,8 @@ static inline VALUE newobj_init(VALUE klass, VALUE flags, VALUE v1, VALUE v2, VALUE v3, int wb_protected, rb_objspace_t *objspace, VALUE obj) { #if !__has_feature(memory_sanitizer) - assert(BUILTIN_TYPE(obj) == T_NONE); - assert((flags & FL_WB_PROTECTED) == 0); + GC_ASSERT(BUILTIN_TYPE(obj) == T_NONE); + GC_ASSERT((flags & FL_WB_PROTECTED) == 0); #endif /* OBJSETUP */ @@ -2339,7 +2336,7 @@ obj_free(rb_objspace_t *objspace, VALUE obj) FL_UNSET(obj, FL_SEEN_OBJ_ID); if (st_delete(objspace->obj_to_id_tbl, (st_data_t *)&obj, &id)) { - assert(id); + GC_ASSERT(id); st_delete(objspace->id_to_obj_tbl, (st_data_t *)&id, NULL); } else { @@ -3439,11 +3436,11 @@ cached_object_id(VALUE obj) rb_objspace_t *objspace = &rb_objspace; if (st_lookup(objspace->obj_to_id_tbl, (st_data_t)obj, &id)) { - assert(FL_TEST(obj, FL_SEEN_OBJ_ID)); + GC_ASSERT(FL_TEST(obj, FL_SEEN_OBJ_ID)); return nonspecial_obj_id(id); } else { - assert(!FL_TEST(obj, FL_SEEN_OBJ_ID)); + GC_ASSERT(!FL_TEST(obj, FL_SEEN_OBJ_ID)); id = obj; while (1) { From e2512cff05b1d1cc60a03ef4388cab07531877ca Mon Sep 17 00:00:00 2001 From: aycabta Date: Mon, 15 Jul 2019 10:39:44 +0900 Subject: [PATCH 176/452] Move a test file of Reline to test/reline/ --- test/{ => reline}/test_history.rb | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/{ => reline}/test_history.rb (100%) diff --git a/test/test_history.rb b/test/reline/test_history.rb similarity index 100% rename from test/test_history.rb rename to test/reline/test_history.rb From 05cc87df1b5f7a125e24d64058d9ad1f75cdfd3f Mon Sep 17 00:00:00 2001 From: Kazuhiro NISHIYAMA Date: Mon, 15 Jul 2019 10:51:58 +0900 Subject: [PATCH 177/452] [DOC] Struct::Passwd#uclass renamed from #class at r2500 [ci skip] --- doc/etc.rd.ja | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/etc.rd.ja b/doc/etc.rd.ja index b4ff6ed04ebfa7..5d64594fc3b095 100644 --- a/doc/etc.rd.ja +++ b/doc/etc.rd.ja @@ -31,7 +31,7 @@ change # パスワード変更時間(整数) quota # クォータ(整数) age # エージ(整数) - class # ユーザアクセスクラス(文字列) + uclass # ユーザアクセスクラス(文字列) comment # コメント(文字列) expire # アカウント有効期限(整数) end From a7fdb22373442bb25e687a8f2df36fb5b85d2846 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Mon, 15 Jul 2019 11:00:16 +0900 Subject: [PATCH 178/452] Enable RUBY_ASSERT_MESG_WHEN when RUBY_DEBUG is turned on --- include/ruby/assert.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/include/ruby/assert.h b/include/ruby/assert.h index a5ee396f6b85a6..d19d8e4e3203b3 100644 --- a/include/ruby/assert.h +++ b/include/ruby/assert.h @@ -20,15 +20,16 @@ NORETURN(void rb_assert_failure(const char *, int, const char *, const char *)); ((expr) ? (void)0 : RUBY_ASSERT_FAIL(mesg)) #ifdef HAVE_BUILTIN___BUILTIN_CHOOSE_EXPR_CONSTANT_P # define RUBY_ASSERT_MESG_WHEN(cond, expr, mesg) \ + ((RUBY_DEBUG+0) ? RUBY_ASSERT_MESG((expr), mesg) : \ __builtin_choose_expr( \ __builtin_constant_p(cond), \ __builtin_choose_expr(cond, RUBY_ASSERT_MESG(expr, mesg), (void)0), \ - RUBY_ASSERT_MESG(!(cond) || (expr), mesg)) + RUBY_ASSERT_MESG(!(cond) || (expr), mesg))) #else # define RUBY_ASSERT_MESG_WHEN(cond, expr, mesg) \ - RUBY_ASSERT_MESG(!(cond) || (expr), mesg) + RUBY_ASSERT_MESG(!((RUBY_DEBUG+0) || (cond)) || (expr), mesg) #endif -#define RUBY_ASSERT(expr) RUBY_ASSERT_MESG_WHEN(RUBY_DEBUG+(!RUBY_NDEBUG+0), expr, #expr) +#define RUBY_ASSERT(expr) RUBY_ASSERT_MESG_WHEN((!RUBY_NDEBUG+0), expr, #expr) #define RUBY_ASSERT_WHEN(cond, expr) RUBY_ASSERT_MESG_WHEN(cond, expr, #expr) #define RUBY_ASSERT_ALWAYS(expr) RUBY_ASSERT_MESG_WHEN(TRUE, expr, #expr) From 226d569e5729bc9ffa5a516f88251d99f404c7c7 Mon Sep 17 00:00:00 2001 From: Kazuhiro NISHIYAMA Date: Mon, 15 Jul 2019 11:01:57 +0900 Subject: [PATCH 179/452] doc/irb/irb.rd.ja: Update options from `irb -h` [ci skip] --- doc/irb/irb.rd.ja | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/doc/irb/irb.rd.ja b/doc/irb/irb.rd.ja index 6ef6e9c1f6a595..31b7cdf3e3a81e 100644 --- a/doc/irb/irb.rd.ja +++ b/doc/irb/irb.rd.ja @@ -40,39 +40,44 @@ irbの使い方は, Rubyさえ知っていればいたって簡単です. 基本 irb.rb [options] file_name opts options: -f ~/.irbrc を読み込まない. - -m bcモード(分数, 行列の計算ができる) -d $DEBUG をtrueにする(ruby -d と同じ) - -Kc ruby -Kcと同じ -r load-module ruby -r と同じ. - --verbose これから実行する行を表示する(デフォルト) - --noverbose これから実行する行を表示しない - --echo 実行結果を表示する(デフォルト) - --noecho 実行結果を表示しない - --inspect 結果出力にinspectを用いる(bcモード以外はデフォルト). + -I path $LOAD_PATH に path を追加する. + -U ruby -U と同じ. + -E enc ruby -E と同じ. + -w ruby -w と同じ. + -W[level=2] ruby -W と同じ. + --context-mode n 新しいワークスペースを作成した時に関連する Binding + オブジェクトの作成方法を 0 から 3 のいずれかに設定する. + --echo 実行結果を表示する(デフォルト). + --noecho 実行結果を表示しない. + --inspect 結果出力にinspectを用いる. --noinspect 結果出力にinspectを用いない. --readline readlineライブラリを利用する. - --noreadline readlineライブラリを利用しない. デフォルトの動作は, - inf-ruby-mode以外でreadlineライブラリを利用しよう - とする. + --noreadline readlineライブラリを利用しない. --colorize 色付けを利用する. --nocolorize 色付けを利用しない. - --prompt prompt-mode - --prompt-mode prompt-mode + --prompt prompt-mode/--prompt-mode prompt-mode プロンプトモードを切替えます. 現在定義されているプ ロンプトモードは, default, simple, xmp, inf-rubyが - 用意されています. デフォルトはdefaultプロンプトモー - ドになっています. - + 用意されています. --inf-ruby-mode emacsのinf-ruby-mode用のプロンプト表示を行なう. 特 に指定がない限り, readlineライブラリは使わなくなる. - --simple-prompt + --sample-book-mode/--simple-prompt 非常にシンプルなプロンプトを用いるモードです. --noprompt プロンプト表示を行なわない. + --single-irb irb 中で self を実行して得られるオブジェクトをサ + ブ irb と共有する. --tracer コマンド実行時にトレースを行なう. --back-trace-limit n バックトレース表示をバックトレースの頭から n, 後ろ からnだけ行なう. デフォルトは16 - -v, --version irbのバージョンを表示する + + --verbose 詳細なメッセージを出力する. + --noverbose 詳細なメッセージを出力しない(デフォルト). + -v, --version irbのバージョンを表示する. + -h, --help irb のヘルプを表示する. + -- 以降のコマンドライン引数をオプションとして扱わない. = コンフィギュレーション From 73346823e1119a8e72baefab381dbe822c4c01f7 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Mon, 15 Jul 2019 11:04:12 +0900 Subject: [PATCH 180/452] Try to prevent random build failure on Travis osx --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 03f110702ecbb2..56320ec118082b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -334,6 +334,8 @@ env: - TEST_ALL_ISOLATED_TESTS="../test/ruby/test_gc_compact.rb" # Disabling -j3 because it seems to cause a hang on building Ruby: https://travis-ci.org/ruby/ruby/jobs/471021727 - JOBS= + # Prevent random failure by missing build dependency like https://travis-ci.org/ruby/ruby/jobs/558571461 + - ALWAYS_UPDATE_UNICODE=yes - &dependency name: Check dependencies in makefiles From 41c5f9a166637bf9e49af19b3fa94163b51db64d Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Mon, 15 Jul 2019 10:43:12 +0900 Subject: [PATCH 181/452] Put jisx0208.rb to under the library directory. --- tool/enc-emoji-citrus-gen.rb | 2 +- tool/{ => lib}/jisx0208.rb | 0 tool/test/test_jisx0208.rb | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename tool/{ => lib}/jisx0208.rb (100%) diff --git a/tool/enc-emoji-citrus-gen.rb b/tool/enc-emoji-citrus-gen.rb index 94864e5fa072cf..da9c8a6b6222b3 100644 --- a/tool/enc-emoji-citrus-gen.rb +++ b/tool/enc-emoji-citrus-gen.rb @@ -1,4 +1,4 @@ -require File.expand_path('../jisx0208', __FILE__) +require File.expand_path('../lib/jisx0208', __FILE__) ENCODES = [ { diff --git a/tool/jisx0208.rb b/tool/lib/jisx0208.rb similarity index 100% rename from tool/jisx0208.rb rename to tool/lib/jisx0208.rb diff --git a/tool/test/test_jisx0208.rb b/tool/test/test_jisx0208.rb index 703ee36f584524..98f216ff4ff9d5 100644 --- a/tool/test/test_jisx0208.rb +++ b/tool/test/test_jisx0208.rb @@ -1,6 +1,6 @@ require 'test/unit' -require_relative '../jisx0208' +require_relative '../lib/jisx0208' class Test_JISX0208_Char < Test::Unit::TestCase def test_create_with_row_cell From ac6d137157121381fb57e3febd34c84cb7ca47b2 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Mon, 15 Jul 2019 11:16:05 +0900 Subject: [PATCH 182/452] Added test-tool target for the test suite of tool/test files. --- common.mk | 8 +++++++- tool/test/runner.rb | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 tool/test/runner.rb diff --git a/common.mk b/common.mk index ee8f9295952bee..8f45b1e851a8ce 100644 --- a/common.mk +++ b/common.mk @@ -187,6 +187,7 @@ INSTALL_DATA_MODE = 0644 TESTSDIR = $(srcdir)/test TOOL_TESTSDIR = $(srcdir)/tool/test TEST_EXCLUDES = --excludes-dir=$(TESTSDIR)/excludes --name=!/memory_leak/ +EXCLUDE_TESTFRAMEWORK = --exclude=/testunit/ --exclude=/minitest/ TESTWORKDIR = testwork TESTOPTS = $(RUBY_TESTOPTS) @@ -753,9 +754,14 @@ yes-test-knownbug: prog PHONY test-testframework: $(TEST_RUNNABLE)-test-testframework yes-test-testframework: prog PHONY - $(gnumake_recursive)$(Q)$(exec) $(RUNRUBY) "$(srcdir)/test/runner.rb" --ruby="$(RUNRUBY)" --basedir=$(TOOL_TESTSDIR) $(TESTOPTS) testunit minitest + $(gnumake_recursive)$(Q)$(exec) $(RUNRUBY) "$(TOOL_TESTSDIR)/runner.rb" --ruby="$(RUNRUBY)" --basedir=$(TOOL_TESTSDIR) $(TESTOPTS) testunit minitest no-test-testframework: PHONY +test-tool: $(TEST_RUNNABLE)-test-tool +yes-test-tool: prog PHONY + $(gnumake_recursive)$(Q)$(exec) $(RUNRUBY) "$(TOOL_TESTSDIR)/runner.rb" --ruby="$(RUNRUBY)" --basedir=$(TOOL_TESTSDIR) $(TESTOPTS) $(EXCLUDE_TESTFRAMEWORK) +no-test-tool: PHONY + test-sample: test-basic # backward compatibility for mswin-build test-short: btest-ruby test-knownbug test-basic test: test-short diff --git a/tool/test/runner.rb b/tool/test/runner.rb new file mode 100644 index 00000000000000..64f6df167edd70 --- /dev/null +++ b/tool/test/runner.rb @@ -0,0 +1,39 @@ +# frozen_string_literal: false +require 'rbconfig' + +src_testdir = File.dirname(File.realpath(__FILE__)) +$LOAD_PATH << src_testdir +tool_dir = File.join src_testdir, ".." +$LOAD_PATH.unshift "#{tool_dir}/lib" + +# Get bundled gems on load path +Dir.glob("#{src_testdir}/../gems/*/*.gemspec") + .reject {|f| f =~ /minitest|test-unit|power_assert/ } + .map {|f| $LOAD_PATH.unshift File.join(File.dirname(f), "lib") } + +require 'test/unit' + +module Gem +end +class Gem::TestCase < MiniTest::Unit::TestCase + @@project_dir = File.dirname($LOAD_PATH.last) +end + +ENV["GEM_SKIP"] = ENV["GEM_HOME"] = ENV["GEM_PATH"] = "".freeze + +require_relative "#{tool_dir}/lib/profile_test_all" if ENV.has_key?('RUBY_TEST_ALL_PROFILE') +require_relative "#{tool_dir}/lib/tracepointchecker" +require_relative "#{tool_dir}/lib/zombie_hunter" +require_relative "#{tool_dir}/lib/iseq_loader_checker" + +if ENV['COVERAGE'] + require_relative "#{tool_dir}/test-coverage.rb" +end + +begin + exit Test::Unit::AutoRunner.run(true, src_testdir) +rescue NoMemoryError + system("cat /proc/meminfo") if File.exist?("/proc/meminfo") + system("ps x -opid,args,%cpu,%mem,nlwp,rss,vsz,wchan,stat,start,time,etime,blocked,caught,ignored,pending,f") if File.exist?("/bin/ps") + raise +end From d02f2fc3e2b4d14793c3b25079787a8972ce49c8 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Mon, 15 Jul 2019 11:19:13 +0900 Subject: [PATCH 183/452] Added help message for test-tool target. --- common.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/common.mk b/common.mk index 8f45b1e851a8ce..de62185e845dbd 100644 --- a/common.mk +++ b/common.mk @@ -1503,6 +1503,7 @@ help: PHONY " test-spec: run the Ruby spec suite [SPECOPTS=]" \ " test-bundler: run the Bundler spec" \ " test-bundled-gems: run the test suite of bundled gems" \ + " test-tool: tests under the tool/test" \ " update-gems: download files of the bundled gems" \ " update-bundled_gems: update the latest version of bundled gems" \ " sync-default-gems: sync default gems from upstream [GEM=]" \ From c23e5976744f1984b309f0af724fbd8ddea2c56a Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Mon, 15 Jul 2019 11:27:38 +0900 Subject: [PATCH 184/452] respect RUBY_DEBUG. see RUBY_DEBUG for each debug options. --- hash.c | 4 ++-- internal.h | 2 +- vm_core.h | 7 +++++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/hash.c b/hash.c index df77e898a13390..9c2da83fee966d 100644 --- a/hash.c +++ b/hash.c @@ -394,9 +394,10 @@ ar_empty_entry(ar_table_entry *entry) #define RHASH_TYPE(hash) (RHASH_AR_TABLE_P(hash) ? &objhash : RHASH_ST_TABLE(hash)->type) #define RHASH_AR_TABLE_REF(hash, n) (&RHASH_AR_TABLE(hash)->entries[n]) +#define HASH_ASSERT(expr) RUBY_ASSERT_MESG_WHEN(1, expr, #expr) + #if HASH_DEBUG #define hash_verify(hash) hash_verify_(hash, __FILE__, __LINE__) -#define HASH_ASSERT(expr) RUBY_ASSERT_MESG_WHEN(1, expr, #expr) void rb_hash_dump(VALUE hash) @@ -471,7 +472,6 @@ hash_verify_(VALUE hash, const char *file, int line) #else #define hash_verify(h) ((void)0) -#define HASH_ASSERT(e) ((void)0) #endif static inline int diff --git a/internal.h b/internal.h index 0539d49f5baff0..fb184e290cd444 100644 --- a/internal.h +++ b/internal.h @@ -1302,7 +1302,7 @@ VALUE rb_gvar_defined(struct rb_global_entry *); /* array.c */ #ifndef ARRAY_DEBUG -#define ARRAY_DEBUG 0 +#define ARRAY_DEBUG (0+RUBY_DEBUG) #endif #ifdef ARRAY_DEBUG diff --git a/vm_core.h b/vm_core.h index 8ebdadb08a0e77..0120f21831c262 100644 --- a/vm_core.h +++ b/vm_core.h @@ -17,7 +17,11 @@ * 1: enable local assertions. */ #ifndef VM_CHECK_MODE -#define VM_CHECK_MODE 0 + +// respect RUBY_DUBUG: if given n is 0, then use RUBY_DEBUG +#define N_OR_RUBY_DEBUG(n) (((n) > 0) ? (n) : RUBY_DEBUG) + +#define VM_CHECK_MODE N_OR_RUBY_DEBUG(0) #endif /** @@ -46,7 +50,6 @@ #if VM_CHECK_MODE > 0 #define VM_ASSERT(expr) RUBY_ASSERT_MESG_WHEN(VM_CHECK_MODE > 0, expr, #expr) - #define VM_UNREACHABLE(func) rb_bug(#func ": unreachable") #else From 76bad330aae4ee867585dda3e547e5db740fc0f3 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Mon, 15 Jul 2019 12:00:12 +0900 Subject: [PATCH 185/452] encoding.c (enc_table_expand): prefer xrealloc to realloc And raise an exception when failed to register an encoding --- encoding.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/encoding.c b/encoding.c index f4606eeb149022..ff5e488930b32c 100644 --- a/encoding.c +++ b/encoding.c @@ -268,8 +268,7 @@ enc_table_expand(int newsize) if (enc_table.size >= newsize) return newsize; newsize = (newsize + 7) / 8 * 8; - ent = realloc(enc_table.list, sizeof(*enc_table.list) * newsize); - if (!ent) return -1; + ent = xrealloc(enc_table.list, sizeof(*enc_table.list) * newsize); memset(ent + enc_table.size, 0, sizeof(*ent)*(newsize - enc_table.size)); enc_table.list = ent; enc_table.size = newsize; @@ -443,6 +442,9 @@ enc_replicate_with_index(const char *name, rb_encoding *origenc, int idx) set_base_encoding(idx, origenc); set_encoding_const(name, rb_enc_from_index(idx)); } + else { + rb_raise(rb_eArgError, "failed to replicate encoding"); + } return idx; } From 8ac1c6eb4837f5d088b7fc0a6ee51a5723f728a9 Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Mon, 15 Jul 2019 12:05:55 +0900 Subject: [PATCH 186/452] respect RUBY_DEBUG too --- encoding.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/encoding.c b/encoding.c index ff5e488930b32c..012d18c690fc2f 100644 --- a/encoding.c +++ b/encoding.c @@ -20,7 +20,7 @@ #ifndef ENC_DEBUG #define ENC_DEBUG 0 #endif -#define ENC_ASSERT (!ENC_DEBUG)?(void)0:assert +#define ENC_ASSERT(expr) RUBY_ASSERT_WHEN(ENC_DEBUG, expr) #define MUST_STRING(str) (ENC_ASSERT(RB_TYPE_P(str, T_STRING)), str) #undef rb_ascii8bit_encindex From bd494ae79b18e260b0123bf40ddc1c694d7b25b8 Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Mon, 15 Jul 2019 12:59:53 +0900 Subject: [PATCH 187/452] add tests for "break" in lambda. --- test/ruby/test_lambda.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/ruby/test_lambda.rb b/test/ruby/test_lambda.rb index 3ac2e4cb988cb2..a30ea483e4b374 100644 --- a/test/ruby/test_lambda.rb +++ b/test/ruby/test_lambda.rb @@ -157,6 +157,21 @@ def test_return assert_equal(42, return_in_callee(42), feature8693) end + def break_in_current(val) + 1.tap(&->(*) {break 0}) + val + end + + def break_in_callee(val) + yield_block(&->(*) {break 0}) + val + end + + def test_break + assert_equal(42, break_in_current(42)) + assert_equal(42, break_in_callee(42)) + end + def test_do_lambda_source_location exp_lineno = __LINE__ + 3 lmd = ->(x, From badfbdf32c26f44b93687698b4dca9dd95f70a75 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Mon, 15 Jul 2019 13:15:13 +0900 Subject: [PATCH 188/452] Move vpath.rb into tool library direcotry. --- tool/checksum.rb | 2 +- tool/generic_erb.rb | 2 +- tool/id2token.rb | 2 +- tool/{ => lib}/vpath.rb | 0 4 files changed, 3 insertions(+), 3 deletions(-) rename tool/{ => lib}/vpath.rb (100%) diff --git a/tool/checksum.rb b/tool/checksum.rb index 3b41aedcfccc6e..bcc60ee14a63d9 100755 --- a/tool/checksum.rb +++ b/tool/checksum.rb @@ -1,6 +1,6 @@ #!ruby -require_relative 'vpath' +require_relative 'lib/vpath' class Checksum def initialize(vpath) diff --git a/tool/generic_erb.rb b/tool/generic_erb.rb index 3184cbb9f82dfb..eaafe0c7a51d56 100644 --- a/tool/generic_erb.rb +++ b/tool/generic_erb.rb @@ -6,7 +6,7 @@ require 'erb' require 'optparse' $:.unshift(File.dirname(__FILE__)) -require 'vpath' +require_relative 'lib/vpath' require_relative 'lib/colorize' vpath = VPath.new diff --git a/tool/id2token.rb b/tool/id2token.rb index 706154ecfb0246..9267126e8ff54f 100755 --- a/tool/id2token.rb +++ b/tool/id2token.rb @@ -6,7 +6,7 @@ BEGIN { require 'optparse' $:.unshift(File.dirname(__FILE__)) - require 'vpath' + require_relative 'lib/vpath' vpath = VPath.new header = nil diff --git a/tool/vpath.rb b/tool/lib/vpath.rb similarity index 100% rename from tool/vpath.rb rename to tool/lib/vpath.rb From 99afea5328c61d3f212bbb684b33abf0d814f080 Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Thu, 20 Jun 2019 10:21:34 -0700 Subject: [PATCH 189/452] Add bug triaging guide Implements [Misc #15943] --- doc/bug_triaging.rdoc | 80 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 doc/bug_triaging.rdoc diff --git a/doc/bug_triaging.rdoc b/doc/bug_triaging.rdoc new file mode 100644 index 00000000000000..310eff1aeb2793 --- /dev/null +++ b/doc/bug_triaging.rdoc @@ -0,0 +1,80 @@ += Bug Triaging Guide + +This guide discusses recommendations for triaging bugs in Ruby's bug tracker. + +== Bugs with Reproducible Examples + +These are the best bug reports. First, consider whether the bug reported is +actually an issue or if it is expected Ruby behavior. If it is expected Ruby +behavior, update the issue with why the behavior is expected, and set the +status to Rejected. + +If the bug reported appears to be an actual bug, try reproducing the bug with +the master branch. If you are not able to reproduce the issue on the master +branch, try reproducing it on the latest version for the branch the bug was +reported on. If you cannot reproduce the issue in either case, update +the issue stating you cannot reproduce the issue, ask the reporter if they +can reproduce the issue with either the master branch or a later release, +and set the status to Feedback. + +If you can reproduce the example with the master branch, try to figure out +what is causing the issue. If you feel comfortable, try working on a +patch for the issue, update the issue, and attach the patch. Try to figure +out which committer should be assigned to the issue, and set them as the +assignee, and set the status to Assigned. + +If you cannot reproduce the example with the master branch, but can reproduce +the issue on the latest version for the branch, then it is likely the bug has +already been fixed, but it has not been backported yet. Try to determine +which commit fixed it, and update the issue noting that the issue has been +fixed but not yet backported. If the ruby version is in the security +maintenance phase or no longer supported, change the status to Closed. This +change be made without adding a note to avoid spamming the mailing list. + +For issues that may require backwards incompatible changes or may benefit from +general committer attention or discussion, considering adding them as agenda +items for the next committer meeting (https://bugs.ruby-lang.org/issues/14770). + +== Crash Bugs Without Reproducers + +Many bugs reported have little more than a crash report, often with no way to +reproduce the issue. These bugs are difficult to triage as they often do not +contain enough information. + + +For these bugs, if the ruby version is the master branch or is the latest +release for the branch and the branch is in normal maintenance phase, look at +the backtrace and see if you can determine what could be causing the issue. +If you can guess would could be causing the issue, see if you can put together +a reproducible example (this is in general quite difficult). If you cannot +guess what could be causing the issue, or cannot put together a reproducible +example yourself, please ask the reporter to provide a reproducible example, +and change the status to Feedback. + +if the ruby version is no longer current (e.g. 2.5.0 when the latest version +on the ruby 2.5 branch is 2.5.5), add a note to the issue asking the reporter +to try the latest ruby version for the branch and report back, and change the +status to Feedback. If the ruby version is in the security maintenance phase +or no longer supported, change the status to Closed. This change can be made +without adding a note. + +== Crash Bugs With 3rd Party C Extensions + +If the crash happens inside a 3rd party C extension, try to figure out which +C extension it happens inside, and add a note to the issue to report the +issue to that C extension, and set the status to Third Party's Issue. + +== Non-Bug reports + +Any issues in the bug tracker that are not reports of problems should have +the tracker changed from Bug to either Feature (new features or performance +improvements) or Misc. This change can be made without adding a note. + +== Stale Issues + +There are many issues that are stale, with no updates in months or even years. +For stale issues in Feedback state, where the feedback has not been received, +you can change the status to Closed without adding a note. For stale issues +in Assigned state, you can reach out the assignee and see if they can update +the issue. If the assignee is no longer an active committer, remove them +as the assignee and change the status to Open. From b401fb35a4196ba0229622a1bcdc5966f10e8e5d Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Mon, 15 Jul 2019 13:42:37 +0900 Subject: [PATCH 190/452] Removed needless LOAD_PATH modification. We can use require_relative now. --- tool/generic_erb.rb | 1 - tool/id2token.rb | 1 - 2 files changed, 2 deletions(-) diff --git a/tool/generic_erb.rb b/tool/generic_erb.rb index eaafe0c7a51d56..6af995fc139e4b 100644 --- a/tool/generic_erb.rb +++ b/tool/generic_erb.rb @@ -5,7 +5,6 @@ require 'erb' require 'optparse' -$:.unshift(File.dirname(__FILE__)) require_relative 'lib/vpath' require_relative 'lib/colorize' diff --git a/tool/id2token.rb b/tool/id2token.rb index 9267126e8ff54f..d12ea9c08e5b7a 100755 --- a/tool/id2token.rb +++ b/tool/id2token.rb @@ -5,7 +5,6 @@ BEGIN { require 'optparse' - $:.unshift(File.dirname(__FILE__)) require_relative 'lib/vpath' vpath = VPath.new header = nil From 929fa856ef8a9217b58dc43c9883c3202603c18e Mon Sep 17 00:00:00 2001 From: Kazuhiro NISHIYAMA Date: Mon, 15 Jul 2019 13:44:50 +0900 Subject: [PATCH 191/452] Add tool/leaked-globals to .gitattributes [ci skip] --- .gitattributes | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitattributes b/.gitattributes index c922b03c93a879..d0c2d266b4a154 100644 --- a/.gitattributes +++ b/.gitattributes @@ -5,3 +5,4 @@ bin/* diff=ruby tool/update-deps diff=ruby tool/make-snapshot diff=ruby tool/format-release diff=ruby +tool/leaked-globals diff=ruby From d1e2650aca8ba340d98af22a08be20baf0abde0e Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Mon, 15 Jul 2019 13:47:28 +0900 Subject: [PATCH 192/452] Force-fetch unicode update only when it's needed nobu said that we could be banned if we aggressively downloaded unicode file from Travis. --- .travis.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 56320ec118082b..36a9f8d1577e15 100644 --- a/.travis.yml +++ b/.travis.yml @@ -334,8 +334,6 @@ env: - TEST_ALL_ISOLATED_TESTS="../test/ruby/test_gc_compact.rb" # Disabling -j3 because it seems to cause a hang on building Ruby: https://travis-ci.org/ruby/ruby/jobs/471021727 - JOBS= - # Prevent random failure by missing build dependency like https://travis-ci.org/ruby/ruby/jobs/558571461 - - ALWAYS_UPDATE_UNICODE=yes - &dependency name: Check dependencies in makefiles @@ -415,7 +413,12 @@ before_script: - "> .rbconfig.time" - sed -f tool/prereq.status template/Makefile.in common.mk > Makefile - date; make touch-unicode-files - - date; make -s $JOBS $UPDATE_UNICODE up + - |- + date + if ! make -s $JOBS $UPDATE_UNICODE up; then + # Prevent random failure by missing build dependency like https://travis-ci.org/ruby/ruby/jobs/558571461 + make -s $JOBS $UPDATE_UNICODE ALWAYS_UPDATE_UNICODE=yes up + fi - date; make -s $JOBS srcs - rm -f config.status Makefile rbconfig.rb .rbconfig.time - |- From 9c38904ead89df7c41243f7a23dde3d07f22bd86 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Mon, 15 Jul 2019 13:56:32 +0900 Subject: [PATCH 193/452] Use consistent fetchDepth for all jobs a7dd6763bd1dac7952ace46be58083dbea332a0a was not applied for all jobs. --- azure-pipelines.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 7714121c739795..4b4de37951b9e9 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -50,7 +50,7 @@ jobs: - script: brew update && brew install autoconf bison openssl displayName: "Install dependencies" - checkout: self - fetchDepth: 10 + fetchDepth: 20 - script: | autoconf ./configure --with-openssl-dir=/usr/local/opt/openssl @@ -117,7 +117,7 @@ jobs: timeoutInMinutes: 20 continueOnError: true # unstable. TODO: somehow use VM having these dependencies beforehand, and remove this `continueOnError` - checkout: self - fetchDepth: 10 + fetchDepth: 20 - script: | call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvars64.bat" cinst winflexbison @@ -150,7 +150,7 @@ jobs: steps: # - script: vcpkg --triplet x64-windows install openssl readline zlib - checkout: self - fetchDepth: 10 + fetchDepth: 20 - script: | call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Auxiliary\Build\vcvars64.bat" cinst winflexbison From 62f34bd1fe9630b0e760860017955cec2d5fbd0a Mon Sep 17 00:00:00 2001 From: Kazuhiro NISHIYAMA Date: Mon, 15 Jul 2019 13:57:43 +0900 Subject: [PATCH 194/452] doc/globals.rdoc: Add deprecated to TRUE,FALSE,NIL [ci skip] They are warned since 2.4.0. --- doc/globals.rdoc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/globals.rdoc b/doc/globals.rdoc index d3c3553d4da535..146b7fc34f3fc4 100644 --- a/doc/globals.rdoc +++ b/doc/globals.rdoc @@ -50,9 +50,9 @@ $-p:: True if option -p is set. Read-only variable. == Pre-defined global constants -TRUE:: The typical true value. -FALSE:: The +false+ itself. -NIL:: The +nil+ itself. +TRUE:: The typical true value. Deprecated. +FALSE:: The +false+ itself. Deprecated. +NIL:: The +nil+ itself. Deprecated. STDIN:: The standard input. The default value for $stdin. STDOUT:: The standard output. The default value for $stdout. STDERR:: The standard error output. The default value for $stderr. From 5353401c254a926426d9a289606fad18a755fcd2 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Mon, 15 Jul 2019 14:02:45 +0900 Subject: [PATCH 195/452] thread.c (rb_thread_shield_waiting_{inc,dec}): prefer long to int `(unsigned int)(THREAD_SHIELD_WAITING_MASK>>THREAD_SHIELD_WAITING_SHIFT)` is 0xffffffff, and w > 0xffffffff is always true. Coverity Scan pointed out this issue. --- thread.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/thread.c b/thread.c index 55df74d7d3d3cb..f00b77c79d717f 100644 --- a/thread.c +++ b/thread.c @@ -4720,14 +4720,14 @@ thread_shield_alloc(VALUE klass) #define GetThreadShieldPtr(obj) ((VALUE)rb_check_typeddata((obj), &thread_shield_data_type)) #define THREAD_SHIELD_WAITING_MASK (FL_USER0|FL_USER1|FL_USER2|FL_USER3|FL_USER4|FL_USER5|FL_USER6|FL_USER7|FL_USER8|FL_USER9|FL_USER10|FL_USER11|FL_USER12|FL_USER13|FL_USER14|FL_USER15|FL_USER16|FL_USER17|FL_USER18|FL_USER19) #define THREAD_SHIELD_WAITING_SHIFT (FL_USHIFT) -#define rb_thread_shield_waiting(b) (int)((RBASIC(b)->flags&THREAD_SHIELD_WAITING_MASK)>>THREAD_SHIELD_WAITING_SHIFT) +#define rb_thread_shield_waiting(b) ((RBASIC(b)->flags&THREAD_SHIELD_WAITING_MASK)>>THREAD_SHIELD_WAITING_SHIFT) static inline void rb_thread_shield_waiting_inc(VALUE b) { - unsigned int w = rb_thread_shield_waiting(b); + unsigned long w = rb_thread_shield_waiting(b); w++; - if (w > (unsigned int)(THREAD_SHIELD_WAITING_MASK>>THREAD_SHIELD_WAITING_SHIFT)) + if (w > (THREAD_SHIELD_WAITING_MASK>>THREAD_SHIELD_WAITING_SHIFT)) rb_raise(rb_eRuntimeError, "waiting count overflow"); RBASIC(b)->flags &= ~THREAD_SHIELD_WAITING_MASK; RBASIC(b)->flags |= ((VALUE)w << THREAD_SHIELD_WAITING_SHIFT); @@ -4736,7 +4736,7 @@ rb_thread_shield_waiting_inc(VALUE b) static inline void rb_thread_shield_waiting_dec(VALUE b) { - unsigned int w = rb_thread_shield_waiting(b); + unsigned long w = rb_thread_shield_waiting(b); if (!w) rb_raise(rb_eRuntimeError, "waiting count underflow"); w--; RBASIC(b)->flags &= ~THREAD_SHIELD_WAITING_MASK; From 711dfec3fa9623c5e8ef6f5ce3627f8f1a85f19d Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Mon, 15 Jul 2019 14:07:22 +0900 Subject: [PATCH 196/452] parse.y (here_document): remove dead code str is always zero when evaluating the branch. Found by Coverity Scan. --- parse.y | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/parse.y b/parse.y index e006ababaf5289..6389730d997955 100644 --- a/parse.y +++ b/parse.y @@ -7306,10 +7306,7 @@ here_document(struct parser_params *p, rb_strterm_heredoc_t *here) dispatch_scan_event(p, tSTRING_CONTENT); } else { - if (str) { - rb_str_append(p->delayed, str); - } - else if ((len = p->lex.pcur - p->lex.ptok) > 0) { + if ((len = p->lex.pcur - p->lex.ptok) > 0) { if (!(func & STR_FUNC_REGEXP) && rb_enc_asciicompat(enc)) { int cr = ENC_CODERANGE_UNKNOWN; rb_str_coderange_scan_restartable(p->lex.ptok, p->lex.pcur, enc, &cr); From e4c1b199961cc5fa34c02b2225bbc14b75259fd2 Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Mon, 15 Jul 2019 14:17:27 +0900 Subject: [PATCH 197/452] add tests for orphan/not-orphan proc/lambda. --- test/ruby/test_lambda.rb | 27 +++++++++++++++++++++++++++ test/ruby/test_proc.rb | 27 +++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/test/ruby/test_lambda.rb b/test/ruby/test_lambda.rb index a30ea483e4b374..b9412d4540e108 100644 --- a/test/ruby/test_lambda.rb +++ b/test/ruby/test_lambda.rb @@ -195,4 +195,31 @@ def test_brace_lambda_source_location assert_match(/^#{ Regexp.quote(__FILE__) }$/, file) assert_equal(exp_lineno, lineno, "must be at the beginning of the block") end + + def test_not_orphan_return + assert_equal(42, Module.new { extend self + def m1(&b) b.call end; def m2(); m1(&-> { return 42 }) end }.m2) + assert_equal(42, Module.new { extend self + def m1(&b) b end; def m2(); m1(&-> { return 42 }).call end }.m2) + assert_equal(42, Module.new { extend self + def m1(&b) b end; def m2(); m1(&-> { return 42 }) end }.m2.call) + end + + def test_not_orphan_break + assert_equal(42, Module.new { extend self + def m1(&b) b.call end; def m2(); m1(&-> { break 42 }) end }.m2) + assert_equal(42, Module.new { extend self + def m1(&b) b end; def m2(); m1(&-> { break 42 }).call end }.m2) + assert_equal(42, Module.new { extend self + def m1(&b) b end; def m2(); m1(&-> { break 42 }) end }.m2.call) + end + + def test_not_orphan_next + assert_equal(42, Module.new { extend self + def m1(&b) b.call end; def m2(); m1(&-> { next 42 }) end }.m2) + assert_equal(42, Module.new { extend self + def m1(&b) b end; def m2(); m1(&-> { next 42 }).call end }.m2) + assert_equal(42, Module.new { extend self + def m1(&b) b end; def m2(); m1(&-> { next 42 }) end }.m2.call) + end end diff --git a/test/ruby/test_proc.rb b/test/ruby/test_proc.rb index bc270115df08f2..0e9c6e0b17d110 100644 --- a/test/ruby/test_proc.rb +++ b/test/ruby/test_proc.rb @@ -1484,4 +1484,31 @@ def test_compose_with_noncallable (f >> 5).call(2) } end + + def test_orphan_return + assert_equal(42, Module.new { extend self + def m1(&b) b.call end; def m2(); m1 { return 42 } end }.m2) + assert_equal(42, Module.new { extend self + def m1(&b) b end; def m2(); m1 { return 42 }.call end }.m2) + assert_raise(LocalJumpError) { Module.new { extend self + def m1(&b) b end; def m2(); m1 { return 42 } end }.m2.call } + end + + def test_orphan_break + assert_equal(42, Module.new { extend self + def m1(&b) b.call end; def m2(); m1 { break 42 } end }.m2 ) + assert_raise(LocalJumpError) { Module.new { extend self + def m1(&b) b end; def m2(); m1 { break 42 }.call end }.m2 } + assert_raise(LocalJumpError) { Module.new { extend self + def m1(&b) b end; def m2(); m1 { break 42 } end }.m2.call } + end + + def test_not_orphan_next + assert_equal(42, Module.new { extend self + def m1(&b) b.call end; def m2(); m1 { next 42 } end }.m2) + assert_equal(42, Module.new { extend self + def m1(&b) b end; def m2(); m1 { next 42 }.call end }.m2) + assert_equal(42, Module.new { extend self + def m1(&b) b end; def m2(); m1 { next 42 } end }.m2.call) + end end From 3dc212896c422add43c850ee1d1a613c7cc96737 Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Mon, 15 Jul 2019 13:52:25 +0900 Subject: [PATCH 198/452] check return value of blocking_region_begin(). blocking_region_begin() can return FALSE if it fails to acquire GVL, so check it. --- thread.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/thread.c b/thread.c index f00b77c79d717f..2b785a7ebe12d3 100644 --- a/thread.c +++ b/thread.c @@ -1679,7 +1679,8 @@ rb_thread_call_with_gvl(void *(*func)(void *), void *data1) /* enter to Ruby world: You can access Ruby values, methods and so on. */ r = (*func)(data1); /* leave from Ruby world: You can not access Ruby values, etc. */ - blocking_region_begin(th, brb, prev_unblock.func, prev_unblock.arg, FALSE); + int released = blocking_region_begin(th, brb, prev_unblock.func, prev_unblock.arg, FALSE); + RUBY_ASSERT_ALWAYS(released); return r; } From 99c14fb69491d52c474c3f303405e6f59b41034f Mon Sep 17 00:00:00 2001 From: Colby Swandale Date: Wed, 12 Dec 2018 11:27:26 +1100 Subject: [PATCH 199/452] [ruby/logger] remove files that dont need to be included in gem releases https://github.com/ruby/logger/commit/9a3be8650f --- lib/logger.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/logger.gemspec b/lib/logger.gemspec index 815ae5bc466f30..6d7025618b8039 100644 --- a/lib/logger.gemspec +++ b/lib/logger.gemspec @@ -16,7 +16,7 @@ Gem::Specification.new do |spec| spec.homepage = "https://github.com/ruby/logger" spec.license = "BSD-2-Clause" - spec.files = [".gitignore", ".travis.yml", "Gemfile", "LICENSE.txt", "README.md", "Rakefile", "bin/console", "bin/setup", "lib/logger.rb", "logger.gemspec"] + spec.files = ["Gemfile", "LICENSE.txt", "README.md", "Rakefile", "lib/logger.rb", "logger.gemspec"] spec.bindir = "exe" spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] From b9ba07a05c48176bfbba44133a9f3a43f387bedd Mon Sep 17 00:00:00 2001 From: Colby Swandale Date: Thu, 13 Dec 2018 20:45:08 +1100 Subject: [PATCH 200/452] [ruby/logger] dont lock bundler to a specific version in travis https://github.com/ruby/logger/commit/eb5ac229a5 --- lib/logger.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/logger.gemspec b/lib/logger.gemspec index 6d7025618b8039..cc1f8c6e6b9fd0 100644 --- a/lib/logger.gemspec +++ b/lib/logger.gemspec @@ -21,7 +21,7 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - spec.add_development_dependency "bundler", "~> 1.16" + spec.add_development_dependency "bundler", ">= 0" spec.add_development_dependency "rake", "~> 10.0" spec.add_development_dependency "minitest", "~> 5.0" end From 227eae79acde90e7c3ba171dbf4bdcedbb39a9f2 Mon Sep 17 00:00:00 2001 From: Samuel Giddins Date: Thu, 17 Jan 2019 09:59:55 -0800 Subject: [PATCH 201/452] [ruby/logger] Say that logger requires ruby >= 2.3 Since it uses `&.`, it can't be used on older rubies https://github.com/ruby/logger/commit/b872f90ab9 --- lib/logger.gemspec | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/logger.gemspec b/lib/logger.gemspec index cc1f8c6e6b9fd0..647faf29137db3 100644 --- a/lib/logger.gemspec +++ b/lib/logger.gemspec @@ -20,6 +20,8 @@ Gem::Specification.new do |spec| spec.bindir = "exe" spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] + + spec.required_ruby_version = ">= 2.3.0 spec.add_development_dependency "bundler", ">= 0" spec.add_development_dependency "rake", "~> 10.0" From 310198d6be1ca5dc2f1279096d7134a02ee3d8ec Mon Sep 17 00:00:00 2001 From: Samuel Giddins Date: Thu, 17 Jan 2019 10:13:20 -0800 Subject: [PATCH 202/452] [ruby/logger] Add missing closing " https://github.com/ruby/logger/commit/b4b3caae40 --- lib/logger.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/logger.gemspec b/lib/logger.gemspec index 647faf29137db3..cc453c58067943 100644 --- a/lib/logger.gemspec +++ b/lib/logger.gemspec @@ -21,7 +21,7 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - spec.required_ruby_version = ">= 2.3.0 + spec.required_ruby_version = ">= 2.3.0" spec.add_development_dependency "bundler", ">= 0" spec.add_development_dependency "rake", "~> 10.0" From 47500f2055467d0c72c7ce53b2535d7610347fb0 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Fri, 15 Mar 2019 12:12:11 +1300 Subject: [PATCH 203/452] [ruby/logger] Add support for changing severity using bang methods. https://github.com/ruby/logger/commit/ae4c6dfcbb --- lib/logger.rb | 15 +++++++++++++++ test/logger/test_severity.rb | 11 +++++++++++ 2 files changed, 26 insertions(+) diff --git a/lib/logger.rb b/lib/logger.rb index 918caf09567afe..7e65af34ebc08b 100644 --- a/lib/logger.rb +++ b/lib/logger.rb @@ -322,22 +322,37 @@ def datetime_format # +DEBUG+ messages. def debug?; @level <= DEBUG; end + # Sets the severity to DEBUG. + def debug!; self.level = DEBUG; end + # Returns +true+ iff the current severity level allows for the printing of # +INFO+ messages. def info?; @level <= INFO; end + # Sets the severity to INFO. + def info!; self.level = INFO; end + # Returns +true+ iff the current severity level allows for the printing of # +WARN+ messages. def warn?; @level <= WARN; end + # Sets the severity to WARN. + def warn!; self.level = WARN; end + # Returns +true+ iff the current severity level allows for the printing of # +ERROR+ messages. def error?; @level <= ERROR; end + # Sets the severity to ERROR. + def error!; self.level = ERROR; end + # Returns +true+ iff the current severity level allows for the printing of # +FATAL+ messages. def fatal?; @level <= FATAL; end + # Sets the severity to FATAL. + def fatal!; self.level = FATAL; end + # # :call-seq: # Logger.new(logdev, shift_age = 0, shift_size = 1048576) diff --git a/test/logger/test_severity.rb b/test/logger/test_severity.rb index f17a3928291984..8889a1dc5220cc 100644 --- a/test/logger/test_severity.rb +++ b/test/logger/test_severity.rb @@ -13,4 +13,15 @@ def test_enum end assert_equal(levels.size, Logger::Severity.constants.size) end + + def test_level_assignment + logger = Logger.new(nil) + + Logger::Severity.constants.each do |level| + next if level == :UNKNOWN + + logger.send("#{level.downcase}!") + assert(logger.level) == Logger::Severity.const_get(level) + end + end end From 136196785b10f7cffa1e4d557bc3bcc0e863813a Mon Sep 17 00:00:00 2001 From: sonots Date: Mon, 18 Mar 2019 19:34:01 +0900 Subject: [PATCH 204/452] [ruby/logger] Fix to use logger and test-unit in this repo with `ruby test/logger/test_xxx.rb` https://github.com/ruby/logger/commit/d3c2402340 --- test/helper.rb | 5 +++++ test/logger/test_logdevice.rb | 3 +-- test/logger/test_logger.rb | 3 +-- test/logger/test_severity.rb | 9 ++++----- 4 files changed, 11 insertions(+), 9 deletions(-) create mode 100644 test/helper.rb diff --git a/test/helper.rb b/test/helper.rb new file mode 100644 index 00000000000000..d29332104bc8aa --- /dev/null +++ b/test/helper.rb @@ -0,0 +1,5 @@ +ROOT_DIR = File.dirname(__dir__) +$LOAD_PATH.unshift File.join(ROOT_DIR, 'lib') # to use logger in this repo instead of ruby built-in logger +$LOAD_PATH.unshift File.join(ROOT_DIR, 'test', 'lib') # to use custom test-unit in this repo +require 'logger' +require 'test/unit' diff --git a/test/logger/test_logdevice.rb b/test/logger/test_logdevice.rb index 7d5bf9ac817e6f..30047f89b1a07e 100644 --- a/test/logger/test_logdevice.rb +++ b/test/logger/test_logdevice.rb @@ -1,7 +1,6 @@ # coding: US-ASCII # frozen_string_literal: false -require 'test/unit' -require 'logger' +require_relative '../helper' require 'tempfile' require 'tmpdir' diff --git a/test/logger/test_logger.rb b/test/logger/test_logger.rb index 3f2319b961da8c..5806e0c68501e6 100644 --- a/test/logger/test_logger.rb +++ b/test/logger/test_logger.rb @@ -1,7 +1,6 @@ # coding: US-ASCII # frozen_string_literal: false -require 'test/unit' -require 'logger' +require_relative '../helper' require 'tempfile' class TestLogger < Test::Unit::TestCase diff --git a/test/logger/test_severity.rb b/test/logger/test_severity.rb index 8889a1dc5220cc..4da23cdd0f90bf 100644 --- a/test/logger/test_severity.rb +++ b/test/logger/test_severity.rb @@ -1,7 +1,6 @@ # coding: US-ASCII # frozen_string_literal: false -require 'test/unit' -require 'logger' +require_relative '../helper' class TestLoggerSeverity < Test::Unit::TestCase def test_enum @@ -13,13 +12,13 @@ def test_enum end assert_equal(levels.size, Logger::Severity.constants.size) end - + def test_level_assignment logger = Logger.new(nil) - + Logger::Severity.constants.each do |level| next if level == :UNKNOWN - + logger.send("#{level.downcase}!") assert(logger.level) == Logger::Severity.const_get(level) end From bbe157f34046ec9ef81e6ad9ed37c86a0d9155e4 Mon Sep 17 00:00:00 2001 From: Colby Swandale Date: Wed, 12 Dec 2018 14:08:35 +1100 Subject: [PATCH 205/452] [ruby/logger] split logger classes/modules into separate files https://github.com/ruby/logger/commit/f10ce9fff2 --- lib/logger.gemspec | 5 +- lib/logger.rb | 295 +-------------------------------------- lib/logger/errors.rb | 7 + lib/logger/formatter.rb | 35 +++++ lib/logger/log_device.rb | 197 ++++++++++++++++++++++++++ lib/logger/period.rb | 41 ++++++ lib/logger/severity.rb | 17 +++ lib/logger/version.rb | 5 + 8 files changed, 308 insertions(+), 294 deletions(-) create mode 100644 lib/logger/errors.rb create mode 100644 lib/logger/formatter.rb create mode 100644 lib/logger/log_device.rb create mode 100644 lib/logger/period.rb create mode 100644 lib/logger/severity.rb create mode 100644 lib/logger/version.rb diff --git a/lib/logger.gemspec b/lib/logger.gemspec index cc453c58067943..da28b629be2f70 100644 --- a/lib/logger.gemspec +++ b/lib/logger.gemspec @@ -1,8 +1,7 @@ begin - require_relative "lib/logger" + require File.expand_path("../lib/logger/version", __FILE__) rescue LoadError - # for Ruby core repository - require_relative "logger" + require File.expand_path("../logger/version", __FILE__) end Gem::Specification.new do |spec| diff --git a/lib/logger.rb b/lib/logger.rb index 7e65af34ebc08b..489df1dcdafe6b 100644 --- a/lib/logger.rb +++ b/lib/logger.rb @@ -11,6 +11,10 @@ # A simple system for logging messages. See Logger for more documentation. require 'monitor' +require 'logger/version' +require 'logger/formatter' +require 'logger/log_device' +require 'logger/severity' # == Description # @@ -224,7 +228,6 @@ # }) # class Logger - VERSION = "1.3.0" _, name, rev = %w$Id$ if name name = name.chomp(",v") @@ -234,27 +237,6 @@ class Logger rev ||= "v#{VERSION}" ProgName = "#{name}/#{rev}".freeze - class Error < RuntimeError # :nodoc: - end - # not used after 1.2.7. just for compat. - class ShiftingError < Error # :nodoc: - end - - # Logging severity. - module Severity - # Low-level information, mostly for developers. - DEBUG = 0 - # Generic (useful) information about system operation. - INFO = 1 - # A warning. - WARN = 2 - # A handleable error condition. - ERROR = 3 - # An unhandleable error that results in a program crash. - FATAL = 4 - # An unknown message that should always be logged. - UNKNOWN = 5 - end include Severity # Logging severity threshold (e.g. Logger::INFO). @@ -596,273 +578,4 @@ def format_severity(severity) def format_message(severity, datetime, progname, msg) (@formatter || @default_formatter).call(severity, datetime, progname, msg) end - - - # Default formatter for log messages. - class Formatter - Format = "%s, [%s#%d] %5s -- %s: %s\n".freeze - - attr_accessor :datetime_format - - def initialize - @datetime_format = nil - end - - def call(severity, time, progname, msg) - Format % [severity[0..0], format_datetime(time), $$, severity, progname, - msg2str(msg)] - end - - private - - def format_datetime(time) - time.strftime(@datetime_format || "%Y-%m-%dT%H:%M:%S.%6N ".freeze) - end - - def msg2str(msg) - case msg - when ::String - msg - when ::Exception - "#{ msg.message } (#{ msg.class })\n" << - (msg.backtrace || []).join("\n") - else - msg.inspect - end - end - end - - module Period - module_function - - SiD = 24 * 60 * 60 - - def next_rotate_time(now, shift_age) - case shift_age - when 'daily' - t = Time.mktime(now.year, now.month, now.mday) + SiD - when 'weekly' - t = Time.mktime(now.year, now.month, now.mday) + SiD * (7 - now.wday) - when 'monthly' - t = Time.mktime(now.year, now.month, 1) + SiD * 32 - return Time.mktime(t.year, t.month, 1) - else - return now - end - if t.hour.nonzero? or t.min.nonzero? or t.sec.nonzero? - hour = t.hour - t = Time.mktime(t.year, t.month, t.mday) - t += SiD if hour > 12 - end - t - end - - def previous_period_end(now, shift_age) - case shift_age - when 'daily' - t = Time.mktime(now.year, now.month, now.mday) - SiD / 2 - when 'weekly' - t = Time.mktime(now.year, now.month, now.mday) - (SiD * now.wday + SiD / 2) - when 'monthly' - t = Time.mktime(now.year, now.month, 1) - SiD / 2 - else - return now - end - Time.mktime(t.year, t.month, t.mday, 23, 59, 59) - end - end - - # Device used for logging messages. - class LogDevice - include Period - - attr_reader :dev - attr_reader :filename - include MonitorMixin - - def initialize(log = nil, shift_age: nil, shift_size: nil, shift_period_suffix: nil) - @dev = @filename = @shift_age = @shift_size = @shift_period_suffix = nil - mon_initialize - set_dev(log) - if @filename - @shift_age = shift_age || 7 - @shift_size = shift_size || 1048576 - @shift_period_suffix = shift_period_suffix || '%Y%m%d' - - unless @shift_age.is_a?(Integer) - base_time = @dev.respond_to?(:stat) ? @dev.stat.mtime : Time.now - @next_rotate_time = next_rotate_time(base_time, @shift_age) - end - end - end - - def write(message) - begin - synchronize do - if @shift_age and @dev.respond_to?(:stat) - begin - check_shift_log - rescue - warn("log shifting failed. #{$!}") - end - end - begin - @dev.write(message) - rescue - warn("log writing failed. #{$!}") - end - end - rescue Exception => ignored - warn("log writing failed. #{ignored}") - end - end - - def close - begin - synchronize do - @dev.close rescue nil - end - rescue Exception - @dev.close rescue nil - end - end - - def reopen(log = nil) - # reopen the same filename if no argument, do nothing for IO - log ||= @filename if @filename - if log - synchronize do - if @filename and @dev - @dev.close rescue nil # close only file opened by Logger - @filename = nil - end - set_dev(log) - end - end - self - end - - private - - def set_dev(log) - if log.respond_to?(:write) and log.respond_to?(:close) - @dev = log - else - @dev = open_logfile(log) - @dev.sync = true - @filename = log - end - end - - def open_logfile(filename) - begin - File.open(filename, (File::WRONLY | File::APPEND)) - rescue Errno::ENOENT - create_logfile(filename) - end - end - - def create_logfile(filename) - begin - logdev = File.open(filename, (File::WRONLY | File::APPEND | File::CREAT | File::EXCL)) - logdev.flock(File::LOCK_EX) - logdev.sync = true - add_log_header(logdev) - logdev.flock(File::LOCK_UN) - rescue Errno::EEXIST - # file is created by another process - logdev = open_logfile(filename) - logdev.sync = true - end - logdev - end - - def add_log_header(file) - file.write( - "# Logfile created on %s by %s\n" % [Time.now.to_s, Logger::ProgName] - ) if file.size == 0 - end - - def check_shift_log - if @shift_age.is_a?(Integer) - # Note: always returns false if '0'. - if @filename && (@shift_age > 0) && (@dev.stat.size > @shift_size) - lock_shift_log { shift_log_age } - end - else - now = Time.now - if now >= @next_rotate_time - @next_rotate_time = next_rotate_time(now, @shift_age) - lock_shift_log { shift_log_period(previous_period_end(now, @shift_age)) } - end - end - end - - if /mswin|mingw/ =~ RUBY_PLATFORM - def lock_shift_log - yield - end - else - def lock_shift_log - retry_limit = 8 - retry_sleep = 0.1 - begin - File.open(@filename, File::WRONLY | File::APPEND) do |lock| - lock.flock(File::LOCK_EX) # inter-process locking. will be unlocked at closing file - if File.identical?(@filename, lock) and File.identical?(lock, @dev) - yield # log shifting - else - # log shifted by another process (i-node before locking and i-node after locking are different) - @dev.close rescue nil - @dev = open_logfile(@filename) - @dev.sync = true - end - end - rescue Errno::ENOENT - # @filename file would not exist right after #rename and before #create_logfile - if retry_limit <= 0 - warn("log rotation inter-process lock failed. #{$!}") - else - sleep retry_sleep - retry_limit -= 1 - retry_sleep *= 2 - retry - end - end - rescue - warn("log rotation inter-process lock failed. #{$!}") - end - end - - def shift_log_age - (@shift_age-3).downto(0) do |i| - if FileTest.exist?("#{@filename}.#{i}") - File.rename("#{@filename}.#{i}", "#{@filename}.#{i+1}") - end - end - @dev.close rescue nil - File.rename("#{@filename}", "#{@filename}.0") - @dev = create_logfile(@filename) - return true - end - - def shift_log_period(period_end) - suffix = period_end.strftime(@shift_period_suffix) - age_file = "#{@filename}.#{suffix}" - if FileTest.exist?(age_file) - # try to avoid filename crash caused by Timestamp change. - idx = 0 - # .99 can be overridden; avoid too much file search with 'loop do' - while idx < 100 - idx += 1 - age_file = "#{@filename}.#{suffix}.#{idx}" - break unless FileTest.exist?(age_file) - end - end - @dev.close rescue nil - File.rename("#{@filename}", age_file) - @dev = create_logfile(@filename) - return true - end - end end diff --git a/lib/logger/errors.rb b/lib/logger/errors.rb new file mode 100644 index 00000000000000..e0fb4c643f5ae2 --- /dev/null +++ b/lib/logger/errors.rb @@ -0,0 +1,7 @@ +class Logger + class Error < RuntimeError # :nodoc: + end + # not used after 1.2.7. just for compat. + class ShiftingError < Error # :nodoc: + end +end diff --git a/lib/logger/formatter.rb b/lib/logger/formatter.rb new file mode 100644 index 00000000000000..13cb1a8390fde9 --- /dev/null +++ b/lib/logger/formatter.rb @@ -0,0 +1,35 @@ +class Logger + # Default formatter for log messages. + class Formatter + Format = "%s, [%s#%d] %5s -- %s: %s\n".freeze + + attr_accessor :datetime_format + + def initialize + @datetime_format = nil + end + + def call(severity, time, progname, msg) + Format % [severity[0..0], format_datetime(time), $$, severity, progname, + msg2str(msg)] + end + + private + + def format_datetime(time) + time.strftime(@datetime_format || "%Y-%m-%dT%H:%M:%S.%6N ".freeze) + end + + def msg2str(msg) + case msg + when ::String + msg + when ::Exception + "#{ msg.message } (#{ msg.class })\n" << + (msg.backtrace || []).join("\n") + else + msg.inspect + end + end + end +end diff --git a/lib/logger/log_device.rb b/lib/logger/log_device.rb new file mode 100644 index 00000000000000..7cfb45b5566785 --- /dev/null +++ b/lib/logger/log_device.rb @@ -0,0 +1,197 @@ +require 'logger/period' + +class Logger + # Device used for logging messages. + class LogDevice + include Period + + attr_reader :dev + attr_reader :filename + include MonitorMixin + + def initialize(log = nil, shift_age: nil, shift_size: nil, shift_period_suffix: nil) + @dev = @filename = @shift_age = @shift_size = @shift_period_suffix = nil + mon_initialize + set_dev(log) + if @filename + @shift_age = shift_age || 7 + @shift_size = shift_size || 1048576 + @shift_period_suffix = shift_period_suffix || '%Y%m%d' + + unless @shift_age.is_a?(Integer) + base_time = @dev.respond_to?(:stat) ? @dev.stat.mtime : Time.now + @next_rotate_time = next_rotate_time(base_time, @shift_age) + end + end + end + + def write(message) + begin + synchronize do + if @shift_age and @dev.respond_to?(:stat) + begin + check_shift_log + rescue + warn("log shifting failed. #{$!}") + end + end + begin + @dev.write(message) + rescue + warn("log writing failed. #{$!}") + end + end + rescue Exception => ignored + warn("log writing failed. #{ignored}") + end + end + + def close + begin + synchronize do + @dev.close rescue nil + end + rescue Exception + @dev.close rescue nil + end + end + + def reopen(log = nil) + # reopen the same filename if no argument, do nothing for IO + log ||= @filename if @filename + if log + synchronize do + if @filename and @dev + @dev.close rescue nil # close only file opened by Logger + @filename = nil + end + set_dev(log) + end + end + self + end + + private + + def set_dev(log) + if log.respond_to?(:write) and log.respond_to?(:close) + @dev = log + else + @dev = open_logfile(log) + @dev.sync = true + @filename = log + end + end + + def open_logfile(filename) + begin + File.open(filename, (File::WRONLY | File::APPEND)) + rescue Errno::ENOENT + create_logfile(filename) + end + end + + def create_logfile(filename) + begin + logdev = File.open(filename, (File::WRONLY | File::APPEND | File::CREAT | File::EXCL)) + logdev.flock(File::LOCK_EX) + logdev.sync = true + add_log_header(logdev) + logdev.flock(File::LOCK_UN) + rescue Errno::EEXIST + # file is created by another process + logdev = open_logfile(filename) + logdev.sync = true + end + logdev + end + + def add_log_header(file) + file.write( + "# Logfile created on %s by %s\n" % [Time.now.to_s, Logger::ProgName] + ) if file.size == 0 + end + + def check_shift_log + if @shift_age.is_a?(Integer) + # Note: always returns false if '0'. + if @filename && (@shift_age > 0) && (@dev.stat.size > @shift_size) + lock_shift_log { shift_log_age } + end + else + now = Time.now + if now >= @next_rotate_time + @next_rotate_time = next_rotate_time(now, @shift_age) + lock_shift_log { shift_log_period(previous_period_end(now, @shift_age)) } + end + end + end + + if /mswin|mingw/ =~ RUBY_PLATFORM + def lock_shift_log + yield + end + else + def lock_shift_log + retry_limit = 8 + retry_sleep = 0.1 + begin + File.open(@filename, File::WRONLY | File::APPEND) do |lock| + lock.flock(File::LOCK_EX) # inter-process locking. will be unlocked at closing file + if File.identical?(@filename, lock) and File.identical?(lock, @dev) + yield # log shifting + else + # log shifted by another process (i-node before locking and i-node after locking are different) + @dev.close rescue nil + @dev = open_logfile(@filename) + @dev.sync = true + end + end + rescue Errno::ENOENT + # @filename file would not exist right after #rename and before #create_logfile + if retry_limit <= 0 + warn("log rotation inter-process lock failed. #{$!}") + else + sleep retry_sleep + retry_limit -= 1 + retry_sleep *= 2 + retry + end + end + rescue + warn("log rotation inter-process lock failed. #{$!}") + end + end + + def shift_log_age + (@shift_age-3).downto(0) do |i| + if FileTest.exist?("#{@filename}.#{i}") + File.rename("#{@filename}.#{i}", "#{@filename}.#{i+1}") + end + end + @dev.close rescue nil + File.rename("#{@filename}", "#{@filename}.0") + @dev = create_logfile(@filename) + return true + end + + def shift_log_period(period_end) + suffix = period_end.strftime(@shift_period_suffix) + age_file = "#{@filename}.#{suffix}" + if FileTest.exist?(age_file) + # try to avoid filename crash caused by Timestamp change. + idx = 0 + # .99 can be overridden; avoid too much file search with 'loop do' + while idx < 100 + idx += 1 + age_file = "#{@filename}.#{suffix}.#{idx}" + break unless FileTest.exist?(age_file) + end + end + @dev.close rescue nil + File.rename("#{@filename}", age_file) + @dev = create_logfile(@filename) + return true + end + end +end diff --git a/lib/logger/period.rb b/lib/logger/period.rb new file mode 100644 index 00000000000000..bb8cffc2f8d992 --- /dev/null +++ b/lib/logger/period.rb @@ -0,0 +1,41 @@ +class Logger + module Period + module_function + + SiD = 24 * 60 * 60 + + def next_rotate_time(now, shift_age) + case shift_age + when 'daily' + t = Time.mktime(now.year, now.month, now.mday) + SiD + when 'weekly' + t = Time.mktime(now.year, now.month, now.mday) + SiD * (7 - now.wday) + when 'monthly' + t = Time.mktime(now.year, now.month, 1) + SiD * 32 + return Time.mktime(t.year, t.month, 1) + else + return now + end + if t.hour.nonzero? or t.min.nonzero? or t.sec.nonzero? + hour = t.hour + t = Time.mktime(t.year, t.month, t.mday) + t += SiD if hour > 12 + end + t + end + + def previous_period_end(now, shift_age) + case shift_age + when 'daily' + t = Time.mktime(now.year, now.month, now.mday) - SiD / 2 + when 'weekly' + t = Time.mktime(now.year, now.month, now.mday) - (SiD * now.wday + SiD / 2) + when 'monthly' + t = Time.mktime(now.year, now.month, 1) - SiD / 2 + else + return now + end + Time.mktime(t.year, t.month, t.mday, 23, 59, 59) + end + end +end diff --git a/lib/logger/severity.rb b/lib/logger/severity.rb new file mode 100644 index 00000000000000..c8179cb017b36f --- /dev/null +++ b/lib/logger/severity.rb @@ -0,0 +1,17 @@ +class Logger + # Logging severity. + module Severity + # Low-level information, mostly for developers. + DEBUG = 0 + # Generic (useful) information about system operation. + INFO = 1 + # A warning. + WARN = 2 + # A handleable error condition. + ERROR = 3 + # An unhandleable error that results in a program crash. + FATAL = 4 + # An unknown message that should always be logged. + UNKNOWN = 5 + end +end diff --git a/lib/logger/version.rb b/lib/logger/version.rb new file mode 100644 index 00000000000000..af122736c3f50b --- /dev/null +++ b/lib/logger/version.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +class Logger + VERSION = "1.3.0" +end From 7f10da9d2762d1b6d0f3c45df4a23bbdc2d78e4c Mon Sep 17 00:00:00 2001 From: sonots Date: Mon, 18 Mar 2019 21:02:02 +0900 Subject: [PATCH 206/452] [ruby/logger] require 'logger/errors' just for compat https://github.com/ruby/logger/commit/255a51dc10 --- lib/logger.rb | 1 + lib/logger/errors.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/logger.rb b/lib/logger.rb index 489df1dcdafe6b..d6539a6f698400 100644 --- a/lib/logger.rb +++ b/lib/logger.rb @@ -15,6 +15,7 @@ require 'logger/formatter' require 'logger/log_device' require 'logger/severity' +require 'logger/errors' # == Description # diff --git a/lib/logger/errors.rb b/lib/logger/errors.rb index e0fb4c643f5ae2..8095acc9c83ce8 100644 --- a/lib/logger/errors.rb +++ b/lib/logger/errors.rb @@ -1,7 +1,7 @@ +# not used after 1.2.7. just for compat. class Logger class Error < RuntimeError # :nodoc: end - # not used after 1.2.7. just for compat. class ShiftingError < Error # :nodoc: end end From 7ef08562871ca6d209415f16f942f6cd2a67df54 Mon Sep 17 00:00:00 2001 From: sonots Date: Mon, 18 Mar 2019 20:56:29 +0900 Subject: [PATCH 207/452] [ruby/logger] Update logger.gemspec https://github.com/ruby/logger/commit/1335a71d98 --- lib/logger.gemspec | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/logger.gemspec b/lib/logger.gemspec index da28b629be2f70..53ed1e28fd737d 100644 --- a/lib/logger.gemspec +++ b/lib/logger.gemspec @@ -1,7 +1,7 @@ begin - require File.expand_path("../lib/logger/version", __FILE__) -rescue LoadError - require File.expand_path("../logger/version", __FILE__) + require_relative "lib/logger/version" +rescue LoadError # Fallback to load version file in ruby core repository + require_relative "logger/version" end Gem::Specification.new do |spec| @@ -19,7 +19,7 @@ Gem::Specification.new do |spec| spec.bindir = "exe" spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - + spec.required_ruby_version = ">= 2.3.0" spec.add_development_dependency "bundler", ">= 0" From 3fdb963827fde7fbe1837763cb834842b8336fee Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Thu, 21 Mar 2019 12:35:29 +1300 Subject: [PATCH 208/452] [ruby/logger] Prefer require_relative, it's a little bit faster. https://github.com/ruby/logger/commit/1e2aab4bea --- lib/logger.rb | 11 ++++++----- lib/logger/log_device.rb | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/logger.rb b/lib/logger.rb index d6539a6f698400..6ea4e8e8dc5e3c 100644 --- a/lib/logger.rb +++ b/lib/logger.rb @@ -11,11 +11,12 @@ # A simple system for logging messages. See Logger for more documentation. require 'monitor' -require 'logger/version' -require 'logger/formatter' -require 'logger/log_device' -require 'logger/severity' -require 'logger/errors' + +require_relative 'logger/version' +require_relative 'logger/formatter' +require_relative 'logger/log_device' +require_relative 'logger/severity' +require_relative 'logger/errors' # == Description # diff --git a/lib/logger/log_device.rb b/lib/logger/log_device.rb index 7cfb45b5566785..d287a470fcfbdc 100644 --- a/lib/logger/log_device.rb +++ b/lib/logger/log_device.rb @@ -1,4 +1,4 @@ -require 'logger/period' +require_relative 'period' class Logger # Device used for logging messages. From 2c22051b4b54482531e43915f5edef0c3d3a053b Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Thu, 21 Mar 2019 16:58:17 +1300 Subject: [PATCH 209/452] [ruby/logger] Enable `frozen_string_literal: true` in `logger.rb`. https://github.com/ruby/logger/commit/2dc832e901 --- lib/logger.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/logger.rb b/lib/logger.rb index 6ea4e8e8dc5e3c..4794911a693df7 100644 --- a/lib/logger.rb +++ b/lib/logger.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true # logger.rb - simple logging utility # Copyright (C) 2000-2003, 2005, 2008, 2011 NAKAMURA, Hiroshi . # From f4064a0a0c24734b1ec98e6e2dbdf5e38e856c41 Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Thu, 16 May 2019 17:35:21 -0700 Subject: [PATCH 210/452] [ruby/logger] Set filename when initializing logger with a File object This should allow reopen to work. Requested in ruby issue #14595. https://github.com/ruby/logger/commit/bd367aff12 --- lib/logger/log_device.rb | 3 +++ test/logger/test_logdevice.rb | 15 +++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/lib/logger/log_device.rb b/lib/logger/log_device.rb index d287a470fcfbdc..c6dc43c11a79ba 100644 --- a/lib/logger/log_device.rb +++ b/lib/logger/log_device.rb @@ -76,6 +76,9 @@ def reopen(log = nil) def set_dev(log) if log.respond_to?(:write) and log.respond_to?(:close) @dev = log + if log.respond_to?(:path) + @filename = log.path + end else @dev = open_logfile(log) @dev.sync = true diff --git a/test/logger/test_logdevice.rb b/test/logger/test_logdevice.rb index 30047f89b1a07e..72802f690dd395 100644 --- a/test/logger/test_logdevice.rb +++ b/test/logger/test_logdevice.rb @@ -60,6 +60,21 @@ def test_initialize ensure logdev.close end + # logfile object with path + tempfile = Tempfile.new("logger") + tempfile.sync = true + logdev = d(tempfile) + begin + logdev.write('world') + logfile = File.read(tempfile.path) + assert_equal(1, logfile.split(/\n/).size) + assert_match(/^world$/, logfile) + assert_equal(tempfile.path, logdev.filename) + ensure + logdev.close + File.unlink(tempfile) + tempfile.close(true) + end end def test_write From 58065b87018a9d1ed972b8c856004bf75728da02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Tue, 4 Jun 2019 18:07:26 -0400 Subject: [PATCH 211/452] [ruby/logger] Add option to set the binary mode of the log device Without binmode strings with incompatible encoding can't be written in the file. This is very common in applications that log user provided parameters. We need to allow changing the binnary mode because right now it is impossible to use the built-in log rotation feature when you provide a File object to the LogDevice, and if you provide a filename you can't have binmode. https://github.com/ruby/logger/commit/9114b3ac7e --- lib/logger.rb | 11 +++++++---- lib/logger/log_device.rb | 5 ++++- test/logger/test_logdevice.rb | 3 +++ test/logger/test_logger.rb | 23 +++++++++++++++++++++++ 4 files changed, 37 insertions(+), 5 deletions(-) diff --git a/lib/logger.rb b/lib/logger.rb index 4794911a693df7..ddd80176dff4cd 100644 --- a/lib/logger.rb +++ b/lib/logger.rb @@ -365,6 +365,8 @@ def fatal!; self.level = FATAL; end # Logging formatter. Default values is an instance of Logger::Formatter. # +datetime_format+:: # Date and time format. Default value is '%Y-%m-%d %H:%M:%S'. + # +binmode+:: + # Use binany mode on the log device. Defaul value is false. # +shift_period_suffix+:: # The log file suffix format for +daily+, +weekly+ or +monthly+ rotation. # Default is '%Y%m%d'. @@ -375,7 +377,7 @@ def fatal!; self.level = FATAL; end # def initialize(logdev, shift_age = 0, shift_size = 1048576, level: DEBUG, progname: nil, formatter: nil, datetime_format: nil, - shift_period_suffix: '%Y%m%d') + binmode: false, shift_period_suffix: '%Y%m%d') self.level = level self.progname = progname @default_formatter = Formatter.new @@ -383,9 +385,10 @@ def initialize(logdev, shift_age = 0, shift_size = 1048576, level: DEBUG, self.formatter = formatter @logdev = nil if logdev - @logdev = LogDevice.new(logdev, :shift_age => shift_age, - :shift_size => shift_size, - :shift_period_suffix => shift_period_suffix) + @logdev = LogDevice.new(logdev, shift_age: shift_age, + shift_size: shift_size, + shift_period_suffix: shift_period_suffix, + binmode: binmode) end end diff --git a/lib/logger/log_device.rb b/lib/logger/log_device.rb index c6dc43c11a79ba..5661f5ce1458cc 100644 --- a/lib/logger/log_device.rb +++ b/lib/logger/log_device.rb @@ -9,8 +9,9 @@ class LogDevice attr_reader :filename include MonitorMixin - def initialize(log = nil, shift_age: nil, shift_size: nil, shift_period_suffix: nil) + def initialize(log = nil, shift_age: nil, shift_size: nil, shift_period_suffix: nil, binmode: false) @dev = @filename = @shift_age = @shift_size = @shift_period_suffix = nil + @binmode = binmode mon_initialize set_dev(log) if @filename @@ -82,6 +83,7 @@ def set_dev(log) else @dev = open_logfile(log) @dev.sync = true + @dev.binmode if @binmode @filename = log end end @@ -99,6 +101,7 @@ def create_logfile(filename) logdev = File.open(filename, (File::WRONLY | File::APPEND | File::CREAT | File::EXCL)) logdev.flock(File::LOCK_EX) logdev.sync = true + logdev.binmode if @binmode add_log_header(logdev) logdev.flock(File::LOCK_UN) rescue Errno::EEXIST diff --git a/test/logger/test_logdevice.rb b/test/logger/test_logdevice.rb index 72802f690dd395..40f646d855cba9 100644 --- a/test/logger/test_logdevice.rb +++ b/test/logger/test_logdevice.rb @@ -45,6 +45,7 @@ def test_initialize begin assert_file.exist?(@filename) assert_predicate(logdev.dev, :sync) + refute_predicate(logdev.dev, :binmode?) assert_equal(@filename, logdev.filename) logdev.write('hello') ensure @@ -53,6 +54,8 @@ def test_initialize # create logfile whitch is already exist. logdev = d(@filename) begin + assert_predicate(logdev.dev, :sync) + refute_predicate(logdev.dev, :binmode?) logdev.write('world') logfile = File.read(@filename) assert_equal(2, logfile.split(/\n/).size) diff --git a/test/logger/test_logger.rb b/test/logger/test_logger.rb index 5806e0c68501e6..029203877a597d 100644 --- a/test/logger/test_logger.rb +++ b/test/logger/test_logger.rb @@ -240,6 +240,29 @@ def test_add assert_equal("false\n", log.msg) end + def test_add_binary_data_with_binmode_logdev + EnvUtil.with_default_internal(Encoding::UTF_8) do + begin + tempfile = Tempfile.new("logger") + tempfile.close + filename = tempfile.path + File.unlink(filename) + + logger = Logger.new filename, binmode: true + logger.level = Logger::DEBUG + + str = +"\x80" + str.force_encoding("ASCII-8BIT") + + logger.add Logger::DEBUG, str + assert_equal(2, File.binread(filename).split(/\n/).size) + ensure + logger.close + tempfile.unlink + end + end + end + def test_level_log logger = Logger.new(nil) logger.progname = "my_progname" From 1b59ed9b494104d3a571bb222ee843cd82d1c9ba Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Mon, 15 Jul 2019 14:39:10 +0900 Subject: [PATCH 212/452] Move helper file of logger to under the test/logger. --- test/{ => logger}/helper.rb | 0 test/logger/test_logdevice.rb | 2 +- test/logger/test_logger.rb | 2 +- test/logger/test_logperiod.rb | 3 +-- test/logger/test_severity.rb | 2 +- 5 files changed, 4 insertions(+), 5 deletions(-) rename test/{ => logger}/helper.rb (100%) diff --git a/test/helper.rb b/test/logger/helper.rb similarity index 100% rename from test/helper.rb rename to test/logger/helper.rb diff --git a/test/logger/test_logdevice.rb b/test/logger/test_logdevice.rb index 40f646d855cba9..2c842e93437272 100644 --- a/test/logger/test_logdevice.rb +++ b/test/logger/test_logdevice.rb @@ -1,6 +1,6 @@ # coding: US-ASCII # frozen_string_literal: false -require_relative '../helper' +require_relative 'helper' require 'tempfile' require 'tmpdir' diff --git a/test/logger/test_logger.rb b/test/logger/test_logger.rb index 029203877a597d..da68e581759015 100644 --- a/test/logger/test_logger.rb +++ b/test/logger/test_logger.rb @@ -1,6 +1,6 @@ # coding: US-ASCII # frozen_string_literal: false -require_relative '../helper' +require_relative 'helper' require 'tempfile' class TestLogger < Test::Unit::TestCase diff --git a/test/logger/test_logperiod.rb b/test/logger/test_logperiod.rb index e3be0a6fc6487e..5c5318ac955d96 100644 --- a/test/logger/test_logperiod.rb +++ b/test/logger/test_logperiod.rb @@ -1,7 +1,6 @@ # coding: US-ASCII # frozen_string_literal: false -require 'test/unit' -require 'logger' +require_relative 'helper' require 'time' class TestLogPeriod < Test::Unit::TestCase diff --git a/test/logger/test_severity.rb b/test/logger/test_severity.rb index 4da23cdd0f90bf..1197e8abb9a7d0 100644 --- a/test/logger/test_severity.rb +++ b/test/logger/test_severity.rb @@ -1,6 +1,6 @@ # coding: US-ASCII # frozen_string_literal: false -require_relative '../helper' +require_relative 'helper' class TestLoggerSeverity < Test::Unit::TestCase def test_enum From 0eafa1dce86be0e2f86a029271ec24cf6b577fad Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Mon, 15 Jul 2019 14:41:22 +0900 Subject: [PATCH 213/452] Fixed inconsitency locations of default gems. --- lib/{ => e2mmap}/e2mmap.gemspec | 0 lib/{ => logger}/logger.gemspec | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename lib/{ => e2mmap}/e2mmap.gemspec (100%) rename lib/{ => logger}/logger.gemspec (100%) diff --git a/lib/e2mmap.gemspec b/lib/e2mmap/e2mmap.gemspec similarity index 100% rename from lib/e2mmap.gemspec rename to lib/e2mmap/e2mmap.gemspec diff --git a/lib/logger.gemspec b/lib/logger/logger.gemspec similarity index 100% rename from lib/logger.gemspec rename to lib/logger/logger.gemspec From 4b345f9d4bbff2cfc9895155fb0e8f90d1cac816 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Mon, 15 Jul 2019 14:42:22 +0900 Subject: [PATCH 214/452] compile.c: ignore the result of COMPILE by marking with NO_CHECK to suppress many warnings of Coverity Scan --- compile.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/compile.c b/compile.c index ddb081526cbc2f..a7b49c814e04e5 100644 --- a/compile.c +++ b/compile.c @@ -442,6 +442,7 @@ do { \ #define COMPILE_NG 0 #define CHECK(sub) if (!(sub)) {BEFORE_RETURN;return COMPILE_NG;} +#define NO_CHECK(sub) (void)(sub) #define BEFORE_RETURN /* leave name uninitialized so that compiler warn if INIT_ANCHOR is @@ -638,7 +639,7 @@ rb_iseq_compile_node(rb_iseq_t *iseq, const NODE *node) } if (node == 0) { - COMPILE(ret, "nil", node); + NO_CHECK(COMPILE(ret, "nil", node)); iseq_set_local_table(iseq, 0); } /* assume node is T_NODE */ @@ -1575,7 +1576,7 @@ iseq_set_arguments_keywords(rb_iseq_t *iseq, LINK_ANCHOR *const optargs, dv = Qfalse; break; default: - COMPILE_POPPED(optargs, "kwarg", node); /* nd_type(node) == NODE_KW_ARG */ + NO_CHECK(COMPILE_POPPED(optargs, "kwarg", node)); /* nd_type(node) == NODE_KW_ARG */ dv = complex_mark; } @@ -1712,7 +1713,7 @@ iseq_set_arguments(rb_iseq_t *iseq, LINK_ANCHOR *const optargs, const NODE *cons COMPILE_POPPED(optargs, "init arguments (m)", args->pre_init); } if (args->post_init) { /* p_init */ - COMPILE_POPPED(optargs, "init arguments (p)", args->post_init); + NO_CHECK(COMPILE_POPPED(optargs, "init arguments (p)", args->post_init)); } if (body->type == ISEQ_TYPE_BLOCK) { @@ -3832,7 +3833,7 @@ compile_keyword_arg(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *key_node = node->nd_head; const NODE *val_node = node->nd_next->nd_head; keywords[i] = key_node->nd_lit; - COMPILE(ret, "keyword values", val_node); + NO_CHECK(COMPILE(ret, "keyword values", val_node)); } assert(i == len); return TRUE; @@ -3858,7 +3859,7 @@ compile_args(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node_roo len--; } else { - COMPILE_(ret, "array element", node->nd_head, FALSE); + NO_CHECK(COMPILE_(ret, "array element", node->nd_head, FALSE)); } } @@ -4055,7 +4056,7 @@ compile_array(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node_ro if (i > 0 || !first) ADD_INSN(ret, line, swap); else ADD_INSN1(ret, line, newhash, INT2FIX(0)); } - COMPILE(ret, "keyword splat", kw); + NO_CHECK(COMPILE(ret, "keyword splat", kw)); if (popped) { ADD_INSN(ret, line, pop); } @@ -4280,10 +4281,10 @@ compile_massign_opt(rb_iseq_t *iseq, LINK_ANCHOR *const ret, while (rhsn) { if (llen <= rlen) { - COMPILE_POPPED(ret, "masgn val (popped)", rhsn->nd_head); + NO_CHECK(COMPILE_POPPED(ret, "masgn val (popped)", rhsn->nd_head)); } else { - COMPILE(ret, "masgn val", rhsn->nd_head); + NO_CHECK(COMPILE(ret, "masgn val", rhsn->nd_head)); } rhsn = rhsn->nd_next; rlen++; @@ -4331,7 +4332,7 @@ compile_massign(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, lhsn = lhsn->nd_next; } - COMPILE(ret, "normal masgn rhs", rhsn); + NO_CHECK(COMPILE(ret, "normal masgn rhs", rhsn)); if (!popped) { ADD_INSN(ret, nd_line(node), dup); @@ -4432,7 +4433,7 @@ compile_cpath(LINK_ANCHOR *const ret, rb_iseq_t *iseq, const NODE *cpath) } else if (cpath->nd_head) { /* Bar::Foo */ - COMPILE(ret, "nd_else->nd_head", cpath->nd_head); + NO_CHECK(COMPILE(ret, "nd_else->nd_head", cpath->nd_head)); return VM_DEFINECLASS_FLAG_SCOPED; } else { @@ -4529,7 +4530,7 @@ defined_expr0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, } defined_expr0(iseq, ret, node->nd_head, lfinish, Qfalse); ADD_INSNL(ret, line, branchunless, lfinish[1]); - COMPILE(ret, "defined/colon2#nd_head", node->nd_head); + NO_CHECK(COMPILE(ret, "defined/colon2#nd_head", node->nd_head)); ADD_INSN3(ret, line, defined, (rb_is_const_id(node->nd_mid) ? @@ -4564,7 +4565,7 @@ defined_expr0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, if (explicit_receiver) { defined_expr0(iseq, ret, node->nd_recv, lfinish, Qfalse); ADD_INSNL(ret, line, branchunless, lfinish[1]); - COMPILE(ret, "defined/recv", node->nd_recv); + NO_CHECK(COMPILE(ret, "defined/recv", node->nd_recv)); ADD_INSN3(ret, line, defined, INT2FIX(DEFINED_METHOD), ID2SYM(node->nd_mid), needstr); } @@ -4752,7 +4753,7 @@ add_ensure_iseq(LINK_ANCHOR *const ret, rb_iseq_t *iseq, int is_return) ISEQ_COMPILE_DATA(iseq)->ensure_node_stack = enlp->prev; ADD_LABEL(ensure_part, lstart); - COMPILE_POPPED(ensure_part, "ensure part", enlp->ensure_node); + NO_CHECK(COMPILE_POPPED(ensure_part, "ensure part", enlp->ensure_node)); ADD_LABEL(ensure_part, lend); ADD_SEQ(ensure, ensure_part); } @@ -4790,7 +4791,7 @@ setup_args_core(rb_iseq_t *iseq, LINK_ANCHOR *const args, const NODE *argn, if (argn) { switch (nd_type(argn)) { case NODE_SPLAT: { - COMPILE(args, "args (splat)", argn->nd_head); + NO_CHECK(COMPILE(args, "args (splat)", argn->nd_head)); ADD_INSN1(args, nd_line(argn), splatarray, dup_rest ? Qtrue : Qfalse); if (flag) *flag |= VM_CALL_ARGS_SPLAT; return INT2FIX(1); @@ -4799,7 +4800,7 @@ setup_args_core(rb_iseq_t *iseq, LINK_ANCHOR *const args, const NODE *argn, case NODE_ARGSPUSH: { int next_is_array = (nd_type(argn->nd_head) == NODE_ARRAY); VALUE argc = setup_args_core(iseq, args, argn->nd_head, 1, NULL, NULL); - COMPILE(args, "args (cat: splat)", argn->nd_body); + NO_CHECK(COMPILE(args, "args (cat: splat)", argn->nd_body)); if (flag) { *flag |= VM_CALL_ARGS_SPLAT; /* This is a dirty hack. It traverses the AST twice. @@ -4844,7 +4845,7 @@ setup_args(rb_iseq_t *iseq, LINK_ANCHOR *const args, const NODE *argn, if (argn && nd_type(argn) == NODE_BLOCK_PASS) { DECL_ANCHOR(arg_block); INIT_ANCHOR(arg_block); - COMPILE(arg_block, "block", argn->nd_body); + NO_CHECK(COMPILE(arg_block, "block", argn->nd_body)); *flag |= VM_CALL_ARGS_BLOCKARG; ret = setup_args_core(iseq, args, argn->nd_head, 0, flag, keywords); @@ -4901,7 +4902,7 @@ compile_named_capture_assign(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE ADD_INSN(ret, line, dup); } last = ret->last; - COMPILE_POPPED(ret, "capture", vars->nd_head); + NO_CHECK(COMPILE_POPPED(ret, "capture", vars->nd_head)); last = last->next; /* putobject :var */ cap = new_insn_send(iseq, line, idAREF, INT2FIX(1), NULL, INT2FIX(0), NULL); From f103ed8b7dae9ba9cb1d8dcc71164c972a4ebccd Mon Sep 17 00:00:00 2001 From: git Date: Mon, 15 Jul 2019 14:43:39 +0900 Subject: [PATCH 215/452] * expand tabs. --- compile.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/compile.c b/compile.c index a7b49c814e04e5..d521d8a489af20 100644 --- a/compile.c +++ b/compile.c @@ -639,7 +639,7 @@ rb_iseq_compile_node(rb_iseq_t *iseq, const NODE *node) } if (node == 0) { - NO_CHECK(COMPILE(ret, "nil", node)); + NO_CHECK(COMPILE(ret, "nil", node)); iseq_set_local_table(iseq, 0); } /* assume node is T_NODE */ @@ -1576,7 +1576,7 @@ iseq_set_arguments_keywords(rb_iseq_t *iseq, LINK_ANCHOR *const optargs, dv = Qfalse; break; default: - NO_CHECK(COMPILE_POPPED(optargs, "kwarg", node)); /* nd_type(node) == NODE_KW_ARG */ + NO_CHECK(COMPILE_POPPED(optargs, "kwarg", node)); /* nd_type(node) == NODE_KW_ARG */ dv = complex_mark; } @@ -1713,7 +1713,7 @@ iseq_set_arguments(rb_iseq_t *iseq, LINK_ANCHOR *const optargs, const NODE *cons COMPILE_POPPED(optargs, "init arguments (m)", args->pre_init); } if (args->post_init) { /* p_init */ - NO_CHECK(COMPILE_POPPED(optargs, "init arguments (p)", args->post_init)); + NO_CHECK(COMPILE_POPPED(optargs, "init arguments (p)", args->post_init)); } if (body->type == ISEQ_TYPE_BLOCK) { @@ -3833,7 +3833,7 @@ compile_keyword_arg(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *key_node = node->nd_head; const NODE *val_node = node->nd_next->nd_head; keywords[i] = key_node->nd_lit; - NO_CHECK(COMPILE(ret, "keyword values", val_node)); + NO_CHECK(COMPILE(ret, "keyword values", val_node)); } assert(i == len); return TRUE; @@ -4056,7 +4056,7 @@ compile_array(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node_ro if (i > 0 || !first) ADD_INSN(ret, line, swap); else ADD_INSN1(ret, line, newhash, INT2FIX(0)); } - NO_CHECK(COMPILE(ret, "keyword splat", kw)); + NO_CHECK(COMPILE(ret, "keyword splat", kw)); if (popped) { ADD_INSN(ret, line, pop); } @@ -4281,10 +4281,10 @@ compile_massign_opt(rb_iseq_t *iseq, LINK_ANCHOR *const ret, while (rhsn) { if (llen <= rlen) { - NO_CHECK(COMPILE_POPPED(ret, "masgn val (popped)", rhsn->nd_head)); + NO_CHECK(COMPILE_POPPED(ret, "masgn val (popped)", rhsn->nd_head)); } else { - NO_CHECK(COMPILE(ret, "masgn val", rhsn->nd_head)); + NO_CHECK(COMPILE(ret, "masgn val", rhsn->nd_head)); } rhsn = rhsn->nd_next; rlen++; @@ -4332,7 +4332,7 @@ compile_massign(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, lhsn = lhsn->nd_next; } - NO_CHECK(COMPILE(ret, "normal masgn rhs", rhsn)); + NO_CHECK(COMPILE(ret, "normal masgn rhs", rhsn)); if (!popped) { ADD_INSN(ret, nd_line(node), dup); @@ -4433,7 +4433,7 @@ compile_cpath(LINK_ANCHOR *const ret, rb_iseq_t *iseq, const NODE *cpath) } else if (cpath->nd_head) { /* Bar::Foo */ - NO_CHECK(COMPILE(ret, "nd_else->nd_head", cpath->nd_head)); + NO_CHECK(COMPILE(ret, "nd_else->nd_head", cpath->nd_head)); return VM_DEFINECLASS_FLAG_SCOPED; } else { @@ -4530,7 +4530,7 @@ defined_expr0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, } defined_expr0(iseq, ret, node->nd_head, lfinish, Qfalse); ADD_INSNL(ret, line, branchunless, lfinish[1]); - NO_CHECK(COMPILE(ret, "defined/colon2#nd_head", node->nd_head)); + NO_CHECK(COMPILE(ret, "defined/colon2#nd_head", node->nd_head)); ADD_INSN3(ret, line, defined, (rb_is_const_id(node->nd_mid) ? @@ -4565,7 +4565,7 @@ defined_expr0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, if (explicit_receiver) { defined_expr0(iseq, ret, node->nd_recv, lfinish, Qfalse); ADD_INSNL(ret, line, branchunless, lfinish[1]); - NO_CHECK(COMPILE(ret, "defined/recv", node->nd_recv)); + NO_CHECK(COMPILE(ret, "defined/recv", node->nd_recv)); ADD_INSN3(ret, line, defined, INT2FIX(DEFINED_METHOD), ID2SYM(node->nd_mid), needstr); } @@ -4753,7 +4753,7 @@ add_ensure_iseq(LINK_ANCHOR *const ret, rb_iseq_t *iseq, int is_return) ISEQ_COMPILE_DATA(iseq)->ensure_node_stack = enlp->prev; ADD_LABEL(ensure_part, lstart); - NO_CHECK(COMPILE_POPPED(ensure_part, "ensure part", enlp->ensure_node)); + NO_CHECK(COMPILE_POPPED(ensure_part, "ensure part", enlp->ensure_node)); ADD_LABEL(ensure_part, lend); ADD_SEQ(ensure, ensure_part); } @@ -4902,7 +4902,7 @@ compile_named_capture_assign(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE ADD_INSN(ret, line, dup); } last = ret->last; - NO_CHECK(COMPILE_POPPED(ret, "capture", vars->nd_head)); + NO_CHECK(COMPILE_POPPED(ret, "capture", vars->nd_head)); last = last->next; /* putobject :var */ cap = new_insn_send(iseq, line, idAREF, INT2FIX(1), NULL, INT2FIX(0), NULL); From 036039c8a29d3d8045207c111f9bbc481c904998 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Mon, 15 Jul 2019 14:45:05 +0900 Subject: [PATCH 216/452] Fixed LoadError of version file. --- lib/logger/logger.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/logger/logger.gemspec b/lib/logger/logger.gemspec index 53ed1e28fd737d..e5b926abc19b7b 100644 --- a/lib/logger/logger.gemspec +++ b/lib/logger/logger.gemspec @@ -1,7 +1,7 @@ begin require_relative "lib/logger/version" rescue LoadError # Fallback to load version file in ruby core repository - require_relative "logger/version" + require_relative "version" end Gem::Specification.new do |spec| From 5349aa23c8ad23786d25c1e18a3f541de06f4700 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Mon, 15 Jul 2019 14:47:29 +0900 Subject: [PATCH 217/452] Also fixed up with 036039c8a29d3d8045207c111f9bbc481c904998 --- lib/e2mmap/e2mmap.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/e2mmap/e2mmap.gemspec b/lib/e2mmap/e2mmap.gemspec index b9808d89ffdb5a..fc3efde04bcb32 100644 --- a/lib/e2mmap/e2mmap.gemspec +++ b/lib/e2mmap/e2mmap.gemspec @@ -2,7 +2,7 @@ begin require_relative "lib/e2mmap/version" rescue LoadError # for Ruby core repository - require_relative "e2mmap/version" + require_relative "version" end Gem::Specification.new do |spec| From f73ea3342b5abd3136a1fb27fc0fdbe4039bc3bf Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Mon, 15 Jul 2019 15:07:26 +0900 Subject: [PATCH 218/452] Fixed ruby/spec for Logger::LogDevice changes. --- spec/ruby/library/logger/device/close_spec.rb | 15 ++++++++++++--- spec/ruby/library/logger/device/write_spec.rb | 15 ++++++++++++--- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/spec/ruby/library/logger/device/close_spec.rb b/spec/ruby/library/logger/device/close_spec.rb index 3d7ab134e091d5..3fd96675a49f20 100644 --- a/spec/ruby/library/logger/device/close_spec.rb +++ b/spec/ruby/library/logger/device/close_spec.rb @@ -15,8 +15,17 @@ rm_r @file_path end - it "closes the LogDevice's stream" do - @device.close - lambda { @device.write("Test") }.should complain(/\Alog writing failed\./) + ruby_version_is ""..."2.7" do + it "closes the LogDevice's stream" do + @device.close + lambda { @device.write("Test") }.should complain(/\Alog writing failed\./) + end + end + + ruby_version_is "2.7" do + it "closes the LogDevice's stream" do + @device.close + lambda { @device.write("Test") }.should complain(/\Alog shifting failed\./) + end end end diff --git a/spec/ruby/library/logger/device/write_spec.rb b/spec/ruby/library/logger/device/write_spec.rb index 6305a623e34583..6f4e13c8e6b807 100644 --- a/spec/ruby/library/logger/device/write_spec.rb +++ b/spec/ruby/library/logger/device/write_spec.rb @@ -35,8 +35,17 @@ rm_r path end - it "fails if the device is already closed" do - @device.close - lambda { @device.write "foo" }.should complain(/\Alog writing failed\./) + ruby_version_is ""..."2.7" do + it "fails if the device is already closed" do + @device.close + lambda { @device.write "foo" }.should complain(/\Alog writing failed\./) + end + end + + ruby_version_is "2.7" do + it "fails if the device is already closed" do + @device.close + lambda { @device.write "foo" }.should complain(/\Alog shifting failed\./) + end end end From 3a1d3556e2ae5f6083dbd8b97e5b3009eaceaab3 Mon Sep 17 00:00:00 2001 From: aycabta Date: Mon, 15 Jul 2019 15:45:51 +0900 Subject: [PATCH 219/452] Fix a typo of Markdown of NEWS --- NEWS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 31f48984b5f740..1e38c6c5b81902 100644 --- a/NEWS +++ b/NEWS @@ -217,7 +217,7 @@ open-uri:: * The default charset of text/* media type is UTF-8 instead of ISO-8859-1. [Bug #15933] -Pathname: +Pathname:: * Delegates 3 arguments from Pathname.glob to Dir.glob to accept base: keyword. From 574e8a6812aea072acbf55970f7ff2e32ed4e599 Mon Sep 17 00:00:00 2001 From: aycabta Date: Mon, 15 Jul 2019 15:49:59 +0900 Subject: [PATCH 220/452] Add Reline section to NEWS --- NEWS | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/NEWS b/NEWS index 1e38c6c5b81902..b66c52ce70014b 100644 --- a/NEWS +++ b/NEWS @@ -226,6 +226,11 @@ Racc:: * Merge 1.4.15 from upstream repository and added cli of racc. +Reline:: + + * New stdlib that is compatible with readline stdlib by pure Ruby and also + has a multiline mode. + RSS:: * Upgrade to RSS 0.2.8. From de0f192444e3822968d04cdea6e868bd42ccfa7f Mon Sep 17 00:00:00 2001 From: aycabta Date: Mon, 15 Jul 2019 16:25:50 +0900 Subject: [PATCH 221/452] Add features of IRB to NEWS --- NEWS | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/NEWS b/NEWS index b66c52ce70014b..4b6e756ab5922a 100644 --- a/NEWS +++ b/NEWS @@ -205,6 +205,12 @@ IRB:: * Introduce syntax highlight inspired by pry.gem to Binding#irb source lines, REPL input, and inspect output of some core-class objects. + * Introduce multiline mode by Reline. + + * Show documents when completion. + + * Enable auto indent and save/load history by default. + Net::IMAP:: * Add Server Name Indication (SNI) support. [Feature #15594] From 5e0d27a32f2b3f1242c9990acf83b7970b37bbce Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Mon, 15 Jul 2019 16:44:07 +0900 Subject: [PATCH 222/452] Removed dead code If `emesg` is `Qundef`, it is not a message string and then `elen` (the length of the message) is 0. So `emesg` cannot be `Qundef` in the `elen != 0` block. Pointed out by Coverity Scan. --- eval_error.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/eval_error.c b/eval_error.c index b0ee0f45c90206..44d82e8a7f4518 100644 --- a/eval_error.c +++ b/eval_error.c @@ -169,9 +169,10 @@ print_errinfo(const VALUE eclass, const VALUE errat, const VALUE emesg, const VA write_warn(str, "\n"); } else { + /* emesg is a String instance */ const char *tail = 0; - if (emesg == Qundef && highlight) write_warn(str, bold); + if (highlight) write_warn(str, bold); if (RSTRING_PTR(epath)[0] == '#') epath = 0; if ((tail = memchr(einfo, '\n', elen)) != 0) { From 5a42dca6887203ebba3532f4430c17d3a73a6169 Mon Sep 17 00:00:00 2001 From: git Date: Mon, 15 Jul 2019 16:51:18 +0900 Subject: [PATCH 223/452] * expand tabs. --- eval_error.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eval_error.c b/eval_error.c index 44d82e8a7f4518..6132cbe8c8cedb 100644 --- a/eval_error.c +++ b/eval_error.c @@ -169,10 +169,10 @@ print_errinfo(const VALUE eclass, const VALUE errat, const VALUE emesg, const VA write_warn(str, "\n"); } else { - /* emesg is a String instance */ + /* emesg is a String instance */ const char *tail = 0; - if (highlight) write_warn(str, bold); + if (highlight) write_warn(str, bold); if (RSTRING_PTR(epath)[0] == '#') epath = 0; if ((tail = memchr(einfo, '\n', elen)) != 0) { From c781b1b7a3d112c6f9b2521c4ff2c5408a429a72 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Mon, 15 Jul 2019 17:06:35 +0900 Subject: [PATCH 224/452] update-deps for dependencies --- defs/gmake.mk | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/defs/gmake.mk b/defs/gmake.mk index 4a3d1c857c90ce..012c3832b98b28 100644 --- a/defs/gmake.mk +++ b/defs/gmake.mk @@ -284,3 +284,20 @@ ifneq ($(filter $(VCS),git),) update-src:: @$(BASERUBY) $(srcdir)/tool/lib/colorize.rb pass "Latest commit hash = $(shell $(filter-out svn,$(VCS)) -C $(srcdir) rev-parse --short=10 HEAD)" endif + +# Update dependencies and commit the updates to the current branch. +update-deps: + $(eval update_deps := $(shell date +update-deps-%Y%m%d)) + $(eval deps_dir := $(shell mktemp -d)/$(update_deps)) + $(eval GIT_DIR := $(shell git -C $(srcdir) rev-parse --absolute-git-dir)) + git --git-dir=$(GIT_DIR) worktree add $(deps_dir) + cp $(srcdir)/tool/config.guess $(srcdir)/tool/config.sub $(deps_dir)/tool + [ -f config.status ] && cp config.status $(deps_dir) + cd $(deps_dir) && autoconf && \ + exec ./configure -q -C --enable-load-relative --disable-install-doc --disable-rubygems 'optflags=-O0' 'debugflags=-save-temps=obj -g' + $(RUNRUBY) -C $(deps_dir) tool/update-deps --fix + git -C $(deps_dir) diff --no-ext-diff --ignore-submodules --exit-code || \ + git -C $(deps_dir) commit --all --message='Update dependencies' + git --git-dir=$(GIT_DIR) worktree remove $(deps_dir) + git --git-dir=$(GIT_DIR) merge --no-edit --ff-only $(update_deps) + git --git-dir=$(GIT_DIR) branch --delete $(update_deps) From c20445ab561b6b74bc60787b7c7f69795986e4a3 Mon Sep 17 00:00:00 2001 From: aycabta Date: Mon, 15 Jul 2019 17:20:48 +0900 Subject: [PATCH 225/452] Require Ruby 2.4 or later because needs lex_state from Ripper --- lib/irb/irb.gemspec | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/irb/irb.gemspec b/lib/irb/irb.gemspec index 35e40efae04919..84fe4fff68bbd8 100644 --- a/lib/irb/irb.gemspec +++ b/lib/irb/irb.gemspec @@ -21,6 +21,8 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] + spec.required_ruby_version = Gem::Requirement.new(">= 2.4") + spec.add_dependency "reline", ">= 0.0.1" spec.add_development_dependency "bundler" spec.add_development_dependency "rake" From b452c03a14f943ae25338547bd680fce67399d85 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Mon, 15 Jul 2019 17:45:37 +0900 Subject: [PATCH 226/452] Always evaluate the expression RUBY_ASSERT_MESG_WHEN just once --- include/ruby/assert.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/ruby/assert.h b/include/ruby/assert.h index d19d8e4e3203b3..bdc0234c58e295 100644 --- a/include/ruby/assert.h +++ b/include/ruby/assert.h @@ -23,7 +23,7 @@ NORETURN(void rb_assert_failure(const char *, int, const char *, const char *)); ((RUBY_DEBUG+0) ? RUBY_ASSERT_MESG((expr), mesg) : \ __builtin_choose_expr( \ __builtin_constant_p(cond), \ - __builtin_choose_expr(cond, RUBY_ASSERT_MESG(expr, mesg), (void)0), \ + __builtin_choose_expr(cond, RUBY_ASSERT_MESG(expr, mesg), (void)(expr)), \ RUBY_ASSERT_MESG(!(cond) || (expr), mesg))) #else # define RUBY_ASSERT_MESG_WHEN(cond, expr, mesg) \ From 0c6c937904aafc1809386bd892a2d114d22d01fe Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Mon, 15 Jul 2019 19:31:48 +0900 Subject: [PATCH 227/452] Removed duplicate highlighting --- eval_error.c | 2 -- test/ruby/test_exception.rb | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/eval_error.c b/eval_error.c index 6132cbe8c8cedb..17c0e865b94bd6 100644 --- a/eval_error.c +++ b/eval_error.c @@ -144,8 +144,6 @@ print_errinfo(const VALUE eclass, const VALUE errat, const VALUE emesg, const VA write_warn(str, ": "); } - if (highlight) write_warn(str, bold); - if (!NIL_P(emesg)) { einfo = RSTRING_PTR(emesg); elen = RSTRING_LEN(emesg); diff --git a/test/ruby/test_exception.rb b/test/ruby/test_exception.rb index c69d18b0c9a6e9..713a59df70db2d 100644 --- a/test/ruby/test_exception.rb +++ b/test/ruby/test_exception.rb @@ -1407,6 +1407,9 @@ def test_full_message message = e.full_message(highlight: true) assert_match(/\e/, message) + assert_not_match(/(\e\[1)m\1/, message) + e2 = assert_raise(RuntimeError) {raise RuntimeError, "", bt} + assert_not_match(/(\e\[1)m\1/, e2.full_message(highlight: true)) message = e.full_message if Exception.to_tty? From 6aab77a7a3e29a82006878f87e24ed30fa985a1f Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Tue, 16 Jul 2019 07:17:57 +0900 Subject: [PATCH 228/452] Add a /* fall through */ comment --- compile.c | 1 + 1 file changed, 1 insertion(+) diff --git a/compile.c b/compile.c index d521d8a489af20..e553473847e8d7 100644 --- a/compile.c +++ b/compile.c @@ -8636,6 +8636,7 @@ iseq_build_from_ary_body(rb_iseq_t *iseq, LINK_ANCHOR *const anchor, break; case TS_ISE: FL_SET(iseq, ISEQ_MARKABLE_ISEQ); + /* fall through */ case TS_IC: argv[j] = op; if (NUM2UINT(op) >= iseq->body->is_size) { From c184a1c261209da403db553eef7f7353f7ee5edd Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Tue, 16 Jul 2019 07:18:54 +0900 Subject: [PATCH 229/452] compile.c: add NO_CHECK for the calls to COMPILE whose result is unused to suppress many warnings of Coverity Scan --- compile.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compile.c b/compile.c index e553473847e8d7..8a098c71b3011f 100644 --- a/compile.c +++ b/compile.c @@ -1710,7 +1710,7 @@ iseq_set_arguments(rb_iseq_t *iseq, LINK_ANCHOR *const optargs, const NODE *cons body->param.size = arg_size; if (args->pre_init) { /* m_init */ - COMPILE_POPPED(optargs, "init arguments (m)", args->pre_init); + NO_CHECK(COMPILE_POPPED(optargs, "init arguments (m)", args->pre_init)); } if (args->post_init) { /* p_init */ NO_CHECK(COMPILE_POPPED(optargs, "init arguments (p)", args->post_init)); @@ -3961,7 +3961,7 @@ compile_array(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node_ro opt_p = 0; } - COMPILE_(anchor, "array element", node->nd_head, popped); + NO_CHECK(COMPILE_(anchor, "array element", node->nd_head, popped)); } if (opt_p) { @@ -4931,7 +4931,7 @@ compile_named_capture_assign(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE ADD_INSN(ret, line, pop); for (vars = node; vars; vars = vars->nd_next) { last = ret->last; - COMPILE_POPPED(ret, "capture", vars->nd_head); + NO_CHECK(COMPILE_POPPED(ret, "capture", vars->nd_head)); last = last->next; /* putobject :var */ ((INSN*)last)->insn_id = BIN(putnil); ((INSN*)last)->operand_size = 0; From a8e4b7b12f348d5fdde4ba360a68d10c0f2689bf Mon Sep 17 00:00:00 2001 From: git Date: Tue, 16 Jul 2019 07:19:52 +0900 Subject: [PATCH 230/452] * expand tabs. --- compile.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compile.c b/compile.c index 8a098c71b3011f..62cfbbff3e0c9f 100644 --- a/compile.c +++ b/compile.c @@ -1710,7 +1710,7 @@ iseq_set_arguments(rb_iseq_t *iseq, LINK_ANCHOR *const optargs, const NODE *cons body->param.size = arg_size; if (args->pre_init) { /* m_init */ - NO_CHECK(COMPILE_POPPED(optargs, "init arguments (m)", args->pre_init)); + NO_CHECK(COMPILE_POPPED(optargs, "init arguments (m)", args->pre_init)); } if (args->post_init) { /* p_init */ NO_CHECK(COMPILE_POPPED(optargs, "init arguments (p)", args->post_init)); @@ -4931,7 +4931,7 @@ compile_named_capture_assign(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE ADD_INSN(ret, line, pop); for (vars = node; vars; vars = vars->nd_next) { last = ret->last; - NO_CHECK(COMPILE_POPPED(ret, "capture", vars->nd_head)); + NO_CHECK(COMPILE_POPPED(ret, "capture", vars->nd_head)); last = last->next; /* putobject :var */ ((INSN*)last)->insn_id = BIN(putnil); ((INSN*)last)->operand_size = 0; @@ -8636,7 +8636,7 @@ iseq_build_from_ary_body(rb_iseq_t *iseq, LINK_ANCHOR *const anchor, break; case TS_ISE: FL_SET(iseq, ISEQ_MARKABLE_ISEQ); - /* fall through */ + /* fall through */ case TS_IC: argv[j] = op; if (NUM2UINT(op) >= iseq->body->is_size) { From 325d546d627f3cfb50c0371775f671cd88521c49 Mon Sep 17 00:00:00 2001 From: git Date: Tue, 16 Jul 2019 07:19:56 +0900 Subject: [PATCH 231/452] * 2019-07-16 --- version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.h b/version.h index ff89d70166dd30..1580536943372e 100644 --- a/version.h +++ b/version.h @@ -6,7 +6,7 @@ #define RUBY_RELEASE_YEAR 2019 #define RUBY_RELEASE_MONTH 7 -#define RUBY_RELEASE_DAY 15 +#define RUBY_RELEASE_DAY 16 #include "ruby/version.h" From 34019a22eb41206e3d5d1ac29b3874275aa7f71c Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 16 Jul 2019 07:58:47 +0900 Subject: [PATCH 232/452] Expanded f_denominator --- complex.c | 14 ++++++++++++-- internal.h | 1 + rational.c | 6 +++--- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/complex.c b/complex.c index bcdc4865953502..74d91b044f4ce9 100644 --- a/complex.c +++ b/complex.c @@ -191,7 +191,17 @@ f_arg(VALUE x) return rb_funcall(x, id_arg, 0); } -fun1(denominator) +inline static VALUE +f_denominator(VALUE x) +{ + if (RB_TYPE_P(x, T_RATIONAL)) { + return RRATIONAL(x)->den; + } + if (RB_FLOAT_TYPE_P(x)) { + return rb_float_denominator(x); + } + return INT2FIX(1); +} inline static VALUE f_negate(VALUE x) @@ -1252,7 +1262,7 @@ nucomp_numerator(VALUE self) get_dat1(self); - cd = f_denominator(self); + cd = nucomp_denominator(self); return f_complex_new2(CLASS_OF(self), f_mul(f_numerator(dat->real), f_div(cd, f_denominator(dat->real))), diff --git a/internal.h b/internal.h index fb184e290cd444..bd82231d37f74c 100644 --- a/internal.h +++ b/internal.h @@ -2029,6 +2029,7 @@ VALUE rb_rational_abs(VALUE self); VALUE rb_rational_cmp(VALUE self, VALUE other); VALUE rb_rational_pow(VALUE self, VALUE other); VALUE rb_numeric_quo(VALUE x, VALUE y); +VALUE rb_float_denominator(VALUE x); /* re.c */ VALUE rb_reg_compile(VALUE str, int options, const char *sourcefile, int sourceline); diff --git a/rational.c b/rational.c index e137ac23e70907..7607628cb0965d 100644 --- a/rational.c +++ b/rational.c @@ -2080,8 +2080,8 @@ float_numerator(VALUE self) * * See also Float#numerator. */ -static VALUE -float_denominator(VALUE self) +VALUE +rb_float_denominator(VALUE self) { double d = RFLOAT_VALUE(self); VALUE r; @@ -2778,7 +2778,7 @@ Init_Rational(void) rb_define_method(rb_cInteger, "denominator", integer_denominator, 0); rb_define_method(rb_cFloat, "numerator", float_numerator, 0); - rb_define_method(rb_cFloat, "denominator", float_denominator, 0); + rb_define_method(rb_cFloat, "denominator", rb_float_denominator, 0); rb_define_method(rb_cNilClass, "to_r", nilclass_to_r, 0); rb_define_method(rb_cNilClass, "rationalize", nilclass_rationalize, -1); From ca524bcd494e2f284c3211cad8e8dde70e8aa86a Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 16 Jul 2019 08:15:05 +0900 Subject: [PATCH 233/452] Expanded f_numerator --- complex.c | 13 ++++++++++++- internal.h | 1 + rational.c | 6 +++--- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/complex.c b/complex.c index 74d91b044f4ce9..fa00036ffb9a95 100644 --- a/complex.c +++ b/complex.c @@ -191,6 +191,18 @@ f_arg(VALUE x) return rb_funcall(x, id_arg, 0); } +inline static VALUE +f_numerator(VALUE x) +{ + if (RB_TYPE_P(x, T_RATIONAL)) { + return RRATIONAL(x)->num; + } + if (RB_FLOAT_TYPE_P(x)) { + return rb_float_numerator(x); + } + return x; +} + inline static VALUE f_denominator(VALUE x) { @@ -221,7 +233,6 @@ f_negate(VALUE x) return rb_funcall(x, id_negate, 0); } -fun1(numerator) fun1(real_p) inline static VALUE diff --git a/internal.h b/internal.h index bd82231d37f74c..2f0a5afe8019d6 100644 --- a/internal.h +++ b/internal.h @@ -2029,6 +2029,7 @@ VALUE rb_rational_abs(VALUE self); VALUE rb_rational_cmp(VALUE self, VALUE other); VALUE rb_rational_pow(VALUE self, VALUE other); VALUE rb_numeric_quo(VALUE x, VALUE y); +VALUE rb_float_numerator(VALUE x); VALUE rb_float_denominator(VALUE x); /* re.c */ diff --git a/rational.c b/rational.c index 7607628cb0965d..7113e15e8e7585 100644 --- a/rational.c +++ b/rational.c @@ -2057,8 +2057,8 @@ static VALUE float_to_r(VALUE self); * * See also Float#denominator. */ -static VALUE -float_numerator(VALUE self) +VALUE +rb_float_numerator(VALUE self) { double d = RFLOAT_VALUE(self); VALUE r; @@ -2777,7 +2777,7 @@ Init_Rational(void) rb_define_method(rb_cInteger, "numerator", integer_numerator, 0); rb_define_method(rb_cInteger, "denominator", integer_denominator, 0); - rb_define_method(rb_cFloat, "numerator", float_numerator, 0); + rb_define_method(rb_cFloat, "numerator", rb_float_numerator, 0); rb_define_method(rb_cFloat, "denominator", rb_float_denominator, 0); rb_define_method(rb_cNilClass, "to_r", nilclass_to_r, 0); From 71d5b4c32e892d1771d73ca869da3a59f5d0b4d1 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 16 Jul 2019 08:25:39 +0900 Subject: [PATCH 234/452] Fixed the library path for tools --- defs/gmake.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/defs/gmake.mk b/defs/gmake.mk index 012c3832b98b28..0824cabc8d91de 100644 --- a/defs/gmake.mk +++ b/defs/gmake.mk @@ -145,7 +145,7 @@ $(TIMESTAMPDIR)/.exec.time: .PHONY: commit commit: $(if $(filter commit,$(MAKECMDGOALS)),$(filter-out commit,$(MAKECMDGOALS))) - @$(BASERUBY) -C "$(srcdir)" -I./tool -rvcs -e 'VCS.detect(".").commit' + @$(BASERUBY) -C "$(srcdir)" -I./tool/lib -rvcs -e 'VCS.detect(".").commit' +$(Q) \ { \ $(CHDIR) "$(srcdir)"; \ From 8e37ef76f6f640178ffaea4d7c0d36a17e6ca171 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 16 Jul 2019 08:46:38 +0900 Subject: [PATCH 235/452] Fixed the library path for tools --- common.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common.mk b/common.mk index de62185e845dbd..b40a8e0fa47e3e 100644 --- a/common.mk +++ b/common.mk @@ -1474,7 +1474,7 @@ sudo-precheck: PHONY @$(SUDO) echo > $(NULL) update-man-date: PHONY - -$(Q) $(BASERUBY) -I"$(srcdir)/tool" -rvcs -i -p \ + -$(Q) $(BASERUBY) -I"$(srcdir)/tool/lib" -rvcs -i -p \ -e 'BEGIN{@vcs=VCS.detect(ARGV.shift)}' \ -e '$$_.sub!(/^(\.Dd ).*/){$$1+@vcs.modified(ARGF.path).strftime("%B %d, %Y")}' \ "$(srcdir)" "$(srcdir)"/man/*.1 From 00dc0dae0d7b247a917f5b676a777db86cdf1f3a Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 16 Jul 2019 08:48:57 +0900 Subject: [PATCH 236/452] Removed intermediate local variables --- class.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/class.c b/class.c index 6c71ec8bd0a211..e3f4f5278139f7 100644 --- a/class.c +++ b/class.c @@ -1871,8 +1871,8 @@ rb_get_kwargs(VALUE keyword_hash, const ID *table, int required, int optional, V #define extract_kwarg(keyword, val) \ (key = (st_data_t)(keyword), values ? \ - rb_hash_stlike_delete(keyword_hash, &key, (val)) : \ - rb_hash_stlike_lookup(keyword_hash, key, (val))) + (rb_hash_stlike_delete(keyword_hash, &key, &(val)) || ((val) = Qundef, 0)) : \ + rb_hash_stlike_lookup(keyword_hash, key, NULL)) if (NIL_P(keyword_hash)) keyword_hash = 0; @@ -1880,18 +1880,11 @@ rb_get_kwargs(VALUE keyword_hash, const ID *table, int required, int optional, V rest = 1; optional = -1-optional; } - if (values) { - for (j = 0; j < required + optional; j++) { - values[j] = Qundef; - } - } if (required) { for (; i < required; i++) { VALUE keyword = ID2SYM(table[i]); if (keyword_hash) { - st_data_t val; - if (extract_kwarg(keyword, &val)) { - if (values) values[i] = (VALUE)val; + if (extract_kwarg(keyword, values[i])) { continue; } } @@ -1905,9 +1898,7 @@ rb_get_kwargs(VALUE keyword_hash, const ID *table, int required, int optional, V j = i; if (optional && keyword_hash) { for (i = 0; i < optional; i++) { - st_data_t val; - if (extract_kwarg(ID2SYM(table[required+i]), &val)) { - if (values) values[required+i] = (VALUE)val; + if (extract_kwarg(ID2SYM(table[required+i]), values[required+i])) { j++; } } @@ -1917,6 +1908,11 @@ rb_get_kwargs(VALUE keyword_hash, const ID *table, int required, int optional, V unknown_keyword_error(keyword_hash, table, required+optional); } } + if (values && !keyword_hash) { + for (i = 0; i < required + optional; i++) { + values[i] = Qundef; + } + } return j; #undef extract_kwarg } From e2f987e65461bff85be2146dda93655b7d13a537 Mon Sep 17 00:00:00 2001 From: git Date: Tue, 16 Jul 2019 09:22:11 +0900 Subject: [PATCH 237/452] * expand tabs. --- class.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/class.c b/class.c index e3f4f5278139f7..7922df56b20405 100644 --- a/class.c +++ b/class.c @@ -1884,7 +1884,7 @@ rb_get_kwargs(VALUE keyword_hash, const ID *table, int required, int optional, V for (; i < required; i++) { VALUE keyword = ID2SYM(table[i]); if (keyword_hash) { - if (extract_kwarg(keyword, values[i])) { + if (extract_kwarg(keyword, values[i])) { continue; } } @@ -1898,7 +1898,7 @@ rb_get_kwargs(VALUE keyword_hash, const ID *table, int required, int optional, V j = i; if (optional && keyword_hash) { for (i = 0; i < optional; i++) { - if (extract_kwarg(ID2SYM(table[required+i]), values[required+i])) { + if (extract_kwarg(ID2SYM(table[required+i]), values[required+i])) { j++; } } @@ -1909,9 +1909,9 @@ rb_get_kwargs(VALUE keyword_hash, const ID *table, int required, int optional, V } } if (values && !keyword_hash) { - for (i = 0; i < required + optional; i++) { - values[i] = Qundef; - } + for (i = 0; i < required + optional; i++) { + values[i] = Qundef; + } } return j; #undef extract_kwarg From 75fb0a9afad1685cedee9c7665a7f30ec95068fc Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 16 Jul 2019 09:30:58 +0900 Subject: [PATCH 238/452] Allow mday in Date.iso8601 to be omitted [Bug #12285] --- ext/date/date_parse.c | 6 +++--- test/date/test_date_parse.rb | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ext/date/date_parse.c b/ext/date/date_parse.c index e0634c39f1be45..ab46bda4ad178a 100644 --- a/ext/date/date_parse.c +++ b/ext/date/date_parse.c @@ -2262,8 +2262,8 @@ iso8601_ext_datetime_cb(VALUE m, VALUE hash) s[i] = rb_reg_nth_match(i, m); } - if (!NIL_P(s[3])) { - set_hash("mday", str2num(s[3])); + if (!NIL_P(s[1])) { + if (!NIL_P(s[3])) set_hash("mday", str2num(s[3])); if (strcmp(RSTRING_PTR(s[1]), "-") != 0) { y = str2num(s[1]); if (RSTRING_LEN(s[1]) < 4) @@ -2320,7 +2320,7 @@ static int iso8601_ext_datetime(VALUE str, VALUE hash) { static const char pat_source[] = - "\\A\\s*(?:([-+]?\\d{2,}|-)-(\\d{2})?-(\\d{2})|" + "\\A\\s*(?:([-+]?\\d{2,}|-)-(\\d{2})?(?:-(\\d{2}))?|" "([-+]?\\d{2,})?-(\\d{3})|" "(\\d{4}|\\d{2})?-w(\\d{2})-(\\d)|" "-w-(\\d))" diff --git a/test/date/test_date_parse.rb b/test/date/test_date_parse.rb index e17fd3eb25fbc5..dda952b8ce0d01 100644 --- a/test/date/test_date_parse.rb +++ b/test/date/test_date_parse.rb @@ -712,6 +712,9 @@ def test__iso8601 h = Date._iso8601('2001-02-03T04:05:06.07+01:00') assert_equal([2001, 2, 3, 4, 5, 6, 3600], h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset)) + h = Date._iso8601('2001-02') + assert_equal([2001, 2], + h.values_at(:year, :mon)) h = Date._iso8601('010203T040506Z') assert_equal([2001, 2, 3, 4, 5, 6, 0], From 76c6cf2cbc549dead57725ccd934a42df5bc150d Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 16 Jul 2019 17:23:43 +0900 Subject: [PATCH 239/452] Print debugging information when updating failed --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 36a9f8d1577e15..0dbcde7464ed97 100644 --- a/.travis.yml +++ b/.travis.yml @@ -417,7 +417,7 @@ before_script: date if ! make -s $JOBS $UPDATE_UNICODE up; then # Prevent random failure by missing build dependency like https://travis-ci.org/ruby/ruby/jobs/558571461 - make -s $JOBS $UPDATE_UNICODE ALWAYS_UPDATE_UNICODE=yes up + make --debug -s $JOBS $UPDATE_UNICODE up fi - date; make -s $JOBS srcs - rm -f config.status Makefile rbconfig.rb .rbconfig.time From 19d592dc82a31adf0bb6f027392cae69615c2394 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 16 Jul 2019 18:41:11 +0900 Subject: [PATCH 240/452] Somehow `if` didn't work --- .travis.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0dbcde7464ed97..f6822b913d5fa0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -413,12 +413,7 @@ before_script: - "> .rbconfig.time" - sed -f tool/prereq.status template/Makefile.in common.mk > Makefile - date; make touch-unicode-files - - |- - date - if ! make -s $JOBS $UPDATE_UNICODE up; then - # Prevent random failure by missing build dependency like https://travis-ci.org/ruby/ruby/jobs/558571461 - make --debug -s $JOBS $UPDATE_UNICODE up - fi + - date; make -s $JOBS $UPDATE_UNICODE up || make --debug -s $JOBS $UPDATE_UNICODE up - date; make -s $JOBS srcs - rm -f config.status Makefile rbconfig.rb .rbconfig.time - |- From 8deabcd3280f6042ea1ed14b629d70680e081fec Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 16 Jul 2019 18:42:56 +0900 Subject: [PATCH 241/452] Constified afamily functions --- ext/socket/raddrinfo.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ext/socket/raddrinfo.c b/ext/socket/raddrinfo.c index a6abad646720cd..1054d0440d4da1 100644 --- a/ext/socket/raddrinfo.c +++ b/ext/socket/raddrinfo.c @@ -1114,16 +1114,16 @@ addrinfo_initialize(int argc, VALUE *argv, VALUE self) } static int -get_afamily(struct sockaddr *addr, socklen_t len) +get_afamily(const struct sockaddr *addr, socklen_t len) { - if ((socklen_t)((char*)&addr->sa_family + sizeof(addr->sa_family) - (char*)addr) <= len) + if ((socklen_t)((const char*)&addr->sa_family + sizeof(addr->sa_family) - (char*)addr) <= len) return addr->sa_family; else return AF_UNSPEC; } static int -ai_get_afamily(rb_addrinfo_t *rai) +ai_get_afamily(const rb_addrinfo_t *rai) { return get_afamily(&rai->addr.addr, rai->sockaddr_len); } From e988048e2589b6f517c11430d568e2ccf118e901 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 16 Jul 2019 18:47:35 +0900 Subject: [PATCH 242/452] Moved the check for `exception` to rb_execarg_addopt Check for `exception` option in rb_execarg_addopt, as well as other options. And then raise a particular ArgumentError if it is not allowed. --- internal.h | 1 + process.c | 23 +++++++++++++---------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/internal.h b/internal.h index 2f0a5afe8019d6..b931c115dfa4ab 100644 --- a/internal.h +++ b/internal.h @@ -1977,6 +1977,7 @@ struct rb_execarg { unsigned uid_given : 1; unsigned gid_given : 1; unsigned exception : 1; + unsigned exception_given : 1; struct waitpid_state *waitpid_state; /* for async process management */ rb_pid_t pgroup_pgid; /* asis(-1), new pgroup(0), specified pgroup (0exception_given) { + rb_raise(rb_eArgError, "exception option specified twice"); + } + eargp->exception = RTEST(val); + eargp->exception_given = 1; + } else { return ST_STOP; } @@ -2592,23 +2599,16 @@ rb_execarg_get(VALUE execarg_obj) } static VALUE -rb_execarg_init(int argc, const VALUE *orig_argv, int accept_shell, VALUE execarg_obj, int allow_exc_opt) +rb_execarg_init(int argc, const VALUE *orig_argv, int accept_shell, VALUE execarg_obj) { struct rb_execarg *eargp = rb_execarg_get(execarg_obj); - VALUE prog, ret, exception = Qnil; + VALUE prog, ret; VALUE env = Qnil, opthash = Qnil; VALUE argv_buf; VALUE *argv = ALLOCV_N(VALUE, argv_buf, argc); MEMCPY(argv, orig_argv, VALUE, argc); prog = rb_exec_getargs(&argc, &argv, accept_shell, &env, &opthash); - if (allow_exc_opt && !NIL_P(opthash) && rb_hash_has_key(opthash, ID2SYM(id_exception))) { - opthash = rb_hash_dup(opthash); - exception = rb_hash_delete(opthash, ID2SYM(id_exception)); - } rb_exec_fillarg(prog, argc, argv, env, opthash, execarg_obj); - if (RTEST(exception)) { - eargp->exception = 1; - } ALLOCV_END(argv_buf); ret = eargp->use_shell ? eargp->invoke.sh.shell_script : eargp->invoke.cmd.command_name; RB_GC_GUARD(execarg_obj); @@ -2621,7 +2621,10 @@ rb_execarg_new(int argc, const VALUE *argv, int accept_shell, int allow_exc_opt) VALUE execarg_obj; struct rb_execarg *eargp; execarg_obj = TypedData_Make_Struct(0, struct rb_execarg, &exec_arg_data_type, eargp); - rb_execarg_init(argc, argv, accept_shell, execarg_obj, allow_exc_opt); + rb_execarg_init(argc, argv, accept_shell, execarg_obj); + if (!allow_exc_opt && eargp->exception_given) { + rb_raise(rb_eArgError, "exception option is not allowed"); + } return execarg_obj; } From d8e23a67c3869c70ef82b4337499367632ce911a Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 16 Jul 2019 19:27:22 +0900 Subject: [PATCH 243/452] nil as the default of optional parameters --- process.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/process.c b/process.c index 2bc11103f9cd46..9fb40aaacb5323 100644 --- a/process.c +++ b/process.c @@ -2039,7 +2039,7 @@ rb_execarg_addopt(VALUE execarg_obj, VALUE key, VALUE val) rb_raise(rb_eArgError, "new_pgroup option specified twice"); } eargp->new_pgroup_given = 1; - eargp->new_pgroup_flag = RTEST(val) ? 1 : 0; + eargp->new_pgroup_flag = rb_bool_expected(val, "new_pgroup"); } else #endif @@ -2048,7 +2048,7 @@ rb_execarg_addopt(VALUE execarg_obj, VALUE key, VALUE val) rb_raise(rb_eArgError, "unsetenv_others option specified twice"); } eargp->unsetenv_others_given = 1; - eargp->unsetenv_others_do = RTEST(val) ? 1 : 0; + eargp->unsetenv_others_do = rb_bool_expected(val, "unsetenv_others"); } else if (id == id_chdir) { if (eargp->chdir_given) { @@ -2072,7 +2072,7 @@ rb_execarg_addopt(VALUE execarg_obj, VALUE key, VALUE val) rb_raise(rb_eArgError, "close_others option specified twice"); } eargp->close_others_given = 1; - eargp->close_others_do = RTEST(val) ? 1 : 0; + eargp->close_others_do = rb_bool_expected(val, "close_others"); } else if (id == id_in) { key = INT2FIX(0); @@ -2120,8 +2120,8 @@ rb_execarg_addopt(VALUE execarg_obj, VALUE key, VALUE val) if (eargp->exception_given) { rb_raise(rb_eArgError, "exception option specified twice"); } - eargp->exception = RTEST(val); eargp->exception_given = 1; + eargp->exception = rb_bool_expected(val, "exception"); } else { return ST_STOP; @@ -6483,8 +6483,11 @@ proc_daemon(int argc, VALUE *argv) int n, nochdir = FALSE, noclose = FALSE; switch (rb_check_arity(argc, 0, 2)) { - case 2: noclose = RTEST(argv[1]); - case 1: nochdir = RTEST(argv[0]); + case 2: + if (!NIL_P(argv[1])) noclose = rb_bool_expected(argv[1], "noclose"); + /* fallthrough */ + case 1: + if (!NIL_P(argv[0])) nochdir = rb_bool_expected(argv[0], "nochdir"); } prefork(); From d45d448d71bfe9db4a71e06289e7b4d640bbd55c Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 16 Jul 2019 21:38:25 +0900 Subject: [PATCH 244/452] nil as the default of optional parameters --- process.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/process.c b/process.c index 9fb40aaacb5323..f1cd802f95cba0 100644 --- a/process.c +++ b/process.c @@ -1992,6 +1992,7 @@ rb_execarg_addopt_rlimit(struct rb_execarg *eargp, int rtype, VALUE val) } #endif +#define TO_BOOL(val, name) NIL_P(val) ? 0 : rb_bool_expected((val), name) int rb_execarg_addopt(VALUE execarg_obj, VALUE key, VALUE val) { @@ -2039,7 +2040,7 @@ rb_execarg_addopt(VALUE execarg_obj, VALUE key, VALUE val) rb_raise(rb_eArgError, "new_pgroup option specified twice"); } eargp->new_pgroup_given = 1; - eargp->new_pgroup_flag = rb_bool_expected(val, "new_pgroup"); + eargp->new_pgroup_flag = TO_BOOL(val, "new_pgroup"); } else #endif @@ -2048,7 +2049,7 @@ rb_execarg_addopt(VALUE execarg_obj, VALUE key, VALUE val) rb_raise(rb_eArgError, "unsetenv_others option specified twice"); } eargp->unsetenv_others_given = 1; - eargp->unsetenv_others_do = rb_bool_expected(val, "unsetenv_others"); + eargp->unsetenv_others_do = TO_BOOL(val, "unsetenv_others"); } else if (id == id_chdir) { if (eargp->chdir_given) { @@ -2072,7 +2073,7 @@ rb_execarg_addopt(VALUE execarg_obj, VALUE key, VALUE val) rb_raise(rb_eArgError, "close_others option specified twice"); } eargp->close_others_given = 1; - eargp->close_others_do = rb_bool_expected(val, "close_others"); + eargp->close_others_do = TO_BOOL(val, "close_others"); } else if (id == id_in) { key = INT2FIX(0); @@ -2121,7 +2122,7 @@ rb_execarg_addopt(VALUE execarg_obj, VALUE key, VALUE val) rb_raise(rb_eArgError, "exception option specified twice"); } eargp->exception_given = 1; - eargp->exception = rb_bool_expected(val, "exception"); + eargp->exception = TO_BOOL(val, "exception"); } else { return ST_STOP; @@ -6483,11 +6484,8 @@ proc_daemon(int argc, VALUE *argv) int n, nochdir = FALSE, noclose = FALSE; switch (rb_check_arity(argc, 0, 2)) { - case 2: - if (!NIL_P(argv[1])) noclose = rb_bool_expected(argv[1], "noclose"); - /* fallthrough */ - case 1: - if (!NIL_P(argv[0])) nochdir = rb_bool_expected(argv[0], "nochdir"); + case 2: noclose = TO_BOOL(argv[1], "noclose"); + case 1: nochdir = TO_BOOL(argv[0], "nochdir"); } prefork(); From 6ab95fb741168895f9aebe8d6c45e5242cc81f2b Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 16 Jul 2019 22:00:54 +0900 Subject: [PATCH 245/452] Removed twisted tests Why does only Process.daemon have these tests? --- spec/ruby/core/process/daemon_spec.rb | 8 -------- 1 file changed, 8 deletions(-) diff --git a/spec/ruby/core/process/daemon_spec.rb b/spec/ruby/core/process/daemon_spec.rb index 9567382d3d021b..b472a3b9e98465 100644 --- a/spec/ruby/core/process/daemon_spec.rb +++ b/spec/ruby/core/process/daemon_spec.rb @@ -86,10 +86,6 @@ @daemon.invoke("stay_in_dir", [true]).should == @invoke_dir end - it "does not change to the root directory if the first argument is non-false" do - @daemon.invoke("stay_in_dir", [:yes]).should == @invoke_dir - end - describe "when the second argument is not given" do it_behaves_like :process_daemon_keep_stdio_open_false, nil, [false] end @@ -105,10 +101,6 @@ describe "when the second argument is true" do it_behaves_like :process_daemon_keep_stdio_open_true, nil, [false, true] end - - describe "when the second argument is non-false" do - it_behaves_like :process_daemon_keep_stdio_open_true, nil, [false, :yes] - end end end From ed2f2b4f98800540024b9c4a5ebde98674889013 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 16 Jul 2019 22:39:39 +0900 Subject: [PATCH 246/452] Named the backward compatible dump size --- time.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/time.c b/time.c index fe1ef787560ba0..f7808c767434f9 100644 --- a/time.c +++ b/time.c @@ -5008,13 +5008,15 @@ time_strftime(VALUE time, VALUE format) int ruby_marshal_write_long(long x, char *buf); +enum {base_dump_size = 8}; + /* :nodoc: */ static VALUE time_mdump(VALUE time) { struct time_object *tobj; unsigned long p, s; - char buf[8]; + char buf[base_dump_size]; int i; VALUE str; @@ -5090,7 +5092,7 @@ time_mdump(VALUE time) * binary (like as Fixnum and Bignum). */ size_t ysize = rb_absint_size(year_extend, NULL); - char *p, buf_year_extend[9]; + char *p, buf_year_extend[sizeof(long)+1]; if (ysize > LONG_MAX || (i = ruby_marshal_write_long((long)ysize, buf_year_extend)) < 0) { rb_raise(rb_eArgError, "year too %s to marshal: %"PRIsVALUE" UTC", @@ -5217,7 +5219,7 @@ time_mload(VALUE time, VALUE str) StringValue(str); buf = (unsigned char *)RSTRING_PTR(str); - if (RSTRING_LEN(str) < 8) { + if (RSTRING_LEN(str) < base_dump_size) { invalid_format: rb_raise(rb_eTypeError, "marshaled time format differ"); } @@ -5245,11 +5247,11 @@ time_mload(VALUE time, VALUE str) if (NIL_P(year)) { year = INT2FIX(((int)(p >> 14) & 0xffff) + 1900); } - if (RSTRING_LEN(str) > 8) { - long len = RSTRING_LEN(str) - 8; + if (RSTRING_LEN(str) > base_dump_size) { + long len = RSTRING_LEN(str) - base_dump_size; long ysize = 0; VALUE year_extend; - const char *ybuf = (const char *)(buf += 8); + const char *ybuf = (const char *)(buf += base_dump_size); ysize = ruby_marshal_read_long(&ybuf, len); len -= ybuf - (const char *)buf; if (ysize < 0 || ysize > len) goto invalid_format; From f487e5b7a4b13d23a8bb7807e4f5cc3f9b2a30e3 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 16 Jul 2019 21:47:32 +0900 Subject: [PATCH 247/452] Expanded buf to copy at once Build dumped string from base packed data and extended year at once. Although currently ruby_marshal_write_long() never writes more than 5 bytes per its format specification, allocate `sizeof(long)+1` for the sanitation. --- time.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/time.c b/time.c index f7808c767434f9..18f1b246f04167 100644 --- a/time.c +++ b/time.c @@ -5016,7 +5016,7 @@ time_mdump(VALUE time) { struct time_object *tobj; unsigned long p, s; - char buf[base_dump_size]; + char buf[base_dump_size + sizeof(long) + 1]; int i; VALUE str; @@ -5083,7 +5083,6 @@ time_mdump(VALUE time) s = RSHIFT(s, 8); } - str = rb_str_new(buf, 8); if (!NIL_P(year_extend)) { /* * Append extended year distance from 1900..(1900+0xffff). In @@ -5092,18 +5091,22 @@ time_mdump(VALUE time) * binary (like as Fixnum and Bignum). */ size_t ysize = rb_absint_size(year_extend, NULL); - char *p, buf_year_extend[sizeof(long)+1]; + char *p, *const buf_year_extend = buf + base_dump_size; if (ysize > LONG_MAX || (i = ruby_marshal_write_long((long)ysize, buf_year_extend)) < 0) { rb_raise(rb_eArgError, "year too %s to marshal: %"PRIsVALUE" UTC", (year == 1900 ? "small" : "big"), vtm.year); } - rb_str_resize(str, sizeof(buf) + i + ysize); - p = RSTRING_PTR(str) + sizeof(buf); - memcpy(p, buf_year_extend, i); + i += base_dump_size; + str = rb_str_new(NULL, i + ysize); + p = RSTRING_PTR(str); + memcpy(p, buf, i); p += i; rb_integer_pack(year_extend, p, ysize, 1, 0, INTEGER_PACK_LITTLE_ENDIAN); } + else { + str = rb_str_new(buf, base_dump_size); + } rb_copy_generic_ivar(str, time); if (!rb_equal(nano, INT2FIX(0))) { if (RB_TYPE_P(nano, T_RATIONAL)) { From 0965bb6091a70d5237a8afd88d414b2d7fc9f5a8 Mon Sep 17 00:00:00 2001 From: git Date: Wed, 17 Jul 2019 10:53:00 +0900 Subject: [PATCH 248/452] * 2019-07-17 --- version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.h b/version.h index 1580536943372e..6b295e9b840168 100644 --- a/version.h +++ b/version.h @@ -6,7 +6,7 @@ #define RUBY_RELEASE_YEAR 2019 #define RUBY_RELEASE_MONTH 7 -#define RUBY_RELEASE_DAY 16 +#define RUBY_RELEASE_DAY 17 #include "ruby/version.h" From af07e07ac9331ec9c2f16b2329a0471ea663dd95 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 17 Jul 2019 11:56:40 +0900 Subject: [PATCH 249/452] Separate pull-github from merge-github [ci skip] --- defs/gmake.mk | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/defs/gmake.mk b/defs/gmake.mk index 0824cabc8d91de..4a16552a1f3b6c 100644 --- a/defs/gmake.mk +++ b/defs/gmake.mk @@ -185,36 +185,54 @@ endef checkout-github: fetch-github git -C "$(srcdir)" checkout "gh-$(PR)" +.PHONY: pull-github +pull-github: fetch-github + $(call pull-github,$(PR)) + .PHONY: merge-github -merge-github: fetch-github +merge-github: pull-github $(call merge-github,$(PR)) -define merge-github +define pull-github $(eval GITHUB_MERGE_BASE := $(shell git -C "$(srcdir)" log -1 --format=format:%H)) $(eval GITHUB_MERGE_BRANCH := $(shell git -C "$(srcdir)" symbolic-ref --short HEAD)) $(eval GITHUB_MERGE_WORKTREE := $(shell mktemp -d "$(srcdir)/gh-$(1)-XXXXXX")) git -C "$(srcdir)" worktree add $(notdir $(GITHUB_MERGE_WORKTREE)) "gh-$(1)" git -C "$(GITHUB_MERGE_WORKTREE)" rebase $(GITHUB_MERGE_BRANCH) - git -C "$(srcdir)" worktree remove $(notdir $(GITHUB_MERGE_WORKTREE)) - git -C "$(srcdir)" merge --ff-only "gh-$(1)" - git -C "$(srcdir)" branch -D "gh-$(1)" - git -C "$(srcdir)" filter-branch -f \ + git -C "$(GITHUB_MERGE_WORKTREE)" filter-branch -f \ --msg-filter 'cat && echo && echo "Closes: $(GITHUB_RUBY_URL)/pull/$(1)"' \ -- "$(GITHUB_MERGE_BASE)..@" $(eval COMMIT_GPG_SIGN := $(COMMIT_GPG_SIGN)) $(if $(filter true,$(COMMIT_GPG_SIGN)), \ - git -C "$(srcdir)" rebase --exec "git commit --amend --no-edit -S" "$(GITHUB_MERGE_BASE)"; \ + git -C "$(GITHUB_MERGE_WORKTREE)" rebase --exec "git commit --amend --no-edit -S" "$(GITHUB_MERGE_BASE)"; \ ) endef +define merge-github + git -C "$(srcdir)" worktree remove $(notdir $(GITHUB_MERGE_WORKTREE)) + git -C "$(srcdir)" merge --ff-only "gh-$(1)" + git -C "$(srcdir)" branch -D "gh-$(1)" +endef + +.PHONY: fetch-github-% fetch-github-%: $(call fetch-github,$*) -pr-% merge-github-%: fetch-github-% +.PHONY: checkout-github-% +checkout-github-%: fetch-github-% + git -C "$(srcdir)" checkout "gh-$(1)" + +.PHONY: pr-% pull-github-% +pr-% pull-github-%: fetch-github-% + $(call pull-github,$*) + +.PHONY: merge-github-% +merge-github-%: pull-github-% $(call merge-github,$*) HELP_EXTRA_TASKS = \ " checkout-github: checkout GitHub Pull Request [PR=1234]" \ + " pull-github: rebase GitHub Pull Request to new worktree [PR=1234]" \ " merge-github: merge GitHub Pull Request to current HEAD [PR=1234]" \ "" From cd372f8db2e050241abf1d7360b7b29ac614ceec Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 17 Jul 2019 14:45:33 +0900 Subject: [PATCH 250/452] Get rid of LoadError with $DEBUG --- lib/resolv.rb | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/resolv.rb b/lib/resolv.rb index 099c7406f3a935..568c879d316548 100644 --- a/lib/resolv.rb +++ b/lib/resolv.rb @@ -166,13 +166,14 @@ class ResolvTimeout < Timeout::Error; end # Resolv::Hosts is a hostname resolver that uses the system hosts file. class Hosts - begin - raise LoadError unless /mswin|mingw|cygwin/ =~ RUBY_PLATFORM - require 'win32/resolv' - DefaultFileName = Win32::Resolv.get_hosts_path || IO::NULL - rescue LoadError - DefaultFileName = '/etc/hosts' + if /mswin|mingw|cygwin/ =~ RUBY_PLATFORM and + begin + require 'win32/resolv' + DefaultFileName = Win32::Resolv.get_hosts_path || IO::NULL + rescue LoadError + end end + DefaultFileName ||= '/etc/hosts' ## # Creates a new Resolv::Hosts, using +filename+ for its data source. From 0e23e0c3a0c1053c230205117b82cc8156f3a26a Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 17 Jul 2019 15:55:50 +0900 Subject: [PATCH 251/452] Adjust indent [ci skip] --- parse.y | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/parse.y b/parse.y index 6389730d997955..a950208e521de7 100644 --- a/parse.y +++ b/parse.y @@ -747,7 +747,8 @@ new_array_pattern_tail(struct parser_params *p, VALUE pre_args, VALUE has_rest, NODE *t; if (has_rest) { rest_arg = dispatch1(var_field, rest_arg ? rest_arg : Qnil); - } else { + } + else { rest_arg = Qnil; } t = rb_node_newnode(NODE_ARYPTN, pre_args, rest_arg, post_args, &NULL_LOC); @@ -4040,7 +4041,7 @@ p_kwrest : kwrest_mark tIDENTIFIER } ; -p_value : p_primitive +p_value : p_primitive | p_primitive tDOT2 p_primitive { /*%%%*/ @@ -4162,7 +4163,7 @@ p_var_ref : '^' tIDENTIFIER } ; -p_const : tCOLON3 cname +p_const : tCOLON3 cname { /*%%%*/ $$ = NEW_COLON3($2, &@$); @@ -11234,7 +11235,8 @@ new_array_pattern(struct parser_params *p, NODE *constant, NODE *pre_arg, NODE * NODE *pre_args = NEW_LIST(pre_arg, loc); if (apinfo->pre_args) { apinfo->pre_args = list_concat(pre_args, apinfo->pre_args); - } else { + } + else { apinfo->pre_args = pre_args; } } @@ -11258,10 +11260,12 @@ new_array_pattern_tail(struct parser_params *p, NODE *pre_args, int has_rest, ID if (has_rest) { if (rest_arg) { apinfo->rest_arg = assignable(p, rest_arg, 0, loc); - } else { + } + else { apinfo->rest_arg = NODE_SPECIAL_NO_NAME_REST; } - } else { + } + else { apinfo->rest_arg = NULL; } From 416ead4cdaf849fe1f3dcda26d6ba04c80e36746 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Wed, 17 Jul 2019 08:24:25 +0900 Subject: [PATCH 252/452] compile.c: add NO_CHECK for the calls to COMPILE whose result is unused to suppress many warnings of Coverity Scan --- compile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compile.c b/compile.c index 62cfbbff3e0c9f..cf9c70f513fa48 100644 --- a/compile.c +++ b/compile.c @@ -1650,7 +1650,7 @@ iseq_set_arguments(rb_iseq_t *iseq, LINK_ANCHOR *const optargs, const NODE *cons label = NEW_LABEL(nd_line(node)); rb_ary_push(labels, (VALUE)label | 1); ADD_LABEL(optargs, label); - COMPILE_POPPED(optargs, "optarg", node->nd_body); + NO_CHECK(COMPILE_POPPED(optargs, "optarg", node->nd_body)); node = node->nd_next; i += 1; } From bdec1ad9a96700eb00ab953ea6ee2168449827d9 Mon Sep 17 00:00:00 2001 From: git Date: Wed, 17 Jul 2019 23:42:21 +0900 Subject: [PATCH 253/452] * expand tabs. --- compile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compile.c b/compile.c index cf9c70f513fa48..7d71f26208286e 100644 --- a/compile.c +++ b/compile.c @@ -1650,7 +1650,7 @@ iseq_set_arguments(rb_iseq_t *iseq, LINK_ANCHOR *const optargs, const NODE *cons label = NEW_LABEL(nd_line(node)); rb_ary_push(labels, (VALUE)label | 1); ADD_LABEL(optargs, label); - NO_CHECK(COMPILE_POPPED(optargs, "optarg", node->nd_body)); + NO_CHECK(COMPILE_POPPED(optargs, "optarg", node->nd_body)); node = node->nd_next; i += 1; } From 9b28eefeb2cea9690b897aeb3a1e1de2cbc19137 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Thu, 18 Jul 2019 11:13:49 +1200 Subject: [PATCH 254/452] Add benchmark to help diagnose performance regression. See https://bugs.ruby-lang.org/issues/16009 for more details. --- benchmark/vm2_fiber_reuse_gc.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 benchmark/vm2_fiber_reuse_gc.yml diff --git a/benchmark/vm2_fiber_reuse_gc.yml b/benchmark/vm2_fiber_reuse_gc.yml new file mode 100644 index 00000000000000..8fb91a84eb61a7 --- /dev/null +++ b/benchmark/vm2_fiber_reuse_gc.yml @@ -0,0 +1,12 @@ +# https://bugs.ruby-lang.org/issues/16009 +prelude: | + fibers = [] +benchmark: + vm2_fiber_reuse_gc: | + 2000.times do + fiber = Fiber.new{Fiber.yield} + fibers << fiber + fiber.resume + end + fibers.clear +loop_count: 100 From 97808e29cd5691092ad9004078852b3f16592cf2 Mon Sep 17 00:00:00 2001 From: git Date: Thu, 18 Jul 2019 08:15:46 +0900 Subject: [PATCH 255/452] * 2019-07-18 --- version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.h b/version.h index 6b295e9b840168..7ffdef6200fa1f 100644 --- a/version.h +++ b/version.h @@ -6,7 +6,7 @@ #define RUBY_RELEASE_YEAR 2019 #define RUBY_RELEASE_MONTH 7 -#define RUBY_RELEASE_DAY 17 +#define RUBY_RELEASE_DAY 18 #include "ruby/version.h" From 1b82c877dfa72e8505ded149fd0e3ba956529d3f Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Sat, 1 Jun 2019 17:48:25 +1200 Subject: [PATCH 256/452] Make FIBER_USE_NATIVE the default and reformat code. --- cont.c | 770 +++++++++++++++++++-------------------------------------- 1 file changed, 252 insertions(+), 518 deletions(-) diff --git a/cont.c b/cont.c index e25e61fbd65312..5e72c24b96eb6d 100644 --- a/cont.c +++ b/cont.c @@ -15,81 +15,18 @@ #include "eval_intern.h" #include "mjit.h" -/* FIBER_USE_NATIVE enables Fiber performance improvement using system - * dependent method such as make/setcontext on POSIX system or - * CreateFiber() API on Windows. - * This hack make Fiber context switch faster (x2 or more). - * However, it decrease maximum number of Fiber. For example, on the - * 32bit POSIX OS, ten or twenty thousands Fiber can be created. - * - * Details is reported in the paper "A Fast Fiber Implementation for Ruby 1.9" - * in Proc. of 51th Programming Symposium, pp.21--28 (2010) (in Japanese). - */ - -/* - Enable FIBER_USE_COROUTINE to make fiber yield/resume much faster by using native assembly implementations. - - rvm install ruby-head-ioquatix-native-fiber --url https://github.com/ioquatix/ruby --branch native-fiber - - # Without libcoro - koyoko% ./build/bin/ruby ./fiber_benchmark.rb 10000 1000 - setup time for 10000 fibers: 0.099961 - execution time for 1000 messages: 19.505909 - - # With libcoro - koyoko% ./build/bin/ruby ./fiber_benchmark.rb 10000 1000 - setup time for 10000 fibers: 0.099268 - execution time for 1000 messages: 8.491746 -*/ - #ifdef FIBER_USE_COROUTINE #include FIBER_USE_COROUTINE -#define FIBER_USE_NATIVE 1 -#else -#pragma message "Native coroutine not available!" #endif -#if !defined(FIBER_USE_NATIVE) -# if defined(HAVE_GETCONTEXT) && defined(HAVE_SETCONTEXT) -# if 0 -# elif defined(__NetBSD__) -/* On our experience, NetBSD doesn't support using setcontext() and pthread - * simultaneously. This is because pthread_self(), TLS and other information - * are represented by stack pointer (higher bits of stack pointer). - * TODO: check such constraint on configure. - */ -# define FIBER_USE_NATIVE 0 -# elif defined(__sun) -/* On Solaris because resuming any Fiber caused SEGV, for some reason. - */ -# define FIBER_USE_NATIVE 0 -# elif defined(__GNU__) -/* GNU/Hurd doesn't fully support getcontext, setcontext, makecontext - * and swapcontext functions. Disabling their usage till support is - * implemented. More info at - * http://darnassus.sceen.net/~hurd-web/open_issues/glibc/#getcontext - */ -# define FIBER_USE_NATIVE 0 -# else -# define FIBER_USE_NATIVE 1 -# endif -# elif defined(_WIN32) -# define FIBER_USE_NATIVE 1 -# endif -#endif -#if !defined(FIBER_USE_NATIVE) -#define FIBER_USE_NATIVE 0 -#endif - -#if FIBER_USE_NATIVE #ifndef _WIN32 #include #include #endif + #define RB_PAGE_SIZE (pagesize) #define RB_PAGE_MASK (~(RB_PAGE_SIZE - 1)) static long pagesize; -#endif /*FIBER_USE_NATIVE*/ #define CAPTURE_JUST_VALID_VM_STACK 1 @@ -115,9 +52,9 @@ typedef struct rb_context_struct { struct cont_saved_vm_stack saved_vm_stack; struct { - VALUE *stack; - VALUE *stack_src; - size_t stack_size; + VALUE *stack; + VALUE *stack_src; + size_t stack_size; } machine; rb_execution_context_t saved_ec; int free_vm_stack; @@ -153,25 +90,6 @@ enum fiber_status { #define FIBER_TERMINATED_P(fiber) ((fiber)->status == FIBER_TERMINATED) #define FIBER_RUNNABLE_P(fiber) (FIBER_CREATED_P(fiber) || FIBER_SUSPENDED_P(fiber)) -#if FIBER_USE_NATIVE && !defined(FIBER_USE_COROUTINE) && !defined(_WIN32) -static inline int -fiber_context_create(ucontext_t *context, void (*func)(), void *arg, void *ptr, size_t size) -{ - if (getcontext(context) < 0) return -1; - /* - * getcontext() may fail by some reasons: - * 1. SELinux policy banned one of "rt_sigprocmask", - * "sigprocmask" or "swapcontext"; - * 2. libseccomp (aka. syscall filter) banned one of them. - */ - context->uc_link = NULL; - context->uc_stack.ss_sp = ptr; - context->uc_stack.ss_size = size; - makecontext(context, func, 0); - return 0; -} -#endif - struct rb_fiber_struct { rb_context_t cont; VALUE first_proc; @@ -183,28 +101,11 @@ struct rb_fiber_struct { */ unsigned int transferred : 1; -#if FIBER_USE_NATIVE -#if defined(FIBER_USE_COROUTINE) -#define FIBER_ALLOCATE_STACK struct coroutine_context context; void *ss_sp; size_t ss_size; -#elif defined(_WIN32) - void *fiber_handle; -#else -#define FIBER_ALLOCATE_STACK - ucontext_t context; - /* Because context.uc_stack.ss_sp and context.uc_stack.ss_size - * are not necessarily valid after makecontext() or swapcontext(), - * they are saved in these variables for later use. - */ - void *ss_sp; - size_t ss_size; -#endif -#endif }; -#ifdef FIBER_ALLOCATE_STACK #define MAX_MACHINE_STACK_CACHE 10 static int machine_stack_cache_index = 0; typedef struct machine_stack_cache_struct { @@ -213,7 +114,6 @@ typedef struct machine_stack_cache_struct { } machine_stack_cache_t; static machine_stack_cache_t machine_stack_cache[MAX_MACHINE_STACK_CACHE]; static machine_stack_cache_t terminated_machine_stack; -#endif static const char * fiber_status_name(enum fiber_status s) @@ -237,16 +137,16 @@ fiber_verify(const rb_fiber_t *fiber) switch (fiber->status) { case FIBER_RESUMED: VM_ASSERT(fiber->cont.saved_ec.vm_stack != NULL); - break; + break; case FIBER_SUSPENDED: VM_ASSERT(fiber->cont.saved_ec.vm_stack != NULL); - break; + break; case FIBER_CREATED: case FIBER_TERMINATED: - /* TODO */ - break; + /* TODO */ + break; default: - VM_UNREACHABLE(fiber_verify); + VM_UNREACHABLE(fiber_verify); } #endif } @@ -316,7 +216,7 @@ fiber_ptr(VALUE obj) NOINLINE(static VALUE cont_capture(volatile int *volatile stat)); #define THREAD_MUST_BE_RUNNING(th) do { \ - if (!(th)->ec->tag) rb_raise(rb_eThreadError, "not running thread"); \ + if (!(th)->ec->tag) rb_raise(rb_eThreadError, "not running thread"); \ } while (0) static VALUE @@ -347,29 +247,29 @@ cont_mark(void *ptr) if (cont->saved_vm_stack.ptr) { #ifdef CAPTURE_JUST_VALID_VM_STACK - rb_gc_mark_locations(cont->saved_vm_stack.ptr, - cont->saved_vm_stack.ptr + cont->saved_vm_stack.slen + cont->saved_vm_stack.clen); + rb_gc_mark_locations(cont->saved_vm_stack.ptr, + cont->saved_vm_stack.ptr + cont->saved_vm_stack.slen + cont->saved_vm_stack.clen); #else - rb_gc_mark_locations(cont->saved_vm_stack.ptr, - cont->saved_vm_stack.ptr, cont->saved_ec.stack_size); + rb_gc_mark_locations(cont->saved_vm_stack.ptr, + cont->saved_vm_stack.ptr, cont->saved_ec.stack_size); #endif } if (cont->machine.stack) { - if (cont->type == CONTINUATION_CONTEXT) { - /* cont */ - rb_gc_mark_locations(cont->machine.stack, - cont->machine.stack + cont->machine.stack_size); - } - else { - /* fiber */ + if (cont->type == CONTINUATION_CONTEXT) { + /* cont */ + rb_gc_mark_locations(cont->machine.stack, + cont->machine.stack + cont->machine.stack_size); + } + else { + /* fiber */ const rb_fiber_t *fiber = (rb_fiber_t*)cont; if (!FIBER_TERMINATED_P(fiber)) { - 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); + } + } } RUBY_MARK_LEAVE("cont"); @@ -392,16 +292,11 @@ cont_free(void *ptr) ruby_xfree(cont->saved_ec.vm_stack); } -#if FIBER_USE_NATIVE if (cont->type == CONTINUATION_CONTEXT) { - /* cont */ - ruby_xfree(cont->ensure_array); - RUBY_FREE_UNLESS_NULL(cont->machine.stack); - } - else { - /* fiber */ + ruby_xfree(cont->ensure_array); + RUBY_FREE_UNLESS_NULL(cont->machine.stack); + } else { rb_fiber_t *fiber = (rb_fiber_t*)cont; -#if defined(FIBER_USE_COROUTINE) coroutine_destroy(&fiber->context); if (fiber->ss_sp != NULL) { if (fiber_is_root_p(fiber)) { @@ -413,25 +308,9 @@ cont_free(void *ptr) munmap((void*)fiber->ss_sp, fiber->ss_size); #endif fiber->ss_sp = NULL; - } -#elif defined(_WIN32) - if (!fiber_is_root_p(fiber)) { - /* don't delete root fiber handle */ - if (fiber->fiber_handle) { - DeleteFiber(fiber->fiber_handle); - } - } -#else /* not WIN32 */ - /* fiber->ss_sp == NULL is possible for root fiber */ - if (fiber->ss_sp != NULL) { - munmap((void*)fiber->ss_sp, fiber->ss_size); - } -#endif + } } -#else /* not FIBER_USE_NATIVE */ - ruby_xfree(cont->ensure_array); - RUBY_FREE_UNLESS_NULL(cont->machine.stack); -#endif + RUBY_FREE_UNLESS_NULL(cont->saved_vm_stack.ptr); if (mjit_enabled && cont->mjit_cont != NULL) { @@ -451,15 +330,15 @@ cont_memsize(const void *ptr) size = sizeof(*cont); if (cont->saved_vm_stack.ptr) { #ifdef CAPTURE_JUST_VALID_VM_STACK - size_t n = (cont->saved_vm_stack.slen + cont->saved_vm_stack.clen); + size_t n = (cont->saved_vm_stack.slen + cont->saved_vm_stack.clen); #else - size_t n = cont->saved_ec.vm_stack_size; + size_t n = cont->saved_ec.vm_stack_size; #endif - size += n * sizeof(*cont->saved_vm_stack.ptr); + size += n * sizeof(*cont->saved_vm_stack.ptr); } if (cont->machine.stack) { - size += cont->machine.stack_size * sizeof(*cont->machine.stack); + size += cont->machine.stack_size * sizeof(*cont->machine.stack); } return size; @@ -507,16 +386,6 @@ fiber_mark(void *ptr) fiber_verify(fiber); rb_gc_mark_no_pin(fiber->first_proc); if (fiber->prev) rb_fiber_mark_self(fiber->prev); - -#if !FIBER_USE_NATIVE - if (fiber->status == FIBER_TERMINATED) { - /* FIBER_TERMINATED fiber should not mark machine stack */ - if (fiber->cont.saved_ec.machine.stack_end != NULL) { - fiber->cont.saved_ec.machine.stack_end = NULL; - } - } -#endif - cont_mark(&fiber->cont); RUBY_MARK_LEAVE("cont"); } @@ -547,7 +416,7 @@ fiber_memsize(const void *ptr) * vm.c::thread_memsize already counts th->ec->local_storage */ if (saved_ec->local_storage && fiber != th->root_fiber) { - size += st_memsize(saved_ec->local_storage); + size += st_memsize(saved_ec->local_storage); } size += cont_memsize(&fiber->cont); return size; @@ -557,10 +426,10 @@ VALUE rb_obj_is_fiber(VALUE obj) { if (rb_typeddata_is_kind_of(obj, &fiber_data_type)) { - return Qtrue; + return Qtrue; } else { - return Qfalse; + return Qfalse; } } @@ -572,19 +441,19 @@ cont_save_machine_stack(rb_thread_t *th, rb_context_t *cont) SET_MACHINE_STACK_END(&th->ec->machine.stack_end); if (th->ec->machine.stack_start > th->ec->machine.stack_end) { - size = cont->machine.stack_size = th->ec->machine.stack_start - th->ec->machine.stack_end; - cont->machine.stack_src = th->ec->machine.stack_end; + size = cont->machine.stack_size = th->ec->machine.stack_start - th->ec->machine.stack_end; + cont->machine.stack_src = th->ec->machine.stack_end; } else { - size = cont->machine.stack_size = th->ec->machine.stack_end - th->ec->machine.stack_start; - cont->machine.stack_src = th->ec->machine.stack_start; + size = cont->machine.stack_size = th->ec->machine.stack_end - th->ec->machine.stack_start; + cont->machine.stack_src = th->ec->machine.stack_start; } if (cont->machine.stack) { - REALLOC_N(cont->machine.stack, VALUE, size); + 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; @@ -646,24 +515,24 @@ show_vm_stack(const rb_execution_context_t *ec) { VALUE *p = ec->vm_stack; while (p < ec->cfp->sp) { - fprintf(stderr, "%3d ", (int)(p - ec->vm_stack)); - rb_obj_info_dump(*p); - p++; + fprintf(stderr, "%3d ", (int)(p - ec->vm_stack)); + rb_obj_info_dump(*p); + p++; } } void show_vm_pcs(const rb_control_frame_t *cfp, - const rb_control_frame_t *end_of_cfp) + const rb_control_frame_t *end_of_cfp) { int i=0; while (cfp != end_of_cfp) { - int pc = 0; - if (cfp->iseq) { - pc = cfp->pc - cfp->iseq->body->iseq_encoded; - } - fprintf(stderr, "%2d pc: %d\n", i++, pc); - cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp); + int pc = 0; + if (cfp->iseq) { + pc = cfp->pc - cfp->iseq->body->iseq_encoded; + } + fprintf(stderr, "%2d pc: %d\n", i++, pc); + cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp); } } #endif @@ -689,12 +558,12 @@ cont_capture(volatile int *volatile stat) cont->saved_vm_stack.clen = ec->vm_stack + ec->vm_stack_size - (VALUE*)ec->cfp; cont->saved_vm_stack.ptr = ALLOC_N(VALUE, cont->saved_vm_stack.slen + cont->saved_vm_stack.clen); MEMCPY(cont->saved_vm_stack.ptr, - ec->vm_stack, - VALUE, cont->saved_vm_stack.slen); + ec->vm_stack, + VALUE, cont->saved_vm_stack.slen); MEMCPY(cont->saved_vm_stack.ptr + cont->saved_vm_stack.slen, - (VALUE*)ec->cfp, - VALUE, - cont->saved_vm_stack.clen); + (VALUE*)ec->cfp, + VALUE, + cont->saved_vm_stack.clen); #else cont->saved_vm_stack.ptr = ALLOC_N(VALUE, ec->vm_stack_size); MEMCPY(cont->saved_vm_stack.ptr, ec->vm_stack, VALUE, ec->vm_stack_size); @@ -704,33 +573,33 @@ cont_capture(volatile int *volatile stat) /* backup ensure_list to array for search in another context */ { - rb_ensure_list_t *p; - int size = 0; - rb_ensure_entry_t *entry; - for (p=th->ec->ensure_list; p; p=p->next) - size++; - entry = cont->ensure_array = ALLOC_N(rb_ensure_entry_t,size+1); - for (p=th->ec->ensure_list; p; p=p->next) { - if (!p->entry.marker) - p->entry.marker = rb_ary_tmp_new(0); /* dummy object */ - *entry++ = p->entry; - } - entry->marker = 0; + rb_ensure_list_t *p; + int size = 0; + rb_ensure_entry_t *entry; + for (p=th->ec->ensure_list; p; p=p->next) + size++; + entry = cont->ensure_array = ALLOC_N(rb_ensure_entry_t,size+1); + for (p=th->ec->ensure_list; p; p=p->next) { + if (!p->entry.marker) + p->entry.marker = rb_ary_tmp_new(0); /* dummy object */ + *entry++ = p->entry; + } + entry->marker = 0; } if (ruby_setjmp(cont->jmpbuf)) { - VALUE value; + VALUE value; - VAR_INITIALIZED(cont); - value = cont->value; - if (cont->argc == -1) rb_exc_raise(value); - cont->value = Qnil; - *stat = 1; - return value; + VAR_INITIALIZED(cont); + value = cont->value; + if (cont->argc == -1) rb_exc_raise(value); + cont->value = Qnil; + *stat = 1; + return value; } else { - *stat = 0; - return contval; + *stat = 0; + return contval; } } COMPILER_WARNING_POP @@ -749,91 +618,61 @@ cont_restore_thread(rb_context_t *cont) /* restore thread context */ if (cont->type == CONTINUATION_CONTEXT) { - /* continuation */ - rb_execution_context_t *sec = &cont->saved_ec; + /* continuation */ + rb_execution_context_t *sec = &cont->saved_ec; rb_fiber_t *fiber = NULL; - if (sec->fiber_ptr != NULL) { + if (sec->fiber_ptr != NULL) { fiber = sec->fiber_ptr; - } - else if (th->root_fiber) { + } + else if (th->root_fiber) { fiber = th->root_fiber; - } + } if (fiber && th->ec != &fiber->cont.saved_ec) { ec_switch(th, fiber); - } + } if (th->ec->trace_arg != sec->trace_arg) { rb_raise(rb_eRuntimeError, "can't call across trace_func"); } - /* copy vm stack */ + /* copy vm stack */ #ifdef CAPTURE_JUST_VALID_VM_STACK - MEMCPY(th->ec->vm_stack, - cont->saved_vm_stack.ptr, - VALUE, cont->saved_vm_stack.slen); - MEMCPY(th->ec->vm_stack + th->ec->vm_stack_size - cont->saved_vm_stack.clen, - cont->saved_vm_stack.ptr + cont->saved_vm_stack.slen, - VALUE, cont->saved_vm_stack.clen); + MEMCPY(th->ec->vm_stack, + cont->saved_vm_stack.ptr, + VALUE, cont->saved_vm_stack.slen); + MEMCPY(th->ec->vm_stack + th->ec->vm_stack_size - cont->saved_vm_stack.clen, + cont->saved_vm_stack.ptr + cont->saved_vm_stack.slen, + VALUE, cont->saved_vm_stack.clen); #else - MEMCPY(th->ec->vm_stack, cont->saved_vm_stack.ptr, VALUE, sec->vm_stack_size); + MEMCPY(th->ec->vm_stack, cont->saved_vm_stack.ptr, VALUE, sec->vm_stack_size); #endif - /* other members of ec */ + /* other members of ec */ - th->ec->cfp = sec->cfp; - th->ec->raised_flag = sec->raised_flag; - th->ec->tag = sec->tag; - th->ec->protect_tag = sec->protect_tag; - th->ec->root_lep = sec->root_lep; - th->ec->root_svar = sec->root_svar; - th->ec->ensure_list = sec->ensure_list; - th->ec->errinfo = sec->errinfo; + th->ec->cfp = sec->cfp; + th->ec->raised_flag = sec->raised_flag; + th->ec->tag = sec->tag; + th->ec->protect_tag = sec->protect_tag; + th->ec->root_lep = sec->root_lep; + th->ec->root_svar = sec->root_svar; + th->ec->ensure_list = sec->ensure_list; + th->ec->errinfo = sec->errinfo; - VM_ASSERT(th->ec->vm_stack != NULL); + VM_ASSERT(th->ec->vm_stack != NULL); } else { - /* fiber */ - fiber_restore_thread(th, (rb_fiber_t*)cont); + /* fiber */ + fiber_restore_thread(th, (rb_fiber_t*)cont); } } -#if FIBER_USE_NATIVE -#if defined(FIBER_USE_COROUTINE) static COROUTINE fiber_entry(struct coroutine_context * from, struct coroutine_context * to) { rb_fiber_start(); } -#elif defined(_WIN32) -static void -fiber_set_stack_location(void) -{ - rb_thread_t *th = GET_THREAD(); - VALUE *ptr; - - SET_MACHINE_STACK_END(&ptr); - th->ec->machine.stack_start = (void*)(((VALUE)ptr & RB_PAGE_MASK) + STACK_UPPER((void *)&ptr, 0, RB_PAGE_SIZE)); -} - -NORETURN(static VOID CALLBACK fiber_entry(void *arg)); -static VOID CALLBACK -fiber_entry(void *arg) -{ - fiber_set_stack_location(); - rb_fiber_start(); -} -#else -NORETURN(static void fiber_entry(void *arg)); -static void -fiber_entry(void *arg) -{ - rb_fiber_start(); -} -#endif -#endif -#ifdef FIBER_ALLOCATE_STACK /* * FreeBSD require a first (i.e. addr) argument of mmap(2) is not NULL * if MAP_STACK is passed. @@ -898,15 +737,12 @@ fiber_machine_stack_alloc(size_t size) return ptr; } -#endif -#if FIBER_USE_NATIVE static void fiber_initialize_machine_stack_context(rb_fiber_t *fiber, size_t size) { rb_execution_context_t *sec = &fiber->cont.saved_ec; -#if defined(FIBER_USE_COROUTINE) char *ptr; STACK_GROW_DIR_DETECTION; @@ -916,34 +752,6 @@ fiber_initialize_machine_stack_context(rb_fiber_t *fiber, size_t size) coroutine_initialize(&fiber->context, fiber_entry, ptr, size); sec->machine.stack_start = (VALUE*)(ptr + STACK_DIR_UPPER(0, size)); sec->machine.stack_maxsize = size - RB_PAGE_SIZE; -#elif defined(_WIN32) -# if defined(_MSC_VER) && _MSC_VER <= 1200 -# define CreateFiberEx(cs, stacksize, flags, entry, param) \ - CreateFiber((stacksize), (entry), (param)) -# endif - fiber->fiber_handle = CreateFiberEx(size - 1, size, 0, fiber_entry, NULL); - if (!fiber->fiber_handle) { - /* try to release unnecessary fibers & retry to create */ - rb_gc(); - fiber->fiber_handle = CreateFiberEx(size - 1, size, 0, fiber_entry, NULL); - if (!fiber->fiber_handle) { - rb_raise(rb_eFiberError, "can't create fiber"); - } - } - sec->machine.stack_maxsize = size; -#else /* not WIN32 */ - char *ptr; - STACK_GROW_DIR_DETECTION; - - ptr = fiber_machine_stack_alloc(size); - fiber->ss_sp = ptr; - fiber->ss_size = size; - if (fiber_context_create(&fiber->context, fiber_entry, NULL, fiber->ss_sp, fiber->ss_size)) { - rb_raise(rb_eFiberError, "can't get context for creating fiber: %s", ERRNOMSG); - } - sec->machine.stack_start = (VALUE*)(ptr + STACK_DIR_UPPER(0, size)); - sec->machine.stack_maxsize = size - RB_PAGE_SIZE; -#endif } NOINLINE(static void fiber_setcontext(rb_fiber_t *new_fiber, rb_fiber_t *old_fiber)); @@ -955,16 +763,16 @@ fiber_setcontext(rb_fiber_t *new_fiber, rb_fiber_t *old_fiber) /* save old_fiber's machine stack / TODO: is it needed? */ if (!FIBER_TERMINATED_P(old_fiber)) { - STACK_GROW_DIR_DETECTION; - SET_MACHINE_STACK_END(&th->ec->machine.stack_end); - if (STACK_DIR_UPPER(0, 1)) { + STACK_GROW_DIR_DETECTION; + SET_MACHINE_STACK_END(&th->ec->machine.stack_end); + if (STACK_DIR_UPPER(0, 1)) { old_fiber->cont.machine.stack_size = th->ec->machine.stack_start - th->ec->machine.stack_end; old_fiber->cont.machine.stack = th->ec->machine.stack_end; - } - else { + } + else { old_fiber->cont.machine.stack_size = th->ec->machine.stack_end - th->ec->machine.stack_start; old_fiber->cont.machine.stack = th->ec->machine.stack_start; - } + } } /* exchange machine_stack_start between old_fiber and new_fiber */ @@ -977,18 +785,8 @@ fiber_setcontext(rb_fiber_t *new_fiber, rb_fiber_t *old_fiber) fiber_restore_thread(th, new_fiber); /* swap machine context */ -#if defined(FIBER_USE_COROUTINE) coroutine_transfer(&old_fiber->context, &new_fiber->context); -#elif defined(_WIN32) - SwitchToFiber(new_fiber->fiber_handle); -#else - if (!new_fiber->context.uc_stack.ss_sp && th->root_fiber != new_fiber) { - rb_bug("non_root_fiber->context.uc_stac.ss_sp should not be NULL"); - } - swapcontext(&old_fiber->context, &new_fiber->context); -#endif } -#endif /* FIBER_USE_NATIVE */ NOINLINE(NORETURN(static void cont_restore_1(rb_context_t *))); @@ -1000,17 +798,17 @@ cont_restore_1(rb_context_t *cont) /* restore machine stack */ #ifdef _M_AMD64 { - /* workaround for x64 SEH */ - jmp_buf buf; - setjmp(buf); - ((_JUMP_BUFFER*)(&cont->jmpbuf))->Frame = - ((_JUMP_BUFFER*)(&buf))->Frame; + /* workaround for x64 SEH */ + jmp_buf buf; + setjmp(buf); + ((_JUMP_BUFFER*)(&cont->jmpbuf))->Frame = + ((_JUMP_BUFFER*)(&buf))->Frame; } #endif if (cont->machine.stack_src) { - FLUSH_REGISTER_WINDOWS; - MEMCPY(cont->machine.stack_src, cont->machine.stack, - VALUE, cont->machine.stack_size); + FLUSH_REGISTER_WINDOWS; + MEMCPY(cont->machine.stack_src, cont->machine.stack, + VALUE, cont->machine.stack_size); } ruby_longjmp(cont->jmpbuf, 1); @@ -1027,41 +825,41 @@ cont_restore_0(rb_context_t *cont, VALUE *addr_in_prev_frame) #else #define STACK_PAD_SIZE 1024 #endif - VALUE space[STACK_PAD_SIZE]; + VALUE space[STACK_PAD_SIZE]; #if !STACK_GROW_DIRECTION - if (addr_in_prev_frame > &space[0]) { - /* Stack grows downward */ + if (addr_in_prev_frame > &space[0]) { + /* Stack grows downward */ #endif #if STACK_GROW_DIRECTION <= 0 - volatile VALUE *const end = cont->machine.stack_src; - if (&space[0] > end) { + volatile VALUE *const end = cont->machine.stack_src; + if (&space[0] > end) { # ifdef HAVE_ALLOCA - volatile VALUE *sp = ALLOCA_N(VALUE, &space[0] - end); - space[0] = *sp; + volatile VALUE *sp = ALLOCA_N(VALUE, &space[0] - end); + space[0] = *sp; # else - cont_restore_0(cont, &space[0]); + cont_restore_0(cont, &space[0]); # endif - } + } #endif #if !STACK_GROW_DIRECTION - } - else { - /* Stack grows upward */ + } + else { + /* Stack grows upward */ #endif #if STACK_GROW_DIRECTION >= 0 - volatile VALUE *const end = cont->machine.stack_src + cont->machine.stack_size; - if (&space[STACK_PAD_SIZE] < end) { + 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]); - space[0] = *sp; + volatile VALUE *sp = ALLOCA_N(VALUE, end - &space[STACK_PAD_SIZE]); + space[0] = *sp; # else - cont_restore_0(cont, &space[STACK_PAD_SIZE-1]); + cont_restore_0(cont, &space[STACK_PAD_SIZE-1]); # endif - } + } #endif #if !STACK_GROW_DIRECTION - } + } #endif } cont_restore_1(cont); @@ -1157,10 +955,10 @@ rb_callcc(VALUE self) volatile VALUE val = cont_capture(&called); if (called) { - return val; + return val; } else { - return rb_yield(val); + return rb_yield(val); } } @@ -1169,13 +967,13 @@ make_passing_arg(int argc, const VALUE *argv) { switch (argc) { case -1: - return argv[0]; + return argv[0]; case 0: - return Qnil; + return Qnil; case 1: - return argv[0]; + return argv[0]; default: - return rb_ary_new4(argc, argv); + return rb_ary_new4(argc, argv); } } @@ -1186,7 +984,7 @@ ruby_register_rollback_func_for_ensure(VALUE (*ensure_func)(ANYARGS), VALUE (*ro { st_table **table_p = &GET_VM()->ensure_rollback_table; if (UNLIKELY(*table_p == NULL)) { - *table_p = st_init_numtable(); + *table_p = st_init_numtable(); } st_insert(*table_p, (st_data_t)ensure_func, (st_data_t)rollback_func); } @@ -1197,7 +995,7 @@ lookup_rollback_func(VALUE (*ensure_func)(ANYARGS)) st_table *table = GET_VM()->ensure_rollback_table; st_data_t val; if (table && st_lookup(table, (st_data_t)ensure_func, &val)) - return (VALUE) val; + return (VALUE) val; return Qundef; } @@ -1215,34 +1013,34 @@ rollback_ensure_stack(VALUE self,rb_ensure_list_t *current,rb_ensure_entry_t *ta cur_size = 0; for (p=current; p; p=p->next) - cur_size++; + cur_size++; target_size = 0; for (entry=target; entry->marker; entry++) - target_size++; + target_size++; /* search common stack point */ p = current; base_point = cur_size; while (base_point) { - if (target_size >= base_point && - p->entry.marker == target[target_size - base_point].marker) - break; - base_point --; - p = p->next; + if (target_size >= base_point && + p->entry.marker == target[target_size - base_point].marker) + break; + base_point --; + p = p->next; } /* rollback function check */ for (i=0; i < target_size - base_point; i++) { - if (!lookup_rollback_func(target[i].e_proc)) { - rb_raise(rb_eRuntimeError, "continuation called from out of critical rb_ensure scope"); - } + if (!lookup_rollback_func(target[i].e_proc)) { + rb_raise(rb_eRuntimeError, "continuation called from out of critical rb_ensure scope"); + } } /* pop ensure stack */ while (cur_size > base_point) { - /* escape from ensure block */ - (*current->entry.e_proc)(current->entry.data2); - current = current->next; - cur_size--; + /* escape from ensure block */ + (*current->entry.e_proc)(current->entry.data2); + current = current->next; + cur_size--; } /* push ensure stack */ for (j = 0; j < i; j++) { @@ -1275,15 +1073,15 @@ rb_cont_call(int argc, VALUE *argv, VALUE contval) rb_thread_t *th = GET_THREAD(); if (cont_thread_value(cont) != th->self) { - rb_raise(rb_eRuntimeError, "continuation called across threads"); + rb_raise(rb_eRuntimeError, "continuation called across threads"); } if (cont->saved_ec.protect_tag != th->ec->protect_tag) { - rb_raise(rb_eRuntimeError, "continuation called across stack rewinding barrier"); + rb_raise(rb_eRuntimeError, "continuation called across stack rewinding barrier"); } if (cont->saved_ec.fiber_ptr) { - if (th->ec->fiber_ptr != cont->saved_ec.fiber_ptr) { - rb_raise(rb_eRuntimeError, "continuation called across fiber"); - } + if (th->ec->fiber_ptr != cont->saved_ec.fiber_ptr) { + rb_raise(rb_eRuntimeError, "continuation called across fiber"); + } } rollback_ensure_stack(contval, th->ec->ensure_list, cont->ensure_array); @@ -1380,7 +1178,7 @@ fiber_t_alloc(VALUE fiber_value) rb_thread_t *th = GET_THREAD(); if (DATA_PTR(fiber_value) != 0) { - rb_raise(rb_eRuntimeError, "cannot initialize twice"); + rb_raise(rb_eRuntimeError, "cannot initialize twice"); } THREAD_MUST_BE_RUNNING(th); @@ -1402,15 +1200,15 @@ fiber_t_alloc(VALUE fiber_value) rb_control_frame_t * rb_vm_push_frame(rb_execution_context_t *sec, - const rb_iseq_t *iseq, - VALUE type, - VALUE self, - VALUE specval, - VALUE cref_or_me, - const VALUE *pc, - VALUE *sp, - int local_size, - int stack_max); + const rb_iseq_t *iseq, + VALUE type, + VALUE self, + VALUE specval, + VALUE cref_or_me, + const VALUE *pc, + VALUE *sp, + int local_size, + int stack_max); static VALUE fiber_init(VALUE fiber_value, VALUE proc) @@ -1420,20 +1218,21 @@ fiber_init(VALUE fiber_value, VALUE proc) rb_execution_context_t *sec = &cont->saved_ec; rb_thread_t *cth = GET_THREAD(); rb_vm_t *vm = cth->vm; - size_t fiber_stack_bytes = vm->default_params.fiber_vm_stack_size; - size_t thr_stack_bytes = vm->default_params.thread_vm_stack_size; + size_t fiber_vm_stack_size = vm->default_params.fiber_vm_stack_size; + size_t thread_vm_stack_size = vm->default_params.thread_vm_stack_size; VALUE *vm_stack; /* initialize cont */ cont->saved_vm_stack.ptr = NULL; - if (fiber_stack_bytes == thr_stack_bytes) { - vm_stack = rb_thread_recycle_stack(fiber_stack_bytes / sizeof(VALUE)); + if (fiber_vm_stack_size == thread_vm_stack_size) { + vm_stack = rb_thread_recycle_stack(fiber_vm_stack_size / sizeof(VALUE)); } else { - vm_stack = ruby_xmalloc(fiber_stack_bytes); + vm_stack = ruby_xmalloc(fiber_vm_stack_size); } + cont->free_vm_stack = 1; - rb_ec_initialize_vm_stack(sec, vm_stack, fiber_stack_bytes / sizeof(VALUE)); + rb_ec_initialize_vm_stack(sec, vm_stack, fiber_vm_stack_size / sizeof(VALUE)); sec->tag = NULL; sec->local_storage = NULL; @@ -1442,10 +1241,6 @@ fiber_init(VALUE fiber_value, VALUE proc) fiber->first_proc = proc; -#if !FIBER_USE_NATIVE - MEMCPY(&cont->jmpbuf, &cth->root_jmpbuf, rb_jmpbuf_t, 1); -#endif - return fiber_value; } @@ -1479,34 +1274,34 @@ rb_fiber_start(void) EC_PUSH_TAG(th->ec); if ((state = EC_EXEC_TAG()) == TAG_NONE) { rb_context_t *cont = &VAR_FROM_MEMORY(fiber)->cont; - int argc; - const VALUE *argv, args = cont->value; + int argc; + const VALUE *argv, args = cont->value; GetProcPtr(fiber->first_proc, proc); - argv = (argc = cont->argc) > 1 ? RARRAY_CONST_PTR(args) : &args; - cont->value = Qnil; - th->ec->errinfo = Qnil; + argv = (argc = cont->argc) > 1 ? RARRAY_CONST_PTR(args) : &args; + cont->value = Qnil; + th->ec->errinfo = Qnil; th->ec->root_lep = rb_vm_proc_local_ep(fiber->first_proc); - th->ec->root_svar = Qfalse; + th->ec->root_svar = Qfalse; - EXEC_EVENT_HOOK(th->ec, RUBY_EVENT_FIBER_SWITCH, th->self, 0, 0, 0, Qnil); - cont->value = rb_vm_invoke_proc(th->ec, proc, argc, argv, VM_BLOCK_HANDLER_NONE); + EXEC_EVENT_HOOK(th->ec, RUBY_EVENT_FIBER_SWITCH, th->self, 0, 0, 0, Qnil); + cont->value = rb_vm_invoke_proc(th->ec, proc, argc, argv, VM_BLOCK_HANDLER_NONE); } EC_POP_TAG(); if (state) { - VALUE err = th->ec->errinfo; + VALUE err = th->ec->errinfo; VM_ASSERT(FIBER_RESUMED_P(fiber)); - if (state == TAG_RAISE || state == TAG_FATAL) { - rb_threadptr_pending_interrupt_enque(th, err); - } - else { - err = rb_vm_make_jump_tag_but_local_jump(state, err); - if (!NIL_P(err)) { - rb_threadptr_pending_interrupt_enque(th, err); - } - } - need_interrupt = TRUE; + if (state == TAG_RAISE || state == TAG_FATAL) { + rb_threadptr_pending_interrupt_enque(th, err); + } + else { + err = rb_vm_make_jump_tag_but_local_jump(state, err); + if (!NIL_P(err)) { + rb_threadptr_pending_interrupt_enque(th, err); + } + } + need_interrupt = TRUE; } rb_fiber_terminate(fiber, need_interrupt); @@ -1527,21 +1322,7 @@ root_fiber_alloc(rb_thread_t *th) DATA_PTR(fiber_value) = fiber; fiber->cont.self = fiber_value; -#if FIBER_USE_NATIVE -#if defined(FIBER_USE_COROUTINE) coroutine_initialize_main(&fiber->context); -#elif defined(_WIN32) - /* setup fiber_handle for root Fiber */ - if (fiber->fiber_handle == 0) { - if ((fiber->fiber_handle = ConvertThreadToFiber(0)) == 0) { - rb_bug("root_fiber_alloc: ConvertThreadToFiber() failed - %s\n", rb_w32_strerror(-1)); - } - } - else { - rb_bug("root_fiber_alloc: fiber_handle is not NULL."); - } -#endif -#endif return fiber; } @@ -1566,19 +1347,17 @@ void rb_threadptr_root_fiber_release(rb_thread_t *th) { if (th->root_fiber) { - /* ignore. A root fiber object will free th->ec */ + /* ignore. A root fiber object will free th->ec */ } else { - VM_ASSERT(th->ec->fiber_ptr->cont.type == FIBER_CONTEXT); - VM_ASSERT(th->ec->fiber_ptr->cont.self == 0); + VM_ASSERT(th->ec->fiber_ptr->cont.type == FIBER_CONTEXT); + VM_ASSERT(th->ec->fiber_ptr->cont.self == 0); + fiber_free(th->ec->fiber_ptr); - // th->ec->fiber_ptr->cont.saved_ec.vm_stack = NULL; - fiber_free(th->ec->fiber_ptr); - - if (th->ec == ruby_current_execution_context_ptr) { - ruby_current_execution_context_ptr = NULL; - } - th->ec = NULL; + if (th->ec == ruby_current_execution_context_ptr) { + ruby_current_execution_context_ptr = NULL; + } + th->ec = NULL; } } @@ -1598,7 +1377,7 @@ fiber_current(void) { rb_execution_context_t *ec = GET_EC(); if (ec->fiber_ptr->cont.self == 0) { - root_fiber_alloc(rb_ec_thread_ptr(ec)); + root_fiber_alloc(rb_ec_thread_ptr(ec)); } return ec->fiber_ptr; } @@ -1610,19 +1389,19 @@ return_fiber(void) rb_fiber_t *prev = fiber->prev; if (!prev) { - rb_thread_t *th = GET_THREAD(); - rb_fiber_t *root_fiber = th->root_fiber; + rb_thread_t *th = GET_THREAD(); + rb_fiber_t *root_fiber = th->root_fiber; - VM_ASSERT(root_fiber != NULL); + VM_ASSERT(root_fiber != NULL); if (root_fiber == fiber) { - rb_raise(rb_eFiberError, "can't yield from root fiber"); - } - return root_fiber; + rb_raise(rb_eFiberError, "can't yield from root fiber"); + } + return root_fiber; } else { fiber->prev = NULL; - return prev; + return prev; } } @@ -1648,25 +1427,16 @@ fiber_store(rb_fiber_t *next_fiber, rb_thread_t *th) VM_ASSERT(FIBER_RESUMED_P(fiber) || FIBER_TERMINATED_P(fiber)); VM_ASSERT(FIBER_RUNNABLE_P(next_fiber)); -#if FIBER_USE_NATIVE if (FIBER_CREATED_P(next_fiber)) { fiber_initialize_machine_stack_context(next_fiber, th->vm->default_params.fiber_machine_stack_size); } -#endif if (FIBER_RESUMED_P(fiber)) fiber_status_set(fiber, FIBER_SUSPENDED); -#if FIBER_USE_NATIVE == 0 - /* should (re-)allocate stack are before fiber->status change to pass fiber_verify() */ - cont_save_machine_stack(th, &fiber->cont); -#endif - fiber_status_set(next_fiber, FIBER_RESUMED); -#if FIBER_USE_NATIVE fiber_setcontext(next_fiber, fiber); - /* restored */ -#ifdef MAX_MACHINE_STACK_CACHE + if (terminated_machine_stack.ptr) { if (machine_stack_cache_index < MAX_MACHINE_STACK_CACHE) { machine_stack_cache[machine_stack_cache_index++] = terminated_machine_stack; @@ -1686,29 +1456,10 @@ fiber_store(rb_fiber_t *next_fiber, rb_thread_t *th) terminated_machine_stack.ptr = NULL; terminated_machine_stack.size = 0; } -#endif /* MAX_MACHINE_STACK_CACHE */ + fiber = th->ec->fiber_ptr; if (fiber->cont.argc == -1) rb_exc_raise(fiber->cont.value); return fiber->cont.value; - -#else /* FIBER_USE_NATIVE */ - fiber->cont.saved_ec.machine.stack_end = NULL; - if (ruby_setjmp(fiber->cont.jmpbuf)) { - /* restored */ - fiber = th->ec->fiber_ptr; - if (fiber->cont.argc == -1) rb_exc_raise(fiber->cont.value); - if (next_fiber->cont.value == Qundef) { - cont_restore_0(&next_fiber->cont, &next_fiber->cont.value); - VM_UNREACHABLE(fiber_store); - } - return fiber->cont.value; - } - else { - VALUE undef = Qundef; - cont_restore_0(&next_fiber->cont, &undef); - VM_UNREACHABLE(fiber_store); - } -#endif /* FIBER_USE_NATIVE */ } static inline VALUE @@ -1722,41 +1473,39 @@ fiber_switch(rb_fiber_t *fiber, int argc, const VALUE *argv, int is_resume) if (th->root_fiber == NULL) root_fiber_alloc(th); if (th->ec->fiber_ptr == fiber) { - /* ignore fiber context switch + /* ignore fiber context switch * because destination fiber is same as current fiber - */ - return make_passing_arg(argc, argv); + */ + return make_passing_arg(argc, argv); } if (cont_thread_value(cont) != th->self) { - rb_raise(rb_eFiberError, "fiber called across threads"); + rb_raise(rb_eFiberError, "fiber called across threads"); } else if (cont->saved_ec.protect_tag != th->ec->protect_tag) { - rb_raise(rb_eFiberError, "fiber called across stack rewinding barrier"); + rb_raise(rb_eFiberError, "fiber called across stack rewinding barrier"); } else if (FIBER_TERMINATED_P(fiber)) { - value = rb_exc_new2(rb_eFiberError, "dead fiber called"); - - if (!FIBER_TERMINATED_P(th->ec->fiber_ptr)) { - rb_exc_raise(value); - VM_UNREACHABLE(fiber_switch); - } - else { - /* th->ec->fiber_ptr is also dead => switch to root fiber */ - /* (this means we're being called from rb_fiber_terminate, */ - /* and the terminated fiber's return_fiber() is already dead) */ - VM_ASSERT(FIBER_SUSPENDED_P(th->root_fiber)); - - cont = &th->root_fiber->cont; - cont->argc = -1; - cont->value = value; -#if FIBER_USE_NATIVE - fiber_setcontext(th->root_fiber, th->ec->fiber_ptr); -#else - cont_restore_0(cont, &value); -#endif - VM_UNREACHABLE(fiber_switch); - } + value = rb_exc_new2(rb_eFiberError, "dead fiber called"); + + if (!FIBER_TERMINATED_P(th->ec->fiber_ptr)) { + rb_exc_raise(value); + VM_UNREACHABLE(fiber_switch); + } + else { + /* th->ec->fiber_ptr is also dead => switch to root fiber */ + /* (this means we're being called from rb_fiber_terminate, */ + /* and the terminated fiber's return_fiber() is already dead) */ + VM_ASSERT(FIBER_SUSPENDED_P(th->root_fiber)); + + cont = &th->root_fiber->cont; + cont->argc = -1; + cont->value = value; + + fiber_setcontext(th->root_fiber, th->ec->fiber_ptr); + + VM_UNREACHABLE(fiber_switch); + } } if (is_resume) { @@ -1799,11 +1548,6 @@ rb_fiber_close(rb_fiber_t *fiber) } rb_ec_clear_vm_stack(ec); - -#if !FIBER_USE_NATIVE - /* should not mark machine stack any more */ - ec->machine.stack_end = NULL; -#endif } static void @@ -1815,22 +1559,14 @@ rb_fiber_terminate(rb_fiber_t *fiber, int need_interrupt) VM_ASSERT(FIBER_RESUMED_P(fiber)); rb_fiber_close(fiber); -#if FIBER_USE_NATIVE -#if defined(FIBER_USE_COROUTINE) coroutine_destroy(&fiber->context); -#elif !defined(_WIN32) - fiber->context.uc_stack.ss_sp = NULL; -#endif -#ifdef MAX_MACHINE_STACK_CACHE /* Ruby must not switch to other thread until storing terminated_machine_stack */ terminated_machine_stack.ptr = fiber->ss_sp; terminated_machine_stack.size = fiber->ss_size / sizeof(VALUE); fiber->ss_sp = NULL; fiber->cont.machine.stack = NULL; fiber->cont.machine.stack_size = 0; -#endif -#endif ret_fiber = return_fiber(); if (need_interrupt) RUBY_VM_SET_INTERRUPT(&ret_fiber->cont.saved_ec); @@ -1847,11 +1583,11 @@ rb_fiber_resume(VALUE fiber_value, int argc, const VALUE *argv) } if (fiber->prev != 0 || fiber_is_root_p(fiber)) { - rb_raise(rb_eFiberError, "double resume"); + rb_raise(rb_eFiberError, "double resume"); } if (fiber->transferred != 0) { - rb_raise(rb_eFiberError, "cannot resume transferred Fiber"); + rb_raise(rb_eFiberError, "cannot resume transferred Fiber"); } return fiber_switch(fiber, argc, argv, 1); @@ -1867,7 +1603,7 @@ void rb_fiber_reset_root_local_storage(rb_thread_t *th) { if (th->root_fiber && th->root_fiber != th->ec->fiber_ptr) { - th->ec->local_storage = th->root_fiber->cont.saved_ec.local_storage; + th->ec->local_storage = th->root_fiber->cont.saved_ec.local_storage; } } @@ -2034,10 +1770,10 @@ fiber_to_s(VALUE fiber_value) snprintf(status_info, 0x10, " (%s)", fiber_status_name(fiber->status)); if (!rb_obj_is_proc(fiber->first_proc)) { VALUE str = rb_any_to_s(fiber_value); - strlcat(status_info, ">", sizeof(status_info)); - rb_str_set_len(str, RSTRING_LEN(str)-1); - rb_str_cat_cstr(str, status_info); - return str; + strlcat(status_info, ">", sizeof(status_info)); + rb_str_set_len(str, RSTRING_LEN(str)-1); + rb_str_cat_cstr(str, status_info); + return str; } GetProcPtr(fiber->first_proc, proc); return rb_block_to_s(fiber_value, &proc->block, status_info); @@ -2072,7 +1808,6 @@ rb_fiber_atfork(rb_thread_t *th) void Init_Cont(void) { -#if FIBER_USE_NATIVE rb_thread_t *th = GET_THREAD(); #ifdef _WIN32 @@ -2083,7 +1818,6 @@ Init_Cont(void) pagesize = sysconf(_SC_PAGESIZE); #endif SET_MACHINE_STACK_END(&th->ec->machine.stack_end); -#endif rb_cFiber = rb_define_class("Fiber", rb_cObject); rb_define_alloc_func(rb_cFiber, fiber_alloc); From 14cf95cff35612c6238790ad2f605530f69e9a44 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Sun, 2 Jun 2019 12:49:58 +1200 Subject: [PATCH 257/452] Implement fiber pool for reduced fiber allocation overhead. Replace previous stack cache with fiber pool cache. The fiber pool allocates many stacks in a single memory region. Stack allocation becomes O(log N) and fiber creation is amortized O(1). Around 10x performance improvement was measured in micro-benchmarks. --- cont.c | 700 +++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 508 insertions(+), 192 deletions(-) diff --git a/cont.c b/cont.c index 5e72c24b96eb6d..51f0a3a3d7bd53 100644 --- a/cont.c +++ b/cont.c @@ -24,10 +24,20 @@ #include #endif +static const int DEBUG = 0; + #define RB_PAGE_SIZE (pagesize) #define RB_PAGE_MASK (~(RB_PAGE_SIZE - 1)) static long pagesize; +static const rb_data_type_t cont_data_type, fiber_data_type; +static VALUE rb_cContinuation; +static VALUE rb_cFiber; +static VALUE rb_eFiberError; +#ifdef RB_EXPERIMENTAL_FIBER_POOL +static VALUE rb_cFiberPool; +#endif + #define CAPTURE_JUST_VALID_VM_STACK 1 enum context_type { @@ -43,6 +53,99 @@ struct cont_saved_vm_stack { #endif }; +struct fiber_pool; + +// Represents a single stack. +struct fiber_pool_stack { + // A pointer to the memory allocation (lowest address) for the stack. + void * base; + + // The current stack pointer, taking into account the direction of the stack. + void * current; + + // The size of the stack including any guard pages. + size_t size; + + // The available stack capacity w.r.t. the current stack offset. + size_t available; + + // The pool this stack is managed by. + struct fiber_pool * pool; +}; + +// A singly linked list of vacant (unused) stacks. +// This structure is stored in the first page of a stack if it is not in use. +// @sa fiber_pool_vacancy_pointer +struct fiber_pool_vacancy { + // Details about the vacant stack: + struct fiber_pool_stack stack; + + // The next vacancy in the linked list. + struct fiber_pool_vacancy * next; +}; + +// Manages singly linked list of mapped regions of memory which contains 1 more more stack: +// +// base = +-------------------------------+-----------------------+ + +// |VM Stack |VM Stack | | | +// | | | | | +// | | | | | +// +-------------------------------+ | | +// |Machine Stack |Machine Stack | | | +// | | | | | +// | | | | | +// | | | . . . . | | size +// | | | | | +// | | | | | +// | | | | | +// | | | | | +// | | | | | +// +-------------------------------+ | | +// |Guard Page |Guard Page | | | +// +-------------------------------+-----------------------+ v +// +// +-------------------------------------------------------> +// +// count +// +struct fiber_pool_allocation { + // A pointer to the memory mapped region. + void * base; + + // The size of the individual stacks. + size_t size; + + // The number of stacks that were allocated. + size_t count; + + // The number of stacks used in this allocation. + // size_t used; + + // The next allocation in the linked list. + struct fiber_pool_allocation * next; +}; + +// A fiber pool manages vacant stacks to reduce the overhead of creating fibers. +struct fiber_pool { + // A singly-linked list of allocations which contain 1 or more stacks each. + struct fiber_pool_allocation * allocations; + + // Provides O(1) stack "allocation": + struct fiber_pool_vacancy * vacancies; + + // The size of the stack allocations including guard page. + size_t size; + + // The total number of stacks that have been allocated in this pool. + size_t count; + + // The number of stacks that have been used in this pool. + size_t used; + + // The amount to allocate for the vm_stack: + size_t vm_stack_size; +}; + typedef struct rb_context_struct { enum context_type type; int argc; @@ -57,7 +160,6 @@ typedef struct rb_context_struct { size_t stack_size; } machine; rb_execution_context_t saved_ec; - int free_vm_stack; rb_jmpbuf_t jmpbuf; rb_ensure_entry_t *ensure_array; /* Pointer to MJIT info about the continuation. */ @@ -102,18 +204,272 @@ struct rb_fiber_struct { unsigned int transferred : 1; struct coroutine_context context; - void *ss_sp; - size_t ss_size; + struct fiber_pool_stack stack; }; -#define MAX_MACHINE_STACK_CACHE 10 -static int machine_stack_cache_index = 0; -typedef struct machine_stack_cache_struct { - void *ptr; - size_t size; -} machine_stack_cache_t; -static machine_stack_cache_t machine_stack_cache[MAX_MACHINE_STACK_CACHE]; -static machine_stack_cache_t terminated_machine_stack; +static struct fiber_pool shared_fiber_pool = {NULL, NULL, 0, 0, 0, 0}; + +/* + * FreeBSD require a first (i.e. addr) argument of mmap(2) is not NULL + * if MAP_STACK is passed. + * http://www.FreeBSD.org/cgi/query-pr.cgi?pr=158755 + */ +#if defined(MAP_STACK) && !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__) +#define FIBER_STACK_FLAGS (MAP_PRIVATE | MAP_ANON | MAP_STACK) +#else +#define FIBER_STACK_FLAGS (MAP_PRIVATE | MAP_ANON) +#endif + +#define ERRNOMSG strerror(errno) + +// Locates the stack vacancy details for the given stack. +// Requires that fiber_pool_vacancy fits within one page. +inline static struct fiber_pool_vacancy * +fiber_pool_vacancy_pointer(void * base, size_t size) +{ + STACK_GROW_DIR_DETECTION; + + return (struct fiber_pool_vacancy *)( + (char*)base + STACK_DIR_UPPER(0, size - RB_PAGE_SIZE) + ); +} + +// Given an existing fiber pool, expand it by the specified number of stacks. +static struct fiber_pool_allocation * +fiber_pool_expand(struct fiber_pool * fiber_pool, size_t count) +{ + size_t i; + struct fiber_pool_vacancy * vacancies = fiber_pool->vacancies; + struct fiber_pool_allocation * allocation = RB_ALLOC(struct fiber_pool_allocation); + + size_t size = fiber_pool->size; + + /* Initialize fiber pool */ + allocation->base = NULL; + allocation->size = size; + allocation->count = count; + + if (DEBUG) fprintf(stderr, "fiber_pool_expand(%zu): %p, %zu/%zu x [%zu:%zu]\n", count, fiber_pool, fiber_pool->used, fiber_pool->count, size, fiber_pool->vm_stack_size); + +#ifdef _WIN32 + DWORD old_protect; + + allocation->base = VirtualAlloc(0, count*size, MEM_COMMIT, PAGE_READWRITE); + + if (!allocation->base) { + rb_raise(rb_eFiberError, "can't alloc machine stack to fiber (%zu x %zu bytes): %s", count, size, ERRNOMSG); + } + + for (i = 0; i < count; i += 1) { + void * base = (char*)allocation->base + (size * i); + + if (!VirtualProtect(base, RB_PAGE_SIZE, PAGE_READWRITE | PAGE_GUARD, &old_protect)) { + VirtualFree(allocation->base, 0, MEM_RELEASE); + rb_raise(rb_eFiberError, "can't set a guard page: %s", ERRNOMSG); + } + + struct fiber_pool_vacancy * vacancy = fiber_pool_vacancy_pointer(base, size); + vacancy->stack.base = base; + vacancy->stack.current = (char*)base + size; + vacancy->stack.size = size; + vacancy->stack.available = size - pagesize; + vacancy->stack.pool = fiber_pool; + vacancy->next = vacancies; + vacancies = vacancy; + } +#else + STACK_GROW_DIR_DETECTION; + + errno = 0; + allocation->base = mmap(NULL, count*size, PROT_READ | PROT_WRITE, FIBER_STACK_FLAGS, -1, 0); + + if (allocation->base == MAP_FAILED) { + rb_raise(rb_eFiberError, "can't alloc machine stack to fiber (%zu x %zu bytes): %s", count, size, ERRNOMSG); + } + + for (i = 0; i < count; i += 1) { + void * base = (char*)allocation->base + (size * i); + void * page = (char*)base + STACK_DIR_UPPER(size - RB_PAGE_SIZE, 0); + + if (mprotect(page, RB_PAGE_SIZE, PROT_NONE) < 0) { + munmap(allocation->base, count*size); + rb_raise(rb_eFiberError, "can't set a guard page: %s", ERRNOMSG); + } + + struct fiber_pool_vacancy * vacancy = fiber_pool_vacancy_pointer(base, size); + vacancy->stack.base = base; + vacancy->stack.current = (char*)base + STACK_DIR_UPPER(0, size); + vacancy->stack.size = size; + vacancy->stack.available = size - pagesize; + vacancy->stack.pool = fiber_pool; + vacancy->next = vacancies; + vacancies = vacancy; + } +#endif + + // Insert the allocation into the head of the pool: + allocation->next = fiber_pool->allocations; + fiber_pool->allocations = allocation; + fiber_pool->vacancies = vacancies; + fiber_pool->count += count; + + return allocation; +} + +// Initialize the specified fiber pool with the given number of stacks. +// @param vm_stack_size The size of the vm stack to allocate. +static void +fiber_pool_initialize(struct fiber_pool * fiber_pool, size_t size, size_t count, size_t vm_stack_size) +{ + VM_ASSERT(vm_stack_size < size); + + fiber_pool->allocations = NULL; + fiber_pool->vacancies = NULL; + fiber_pool->size = ((size / RB_PAGE_SIZE) + 1) * RB_PAGE_SIZE; + fiber_pool->count = count; + fiber_pool->used = 0; + + fiber_pool->vm_stack_size = vm_stack_size; + + fiber_pool_expand(fiber_pool, count); +} + +#ifdef RB_EXPERIMENTAL_FIBER_POOL +// Free the list of fiber pool allocations. +static void +fiber_pool_free_allocations(struct fiber_pool_allocation * allocation) +{ + // If no stacks are being used, we can free this allocation: + // VM_ASSERT(allocation->used == 0); + +#ifdef _WIN32 + VirtualFree(allocation->base, 0, MEM_RELEASE); +#else + munmap(allocation->base, allocation->size * allocation->count); +#endif + allocation->base = NULL; + + if (allocation->next != NULL) { + fiber_pool_free_allocations(allocation->next); + } + + ruby_xfree(allocation); +} +#endif + +// Reset the current stack pointer and available size of the given stack. +inline static void +fiber_pool_stack_reset(struct fiber_pool_stack * stack) +{ + STACK_GROW_DIR_DETECTION; + + stack->current = (char*)stack->base + STACK_DIR_UPPER(0, stack->size); + stack->available = stack->size - RB_PAGE_SIZE; +} + +// A pointer to the base of the current unused portion of the stack. +inline static void * +fiber_pool_stack_base(struct fiber_pool_stack * stack) +{ + STACK_GROW_DIR_DETECTION; + + return STACK_DIR_UPPER(stack->current, (char*)stack->current - stack->available); +} + +// Allocate some memory from the stack. Used to allocate vm_stack inline with machine stack. +// @sa fiber_initialize_coroutine +inline static void * +fiber_pool_stack_alloca(struct fiber_pool_stack * stack, size_t offset) +{ + STACK_GROW_DIR_DETECTION; + + VM_ASSERT(stack->available >= offset); + + // The pointer to the memory being allocated: + void * pointer = STACK_DIR_UPPER(stack->current, (char*)stack->current - offset); + + // Move the stack pointer: + stack->current = STACK_DIR_UPPER((char*)stack->current + offset, (char*)stack->current - offset); + stack->available -= offset; + + return pointer; +} + +// Acquire a stack from the given fiber pool. If none are avilable, allocate more. +static struct fiber_pool_stack +fiber_pool_stack_acquire(struct fiber_pool * fiber_pool) { + struct fiber_pool_vacancy * vacancy = fiber_pool->vacancies; + + if (DEBUG) fprintf(stderr, "fiber_pool_stack_acquire: %p used=%zu\n", fiber_pool->vacancies, fiber_pool->used); + + if (!vacancy) { + size_t count = fiber_pool->count; + if (count > 1024) count = 1024; + + fiber_pool_expand(fiber_pool, count); + + // The free list should now contain some stacks: + VM_ASSERT(fiber_pool->vacancies); + + vacancy = fiber_pool->vacancies; + } + + // Take the top item from the free list: + fiber_pool->vacancies = vacancy->next; + fiber_pool->used += 1; + + fiber_pool_stack_reset(&vacancy->stack); + + return vacancy->stack; +} + +// Release and return a stack to the vacancy list. +static void +fiber_pool_stack_release(struct fiber_pool_stack stack) { + struct fiber_pool_vacancy * vacancy = fiber_pool_vacancy_pointer(stack.base, stack.size); + +#if defined(MADV_FREE) && defined(__linux__) + // Using madvise can make physical memory available to OS when there is memory pressure. + // But bencmarks show that this approach makes performance worse. + // madvise(vacancy->stack.base, vacancy->stack.size - RB_PAGE_SIZE, MADV_FREE); +#endif + + vacancy->stack = stack; + vacancy->next = stack.pool->vacancies; + stack.pool->vacancies = vacancy; + stack.pool->used -= 1; + + if (DEBUG) fprintf(stderr, "fiber_pool_stack_release: %p used=%zu\n", stack.base, stack.pool->used); +} + +static COROUTINE +fiber_entry(struct coroutine_context * from, struct coroutine_context * to) +{ + rb_fiber_start(); +} + +static VALUE * +fiber_initialize_machine_stack_context(rb_fiber_t *fiber, size_t * vm_stack_size) +{ + struct fiber_pool * fiber_pool = fiber->stack.pool; + rb_execution_context_t *sec = &fiber->cont.saved_ec; + void * vm_stack = NULL; + + STACK_GROW_DIR_DETECTION; + + VM_ASSERT(fiber_pool != NULL); + + fiber->stack = fiber_pool_stack_acquire(fiber_pool); + vm_stack = fiber_pool_stack_alloca(&fiber->stack, fiber_pool->vm_stack_size); + *vm_stack_size = fiber_pool->vm_stack_size; + + coroutine_initialize(&fiber->context, fiber_entry, fiber_pool_stack_base(&fiber->stack), fiber->stack.available); + + sec->machine.stack_start = fiber->stack.current; + sec->machine.stack_maxsize = fiber->stack.available; + + return vm_stack; +} static const char * fiber_status_name(enum fiber_status s) @@ -159,10 +515,10 @@ rb_ec_verify(const rb_execution_context_t *ec) } #endif -static void +inline static void fiber_status_set(rb_fiber_t *fiber, enum fiber_status s) { - if (0) fprintf(stderr, "fiber: %p, status: %s -> %s\n", (void *)fiber, fiber_status_name(fiber->status), fiber_status_name(s)); + if (DEBUG) fprintf(stderr, "fiber: %p, status: %s -> %s\n", (void *)fiber, fiber_status_name(fiber->status), fiber_status_name(s)); VM_ASSERT(!FIBER_TERMINATED_P(fiber)); VM_ASSERT(fiber->status != s); fiber_verify(fiber); @@ -187,11 +543,6 @@ ec_switch(rb_thread_t *th, rb_fiber_t *fiber) VM_ASSERT(ec->fiber_ptr->cont.self == 0 || ec->vm_stack != NULL); } -static const rb_data_type_t cont_data_type, fiber_data_type; -static VALUE rb_cContinuation; -static VALUE rb_cFiber; -static VALUE rb_eFiberError; - static rb_context_t * cont_ptr(VALUE obj) { @@ -288,26 +639,21 @@ cont_free(void *ptr) RUBY_FREE_ENTER("cont"); - if (cont->free_vm_stack) { - ruby_xfree(cont->saved_ec.vm_stack); - } - if (cont->type == CONTINUATION_CONTEXT) { + ruby_xfree(cont->saved_ec.vm_stack); ruby_xfree(cont->ensure_array); RUBY_FREE_UNLESS_NULL(cont->machine.stack); } else { rb_fiber_t *fiber = (rb_fiber_t*)cont; coroutine_destroy(&fiber->context); - if (fiber->ss_sp != NULL) { + if (fiber->stack.base != NULL) { if (fiber_is_root_p(fiber)) { rb_bug("Illegal root fiber parameter"); } -#ifdef _WIN32 - VirtualFree((void*)fiber->ss_sp, 0, MEM_RELEASE); -#else - munmap((void*)fiber->ss_sp, fiber->ss_size); -#endif - fiber->ss_sp = NULL; + if (fiber->stack.base) { + fiber_pool_stack_release(fiber->stack); + fiber->stack.base = NULL; + } } } @@ -667,93 +1013,6 @@ cont_restore_thread(rb_context_t *cont) } } -static COROUTINE -fiber_entry(struct coroutine_context * from, struct coroutine_context * to) -{ - rb_fiber_start(); -} - -/* - * FreeBSD require a first (i.e. addr) argument of mmap(2) is not NULL - * if MAP_STACK is passed. - * http://www.FreeBSD.org/cgi/query-pr.cgi?pr=158755 - */ -#if defined(MAP_STACK) && !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__) -#define FIBER_STACK_FLAGS (MAP_PRIVATE | MAP_ANON | MAP_STACK) -#else -#define FIBER_STACK_FLAGS (MAP_PRIVATE | MAP_ANON) -#endif - -#define ERRNOMSG strerror(errno) - -static char* -fiber_machine_stack_alloc(size_t size) -{ - char *ptr; -#ifdef _WIN32 - DWORD old_protect; -#endif - - if (machine_stack_cache_index > 0) { - if (machine_stack_cache[machine_stack_cache_index - 1].size == (size / sizeof(VALUE))) { - ptr = machine_stack_cache[machine_stack_cache_index - 1].ptr; - machine_stack_cache_index--; - machine_stack_cache[machine_stack_cache_index].ptr = NULL; - machine_stack_cache[machine_stack_cache_index].size = 0; - } - else { - /* TODO handle multiple machine stack size */ - rb_bug("machine_stack_cache size is not canonicalized"); - } - } - else { -#ifdef _WIN32 - ptr = VirtualAlloc(0, size, MEM_COMMIT, PAGE_READWRITE); - - if (!ptr) { - rb_raise(rb_eFiberError, "can't allocate machine stack to fiber: %s", ERRNOMSG); - } - - if (!VirtualProtect(ptr, RB_PAGE_SIZE, PAGE_READWRITE | PAGE_GUARD, &old_protect)) { - rb_raise(rb_eFiberError, "can't set a guard page: %s", ERRNOMSG); - } -#else - void *page; - STACK_GROW_DIR_DETECTION; - - errno = 0; - ptr = mmap(NULL, size, PROT_READ | PROT_WRITE, FIBER_STACK_FLAGS, -1, 0); - if (ptr == MAP_FAILED) { - rb_raise(rb_eFiberError, "can't alloc machine stack to fiber: %s", ERRNOMSG); - } - - /* guard page setup */ - page = ptr + STACK_DIR_UPPER(size - RB_PAGE_SIZE, 0); - if (mprotect(page, RB_PAGE_SIZE, PROT_NONE) < 0) { - rb_raise(rb_eFiberError, "can't set a guard page: %s", ERRNOMSG); - } -#endif - } - - return ptr; -} - -static void -fiber_initialize_machine_stack_context(rb_fiber_t *fiber, size_t size) -{ - rb_execution_context_t *sec = &fiber->cont.saved_ec; - - char *ptr; - STACK_GROW_DIR_DETECTION; - - ptr = fiber_machine_stack_alloc(size); - fiber->ss_sp = ptr; - fiber->ss_size = size; - coroutine_initialize(&fiber->context, fiber_entry, ptr, size); - sec->machine.stack_start = (VALUE*)(ptr + STACK_DIR_UPPER(0, size)); - sec->machine.stack_maxsize = size - RB_PAGE_SIZE; -} - NOINLINE(static void fiber_setcontext(rb_fiber_t *new_fiber, rb_fiber_t *old_fiber)); static void @@ -915,7 +1174,7 @@ cont_restore_0(rb_context_t *cont, VALUE *addr_in_prev_frame) * require "continuation" * callcc {|cont| * for i in 0..4 - * print "\n#{i}: " + * print "#{i}: " * for j in i*5...(i+1)*5 * cont.call() if j == 17 * printf "%3d", j @@ -1211,50 +1470,47 @@ rb_vm_push_frame(rb_execution_context_t *sec, int stack_max); static VALUE -fiber_init(VALUE fiber_value, VALUE proc) +fiber_initialize(VALUE self, VALUE proc, struct fiber_pool * fiber_pool) +{ + rb_fiber_t *fiber = fiber_t_alloc(self); + + fiber->first_proc = proc; + fiber->stack.base = NULL; + fiber->stack.pool = fiber_pool; + + return self; +} + +static void +fiber_prepare_stack(rb_fiber_t *fiber) { - rb_fiber_t *fiber = fiber_t_alloc(fiber_value); rb_context_t *cont = &fiber->cont; rb_execution_context_t *sec = &cont->saved_ec; - rb_thread_t *cth = GET_THREAD(); - rb_vm_t *vm = cth->vm; - size_t fiber_vm_stack_size = vm->default_params.fiber_vm_stack_size; - size_t thread_vm_stack_size = vm->default_params.thread_vm_stack_size; - VALUE *vm_stack; + + size_t vm_stack_size = 0; + VALUE *vm_stack = fiber_initialize_machine_stack_context(fiber, &vm_stack_size); /* initialize cont */ cont->saved_vm_stack.ptr = NULL; - if (fiber_vm_stack_size == thread_vm_stack_size) { - vm_stack = rb_thread_recycle_stack(fiber_vm_stack_size / sizeof(VALUE)); - } - else { - vm_stack = ruby_xmalloc(fiber_vm_stack_size); - } - - cont->free_vm_stack = 1; - rb_ec_initialize_vm_stack(sec, vm_stack, fiber_vm_stack_size / sizeof(VALUE)); + rb_ec_initialize_vm_stack(sec, vm_stack, vm_stack_size / sizeof(VALUE)); sec->tag = NULL; sec->local_storage = NULL; sec->local_storage_recursive_hash = Qnil; sec->local_storage_recursive_hash_for_trace = Qnil; - - fiber->first_proc = proc; - - return fiber_value; } /* :nodoc: */ static VALUE -rb_fiber_init(VALUE fiber_value) +rb_fiber_initialize(int argc, VALUE* argv, VALUE self) { - return fiber_init(fiber_value, rb_block_proc()); + return fiber_initialize(self, rb_block_proc(), &shared_fiber_pool); } VALUE rb_fiber_new(VALUE (*func)(ANYARGS), VALUE obj) { - return fiber_init(fiber_alloc(rb_cFiber), rb_proc_new(func, obj)); + return fiber_initialize(fiber_alloc(rb_cFiber), rb_proc_new(func, obj), &shared_fiber_pool); } static void rb_fiber_terminate(rb_fiber_t *fiber, int need_interrupt); @@ -1337,10 +1593,6 @@ rb_threadptr_root_fiber_setup(rb_thread_t *th) fiber->cont.saved_ec.thread_ptr = th; fiber_status_set(fiber, FIBER_RESUMED); /* skip CREATED */ th->ec = &fiber->cont.saved_ec; - - VM_ASSERT(fiber->cont.free_vm_stack == 0); - - /* NOTE: On WIN32, fiber_handle is not allocated yet. */ } void @@ -1411,6 +1663,20 @@ rb_fiber_current(void) return fiber_current()->cont.self; } +static void +fiber_stack_release(rb_fiber_t * fiber) +{ + rb_execution_context_t *ec = &fiber->cont.saved_ec; + + if (fiber->stack.base) { + fiber_pool_stack_release(fiber->stack); + fiber->stack.base = NULL; + } + + // The stack is no longer associated with this execution context: + rb_ec_clear_vm_stack(ec); +} + static inline VALUE fiber_store(rb_fiber_t *next_fiber, rb_thread_t *th) { @@ -1424,41 +1690,23 @@ fiber_store(rb_fiber_t *next_fiber, rb_thread_t *th) fiber = root_fiber_alloc(th); } - VM_ASSERT(FIBER_RESUMED_P(fiber) || FIBER_TERMINATED_P(fiber)); - VM_ASSERT(FIBER_RUNNABLE_P(next_fiber)); - if (FIBER_CREATED_P(next_fiber)) { - fiber_initialize_machine_stack_context(next_fiber, th->vm->default_params.fiber_machine_stack_size); + fiber_prepare_stack(next_fiber); } + VM_ASSERT(FIBER_RESUMED_P(fiber) || FIBER_TERMINATED_P(fiber)); + VM_ASSERT(FIBER_RUNNABLE_P(next_fiber)); + if (FIBER_RESUMED_P(fiber)) fiber_status_set(fiber, FIBER_SUSPENDED); fiber_status_set(next_fiber, FIBER_RESUMED); - fiber_setcontext(next_fiber, fiber); - if (terminated_machine_stack.ptr) { - if (machine_stack_cache_index < MAX_MACHINE_STACK_CACHE) { - machine_stack_cache[machine_stack_cache_index++] = terminated_machine_stack; - } - else { - if (terminated_machine_stack.ptr != fiber->cont.machine.stack) { -#ifdef _WIN32 - VirtualFree(terminated_machine_stack.ptr, 0, MEM_RELEASE); -#else - munmap((void*)terminated_machine_stack.ptr, terminated_machine_stack.size * sizeof(VALUE)); -#endif - } - else { - rb_bug("terminated fiber resumed"); - } - } - terminated_machine_stack.ptr = NULL; - terminated_machine_stack.size = 0; - } - fiber = th->ec->fiber_ptr; + + /* Raise an exception if that was the result of executing the fiber */ if (fiber->cont.argc == -1) rb_exc_raise(fiber->cont.value); + return fiber->cont.value; } @@ -1516,7 +1764,13 @@ fiber_switch(rb_fiber_t *fiber, int argc, const VALUE *argv, int is_resume) cont->argc = argc; cont->value = make_passing_arg(argc, argv); + value = fiber_store(fiber, th); + + if (is_resume && FIBER_TERMINATED_P(fiber)) { + fiber_stack_release(fiber); + } + RUBY_VM_CHECK_INTS(th->ec); EXEC_EVENT_HOOK(th->ec, RUBY_EVENT_FIBER_SWITCH, th->self, 0, 0, 0, Qnil); @@ -1533,44 +1787,27 @@ rb_fiber_transfer(VALUE fiber_value, int argc, const VALUE *argv) void rb_fiber_close(rb_fiber_t *fiber) { - rb_execution_context_t *ec = &fiber->cont.saved_ec; - VALUE *vm_stack = ec->vm_stack; - size_t stack_bytes = ec->vm_stack_size * sizeof(VALUE); - fiber_status_set(fiber, FIBER_TERMINATED); - if (fiber->cont.free_vm_stack) { - if (stack_bytes == rb_ec_vm_ptr(ec)->default_params.thread_vm_stack_size) { - rb_thread_recycle_stack_release(vm_stack); - } - else { - ruby_xfree(vm_stack); - } - } - - rb_ec_clear_vm_stack(ec); + fiber_stack_release(fiber); } static void rb_fiber_terminate(rb_fiber_t *fiber, int need_interrupt) { VALUE value = fiber->cont.value; - rb_fiber_t *ret_fiber; + rb_fiber_t *next_fiber; VM_ASSERT(FIBER_RESUMED_P(fiber)); rb_fiber_close(fiber); coroutine_destroy(&fiber->context); - /* Ruby must not switch to other thread until storing terminated_machine_stack */ - terminated_machine_stack.ptr = fiber->ss_sp; - terminated_machine_stack.size = fiber->ss_size / sizeof(VALUE); - fiber->ss_sp = NULL; fiber->cont.machine.stack = NULL; fiber->cont.machine.stack_size = 0; - ret_fiber = return_fiber(); - if (need_interrupt) RUBY_VM_SET_INTERRUPT(&ret_fiber->cont.saved_ec); - fiber_switch(ret_fiber, 1, &value, 0); + next_fiber = return_fiber(); + if (need_interrupt) RUBY_VM_SET_INTERRUPT(&next_fiber->cont.saved_ec); + fiber_switch(next_fiber, 1, &value, 0); } VALUE @@ -1792,6 +2029,74 @@ rb_fiber_atfork(rb_thread_t *th) } #endif +#ifdef RB_EXPERIMENTAL_FIBER_POOL +static void +fiber_pool_free(void *ptr) +{ + struct fiber_pool * fiber_pool = ptr; + RUBY_FREE_ENTER("fiber_pool"); + + fiber_pool_free_allocations(fiber_pool->allocations); + ruby_xfree(fiber_pool); + + RUBY_FREE_LEAVE("fiber_pool"); +} + +static size_t +fiber_pool_memsize(const void *ptr) +{ + const struct fiber_pool * fiber_pool = ptr; + size_t size = sizeof(*fiber_pool); + + size += fiber_pool->count * fiber_pool->size; + + return size; +} + +static const rb_data_type_t FiberPoolDataType = { + "fiber_pool", + {NULL, fiber_pool_free, fiber_pool_memsize,}, + 0, 0, RUBY_TYPED_FREE_IMMEDIATELY +}; + +static VALUE +fiber_pool_alloc(VALUE klass) +{ + struct fiber_pool * fiber_pool = RB_ALLOC(struct fiber_pool); + + return TypedData_Wrap_Struct(klass, &FiberPoolDataType, fiber_pool); +} + +static VALUE +rb_fiber_pool_initialize(int argc, VALUE* argv, VALUE self) +{ + rb_thread_t *th = GET_THREAD(); + VALUE size = Qnil, count = Qnil, vm_stack_size = Qnil; + struct fiber_pool * fiber_pool = NULL; + + // Maybe these should be keyworkd arguments. + rb_scan_args(argc, argv, "03", &size, &count, &vm_stack_size); + + if (NIL_P(size)) { + size = INT2NUM(th->vm->default_params.fiber_machine_stack_size); + } + + if (NIL_P(count)) { + count = INT2NUM(128); + } + + if (NIL_P(vm_stack_size)) { + vm_stack_size = INT2NUM(th->vm->default_params.fiber_vm_stack_size); + } + + TypedData_Get_Struct(self, struct fiber_pool, &FiberPoolDataType, fiber_pool); + + fiber_pool_initialize(fiber_pool, NUM2SIZET(size), NUM2SIZET(count), NUM2SIZET(vm_stack_size)); + + return self; +} +#endif + /* * Document-class: FiberError * @@ -1809,6 +2114,9 @@ void Init_Cont(void) { rb_thread_t *th = GET_THREAD(); + size_t vm_stack_size = th->vm->default_params.fiber_vm_stack_size; + size_t machine_stack_size = th->vm->default_params.fiber_machine_stack_size; + size_t stack_size = machine_stack_size + vm_stack_size; #ifdef _WIN32 SYSTEM_INFO info; @@ -1819,15 +2127,23 @@ Init_Cont(void) #endif SET_MACHINE_STACK_END(&th->ec->machine.stack_end); + fiber_pool_initialize(&shared_fiber_pool, stack_size, 8, vm_stack_size); + rb_cFiber = rb_define_class("Fiber", rb_cObject); rb_define_alloc_func(rb_cFiber, fiber_alloc); rb_eFiberError = rb_define_class("FiberError", rb_eStandardError); rb_define_singleton_method(rb_cFiber, "yield", rb_fiber_s_yield, -1); - rb_define_method(rb_cFiber, "initialize", rb_fiber_init, 0); + rb_define_method(rb_cFiber, "initialize", rb_fiber_initialize, -1); rb_define_method(rb_cFiber, "resume", rb_fiber_m_resume, -1); rb_define_method(rb_cFiber, "raise", rb_fiber_raise, -1); rb_define_method(rb_cFiber, "to_s", fiber_to_s, 0); rb_define_alias(rb_cFiber, "inspect", "to_s"); + +#ifdef RB_EXPERIMENTAL_FIBER_POOL + rb_cFiberPool = rb_define_class("Pool", rb_cFiber); + rb_define_alloc_func(rb_cFiberPool, fiber_pool_alloc); + rb_define_method(rb_cFiberPool, "initialize", rb_fiber_pool_initialize, -1); +#endif } RUBY_SYMBOL_EXPORT_BEGIN From 8779382da44723438eb6cae23bd7267990157433 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Thu, 20 Jun 2019 00:13:49 +1200 Subject: [PATCH 258/452] Remove unused vm_stack recycling. --- vm.c | 36 ------------------------------------ 1 file changed, 36 deletions(-) diff --git a/vm.c b/vm.c index 939c0fc6fffc3b..f678a16ba5a683 100644 --- a/vm.c +++ b/vm.c @@ -2438,42 +2438,6 @@ vm_init2(rb_vm_t *vm) vm_default_params_setup(vm); } -/* Thread */ - -#define USE_THREAD_DATA_RECYCLE 1 - -#if USE_THREAD_DATA_RECYCLE -#define RECYCLE_MAX 64 -static VALUE *thread_recycle_stack_slot[RECYCLE_MAX]; -static int thread_recycle_stack_count = 0; -#endif /* USE_THREAD_DATA_RECYCLE */ - -VALUE * -rb_thread_recycle_stack(size_t size) -{ -#if USE_THREAD_DATA_RECYCLE - if (thread_recycle_stack_count > 0) { - /* TODO: check stack size if stack sizes are variable */ - return thread_recycle_stack_slot[--thread_recycle_stack_count]; - } -#endif /* USE_THREAD_DATA_RECYCLE */ - return ALLOC_N(VALUE, size); -} - -void -rb_thread_recycle_stack_release(VALUE *stack) -{ - VM_ASSERT(stack != NULL); - -#if USE_THREAD_DATA_RECYCLE - if (thread_recycle_stack_count < RECYCLE_MAX) { - thread_recycle_stack_slot[thread_recycle_stack_count++] = stack; - return; - } -#endif - ruby_xfree(stack); -} - void rb_execution_context_update(const rb_execution_context_t *ec) { From 91aae651bf90be46773a246e4c46b9e221353fbd Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Thu, 27 Jun 2019 18:59:25 +1200 Subject: [PATCH 259/452] Stack copying implementation of coroutines. --- cont.c | 25 ++++++- coroutine/copy/Context.c | 141 +++++++++++++++++++++++++++++++++++++++ coroutine/copy/Context.h | 79 ++++++++++++++++++++++ 3 files changed, 243 insertions(+), 2 deletions(-) create mode 100644 coroutine/copy/Context.c create mode 100644 coroutine/copy/Context.h diff --git a/cont.c b/cont.c index 51f0a3a3d7bd53..9ebc2c1a1f29d5 100644 --- a/cont.c +++ b/cont.c @@ -17,6 +17,9 @@ #ifdef FIBER_USE_COROUTINE #include FIBER_USE_COROUTINE +#else +// Stack copying implementation, should work everywhere: +#include "coroutine/copy/Context.h" #endif #ifndef _WIN32 @@ -448,8 +451,9 @@ fiber_entry(struct coroutine_context * from, struct coroutine_context * to) rb_fiber_start(); } +// Initialize a fiber's coroutine's machine stack and vm stack. static VALUE * -fiber_initialize_machine_stack_context(rb_fiber_t *fiber, size_t * vm_stack_size) +fiber_initialize_coroutine(rb_fiber_t *fiber, size_t * vm_stack_size) { struct fiber_pool * fiber_pool = fiber->stack.pool; rb_execution_context_t *sec = &fiber->cont.saved_ec; @@ -463,10 +467,22 @@ fiber_initialize_machine_stack_context(rb_fiber_t *fiber, size_t * vm_stack_size vm_stack = fiber_pool_stack_alloca(&fiber->stack, fiber_pool->vm_stack_size); *vm_stack_size = fiber_pool->vm_stack_size; +#ifdef COROUTINE_PRIVATE_STACK + coroutine_initialize(&fiber->context, fiber_entry, fiber_pool_stack_base(&fiber->stack), fiber->stack.available, sec->machine.stack_start); + // The stack for this execution context is still the main machine stack, so don't adjust it. + // If this is not managed correctly, you will fail in `rb_ec_stack_check`. + + // We limit the machine stack usage to the fiber stack size. + if (sec->machine.stack_maxsize > fiber->stack.available) { + sec->machine.stack_maxsize = fiber->stack.available; + } +#else coroutine_initialize(&fiber->context, fiber_entry, fiber_pool_stack_base(&fiber->stack), fiber->stack.available); + // The stack for this execution context is the one we allocated: sec->machine.stack_start = fiber->stack.current; sec->machine.stack_maxsize = fiber->stack.available; +#endif return vm_stack; } @@ -1488,7 +1504,7 @@ fiber_prepare_stack(rb_fiber_t *fiber) rb_execution_context_t *sec = &cont->saved_ec; size_t vm_stack_size = 0; - VALUE *vm_stack = fiber_initialize_machine_stack_context(fiber, &vm_stack_size); + VALUE *vm_stack = fiber_initialize_coroutine(fiber, &vm_stack_size); /* initialize cont */ cont->saved_vm_stack.ptr = NULL; @@ -1578,7 +1594,12 @@ root_fiber_alloc(rb_thread_t *th) DATA_PTR(fiber_value) = fiber; fiber->cont.self = fiber_value; +#ifdef COROUTINE_PRIVATE_STACK + fiber->stack = fiber_pool_stack_acquire(&shared_fiber_pool); + coroutine_initialize_main(&fiber->context, fiber_pool_stack_base(&fiber->stack), fiber->stack.available, th->ec->machine.stack_start); +#else coroutine_initialize_main(&fiber->context); +#endif return fiber; } diff --git a/coroutine/copy/Context.c b/coroutine/copy/Context.c new file mode 100644 index 00000000000000..a1b8a7120037fe --- /dev/null +++ b/coroutine/copy/Context.c @@ -0,0 +1,141 @@ +/* + * This file is part of the "Coroutine" project and released under the MIT License. + * + * Created by Samuel Williams on 24/6/2019. + * Copyright, 2019, by Samuel Williams. All rights reserved. +*/ + +#include "Context.h" + +// http://gcc.gnu.org/onlinedocs/gcc/Alternate-Keywords.html +#ifndef __GNUC__ +#define __asm__ asm +#endif + +#if defined(__sparc) +__attribute__((noinline)) +// https://marc.info/?l=linux-sparc&m=131914569320660&w=2 +static void coroutine_flush_register_windows() { + __asm__ +#ifdef __GNUC__ + __volatile__ +#endif +#if defined(__sparcv9) || defined(__sparc_v9__) || defined(__arch64__) +#ifdef __GNUC__ + ("flushw" : : : "%o7") +#else + ("flushw") +#endif +#else + ("ta 0x03") +#endif + ; +} +#else +static void coroutine_flush_register_windows() {} +#endif + +int coroutine_save_stack(struct coroutine_context * context) { + void *stack_pointer = &stack_pointer; + + assert(context->stack); + assert(context->base); + + // At this point, you may need to ensure on architectures that use register windows, that all registers are flushed to the stack. + coroutine_flush_register_windows(); + + // Save stack to private area: + if (stack_pointer < context->base) { + size_t size = (char*)context->base - (char*)stack_pointer; + assert(size <= context->size); + + memcpy(context->stack, stack_pointer, size); + context->used = size; + } else { + size_t size = (char*)stack_pointer - (char*)context->base; + assert(size <= context->size); + + memcpy(context->stack, context->base, size); + context->used = size; + } + + // Save registers / restore point: + return _setjmp(context->state); +} + +__attribute__((noreturn, noinline)) +static void coroutine_restore_stack_padded(struct coroutine_context *context, void * buffer) { + void *stack_pointer = &stack_pointer; + + assert(context->base); + + // Restore stack from private area: + if (stack_pointer < context->base) { + void * bottom = (char*)context->base - context->used; + assert(bottom > stack_pointer); + + memcpy(bottom, context->stack, context->used); + } else { + void * top = (char*)context->base + context->used; + assert(top < stack_pointer); + + memcpy(context->base, context->stack, context->used); + } + + // Restore registers: + // The `| (int)buffer` is to force the compiler NOT to elide he buffer and `alloca`. + _longjmp(context->state, 1 | (int)buffer); +} + +static const size_t GAP = 128; + +// In order to swap between coroutines, we need to swap the stack and registers. +// `setjmp` and `longjmp` are able to swap registers, but what about swapping stacks? You can use `memcpy` to copy the current stack to a private area and `memcpy` to copy the private stack of the next coroutine to the main stack. +// But if the stack yop are copying in to the main stack is bigger than the currently executing stack, the `memcpy` will clobber the current stack frame (including the context argument). So we use `alloca` to push the current stack frame *beyond* the stack we are about to copy in. This ensures the current stack frame in `coroutine_restore_stack_padded` remains valid for calling `longjmp`. +__attribute__((noreturn)) +void coroutine_restore_stack(struct coroutine_context *context) { + void *stack_pointer = &stack_pointer; + void *buffer = NULL; + ssize_t offset = 0; + + // We must ensure that the next stack frame is BEYOND the stack we are restoring: + if (stack_pointer < context->base) { + offset = (char*)stack_pointer - ((char*)context->base - context->used) + GAP; + if (offset > 0) buffer = alloca(offset); + } else { + offset = ((char*)context->base + context->used) - (char*)stack_pointer + GAP; + if (offset > 0) buffer = alloca(offset); + } + + assert(context->used > 0); + + coroutine_restore_stack_padded(context, buffer); +} + +struct coroutine_context *coroutine_transfer(struct coroutine_context *current, struct coroutine_context *target) +{ + struct coroutine_context *previous = target->from; + + // In theory, either this condition holds true, or we should assign the base address to target: + assert(current->base == target->base); + // If you are trying to copy the coroutine to a different thread + // target->base = current->base + + target->from = current; + + assert(current != target); + + // It's possible to come here, even thought the current fiber has been terminated. We are never going to return so we don't bother saving the stack. + + if (current->stack) { + if (coroutine_save_stack(current) == 0) { + coroutine_restore_stack(target); + } + } else { + coroutine_restore_stack(target); + } + + target->from = previous; + + return target; +} diff --git a/coroutine/copy/Context.h b/coroutine/copy/Context.h new file mode 100644 index 00000000000000..a62efa4e8a7697 --- /dev/null +++ b/coroutine/copy/Context.h @@ -0,0 +1,79 @@ +/* + * This file is part of the "Coroutine" project and released under the MIT License. + * + * Created by Samuel Williams on 27/6/2019. + * Copyright, 2019, by Samuel Williams. All rights reserved. +*/ + +#pragma once + +#include +#include +#include +#include +#include +#include + +#define COROUTINE __attribute__((noreturn)) void + +// This stack copying implementation which uses a private stack for each coroutine, including the main one. +#define COROUTINE_PRIVATE_STACK + +struct coroutine_context +{ + // Private stack: + void *stack; + size_t size, used; + + // The top (or bottom) of the currently executing stack: + void *base; + + jmp_buf state; + + struct coroutine_context *from; +}; + +typedef COROUTINE(*coroutine_start)(struct coroutine_context *from, struct coroutine_context *self); + +int coroutine_save_stack(struct coroutine_context * context); +COROUTINE coroutine_restore_stack(struct coroutine_context *context); + +// @param stack The private stack area memory allocation (pointer to lowest address). +// @param size The size of the private stack area. +// @param base A stack pointer to the base of the main stack. On x86 hardware, this is the upper extent of the region that will be copied to the private stack. +static inline void coroutine_initialize_main(struct coroutine_context *context, void *stack, size_t size, void *base) { + context->stack = stack; + context->size = size; + context->used = 0; + + assert(base); + context->base = base; + + context->from = NULL; +} + +// @param start The start function to invoke. +static inline void coroutine_initialize( + struct coroutine_context *context, + coroutine_start start, + void *stack, + size_t size, + void *base +) { + assert(start && stack && size >= 1024); + + coroutine_initialize_main(context, stack, size, base); + + if (coroutine_save_stack(context)) { + start(context->from, context); + } +} + +struct coroutine_context *coroutine_transfer(struct coroutine_context *current, register struct coroutine_context *target); + +static inline void coroutine_destroy(struct coroutine_context *context) +{ + context->stack = NULL; + context->size = 0; + context->from = NULL; +} From 7291fef55c90b9ab6b3c22018b16972861b98c9d Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Sat, 29 Jun 2019 13:07:07 +1200 Subject: [PATCH 260/452] Improve build process and coroutine implementation selection. --- common.mk | 3 +-- configure.ac | 58 +++++++++++++++++++++++++------------------- cont.c | 7 +----- template/Makefile.in | 3 ++- win32/Makefile.sub | 26 ++++++++++---------- 5 files changed, 50 insertions(+), 47 deletions(-) diff --git a/common.mk b/common.mk index b40a8e0fa47e3e..7416d01a663cf1 100644 --- a/common.mk +++ b/common.mk @@ -924,9 +924,8 @@ strlcpy.$(OBJEXT): {$(VPATH)}strlcpy.c strstr.$(OBJEXT): {$(VPATH)}strstr.c nt.$(OBJEXT): {$(VPATH)}nt.c -COROUTINE_SRC = $(COROUTINE_H:.h=).$(ASMEXT) .coroutine_obj $(COROUTINE_OBJ): \ - {$(VPATH)}$(COROUTINE_SRC:/ucontext/Context.S=/ucontext/Context.c) \ + {$(VPATH)}$(COROUTINE_SRC) \ $(COROUTINE_H:/Context.h=/.time) $(COROUTINE_H:/Context.h=/.time): $(Q) $(MAKEDIRS) $(@D) diff --git a/configure.ac b/configure.ac index bc678cdc2d876b..9703591af7eed9 100644 --- a/configure.ac +++ b/configure.ac @@ -964,7 +964,7 @@ main() AS_IF([test "$target_cpu" = x64], [ ac_cv_func___builtin_setjmp=yes ac_cv_func_round=no - rb_cv_fiber_coroutine=yes + rb_cv_coroutine=yes ]) ac_cv_func_tgamma=no rb_cv_negative_time_t=yes @@ -2251,60 +2251,67 @@ AS_IF([test "${universal_binary-no}" = yes ], [ AC_DEFINE_UNQUOTED(STACK_GROW_DIRECTION, $dir) ]) -AC_ARG_ENABLE(fiber-coroutine, - AS_HELP_STRING([--disable-fiber-coroutine], [disable native coroutine implementation for fiber]), - [rb_cv_fiber_coroutine=$enableval]) -AS_CASE(["$rb_cv_fiber_coroutine"], [yes|''], [ +AC_ARG_WITH(coroutine, + AS_HELP_STRING([--with-coroutine=IMPLEMENTATION], [specify the coroutine implementation to use]), + [rb_cv_coroutine=$withval]) +AS_CASE([$rb_cv_coroutine], [yes|''], [ AC_MSG_CHECKING(native coroutine implementation for ${target_cpu}-${target_os}) AS_CASE(["$target_cpu-$target_os"], [x*64-darwin*], [ - rb_cv_fiber_coroutine=amd64 + rb_cv_coroutine=amd64 ], [x*64-linux], [ AS_CASE(["$ac_cv_sizeof_voidp"], - [8], [ rb_cv_fiber_coroutine=amd64 ], - [4], [ rb_cv_fiber_coroutine=x86 ], - [*], [ rb_cv_fiber_coroutine= ] + [8], [ rb_cv_coroutine=amd64 ], + [4], [ rb_cv_coroutine=x86 ], + [*], [ rb_cv_coroutine= ] ) ], [*86-linux], [ - rb_cv_fiber_coroutine=x86 + rb_cv_coroutine=x86 ], [x64-mingw32], [ - rb_cv_fiber_coroutine=win64 + rb_cv_coroutine=win64 ], [*86-mingw32], [ - rb_cv_fiber_coroutine=win32 + rb_cv_coroutine=win32 ], [armv7*-linux-*], [ - rb_cv_fiber_coroutine=ucontext + rb_cv_coroutine=ucontext ], [aarch64-linux], [ - rb_cv_fiber_coroutine=arm64 + rb_cv_coroutine=arm64 ], [powerpc64le-linux], [ - rb_cv_fiber_coroutine=ppc64le + rb_cv_coroutine=ppc64le ], [x86_64-openbsd*], [ - rb_cv_fiber_coroutine=amd64 + rb_cv_coroutine=amd64 ], [i386-openbsd*], [ - rb_cv_fiber_coroutine=x86 + rb_cv_coroutine=x86 ], [*-openbsd*], [ - rb_cv_fiber_coroutine= + rb_cv_coroutine=copy ], [*], [ - rb_cv_fiber_coroutine=ucontext + rb_cv_coroutine=ucontext ] ) - AC_MSG_RESULT(${rb_cv_fiber_coroutine:-no}) -]) -AS_IF([test "${rb_cv_fiber_coroutine:-no}" != no], [ - COROUTINE_H=coroutine/$rb_cv_fiber_coroutine/Context.h - AC_DEFINE_UNQUOTED(FIBER_USE_COROUTINE, ["$COROUTINE_H"]) - AC_SUBST(X_FIBER_COROUTINE_H, [$COROUTINE_H]) + AC_MSG_RESULT(${rb_cv_coroutine}) ]) +COROUTINE_H=coroutine/$rb_cv_coroutine/Context.h +AS_CASE([$rb_cv_coroutine], + [copy|ucontext], [ + COROUTINE_SRC=coroutine/$rb_cv_coroutine/Context.c + ], + [*], [ + COROUTINE_SRC=coroutine/$rb_cv_coroutine/Context.'$(ASMEXT)' + ], +) +AC_DEFINE_UNQUOTED(COROUTINE_H, ["$COROUTINE_H"]) +AC_SUBST(X_COROUTINE_H, [$COROUTINE_H]) +AC_SUBST(X_COROUTINE_SRC, [$COROUTINE_SRC]) AS_IF([test x"$enable_pthread" = xyes], [ for pthread_lib in thr pthread pthreads c c_r root; do @@ -4009,6 +4016,7 @@ config_summary "vendor path" "$vendordir" config_summary "target OS" "$target_os" config_summary "compiler" "$CC" config_summary "with pthread" "$enable_pthread" +config_summary "with coroutine" "$rb_cv_coroutine" config_summary "enable shared libs" "$ENABLE_SHARED" config_summary "dynamic library ext" "$DLEXT" config_summary "CFLAGS" "$cflags" diff --git a/cont.c b/cont.c index 9ebc2c1a1f29d5..c4de4a0c42af17 100644 --- a/cont.c +++ b/cont.c @@ -15,12 +15,7 @@ #include "eval_intern.h" #include "mjit.h" -#ifdef FIBER_USE_COROUTINE -#include FIBER_USE_COROUTINE -#else -// Stack copying implementation, should work everywhere: -#include "coroutine/copy/Context.h" -#endif +#include COROUTINE_H #ifndef _WIN32 #include diff --git a/template/Makefile.in b/template/Makefile.in index 110071de6a9637..eae67a5d050407 100644 --- a/template/Makefile.in +++ b/template/Makefile.in @@ -152,8 +152,9 @@ XRUBY_RUBYLIBDIR = @XRUBY_RUBYLIBDIR@ XRUBY_RUBYHDRDIR = @XRUBY_RUBYHDRDIR@ BOOTSTRAPRUBY = @BOOTSTRAPRUBY@ -COROUTINE_H = @X_FIBER_COROUTINE_H@ +COROUTINE_H = @X_COROUTINE_H@ COROUTINE_OBJ = $(COROUTINE_H:.h=.@OBJEXT@) +COROUTINE_SRC = @X_COROUTINE_SRC@ #### End of system configuration section. #### diff --git a/win32/Makefile.sub b/win32/Makefile.sub index d79a16bddb9eb0..a990a557ea1527 100644 --- a/win32/Makefile.sub +++ b/win32/Makefile.sub @@ -290,19 +290,18 @@ MISSING = $(MISSING) acosh.obj cbrt.obj erf.obj nan.obj tgamma.obj MISSING = $(MISSING) explicit_bzero.obj !endif DLNOBJ = dln.obj + !if "$(ARCH)" == "x64" -COROUTINE_OBJ = coroutine/Win64/Context.obj +COROUTINE_OBJ = coroutine/win64/Context.obj +COROUTINE_SRC = $(COROUTINE_OBJ:.obj=.asm) !elseif "$(ARCH)" == "i386" -COROUTINE_OBJ = coroutine/Win32/Context.obj +COROUTINE_OBJ = coroutine/win32/Context.obj +COROUTINE_SRC = $(COROUTINE_OBJ:.obj=.asm) !else -COROUTINE_OBJ = +COROUTINE_OBJ = coroutine/copy/Context.obj +COROUTINE_SRC = $(COROUTINE_OBJ:.obj=.c) !endif -!if "$(COROUTINE_OBJ)" == "" -# get rid of empty value not to leave VPATH only in dependencies -COROUTINE_H = coroutine/Win32/Context.h -!else COROUTINE_H = $(COROUTINE_OBJ:.obj=.h) -!endif ARFLAGS = -machine:$(MACHINE) -out: LD = $(CC) @@ -871,9 +870,7 @@ $(CONFIG_H): $(MKFILES) $(srcdir)/win32/Makefile.sub $(win_srcdir)/Makefile.sub !if "$(MACHINE)" == "x86" || "$(ARCH)" == "x64" #define STACK_GROW_DIRECTION -1 !endif -!if "$(COROUTINE_OBJ)" != "" -#define FIBER_USE_COROUTINE "$(COROUTINE_H)" -!endif +#define COROUTINE_H "$(COROUTINE_H)" #define DEFAULT_KCODE KCODE_NONE #define LOAD_RELATIVE 1 #define DLEXT ".so" @@ -1235,12 +1232,15 @@ $(ruby_pc): $(RBCONFIG) -output=$@ -mode=$(INSTALL_DATA_MODE) -config=rbconfig.rb \ $(srcdir)/template/ruby.pc.in -{$(srcdir)/coroutine/Win32}.asm{coroutine/Win32}.obj: +{$(srcdir)/coroutine/win32}.asm{coroutine/win32}.obj: $(ECHO) assembling $(<:\=/) $(Q) $(AS) $(ASFLAGS) $(XCFLAGS) $(CPPFLAGS) $(COUTFLAG)$@ -c $(<:\=/) -{$(srcdir)/coroutine/Win64}.asm{coroutine/Win64}.obj: +{$(srcdir)/coroutine/win64}.asm{coroutine/win64}.obj: $(ECHO) assembling $(<:\=/) $(Q) $(AS) $(ASFLAGS) $(XCFLAGS) $(CPPFLAGS) $(COUTFLAG)$@ -c $(<:\=/) +{$(srcdir)/coroutine/copy}.c{coroutine/copy}.obj: + $(ECHO) compiling $(<:\=/) + $(Q) $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$(<:\=/) {$(srcdir)/enc/trans}.c.obj: $(ECHO) compiling $(<:\=/) From b8242bce2301e33d3ba1fae95b68a291cc3004b5 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Sun, 30 Jun 2019 00:21:19 +1200 Subject: [PATCH 261/452] Add `ucontext` and `copy` coroutine implementations to test matrix. --- .travis.yml | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index f6822b913d5fa0..4db6d0a48b0ddf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -156,12 +156,19 @@ env: - GEMS_FOR_TEST= - cppflags=-DVM_CHECK_MODE=0x0003 - - &FIBER_USE_sjlj - name: FIBER_USE_NATIVE=0 + - &WITH_COROUTINE_UCONTEXT + name: COROUTINE=ucontext <<: *linux - <<: *cron-only + # <<: *cron-only + env: + - CONFIG_FLAG='--with-coroutine=ucontext' + + - &WITH_COROUTINE_COPY + name: COROUTINE=copy + <<: *linux + # <<: *cron-only env: - - cppflags=-DFIBER_USE_NATIVE=0 + - CONFIG_FLAG='--with-coroutine=copy' - &TOKEN_THREADED_CODE name: TOKEN_THREADED_CODE @@ -385,7 +392,8 @@ matrix: - <<: *UBSAN - <<: *assertions - <<: *VM_CHECK_MODE - - <<: *FIBER_USE_sjlj + - <<: *WITH_COROUTINE_UCONTEXT + - <<: *WITH_COROUTINE_COPY - <<: *TOKEN_THREADED_CODE - <<: *CALL_THREADED_CODE - <<: *NO_THREADED_CODE From 47c0cab248ca09deb9508ff29edfd1dfc11b5f31 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Mon, 1 Jul 2019 16:24:39 +1200 Subject: [PATCH 262/452] Add details of fiber pool and coroutine selection to NEWS. --- NEWS | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/NEWS b/NEWS index 4b6e756ab5922a..3f841a69391435 100644 --- a/NEWS +++ b/NEWS @@ -259,6 +259,19 @@ profile.rb, Profiler__:: === Implementation improvements +Fiber:: + + * Allow selecting different coroutine implementation by using + `--with-coroutine=`, e.g. + + ./confgure --with-coroutine=ucontext + ./confgure --with-coroutine=copy + + * Replace previous stack cache with fiber pool cache. The fiber pool + allocates many stacks in a single memory region. Stack allocation + becomes O(log N) and fiber creation is amortized O(1). Around 10x + performance improvement was measured in micro-benchmarks. + Thread:: * VM stack memory allocation is now combined with native thread stack, From 77f3319071e600a2aafaa9863b892dfd3c1da343 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Thu, 11 Jul 2019 19:17:34 +1200 Subject: [PATCH 263/452] Enable `madvise` to release stack space back to OS. --- cont.c | 240 ++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 142 insertions(+), 98 deletions(-) diff --git a/cont.c b/cont.c index c4de4a0c42af17..2ca7569e89fc38 100644 --- a/cont.c +++ b/cont.c @@ -232,78 +232,136 @@ fiber_pool_vacancy_pointer(void * base, size_t size) ); } +// Reset the current stack pointer and available size of the given stack. +inline static void +fiber_pool_stack_reset(struct fiber_pool_stack * stack) +{ + STACK_GROW_DIR_DETECTION; + + stack->current = (char*)stack->base + STACK_DIR_UPPER(0, stack->size); + stack->available = stack->size; +} + +// A pointer to the base of the current unused portion of the stack. +inline static void * +fiber_pool_stack_base(struct fiber_pool_stack * stack) +{ + STACK_GROW_DIR_DETECTION; + + return STACK_DIR_UPPER(stack->current, (char*)stack->current - stack->available); +} + +// Allocate some memory from the stack. Used to allocate vm_stack inline with machine stack. +// @sa fiber_initialize_coroutine +inline static void * +fiber_pool_stack_alloca(struct fiber_pool_stack * stack, size_t offset) +{ + STACK_GROW_DIR_DETECTION; + + VM_ASSERT(stack->available >= offset); + + // The pointer to the memory being allocated: + void * pointer = STACK_DIR_UPPER(stack->current, (char*)stack->current - offset); + + // Move the stack pointer: + stack->current = STACK_DIR_UPPER((char*)stack->current + offset, (char*)stack->current - offset); + stack->available -= offset; + + return pointer; +} + +// Reset the current stack pointer and available size of the given stack. +inline static void +fiber_pool_vacancy_reset(struct fiber_pool_vacancy * vacancy) +{ + fiber_pool_stack_reset(&vacancy->stack); + + // Consume one page of the stack because it's used for the vacancy list: + fiber_pool_stack_alloca(&vacancy->stack, RB_PAGE_SIZE); +} + +// Initialize the vacant stack. The [base, size] allocation should not include the guard page. +// @param base The pointer to the lowest address of the allocated memory. +// @param size The size of the allocated memory. +inline static struct fiber_pool_vacancy * +fiber_pool_vacancy_initialize(struct fiber_pool * fiber_pool, struct fiber_pool_vacancy * vacancies, void * base, size_t size) +{ + struct fiber_pool_vacancy * vacancy = fiber_pool_vacancy_pointer(base, size); + + vacancy->stack.base = base; + vacancy->stack.size = size; + + fiber_pool_vacancy_reset(vacancy); + + vacancy->stack.pool = fiber_pool; + vacancy->next = vacancies; + + return vacancy; +} + // Given an existing fiber pool, expand it by the specified number of stacks. static struct fiber_pool_allocation * fiber_pool_expand(struct fiber_pool * fiber_pool, size_t count) { + STACK_GROW_DIR_DETECTION; + size_t i; struct fiber_pool_vacancy * vacancies = fiber_pool->vacancies; struct fiber_pool_allocation * allocation = RB_ALLOC(struct fiber_pool_allocation); size_t size = fiber_pool->size; - /* Initialize fiber pool */ + // The size of stack including guard page: + size_t stride = size + RB_PAGE_SIZE; + + // Initialize fiber pool allocation: allocation->base = NULL; allocation->size = size; allocation->count = count; if (DEBUG) fprintf(stderr, "fiber_pool_expand(%zu): %p, %zu/%zu x [%zu:%zu]\n", count, fiber_pool, fiber_pool->used, fiber_pool->count, size, fiber_pool->vm_stack_size); -#ifdef _WIN32 - DWORD old_protect; - - allocation->base = VirtualAlloc(0, count*size, MEM_COMMIT, PAGE_READWRITE); + // Allocate the memory required for the stacks: +#if defined(_WIN32) + allocation->base = VirtualAlloc(0, count*stride, MEM_COMMIT, PAGE_READWRITE); if (!allocation->base) { rb_raise(rb_eFiberError, "can't alloc machine stack to fiber (%zu x %zu bytes): %s", count, size, ERRNOMSG); } - - for (i = 0; i < count; i += 1) { - void * base = (char*)allocation->base + (size * i); - - if (!VirtualProtect(base, RB_PAGE_SIZE, PAGE_READWRITE | PAGE_GUARD, &old_protect)) { - VirtualFree(allocation->base, 0, MEM_RELEASE); - rb_raise(rb_eFiberError, "can't set a guard page: %s", ERRNOMSG); - } - - struct fiber_pool_vacancy * vacancy = fiber_pool_vacancy_pointer(base, size); - vacancy->stack.base = base; - vacancy->stack.current = (char*)base + size; - vacancy->stack.size = size; - vacancy->stack.available = size - pagesize; - vacancy->stack.pool = fiber_pool; - vacancy->next = vacancies; - vacancies = vacancy; - } #else - STACK_GROW_DIR_DETECTION; - errno = 0; - allocation->base = mmap(NULL, count*size, PROT_READ | PROT_WRITE, FIBER_STACK_FLAGS, -1, 0); + allocation->base = mmap(NULL, count*stride, PROT_READ | PROT_WRITE, FIBER_STACK_FLAGS, -1, 0); if (allocation->base == MAP_FAILED) { rb_raise(rb_eFiberError, "can't alloc machine stack to fiber (%zu x %zu bytes): %s", count, size, ERRNOMSG); } +#endif + // Iterate over all stacks, initializing the vacancy list: for (i = 0; i < count; i += 1) { - void * base = (char*)allocation->base + (size * i); - void * page = (char*)base + STACK_DIR_UPPER(size - RB_PAGE_SIZE, 0); + void * base = (char*)allocation->base + (stride * i); + void * page = (char*)base + STACK_DIR_UPPER(size, 0); + +#if defined(_WIN32) + DWORD old_protect; + if (!VirtualProtect(page, RB_PAGE_SIZE, PAGE_READWRITE | PAGE_GUARD, &old_protect)) { + VirtualFree(allocation->base, 0, MEM_RELEASE); + rb_raise(rb_eFiberError, "can't set a guard page: %s", ERRNOMSG); + } +#else if (mprotect(page, RB_PAGE_SIZE, PROT_NONE) < 0) { - munmap(allocation->base, count*size); + munmap(allocation->base, count*stride); rb_raise(rb_eFiberError, "can't set a guard page: %s", ERRNOMSG); } +#endif - struct fiber_pool_vacancy * vacancy = fiber_pool_vacancy_pointer(base, size); - vacancy->stack.base = base; - vacancy->stack.current = (char*)base + STACK_DIR_UPPER(0, size); - vacancy->stack.size = size; - vacancy->stack.available = size - pagesize; - vacancy->stack.pool = fiber_pool; - vacancy->next = vacancies; - vacancies = vacancy; + vacancies = fiber_pool_vacancy_initialize( + fiber_pool, vacancies, + (char*)base + STACK_DIR_UPPER(0, RB_PAGE_SIZE), + size + ); } -#endif // Insert the allocation into the head of the pool: allocation->next = fiber_pool->allocations; @@ -355,44 +413,6 @@ fiber_pool_free_allocations(struct fiber_pool_allocation * allocation) } #endif -// Reset the current stack pointer and available size of the given stack. -inline static void -fiber_pool_stack_reset(struct fiber_pool_stack * stack) -{ - STACK_GROW_DIR_DETECTION; - - stack->current = (char*)stack->base + STACK_DIR_UPPER(0, stack->size); - stack->available = stack->size - RB_PAGE_SIZE; -} - -// A pointer to the base of the current unused portion of the stack. -inline static void * -fiber_pool_stack_base(struct fiber_pool_stack * stack) -{ - STACK_GROW_DIR_DETECTION; - - return STACK_DIR_UPPER(stack->current, (char*)stack->current - stack->available); -} - -// Allocate some memory from the stack. Used to allocate vm_stack inline with machine stack. -// @sa fiber_initialize_coroutine -inline static void * -fiber_pool_stack_alloca(struct fiber_pool_stack * stack, size_t offset) -{ - STACK_GROW_DIR_DETECTION; - - VM_ASSERT(stack->available >= offset); - - // The pointer to the memory being allocated: - void * pointer = STACK_DIR_UPPER(stack->current, (char*)stack->current - offset); - - // Move the stack pointer: - stack->current = STACK_DIR_UPPER((char*)stack->current + offset, (char*)stack->current - offset); - stack->available -= offset; - - return pointer; -} - // Acquire a stack from the given fiber pool. If none are avilable, allocate more. static struct fiber_pool_stack fiber_pool_stack_acquire(struct fiber_pool * fiber_pool) { @@ -421,18 +441,39 @@ fiber_pool_stack_acquire(struct fiber_pool * fiber_pool) { return vacancy->stack; } +// We advise the operating system that the stack memory pages are no longer being used. +// This introduce some performance overhead but allows system to relaim memory when there is pressure. +static inline void +fiber_pool_stack_free(struct fiber_pool_stack * stack) { + void * base = fiber_pool_stack_base(stack); + size_t size = stack->available - RB_PAGE_SIZE; + + if (DEBUG) fprintf(stderr, "fiber_pool_stack_free: %p+%zu [base=%p, size=%zu]\n", base, size, stack->base, stack->size); + +#if defined(MADV_FREE_REUSABLE) + madvise(base, size, MADV_FREE_REUSABLE); +#elif defined(MADV_FREE) + madvise(base, size, MADV_FREE); +#elif defined(MADV_DONTNEED) + madvise(base, size, MADV_DONTNEED); +#elif defined(_WIN32) + VirtualAlloc(base, size, MEM_RESET, PAGE_READWRITE); + // Not available in all versions of Windows. + //DiscardVirtualMemory(base, size); +#endif +} + // Release and return a stack to the vacancy list. static void fiber_pool_stack_release(struct fiber_pool_stack stack) { struct fiber_pool_vacancy * vacancy = fiber_pool_vacancy_pointer(stack.base, stack.size); -#if defined(MADV_FREE) && defined(__linux__) - // Using madvise can make physical memory available to OS when there is memory pressure. - // But bencmarks show that this approach makes performance worse. - // madvise(vacancy->stack.base, vacancy->stack.size - RB_PAGE_SIZE, MADV_FREE); -#endif - + // Copy the stack details into the vacancy area: vacancy->stack = stack; + fiber_pool_vacancy_reset(vacancy); + + fiber_pool_stack_free(&vacancy->stack); + vacancy->next = stack.pool->vacancies; stack.pool->vacancies = vacancy; stack.pool->used -= 1; @@ -482,6 +523,21 @@ fiber_initialize_coroutine(rb_fiber_t *fiber, size_t * vm_stack_size) return vm_stack; } +// Release the stack from the fiber, it's execution context, and return it to the fiber pool. +static void +fiber_stack_release(rb_fiber_t * fiber) +{ + rb_execution_context_t *ec = &fiber->cont.saved_ec; + + if (fiber->stack.base) { + fiber_pool_stack_release(fiber->stack); + fiber->stack.base = NULL; + } + + // The stack is no longer associated with this execution context: + rb_ec_clear_vm_stack(ec); +} + static const char * fiber_status_name(enum fiber_status s) { @@ -757,6 +813,8 @@ fiber_free(void *ptr) st_free_table(fiber->cont.saved_ec.local_storage); } + fiber_stack_release(fiber); + cont_free(&fiber->cont); RUBY_FREE_LEAVE("fiber"); } @@ -1031,7 +1089,7 @@ fiber_setcontext(rb_fiber_t *new_fiber, rb_fiber_t *old_fiber) { rb_thread_t *th = GET_THREAD(); - /* save old_fiber's machine stack / TODO: is it needed? */ + /* save old_fiber's machine stack - to ensure efficienct garbage collection */ if (!FIBER_TERMINATED_P(old_fiber)) { STACK_GROW_DIR_DETECTION; SET_MACHINE_STACK_END(&th->ec->machine.stack_end); @@ -1679,20 +1737,7 @@ rb_fiber_current(void) return fiber_current()->cont.self; } -static void -fiber_stack_release(rb_fiber_t * fiber) -{ - rb_execution_context_t *ec = &fiber->cont.saved_ec; - - if (fiber->stack.base) { - fiber_pool_stack_release(fiber->stack); - fiber->stack.base = NULL; - } - - // The stack is no longer associated with this execution context: - rb_ec_clear_vm_stack(ec); -} - +// Prepare to execute next_fiber on the given thread. static inline VALUE fiber_store(rb_fiber_t *next_fiber, rb_thread_t *th) { @@ -1804,7 +1849,6 @@ void rb_fiber_close(rb_fiber_t *fiber) { fiber_status_set(fiber, FIBER_TERMINATED); - fiber_stack_release(fiber); } static void From 8ac9a7be0fea95d9fc17cce53c0d18d70cc8d091 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Fri, 12 Jul 2019 13:42:34 +1200 Subject: [PATCH 264/452] Limit expansion of fiber pool on 32-bit platforms. On 32-bit platforms, expanding the fiber pool by a large amount may fail, even if a smaller amount may succeed. We limit the maximum size of a single allocation to maximise the number of fibers that can be allocated. Additionally, we implement the book-keeping required to free allocations when their usage falls to zero. --- cont.c | 196 +++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 150 insertions(+), 46 deletions(-) diff --git a/cont.c b/cont.c index 2ca7569e89fc38..d447b424c63bc5 100644 --- a/cont.c +++ b/cont.c @@ -61,17 +61,20 @@ struct fiber_pool_stack { // The current stack pointer, taking into account the direction of the stack. void * current; - // The size of the stack including any guard pages. + // The size of the stack excluding any guard pages. size_t size; // The available stack capacity w.r.t. the current stack offset. size_t available; - // The pool this stack is managed by. + // The pool this stack should be allocated from. struct fiber_pool * pool; + + // If the stack is allocated, the allocation it came from. + struct fiber_pool_allocation * allocation; }; -// A singly linked list of vacant (unused) stacks. +// A linked list of vacant (unused) stacks. // This structure is stored in the first page of a stack if it is not in use. // @sa fiber_pool_vacancy_pointer struct fiber_pool_vacancy { @@ -79,6 +82,7 @@ struct fiber_pool_vacancy { struct fiber_pool_stack stack; // The next vacancy in the linked list. + struct fiber_pool_vacancy * previous; struct fiber_pool_vacancy * next; }; @@ -113,13 +117,19 @@ struct fiber_pool_allocation { // The size of the individual stacks. size_t size; + // The stride of individual stacks (including any guard pages or other accounting details). + size_t stride; + // The number of stacks that were allocated. size_t count; // The number of stacks used in this allocation. - // size_t used; + size_t used; + + struct fiber_pool * pool; // The next allocation in the linked list. + struct fiber_pool_allocation * previous; struct fiber_pool_allocation * next; }; @@ -131,12 +141,15 @@ struct fiber_pool { // Provides O(1) stack "allocation": struct fiber_pool_vacancy * vacancies; - // The size of the stack allocations including guard page. + // The size of the stack allocations (excluding any guard page). size_t size; // The total number of stacks that have been allocated in this pool. size_t count; + // The initial number of stacks to allocate. + size_t initial_count; + // The number of stacks that have been used in this pool. size_t used; @@ -280,6 +293,42 @@ fiber_pool_vacancy_reset(struct fiber_pool_vacancy * vacancy) fiber_pool_stack_alloca(&vacancy->stack, RB_PAGE_SIZE); } +inline static struct fiber_pool_vacancy * +fiber_pool_vacancy_push(struct fiber_pool_vacancy * vacancy, struct fiber_pool_vacancy * head) { + vacancy->next = head; + + if (head) { + head->previous = vacancy; + } + + return vacancy; +} + +static void +fiber_pool_vacancy_remove(struct fiber_pool_vacancy * vacancy) { + if (vacancy->next) { + vacancy->next->previous = vacancy->previous; + } + + if (vacancy->previous) { + vacancy->previous->next = vacancy->next; + } else { + // It's the head of the list: + vacancy->stack.pool->vacancies = vacancy->next; + } +} + +inline static struct fiber_pool_vacancy * +fiber_pool_vacancy_pop(struct fiber_pool * pool) { + struct fiber_pool_vacancy * vacancy = pool->vacancies; + + if (vacancy) { + fiber_pool_vacancy_remove(vacancy); + } + + return vacancy; +} + // Initialize the vacant stack. The [base, size] allocation should not include the guard page. // @param base The pointer to the lowest address of the allocated memory. // @param size The size of the allocated memory. @@ -294,9 +343,8 @@ fiber_pool_vacancy_initialize(struct fiber_pool * fiber_pool, struct fiber_pool_ fiber_pool_vacancy_reset(vacancy); vacancy->stack.pool = fiber_pool; - vacancy->next = vacancies; - return vacancy; + return fiber_pool_vacancy_push(vacancy, vacancies); } // Given an existing fiber pool, expand it by the specified number of stacks. @@ -310,14 +358,15 @@ fiber_pool_expand(struct fiber_pool * fiber_pool, size_t count) struct fiber_pool_allocation * allocation = RB_ALLOC(struct fiber_pool_allocation); size_t size = fiber_pool->size; - - // The size of stack including guard page: size_t stride = size + RB_PAGE_SIZE; // Initialize fiber pool allocation: allocation->base = NULL; allocation->size = size; + allocation->stride = stride; allocation->count = count; + allocation->used = 0; + allocation->pool = fiber_pool; if (DEBUG) fprintf(stderr, "fiber_pool_expand(%zu): %p, %zu/%zu x [%zu:%zu]\n", count, fiber_pool, fiber_pool->used, fiber_pool->count, size, fiber_pool->vm_stack_size); @@ -361,10 +410,19 @@ fiber_pool_expand(struct fiber_pool * fiber_pool, size_t count) (char*)base + STACK_DIR_UPPER(0, RB_PAGE_SIZE), size ); + + vacancies->stack.allocation = allocation; } // Insert the allocation into the head of the pool: allocation->next = fiber_pool->allocations; + + if (allocation->next) { + allocation->next->previous = allocation; + } + + allocation->previous = NULL; + fiber_pool->allocations = allocation; fiber_pool->vacancies = vacancies; fiber_pool->count += count; @@ -372,6 +430,15 @@ fiber_pool_expand(struct fiber_pool * fiber_pool, size_t count) return allocation; } +static inline size_t +fiber_pool_default_allocation_count_limit() { + if (sizeof(void*) <= 4) { + return 32; + } else { + return 1024; + } +} + // Initialize the specified fiber pool with the given number of stacks. // @param vm_stack_size The size of the vm stack to allocate. static void @@ -382,7 +449,8 @@ fiber_pool_initialize(struct fiber_pool * fiber_pool, size_t size, size_t count, fiber_pool->allocations = NULL; fiber_pool->vacancies = NULL; fiber_pool->size = ((size / RB_PAGE_SIZE) + 1) * RB_PAGE_SIZE; - fiber_pool->count = count; + fiber_pool->count = 0; + fiber_pool->initial_count = count; fiber_pool->used = 0; fiber_pool->vm_stack_size = vm_stack_size; @@ -390,52 +458,78 @@ fiber_pool_initialize(struct fiber_pool * fiber_pool, size_t size, size_t count, fiber_pool_expand(fiber_pool, count); } -#ifdef RB_EXPERIMENTAL_FIBER_POOL // Free the list of fiber pool allocations. static void -fiber_pool_free_allocations(struct fiber_pool_allocation * allocation) +fiber_pool_allocation_free(struct fiber_pool_allocation * allocation) { - // If no stacks are being used, we can free this allocation: - // VM_ASSERT(allocation->used == 0); + STACK_GROW_DIR_DETECTION; + + VM_ASSERT(allocation->used == 0); + + if (DEBUG) fprintf(stderr, "fiber_pool_allocation_free: %p base=%p count=%zu\n", allocation, allocation->base, allocation->count); + + size_t i; + for (i = 0; i < allocation->count; i += 1) { + void * base = (char*)allocation->base + (allocation->stride * i) + STACK_DIR_UPPER(0, RB_PAGE_SIZE); + + struct fiber_pool_vacancy * vacancy = fiber_pool_vacancy_pointer(base, allocation->size); + + // Pop the vacant stack off the free list: + fiber_pool_vacancy_remove(vacancy); + } #ifdef _WIN32 - VirtualFree(allocation->base, 0, MEM_RELEASE); + VirtualFree(allocation->base, 0, MEM_RELEASE); #else - munmap(allocation->base, allocation->size * allocation->count); + munmap(allocation->base, allocation->stride * allocation->count); #endif - allocation->base = NULL; - if (allocation->next != NULL) { - fiber_pool_free_allocations(allocation->next); + if (allocation->previous) { + allocation->previous->next = allocation->next; + } else { + // We are the head of the list, so update the pool: + allocation->pool->allocations = allocation->next; + } + + if (allocation->next) { + allocation->next->previous = allocation->previous; } + allocation->pool->count -= allocation->count; + ruby_xfree(allocation); } -#endif // Acquire a stack from the given fiber pool. If none are avilable, allocate more. static struct fiber_pool_stack fiber_pool_stack_acquire(struct fiber_pool * fiber_pool) { - struct fiber_pool_vacancy * vacancy = fiber_pool->vacancies; + struct fiber_pool_vacancy * vacancy = fiber_pool_vacancy_pop(fiber_pool); if (DEBUG) fprintf(stderr, "fiber_pool_stack_acquire: %p used=%zu\n", fiber_pool->vacancies, fiber_pool->used); if (!vacancy) { + const size_t maximum = fiber_pool_default_allocation_count_limit(); + const size_t minimum = fiber_pool->initial_count; + size_t count = fiber_pool->count; - if (count > 1024) count = 1024; + if (count > maximum) count = maximum; + if (count < minimum) count = minimum; fiber_pool_expand(fiber_pool, count); // The free list should now contain some stacks: VM_ASSERT(fiber_pool->vacancies); - vacancy = fiber_pool->vacancies; + vacancy = fiber_pool_vacancy_pop(fiber_pool); } + VM_ASSERT(vacancy); + // Take the top item from the free list: - fiber_pool->vacancies = vacancy->next; fiber_pool->used += 1; + vacancy->stack.allocation->used += 1; + fiber_pool_stack_reset(&vacancy->stack); return vacancy->stack; @@ -446,7 +540,7 @@ fiber_pool_stack_acquire(struct fiber_pool * fiber_pool) { static inline void fiber_pool_stack_free(struct fiber_pool_stack * stack) { void * base = fiber_pool_stack_base(stack); - size_t size = stack->available - RB_PAGE_SIZE; + size_t size = stack->available; if (DEBUG) fprintf(stderr, "fiber_pool_stack_free: %p+%zu [base=%p, size=%zu]\n", base, size, stack->base, stack->size); @@ -465,20 +559,28 @@ fiber_pool_stack_free(struct fiber_pool_stack * stack) { // Release and return a stack to the vacancy list. static void -fiber_pool_stack_release(struct fiber_pool_stack stack) { - struct fiber_pool_vacancy * vacancy = fiber_pool_vacancy_pointer(stack.base, stack.size); +fiber_pool_stack_release(struct fiber_pool_stack * stack) { + struct fiber_pool_vacancy * vacancy = fiber_pool_vacancy_pointer(stack->base, stack->size); + + if (DEBUG) fprintf(stderr, "fiber_pool_stack_release: %p used=%zu\n", stack->base, stack->pool->used); // Copy the stack details into the vacancy area: - vacancy->stack = stack; - fiber_pool_vacancy_reset(vacancy); + vacancy->stack = *stack; - fiber_pool_stack_free(&vacancy->stack); + // Reset the stack pointers and reserve space for the vacancy data: + fiber_pool_vacancy_reset(vacancy); - vacancy->next = stack.pool->vacancies; - stack.pool->vacancies = vacancy; - stack.pool->used -= 1; + // Push the vacancy into the vancancies list: + stack->pool->vacancies = fiber_pool_vacancy_push(vacancy, stack->pool->vacancies); + stack->pool->used -= 1; + stack->allocation->used -= 1; - if (DEBUG) fprintf(stderr, "fiber_pool_stack_release: %p used=%zu\n", stack.base, stack.pool->used); + // Release address space and/or dirty memory: + if (stack->allocation->used == 0) { + fiber_pool_allocation_free(stack->allocation); + } else { + // fiber_pool_stack_free(stack); + } } static COROUTINE @@ -529,8 +631,11 @@ fiber_stack_release(rb_fiber_t * fiber) { rb_execution_context_t *ec = &fiber->cont.saved_ec; + if (DEBUG) fprintf(stderr, "fiber_stack_release: %p, stack.base=%p\n", fiber, fiber->stack.base); + + // Return the stack back to the fiber pool if it wasn't already: if (fiber->stack.base) { - fiber_pool_stack_release(fiber->stack); + fiber_pool_stack_release(&fiber->stack); fiber->stack.base = NULL; } @@ -713,14 +818,8 @@ cont_free(void *ptr) } else { rb_fiber_t *fiber = (rb_fiber_t*)cont; coroutine_destroy(&fiber->context); - if (fiber->stack.base != NULL) { - if (fiber_is_root_p(fiber)) { - rb_bug("Illegal root fiber parameter"); - } - if (fiber->stack.base) { - fiber_pool_stack_release(fiber->stack); - fiber->stack.base = NULL; - } + if (!fiber_is_root_p(fiber)) { + fiber_stack_release(fiber); } } @@ -809,12 +908,12 @@ fiber_free(void *ptr) rb_fiber_t *fiber = ptr; RUBY_FREE_ENTER("fiber"); + if (DEBUG) fprintf(stderr, "fiber_free: %p[%p]\n", fiber, fiber->stack.base); + if (fiber->cont.saved_ec.local_storage) { st_free_table(fiber->cont.saved_ec.local_storage); } - fiber_stack_release(fiber); - cont_free(&fiber->cont); RUBY_FREE_LEAVE("fiber"); } @@ -1089,7 +1188,7 @@ fiber_setcontext(rb_fiber_t *new_fiber, rb_fiber_t *old_fiber) { rb_thread_t *th = GET_THREAD(); - /* save old_fiber's machine stack - to ensure efficienct garbage collection */ + /* save old_fiber's machine stack - to ensure efficient garbage collection */ if (!FIBER_TERMINATED_P(old_fiber)) { STACK_GROW_DIR_DETECTION; SET_MACHINE_STACK_END(&th->ec->machine.stack_end); @@ -1112,8 +1211,13 @@ fiber_setcontext(rb_fiber_t *new_fiber, rb_fiber_t *old_fiber) /* restore thread context */ fiber_restore_thread(th, new_fiber); + if (DEBUG) fprintf(stderr, "fiber_setcontext: %p[%p] -> %p[%p]\n", old_fiber, old_fiber->stack.base, new_fiber, new_fiber->stack.base); + /* swap machine context */ coroutine_transfer(&old_fiber->context, &new_fiber->context); + + // It's possible to get here, and new_fiber is already trashed. + if (DEBUG) fprintf(stderr, "fiber_setcontext: %p[%p] <- %p[%p]\n", old_fiber, old_fiber->stack.base, new_fiber, new_fiber->stack.base); } NOINLINE(NORETURN(static void cont_restore_1(rb_context_t *))); From 4d60a5820ae2c7bc2ce5bee441b834129a3a56e1 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Tue, 16 Jul 2019 12:49:14 +1200 Subject: [PATCH 265/452] Add FIBER_POOL_ALLOCATION_FREE to control allocation/free strategy. --- cont.c | 51 +++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 43 insertions(+), 8 deletions(-) diff --git a/cont.c b/cont.c index d447b424c63bc5..938db70122e1c3 100644 --- a/cont.c +++ b/cont.c @@ -37,6 +37,7 @@ static VALUE rb_cFiberPool; #endif #define CAPTURE_JUST_VALID_VM_STACK 1 +//#define FIBER_POOL_ALLOCATION_FREE enum context_type { CONTINUATION_CONTEXT = 0, @@ -81,8 +82,10 @@ struct fiber_pool_vacancy { // Details about the vacant stack: struct fiber_pool_stack stack; - // The next vacancy in the linked list. + // The vacancy linked list. +#ifdef FIBER_POOL_ALLOCATION_FREE struct fiber_pool_vacancy * previous; +#endif struct fiber_pool_vacancy * next; }; @@ -123,13 +126,17 @@ struct fiber_pool_allocation { // The number of stacks that were allocated. size_t count; +#ifdef FIBER_POOL_ALLOCATION_FREE // The number of stacks used in this allocation. size_t used; +#endif struct fiber_pool * pool; - // The next allocation in the linked list. + // The allocation linked list. +#ifdef FIBER_POOL_ALLOCATION_FREE struct fiber_pool_allocation * previous; +#endif struct fiber_pool_allocation * next; }; @@ -297,13 +304,16 @@ inline static struct fiber_pool_vacancy * fiber_pool_vacancy_push(struct fiber_pool_vacancy * vacancy, struct fiber_pool_vacancy * head) { vacancy->next = head; +#ifdef FIBER_POOL_ALLOCATION_FREE if (head) { head->previous = vacancy; } +#endif return vacancy; } +#ifdef FIBER_POOL_ALLOCATION_FREE static void fiber_pool_vacancy_remove(struct fiber_pool_vacancy * vacancy) { if (vacancy->next) { @@ -328,6 +338,18 @@ fiber_pool_vacancy_pop(struct fiber_pool * pool) { return vacancy; } +#else +inline static struct fiber_pool_vacancy * +fiber_pool_vacancy_pop(struct fiber_pool * pool) { + struct fiber_pool_vacancy * vacancy = pool->vacancies; + + if (vacancy) { + pool->vacancies = vacancy->next; + } + + return vacancy; +} +#endif // Initialize the vacant stack. The [base, size] allocation should not include the guard page. // @param base The pointer to the lowest address of the allocated memory. @@ -365,7 +387,9 @@ fiber_pool_expand(struct fiber_pool * fiber_pool, size_t count) allocation->size = size; allocation->stride = stride; allocation->count = count; +#ifdef FIBER_POOL_ALLOCATION_FREE allocation->used = 0; +#endif allocation->pool = fiber_pool; if (DEBUG) fprintf(stderr, "fiber_pool_expand(%zu): %p, %zu/%zu x [%zu:%zu]\n", count, fiber_pool, fiber_pool->used, fiber_pool->count, size, fiber_pool->vm_stack_size); @@ -411,17 +435,21 @@ fiber_pool_expand(struct fiber_pool * fiber_pool, size_t count) size ); +#ifdef FIBER_POOL_ALLOCATION_FREE vacancies->stack.allocation = allocation; +#endif } // Insert the allocation into the head of the pool: allocation->next = fiber_pool->allocations; +#ifdef FIBER_POOL_ALLOCATION_FREE if (allocation->next) { allocation->next->previous = allocation; } allocation->previous = NULL; +#endif fiber_pool->allocations = allocation; fiber_pool->vacancies = vacancies; @@ -458,6 +486,7 @@ fiber_pool_initialize(struct fiber_pool * fiber_pool, size_t size, size_t count, fiber_pool_expand(fiber_pool, count); } +#ifdef FIBER_POOL_ALLOCATION_FREE // Free the list of fiber pool allocations. static void fiber_pool_allocation_free(struct fiber_pool_allocation * allocation) @@ -499,6 +528,7 @@ fiber_pool_allocation_free(struct fiber_pool_allocation * allocation) ruby_xfree(allocation); } +#endif // Acquire a stack from the given fiber pool. If none are avilable, allocate more. static struct fiber_pool_stack @@ -528,7 +558,9 @@ fiber_pool_stack_acquire(struct fiber_pool * fiber_pool) { // Take the top item from the free list: fiber_pool->used += 1; +#ifdef FIBER_POOL_ALLOCATION_FREE vacancy->stack.allocation->used += 1; +#endif fiber_pool_stack_reset(&vacancy->stack); @@ -573,14 +605,17 @@ fiber_pool_stack_release(struct fiber_pool_stack * stack) { // Push the vacancy into the vancancies list: stack->pool->vacancies = fiber_pool_vacancy_push(vacancy, stack->pool->vacancies); stack->pool->used -= 1; + +#ifdef FIBER_POOL_ALLOCATION_FREE stack->allocation->used -= 1; // Release address space and/or dirty memory: if (stack->allocation->used == 0) { fiber_pool_allocation_free(stack->allocation); } else { - // fiber_pool_stack_free(stack); + fiber_pool_stack_free(stack); } +#endif } static COROUTINE @@ -690,7 +725,7 @@ rb_ec_verify(const rb_execution_context_t *ec) inline static void fiber_status_set(rb_fiber_t *fiber, enum fiber_status s) { - if (DEBUG) fprintf(stderr, "fiber: %p, status: %s -> %s\n", (void *)fiber, fiber_status_name(fiber->status), fiber_status_name(s)); + // if (DEBUG) fprintf(stderr, "fiber: %p, status: %s -> %s\n", (void *)fiber, fiber_status_name(fiber->status), fiber_status_name(s)); VM_ASSERT(!FIBER_TERMINATED_P(fiber)); VM_ASSERT(fiber->status != s); fiber_verify(fiber); @@ -908,7 +943,7 @@ fiber_free(void *ptr) rb_fiber_t *fiber = ptr; RUBY_FREE_ENTER("fiber"); - if (DEBUG) fprintf(stderr, "fiber_free: %p[%p]\n", fiber, fiber->stack.base); + //if (DEBUG) fprintf(stderr, "fiber_free: %p[%p]\n", fiber, fiber->stack.base); if (fiber->cont.saved_ec.local_storage) { st_free_table(fiber->cont.saved_ec.local_storage); @@ -1211,13 +1246,13 @@ fiber_setcontext(rb_fiber_t *new_fiber, rb_fiber_t *old_fiber) /* restore thread context */ fiber_restore_thread(th, new_fiber); - if (DEBUG) fprintf(stderr, "fiber_setcontext: %p[%p] -> %p[%p]\n", old_fiber, old_fiber->stack.base, new_fiber, new_fiber->stack.base); + // if (DEBUG) fprintf(stderr, "fiber_setcontext: %p[%p] -> %p[%p]\n", old_fiber, old_fiber->stack.base, new_fiber, new_fiber->stack.base); /* swap machine context */ coroutine_transfer(&old_fiber->context, &new_fiber->context); - // It's possible to get here, and new_fiber is already trashed. - if (DEBUG) fprintf(stderr, "fiber_setcontext: %p[%p] <- %p[%p]\n", old_fiber, old_fiber->stack.base, new_fiber, new_fiber->stack.base); + // It's possible to get here, and new_fiber is already freed. + // if (DEBUG) fprintf(stderr, "fiber_setcontext: %p[%p] <- %p[%p]\n", old_fiber, old_fiber->stack.base, new_fiber, new_fiber->stack.base); } NOINLINE(NORETURN(static void cont_restore_1(rb_context_t *))); From 385ea910fc28f0e46c72669a260e44d4f3f37d9e Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Tue, 16 Jul 2019 16:00:35 +1200 Subject: [PATCH 266/452] Add `struct fiber_pool {int free_stacks;}` to control usage of madvise. `madvise(free)` and similar operations are good because they avoid swap usage by clearing the dirty bit on memory pages which are mapped but no longer needed. However, there is some performance penalty if there is no memory pressure. Therefore, we do it by default, but it can be avoided. --- cont.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/cont.c b/cont.c index 938db70122e1c3..16e8d7c33d0136 100644 --- a/cont.c +++ b/cont.c @@ -157,6 +157,9 @@ struct fiber_pool { // The initial number of stacks to allocate. size_t initial_count; + // Whether to madvise(free) the stack or not: + int free_stacks; + // The number of stacks that have been used in this pool. size_t used; @@ -479,6 +482,7 @@ fiber_pool_initialize(struct fiber_pool * fiber_pool, size_t size, size_t count, fiber_pool->size = ((size / RB_PAGE_SIZE) + 1) * RB_PAGE_SIZE; fiber_pool->count = 0; fiber_pool->initial_count = count; + fiber_pool->free_stacks = 1; fiber_pool->used = 0; fiber_pool->vm_stack_size = vm_stack_size; @@ -612,7 +616,12 @@ fiber_pool_stack_release(struct fiber_pool_stack * stack) { // Release address space and/or dirty memory: if (stack->allocation->used == 0) { fiber_pool_allocation_free(stack->allocation); - } else { + } else if (stack->pool->free_stacks) { + fiber_pool_stack_free(stack); + } +#else + // This is entirely optional, but clears the dirty flag from the stack memory, so it won't get swapped to disk when there is memory pressure: + if (stack->pool->free_stacks) { fiber_pool_stack_free(stack); } #endif From 001f187ed6539f320421d8893d2f3c8f584cc3a5 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Tue, 16 Jul 2019 16:11:55 +1200 Subject: [PATCH 267/452] Make fiber_pool more conservative on platforms with limited address space. We use COROUTINE_LIMITED_ADDRESS_SPACE to select platforms where address space is 32-bits or less. Fiber pool implementation enables more book keeping, and reduces upper limits, in order to minimise address space utilisation. --- cont.c | 24 ++++++++++++------------ coroutine/arm32/Context.h | 1 + coroutine/copy/Context.h | 4 ++++ coroutine/ucontext/Context.h | 4 ++++ coroutine/win32/Context.h | 1 + coroutine/x86/Context.h | 1 + 6 files changed, 23 insertions(+), 12 deletions(-) diff --git a/cont.c b/cont.c index 16e8d7c33d0136..25fb62354a4400 100644 --- a/cont.c +++ b/cont.c @@ -37,7 +37,16 @@ static VALUE rb_cFiberPool; #endif #define CAPTURE_JUST_VALID_VM_STACK 1 -//#define FIBER_POOL_ALLOCATION_FREE + +// Defined in `coroutine/$arch/Context.h`: +#ifdef COROUTINE_LIMITED_ADDRESS_SPACE +#define FIBER_POOL_ALLOCATION_FREE +#define FIBER_POOL_INITIAL_SIZE 8 +#define FIBER_POOL_ALLOCATION_MAXIMUM_SIZE 32 +#else +#define FIBER_POOL_INITIAL_SIZE 32 +#define FIBER_POOL_ALLOCATION_MAXIMUM_SIZE 4096 +#endif enum context_type { CONTINUATION_CONTEXT = 0, @@ -461,15 +470,6 @@ fiber_pool_expand(struct fiber_pool * fiber_pool, size_t count) return allocation; } -static inline size_t -fiber_pool_default_allocation_count_limit() { - if (sizeof(void*) <= 4) { - return 32; - } else { - return 1024; - } -} - // Initialize the specified fiber pool with the given number of stacks. // @param vm_stack_size The size of the vm stack to allocate. static void @@ -542,7 +542,7 @@ fiber_pool_stack_acquire(struct fiber_pool * fiber_pool) { if (DEBUG) fprintf(stderr, "fiber_pool_stack_acquire: %p used=%zu\n", fiber_pool->vacancies, fiber_pool->used); if (!vacancy) { - const size_t maximum = fiber_pool_default_allocation_count_limit(); + const size_t maximum = FIBER_POOL_ALLOCATION_MAXIMUM_SIZE; const size_t minimum = fiber_pool->initial_count; size_t count = fiber_pool->count; @@ -2335,7 +2335,7 @@ Init_Cont(void) #endif SET_MACHINE_STACK_END(&th->ec->machine.stack_end); - fiber_pool_initialize(&shared_fiber_pool, stack_size, 8, vm_stack_size); + fiber_pool_initialize(&shared_fiber_pool, stack_size, FIBER_POOL_INITIAL_SIZE, vm_stack_size); rb_cFiber = rb_define_class("Fiber", rb_cObject); rb_define_alloc_func(rb_cFiber, fiber_alloc); diff --git a/coroutine/arm32/Context.h b/coroutine/arm32/Context.h index 27f97908bc139d..e29fe1bb638966 100644 --- a/coroutine/arm32/Context.h +++ b/coroutine/arm32/Context.h @@ -11,6 +11,7 @@ #include #define COROUTINE __attribute__((noreturn)) void +#define COROUTINE_LIMITED_ADDRESS_SPACE enum {COROUTINE_REGISTERS = 8}; diff --git a/coroutine/copy/Context.h b/coroutine/copy/Context.h index a62efa4e8a7697..0b6e3a9be0d3bb 100644 --- a/coroutine/copy/Context.h +++ b/coroutine/copy/Context.h @@ -16,6 +16,10 @@ #define COROUTINE __attribute__((noreturn)) void +#if INTPTR_MAX <= INT32_MAX +#define COROUTINE_LIMITED_ADDRESS_SPACE +#endif + // This stack copying implementation which uses a private stack for each coroutine, including the main one. #define COROUTINE_PRIVATE_STACK diff --git a/coroutine/ucontext/Context.h b/coroutine/ucontext/Context.h index bde9be302a2d43..6cf16c86040d25 100644 --- a/coroutine/ucontext/Context.h +++ b/coroutine/ucontext/Context.h @@ -13,6 +13,10 @@ #define COROUTINE __attribute__((noreturn)) void +#if INTPTR_MAX <= INT32_MAX +#define COROUTINE_LIMITED_ADDRESS_SPACE +#endif + struct coroutine_context { ucontext_t state; diff --git a/coroutine/win32/Context.h b/coroutine/win32/Context.h index fe1a8a3648c282..c70b65cd2ff0dc 100644 --- a/coroutine/win32/Context.h +++ b/coroutine/win32/Context.h @@ -11,6 +11,7 @@ #include #define COROUTINE __declspec(noreturn) void __fastcall +#define COROUTINE_LIMITED_ADDRESS_SPACE /* This doesn't include thread information block */ enum {COROUTINE_REGISTERS = 4}; diff --git a/coroutine/x86/Context.h b/coroutine/x86/Context.h index a783dd296ff87f..6d3a56eaa6cf21 100644 --- a/coroutine/x86/Context.h +++ b/coroutine/x86/Context.h @@ -11,6 +11,7 @@ #include #define COROUTINE __attribute__((noreturn, fastcall)) void +#define COROUTINE_LIMITED_ADDRESS_SPACE enum {COROUTINE_REGISTERS = 4}; From 56fcf988495ec1b36655534f4cc2ae786e2ab8c5 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Tue, 16 Jul 2019 16:35:27 +1200 Subject: [PATCH 268/452] Add note about setting `vm.max_map_count` for Linux. --- benchmark/vm2_fiber_count.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/benchmark/vm2_fiber_count.yml b/benchmark/vm2_fiber_count.yml index 2005772e8466cb..3ecf6bdcb2891b 100644 --- a/benchmark/vm2_fiber_count.yml +++ b/benchmark/vm2_fiber_count.yml @@ -1,3 +1,5 @@ +# On Linux, you will need to increase the maximum number of memory maps: +# sudo sysctl -w vm.max_map_count=200000 prelude: | fibers = [] benchmark: From 311007bf403160b978e015997ad5076a229290da Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Tue, 16 Jul 2019 16:35:55 +1200 Subject: [PATCH 269/452] Add experimental `RUBY_SHARED_FIBER_POOL_FREE_STACKS` to control madvise. --- cont.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cont.c b/cont.c index 25fb62354a4400..f8369c7ab2a97d 100644 --- a/cont.c +++ b/cont.c @@ -2337,6 +2337,11 @@ Init_Cont(void) fiber_pool_initialize(&shared_fiber_pool, stack_size, FIBER_POOL_INITIAL_SIZE, vm_stack_size); + char * fiber_shared_fiber_pool_free_stacks = getenv("RUBY_SHARED_FIBER_POOL_FREE_STACKS"); + if (fiber_shared_fiber_pool_free_stacks) { + shared_fiber_pool.free_stacks = atoi(fiber_shared_fiber_pool_free_stacks); + } + rb_cFiber = rb_define_class("Fiber", rb_cObject); rb_define_alloc_func(rb_cFiber, fiber_alloc); rb_eFiberError = rb_define_class("FiberError", rb_eStandardError); From 38e3c65a33aa7bcd4cee922487e259a8da699831 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Thu, 18 Jul 2019 19:02:16 +1200 Subject: [PATCH 270/452] Improve `fiber_pool_expand` allocation strategy. If `mmap` fails to allocate memory, try half the size, and so on. Limit FIBER_POOL_ALLOCATION_MAXIMUM_SIZE to 1024 stacks. In typical configurations this limits the memory mapped region to ~128MB per allocation. --- cont.c | 70 +++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 47 insertions(+), 23 deletions(-) diff --git a/cont.c b/cont.c index f8369c7ab2a97d..2c5d931692d3ec 100644 --- a/cont.c +++ b/cont.c @@ -45,7 +45,7 @@ static VALUE rb_cFiberPool; #define FIBER_POOL_ALLOCATION_MAXIMUM_SIZE 32 #else #define FIBER_POOL_INITIAL_SIZE 32 -#define FIBER_POOL_ALLOCATION_MAXIMUM_SIZE 4096 +#define FIBER_POOL_ALLOCATION_MAXIMUM_SIZE 1024 #endif enum context_type { @@ -381,21 +381,61 @@ fiber_pool_vacancy_initialize(struct fiber_pool * fiber_pool, struct fiber_pool_ return fiber_pool_vacancy_push(vacancy, vacancies); } +// Allocate a maximum of count stacks, size given by stride. +// @param count the number of stacks to allocate / were allocated. +// @param stride the size of the individual stacks. +// @return [void *] the allocated memory or NULL if allocation failed. +inline static void * +fiber_pool_allocate_memory(size_t * count, size_t stride) +{ + while (*count > 1) { +#if defined(_WIN32) + void * base = VirtualAlloc(0, (*count)*stride, MEM_COMMIT, PAGE_READWRITE); + + if (!base) { + *count = (*count) >> 1; + } else { + return base; + } +#else + errno = 0; + void * base = mmap(NULL, (*count)*stride, PROT_READ | PROT_WRITE, FIBER_STACK_FLAGS, -1, 0); + + if (base == MAP_FAILED) { + *count = (*count) >> 1; + } else { + return base; + } +#endif + } + + return NULL; +} + // Given an existing fiber pool, expand it by the specified number of stacks. +// @param count the maximum number of stacks to allocate. +// @return the allocated fiber pool. +// @sa fiber_pool_allocation_free static struct fiber_pool_allocation * fiber_pool_expand(struct fiber_pool * fiber_pool, size_t count) { STACK_GROW_DIR_DETECTION; - size_t i; - struct fiber_pool_vacancy * vacancies = fiber_pool->vacancies; - struct fiber_pool_allocation * allocation = RB_ALLOC(struct fiber_pool_allocation); - size_t size = fiber_pool->size; size_t stride = size + RB_PAGE_SIZE; + // Allocate the memory required for the stacks: + void * base = fiber_pool_allocate_memory(&count, stride); + + if (base == NULL) { + rb_raise(rb_eFiberError, "can't alloc machine stack to fiber (%zu x %zu bytes): %s", count, size, ERRNOMSG); + } + + struct fiber_pool_vacancy * vacancies = fiber_pool->vacancies; + struct fiber_pool_allocation * allocation = RB_ALLOC(struct fiber_pool_allocation); + // Initialize fiber pool allocation: - allocation->base = NULL; + allocation->base = base; allocation->size = size; allocation->stride = stride; allocation->count = count; @@ -406,24 +446,8 @@ fiber_pool_expand(struct fiber_pool * fiber_pool, size_t count) if (DEBUG) fprintf(stderr, "fiber_pool_expand(%zu): %p, %zu/%zu x [%zu:%zu]\n", count, fiber_pool, fiber_pool->used, fiber_pool->count, size, fiber_pool->vm_stack_size); - // Allocate the memory required for the stacks: -#if defined(_WIN32) - allocation->base = VirtualAlloc(0, count*stride, MEM_COMMIT, PAGE_READWRITE); - - if (!allocation->base) { - rb_raise(rb_eFiberError, "can't alloc machine stack to fiber (%zu x %zu bytes): %s", count, size, ERRNOMSG); - } -#else - errno = 0; - allocation->base = mmap(NULL, count*stride, PROT_READ | PROT_WRITE, FIBER_STACK_FLAGS, -1, 0); - - if (allocation->base == MAP_FAILED) { - rb_raise(rb_eFiberError, "can't alloc machine stack to fiber (%zu x %zu bytes): %s", count, size, ERRNOMSG); - } -#endif - // Iterate over all stacks, initializing the vacancy list: - for (i = 0; i < count; i += 1) { + for (size_t i = 0; i < count; i += 1) { void * base = (char*)allocation->base + (stride * i); void * page = (char*)base + STACK_DIR_UPPER(size, 0); From 78bc6cd8dff9ee584a447251490c88ee035d218d Mon Sep 17 00:00:00 2001 From: git Date: Thu, 18 Jul 2019 17:55:22 +0900 Subject: [PATCH 271/452] * remove trailing spaces. --- cont.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cont.c b/cont.c index 2c5d931692d3ec..db7457ff7f8aac 100644 --- a/cont.c +++ b/cont.c @@ -568,7 +568,7 @@ fiber_pool_stack_acquire(struct fiber_pool * fiber_pool) { if (!vacancy) { const size_t maximum = FIBER_POOL_ALLOCATION_MAXIMUM_SIZE; const size_t minimum = fiber_pool->initial_count; - + size_t count = fiber_pool->count; if (count > maximum) count = maximum; if (count < minimum) count = minimum; From 9790b778a339f36f9b29517a1d762cf02a2f0293 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Fri, 19 Jul 2019 00:33:03 +1200 Subject: [PATCH 272/452] Ensure we don't have dangling cfp. --- cont.c | 1 + 1 file changed, 1 insertion(+) diff --git a/cont.c b/cont.c index db7457ff7f8aac..c16c697ee770ce 100644 --- a/cont.c +++ b/cont.c @@ -709,6 +709,7 @@ fiber_stack_release(rb_fiber_t * fiber) // The stack is no longer associated with this execution context: rb_ec_clear_vm_stack(ec); + ec->cfp = NULL; } static const char * From d40d8b3caf40e0b1769bb4a196aa7740aef4737e Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Thu, 18 Jul 2019 22:59:44 +0900 Subject: [PATCH 273/452] check saved_ec.cfp --- cont.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cont.c b/cont.c index c16c697ee770ce..ba6120f9cd41c2 100644 --- a/cont.c +++ b/cont.c @@ -834,7 +834,9 @@ cont_mark(void *ptr) RUBY_MARK_ENTER("cont"); rb_gc_mark_no_pin(cont->value); - rb_execution_context_mark(&cont->saved_ec); + if (cont->saved_ec.cfp) { + rb_execution_context_mark(&cont->saved_ec); + } rb_gc_mark(cont_thread_value(cont)); if (cont->saved_vm_stack.ptr) { From a027c4b5b0bc1d6786852249847e8a2f56404d1a Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 19 Jul 2019 06:15:05 +0900 Subject: [PATCH 274/452] Use Qnull instead of 0 and Qundef --- parse.y | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/parse.y b/parse.y index a950208e521de7..e6deefc9782840 100644 --- a/parse.y +++ b/parse.y @@ -5100,10 +5100,7 @@ opt_f_block_arg : ',' f_block_arg } | none { - /*%%%*/ - $$ = 0; - /*% %*/ - /*% ripper: Qundef %*/ + $$ = Qnull; } ; From a036a8a038820660a6903af60376a2df502d0266 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 19 Jul 2019 06:15:47 +0900 Subject: [PATCH 275/452] Adjust styles and indents --- cont.c | 54 +++++++++++++++++++++++++++++++++--------------------- hash.c | 3 ++- node.h | 3 ++- numeric.c | 3 ++- 4 files changed, 39 insertions(+), 24 deletions(-) diff --git a/cont.c b/cont.c index ba6120f9cd41c2..75b259a3c2bf59 100644 --- a/cont.c +++ b/cont.c @@ -313,7 +313,8 @@ fiber_pool_vacancy_reset(struct fiber_pool_vacancy * vacancy) } inline static struct fiber_pool_vacancy * -fiber_pool_vacancy_push(struct fiber_pool_vacancy * vacancy, struct fiber_pool_vacancy * head) { +fiber_pool_vacancy_push(struct fiber_pool_vacancy * vacancy, struct fiber_pool_vacancy * head) +{ vacancy->next = head; #ifdef FIBER_POOL_ALLOCATION_FREE @@ -327,36 +328,40 @@ fiber_pool_vacancy_push(struct fiber_pool_vacancy * vacancy, struct fiber_pool_v #ifdef FIBER_POOL_ALLOCATION_FREE static void -fiber_pool_vacancy_remove(struct fiber_pool_vacancy * vacancy) { +fiber_pool_vacancy_remove(struct fiber_pool_vacancy * vacancy) +{ if (vacancy->next) { vacancy->next->previous = vacancy->previous; } if (vacancy->previous) { vacancy->previous->next = vacancy->next; - } else { + } + else { // It's the head of the list: vacancy->stack.pool->vacancies = vacancy->next; } } inline static struct fiber_pool_vacancy * -fiber_pool_vacancy_pop(struct fiber_pool * pool) { +fiber_pool_vacancy_pop(struct fiber_pool * pool) +{ struct fiber_pool_vacancy * vacancy = pool->vacancies; if (vacancy) { - fiber_pool_vacancy_remove(vacancy); + fiber_pool_vacancy_remove(vacancy); } return vacancy; } #else inline static struct fiber_pool_vacancy * -fiber_pool_vacancy_pop(struct fiber_pool * pool) { +fiber_pool_vacancy_pop(struct fiber_pool * pool) +{ struct fiber_pool_vacancy * vacancy = pool->vacancies; if (vacancy) { - pool->vacancies = vacancy->next; + pool->vacancies = vacancy->next; } return vacancy; @@ -394,7 +399,8 @@ fiber_pool_allocate_memory(size_t * count, size_t stride) if (!base) { *count = (*count) >> 1; - } else { + } + else { return base; } #else @@ -403,7 +409,8 @@ fiber_pool_allocate_memory(size_t * count, size_t stride) if (base == MAP_FAILED) { *count = (*count) >> 1; - } else { + } + else { return base; } #endif @@ -466,9 +473,9 @@ fiber_pool_expand(struct fiber_pool * fiber_pool, size_t count) #endif vacancies = fiber_pool_vacancy_initialize( - fiber_pool, vacancies, - (char*)base + STACK_DIR_UPPER(0, RB_PAGE_SIZE), - size + fiber_pool, vacancies, + (char*)base + STACK_DIR_UPPER(0, RB_PAGE_SIZE), + size ); #ifdef FIBER_POOL_ALLOCATION_FREE @@ -536,14 +543,15 @@ fiber_pool_allocation_free(struct fiber_pool_allocation * allocation) } #ifdef _WIN32 - VirtualFree(allocation->base, 0, MEM_RELEASE); + VirtualFree(allocation->base, 0, MEM_RELEASE); #else - munmap(allocation->base, allocation->stride * allocation->count); + munmap(allocation->base, allocation->stride * allocation->count); #endif if (allocation->previous) { allocation->previous->next = allocation->next; - } else { + } + else { // We are the head of the list, so update the pool: allocation->pool->allocations = allocation->next; } @@ -598,7 +606,8 @@ fiber_pool_stack_acquire(struct fiber_pool * fiber_pool) { // We advise the operating system that the stack memory pages are no longer being used. // This introduce some performance overhead but allows system to relaim memory when there is pressure. static inline void -fiber_pool_stack_free(struct fiber_pool_stack * stack) { +fiber_pool_stack_free(struct fiber_pool_stack * stack) +{ void * base = fiber_pool_stack_base(stack); size_t size = stack->available; @@ -619,7 +628,8 @@ fiber_pool_stack_free(struct fiber_pool_stack * stack) { // Release and return a stack to the vacancy list. static void -fiber_pool_stack_release(struct fiber_pool_stack * stack) { +fiber_pool_stack_release(struct fiber_pool_stack * stack) +{ struct fiber_pool_vacancy * vacancy = fiber_pool_vacancy_pointer(stack->base, stack->size); if (DEBUG) fprintf(stderr, "fiber_pool_stack_release: %p used=%zu\n", stack->base, stack->pool->used); @@ -640,7 +650,8 @@ fiber_pool_stack_release(struct fiber_pool_stack * stack) { // Release address space and/or dirty memory: if (stack->allocation->used == 0) { fiber_pool_allocation_free(stack->allocation); - } else if (stack->pool->free_stacks) { + } + else if (stack->pool->free_stacks) { fiber_pool_stack_free(stack); } #else @@ -808,7 +819,7 @@ fiber_ptr(VALUE obj) NOINLINE(static VALUE cont_capture(volatile int *volatile stat)); #define THREAD_MUST_BE_RUNNING(th) do { \ - if (!(th)->ec->tag) rb_raise(rb_eThreadError, "not running thread"); \ + if (!(th)->ec->tag) rb_raise(rb_eThreadError, "not running thread"); \ } while (0) static VALUE @@ -886,7 +897,8 @@ cont_free(void *ptr) ruby_xfree(cont->saved_ec.vm_stack); ruby_xfree(cont->ensure_array); RUBY_FREE_UNLESS_NULL(cont->machine.stack); - } else { + } + else { rb_fiber_t *fiber = (rb_fiber_t*)cont; coroutine_destroy(&fiber->context); if (!fiber_is_root_p(fiber)) { @@ -1311,7 +1323,7 @@ cont_restore_1(rb_context_t *cont) if (cont->machine.stack_src) { FLUSH_REGISTER_WINDOWS; MEMCPY(cont->machine.stack_src, cont->machine.stack, - VALUE, cont->machine.stack_size); + VALUE, cont->machine.stack_size); } ruby_longjmp(cont->jmpbuf, 1); diff --git a/hash.c b/hash.c index 9c2da83fee966d..f458fd71aa7271 100644 --- a/hash.c +++ b/hash.c @@ -564,7 +564,8 @@ hash_ar_table_set(VALUE hash, ar_table *ar) #define RHASH_AR_TABLE_SIZE_INC(h) HASH_AR_TABLE_SIZE_ADD(h, 1) static inline void -RHASH_AR_TABLE_SIZE_DEC(VALUE h) { +RHASH_AR_TABLE_SIZE_DEC(VALUE h) +{ HASH_ASSERT(RHASH_AR_TABLE_P(h)); int new_size = RHASH_AR_TABLE_SIZE(h) - 1; diff --git a/node.h b/node.h index ebcc49c9be9141..a1f01ed08819c5 100644 --- a/node.h +++ b/node.h @@ -138,7 +138,8 @@ typedef struct rb_code_location_struct { rb_code_position_t end_pos; } rb_code_location_t; -static inline rb_code_location_t code_loc_gen(rb_code_location_t *loc1, rb_code_location_t *loc2) +static inline rb_code_location_t +code_loc_gen(rb_code_location_t *loc1, rb_code_location_t *loc2) { rb_code_location_t loc; loc.beg_pos = loc1->beg_pos; diff --git a/numeric.c b/numeric.c index 9bf5e0a2053afa..5b0ab8cbe8977d 100644 --- a/numeric.c +++ b/numeric.c @@ -4673,7 +4673,8 @@ compare_indexes(VALUE a, VALUE b) } static VALUE -generate_mask(VALUE len) { +generate_mask(VALUE len) +{ return rb_int_minus(rb_int_lshift(INT2FIX(1), len), INT2FIX(1)); } From d4c4029597d575aa9820698b5be7594b642b024f Mon Sep 17 00:00:00 2001 From: git Date: Fri, 19 Jul 2019 06:40:24 +0900 Subject: [PATCH 276/452] * 2019-07-19 --- version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.h b/version.h index 7ffdef6200fa1f..05dc62f0a391a5 100644 --- a/version.h +++ b/version.h @@ -6,7 +6,7 @@ #define RUBY_RELEASE_YEAR 2019 #define RUBY_RELEASE_MONTH 7 -#define RUBY_RELEASE_DAY 18 +#define RUBY_RELEASE_DAY 19 #include "ruby/version.h" From 18bce998ddbcf1266d53071a5d46a9e71950f0ea Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 19 Jul 2019 07:48:30 +0900 Subject: [PATCH 277/452] Fixed build error with RIPPER_DEBUG --- parse.y | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/parse.y b/parse.y index e6deefc9782840..d778a16c195e66 100644 --- a/parse.y +++ b/parse.y @@ -12479,8 +12479,6 @@ rb_yytnamerr(struct parser_params *p, char *yyres, const char *yystr) #ifdef RIPPER #ifdef RIPPER_DEBUG -extern int rb_is_pointer_to_heap(VALUE); - /* :nodoc: */ static VALUE ripper_validate_object(VALUE self, VALUE x) @@ -12492,8 +12490,6 @@ ripper_validate_object(VALUE self, VALUE x) rb_raise(rb_eArgError, "Qundef given"); if (FIXNUM_P(x)) return x; if (SYMBOL_P(x)) return x; - if (!rb_is_pointer_to_heap(x)) - rb_raise(rb_eArgError, "invalid pointer: %p", x); switch (BUILTIN_TYPE(x)) { case T_STRING: case T_OBJECT: @@ -12504,13 +12500,13 @@ ripper_validate_object(VALUE self, VALUE x) case T_RATIONAL: return x; case T_NODE: - if (nd_type(x) != NODE_RIPPER) { - rb_raise(rb_eArgError, "NODE given: %p", x); + if (nd_type((NODE *)x) != NODE_RIPPER) { + rb_raise(rb_eArgError, "NODE given: %p", (void *)x); } return ((NODE *)x)->nd_rval; default: rb_raise(rb_eArgError, "wrong type of ruby object: %p (%s)", - x, rb_obj_classname(x)); + (void *)x, rb_obj_classname(x)); } return x; } From 59d6ce4f4bf2d77dfd07975fed6a49609c2df97e Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 19 Jul 2019 07:48:55 +0900 Subject: [PATCH 278/452] Moved RIPPER_DEBUG methods to Ripper from Kernel --- parse.y | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/parse.y b/parse.y index d778a16c195e66..315c09f6d5c97f 100644 --- a/parse.y +++ b/parse.y @@ -12919,9 +12919,9 @@ InitVM_ripper(void) rb_define_method(Ripper, "debug_output=", rb_parser_set_debug_output, 1); rb_define_method(Ripper, "error?", ripper_error_p, 0); #ifdef RIPPER_DEBUG - rb_define_method(rb_mKernel, "assert_Qundef", ripper_assert_Qundef, 2); - rb_define_method(rb_mKernel, "rawVALUE", ripper_value, 1); - rb_define_method(rb_mKernel, "validate_object", ripper_validate_object, 1); + rb_define_method(Ripper, "assert_Qundef", ripper_assert_Qundef, 2); + rb_define_method(Ripper, "rawVALUE", ripper_value, 1); + rb_define_method(Ripper, "validate_object", ripper_validate_object, 1); #endif rb_define_singleton_method(Ripper, "dedent_string", parser_dedent_string, 2); From 0b826418af2a96b0e3a24a8b871996962efb6127 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 19 Jul 2019 07:51:48 +0900 Subject: [PATCH 279/452] Update before commit --- defs/gmake.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/defs/gmake.mk b/defs/gmake.mk index 4a16552a1f3b6c..b21fa4f738ff46 100644 --- a/defs/gmake.mk +++ b/defs/gmake.mk @@ -144,7 +144,7 @@ $(TIMESTAMPDIR)/.exec.time: $(Q) exit > $@ .PHONY: commit -commit: $(if $(filter commit,$(MAKECMDGOALS)),$(filter-out commit,$(MAKECMDGOALS))) +commit: $(if $(filter commit,$(MAKECMDGOALS)),$(filter-out commit,$(MAKECMDGOALS))) up @$(BASERUBY) -C "$(srcdir)" -I./tool/lib -rvcs -e 'VCS.detect(".").commit' +$(Q) \ { \ From fd461dea06b1a56eca9d1c662c3dc0c416c9e495 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 19 Jul 2019 07:55:40 +0900 Subject: [PATCH 280/452] Ripper#validate_object: check if the object is hidden --- parse.y | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/parse.y b/parse.y index 315c09f6d5c97f..46c263fa7b259a 100644 --- a/parse.y +++ b/parse.y @@ -12487,7 +12487,7 @@ ripper_validate_object(VALUE self, VALUE x) if (x == Qtrue) return x; if (x == Qnil) return x; if (x == Qundef) - rb_raise(rb_eArgError, "Qundef given"); + rb_raise(rb_eArgError, "Qundef given"); if (FIXNUM_P(x)) return x; if (SYMBOL_P(x)) return x; switch (BUILTIN_TYPE(x)) { @@ -12498,15 +12498,20 @@ ripper_validate_object(VALUE self, VALUE x) case T_FLOAT: case T_COMPLEX: case T_RATIONAL: - return x; + break; case T_NODE: if (nd_type((NODE *)x) != NODE_RIPPER) { rb_raise(rb_eArgError, "NODE given: %p", (void *)x); } - return ((NODE *)x)->nd_rval; + x = ((NODE *)x)->nd_rval; + break; default: - rb_raise(rb_eArgError, "wrong type of ruby object: %p (%s)", - (void *)x, rb_obj_classname(x)); + rb_raise(rb_eArgError, "wrong type of ruby object: %p (%s)", + (void *)x, rb_obj_classname(x)); + } + if (!RBASIC_CLASS(x)) { + rb_raise(rb_eArgError, "hidden ruby object: %p (%s)", + (void *)x, rb_builtin_type_name(TYPE(x))); } return x; } From 9dda0a03cc19d0ca20fc8fc220760e37cb5b9f02 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Fri, 19 Jul 2019 11:00:58 +1200 Subject: [PATCH 281/452] Remove `rb_vm_push_frame` as it is no longer used. --- cont.c | 12 ------------ thread.c | 11 ----------- vm.c | 2 +- vm_insnhelper.c | 15 --------------- 4 files changed, 1 insertion(+), 39 deletions(-) diff --git a/cont.c b/cont.c index 75b259a3c2bf59..c0be42bffcde3a 100644 --- a/cont.c +++ b/cont.c @@ -1713,18 +1713,6 @@ fiber_t_alloc(VALUE fiber_value) return fiber; } -rb_control_frame_t * -rb_vm_push_frame(rb_execution_context_t *sec, - const rb_iseq_t *iseq, - VALUE type, - VALUE self, - VALUE specval, - VALUE cref_or_me, - const VALUE *pc, - VALUE *sp, - int local_size, - int stack_max); - static VALUE fiber_initialize(VALUE self, VALUE proc, struct fiber_pool * fiber_pool) { diff --git a/thread.c b/thread.c index 2b785a7ebe12d3..f9fc70f3cf0d0b 100644 --- a/thread.c +++ b/thread.c @@ -691,17 +691,6 @@ thread_do_start(rb_thread_t *th) } void rb_ec_clear_current_thread_trace_func(const rb_execution_context_t *ec); -rb_control_frame_t * -rb_vm_push_frame(rb_execution_context_t *sec, - const rb_iseq_t *iseq, - VALUE type, - VALUE self, - VALUE specval, - VALUE cref_or_me, - const VALUE *pc, - VALUE *sp, - int local_size, - int stack_max); static int thread_start_func_2(rb_thread_t *th, VALUE *stack_start) diff --git a/vm.c b/vm.c index f678a16ba5a683..13b302a27bb14d 100644 --- a/vm.c +++ b/vm.c @@ -2662,7 +2662,7 @@ rb_ec_initialize_vm_stack(rb_execution_context_t *ec, VALUE *stack, size_t size) ec->cfp = (void *)(ec->vm_stack + ec->vm_stack_size); - rb_vm_push_frame(ec, + vm_push_frame(ec, NULL /* dummy iseq */, VM_FRAME_MAGIC_DUMMY | VM_ENV_FLAG_LOCAL | VM_FRAME_FLAG_FINISH | VM_FRAME_FLAG_CFRAME /* dummy frame */, Qnil /* dummy self */, VM_BLOCK_HANDLER_NONE /* dummy block ptr */, diff --git a/vm_insnhelper.c b/vm_insnhelper.c index c5584d4d4053d8..57f6d91e884e1c 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -345,21 +345,6 @@ vm_push_frame(rb_execution_context_t *ec, return cfp; } -rb_control_frame_t * -rb_vm_push_frame(rb_execution_context_t *ec, - const rb_iseq_t *iseq, - VALUE type, - VALUE self, - VALUE specval, - VALUE cref_or_me, - const VALUE *pc, - VALUE *sp, - int local_size, - int stack_max) -{ - return vm_push_frame(ec, iseq, type, self, specval, cref_or_me, pc, sp, local_size, stack_max); -} - /* return TRUE if the frame is finished */ static inline int vm_pop_frame(rb_execution_context_t *ec, rb_control_frame_t *cfp, const VALUE *ep) From d7fdf45a4ae1bcb6fac30a24b025d4f20149ba0a Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Fri, 19 Jul 2019 11:09:52 +1200 Subject: [PATCH 282/452] Ensure cfp is initialized to NULL. `cont_init` didn't initialize `cont->saved_ec.cfp`. Calling `cont_mark` would result in an invalid `cfp` in `rb_execution_context_mark`. Because fibers lazy-initialize the stack, fibers that are created but not resumed could cause this problem to occur. --- cont.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cont.c b/cont.c index c0be42bffcde3a..984733db6e3c97 100644 --- a/cont.c +++ b/cont.c @@ -845,6 +845,8 @@ cont_mark(void *ptr) RUBY_MARK_ENTER("cont"); rb_gc_mark_no_pin(cont->value); + // Don't try to scan the vm_stack unless it's initialized. + // @sa cont_init, fiber_prepare_stack if (cont->saved_ec.cfp) { rb_execution_context_mark(&cont->saved_ec); } @@ -1083,6 +1085,10 @@ cont_init(rb_context_t *cont, rb_thread_t *th) { /* save thread context */ cont_save_thread(cont, th); + + // cfp is not valid until stack is initialized. + cont->saved_ec.cfp = NULL; + cont->saved_ec.thread_ptr = th; cont->saved_ec.local_storage = NULL; cont->saved_ec.local_storage_recursive_hash = Qnil; From c8ee44f44c0c7d333a33c62c811d1d0cdbc3554a Mon Sep 17 00:00:00 2001 From: aycabta Date: Fri, 19 Jul 2019 08:23:37 +0900 Subject: [PATCH 283/452] Fix showing doc of "nil.to_s", nil doesn't have #name --- lib/irb/completion.rb | 2 +- lib/reline/line_editor.rb | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/irb/completion.rb b/lib/irb/completion.rb index 84b1ad982c1b3d..f75dd0ebcd3e61 100644 --- a/lib/irb/completion.rb +++ b/lib/irb/completion.rb @@ -237,7 +237,7 @@ def self.retrieve_completion_data(input, doc_namespace = false) candidates.uniq! end if doc_namespace - "#{rec.name}#{sep}#{candidates.find{ |i| i == message }}" + "#{rec.class.name}#{sep}#{candidates.find{ |i| i == message }}" else select_message(receiver, message, candidates, sep) end diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb index 2f60c76aeef225..a238e4954cbb4d 100644 --- a/lib/reline/line_editor.rb +++ b/lib/reline/line_editor.rb @@ -255,12 +255,15 @@ def rerender # TODO: support physical and logical lines move_cursor_up(@highest_in_all - 1 - @first_line_started_from) @menu_info = nil end + special_prompt = nil if @vi_arg prompt = "(arg: #{@vi_arg}) " prompt_width = calculate_width(prompt) + special_prompt = prompt elsif @searching_prompt prompt = @searching_prompt prompt_width = calculate_width(prompt) + special_prompt = prompt else prompt = @prompt prompt_width = calculate_width(prompt, true) @@ -272,6 +275,7 @@ def rerender # TODO: support physical and logical lines prompt_list = nil if @prompt_proc prompt_list = @prompt_proc.(whole_lines) + prompt_list[@line_index] = special_prompt if special_prompt prompt = prompt_list[@line_index] prompt_width = calculate_width(prompt, true) end @@ -303,6 +307,7 @@ def rerender # TODO: support physical and logical lines prompt_list = nil if @prompt_proc prompt_list = @prompt_proc.(new_lines) + prompt_list[@line_index] = special_prompt if special_prompt prompt = prompt_list[@line_index] prompt_width = calculate_width(prompt, true) end @@ -372,6 +377,7 @@ def rerender # TODO: support physical and logical lines prompt_list = nil if @prompt_proc prompt_list = @prompt_proc.(new_buffer) + prompt_list[@line_index] = special_prompt if special_prompt prompt = prompt_list[@line_index] prompt_width = calculate_width(prompt, true) end @@ -429,6 +435,7 @@ def rerender # TODO: support physical and logical lines prompt_list = nil if @prompt_proc prompt_list = @prompt_proc.(whole_lines) + prompt_list[@line_index] = special_prompt if special_prompt prompt = prompt_list[@line_index] prompt_width = calculate_width(prompt, true) end From 8ca32020b03a4f3e69c8f0b15e015eb7ad5d8e05 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Fri, 19 Jul 2019 11:32:40 +1200 Subject: [PATCH 284/452] Revert "Ensure cfp is initialized to NULL." This reverts commit d7fdf45a4ae1bcb6fac30a24b025d4f20149ba0a. --- cont.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/cont.c b/cont.c index 984733db6e3c97..c0be42bffcde3a 100644 --- a/cont.c +++ b/cont.c @@ -845,8 +845,6 @@ cont_mark(void *ptr) RUBY_MARK_ENTER("cont"); rb_gc_mark_no_pin(cont->value); - // Don't try to scan the vm_stack unless it's initialized. - // @sa cont_init, fiber_prepare_stack if (cont->saved_ec.cfp) { rb_execution_context_mark(&cont->saved_ec); } @@ -1085,10 +1083,6 @@ cont_init(rb_context_t *cont, rb_thread_t *th) { /* save thread context */ cont_save_thread(cont, th); - - // cfp is not valid until stack is initialized. - cont->saved_ec.cfp = NULL; - cont->saved_ec.thread_ptr = th; cont->saved_ec.local_storage = NULL; cont->saved_ec.local_storage_recursive_hash = Qnil; From 4ec5b39ce8bd3b13dec0ac290b2d7d29c640b304 Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Fri, 19 Jul 2019 08:53:19 +0900 Subject: [PATCH 285/452] initialize only Fiber's cfp. fiber->cont.saved_ec.cfp should be initialized by NULL because no vm_stack is allocated. However, cont_init() captures current Fiber's cfp for continuation, so it should only initialize fibers. --- cont.c | 1 + 1 file changed, 1 insertion(+) diff --git a/cont.c b/cont.c index c0be42bffcde3a..c97c4914199f3d 100644 --- a/cont.c +++ b/cont.c @@ -1702,6 +1702,7 @@ fiber_t_alloc(VALUE fiber_value) fiber->cont.type = FIBER_CONTEXT; cont_init(&fiber->cont, th); fiber->cont.saved_ec.fiber_ptr = fiber; + fiber->cont.saved_ec.cfp = NULL; fiber->prev = NULL; /* fiber->status == 0 == CREATED From e644e2de85d0d76e1c28d45710f765757a22f5c6 Mon Sep 17 00:00:00 2001 From: Kazuhiro NISHIYAMA Date: Fri, 19 Jul 2019 09:00:55 +0900 Subject: [PATCH 286/452] Remove doc/etc.rd.ja [ci skip] [Feature #16003] [ruby-dev:50814] --- doc/etc.rd.ja | 75 --------------------------------------------------- 1 file changed, 75 deletions(-) delete mode 100644 doc/etc.rd.ja diff --git a/doc/etc.rd.ja b/doc/etc.rd.ja deleted file mode 100644 index 5d64594fc3b095..00000000000000 --- a/doc/etc.rd.ja +++ /dev/null @@ -1,75 +0,0 @@ -# etc.rd.ja - -*- mode: rd; coding: utf-8; -*- created at: Fri Jul 14 00:47:15 JST 1995 -=begin - -= Etc(モジュール) - -実行しているOSからの情報を得るためのモジュール.クラスにインクルード -して使うこともできる. - -== Module Function - ---- getlogin - - 自分のlogin名を返す.これが失敗した場合はgetpwuid()を用いると - 良い. - ---- getpwnam(name) - - /etc/passwdファイル(あるいはDBMファイルやNISデータベース)を検 - 索し,nameの名前を持つpasswdエントリを返す.戻り値はpasswd構造 - 体で以下のメンバを持つ. - - struct passwd - name # ユーザ名(文字列) - passwd # パスワード(文字列) - uid # ユーザID(整数) - gid # グループID(整数) - gecos # gecosフィールド(文字列) - dir # ホームディレクトリ(文字列) - shell # ログインシェル(文字列) - # 以降のメンバはシステムによっては提供されない. - change # パスワード変更時間(整数) - quota # クォータ(整数) - age # エージ(整数) - uclass # ユーザアクセスクラス(文字列) - comment # コメント(文字列) - expire # アカウント有効期限(整数) - end - - 詳細はgetpwnam(3)を参照のこと. - ---- getpwuid([uid]) - - uidをユーザIDとするpasswdエントリを返す.戻り値はgetpwnam()と - 同様である.引数を省略した場合にはgetuid()の値を用いる.詳細は - getpwuid(3)を参照のこと. - ---- getgrgid(gid) - - /etc/groupファイル(あるいは…getpwnam参照)を検索し,gidをグルー - プIDとするグループエントリを返す.戻り値はgroup構造体で以下の - メンバを持つ. - - struct group - name # グループ名(文字列) - passwd # グループのパスワード(文字列) - gid # グループID(整数) - mem # グループメンバ名の配列 - end - - 詳細はgetgrgid(3)を参照のこと. - ---- getgrnam(name) - - nameという名前のグループエントリを返す.戻り値はgetgrgid()と同 - 様である.詳細はgetgrnam(3)を参照. - ---- group - - 全てのグループエントリを順にアクセスするためのイテレータ. - ---- passwd - - 全てのpasswdエントリを順にアクセスするためのイテレータ. - -=end From 63160a84b42cd3a7924e5abe94bbb08bb566f24b Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Fri, 19 Jul 2019 12:04:32 +0900 Subject: [PATCH 287/452] respect NDEBUG. ruby/ruby.h includes ruby/assert.h, and RUBY_NDEBUG is defined by checking NDEBUG. In other words, NDEBUG is only seen just after ruby/ruby.h. This patch also cheks NDEBUG just after including ruby_assert.h. Without this patch, assertions in array.c are always enabled. --- ruby_assert.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ruby_assert.h b/ruby_assert.h index 139256fed8cb76..fa15da1e25eb38 100644 --- a/ruby_assert.h +++ b/ruby_assert.h @@ -8,3 +8,8 @@ #undef assert #define assert RUBY_ASSERT #endif + +#ifdef NDEBUG + #undef RUBY_NDEBUG + #define RUBY_NDEBUG 1 +#endif From 6eef80d824aa4aca91ff13ea215f5cd053d16906 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Fri, 19 Jul 2019 14:54:31 +1200 Subject: [PATCH 288/452] Improve ec assertions. --- cont.c | 8 -------- vm.c | 16 +++++++--------- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/cont.c b/cont.c index c97c4914199f3d..530590749850fa 100644 --- a/cont.c +++ b/cont.c @@ -759,14 +759,6 @@ fiber_verify(const rb_fiber_t *fiber) #endif } -#if VM_CHECK_MODE > 0 -void -rb_ec_verify(const rb_execution_context_t *ec) -{ - /* TODO */ -} -#endif - inline static void fiber_status_set(rb_fiber_t *fiber, enum fiber_status s) { diff --git a/vm.c b/vm.c index 13b302a27bb14d..c030be644fd239 100644 --- a/vm.c +++ b/vm.c @@ -2443,6 +2443,8 @@ rb_execution_context_update(const rb_execution_context_t *ec) { /* update VM stack */ if (ec->vm_stack) { + VM_ASSERT(ec->cfp); + rb_control_frame_t *cfp = ec->cfp; rb_control_frame_t *limit_cfp = (void *)(ec->vm_stack + ec->vm_stack_size); @@ -2461,23 +2463,17 @@ rb_execution_context_update(const rb_execution_context_t *ec) cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp); } + } else { + VM_ASSERT(!ec->cfp); } -#if VM_CHECK_MODE > 0 - void rb_ec_verify(const rb_execution_context_t *ec); /* cont.c */ - rb_ec_verify(ec); -#endif } void rb_execution_context_mark(const rb_execution_context_t *ec) { -#if VM_CHECK_MODE > 0 - void rb_ec_verify(const rb_execution_context_t *ec); /* cont.c */ - rb_ec_verify(ec); -#endif - /* mark VM stack */ if (ec->vm_stack) { + VM_ASSERT(ec->cfp); VALUE *p = ec->vm_stack; VALUE *sp = ec->cfp->sp; rb_control_frame_t *cfp = ec->cfp; @@ -2501,6 +2497,8 @@ rb_execution_context_mark(const rb_execution_context_t *ec) cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp); } + } else { + VM_ASSERT(!ec->cfp); } /* mark machine stack */ From cf93f98a609d8a48e3b69790bc38ae9edf8aa687 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Fri, 19 Jul 2019 15:45:44 +1200 Subject: [PATCH 289/452] Better usage of `rb_ec_clear_vm_stack` to maintain invariants. --- cont.c | 13 +++++++------ vm.c | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/cont.c b/cont.c index 530590749850fa..8f117e2a551d90 100644 --- a/cont.c +++ b/cont.c @@ -720,7 +720,6 @@ fiber_stack_release(rb_fiber_t * fiber) // The stack is no longer associated with this execution context: rb_ec_clear_vm_stack(ec); - ec->cfp = NULL; } static const char * @@ -837,9 +836,7 @@ cont_mark(void *ptr) RUBY_MARK_ENTER("cont"); rb_gc_mark_no_pin(cont->value); - if (cont->saved_ec.cfp) { - rb_execution_context_mark(&cont->saved_ec); - } + rb_execution_context_mark(&cont->saved_ec); rb_gc_mark(cont_thread_value(cont)); if (cont->saved_vm_stack.ptr) { @@ -1157,7 +1154,9 @@ cont_capture(volatile int *volatile stat) cont->saved_vm_stack.ptr = ALLOC_N(VALUE, ec->vm_stack_size); MEMCPY(cont->saved_vm_stack.ptr, ec->vm_stack, VALUE, ec->vm_stack_size); #endif - rb_ec_clear_vm_stack(&cont->saved_ec); + // At this point, `cfp` is valid but `vm_stack` should be cleared: + rb_ec_set_vm_stack(&cont->saved_ec, NULL, 0); + VM_ASSERT(cont->saved_ec.cfp != NULL); cont_save_machine_stack(th, cont); /* backup ensure_list to array for search in another context */ @@ -1693,8 +1692,10 @@ fiber_t_alloc(VALUE fiber_value) fiber->cont.self = fiber_value; fiber->cont.type = FIBER_CONTEXT; cont_init(&fiber->cont, th); + fiber->cont.saved_ec.fiber_ptr = fiber; - fiber->cont.saved_ec.cfp = NULL; + rb_ec_clear_vm_stack(&fiber->cont.saved_ec); + fiber->prev = NULL; /* fiber->status == 0 == CREATED diff --git a/vm.c b/vm.c index c030be644fd239..7cebff352cf7c1 100644 --- a/vm.c +++ b/vm.c @@ -2675,7 +2675,7 @@ rb_ec_clear_vm_stack(rb_execution_context_t *ec) rb_ec_set_vm_stack(ec, NULL, 0); // Avoid dangling pointers: - // ec->cfp = NULL; + ec->cfp = NULL; } static void From dd0e33f0839124a910f4eb0bb67423e041036645 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Fri, 19 Jul 2019 15:53:47 +1200 Subject: [PATCH 290/452] Split assertions to check which one fails. --- coroutine/copy/Context.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/coroutine/copy/Context.h b/coroutine/copy/Context.h index 0b6e3a9be0d3bb..03ee80f0ec6e30 100644 --- a/coroutine/copy/Context.h +++ b/coroutine/copy/Context.h @@ -64,7 +64,9 @@ static inline void coroutine_initialize( size_t size, void *base ) { - assert(start && stack && size >= 1024); + assert(start); + assert(stack); + assert(size >= 1024); coroutine_initialize_main(context, stack, size, base); From e14f5762c532241706ad5bd8f81b520c46d97654 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Fri, 19 Jul 2019 15:55:34 +1200 Subject: [PATCH 291/452] Add assertions to `coroutine_initialize_main`. --- coroutine/copy/Context.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/coroutine/copy/Context.h b/coroutine/copy/Context.h index 03ee80f0ec6e30..1319f55d1641e5 100644 --- a/coroutine/copy/Context.h +++ b/coroutine/copy/Context.h @@ -46,6 +46,9 @@ COROUTINE coroutine_restore_stack(struct coroutine_context *context); // @param size The size of the private stack area. // @param base A stack pointer to the base of the main stack. On x86 hardware, this is the upper extent of the region that will be copied to the private stack. static inline void coroutine_initialize_main(struct coroutine_context *context, void *stack, size_t size, void *base) { + assert(stack); + assert(size >= 1024); + context->stack = stack; context->size = size; context->used = 0; @@ -65,8 +68,6 @@ static inline void coroutine_initialize( void *base ) { assert(start); - assert(stack); - assert(size >= 1024); coroutine_initialize_main(context, stack, size, base); From 547f574b639cd8586568ebb8570c51faf102c313 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Fri, 19 Jul 2019 16:03:47 +1200 Subject: [PATCH 292/452] In some situations, `vm_stack` can be NULL, but `cfp` is valid. --- vm.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/vm.c b/vm.c index 7cebff352cf7c1..86b0e6075fb596 100644 --- a/vm.c +++ b/vm.c @@ -2463,8 +2463,6 @@ rb_execution_context_update(const rb_execution_context_t *ec) cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp); } - } else { - VM_ASSERT(!ec->cfp); } } @@ -2497,8 +2495,6 @@ rb_execution_context_mark(const rb_execution_context_t *ec) cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp); } - } else { - VM_ASSERT(!ec->cfp); } /* mark machine stack */ From 182ae1407b3f6597cdbf6872f788c1ed3aa22a35 Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Fri, 19 Jul 2019 13:02:38 +0900 Subject: [PATCH 293/452] fix shared array terminology. Shared arrays created by Array#dup and so on points a shared_root object to manage lifetime of Array buffer. However, sometimes shared_root is called only shared so it is confusing. So I fixed these wording "shared" to "shared_root". * RArray::heap::aux::shared -> RArray::heap::aux::shared_root * ARY_SHARED() -> ARY_SHARED_ROOT() * ARY_SHARED_NUM() -> ARY_SHARED_ROOT_REFCNT() Also, add some debug_counters to count shared array objects. * ary_shared_create: shared ary by Array#dup and so on. * ary_shared: finished in shard. * ary_shared_root_occupied: shared_root but has only 1 refcnt. The number (ary_shared - ary_shared_root_occupied) is meaningful. --- array.c | 115 ++++++++++++++++++++++++-------------------- debug_counter.h | 9 ++++ gc.c | 6 +-- include/ruby/ruby.h | 2 +- 4 files changed, 75 insertions(+), 57 deletions(-) diff --git a/array.c b/array.c index c693b007554a1d..a84361f05cd9b3 100644 --- a/array.c +++ b/array.c @@ -10,7 +10,6 @@ Copyright (C) 2000 Information-technology Promotion Agency, Japan **********************************************************************/ - #include "ruby/encoding.h" #include "ruby/util.h" #include "ruby/st.h" @@ -116,21 +115,21 @@ VALUE rb_cArray; RARRAY(ary)->as.heap.aux.capa = (n); \ } while (0) -#define ARY_SHARED(ary) (assert(ARY_SHARED_P(ary)), RARRAY(ary)->as.heap.aux.shared) +#define ARY_SHARED_ROOT(ary) (assert(ARY_SHARED_P(ary)), RARRAY(ary)->as.heap.aux.shared_root) #define ARY_SET_SHARED(ary, value) do { \ const VALUE _ary_ = (ary); \ const VALUE _value_ = (value); \ assert(!ARY_EMBED_P(_ary_)); \ assert(ARY_SHARED_P(_ary_)); \ assert(ARY_SHARED_ROOT_P(_value_)); \ - RB_OBJ_WRITE(_ary_, &RARRAY(_ary_)->as.heap.aux.shared, _value_); \ + RB_OBJ_WRITE(_ary_, &RARRAY(_ary_)->as.heap.aux.shared_root, _value_); \ } while (0) #define RARRAY_SHARED_ROOT_FLAG FL_USER5 #define ARY_SHARED_ROOT_P(ary) (FL_TEST((ary), RARRAY_SHARED_ROOT_FLAG)) -#define ARY_SHARED_NUM(ary) \ +#define ARY_SHARED_ROOT_REFCNT(ary) \ (assert(ARY_SHARED_ROOT_P(ary)), RARRAY(ary)->as.heap.aux.capa) -#define ARY_SHARED_OCCUPIED(ary) (ARY_SHARED_NUM(ary) == 1) -#define ARY_SET_SHARED_NUM(ary, value) do { \ +#define ARY_SHARED_ROOT_OCCUPIED(ary) (ARY_SHARED_ROOT_REFCNT(ary) == 1) +#define ARY_SET_SHARED_ROOT_REFCNT(ary, value) do { \ assert(ARY_SHARED_ROOT_P(ary)); \ RARRAY(ary)->as.heap.aux.capa = (value); \ } while (0) @@ -160,7 +159,7 @@ ary_verify_(VALUE ary, const char *file, int line) assert(RB_TYPE_P(ary, T_ARRAY)); if (FL_TEST(ary, ELTS_SHARED)) { - VALUE root = RARRAY(ary)->as.heap.aux.shared; + VALUE root = RARRAY(ary)->as.heap.aux.shared_root; const VALUE *ptr = ARY_HEAP_PTR(ary); const VALUE *root_ptr = RARRAY_CONST_PTR_TRANSIENT(root); long len = ARY_HEAP_LEN(ary), root_len = RARRAY_LEN(root); @@ -470,16 +469,16 @@ ary_double_capa(VALUE ary, long min) } static void -rb_ary_decrement_share(VALUE shared) +rb_ary_decrement_share(VALUE shared_root) { - if (shared) { - long num = ARY_SHARED_NUM(shared) - 1; + if (shared_root) { + long num = ARY_SHARED_ROOT_REFCNT(shared_root) - 1; if (num == 0) { - rb_ary_free(shared); - rb_gc_force_recycle(shared); + rb_ary_free(shared_root); + rb_gc_force_recycle(shared_root); } else if (num > 0) { - ARY_SET_SHARED_NUM(shared, num); + ARY_SET_SHARED_ROOT_REFCNT(shared_root, num); } } } @@ -487,8 +486,8 @@ rb_ary_decrement_share(VALUE shared) static void rb_ary_unshare(VALUE ary) { - VALUE shared = RARRAY(ary)->as.heap.aux.shared; - rb_ary_decrement_share(shared); + VALUE shared_root = RARRAY(ary)->as.heap.aux.shared_root; + rb_ary_decrement_share(shared_root); FL_UNSET_SHARED(ary); } @@ -501,21 +500,22 @@ rb_ary_unshare_safe(VALUE ary) } static VALUE -rb_ary_increment_share(VALUE shared) +rb_ary_increment_share(VALUE shared_root) { - long num = ARY_SHARED_NUM(shared); + long num = ARY_SHARED_ROOT_REFCNT(shared_root); if (num >= 0) { - ARY_SET_SHARED_NUM(shared, num + 1); + ARY_SET_SHARED_ROOT_REFCNT(shared_root, num + 1); } - return shared; + return shared_root; } static void -rb_ary_set_shared(VALUE ary, VALUE shared) +rb_ary_set_shared(VALUE ary, VALUE shared_root) { - rb_ary_increment_share(shared); + rb_ary_increment_share(shared_root); FL_SET_SHARED(ary); - ARY_SET_SHARED(ary, shared); + RB_DEBUG_COUNTER_INC(obj_ary_shared_create); + ARY_SET_SHARED(ary, shared_root); } static inline void @@ -531,28 +531,28 @@ rb_ary_modify(VALUE ary) rb_ary_modify_check(ary); if (ARY_SHARED_P(ary)) { long shared_len, len = RARRAY_LEN(ary); - VALUE shared = ARY_SHARED(ary); + VALUE shared_root = ARY_SHARED_ROOT(ary); - ary_verify(shared); + ary_verify(shared_root); if (len <= RARRAY_EMBED_LEN_MAX) { const VALUE *ptr = ARY_HEAP_PTR(ary); FL_UNSET_SHARED(ary); FL_SET_EMBED(ary); MEMCPY((VALUE *)ARY_EMBED_PTR(ary), ptr, VALUE, len); - rb_ary_decrement_share(shared); + rb_ary_decrement_share(shared_root); ARY_SET_EMBED_LEN(ary, len); } - else if (ARY_SHARED_OCCUPIED(shared) && len > ((shared_len = RARRAY_LEN(shared))>>1)) { - long shift = RARRAY_CONST_PTR_TRANSIENT(ary) - RARRAY_CONST_PTR_TRANSIENT(shared); + else if (ARY_SHARED_ROOT_OCCUPIED(shared_root) && len > ((shared_len = RARRAY_LEN(shared_root))>>1)) { + long shift = RARRAY_CONST_PTR_TRANSIENT(ary) - RARRAY_CONST_PTR_TRANSIENT(shared_root); FL_UNSET_SHARED(ary); - ARY_SET_PTR(ary, RARRAY_CONST_PTR_TRANSIENT(shared)); + ARY_SET_PTR(ary, RARRAY_CONST_PTR_TRANSIENT(shared_root)); ARY_SET_CAPA(ary, shared_len); RARRAY_PTR_USE_TRANSIENT(ary, ptr, { MEMMOVE(ptr, ptr+shift, VALUE, len); }); - FL_SET_EMBED(shared); - rb_ary_decrement_share(shared); + FL_SET_EMBED(shared_root); + rb_ary_decrement_share(shared_root); } else { VALUE *ptr = ary_heap_alloc(ary, len); @@ -579,14 +579,14 @@ ary_ensure_room_for_push(VALUE ary, long add_len) } if (ARY_SHARED_P(ary)) { if (new_len > RARRAY_EMBED_LEN_MAX) { - VALUE shared = ARY_SHARED(ary); - if (ARY_SHARED_OCCUPIED(shared)) { - if (ARY_HEAP_PTR(ary) - RARRAY_CONST_PTR_TRANSIENT(shared) + new_len <= RARRAY_LEN(shared)) { + VALUE shared_root = ARY_SHARED_ROOT(ary); + if (ARY_SHARED_ROOT_OCCUPIED(shared_root)) { + if (ARY_HEAP_PTR(ary) - RARRAY_CONST_PTR_TRANSIENT(shared_root) + new_len <= RARRAY_LEN(shared_root)) { rb_ary_modify_check(ary); ary_verify(ary); - ary_verify(shared); - return shared; + ary_verify(shared_root); + return shared_root; } else { /* if array is shared, then it is likely it participate in push/shift pattern */ @@ -643,7 +643,7 @@ rb_ary_shared_with_p(VALUE ary1, VALUE ary2) { if (!ARY_EMBED_P(ary1) && ARY_SHARED_P(ary1) && !ARY_EMBED_P(ary2) && ARY_SHARED_P(ary2) && - RARRAY(ary1)->as.heap.aux.shared == RARRAY(ary2)->as.heap.aux.shared && + RARRAY(ary1)->as.heap.aux.shared_root == RARRAY(ary2)->as.heap.aux.shared_root && RARRAY(ary1)->as.heap.len == RARRAY(ary2)->as.heap.len) { return Qtrue; } @@ -778,6 +778,13 @@ rb_ary_free(VALUE ary) else { RB_DEBUG_COUNTER_INC(obj_ary_embed); } + + if (ARY_SHARED_P(ary)) { + RB_DEBUG_COUNTER_INC(obj_ary_shared); + } + if (ARY_SHARED_ROOT_P(ary) && ARY_SHARED_ROOT_OCCUPIED(ary)) { + RB_DEBUG_COUNTER_INC(obj_ary_shared_root_occupied); + } } RUBY_FUNC_EXPORTED size_t @@ -806,7 +813,7 @@ ary_make_shared(VALUE ary) ary_verify(ary); if (ARY_SHARED_P(ary)) { - return ARY_SHARED(ary); + return ARY_SHARED_ROOT(ary); } else if (ARY_SHARED_ROOT_P(ary)) { return ary; @@ -815,7 +822,7 @@ ary_make_shared(VALUE ary) rb_ary_transient_heap_evacuate(ary, TRUE); ary_shrink_capa(ary); FL_SET_SHARED_ROOT(ary); - ARY_SET_SHARED_NUM(ary, 1); + ARY_SET_SHARED_ROOT_REFCNT(ary, 1); return ary; } else { @@ -831,13 +838,15 @@ ary_make_shared(VALUE ary) ARY_SET_PTR((VALUE)shared, ptr); ary_mem_clear((VALUE)shared, len, capa - len); FL_SET_SHARED_ROOT(shared); - ARY_SET_SHARED_NUM((VALUE)shared, 1); + ARY_SET_SHARED_ROOT_REFCNT((VALUE)shared, 1); FL_SET_SHARED(ary); + RB_DEBUG_COUNTER_INC(obj_ary_shared_create); ARY_SET_SHARED(ary, (VALUE)shared); OBJ_FREEZE(shared); ary_verify((VALUE)shared); ary_verify(ary); + return (VALUE)shared; } } @@ -1279,7 +1288,7 @@ rb_ary_shift(VALUE ary) ARY_SET(ary, 0, Qnil); ary_make_shared(ary); } - else if (ARY_SHARED_OCCUPIED(ARY_SHARED(ary))) { + else if (ARY_SHARED_ROOT_OCCUPIED(ARY_SHARED_ROOT(ary))) { RARRAY_PTR_USE_TRANSIENT(ary, ptr, ptr[0] = Qnil); } ARY_INCREASE_PTR(ary, 1); /* shift ptr */ @@ -1338,7 +1347,7 @@ rb_ary_behead(VALUE ary, long n) rb_ary_modify_check(ary); if (ARY_SHARED_P(ary)) { - if (ARY_SHARED_OCCUPIED(ARY_SHARED(ary))) { + if (ARY_SHARED_ROOT_OCCUPIED(ARY_SHARED_ROOT(ary))) { setup_occupied_shared: ary_mem_clear(ary, 0, n); } @@ -1374,12 +1383,12 @@ ary_ensure_room_for_unshift(VALUE ary, int argc) } if (ARY_SHARED_P(ary)) { - VALUE shared = ARY_SHARED(ary); - capa = RARRAY_LEN(shared); - if (ARY_SHARED_OCCUPIED(shared) && capa > new_len) { + VALUE shared_root = ARY_SHARED_ROOT(ary); + capa = RARRAY_LEN(shared_root); + if (ARY_SHARED_ROOT_OCCUPIED(shared_root) && capa > new_len) { rb_ary_modify_check(ary); head = RARRAY_CONST_PTR_TRANSIENT(ary); - sharedp = RARRAY_CONST_PTR_TRANSIENT(shared); + sharedp = RARRAY_CONST_PTR_TRANSIENT(shared_root); goto makeroom_if_need; } } @@ -1410,10 +1419,10 @@ ary_ensure_room_for_unshift(VALUE ary, int argc) head = sharedp + argc + room; } ARY_SET_PTR(ary, head - argc); - assert(ARY_SHARED_OCCUPIED(ARY_SHARED(ary))); + assert(ARY_SHARED_ROOT_OCCUPIED(ARY_SHARED_ROOT(ary))); ary_verify(ary); - return ARY_SHARED(ary); + return ARY_SHARED_ROOT(ary); } else { /* sliding items */ @@ -3784,24 +3793,24 @@ rb_ary_replace(VALUE copy, VALUE orig) if (copy == orig) return copy; if (RARRAY_LEN(orig) <= RARRAY_EMBED_LEN_MAX) { - VALUE shared = 0; + VALUE shared_root = 0; if (ARY_OWNS_HEAP_P(copy)) { ary_heap_free(copy); } else if (ARY_SHARED_P(copy)) { - shared = ARY_SHARED(copy); + shared_root = ARY_SHARED_ROOT(copy); FL_UNSET_SHARED(copy); } FL_SET_EMBED(copy); ary_memcpy(copy, 0, RARRAY_LEN(orig), RARRAY_CONST_PTR_TRANSIENT(orig)); - if (shared) { - rb_ary_decrement_share(shared); + if (shared_root) { + rb_ary_decrement_share(shared_root); } ARY_SET_LEN(copy, RARRAY_LEN(orig)); } else { - VALUE shared = ary_make_shared(orig); + VALUE shared_root = ary_make_shared(orig); if (ARY_OWNS_HEAP_P(copy)) { ary_heap_free(copy); } @@ -3811,7 +3820,7 @@ rb_ary_replace(VALUE copy, VALUE orig) FL_UNSET_EMBED(copy); ARY_SET_PTR(copy, ARY_HEAP_PTR(orig)); ARY_SET_LEN(copy, ARY_HEAP_LEN(orig)); - rb_ary_set_shared(copy, shared); + rb_ary_set_shared(copy, shared_root); } ary_verify(copy); return copy; diff --git a/debug_counter.h b/debug_counter.h index f0444d719093c9..6e0313db3be3b2 100644 --- a/debug_counter.h +++ b/debug_counter.h @@ -206,6 +206,15 @@ RB_DEBUG_COUNTER(obj_str_fstr) RB_DEBUG_COUNTER(obj_ary_embed) RB_DEBUG_COUNTER(obj_ary_transient) RB_DEBUG_COUNTER(obj_ary_ptr) +/* + ary_shared_create: shared ary by Array#dup and so on. + ary_shared: finished in shard. + ary_shared_root_occupied: shared_root but has only 1 refcnt. + The number (ary_shared - ary_shared_root_occupied) is meaningful. + */ +RB_DEBUG_COUNTER(obj_ary_shared_create) +RB_DEBUG_COUNTER(obj_ary_shared) +RB_DEBUG_COUNTER(obj_ary_shared_root_occupied) RB_DEBUG_COUNTER(obj_hash_empty) RB_DEBUG_COUNTER(obj_hash_under4) diff --git a/gc.c b/gc.c index f1e9ecf47c0fae..060e1ed48bd31e 100644 --- a/gc.c +++ b/gc.c @@ -5083,7 +5083,7 @@ gc_mark_children(rb_objspace_t *objspace, VALUE obj) case T_ARRAY: if (FL_TEST(obj, ELTS_SHARED)) { - VALUE root = any->as.array.as.heap.aux.shared; + VALUE root = any->as.array.as.heap.aux.shared_root; gc_mark(objspace, root); } else { @@ -8007,7 +8007,7 @@ gc_update_object_references(rb_objspace_t *objspace, VALUE obj) case T_ARRAY: if (FL_TEST(obj, ELTS_SHARED)) { - UPDATE_IF_MOVED(objspace, any->as.array.as.heap.aux.shared); + UPDATE_IF_MOVED(objspace, any->as.array.as.heap.aux.shared_root); } else { gc_ref_update_array(objspace, obj); @@ -11219,7 +11219,7 @@ rb_raw_obj_info(char *buff, const int buff_size, VALUE obj) case T_ARRAY: if (FL_TEST(obj, ELTS_SHARED)) { APPENDF((BUFF_ARGS, "shared -> %s", - rb_obj_info(RARRAY(obj)->as.heap.aux.shared))); + rb_obj_info(RARRAY(obj)->as.heap.aux.shared_root))); } else if (FL_TEST(obj, RARRAY_EMBED_FLAG)) { APPENDF((BUFF_ARGS, "[%s%s] len: %d (embed)", diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h index 863102228b892b..c7ce5ba3bdb32d 100644 --- a/include/ruby/ruby.h +++ b/include/ruby/ruby.h @@ -1054,7 +1054,7 @@ struct RArray { long len; union { long capa; - VALUE shared; + VALUE shared_root; } aux; const VALUE *ptr; } heap; From a44ad9a1451eb86385339cfd72713ff764f1c820 Mon Sep 17 00:00:00 2001 From: git Date: Fri, 19 Jul 2019 13:10:08 +0900 Subject: [PATCH 294/452] * expand tabs. --- array.c | 38 +++++++++++++++++++------------------- include/ruby/ruby.h | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/array.c b/array.c index a84361f05cd9b3..f46bc554810165 100644 --- a/array.c +++ b/array.c @@ -472,13 +472,13 @@ static void rb_ary_decrement_share(VALUE shared_root) { if (shared_root) { - long num = ARY_SHARED_ROOT_REFCNT(shared_root) - 1; + long num = ARY_SHARED_ROOT_REFCNT(shared_root) - 1; if (num == 0) { - rb_ary_free(shared_root); - rb_gc_force_recycle(shared_root); + rb_ary_free(shared_root); + rb_gc_force_recycle(shared_root); } else if (num > 0) { - ARY_SET_SHARED_ROOT_REFCNT(shared_root, num); + ARY_SET_SHARED_ROOT_REFCNT(shared_root, num); } } } @@ -504,7 +504,7 @@ rb_ary_increment_share(VALUE shared_root) { long num = ARY_SHARED_ROOT_REFCNT(shared_root); if (num >= 0) { - ARY_SET_SHARED_ROOT_REFCNT(shared_root, num + 1); + ARY_SET_SHARED_ROOT_REFCNT(shared_root, num + 1); } return shared_root; } @@ -531,7 +531,7 @@ rb_ary_modify(VALUE ary) rb_ary_modify_check(ary); if (ARY_SHARED_P(ary)) { long shared_len, len = RARRAY_LEN(ary); - VALUE shared_root = ARY_SHARED_ROOT(ary); + VALUE shared_root = ARY_SHARED_ROOT(ary); ary_verify(shared_root); @@ -543,7 +543,7 @@ rb_ary_modify(VALUE ary) rb_ary_decrement_share(shared_root); ARY_SET_EMBED_LEN(ary, len); } - else if (ARY_SHARED_ROOT_OCCUPIED(shared_root) && len > ((shared_len = RARRAY_LEN(shared_root))>>1)) { + else if (ARY_SHARED_ROOT_OCCUPIED(shared_root) && len > ((shared_len = RARRAY_LEN(shared_root))>>1)) { long shift = RARRAY_CONST_PTR_TRANSIENT(ary) - RARRAY_CONST_PTR_TRANSIENT(shared_root); FL_UNSET_SHARED(ary); ARY_SET_PTR(ary, RARRAY_CONST_PTR_TRANSIENT(shared_root)); @@ -551,8 +551,8 @@ rb_ary_modify(VALUE ary) RARRAY_PTR_USE_TRANSIENT(ary, ptr, { MEMMOVE(ptr, ptr+shift, VALUE, len); }); - FL_SET_EMBED(shared_root); - rb_ary_decrement_share(shared_root); + FL_SET_EMBED(shared_root); + rb_ary_decrement_share(shared_root); } else { VALUE *ptr = ary_heap_alloc(ary, len); @@ -579,8 +579,8 @@ ary_ensure_room_for_push(VALUE ary, long add_len) } if (ARY_SHARED_P(ary)) { if (new_len > RARRAY_EMBED_LEN_MAX) { - VALUE shared_root = ARY_SHARED_ROOT(ary); - if (ARY_SHARED_ROOT_OCCUPIED(shared_root)) { + VALUE shared_root = ARY_SHARED_ROOT(ary); + if (ARY_SHARED_ROOT_OCCUPIED(shared_root)) { if (ARY_HEAP_PTR(ary) - RARRAY_CONST_PTR_TRANSIENT(shared_root) + new_len <= RARRAY_LEN(shared_root)) { rb_ary_modify_check(ary); @@ -643,7 +643,7 @@ rb_ary_shared_with_p(VALUE ary1, VALUE ary2) { if (!ARY_EMBED_P(ary1) && ARY_SHARED_P(ary1) && !ARY_EMBED_P(ary2) && ARY_SHARED_P(ary2) && - RARRAY(ary1)->as.heap.aux.shared_root == RARRAY(ary2)->as.heap.aux.shared_root && + RARRAY(ary1)->as.heap.aux.shared_root == RARRAY(ary2)->as.heap.aux.shared_root && RARRAY(ary1)->as.heap.len == RARRAY(ary2)->as.heap.len) { return Qtrue; } @@ -822,7 +822,7 @@ ary_make_shared(VALUE ary) rb_ary_transient_heap_evacuate(ary, TRUE); ary_shrink_capa(ary); FL_SET_SHARED_ROOT(ary); - ARY_SET_SHARED_ROOT_REFCNT(ary, 1); + ARY_SET_SHARED_ROOT_REFCNT(ary, 1); return ary; } else { @@ -1347,7 +1347,7 @@ rb_ary_behead(VALUE ary, long n) rb_ary_modify_check(ary); if (ARY_SHARED_P(ary)) { - if (ARY_SHARED_ROOT_OCCUPIED(ARY_SHARED_ROOT(ary))) { + if (ARY_SHARED_ROOT_OCCUPIED(ARY_SHARED_ROOT(ary))) { setup_occupied_shared: ary_mem_clear(ary, 0, n); } @@ -1383,9 +1383,9 @@ ary_ensure_room_for_unshift(VALUE ary, int argc) } if (ARY_SHARED_P(ary)) { - VALUE shared_root = ARY_SHARED_ROOT(ary); - capa = RARRAY_LEN(shared_root); - if (ARY_SHARED_ROOT_OCCUPIED(shared_root) && capa > new_len) { + VALUE shared_root = ARY_SHARED_ROOT(ary); + capa = RARRAY_LEN(shared_root); + if (ARY_SHARED_ROOT_OCCUPIED(shared_root) && capa > new_len) { rb_ary_modify_check(ary); head = RARRAY_CONST_PTR_TRANSIENT(ary); sharedp = RARRAY_CONST_PTR_TRANSIENT(shared_root); @@ -1419,10 +1419,10 @@ ary_ensure_room_for_unshift(VALUE ary, int argc) head = sharedp + argc + room; } ARY_SET_PTR(ary, head - argc); - assert(ARY_SHARED_ROOT_OCCUPIED(ARY_SHARED_ROOT(ary))); + assert(ARY_SHARED_ROOT_OCCUPIED(ARY_SHARED_ROOT(ary))); ary_verify(ary); - return ARY_SHARED_ROOT(ary); + return ARY_SHARED_ROOT(ary); } else { /* sliding items */ diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h index c7ce5ba3bdb32d..af561ff63802cf 100644 --- a/include/ruby/ruby.h +++ b/include/ruby/ruby.h @@ -1054,7 +1054,7 @@ struct RArray { long len; union { long capa; - VALUE shared_root; + VALUE shared_root; } aux; const VALUE *ptr; } heap; From ae750799c1b28b06d02e50cd26450b9903516526 Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Fri, 19 Jul 2019 14:37:59 +0900 Subject: [PATCH 295/452] Use FL_TEST_RAW() to check flags. FL_TEST() uses FL_ABLE() which test data types. However, in array.c we don't need to check it (all of them should be T_ARRAY), so I changed from FL_TEST() to FL_TEST_RAW() which does not check FL_ABLE(). Instead of FL_ABLE(), add assertion to check given object is a T_ARRAY object. For example, rb_ary_free() becomes slim: with FL_TEST(): 0000000000006a30 : 6a30: 40 f6 c7 07 test $0x7,%dil 6a34: 48 8b 07 mov (%rdi),%rax 6a37: 75 09 jne 6a42 6a39: 48 f7 c7 f7 ff ff ff test $0xfffffffffffffff7,%rdi 6a40: 75 1e jne 6a60 6a42: a9 00 00 00 02 test $0x2000000,%eax 6a47: 74 07 je 6a50 6a49: f3 c3 repz retq 6a4b: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1) 6a50: 48 8b 7f 20 mov 0x20(%rdi),%rdi 6a54: e9 00 00 00 00 jmpq 6a59 6a59: 0f 1f 80 00 00 00 00 nopl 0x0(%rax) 6a60: 89 c2 mov %eax,%edx 6a62: 83 e2 1f and $0x1f,%edx 6a65: 83 fa 1b cmp $0x1b,%edx 6a68: 74 d8 je 6a42 6a6a: f6 c4 60 test $0x60,%ah 6a6d: 74 d3 je 6a42 6a6f: eb d8 jmp 6a49 ``` with FL_TEST_RAW(): 0000000000006a30 : 6a30: 48 f7 07 00 60 00 02 testq $0x2006000,(%rdi) 6a37: 74 07 je 6a40 6a39: f3 c3 repz retq 6a3b: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1) 6a40: 48 8b 7f 20 mov 0x20(%rdi),%rdi 6a44: e9 00 00 00 00 jmpq 6a49 --- array.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/array.c b/array.c index f46bc554810165..ffeb884134d779 100644 --- a/array.c +++ b/array.c @@ -34,16 +34,20 @@ VALUE rb_cArray; #define ARY_MAX_SIZE (LONG_MAX / (int)sizeof(VALUE)) #define SMALL_ARRAY_LEN 16 -# define ARY_SHARED_P(ary) \ - (assert(!FL_TEST((ary), ELTS_SHARED) || !FL_TEST((ary), RARRAY_EMBED_FLAG)), \ - FL_TEST((ary),ELTS_SHARED)!=0) -# define ARY_EMBED_P(ary) \ - (assert(!FL_TEST((ary), ELTS_SHARED) || !FL_TEST((ary), RARRAY_EMBED_FLAG)), \ - FL_TEST((ary), RARRAY_EMBED_FLAG)!=0) +#define ARY_SHARED_P(ary) \ + (assert(RB_TYPE_P((VALUE)(ary), T_ARRAY)), \ + assert(!FL_TEST((ary), ELTS_SHARED) || !FL_TEST((ary), RARRAY_EMBED_FLAG)), \ + FL_TEST_RAW((ary),ELTS_SHARED)!=0) + +#define ARY_EMBED_P(ary) \ + (assert(RB_TYPE_P((VALUE)(ary), T_ARRAY)), \ + assert(!FL_TEST((ary), ELTS_SHARED) || !FL_TEST((ary), RARRAY_EMBED_FLAG)), \ + FL_TEST_RAW((ary), RARRAY_EMBED_FLAG) != 0) #define ARY_HEAP_PTR(a) (assert(!ARY_EMBED_P(a)), RARRAY(a)->as.heap.ptr) #define ARY_HEAP_LEN(a) (assert(!ARY_EMBED_P(a)), RARRAY(a)->as.heap.len) -#define ARY_HEAP_CAPA(a) (assert(!ARY_EMBED_P(a)), assert(!ARY_SHARED_ROOT_P(a)), RARRAY(a)->as.heap.aux.capa) +#define ARY_HEAP_CAPA(a) (assert(!ARY_EMBED_P(a)), assert(!ARY_SHARED_ROOT_P(a)), \ + RARRAY(a)->as.heap.aux.capa) #define ARY_EMBED_PTR(a) (assert(ARY_EMBED_P(a)), RARRAY(a)->as.ary) #define ARY_EMBED_LEN(a) \ @@ -52,13 +56,16 @@ VALUE rb_cArray; (RARRAY_EMBED_LEN_MASK >> RARRAY_EMBED_LEN_SHIFT))) #define ARY_HEAP_SIZE(a) (assert(!ARY_EMBED_P(a)), assert(ARY_OWNS_HEAP_P(a)), ARY_CAPA(a) * sizeof(VALUE)) -#define ARY_OWNS_HEAP_P(a) (!FL_TEST((a), ELTS_SHARED|RARRAY_EMBED_FLAG)) +#define ARY_OWNS_HEAP_P(a) (assert(RB_TYPE_P((a), T_ARRAY)), \ + !FL_TEST_RAW((a), ELTS_SHARED|RARRAY_EMBED_FLAG)) + #define FL_SET_EMBED(a) do { \ assert(!ARY_SHARED_P(a)); \ FL_SET((a), RARRAY_EMBED_FLAG); \ RARY_TRANSIENT_UNSET(a); \ ary_verify(a); \ } while (0) + #define FL_UNSET_EMBED(ary) FL_UNSET((ary), RARRAY_EMBED_FLAG|RARRAY_EMBED_LEN_MASK) #define FL_SET_SHARED(ary) do { \ assert(!ARY_EMBED_P(ary)); \ @@ -125,7 +132,8 @@ VALUE rb_cArray; RB_OBJ_WRITE(_ary_, &RARRAY(_ary_)->as.heap.aux.shared_root, _value_); \ } while (0) #define RARRAY_SHARED_ROOT_FLAG FL_USER5 -#define ARY_SHARED_ROOT_P(ary) (FL_TEST((ary), RARRAY_SHARED_ROOT_FLAG)) +#define ARY_SHARED_ROOT_P(ary) (assert(RB_TYPE_P((ary), T_ARRAY)), \ + FL_TEST_RAW((ary), RARRAY_SHARED_ROOT_FLAG)) #define ARY_SHARED_ROOT_REFCNT(ary) \ (assert(ARY_SHARED_ROOT_P(ary)), RARRAY(ary)->as.heap.aux.capa) #define ARY_SHARED_ROOT_OCCUPIED(ary) (ARY_SHARED_ROOT_REFCNT(ary) == 1) @@ -776,7 +784,7 @@ rb_ary_free(VALUE ary) } } else { - RB_DEBUG_COUNTER_INC(obj_ary_embed); + RB_DEBUG_COUNTER_INC(obj_ary_embed); } if (ARY_SHARED_P(ary)) { From fba3e76e3fded3534a34b21412c17af2b02a5f3d Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Fri, 19 Jul 2019 16:24:14 +0900 Subject: [PATCH 296/452] fix debug counter for Hash counts. Change debug_counters for Hash object counts: * obj_hash_under4 (1-3) -> obj_hash_1_4 (1-4) * obj_hash_ge4 (4-7) -> obj_hash_5_8 (5-8) * obj_hash_ge8 (>=8) -> obj_hash_g8 (> 8) For example on rdoc benchmark: [RUBY_DEBUG_COUNTER] obj_hash_empty 554,900 [RUBY_DEBUG_COUNTER] obj_hash_under4 572,998 [RUBY_DEBUG_COUNTER] obj_hash_ge4 1,825 [RUBY_DEBUG_COUNTER] obj_hash_ge8 2,344 [RUBY_DEBUG_COUNTER] obj_hash_empty 553,097 [RUBY_DEBUG_COUNTER] obj_hash_1_4 571,880 [RUBY_DEBUG_COUNTER] obj_hash_5_8 982 [RUBY_DEBUG_COUNTER] obj_hash_g8 2,189 --- debug_counter.h | 12 ++++++------ gc.c | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/debug_counter.h b/debug_counter.h index 6e0313db3be3b2..97b73127940b4c 100644 --- a/debug_counter.h +++ b/debug_counter.h @@ -174,9 +174,9 @@ RB_DEBUG_COUNTER(gc_isptr_maybe) * * str_nofree: nofree * * str_fstr: fstr * * hash_empty: hash is empty - * * hash_under4: has under 4 entries - * * hash_ge4: has n entries (4<=n<8) - * * hash_ge8: has n entries (8<=n) + * * hash_1_4: has 1 to 4 entries + * * hash_5_8: has 5 to 8 entries + * * hash_g8: has n entries (n>8) * * match_under4: has under 4 oniguruma regions allocated * * match_ge4: has n regions allocated (4<=n<8) * * match_ge8: has n regions allocated (8<=n) @@ -217,9 +217,9 @@ RB_DEBUG_COUNTER(obj_ary_shared) RB_DEBUG_COUNTER(obj_ary_shared_root_occupied) RB_DEBUG_COUNTER(obj_hash_empty) -RB_DEBUG_COUNTER(obj_hash_under4) -RB_DEBUG_COUNTER(obj_hash_ge4) -RB_DEBUG_COUNTER(obj_hash_ge8) +RB_DEBUG_COUNTER(obj_hash_1_4) +RB_DEBUG_COUNTER(obj_hash_5_8) +RB_DEBUG_COUNTER(obj_hash_g8) RB_DEBUG_COUNTER(obj_hash_ar) RB_DEBUG_COUNTER(obj_hash_st) RB_DEBUG_COUNTER(obj_hash_transient) diff --git a/gc.c b/gc.c index 060e1ed48bd31e..df48bc12699228 100644 --- a/gc.c +++ b/gc.c @@ -2410,14 +2410,14 @@ obj_free(rb_objspace_t *objspace, VALUE obj) break; case T_HASH: #if USE_DEBUG_COUNTER - if (RHASH_SIZE(obj) >= 8) { - RB_DEBUG_COUNTER_INC(obj_hash_ge8); + if (RHASH_SIZE(obj) > 8) { + RB_DEBUG_COUNTER_INC(obj_hash_g8); } - else if (RHASH_SIZE(obj) >= 4) { - RB_DEBUG_COUNTER_INC(obj_hash_ge4); + else if (RHASH_SIZE(obj) > 4) { + RB_DEBUG_COUNTER_INC(obj_hash_5_8); } - else if (RHASH_SIZE(obj) >= 1) { - RB_DEBUG_COUNTER_INC(obj_hash_under4); + else if (RHASH_SIZE(obj) > 0) { + RB_DEBUG_COUNTER_INC(obj_hash_1_4); } else { RB_DEBUG_COUNTER_INC(obj_hash_empty); From e004afd46d3bd27bda4c4922eadcf11c7e4bfc55 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Fri, 19 Jul 2019 19:42:00 +1200 Subject: [PATCH 297/452] Ensure that madvise does not clobber vacancy data. After calling `fiber_pool_vacancy_reset`, `vacancy->stack` and `stack` are no longer in sync. Therefore, `fiber_pool_stack_free(&vacancy->stack)` can do the wrong thing and clobber the vacancy data. Additionally, when testing using VM_CHECK_MODE > 0, use MADV_DONTNEED if possible, to catch issues w.r.t. clobbered vacancy data earlier. --- cont.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/cont.c b/cont.c index 8f117e2a551d90..ecbfc4f134b089 100644 --- a/cont.c +++ b/cont.c @@ -280,6 +280,8 @@ fiber_pool_stack_base(struct fiber_pool_stack * stack) { STACK_GROW_DIR_DETECTION; + VM_ASSERT(stack->current); + return STACK_DIR_UPPER(stack->current, (char*)stack->current - stack->available); } @@ -290,6 +292,7 @@ fiber_pool_stack_alloca(struct fiber_pool_stack * stack, size_t offset) { STACK_GROW_DIR_DETECTION; + if (DEBUG) fprintf(stderr, "fiber_pool_stack_alloca(%p): %zu/%zu\n", stack, offset, stack->available); VM_ASSERT(stack->available >= offset); // The pointer to the memory being allocated: @@ -590,6 +593,7 @@ fiber_pool_stack_acquire(struct fiber_pool * fiber_pool) { } VM_ASSERT(vacancy); + VM_ASSERT(vacancy->stack.base); // Take the top item from the free list: fiber_pool->used += 1; @@ -611,9 +615,15 @@ fiber_pool_stack_free(struct fiber_pool_stack * stack) void * base = fiber_pool_stack_base(stack); size_t size = stack->available; + // If this is true, the vacancy information will almost certainly be destroyed: + VM_ASSERT(size <= (stack->size - RB_PAGE_SIZE)); + if (DEBUG) fprintf(stderr, "fiber_pool_stack_free: %p+%zu [base=%p, size=%zu]\n", base, size, stack->base, stack->size); -#if defined(MADV_FREE_REUSABLE) +#if VM_CHECK_MODE > 0 && defined(MADV_DONTNEED) + // This immediately discards the pages and the memory is reset to zero. + madvise(base, size, MADV_DONTNEED); +#elif defined(MADV_FREE_REUSABLE) madvise(base, size, MADV_FREE_REUSABLE); #elif defined(MADV_FREE) madvise(base, size, MADV_FREE); @@ -630,21 +640,25 @@ fiber_pool_stack_free(struct fiber_pool_stack * stack) static void fiber_pool_stack_release(struct fiber_pool_stack * stack) { + struct fiber_pool * pool = stack->pool; struct fiber_pool_vacancy * vacancy = fiber_pool_vacancy_pointer(stack->base, stack->size); if (DEBUG) fprintf(stderr, "fiber_pool_stack_release: %p used=%zu\n", stack->base, stack->pool->used); // Copy the stack details into the vacancy area: vacancy->stack = *stack; + // After this point, be careful about updating/using state in stack, since it's copied to the vacancy area. // Reset the stack pointers and reserve space for the vacancy data: fiber_pool_vacancy_reset(vacancy); // Push the vacancy into the vancancies list: - stack->pool->vacancies = fiber_pool_vacancy_push(vacancy, stack->pool->vacancies); - stack->pool->used -= 1; + pool->vacancies = fiber_pool_vacancy_push(vacancy, stack->pool->vacancies); + pool->used -= 1; #ifdef FIBER_POOL_ALLOCATION_FREE + fiber_pool_allocation * allocation = stack->allocation; + stack->allocation->used -= 1; // Release address space and/or dirty memory: @@ -652,12 +666,12 @@ fiber_pool_stack_release(struct fiber_pool_stack * stack) fiber_pool_allocation_free(stack->allocation); } else if (stack->pool->free_stacks) { - fiber_pool_stack_free(stack); + fiber_pool_stack_free(&vacancy->stack); } #else // This is entirely optional, but clears the dirty flag from the stack memory, so it won't get swapped to disk when there is memory pressure: if (stack->pool->free_stacks) { - fiber_pool_stack_free(stack); + fiber_pool_stack_free(&vacancy->stack); } #endif } From 517f7f9b578f8f48ce80dfbe5c8e61b4f8ebd1d4 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Fri, 19 Jul 2019 20:09:03 +1200 Subject: [PATCH 298/452] Fix 32-bit build and typo. "Therefore, `fiber_pool_stack_free(&vacancy->stack)` can do the wrong thing..." should be "... `fiber_pool_stack_free(stack)` ...". --- cont.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cont.c b/cont.c index ecbfc4f134b089..b3b38e844a17ba 100644 --- a/cont.c +++ b/cont.c @@ -615,7 +615,7 @@ fiber_pool_stack_free(struct fiber_pool_stack * stack) void * base = fiber_pool_stack_base(stack); size_t size = stack->available; - // If this is true, the vacancy information will almost certainly be destroyed: + // If this is not true, the vacancy information will almost certainly be destroyed: VM_ASSERT(size <= (stack->size - RB_PAGE_SIZE)); if (DEBUG) fprintf(stderr, "fiber_pool_stack_free: %p+%zu [base=%p, size=%zu]\n", base, size, stack->base, stack->size); @@ -657,7 +657,7 @@ fiber_pool_stack_release(struct fiber_pool_stack * stack) pool->used -= 1; #ifdef FIBER_POOL_ALLOCATION_FREE - fiber_pool_allocation * allocation = stack->allocation; + struct fiber_pool_allocation * allocation = stack->allocation; stack->allocation->used -= 1; From 0a7093a8e9277d9f459b2c14f2eade02eed15e28 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Fri, 19 Jul 2019 20:18:42 +1200 Subject: [PATCH 299/452] Add documentation to `fiber_pool_allocate_memory`. --- cont.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cont.c b/cont.c index b3b38e844a17ba..409fbcc55db519 100644 --- a/cont.c +++ b/cont.c @@ -396,6 +396,12 @@ fiber_pool_vacancy_initialize(struct fiber_pool * fiber_pool, struct fiber_pool_ inline static void * fiber_pool_allocate_memory(size_t * count, size_t stride) { + // We use a divide-by-2 strategy to try and allocate memory. We are trying + // to allocate `count` stacks. In normal situation, this won't fail. But + // if we ran out of address space, or we are allocating more memory than + // the system would allow (e.g. overcommit * physical memory + swap), we + // divide count by two and try again. This condition should only be + // encountered in edge cases, but we handle it here gracefully. while (*count > 1) { #if defined(_WIN32) void * base = VirtualAlloc(0, (*count)*stride, MEM_COMMIT, PAGE_READWRITE); @@ -411,6 +417,7 @@ fiber_pool_allocate_memory(size_t * count, size_t stride) void * base = mmap(NULL, (*count)*stride, PROT_READ | PROT_WRITE, FIBER_STACK_FLAGS, -1, 0); if (base == MAP_FAILED) { + // If the allocation fails, count = count / 2, and try again. *count = (*count) >> 1; } else { From 3e8d4ff3e571bd556898efd94badb66a5dadf4d2 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Fri, 19 Jul 2019 23:41:24 +0900 Subject: [PATCH 300/452] array.c: factor out `assert(RB_TYPE_P(ary, T_ARRAY))` to a function The assertion blows up gcc 8 by consuming approx. 1.8 GB memory. This change reduces the amount of memory required to about 200 MB. A follow-up of ae750799c1b28b06d02e50cd26450b9903516526. --- array.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/array.c b/array.c index ffeb884134d779..a4652e6eb9c40b 100644 --- a/array.c +++ b/array.c @@ -34,13 +34,19 @@ VALUE rb_cArray; #define ARY_MAX_SIZE (LONG_MAX / (int)sizeof(VALUE)) #define SMALL_ARRAY_LEN 16 +static void +assert_T_ARRAY(VALUE ary) +{ + assert(RB_TYPE_P(ary, T_ARRAY)); +} + #define ARY_SHARED_P(ary) \ - (assert(RB_TYPE_P((VALUE)(ary), T_ARRAY)), \ + (assert_T_ARRAY((VALUE)(ary)), \ assert(!FL_TEST((ary), ELTS_SHARED) || !FL_TEST((ary), RARRAY_EMBED_FLAG)), \ FL_TEST_RAW((ary),ELTS_SHARED)!=0) #define ARY_EMBED_P(ary) \ - (assert(RB_TYPE_P((VALUE)(ary), T_ARRAY)), \ + (assert_T_ARRAY((VALUE)(ary)), \ assert(!FL_TEST((ary), ELTS_SHARED) || !FL_TEST((ary), RARRAY_EMBED_FLAG)), \ FL_TEST_RAW((ary), RARRAY_EMBED_FLAG) != 0) @@ -56,7 +62,7 @@ VALUE rb_cArray; (RARRAY_EMBED_LEN_MASK >> RARRAY_EMBED_LEN_SHIFT))) #define ARY_HEAP_SIZE(a) (assert(!ARY_EMBED_P(a)), assert(ARY_OWNS_HEAP_P(a)), ARY_CAPA(a) * sizeof(VALUE)) -#define ARY_OWNS_HEAP_P(a) (assert(RB_TYPE_P((a), T_ARRAY)), \ +#define ARY_OWNS_HEAP_P(a) (assert_T_ARRAY((VALUE)(a)), \ !FL_TEST_RAW((a), ELTS_SHARED|RARRAY_EMBED_FLAG)) #define FL_SET_EMBED(a) do { \ @@ -132,7 +138,7 @@ VALUE rb_cArray; RB_OBJ_WRITE(_ary_, &RARRAY(_ary_)->as.heap.aux.shared_root, _value_); \ } while (0) #define RARRAY_SHARED_ROOT_FLAG FL_USER5 -#define ARY_SHARED_ROOT_P(ary) (assert(RB_TYPE_P((ary), T_ARRAY)), \ +#define ARY_SHARED_ROOT_P(ary) (assert_T_ARRAY((VALUE)(ary)), \ FL_TEST_RAW((ary), RARRAY_SHARED_ROOT_FLAG)) #define ARY_SHARED_ROOT_REFCNT(ary) \ (assert(ARY_SHARED_ROOT_P(ary)), RARRAY(ary)->as.heap.aux.capa) From 0a16ff9f8366fd0d751191bd9c6eaa47f0ae33c8 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Fri, 19 Jul 2019 23:50:30 +0900 Subject: [PATCH 301/452] array.c: use assert in macro instead of in a function The old code lost information of lineno. Now, an assertion error will output a correct lineno (but now gcc 8 requires 250 MB, unfortunately). --- array.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/array.c b/array.c index a4652e6eb9c40b..0c5ea0acfea5e0 100644 --- a/array.c +++ b/array.c @@ -34,19 +34,19 @@ VALUE rb_cArray; #define ARY_MAX_SIZE (LONG_MAX / (int)sizeof(VALUE)) #define SMALL_ARRAY_LEN 16 -static void -assert_T_ARRAY(VALUE ary) +static int +should_be_T_ARRAY(VALUE ary) { - assert(RB_TYPE_P(ary, T_ARRAY)); + return RB_TYPE_P(ary, T_ARRAY); } #define ARY_SHARED_P(ary) \ - (assert_T_ARRAY((VALUE)(ary)), \ + (assert(should_be_T_ARRAY((VALUE)(ary))), \ assert(!FL_TEST((ary), ELTS_SHARED) || !FL_TEST((ary), RARRAY_EMBED_FLAG)), \ FL_TEST_RAW((ary),ELTS_SHARED)!=0) #define ARY_EMBED_P(ary) \ - (assert_T_ARRAY((VALUE)(ary)), \ + (assert(should_be_T_ARRAY((VALUE)(ary))), \ assert(!FL_TEST((ary), ELTS_SHARED) || !FL_TEST((ary), RARRAY_EMBED_FLAG)), \ FL_TEST_RAW((ary), RARRAY_EMBED_FLAG) != 0) @@ -62,7 +62,7 @@ assert_T_ARRAY(VALUE ary) (RARRAY_EMBED_LEN_MASK >> RARRAY_EMBED_LEN_SHIFT))) #define ARY_HEAP_SIZE(a) (assert(!ARY_EMBED_P(a)), assert(ARY_OWNS_HEAP_P(a)), ARY_CAPA(a) * sizeof(VALUE)) -#define ARY_OWNS_HEAP_P(a) (assert_T_ARRAY((VALUE)(a)), \ +#define ARY_OWNS_HEAP_P(a) (assert(should_be_T_ARRAY((VALUE)(a))), \ !FL_TEST_RAW((a), ELTS_SHARED|RARRAY_EMBED_FLAG)) #define FL_SET_EMBED(a) do { \ @@ -138,7 +138,7 @@ assert_T_ARRAY(VALUE ary) RB_OBJ_WRITE(_ary_, &RARRAY(_ary_)->as.heap.aux.shared_root, _value_); \ } while (0) #define RARRAY_SHARED_ROOT_FLAG FL_USER5 -#define ARY_SHARED_ROOT_P(ary) (assert_T_ARRAY((VALUE)(ary)), \ +#define ARY_SHARED_ROOT_P(ary) (assert(should_be_T_ARRAY((VALUE)(ary))), \ FL_TEST_RAW((ary), RARRAY_SHARED_ROOT_FLAG)) #define ARY_SHARED_ROOT_REFCNT(ary) \ (assert(ARY_SHARED_ROOT_P(ary)), RARRAY(ary)->as.heap.aux.capa) From de18328192de61be6f510c7402e1d7bd23efef6a Mon Sep 17 00:00:00 2001 From: aycabta Date: Sat, 20 Jul 2019 02:53:40 +0900 Subject: [PATCH 302/452] Some keywords, "true", "false", and "nil" should be treated as a variable --- lib/irb/completion.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/irb/completion.rb b/lib/irb/completion.rb index f75dd0ebcd3e61..04f5c447c9788b 100644 --- a/lib/irb/completion.rb +++ b/lib/irb/completion.rb @@ -205,7 +205,7 @@ def self.retrieve_completion_data(input, doc_namespace = false) sep = $2 message = Regexp.quote($3) - gv = eval("global_variables", bind).collect{|m| m.to_s} + gv = eval("global_variables", bind).collect{|m| m.to_s}.append("true", "false", "nil") lv = eval("local_variables", bind).collect{|m| m.to_s} iv = eval("instance_variables", bind).collect{|m| m.to_s} cv = eval("self.class.constants", bind).collect{|m| m.to_s} From 57b7bfad9e6421fb8387698908e06dcf363df213 Mon Sep 17 00:00:00 2001 From: git Date: Sat, 20 Jul 2019 02:54:41 +0900 Subject: [PATCH 303/452] * 2019-07-20 --- version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.h b/version.h index 05dc62f0a391a5..c0da8b1737bbf6 100644 --- a/version.h +++ b/version.h @@ -6,7 +6,7 @@ #define RUBY_RELEASE_YEAR 2019 #define RUBY_RELEASE_MONTH 7 -#define RUBY_RELEASE_DAY 19 +#define RUBY_RELEASE_DAY 20 #include "ruby/version.h" From 71d21f3c750f41ab44e618162515bd9e4a9f289e Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Fri, 19 Jul 2019 09:58:20 -0700 Subject: [PATCH 304/452] Document required keyword argument syntax [ci skip] Fixes [Bug #8952] --- doc/syntax/methods.rdoc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/doc/syntax/methods.rdoc b/doc/syntax/methods.rdoc index a47c1a3cbf5fc2..564159ac01fb46 100644 --- a/doc/syntax/methods.rdoc +++ b/doc/syntax/methods.rdoc @@ -398,6 +398,17 @@ When calling a method with keyword arguments the arguments may appear in any order. If an unknown keyword argument is sent by the caller an ArgumentError is raised. +To require a specific keyword argument, do not include a default value +for the keyword argument: + + def add_values(first:, second:) + first + second + end + add_values + # ArgumentError (missing keywords: first, second) + add_values(first: 1, second: 2) + # => 3 + When mixing keyword arguments and positional arguments, all positional arguments must appear before any keyword arguments. From bf2f84b2ff298583d3efbecb88da271e99fa7930 Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Fri, 19 Jul 2019 11:18:23 -0700 Subject: [PATCH 305/452] Document evaluation order of arguments [ci skip] Fixes [Misc #8905] --- doc/syntax/methods.rdoc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/doc/syntax/methods.rdoc b/doc/syntax/methods.rdoc index 564159ac01fb46..618eb14a1fbdca 100644 --- a/doc/syntax/methods.rdoc +++ b/doc/syntax/methods.rdoc @@ -283,6 +283,25 @@ This will raise a SyntaxError: a + b + c end +Default argument values can refer to arguments that have already been +evaluated as local variables, and argument values are always evaluated +left to right. So this is allowed: + + def add_values(a = 1, b = a) + a + b + end + add_values + # => 2 + +But this will raise a +NameError+ (unless there is a method named ++b+ defined): + + def add_values(a = b, b = 1) + a + b + end + add_values + # NameError (undefined local variable or method `b' for main:Object) + === Array Decomposition You can decompose (unpack or extract values from) an Array using extra From 7e2677675d76551a8a7abdba3fed350056640492 Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Fri, 19 Jul 2019 11:20:08 -0700 Subject: [PATCH 306/452] Remove mention of Proc.new with implicit block [ci skip] This support is now deprecated and will be removed in Ruby 3. --- doc/syntax/methods.rdoc | 4 ---- 1 file changed, 4 deletions(-) diff --git a/doc/syntax/methods.rdoc b/doc/syntax/methods.rdoc index 618eb14a1fbdca..4e6b926c01887e 100644 --- a/doc/syntax/methods.rdoc +++ b/doc/syntax/methods.rdoc @@ -459,10 +459,6 @@ parameter. When a block argument is assigned to a variable a Proc object is created which holds the block. When using yield this Proc object is not created. -If you only need to use the block sometimes you can use Proc.new to create a -proc from the block that was passed to your method. See Proc.new for further -details. - == Exception Handling Methods have an implied exception handling block so you do not need to use From ceeb1535dd6f618ac6069415a69be6d8b2916450 Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Fri, 19 Jul 2019 11:23:00 -0700 Subject: [PATCH 307/452] Remove section on performance advantage of not using a block parameter [ci skip] Improvements in Ruby 2.5 and 2.6 make this section no longer accurate. --- doc/syntax/methods.rdoc | 5 ----- 1 file changed, 5 deletions(-) diff --git a/doc/syntax/methods.rdoc b/doc/syntax/methods.rdoc index 4e6b926c01887e..94fed45e9a8032 100644 --- a/doc/syntax/methods.rdoc +++ b/doc/syntax/methods.rdoc @@ -454,11 +454,6 @@ in this section: yield self end -There is also a performance benefit to using yield over a calling a block -parameter. When a block argument is assigned to a variable a Proc object is -created which holds the block. When using yield this Proc object is not -created. - == Exception Handling Methods have an implied exception handling block so you do not need to use From c945d115a55710089ac23027c74ed32a40cd9e50 Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Fri, 19 Jul 2019 11:36:12 -0700 Subject: [PATCH 308/452] Document use of ensure and else at method level [ci skip] --- doc/syntax/methods.rdoc | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/doc/syntax/methods.rdoc b/doc/syntax/methods.rdoc index 94fed45e9a8032..6424c9d9ec0b52 100644 --- a/doc/syntax/methods.rdoc +++ b/doc/syntax/methods.rdoc @@ -475,6 +475,28 @@ May be written as: # handle exception end +Similarly, if you wish to always run code even if an exception is raised, +you can use +ensure+ without +begin+ and +end+: + + def my_method + # code that may raise an exception + ensure + # code that runs even if previous code raised an exception + end + +You can also combine +rescue+ with +ensure+ and/or +else+, without ++begin+ and +end+: + + def my_method + # code that may raise an exception + rescue + # handle exception + else + # only run if no exception raised above + ensure + # code that runs even if previous code raised an exception + end + If you wish to rescue an exception for only part of your method, use +begin+ and +end+. For more details see the page on {exception handling}[rdoc-ref:syntax/exceptions.rdoc]. From d304f77c585c42a2e8b008d170ac153b7d8e5243 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 19 Jul 2019 15:12:02 -0700 Subject: [PATCH 309/452] Only disable GC around reference updating This is the only place that can change the size of the object id tables and cause a GC. --- gc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gc.c b/gc.c index df48bc12699228..1c2959cbadf7de 100644 --- a/gc.c +++ b/gc.c @@ -8215,9 +8215,7 @@ gc_compact(rb_objspace_t *objspace, int use_toward_empty, int use_double_pages, /* pin objects referenced by maybe pointers */ rb_gc(); /* compact */ - rb_gc_disable(); gc_compact_after_gc(objspace, use_toward_empty, use_double_pages, TRUE); - rb_gc_enable(); } objspace->flags.during_compacting = FALSE; return gc_compact_stats(objspace); @@ -8312,7 +8310,10 @@ gc_compact_after_gc(rb_objspace_t *objspace, int use_toward_empty, int use_doubl moved_list = gc_compact_heap(objspace, compare_pinned); } heap_eden->freelist = NULL; + + VALUE disabled = rb_gc_disable(); gc_update_references(objspace); + if (!RTEST(disabled)) rb_gc_enable(); if (use_verifier) { gc_check_references_for_moved(Qnil); From 77bb79b8cf69f6504bf0abe2e07a1a631cc4ef32 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Sat, 20 Jul 2019 09:08:34 +0900 Subject: [PATCH 310/452] array.c: factor out a complex condition of assert ARY_SHARED_P and ARY_EMBED_P included: assert(!FL_TEST((ary), ELTS_SHARED) || !FL_TEST((ary), RARRAY_EMBED_FLAG)), The two predicate macros are used in many other assert conditions, which caused memory bloat during C compilation. This change factors out the assertion above to a function. Now gcc consumes 160 MB instead of 250 MB to compile array.c. --- array.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/array.c b/array.c index 0c5ea0acfea5e0..7989adeada0a74 100644 --- a/array.c +++ b/array.c @@ -40,14 +40,20 @@ should_be_T_ARRAY(VALUE ary) return RB_TYPE_P(ary, T_ARRAY); } +static int +should_not_be_shared_and_embedded(VALUE ary) +{ + return !FL_TEST((ary), ELTS_SHARED) || !FL_TEST((ary), RARRAY_EMBED_FLAG); +} + #define ARY_SHARED_P(ary) \ (assert(should_be_T_ARRAY((VALUE)(ary))), \ - assert(!FL_TEST((ary), ELTS_SHARED) || !FL_TEST((ary), RARRAY_EMBED_FLAG)), \ + assert(should_not_be_shared_and_embedded((VALUE)ary)), \ FL_TEST_RAW((ary),ELTS_SHARED)!=0) #define ARY_EMBED_P(ary) \ (assert(should_be_T_ARRAY((VALUE)(ary))), \ - assert(!FL_TEST((ary), ELTS_SHARED) || !FL_TEST((ary), RARRAY_EMBED_FLAG)), \ + assert(should_not_be_shared_and_embedded((VALUE)ary)), \ FL_TEST_RAW((ary), RARRAY_EMBED_FLAG) != 0) #define ARY_HEAP_PTR(a) (assert(!ARY_EMBED_P(a)), RARRAY(a)->as.heap.ptr) From 8a38eff2bd6338be412c8ef82e1bc50032c9f88f Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Sat, 20 Jul 2019 15:13:02 +0900 Subject: [PATCH 311/452] Upgrade benchmark-driver.gem version This is to make `make run` with benchmark/lib/load.rb work for ko1 https://github.com/benchmark-driver/benchmark-driver/compare/v0.14.17...v0.14.18 --- common.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common.mk b/common.mk index 7416d01a663cf1..980180c5c65895 100644 --- a/common.mk +++ b/common.mk @@ -47,7 +47,7 @@ GEM_PATH = GEM_VENDOR = BENCHMARK_DRIVER_GIT_URL = https://github.com/benchmark-driver/benchmark-driver -BENCHMARK_DRIVER_GIT_REF = v0.14.17 +BENCHMARK_DRIVER_GIT_REF = v0.14.18 SIMPLECOV_GIT_URL = https://github.com/colszowka/simplecov.git SIMPLECOV_GIT_REF = v0.15.0 SIMPLECOV_HTML_GIT_URL = https://github.com/colszowka/simplecov-html.git From 56b957e88a015a6feb9401a57634d72f367df3be Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Sat, 20 Jul 2019 15:27:57 +0900 Subject: [PATCH 312/452] Upgrade benchmark-driver.gem again because v0.14.18 was actually not working with `make run`. In `make run`, `Gem` is defined but `Gem::Version` isn't. v0.14.19 checks `defined?(Gem::Version)` instead of `defined?(Gem)`. --- common.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common.mk b/common.mk index 980180c5c65895..270ffaf30ee7db 100644 --- a/common.mk +++ b/common.mk @@ -47,7 +47,7 @@ GEM_PATH = GEM_VENDOR = BENCHMARK_DRIVER_GIT_URL = https://github.com/benchmark-driver/benchmark-driver -BENCHMARK_DRIVER_GIT_REF = v0.14.18 +BENCHMARK_DRIVER_GIT_REF = v0.14.19 SIMPLECOV_GIT_URL = https://github.com/colszowka/simplecov.git SIMPLECOV_GIT_REF = v0.15.0 SIMPLECOV_HTML_GIT_URL = https://github.com/colszowka/simplecov-html.git From 1392b821b99dacb4d4da5081640cfe7a4fb866f4 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Sat, 20 Jul 2019 15:32:36 +0900 Subject: [PATCH 313/452] Explain what's benchmark/lib/load.rb [ci skip] I'm actually not using this, but ko1 is. --- benchmark/lib/load.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/benchmark/lib/load.rb b/benchmark/lib/load.rb index 4d73a63323353c..31b770c4847214 100755 --- a/benchmark/lib/load.rb +++ b/benchmark/lib/load.rb @@ -1,2 +1,18 @@ +# How to use this file: +# 1. write a `$(srcdir)/test.rb` like: +=begin +require_relative 'benchmark/lib/load' + +Benchmark.driver(repeat_count: 5){|x| + x.executable name: 'clean-miniruby', command: %w'../clean-trunk/miniruby' + x.executable name: 'modif-miniruby', command: %w'./miniruby' + + x.report %q{ + h = {a: 1, b: 2, c: 3, d: 4} + } +} +=end +# +# 2. `make run` $:.unshift(File.join(__dir__, '../benchmark-driver/lib')) require 'benchmark_driver' From 81fc3becc7b883571e5c716f4fdc490d107ad990 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Sat, 20 Jul 2019 15:42:59 +0900 Subject: [PATCH 314/452] file.c: add a NORETURN declaration for statx_notimplement clang complains the lack. --- file.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/file.c b/file.c index f8df0f6e437497..0742c52d660114 100644 --- a/file.c +++ b/file.c @@ -1222,6 +1222,8 @@ rb_statx(VALUE file, struct statx *stx, unsigned int mask) # define statx_has_birthtime(st) ((st)->stx_mask & STATX_BTIME) +NORETURN(static void statx_notimplement(const char *field_name)); + /* rb_notimplement() shows "function is unimplemented on this machine". It is not applicable to statx which behavior depends on the filesystem. */ static void From e7b5b9144a8931af7510c7bc95c798df75af9499 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Sat, 20 Jul 2019 15:44:10 +0900 Subject: [PATCH 315/452] --debug was not functional either Even after 19d592dc82a31adf0bb6f027392cae69615c2394, the retry seems not functional. Let's just add --debug from the beginning because an output of each step is collapsed and we don't see `make up` output so often. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4db6d0a48b0ddf..19fed7fa01a455 100644 --- a/.travis.yml +++ b/.travis.yml @@ -421,7 +421,7 @@ before_script: - "> .rbconfig.time" - sed -f tool/prereq.status template/Makefile.in common.mk > Makefile - date; make touch-unicode-files - - date; make -s $JOBS $UPDATE_UNICODE up || make --debug -s $JOBS $UPDATE_UNICODE up + - date; make --debug -s $JOBS $UPDATE_UNICODE up - date; make -s $JOBS srcs - rm -f config.status Makefile rbconfig.rb .rbconfig.time - |- From c584dd8460bdbb78b0e5ab47a1c15b2df2c45ded Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Sat, 20 Jul 2019 19:44:49 +1200 Subject: [PATCH 316/452] Move travis coroutine check to cron only. --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 19fed7fa01a455..8e8f2759cc5959 100644 --- a/.travis.yml +++ b/.travis.yml @@ -159,14 +159,14 @@ env: - &WITH_COROUTINE_UCONTEXT name: COROUTINE=ucontext <<: *linux - # <<: *cron-only + <<: *cron-only env: - CONFIG_FLAG='--with-coroutine=ucontext' - &WITH_COROUTINE_COPY name: COROUTINE=copy <<: *linux - # <<: *cron-only + <<: *cron-only env: - CONFIG_FLAG='--with-coroutine=copy' From d285579ea796c0a9132cade07de4ffb6bae137e9 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Sun, 21 Jul 2019 09:46:49 +0900 Subject: [PATCH 317/452] Update simplecov and doclie to the latest version. --- common.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common.mk b/common.mk index 270ffaf30ee7db..63312b5fb1fc13 100644 --- a/common.mk +++ b/common.mk @@ -49,11 +49,11 @@ GEM_VENDOR = BENCHMARK_DRIVER_GIT_URL = https://github.com/benchmark-driver/benchmark-driver BENCHMARK_DRIVER_GIT_REF = v0.14.19 SIMPLECOV_GIT_URL = https://github.com/colszowka/simplecov.git -SIMPLECOV_GIT_REF = v0.15.0 +SIMPLECOV_GIT_REF = v0.17.0 SIMPLECOV_HTML_GIT_URL = https://github.com/colszowka/simplecov-html.git SIMPLECOV_HTML_GIT_REF = v0.10.2 DOCLIE_GIT_URL = https://github.com/ms-ati/docile.git -DOCLIE_GIT_REF = v1.1.5 +DOCLIE_GIT_REF = v1.3.2 STATIC_RUBY = static-ruby From 523fec8a4baec1e2a9c1adc0095646b12aa6c76c Mon Sep 17 00:00:00 2001 From: git Date: Sun, 21 Jul 2019 09:47:57 +0900 Subject: [PATCH 318/452] * 2019-07-21 --- version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.h b/version.h index c0da8b1737bbf6..e48bb85bea370f 100644 --- a/version.h +++ b/version.h @@ -6,7 +6,7 @@ #define RUBY_RELEASE_YEAR 2019 #define RUBY_RELEASE_MONTH 7 -#define RUBY_RELEASE_DAY 20 +#define RUBY_RELEASE_DAY 21 #include "ruby/version.h" From 24712eeec39f5e9a11cfc2b940358403cda4f2b6 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Sun, 21 Jul 2019 19:19:08 +0900 Subject: [PATCH 319/452] tool/test/runner.rb: support --test-target-dir option tool/test/runner.rb had been copied from test/runner.rb. test/runner.rb was for `make test-all`, and tool/test/runner.rb was for `make test-testframework` and `make test-tool`. But I want to avoid the code clones. This change makes tool/test/runner.rb support --test-target-dir option which allows tool/test/runner.rb to run `make test-all`. Now we can remove test/runner.rb. --- common.mk | 10 +++++----- test/runner.rb | 39 --------------------------------------- tool/lib/test/unit.rb | 3 --- tool/test/runner.rb | 17 +++++++++++++++-- 4 files changed, 20 insertions(+), 49 deletions(-) delete mode 100644 test/runner.rb diff --git a/common.mk b/common.mk index 63312b5fb1fc13..da81afa418a54c 100644 --- a/common.mk +++ b/common.mk @@ -754,12 +754,12 @@ yes-test-knownbug: prog PHONY test-testframework: $(TEST_RUNNABLE)-test-testframework yes-test-testframework: prog PHONY - $(gnumake_recursive)$(Q)$(exec) $(RUNRUBY) "$(TOOL_TESTSDIR)/runner.rb" --ruby="$(RUNRUBY)" --basedir=$(TOOL_TESTSDIR) $(TESTOPTS) testunit minitest + $(gnumake_recursive)$(Q)$(exec) $(RUNRUBY) "$(TOOL_TESTSDIR)/runner.rb" --test-target-dir="$(TOOL_TESTSDIR)" -- --ruby="$(RUNRUBY)" $(TESTOPTS) testunit minitest no-test-testframework: PHONY test-tool: $(TEST_RUNNABLE)-test-tool yes-test-tool: prog PHONY - $(gnumake_recursive)$(Q)$(exec) $(RUNRUBY) "$(TOOL_TESTSDIR)/runner.rb" --ruby="$(RUNRUBY)" --basedir=$(TOOL_TESTSDIR) $(TESTOPTS) $(EXCLUDE_TESTFRAMEWORK) + $(gnumake_recursive)$(Q)$(exec) $(RUNRUBY) "$(TOOL_TESTSDIR)/runner.rb" --test-target-dir="$(TOOL_TESTSDIR)" -- --ruby="$(RUNRUBY)" $(TESTOPTS) $(EXCLUDE_TESTFRAMEWORK) no-test-tool: PHONY test-sample: test-basic # backward compatibility for mswin-build @@ -770,10 +770,10 @@ test: test-short # for example, make test-all TESTOPTS="-j2 -v -n test-name -- test-file-name" test-all: $(TEST_RUNNABLE)-test-all yes-test-all: programs PHONY - $(gnumake_recursive)$(Q)$(exec) $(RUNRUBY) "$(srcdir)/test/runner.rb" --ruby="$(RUNRUBY)" $(TEST_EXCLUDES) $(TESTOPTS) $(TESTS) + $(gnumake_recursive)$(Q)$(exec) $(RUNRUBY) "$(TOOL_TESTSDIR)/runner.rb" --test-target-dir="$(TESTSDIR)" -- --ruby="$(RUNRUBY)" $(TEST_EXCLUDES) $(TESTOPTS) $(TESTS) TESTS_BUILD = mkmf no-test-all: PHONY - $(gnumake_recursive)$(MINIRUBY) -I"$(srcdir)/lib" "$(srcdir)/test/runner.rb" $(TESTOPTS) $(TESTS_BUILD) + $(gnumake_recursive)$(MINIRUBY) -I"$(srcdir)/lib" "$(TOOL_TESTSDIR)/runner.rb" --test-target-dir="$(TESTSDIR)" -- $(TESTOPTS) $(TESTS_BUILD) test-almost: test-all yes-test-almost: yes-test-all @@ -782,7 +782,7 @@ no-test-almost: no-test-all test-ruby: $(TEST_RUNNABLE)-test-ruby no-test-ruby: PHONY yes-test-ruby: prog encs PHONY - $(gnumake_recursive)$(RUNRUBY) "$(srcdir)/test/runner.rb" $(TEST_EXCLUDES) $(TESTOPTS) -- ruby -ext- + $(gnumake_recursive)$(RUNRUBY) "$(TOOL_TESTSDIR)/runner.rb" --test-target-dir="$(TESTSDIR)" -- $(TEST_EXCLUDES) $(TESTOPTS) -- ruby -ext- extconf: $(PREP) $(Q) $(MAKEDIRS) "$(EXTCONFDIR)" diff --git a/test/runner.rb b/test/runner.rb deleted file mode 100644 index db2084949e7155..00000000000000 --- a/test/runner.rb +++ /dev/null @@ -1,39 +0,0 @@ -# frozen_string_literal: false -require 'rbconfig' - -src_testdir = File.dirname(File.realpath(__FILE__)) -$LOAD_PATH << src_testdir -tool_dir = File.join src_testdir, "..", "tool" -$LOAD_PATH.unshift "#{tool_dir}/lib" - -# Get bundled gems on load path -Dir.glob("#{src_testdir}/../gems/*/*.gemspec") - .reject {|f| f =~ /minitest|test-unit|power_assert/ } - .map {|f| $LOAD_PATH.unshift File.join(File.dirname(f), "lib") } - -require 'test/unit' - -module Gem -end -class Gem::TestCase < MiniTest::Unit::TestCase - @@project_dir = File.dirname($LOAD_PATH.last) -end - -ENV["GEM_SKIP"] = ENV["GEM_HOME"] = ENV["GEM_PATH"] = "".freeze - -require_relative "#{tool_dir}/lib/profile_test_all" if ENV.has_key?('RUBY_TEST_ALL_PROFILE') -require_relative "#{tool_dir}/lib/tracepointchecker" -require_relative "#{tool_dir}/lib/zombie_hunter" -require_relative "#{tool_dir}/lib/iseq_loader_checker" - -if ENV['COVERAGE'] - require_relative "#{tool_dir}/test-coverage.rb" -end - -begin - exit Test::Unit::AutoRunner.run(true, src_testdir) -rescue NoMemoryError - system("cat /proc/meminfo") if File.exist?("/proc/meminfo") - system("ps x -opid,args,%cpu,%mem,nlwp,rss,vsz,wchan,stat,start,time,etime,blocked,caught,ignored,pending,f") if File.exist?("/bin/ps") - raise -end diff --git a/tool/lib/test/unit.rb b/tool/lib/test/unit.rb index d237a9a0e95bad..1034a993b0a5ca 100644 --- a/tool/lib/test/unit.rb +++ b/tool/lib/test/unit.rb @@ -856,9 +856,6 @@ module GlobOption # :nodoc: all def setup_options(parser, options) super parser.separator "globbing options:" - parser.on '-b', '--basedir=DIR', 'Base directory of test suites.' do |dir| - options[:base_directory] = dir - end parser.on '-x', '--exclude REGEXP', 'Exclude test files on pattern.' do |pattern| (options[:reject] ||= []) << pattern end diff --git a/tool/test/runner.rb b/tool/test/runner.rb index 64f6df167edd70..db23ae2d33c2c9 100644 --- a/tool/test/runner.rb +++ b/tool/test/runner.rb @@ -1,9 +1,22 @@ # frozen_string_literal: false require 'rbconfig' -src_testdir = File.dirname(File.realpath(__FILE__)) +tool_dir = File.dirname(File.dirname(File.realpath(__FILE__))) +src_testdir = nil + +while opt = ARGV.shift + break if opt == "--" + case opt + when /\A--test-target-dir=(.*?)\z/ + src_testdir = File.realpath($1) + else + raise "unknown runner option: #{ opt }" + end +end + +raise "#$0: specify --test-target-dir" if !src_testdir + $LOAD_PATH << src_testdir -tool_dir = File.join src_testdir, ".." $LOAD_PATH.unshift "#{tool_dir}/lib" # Get bundled gems on load path From 08ea9240437bd866ae1169a91010d7767a22c9c1 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Sun, 21 Jul 2019 22:30:15 +0900 Subject: [PATCH 320/452] common.mk: `make check` now includes `make test-tool` And `make test-tool` includes `make test-testframework`. This change may be arguable because I'm unsure who is an intended user of `make check`: a normal user, or Ruby-core developer. Normal users don't have to run `make test-tool` for testing their installation, but Ruby committers should run it before they commit anything. In this case, I'd be conservative; `make check` includes `test-tool`. If normal users often report a failure of `make test-tool`, then we can consider to split `make check` for two sets of target users. --- common.mk | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/common.mk b/common.mk index da81afa418a54c..74f77519b493d8 100644 --- a/common.mk +++ b/common.mk @@ -187,7 +187,6 @@ INSTALL_DATA_MODE = 0644 TESTSDIR = $(srcdir)/test TOOL_TESTSDIR = $(srcdir)/tool/test TEST_EXCLUDES = --excludes-dir=$(TESTSDIR)/excludes --name=!/memory_leak/ -EXCLUDE_TESTFRAMEWORK = --exclude=/testunit/ --exclude=/minitest/ TESTWORKDIR = testwork TESTOPTS = $(RUBY_TESTOPTS) @@ -715,7 +714,7 @@ clean-spec: PHONY -$(Q) $(RM) $(RUBYSPEC_CAPIEXT)/*.$(OBJEXT) $(RUBYSPEC_CAPIEXT)/*.$(DLEXT) -$(Q) $(RMDIRS) $(RUBYSPEC_CAPIEXT) 2> $(NULL) || exit 0 -check: main test test-testframework test-all test-spec +check: main test test-tool test-all test-spec $(ECHO) check succeeded check-ruby: test test-ruby @@ -759,7 +758,7 @@ no-test-testframework: PHONY test-tool: $(TEST_RUNNABLE)-test-tool yes-test-tool: prog PHONY - $(gnumake_recursive)$(Q)$(exec) $(RUNRUBY) "$(TOOL_TESTSDIR)/runner.rb" --test-target-dir="$(TOOL_TESTSDIR)" -- --ruby="$(RUNRUBY)" $(TESTOPTS) $(EXCLUDE_TESTFRAMEWORK) + $(gnumake_recursive)$(Q)$(exec) $(RUNRUBY) "$(TOOL_TESTSDIR)/runner.rb" --test-target-dir="$(TOOL_TESTSDIR)" -- --ruby="$(RUNRUBY)" $(TESTOPTS) no-test-tool: PHONY test-sample: test-basic # backward compatibility for mswin-build @@ -1496,7 +1495,7 @@ help: PHONY " runruby: runs test.rb by ruby you just built" \ " gdb: runs test.rb by miniruby under gdb" \ " gdb-ruby: runs test.rb by ruby under gdb" \ - " check: equals make test test-all test-spec" \ + " check: equals make test test-tool test-all test-spec" \ " test: ruby core tests" \ " test-all: all ruby tests [TESTOPTS=-j4 TESTS=]" \ " test-spec: run the Ruby spec suite [SPECOPTS=]" \ From 28ae30b6ac0616ce3a7742d311d22909ee200dd8 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Mon, 22 Jul 2019 10:10:28 +0900 Subject: [PATCH 321/452] Run test-tool in the order of the tests --- defs/gmake.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/defs/gmake.mk b/defs/gmake.mk index b21fa4f738ff46..2f1698bfd832db 100644 --- a/defs/gmake.mk +++ b/defs/gmake.mk @@ -12,7 +12,7 @@ TEST_DEPENDS := $(filter-out commit $(TEST_TARGETS),$(MAKECMDGOALS)) TEST_TARGETS := $(patsubst great,exam,$(TEST_TARGETS)) TEST_DEPENDS := $(filter-out great $(TEST_TARGETS),$(TEST_DEPENDS)) TEST_TARGETS := $(patsubst exam,check,$(TEST_TARGETS)) -TEST_TARGETS := $(patsubst check,test-spec test-all test-testframework test-short,$(TEST_TARGETS)) +TEST_TARGETS := $(patsubst check,test-spec test-all test-tool test-short,$(TEST_TARGETS)) TEST_TARGETS := $(patsubst test-rubyspec,test-spec,$(TEST_TARGETS)) TEST_DEPENDS := $(filter-out exam check test-spec $(TEST_TARGETS),$(TEST_DEPENDS)) TEST_TARGETS := $(patsubst love,check,$(TEST_TARGETS)) @@ -64,7 +64,7 @@ endif ORDERED_TEST_TARGETS := $(filter $(TEST_TARGETS), \ btest-ruby test-knownbug test-basic \ - test-testframework test-ruby test-all \ + test-testframework test-tool test-ruby test-all \ test-spec test-bundler-prepare test-bundler \ ) prev_test := $(if $(filter test-spec,$(ORDERED_TEST_TARGETS)),test-spec-precheck) From f6a7b10afa6f90a43df0bb336dfac05d38accf1e Mon Sep 17 00:00:00 2001 From: git Date: Mon, 22 Jul 2019 10:10:51 +0900 Subject: [PATCH 322/452] * 2019-07-22 --- version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.h b/version.h index e48bb85bea370f..c797198e7bc849 100644 --- a/version.h +++ b/version.h @@ -6,7 +6,7 @@ #define RUBY_RELEASE_YEAR 2019 #define RUBY_RELEASE_MONTH 7 -#define RUBY_RELEASE_DAY 21 +#define RUBY_RELEASE_DAY 22 #include "ruby/version.h" From 463092b84da7933f307cc8747f948f68ef19f5fd Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Mon, 22 Jul 2019 11:05:34 +0900 Subject: [PATCH 323/452] Update rake-12.3.3. --- gems/bundled_gems | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gems/bundled_gems b/gems/bundled_gems index e5636a81143228..32f14aec3bc1da 100644 --- a/gems/bundled_gems +++ b/gems/bundled_gems @@ -2,6 +2,6 @@ did_you_mean 1.3.0 https://github.com/yuki24/did_you_mean minitest 5.11.3 https://github.com/seattlerb/minitest net-telnet 0.2.0 https://github.com/ruby/net-telnet power_assert 1.1.4 https://github.com/k-tsj/power_assert -rake 12.3.2 https://github.com/ruby/rake +rake 12.3.3 https://github.com/ruby/rake test-unit 3.3.3 https://github.com/test-unit/test-unit xmlrpc 0.3.0 https://github.com/ruby/xmlrpc From f6461fa890fa12501fe1696a36ab2cca036477ff Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Mon, 22 Jul 2019 12:31:40 +0900 Subject: [PATCH 324/452] Only the first argument can be --test-target-dir option Raise the proper exception when that option is not given but non-option argument is. --- common.mk | 10 +++++----- tool/test/runner.rb | 14 ++++++-------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/common.mk b/common.mk index 74f77519b493d8..f795df874ad247 100644 --- a/common.mk +++ b/common.mk @@ -753,12 +753,12 @@ yes-test-knownbug: prog PHONY test-testframework: $(TEST_RUNNABLE)-test-testframework yes-test-testframework: prog PHONY - $(gnumake_recursive)$(Q)$(exec) $(RUNRUBY) "$(TOOL_TESTSDIR)/runner.rb" --test-target-dir="$(TOOL_TESTSDIR)" -- --ruby="$(RUNRUBY)" $(TESTOPTS) testunit minitest + $(gnumake_recursive)$(Q)$(exec) $(RUNRUBY) "$(TOOL_TESTSDIR)/runner.rb" --test-target-dir="$(TOOL_TESTSDIR)" --ruby="$(RUNRUBY)" $(TESTOPTS) testunit minitest no-test-testframework: PHONY test-tool: $(TEST_RUNNABLE)-test-tool yes-test-tool: prog PHONY - $(gnumake_recursive)$(Q)$(exec) $(RUNRUBY) "$(TOOL_TESTSDIR)/runner.rb" --test-target-dir="$(TOOL_TESTSDIR)" -- --ruby="$(RUNRUBY)" $(TESTOPTS) + $(gnumake_recursive)$(Q)$(exec) $(RUNRUBY) "$(TOOL_TESTSDIR)/runner.rb" --test-target-dir="$(TOOL_TESTSDIR)" --ruby="$(RUNRUBY)" $(TESTOPTS) no-test-tool: PHONY test-sample: test-basic # backward compatibility for mswin-build @@ -769,10 +769,10 @@ test: test-short # for example, make test-all TESTOPTS="-j2 -v -n test-name -- test-file-name" test-all: $(TEST_RUNNABLE)-test-all yes-test-all: programs PHONY - $(gnumake_recursive)$(Q)$(exec) $(RUNRUBY) "$(TOOL_TESTSDIR)/runner.rb" --test-target-dir="$(TESTSDIR)" -- --ruby="$(RUNRUBY)" $(TEST_EXCLUDES) $(TESTOPTS) $(TESTS) + $(gnumake_recursive)$(Q)$(exec) $(RUNRUBY) "$(TOOL_TESTSDIR)/runner.rb" --test-target-dir="$(TESTSDIR)" --ruby="$(RUNRUBY)" $(TEST_EXCLUDES) $(TESTOPTS) $(TESTS) TESTS_BUILD = mkmf no-test-all: PHONY - $(gnumake_recursive)$(MINIRUBY) -I"$(srcdir)/lib" "$(TOOL_TESTSDIR)/runner.rb" --test-target-dir="$(TESTSDIR)" -- $(TESTOPTS) $(TESTS_BUILD) + $(gnumake_recursive)$(MINIRUBY) -I"$(srcdir)/lib" "$(TOOL_TESTSDIR)/runner.rb" --test-target-dir="$(TESTSDIR)" $(TESTOPTS) $(TESTS_BUILD) test-almost: test-all yes-test-almost: yes-test-all @@ -781,7 +781,7 @@ no-test-almost: no-test-all test-ruby: $(TEST_RUNNABLE)-test-ruby no-test-ruby: PHONY yes-test-ruby: prog encs PHONY - $(gnumake_recursive)$(RUNRUBY) "$(TOOL_TESTSDIR)/runner.rb" --test-target-dir="$(TESTSDIR)" -- $(TEST_EXCLUDES) $(TESTOPTS) -- ruby -ext- + $(gnumake_recursive)$(RUNRUBY) "$(TOOL_TESTSDIR)/runner.rb" --test-target-dir="$(TESTSDIR)" $(TEST_EXCLUDES) $(TESTOPTS) -- ruby -ext- extconf: $(PREP) $(Q) $(MAKEDIRS) "$(EXTCONFDIR)" diff --git a/tool/test/runner.rb b/tool/test/runner.rb index db23ae2d33c2c9..b3cdba6f17f4b6 100644 --- a/tool/test/runner.rb +++ b/tool/test/runner.rb @@ -4,14 +4,12 @@ tool_dir = File.dirname(File.dirname(File.realpath(__FILE__))) src_testdir = nil -while opt = ARGV.shift - break if opt == "--" - case opt - when /\A--test-target-dir=(.*?)\z/ - src_testdir = File.realpath($1) - else - raise "unknown runner option: #{ opt }" - end +case ARGV.first +when /\A--test-target-dir=(.*?)\z/ + ARGV.shift + src_testdir = File.realpath($1) +else + raise "unknown runner option: #{ opt }" end raise "#$0: specify --test-target-dir" if !src_testdir From d1c2b1969814fee14a01296aa2867abd07f70d04 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Mon, 22 Jul 2019 13:51:14 +0900 Subject: [PATCH 325/452] Fixed exception message --- tool/test/runner.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tool/test/runner.rb b/tool/test/runner.rb index b3cdba6f17f4b6..20ae9aa1a37295 100644 --- a/tool/test/runner.rb +++ b/tool/test/runner.rb @@ -9,7 +9,7 @@ ARGV.shift src_testdir = File.realpath($1) else - raise "unknown runner option: #{ opt }" + raise "unknown runner option: #{ ARGV.first }" end raise "#$0: specify --test-target-dir" if !src_testdir From f75561b8d455e1cf92dac8ac8838fdafc88cba71 Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Mon, 22 Jul 2019 17:01:31 +0900 Subject: [PATCH 326/452] constify RHash::ifnone. RHash::ifnone should be protected by write-barriers so this field should be const. However, to introduce GC.compact, the const was removed. This commit revert this removing `const` and modify gc.c `TYPED_UPDATE_IF_MOVED` to remove `const` forcely by a type cast. --- gc.c | 2 +- internal.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gc.c b/gc.c index 1c2959cbadf7de..feea9852ecb680 100644 --- a/gc.c +++ b/gc.c @@ -915,7 +915,7 @@ static inline void gc_prof_set_heap_info(rb_objspace_t *); #define TYPED_UPDATE_IF_MOVED(_objspace, _type, _thing) do { \ if (gc_object_moved_p(_objspace, (VALUE)_thing)) { \ - (_thing) = (_type)RMOVED((_thing))->destination; \ + *((_type *)(&_thing)) = (_type)RMOVED((_thing))->destination; \ } \ } while (0) diff --git a/internal.h b/internal.h index b931c115dfa4ab..f8baba48c1423a 100644 --- a/internal.h +++ b/internal.h @@ -873,7 +873,7 @@ struct RHash { struct ar_table_struct *ar; /* possibly 0 */ } as; int iter_lev; - VALUE ifnone; + const VALUE ifnone; }; #ifdef RHASH_ITER_LEV From 9095ff53cf6c25154c7f80910aab8d1af45c42ec Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Wed, 26 Jun 2019 16:36:52 -0700 Subject: [PATCH 327/452] [ruby/date] Describe what is meant by valid in the Date.valid_date? rdoc https://github.com/ruby/date/commit/8eca79d1f0 --- ext/date/date_core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ext/date/date_core.c b/ext/date/date_core.c index 67ed6171a78400..388b30ba7a96ce 100644 --- a/ext/date/date_core.c +++ b/ext/date/date_core.c @@ -2545,9 +2545,12 @@ date_s__valid_civil_p(int argc, VALUE *argv, VALUE klass) * Date.valid_date?(year, month, mday[, start=Date::ITALY]) -> bool * * Returns true if the given calendar date is valid, and false if not. + * Valid in this context is whether the arguments passed to this + * method would be accepted by ::new. * * Date.valid_date?(2001,2,3) #=> true * Date.valid_date?(2001,2,29) #=> false + * Date.valid_date?(2001,2,-1) #=> true * * See also ::jd and ::civil. */ From 1feda1c2b091b950efcaa481a11fd660efa9e717 Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Mon, 22 Jul 2019 17:44:58 +0900 Subject: [PATCH 328/452] constify again. Same as last commit, make some fields `const`. include/ruby/ruby.h: * Rasic::klass * RArray::heap::aux::shared_root * RRegexp::src internal.h: * rb_classext_struct::origin_, redefined_class * vm_svar::cref_or_me, lastline, backref, others * vm_throw_data::throw_obj * vm_ifunc::data * MEMO::v1, v2, u3::value While modifying this patch, I found write-barrier miss on rb_classext_struct::redefined_class. Also vm_throw_data::throw_state is only `int` so change the type. --- class.c | 2 +- eval.c | 10 +++++----- include/ruby/ruby.h | 6 +++--- internal.h | 24 ++++++++++++------------ vm_insnhelper.h | 4 ++-- 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/class.c b/class.c index 7922df56b20405..a8d21f94433c92 100644 --- a/class.c +++ b/class.c @@ -176,7 +176,7 @@ class_alloc(VALUE flags, VALUE klass) */ RCLASS_SET_ORIGIN((VALUE)obj, (VALUE)obj); RCLASS_SERIAL(obj) = rb_next_class_serial(); - RCLASS_REFINED_CLASS(obj) = Qnil; + RB_OBJ_WRITE(obj, &RCLASS_REFINED_CLASS(obj), Qnil); RCLASS_EXT(obj)->allocator = 0; return (VALUE)obj; diff --git a/eval.c b/eval.c index 138006e0db6b87..afc78532dfa7af 100644 --- a/eval.c +++ b/eval.c @@ -1356,7 +1356,7 @@ rb_using_refinement(rb_cref_t *cref, VALUE klass, VALUE module) FL_SET(module, RMODULE_IS_OVERLAID); superclass = refinement_superclass(superclass); c = iclass = rb_include_class_new(module, superclass); - RCLASS_REFINED_CLASS(c) = klass; + RB_OBJ_WRITE(c, &RCLASS_REFINED_CLASS(c), klass); RCLASS_M_TBL(OBJ_WB_UNPROTECT(c)) = RCLASS_M_TBL(OBJ_WB_UNPROTECT(module)); /* TODO: check unprotecting */ @@ -1365,8 +1365,8 @@ rb_using_refinement(rb_cref_t *cref, VALUE klass, VALUE module) while (module && module != klass) { FL_SET(module, RMODULE_IS_OVERLAID); c = RCLASS_SET_SUPER(c, rb_include_class_new(module, RCLASS_SUPER(c))); - RCLASS_REFINED_CLASS(c) = klass; - module = RCLASS_SUPER(module); + RB_OBJ_WRITE(c, &RCLASS_REFINED_CLASS(c), klass); + module = RCLASS_SUPER(module); } rb_hash_aset(CREF_REFINEMENTS(cref), klass, iclass); } @@ -1451,12 +1451,12 @@ add_activated_refinement(VALUE activated_refinements, FL_SET(refinement, RMODULE_IS_OVERLAID); superclass = refinement_superclass(superclass); c = iclass = rb_include_class_new(refinement, superclass); - RCLASS_REFINED_CLASS(c) = klass; + RB_OBJ_WRITE(c, &RCLASS_REFINED_CLASS(c), klass); refinement = RCLASS_SUPER(refinement); while (refinement && refinement != klass) { FL_SET(refinement, RMODULE_IS_OVERLAID); c = RCLASS_SET_SUPER(c, rb_include_class_new(refinement, RCLASS_SUPER(c))); - RCLASS_REFINED_CLASS(c) = klass; + RB_OBJ_WRITE(c, &RCLASS_REFINED_CLASS(c), klass); refinement = RCLASS_SUPER(refinement); } rb_hash_aset(activated_refinements, klass, iclass); diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h index af561ff63802cf..5456dbc941bd12 100644 --- a/include/ruby/ruby.h +++ b/include/ruby/ruby.h @@ -887,7 +887,7 @@ enum ruby_fl_type { struct RUBY_ALIGNAS(SIZEOF_VALUE) RBasic { VALUE flags; - VALUE klass; + const VALUE klass; }; VALUE rb_obj_hide(VALUE obj); @@ -1054,7 +1054,7 @@ struct RArray { long len; union { long capa; - VALUE shared_root; + const VALUE shared_root; } aux; const VALUE *ptr; } heap; @@ -1109,7 +1109,7 @@ struct RArray { struct RRegexp { struct RBasic basic; struct re_pattern_buffer *ptr; - VALUE src; + const VALUE src; unsigned long usecnt; }; #define RREGEXP_PTR(r) (RREGEXP(r)->ptr) diff --git a/internal.h b/internal.h index f8baba48c1423a..4b4352d1827f82 100644 --- a/internal.h +++ b/internal.h @@ -1009,8 +1009,8 @@ struct rb_classext_struct { */ rb_subclass_entry_t **module_subclasses; rb_serial_t class_serial; - VALUE origin_; - VALUE refined_class; + const VALUE origin_; + const VALUE refined_class; rb_alloc_func_t allocator; }; @@ -1127,10 +1127,10 @@ imemo_type_p(VALUE imemo, enum imemo_type imemo_type) /*! SVAR (Special VARiable) */ struct vm_svar { VALUE flags; - VALUE cref_or_me; /*!< class reference or rb_method_entry_t */ - VALUE lastline; - VALUE backref; - VALUE others; + const VALUE cref_or_me; /*!< class reference or rb_method_entry_t */ + const VALUE lastline; + const VALUE backref; + const VALUE others; }; @@ -1140,9 +1140,9 @@ struct vm_svar { struct vm_throw_data { VALUE flags; VALUE reserved; - VALUE throw_obj; + const VALUE throw_obj; const struct rb_control_frame_struct *catch_frame; - VALUE throw_state; + int throw_state; }; #define THROW_DATA_P(err) RB_TYPE_P((VALUE)(err), T_IMEMO) @@ -1163,7 +1163,7 @@ struct vm_ifunc { VALUE flags; VALUE reserved; VALUE (*func)(ANYARGS); - void *data; + const void *data; struct vm_ifunc_argc argc; }; @@ -1220,12 +1220,12 @@ void rb_strterm_mark(VALUE obj); struct MEMO { VALUE flags; VALUE reserved; - VALUE v1; - VALUE v2; + const VALUE v1; + const VALUE v2; union { long cnt; long state; - VALUE value; + const VALUE value; VALUE (*func)(ANYARGS); } u3; }; diff --git a/vm_insnhelper.h b/vm_insnhelper.h index 98aee9d46c9b18..920ea6ac17a5f2 100644 --- a/vm_insnhelper.h +++ b/vm_insnhelper.h @@ -203,7 +203,7 @@ static inline int THROW_DATA_STATE(const struct vm_throw_data *obj) { VM_ASSERT(THROW_DATA_P(obj)); - return (int)obj->throw_state; + return obj->throw_state; } static inline int @@ -224,7 +224,7 @@ static inline void THROW_DATA_STATE_SET(struct vm_throw_data *obj, int st) { VM_ASSERT(THROW_DATA_P(obj)); - obj->throw_state = (VALUE)st; + obj->throw_state = st; } static inline void From 9f9a6dbc1491fa9407bf3da70646dc8636c566f5 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Mon, 22 Jul 2019 18:00:37 +0900 Subject: [PATCH 329/452] Allways fetch the latest commit from default gems repository. --- tool/sync_default_gems.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tool/sync_default_gems.rb b/tool/sync_default_gems.rb index 93031ac849e95d..7f125fae295650 100644 --- a/tool/sync_default_gems.rb +++ b/tool/sync_default_gems.rb @@ -234,9 +234,9 @@ def sync_default_gems_with_commits(gem, range) IO.popen(%W"git remote") do |f| unless f.read.split.include?(gem) `git remote add #{gem} git@github.com:#{$repositories[gem.to_sym]}.git` - `git fetch #{gem}` end end + `git fetch #{gem}` IO.popen(%W"git log --format=%H,%s #{range}") do |f| commits = f.read.split("\n").reverse.map{|commit| commit.split(',')} From 2f6cc00338826dbaa439a18e4b4f7a19c1f5987a Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Tue, 9 Jul 2019 21:33:01 -0700 Subject: [PATCH 330/452] Fix documentation for Array#pack m directive count specifier [ci skip] Fixes [Bug #10025] --- pack.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pack.c b/pack.c index 3305ccaa1e2531..e43e43777e0d1b 100644 --- a/pack.c +++ b/pack.c @@ -286,8 +286,10 @@ VALUE_to_float(VALUE obj) * u | String | UU-encoded string * M | String | quoted printable, MIME encoding (see also RFC2045) * | | (text mode but input must use LF and output LF) - * m | String | base64 encoded string (see RFC 2045, count is width) + * m | String | base64 encoded string (see RFC 2045) * | | (if count is 0, no line feed are added, see RFC 4648) + * | | (count specifies input bytes between each LF, + * | | rounded down to nearest multiple of 3) * P | String | pointer to a structure (fixed-length string) * p | String | pointer to a null-terminated string * From 6b62aa7aec1c8beffafc5e321419cba408bf3c24 Mon Sep 17 00:00:00 2001 From: git Date: Tue, 23 Jul 2019 04:10:42 +0900 Subject: [PATCH 331/452] * 2019-07-23 --- version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.h b/version.h index c797198e7bc849..0706e7f98e3b80 100644 --- a/version.h +++ b/version.h @@ -6,7 +6,7 @@ #define RUBY_RELEASE_YEAR 2019 #define RUBY_RELEASE_MONTH 7 -#define RUBY_RELEASE_DAY 22 +#define RUBY_RELEASE_DAY 23 #include "ruby/version.h" From 11f3da8e9dd98cb6b0c2c2fd22220f8508af32f2 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 23 Jul 2019 05:20:04 +0900 Subject: [PATCH 332/452] Stop packing rb_method_definition_t By using `BITFIELD`, `type` field should not be forced to align. --- method.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/method.h b/method.h index a604554467e9d2..84ade7fef371c7 100644 --- a/method.h +++ b/method.h @@ -160,7 +160,7 @@ enum method_optimized_type { OPTIMIZED_METHOD_TYPE__MAX }; -PACKED_STRUCT_UNALIGNED(struct rb_method_definition_struct { +struct rb_method_definition_struct { BITFIELD(rb_method_type_t, type, VM_METHOD_TYPE_MINIMUM_BITS); int alias_count : 28; int complemented_count : 28; @@ -177,9 +177,10 @@ PACKED_STRUCT_UNALIGNED(struct rb_method_definition_struct { } body; ID original_id; -}); +}; typedef struct rb_method_definition_struct rb_method_definition_t; +STATIC_ASSERT(sizeof_method_def, offsetof(rb_method_definition_t, body)==8); #define UNDEFINED_METHOD_ENTRY_P(me) (!(me) || !(me)->def || (me)->def->type == VM_METHOD_TYPE_UNDEF) #define UNDEFINED_REFINED_METHOD_P(def) \ From d2710ba86677380f016b6a84d81e5cb39837c04d Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 23 Jul 2019 05:21:41 +0900 Subject: [PATCH 333/452] Split test/ripper/test_files.rb to run in parallel --- .../{test_files.rb => assert_parse_files.rb} | 18 ------------------ test/ripper/test_files_ext.rb | 8 ++++++++ test/ripper/test_files_lib.rb | 14 ++++++++++++++ test/ripper/test_files_sample.rb | 8 ++++++++ test/ripper/test_files_test.rb | 8 ++++++++ test/ripper/test_files_test_1.rb | 9 +++++++++ test/ripper/test_files_test_2.rb | 9 +++++++++ 7 files changed, 56 insertions(+), 18 deletions(-) rename test/ripper/{test_files.rb => assert_parse_files.rb} (73%) create mode 100644 test/ripper/test_files_ext.rb create mode 100644 test/ripper/test_files_lib.rb create mode 100644 test/ripper/test_files_sample.rb create mode 100644 test/ripper/test_files_test.rb create mode 100644 test/ripper/test_files_test_1.rb create mode 100644 test/ripper/test_files_test_2.rb diff --git a/test/ripper/test_files.rb b/test/ripper/assert_parse_files.rb similarity index 73% rename from test/ripper/test_files.rb rename to test/ripper/assert_parse_files.rb index d90cd6479eba28..85d20cf69e5aa9 100644 --- a/test/ripper/test_files.rb +++ b/test/ripper/assert_parse_files.rb @@ -5,24 +5,6 @@ module TestRipper; end class TestRipper::Generic < Test::Unit::TestCase SRCDIR = File.expand_path("../../..", __FILE__) - %w[sample ext].each do |dir| - define_method("test_parse_files:#{dir}") do - assert_parse_files(dir) - end - end - - %w[lib test].each do |dir| - define_method("test_parse_files:#{dir}") do - assert_parse_files(dir, "*.rb") - end - Dir["#{SRCDIR}/#{dir}/*/"].each do |dir| - dir = dir[(SRCDIR.length+1)..-2] - define_method("test_parse_files:#{dir}") do - assert_parse_files(dir) - end - end - end - def assert_parse_files(dir, pattern = "**/*.rb") assert_separately(%W[--disable-gem -rripper - #{SRCDIR}/#{dir} #{pattern}], __FILE__, __LINE__, "#{<<-"begin;"}\n#{<<-'end;'}", timeout: Float::INFINITY) diff --git a/test/ripper/test_files_ext.rb b/test/ripper/test_files_ext.rb new file mode 100644 index 00000000000000..b77ec0fc8de231 --- /dev/null +++ b/test/ripper/test_files_ext.rb @@ -0,0 +1,8 @@ +require_relative 'assert_parse_files.rb' +class TestRipper::Generic + %w[ext].each do |dir| + define_method("test_parse_files:#{dir}") do + assert_parse_files(dir) + end + end +end diff --git a/test/ripper/test_files_lib.rb b/test/ripper/test_files_lib.rb new file mode 100644 index 00000000000000..19f204da568938 --- /dev/null +++ b/test/ripper/test_files_lib.rb @@ -0,0 +1,14 @@ +require_relative 'assert_parse_files.rb' +class TestRipper::Generic + %w[lib].each do |dir| + define_method("test_parse_files:#{dir}") do + assert_parse_files(dir, "*.rb") + end + Dir["#{SRCDIR}/#{dir}/*/"].each do |dir| + dir = dir[(SRCDIR.length+1)..-2] + define_method("test_parse_files:#{dir}") do + assert_parse_files(dir) + end + end + end +end diff --git a/test/ripper/test_files_sample.rb b/test/ripper/test_files_sample.rb new file mode 100644 index 00000000000000..57538b1358b34d --- /dev/null +++ b/test/ripper/test_files_sample.rb @@ -0,0 +1,8 @@ +require_relative 'assert_parse_files.rb' +class TestRipper::Generic + %w[sample].each do |dir| + define_method("test_parse_files:#{dir}") do + assert_parse_files(dir) + end + end +end diff --git a/test/ripper/test_files_test.rb b/test/ripper/test_files_test.rb new file mode 100644 index 00000000000000..5a8e368c718008 --- /dev/null +++ b/test/ripper/test_files_test.rb @@ -0,0 +1,8 @@ +require_relative 'assert_parse_files.rb' +class TestRipper::Generic + %w[test].each do |dir| + define_method("test_parse_files:#{dir}") do + assert_parse_files(dir, "*.rb") + end + end +end diff --git a/test/ripper/test_files_test_1.rb b/test/ripper/test_files_test_1.rb new file mode 100644 index 00000000000000..25db87783eaf3d --- /dev/null +++ b/test/ripper/test_files_test_1.rb @@ -0,0 +1,9 @@ +require_relative 'assert_parse_files.rb' +class TestRipper::Generic + Dir["#{SRCDIR}/test/[-a-n]*/"].each do |dir| + dir = dir[(SRCDIR.length+1)..-2] + define_method("test_parse_files:#{dir}") do + assert_parse_files(dir) + end + end +end diff --git a/test/ripper/test_files_test_2.rb b/test/ripper/test_files_test_2.rb new file mode 100644 index 00000000000000..24e935e71ebab5 --- /dev/null +++ b/test/ripper/test_files_test_2.rb @@ -0,0 +1,9 @@ +require_relative 'assert_parse_files.rb' +class TestRipper::Generic + Dir["#{SRCDIR}/test/[o-z]*/"].each do |dir| + dir = dir[(SRCDIR.length+1)..-2] + define_method("test_parse_files:#{dir}") do + assert_parse_files(dir) + end + end +end From c1ad6321b03bcf9f96f975bcba7ff1d205990149 Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Mon, 22 Jul 2019 14:02:39 -0700 Subject: [PATCH 334/452] Adjust documentation for Kernel#raise [ci skip] Mention how each of the arguments are retrievable from the generated Exception object. Fixes [Bug #10110] --- eval.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/eval.c b/eval.c index afc78532dfa7af..437838207caedf 100644 --- a/eval.c +++ b/eval.c @@ -714,23 +714,23 @@ extract_raise_opts(int argc, const VALUE *argv, VALUE *opts) * fail(exception [, string [, array]], cause: $!) * * With no arguments, raises the exception in $! or raises - * a RuntimeError if $! is +nil+. - * With a single +String+ argument, raises a - * +RuntimeError+ with the string as a message. Otherwise, - * the first parameter should be the name of an +Exception+ - * class (or an object that returns an +Exception+ object when sent - * an +exception+ message). The optional second parameter sets the - * message associated with the exception, and the third parameter is an - * array of callback information. Exceptions are caught by the - * +rescue+ clause of begin...end blocks. + * a RuntimeError if $! is +nil+. With a single +String+ + * argument, raises a +RuntimeError+ with the string as a message. Otherwise, + * the first parameter should be an +Exception+ class (or another + * object that returns an +Exception+ object when sent an +exception+ + * message). The optional second parameter sets the message associated with + * the exception (accessible via Exception#message), and the third parameter + * is an array of callback information (accessible via Exception#backtrace). + * The +cause+ of the generated exception (accessible via Exception#cause) + * is automatically set to the "current" exception ($!), if any. + * An alternative value, either an +Exception+ object or +nil+, can be + * specified via the +:cause+ argument. + * + * Exceptions are caught by the +rescue+ clause of + * begin...end blocks. * * raise "Failed to create socket" * raise ArgumentError, "No parameters", caller - * - * The +cause+ of the generated exception is automatically set to the - * "current" exception ($!) if any. An alternative - * value, either an +Exception+ object or +nil+, can be specified via - * the +:cause+ argument. */ VALUE From 32ec6dd5c7cb89979d48100acf8971ac09e0d02e Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Mon, 22 Jul 2019 14:43:36 -0700 Subject: [PATCH 335/452] Document encoding of string returned by Regexp.quote [ci skip] Also, remove documentation about returning self, which makes no sense as self would be the Regexp class. It could be interpreted as return the argument if no changes were made, but that hasn't been the behavior at least since 1.8.7 (and probably before). Fixes [Bug #10239] --- re.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/re.c b/re.c index 9941cf2debcb2f..969c1ec7b4b8f0 100644 --- a/re.c +++ b/re.c @@ -3578,8 +3578,8 @@ rb_reg_quote(VALUE str) * Regexp.quote(str) -> string * * Escapes any characters that would have special meaning in a regular - * expression. Returns a new escaped string, or self if no characters are - * escaped. For any string, + * expression. Returns a new escaped string with the same or compatible + * encoding. For any string, * Regexp.new(Regexp.escape(str))=~str will be true. * * Regexp.escape('\*?{}.') #=> \\\*\?\{\}\. From 01995df6453de45ba0d99835e26799260517657c Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Mon, 22 Jul 2019 15:07:22 -0700 Subject: [PATCH 336/452] Document BasicObject does not implement #object_id and #send [ci skip] Fixes [Bug #10422] --- gc.c | 2 ++ vm_eval.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/gc.c b/gc.c index feea9852ecb680..d61db0448ad8bf 100644 --- a/gc.c +++ b/gc.c @@ -3489,6 +3489,8 @@ rb_memory_id(VALUE obj) * Note: that some objects of builtin classes are reused for optimization. * This is the case for immediate values and frozen string literals. * + * BasicObject implements +__id__+, Kernel implements +object_id+. + * * Immediate values are not passed by reference but are passed by value: * +nil+, +true+, +false+, Fixnums, Symbols, and some Floats. * diff --git a/vm_eval.c b/vm_eval.c index 068944d0b5ef23..9281ebd40eb22d 100644 --- a/vm_eval.c +++ b/vm_eval.c @@ -951,6 +951,8 @@ send_internal(int argc, const VALUE *argv, VALUE recv, call_type scope) * When the method is identified by a string, the string is converted * to a symbol. * + * BasicObject implements +__send__+, Kernel implements +send+. + * * class Klass * def hello(*args) * "Hello " + args.join(' ') From 44cfabddbe8f62ce247118b12e75f4d2294d50b8 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Tue, 23 Jul 2019 11:20:08 +0900 Subject: [PATCH 337/452] Removed duplicated entry for racc. --- doc/maintainers.rdoc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/doc/maintainers.rdoc b/doc/maintainers.rdoc index 1718be1bf994f8..1f4955dd3f3758 100644 --- a/doc/maintainers.rdoc +++ b/doc/maintainers.rdoc @@ -90,8 +90,6 @@ Zachary Scott (zzak) Tanaka Akira (akr) [lib/pstore.rb] _unmaintained_ -[lib/racc/*] - Aaron Patterson (tenderlove) [lib/reline.rb, lib/reline/*] aycabta [lib/resolv-replace.rb] @@ -156,8 +154,6 @@ Zachary Scott (zzak) Tanaka Akira (akr) [ext/pty] _unmaintained_ -[ext/racc] - Aaron Patterson (tenderlove) [ext/readline] TAKAO Kouji (kouji) [ext/ripper] @@ -266,6 +262,8 @@ Zachary Scott (zzak) [ext/psych] Aaron Patterson (tenderlove), Hiroshi SHIBATA (hsbt) https://github.com/ruby/psych +[ext/racc] + Aaron Patterson (tenderlove), Hiroshi SHIBATA (hsbt) [ext/sdbm] Yukihiro Matsumoto (matz) https://github.com/ruby/sdbm From 73d56d6fe7dd387342ddfcefbaff402f7dcaa232 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Tue, 23 Jul 2019 13:32:21 +0900 Subject: [PATCH 338/452] reline is default gems now. --- doc/maintainers.rdoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/maintainers.rdoc b/doc/maintainers.rdoc index 1f4955dd3f3758..f35d560b8f9c07 100644 --- a/doc/maintainers.rdoc +++ b/doc/maintainers.rdoc @@ -90,8 +90,6 @@ Zachary Scott (zzak) Tanaka Akira (akr) [lib/pstore.rb] _unmaintained_ -[lib/reline.rb, lib/reline/*] - aycabta [lib/resolv-replace.rb] Tanaka Akira (akr) [lib/resolv.rb] @@ -208,6 +206,8 @@ Zachary Scott (zzak) [lib/rdoc.rb, lib/rdoc/*] Eric Hodel (drbrain), Hiroshi SHIBATA (hsbt) https://github.com/ruby/rdoc +[lib/reline.rb, lib/reline/*] + aycabta [lib/rexml/*] Kouhei Sutou (kou) [lib/rss.rb, lib/rss/*] From ab087ecb4dd21ea5f7d1cbadd8298f2f1a3c9ce9 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Tue, 23 Jul 2019 13:34:35 +0900 Subject: [PATCH 339/452] Added the upstream repositories to default gems. --- doc/maintainers.rdoc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/doc/maintainers.rdoc b/doc/maintainers.rdoc index f35d560b8f9c07..e01df7f2b01b12 100644 --- a/doc/maintainers.rdoc +++ b/doc/maintainers.rdoc @@ -186,20 +186,28 @@ Zachary Scott (zzak) https://github.com/ruby/fileutils [lib/forwardable.rb] Keiju ISHITSUKA (keiju) + https://github.com/ruby/forwardable [lib/ipaddr.rb] Akinori MUSHA (knu) + https://github.com/ruby/ipaddr [lib/irb.rb, lib/irb/*] Keiju ISHITSUKA (keiju) + https://github.com/ruby/irb [lib/logger.rb] Naotoshi Seo (sonots) + https://github.com/ruby/logger [lib/matrix.rb] Marc-Andre Lafortune (marcandre) + https://github.com/ruby/matrix [lib/mutex_m.rb] Keiju ISHITSUKA (keiju) + https://github.com/ruby/mutex_m [lib/ostruct.rb] Marc-Andre Lafortune (marcandre) + https://github.com/ruby/ostruct [lib/prime.rb] Yuki Sonoda (yugui) + https://github.com/ruby/prime [lib/racc.rb, lib/racc/*] Aaron Patterson (tenderlove), Hiroshi SHIBATA (hsbt) https://github.com/ruby/racc @@ -208,21 +216,28 @@ Zachary Scott (zzak) https://github.com/ruby/rdoc [lib/reline.rb, lib/reline/*] aycabta + https://github.com/ruby/reline [lib/rexml/*] Kouhei Sutou (kou) + https://github.com/ruby/rexml [lib/rss.rb, lib/rss/*] Kouhei Sutou (kou) + https://github.com/ruby/rss [lib/scanf.rb] David A. Black (dblack) https://github.com/ruby/scanf [lib/shell.rb, lib/shell/*] Keiju ISHITSUKA (keiju) + https://github.com/ruby/shell [lib/sync.rb] Keiju ISHITSUKA (keiju) + https://github.com/ruby/sync [lib/thwait.rb] Keiju ISHITSUKA (keiju) + https://github.com/ruby/thwait [lib/tracer.rb] Keiju ISHITSUKA (keiju) + https://github.com/ruby/tracer [lib/webrick.rb, lib/webrick/*] Eric Wong (normalperson) https://bugs.ruby-lang.org/ @@ -264,6 +279,7 @@ Zachary Scott (zzak) https://github.com/ruby/psych [ext/racc] Aaron Patterson (tenderlove), Hiroshi SHIBATA (hsbt) + https://github.com/ruby/racc [ext/sdbm] Yukihiro Matsumoto (matz) https://github.com/ruby/sdbm From 90c4bd2d2bd10b19c2b09834396553742bc7e8a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lourens=20Naud=C3=A9?= Date: Mon, 22 Apr 2019 23:24:52 +0100 Subject: [PATCH 340/452] Let memory sizes of the various IMEMO object types be reflected correctly [Feature #15805] Closes: https://github.com/ruby/ruby/pull/2140 --- gc.c | 39 ++++++++++++++++++++++++++++++++++++--- iseq.c | 6 +++--- node.c | 23 +++++++++++++++++++++-- node.h | 1 + 4 files changed, 61 insertions(+), 8 deletions(-) diff --git a/gc.c b/gc.c index d61db0448ad8bf..a978887ae92352 100644 --- a/gc.c +++ b/gc.c @@ -842,6 +842,7 @@ int ruby_disable_gc = 0; void rb_iseq_mark(const rb_iseq_t *iseq); void rb_iseq_update_references(rb_iseq_t *iseq); void rb_iseq_free(const rb_iseq_t *iseq); +size_t rb_iseq_memsize(const rb_iseq_t *iseq); void rb_vm_update_references(void *ptr); void rb_gcdebug_print_obj_condition(VALUE obj); @@ -2159,6 +2160,40 @@ rb_imemo_tmpbuf_parser_heap(void *buf, rb_imemo_tmpbuf_t *old_heap, size_t cnt) return (rb_imemo_tmpbuf_t *)rb_imemo_tmpbuf_new((VALUE)buf, (VALUE)old_heap, (VALUE)cnt, 0); } +static size_t +imemo_memsize(VALUE obj) +{ + size_t size = 0; + switch (imemo_type(obj)) { + case imemo_ment: + size += sizeof(RANY(obj)->as.imemo.ment.def); + break; + case imemo_iseq: + size += rb_iseq_memsize((rb_iseq_t *)obj); + break; + case imemo_env: + size += RANY(obj)->as.imemo.env.env_size * sizeof(VALUE); + break; + case imemo_tmpbuf: + size += RANY(obj)->as.imemo.alloc.cnt * sizeof(VALUE); + break; + case imemo_ast: + size += rb_ast_memsize(&RANY(obj)->as.imemo.ast); + break; + case imemo_cref: + case imemo_svar: + case imemo_throw_data: + case imemo_ifunc: + case imemo_memo: + case imemo_parser_strterm: + break; + default: + /* unreachable */ + break; + } + return size; +} + #if IMEMO_DEBUG VALUE rb_imemo_new_debug(enum imemo_type type, VALUE v1, VALUE v2, VALUE v3, VALUE v0, const char *file, int line) @@ -3628,9 +3663,7 @@ obj_memsize_of(VALUE obj, int use_all_types) case T_COMPLEX: break; case T_IMEMO: - if (imemo_type_p(obj, imemo_tmpbuf)) { - size += RANY(obj)->as.imemo.alloc.cnt * sizeof(VALUE); - } + size += imemo_memsize(obj); break; case T_FLOAT: diff --git a/iseq.c b/iseq.c index fa4e72d2cdfc85..9ee8d412757d5a 100644 --- a/iseq.c +++ b/iseq.c @@ -361,8 +361,8 @@ param_keyword_size(const struct rb_iseq_param_keyword *pkw) return size; } -static size_t -iseq_memsize(const rb_iseq_t *iseq) +size_t +rb_iseq_memsize(const rb_iseq_t *iseq) { size_t size = 0; /* struct already counted as RVALUE size */ const struct rb_iseq_constant_body *body = iseq->body; @@ -1109,7 +1109,7 @@ iseqw_mark(void *ptr) static size_t iseqw_memsize(const void *ptr) { - return iseq_memsize((const rb_iseq_t *)ptr); + return rb_iseq_memsize((const rb_iseq_t *)ptr); } static const rb_data_type_t iseqw_data_type = { diff --git a/node.c b/node.c index e4c4961217d196..99558319f832b0 100644 --- a/node.c +++ b/node.c @@ -12,6 +12,8 @@ #include "ruby/ruby.h" #include "vm_core.h" +#define NODE_BUF_DEFAULT_LEN 16 + #define A(str) rb_str_cat2(buf, (str)) #define AR(str) rb_str_concat(buf, (str)) @@ -1122,9 +1124,9 @@ struct node_buffer_struct { static node_buffer_t * rb_node_buffer_new(void) { - node_buffer_t *nb = xmalloc(sizeof(node_buffer_t) + offsetof(node_buffer_elem_t, buf) + 16 * sizeof(NODE)); + node_buffer_t *nb = xmalloc(sizeof(node_buffer_t) + offsetof(node_buffer_elem_t, buf) + NODE_BUF_DEFAULT_LEN * sizeof(NODE)); nb->idx = 0; - nb->len = 16; + nb->len = NODE_BUF_DEFAULT_LEN; nb->head = nb->last = (node_buffer_elem_t*) &nb[1]; nb->head->next = NULL; nb->mark_ary = rb_ary_tmp_new(0); @@ -1193,6 +1195,23 @@ rb_ast_free(rb_ast_t *ast) } } +size_t +rb_ast_memsize(const rb_ast_t *ast) +{ + size_t size = 0; + node_buffer_t *nb = ast->node_buffer; + + if (nb) { + size += sizeof(node_buffer_t) + offsetof(node_buffer_elem_t, buf) + NODE_BUF_DEFAULT_LEN * sizeof(NODE); + node_buffer_elem_t *nbe = nb->head; + while (nbe != nb->last) { + nbe = nbe->next; + size += offsetof(node_buffer_elem_t, buf) + nb->len * sizeof(NODE); + } + } + return size; +} + void rb_ast_dispose(rb_ast_t *ast) { diff --git a/node.h b/node.h index a1f01ed08819c5..3741e649caa2eb 100644 --- a/node.h +++ b/node.h @@ -406,6 +406,7 @@ rb_ast_t *rb_ast_new(void); void rb_ast_mark(rb_ast_t*); void rb_ast_dispose(rb_ast_t*); void rb_ast_free(rb_ast_t*); +size_t rb_ast_memsize(const rb_ast_t*); void rb_ast_add_mark_object(rb_ast_t*, VALUE); NODE *rb_ast_newnode(rb_ast_t*); void rb_ast_delete_node(rb_ast_t*, NODE *n); From 33f54da15ba137fc1569016f5caa492c1a57eb4d Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 23 Jul 2019 16:18:40 +0900 Subject: [PATCH 341/452] Support memsize of AST --- ast.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ast.c b/ast.c index a1af214b336cb5..4c6477d3c93b69 100644 --- a/ast.c +++ b/ast.c @@ -22,9 +22,16 @@ node_gc_mark(void *ptr) rb_gc_mark((VALUE)data->ast); } +static size_t +node_memsize(const void *ptr) +{ + struct ASTNodeData *data = (struct ASTNodeData *)ptr; + return rb_ast_memsize(data->ast); +} + static const rb_data_type_t rb_node_type = { "AST/node", - {node_gc_mark, RUBY_TYPED_DEFAULT_FREE, 0,}, + {node_gc_mark, RUBY_TYPED_DEFAULT_FREE, node_memsize,}, 0, 0, RUBY_TYPED_FREE_IMMEDIATELY, }; From c25ff7bb5d8e8d2985ec8fd32a7211a06ad4eca0 Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Tue, 23 Jul 2019 08:42:20 +0100 Subject: [PATCH 342/452] check iseq is executable --- iseq.c | 56 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/iseq.c b/iseq.c index 9ee8d412757d5a..776576a52b3059 100644 --- a/iseq.c +++ b/iseq.c @@ -370,41 +370,41 @@ rb_iseq_memsize(const rb_iseq_t *iseq) /* TODO: should we count original_iseq? */ - if (body) { - struct rb_call_info_with_kwarg *ci_kw_entries = (struct rb_call_info_with_kwarg *)&body->ci_entries[body->ci_size]; + if (ISEQ_EXECUTABLE_P(iseq) && body) { + struct rb_call_info_with_kwarg *ci_kw_entries = (struct rb_call_info_with_kwarg *)&body->ci_entries[body->ci_size]; - size += sizeof(struct rb_iseq_constant_body); - size += body->iseq_size * sizeof(VALUE); - size += body->insns_info.size * (sizeof(struct iseq_insn_info_entry) + sizeof(unsigned int)); - size += body->local_table_size * sizeof(ID); - if (body->catch_table) { - size += iseq_catch_table_bytes(body->catch_table->size); - } - size += (body->param.opt_num + 1) * sizeof(VALUE); - size += param_keyword_size(body->param.keyword); + size += sizeof(struct rb_iseq_constant_body); + size += body->iseq_size * sizeof(VALUE); + size += body->insns_info.size * (sizeof(struct iseq_insn_info_entry) + sizeof(unsigned int)); + size += body->local_table_size * sizeof(ID); + if (body->catch_table) { + size += iseq_catch_table_bytes(body->catch_table->size); + } + size += (body->param.opt_num + 1) * sizeof(VALUE); + size += param_keyword_size(body->param.keyword); - /* body->is_entries */ - size += body->is_size * sizeof(union iseq_inline_storage_entry); + /* body->is_entries */ + size += body->is_size * sizeof(union iseq_inline_storage_entry); - /* body->ci_entries */ - size += body->ci_size * sizeof(struct rb_call_info); - size += body->ci_kw_size * sizeof(struct rb_call_info_with_kwarg); + /* body->ci_entries */ + size += body->ci_size * sizeof(struct rb_call_info); + size += body->ci_kw_size * sizeof(struct rb_call_info_with_kwarg); - /* body->cc_entries */ - size += body->ci_size * sizeof(struct rb_call_cache); - size += body->ci_kw_size * sizeof(struct rb_call_cache); + /* body->cc_entries */ + size += body->ci_size * sizeof(struct rb_call_cache); + size += body->ci_kw_size * sizeof(struct rb_call_cache); - if (ci_kw_entries) { - unsigned int i; + if (ci_kw_entries) { + unsigned int i; - for (i = 0; i < body->ci_kw_size; i++) { - const struct rb_call_info_kw_arg *kw_arg = ci_kw_entries[i].kw_arg; + for (i = 0; i < body->ci_kw_size; i++) { + const struct rb_call_info_kw_arg *kw_arg = ci_kw_entries[i].kw_arg; - if (kw_arg) { - size += rb_call_info_kw_arg_bytes(kw_arg->keyword_len); - } - } - } + if (kw_arg) { + size += rb_call_info_kw_arg_bytes(kw_arg->keyword_len); + } + } + } } compile_data = ISEQ_COMPILE_DATA(iseq); From 6546aed4757be07f4932326e1eb41a5d69141acf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lourens=20Naud=C3=A9?= Date: Sat, 13 Apr 2019 17:05:58 +0100 Subject: [PATCH 343/452] Explicitly initialise encodings on init to remove branches on encoding lookup [Misc #15806] Closes: https://github.com/ruby/ruby/pull/2128 --- encoding.c | 23 ++++++----------------- inits.c | 1 + 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/encoding.c b/encoding.c index 012d18c690fc2f..9655213f733caa 100644 --- a/encoding.c +++ b/encoding.c @@ -66,8 +66,6 @@ static struct { #define ENC_DUMMY_P(enc) ((enc)->ruby_encoding_index & ENC_DUMMY_FLAG) #define ENC_SET_DUMMY(enc) ((enc)->ruby_encoding_index |= ENC_DUMMY_FLAG) -void rb_enc_init(void); - #define ENCODING_COUNT ENCINDEX_BUILTIN_MAX #define UNSPECIFIED_ENCODING INT_MAX @@ -557,9 +555,6 @@ rb_enc_alias(const char *alias, const char *orig) int idx; enc_check_duplication(alias); - if (!enc_table.list) { - rb_enc_init(); - } if ((idx = rb_enc_find_index(orig)) < 0) { return -1; } @@ -613,9 +608,6 @@ rb_enc_init(void) rb_encoding * rb_enc_from_index(int index) { - if (!enc_table.list) { - rb_enc_init(); - } if (index < 0 || enc_table.count <= (index &= ENC_INDEX_MASK)) { return 0; } @@ -1324,9 +1316,6 @@ enc_m_loader(VALUE klass, VALUE str) rb_encoding * rb_ascii8bit_encoding(void) { - if (!enc_table.list) { - rb_enc_init(); - } return enc_table.list[ENCINDEX_ASCII].enc; } @@ -1339,9 +1328,6 @@ rb_ascii8bit_encindex(void) rb_encoding * rb_utf8_encoding(void) { - if (!enc_table.list) { - rb_enc_init(); - } return enc_table.list[ENCINDEX_UTF_8].enc; } @@ -1354,9 +1340,6 @@ rb_utf8_encindex(void) rb_encoding * rb_usascii_encoding(void) { - if (!enc_table.list) { - rb_enc_init(); - } return enc_table.list[ENCINDEX_US_ASCII].enc; } @@ -1933,6 +1916,12 @@ rb_enc_aliases(VALUE klass) * */ +void +Init_encodings(void) +{ + rb_enc_init(); +} + void Init_Encoding(void) { diff --git a/inits.c b/inits.c index ad34223e36bb3e..75ee976192a3a7 100644 --- a/inits.c +++ b/inits.c @@ -22,6 +22,7 @@ rb_call_inits(void) CALL(vm_postponed_job); CALL(Method); CALL(RandomSeedCore); + CALL(encodings); CALL(sym); CALL(var_tables); CALL(Object); From 009ec37a47e2f2b5e7f928004fbc3403f0bd8abe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lourens=20Naud=C3=A9?= Date: Sat, 13 Apr 2019 17:39:05 +0100 Subject: [PATCH 344/452] Let the index boundary check in rb_enc_from_index be flagged as unlikely [Misc #15806] Closes: https://github.com/ruby/ruby/pull/2128 --- encoding.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/encoding.c b/encoding.c index 9655213f733caa..908a6458a0c009 100644 --- a/encoding.c +++ b/encoding.c @@ -608,7 +608,7 @@ rb_enc_init(void) rb_encoding * rb_enc_from_index(int index) { - if (index < 0 || enc_table.count <= (index &= ENC_INDEX_MASK)) { + if (UNLIKELY(index < 0 || enc_table.count <= (index &= ENC_INDEX_MASK))) { return 0; } return enc_table.list[index].enc; From 0338c44bde4fe55f0507a82fe470dce2ac70127a Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 23 Jul 2019 17:39:03 +0900 Subject: [PATCH 345/452] Retry to update Unicode timestamp --- .travis.yml | 8 ++++++-- common.mk | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8e8f2759cc5959..71074650c585ae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -420,8 +420,12 @@ before_script: - "> config.status" - "> .rbconfig.time" - sed -f tool/prereq.status template/Makefile.in common.mk > Makefile - - date; make touch-unicode-files - - date; make --debug -s $JOBS $UPDATE_UNICODE up + - |- + for i in 1 2 3; do + date; make touch-unicode-files || break + ls -l tool/generic_erb.rb template/unicode_norm_gen.tmpl enc/unicode/data/*/ucd/.unicode-tables.time + date; make -s $JOBS $UPDATE_UNICODE up && break + done - date; make -s $JOBS srcs - rm -f config.status Makefile rbconfig.rb .rbconfig.time - |- diff --git a/common.mk b/common.mk index f795df874ad247..0d6da60672be20 100644 --- a/common.mk +++ b/common.mk @@ -1399,7 +1399,7 @@ $(UNICODE_SRC_DATA_DIR)/.unicode-tables.time: $(srcdir)/tool/generic_erb.rb \ $(Q) $(MAKE) $(@D) $(Q) $(BASERUBY) $(srcdir)/tool/generic_erb.rb \ -c $(UNICODE_TABLES_TIMESTAMP:yes=-t$@) \ - -o $(srcdir)/lib/unicode_normalize/tables.rb \ + -o $(srcdir)/lib/unicode_normalize/tables.rb \ -I $(srcdir) \ $(srcdir)/template/unicode_norm_gen.tmpl \ $(UNICODE_DATA_DIR) lib/unicode_normalize From e8d4f0cbc78b0e06806394a93ba73b7d04eba14d Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 23 Jul 2019 17:59:43 +0900 Subject: [PATCH 346/452] Show seconds and in the modified time order [ci skip] --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 71074650c585ae..53f5caa34dc1fa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -423,7 +423,7 @@ before_script: - |- for i in 1 2 3; do date; make touch-unicode-files || break - ls -l tool/generic_erb.rb template/unicode_norm_gen.tmpl enc/unicode/data/*/ucd/.unicode-tables.time + ls -ltT tool/generic_erb.rb template/unicode_norm_gen.tmpl enc/unicode/data/*/ucd/.unicode-tables.time date; make -s $JOBS $UPDATE_UNICODE up && break done - date; make -s $JOBS srcs From 03958a0c0d0140a2c27f8e3175f9c118425c762c Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 23 Jul 2019 18:22:25 +0900 Subject: [PATCH 347/452] Relaxed target_os matching When target_alias is not empty, `-gnu` suffixed is not stripped. [Bug #16015] --- configure.ac | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index 9703591af7eed9..61427167851fdd 100644 --- a/configure.ac +++ b/configure.ac @@ -2260,14 +2260,14 @@ AS_CASE([$rb_cv_coroutine], [yes|''], [ [x*64-darwin*], [ rb_cv_coroutine=amd64 ], - [x*64-linux], [ + [x*64-linux*], [ AS_CASE(["$ac_cv_sizeof_voidp"], [8], [ rb_cv_coroutine=amd64 ], [4], [ rb_cv_coroutine=x86 ], [*], [ rb_cv_coroutine= ] ) ], - [*86-linux], [ + [*86-linux*], [ rb_cv_coroutine=x86 ], [x64-mingw32], [ @@ -2276,13 +2276,13 @@ AS_CASE([$rb_cv_coroutine], [yes|''], [ [*86-mingw32], [ rb_cv_coroutine=win32 ], - [armv7*-linux-*], [ + [armv7*-linux*], [ rb_cv_coroutine=ucontext ], - [aarch64-linux], [ + [aarch64-linux*], [ rb_cv_coroutine=arm64 ], - [powerpc64le-linux], [ + [powerpc64le-linux*], [ rb_cv_coroutine=ppc64le ], [x86_64-openbsd*], [ From 676df311d90990a4666adb5b1db4c7aa6b080e57 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 23 Jul 2019 20:51:23 +0900 Subject: [PATCH 348/452] Reset mtime of all files on osx Often checked out files are in the future on OSX image. --- .travis.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 53f5caa34dc1fa..683a58baba4cab 100644 --- a/.travis.yml +++ b/.travis.yml @@ -341,6 +341,8 @@ env: - TEST_ALL_ISOLATED_TESTS="../test/ruby/test_gc_compact.rb" # Disabling -j3 because it seems to cause a hang on building Ruby: https://travis-ci.org/ruby/ruby/jobs/471021727 - JOBS= + # Reset timestamps earily, before updating Homebrew etc. + - _=$(touch NEWS && find . -type f -exec touch -r NEWS {} +) - &dependency name: Check dependencies in makefiles @@ -420,12 +422,8 @@ before_script: - "> config.status" - "> .rbconfig.time" - sed -f tool/prereq.status template/Makefile.in common.mk > Makefile - - |- - for i in 1 2 3; do - date; make touch-unicode-files || break - ls -ltT tool/generic_erb.rb template/unicode_norm_gen.tmpl enc/unicode/data/*/ucd/.unicode-tables.time - date; make -s $JOBS $UPDATE_UNICODE up && break - done + - date; make touch-unicode-files + - date; make -s $JOBS $UPDATE_UNICODE up - date; make -s $JOBS srcs - rm -f config.status Makefile rbconfig.rb .rbconfig.time - |- From b6f07f748a95f1d5dc0d21e821320564776c744d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Burgos=20Maci=C3=A1?= Date: Fri, 19 Jul 2019 15:59:21 -0400 Subject: [PATCH 349/452] Document that non-blocking mode isn't always supported on Windows [ci skip] --- prelude.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/prelude.rb b/prelude.rb index 4f4277b66490cb..25f66cdf13b366 100644 --- a/prelude.rb +++ b/prelude.rb @@ -39,6 +39,10 @@ class IO # # read_nonblock causes EOFError on EOF. # + # On some platforms, such as Windows, non-blocking mode is not supported + # on IO objects other than sockets. In such cases, Errno::EBADF will + # be raised. + # # If the read byte buffer is not empty, # read_nonblock reads from the buffer like readpartial. # In this case, the read(2) system call is not called. From 325f7b6008a4a10e9b0f1c69ee4518b0669461be Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Sun, 7 Jul 2019 20:16:57 -0700 Subject: [PATCH 350/452] Make pkg_config in mkmf include -I cflags in return value This was the historical behavior, it was modified unintentionally by 097c3e9cbbf23718371f08c24b2d2297b039f63f, which started storing these flags in a different global variable. Also, include the incflags when logging, and document that the method modifies $INCFLAGS. Fixes [Bug #10651] --- lib/mkmf.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/mkmf.rb b/lib/mkmf.rb index bf95484aa8d677..692ceb43a99e0c 100644 --- a/lib/mkmf.rb +++ b/lib/mkmf.rb @@ -1801,7 +1801,7 @@ def dir_config(target, idefault=nil, ldefault=nil) # # Where {option} is, for instance, --cflags. # - # The values obtained are appended to +$CFLAGS+, +$LDFLAGS+ and + # The values obtained are appended to +$INCFLAGS+, +$CFLAGS+, +$LDFLAGS+ and # +$libs+. # # If an option argument is given, the config command is @@ -1857,9 +1857,9 @@ def pkg_config(pkg, option=nil) $LDFLAGS = [orig_ldflags, ldflags].join(' ') Logging::message "package configuration for %s\n", pkg - Logging::message "cflags: %s\nldflags: %s\nlibs: %s\n\n", - cflags, ldflags, libs - [cflags, ldflags, libs] + Logging::message "incflags: %s\ncflags: %s\nldflags: %s\nlibs: %s\n\n", + incflags, cflags, ldflags, libs + [[incflags, cflags].join(' '), ldflags, libs] else Logging::message "package configuration for %s is not found\n", pkg nil From c9826c20d204d4b8894e6fd51e5913959676776d Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 24 Jul 2019 00:24:12 +0900 Subject: [PATCH 351/452] Show the caller's location * lib/net/http/header.rb: show the caller's location instead of the current lines. --- lib/net/http/header.rb | 4 ++-- test/net/http/test_httpheader.rb | 14 +++++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/net/http/header.rb b/lib/net/http/header.rb index 7865814208a532..356b08d6fb495d 100644 --- a/lib/net/http/header.rb +++ b/lib/net/http/header.rb @@ -14,9 +14,9 @@ def initialize_http_header(initheader) @header = {} return unless initheader initheader.each do |key, value| - warn "net/http: duplicated HTTP header: #{key}", uplevel: 1 if key?(key) and $VERBOSE + warn "net/http: duplicated HTTP header: #{key}", uplevel: 3 if key?(key) and $VERBOSE if value.nil? - warn "net/http: nil HTTP header: #{key}", uplevel: 1 if $VERBOSE + warn "net/http: nil HTTP header: #{key}", uplevel: 3 if $VERBOSE else value = value.strip # raise error for invalid byte sequences if value.count("\r\n") > 0 diff --git a/test/net/http/test_httpheader.rb b/test/net/http/test_httpheader.rb index cb4678a8050caf..cfbe36bcfd4187 100644 --- a/test/net/http/test_httpheader.rb +++ b/test/net/http/test_httpheader.rb @@ -119,7 +119,19 @@ def test_get_fields class D; include Net::HTTPHeader; end def test_nil_variable_header - assert_nothing_raised { D.new.initialize_http_header({Authorization: nil}) } + assert_nothing_raised do + assert_warning("#{__FILE__}:#{__LINE__+1}: warning: net/http: nil HTTP header: Authorization\n") do + D.new.initialize_http_header({Authorization: nil}) + end + end + end + + def test_duplicated_variable_header + assert_nothing_raised do + assert_warning("#{__FILE__}:#{__LINE__+1}: warning: net/http: duplicated HTTP header: Authorization\n") do + D.new.initialize_http_header({"AUTHORIZATION": "yes", "Authorization": "no"}) + end + end end def test_delete From f295e23e54dd000806e252798e352f327606cd86 Mon Sep 17 00:00:00 2001 From: git Date: Wed, 24 Jul 2019 00:32:43 +0900 Subject: [PATCH 352/452] * 2019-07-24 --- version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.h b/version.h index 0706e7f98e3b80..68d73dcc1c1e2a 100644 --- a/version.h +++ b/version.h @@ -6,7 +6,7 @@ #define RUBY_RELEASE_YEAR 2019 #define RUBY_RELEASE_MONTH 7 -#define RUBY_RELEASE_DAY 23 +#define RUBY_RELEASE_DAY 24 #include "ruby/version.h" From afea8db8c7a6bca9042002dd305d45494eb2656f Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 24 Jul 2019 01:42:05 +0900 Subject: [PATCH 353/452] Test invalid offset warnings --- test/date/test_date_strftime.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/date/test_date_strftime.rb b/test/date/test_date_strftime.rb index dc237a909dbe51..f82874d26d025b 100644 --- a/test/date/test_date_strftime.rb +++ b/test/date/test_date_strftime.rb @@ -186,13 +186,16 @@ def test_strftime__offset (-24..24).collect{|x| '%+.2d' % x}.each do |hh| %w(00 30).each do |mm| r = hh + mm - if r[-4,4] == '2430' - r = '+0000' - end + next if r.end_with?('2430') d = DateTime.parse(s + hh + mm) assert_equal(r, d.strftime('%z')) end end + %w[+2430 -2430].each do |r| + assert_warning(/invalid offset/) do + DateTime.parse(s + r) + end + end end def test_strftime_milli From 11662c70b073da21dcd5213b61434bce2ed6af8f Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 24 Jul 2019 01:42:35 +0900 Subject: [PATCH 354/452] Test missing Content-Type warnings --- test/net/http/test_http.rb | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/test/net/http/test_http.rb b/test/net/http/test_http.rb index 0344ad786bf7f6..b5c4463544cfd2 100644 --- a/test/net/http/test_http.rb +++ b/test/net/http/test_http.rb @@ -469,9 +469,11 @@ def _test_post__no_data(http) def test_s_post url = "http://#{config('host')}:#{config('port')}/?q=a" - res = Net::HTTP.post( + res = assert_warning(/Content-Type did not set/) do + Net::HTTP.post( URI.parse(url), "a=x") + end assert_equal "application/x-www-form-urlencoded", res["Content-Type"] assert_equal "a=x", res.body assert_equal url, res["X-request-uri"] @@ -542,7 +544,11 @@ def test_timeout_during_HTTP_session_write th = Thread.new do err = !windows? ? Net::WriteTimeout : Net::ReadTimeout - assert_raise(err) { conn.post('/', "a"*50_000_000) } + assert_raise(err) do + assert_warning(/Content-Type did not set/) do + conn.post('/', "a"*50_000_000) + end + end end assert th.join(EnvUtil.apply_timeout_scale(10)) } @@ -989,7 +995,7 @@ def test_expect_continue_error_before_body raise WEBrick::HTTPStatus::Forbidden } start {|http| - uheader = {'content-length' => '5', 'expect' => '100-continue'} + uheader = {'content-type' => 'application/x-www-form-urlencoded', 'content-length' => '5', 'expect' => '100-continue'} http.continue_timeout = 1 # allow the server to respond before sending http.request_post('/continue', 'data', uheader) {|res| assert_equal(res.code, '403') @@ -1041,7 +1047,8 @@ def test_info } start {|http| http.continue_timeout = 0.2 - http.request_post('/continue', 'body=BODY') {|res| + http.request_post('/continue', 'body=BODY', + 'content-type' => 'application/x-www-form-urlencoded') {|res| assert_equal('BODY', res.read_body) } } From 9aba971e42c78bb9e446f28c0402bad55147a863 Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Sun, 7 Jul 2019 17:58:25 -0700 Subject: [PATCH 355/452] Make Object#singleton_methods work correctly for singleton classes of objects Fixes [Bug #10901] --- class.c | 3 +++ test/ruby/test_object.rb | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/class.c b/class.c index a8d21f94433c92..243f8c4610f765 100644 --- a/class.c +++ b/class.c @@ -1447,6 +1447,9 @@ rb_obj_singleton_methods(int argc, const VALUE *argv, VALUE obj) int recur = TRUE; if (rb_check_arity(argc, 0, 1)) recur = RTEST(argv[0]); + if (RB_TYPE_P(obj, T_CLASS) && FL_TEST(obj, FL_SINGLETON)) { + rb_singleton_class(obj); + } klass = CLASS_OF(obj); origin = RCLASS_ORIGIN(klass); me_arg.list = st_init_numtable(); diff --git a/test/ruby/test_object.rb b/test/ruby/test_object.rb index 277995b32359c7..fcb6c2826f22b1 100644 --- a/test/ruby/test_object.rb +++ b/test/ruby/test_object.rb @@ -865,6 +865,29 @@ def initialize assert_match(/@\u{3046}=6\b/, x.inspect) end + def test_singleton_methods + assert_equal([], Object.new.singleton_methods) + assert_equal([], Object.new.singleton_methods(false)) + c = Class.new + def c.foo; end + assert_equal([:foo], c.singleton_methods - [:yaml_tag]) + assert_equal([:foo], c.singleton_methods(false)) + assert_equal([], c.singleton_class.singleton_methods(false)) + c.singleton_class.singleton_class + assert_equal([], c.singleton_class.singleton_methods(false)) + + o = c.new.singleton_class + assert_equal([:foo], o.singleton_methods - [:yaml_tag]) + assert_equal([], o.singleton_methods(false)) + o.singleton_class + assert_equal([:foo], o.singleton_methods - [:yaml_tag]) + assert_equal([], o.singleton_methods(false)) + + c.extend(Module.new{def bar; end}) + assert_equal([:bar, :foo], c.singleton_methods.sort - [:yaml_tag]) + assert_equal([:foo], c.singleton_methods(false)) + end + def test_singleton_class x = Object.new xs = class << x; self; end From a4e5690760c9177bc4234fdc5152d82ba73d26d0 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Wed, 24 Jul 2019 04:49:51 +0900 Subject: [PATCH 356/452] transcode.c (rb_econv_open0): remove unused code Coverity Scan found this. --- transcode.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/transcode.c b/transcode.c index 0f72a2d735ee8c..86ca57b74844ca 100644 --- a/transcode.c +++ b/transcode.c @@ -974,21 +974,10 @@ rb_econv_open0(const char *sname, const char *dname, int ecflags) int num_trans; rb_econv_t *ec; - int sidx, didx; - - if (*sname) { - sidx = rb_enc_find_index(sname); - if (0 <= sidx) { - rb_enc_from_index(sidx); - } - } - - if (*dname) { - didx = rb_enc_find_index(dname); - if (0 <= didx) { - rb_enc_from_index(didx); - } - } + /* Just check if sname and dname are defined */ + /* (This check is needed?) */ + if (*sname) rb_enc_find_index(sname); + if (*dname) rb_enc_find_index(dname); if (*sname == '\0' && *dname == '\0') { num_trans = 0; From df317151a5b4e0c5a30fcc321a9dc6abad63f7ed Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Wed, 24 Jul 2019 05:32:09 +0900 Subject: [PATCH 357/452] should not free local hook_list here. exec_hooks_postcheck() clean executed hook_list if it is needed. list_exec is freed if there are no events and this list is local event (connected to specific iseq). However, iseq keeps to point this local hook_list, freed list. To prevent this situation, do not free hook_list here even if it has no events. This issue is reported by @joker1007. https://twitter.com/joker1007/status/1153649170797830144 --- test/ruby/test_settracefunc.rb | 17 +++++++++++++++++ vm_trace.c | 3 --- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/test/ruby/test_settracefunc.rb b/test/ruby/test_settracefunc.rb index cfc90f50b7bd30..1f99d3ee88dcf4 100644 --- a/test/ruby/test_settracefunc.rb +++ b/test/ruby/test_settracefunc.rb @@ -2166,4 +2166,21 @@ def obj.example tp.enable {obj.example} assert ok, "return event should be emitted" end + + def test_disable_local_tracepoint_in_trace + assert_normal_exit <<-EOS + def foo + trace = TracePoint.new(:b_return){|tp| + tp.disable + } + trace.enable(target: method(:bar)) + end + def bar + 100.times{|i| + foo; foo + } + end + bar + EOS + end end diff --git a/vm_trace.c b/vm_trace.c index da68a0a8ded9f1..ac7550d7e95d35 100644 --- a/vm_trace.c +++ b/vm_trace.c @@ -198,9 +198,6 @@ clean_hooks(const rb_execution_context_t *ec, rb_hook_list_t *list) } else { /* local events */ - if (list->events == 0) { - ruby_xfree(list); - } } } From a39f218f22e8ec205291022f9b748d51daa8df3b Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 24 Jul 2019 11:51:04 +0900 Subject: [PATCH 358/452] Reduced duplicate commands in test-bundled-gems-run --- template/Makefile.in | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/template/Makefile.in b/template/Makefile.in index eae67a5d050407..df424997f47865 100644 --- a/template/Makefile.in +++ b/template/Makefile.in @@ -536,13 +536,11 @@ cont.$(OBJEXT): $(COROUTINE_H) TEST_BUNDLED_GEMS_ALLOW_FAILURES = test-bundled-gems-run: - $(Q) set -e; while read gem _; do \ + $(Q) while read gem _; do \ echo testing $$gem gem; \ - if echo $(TEST_BUNDLED_GEMS_ALLOW_FAILURES) | grep -q $$gem; then \ - $(XRUBY) -C $(srcdir)/gems/src/$$gem -Ilib ../../../.bundle/bin/rake || true; \ - else \ - $(XRUBY) -C $(srcdir)/gems/src/$$gem -Ilib ../../../.bundle/bin/rake; \ - fi; \ + echo $(TEST_BUNDLED_GEMS_ALLOW_FAILURES) | grep -q $$gem || set -e; \ + $(XRUBY) -C $(srcdir)/gems/src/$$gem -Ilib ../../../.bundle/bin/rake; \ + set +e; \ done < $(srcdir)/gems/bundled_gems update-src:: From 5108a5dd7f8d29043354f7ad923f3d670a01d0a5 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 24 Jul 2019 12:13:07 +0900 Subject: [PATCH 359/452] test-bundled-gems-run: Respect -k option --- template/Makefile.in | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/template/Makefile.in b/template/Makefile.in index df424997f47865..718f3804d360f1 100644 --- a/template/Makefile.in +++ b/template/Makefile.in @@ -536,12 +536,15 @@ cont.$(OBJEXT): $(COROUTINE_H) TEST_BUNDLED_GEMS_ALLOW_FAILURES = test-bundled-gems-run: - $(Q) while read gem _; do \ + $(Q) fail=0 keep=; case "$(MFLAGS)" in *k*) keep=1;; esac; \ + while read gem _; do \ echo testing $$gem gem; \ - echo $(TEST_BUNDLED_GEMS_ALLOW_FAILURES) | grep -q $$gem || set -e; \ + [ $$keep ] || echo $(TEST_BUNDLED_GEMS_ALLOW_FAILURES) | grep -q $$gem || set -e; \ $(XRUBY) -C $(srcdir)/gems/src/$$gem -Ilib ../../../.bundle/bin/rake; \ + [ $$? = 0 ] || fail=1; \ set +e; \ - done < $(srcdir)/gems/bundled_gems + done < $(srcdir)/gems/bundled_gems; \ + exit $$fail update-src:: @$(CHDIR) "$(srcdir)" && LC_TIME=C exec $(VCSUP) From 3a227b99e78927cdd53e4c1b6b1e5f1af004ca41 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 24 Jul 2019 12:25:02 +0900 Subject: [PATCH 360/452] Adjusted test runner --- defs/gmake.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/defs/gmake.mk b/defs/gmake.mk index 2f1698bfd832db..88d90e144665a4 100644 --- a/defs/gmake.mk +++ b/defs/gmake.mk @@ -290,7 +290,7 @@ rdoc\:%: PHONY $(Q)$(RUNRUBY) $(srcdir)/libexec/ri --no-standard-docs --doc-dir=$(RDOCOUT) $(patsubst rdoc:%,%,$@) test_%.rb test/%: programs PHONY - +$(Q)$(exec) $(RUNRUBY) "$(srcdir)/test/runner.rb" --ruby="$(RUNRUBY)" $(TEST_EXCLUDES) $(TESTOPTS) -- $(patsubst test/%,%,$@) + +$(Q)$(exec) $(RUNRUBY) "$(TOOL_TESTSDIR)/runner.rb" --test-target-dir="$(TESTSDIR)" --ruby="$(RUNRUBY)" $(TEST_EXCLUDES) $(TESTOPTS) -- $(patsubst test/%,%,$@) clean-srcs-ext:: $(Q)$(RM) $(patsubst $(srcdir)/%,%,$(EXT_SRCS)) From 99680f81e832506792cf32d830d09954acd220fc Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 24 Jul 2019 13:24:18 +0900 Subject: [PATCH 361/452] [rubygems/rubygems] Resolve `@@project_dir` from test file paths `Dir.pwd` may differ from the source path. Test directories and files should be resolved from test file paths. https://github.com/rubygems/rubygems/commit/e18e7c81b4 --- lib/rubygems/test_case.rb | 2 -- test/rubygems/test_gem.rb | 2 ++ test/rubygems/test_gem_command_manager.rb | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/rubygems/test_case.rb b/lib/rubygems/test_case.rb index b466e7a4e0493d..a8cc5d0060a896 100644 --- a/lib/rubygems/test_case.rb +++ b/lib/rubygems/test_case.rb @@ -232,8 +232,6 @@ def assert_contains_make_command(target, output, msg = nil) undef_method :default_test if instance_methods.include? 'default_test' or instance_methods.include? :default_test - @@project_dir = Dir.pwd.untaint unless defined?(@@project_dir) - ## # #setup prepares a sandboxed location to install gems. All installs are # directed to a temporary directory. All install plugins are removed. diff --git a/test/rubygems/test_gem.rb b/test/rubygems/test_gem.rb index c90ad2d41a4473..a08a86d28416b4 100644 --- a/test/rubygems/test_gem.rb +++ b/test/rubygems/test_gem.rb @@ -17,6 +17,8 @@ class TestGem < Gem::TestCase PLUGINS_LOADED = [] # rubocop:disable Style/MutableConstant + @@project_dir = File.expand_path('../../..', __FILE__).untaint + def setup super diff --git a/test/rubygems/test_gem_command_manager.rb b/test/rubygems/test_gem_command_manager.rb index 6ada96f1c1c7cb..73bfd207c640fa 100644 --- a/test/rubygems/test_gem_command_manager.rb +++ b/test/rubygems/test_gem_command_manager.rb @@ -4,6 +4,8 @@ class TestGemCommandManager < Gem::TestCase + @@project_dir = File.expand_path('../../..', __FILE__).untaint + def setup super From 99fb637c41c6301286042afbc9edaea71cd7643b Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 24 Jul 2019 13:57:59 +0900 Subject: [PATCH 362/452] [rubygems/rubygems] Make `@@project_dir` constants per files https://github.com/rubygems/rubygems/commit/955174658f --- test/rubygems/test_gem.rb | 22 +++++++++++----------- test/rubygems/test_gem_command_manager.rb | 6 +++--- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/test/rubygems/test_gem.rb b/test/rubygems/test_gem.rb index a08a86d28416b4..86ad90c540940d 100644 --- a/test/rubygems/test_gem.rb +++ b/test/rubygems/test_gem.rb @@ -17,7 +17,7 @@ class TestGem < Gem::TestCase PLUGINS_LOADED = [] # rubocop:disable Style/MutableConstant - @@project_dir = File.expand_path('../../..', __FILE__).untaint + PROJECT_DIR = File.expand_path('../../..', __FILE__).untaint def setup super @@ -632,7 +632,7 @@ def test_self_extension_dir_static end def test_self_find_files - cwd = File.expand_path("test/rubygems", @@project_dir) + cwd = File.expand_path("test/rubygems", PROJECT_DIR) $LOAD_PATH.unshift cwd discover_path = File.join 'lib', 'sff', 'discover.rb' @@ -652,7 +652,7 @@ def test_self_find_files Gem.refresh expected = [ - File.expand_path('test/rubygems/sff/discover.rb', @@project_dir), + File.expand_path('test/rubygems/sff/discover.rb', PROJECT_DIR), File.join(foo2.full_gem_path, discover_path), File.join(foo1.full_gem_path, discover_path), ] @@ -664,7 +664,7 @@ def test_self_find_files end def test_self_find_files_with_gemfile - cwd = File.expand_path("test/rubygems", @@project_dir) + cwd = File.expand_path("test/rubygems", PROJECT_DIR) actual_load_path = $LOAD_PATH.unshift(cwd).dup discover_path = File.join 'lib', 'sff', 'discover.rb' @@ -689,7 +689,7 @@ def test_self_find_files_with_gemfile Gem.use_gemdeps(File.join Dir.pwd, 'Gemfile') expected = [ - File.expand_path('test/rubygems/sff/discover.rb', @@project_dir), + File.expand_path('test/rubygems/sff/discover.rb', PROJECT_DIR), File.join(foo1.full_gem_path, discover_path) ].sort @@ -700,7 +700,7 @@ def test_self_find_files_with_gemfile end def test_self_find_latest_files - cwd = File.expand_path("test/rubygems", @@project_dir) + cwd = File.expand_path("test/rubygems", PROJECT_DIR) $LOAD_PATH.unshift cwd discover_path = File.join 'lib', 'sff', 'discover.rb' @@ -720,7 +720,7 @@ def test_self_find_latest_files Gem.refresh expected = [ - File.expand_path('test/rubygems/sff/discover.rb', @@project_dir), + File.expand_path('test/rubygems/sff/discover.rb', PROJECT_DIR), File.join(foo2.full_gem_path, discover_path), ] @@ -872,12 +872,12 @@ def test_self_platforms end def test_self_prefix - assert_equal @@project_dir, Gem.prefix + assert_equal PROJECT_DIR, Gem.prefix end def test_self_prefix_libdir orig_libdir = RbConfig::CONFIG['libdir'] - RbConfig::CONFIG['libdir'] = @@project_dir + RbConfig::CONFIG['libdir'] = PROJECT_DIR assert_nil Gem.prefix ensure @@ -886,7 +886,7 @@ def test_self_prefix_libdir def test_self_prefix_sitelibdir orig_sitelibdir = RbConfig::CONFIG['sitelibdir'] - RbConfig::CONFIG['sitelibdir'] = @@project_dir + RbConfig::CONFIG['sitelibdir'] = PROJECT_DIR assert_nil Gem.prefix ensure @@ -1867,7 +1867,7 @@ def with_clean_path_to_ruby def with_plugin(path) test_plugin_path = File.expand_path("test/rubygems/plugin/#{path}", - @@project_dir) + PROJECT_DIR) # A single test plugin should get loaded once only, in order to preserve # sane test semantics. diff --git a/test/rubygems/test_gem_command_manager.rb b/test/rubygems/test_gem_command_manager.rb index 73bfd207c640fa..3cfa4f09ddd782 100644 --- a/test/rubygems/test_gem_command_manager.rb +++ b/test/rubygems/test_gem_command_manager.rb @@ -4,7 +4,7 @@ class TestGemCommandManager < Gem::TestCase - @@project_dir = File.expand_path('../../..', __FILE__).untaint + PROJECT_DIR = File.expand_path('../../..', __FILE__).untaint def setup super @@ -60,7 +60,7 @@ def test_find_command_unknown def test_run_interrupt old_load_path = $:.dup - $: << File.expand_path("test/rubygems", @@project_dir) + $: << File.expand_path("test/rubygems", PROJECT_DIR) Gem.load_env_plugins @command_manager.register_command :interrupt @@ -79,7 +79,7 @@ def test_run_interrupt def test_run_crash_command old_load_path = $:.dup - $: << File.expand_path("test/rubygems", @@project_dir) + $: << File.expand_path("test/rubygems", PROJECT_DIR) @command_manager.register_command :crash use_ui @ui do From dc954cbb75381149970e45927153829a88cbe0b5 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 24 Jul 2019 20:08:40 +0900 Subject: [PATCH 363/452] @@project_dir in Gem::TestCase is no longer used --- tool/lib/test/unit/parallel.rb | 6 ------ tool/test/runner.rb | 6 ------ 2 files changed, 12 deletions(-) diff --git a/tool/lib/test/unit/parallel.rb b/tool/lib/test/unit/parallel.rb index d851326acabae5..730d7a7f3d6540 100644 --- a/tool/lib/test/unit/parallel.rb +++ b/tool/lib/test/unit/parallel.rb @@ -198,11 +198,5 @@ def on_parallel_worker? end end require 'rubygems' - module Gem # :nodoc: - end - class Gem::TestCase < MiniTest::Unit::TestCase # :nodoc: - @@project_dir = File.expand_path('../../../../..', __FILE__) - end - Test::Unit::Worker.new.run(ARGV) end diff --git a/tool/test/runner.rb b/tool/test/runner.rb index 20ae9aa1a37295..f8769857ad4610 100644 --- a/tool/test/runner.rb +++ b/tool/test/runner.rb @@ -24,12 +24,6 @@ require 'test/unit' -module Gem -end -class Gem::TestCase < MiniTest::Unit::TestCase - @@project_dir = File.dirname($LOAD_PATH.last) -end - ENV["GEM_SKIP"] = ENV["GEM_HOME"] = ENV["GEM_PATH"] = "".freeze require_relative "#{tool_dir}/lib/profile_test_all" if ENV.has_key?('RUBY_TEST_ALL_PROFILE') From 7b1893c771d21876884e17e8281c737bfc1c4643 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Wed, 24 Jul 2019 20:50:50 +0900 Subject: [PATCH 364/452] Resurrect timestamp debug log because it failed again https://travis-ci.org/ruby/ruby/jobs/563026412 even after 676df311d90990a4666adb5b1db4c7aa6b080e57. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 683a58baba4cab..9a3e08f7ca8403 100644 --- a/.travis.yml +++ b/.travis.yml @@ -423,6 +423,7 @@ before_script: - "> .rbconfig.time" - sed -f tool/prereq.status template/Makefile.in common.mk > Makefile - date; make touch-unicode-files + - ls -ltT tool/generic_erb.rb template/unicode_norm_gen.tmpl enc/unicode/data/*/ucd/.unicode-tables.time - date; make -s $JOBS $UPDATE_UNICODE up - date; make -s $JOBS srcs - rm -f config.status Makefile rbconfig.rb .rbconfig.time From 65a9d4b0f7ae07c026622392e06fc70dbcc5bfc1 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Wed, 24 Jul 2019 20:51:29 +0900 Subject: [PATCH 365/452] Fix typo [ci skip] --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 9a3e08f7ca8403..7911abb643dd15 100644 --- a/.travis.yml +++ b/.travis.yml @@ -341,7 +341,7 @@ env: - TEST_ALL_ISOLATED_TESTS="../test/ruby/test_gc_compact.rb" # Disabling -j3 because it seems to cause a hang on building Ruby: https://travis-ci.org/ruby/ruby/jobs/471021727 - JOBS= - # Reset timestamps earily, before updating Homebrew etc. + # Reset timestamps early, before updating Homebrew etc. - _=$(touch NEWS && find . -type f -exec touch -r NEWS {} +) - &dependency From 96b0d7cd6fcff7cb2f42315e39a961d84c630e9d Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 24 Jul 2019 21:03:01 +0900 Subject: [PATCH 366/452] GNU ls -T has different meaning --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 7911abb643dd15..de1f6e5b0a4b06 100644 --- a/.travis.yml +++ b/.travis.yml @@ -423,7 +423,7 @@ before_script: - "> .rbconfig.time" - sed -f tool/prereq.status template/Makefile.in common.mk > Makefile - date; make touch-unicode-files - - ls -ltT tool/generic_erb.rb template/unicode_norm_gen.tmpl enc/unicode/data/*/ucd/.unicode-tables.time + - [ ${TRAVIS_OS_NAME} != osx ] || ls -ltT tool/generic_erb.rb template/unicode_norm_gen.tmpl enc/unicode/data/*/ucd/.unicode-tables.time - date; make -s $JOBS $UPDATE_UNICODE up - date; make -s $JOBS srcs - rm -f config.status Makefile rbconfig.rb .rbconfig.time From 538ba984c8e3c6ae33cbc87a5090725af24caf2e Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 24 Jul 2019 21:07:12 +0900 Subject: [PATCH 367/452] Split ls line --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index de1f6e5b0a4b06..f71b1fe521192b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -423,7 +423,9 @@ before_script: - "> .rbconfig.time" - sed -f tool/prereq.status template/Makefile.in common.mk > Makefile - date; make touch-unicode-files - - [ ${TRAVIS_OS_NAME} != osx ] || ls -ltT tool/generic_erb.rb template/unicode_norm_gen.tmpl enc/unicode/data/*/ucd/.unicode-tables.time + - |- + [ ${TRAVIS_OS_NAME} != osx ] || + ls -ltT tool/generic_erb.rb template/unicode_norm_gen.tmpl enc/unicode/data/*/ucd/.unicode-tables.time - date; make -s $JOBS $UPDATE_UNICODE up - date; make -s $JOBS srcs - rm -f config.status Makefile rbconfig.rb .rbconfig.time From 1cce4303247110d94eab8326f187a2a80130b324 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 24 Jul 2019 22:07:10 +0900 Subject: [PATCH 368/452] Suppress deflateParams() warnings --- test/zlib/test_zlib.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/zlib/test_zlib.rb b/test/zlib/test_zlib.rb index fc2ab5073f0856..bc8b97651853f1 100644 --- a/test/zlib/test_zlib.rb +++ b/test/zlib/test_zlib.rb @@ -199,10 +199,10 @@ def test_params z = Zlib::Deflate.new s = z.deflate("foo", Zlib::FULL_FLUSH) z.avail_out = 0 - z.params(Zlib::NO_COMPRESSION, Zlib::FILTERED) + EnvUtil.suppress_warning {z.params(Zlib::NO_COMPRESSION, Zlib::FILTERED)} s << z.deflate("bar", Zlib::FULL_FLUSH) z.avail_out = 0 - z.params(Zlib::BEST_COMPRESSION, Zlib::HUFFMAN_ONLY) + EnvUtil.suppress_warning {z.params(Zlib::BEST_COMPRESSION, Zlib::HUFFMAN_ONLY)} s << z.deflate("baz", Zlib::FINISH) assert_equal("foobarbaz", Zlib::Inflate.inflate(s)) @@ -415,10 +415,10 @@ def test_sync z = Zlib::Deflate.new s = z.deflate("foo" * 1000, Zlib::FULL_FLUSH) z.avail_out = 0 - z.params(Zlib::NO_COMPRESSION, Zlib::FILTERED) + EnvUtil.suppress_warning {z.params(Zlib::NO_COMPRESSION, Zlib::FILTERED)} s << z.deflate("bar" * 1000, Zlib::FULL_FLUSH) z.avail_out = 0 - z.params(Zlib::BEST_COMPRESSION, Zlib::HUFFMAN_ONLY) + EnvUtil.suppress_warning {z.params(Zlib::BEST_COMPRESSION, Zlib::HUFFMAN_ONLY)} s << z.deflate("baz" * 1000, Zlib::FINISH) z = Zlib::Inflate.new From 3556cba5038530e728eb6309dcf5d4d1a96a02ac Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Wed, 24 Jul 2019 10:30:56 -0700 Subject: [PATCH 369/452] Document that Range#cover? returns false if <=> returns nil Fixes [Bug #12090] --- range.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/range.c b/range.c index 271c0f2ae9ed5a..e8515e0b8aec90 100644 --- a/range.c +++ b/range.c @@ -1455,11 +1455,14 @@ static int r_cover_range_p(VALUE range, VALUE beg, VALUE end, VALUE val); * the end of the sequence must be calculated, which may exhibit poor * performance if c is non-numeric. * Returns false if the begin value of the - * range is larger than the end value. + * range is larger than the end value. Also returns +false+ if one of the + * internal calls to <=> returns +nil+ (indicating the objects + * are not comparable). * * ("a".."z").cover?("c") #=> true * ("a".."z").cover?("5") #=> false * ("a".."z").cover?("cc") #=> true + * ("a".."z").cover?(1) #=> false * (1..5).cover?(2..3) #=> true * (1..5).cover?(0..6) #=> false * (1..5).cover?(1...6) #=> true From 48b4deb418b374c6433fb346ea4550db46843fca Mon Sep 17 00:00:00 2001 From: git Date: Thu, 25 Jul 2019 02:36:25 +0900 Subject: [PATCH 370/452] * 2019-07-25 --- version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.h b/version.h index 68d73dcc1c1e2a..54eae25cdba9cc 100644 --- a/version.h +++ b/version.h @@ -6,7 +6,7 @@ #define RUBY_RELEASE_YEAR 2019 #define RUBY_RELEASE_MONTH 7 -#define RUBY_RELEASE_DAY 24 +#define RUBY_RELEASE_DAY 25 #include "ruby/version.h" From da76c4460f754baabc7a8db16d2e1b5f1c3eb264 Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Wed, 24 Jul 2019 11:54:07 -0700 Subject: [PATCH 371/452] Clarify Thread exception handling documentation [ci skip] From djellemah (John Anderson). Fixes [Bug #12252] --- vm.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/vm.c b/vm.c index 86b0e6075fb596..ca5df22315312b 100644 --- a/vm.c +++ b/vm.c @@ -2975,6 +2975,11 @@ Init_VM(void) * * threads.each { |thr| thr.join } * + * To retrieve the last value of a thread, use #value + * + * thr = Thread.new { sleep 1; "Useful value" } + * thr.value #=> "Useful value" + * * === Thread initialization * * In order to create new threads, Ruby provides ::new, ::start, and @@ -3058,15 +3063,21 @@ Init_VM(void) * * === Exception handling * - * Any thread can raise an exception using the #raise instance method, - * which operates similarly to Kernel#raise. + * When an unhandled exception is raised inside a thread, it will + * terminate. By default, this exception will not propagate to other + * threads. The exception is stored and when another thread calls #value + * or #join, the exception will be re-raised in that thread. + * + * t = Thread.new{ raise 'something went wrong' } + * t.value #=> RuntimeError: something went wrong + * + * An exception can be raised from outside the thread using the + * Thread#raise instance method, which takes the same parameters as + * Kernel#raise. * - * However, it's important to note that an exception that occurs in any - * thread except the main thread depends on #abort_on_exception. This - * option is +false+ by default, meaning that any unhandled exception will - * cause the thread to terminate silently when waited on by either #join - * or #value. You can change this default by either #abort_on_exception= - * +true+ or setting $DEBUG to +true+. + * Setting Thread.abort_on_exception = true, Thread#abort_on_exception = + * true, or $DEBUG = true will cause a subsequent unhandled exception + * raised in a thread to be automatically re-raised in the main thread. * * With the addition of the class method ::handle_interrupt, you can now * handle exceptions asynchronously with threads. From efa380b006aeafbad90b2d4e795a602404fec3c5 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 25 Jul 2019 05:54:38 +0900 Subject: [PATCH 372/452] Use PRIuSIZE instead of "%zu" --- cont.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/cont.c b/cont.c index 409fbcc55db519..286e35dfa58418 100644 --- a/cont.c +++ b/cont.c @@ -292,7 +292,7 @@ fiber_pool_stack_alloca(struct fiber_pool_stack * stack, size_t offset) { STACK_GROW_DIR_DETECTION; - if (DEBUG) fprintf(stderr, "fiber_pool_stack_alloca(%p): %zu/%zu\n", stack, offset, stack->available); + if (DEBUG) fprintf(stderr, "fiber_pool_stack_alloca(%p): %"PRIuSIZE"/%"PRIuSIZE"\n", stack, offset, stack->available); VM_ASSERT(stack->available >= offset); // The pointer to the memory being allocated: @@ -445,7 +445,7 @@ fiber_pool_expand(struct fiber_pool * fiber_pool, size_t count) void * base = fiber_pool_allocate_memory(&count, stride); if (base == NULL) { - rb_raise(rb_eFiberError, "can't alloc machine stack to fiber (%zu x %zu bytes): %s", count, size, ERRNOMSG); + rb_raise(rb_eFiberError, "can't alloc machine stack to fiber (%"PRIuSIZE" x %"PRIuSIZE" bytes): %s", count, size, ERRNOMSG); } struct fiber_pool_vacancy * vacancies = fiber_pool->vacancies; @@ -461,7 +461,10 @@ fiber_pool_expand(struct fiber_pool * fiber_pool, size_t count) #endif allocation->pool = fiber_pool; - if (DEBUG) fprintf(stderr, "fiber_pool_expand(%zu): %p, %zu/%zu x [%zu:%zu]\n", count, fiber_pool, fiber_pool->used, fiber_pool->count, size, fiber_pool->vm_stack_size); + if (DEBUG) { + fprintf(stderr, "fiber_pool_expand(%"PRIuSIZE"): %p, %"PRIuSIZE"/%"PRIuSIZE" x [%"PRIuSIZE":%"PRIuSIZE"]\n", + count, fiber_pool, fiber_pool->used, fiber_pool->count, size, fiber_pool->vm_stack_size); + } // Iterate over all stacks, initializing the vacancy list: for (size_t i = 0; i < count; i += 1) { @@ -540,7 +543,7 @@ fiber_pool_allocation_free(struct fiber_pool_allocation * allocation) VM_ASSERT(allocation->used == 0); - if (DEBUG) fprintf(stderr, "fiber_pool_allocation_free: %p base=%p count=%zu\n", allocation, allocation->base, allocation->count); + if (DEBUG) fprintf(stderr, "fiber_pool_allocation_free: %p base=%p count=%"PRIuSIZE"\n", allocation, allocation->base, allocation->count); size_t i; for (i = 0; i < allocation->count; i += 1) { @@ -581,7 +584,7 @@ static struct fiber_pool_stack fiber_pool_stack_acquire(struct fiber_pool * fiber_pool) { struct fiber_pool_vacancy * vacancy = fiber_pool_vacancy_pop(fiber_pool); - if (DEBUG) fprintf(stderr, "fiber_pool_stack_acquire: %p used=%zu\n", fiber_pool->vacancies, fiber_pool->used); + if (DEBUG) fprintf(stderr, "fiber_pool_stack_acquire: %p used=%"PRIuSIZE"\n", fiber_pool->vacancies, fiber_pool->used); if (!vacancy) { const size_t maximum = FIBER_POOL_ALLOCATION_MAXIMUM_SIZE; @@ -625,7 +628,7 @@ fiber_pool_stack_free(struct fiber_pool_stack * stack) // If this is not true, the vacancy information will almost certainly be destroyed: VM_ASSERT(size <= (stack->size - RB_PAGE_SIZE)); - if (DEBUG) fprintf(stderr, "fiber_pool_stack_free: %p+%zu [base=%p, size=%zu]\n", base, size, stack->base, stack->size); + if (DEBUG) fprintf(stderr, "fiber_pool_stack_free: %p+%"PRIuSIZE" [base=%p, size=%"PRIuSIZE"]\n", base, size, stack->base, stack->size); #if VM_CHECK_MODE > 0 && defined(MADV_DONTNEED) // This immediately discards the pages and the memory is reset to zero. @@ -650,7 +653,7 @@ fiber_pool_stack_release(struct fiber_pool_stack * stack) struct fiber_pool * pool = stack->pool; struct fiber_pool_vacancy * vacancy = fiber_pool_vacancy_pointer(stack->base, stack->size); - if (DEBUG) fprintf(stderr, "fiber_pool_stack_release: %p used=%zu\n", stack->base, stack->pool->used); + if (DEBUG) fprintf(stderr, "fiber_pool_stack_release: %p used=%"PRIuSIZE"\n", stack->base, stack->pool->used); // Copy the stack details into the vacancy area: vacancy->stack = *stack; From 0a63c4d5fbbbfae9aba92c78e39b1521b90f1b06 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 25 Jul 2019 06:39:40 +0900 Subject: [PATCH 373/452] Fix errno at seeking socket/pipe on Windows [Bug #12230] --- include/ruby/win32.h | 3 ++- test/ruby/test_io.rb | 3 +++ win32/win32.c | 11 +++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/include/ruby/win32.h b/include/ruby/win32.h index fe1978fddecb88..b29470b0c473eb 100644 --- a/include/ruby/win32.h +++ b/include/ruby/win32.h @@ -146,7 +146,7 @@ typedef int clockid_t; #define HAVE_UTIMENSAT 1 #define AT_FDCWD -100 #define utimensat(_d, _p, _t, _f) rb_w32_utimensat(_d, _p, _t, _f) -#define lseek(_f, _o, _w) _lseeki64(_f, _o, _w) +#define lseek(_f, _o, _w) rb_w32_lseek(_f, _o, _w) #define pipe(p) rb_w32_pipe(p) #define open rb_w32_open @@ -751,6 +751,7 @@ int rb_w32_fclose(FILE*); int rb_w32_pipe(int[2]); ssize_t rb_w32_read(int, void *, size_t); ssize_t rb_w32_write(int, const void *, size_t); +off_t rb_w32_lseek(int, off_t, int); int rb_w32_utime(const char *, const struct utimbuf *); int rb_w32_uutime(const char *, const struct utimbuf *); int rb_w32_utimes(const char *, const struct timeval *); diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index 3c5dc7671a8812..0c81f4cb82b50c 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -2240,6 +2240,9 @@ def test_read_command assert_raise(Errno::ENOENT, Errno::EINVAL) do Class.new(IO).binread("|#{EnvUtil.rubybin} -e puts") end + assert_raise(Errno::ESPIPE) do + IO.read("|echo foo", 1, 1) + end end def test_reopen diff --git a/win32/win32.c b/win32/win32.c index d28bd56452de7b..825b42399ce04c 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -5845,6 +5845,17 @@ rb_w32_lstati128(const char *path, struct stati128 *st) return w32_stati128(path, st, filecp(), TRUE); } +off_t +rb_w32_lseek(int fd, off_t ofs, int whence) +{ + SOCKET sock = TO_SOCKET(fd); + if (is_socket(sock) || is_pipe(sock)) { + errno = ESPIPE; + return -1; + } + return _lseeki64(fd, ofs, whence); +} + /* License: Ruby's */ int rb_w32_access(const char *path, int mode) From 938032a790b22a1b49c1b112ede2da4597b4e75c Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Sun, 21 Jul 2019 12:16:56 +0900 Subject: [PATCH 374/452] [ruby/psych] Do not use add_development_dependency. https://github.com/ruby/psych/commit/939754237f --- ext/psych/psych.gemspec | 5 ----- 1 file changed, 5 deletions(-) diff --git a/ext/psych/psych.gemspec b/ext/psych/psych.gemspec index 469ee5de732d2f..f564c51bb590dc 100644 --- a/ext/psych/psych.gemspec +++ b/ext/psych/psych.gemspec @@ -51,9 +51,6 @@ DESCRIPTION s.rubygems_version = "2.5.1" s.required_rubygems_version = Gem::Requirement.new(">= 0") - s.add_development_dependency 'rake-compiler', ">= 0.4.1" - s.add_development_dependency 'minitest', "~> 5.0" - if RUBY_ENGINE == 'jruby' s.platform = 'java' s.files.concat [ @@ -67,9 +64,7 @@ DESCRIPTION ] s.requirements = "jar org.yaml:snakeyaml, #{Psych::DEFAULT_SNAKEYAML_VERSION}" s.add_dependency 'jar-dependencies', '>= 0.1.7' - s.add_development_dependency 'ruby-maven' else s.extensions = ["ext/psych/extconf.rb"] - s.add_development_dependency 'rake-compiler-dock', ">= 0.6.3" end end From 50076903ab06e2301051e459925afea20325ba7c Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Sun, 21 Jul 2019 12:21:27 +0900 Subject: [PATCH 375/452] [ruby/psych] Drop to support fat gem support. ref. https://github.com/ruby/bigdecimal/pull/149 https://github.com/ruby/psych/commit/25ae263252 --- ext/psych/lib/psych.rb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/ext/psych/lib/psych.rb b/ext/psych/lib/psych.rb index 2a2ec2af43c6bd..9513f794b8a9ed 100644 --- a/ext/psych/lib/psych.rb +++ b/ext/psych/lib/psych.rb @@ -10,11 +10,7 @@ org.jruby.ext.psych.PsychLibrary.new.load(JRuby.runtime, false) end else - begin - require "#{RUBY_VERSION[/\d+\.\d+/]}/psych.so" - rescue LoadError - require 'psych.so' - end + require 'psych.so' end require 'psych/nodes' require 'psych/streaming' From 6ca7dc69effddeb63a8fb8f759e29ff8649907ec Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Mon, 22 Jul 2019 12:02:23 +0200 Subject: [PATCH 376/452] [ruby/psych] Deduplicate hash keys if they're strings https://github.com/ruby/psych/commit/0414982ffd --- ext/psych/lib/psych/visitors/to_ruby.rb | 24 +++++++++++++++++++++++- test/psych/test_hash.rb | 14 ++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/ext/psych/lib/psych/visitors/to_ruby.rb b/ext/psych/lib/psych/visitors/to_ruby.rb index c265acb8191fe1..49447e124abd46 100644 --- a/ext/psych/lib/psych/visitors/to_ruby.rb +++ b/ext/psych/lib/psych/visitors/to_ruby.rb @@ -336,7 +336,7 @@ def register_empty object SHOVEL = '<<' def revive_hash hash, o o.children.each_slice(2) { |k,v| - key = accept(k) + key = deduplicate(accept(k)) val = accept(v) if key == SHOVEL && k.tag != "tag:yaml.org,2002:str" @@ -368,6 +368,28 @@ def revive_hash hash, o hash end + if String.method_defined?(:-@) + def deduplicate key + if key.is_a?(String) + # It is important to untaint the string, otherwise it won't + # be deduplicated into and fstring, but simply frozen. + -(key.untaint) + else + key + end + end + else + def deduplicate key + if key.is_a?(String) + # Deduplication is not supported by this implementation, + # but we emulate it's side effects + key.untaint.freeze + else + key + end + end + end + def merge_key hash, key, val end diff --git a/test/psych/test_hash.rb b/test/psych/test_hash.rb index 2a563da1da74f2..ba11b827da2a45 100644 --- a/test/psych/test_hash.rb +++ b/test/psych/test_hash.rb @@ -111,5 +111,19 @@ def test_ref_append eoyml assert_equal({"foo"=>{"hello"=>"world"}, "bar"=>{"hello"=>"world"}}, hash) end + + def test_key_deduplication + unless String.method_defined?(:-@) && (-("a" * 20)).equal?((-("a" * 20))) + skip "This Ruby implementation doesn't support string deduplication" + end + + hashes = Psych.load(<<-eoyml) +--- +- unique_identifier: 1 +- unique_identifier: 2 +eoyml + + assert_same hashes[0].keys.first, hashes[1].keys.first + end end end From 698dde525ad3df1444276ccd28c6349c81af2a19 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 24 Jul 2019 22:21:49 +0900 Subject: [PATCH 377/452] [ruby/psych] Suppress uninitialized instance variable warnings In verbose mode, `test_delegator` in `test/psych/visitors/test_yaml_tree.rb` shows following warning. https://travis-ci.org/ruby/psych/jobs/562435717#L268 ``` /home/travis/build/ruby/psych/test/psych/visitors/test_yaml_tree.rb:10: warning: instance variable @obj not initialized ``` This is because `Psych.load` bypasses #initialize with the #init_with method. https://github.com/ruby/psych/commit/f99523388f --- test/psych/visitors/test_yaml_tree.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/psych/visitors/test_yaml_tree.rb b/test/psych/visitors/test_yaml_tree.rb index 01f1aecd086a7d..69885ee9c62f3a 100644 --- a/test/psych/visitors/test_yaml_tree.rb +++ b/test/psych/visitors/test_yaml_tree.rb @@ -7,7 +7,7 @@ class TestYAMLTree < TestCase class TestDelegatorClass < Delegator def initialize(obj); super; @obj = obj; end def __setobj__(obj); @obj = obj; end - def __getobj__; @obj; end + def __getobj__; @obj if defined?(@obj); end end class TestSimpleDelegatorClass < SimpleDelegator From 414d6cf1d310de8f9eed1263116ad568b05a98ec Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 25 Jul 2019 03:29:41 +0900 Subject: [PATCH 378/452] [ruby/psych] Get rid of C90 feature MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For ruby 2.6 and earlier. https://travis-ci.org/ruby/psych/jobs/562435717#L245-L248 ``` ../../../../ext/psych/psych_parser.c: In function ‘make_exception’: ../../../../ext/psych/psych_parser.c:87:5: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement] VALUE ePsychSyntaxError = rb_const_get(mPsych, rb_intern("SyntaxError")); ^ ``` https://github.com/ruby/psych/commit/aa457443b8 --- ext/psych/psych_parser.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ext/psych/psych_parser.c b/ext/psych/psych_parser.c index 6e58611c3c717e..0fef1737296306 100644 --- a/ext/psych/psych_parser.c +++ b/ext/psych/psych_parser.c @@ -80,11 +80,12 @@ static VALUE allocate(VALUE klass) static VALUE make_exception(yaml_parser_t * parser, VALUE path) { size_t line, column; + VALUE ePsychSyntaxError; line = parser->context_mark.line + 1; column = parser->context_mark.column + 1; - VALUE ePsychSyntaxError = rb_const_get(mPsych, rb_intern("SyntaxError")); + ePsychSyntaxError = rb_const_get(mPsych, rb_intern("SyntaxError")); return rb_funcall(ePsychSyntaxError, rb_intern("new"), 6, path, From 077c28887a68c08f84d91e104fd9ac9c39810482 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 25 Jul 2019 05:00:33 +0900 Subject: [PATCH 379/452] [ruby/io-console] Do not use add_development_dependency https://github.com/ruby/io-console/commit/bc77f46391 --- ext/io/console/io-console.gemspec | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/ext/io/console/io-console.gemspec b/ext/io/console/io-console.gemspec index 60aeabd3e704a5..73b4c1a5b2c1c7 100644 --- a/ext/io/console/io-console.gemspec +++ b/ext/io/console/io-console.gemspec @@ -1,5 +1,5 @@ # -*- ruby -*- -_VERSION = "0.4.7" +_VERSION = "0.4.9" date = %w$Date:: $[1] Gem::Specification.new do |s| @@ -25,7 +25,4 @@ Gem::Specification.new do |s| ] s.extensions = %w[ext/io/console/extconf.rb] s.license = "BSD-2-Clause" - - s.add_development_dependency 'rake-compiler' - s.add_development_dependency 'rake-compiler-dock', ">= 0.6.1" end From 82ae46211341f926d79c6e2e26f4b9097625443c Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 25 Jul 2019 08:19:03 +0900 Subject: [PATCH 380/452] Do not fetch remote tags --- tool/sync_default_gems.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tool/sync_default_gems.rb b/tool/sync_default_gems.rb index 7f125fae295650..7545a2704904e6 100644 --- a/tool/sync_default_gems.rb +++ b/tool/sync_default_gems.rb @@ -236,7 +236,7 @@ def sync_default_gems_with_commits(gem, range) `git remote add #{gem} git@github.com:#{$repositories[gem.to_sym]}.git` end end - `git fetch #{gem}` + `git fetch --no-tags #{gem}` IO.popen(%W"git log --format=%H,%s #{range}") do |f| commits = f.read.split("\n").reverse.map{|commit| commit.split(',')} @@ -266,7 +266,7 @@ def sync_default_gems_with_commits(gem, range) def sync_lib(repo) unless File.directory?("../#{repo}") - abort "Expected '../#{repo}' (#{File.expand_path("../#{repo}")}) to be a directory, but it wasn't." + abort %[Expected '../#{repo}' (#{File.expand_path("../#{repo}")}) to be a directory, but it wasn't.] end rm_rf(["lib/#{repo}.rb", "lib/#{repo}/*", "test/test_#{repo}.rb"]) cp_r(Dir.glob("../#{repo}/lib/*"), "lib") From a850be68a57dce65449766654aa1912b5fa660cb Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 24 Jul 2019 11:04:26 +0900 Subject: [PATCH 381/452] Moved NoMemoryError hook to Test::Unit::AutoRunner --- tool/lib/test/unit.rb | 4 ++++ tool/test/runner.rb | 8 +------- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/tool/lib/test/unit.rb b/tool/lib/test/unit.rb index 1034a993b0a5ca..146d6bb3c7126a 100644 --- a/tool/lib/test/unit.rb +++ b/tool/lib/test/unit.rb @@ -1135,6 +1135,10 @@ def run abort @options.banner end @runner.run(@argv) || true + rescue NoMemoryError + system("cat /proc/meminfo") if File.exist?("/proc/meminfo") + system("ps x -opid,args,%cpu,%mem,nlwp,rss,vsz,wchan,stat,start,time,etime,blocked,caught,ignored,pending,f") if File.exist?("/bin/ps") + raise end def self.run(*args) diff --git a/tool/test/runner.rb b/tool/test/runner.rb index f8769857ad4610..38e7c0438cfdeb 100644 --- a/tool/test/runner.rb +++ b/tool/test/runner.rb @@ -35,10 +35,4 @@ require_relative "#{tool_dir}/test-coverage.rb" end -begin - exit Test::Unit::AutoRunner.run(true, src_testdir) -rescue NoMemoryError - system("cat /proc/meminfo") if File.exist?("/proc/meminfo") - system("ps x -opid,args,%cpu,%mem,nlwp,rss,vsz,wchan,stat,start,time,etime,blocked,caught,ignored,pending,f") if File.exist?("/bin/ps") - raise -end +exit Test::Unit::AutoRunner.run(true, src_testdir) From d8e90f555817146d17ec82a55360b6d69c649d67 Mon Sep 17 00:00:00 2001 From: Kazuhiro NISHIYAMA Date: Thu, 25 Jul 2019 16:39:28 +0900 Subject: [PATCH 382/452] Fix a typo in inspect --- lib/csv.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/csv.rb b/lib/csv.rb index aaa0c4823148f2..fcf54a2fa4aa3f 100644 --- a/lib/csv.rb +++ b/lib/csv.rb @@ -1306,7 +1306,7 @@ def shift # ASCII compatible String. # def inspect - str = ["<#", self.class.to_s, " io_type:"] + str = ["#<", self.class.to_s, " io_type:"] # show type of wrapped IO if @io == $stdout then str << "$stdout" elsif @io == $stdin then str << "$stdin" From f5ea05481017d34a1ebdc0eec32ef10254420ee5 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 25 Jul 2019 14:29:15 +0900 Subject: [PATCH 383/452] Moved NoMemoryError hook Moved NoMemoryError hook from AutoRunner.run to Runner#run, so it will work even in non-autorunning mode. --- tool/lib/test/unit.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tool/lib/test/unit.rb b/tool/lib/test/unit.rb index 146d6bb3c7126a..9cded97a334912 100644 --- a/tool/lib/test/unit.rb +++ b/tool/lib/test/unit.rb @@ -1072,6 +1072,14 @@ class Runner < MiniTest::Unit # :nodoc: all include Test::Unit::TimeoutOption include Test::Unit::RunCount + def run(argv) + super + rescue NoMemoryError + system("cat /proc/meminfo") if File.exist?("/proc/meminfo") + system("ps x -opid,args,%cpu,%mem,nlwp,rss,vsz,wchan,stat,start,time,etime,blocked,caught,ignored,pending,f") if File.exist?("/bin/ps") + raise + end + class << self; undef autorun; end @@stop_auto_run = false @@ -1135,10 +1143,6 @@ def run abort @options.banner end @runner.run(@argv) || true - rescue NoMemoryError - system("cat /proc/meminfo") if File.exist?("/proc/meminfo") - system("ps x -opid,args,%cpu,%mem,nlwp,rss,vsz,wchan,stat,start,time,etime,blocked,caught,ignored,pending,f") if File.exist?("/bin/ps") - raise end def self.run(*args) From 4c1db84d1748b56334da8293ee328186fcb08162 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 25 Jul 2019 16:45:18 +0900 Subject: [PATCH 384/452] Added --base-directory option --- tool/lib/test/unit.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tool/lib/test/unit.rb b/tool/lib/test/unit.rb index 9cded97a334912..a3e41a840eed0d 100644 --- a/tool/lib/test/unit.rb +++ b/tool/lib/test/unit.rb @@ -856,6 +856,10 @@ module GlobOption # :nodoc: all def setup_options(parser, options) super parser.separator "globbing options:" + parser.on '-B', '--base-directory DIR', 'Base directory to glob.' do |dir| + raise OptionParser::InvalidArgument, "not a directory: #{dir}" unless File.directory?(dir) + options[:base_directory] = dir + end parser.on '-x', '--exclude REGEXP', 'Exclude test files on pattern.' do |pattern| (options[:reject] ||= []) << pattern end From 46771abfe53d95e8cecf917a5c999e32388be184 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 25 Jul 2019 16:52:03 +0900 Subject: [PATCH 385/452] Use libraries in the base directory if given --- tool/lib/test/unit.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tool/lib/test/unit.rb b/tool/lib/test/unit.rb index a3e41a840eed0d..37c17babb4ef8f 100644 --- a/tool/lib/test/unit.rb +++ b/tool/lib/test/unit.rb @@ -1123,10 +1123,11 @@ class Runner < Test::Unit::Runner def initialize(force_standalone = false, default_dir = nil, argv = ARGV) @force_standalone = force_standalone @runner = Runner.new do |files, options| - options[:base_directory] ||= default_dir + base = options[:base_directory] ||= default_dir files << default_dir if files.empty? and default_dir @to_run = files yield self if block_given? + $LOAD_PATH.unshift base if base files end Runner.runner = @runner From 8e53d18e6724211bd0597ec5852869e6bf9679f1 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 24 Jul 2019 11:07:15 +0900 Subject: [PATCH 386/452] Separated tool/test/runner.rb and test/runner.rb As `make test-tool` does not use gems, and no Rubygems stuffs is needed, so moved such things to test/runner.rb. Also no longer nees `--test-target-dir` option. --- common.mk | 10 +++++----- defs/gmake.mk | 2 +- test/runner.rb | 11 +++++++++++ tool/test/runner.rb | 48 +++++++++++++++------------------------------ 4 files changed, 33 insertions(+), 38 deletions(-) create mode 100644 test/runner.rb diff --git a/common.mk b/common.mk index 0d6da60672be20..817dc3fe725e3c 100644 --- a/common.mk +++ b/common.mk @@ -753,12 +753,12 @@ yes-test-knownbug: prog PHONY test-testframework: $(TEST_RUNNABLE)-test-testframework yes-test-testframework: prog PHONY - $(gnumake_recursive)$(Q)$(exec) $(RUNRUBY) "$(TOOL_TESTSDIR)/runner.rb" --test-target-dir="$(TOOL_TESTSDIR)" --ruby="$(RUNRUBY)" $(TESTOPTS) testunit minitest + $(gnumake_recursive)$(Q)$(exec) $(RUNRUBY) "$(TOOL_TESTSDIR)/runner.rb" --ruby="$(RUNRUBY)" $(TESTOPTS) testunit minitest no-test-testframework: PHONY test-tool: $(TEST_RUNNABLE)-test-tool yes-test-tool: prog PHONY - $(gnumake_recursive)$(Q)$(exec) $(RUNRUBY) "$(TOOL_TESTSDIR)/runner.rb" --test-target-dir="$(TOOL_TESTSDIR)" --ruby="$(RUNRUBY)" $(TESTOPTS) + $(gnumake_recursive)$(Q)$(exec) $(RUNRUBY) "$(TOOL_TESTSDIR)/runner.rb" --ruby="$(RUNRUBY)" $(TESTOPTS) no-test-tool: PHONY test-sample: test-basic # backward compatibility for mswin-build @@ -769,10 +769,10 @@ test: test-short # for example, make test-all TESTOPTS="-j2 -v -n test-name -- test-file-name" test-all: $(TEST_RUNNABLE)-test-all yes-test-all: programs PHONY - $(gnumake_recursive)$(Q)$(exec) $(RUNRUBY) "$(TOOL_TESTSDIR)/runner.rb" --test-target-dir="$(TESTSDIR)" --ruby="$(RUNRUBY)" $(TEST_EXCLUDES) $(TESTOPTS) $(TESTS) + $(gnumake_recursive)$(Q)$(exec) $(RUNRUBY) "$(TESTSDIR)/runner.rb" --ruby="$(RUNRUBY)" $(TEST_EXCLUDES) $(TESTOPTS) $(TESTS) TESTS_BUILD = mkmf no-test-all: PHONY - $(gnumake_recursive)$(MINIRUBY) -I"$(srcdir)/lib" "$(TOOL_TESTSDIR)/runner.rb" --test-target-dir="$(TESTSDIR)" $(TESTOPTS) $(TESTS_BUILD) + $(gnumake_recursive)$(MINIRUBY) -I"$(srcdir)/lib" "$(TESTSDIR)/runner.rb" $(TESTOPTS) $(TESTS_BUILD) test-almost: test-all yes-test-almost: yes-test-all @@ -781,7 +781,7 @@ no-test-almost: no-test-all test-ruby: $(TEST_RUNNABLE)-test-ruby no-test-ruby: PHONY yes-test-ruby: prog encs PHONY - $(gnumake_recursive)$(RUNRUBY) "$(TOOL_TESTSDIR)/runner.rb" --test-target-dir="$(TESTSDIR)" $(TEST_EXCLUDES) $(TESTOPTS) -- ruby -ext- + $(gnumake_recursive)$(RUNRUBY) "$(TESTSDIR)/runner.rb" $(TEST_EXCLUDES) $(TESTOPTS) -- ruby -ext- extconf: $(PREP) $(Q) $(MAKEDIRS) "$(EXTCONFDIR)" diff --git a/defs/gmake.mk b/defs/gmake.mk index 88d90e144665a4..f2808b5a7d9b6d 100644 --- a/defs/gmake.mk +++ b/defs/gmake.mk @@ -290,7 +290,7 @@ rdoc\:%: PHONY $(Q)$(RUNRUBY) $(srcdir)/libexec/ri --no-standard-docs --doc-dir=$(RDOCOUT) $(patsubst rdoc:%,%,$@) test_%.rb test/%: programs PHONY - +$(Q)$(exec) $(RUNRUBY) "$(TOOL_TESTSDIR)/runner.rb" --test-target-dir="$(TESTSDIR)" --ruby="$(RUNRUBY)" $(TEST_EXCLUDES) $(TESTOPTS) -- $(patsubst test/%,%,$@) + +$(Q)$(exec) $(RUNRUBY) "$(TESTSDIR)/runner.rb" --ruby="$(RUNRUBY)" $(TEST_EXCLUDES) $(TESTOPTS) -- $(patsubst test/%,%,$@) clean-srcs-ext:: $(Q)$(RM) $(patsubst $(srcdir)/%,%,$(EXT_SRCS)) diff --git a/test/runner.rb b/test/runner.rb new file mode 100644 index 00000000000000..3e2e1316b1abdb --- /dev/null +++ b/test/runner.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +# Should be done in rubygems test files? +ENV["GEM_SKIP"] = ENV["GEM_HOME"] = ENV["GEM_PATH"] = "".freeze + +# Get bundled gems on load path +Dir.glob("#{__dir__}/../gems/*/*.gemspec") + .reject {|f| f =~ /minitest|test-unit|power_assert/ } + .map {|f| $LOAD_PATH.unshift File.join(File.dirname(f), "lib") } + +require_relative '../tool/test/runner' diff --git a/tool/test/runner.rb b/tool/test/runner.rb index 38e7c0438cfdeb..15b2cdd9fa3748 100644 --- a/tool/test/runner.rb +++ b/tool/test/runner.rb @@ -1,38 +1,22 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rbconfig' -tool_dir = File.dirname(File.dirname(File.realpath(__FILE__))) -src_testdir = nil - -case ARGV.first -when /\A--test-target-dir=(.*?)\z/ - ARGV.shift - src_testdir = File.realpath($1) -else - raise "unknown runner option: #{ ARGV.first }" -end - -raise "#$0: specify --test-target-dir" if !src_testdir - -$LOAD_PATH << src_testdir -$LOAD_PATH.unshift "#{tool_dir}/lib" - -# Get bundled gems on load path -Dir.glob("#{src_testdir}/../gems/*/*.gemspec") - .reject {|f| f =~ /minitest|test-unit|power_assert/ } - .map {|f| $LOAD_PATH.unshift File.join(File.dirname(f), "lib") } +$LOAD_PATH.unshift File.expand_path("../lib", __dir__) require 'test/unit' -ENV["GEM_SKIP"] = ENV["GEM_HOME"] = ENV["GEM_PATH"] = "".freeze - -require_relative "#{tool_dir}/lib/profile_test_all" if ENV.has_key?('RUBY_TEST_ALL_PROFILE') -require_relative "#{tool_dir}/lib/tracepointchecker" -require_relative "#{tool_dir}/lib/zombie_hunter" -require_relative "#{tool_dir}/lib/iseq_loader_checker" - -if ENV['COVERAGE'] - require_relative "#{tool_dir}/test-coverage.rb" +require_relative "../lib/profile_test_all" if ENV.key?('RUBY_TEST_ALL_PROFILE') +require_relative "../lib/tracepointchecker" +require_relative "../lib/zombie_hunter" +require_relative "../lib/iseq_loader_checker" +require_relative "../test-coverage.rb" if ENV.key?('COVERAGE') + +case $0 +when __FILE__ + dir = __dir__ +when "-e" + # No default directory +else + dir = File.expand_path("..", $0) end - -exit Test::Unit::AutoRunner.run(true, src_testdir) +Test::Unit::AutoRunner.new(true, dir) From 0f9ec4a877496278534e5956b640ed43a02229ad Mon Sep 17 00:00:00 2001 From: aycabta Date: Thu, 25 Jul 2019 17:19:11 +0900 Subject: [PATCH 387/452] Check wether multibyte character is split --- lib/reline/line_editor.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb index a238e4954cbb4d..e9e693eb2baa01 100644 --- a/lib/reline/line_editor.rb +++ b/lib/reline/line_editor.rb @@ -811,6 +811,10 @@ def retrieve_completion_block i = 0 while i < @byte_pointer do slice = @line.byteslice(i, @byte_pointer - i) + unless slice.valid_encoding? + i += 1 + next + end if quote and slice.start_with?(/(?!\\)#{Regexp.escape(quote)}/) # closing " quote = nil i += 1 From a50c844645c337742584560abc2e2b63bf566e79 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 25 Jul 2019 17:15:48 +0900 Subject: [PATCH 388/452] Initialize vm_throw_data::throw_state as int As `struct vm_throw_data::throw_state` is initialized as `VALUE` by rb_imemo_new, extended MSW part is assigned to it on LP64 big-endian platforms. Fix up 1feda1c2b091b950efcaa481a11fd660efa9e717 --- vm_insnhelper.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/vm_insnhelper.h b/vm_insnhelper.h index 920ea6ac17a5f2..f937af8b5944b2 100644 --- a/vm_insnhelper.h +++ b/vm_insnhelper.h @@ -180,9 +180,11 @@ enum vm_regan_acttype { #define INC_GLOBAL_CONSTANT_STATE() (++ruby_vm_global_constant_state) static inline struct vm_throw_data * -THROW_DATA_NEW(VALUE val, const rb_control_frame_t *cf, VALUE st) +THROW_DATA_NEW(VALUE val, const rb_control_frame_t *cf, int st) { - return (struct vm_throw_data *)rb_imemo_new(imemo_throw_data, val, (VALUE)cf, st, 0); + struct vm_throw_data *obj = (struct vm_throw_data *)rb_imemo_new(imemo_throw_data, val, (VALUE)cf, 0, 0); + obj->throw_state = st; + return obj; } static inline VALUE From 7e33f324e1d1de31a69d16dc9f27ec223523c6e8 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 25 Jul 2019 20:57:32 +0900 Subject: [PATCH 389/452] Get rid of failures about coverage Run test suites explicitly instead of auto-running, to get rid of failures when simplecov is not installed but COVERAGE is set. --- tool/test/runner.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tool/test/runner.rb b/tool/test/runner.rb index 15b2cdd9fa3748..1ee4fdf8c6e85a 100644 --- a/tool/test/runner.rb +++ b/tool/test/runner.rb @@ -19,4 +19,4 @@ else dir = File.expand_path("..", $0) end -Test::Unit::AutoRunner.new(true, dir) +exit Test::Unit::AutoRunner.run(true, dir) From 957a29fc6eb5e4e4ad562d5cafb393f62c9f05db Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 26 Jul 2019 09:03:34 +0900 Subject: [PATCH 390/452] Bump osx_image on Travis CI to xcode11 Also Homebrew is up-to-date and "Updating Homebrew" takes less than one minute. --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index f71b1fe521192b..11aab5285179d6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,7 +21,7 @@ language: c dist: xenial -osx_image: xcode10.1 +osx_image: xcode11 git: quiet: true @@ -332,8 +332,8 @@ env: language: ruby rvm: 1.9.3 - - &x86_64-darwin17 - name: x86_64-darwin17 + - &x86_64-darwin18 + name: x86_64-darwin18 <<: *osx env: - CONFIG_FLAG=--with-opt-dir=/usr/local/opt/openssl@1.1:/usr/local/opt/zlib @@ -384,7 +384,7 @@ env: matrix: include: # to reduce time for finishing all jobs, run the slowest osx build first. - - <<: *x86_64-darwin17 + - <<: *x86_64-darwin18 - <<: *x86_64-linux - <<: *i686-linux - <<: *jemalloc From 300de6aec29b1d220b961a287820a32a89940882 Mon Sep 17 00:00:00 2001 From: git Date: Fri, 26 Jul 2019 10:46:31 +0900 Subject: [PATCH 391/452] * 2019-07-26 --- version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.h b/version.h index 54eae25cdba9cc..b54100b3ea57d9 100644 --- a/version.h +++ b/version.h @@ -6,7 +6,7 @@ #define RUBY_RELEASE_YEAR 2019 #define RUBY_RELEASE_MONTH 7 -#define RUBY_RELEASE_DAY 25 +#define RUBY_RELEASE_DAY 26 #include "ruby/version.h" From 82b02c131ee1a87ac1b95443c85c6c8f7b30644f Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Fri, 26 Jul 2019 11:37:02 +0900 Subject: [PATCH 392/452] pass to obj_info(). obj_info() has a routine to show SPECIAL_CONST_P() objects so we don't need to check it here. --- gc.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/gc.c b/gc.c index a978887ae92352..1b0f13efbb1034 100644 --- a/gc.c +++ b/gc.c @@ -11421,12 +11421,7 @@ obj_info(VALUE obj) MJIT_FUNC_EXPORTED const char * rb_obj_info(VALUE obj) { - if (!rb_special_const_p(obj)) { - return obj_info(obj); - } - else { - return obj_type_name(obj); - } + return obj_info(obj); } void From 51f22deadba35ed57b794339fd19889ed0cc8dc8 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Fri, 26 Jul 2019 15:34:15 +0800 Subject: [PATCH 393/452] Adjust the test direcotry structure of rdoc. --- tool/sync_default_gems.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tool/sync_default_gems.rb b/tool/sync_default_gems.rb index 7545a2704904e6..f67c868f44b824 100644 --- a/tool/sync_default_gems.rb +++ b/tool/sync_default_gems.rb @@ -105,7 +105,7 @@ def sync_default_gems(gem) when "rdoc" rm_rf(%w[lib/rdoc* test/rdoc libexec/rdoc libexec/ri]) cp_r(Dir.glob("#{upstream}/lib/rdoc*"), "lib") - cp_r("#{upstream}/test", "test/rdoc") + cp_r("#{upstream}/test/rdoc", "test") cp_r("#{upstream}/rdoc.gemspec", "lib/rdoc") cp_r("#{upstream}/exe/rdoc", "libexec") cp_r("#{upstream}/exe/ri", "libexec") From 348c9687bf0454fce787e0d4886fe244831b0a84 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Fri, 26 Jul 2019 15:45:18 +0800 Subject: [PATCH 394/452] Escape parentheses for syntax hilighting for VScode. --- tool/sync_default_gems.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tool/sync_default_gems.rb b/tool/sync_default_gems.rb index f67c868f44b824..aa98f60ca1a372 100644 --- a/tool/sync_default_gems.rb +++ b/tool/sync_default_gems.rb @@ -266,7 +266,7 @@ def sync_default_gems_with_commits(gem, range) def sync_lib(repo) unless File.directory?("../#{repo}") - abort %[Expected '../#{repo}' (#{File.expand_path("../#{repo}")}) to be a directory, but it wasn't.] + abort %[Expected '../#{repo}' \(#{File.expand_path("../#{repo}")}\) to be a directory, but it wasn't.] end rm_rf(["lib/#{repo}.rb", "lib/#{repo}/*", "test/test_#{repo}.rb"]) cp_r(Dir.glob("../#{repo}/lib/*"), "lib") From 071bf889706d13879c323d61fd2e757ff32c8bda Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Fri, 26 Jul 2019 16:06:54 +0800 Subject: [PATCH 395/452] Improve the commits list for cherry-picking from default gems. * Ignore Merge commit from the commit lists before trying to pick commit. * Show the commits list at first. --- tool/sync_default_gems.rb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tool/sync_default_gems.rb b/tool/sync_default_gems.rb index aa98f60ca1a372..599d6b3281190c 100644 --- a/tool/sync_default_gems.rb +++ b/tool/sync_default_gems.rb @@ -240,12 +240,15 @@ def sync_default_gems_with_commits(gem, range) IO.popen(%W"git log --format=%H,%s #{range}") do |f| commits = f.read.split("\n").reverse.map{|commit| commit.split(',')} + + # Ignore Merge commit for ruby core repository. + commits.delete_if{|_, subject| subject =~ /^Merge/} + + puts "Try to pick these commits:" + puts commits.map{|commit| commit.join(": ")}.join("\n") + commits.each do |sha, subject| puts "Pick #{sha} from #{$repositories[gem.to_sym]}." - if subject =~ /^Merge/ - puts "Skip #{sha}. Because It was merge commit" - next - end `git cherry-pick #{sha}` unless $?.success? From 95aa60f6cde1ab7bc5cfe33c95c4fd2d2154cd52 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Fri, 26 Jul 2019 17:14:32 +0800 Subject: [PATCH 396/452] Ignore Merge commit and insufficiency commit for ruby core repository. --- tool/sync_default_gems.rb | 46 +++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/tool/sync_default_gems.rb b/tool/sync_default_gems.rb index 599d6b3281190c..cb9492f26ed319 100644 --- a/tool/sync_default_gems.rb +++ b/tool/sync_default_gems.rb @@ -238,31 +238,39 @@ def sync_default_gems_with_commits(gem, range) end `git fetch --no-tags #{gem}` + commits = [] + IO.popen(%W"git log --format=%H,%s #{range}") do |f| commits = f.read.split("\n").reverse.map{|commit| commit.split(',')} + end - # Ignore Merge commit for ruby core repository. - commits.delete_if{|_, subject| subject =~ /^Merge/} - - puts "Try to pick these commits:" - puts commits.map{|commit| commit.join(": ")}.join("\n") + # Ignore Merge commit and insufficiency commit for ruby core repository. + commits.delete_if do |sha, subject| + files = [] + IO.popen(%W"git diff-tree --no-commit-id --name-only -r #{sha}") do |f| + files = f.read.split("\n") + end + subject =~ /^Merge/ || files.all?{|file| file =~ /(\.travis.yml|appveyor\.yml|azure\-pipelines\.yml|\.gitignore|Gemfile|README\.md)/} + end - commits.each do |sha, subject| - puts "Pick #{sha} from #{$repositories[gem.to_sym]}." + puts "Try to pick these commits:" + puts commits.map{|commit| commit.join(": ")}.join("\n") + puts "----" - `git cherry-pick #{sha}` - unless $?.success? - puts "Failed to pick #{sha}" - break - end + commits.each do |sha, subject| + puts "Pick #{sha} from #{$repositories[gem.to_sym]}." - prefix = "[#{($repositories[gem.to_sym])}]".gsub(/\//, '\/') - suffix = "https://github.com/#{($repositories[gem.to_sym])}/commit/#{sha[0,10]}" - `git filter-branch -f --msg-filter 'sed "1s/^/#{prefix} /" && echo && echo #{suffix}' -- HEAD~1..HEAD` - unless $?.success? - puts "Failed to modify commit message of #{sha}" - break - end + `git cherry-pick #{sha}` + unless $?.success? + puts "Failed to pick #{sha}" + break + end + prefix = "[#{($repositories[gem.to_sym])}]".gsub(/\//, '\/') + suffix = "https://github.com/#{($repositories[gem.to_sym])}/commit/#{sha[0,10]}" + `git filter-branch -f --msg-filter 'sed "1s/^/#{prefix} /" && echo && echo #{suffix}' -- HEAD~1..HEAD` + unless $?.success? + puts "Failed to modify commit message of #{sha}" + break end end end From f7cbbc707413f7e1c71ac1839b0c8834550451e6 Mon Sep 17 00:00:00 2001 From: aycabta Date: Sun, 20 Jan 2019 13:18:22 +0900 Subject: [PATCH 397/452] [ruby/rdoc] ClassModule#add_comment should receive RDoc::Comment https://github.com/ruby/rdoc/commit/3fb03bf399 --- lib/rdoc/class_module.rb | 2 +- lib/rdoc/comment.rb | 5 +++++ test/rdoc/test_rdoc_class_module.rb | 21 ++++++++++++--------- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/lib/rdoc/class_module.rb b/lib/rdoc/class_module.rb index fdd56e236bd06b..7609080fbf1a84 100644 --- a/lib/rdoc/class_module.rb +++ b/lib/rdoc/class_module.rb @@ -210,7 +210,7 @@ def comment= comment # :nodoc: normalize_comment comment end - comment = "#{@comment}\n---\n#{comment}" unless @comment.empty? + comment = "#{@comment.to_s}\n---\n#{comment.to_s}" unless @comment.empty? super comment end diff --git a/lib/rdoc/comment.rb b/lib/rdoc/comment.rb index 134f6440a0358a..0f643c45b93318 100644 --- a/lib/rdoc/comment.rb +++ b/lib/rdoc/comment.rb @@ -33,6 +33,11 @@ class RDoc::Comment attr_reader :text + ## + # Alias for text + + alias to_s text + ## # Overrides the content returned by #parse. Use when there is no #text # source for this comment diff --git a/test/rdoc/test_rdoc_class_module.rb b/test/rdoc/test_rdoc_class_module.rb index cc53a13528af9e..138ede58b62344 100644 --- a/test/rdoc/test_rdoc_class_module.rb +++ b/test/rdoc/test_rdoc_class_module.rb @@ -9,21 +9,24 @@ def test_add_comment tl3 = @store.add_file 'three.rb' cm = RDoc::ClassModule.new 'Klass' - cm.add_comment '# comment 1', tl1 + comment_tl1 = RDoc::Comment.new('# comment 1') + cm.add_comment comment_tl1, tl1 - assert_equal [['comment 1', tl1]], cm.comment_location - assert_equal 'comment 1', cm.comment + assert_equal [[comment_tl1, tl1]], cm.comment_location + assert_equal 'comment 1', cm.comment.text - cm.add_comment '# comment 2', tl2 + comment_tl2 = RDoc::Comment.new('# comment 2') + cm.add_comment comment_tl2, tl2 - assert_equal [['comment 1', tl1], ['comment 2', tl2]], cm.comment_location + assert_equal [[comment_tl1, tl1], [comment_tl2, tl2]], cm.comment_location assert_equal "comment 1\n---\ncomment 2", cm.comment - cm.add_comment "# * comment 3", tl3 + comment_tl3 = RDoc::Comment.new('# * comment 3') + cm.add_comment comment_tl3, tl3 - assert_equal [['comment 1', tl1], - ['comment 2', tl2], - ['* comment 3', tl3]], cm.comment_location + assert_equal [[comment_tl1, tl1], + [comment_tl2, tl2], + [comment_tl3, tl3]], cm.comment_location assert_equal "comment 1\n---\ncomment 2\n---\n* comment 3", cm.comment end From a86d4eef4b4551a48a5329bb993c3c6c39a1b1f3 Mon Sep 17 00:00:00 2001 From: aycabta Date: Tue, 22 Jan 2019 04:46:46 +0900 Subject: [PATCH 398/452] [ruby/rdoc] Normalization of comment should check language RDoc::Text#normalize_comment that is included RDoc::Comment always remove Ruby style comment indicator "#" and C style comment indicator "/**/", but should check language and remove only the language's comment indicator. https://github.com/ruby/rdoc/commit/ca68ba1e73 --- lib/rdoc/comment.rb | 3 +- lib/rdoc/parser/c.rb | 18 +++++----- lib/rdoc/parser/ruby.rb | 2 +- lib/rdoc/text.rb | 10 ++++-- test/rdoc/minitest_helper.rb | 5 +-- test/rdoc/test_rdoc_class_module.rb | 28 ++++++++-------- test/rdoc/test_rdoc_comment.rb | 1 + test/rdoc/test_rdoc_context_section.rb | 2 +- test/rdoc/test_rdoc_parser_c.rb | 2 +- test/rdoc/test_rdoc_parser_ruby.rb | 46 +++++++++++++------------- test/rdoc/test_rdoc_text.rb | 9 +++++ 11 files changed, 73 insertions(+), 53 deletions(-) diff --git a/lib/rdoc/comment.rb b/lib/rdoc/comment.rb index 0f643c45b93318..35cacdd087b8b5 100644 --- a/lib/rdoc/comment.rb +++ b/lib/rdoc/comment.rb @@ -48,9 +48,10 @@ class RDoc::Comment # Creates a new comment with +text+ that is found in the RDoc::TopLevel # +location+. - def initialize text = nil, location = nil + def initialize text = nil, location = nil, language = nil @location = location @text = text.nil? ? nil : text.dup + @language = language @document = nil @format = 'rdoc' diff --git a/lib/rdoc/parser/c.rb b/lib/rdoc/parser/c.rb index c51e2f636594af..5cc009e499a062 100644 --- a/lib/rdoc/parser/c.rb +++ b/lib/rdoc/parser/c.rb @@ -446,7 +446,7 @@ def do_includes next unless cls = @classes[c] m = @known_classes[m] || m - comment = RDoc::Comment.new '', @top_level + comment = RDoc::Comment.new '', @top_level, :c incl = cls.add_include RDoc::Include.new(m, comment) incl.record_location @top_level end @@ -564,7 +564,7 @@ def find_alias_comment class_name, new_name, old_name \s*"#{Regexp.escape new_name}"\s*, \s*"#{Regexp.escape old_name}"\s*\);%xm - RDoc::Comment.new($1 || '', @top_level) + RDoc::Comment.new($1 || '', @top_level, :c) end ## @@ -603,7 +603,7 @@ def find_attr_comment var_name, attr_name, read = nil, write = nil '' end - RDoc::Comment.new comment, @top_level + RDoc::Comment.new comment, @top_level, :c end ## @@ -643,7 +643,7 @@ def find_body class_name, meth_name, meth_obj, file_content, quiet = false case type when :func_def - comment = RDoc::Comment.new args[0], @top_level + comment = RDoc::Comment.new args[0], @top_level, :c body = args[1] offset, = args[2] @@ -673,7 +673,7 @@ def find_body class_name, meth_name, meth_obj, file_content, quiet = false body when :macro_def - comment = RDoc::Comment.new args[0], @top_level + comment = RDoc::Comment.new args[0], @top_level, :c body = args[1] offset, = args[2] @@ -780,7 +780,7 @@ def find_class_comment class_name, class_mod comment = '' end - comment = RDoc::Comment.new comment, @top_level + comment = RDoc::Comment.new comment, @top_level, :c comment.normalize look_for_directives_in class_mod, comment @@ -825,7 +825,7 @@ def find_const_comment(type, const_name, class_name = nil) table[const_name] || '' - RDoc::Comment.new comment, @top_level + RDoc::Comment.new comment, @top_level, :c end ## @@ -856,7 +856,7 @@ def find_override_comment class_name, meth_obj return unless comment - RDoc::Comment.new comment, @top_level + RDoc::Comment.new comment, @top_level, :c end ## @@ -990,7 +990,7 @@ def handle_constants(type, var_name, const_name, definition) new_comment = "#{$1}#{new_comment.lstrip}" - new_comment = RDoc::Comment.new new_comment, @top_level + new_comment = RDoc::Comment.new new_comment, @top_level, :c con = RDoc::Constant.new const_name, new_definition, new_comment else diff --git a/lib/rdoc/parser/ruby.rb b/lib/rdoc/parser/ruby.rb index 97399f87ffaa48..8da19cf2e294f8 100644 --- a/lib/rdoc/parser/ruby.rb +++ b/lib/rdoc/parser/ruby.rb @@ -667,7 +667,7 @@ def make_message message # Creates a comment with the correct format def new_comment comment - c = RDoc::Comment.new comment, @top_level + c = RDoc::Comment.new comment, @top_level, :ruby c.format = @markup c end diff --git a/lib/rdoc/text.rb b/lib/rdoc/text.rb index 22c3777ff910e1..c3218fdb2fb796 100644 --- a/lib/rdoc/text.rb +++ b/lib/rdoc/text.rb @@ -10,6 +10,8 @@ module RDoc::Text + attr_accessor :language + ## # Maps markup formats to classes that can parse them. If the format is # unknown, "rdoc" format is used. @@ -111,8 +113,12 @@ def markup text def normalize_comment text return text if text.empty? - text = strip_stars text - text = strip_hashes text + case language + when :ruby + text = strip_hashes text + when :c + text = strip_stars text + end text = expand_tabs text text = flush_left text text = strip_newlines text diff --git a/test/rdoc/minitest_helper.rb b/test/rdoc/minitest_helper.rb index 9fb0cd676b72e4..5db0c315efd3b0 100644 --- a/test/rdoc/minitest_helper.rb +++ b/test/rdoc/minitest_helper.rb @@ -97,8 +97,9 @@ def block *contents # Creates an RDoc::Comment with +text+ which was defined on +top_level+. # By default the comment has the 'rdoc' format. - def comment text, top_level = @top_level - RDoc::Comment.new text, top_level + def comment text, top_level = @top_level, language = nil + comment = RDoc::Comment.new text, top_level, language + comment end ## diff --git a/test/rdoc/test_rdoc_class_module.rb b/test/rdoc/test_rdoc_class_module.rb index 138ede58b62344..4dcc5d15ab1557 100644 --- a/test/rdoc/test_rdoc_class_module.rb +++ b/test/rdoc/test_rdoc_class_module.rb @@ -9,19 +9,19 @@ def test_add_comment tl3 = @store.add_file 'three.rb' cm = RDoc::ClassModule.new 'Klass' - comment_tl1 = RDoc::Comment.new('# comment 1') + comment_tl1 = RDoc::Comment.new('# comment 1', @top_level, :ruby) cm.add_comment comment_tl1, tl1 assert_equal [[comment_tl1, tl1]], cm.comment_location assert_equal 'comment 1', cm.comment.text - comment_tl2 = RDoc::Comment.new('# comment 2') + comment_tl2 = RDoc::Comment.new('# comment 2', @top_level, :ruby) cm.add_comment comment_tl2, tl2 assert_equal [[comment_tl1, tl1], [comment_tl2, tl2]], cm.comment_location assert_equal "comment 1\n---\ncomment 2", cm.comment - comment_tl3 = RDoc::Comment.new('# * comment 3') + comment_tl3 = RDoc::Comment.new('# * comment 3', @top_level, :ruby) cm.add_comment comment_tl3, tl3 assert_equal [[comment_tl1, tl1], @@ -42,11 +42,13 @@ def test_add_comment_duplicate tl1 = @store.add_file 'one.rb' cm = RDoc::ClassModule.new 'Klass' - cm.add_comment '# comment 1', tl1 - cm.add_comment '# comment 2', tl1 + comment1 = RDoc::Comment.new('# comment 1', @top_level, :ruby) + comment2 = RDoc::Comment.new('# comment 2', @top_level, :ruby) + cm.add_comment comment1, tl1 + cm.add_comment comment2, tl1 - assert_equal [['comment 1', tl1], - ['comment 2', tl1]], cm.comment_location + assert_equal [[comment1, tl1], + [comment2, tl1]], cm.comment_location end def test_add_comment_stopdoc @@ -66,17 +68,17 @@ def test_ancestors def test_comment_equals cm = RDoc::ClassModule.new 'Klass' - cm.comment = '# comment 1' + cm.comment = RDoc::Comment.new('# comment 1', @top_level, :ruby) - assert_equal 'comment 1', cm.comment + assert_equal 'comment 1', cm.comment.to_s - cm.comment = '# comment 2' + cm.comment = RDoc::Comment.new('# comment 2', @top_level, :ruby) - assert_equal "comment 1\n---\ncomment 2", cm.comment + assert_equal "comment 1\n---\ncomment 2", cm.comment.to_s - cm.comment = "# * comment 3" + cm.comment = RDoc::Comment.new('# * comment 3', @top_level, :ruby) - assert_equal "comment 1\n---\ncomment 2\n---\n* comment 3", cm.comment + assert_equal "comment 1\n---\ncomment 2\n---\n* comment 3", cm.comment.to_s end def test_comment_equals_comment diff --git a/test/rdoc/test_rdoc_comment.rb b/test/rdoc/test_rdoc_comment.rb index 9b3c105bb0451b..48d0042f16143d 100644 --- a/test/rdoc/test_rdoc_comment.rb +++ b/test/rdoc/test_rdoc_comment.rb @@ -241,6 +241,7 @@ def test_normalize @comment.text = <<-TEXT # comment TEXT + @comment.language = :ruby assert_same @comment, @comment.normalize diff --git a/test/rdoc/test_rdoc_context_section.rb b/test/rdoc/test_rdoc_context_section.rb index f1cf493d3d0ca3..93cfbdf0a7be6f 100644 --- a/test/rdoc/test_rdoc_context_section.rb +++ b/test/rdoc/test_rdoc_context_section.rb @@ -11,7 +11,7 @@ def setup @klass = @top_level.add_class RDoc::NormalClass, 'Object' @S = RDoc::Context::Section - @s = @S.new @klass, 'section', comment('# comment', @top_level) + @s = @S.new @klass, 'section', comment('# comment', @top_level, :ruby) end def test_add_comment diff --git a/test/rdoc/test_rdoc_parser_c.rb b/test/rdoc/test_rdoc_parser_c.rb index 3d30d767dfb186..ca668f61fc96f0 100644 --- a/test/rdoc/test_rdoc_parser_c.rb +++ b/test/rdoc/test_rdoc_parser_c.rb @@ -1381,7 +1381,7 @@ def test_find_modifiers_nodoc end def test_find_modifiers_yields - comment = RDoc::Comment.new <<-COMMENT + comment = RDoc::Comment.new <<-COMMENT, @top_level, :c /* :yields: a, b * * Blah diff --git a/test/rdoc/test_rdoc_parser_ruby.rb b/test/rdoc/test_rdoc_parser_ruby.rb index 97abafca5841b6..95a8658fdb6b3f 100644 --- a/test/rdoc/test_rdoc_parser_ruby.rb +++ b/test/rdoc/test_rdoc_parser_ruby.rb @@ -435,7 +435,7 @@ def test_parse_attr klass = RDoc::NormalClass.new 'Foo' klass.parent = @top_level - comment = RDoc::Comment.new "##\n# my attr\n", @top_level + comment = RDoc::Comment.new "##\n# my attr\n", @top_level, :ruby util_parser "attr :foo, :bar" @@ -472,7 +472,7 @@ def test_parse_attr_accessor klass = RDoc::NormalClass.new 'Foo' klass.parent = @top_level - comment = RDoc::Comment.new "##\n# my attr\n", @top_level + comment = RDoc::Comment.new "##\n# my attr\n", @top_level, :ruby util_parser "attr_accessor :foo, :bar" @@ -499,7 +499,7 @@ def test_parse_attr_accessor_with_newline klass = RDoc::NormalClass.new 'Foo' klass.parent = @top_level - comment = RDoc::Comment.new "##\n# my attr\n", @top_level + comment = RDoc::Comment.new "##\n# my attr\n", @top_level, :ruby util_parser "attr_accessor :foo, :bar,\n :baz,\n :qux" @@ -584,7 +584,7 @@ def test_parse_attr_accessor_writer klass = RDoc::NormalClass.new 'Foo' klass.parent = @top_level - comment = RDoc::Comment.new "##\n# my attr\n", @top_level + comment = RDoc::Comment.new "##\n# my attr\n", @top_level, :ruby util_parser "attr_writer :foo, :bar" @@ -610,7 +610,7 @@ def test_parse_meta_attr klass = RDoc::NormalClass.new 'Foo' klass.parent = @top_level - comment = RDoc::Comment.new "##\n# :attr: \n# my method\n", @top_level + comment = RDoc::Comment.new "##\n# :attr: \n# my method\n", @top_level, :ruby util_parser "add_my_method :foo, :bar" @@ -631,7 +631,7 @@ def test_parse_meta_attr_accessor klass.parent = @top_level comment = - RDoc::Comment.new "##\n# :attr_accessor: \n# my method\n", @top_level + RDoc::Comment.new "##\n# :attr_accessor: \n# my method\n", @top_level, :ruby util_parser "add_my_method :foo, :bar" @@ -651,7 +651,7 @@ def test_parse_meta_attr_named klass = RDoc::NormalClass.new 'Foo' klass.parent = @top_level - comment = RDoc::Comment.new "##\n# :attr: foo\n# my method\n", @top_level + comment = RDoc::Comment.new "##\n# :attr: foo\n# my method\n", @top_level, :ruby util_parser "add_my_method :foo, :bar" @@ -672,7 +672,7 @@ def test_parse_meta_attr_reader klass.parent = @top_level comment = - RDoc::Comment.new "##\n# :attr_reader: \n# my method\n", @top_level + RDoc::Comment.new "##\n# :attr_reader: \n# my method\n", @top_level, :ruby util_parser "add_my_method :foo, :bar" @@ -708,7 +708,7 @@ def test_parse_meta_attr_writer klass.parent = @top_level comment = - RDoc::Comment.new "##\n# :attr_writer: \n# my method\n", @top_level + RDoc::Comment.new "##\n# :attr_writer: \n# my method\n", @top_level, :ruby util_parser "add_my_method :foo, :bar" @@ -724,7 +724,7 @@ def test_parse_meta_attr_writer end def test_parse_class - comment = RDoc::Comment.new "##\n# my class\n", @top_level + comment = RDoc::Comment.new "##\n# my class\n", @top_level, :ruby util_parser "class Foo\nend" @@ -1001,7 +1001,7 @@ def test_parse_class_nested_superclass end def test_parse_module - comment = RDoc::Comment.new "##\n# my module\n", @top_level + comment = RDoc::Comment.new "##\n# my module\n", @top_level, :ruby util_parser "module Foo\nend" @@ -1247,7 +1247,7 @@ def test_parse_comment_attr klass = RDoc::NormalClass.new 'Foo' klass.parent = @top_level - comment = RDoc::Comment.new "##\n# :attr: foo\n# my attr\n", @top_level + comment = RDoc::Comment.new "##\n# :attr: foo\n# my attr\n", @top_level, :ruby util_parser "\n" @@ -1311,7 +1311,7 @@ def test_parse_comment_method klass = RDoc::NormalClass.new 'Foo' klass.parent = @top_level - comment = RDoc::Comment.new "##\n# :method: foo\n# my method\n", @top_level + comment = RDoc::Comment.new "##\n# :method: foo\n# my method\n", @top_level, :ruby util_parser "\n" @@ -1595,7 +1595,7 @@ def test_parse_extend_or_include_extend klass = RDoc::NormalClass.new 'C' klass.parent = @top_level - comment = RDoc::Comment.new "# my extend\n", @top_level + comment = RDoc::Comment.new "# my extend\n", @top_level, :ruby util_parser "extend I" @@ -1615,7 +1615,7 @@ def test_parse_extend_or_include_include klass = RDoc::NormalClass.new 'C' klass.parent = @top_level - comment = RDoc::Comment.new "# my include\n", @top_level + comment = RDoc::Comment.new "# my include\n", @top_level, :ruby util_parser "include I" @@ -1635,7 +1635,7 @@ def test_parse_meta_method klass = RDoc::NormalClass.new 'Foo' klass.parent = @top_level - comment = RDoc::Comment.new "##\n# my method\n", @top_level + comment = RDoc::Comment.new "##\n# my method\n", @top_level, :ruby util_parser "add_my_method :foo, :bar\nadd_my_method :baz" @@ -1719,7 +1719,7 @@ def test_parse_meta_method_block def test_parse_meta_method_define_method klass = RDoc::NormalClass.new 'Foo' - comment = RDoc::Comment.new "##\n# my method\n", @top_level + comment = RDoc::Comment.new "##\n# my method\n", @top_level, :ruby util_parser "define_method :foo do end" @@ -1738,7 +1738,7 @@ def test_parse_meta_method_name klass.parent = @top_level comment = - RDoc::Comment.new "##\n# :method: woo_hoo!\n# my method\n", @top_level + RDoc::Comment.new "##\n# :method: woo_hoo!\n# my method\n", @top_level, :ruby util_parser "add_my_method :foo, :bar\nadd_my_method :baz" @@ -1757,7 +1757,7 @@ def test_parse_meta_method_singleton klass.parent = @top_level comment = - RDoc::Comment.new "##\n# :singleton-method:\n# my method\n", @top_level + RDoc::Comment.new "##\n# :singleton-method:\n# my method\n", @top_level, :ruby util_parser "add_my_method :foo, :bar\nadd_my_method :baz" @@ -1778,7 +1778,7 @@ def test_parse_meta_method_singleton_name comment = RDoc::Comment.new "##\n# :singleton-method: woo_hoo!\n# my method\n", - @top_level + @top_level, :ruby util_parser "add_my_method :foo, :bar\nadd_my_method :baz" @@ -1795,7 +1795,7 @@ def test_parse_meta_method_singleton_name def test_parse_meta_method_string_name klass = RDoc::NormalClass.new 'Foo' - comment = RDoc::Comment.new "##\n# my method\n", @top_level + comment = RDoc::Comment.new "##\n# my method\n", @top_level, :ruby util_parser "add_my_method 'foo'" @@ -1827,7 +1827,7 @@ def test_parse_meta_method_stopdoc def test_parse_meta_method_unknown klass = RDoc::NormalClass.new 'Foo' - comment = RDoc::Comment.new "##\n# my method\n", @top_level + comment = RDoc::Comment.new "##\n# my method\n", @top_level, :ruby util_parser "add_my_method ('foo')" @@ -1845,7 +1845,7 @@ def test_parse_method klass = RDoc::NormalClass.new 'Foo' klass.parent = @top_level - comment = RDoc::Comment.new "##\n# my method\n", @top_level + comment = RDoc::Comment.new "##\n# my method\n", @top_level, :ruby util_parser "def foo() :bar end" diff --git a/test/rdoc/test_rdoc_text.rb b/test/rdoc/test_rdoc_text.rb index 2669766e71e171..fcd993f83454b7 100644 --- a/test/rdoc/test_rdoc_text.rb +++ b/test/rdoc/test_rdoc_text.rb @@ -13,6 +13,7 @@ def setup @options = RDoc::Options.new @top_level = @store.add_file 'file.rb' + @language = nil end def test_self_encode_fallback @@ -137,6 +138,8 @@ def test_normalize_comment_hash The comments associated with EXPECTED + @language = :ruby + assert_equal expected, normalize_comment(text) end @@ -155,6 +158,8 @@ def test_normalize_comment_stars_single_space The comments associated with EXPECTED + @language = :c + assert_equal expected, normalize_comment(text) end @@ -173,6 +178,8 @@ def test_normalize_comment_stars_single_double_space The comments associated with EXPECTED + @language = :c + assert_equal expected, normalize_comment(text) end @@ -200,6 +207,8 @@ def test_parse_empty end def test_parse_empty_newline + @language = :ruby + assert_equal RDoc::Markup::Document.new, parse("#\n") end From 3b0f952ec810c08eac01ce2377dfbb252026760b Mon Sep 17 00:00:00 2001 From: aycabta Date: Fri, 25 Jan 2019 23:58:30 +0900 Subject: [PATCH 399/452] [ruby/rdoc] Support nesting text page URL RDoc::Servlet#documentation_page replaces "/" in URL with "::" for class or module but it's also used for the replaced name on text pages. This causes a bug when text pages are in nesting directory. This commit fixes #615. https://github.com/ruby/rdoc/commit/d73b915b1e --- lib/rdoc/servlet.rb | 5 ++++- test/rdoc/test_rdoc_servlet.rb | 12 ++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/rdoc/servlet.rb b/lib/rdoc/servlet.rb index 79550fe63b23dc..72e6e90193b2c9 100644 --- a/lib/rdoc/servlet.rb +++ b/lib/rdoc/servlet.rb @@ -145,12 +145,15 @@ def do_GET req, res # +generator+ is used to create the page. def documentation_page store, generator, path, req, res - name = path.sub(/.html$/, '').gsub '/', '::' + text_name = path.sub /.html$/, '' + name = text_name.gsub '/', '::' if klass = store.find_class_or_module(name) then res.body = generator.generate_class klass elsif page = store.find_text_page(name.sub(/_([^_]*)$/, '.\1')) then res.body = generator.generate_page page + elsif page = store.find_text_page(text_name.sub(/_([^_]*)$/, '.\1')) then + res.body = generator.generate_page page else not_found generator, req, res end diff --git a/test/rdoc/test_rdoc_servlet.rb b/test/rdoc/test_rdoc_servlet.rb index a3d4246229b0e9..b772eeaddf2633 100644 --- a/test/rdoc/test_rdoc_servlet.rb +++ b/test/rdoc/test_rdoc_servlet.rb @@ -232,6 +232,18 @@ def test_documentation_page_page assert_match %r%]+ class="file">%, @res.body end + def test_documentation_page_page_with_nesting + store = RDoc::Store.new + + generator = @s.generator_for store + + readme = store.add_file 'nesting/README.rdoc', parser: RDoc::Parser::Simple + + @s.documentation_page store, generator, 'nesting/README_rdoc.html', @req, @res + + assert_equal 200, @res.status + end + def test_documentation_source store, path = @s.documentation_source '/ruby/Object.html' From 8bb48923761e0e3689ea61fec05b2c36faf9d899 Mon Sep 17 00:00:00 2001 From: aycabta Date: Mon, 1 Apr 2019 17:16:57 +0900 Subject: [PATCH 400/452] [ruby/rdoc] Update jQuery to 3.3.1 https://github.com/ruby/rdoc/commit/17df871ee --- lib/rdoc/generator/template/darkfish/js/jquery.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/rdoc/generator/template/darkfish/js/jquery.js b/lib/rdoc/generator/template/darkfish/js/jquery.js index 628ed9b31604ed..4d9b3a258759c5 100644 --- a/lib/rdoc/generator/template/darkfish/js/jquery.js +++ b/lib/rdoc/generator/template/darkfish/js/jquery.js @@ -1,4 +1,2 @@ -/*! 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 +/*! jQuery v3.3.1 | (c) JS Foundation and other contributors | jquery.org/license */ +!function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(e,t){"use strict";var n=[],r=e.document,i=Object.getPrototypeOf,o=n.slice,a=n.concat,s=n.push,u=n.indexOf,l={},c=l.toString,f=l.hasOwnProperty,p=f.toString,d=p.call(Object),h={},g=function e(t){return"function"==typeof t&&"number"!=typeof t.nodeType},y=function e(t){return null!=t&&t===t.window},v={type:!0,src:!0,noModule:!0};function m(e,t,n){var i,o=(t=t||r).createElement("script");if(o.text=e,n)for(i in v)n[i]&&(o[i]=n[i]);t.head.appendChild(o).parentNode.removeChild(o)}function x(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?l[c.call(e)]||"object":typeof e}var b="3.3.1",w=function(e,t){return new w.fn.init(e,t)},T=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;w.fn=w.prototype={jquery:"3.3.1",constructor:w,length:0,toArray:function(){return o.call(this)},get:function(e){return null==e?o.call(this):e<0?this[e+this.length]:this[e]},pushStack:function(e){var t=w.merge(this.constructor(),e);return t.prevObject=this,t},each:function(e){return w.each(this,e)},map:function(e){return this.pushStack(w.map(this,function(t,n){return e.call(t,n,t)}))},slice:function(){return this.pushStack(o.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(e){var t=this.length,n=+e+(e<0?t:0);return this.pushStack(n>=0&&n0&&t-1 in e)}var E=function(e){var t,n,r,i,o,a,s,u,l,c,f,p,d,h,g,y,v,m,x,b="sizzle"+1*new Date,w=e.document,T=0,C=0,E=ae(),k=ae(),S=ae(),D=function(e,t){return e===t&&(f=!0),0},N={}.hasOwnProperty,A=[],j=A.pop,q=A.push,L=A.push,H=A.slice,O=function(e,t){for(var n=0,r=e.length;n+~]|"+M+")"+M+"*"),z=new RegExp("="+M+"*([^\\]'\"]*?)"+M+"*\\]","g"),X=new RegExp(W),U=new RegExp("^"+R+"$"),V={ID:new RegExp("^#("+R+")"),CLASS:new RegExp("^\\.("+R+")"),TAG:new RegExp("^("+R+"|[*])"),ATTR:new RegExp("^"+I),PSEUDO:new RegExp("^"+W),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+P+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},G=/^(?:input|select|textarea|button)$/i,Y=/^h\d$/i,Q=/^[^{]+\{\s*\[native \w/,J=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,K=/[+~]/,Z=new RegExp("\\\\([\\da-f]{1,6}"+M+"?|("+M+")|.)","ig"),ee=function(e,t,n){var r="0x"+t-65536;return r!==r||n?t:r<0?String.fromCharCode(r+65536):String.fromCharCode(r>>10|55296,1023&r|56320)},te=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ne=function(e,t){return t?"\0"===e?"\ufffd":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e},re=function(){p()},ie=me(function(e){return!0===e.disabled&&("form"in e||"label"in e)},{dir:"parentNode",next:"legend"});try{L.apply(A=H.call(w.childNodes),w.childNodes),A[w.childNodes.length].nodeType}catch(e){L={apply:A.length?function(e,t){q.apply(e,H.call(t))}:function(e,t){var n=e.length,r=0;while(e[n++]=t[r++]);e.length=n-1}}}function oe(e,t,r,i){var o,s,l,c,f,h,v,m=t&&t.ownerDocument,T=t?t.nodeType:9;if(r=r||[],"string"!=typeof e||!e||1!==T&&9!==T&&11!==T)return r;if(!i&&((t?t.ownerDocument||t:w)!==d&&p(t),t=t||d,g)){if(11!==T&&(f=J.exec(e)))if(o=f[1]){if(9===T){if(!(l=t.getElementById(o)))return r;if(l.id===o)return r.push(l),r}else if(m&&(l=m.getElementById(o))&&x(t,l)&&l.id===o)return r.push(l),r}else{if(f[2])return L.apply(r,t.getElementsByTagName(e)),r;if((o=f[3])&&n.getElementsByClassName&&t.getElementsByClassName)return L.apply(r,t.getElementsByClassName(o)),r}if(n.qsa&&!S[e+" "]&&(!y||!y.test(e))){if(1!==T)m=t,v=e;else if("object"!==t.nodeName.toLowerCase()){(c=t.getAttribute("id"))?c=c.replace(te,ne):t.setAttribute("id",c=b),s=(h=a(e)).length;while(s--)h[s]="#"+c+" "+ve(h[s]);v=h.join(","),m=K.test(e)&&ge(t.parentNode)||t}if(v)try{return L.apply(r,m.querySelectorAll(v)),r}catch(e){}finally{c===b&&t.removeAttribute("id")}}}return u(e.replace(B,"$1"),t,r,i)}function ae(){var e=[];function t(n,i){return e.push(n+" ")>r.cacheLength&&delete t[e.shift()],t[n+" "]=i}return t}function se(e){return e[b]=!0,e}function ue(e){var t=d.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function le(e,t){var n=e.split("|"),i=n.length;while(i--)r.attrHandle[n[i]]=t}function ce(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function fe(e){return function(t){return"input"===t.nodeName.toLowerCase()&&t.type===e}}function pe(e){return function(t){var n=t.nodeName.toLowerCase();return("input"===n||"button"===n)&&t.type===e}}function de(e){return function(t){return"form"in t?t.parentNode&&!1===t.disabled?"label"in t?"label"in t.parentNode?t.parentNode.disabled===e:t.disabled===e:t.isDisabled===e||t.isDisabled!==!e&&ie(t)===e:t.disabled===e:"label"in t&&t.disabled===e}}function he(e){return se(function(t){return t=+t,se(function(n,r){var i,o=e([],n.length,t),a=o.length;while(a--)n[i=o[a]]&&(n[i]=!(r[i]=n[i]))})})}function ge(e){return e&&"undefined"!=typeof e.getElementsByTagName&&e}n=oe.support={},o=oe.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return!!t&&"HTML"!==t.nodeName},p=oe.setDocument=function(e){var t,i,a=e?e.ownerDocument||e:w;return a!==d&&9===a.nodeType&&a.documentElement?(d=a,h=d.documentElement,g=!o(d),w!==d&&(i=d.defaultView)&&i.top!==i&&(i.addEventListener?i.addEventListener("unload",re,!1):i.attachEvent&&i.attachEvent("onunload",re)),n.attributes=ue(function(e){return e.className="i",!e.getAttribute("className")}),n.getElementsByTagName=ue(function(e){return e.appendChild(d.createComment("")),!e.getElementsByTagName("*").length}),n.getElementsByClassName=Q.test(d.getElementsByClassName),n.getById=ue(function(e){return h.appendChild(e).id=b,!d.getElementsByName||!d.getElementsByName(b).length}),n.getById?(r.filter.ID=function(e){var t=e.replace(Z,ee);return function(e){return e.getAttribute("id")===t}},r.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&g){var n=t.getElementById(e);return n?[n]:[]}}):(r.filter.ID=function(e){var t=e.replace(Z,ee);return function(e){var n="undefined"!=typeof e.getAttributeNode&&e.getAttributeNode("id");return n&&n.value===t}},r.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&g){var n,r,i,o=t.getElementById(e);if(o){if((n=o.getAttributeNode("id"))&&n.value===e)return[o];i=t.getElementsByName(e),r=0;while(o=i[r++])if((n=o.getAttributeNode("id"))&&n.value===e)return[o]}return[]}}),r.find.TAG=n.getElementsByTagName?function(e,t){return"undefined"!=typeof t.getElementsByTagName?t.getElementsByTagName(e):n.qsa?t.querySelectorAll(e):void 0}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},r.find.CLASS=n.getElementsByClassName&&function(e,t){if("undefined"!=typeof t.getElementsByClassName&&g)return t.getElementsByClassName(e)},v=[],y=[],(n.qsa=Q.test(d.querySelectorAll))&&(ue(function(e){h.appendChild(e).innerHTML="",e.querySelectorAll("[msallowcapture^='']").length&&y.push("[*^$]="+M+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||y.push("\\["+M+"*(?:value|"+P+")"),e.querySelectorAll("[id~="+b+"-]").length||y.push("~="),e.querySelectorAll(":checked").length||y.push(":checked"),e.querySelectorAll("a#"+b+"+*").length||y.push(".#.+[+~]")}),ue(function(e){e.innerHTML="";var t=d.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&y.push("name"+M+"*[*^$|!~]?="),2!==e.querySelectorAll(":enabled").length&&y.push(":enabled",":disabled"),h.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&y.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),y.push(",.*:")})),(n.matchesSelector=Q.test(m=h.matches||h.webkitMatchesSelector||h.mozMatchesSelector||h.oMatchesSelector||h.msMatchesSelector))&&ue(function(e){n.disconnectedMatch=m.call(e,"*"),m.call(e,"[s!='']:x"),v.push("!=",W)}),y=y.length&&new RegExp(y.join("|")),v=v.length&&new RegExp(v.join("|")),t=Q.test(h.compareDocumentPosition),x=t||Q.test(h.contains)?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},D=t?function(e,t){if(e===t)return f=!0,0;var r=!e.compareDocumentPosition-!t.compareDocumentPosition;return r||(1&(r=(e.ownerDocument||e)===(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!n.sortDetached&&t.compareDocumentPosition(e)===r?e===d||e.ownerDocument===w&&x(w,e)?-1:t===d||t.ownerDocument===w&&x(w,t)?1:c?O(c,e)-O(c,t):0:4&r?-1:1)}:function(e,t){if(e===t)return f=!0,0;var n,r=0,i=e.parentNode,o=t.parentNode,a=[e],s=[t];if(!i||!o)return e===d?-1:t===d?1:i?-1:o?1:c?O(c,e)-O(c,t):0;if(i===o)return ce(e,t);n=e;while(n=n.parentNode)a.unshift(n);n=t;while(n=n.parentNode)s.unshift(n);while(a[r]===s[r])r++;return r?ce(a[r],s[r]):a[r]===w?-1:s[r]===w?1:0},d):d},oe.matches=function(e,t){return oe(e,null,null,t)},oe.matchesSelector=function(e,t){if((e.ownerDocument||e)!==d&&p(e),t=t.replace(z,"='$1']"),n.matchesSelector&&g&&!S[t+" "]&&(!v||!v.test(t))&&(!y||!y.test(t)))try{var r=m.call(e,t);if(r||n.disconnectedMatch||e.document&&11!==e.document.nodeType)return r}catch(e){}return oe(t,d,null,[e]).length>0},oe.contains=function(e,t){return(e.ownerDocument||e)!==d&&p(e),x(e,t)},oe.attr=function(e,t){(e.ownerDocument||e)!==d&&p(e);var i=r.attrHandle[t.toLowerCase()],o=i&&N.call(r.attrHandle,t.toLowerCase())?i(e,t,!g):void 0;return void 0!==o?o:n.attributes||!g?e.getAttribute(t):(o=e.getAttributeNode(t))&&o.specified?o.value:null},oe.escape=function(e){return(e+"").replace(te,ne)},oe.error=function(e){throw new Error("Syntax error, unrecognized expression: "+e)},oe.uniqueSort=function(e){var t,r=[],i=0,o=0;if(f=!n.detectDuplicates,c=!n.sortStable&&e.slice(0),e.sort(D),f){while(t=e[o++])t===e[o]&&(i=r.push(o));while(i--)e.splice(r[i],1)}return c=null,e},i=oe.getText=function(e){var t,n="",r=0,o=e.nodeType;if(o){if(1===o||9===o||11===o){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=i(e)}else if(3===o||4===o)return e.nodeValue}else while(t=e[r++])n+=i(t);return n},(r=oe.selectors={cacheLength:50,createPseudo:se,match:V,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(Z,ee),e[3]=(e[3]||e[4]||e[5]||"").replace(Z,ee),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||oe.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&oe.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return V.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&X.test(n)&&(t=a(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(Z,ee).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=E[e+" "];return t||(t=new RegExp("(^|"+M+")"+e+"("+M+"|$)"))&&E(e,function(e){return t.test("string"==typeof e.className&&e.className||"undefined"!=typeof e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(e,t,n){return function(r){var i=oe.attr(r,e);return null==i?"!="===t:!t||(i+="","="===t?i===n:"!="===t?i!==n:"^="===t?n&&0===i.indexOf(n):"*="===t?n&&i.indexOf(n)>-1:"$="===t?n&&i.slice(-n.length)===n:"~="===t?(" "+i.replace($," ")+" ").indexOf(n)>-1:"|="===t&&(i===n||i.slice(0,n.length+1)===n+"-"))}},CHILD:function(e,t,n,r,i){var o="nth"!==e.slice(0,3),a="last"!==e.slice(-4),s="of-type"===t;return 1===r&&0===i?function(e){return!!e.parentNode}:function(t,n,u){var l,c,f,p,d,h,g=o!==a?"nextSibling":"previousSibling",y=t.parentNode,v=s&&t.nodeName.toLowerCase(),m=!u&&!s,x=!1;if(y){if(o){while(g){p=t;while(p=p[g])if(s?p.nodeName.toLowerCase()===v:1===p.nodeType)return!1;h=g="only"===e&&!h&&"nextSibling"}return!0}if(h=[a?y.firstChild:y.lastChild],a&&m){x=(d=(l=(c=(f=(p=y)[b]||(p[b]={}))[p.uniqueID]||(f[p.uniqueID]={}))[e]||[])[0]===T&&l[1])&&l[2],p=d&&y.childNodes[d];while(p=++d&&p&&p[g]||(x=d=0)||h.pop())if(1===p.nodeType&&++x&&p===t){c[e]=[T,d,x];break}}else if(m&&(x=d=(l=(c=(f=(p=t)[b]||(p[b]={}))[p.uniqueID]||(f[p.uniqueID]={}))[e]||[])[0]===T&&l[1]),!1===x)while(p=++d&&p&&p[g]||(x=d=0)||h.pop())if((s?p.nodeName.toLowerCase()===v:1===p.nodeType)&&++x&&(m&&((c=(f=p[b]||(p[b]={}))[p.uniqueID]||(f[p.uniqueID]={}))[e]=[T,x]),p===t))break;return(x-=i)===r||x%r==0&&x/r>=0}}},PSEUDO:function(e,t){var n,i=r.pseudos[e]||r.setFilters[e.toLowerCase()]||oe.error("unsupported pseudo: "+e);return i[b]?i(t):i.length>1?(n=[e,e,"",t],r.setFilters.hasOwnProperty(e.toLowerCase())?se(function(e,n){var r,o=i(e,t),a=o.length;while(a--)e[r=O(e,o[a])]=!(n[r]=o[a])}):function(e){return i(e,0,n)}):i}},pseudos:{not:se(function(e){var t=[],n=[],r=s(e.replace(B,"$1"));return r[b]?se(function(e,t,n,i){var o,a=r(e,null,i,[]),s=e.length;while(s--)(o=a[s])&&(e[s]=!(t[s]=o))}):function(e,i,o){return t[0]=e,r(t,null,o,n),t[0]=null,!n.pop()}}),has:se(function(e){return function(t){return oe(e,t).length>0}}),contains:se(function(e){return e=e.replace(Z,ee),function(t){return(t.textContent||t.innerText||i(t)).indexOf(e)>-1}}),lang:se(function(e){return U.test(e||"")||oe.error("unsupported lang: "+e),e=e.replace(Z,ee).toLowerCase(),function(t){var n;do{if(n=g?t.lang:t.getAttribute("xml:lang")||t.getAttribute("lang"))return(n=n.toLowerCase())===e||0===n.indexOf(e+"-")}while((t=t.parentNode)&&1===t.nodeType);return!1}}),target:function(t){var n=e.location&&e.location.hash;return n&&n.slice(1)===t.id},root:function(e){return e===h},focus:function(e){return e===d.activeElement&&(!d.hasFocus||d.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:de(!1),disabled:de(!0),checked:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&!!e.checked||"option"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,!0===e.selected},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeType<6)return!1;return!0},parent:function(e){return!r.pseudos.empty(e)},header:function(e){return Y.test(e.nodeName)},input:function(e){return G.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&"button"===e.type||"button"===t},text:function(e){var t;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(t=e.getAttribute("type"))||"text"===t.toLowerCase())},first:he(function(){return[0]}),last:he(function(e,t){return[t-1]}),eq:he(function(e,t,n){return[n<0?n+t:n]}),even:he(function(e,t){for(var n=0;n=0;)e.push(r);return e}),gt:he(function(e,t,n){for(var r=n<0?n+t:n;++r1?function(t,n,r){var i=e.length;while(i--)if(!e[i](t,n,r))return!1;return!0}:e[0]}function be(e,t,n){for(var r=0,i=t.length;r-1&&(o[l]=!(a[l]=f))}}else v=we(v===a?v.splice(h,v.length):v),i?i(null,a,v,u):L.apply(a,v)})}function Ce(e){for(var t,n,i,o=e.length,a=r.relative[e[0].type],s=a||r.relative[" "],u=a?1:0,c=me(function(e){return e===t},s,!0),f=me(function(e){return O(t,e)>-1},s,!0),p=[function(e,n,r){var i=!a&&(r||n!==l)||((t=n).nodeType?c(e,n,r):f(e,n,r));return t=null,i}];u1&&xe(p),u>1&&ve(e.slice(0,u-1).concat({value:" "===e[u-2].type?"*":""})).replace(B,"$1"),n,u0,i=e.length>0,o=function(o,a,s,u,c){var f,h,y,v=0,m="0",x=o&&[],b=[],w=l,C=o||i&&r.find.TAG("*",c),E=T+=null==w?1:Math.random()||.1,k=C.length;for(c&&(l=a===d||a||c);m!==k&&null!=(f=C[m]);m++){if(i&&f){h=0,a||f.ownerDocument===d||(p(f),s=!g);while(y=e[h++])if(y(f,a||d,s)){u.push(f);break}c&&(T=E)}n&&((f=!y&&f)&&v--,o&&x.push(f))}if(v+=m,n&&m!==v){h=0;while(y=t[h++])y(x,b,a,s);if(o){if(v>0)while(m--)x[m]||b[m]||(b[m]=j.call(u));b=we(b)}L.apply(u,b),c&&!o&&b.length>0&&v+t.length>1&&oe.uniqueSort(u)}return c&&(T=E,l=w),x};return n?se(o):o}return s=oe.compile=function(e,t){var n,r=[],i=[],o=S[e+" "];if(!o){t||(t=a(e)),n=t.length;while(n--)(o=Ce(t[n]))[b]?r.push(o):i.push(o);(o=S(e,Ee(i,r))).selector=e}return o},u=oe.select=function(e,t,n,i){var o,u,l,c,f,p="function"==typeof e&&e,d=!i&&a(e=p.selector||e);if(n=n||[],1===d.length){if((u=d[0]=d[0].slice(0)).length>2&&"ID"===(l=u[0]).type&&9===t.nodeType&&g&&r.relative[u[1].type]){if(!(t=(r.find.ID(l.matches[0].replace(Z,ee),t)||[])[0]))return n;p&&(t=t.parentNode),e=e.slice(u.shift().value.length)}o=V.needsContext.test(e)?0:u.length;while(o--){if(l=u[o],r.relative[c=l.type])break;if((f=r.find[c])&&(i=f(l.matches[0].replace(Z,ee),K.test(u[0].type)&&ge(t.parentNode)||t))){if(u.splice(o,1),!(e=i.length&&ve(u)))return L.apply(n,i),n;break}}}return(p||s(e,d))(i,t,!g,n,!t||K.test(e)&&ge(t.parentNode)||t),n},n.sortStable=b.split("").sort(D).join("")===b,n.detectDuplicates=!!f,p(),n.sortDetached=ue(function(e){return 1&e.compareDocumentPosition(d.createElement("fieldset"))}),ue(function(e){return e.innerHTML="","#"===e.firstChild.getAttribute("href")})||le("type|href|height|width",function(e,t,n){if(!n)return e.getAttribute(t,"type"===t.toLowerCase()?1:2)}),n.attributes&&ue(function(e){return e.innerHTML="",e.firstChild.setAttribute("value",""),""===e.firstChild.getAttribute("value")})||le("value",function(e,t,n){if(!n&&"input"===e.nodeName.toLowerCase())return e.defaultValue}),ue(function(e){return null==e.getAttribute("disabled")})||le(P,function(e,t,n){var r;if(!n)return!0===e[t]?t.toLowerCase():(r=e.getAttributeNode(t))&&r.specified?r.value:null}),oe}(e);w.find=E,w.expr=E.selectors,w.expr[":"]=w.expr.pseudos,w.uniqueSort=w.unique=E.uniqueSort,w.text=E.getText,w.isXMLDoc=E.isXML,w.contains=E.contains,w.escapeSelector=E.escape;var k=function(e,t,n){var r=[],i=void 0!==n;while((e=e[t])&&9!==e.nodeType)if(1===e.nodeType){if(i&&w(e).is(n))break;r.push(e)}return r},S=function(e,t){for(var n=[];e;e=e.nextSibling)1===e.nodeType&&e!==t&&n.push(e);return n},D=w.expr.match.needsContext;function N(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()}var A=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function j(e,t,n){return g(t)?w.grep(e,function(e,r){return!!t.call(e,r,e)!==n}):t.nodeType?w.grep(e,function(e){return e===t!==n}):"string"!=typeof t?w.grep(e,function(e){return u.call(t,e)>-1!==n}):w.filter(t,e,n)}w.filter=function(e,t,n){var r=t[0];return n&&(e=":not("+e+")"),1===t.length&&1===r.nodeType?w.find.matchesSelector(r,e)?[r]:[]:w.find.matches(e,w.grep(t,function(e){return 1===e.nodeType}))},w.fn.extend({find:function(e){var t,n,r=this.length,i=this;if("string"!=typeof e)return this.pushStack(w(e).filter(function(){for(t=0;t1?w.uniqueSort(n):n},filter:function(e){return this.pushStack(j(this,e||[],!1))},not:function(e){return this.pushStack(j(this,e||[],!0))},is:function(e){return!!j(this,"string"==typeof e&&D.test(e)?w(e):e||[],!1).length}});var q,L=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/;(w.fn.init=function(e,t,n){var i,o;if(!e)return this;if(n=n||q,"string"==typeof e){if(!(i="<"===e[0]&&">"===e[e.length-1]&&e.length>=3?[null,e,null]:L.exec(e))||!i[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(i[1]){if(t=t instanceof w?t[0]:t,w.merge(this,w.parseHTML(i[1],t&&t.nodeType?t.ownerDocument||t:r,!0)),A.test(i[1])&&w.isPlainObject(t))for(i in t)g(this[i])?this[i](t[i]):this.attr(i,t[i]);return this}return(o=r.getElementById(i[2]))&&(this[0]=o,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):g(e)?void 0!==n.ready?n.ready(e):e(w):w.makeArray(e,this)}).prototype=w.fn,q=w(r);var H=/^(?:parents|prev(?:Until|All))/,O={children:!0,contents:!0,next:!0,prev:!0};w.fn.extend({has:function(e){var t=w(e,this),n=t.length;return this.filter(function(){for(var e=0;e-1:1===n.nodeType&&w.find.matchesSelector(n,e))){o.push(n);break}return this.pushStack(o.length>1?w.uniqueSort(o):o)},index:function(e){return e?"string"==typeof e?u.call(w(e),this[0]):u.call(this,e.jquery?e[0]:e):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){return this.pushStack(w.uniqueSort(w.merge(this.get(),w(e,t))))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}});function P(e,t){while((e=e[t])&&1!==e.nodeType);return e}w.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return k(e,"parentNode")},parentsUntil:function(e,t,n){return k(e,"parentNode",n)},next:function(e){return P(e,"nextSibling")},prev:function(e){return P(e,"previousSibling")},nextAll:function(e){return k(e,"nextSibling")},prevAll:function(e){return k(e,"previousSibling")},nextUntil:function(e,t,n){return k(e,"nextSibling",n)},prevUntil:function(e,t,n){return k(e,"previousSibling",n)},siblings:function(e){return S((e.parentNode||{}).firstChild,e)},children:function(e){return S(e.firstChild)},contents:function(e){return N(e,"iframe")?e.contentDocument:(N(e,"template")&&(e=e.content||e),w.merge([],e.childNodes))}},function(e,t){w.fn[e]=function(n,r){var i=w.map(this,t,n);return"Until"!==e.slice(-5)&&(r=n),r&&"string"==typeof r&&(i=w.filter(r,i)),this.length>1&&(O[e]||w.uniqueSort(i),H.test(e)&&i.reverse()),this.pushStack(i)}});var M=/[^\x20\t\r\n\f]+/g;function R(e){var t={};return w.each(e.match(M)||[],function(e,n){t[n]=!0}),t}w.Callbacks=function(e){e="string"==typeof e?R(e):w.extend({},e);var t,n,r,i,o=[],a=[],s=-1,u=function(){for(i=i||e.once,r=t=!0;a.length;s=-1){n=a.shift();while(++s-1)o.splice(n,1),n<=s&&s--}),this},has:function(e){return e?w.inArray(e,o)>-1:o.length>0},empty:function(){return o&&(o=[]),this},disable:function(){return i=a=[],o=n="",this},disabled:function(){return!o},lock:function(){return i=a=[],n||t||(o=n=""),this},locked:function(){return!!i},fireWith:function(e,n){return i||(n=[e,(n=n||[]).slice?n.slice():n],a.push(n),t||u()),this},fire:function(){return l.fireWith(this,arguments),this},fired:function(){return!!r}};return l};function I(e){return e}function W(e){throw e}function $(e,t,n,r){var i;try{e&&g(i=e.promise)?i.call(e).done(t).fail(n):e&&g(i=e.then)?i.call(e,t,n):t.apply(void 0,[e].slice(r))}catch(e){n.apply(void 0,[e])}}w.extend({Deferred:function(t){var n=[["notify","progress",w.Callbacks("memory"),w.Callbacks("memory"),2],["resolve","done",w.Callbacks("once memory"),w.Callbacks("once memory"),0,"resolved"],["reject","fail",w.Callbacks("once memory"),w.Callbacks("once memory"),1,"rejected"]],r="pending",i={state:function(){return r},always:function(){return o.done(arguments).fail(arguments),this},"catch":function(e){return i.then(null,e)},pipe:function(){var e=arguments;return w.Deferred(function(t){w.each(n,function(n,r){var i=g(e[r[4]])&&e[r[4]];o[r[1]](function(){var e=i&&i.apply(this,arguments);e&&g(e.promise)?e.promise().progress(t.notify).done(t.resolve).fail(t.reject):t[r[0]+"With"](this,i?[e]:arguments)})}),e=null}).promise()},then:function(t,r,i){var o=0;function a(t,n,r,i){return function(){var s=this,u=arguments,l=function(){var e,l;if(!(t=o&&(r!==W&&(s=void 0,u=[e]),n.rejectWith(s,u))}};t?c():(w.Deferred.getStackHook&&(c.stackTrace=w.Deferred.getStackHook()),e.setTimeout(c))}}return w.Deferred(function(e){n[0][3].add(a(0,e,g(i)?i:I,e.notifyWith)),n[1][3].add(a(0,e,g(t)?t:I)),n[2][3].add(a(0,e,g(r)?r:W))}).promise()},promise:function(e){return null!=e?w.extend(e,i):i}},o={};return w.each(n,function(e,t){var a=t[2],s=t[5];i[t[1]]=a.add,s&&a.add(function(){r=s},n[3-e][2].disable,n[3-e][3].disable,n[0][2].lock,n[0][3].lock),a.add(t[3].fire),o[t[0]]=function(){return o[t[0]+"With"](this===o?void 0:this,arguments),this},o[t[0]+"With"]=a.fireWith}),i.promise(o),t&&t.call(o,o),o},when:function(e){var t=arguments.length,n=t,r=Array(n),i=o.call(arguments),a=w.Deferred(),s=function(e){return function(n){r[e]=this,i[e]=arguments.length>1?o.call(arguments):n,--t||a.resolveWith(r,i)}};if(t<=1&&($(e,a.done(s(n)).resolve,a.reject,!t),"pending"===a.state()||g(i[n]&&i[n].then)))return a.then();while(n--)$(i[n],s(n),a.reject);return a.promise()}});var B=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;w.Deferred.exceptionHook=function(t,n){e.console&&e.console.warn&&t&&B.test(t.name)&&e.console.warn("jQuery.Deferred exception: "+t.message,t.stack,n)},w.readyException=function(t){e.setTimeout(function(){throw t})};var F=w.Deferred();w.fn.ready=function(e){return F.then(e)["catch"](function(e){w.readyException(e)}),this},w.extend({isReady:!1,readyWait:1,ready:function(e){(!0===e?--w.readyWait:w.isReady)||(w.isReady=!0,!0!==e&&--w.readyWait>0||F.resolveWith(r,[w]))}}),w.ready.then=F.then;function _(){r.removeEventListener("DOMContentLoaded",_),e.removeEventListener("load",_),w.ready()}"complete"===r.readyState||"loading"!==r.readyState&&!r.documentElement.doScroll?e.setTimeout(w.ready):(r.addEventListener("DOMContentLoaded",_),e.addEventListener("load",_));var z=function(e,t,n,r,i,o,a){var s=0,u=e.length,l=null==n;if("object"===x(n)){i=!0;for(s in n)z(e,t,s,n[s],!0,o,a)}else if(void 0!==r&&(i=!0,g(r)||(a=!0),l&&(a?(t.call(e,r),t=null):(l=t,t=function(e,t,n){return l.call(w(e),n)})),t))for(;s1,null,!0)},removeData:function(e){return this.each(function(){K.remove(this,e)})}}),w.extend({queue:function(e,t,n){var r;if(e)return t=(t||"fx")+"queue",r=J.get(e,t),n&&(!r||Array.isArray(n)?r=J.access(e,t,w.makeArray(n)):r.push(n)),r||[]},dequeue:function(e,t){t=t||"fx";var n=w.queue(e,t),r=n.length,i=n.shift(),o=w._queueHooks(e,t),a=function(){w.dequeue(e,t)};"inprogress"===i&&(i=n.shift(),r--),i&&("fx"===t&&n.unshift("inprogress"),delete o.stop,i.call(e,a,o)),!r&&o&&o.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return J.get(e,n)||J.access(e,n,{empty:w.Callbacks("once memory").add(function(){J.remove(e,[t+"queue",n])})})}}),w.fn.extend({queue:function(e,t){var n=2;return"string"!=typeof e&&(t=e,e="fx",n--),arguments.length\x20\t\r\n\f]+)/i,he=/^$|^module$|\/(?:java|ecma)script/i,ge={option:[1,""],thead:[1,"","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]};ge.optgroup=ge.option,ge.tbody=ge.tfoot=ge.colgroup=ge.caption=ge.thead,ge.th=ge.td;function ye(e,t){var n;return n="undefined"!=typeof e.getElementsByTagName?e.getElementsByTagName(t||"*"):"undefined"!=typeof e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&N(e,t)?w.merge([e],n):n}function ve(e,t){for(var n=0,r=e.length;n-1)i&&i.push(o);else if(l=w.contains(o.ownerDocument,o),a=ye(f.appendChild(o),"script"),l&&ve(a),n){c=0;while(o=a[c++])he.test(o.type||"")&&n.push(o)}return f}!function(){var e=r.createDocumentFragment().appendChild(r.createElement("div")),t=r.createElement("input");t.setAttribute("type","radio"),t.setAttribute("checked","checked"),t.setAttribute("name","t"),e.appendChild(t),h.checkClone=e.cloneNode(!0).cloneNode(!0).lastChild.checked,e.innerHTML="",h.noCloneChecked=!!e.cloneNode(!0).lastChild.defaultValue}();var be=r.documentElement,we=/^key/,Te=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,Ce=/^([^.]*)(?:\.(.+)|)/;function Ee(){return!0}function ke(){return!1}function Se(){try{return r.activeElement}catch(e){}}function De(e,t,n,r,i,o){var a,s;if("object"==typeof t){"string"!=typeof n&&(r=r||n,n=void 0);for(s in t)De(e,s,n,r,t[s],o);return e}if(null==r&&null==i?(i=n,r=n=void 0):null==i&&("string"==typeof n?(i=r,r=void 0):(i=r,r=n,n=void 0)),!1===i)i=ke;else if(!i)return e;return 1===o&&(a=i,(i=function(e){return w().off(e),a.apply(this,arguments)}).guid=a.guid||(a.guid=w.guid++)),e.each(function(){w.event.add(this,t,i,r,n)})}w.event={global:{},add:function(e,t,n,r,i){var o,a,s,u,l,c,f,p,d,h,g,y=J.get(e);if(y){n.handler&&(n=(o=n).handler,i=o.selector),i&&w.find.matchesSelector(be,i),n.guid||(n.guid=w.guid++),(u=y.events)||(u=y.events={}),(a=y.handle)||(a=y.handle=function(t){return"undefined"!=typeof w&&w.event.triggered!==t.type?w.event.dispatch.apply(e,arguments):void 0}),l=(t=(t||"").match(M)||[""]).length;while(l--)d=g=(s=Ce.exec(t[l])||[])[1],h=(s[2]||"").split(".").sort(),d&&(f=w.event.special[d]||{},d=(i?f.delegateType:f.bindType)||d,f=w.event.special[d]||{},c=w.extend({type:d,origType:g,data:r,handler:n,guid:n.guid,selector:i,needsContext:i&&w.expr.match.needsContext.test(i),namespace:h.join(".")},o),(p=u[d])||((p=u[d]=[]).delegateCount=0,f.setup&&!1!==f.setup.call(e,r,h,a)||e.addEventListener&&e.addEventListener(d,a)),f.add&&(f.add.call(e,c),c.handler.guid||(c.handler.guid=n.guid)),i?p.splice(p.delegateCount++,0,c):p.push(c),w.event.global[d]=!0)}},remove:function(e,t,n,r,i){var o,a,s,u,l,c,f,p,d,h,g,y=J.hasData(e)&&J.get(e);if(y&&(u=y.events)){l=(t=(t||"").match(M)||[""]).length;while(l--)if(s=Ce.exec(t[l])||[],d=g=s[1],h=(s[2]||"").split(".").sort(),d){f=w.event.special[d]||{},p=u[d=(r?f.delegateType:f.bindType)||d]||[],s=s[2]&&new RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"),a=o=p.length;while(o--)c=p[o],!i&&g!==c.origType||n&&n.guid!==c.guid||s&&!s.test(c.namespace)||r&&r!==c.selector&&("**"!==r||!c.selector)||(p.splice(o,1),c.selector&&p.delegateCount--,f.remove&&f.remove.call(e,c));a&&!p.length&&(f.teardown&&!1!==f.teardown.call(e,h,y.handle)||w.removeEvent(e,d,y.handle),delete u[d])}else for(d in u)w.event.remove(e,d+t[l],n,r,!0);w.isEmptyObject(u)&&J.remove(e,"handle events")}},dispatch:function(e){var t=w.event.fix(e),n,r,i,o,a,s,u=new Array(arguments.length),l=(J.get(this,"events")||{})[t.type]||[],c=w.event.special[t.type]||{};for(u[0]=t,n=1;n=1))for(;l!==this;l=l.parentNode||this)if(1===l.nodeType&&("click"!==e.type||!0!==l.disabled)){for(o=[],a={},n=0;n-1:w.find(i,this,null,[l]).length),a[i]&&o.push(r);o.length&&s.push({elem:l,handlers:o})}return l=this,u\x20\t\r\n\f]*)[^>]*)\/>/gi,Ae=/\s*$/g;function Le(e,t){return N(e,"table")&&N(11!==t.nodeType?t:t.firstChild,"tr")?w(e).children("tbody")[0]||e:e}function He(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function Oe(e){return"true/"===(e.type||"").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute("type"),e}function Pe(e,t){var n,r,i,o,a,s,u,l;if(1===t.nodeType){if(J.hasData(e)&&(o=J.access(e),a=J.set(t,o),l=o.events)){delete a.handle,a.events={};for(i in l)for(n=0,r=l[i].length;n1&&"string"==typeof y&&!h.checkClone&&je.test(y))return e.each(function(i){var o=e.eq(i);v&&(t[0]=y.call(this,i,o.html())),Re(o,t,n,r)});if(p&&(i=xe(t,e[0].ownerDocument,!1,e,r),o=i.firstChild,1===i.childNodes.length&&(i=o),o||r)){for(u=(s=w.map(ye(i,"script"),He)).length;f")},clone:function(e,t,n){var r,i,o,a,s=e.cloneNode(!0),u=w.contains(e.ownerDocument,e);if(!(h.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||w.isXMLDoc(e)))for(a=ye(s),r=0,i=(o=ye(e)).length;r0&&ve(a,!u&&ye(e,"script")),s},cleanData:function(e){for(var t,n,r,i=w.event.special,o=0;void 0!==(n=e[o]);o++)if(Y(n)){if(t=n[J.expando]){if(t.events)for(r in t.events)i[r]?w.event.remove(n,r):w.removeEvent(n,r,t.handle);n[J.expando]=void 0}n[K.expando]&&(n[K.expando]=void 0)}}}),w.fn.extend({detach:function(e){return Ie(this,e,!0)},remove:function(e){return Ie(this,e)},text:function(e){return z(this,function(e){return void 0===e?w.text(this):this.empty().each(function(){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||(this.textContent=e)})},null,e,arguments.length)},append:function(){return Re(this,arguments,function(e){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||Le(this,e).appendChild(e)})},prepend:function(){return Re(this,arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=Le(this,e);t.insertBefore(e,t.firstChild)}})},before:function(){return Re(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return Re(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},empty:function(){for(var e,t=0;null!=(e=this[t]);t++)1===e.nodeType&&(w.cleanData(ye(e,!1)),e.textContent="");return this},clone:function(e,t){return e=null!=e&&e,t=null==t?e:t,this.map(function(){return w.clone(this,e,t)})},html:function(e){return z(this,function(e){var t=this[0]||{},n=0,r=this.length;if(void 0===e&&1===t.nodeType)return t.innerHTML;if("string"==typeof e&&!Ae.test(e)&&!ge[(de.exec(e)||["",""])[1].toLowerCase()]){e=w.htmlPrefilter(e);try{for(;n=0&&(u+=Math.max(0,Math.ceil(e["offset"+t[0].toUpperCase()+t.slice(1)]-o-u-s-.5))),u}function et(e,t,n){var r=$e(e),i=Fe(e,t,r),o="border-box"===w.css(e,"boxSizing",!1,r),a=o;if(We.test(i)){if(!n)return i;i="auto"}return a=a&&(h.boxSizingReliable()||i===e.style[t]),("auto"===i||!parseFloat(i)&&"inline"===w.css(e,"display",!1,r))&&(i=e["offset"+t[0].toUpperCase()+t.slice(1)],a=!0),(i=parseFloat(i)||0)+Ze(e,t,n||(o?"border":"content"),a,r,i)+"px"}w.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=Fe(e,"opacity");return""===n?"1":n}}}},cssNumber:{animationIterationCount:!0,columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{},style:function(e,t,n,r){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var i,o,a,s=G(t),u=Xe.test(t),l=e.style;if(u||(t=Je(s)),a=w.cssHooks[t]||w.cssHooks[s],void 0===n)return a&&"get"in a&&void 0!==(i=a.get(e,!1,r))?i:l[t];"string"==(o=typeof n)&&(i=ie.exec(n))&&i[1]&&(n=ue(e,t,i),o="number"),null!=n&&n===n&&("number"===o&&(n+=i&&i[3]||(w.cssNumber[s]?"":"px")),h.clearCloneStyle||""!==n||0!==t.indexOf("background")||(l[t]="inherit"),a&&"set"in a&&void 0===(n=a.set(e,n,r))||(u?l.setProperty(t,n):l[t]=n))}},css:function(e,t,n,r){var i,o,a,s=G(t);return Xe.test(t)||(t=Je(s)),(a=w.cssHooks[t]||w.cssHooks[s])&&"get"in a&&(i=a.get(e,!0,n)),void 0===i&&(i=Fe(e,t,r)),"normal"===i&&t in Ve&&(i=Ve[t]),""===n||n?(o=parseFloat(i),!0===n||isFinite(o)?o||0:i):i}}),w.each(["height","width"],function(e,t){w.cssHooks[t]={get:function(e,n,r){if(n)return!ze.test(w.css(e,"display"))||e.getClientRects().length&&e.getBoundingClientRect().width?et(e,t,r):se(e,Ue,function(){return et(e,t,r)})},set:function(e,n,r){var i,o=$e(e),a="border-box"===w.css(e,"boxSizing",!1,o),s=r&&Ze(e,t,r,a,o);return a&&h.scrollboxSize()===o.position&&(s-=Math.ceil(e["offset"+t[0].toUpperCase()+t.slice(1)]-parseFloat(o[t])-Ze(e,t,"border",!1,o)-.5)),s&&(i=ie.exec(n))&&"px"!==(i[3]||"px")&&(e.style[t]=n,n=w.css(e,t)),Ke(e,n,s)}}}),w.cssHooks.marginLeft=_e(h.reliableMarginLeft,function(e,t){if(t)return(parseFloat(Fe(e,"marginLeft"))||e.getBoundingClientRect().left-se(e,{marginLeft:0},function(){return e.getBoundingClientRect().left}))+"px"}),w.each({margin:"",padding:"",border:"Width"},function(e,t){w.cssHooks[e+t]={expand:function(n){for(var r=0,i={},o="string"==typeof n?n.split(" "):[n];r<4;r++)i[e+oe[r]+t]=o[r]||o[r-2]||o[0];return i}},"margin"!==e&&(w.cssHooks[e+t].set=Ke)}),w.fn.extend({css:function(e,t){return z(this,function(e,t,n){var r,i,o={},a=0;if(Array.isArray(t)){for(r=$e(e),i=t.length;a1)}});function tt(e,t,n,r,i){return new tt.prototype.init(e,t,n,r,i)}w.Tween=tt,tt.prototype={constructor:tt,init:function(e,t,n,r,i,o){this.elem=e,this.prop=n,this.easing=i||w.easing._default,this.options=t,this.start=this.now=this.cur(),this.end=r,this.unit=o||(w.cssNumber[n]?"":"px")},cur:function(){var e=tt.propHooks[this.prop];return e&&e.get?e.get(this):tt.propHooks._default.get(this)},run:function(e){var t,n=tt.propHooks[this.prop];return this.options.duration?this.pos=t=w.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):this.pos=t=e,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):tt.propHooks._default.set(this),this}},tt.prototype.init.prototype=tt.prototype,tt.propHooks={_default:{get:function(e){var t;return 1!==e.elem.nodeType||null!=e.elem[e.prop]&&null==e.elem.style[e.prop]?e.elem[e.prop]:(t=w.css(e.elem,e.prop,""))&&"auto"!==t?t:0},set:function(e){w.fx.step[e.prop]?w.fx.step[e.prop](e):1!==e.elem.nodeType||null==e.elem.style[w.cssProps[e.prop]]&&!w.cssHooks[e.prop]?e.elem[e.prop]=e.now:w.style(e.elem,e.prop,e.now+e.unit)}}},tt.propHooks.scrollTop=tt.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},w.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2},_default:"swing"},w.fx=tt.prototype.init,w.fx.step={};var nt,rt,it=/^(?:toggle|show|hide)$/,ot=/queueHooks$/;function at(){rt&&(!1===r.hidden&&e.requestAnimationFrame?e.requestAnimationFrame(at):e.setTimeout(at,w.fx.interval),w.fx.tick())}function st(){return e.setTimeout(function(){nt=void 0}),nt=Date.now()}function ut(e,t){var n,r=0,i={height:e};for(t=t?1:0;r<4;r+=2-t)i["margin"+(n=oe[r])]=i["padding"+n]=e;return t&&(i.opacity=i.width=e),i}function lt(e,t,n){for(var r,i=(pt.tweeners[t]||[]).concat(pt.tweeners["*"]),o=0,a=i.length;o1)},removeAttr:function(e){return this.each(function(){w.removeAttr(this,e)})}}),w.extend({attr:function(e,t,n){var r,i,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return"undefined"==typeof e.getAttribute?w.prop(e,t,n):(1===o&&w.isXMLDoc(e)||(i=w.attrHooks[t.toLowerCase()]||(w.expr.match.bool.test(t)?dt:void 0)),void 0!==n?null===n?void w.removeAttr(e,t):i&&"set"in i&&void 0!==(r=i.set(e,n,t))?r:(e.setAttribute(t,n+""),n):i&&"get"in i&&null!==(r=i.get(e,t))?r:null==(r=w.find.attr(e,t))?void 0:r)},attrHooks:{type:{set:function(e,t){if(!h.radioValue&&"radio"===t&&N(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}}},removeAttr:function(e,t){var n,r=0,i=t&&t.match(M);if(i&&1===e.nodeType)while(n=i[r++])e.removeAttribute(n)}}),dt={set:function(e,t,n){return!1===t?w.removeAttr(e,n):e.setAttribute(n,n),n}},w.each(w.expr.match.bool.source.match(/\w+/g),function(e,t){var n=ht[t]||w.find.attr;ht[t]=function(e,t,r){var i,o,a=t.toLowerCase();return r||(o=ht[a],ht[a]=i,i=null!=n(e,t,r)?a:null,ht[a]=o),i}});var gt=/^(?:input|select|textarea|button)$/i,yt=/^(?:a|area)$/i;w.fn.extend({prop:function(e,t){return z(this,w.prop,e,t,arguments.length>1)},removeProp:function(e){return this.each(function(){delete this[w.propFix[e]||e]})}}),w.extend({prop:function(e,t,n){var r,i,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return 1===o&&w.isXMLDoc(e)||(t=w.propFix[t]||t,i=w.propHooks[t]),void 0!==n?i&&"set"in i&&void 0!==(r=i.set(e,n,t))?r:e[t]=n:i&&"get"in i&&null!==(r=i.get(e,t))?r:e[t]},propHooks:{tabIndex:{get:function(e){var t=w.find.attr(e,"tabindex");return t?parseInt(t,10):gt.test(e.nodeName)||yt.test(e.nodeName)&&e.href?0:-1}}},propFix:{"for":"htmlFor","class":"className"}}),h.optSelected||(w.propHooks.selected={get:function(e){var t=e.parentNode;return t&&t.parentNode&&t.parentNode.selectedIndex,null},set:function(e){var t=e.parentNode;t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex)}}),w.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){w.propFix[this.toLowerCase()]=this});function vt(e){return(e.match(M)||[]).join(" ")}function mt(e){return e.getAttribute&&e.getAttribute("class")||""}function xt(e){return Array.isArray(e)?e:"string"==typeof e?e.match(M)||[]:[]}w.fn.extend({addClass:function(e){var t,n,r,i,o,a,s,u=0;if(g(e))return this.each(function(t){w(this).addClass(e.call(this,t,mt(this)))});if((t=xt(e)).length)while(n=this[u++])if(i=mt(n),r=1===n.nodeType&&" "+vt(i)+" "){a=0;while(o=t[a++])r.indexOf(" "+o+" ")<0&&(r+=o+" ");i!==(s=vt(r))&&n.setAttribute("class",s)}return this},removeClass:function(e){var t,n,r,i,o,a,s,u=0;if(g(e))return this.each(function(t){w(this).removeClass(e.call(this,t,mt(this)))});if(!arguments.length)return this.attr("class","");if((t=xt(e)).length)while(n=this[u++])if(i=mt(n),r=1===n.nodeType&&" "+vt(i)+" "){a=0;while(o=t[a++])while(r.indexOf(" "+o+" ")>-1)r=r.replace(" "+o+" "," ");i!==(s=vt(r))&&n.setAttribute("class",s)}return this},toggleClass:function(e,t){var n=typeof e,r="string"===n||Array.isArray(e);return"boolean"==typeof t&&r?t?this.addClass(e):this.removeClass(e):g(e)?this.each(function(n){w(this).toggleClass(e.call(this,n,mt(this),t),t)}):this.each(function(){var t,i,o,a;if(r){i=0,o=w(this),a=xt(e);while(t=a[i++])o.hasClass(t)?o.removeClass(t):o.addClass(t)}else void 0!==e&&"boolean"!==n||((t=mt(this))&&J.set(this,"__className__",t),this.setAttribute&&this.setAttribute("class",t||!1===e?"":J.get(this,"__className__")||""))})},hasClass:function(e){var t,n,r=0;t=" "+e+" ";while(n=this[r++])if(1===n.nodeType&&(" "+vt(mt(n))+" ").indexOf(t)>-1)return!0;return!1}});var bt=/\r/g;w.fn.extend({val:function(e){var t,n,r,i=this[0];{if(arguments.length)return r=g(e),this.each(function(n){var i;1===this.nodeType&&(null==(i=r?e.call(this,n,w(this).val()):e)?i="":"number"==typeof i?i+="":Array.isArray(i)&&(i=w.map(i,function(e){return null==e?"":e+""})),(t=w.valHooks[this.type]||w.valHooks[this.nodeName.toLowerCase()])&&"set"in t&&void 0!==t.set(this,i,"value")||(this.value=i))});if(i)return(t=w.valHooks[i.type]||w.valHooks[i.nodeName.toLowerCase()])&&"get"in t&&void 0!==(n=t.get(i,"value"))?n:"string"==typeof(n=i.value)?n.replace(bt,""):null==n?"":n}}}),w.extend({valHooks:{option:{get:function(e){var t=w.find.attr(e,"value");return null!=t?t:vt(w.text(e))}},select:{get:function(e){var t,n,r,i=e.options,o=e.selectedIndex,a="select-one"===e.type,s=a?null:[],u=a?o+1:i.length;for(r=o<0?u:a?o:0;r-1)&&(n=!0);return n||(e.selectedIndex=-1),o}}}}),w.each(["radio","checkbox"],function(){w.valHooks[this]={set:function(e,t){if(Array.isArray(t))return e.checked=w.inArray(w(e).val(),t)>-1}},h.checkOn||(w.valHooks[this].get=function(e){return null===e.getAttribute("value")?"on":e.value})}),h.focusin="onfocusin"in e;var wt=/^(?:focusinfocus|focusoutblur)$/,Tt=function(e){e.stopPropagation()};w.extend(w.event,{trigger:function(t,n,i,o){var a,s,u,l,c,p,d,h,v=[i||r],m=f.call(t,"type")?t.type:t,x=f.call(t,"namespace")?t.namespace.split("."):[];if(s=h=u=i=i||r,3!==i.nodeType&&8!==i.nodeType&&!wt.test(m+w.event.triggered)&&(m.indexOf(".")>-1&&(m=(x=m.split(".")).shift(),x.sort()),c=m.indexOf(":")<0&&"on"+m,t=t[w.expando]?t:new w.Event(m,"object"==typeof t&&t),t.isTrigger=o?2:3,t.namespace=x.join("."),t.rnamespace=t.namespace?new RegExp("(^|\\.)"+x.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,t.result=void 0,t.target||(t.target=i),n=null==n?[t]:w.makeArray(n,[t]),d=w.event.special[m]||{},o||!d.trigger||!1!==d.trigger.apply(i,n))){if(!o&&!d.noBubble&&!y(i)){for(l=d.delegateType||m,wt.test(l+m)||(s=s.parentNode);s;s=s.parentNode)v.push(s),u=s;u===(i.ownerDocument||r)&&v.push(u.defaultView||u.parentWindow||e)}a=0;while((s=v[a++])&&!t.isPropagationStopped())h=s,t.type=a>1?l:d.bindType||m,(p=(J.get(s,"events")||{})[t.type]&&J.get(s,"handle"))&&p.apply(s,n),(p=c&&s[c])&&p.apply&&Y(s)&&(t.result=p.apply(s,n),!1===t.result&&t.preventDefault());return t.type=m,o||t.isDefaultPrevented()||d._default&&!1!==d._default.apply(v.pop(),n)||!Y(i)||c&&g(i[m])&&!y(i)&&((u=i[c])&&(i[c]=null),w.event.triggered=m,t.isPropagationStopped()&&h.addEventListener(m,Tt),i[m](),t.isPropagationStopped()&&h.removeEventListener(m,Tt),w.event.triggered=void 0,u&&(i[c]=u)),t.result}},simulate:function(e,t,n){var r=w.extend(new w.Event,n,{type:e,isSimulated:!0});w.event.trigger(r,null,t)}}),w.fn.extend({trigger:function(e,t){return this.each(function(){w.event.trigger(e,t,this)})},triggerHandler:function(e,t){var n=this[0];if(n)return w.event.trigger(e,t,n,!0)}}),h.focusin||w.each({focus:"focusin",blur:"focusout"},function(e,t){var n=function(e){w.event.simulate(t,e.target,w.event.fix(e))};w.event.special[t]={setup:function(){var r=this.ownerDocument||this,i=J.access(r,t);i||r.addEventListener(e,n,!0),J.access(r,t,(i||0)+1)},teardown:function(){var r=this.ownerDocument||this,i=J.access(r,t)-1;i?J.access(r,t,i):(r.removeEventListener(e,n,!0),J.remove(r,t))}}});var Ct=e.location,Et=Date.now(),kt=/\?/;w.parseXML=function(t){var n;if(!t||"string"!=typeof t)return null;try{n=(new e.DOMParser).parseFromString(t,"text/xml")}catch(e){n=void 0}return n&&!n.getElementsByTagName("parsererror").length||w.error("Invalid XML: "+t),n};var St=/\[\]$/,Dt=/\r?\n/g,Nt=/^(?:submit|button|image|reset|file)$/i,At=/^(?:input|select|textarea|keygen)/i;function jt(e,t,n,r){var i;if(Array.isArray(t))w.each(t,function(t,i){n||St.test(e)?r(e,i):jt(e+"["+("object"==typeof i&&null!=i?t:"")+"]",i,n,r)});else if(n||"object"!==x(t))r(e,t);else for(i in t)jt(e+"["+i+"]",t[i],n,r)}w.param=function(e,t){var n,r=[],i=function(e,t){var n=g(t)?t():t;r[r.length]=encodeURIComponent(e)+"="+encodeURIComponent(null==n?"":n)};if(Array.isArray(e)||e.jquery&&!w.isPlainObject(e))w.each(e,function(){i(this.name,this.value)});else for(n in e)jt(n,e[n],t,i);return r.join("&")},w.fn.extend({serialize:function(){return w.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var e=w.prop(this,"elements");return e?w.makeArray(e):this}).filter(function(){var e=this.type;return this.name&&!w(this).is(":disabled")&&At.test(this.nodeName)&&!Nt.test(e)&&(this.checked||!pe.test(e))}).map(function(e,t){var n=w(this).val();return null==n?null:Array.isArray(n)?w.map(n,function(e){return{name:t.name,value:e.replace(Dt,"\r\n")}}):{name:t.name,value:n.replace(Dt,"\r\n")}}).get()}});var qt=/%20/g,Lt=/#.*$/,Ht=/([?&])_=[^&]*/,Ot=/^(.*?):[ \t]*([^\r\n]*)$/gm,Pt=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Mt=/^(?:GET|HEAD)$/,Rt=/^\/\//,It={},Wt={},$t="*/".concat("*"),Bt=r.createElement("a");Bt.href=Ct.href;function Ft(e){return function(t,n){"string"!=typeof t&&(n=t,t="*");var r,i=0,o=t.toLowerCase().match(M)||[];if(g(n))while(r=o[i++])"+"===r[0]?(r=r.slice(1)||"*",(e[r]=e[r]||[]).unshift(n)):(e[r]=e[r]||[]).push(n)}}function _t(e,t,n,r){var i={},o=e===Wt;function a(s){var u;return i[s]=!0,w.each(e[s]||[],function(e,s){var l=s(t,n,r);return"string"!=typeof l||o||i[l]?o?!(u=l):void 0:(t.dataTypes.unshift(l),a(l),!1)}),u}return a(t.dataTypes[0])||!i["*"]&&a("*")}function zt(e,t){var n,r,i=w.ajaxSettings.flatOptions||{};for(n in t)void 0!==t[n]&&((i[n]?e:r||(r={}))[n]=t[n]);return r&&w.extend(!0,e,r),e}function Xt(e,t,n){var r,i,o,a,s=e.contents,u=e.dataTypes;while("*"===u[0])u.shift(),void 0===r&&(r=e.mimeType||t.getResponseHeader("Content-Type"));if(r)for(i in s)if(s[i]&&s[i].test(r)){u.unshift(i);break}if(u[0]in n)o=u[0];else{for(i in n){if(!u[0]||e.converters[i+" "+u[0]]){o=i;break}a||(a=i)}o=o||a}if(o)return o!==u[0]&&u.unshift(o),n[o]}function Ut(e,t,n,r){var i,o,a,s,u,l={},c=e.dataTypes.slice();if(c[1])for(a in e.converters)l[a.toLowerCase()]=e.converters[a];o=c.shift();while(o)if(e.responseFields[o]&&(n[e.responseFields[o]]=t),!u&&r&&e.dataFilter&&(t=e.dataFilter(t,e.dataType)),u=o,o=c.shift())if("*"===o)o=u;else if("*"!==u&&u!==o){if(!(a=l[u+" "+o]||l["* "+o]))for(i in l)if((s=i.split(" "))[1]===o&&(a=l[u+" "+s[0]]||l["* "+s[0]])){!0===a?a=l[i]:!0!==l[i]&&(o=s[0],c.unshift(s[1]));break}if(!0!==a)if(a&&e["throws"])t=a(t);else try{t=a(t)}catch(e){return{state:"parsererror",error:a?e:"No conversion from "+u+" to "+o}}}return{state:"success",data:t}}w.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:Ct.href,type:"GET",isLocal:Pt.test(Ct.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":$t,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":JSON.parse,"text xml":w.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,t){return t?zt(zt(e,w.ajaxSettings),t):zt(w.ajaxSettings,e)},ajaxPrefilter:Ft(It),ajaxTransport:Ft(Wt),ajax:function(t,n){"object"==typeof t&&(n=t,t=void 0),n=n||{};var i,o,a,s,u,l,c,f,p,d,h=w.ajaxSetup({},n),g=h.context||h,y=h.context&&(g.nodeType||g.jquery)?w(g):w.event,v=w.Deferred(),m=w.Callbacks("once memory"),x=h.statusCode||{},b={},T={},C="canceled",E={readyState:0,getResponseHeader:function(e){var t;if(c){if(!s){s={};while(t=Ot.exec(a))s[t[1].toLowerCase()]=t[2]}t=s[e.toLowerCase()]}return null==t?null:t},getAllResponseHeaders:function(){return c?a:null},setRequestHeader:function(e,t){return null==c&&(e=T[e.toLowerCase()]=T[e.toLowerCase()]||e,b[e]=t),this},overrideMimeType:function(e){return null==c&&(h.mimeType=e),this},statusCode:function(e){var t;if(e)if(c)E.always(e[E.status]);else for(t in e)x[t]=[x[t],e[t]];return this},abort:function(e){var t=e||C;return i&&i.abort(t),k(0,t),this}};if(v.promise(E),h.url=((t||h.url||Ct.href)+"").replace(Rt,Ct.protocol+"//"),h.type=n.method||n.type||h.method||h.type,h.dataTypes=(h.dataType||"*").toLowerCase().match(M)||[""],null==h.crossDomain){l=r.createElement("a");try{l.href=h.url,l.href=l.href,h.crossDomain=Bt.protocol+"//"+Bt.host!=l.protocol+"//"+l.host}catch(e){h.crossDomain=!0}}if(h.data&&h.processData&&"string"!=typeof h.data&&(h.data=w.param(h.data,h.traditional)),_t(It,h,n,E),c)return E;(f=w.event&&h.global)&&0==w.active++&&w.event.trigger("ajaxStart"),h.type=h.type.toUpperCase(),h.hasContent=!Mt.test(h.type),o=h.url.replace(Lt,""),h.hasContent?h.data&&h.processData&&0===(h.contentType||"").indexOf("application/x-www-form-urlencoded")&&(h.data=h.data.replace(qt,"+")):(d=h.url.slice(o.length),h.data&&(h.processData||"string"==typeof h.data)&&(o+=(kt.test(o)?"&":"?")+h.data,delete h.data),!1===h.cache&&(o=o.replace(Ht,"$1"),d=(kt.test(o)?"&":"?")+"_="+Et+++d),h.url=o+d),h.ifModified&&(w.lastModified[o]&&E.setRequestHeader("If-Modified-Since",w.lastModified[o]),w.etag[o]&&E.setRequestHeader("If-None-Match",w.etag[o])),(h.data&&h.hasContent&&!1!==h.contentType||n.contentType)&&E.setRequestHeader("Content-Type",h.contentType),E.setRequestHeader("Accept",h.dataTypes[0]&&h.accepts[h.dataTypes[0]]?h.accepts[h.dataTypes[0]]+("*"!==h.dataTypes[0]?", "+$t+"; q=0.01":""):h.accepts["*"]);for(p in h.headers)E.setRequestHeader(p,h.headers[p]);if(h.beforeSend&&(!1===h.beforeSend.call(g,E,h)||c))return E.abort();if(C="abort",m.add(h.complete),E.done(h.success),E.fail(h.error),i=_t(Wt,h,n,E)){if(E.readyState=1,f&&y.trigger("ajaxSend",[E,h]),c)return E;h.async&&h.timeout>0&&(u=e.setTimeout(function(){E.abort("timeout")},h.timeout));try{c=!1,i.send(b,k)}catch(e){if(c)throw e;k(-1,e)}}else k(-1,"No Transport");function k(t,n,r,s){var l,p,d,b,T,C=n;c||(c=!0,u&&e.clearTimeout(u),i=void 0,a=s||"",E.readyState=t>0?4:0,l=t>=200&&t<300||304===t,r&&(b=Xt(h,E,r)),b=Ut(h,b,E,l),l?(h.ifModified&&((T=E.getResponseHeader("Last-Modified"))&&(w.lastModified[o]=T),(T=E.getResponseHeader("etag"))&&(w.etag[o]=T)),204===t||"HEAD"===h.type?C="nocontent":304===t?C="notmodified":(C=b.state,p=b.data,l=!(d=b.error))):(d=C,!t&&C||(C="error",t<0&&(t=0))),E.status=t,E.statusText=(n||C)+"",l?v.resolveWith(g,[p,C,E]):v.rejectWith(g,[E,C,d]),E.statusCode(x),x=void 0,f&&y.trigger(l?"ajaxSuccess":"ajaxError",[E,h,l?p:d]),m.fireWith(g,[E,C]),f&&(y.trigger("ajaxComplete",[E,h]),--w.active||w.event.trigger("ajaxStop")))}return E},getJSON:function(e,t,n){return w.get(e,t,n,"json")},getScript:function(e,t){return w.get(e,void 0,t,"script")}}),w.each(["get","post"],function(e,t){w[t]=function(e,n,r,i){return g(n)&&(i=i||r,r=n,n=void 0),w.ajax(w.extend({url:e,type:t,dataType:i,data:n,success:r},w.isPlainObject(e)&&e))}}),w._evalUrl=function(e){return w.ajax({url:e,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,"throws":!0})},w.fn.extend({wrapAll:function(e){var t;return this[0]&&(g(e)&&(e=e.call(this[0])),t=w(e,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){var e=this;while(e.firstElementChild)e=e.firstElementChild;return e}).append(this)),this},wrapInner:function(e){return g(e)?this.each(function(t){w(this).wrapInner(e.call(this,t))}):this.each(function(){var t=w(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t=g(e);return this.each(function(n){w(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(e){return this.parent(e).not("body").each(function(){w(this).replaceWith(this.childNodes)}),this}}),w.expr.pseudos.hidden=function(e){return!w.expr.pseudos.visible(e)},w.expr.pseudos.visible=function(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)},w.ajaxSettings.xhr=function(){try{return new e.XMLHttpRequest}catch(e){}};var Vt={0:200,1223:204},Gt=w.ajaxSettings.xhr();h.cors=!!Gt&&"withCredentials"in Gt,h.ajax=Gt=!!Gt,w.ajaxTransport(function(t){var n,r;if(h.cors||Gt&&!t.crossDomain)return{send:function(i,o){var a,s=t.xhr();if(s.open(t.type,t.url,t.async,t.username,t.password),t.xhrFields)for(a in t.xhrFields)s[a]=t.xhrFields[a];t.mimeType&&s.overrideMimeType&&s.overrideMimeType(t.mimeType),t.crossDomain||i["X-Requested-With"]||(i["X-Requested-With"]="XMLHttpRequest");for(a in i)s.setRequestHeader(a,i[a]);n=function(e){return function(){n&&(n=r=s.onload=s.onerror=s.onabort=s.ontimeout=s.onreadystatechange=null,"abort"===e?s.abort():"error"===e?"number"!=typeof s.status?o(0,"error"):o(s.status,s.statusText):o(Vt[s.status]||s.status,s.statusText,"text"!==(s.responseType||"text")||"string"!=typeof s.responseText?{binary:s.response}:{text:s.responseText},s.getAllResponseHeaders()))}},s.onload=n(),r=s.onerror=s.ontimeout=n("error"),void 0!==s.onabort?s.onabort=r:s.onreadystatechange=function(){4===s.readyState&&e.setTimeout(function(){n&&r()})},n=n("abort");try{s.send(t.hasContent&&t.data||null)}catch(e){if(n)throw e}},abort:function(){n&&n()}}}),w.ajaxPrefilter(function(e){e.crossDomain&&(e.contents.script=!1)}),w.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/\b(?:java|ecma)script\b/},converters:{"text script":function(e){return w.globalEval(e),e}}}),w.ajaxPrefilter("script",function(e){void 0===e.cache&&(e.cache=!1),e.crossDomain&&(e.type="GET")}),w.ajaxTransport("script",function(e){if(e.crossDomain){var t,n;return{send:function(i,o){t=w("