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

467 Коммитов

Автор SHA1 Сообщение Дата
mame b3a65c883a * array.c, enum.c: make rdoc format consistent.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-17 12:52:47 +00:00
mame 4ca0483a28 * array.c (rb_ary_max, rb_ary_min): implement Array#max and min with
arguments.  replace super call with rb_nmin_run.

* enum.c (nmin_run): exported (as rb_nmin_run).

* internal.h: added a prototype for rb_nmin_run.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54152 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-17 12:37:20 +00:00
mame 68a6f2e9e0 * array.c (rb_ary_max, rb_ary_min): Array#max and Array#min added.
[Feature #12172]

* internal.h (OPTIMIZED_CMP): moved from enum.c so that array.c can
  use it.

* test/ruby/test_array.rb (test_max, test_min): tests for Array#max
  and Array#min.

* test/ruby/test_enum.rb (test_max, test_min): revised a bit to test
  Enumerable#max and #min explicitly.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54150 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-17 12:14:21 +00:00
mame a22455199b * internal.c: struct cmp_opt_data added for refactoring out a data
structure for CMP_OPTIMIZABLE

* array.c (struct ary_sort_data): use struct cmp_opt_data.

* enum.c (struct min_t, max_t, min_max_t): use struct cmp_opt_data.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54149 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-17 12:03:48 +00:00
akr 85473c481e * enum.c (ary_inject_op): Extracted from enum_inject.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54148 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-17 11:55:58 +00:00
akr fa153d7435 * enum.c (enum_inject): Implement the specialized code for sum of
integers including Bignums.

* internal.h (rb_fix_plus): Declared to be usable from enum_inject.

* numeric.c (rb_fix_plus): Defined.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54147 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-17 09:50:19 +00:00
akr 32674b167b * enum.c (enum_inject): Consider redefinition of Fixnum#+.
[ruby-dev:49510] [Bug#12178] Reported by usa.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54122 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-15 12:53:06 +00:00
akr 43e20c6a9a * enum.c (enum_inject): Implement the specialied code for :+ operator
for Fixnums.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54120 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-15 11:42:23 +00:00
akr 95d2ec93bc * enum.c (enum_inject): Implement the specialized code for self is an
array and a symbol operator is given.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54119 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-15 11:27:34 +00:00
nobu 93eb95f0b9 Rename parameter name
* enum.c (enum_take_while, enum_drop_while): rename block
  parameter to obj, since they are generic objects.  [Fix GH-1226]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53686 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-01-29 07:18:10 +00:00
shugo 3dcd4b2a98 * enum.c (enum_min, enum_max): do the same optimization as r53454.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53456 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-01-07 15:07:25 +00:00
shugo 9f44b77a18 * enum.c (enum_minmax): optimize object comparison in
Enumerable#minmax.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53454 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-01-07 13:06:23 +00:00
hsbt 52cd994814 * enum.c: fix a typo in documentation.
[ci skip][fix GH-1140] Patch by @jutaz
* io.c: ditto.
* iseq.c: ditto.
* numeric.c: ditto.
* process.c: ditto.
* string.c: ditto.
* vm_trace.c: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53105 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-14 02:52:14 +00:00
akr 8595d3099a add a comment.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52027 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-04 14:42:52 +00:00
akr ddb3fbc63d * enum.c (nmin_filter): Fix limit value.
patch by Helder Pereira.
  [Bug #11471] [ruby-core:70477]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52026 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-04 14:41:55 +00:00
nobu 4191a6b90d preserve encodings in error messages
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51962 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-28 02:40:46 +00:00
hsbt 54a8318ecd * enum.c: added doc for Enumerable#zip
[fix GH-985] Patch by @yui-knk
* test/ruby/test_enum.rb: added tests for Enumerable#zip
  [fix GH-985] Patch @yui-knk

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51526 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-11 01:48:20 +00:00
hsbt aebf152ea4 * Add test case for empty array and first method with args.
Patch by @yui-knk [fix GH-955]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-04 10:43:38 +00:00
normal df11c9c5e2 enum.c: remove volatile, use RB_GC_GUARD
volatile appears unnecessary in most cases as the VALUEs are used as
arguments of uninlined functions.  Even worse, volatile can be
insufficient in places where RB_GC_GUARD is necessary.

* enum.c (zip_ary): remove volatile, use RB_GC_GUARD
  (zip_i): ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51139 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-04 05:49:35 +00:00
hsbt 8430f93b8f * Add test for Enumerable#none? [fix GH-950] Patch by @yui-knk
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51083 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-01 01:55:03 +00:00
normal 9f1c009497 enum.c (enum_minmax): simplify return value creation
No need to call three functions on success when one will do.
This results in less LoC and smaller object code, too:

   text    data     bss     dec     hex filename
  33860       0     296   34156    856c gcc/enum.o-before
  33852       0     296   34148    8564 gcc/enum.o

* enum.c (enum_minmax): simplify return value creation
* test/ruby/test_enum.rb: test behavior on empty

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51036 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-25 23:06:48 +00:00
akr 11aa7c9604 * enum.c (enum_chunk_while): New method Enumerable#chunk_while.
[ruby-core:67738] [Feature #10769] proposed by Tsuyoshi Sawada.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50889 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-14 08:54:19 +00:00
gogotanaka 8305152dc0 enum.c: [DOC] Fix typo [ci skip][Fix GH-904]
Patch provided by @jwworth

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50710 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-01 05:38:59 +00:00
hsbt cff3676c94 * enum.c: fix a sample code. Patch by @eagletmt
[fix GH-901][ci skip]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50508 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-16 12:38:11 +00:00
sorah 71588d17e5 * enum.c (enum_grep_v, grep_i, grep_iter_i, Init_enum):
Implement Enumerable#grep_v.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50491 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-14 10:42:42 +00:00
glass d77f4934f8 * enum.c (enum_to_a): revert r50457.
it requires recursion check.
  then, it doesn't make performance improvement.
  [Bug #11130] [Feature #9118]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50483 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-13 08:18:58 +00:00
glass 95f54fb019 * enum.c (enum_to_a): fix incompatibility introduced in r50457.
[Bug #11130]

* test/ruby/test_enum.rb: test for above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50477 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-12 13:24:53 +00:00
glass d908180164 * enum.c (enum_to_a): Use size to set array capa when possible.
the patch is from HonoreDB <aweiner at mdsol.com>.
  [fix GH-444]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50457 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-10 02:25:33 +00:00
glass 2ce35ac863 Revert "temp".
It's my fault.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50456 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-10 02:19:55 +00:00
glass 615a868b4b Revert "capa"
It's my fault.

This reverts commit 5e17fc6bc7cb8b0e58b05fa9ebf2c47ec73ecbb3.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50455 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-10 02:12:16 +00:00
glass 7f49c1dd63 Revert "temp"
This reverts commit 3482910fc4ca8515b38f56bdd9fa0db7002413ad.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50454 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-10 02:10:16 +00:00
glass e9075024dc capa
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50452 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-10 02:06:14 +00:00
glass 1bb3818bea temp
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50451 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-10 02:06:06 +00:00
akr 774f682952 * enum.c: Enumerable#chunk and Enumerable#slice_before no longer takes
the initial_state argument.  [Feature #10958]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50174 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-06 13:53:24 +00:00
ko1 9c64155f30 * enum.c (enum_sort_by): add WBs.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50012 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-18 19:47:36 +00:00
gogotanaka ffe896c3cb * enum.c: [DOC] Fixes Enumerable#member? documentation
[fix GH-756][ci skip] Patch by @shamanime

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49967 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-14 09:15:32 +00:00
ko1 08f3cfb585 * internal.h: use T_IMEMO to represent `struct MEMO' value.
memo->v1 and memo->v2 is WB protected values.
  So use MEMO_V1/V2_SET() macros to set these values.
  memo->u3 is ambiguous (sometimes a VALUE, sometimes an integer
  value), so use gc_mark_maybe() in gc.c to mark it.
  Rename NEW_MEMO() to MEMO_NEW().
  Move MEMO_FOR and NEW_MEMO_FOF macros from node.h.
  Export a rb_imemo_new() function for ext/ripper.
* node.h: remove NODE_MEMO.
* enum.c: catch up these change.
* enumerator.c: ditto.
* load.c: ditto.
* ext/objspace/objspace.c (count_nodes): ditto.
* gc.c (gc_mark_children): mark imemo_memo type.
* parse.y (new_args_gen): use T_IMEMO.
  (I'm not sure it is working correctly...)



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49942 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-11 23:13:01 +00:00
ko1 97e21517a3 * internal.h: define struct MEMO.
* enum.c: use MEMO.
* enumerator.c: ditto.
* load.c: ditto.
* node.h: return (struct MEMO *) pointer.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49928 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-11 00:20:45 +00:00
ktsj f436de8f31 * enum.c (enum_slice_when): [DOC] fix typo.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49918 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-10 14:18:20 +00:00
hsbt 5f4f28d669 * enum.c: Fix typo in slice_after's exception message.
[fix GH-842][ci skip] Patch by @jsyeo

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49839 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-04 01:17:02 +00:00
nobu fe6cf485e6 enum.c: Fixnum only
* enum.c (limit_by_enum_size, enum_size_over_p): check only
  against Fixnum size.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49782 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-28 09:09:18 +00:00
nobu 98273af3f7 enum.c: limit size
* enum.c (enum_each_slice, enum_each_cons): limit elements size by
  the enumerator size.  suggested by Hans Mackowiak <hanmac AT
  gmx.de> at [ruby-core:68335]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49781 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-28 08:18:42 +00:00
nobu 16294913f7 use rb_funcallv
* use rb_funcallv() for no arguments call instead of variadic
  rb_funcall().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49612 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-16 04:08:52 +00:00
akr 80870e14a7 [DOC]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48782 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12 03:15:56 +00:00
akr 2b9191e557 * internal.h: Gather declarations in non-header files.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48480 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-18 15:13:05 +00:00
akr 7cd76ab0c5 * internal.h: Include ruby.h and ruby/encoding.h to be
includable without prior inclusion.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-15 11:49:06 +00:00
nobu 723cee93c4 enum.c: nil if no iteration
* enum.c (enum_inject): return nil if no iteration, instead of
  Qundef.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47928 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-15 06:27:30 +00:00
nobu efaed8c80d enum.c: use Qundef
* enum.c (enum_inject): use Qundef for no initial values.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47926 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-15 05:25:36 +00:00
akr 5a601ec591 * enum.c: min(n) drops elements bigger than the n-th maximum element.
(struct nmin_data): New field to record the n-th maximumelement, limit
  (nmin_filter): Update limit field.
  (nmin_i): Drop too big eleents.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47923 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-14 22:24:34 +00:00
akr 2f83b32f71 update doc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47910 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-13 22:36:17 +00:00
akr 450307e383 * enum.c (nmin_run): max(n) and max_by(n) returns an array in
descending order.
  [ruby-core:65452] Suggested by David Grayson.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47907 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-13 16:30:07 +00:00
akr 5a77a4e71b Update doc. and warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47864 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-10 09:42:47 +00:00
akr 1292c5ec58 * enum.c (enum_chunk): Deprecate the state management.
(enum_slice_before): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47653 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-20 15:01:44 +00:00
akr cc659d2f1b * enum.c (enum_slice_when): New method: Enumerable#slice_when.
(slicewhen_i): New function.
  (slicewhen_ii): New function.

* enumerator.c (InitVM_Enumerator): New method:
  Enumerator::Lazy#slice_when.

  [ruby-core:62499] [Feature #9826]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47652 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-20 06:52:29 +00:00
knu f76e390ed6 Move enum.one? documentation before the relevant method.
* enum.c (enum_one): Move enum.one? documentation before the
  relevant method.  Submitted by @vipulnsward. [Fixes GH-687]
  https://github.com/ruby/ruby/pull/687

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47086 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-06 11:45:47 +00:00
nobu 95d1b61a14 symbols instead of IDs
* encoding.c (rb_enc_get_index): deal with symbols instead of IDs
  to get rid of inadvertent pin-downs.

* enum.c (chunk_ii): ditto.

* enumerator.c (append_method): ditto.

* iseq.c (iseq_load): ditto.

* marshal.c (w_symbol, r_symlink, r_symreal, r_symbol): ditto.

* signal.c (trap_handler): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46988 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-28 08:15:42 +00:00
nobu e23d173679 revert r46859 and r46860
revert "enum.c: optimize any? object allocations for Array and Hash"

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46865 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-18 13:16:37 +00:00
nobu 0d0fc55122 enum.c: optimize any? object allocations for Array and Hash
* enum.c (enum_any): optimize object allocations for Array and
  Hash when `each` is not redefined, always false if empty and the
  case without a block.  [fix GH-617]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46859 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-18 02:10:37 +00:00
zzak b09c01eff0 * enum.c: [DOC] Use #find in example to clarify alias by @rachellogie
Patch submitted via documenting-ruby/ruby#34 [ci skip]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46095 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-25 01:20:30 +00:00
nobu 8d236c317f enum.c: suppress warnings
* enum.c (sliceafter_ii): suppress unused-value warnings.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45990 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-18 03:15:34 +00:00
akr ddd155842f * enum.c: Enumerable#slice_after implemented.
* enumerator.c: Enumerator::Lazy#slice_after implemented.

  Requested by Tsuyoshi Sawada.  [ruby-core:58123] [Feature #9071]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45981 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-18 00:06:05 +00:00
akr 693703c391 [DOC]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45829 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-05 14:12:03 +00:00
nobu 118838ad3a enum.c: fix condition to recycle block argument
* enum.c (dont_recycle_block_arg): fix condition to recycle block
  argument.  lambda with rest can get internal array directly.
  [ruby-core:62060] [Bug #9749]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-16 14:47:38 +00:00
nobu 20675167d7 enum.c: make each_slice and each_cons more efficient
* enum.c (enum_each_slice, enum_each_cons): make more efficient by
  allocating less and recycling block argument arrays if possible.
  [Fixes GH-596]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45589 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-15 03:49:55 +00:00
nobu 3be926db2a revert [Bug #9605]
* enum.c: revert r45284, r45286, r45292.  it conflicts with
  existing behaviors.  [Bug #9605]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45322 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-12 08:16:47 +00:00
nobu e4c06f3c22 enum.c: suppress warnings
* enum.c (each_val_i): svalue is no longer used.
  [ruby-core:61340] [Bug #9605]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45292 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-08 05:49:12 +00:00
nobu c052c80cda enum.c: yield multiple values
* enum.c (find_i): yield multiple values instead of a packed
  array, so that lambda block can work.  with tests by Alex
  Rothenberg.  [ruby-core:61340] [Bug #9605]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45286 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-07 22:36:32 +00:00
akr f526784e1e * enum.c: Enumerable#{min,min_by,max,max_by} extended to take an
optional argument.
  (nmin_cmp): New function.
  (nmin_block_cmp): Ditto
  (nmin_filter): Ditto.
  (nmin_i): Ditto.
  (nmin_run): Ditto.
  (enum_min): Call nmin_run if the optional argument is given.
  (nmin_max): Ditto.
  (nmin_min_by): Ditto.
  (nmin_max_by): Ditto.

* range.c: Range#{min,max} extended to take an optional argument.
  (range_min): Call range_first if the optional argument is given.
  (range_max): Call rb_call_super if the optional argument is given.

[ruby-core:57111] [Feature #8887]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44958 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-14 15:45:11 +00:00
hsbt 993e57d175 * enum.c: document that it is OK to take more than available by @mvidner [fix GH-525] [ci skip]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44901 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-10 05:39:26 +00:00
zzak f72e5b8bd3 * enum.c: [DOC] Add simple example of Enumerable#zip [ci skip]
Patch by @nruth on documenting-ruby/ruby#22
  https://github.com/documenting-ruby/ruby/pull/22


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44672 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-21 07:45:55 +00:00
marcandre 9471f4187f * array.c: Have to_h raise on elements that are not key-value pairs [#9239]
* enum.c: ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44354 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-23 03:42:29 +00:00
marcandre e91ccb6c67 * array.c: More doc examples for Array#{map|collect}{!} using both forms
* enum.c: ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44140 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-11 19:55:56 +00:00
nobu 58553ca184 ruby/ruby.h, enum.c, vm_eval.c: constify argv
* include/ruby/ruby.h (RB_BLOCK_CALL_FUNC_ARGLIST): constify argv.
* enum.c (rb_enum_values_pack): ditto.
* vm_eval.c (rb_block_call, rb_check_block_call): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43911 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-29 08:02:51 +00:00
nobu 7566c49068 ruby/ruby.h: RB_BLOCK_CALL_FUNC_ARGLIST
* include/ruby/ruby.h (RB_BLOCK_CALL_FUNC_ARGLIST): for declaration
  argument list of rb_block_call_func.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43910 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-29 07:59:14 +00:00
nobu 32145ebfd6 array.c, enum.c, range.c: rb_block_call_func compatible
* array.c (take_i), range.c (first_i): make rb_block_call_func
  compatible.

* enum.c (collect_all, DEFINE_ENUMFUNCS): add blockarg.

* enum.c ({min,max,minmax,chunk,slicebefore}_ii): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43908 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-29 07:45:00 +00:00
nobu 9f45081627 ruby/ruby.h: add blockarg to rb_block_call_func
* include/ruby/ruby.h (rb_block_call_func): add blockarg.  block
  function can take block argument, e.g., proc {|&blockarg| ...}.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43907 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-29 02:26:48 +00:00
marcandre dc215dcd9f * array.c: Add Array#to_h [Feature #7292]
* enum.c: Add Enumerable#to_h

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43401 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-23 15:10:48 +00:00
zzak b8d053030e * enum.c: [DOC] Enumerable#to_a accepts arguments [GH-388]
Patch by @kachick https://github.com/ruby/ruby/pull/388


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42999 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-20 15:49:42 +00:00
ko1 ad0ef29da7 * array.c (rb_ary_splice): use RARRAY_PTR_USE() without WB because
there are not new relations.
* enum.c (enum_sort_by): ditto.
* struct.c (setup_struct): use RARRAY_RAWPTR().
* vm_eval.c (yield_under): ditto.
* ext/pathname/pathname.c (path_entries): use RARRAY_AREF().
* ext/pathname/pathname.c (path_s_glob): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42688 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-26 05:47:27 +00:00
nobu c169b51389 internal.h: STATIC_ASSERT
* internal.h (STATIC_ASSERT): move from enum.c.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41895 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-10 11:47:54 +00:00
nobu 5e2f227d21 intern.h: define rb_enumerator_size_func
* include/ruby/intern.h (rb_enumerator_size_func): define strict
  function declaration for rb_enumeratorize_with_size().


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41656 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-26 13:43:22 +00:00
akr bd15d4ca78 * internal.h (numberof): Gathered from various files.
* array.c, math.c, thread_pthread.c, iseq.c, enum.c, string.c, io.c,
  load.c, compile.c, struct.c, eval.c, gc.c, parse.y, process.c,
  error.c, ruby.c: Remove the definitions of numberof.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41142 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-07 10:01:19 +00:00
ko1 83aba04862 * include/ruby/ruby.h: constify RBasic::klass and add
RBASIC_CLASS(obj) macro which returns a class of `obj'.
  This change is a part of RGENGC branch [ruby-trunk - Feature #8339].
* object.c: add new function rb_obj_reveal().
  This function reveal interal (hidden) object by rb_obj_hide().
  Note that do not change class before and after hiding.
  Only permitted example is:
  klass = RBASIC_CLASS(obj);
  rb_obj_hide(obj);
  ....
  rb_obj_reveal(obj, klass);
  TODO: API design. rb_obj_reveal() should be replaced with others.
  TODO: modify constified variables using cast may be harmful for
  compiler's analysis and optimizaton.
  Any idea to prohibt inserting RBasic::klass directly?
  If rename RBasic::klass and force to use RBASIC_CLASS(obj),
  then all codes such as `RBASIC(obj)->klass' will be
  compilation error. Is it acceptable? (We have similar
  experience at Ruby 1.9,
  for example "RARRAY(ary)->ptr" to "RARRAY_PTR(ary)".
* internal.h: add some macros.
* RBASIC_CLEAR_CLASS(obj) clear RBasic::klass to make it internal
  object.
* RBASIC_SET_CLASS(obj, cls) set RBasic::klass.
* RBASIC_SET_CLASS_RAW(obj, cls) same as RBASIC_SET_CLASS
  without write barrier (planned).
* RCLASS_SET_SUPER(a, b) set super class of a.
* array.c, class.c, compile.c, encoding.c, enum.c, error.c, eval.c,
  file.c, gc.c, hash.c, io.c, iseq.c, marshal.c, object.c,
  parse.y, proc.c, process.c, random.c, ruby.c, sprintf.c,
  string.c, thread.c, transcode.c, vm.c, vm_eval.c, win32/file.c:
  Use above macros and functions to access RBasic::klass.
* ext/coverage/coverage.c, ext/readline/readline.c,
  ext/socket/ancdata.c, ext/socket/init.c,
* ext/zlib/zlib.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 10:49:11 +00:00
ko1 aacd771046 * *.c, parse.y, insns.def: use RARRAY_AREF/ASET macro
instead of using RARRAY_PTR().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40690 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 09:56:22 +00:00
eregon bd14f5bf94 * enum.c (Enumerable#chunk): fix grammar of error message
for symbols beginning with an underscore [Bug #8351]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40539 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-01 10:04:21 +00:00
nobu 9f87297c21 enum.c: avoid inadvertent symbol creation
* enum.c (enum_inject): avoid inadvertent symbol creation.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40097 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-04 06:46:53 +00:00
zzak d2c218d559 * enum.c (Enumerable#chunk: Improved examples, grammar, and formatting
Patch by Dan Bernier and Rich Bruchal of newhaven.rb
  [Github documenting-ruby/ruby#8]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39370 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-22 02:11:26 +00:00
marcandre 1677cbce9d * enumerator.c: Use to_enum for Enumerable methods returning Enumerators.
This makes Lazy#cycle no longer needed, so it was removed.
  Make Enumerator#chunk and slice_before return lazy Enumerators.
  [Bug #7715]

* internal.h: Remove ref to rb_enum_cycle_size; no longer needed

* enum.c: Make enum_cycle_size static.

* test/ruby/test_lazy_enumerator.rb: Test for above

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39058 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-05 03:49:59 +00:00
marcandre 96af5360a4 * enum.c (enum_zip): Fix error message
* array.c (take_items): Same, for Array#zip
  [Bug #7706]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38927 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-24 07:51:05 +00:00
ko1 f6f388a5bd * array.c, enum.c, insns.def, io.c, numeric.c, parse.y, process.c,
range.c: use prepared IDs.
  A patch from charliesome (Charlie Somerville).
  [Bug #7495]
* common.mk: add dependency to id.h.
* common.mk: replace ID_H_INCLUDES with id.h.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38143 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-02 09:57:47 +00:00
nobu 66fd9d44d8 adjust style.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38128 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-01 15:25:28 +00:00
nobu db54dc7215 enum.c: prefix
* enum.c (rb_enum_cycle_size): prefix with rb.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37531 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06 22:52:52 +00:00
marcandre 0814c4ac64 * enumerator.c: Support for lazy.cycle.size
[Feature #6636]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37525 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06 17:16:58 +00:00
marcandre cef054d5b2 * enum.c (enum_cycle): Support for Enumerable#cycle.size
[Feature #6636]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37510 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06 17:13:19 +00:00
marcandre fe9386cdcb * enum.c (enum_each_cons): Support for Enumerable#each_cons.size
[Feature #6636]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37509 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06 17:13:04 +00:00
marcandre df8451e606 * enum.c (enum_each_slice): Support for Enumerable#each_slice.size
[Feature #6636]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37508 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06 17:12:50 +00:00
marcandre c82ad6d207 * enum.c: Support for enumerators created by Enumerable with forwarding:
find_all, reject, ...
  [Feature #6636]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37507 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06 17:12:35 +00:00
nobu a7353f6924 enum.c: id_call
* enum.c (enum_find): use id_call.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37020 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-24 01:18:22 +00:00
nobu 8a3856dc1e enum.c: id_call
* enum.c (id_call): intern first and share.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37018 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-24 01:16:36 +00:00
nobu abeedb0875 array.c, enum.c: TypeError in zip
* array.c (take_items), enum.c (enum_zip): raise TypeError at
  non-enumerable objects, not NoMethodError.  [ruby-dev:46145]
  [Bug #7038]
* vm_eval.c (rb_check_block_call): check_funcall variant with block
  function.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36989 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-19 15:42:26 +00:00
zzak 1ae1b85e81 * array.c (rb_ary_select):
Update documentation for Array#select
* enum.c (enum_find_all, enum_reject):
  Update documentation for Enumerable#find_all and Enumerable#reject
  Based on a patch by Jeff Saracco
  [Bug #6908] [ruby-core:47285] [Fixes #166 on github]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36964 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-13 18:32:07 +00:00
ayumin 8198cca945 Merge branch 'pullreq/129' into trunk
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36729 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-18 16:28:42 +00:00
drbrain 38f0dd0aba * enum.c (enum_count): Enumerable#count no longer uses #size when
counting elements.  Patch by Nobuhiro IMAI.  [ruby-trunk - Bug #6473]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35780 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-24 23:51:56 +00:00
drbrain e95f7ea80d * variable.c (trace_ev): Removed "not reached" comment as this line is
reached.
* variable.c (rb_obj_remove_instance_variable):  Replaced "not reached"
  comment with the UNREACHABLE macro.
* variable.c (rb_mod_const_missing):  ditto.
* variable.c (rb_mod_remove_cvar):  ditto.
* enum.c (first_i):  ditto.
* string.c (rb_str_aref):  ditto.
* string.c (str_byte_aref):  ditto.
* string.c (rb_to_id):  ditto.
* io.c (rb_io_fmode_modestr):  ditto.
* io.c (rb_io_oflags_modestr):  ditto.
* pack.c (num2i32):  ditto.
* vm_eval.c (rb_method_missing):  ditto.
* vm_eval.c (rb_f_throw):  ditto.
* dir.c (dir_read):  ditto.
* win32/win32.c (child_result):  ditto.
* struct.c (rb_struct_getmember):  ditto.
* struct.c (rb_struct_set):  ditto.
* struct.c (rb_struct_aref_id):  ditto.
* eval.c (rb_f_raise):  ditto.
* process.c (rb_f_exit_bang):  ditto.
* process.c (rb_f_exit):  ditto.
* process.c (rb_f_abort):  ditto.
* ext/-test-/iter/break.c (iter_break_value):  ditto.
* ext/pty/pty.c (pty_check):  ditto.
* ext/openssl/ossl_pkey.c (ossl_pkey_new):  ditto.
* ext/readline/readline.c (rb_remove_history):  ditto.
* ext/stringio/stringio.c (strio_unimpl):  ditto.
* numeric.c (num_sadded):  ditto.
* numeric.c (num_init_copy):  ditto.
* numeric.c (rb_num2ll):  ditto.
* numeric.c (rb_num2ull):  ditto.
* vm_insnhelper.c (call_cfunc):  ditto.
* ruby.c (opt_W_getter):  ditto.
* bignum.c (rb_big_coerce):  ditto.
* file.c (rb_f_test):  ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35322 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-14 00:36:26 +00:00
shugo 592a629bd0 * enum.c (zip_i): variadic argument needs explicit cast on the
platforms where VALUE is longer than int.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35091 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-19 07:39:12 +00:00
nobu 19451891d8 * enum.c (enum_take): allocate buffer array before iteration, as well
as enum_first did.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35060 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-16 08:33:10 +00:00
nobu a920c29c16 * enum.c (enum_first): remove duplication.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35059 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-16 06:02:37 +00:00
shugo 2baeb78294 * enum.c (rb_enum_values_pack): rename from enum_values_pack, and
remove static.

* enumerator.c (lazy_init_iterator, lazy_init_yielder,
  lazy_select_func, lazy_reject_func, lazy_grep_func): handle
  multiple values correctly.

* enumerator.c (lazy_grep): change the behavior when a block is
  given, to be consistent with Enumerable#grep.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35043 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-15 14:20:27 +00:00
shugo 0b35e9e5dd * enumerator.c (lazy_take): add Enumerable::Lazy#take.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35018 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-14 10:29:25 +00:00
nobu 5362e7fcdd * enum.c (enum_each_slice): arrays to be yielded can be newly
created in the block.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34662 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-17 06:20:56 +00:00
nobu 41e331cc36 * enum.c: move work variables to objects not to let called blocks
access stack area out of scope.  [Bug #5801]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34661 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-17 04:24:48 +00:00
nobu f5d724ab19 * enum.c (id_lshift): use constant ID.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34648 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-16 22:33:31 +00:00
akr 3b1276eb39 update doc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34514 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-09 13:18:26 +00:00
akr de25f35c98 update doc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34494 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-08 15:44:41 +00:00
drbrain 2a4ce0757d * enum.c: Reformat block args to a single standard, { |args| ... }.
Patch by b t.  [Ruby 1.9 - Bug #5393]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33480 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-19 02:07:50 +00:00
drbrain 82f1f640ec * enum.c (group_by): Improve group_by description. Patch by b t. [#5411]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-07 23:55:41 +00:00
drbrain 8f6cb4b473 * enum.c (group_by): Improve documentation based on patch by b t.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33417 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-06 01:01:22 +00:00
drbrain e2974b1a4b * enum.c: Clean up wording in Enumerable documentation. Patch by b t.
[Ruby 1.9 - Bug #5411


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33416 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-06 00:57:06 +00:00
nobu 8e6e8e6288 * use RB_TYPE_P which is optimized for constant types, instead of
comparison with TYPE.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33357 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-29 11:07:45 +00:00
naruse 73220a234e * enum.c (slice_before_i): use rb_attr_get to surpress wrong warning
for internal instance variable slicebefore_initial_state.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33324 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-24 18:43:32 +00:00
naruse 579f2a0aa8 * enum.c (enum_inject): remove empty line to notify rdoc
Enumerable#reduce is alias. patched by milki@github.
  https://github.com/ruby/ruby/pull/26

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32595 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-21 09:12:36 +00:00
nobu 3a47cf3395 * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31573 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-15 11:55:52 +00:00
matz 00e84afa33 * enum.c (enum_inject): typo fixed. a patch from Gaku Ueda in
[ruby-core:35216].

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30857 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-02-12 22:41:02 +00:00
akr e1680f8cc1 * enum.c (sort_by_i): reenter check more strictly.
(sort_by_cmp): ditto.
  [ruby-dev:43003] reported by Usaku NAKAMURA.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30521 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-01-12 10:27:48 +00:00
akr 5a17f4c4a3 fix spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30513 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-01-11 11:34:12 +00:00
akr 113f27ba68 * enum.c (enum_sort_by): use rb_ary_resize.
(ary_cutoff): removed.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30494 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-01-08 12:48:12 +00:00
akr 74b08ff339 * enum.c (enum_sort_by): use less temporary objects.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30439 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-12-31 03:02:53 +00:00
akr e8fc308315 update doc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30428 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-12-30 02:58:42 +00:00
nobu 786e4ce25a * enum.c: use constants in id.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29637 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-30 00:40:56 +00:00
naruse 5c132d0ad2 * enum.c (enum_zip): fix typo of rdoc.
patched by Andrei Kulakov [ruby-core:31974]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-09-01 05:36:31 +00:00
naruse fee5e4ff5f * enum.c (enum_inject): fix typo of rdoc.
patched by Andrei Kulakov [ruby-core:31768]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29043 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-08-19 02:12:32 +00:00
marcandre 165ebcd5ac * enum.c (zip): rdoc fix, patch by okkez [ruby-dev:41737]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28448 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-06-27 03:10:20 +00:00
nobu 45f6fbf339 * removed trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28085 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-29 18:51:39 +00:00
marcandre c5b5ab0935 * enum.c: Documentation: small fixes
* file.c: ditto

* io.c: ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27874 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-17 21:51:01 +00:00
marcandre c1ecff1b1e * hash.c: Documentation: change => in call-seq to ->.
* enum.c: Documentation: whitespace fix for r27865

* error.c: ditto

* file.c: ditto

* io.c: ditto

* load.c: ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27869 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-17 21:31:22 +00:00
marcandre 7729de4d91 * array.c: Documentation: change => in call-seq to ->.
Harmonize "#=>" in examples. [ruby-core:30206]

* bignum.c: ditto

* class.c: ditto

* compar.c: ditto

* cont.c: ditto

* dir.c: ditto

* encoding.c: ditto

* enum.c: ditto

* enumerator.c: ditto

* error.c: ditto

* eval.c: ditto

* file.c: ditto

* gc.c: ditto

* io.c: ditto

* load.c: ditto

* marshal.c: ditto

* math.c: ditto

* numeric.c: ditto

* object.c: ditto

* pack.c: ditto

* proc.c: ditto

* process.c: ditto

* random.c: ditto

* range.c: ditto

* re.c: ditto

* ruby.c: ditto

* signal.c: ditto

* sprintf.c: ditto

* string.c: ditto

* struct.c: ditto

* thread.c: ditto

* time.c: ditto

* transcode.c: ditto

* variable.c: ditto

* vm_eval.c: ditto

* vm_method.c: ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27865 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-17 21:07:33 +00:00
marcandre 4afa9ed041 * array.c: Harmonize documentation, in particular regarding:
- methods returning enumerators
    - array methods and argument naming (array -> ary, an_array -> new_ary)
    - minor improvements, typo fixed and styling issues

  Other documentation errors fixed:
    - return value was self instead of a new array (or vice-versa) for
      Array#{pop,shift,permutation,repeated_permutation,keep_if}
    - Array#rindex was missing the form with a block.

* dir.c: ditto.

* enum.c: ditto. Modified Enumerable#reverse_each' documentation to clarify
  that #each will be finish before any element is yielded.

* error.c: ditto.

* gc.c: ditto.

* hash.c: ditto.

* io.c: ditto. IO#{codepoints,each_codepoint} fixed as per [ruby-core:23948]

* numeric.c: ditto.

* range.c: ditto.

* string.c: ditto.

* struct.c: ditto.

* vm_eval.c: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27777 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-13 05:49:55 +00:00
akr ab284526a4 update doc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27023 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-03-23 13:59:16 +00:00
akr b5388e8538 update rdoc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-03-19 12:54:01 +00:00
akr ad690e96cf rdoc update.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26910 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-03-13 16:40:27 +00:00
matz 8b55878d2a * enum.c (enum_join): remove Enumerable#join. [ruby-core:24786]
* array.c (ary_join_1): use #to_ary to detect recursive array.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26906 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-03-13 05:55:46 +00:00
akr 73fc3b5a34 rdoc update.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26892 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-03-12 14:00:49 +00:00
mame fec209551a * enum.c (min_ii, max_ii, minmax_ii): remove wrong optimization that
reuses array for yield parameter, which caused unexpected behavior.
  [ruby-core:25989]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26866 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-03-10 12:29:50 +00:00
matz 78a59da8bc * enumerator.c: move implementation of each_slice, each_cons,
each_with_object to enum.c.

* enum.c (each_slice_i): convert multiple values from yield into
  an array.

* enum.c (each_cons_i): ditto.

* enum.c (each_with_object_i): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26546 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-02-03 01:29:44 +00:00
akr f7d5887fdb unused variable removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26543 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-02-02 15:14:34 +00:00
matz 970e90dd15 * enum.c (enum_each_entry): new method #each_entry to pack values
from yield into an array.

* lib/set.rb (Set#merge): use Enumerable#each_entry to implement
  Set compatible to 1.8 behavior.  [ruby-core:27985]

* lib/set.rb: replace is_a?(Enumerable) with respond_to?(:each)
  for duck typing.

* lib/set.rb (SortedSet#add): typo fixed.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26540 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-02-02 08:54:52 +00:00
akr b9e0294eda fix typos.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25635 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-11-03 17:46:28 +00:00
matz c0a0aa0c47 * enum.c (enum_count): remove optimization using #size.
revert r25560.

* vm_eval.c (rb_funcall_no_recursive): remove method.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-10-31 16:14:38 +00:00
matz 7f2ef1a96e * enum.c (enum_count): call #size using rb_funcall_no_recursive()
to prevent infinite recursive calls.  [ruby-core:24794]

* vm_eval.c (rb_funcall_no_recursive): utility function to check
  direct recursive call.

* vm_eval.c (rb_check_funcall): move from eval.c. [refactoring]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25560 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-10-29 17:16:05 +00:00
matz 0580ba0611 * array.c (rb_ary_to_ary): do not use #respond_to? to detect
to_ary.  Just call.  [ruby-core:23738]

* eval.c (rb_check_funcall): new function with method existence
  check.  returns Qundef when the method does not exist.

* enumerator.c (enumerator_rewind): just call method, using
  rb_check_funcall().  [ruby-core:23738]

* error.c (exc_equal): ditto.

* object.c (convert_type): ditto.

* error.c (rb_name_err_mesg_new): export function.

* eval.c (make_exception): ditto.

* io.c (pop_last_hash): return early when the last argument is nil.

* io.c (rb_io_puts): treat T_STRING specially for small
  optimization. 

* vm_eval.c (raise_method_missing): skip method call if possible
  using rb_method_basic_definition_p().

* vm_eval.c (method_missing): ditto.

* test/ruby/test_rubyoptions.rb (TestRubyOptions#test_debug): test
  suites changed to ignore exceptions caused by just-call policy.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25556 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-10-29 04:55:10 +00:00
matz 55bf7f9d40 * enum.c (enum_flat_map): new method that concatenates the values
from given block.  also provides alias #collect_concat.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25456 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-10-24 17:01:38 +00:00
akr 3e54f0ee1f rdoc update.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25301 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-10-11 07:39:17 +00:00
akr 31959b52ef * enum.c (slicebefore_ii): use id_eqq.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25222 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-10-03 23:29:03 +00:00
marcandre 51b89eeb03 enum.c (enum_chunk): Give proper error message if no block given. cf [ruby-core:25912]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25204 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-10-03 04:55:00 +00:00
akr a21b7ddf26 rdoc update.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25203 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-10-02 23:10:38 +00:00
akr 5bdef2f984 rdoc update.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25202 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-10-02 23:02:04 +00:00
akr 2e70b9e70d * enum.c (enum_slice_before): take a pattern if no block given.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25188 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-10-02 11:50:11 +00:00
akr e9c728fea3 update rdoc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25185 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-10-02 10:54:31 +00:00
akr 9278fab680 rdoc update.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25123 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-27 14:44:43 +00:00
akr 50bbca9d5c * enum.c (enum_minmax): use struct for memo.
(enum_minmax_by): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25118 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-27 02:28:57 +00:00
akr 0ff9cf3625 fix rdoc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-27 01:58:07 +00:00
akr fdb3e278f5 rdoc update.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25093 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-25 18:29:53 +00:00
akr e6f4473316 rdoc update.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25075 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-24 10:35:35 +00:00
akr fc58a6c5bd * enum.c (enum_minmax): reduce comparison.
(enum_minmax_by): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25059 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-23 15:19:13 +00:00
akr 475074d5da * enum.c (enum_chunk): new method Enumerable#chunk.
* enum.c (enum_slice_before): new method Enumerable#slice_before.
  [ruby-dev:38392] [ruby-dev:39240]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25032 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-22 01:35:53 +00:00
nobu e07cb859cc * suppressed shorten-64-to-32 warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-18 08:05:32 +00:00
nobu af8f8e5b0e * array.c (recursive_join): use obj to tell if recursion occurs.
[ruby-core:24150]

* enum.c (enum_join): reverted r23966.  [ruby-core:24196]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24017 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-10 07:30:08 +00:00
nobu 0f2d1527ab * enum.c (DEFINE_ENUMFUNCS): included function signature.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23980 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-07 04:36:50 +00:00
nobu e895bc3cdb * enum.c (rb_enum_join): non-nil separator must be convertible to
String.  [ruby-core:24172]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-07 04:34:34 +00:00
matz 9041ac4289 * enum.c (rb_enum_join): should propagate taint to the return
value.  the change was overridden by r23967.  [ruby-core:24176]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23978 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-07 03:55:18 +00:00
matz 8c7f7c29b4 * enum.c (enum_to_a): should propagate taint to the return value.
[ruby-core:24152]

* enum.c (enum_sort_by): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23971 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-06 01:03:16 +00:00
nobu def66ceca3 * enum.c (enum_join): deals with self recursive objects to get rid
of infinite recursion.  [ruby-core:24150]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23966 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-06 00:04:56 +00:00
nobu e86d1ce77e * enum.c (enum_join): added rdoc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23965 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-05 23:15:51 +00:00
matz 9d9986d25c * enum.c (enum_join): add Enumerable#join.
* array.c (ary_join_1): recursive join for Enumerators (and
  objects with #to_a).

* array.c (rb_ary_join): performance tune.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23951 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-03 18:14:33 +00:00
nobu 01430b6e69 * enum.c (enum_grep): gets rid of type-punning calls.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23917 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-06-30 21:47:14 +00:00
matz 304c060d4a * enum.c (first_i): wrong condition for no argument #first.
[ruby-core:24017]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23846 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-06-24 22:46:35 +00:00
matz cab726cfac * enum.c (enum_first): should check negative length.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23623 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-06-03 00:06:40 +00:00
matz 967001d9da * enum.c (first_i): Enumerator#first should consume only what is
needed.   a patch from Marc-Andre Lafortune.  [ruby-core:23661]

* enum.c (enum_first): call to_int once for an argument.  based on
  a patch from Marc-Andre Lafortune.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23622 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-06-03 00:02:14 +00:00
nobu 82f2e90d07 * enum.c (collect_all): checks interrupts. [ruby-core:23594]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-05-29 00:30:02 +00:00
nobu 1da3e0f992 * enum.c (zip_ary): should use long.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23496 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-05-20 08:58:56 +00:00
nobu 12d2c8ba41 stripped trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22552 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-22 14:23:33 +00:00
nobu cab67c3197 * array.c (take_items), enum.c (enum_zip): tries to convert to
array first.  [ruby-core:21442]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21678 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-01-19 21:47:48 +00:00
ko1 2e311f6bd5 * include/ruby/node.h, node.h: move node.h from include path.
This change stop to install node.h beacuase of saving ABI
  (node.h will be changed. Extensions should not depends on
  this file).
* blockinlining.c, class.c, compile.c, debug.h, enum.c,
  gc.c, iseq.c, parse.y, ruby.c, signal.c, variable.c,
  vm.c, vm_core.h, vm_dump.c: ditto.
* ext/ripper/depend: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-23 19:52:31 +00:00
nobu 51e0bcb72a * enum.c (enum_take): get rid of extraneous iteration.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18727 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-20 13:24:51 +00:00
nobu 5f9c188d97 * include/ruby/ruby.h (rb_intern_const): tiny optimization.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18653 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-16 00:20:31 +00:00
matz 97c8c1fa0e * enum.c (sort_by_i): use NODE_DOT2 instead of NODE_MEMO to avoid
extra calls to is_pointer_to_heap() in GC.

* enum.c (enum_zip): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17137 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-13 04:02:36 +00:00
nobu 5a647a3f5f * include/ruby/ruby.h (CONST_ID): constant ID cache for non-gcc.
* *.c: no cache in init functions.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17053 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-09 09:25:32 +00:00
knu 3a3e250975 * enum.c (enum_count, count_all_i, Init_Enumerable),
array.c (rb_ary_count): If no argument or block is given, count
  the number of all elements.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16693 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-29 19:18:54 +00:00
knu fc19d23c5d * enum.c (enum_to_a): Pass arguments through to #each().
(enum_sort): Follow the enum_to_a signature change.
  (enum_reverse_each): Add #reverse_each().


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16622 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-27 04:15:44 +00:00
knu 16ddb4f689 Cosmetic.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16619 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-27 03:25:51 +00:00
nobu 1072cb65c9 * enum.c (enum_yield): use rb_yield_values2.
* enum.c (DEFINE_ENUMFUNCS): macro to define enumerator and yielding
  functions.

* enum.c (enum_all_func, enum_any_func, enum_one_func,
  enum_none_func): reduced duplicate code.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16404 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-13 14:32:46 +00:00
knu d701d21dbe * enum.c (grep_i): Be aware of multiple values;
fix [ruby-dev:34653].
  (grep_iter_i): Ditto.
  (count_i): Ditto.
  (find_i): Ditto.
  (find_index_i): Ditto.
  (find_all_i): Ditto.
  (reject_i): Ditto.
  (inject_i): Ditto.
  (inject_op_i): Ditto.
  (partition_i): Ditto.
  (group_by_i): Ditto.
  (first_i): Ditto.
  (sort_by_i): Ditto.
  (all_i): Ditto.
  (all_iter_i): Ditto.
  (any_i): Ditto.
  (any_iter_i): Ditto.
  (one_i): Ditto.
  (one_iter_i): Ditto.
  (none_i): Ditto.
  (none_iter_i): Ditto.
  (min_i): Ditto.
  (min_ii): Ditto.
  (max_i): Ditto.
  (max_ii): Ditto.
  (minmax_i): Ditto.
  (minmax_ii): Ditto.
  (min_by_i): Ditto.
  (max_by_i): Ditto.
  (minmax_by_i): Ditto.
  (member_i): Ditto.
  (take_i): Ditto.
  (take_while_i): Ditto.
  (drop_i): Ditto.
  (drop_while_i): Ditto.
  (cycle_i): Ditto.

* enum.c (each_with_index): Update rdoc.  each_with_index() takes
  argments that are passed through to each(), and a hash preserves
  key order.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16391 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-12 11:21:39 +00:00
nobu 8481c848da * enum.c (all_iter_i, any_iter_i): reduced duplicated code.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16366 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-11 14:19:41 +00:00
nobu 93df43f8ae * enum.c: removed trailing garbage spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16365 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-11 14:10:20 +00:00
knu 181f815591 * enum.c (enum_cycle): Make Enumerable#cycle do a finite loop when
the number of cycles is specified.

* array.c (rb_ary_cycle): Ditto for Array#cycle.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15991 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-13 14:59:55 +00:00
matz 3734fd0e79 * enum.c (count_i): modified to shut warning up.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15975 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-11 08:36:47 +00:00
knu f9c5484cc5 * enum.c (count_i, count_iter_i, enum_count, enum_find_index):
Reduce code.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15974 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-11 08:26:45 +00:00
matz f79e9281ff * enum.c (find_index_i): modified to shut warning up.
* enum.c (find_index_iter_i): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15973 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-11 08:06:31 +00:00
knu 033a32b4c1 * enum.c (enum_find_index): Add support for find_index(obj);
[ruby-dev:34313].

* array.c (rb_ary_index): Define find_index as an alias to index.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15972 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-11 07:58:06 +00:00
mame b6c9957058 * array.c (ary_new): fix size check. [ruby-dev:34123]
* array.c (rb_ary_take, rb_ary_drop): check negative size and use
  NUM2LONG instead of FIX2LONG.  [ruby-dev:34123]

* enum.c (enum_take, enum_drop): check negative size.

* test/ruby/test_array.rb: add tests for above.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15838 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-25 10:13:03 +00:00