Граф коммитов

9785 Коммитов

Автор SHA1 Сообщение Дата
kazu b16f9112ed Fix arguments order of IO#pwrite
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58241 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-03 12:30:04 +00:00
nobu 8109114b18 Add IO#pread and IO#pwrite methods
These methods are useful for safe/concurrent file I/O in
multi-thread/process environments and also fairly standard
nowadays especially in systems supporting pthreads.

Based on patches by Avseyev <sergey.avseyev@gmail.com> at
[ruby-core:79290].  [Feature #4532]

* configure.in: check for pwrite(2).  pread() is already used
  internally for IO.copy_stream.

* io.c: implement wrappers for pread(2) and pwrite(2) and expose
  them in IO.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58240 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-03 00:10:50 +00:00
normal 42166c6266 test/ruby/test_optimization.rb: quiet warnings
This quiets an old "assigned but unused variable" warning left
over after r56653 as well as two new "ambiguous first argment"
warnings introduced in r58233.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58234 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-01 22:18:25 +00:00
normal 120976b9f9 compile.c: optimize literal String range in case/when dispatch
This is similar in spirit to opt_case_dispatch as the literal
Range here is guaranteed to be immutable when used for
checkmatch.

Normal range literals with non-frozen strings are actually
mutable, as Range#begin and Range#end exposes the strings to
modification.  So those Range objects cannot be frozen without
breaking compatibility, but Ranges in case/when dispatch can be
frozen at compile time.

* compile.c (iseq_peephole_optimize): persistent Range creation
  when String literals are used as beginning and end of range
  when used for case/when dispatch.
  [ruby-core:80290] [Feature #13355]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58233 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-01 21:38:25 +00:00
nobu f57d515d69 array.c: Array#append and Array#prepend
* array.c (Init_Array): Add alias "append" to Array#push, and
  "prepend" to Array#unshift.  [Feature #12746] [Fix GH-1574]

Author:    pascbjumper2 <stowers.joshua@live.com>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58227 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-01 07:38:12 +00:00
nobu 85f3636e98 test_minitest_unit.rb: assert_triggered
* test/minitest/test_minitest_unit.rb (assert_triggered): rename
  to be hidden in backtraces.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58209 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-29 09:47:40 +00:00
nobu 205ae26727 test_symbol.rb: switch to assert_not_equal
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58204 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-29 03:00:50 +00:00
normal 149d43d4ad test/ruby/test_symbol.rb: new test for nondeterminism
We need to ensure hashes for static symbols remain
non-deterministic to avoid DoS attacks.   This is currently the
case since 2.4+, but was not for the 2.3 series.

* test/ruby/test_symbol.rb (test_hash_nondeterministic): new test
  [ruby-core:80430] [Bug #13376]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58200 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-28 17:14:49 +00:00
nobu a20715c8ed ostruct.rb: refine visibility failure message
* lib/ostruct.rb (method_missing): raise an exception with proper
  visibility message.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-28 09:21:58 +00:00
nobu 4756365503 dir.c: err at glob failure
* dir.c (glob_helper): raise a SystemCallError exception when
  opendir() failed, except for ENOENT, ENOTDIR, and EACCES.  this
  behavior predates 1.0; the comments in glob.c claimed that
  glob() returned -1 on error but actualy the pointer to a global
  variable, then dir_glob() did check only -1 as the comments, and
  ignored actual errors.  [ruby-core:80226] [Bug #13276]

dir.c: ruby_glob_funcs_t

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-27 14:57:08 +00:00
normal 669a55dfed fix redefinition optimization for -"literal string" (UMinus)
Unfortunately this enlarges insns.def by yet another
instruction.  However, it is much prettier than opt_str_freeze
in use, and maybe we can avoid having so many instructions in
the future.

[ruby-core:80368]

* insns.def (DEFINE_INSN): new instruction: opt_str_uminus (maybe temporary)
* compile.c (iseq_compile_each0): split instructions
* test/ruby/test_optimization.rb (test_string_uminus): new test
* vm.c (vm_init_redefined_flag): set redefinintion flag for uminus
* vm_core.h (enum ruby_basic_operators): add BOP_UMINUS

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58144 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-27 06:12:37 +00:00
nobu cb64ef240b parse.y: unterminated content token
* parse.y (parser_parse_string): defer the end token to next
  reading, to yield tSTRING_CONTENT with the unterminated content.
  [Bug #13363]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58138 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-26 07:13:43 +00:00
nobu 217f599a1e class.c: prohibit refinement module
* class.c (ensure_includable): cannot include refinement
  module, or the type and the class do not match.
  [ruby-core:79632] [Bug #13236]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58083 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-25 03:23:43 +00:00
nobu e5600caf2c keep line number after unterminated string literal
* parse.y (parser_parse_string): keep line number even after an
  unterminated string literal.  it does not matter in the parser,
  ripper needs this value after this error.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58080 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-25 01:07:35 +00:00
nobu cd911b9367 ostruct.rb: fix OpenStruct.allocate
* lib/ostruct.rb (OpenStruct.allocate): initialize an instance
  variable directly, without calling `intialize` method which may
  be overridden in a subclass.  [ruby-core:80292] [Bug #13358]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58077 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-24 12:16:54 +00:00
nobu c8d66b5d82 stringio.c: check range
* ext/stringio/stringio.c (strio_ungetc): raise RangeError instead
  of TypeError at too big value, as well as IO#ungetc.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58041 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-21 03:15:57 +00:00
nobu 853ab8662f stringio.c: check character code
* ext/stringio/stringio.c (strio_ungetc): check if the character
  code is valid in the encoding.  reported by Ahmad Sherif
  (ahmadsherif) at https://hackerone.com/reports/209593.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58040 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-21 03:15:56 +00:00
nobu 976becf7eb vm_args.c: arity check of lambda
* vm_eval.c (rb_yield_lambda): new function which yields an array
  to a proc and splat to a lambda.  mainly for Enumerable only.

* vm_args.c (setup_parameters_complex): remove special lambda
  splatting for [Bug #9605].  [ruby-core:77065] [Bug #12705]

* vm_insnhelper.c (vm_callee_setup_block_arg): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58019 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-19 01:11:12 +00:00
nobu a9d575e507 test_lambda.rb: remove duplcate tests
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58018 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-18 15:58:13 +00:00
nobu 1de013b3da test_lambda.rb: refine test
* test/ruby/test_lambda.rb (test_lambda_as_iterator): refine a
  test for the intention of the original report.
  [ruby-core:61340] [Bug #9605]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58016 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-18 15:30:14 +00:00
nobu 49455d6cdc vm_args.c: pass block
* vm_args.c (refine_sym_proc_call): pass block to the method when
  using refinements.  [ruby-core:80219] [Bug #13325]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58015 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-18 14:22:15 +00:00
svn 77e1c20b8a * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57999 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-17 01:29:24 +00:00
hsbt fa59a2ea80 Merge rubygems-2.6.11
This version fixed regression of rubygems-2.6.10.
  https://github.com/rubygems/rubygems/pull/1856

  See details of changelogs for 2.6.11 release:
  adfcf40502/History.txt (L3)

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57998 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-17 01:29:22 +00:00
nobu a2ac0982cd rational.c: float denom
* rational.c (parse_rat): allow float as a denominator as well as
  a numerator.  [ruby-core:79104] [Bug #13134]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57990 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-16 03:35:29 +00:00
nobu 62fb6147cd rational.c: read_num
* rational.c (read_num): use rb_int_parse_cstr to parse integer
  parts, and make String#to_r consistent with #to_i and #to_f.
  [ruby-core:80098] [Bug #13105]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57989 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-16 03:32:16 +00:00
nobu a441e89c78 test_rational.rb: invalid exponent
* test/ruby/test_rational.rb (test_parse): more checks for invalid
  exponent.  [ruby-core:80098] [Bug #13105]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57987 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-16 03:05:34 +00:00
nobu 1a6f2391ea test_rational.rb: duplicate assertions
* test/ruby/test_rational.rb (test_parse): remove duplicate
  assertions.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57986 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-16 02:02:47 +00:00
nobu b296e29035 rational.c: zero division
* rational.c (read_rat_nos): denominator cannot be 0, raise zero
  division in that case.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57985 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-16 01:53:52 +00:00
nobu c8d3020463 test_rational.rb: shorten
* test/ruby/test_rational.rb (test_parse): reduce repeated
  arguments.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57983 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-16 00:43:07 +00:00
nobu 0b1f6aed94 object.c: make String#to_f consistent with literal
* object.c (rb_cstr_to_dbl): stop at successive underscores, as
  well as Float literals.  [ruby-core:80098] [Bug #13105]

  * `_` should be within digits
  * only one `_` allowed between digits

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-15 08:15:32 +00:00
marcandre 666df14594 * lib/matrix.rb: Add Vector.zero and Vector#zero?
Patch by Chia-sheng Chen [#13208]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57976 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-14 20:09:30 +00:00
mame a4d6fb5584 Stop a global server of Rinda test
This server seemed to cause "leaked file descriptor" warnings.
Moved it into the setup/teardown framework.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57974 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-14 15:14:21 +00:00
glass 279d31f11d Fix bug of Tempfile#size if nothing is written [Bug #13198]
* lib/tempfile.rb (Tempfile#size): Fix its behavior when nothing
  is written. Tempfile#size should return 0 in this case.
  The patch is from nobu <nobu@ruby-lang.org>.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57972 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-14 12:53:32 +00:00
mame 3c96f9c76a Fix a consistency bug of ISEQ_COVERAGE [Bug #13305]
There is an invariant that ISEQ_COVERAGE(iseq) must be Qnil if and only
if option->coverage_enabled is false.  This invariant was broken by
NODE_PRELUDE which updates option->coverage_enabled but not
ISEQ_COVERAGE(iseq).

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57971 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-14 11:39:58 +00:00
ko1 3651c0aa00 Fiber also has same issue. [Bug #13313]
* thread.c (rb_vm_proc_local_ep): added.

* cont.c (rb_fiber_start): use rb_vm_proc_local_ep().


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57970 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-14 06:52:44 +00:00
nobu 1943242a46 thread.c: Thread.start with Symbol
* thread.c (thread_do_start): fix segfault at start with Symbol.
  proc created by Symbol#to_proc does not have environment unless
  using refinements.  [ruby-core:80147] [Bug #13313]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57969 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-14 05:54:35 +00:00
nobu 04eb385192 envutil.rb: basename for diagnostic_reports
* test/lib/envutil.rb (EnvUtil.diagnostic_reports): diagnostic
  report file uses base name only.  [ci skip]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57967 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-14 04:16:02 +00:00
nobu b75f68ab8d file.c: join with /
* file.c (rb_file_join): join using "/" always, not a constant.
  and fix the document.  [ruby-core:79579] [Bug #13223]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57960 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-13 09:29:19 +00:00
nobu 16e804117c string.c: $; is a GC-root
* string.c (Init_String): $; must be a GC-root, not to be
  collected.  [ruby-core:79582]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57958 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-13 09:12:05 +00:00
mrkn 65285fbdb8 bigdecimal: version 1.3.2
Import bigdecimal version 1.3.2.  The full commit log is here:

  https://github.com/ruby/bigdecimal/compare/v1.3.1...v1.3.2

This fixes [ruby-core:79603] [Bug #13232]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57951 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-13 06:03:18 +00:00
nobu 0348262384 test/ruby/test_require.rb: use squiggly heredocs
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57835 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-11 11:15:05 +00:00
nobu 35fde4da0b fix UTF-32 valid_encoding?
* test/ruby/test_io_m17n.rb (TestIO_M17N#test_puts_widechar): do
  not use invalid codepoint.  [ruby-core:79966] [Bug #13292]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57817 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-09 02:10:27 +00:00
nobu 4171ed6c21 fix UTF-32 valid_encoding?
* enc/utf_32be.c (utf32be_mbc_enc_len): check arguments precisely.
  [ruby-core:79966] [Bug #13292]

* enc/utf_32le.c (utf32le_mbc_enc_len): ditto.

* regenc.h (UNICODE_VALID_CODEPOINT_P): predicate for valid
  Unicode codepoints.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57816 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-09 02:04:10 +00:00
nobu e65c9bd177 test_utf16.rb: refine valid_encoding tests
* test/ruby/enc/test_utf16.rb (test_utf16be_valid_encoding):
  assert all data and use assert_predicate.

* test/ruby/enc/test_utf16.rb (test_utf16le_valid_encoding):
  ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57815 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-09 01:55:43 +00:00
nobu 4e61f6d31d proc.c: preserve class name encoding in Proc#to_s
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57808 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-08 07:34:13 +00:00
nobu 249fd9e0b7 parse.y: remove trace
* parse.y (reg_named_capture_assign_iter): do not insert trace
  instructions before local variable assinments.  putobject is
  expected at first.  [ruby-core:79940] [Bug #13287]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57801 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-07 10:56:22 +00:00
nobu d69d98f61a string.c: negation of LONG_MIN
* string.c (rb_str_update): do not use negation of LONG_MIN, which
  is negative too.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57800 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-07 09:13:41 +00:00
naruse a3990118e6 Supress warning: instance variable @repeat_count not initialized
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57795 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-07 05:11:02 +00:00
akr d8cee4ff0a refine a warning message.
The "n" option for regexp, /.../n, is historical.
It doesn't mean the regexp works as binary match since Ruby 1.9.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57759 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-02 23:33:06 +00:00
nobu 033c4a083d test: use RbConfig::Limits
* test/lib/envutil.rb: rbconfig/sizeof may not be available when
  cross-compiling.  use RbConfig::Limits instead of calculating
  limits of Fixnum with hard-coded CHAR_BIT.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57757 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-02 04:54:19 +00:00