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

468 Коммитов

Автор SHA1 Сообщение Дата
knu 1a1990df71 * array.c (rb_ary_index, rb_ary_rindex): We know that argc is not
zero when we reach here.

* array.c (rb_ary_initialize, rb_ary_index): Shrink a double
  space. (NFC)



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22568 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-23 06:54:58 +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 1128e61562 * array.c (rb_ary_resurrect), string.c (rb_str_resurrect): new
functions based on [ruby-dev:37983]

* insns.def (putstring, duparray): use rb_{ary,str}_resurrect().

* iseq.c (iseq_data_to_ary): needs to result TS_VALUE.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22395 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-18 05:33:36 +00:00
mame e722ad99d5 * string.c (rb_hash_uint32, rb_hash_uint, rb_hash_start, rb_hash_end),
include/ruby/intern.h: add Murmurhash API.  [ruby-dev:37784]

* complex.c (nucomp_hash), array.c (rb_ary_hash), time.c (time_hash),
  string.c (rb_str_hsah), object.c (rb_obj_hash), range.c
  (range_hash), struct.c (rb_struct_hash), hash.c (rb_any_hash),
  rational.c (nurat_hash): use Murmurhash.  [ruby-dev:37784]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22317 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-14 19:55:34 +00:00
nobu 766df600db * array.c (rb_ary_uniq_bang, rb_ary_uniq): unique by the result of
given block.  [ruby-dev:37998]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22307 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-14 15:45:43 +00:00
nobu e1646e639a * array.c (ary_resize_capa): should not overwrite outside embedded
array.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22306 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-14 15:39:46 +00:00
nobu f23292afb4 * array.c (ary_make_shared): returns shared root array itself, and
frozen array can be shared.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22231 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-11 06:47:12 +00:00
nobu a2c7fdc709 * array.c (rb_ary_uniq): gets rid of copying.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22073 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-05 03:24:20 +00:00
nobu e3c8cdca44 * array.c (ary_add_hash): split from ary_make_hash().
* array.c (ary_recycle_hash): clears internally used hash.  this
  name came from [ruby-dev:37908].

* array.c (rb_ary_diff, rb_ary_and, rb_ary_or, rb_ary_uniq_bang):
  recycle hashes.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22072 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-05 03:01:55 +00:00
nobu 8b093ebc3c * array.c (ary_make_hash): hide a Hash used internally.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22071 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-05 02:37:49 +00:00
kazu 2b692644d9 * NEWS: add Array#sort_by!.
* array.c (rb_ary_sort_by_bang): RDoc update.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22009 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-03 07:36:55 +00:00
matz 092861f37d * array.c (rb_ary_sort_by_bang): RDoc update. [ruby-core:21742]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21976 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-02 12:05:06 +00:00
matz 765a6be700 * array.c (rb_ary_sort_by_bang): new method. requested in
[ruby-core:21709]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21967 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-02 10:43:27 +00:00
nobu c330fb421e * array.c (rb_ary_aset): fixed arguments evaluation order.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21780 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-01-26 07:00:43 +00:00
matz d47e8e81a0 * array.c (ary_double_capa): a new function to expand array more
aggressively.   [ruby-core:21460]

* array.c (rb_ary_store): use ary_double_capa().

* array.c (rb_ary_unshift_m): ditto.

* array.c (rb_ary_splice): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21719 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-01-21 15:27:35 +00:00
usa 6ff613fc09 * array.c (take_items): to_ary() raises ArgumentError if cannot to
convert to Array. [ruby-dev:37797]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21713 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-01-21 05:43:04 +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
matz 8fb2235f48 * array.c (rb_ary_push_m): add modification check before actual
operation.   [ruby-dev:37440]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20840 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-17 06:56:42 +00:00
matz a89d928bfb * array.c (rb_ary_pop_m): use enum ary_take_pos_flags.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20839 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-17 06:52:18 +00:00
matz 405b527276 * array.c (rb_ary_times): taint (and untrust) status should be
inherited by "ary * 0".  [ruby-dev:37024]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20356 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-11-25 14:29:39 +00:00
yugui 16285e768e merges r20050 from ruby_1_9_1 into trunk.
* array.c (rb_ary_sort_bang): refactoring.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20153 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-11-08 11:09:20 +00:00
nobu 4927a7c77a * 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/trunk@20103 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-11-03 18:28:34 +00:00
yugui c2ded64653 * array.c (rb_ary_take_first_or_last): renamed rb_ary_partial more
appropriately.
  (ary_take_pos_flags): new enum. makes the fourth argument of
  rb_ary_take_first_or_last more descriptive.
  (rb_ary_partial): renamed rb_ary_partial0 more appropriately.
  takes a new parameter klass for what class to instanciate.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20096 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-11-03 04:13:04 +00:00
yugui b4729e2db3 * array.c (ary_partial0): recovers mistakenly feature change at r19723.
Array#[m,n] had returned an Array even for an instance of a
  subclass.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20076 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-31 09:46:31 +00:00
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
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
matz 1c65de7284 * array.c: remove to_a completely.
* array.c (tmpbuf): keep DRY to clear klass of temporary objects.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13666 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-09 09:11:36 +00:00
nobu 81b55c0ff3 * array.c (rb_ary_permutation, rb_ary_combination, rb_ary_product):
hide internal buffer objects.  [ruby-dev:31982]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13664 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-09 07:33:35 +00:00
usa b618f011b7 * array.c (rb_ary_permutation, rb_ary_product): support non C99
compilers.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13625 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-04 11:18:14 +00:00
matz 612b2ed6a7 * array.c (rb_ary_permutation): remove C99 dependency.
[ruby-dev:31934]

* array.c (rb_ary_product): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13612 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-04 06:51:17 +00:00
matz 77a6c82eab * array.c (rb_ary_product): generalized product, now takes
arbitrary number of arrays.  a patch from David Flanagan
  <david AT davidflanagan.com>.  [ruby-core:12346]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13598 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-02 03:33:53 +00:00
matz 209b950f3f * array.c (rb_ary_permutation): small dirty hack by Matz to avoid
arrays on stack.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13591 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-01 23:37:02 +00:00
matz 04bc87e582 * array.c (rb_ary_permutation): implementation contributed from
David Flanagan.  [ruby-core:12344]

* array.c (rb_ary_combination): RDoc update to clarify.  a patch
  from David Flanagan.  [ruby-core:12344]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13590 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-01 23:35:30 +00:00
matz 25ff7ef4c6 * array.c (rb_ary_combination): revisit #combination behavior.
suggested by David Flanagan.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13588 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-01 14:46:07 +00:00
matz 43c4d80930 * array.c (rb_ary_combination): new method to give all combination
of elements from an array.  [ruby-list:42671]

* array.c (rb_ary_product): a new method to get all combinations
  of elements from two arrays.  can be extended to combinations of
  n-arrays, e.g. a.product(b,c,d).  anyone volunteer?

* array.c (rb_ary_permutation): empty function body to calculate
  permutations of array elements.  need volunteer.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13568 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-09-29 08:43:59 +00:00
matz c1a432a7d9 * array.c (rb_ary_equal): should handle recursive array.
* hash.c (hash_equal): should handle recursive hash.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13509 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-09-24 13:43:58 +00:00
matz b3fc59837a * array.c (rb_ary_cycle): avoid infinite loop for empty array.
based on a patch from David Flanagan.  [ruby-core:12085]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13424 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-09-10 05:05:49 +00:00
matz edd7c787ad * array.c (rb_ary_cycle): typo in rdoc. a patch from Yugui
<yugui@yugui.sakura.ne.jp>.  [ruby-dev:31748]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13348 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-09-06 12:33:45 +00:00
matz 9df2b5fd0c * 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/trunk@13346 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-09-05 13:37:18 +00:00
akr 2a4c4f7b0c * include/ruby/intern.h: declare rb_hash_tbl.
* include/ruby/ruby.h (RHash): delay st_table allocation.
  rename tbl field to ntbl to detect direct reference to the st_table
  as a compile error.
  (RHASH_TBL): abstract accessor defined.
  (RHASH_ITER_LEV): ditto.
  (RHASH_IFNONE): ditto.
  (RHASH_SIZE): ditto.
  (RHASH_EMPTY_P): ditto.

* hash.c: delay st_table allocation.

* gc.c: replace tbl by ntbl.

* array.c: replace direct field accessor by abstract field accessor
  such as RHASH(hash)->tbl to RHASH_TBL(hash).

* marshal.c: ditto.

* insns.def: ditto.

* ext/iconv/iconv.c: ditto.

* ext/json/ext/generator/generator.c: ditto.

* ext/json/ext/parser/parser.c: ditto.

* ext/syck/rubyext.c: ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13309 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-29 23:12:21 +00:00
matz a25fbe3b3e * encoding.c: provide basic features for M17N.
* parse.y: encoding aware parsing.

* parse.y (pragma_encoding): encoding specification pragma.

* parse.y (rb_intern3): encoding specified symbols.

* string.c (rb_str_length): length based on characters.  
  for older behavior, bytesize method added.

* string.c (rb_str_index_m): index based on characters.  rindex as
  well.

* string.c (succ_char): encoding aware succeeding string.

* string.c (rb_str_reverse): reverse based on characters.

* string.c (rb_str_inspect): encoding aware string description.

* string.c (rb_str_upcase_bang): encoding aware case conversion.
  downcase, capitalize, swapcase as well.

* string.c (rb_str_tr_bang): tr based on characters.  delete,
  squeeze, tr_s, count as well.

* string.c (rb_str_split_m): split based on characters.

* string.c (rb_str_each_line): encoding aware each_line.

* string.c (rb_str_each_char): added.  iteration based on
  characters.

* string.c (rb_str_strip_bang): encoding aware whitespace
  stripping.  lstrip, rstrip as well.

* string.c (rb_str_justify): encoding aware justifying (ljust,
  rjust, center).

* string.c (str_encoding): get encoding attribute from a string. 

* re.c (rb_reg_initialize): encoding aware regular expression

* sprintf.c (rb_str_format): formatting (i.e. length count) based
  on characters.

* io.c (rb_io_getc): getc to return one-character string.
  for older behavior, getbyte method added.

* ext/stringio/stringio.c (strio_getc): ditto.

* io.c (rb_io_ungetc): allow pushing arbitrary string at the
  current reading point.

* ext/stringio/stringio.c (strio_ungetc): ditto.

* ext/strscan/strscan.c: encoding support.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13261 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-25 03:29:39 +00:00
matz bdf32ff14f * array.c (rb_ary_s_try_convert): more document description.
* re.c (rb_reg_s_try_convert): typo fixed.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13256 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-25 00:43:13 +00:00
matz 5e1c401ff5 * array.c (rb_ary_s_try_convert): a new class method to convert
object or nil if it's not target-type.  this mechanism is used
  to convert types in the C implemented methods.

* hash.c (rb_hash_s_try_convert): ditto.

* io.c (rb_io_s_try_convert): ditto.

* re.c (rb_reg_s_try_convert): ditto.

* string.c (rb_str_s_try_convert): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13251 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-24 17:47:09 +00:00
matz 009debfd02 * io.c (rb_io_s_foreach): argument count check before making
Enumerator.  [ruby-dev:31525]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13119 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-20 14:46:03 +00:00
matz ecb93c3fdf * enum.c (enum_zip): zip no longer converts arguments into
arrays, uses enumerators.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12892 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-06 16:53:36 +00:00
matz b3e977a4c0 * enum.c (enum_cycle): new method to cycle enumerable forever.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12890 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-06 16:26:17 +00:00
nobu f64a557efd * array.c (rb_ary_flatten_bang): check argument if valid
integer.  [ruby-dev:31197]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12748 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-13 01:33:31 +00:00
ko1 6b6bf4dd48 * blockinlining.c: remove "yarv" prefix.
* array.c, numeric.c: ditto.
* insnhelper.ci, insns.def, vm_evalbody.ci: ditto.
* yarvcore.c: removed.
* yarvcore.h: renamed to core.h.
* cont.c, debug.c, error.c, process.c, signal.c : ditto.
* ext/probeprofiler/probeprofiler.c: ditto.
* id.c, id.h: added.
* inits.c: ditto.
* compile.c: rename internal functions.
* compile.h: fix debug flag.
* eval.c, object.c, vm.c: remove ruby_top_self.
  use rb_vm_top_self() instead.
* eval_intern.h, eval_load: ditto.
* gc.c: rename yarv_machine_stack_mark() to
  rb_gc_mark_machine_stack().
* insnhelper.h: remove unused macros.
* iseq.c: add iseq_compile() to create iseq object
  from source string.
* proc.c: rename a internal function.
* template/insns.inc.tmpl: remove YARV prefix.
* thread.c:
* vm.c (rb_iseq_eval): added.
* vm.c: move some functions from yarvcore.c.
* vm_dump.c: fix to remove compiler warning.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-12 04:25:46 +00:00
matz fdf213b71a * hash.c (rb_hash_assoc): new method.
* hash.c (rb_hash_rassoc): ditto.

* hash.c (rb_hash_flatten): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12587 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-22 16:26:07 +00:00
nobu 2b592580bf * include/ruby: moved public headers.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12501 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-10 03:06:15 +00:00
matz 46590a4132 * array.c (rb_ary_zip): a.zip(b,c) should return an array, not
enumerator.

* array.c (rb_ary_zip): a.zip(b,c) should return array with size
  truncated to the size of its shortest argument array.
  [incompatible]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12277 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-05-13 17:15:25 +00:00
matz aa77090aef * array.c (rb_ary_choice): should return nil when the array is
empty.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12276 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-05-13 16:54:58 +00:00
matz 82d5106e09 * array.c (rb_ary_choice): fixed mistake from RDoc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12234 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-05-01 08:57:54 +00:00
matz 2b6252e64e * array.c (rb_ary_choice): a new method to choose an element
randomly from an array.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12233 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-05-01 08:45:28 +00:00
nobu f9b349adb5 * Makefile.in, configure.in, */Makefile.sub (THREAD_MODEL): system
specific thread model.

* compile.h, regint.h, vm.h, array.c: removed unnecessary #include.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11928 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-28 01:33:57 +00:00