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

320 Коммитов

Автор SHA1 Сообщение Дата
Burdette Lamar 28fb6d6b9e
Adding links to literals and Kernel (#5192)
* Adding links to literals and Kernel
2021-12-03 07:12:28 -06:00
S.H 75aae66c4f
Some codes replace to `RBOOL` macro (#5023)
* Some code replace and using RBOOL macro

* Fix indent

* Using RBOOL in syserr_eqq function
2021-11-09 17:09:29 +09:00
Nobuyoshi Nakada 4fb71575e2
[DOC] Fix code markup [ci skip]
Code markup in RDoc must not be concatenated with anothr word.
2021-10-25 01:04:51 +09:00
Nobuyoshi Nakada e2017f8c7c
Unify iteration arguments 2021-10-10 11:45:50 +09:00
Nobuyoshi Nakada 2293547d9b
Update iteration step in step_i_iter 2021-10-10 11:41:26 +09:00
S.H afb95d1004
Refactor sym_step_i function 2021-10-10 11:40:04 +09:00
S.H dc9112cf10
Using NIL_P macro instead of `== Qnil` 2021-10-03 22:34:45 +09:00
Jörg W Mittag fb03598666
Remove unnecessary checks in `Range#each` [Bug #18237]
In commit:7817a438eb1803e7b3358f43bd1f38479badfbdc, the implementation
of `Time#succ`, which had been deprecated for 10 years, was finally
removed.

During that time, there was an explicit `instance_of?` check in
source:range.c#L350 with a comment that the check should be removed
once `Time#succ` is removed.

Since `Time#succ` is now gone, this check should be removed.

Note: this should be coordinated with adding a version guard to the
corresponding check in ruby/spec as well.
2021-10-03 22:16:08 +09:00
Burdette Lamar 854fe9d1c1
Correct two errors in Range RDoc (#4889) 2021-09-23 18:08:49 -05:00
Burdette Lamar fb976df81f
What's Here for Range (#4881) 2021-09-22 14:51:11 -05:00
Burdette Lamar 736eb30e52
Enhanced RDoc for Range (#4870)
Introductory material revised.
2021-09-20 13:41:55 -05:00
Burdette Lamar 1c07c98229
Enhanced RDoc for Range (#4847)
Treated:

    #to_s
    #inspect
    #===
    #include?
    #cover?
    #count
2021-09-18 07:27:02 -05:00
Burdette Lamar 745287d43a
Enhanced RDoc for Range#minmax (#4846) 2021-09-15 15:51:54 -05:00
Burdette Lamar e967740d07
Enhanced RDoc for Range#max (#4844) 2021-09-15 14:48:47 -05:00
Burdette Lamar 97374c7eec
Enhanced RDoc for Range#min (#4842) 2021-09-15 13:37:34 -05:00
Nobuyoshi Nakada a27c274f04
[DOC] Fix broken links [ci skip]
* As the "doc/" prefix is specified by the `--page-dir` option,
  remove from the rdoc references.
* Refer to the original .rdoc instead of the converted .html.
2021-09-15 14:16:14 +09:00
Burdette Lamar a0357acf19
Enhanced RDoc for Range (#4839)
Treated:

    #size
    #to_a
    #each
    #begin
    #end
    #first
    #last
2021-09-14 17:51:31 -05:00
Burdette Lamar 1af5a0c574
Bsearch doc for Array and Range (#4838)
This PR creates doc/bsearch.rdoc to provide common documentation for bsearch in Array and Range.
2021-09-14 16:08:21 -05:00
Burdette Lamar 4e03032a83
Enhanced RDoc for Range (#4833)
Treated:

    ::new
    #include_end?
    #==
    #eql?
    #hash
    #step
2021-09-13 14:00:39 -05:00
S-H-GAMELINKS 83a5e2bb5c Using RB_FLOAT_TYPE_P macro 2021-09-12 11:16:31 +09:00
S.H 378e8cdad6
Using RBOOL macro 2021-08-02 12:06:44 +09:00
S-H-GAMELINKS e882905d0d Refactor sym_each_i function 2021-07-22 14:02:23 +09:00
Aaron Patterson 9f3adaf529 Use public allocators for creating new T_OBJECT objects
This way the header flags and object internals are set correctly
2020-10-28 18:35:22 -07:00
Kenta Murata f754b42285
numeric.c, range.c: prohibit zero step
* numeric.c: prohibit zero step in Numeric#step

* range.c: prohibit zero step in Range#step

* Fix ruby-spec

[Feature #15573]
2020-10-23 15:26:51 +09:00
Stefan Stüben 8c2e5bbf58 Don't redefine #rb_intern over and over again 2020-10-21 12:45:18 +09:00
Kenta Murata a6a8576e87
Feature #16812: Allow slicing arrays with ArithmeticSequence (#3241)
* Support ArithmeticSequence in Array#slice

* Extract rb_range_component_beg_len

* Use rb_range_values to check Range object

* Fix ary_make_partial_step

* Fix for negative step cases

* range.c: Describe the role of err argument in rb_range_component_beg_len

* Raise a RangeError when an arithmetic sequence refers the outside of an array

[Feature #16812]
2020-10-21 02:40:18 +09:00
Kenta Murata 18cecda46e
range.c: Fix an exception message in rb_range_beg_len
[Bug #17271]
2020-10-20 16:01:57 +09:00
Koichi Sasada 0096d2b895 freeze all Range objects.
Matz want to try to freeze all Range objects.
[Feature #15504]
2020-09-25 22:16:55 +09:00
Nobuyoshi Nakada 6321330461
Removed trailing spaces [ci skip] 2020-09-02 13:30:16 +09:00
Jeremy Evans de10a1f358 Update documentation for Range#max 2020-09-01 10:52:47 -07:00
Jeremy Evans 4db4faef0f Revert "Fix Range#{max,minmax} for range with integer beginning and non-integer end"
This reverts commit 8900a25581.
2020-09-01 10:52:47 -07:00
Jeremy Evans e080a4cdee Revert "Special case Range#max for integer beginning and Float::Infinity end"
This reverts commit 05bf811c28.
2020-09-01 10:52:47 -07:00
Jeremy Evans 05bf811c28 Special case Range#max for integer beginning and Float::Infinity end
Popular Ruby libraries such as Rails and Rubocop relying on the
previous behavior, even though it is technically a bug. The
correct behavior is probably raising RangeError, since that is what
an endless range raises.

Related to [Bug #17017]
2020-07-19 10:25:55 -04:00
Michael Kohl 8a5ad2b77d
Fix Range#max for beginless Integer ranges [Bug #17034]
* Fix Range#max for beginless Integer ranges
* Update test/ruby/test_range.rb
* Fix formatting

https://github.com/ruby/ruby/pull/3328

Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
2020-07-19 01:18:40 +09:00
Jeremy Evans 8900a25581
Fix Range#{max,minmax} for range with integer beginning and non-integer end
Previously, for inclusive ranges, the max would show up as the
end of the range, even though the end was not an integer and would
not be the maximum value.  For exclusive ranges, max/minmax would
previously raise a TypeError, even though it is possible to get the
correct maximum.

This change to max/minmax also uncovered a similar error in cover?,
which calls max in certain cases, so adjust the code there so that
cover? still works as expected.

Fixes [Bug #17017]
2020-07-13 10:09:38 -07:00
Jeremy Evans c146362555 Use static variables in Range#minmax 2020-07-04 13:34:38 -07:00
Sam Bostock bf1a6771f3 Fix non-numeric exclusive Range#minmax bug
The implementation of Range#minmax added in d5c60214c4 causes the
following incorrect behaviour:

  ('a'...'c').minmax => ["a", ["a", "b"]]

instead of

  ('a'...'c').minmax => ["a", "b"]

This is because the C implementation of Range#minmax (range_minmax)
directly delegates to the C implementation of Range#min (range_min) and
Range#max (range_max), without changing the execution context.

Range#max's C implementation (range_max), when given a non-numeric
exclusive range, delegates to super, which is meant to call
Enumerable#max. However, because range_max is called directly by
range_minmax, super calls Enumerable#minmax instead, causing the
incorrect nesting.

Perhaps it is possible to change the execution context in an optimized
manner, but the simplest solution seems to be to just explicitly
delegate from Range#minmax to Range#min and Range#max.
2020-07-04 10:02:24 -07:00
卜部昌平 de3e931df7 add UNREACHABLE_RETURN
Not every compilers understand that rb_raise does not return.  When a
function does not end with a return statement, such compilers can issue
warnings.  We would better tell them about reachabilities.
2020-06-29 11:05:41 +09:00
卜部昌平 9c5804ac1c range_each: do not goto into a branch
I'm not necessarily against every goto in general, but jumping into a
branch is definitely a bad idea.  Better refactor.
2020-06-29 11:05:41 +09:00
卜部昌平 9e41a75255 sed -i 's|ruby/impl|ruby/internal|'
To fix build failures.
2020-05-11 09:24:08 +09:00
卜部昌平 d7f4d732c1 sed -i s|ruby/3|ruby/impl|g
This shall fix compile errors.
2020-05-11 09:24:08 +09:00
Nobuyoshi Nakada e474c189da
Suppress -Wswitch warnings 2020-04-08 15:13:37 +09:00
卜部昌平 9e6e39c351
Merge pull request #2991 from shyouhei/ruby.h
Split ruby.h
2020-04-08 13:28:13 +09:00
卜部昌平 115fec062c more on NULL versus functions.
Function pointers are not void*.  See also
ce4ea956d2
8427fca49b
2020-02-07 14:24:19 +09:00
卜部昌平 5e22f873ed decouple internal.h headers
Saves comitters' daily life by avoid #include-ing everything from
internal.h to make each file do so instead.  This would significantly
speed up incremental builds.

We take the following inclusion order in this changeset:

1.  "ruby/config.h", where _GNU_SOURCE is defined (must be the very
    first thing among everything).
2.  RUBY_EXTCONF_H if any.
3.  Standard C headers, sorted alphabetically.
4.  Other system headers, maybe guarded by #ifdef
5.  Everything else, sorted alphabetically.

Exceptions are those win32-related headers, which tend not be self-
containing (headers have inclusion order dependencies).
2019-12-26 20:45:12 +09:00
Yusuke Endoh 81e377023c range.c: Range#min with a beginless one now raise an explicit exception
[Bug #16450]
2019-12-25 13:36:23 +09:00
zverok 5a0102cb61 Enhance Range docs
* Change === docs to mention it uses cover?
* Add different example to === docs to showcase
  behavior better
* Change include? docs to mention cover?
  and clarify the difference
2019-12-22 23:17:39 +09:00
Nobuyoshi Nakada db16629008
Fixed misspellings
Fixed misspellings reported at [Bug #16437], only in ruby and rubyspec.
2019-12-20 09:32:42 +09:00
卜部昌平 00bbdf4451 implement Range#count
As matz requested in [Bug #16366].
2019-12-04 15:32:49 +09:00
Jeremy Evans ffd0820ab3 Deprecate taint/trust and related methods, and make the methods no-ops
This removes the related tests, and puts the related specs behind
version guards.  This affects all code in lib, including some
libraries that may want to support older versions of Ruby.
2019-11-18 01:00:25 +02:00