Nobuyoshi Nakada
189f154786
[DOC] fixed return value of ENV.clone [ci skip]
2021-06-24 21:53:59 +09:00
Burdette Lamar
c1741df1a1
What's Here for Numeric and Comparable
2021-06-21 10:38:16 -07:00
Nobuyoshi Nakada
e4f891ce8d
Adjust styles [ci skip]
...
* --braces-after-func-def-line
* --dont-cuddle-else
* --procnames-start-lines
* --space-after-for
* --space-after-if
* --space-after-while
2021-06-17 10:13:40 +09:00
Jeremy Evans
117310bdc0
Make ENV.clone warn and ENV.dup raise
...
ENV.dup returned a plain Object, since all of ENV's behavior is
defined in ENV's singleton class. So using dup makes no sense.
ENV.clone works and is used in some gems, but it doesn't do what
the user expects, since modifying ENV.clone also modifies ENV.
Add a deprecation warning pointing the user to use ENV.to_h
instead.
This also undefines some private initialize* methods in ENV,
since they are not needed.
Fixes [Bug #17767 ]
2021-06-08 10:19:08 -07:00
S.H
c57610dcd5
Add static modifier to C function in hash.c ( #3138 )
...
* add static modifier for rb_hash_reject_bang func
* add static modifier for rb_hash_reject func
* add static modifier for rb_hash_values_at func
* add static modifier for rb_hash_assoc func
* add static modifier for rb_hash_rassoc func
2021-06-01 01:00:45 -07:00
Nobuyoshi Nakada
0bbab1e515
Protoized old pre-ANSI K&R style declarations and definitions
2021-05-07 00:04:36 +09:00
Benoit Daloze
68d6bd0873
Fix trivial -Wundef warnings
...
* See [Feature #17752 ]
Co-authored-by: xtkoba (Tee KOBAYASHI) <xtkoba+ruby@gmail.com>
2021-05-04 14:56:55 +02:00
Nick Kelley
a9824a3113
Correct documentation example on Hash#dig
...
Fixes [Misc #17842 ]. The current documentation suggests that:
{foo: {bar: {baz: 2}}}.dig(:foo, :bar) # => {:bar=>{:baz=>2}}
when it should be:
{foo: {bar: {baz: 2}}}.dig(:foo, :bar) # => {:baz=>2}
2021-04-30 15:46:19 -07:00
romainsalles
7de7d096e7
Fix wrong documentation
...
It doesn't return `nil` but raises an exception, as explained a few lines after
2021-04-23 12:25:00 -04:00
Kenichi Kamiya
92545977de
[Doc] Add Hash#value? into call-seq ( #4293 )
2021-04-15 11:14:43 +09:00
Kenichi Kamiya
522d4cd32f
Force recycle intermediate collection in Hash#transform_keys! [Bug #17735 ]
...
* Force recycle intermediate hash
* Force recycle intermediate array too
https://github.com/ruby/ruby/pull/4329#issuecomment-808840718
2021-03-28 14:09:52 +09:00
Nobuyoshi Nakada
fb6ebe55d9
Hide an intermediate array
2021-03-28 09:48:45 +09:00
Nobuyoshi Nakada
5e5fb72f99
Clear an intermediate hash [Bug #17735 ]
2021-03-28 09:42:26 +09:00
Kenichi Kamiya
31e0382723
Keep non evaluated keys in `Hash#transform_keys!` [Bug #17735 ]
2021-03-28 09:14:57 +09:00
Kenichi Kamiya
5b272a6453
[Doc] Fix a typo around Hash#compare_by_identity
2021-03-22 08:16:19 -04:00
Kenichi Kamiya
7d3fdfb27d
Hash#transform_values! ensures receiver modifiable in block [Bug #17736 ]
2021-03-22 14:10:52 +09:00
Nobuyoshi Nakada
d36ac283d1
Ensure the receiver hash modifiable before updating [Bug #17736 ]
...
Close https://github.com/ruby/ruby/pull/4298
2021-03-21 10:07:24 +09:00
Nobuyoshi Nakada
298edfa4a2
Refactor hash aset callback
2021-03-21 00:11:08 +09:00
Nobuyoshi Nakada
0b6554e65b
Refactor hash update callbacks
2021-03-20 23:42:15 +09:00
Kenichi Kamiya
7954bb056b
Some Hash destructive methods ensure the receiver modifiable [Bug #17736 ]
...
refs:
* https://bugs.ruby-lang.org/issues/17736
* https://github.com/ruby/ruby/pull/4296
This commit aims to cover following methods
* Hash#select!
* Hash#filter!
* Hash#keep_if
* Hash#reject!
* Hash#delete_if
I think these are not all.
---
* Ensure the receiver is modifiable or not
* Assert the receiver is not modified
2021-03-20 20:46:15 +09:00
Marc-Andre Lafortune
0ef2923c2b
Avoid rehashing in Hash#replace/dup/initialize_copy [Bug #16996 ]
2021-03-18 07:34:40 -04:00
Marc-Andre Lafortune
d094c3ef04
Avoid rehashing in Hash#select/reject [Bug #16996 ]
2021-03-18 07:34:40 -04:00
BurdetteLamar
383685b52b
Explicit references to Enumerable
2021-01-20 09:33:41 -08:00
Burdette Lamar
0e015f9389
Adds RDoc summary of Hash methods ( #4045 )
...
* Adds RDoc summary of Hash methods
2021-01-10 14:13:24 -06:00
Nobuyoshi Nakada
20a8425aa0
Make any hash values fixable [Bug #17488 ]
...
As hnum is an unsigned st_index_t, the result of RSHIFT may not be
in the fixable range.
Co-authored-by: NeoCat <neocat@neocat.jp>
2020-12-31 12:11:45 +09:00
Nobuyoshi Nakada
2eea9156eb
Adjusted indents [ci skip]
2020-12-28 19:43:55 +09:00
Marc-André Lafortune
db2ebbd71b
Optimize calls to `Kernel#hash` ( #3987 )
...
This avoids recursive checks when the `hash` method of an object
isn't specialized.
2020-12-25 02:08:12 +09:00
Marc-Andre Lafortune
0d3dc2ec80
Make `Hash#except` always return a Hash
...
[Feature #15822 ]
2020-12-19 03:59:51 -05:00
Marc-Andre Lafortune
8558d5e480
Document Hash#transform_keys with hash. Amend NEWS [DOC] [ci skip]
2020-12-15 17:09:01 -05:00
Lars Kanis
ca76337a00
Windows: Read ENV names and values as UTF-8 encoded Strings ( #3818 )
...
* Windows: Read ENV names and values as UTF-8 encoded Strings
Implements issue #12650 : fix https://bugs.ruby-lang.org/issues/12650
This also removes the special encoding for ENV['PATH'] and some
complexity in the code that is unnecessary now.
* Windows: Improve readablity of getenv() encoding
getenv() did use the expected codepage as an implicit parameter of the macro.
This is mis-leading since include/ruby/win32.h has a different definition.
Using the "cp" variable explicit (like the other function calls) makes it
more readable and consistent.
* Windows: Change external C-API macros getenv() and execv() to use UTF-8
They used to process and return strings with locale encoding,
but since all ruby-internal spawn and environment functions use UTF-8,
it makes sense to change the C-API equally.
2020-12-08 02:00:39 +09:00
卜部昌平
547c71dec4
Hash#index: delete
...
Has been deprecated since 0c97c8e335
.
2020-12-07 18:35:58 +09:00
卜部昌平
12a121cc0f
ENV.index: delete
...
Has been deprecated since 373282f665
.
2020-12-02 20:17:11 +09:00
Cristian Greco
ce3c9a3437
Fix USE_TRANSIENT_HEAP macro usage in hash.c
...
Additionally fix some typos in transient heap.
2020-11-19 07:11:36 +09:00
Jeremy Evans
c0aeb98aa9
Make ENV.replace handle multiple environ entries with the same key
...
While it is expected that all environment keys are unique, that is
not enforced. It is possible by manipulating environ directly you
can call a process with an environment with duplicate keys. If
ENV.replace was passed a hash with a key where environ had a
duplicate for that key, ENV.replace would end up deleting the key
from environ.
The fix in this case is to not assume that the environment key
list has unique keys, and continue processing the entire key
list in keylist_delete.
Fixes [Bug #17254 ]
2020-10-29 08:08:42 -07:00
Stefan Stüben
8c2e5bbf58
Don't redefine #rb_intern over and over again
2020-10-21 12:45:18 +09:00
Cristian Greco
6527411f05
[ci skip] Minor documentation fix.
...
Add missing period.
2020-10-12 15:16:24 +09:00
Kazuhiro NISHIYAMA
cece71b467
Add call-seq of [Feature #16274 ]
2020-09-29 22:49:44 +09:00
bogdanvlviv
cdb5258bec
Fix `ENV.except`'s docs
2020-09-26 12:02:00 -04:00
Jeremy Evans
df14c758fc
Make hash returned by Hash#transform_values not have a default
...
This sets an explicit default of nil. There is probably a better
approach of removing the default.
Fixes [Bug #17181 ]
2020-09-21 19:35:08 -07:00
Burdette Lamar
8095114f17
Comply with guide for method doc: hash.c ( #3466 )
...
Instance methods considered (most unchanged):
- any
- dig
- \<=
- \<
- \>=
- \>
- to_proc
2020-08-27 14:54:36 -05:00
Burdette Lamar
029c7e6045
Comply with guide for method doc: hash.c ( #3465 )
...
Instance methods considered (maybe not all changed):
invert
merge!
merge
assoc
rassoc
flatten
compact
compact!
compare_by_identity
compare_by_identity?
2020-08-27 13:28:34 -05:00
Burdette Lamar
f332fe236c
Comply with guide for method doc: hash.c ( #3464 )
...
Instance methods considered (maybe not all changed):
to_a
inspect
to_hash
to_h
keys
values
include?
has_value?
==
eql?
hash
2020-08-27 11:52:29 -05:00
Burdette Lamar
b8bfb1d5f5
Comply with guide for method doc: hash.c ( #3459 )
...
Instance methods considered (some maybe not changed):
clear
[]=
replace
length
empty?
each_value
each_key
each_pair
transform_keys
transform_keys!
transform_values
transform_values!
2020-08-27 08:31:32 -05:00
Burdette Lamar
a84a2e872f
Comply with guide for method doc: hash.c ( #3454 )
...
Methods reviewed (a few not modified):
key
delete
shift
delete_if
reject!
reject
slice
except
values_at
fetch_values
select
select!
keep_if
2020-08-25 16:09:31 -05:00
Burdette Lamar
36cc53daae
Comply with guide for method doc: hash.c ( #3451 )
...
Methods:
::new
::[]
::try_convert
#rehash
#[]
#fetch
#default
#default=
#default_proc
#default_proc=
2020-08-25 10:47:23 -05:00
Burdette Lamar
1d3e87a28c
Remove checks for self returned in array.c and hash.c examples ( #3446 )
...
Further compliance with https://github.com/ruby/ruby/blob/master/doc/method_documentation.rdoc#details-and-examples-
2020-08-23 12:10:01 -05:00
Burdette Lamar
0fea0427ae
Remove nil-return examples from hash.c ( #3438 )
...
* Remove nil-return examples from hash.c
2020-08-21 11:42:02 -05:00
Burdette Lamar
1d1e36fab6
Partial compliance with doc/method_documentation.rdoc in hash.c ( #3432 )
...
Removes references to *-convertible thingies.
2020-08-20 07:34:24 -05:00
Marc-Andre Lafortune
eae7aef020
[DOC] Improve Hash's doc for missing keys
2020-08-19 19:32:15 -04:00
Marc-Andre Lafortune
a586ccf21f
[DOC] Improve and simplify key egality documentation for Hash
2020-08-19 19:32:15 -04:00