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

141 Коммитов

Автор SHA1 Сообщение Дата
matz cab726cfac * enum.c (enum_first): should check negative length.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23623 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-06-03 00:06:40 +00:00
matz 967001d9da * enum.c (first_i): Enumerator#first should consume only what is
needed.   a patch from Marc-Andre Lafortune.  [ruby-core:23661]

* enum.c (enum_first): call to_int once for an argument.  based on
  a patch from Marc-Andre Lafortune.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23622 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-06-03 00:02:14 +00:00
nobu 82f2e90d07 * enum.c (collect_all): checks interrupts. [ruby-core:23594]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-05-29 00:30:02 +00:00
nobu 1da3e0f992 * enum.c (zip_ary): should use long.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23496 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-05-20 08:58:56 +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 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
ko1 2e311f6bd5 * include/ruby/node.h, node.h: move node.h from include path.
This change stop to install node.h beacuase of saving ABI
  (node.h will be changed. Extensions should not depends on
  this file).
* blockinlining.c, class.c, compile.c, debug.h, enum.c,
  gc.c, iseq.c, parse.y, ruby.c, signal.c, variable.c,
  vm.c, vm_core.h, vm_dump.c: ditto.
* ext/ripper/depend: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-23 19:52:31 +00:00
nobu 51e0bcb72a * enum.c (enum_take): get rid of extraneous iteration.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18727 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-20 13:24:51 +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
matz 97c8c1fa0e * enum.c (sort_by_i): use NODE_DOT2 instead of NODE_MEMO to avoid
extra calls to is_pointer_to_heap() in GC.

* enum.c (enum_zip): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17137 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-13 04:02:36 +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
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 fc19d23c5d * enum.c (enum_to_a): Pass arguments through to #each().
(enum_sort): Follow the enum_to_a signature change.
  (enum_reverse_each): Add #reverse_each().


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16622 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-27 04:15:44 +00:00
knu 16ddb4f689 Cosmetic.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16619 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-27 03:25:51 +00:00
nobu 1072cb65c9 * enum.c (enum_yield): use rb_yield_values2.
* enum.c (DEFINE_ENUMFUNCS): macro to define enumerator and yielding
  functions.

* enum.c (enum_all_func, enum_any_func, enum_one_func,
  enum_none_func): reduced duplicate code.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16404 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-13 14:32:46 +00:00
knu d701d21dbe * enum.c (grep_i): Be aware of multiple values;
fix [ruby-dev:34653].
  (grep_iter_i): Ditto.
  (count_i): Ditto.
  (find_i): Ditto.
  (find_index_i): Ditto.
  (find_all_i): Ditto.
  (reject_i): Ditto.
  (inject_i): Ditto.
  (inject_op_i): Ditto.
  (partition_i): Ditto.
  (group_by_i): Ditto.
  (first_i): Ditto.
  (sort_by_i): Ditto.
  (all_i): Ditto.
  (all_iter_i): Ditto.
  (any_i): Ditto.
  (any_iter_i): Ditto.
  (one_i): Ditto.
  (one_iter_i): Ditto.
  (none_i): Ditto.
  (none_iter_i): Ditto.
  (min_i): Ditto.
  (min_ii): Ditto.
  (max_i): Ditto.
  (max_ii): Ditto.
  (minmax_i): Ditto.
  (minmax_ii): Ditto.
  (min_by_i): Ditto.
  (max_by_i): Ditto.
  (minmax_by_i): Ditto.
  (member_i): Ditto.
  (take_i): Ditto.
  (take_while_i): Ditto.
  (drop_i): Ditto.
  (drop_while_i): Ditto.
  (cycle_i): Ditto.

* enum.c (each_with_index): Update rdoc.  each_with_index() takes
  argments that are passed through to each(), and a hash preserves
  key order.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16391 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-12 11:21:39 +00:00
nobu 8481c848da * enum.c (all_iter_i, any_iter_i): reduced duplicated code.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16366 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-11 14:19:41 +00:00
nobu 93df43f8ae * enum.c: removed trailing garbage spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16365 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-11 14:10:20 +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
matz 3734fd0e79 * enum.c (count_i): modified to shut warning up.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15975 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-11 08:36:47 +00:00
knu f9c5484cc5 * enum.c (count_i, count_iter_i, enum_count, enum_find_index):
Reduce code.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15974 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-11 08:26:45 +00:00
matz f79e9281ff * enum.c (find_index_i): modified to shut warning up.
* enum.c (find_index_iter_i): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15973 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-11 08:06:31 +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
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
matz 1d2078824f * enum.c (zip_ary): wrong boundary condition.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15765 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-13 16:38:23 +00:00
matz 2b1b74a099 * enum.c (enum_zip): optimize if all arguments are arrays.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15751 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-11 16:20:44 +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
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
mame 0dba38026a * enum.c (enum_one, enum_take_while, enum_drop_while): fix documents.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15221 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-24 14:23:51 +00:00
jeg2 8ed70a5186 * enum.c: Updating the documentation of Enumrable#zip to reflect
the recent changes Matz made to the method.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14959 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-08 23:42:38 +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
matz f46baadb56 * enum.c (collect_all): should pack all values. [ruby-core:14410]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14670 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-25 06:22:27 +00:00
matz 54cf2fca17 * enum.c (enum_yield): when multiple values yielded from #each
pack them into an array.  [ruby-dev:32708]

* enum.c: all method but all?, any?, one? and none? passed packed
  multiple values to the block.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14667 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-25 06:01:22 +00:00
matz 9bfdc4e736 * enum.c (enum_inject): updated documentation. a patch from Keita
Yamaguchi <keita.yamaguchi@gmail.com> in [ruby-dev:32686].

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14556 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-23 20:35:12 +00:00
akr d4463c42c0 * enum.c (enum_count): suppress warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14136 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-08 08:53:20 +00:00
matz 9497f7996a * enum.c (enum_count): precise argument number check.
* enum.c (enum_count): return Enumerator if no block given.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14049 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-30 10:08:03 +00:00
matz 58c070aa9b * enum.c (enum_take_while): returns Enumerator if no block given.
* enum.c (enum_drop_while): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14047 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-30 08:15:12 +00:00
matz c23d672932 * enum.c (each_with_index_i): use rb_yield_values() for
compatibility with Enumerator#with_index().  a patch from Yusuke
  ENDOH <mame AT tsg.ne.jp>.  [ruby-dev:32195]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13850 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-09 04:59:07 +00:00
nobu ec0187ef15 * enum.c (enum_each_with_index): make different arrays at each
iteration.  [ruby-dev:32181]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13833 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-07 06:07:52 +00:00
davidflanagan d04b7871a1 * enum.c (take_while_i, drop_while_i) add RTEST to handle nil return
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13800 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-01 05:53:52 +00:00
usa 4905959e34 * enum.c (enum_drop): fix typo.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13798 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-31 16:53:04 +00:00
matz d2a1637d90 * enum.c (enum_take_while): separate with-block form.
* enum.c (drop_while_i): ditto.

* enum.c (enum_butfirst): abandon butfirst method.  reverted.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13794 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-30 23:43:26 +00:00
matz a68451d610 * enum.c (enum_butfirst): add a new method to iterates over
elements but first n.  RDoc need to be updated.

* enumerator.c (Init_Enumerator): remove unnecessary symbol
  initialization.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13793 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-30 01:06:10 +00:00
matz 15112cf003 * enum.c (enum_cycle): hide temporary array from ObjectSpace.
[ruby-core:12762]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13754 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-22 15:29:17 +00:00
matz 0c7d366e47 * enum.c (enum_find_index): update RDoc. a patch from David Flanagan
<david AT davidflanagan.com> in [ruby-core:12710].

* enum.c (enum_take, enum_drop): ditto.

* enum.c (enum_cycle): should not cause infinite loop for empty
  arrays.  [ruby-core:12710]

  <david AT davidflanagan.com> in [ruby-core:12710].

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13738 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-18 08:12:27 +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 8cb190c416 * enum.c (enum_inject): RDoc update. a patch from David Flanagan
<david AT davidflanagan.com> in [ruby-core:12679]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13713 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-15 16:41:30 +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