aboutsummaryrefslogtreecommitdiffstats
path: root/array.c
Commit message (Collapse)AuthorAgeFilesLines
* * array.c (rb_ary_sample): performance improvement for huge array.nobu2008-08-201-18/+54
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18719 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c (rb_ary_sample): get rid of infinite loop. #455nobu2008-08-201-1/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18718 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/ruby.h (rb_intern_const): tiny optimization.nobu2008-08-161-0/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18653 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * object.c (rb_obj_untrusted): new method Object#untrusted?.shugo2008-08-131-2/+9
| | | | | | | | | | | | | | | (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
* * array.c (rb_ary_delete): Array#delete to return deleted element.matz2008-08-121-2/+6
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18527 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c (rb_ary_sample): rename #choice to #sample. inmatz2008-08-111-9/+36
| | | | | | 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
* * array.c (rb_ary_sort_bang): reset to real class.nobu2008-08-051-1/+1
| | | | | | | | | * 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
* * array.c (rb_ary_sort_bang): respect overridden <=> for String andnobu2008-08-041-10/+38
| | | | | | | | | | | | | | | 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
* * array.c (rb_ary_tmp_new): added.nobu2008-08-041-0/+6
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18358 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c (rb_ary_fill): don't raise even if length is negative.akr2008-07-091-1/+3
| | | | | | | [ruby-core:17483], [ruby-core:17661] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17974 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c (rb_ary_fill): check if beg is too big.nobu2008-07-011-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17756 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c (rb_ary_fill): not depend on unspecified behavior at integernobu2008-06-251-2/+2
| | | | | | | 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
* * array.c (rb_ary_store, rb_ary_splice): not depend on unspecifiednobu2008-06-201-3/+3
| | | | | | | | | 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
* * array.c (ary_new, rb_ary_initialize, rb_ary_store,shyouhei2008-06-191-8/+12
| | | | | | | | | | | | | | | | | 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
* * array.c (rb_ary_zip): ANSI style.mame2008-06-111-4/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17101 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c (rb_ary_shuffle_bang): update RDoc. [ruby-dev:35034]matz2008-06-101-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17076 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/ruby.h (CONST_ID): constant ID cache for non-gcc.nobu2008-06-091-0/+2
| | | | | | | * *.c: no cache in init functions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17053 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c, bignum.c, cont.c, dir.c, dln.c, encoding.c, enumerator.c,ko12008-06-081-1/+1
| | | | | | | | | | | | | | | | | | | 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
* * array.c (rb_ary_delete_if): should return enumerator if no blockmatz2008-05-311-0/+1
| | | | | | is given. [ruby-dev:34901] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16715 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * enum.c (enum_count, count_all_i, Init_Enumerable),knu2008-05-291-3/+7
| | | | | | | | 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
* Fix a typo.knu2008-05-291-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16685 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c (rb_ary_nitems, Init_Array): Axe Array#nitems().knu2008-05-281-41/+0
| | | | | | | cf. [ruby-dev:34676]-[ruby-dev:34713] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16675 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c (rb_ary_slice_bang): Call rb_ary_modify_check() at theknu2008-05-281-0/+1
| | | | | | | beginning. [rubyspec] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16665 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c (rb_ary_slice_bang): Return an empty array instead ofknu2008-05-271-2/+3
| | | | | | | | 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
* * array.c (rb_ary_slice_bang): Be consistent with Array#slice()knu2008-05-231-4/+7
| | | | | | | | | 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
* * array.c (rb_ary_compact_bang): fix reallocation size.akr2008-05-221-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16528 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c (flatten): check if reentered. [ruby-dev:34798]nobu2008-05-221-2/+6
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16522 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c (flatten): free memo hash table before raising exception.matz2008-05-221-0/+1
| | | | | | [ruby-dev:34789] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16518 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c (flatten): fix memory leak.nagai2008-05-211-0/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16517 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c (rb_ary_compact_bang): avoid forceful realloc.matz2008-05-211-3/+5
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16504 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c (rb_ary_sort_bang): should not free shared pointer, and setnobu2008-05-171-1/+2
| | | | | | | shared. [ruby-dev:34732] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16445 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c (rb_ary_sort_bang): stop memory leak. [ruby-dev:34726]matz2008-05-161-5/+6
| | | | | | | | | | | | | | * 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
* * array.c (rb_ary_count): Override Enumerable#count for betterknu2008-05-141-0/+44
| | | | | | | performance. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16412 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c (rb_ary_sort_bang): freeze temporary array.nobu2008-05-081-0/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16326 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* array.c: typo fixed; sorry!matz2008-05-081-4/+4
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16324 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c (sort_reentered): reentered check may be called frommatz2008-05-081-2/+2
| | | | | | Array#sort. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16323 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c (sort_1, sort_2): check for reentered and if elements arenobu2008-05-081-3/+7
| | | | | | | accessible. [ruby-core:16679] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16321 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c (sort_1, sort_2): check reentered. [ruby-core:16679]nobu2008-05-071-2/+12
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16320 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c (rb_ary_slice_bang): should adjust length before makingmatz2008-05-051-0/+3
| | | | | | sub-array. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16292 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c (rb_ary_dup): should dupe corresponding information.matz2008-05-051-1/+1
| | | | | | [ruby-dev:34581] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16291 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c (flatten): returns an instance of same class.nobu2008-04-251-1/+1
| | | | | | | [ruby-core:16554] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16190 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c (rb_ary_take_while, rb_ary_drop_while): removed unusednobu2008-04-151-2/+0
| | | | | | | variables. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16026 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c (ary_new): new integer overflow check condition.matz2008-04-141-2/+2
| | | | | | | | | 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
* * enum.c (enum_cycle): Make Enumerable#cycle do a finite loop whenknu2008-04-131-9/+25
| | | | | | | | | 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
* * enum.c (enum_find_index): Add support for find_index(obj);knu2008-04-111-0/+3
| | | | | | | | | [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
* Fix mistake in the previous commit.knu2008-04-101-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15951 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c (rb_ary_pop_m, rb_ary_shift_m): Update documents forknu2008-04-101-9/+11
| | | | | | | | | | #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
* * array.c (ary_new): fix size check. [ruby-dev:34123]mame2008-03-251-3/+11
| | | | | | | | | | | | * 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
* * array.c (rb_ary_take, rb_ary_take_while, rb_ary_drop,mame2008-03-171-0/+95
| | | | | | | | | 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
* * array.c (rb_ary_slice_bang): should not use rb_ary_subseq()matz2008-03-131-1/+2
| | | | | | | 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