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

58512 Коммитов

Автор SHA1 Сообщение Дата
Yusuke Endoh 1fe73dc860 include/ruby/ruby.h: suppress a false-positive warning of GCC
GCC emits a lot of false positives for rb_scan_args because:

* `rb_scan_args(argc, argv, "*:", NULL, &opts);` makes `n_mand == 0`,
* `n_mand == argc + 1` implies `argc == -1`, and
* `memcpy(ptr, argv, sizeof(VALUE)*argc);` explodes

However, we know that argc is never so big, thus this is a false
positive.  This change suppresses it by adding a condition `n_mand > 0`.

```
In file included from /usr/include/string.h:494,
                 from ./include/ruby/defines.h:145,
                 from ./include/ruby/ruby.h:29,
                 from ./include/ruby/encoding.h:27,
                 from dir.c:14:
In function 'memcpy',
    inlined from 'ruby_nonempty_memcpy.part.0' at ./include/ruby/ruby.h:1763:17,
    inlined from 'ruby_nonempty_memcpy' at ./include/ruby/ruby.h:1760:1,
    inlined from 'rb_scan_args_set' at ./include/ruby/ruby.h:2594:9,
    inlined from 'dir_s_aref' at dir.c:2774:12:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:34:10: warning: '__builtin___memcpy_chk' pointer overflow between offset 0 and size [-8, 9223372036854775807] [-Warray-bounds]
   return __builtin___memcpy_chk (__dest, __src, __len, __bos0 (__dest));
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:34:10: warning:
'__builtin___memcpy_chk' specified size 18446744073709551608 exceeds maximum object size 9223372036854775807 [-Wstringop-overflow=]
```
2019-09-26 11:35:01 +09:00
Nobuyoshi Nakada 5357ceb1ca
[ruby/io-console] Defer creating VT query string
https://github.com/ruby/io-console/commit/3d69c577a4
2019-09-26 09:59:27 +09:00
Nobuyoshi Nakada 9b10698705
[ruby/io-console] Added IO#console_mode
https://github.com/ruby/io-console/commit/77ed8d5a06
2019-09-26 09:59:27 +09:00
Jeremy Evans 3b302ea8c9 Add Module#ruby2_keywords for passing keywords through regular argument splats
This approach uses a flag bit on the final hash object in the regular splat,
as opposed to a previous approach that used a VM frame flag.  The hash flag
approach is less invasive, and handles some cases that the VM frame flag
approach does not, such as saving the argument splat array and splatting it
later:

  ruby2_keywords def foo(*args)
    @args = args
    bar
  end
  def bar
    baz(*@args)
  end
  def baz(*args, **kw)
    [args, kw]
  end
  foo(a:1)    #=> [[], {a: 1}]
  foo({a: 1}, **{}) #=> [[{a: 1}], {}]

  foo({a: 1}) #=> 2.7: [[], {a: 1}] # and warning
  foo({a: 1}) #=> 3.0: [[{a: 1}], {}]

It doesn't handle some cases that the VM frame flag handles, such as when
the final hash object is replaced using Hash#merge, but those cases are
probably less common and are unlikely to properly support keyword
argument separation.

Use ruby2_keywords to handle argument delegation in the delegate library.
2019-09-25 12:33:52 -07:00
Jeremy Evans 80b5a0ff2a
Make rb_scan_args handle keywords more similar to Ruby methods (#2460)
Cfuncs that use rb_scan_args with the : entry suffer similar keyword
argument separation issues that Ruby methods suffer if the cfuncs
accept optional or variable arguments.

This makes the following changes to : handling.

* Treats as **kw, prompting keyword argument separation warnings
  if called with a positional hash.

* Do not look for an option hash if empty keywords are provided.
  For backwards compatibility, treat an empty keyword splat as a empty
  mandatory positional hash argument, but emit a a warning, as this
  behavior will be removed in Ruby 3.  The argument number check
  needs to be moved lower so it can correctly handle an empty
  positional argument being added.

* If the last argument is nil and it is necessary to treat it as an option
  hash in order to make sure all arguments are processed, continue to
  treat the last argument as the option hash. Emit a warning in this case,
  as this behavior will be removed in Ruby 3.

* If splitting the keyword hash into two hashes, issue a warning, as we
  will not be splitting hashes in Ruby 3.

* If the keyword argument is required to fill a mandatory positional
  argument, continue to do so, but emit a warning as this behavior will
  be going away in Ruby 3.

* If keyword arguments are provided and the last argument is not a hash,
  that indicates something wrong. This can happen if a cfunc is calling
  rb_scan_args multiple times, and providing arguments that were not
  passed to it from Ruby.  Callers need to switch to the new
  rb_scan_args_kw function, which allows passing of whether keywords
  were provided.

This commit fixes all warnings caused by the changes above.

It switches some function calls to *_kw versions with appropriate
kw_splat flags. If delegating arguments, RB_PASS_CALLED_KEYWORDS
is used.  If creating new arguments, RB_PASS_KEYWORDS is used if
the last argument is a hash to be treated as keywords.

In open_key_args in io.c, use rb_scan_args_kw.
In this case, the arguments provided come from another C
function, not Ruby.  The last argument may or may not be a hash,
so we can't set keyword argument mode.  However, if it is a
hash, we don't want to warn when treating it as keywords.

In Ruby files, make sure to appropriately use keyword splats
or literal keywords when calling Cfuncs that now issue keyword
argument separation warnings through rb_scan_args.  Also, make
sure not to pass nil in place of an option hash.

Work around Kernel#warn warnings due to problems in the Rubygems
override of the method.  There is an open pull request to fix
these issues in Rubygems, but part of the Rubygems tests for
their override fail on ruby-head due to rb_scan_args not
recognizing empty keyword splats, which this commit fixes.

Implementation wise, adding rb_scan_args_kw is kind of a pain,
because rb_scan_args takes a variable number of arguments.
In order to not duplicate all the code, the function internals need
to be split into two functions taking a va_list, and to avoid passing
in a ton of arguments, a single struct argument is used to handle
the variables previously local to the function.
2019-09-25 11:18:49 -07:00
git 4755e23d2e * 2019-09-26 [ci skip] 2019-09-26 00:27:40 +09:00
Nobuyoshi Nakada ae83dbe28d Get rid of `IO.select` to fix multiline paste 2019-09-26 00:26:33 +09:00
Nobuyoshi Nakada 5b1fd79ad9
[DOC] fixed the return value of IO#ready? [ci skip]
IO#ready? returns true or false only, since r50262(1baa57b003).
2019-09-25 20:54:33 +09:00
Koichi Sasada 6d578164f5 check `ARY_SHARED_ROOT_P()`.
ARY_SHARED_ROOT_P(ary) is true, ARY_HEAP_CAPA(ary) should not
be called.
2019-09-25 17:12:55 +09:00
Koichi Sasada 3deeb3fd91 introduce `obj_ary_extracapa`.
Introduce a new debug counter `obj_ary_extracapa` which counts
arrays which are `len < capa`.
2019-09-25 17:01:54 +09:00
Nobuyoshi Nakada 112c9f1430
lldb_inspect: removed unnecessary newline and `end` option 2019-09-25 16:58:24 +09:00
Nobuyoshi Nakada 33c5ad3154
Removed idNUMPARAM_0 2019-09-25 13:52:53 +09:00
Nobuyoshi Nakada 55e1e22b2d
Changed numbered parameters semantics
* `_1` (and no other numbered parameters) to work as `|x|`.
* giving up `_0`.

[ruby-core:95074] [Bug #16178]
2019-09-25 13:01:03 +09:00
Nobuyoshi Nakada e663299a5f
Simplified duplicate code 2019-09-25 10:39:49 +09:00
Kazuhiro NISHIYAMA c99fb0f41e
Revert "[ruby/io-console] Skip cursor position test on Solaris"
This reverts commit 5294ded681.
2019-09-25 09:48:44 +09:00
Kazuhiro NISHIYAMA ca58e83400
Do not use of non-standard escape character '\e' 2019-09-25 09:48:44 +09:00
Nobuyoshi Nakada c60451d9cd [ruby/io-console] Unique paths to be added
https://github.com/ruby/io-console/commit/a3ad851b6c
2019-09-25 09:43:31 +09:00
Nobuyoshi Nakada fc9eb5b9c1 [ruby/io-console] Load the current libraries
https://github.com/ruby/io-console/commit/ab7653c543
2019-09-25 09:43:29 +09:00
git 8e8dd88c80 * 2019-09-25 [ci skip] 2019-09-25 08:24:44 +09:00
Nobuyoshi Nakada 5294ded681 [ruby/io-console] Skip cursor position test on Solaris
It results in a mysterious failure.

https://github.com/ruby/io-console/commit/e3543c3da4
2019-09-25 08:24:19 +09:00
Nobuyoshi Nakada 0e84eecc17 Make numbered parameters exclusive in a scope 2019-09-24 21:57:54 +09:00
Nobuyoshi Nakada ea68bb914a Changed numbered parameter prefix 2019-09-24 21:57:54 +09:00
Nobuyoshi Nakada e73cc3eead Added implicit block parameter 2019-09-24 21:57:54 +09:00
Kazuhiro NISHIYAMA a1dcb9daa5
Rename from ruby-x.y.z.ext.draft to ruby-x.y.z-draft.ext [ci skip] 2019-09-24 21:52:23 +09:00
Nobuyoshi Nakada c5a97d995a
misc/lldb_cruby.py: update for python3 [ci skip]
lldb module bundled with Xcode is for Python 3 now.
2019-09-24 21:05:29 +09:00
Nobuyoshi Nakada 0526366033
misc/lldb_cruby.py: removed unused module `commands` [ci skip] 2019-09-24 20:59:47 +09:00
Nobuyoshi Nakada 10e3267c31 [ruby/io-console] Made cursor position 0-origin
https://github.com/ruby/io-console/commit/9377e37295
2019-09-24 16:20:31 +09:00
Nobuyoshi Nakada 244f7ec204 [ruby/io-console] Made cursor position consistent with `winsize`
To be consistent with `winsize`, changed the cursor position
format from `[x, y]` to `[row, column]`.

https://github.com/ruby/io-console/commit/d1f5ae9286
2019-09-24 16:20:30 +09:00
卜部昌平 2366c68116 suppress meddlesome clang10 warrning
It says:

vm.c:2519:34: warning: expression does not compute the number of elements in this array; element type is 'const struct __jmp_buf_tag', not 'VALUE' (aka 'unsigned long') [-Wsizeof-array-div]
                             sizeof(ec->machine.regs) / sizeof(VALUE));
                                    ~~~~~~~~~~~~~~~~  ^
vm.c:2519:34: note: place parentheses around the 'sizeof(VALUE)' expression to silence this warning
2019-09-24 11:50:38 +09:00
卜部昌平 14ba62d488 refactor delete unused variable
cadfaacb25 missed it.
2019-09-24 11:44:41 +09:00
git e561e4a8f3 * 2019-09-24 [ci skip] 2019-09-24 01:28:48 +09:00
Jeremy Evans 74e33662fe Make public_send and rb_f_send handle keyword argument separation
Kernel#send takes a different optimized code path that was already
handled.
2019-09-23 09:28:27 -07:00
Nobuyoshi Nakada 9e4be78ea8 [ruby/io-console] Try fallback to stdout when stdin
https://github.com/ruby/io-console/commit/b8017509ef
2019-09-23 19:29:36 +09:00
Nobuyoshi Nakada 8487193b10 [ruby/io-console] Try to write DSR query to writable IO
https://github.com/ruby/io-console/commit/a54b6e4dd1
2019-09-23 19:24:43 +09:00
aycabta b443bdbdb9 Use short wait for select(2)
It is one of the reasons why paste to IRB is slow.
2019-09-23 17:33:25 +09:00
aycabta 934507472c Retrieve key-buffer that was supposed to lose 2019-09-23 17:27:01 +09:00
Nobuyoshi Nakada 142efba93e
Adjusted directives order of a function [ci skip] 2019-09-23 02:21:54 +09:00
Lourens Naudé cadfaacb25 Lazy init thread local storage 2019-09-23 02:14:44 +09:00
Nobuyoshi Nakada 642dbb962c
make-snapshot: store timestamps in UTC for zip which lacks timezone 2019-09-23 01:25:17 +09:00
git 2afe86e4be * 2019-09-23 [ci skip] 2019-09-23 01:04:25 +09:00
Kazuhiro NISHIYAMA d8221a54f2
Add `-mtc=off` to `7z` not to store NTFS timestamps
https://sevenzip.osdn.jp/chm/cmdline/switches/method.htm
2019-09-23 00:55:48 +09:00
Nobuyoshi Nakada b0d24e262f
make-snapshot: Added -no7z option
It disables 7z, which seems not to have an option to stop saving
extra file attributes (uid/gid and atime), in order to make zip
packages stable.
2019-09-22 22:26:07 +09:00
Nobuyoshi Nakada 7fe7dec7e5
make-snapshot: Do not save extra file attributes
Extra file attributes (uid/gid and atime) make the packaged zip
file unstable.
2019-09-22 22:18:14 +09:00
Yusuke Endoh 5f35b8ca30
st.c: Use rb_st_* prefix instead of st_* (#2479)
The original st.c was public domain hash table implementation, but
Ruby's st.c is highly modified, and its data structure is not
compatiblie with the original one.

Therefore, when creating an extension library to wrap C code that uses
the original st.c, the symbols conflict, which leads to segfault.

This changes the prefix `st_*` of st.c functions to `rb_st_*` for
reflecting that they are specific to Ruby's, and avoid symbol conflicts.
2019-09-22 22:12:18 +09:00
Yusuke Endoh 2272efa463 st.c (st_add_direct_with_hash): make it "static inline"
It was originally static inline, but seemed to be accidentally published
at 8f675cdd00.
2019-09-22 16:39:47 +09:00
Yusuke Endoh 28eefb33c8 variable.c: Rename rb_st_copy to rb_iv_tbl_copy
This function was created as a variant of st_copy with firing write
barrier.
It should have more explicit name, such as st_copy_with_write_barrier.
But because it is used only for copying iv_tbl, so I rename it to
rb_iv_tbl_copy now.  If we face other use case than iv_tbl, we may want
to rename it to more general name.
2019-09-22 16:21:26 +09:00
Yusuke Endoh b4c328bebc test/bigdecimal/test_bigdecimal.rb: Use BigDecimal()
instead of deprecated BigDecimal.new.
2019-09-22 11:55:00 +09:00
Kazuhiro NISHIYAMA a0ce0b6297
Add `if: always()` because 2.4.x's `make check` failed on snapshot [ci skip]
`check-snapshot-ruby_2_4` uses `make test` instead of `make check`.
95692e54f4/.github/workflows/snapshot.yml (L448-L449)

`draft-release` use `make check` to make it simple, and
actions is required regardless of success or failure.

On the other hand, snapshot success can be ignored,
so normally it should not fail.
2019-09-22 10:11:51 +09:00
git c020fd6aa8 * 2019-09-22 [ci skip] 2019-09-22 08:10:56 +09:00
Jeremy Evans 2e551356a7 Make Kernel#{Pathname,BigDecimal,Complex} return argument if given correct type
This is how Kernel#{Array,String,Float,Integer,Hash,Rational} work.
BigDecimal and Complex instances are always frozen, so this should
not cause backwards compatibility issues for those.  Pathname
instances are not frozen, so potentially this could cause backwards
compatibility issues by not returning a new object.

Based on a patch from Joshua Ballanco, some minor changes by me.

Fixes [Bug #7522]
2019-09-21 16:10:37 -07:00