Commit graph

210 commits

Author SHA1 Message Date
shyouhei
d754218777 merge revision(s) 20103:
* array.c (rb_ary_join): do not repeat self in a recursive array.
	  [ruby-dev:37019]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@22058 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-04 23:55:33 +00:00
shyouhei
c2034afbab merge revision(s) 17756:
* array.c (rb_ary_fill): check if beg is too big.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@17761 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-01 06:14:29 +00:00
shyouhei
09cb662a8a * array.c (rb_ary_fill): (compatibility) do not raise
ArgumentError on negative length.  This behaviour shall change
  	  in a future release.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@17713 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-29 12:24:52 +00:00
shyouhei
ada89912d7 merge revision(s) 17570:
* array.c (rb_ary_fill): not depend on unspecified behavior at integer
	  overflow.  reported by Vincenzo Iozzo <snagg AT openssl.it>.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@17686 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-29 09:23:33 +00:00
shyouhei
855e79f3de merge revision(s) 17470:17472:
* array.c (rb_ary_store, rb_ary_splice): not depend on unspecified
	  behavior at integer overflow.
	* string.c (str_buf_cat): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@17480 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-20 07:38:15 +00:00
shyouhei
594a34beda * array.c (ary_new, rb_ary_initialize, rb_ary_store,
rb_ary_aplice, rb_ary_times): integer overflows should be
  checked. based on patches from Drew Yao <ayao at apple.com>
  fixed CVE-2008-2726

* string.c (rb_str_buf_append): fixed unsafe use of alloca,
  which led memory corruption. based on a patch from Drew Yao
  <ayao at apple.com> fixed CVE-2008-2726

* sprintf.c (rb_str_format): backported from trunk.

* intern.h: ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@17460 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-19 23:12:46 +00:00
knu
58e65141fd Merge from ruby_1_8.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@16721 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-31 11:58:25 +00:00
knu
0d0c31ff84 Merge from ruby_1_8.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@16695 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-29 19:35:50 +00:00
knu
764980b32d Fix a typo.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@16685 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-29 13:50:59 +00:00
knu
d55bb05153 * array.c (rb_ary_slice_bang): Call rb_ary_modify_check() at the
beginning. [rubyspec]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@16666 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-28 07:54:44 +00:00
knu
4c5e9c3500 Merge from ruby_1_8.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@16645 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-27 11:20:37 +00:00
knu
a412a7e00d Merge from ruby_1_8.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@16583 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-24 20:21:59 +00:00
knu
280f8df370 Merge from ruby_1_8.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@16539 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-22 16:07:42 +00:00
knu
ab3d450a54 Merge from ruby_1_8.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@16521 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-22 03:31:43 +00:00
knu
8480bcc8d5 Merge -r16241:16456 from ruby_1_8.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@16458 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-18 15:02:36 +00:00
knu
74efef0be8 Merge from ruby_1_8.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@16193 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-25 06:51:21 +00:00
knu
09f5560c57 Merge everything from ruby_1_8.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@16084 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-19 11:45:39 +00:00
nobu
4ef650d064 * array.c (rb_ary_take_while, rb_ary_drop_while): removed unused
variables.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16026 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-15 04:29:48 +00:00
knu
f2dc726691 * array.c (rb_ary_flatten, rb_ary_flatten_bang): Take an optional
argument that determines the level of recursion to flatten;
  backported from 1.9.

* array.c (rb_ary_shuffle_bang, rb_ary_shuffle, rb_ary_choice,
  rb_ary_cycle, rb_ary_permutation, rb_ary_combination,
  rb_ary_product, rb_ary_take, rb_ary_take_while, rb_ary_drop,
  rb_ary_drop_while): New methods: Array#shuffle, #shuffle!,
  #choice, #cycle, #permutation, #combination, #product, #take,
  #take_while, #drop, #drop_while; backported from 1.9.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16016 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-14 11:03:42 +00:00
knu
125d830eb8 * array.c (rb_ary_collect_bang, rb_ary_select): Return an
enumerator if no block is given.

* dir.c (dir_each, dir_foreach): Return an enumerator if no block
  is given.

* enum.c (enum_partition, enum_sort_by): Ditto.

* gc.c (os_each_obj): Ditto.

* hash.c (rb_hash_delete_if, rb_hash_reject_bang, rb_hash_select,
  rb_hash_each_value, rb_hash_each_key, rb_hash_each_pair,
  env_each_key, env_each_value, env_each, env_each_pair,
  env_reject_bang, env_delete_if, env_select): Ditto.

* numeric.c (num_step, int_upto, int_downto, int_dotimes): Ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16008 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-14 08:57:23 +00:00
knu
8ca8703de2 * enum.c (enum_count, enum_find_index): New methods:
Enumerable#count and #find_index; backported from 1.9.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16004 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-14 07:04:30 +00:00
knu
8202fc3bc3 * array.c (rb_ary_first, rb_ary_last): Return a shared array when
possible.

* array.c (rb_ary_pop, rb_ary_pop_m, rb_ary_shift, rb_ary_shift_m):
  Array#pop and Array#shift can take an optional argument
  specifying the number of elements to remove and return;
  backported from 1.9.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@15952 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-10 10:36:10 +00:00
knu
99a6e8a3ed Fix a typo.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@15942 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-09 12:56:36 +00:00
knu
357f65d592 * array.c (rb_ary_pop): Do not reallocate too often; backported
from 1.9.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@15941 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-09 12:56:02 +00:00
knu
0c0881d517 Array#reject too.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@15940 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-09 12:34:35 +00:00
knu
343069e16a * array.c (rb_ary_each, rb_ary_each_index, rb_ary_reverse_each,
rb_ary_reject_bang): Calling Array#each, #each_index,
  #reverse_each, #reject! or #delete_if without a block now
  returns an enumerator; backported from 1.9.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@15938 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-09 12:21:25 +00:00
knu
c5827ca193 * array.c (rb_ary_index, rb_ary_index): Array#index and #rindex
take a block instead of an argument; backported from 1.9.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@15936 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-09 11:53:15 +00:00
knu
86d05f81fd * array.c (rb_ary_nitems): Backport Array#nitems with a block;
suggested by Bertram Scharpf <lists@bertram-scharpf.de> in
  [ruby-talk:134083].


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@15917 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-07 12:40:45 +00:00
knu
b0388e77e3 * array.c (rb_ary_slice_bang): If an invalid negative index (<=
-size) is given, do not raise an exception but return nil just
  like slice() does.

* test/ruby/test_array.rb (TestArray::test_slice,
  TestArray::test_slice!): Pull in test cases from trunk.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@14184 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-10 15:08:31 +00:00
matz
35c9feaeb7 * array.c (rb_ary_assoc): check and convert inner arrays (assocs)
using #to_ary.

* hash.c (rb_hash_s_create): check and convert argument hash
  using #to_hash.

* hash.c (rb_hash_s_create): Hash#[] now takes assocs as source of
  hash conversion.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@13803 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-02 06:30:26 +00:00
matz
d84ece5c1c * array.c (rb_ary_subseq): need integer overflow check.
[ruby-dev:31736]

* array.c (rb_ary_splice): ditto.  [ruby-dev:31737]

* array.c (rb_ary_fill): ditto.  [ruby-dev:31738]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@13345 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-09-05 13:36:28 +00:00
matz
6ed97e9294 * array.c (rb_ary_fill): need integer overflow check.
[ruby-dev:31738]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@13344 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-09-05 13:27:52 +00:00
matz
336722930a * array.c (rb_ary_initialize): should call rb_ary_modify() first.
[ruby-core:11562]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@12671 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-30 07:10:43 +00:00
matz
7313b14021 * array.c (rb_ary_first): add negative length check.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@12295 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-05-18 14:18:02 +00:00
matz
642273c070 * array.c (rb_ary_first): call rb_ary_subseq() instead of pushing
values by itself.  [ruby-talk:252062]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@12294 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-05-18 14:10:29 +00:00
nobu
aaf1dc156e * array.c (rb_ary_shift): shorten copy size. fixed: [ruby-list:42907]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@11187 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-10-18 13:57:43 +00:00
matz
3c774662e1 * array.c (rb_ary_shift): should not move memory region if array
body is shared.  a patch from Kent Sibilev <ksruby at gmail.com>.
  [ruby-core:08922]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@11058 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-10-01 14:45:38 +00:00
matz
c451d96fe6 * array.c (rb_ary_shift): should clear shifting top element.
[ruby-talk:216055]

* array.c (rb_ary_shift): avoid creating shared object if array
  size is small.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@11016 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-09-24 23:17:42 +00:00
akr
ceb64ff9fc comment rb_ary_new4 behavior in Ruby 1.9.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@10378 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-24 14:53:36 +00:00
matz
704fbef5b6 * ext/syck/emitter.c (syck_scan_scalar): avoid accessing
uninitialized array element.  a patch from Pat Eyler
  <rubypate at gmail.com>.  [ruby-core:07809]

* array.c (rb_ary_fill): initialize local variables first.  a
  patch from Pat Eyler <rubypate at gmail.com>.  [ruby-core:07810]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@10128 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-05-03 17:29:36 +00:00
matz
8520eae480 * array.c (rb_ary_fill): internalize local variable "beg" to
pacify Coverity.  [ruby-core:07770]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@10113 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-04-26 16:52:54 +00:00
matz
2be9ea9ce1 * array.c: document fix - remove reference of obsoleted
select usage.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@9732 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-12-22 07:08:51 +00:00
akr
205f93b567 * array.c (rb_ary_diff): fix a GC problem on IA64 with
gcc 3.3.5 (Debian 1:3.3.5-13).
  When rb_ary_push is called, there was no register which contains
  `hash' but `&RHASH(hash)->tbl' instead.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@9683 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-12-12 16:47:17 +00:00
ocean
e23aa93e5b * array.c (rb_ary_fill): previous commit disabled this usage:
a = [0,1,2,3,4,5,6,7,8,9]
    a.fill {|i| a[i] * 10} #=> [nil, nil, ...., nil]

  previous commit has advantange for early garbage collection, but
  potensially would break some script. so I reverted behavior.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@9543 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-11-15 07:38:38 +00:00
ocean
518851f88d * array.c (rb_ary_fill): tail elements were vanished when the middle
part of array was filled. (ie: [0,1,2,3,4].fill(-1,2,1) => [0,1,-1])

* test/ruby/test_array.rb (test_fill): added.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@9541 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-11-15 07:06:00 +00:00
matz
18f7059688 * array.c (rb_ary_fill): should adjust array length correctly when
an array is expanded in the fill process.  [ruby-core:06625]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@9539 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-11-15 05:42:36 +00:00
matz
f8c1ca18c9 * array.c (rb_ary_first): RDoc update from Daniel Berger
<djberg96@yahoo.com>.  [ruby-core:06577].


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@9534 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-11-14 08:39:34 +00:00
nobu
c79ef69302 * array.c (sort_2): get rid of yet another bcc's bug.
fixed: [ruby-core:05152]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@8725 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-07-05 14:23:38 +00:00
ocean
387c713786 * array.c (rb_ary_select): can remove argc check. [ruby-core:4911]
(patch from Daniel Berger)


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@8444 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-05-13 03:38:18 +00:00
matz
88d5dcc8de * exception error messages updated. [ruby-core:04497]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@8035 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-02-28 02:45:23 +00:00