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

297 Коммитов

Автор SHA1 Сообщение Дата
nobu 265e855ca7 * array.c (rb_ary_sort_bang): freeze temporary array.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16326 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-08 06:14:36 +00:00
matz 5abd77d925 array.c: typo fixed; sorry!
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16324 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-08 01:46:07 +00:00
matz 12a498ff49 * array.c (sort_reentered): reentered check may be called from
Array#sort.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16323 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-08 01:44:50 +00:00
nobu 4c2b10e0d6 * array.c (sort_1, sort_2): check for reentered and if elements are
accessible.  [ruby-core:16679]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16321 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-08 00:51:55 +00:00
nobu 68c67143b2 * array.c (sort_1, sort_2): check reentered. [ruby-core:16679]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16320 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-07 23:56:33 +00:00
matz a7d8042774 * array.c (rb_ary_slice_bang): should adjust length before making
sub-array.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16292 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-05 03:13:32 +00:00
matz 646988189a * array.c (rb_ary_dup): should dupe corresponding information.
[ruby-dev:34581]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16291 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-05 02:40:13 +00:00
nobu a4c08752f8 * array.c (flatten): returns an instance of same class.
[ruby-core:16554]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16190 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-25 03:37:57 +00:00
nobu d1263ff544 * array.c (rb_ary_take_while, rb_ary_drop_while): removed unused
variables.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16026 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-15 04:29:48 +00:00
matz 6be7386218 * array.c (ary_new): new integer overflow check condition.
suggested by TOYOFUKU Chikanobu <nobu_toyofuku at nifty.com> in
  [ruby-dev:34156].

* array.c (rb_ary_initialize): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15997 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-14 03:58:35 +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
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
knu e8b41deead Fix mistake in the previous commit.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15951 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-10 10:34:49 +00:00
knu c04ad1d7e4 * array.c (rb_ary_pop_m, rb_ary_shift_m): Update documents for
#pop() and #shift().

* array.c (rb_ary_slice_bang): Update document.  Assigning
  array[*args]= nil no longer removes elements.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15950 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-10 10:25:44 +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
mame 89afc5431b * array.c (rb_ary_take, rb_ary_take_while, rb_ary_drop,
rb_ary_drop_while): new method. [ruby-dev:34067]

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


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15791 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-17 13:28:46 +00:00
matz 92f510a9d9 * array.c (rb_ary_slice_bang): should not use rb_ary_subseq()
which shares internal pointer.  splice modifies the receiver
  right after subseq.  [ruby-dev:34005]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15767 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-13 16:39:45 +00:00
matz 8f14847366 * array.c (rb_ary_combination): argument check before creating
Enumerator.

* array.c (rb_ary_permutation): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15750 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-11 16:15:14 +00:00
akr 861219ce4a fix doc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15734 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-09 01:04:46 +00:00
akr 7a23e86588 fix rdoc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15723 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-07 10:18:18 +00:00
matz 39787ea14d * numeric.c (fix_to_s): avoid rb_scan_args() when no argument
given. 
* bignum.c (rb_big_to_s): ditto.
* enum.c (enum_first): ditto.
* eval_jump.c (rb_f_catch): ditto.
* io.c (rb_obj_display): ditto.
* class.c (rb_obj_singleton_methods): ditto.
* object.c (rb_class_initialize): ditto.
* random.c (rb_f_srand): ditto.
* range.c (range_step): ditto.
* re.c (rb_reg_s_last_match): ditto.
* string.c (rb_str_to_i): ditto.
* string.c (rb_str_each_line): ditto.
* string.c (rb_str_chomp_bang): ditto.
* string.c (rb_str_sum): ditto.

* string.c (str_modifiable): declare inline.
* string.c (str_independent): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-05 05:22:17 +00:00
nobu 3b0f5058fa * array.c (combi_len, rb_ary_product): check for overflow.
[ruby-Bugs-18355]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15614 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-26 07:41:34 +00:00
nobu 525b2e78e5 * array.c (recursive_cmp): compare minimal length parts.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15613 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-26 07:38:13 +00:00
nobu eccb4ca2e7 * array.c (rb_ary_eql, rb_ary_cmp): get rid of stack overflow with
self-recursive constructs.  [ruby-Bugs-18356]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15607 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-26 06:30:38 +00:00
nobu b356796f00 * array.c (rb_ary_unshift_m): expands enough for argc. [ruby-dev:33880]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15563 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-21 07:35:29 +00:00
naruse 42dcda08ae * string.c (rb_str_usascii_new{,2}: defined.
(rb_str_new): set US-ASCII and ENC_CODERANGE_7BIT when empty
  string.

* encoding.c (rb_usascii_encoding, rb_usascii_encindex): defined.
  (rb_enc_inspect, enc_name, rb_locale_charmap, rb_enc_name_list_i):
  use rb_str_ascii_new.

* array.c (recursive_join, inspect_ary): ditto.

* object.c (nil_to_s, nil_inspect, true_to_s, false_to_s,
  rb_mod_to_s): ditto.

* hash.c (inspect_hash, rb_hash_inspect, rb_f_getenv, env_fetch,
  env_clear, env_to_s, env_inspect): ditto.

* numeric.c (flo_to_s, int_chr, rb_fix2str): ditto.

* bignum.c (rb_big2str): ditto.

* file.c (rb_file_ftype, rb_file_s_dirname, rb_file_s_extname,
  file_inspect_join, Init_file): ditto.

* test/ruby/test_ruby_m17n.rb: add checks for encoding of string.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15244 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-25 16:40:02 +00:00
matz ffe425ecaa * array.c (sort_1): remove ary_sort_check(). in-place sort keep
original elements even when it's modified.

* array.c (sort_2): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15206 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-24 06:50:22 +00:00
matz 28d5ab7816 * array.c (collect_bang_i): use rb_ary_store() to avoid potential
memory corruption.  a patch from Yusuke Endoh <mame@tsg.ne.jp>
  in [ruby-dev:33328].

* array.c (ITERATE): remove unnecessary macro.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15204 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-24 06:18:18 +00:00
nobu ce2652c9d4 * include/ruby/intern.h (rb_str_tmp_new, rb_str_shared_replace):
prototype moved.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15072 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-16 03:51:32 +00:00
matz 929faf7906 * enum.c (enum_zip): honor length of the receiver, not the
shortest length.  [ruby-core:14738]

* enum.c (enum_zip): returns array not enumerator for no block
  form.  [ruby-core:14738]

* enumerator.c (next_ii): do not ignore multiple values yielded.

* array.c (rb_ary_zip): faster version without creating generators.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14952 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-08 09:50:01 +00:00
akr 6cdef2dc7e * $Date$ keyword removed to avoid inclusion of locale dependent
string.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14912 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-06 15:49:38 +00:00
akr 5088b14db7 fix typos.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14811 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-31 06:43:32 +00:00
nobu 0c48720b46 * array.c (tmpbuf): use rb_str_tmp_new().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14714 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-26 04:29:37 +00:00
akr 30f1eb1856 * include/ruby/intern.h, random.c, array.c:
change exported name.
  genrand_int32 -> rb_genrand_int32.
  genrand_real -> rb_genrand_real.
  [ruby-core:14335]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14588 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-24 08:19:28 +00:00
matz 0fbe6b5da1 * array.c (rb_ary_at): updated documentation. a patch from Tadashi
Saito <shiba AT mail2.accsnet.ne.jp> in [ruby-core:14330].

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14559 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-23 21:37:28 +00:00
ko1 dd6ab4f3d5 * array.c (rb_ary_permutation): add volatile to avoid GC problem.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14459 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-22 05:05:30 +00:00
knu d2e596ad04 * array.c (rb_ary_slice_bang): If an invalid range is given, do
not raise an exception but return nil just like slice() does.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14183 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-10 13:25:39 +00:00
matz d04f108952 * array.c (rb_ary_slice_bang): should return nil if position out
of range.  a patch from Akinori MUSHA <knu AT iDaemons.org>.
  [ruby-dev:32518]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14181 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-10 12:01:45 +00:00
nobu 2257138aa5 * array.c (flatten): some performance improvements, based on a patch
from Yusuke ENDOH <mame AT tsg.ne.jp> in [ruby-core:13877].
  [ruby-core:13851]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14127 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-07 03:27:20 +00:00
matz 2bbffcd6a4 * insns.def (concatarray, splatarray): use to_a instead of
to_splat.

* insnhelper.ci (caller_setup_args): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14063 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-01 05:20:06 +00:00
ko1 53b3bf961c * array.c (rb_ary_permutation): add gc guard codes.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13991 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-21 06:06:10 +00:00
matz 03c4e447fa * array.c (rb_ary_permutation): gives all permutations of elements
if no argument given.  a patch from Yusuke ENDOH <mame AT tsg.ne.jp>.
  [ruby-dev:32309]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13965 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-19 07:06:03 +00:00
matz 53f22d3a05 * array.c (rb_ary_product): core dumped with non array arguments.
a patch from Yusuke ENDOH <mame AT tsg.ne.jp>.  [ruby-dev:32180]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13831 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-06 18:54:02 +00:00
matz d9ebaef79b * array.c (rb_ary_each_index): should return meaningful value.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13829 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-06 18:36:49 +00:00
davidflanagan 27b35eddd6 array.c: raise IndexError for negative length in rb_ary_fill
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13783 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-26 05:52:16 +00:00
matz d9ff0a6c22 * array.c (rb_ary_assoc): check and convert inner arrays (assocs)
using #to_ary.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13775 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-25 16:52:40 +00:00
matz fada885be6 * range.c (range_first): takes first n element if argument is
given.  [ruby-core:12697]

* range.c (range_last): returns last n elements if argument is
  given.

* array.c (rb_ary_subseq, rb_ary_last): export.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13736 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-18 06:58:35 +00:00
matz 7927f32a19 * array.c (rb_ary_combination): fixed memory corruption due to too
small memory allocation

* array.c (rb_ary_product): accessing out of memory bounds.
  condition fixed.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13682 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-12 14:34:37 +00:00
nobu 7550659a33 * array.c (rb_ary_permutation): use frozen shared hidden array.
[ruby-dev:31985]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13668 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-09 12:35:31 +00:00
nobu f6a26d06a2 * array.c (rb_ary_permutation, rb_ary_combination): missing type
names.

* array.c (rb_ary_permutation): used buffer should be t1.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13667 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-09 12:29:21 +00:00