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

344 Коммитов

Автор SHA1 Сообщение Дата
wanabe 5eacf68c2a * array.c (rb_ary_decrement_share): fix to work recycling
shared-array without the following.  [ruby-dev:36991]

* array.c (ary_make_substitution): don't recycle substitution array.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20071 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-31 03:49:29 +00:00
mame ea4ae3302d * array.c (rb_ary_permutation): hide temporal array.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20062 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-30 12:35:04 +00:00
mame e2cb0b9766 * array.c (rb_ary_sort_bang): remove SEGV when replacing array with
embedded one during sort.

* test/ruby/test_array.rb (test_sort!): add tests for above.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20048 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-29 17:24:44 +00:00
mame 2e51b7f9da * array.c (rb_ary_splice): remove redundant check.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20044 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-29 16:35:47 +00:00
mame 0d83c7b6c2 * array.c (rb_ary_sort_bang): replacing array during sort broke
invariant of array.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20026 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-29 14:58:30 +00:00
mame 2a3d7b5992 * revert the previous wrong commit; sorry.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20025 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-29 14:40:31 +00:00
mame 7451e34428 * array.c (rb_ary_sort_bang): replacing array during sort broke
invariant of array.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20024 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-29 14:30:07 +00:00
nobu 4f577310ce * array.c (rb_ary_sample): fixed sizes and randomness.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19924 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-24 15:14:44 +00:00
wanabe b29f3640e9 * array.c: don't recycle shared-array while sort!.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19825 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-17 15:51:35 +00:00
wanabe 331cd4eed6 * array.c: recycle shared-array when it isn't referenced.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19824 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-17 13:09:33 +00:00
yugui 6e738bf2b1 * array.c (ary_resize_capa): renamed RESIZE_CAPA.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19821 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-17 10:42:11 +00:00
usa 6c4895c78a * array.c (RESIZE_CAPA): check whether len is longer than capacity.
* array.c (rb_ary_compact_bang): resize ary before changing capacity.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19793 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-15 13:21:37 +00:00
yugui c86ce094e2 * include/ruby/ruby.h: embeds the elements of an array into its
struct RArray for # of elements <= 3.

	* array.c: ditto.

	* gc.c (gc_mark_children): following the change of struct RArray.

	* ext/tk/tcltklib.c (ip_ruby_cmp): ditto.

	* parse.y (coverage): ditto.

	* proc.c (curry): ditto.

	* .gdbinit: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19723 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-09 05:47:04 +00:00
akr 45d7c84f2a fix a typo.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19219 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-07 11:07:31 +00:00
nobu ee5c9fb983 * array.c (rb_ary_sample): performance improvement for huge array.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18719 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-20 07:40:03 +00:00
nobu 6523eee836 * array.c (rb_ary_sample): get rid of infinite loop. #455
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18718 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-20 03:28:34 +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
shugo f433d710d0 * object.c (rb_obj_untrusted): new method Object#untrusted?.
(rb_obj_untrust): new method Object#untrust.
  (rb_obj_trust): new method Object#trust.
* array.c, debug.c, time.c, include/ruby/ruby.h, re.c, variable.c,
  string.c, io.c, dir.c, vm_method.c, struct.c, class.c, hash.c,
  ruby.c, marshal.c: fixes for Object#untrusted?.
* test/ruby/test_module.rb, test/ruby/test_array.rb,
  test/ruby/test_object.rb, test/ruby/test_string.rb,
  test/ruby/test_marshal.rb, test/ruby/test_hash.rb: added tests for
  Object#untrusted?.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18568 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-13 07:25:05 +00:00
matz e605839355 * array.c (rb_ary_delete): Array#delete to return deleted element.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18527 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-12 09:12:24 +00:00
matz 9295fd4b59 * array.c (rb_ary_sample): rename #choice to #sample. in
addition, sample takes optional argument, a la #first.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18494 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-11 10:00:47 +00:00
nobu f1ff09fbf6 * array.c (rb_ary_sort_bang): reset to real class.
* file.c (rb_find_file_ext, rb_find_file): ditto.

* io.c (io_reopen): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18377 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-05 20:08:33 +00:00
nobu a58e3d763b * array.c (rb_ary_sort_bang): respect overridden <=> for String and
Fixnum.  [ruby-core:17708]

* include/ruby/node.h (NOEX_BASIC): basic definition method flag.

* include/ruby/intern.h, vm_method.c (rb_method_basic_definition_p):
  new function to check if the method is not redefined after the
  initialization.

* vm_method.c (rb_obj_respond_to): use rb_method_basic_definition_p.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18360 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-04 18:29:55 +00:00
nobu b49106dfd7 * array.c (rb_ary_tmp_new): added.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18358 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-04 10:21:46 +00:00
akr 6372357ad5 * array.c (rb_ary_fill): don't raise even if length is negative.
[ruby-core:17483], [ruby-core:17661]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17974 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-09 12:01:08 +00:00
nobu 365f1cd57e * array.c (rb_ary_fill): check if beg is too big.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17756 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-01 04:19:47 +00:00
nobu d02ef8342c * 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/trunk@17570 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-25 06:28:53 +00:00
nobu e1a45b10b6 * 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/trunk@17472 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-20 06:42:07 +00:00
shyouhei 3af6dda231 * 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/trunk@17460 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-19 23:12:46 +00:00
mame 9e412b83a0 * array.c (rb_ary_zip): ANSI style.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17101 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-11 17:43:52 +00:00
matz dd6f7fbaef * array.c (rb_ary_shuffle_bang): update RDoc. [ruby-dev:35034]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17076 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-10 08:44:30 +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
ko1 72ba13aa8e * array.c, bignum.c, cont.c, dir.c, dln.c, encoding.c, enumerator.c,
enumerator.c (enumerator_allocate), eval_jump.c, file.c, hash.c,
  io.c, load.c, pack.c, proc.c, random.c, re.c, ruby.c, st.c,
  string.c, thread.c, thread_pthread.c, time.c, util.c, variable.c,
  vm.c, gc.c:
  allocated memory objects by xmalloc (ruby_xmalloc) should be
  freed by xfree (ruby_xfree).
* ext/curses/curses.c, ext/dbm/dbm.c, ext/digest/digest.c,
  ext/gdbm/gdbm.c, ext/json/ext/parser/parser.c,
  ext/json/ext/parser/unicode.c, ext/openssl/ossl_cipher.c,
  ext/openssl/ossl_hmac.c, ext/openssl/ossl_pkey_ec.c,
  ext/sdbm/init.c, ext/strscan/strscan.c, ext/zlib/zlib.c:
  ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17017 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-08 10:01:40 +00:00
matz 1b039e2a92 * array.c (rb_ary_delete_if): should return enumerator if no block
is given.  [ruby-dev:34901]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16715 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-31 09:27:42 +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 1e90c8ceb3 Fix a typo.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16685 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-29 13:50:59 +00:00
knu 8f706b2d44 * array.c (rb_ary_nitems, Init_Array): Axe Array#nitems().
cf. [ruby-dev:34676]-[ruby-dev:34713]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16675 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-28 09:12:28 +00:00
knu fbf3e22a3d * 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/trunk@16665 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-28 07:52:34 +00:00
knu c3e7816a78 * array.c (rb_ary_slice_bang): Return an empty array instead of
nil when pos is valid and len is adjusted from a valid value to
  zero; caught by RubySpec.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16643 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-27 11:18:50 +00:00
knu 7c52f1ed7a * array.c (rb_ary_slice_bang): Be consistent with Array#slice()
and String#slice!().  Just return nil when a negative length or
  out of boundary index is given instead of raising an exception
  via internal functions.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16559 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-23 09:01:19 +00:00
akr f73c84542c * array.c (rb_ary_compact_bang): fix reallocation size.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16528 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-22 08:19:04 +00:00
nobu feead4dca5 * array.c (flatten): check if reentered. [ruby-dev:34798]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16522 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-22 03:40:57 +00:00
matz 9d27c792c2 * array.c (flatten): free memo hash table before raising exception.
[ruby-dev:34789]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16518 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-22 00:57:47 +00:00
nagai 1ef64a6624 * array.c (flatten): fix memory leak.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16517 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-21 21:41:09 +00:00
matz f827d95685 * array.c (rb_ary_compact_bang): avoid forceful realloc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16504 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-21 07:50:27 +00:00
nobu 9afd5465e2 * array.c (rb_ary_sort_bang): should not free shared pointer, and set
shared.  [ruby-dev:34732]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16445 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-17 05:01:52 +00:00
matz c39e8c6e85 * array.c (rb_ary_sort_bang): stop memory leak. [ruby-dev:34726]
* re.c (rb_reg_search): need to free allocated buffer in re_register.

* regexec.c (onig_region_new): more pedantic malloc check.

* regexec.c (onig_region_resize): ditto.

* regexec.c (STATE_CHECK_BUFF_INIT): ditto.

* regexec.c (onig_region_copy): use onig_region_resize.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16437 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-16 18:27:01 +00:00
knu 921fb6ae25 * array.c (rb_ary_count): Override Enumerable#count for better
performance.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16412 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-14 03:46:37 +00:00
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