Commit graph

82 commits

Author SHA1 Message Date
knu
8fc8d598c9 * array.c (rb_ary_collect), enum.c (enum_collect): rb_warn() is a
bit too noisy when RubyGems, so change it to rb_warning().


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@39959 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-27 02:10:29 +00:00
knu
03373b29e3 * array.c (rb_ary_collect), enum.c (enum_collect): Add
compatibility warnings for a call without a block.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@31013 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-03-03 08:11:16 +00:00
knu
02228688c5 * enum.c (Enumerable#each_entry): New method.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@27059 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-03-26 03:45:32 +00:00
nobu
3f0d0b9398 * *.[chy]: removed trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@25430 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-10-22 01:00:18 +00:00
knu
c5a88815d9 * enum.c (enum_first): Perform negative length check before
attempting to make an array.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@23874 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-06-27 20:10:45 +00:00
matz
dde8e24217 * enum.c (first_i): Enumerator#first should consume only what is
needed.   a patch from Marc-Andre Lafortune.  [ruby-core:23661]

* enum.c (take_i): ditto.

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

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@23624 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-06-03 00:08:43 +00:00
usa
f1b84d1bcf * enum.c (count_i, count_iter_i, count_all_i): add prototypes for VC.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16696 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-29 20:29:27 +00:00
knu
14dd72b35a * enum.c (count_i, count_iter_i): Sync with trunk.
enum.c (enum_count, count_all_i, Init_Enumerable),
  array.c (rb_ary_count): Sync with trunk.  If no argument or
  block is given, count the number of all elements.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16694 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-29 19:35:04 +00:00
knu
90282e4057 * 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/branches/ruby_1_8@16639 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-27 10:25:49 +00:00
knu
a041e91c6c Cosmetic.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16638 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-27 10:18:56 +00:00
nobu
a580ccf6e3 * enum.c (all_iter_i, any_iter_i): reduced duplicated code.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16366 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-11 14:19:41 +00:00
nobu
2c7ff4527d * enum.c: removed trailing garbage spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16365 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-11 14:10:20 +00:00
usa
68cab8a24b * enum.c (inject_i, inject_op_i): prototype.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16013 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-14 10:19:41 +00:00
knu
1b90348252 * enum.c New methods: Enumerable#take, #take_while, #drop and
#drop_while; backported from 1.9.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16012 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-14 10:12:17 +00:00
knu
0e5c1f9981 * enum.c: New methods: Enumerable#one?, #none?, #minmax, #min_by,
#max_by, #minmax_by and #cycle; backported from 1.9.

* enum.c (enum_find_index): Add support for find_index(obj);
  [ruby-dev:34313]; backported from 1.9.

* enum.c (enum_inject): Add support for Enumerable#inject(:binop);
  backported from 1.9.

* enum.c: Alias Enumerable#reject to #inject; backported from 1.9.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16011 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-14 10:00:16 +00:00
knu
f5f1a18ceb * enum.c (enum_find, enum_reject): Return an enumerator if no
block is given.

* io.c (rb_io_each_line, rb_io_each_byte, rb_io_s_foreach,
  argf_each_line, argf_each_byte): Ditto.

* string.c (str_gsub): Ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16010 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-14 09:19:52 +00:00
usa
feb1dfdfc6 * enum.c (find_index_i, find_index_iter_i): add prototype for VC.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16009 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-14 09:10:40 +00:00
knu
125d830eb8 * array.c (rb_ary_collect_bang, rb_ary_select): Return an
enumerator if no block is given.

* dir.c (dir_each, dir_foreach): Return an enumerator if no block
  is given.

* enum.c (enum_partition, enum_sort_by): Ditto.

* gc.c (os_each_obj): Ditto.

* hash.c (rb_hash_delete_if, rb_hash_reject_bang, rb_hash_select,
  rb_hash_each_value, rb_hash_each_key, rb_hash_each_pair,
  env_each_key, env_each_value, env_each, env_each_pair,
  env_reject_bang, env_delete_if, env_select): Ditto.

* numeric.c (num_step, int_upto, int_downto, int_dotimes): Ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16008 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-14 08:57:23 +00:00
knu
39df01c4af fix a typo
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16007 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-14 08:37:04 +00:00
knu
8ca8703de2 * enum.c (enum_count, enum_find_index): New methods:
Enumerable#count and #find_index; backported from 1.9.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16004 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-14 07:04:30 +00:00
knu
eeae41fba9 * enum.c (enum_first, enum_group_by): New methods:
Enumerable#first and #group_by; backported from 1.9.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@15956 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-10 11:12:08 +00:00
usa
da277e53d3 * enum.c (iterate_method): add prototype to avoid warning on VC++.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@15944 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-09 16:43:14 +00:00
knu
fd8c8d09f4 * enumerator.c, inits.c (rb_call_inits), ruby.h, intern.h,
ext/enumerator, common.mk (OBJS, enumerator.$(OBJEXT)): Make the
  enumerator module built-in,

* enumerator.c: New method: Enumerable::Enumerator#with_index.

* enum.c (enum_each_with_index): Enumerable#each_with_index now
  returns an enumerator instead of raising an exception if no
  block is given.  Enumerable#enum_with_index, formerly defined in
  the enumerator module, is kept as an alias to each_with_index
  for backward compatibility.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@15934 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-09 11:13:04 +00:00
nobu
d9ef35c83f * enum.c (sort_by_cmp): check if reentered. [ruby-dev:24291]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@12784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-14 05:04:09 +00:00
drbrain
63bc7ad4f9 Documentation typo
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@10269 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-15 01:24:40 +00:00
nobu
4c04407b19 * enum.c (enum_min, enum_max): must not return Qundef.
fixed: [ruby-core:05299]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@8685 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-06-30 16:46:13 +00:00
nobu
47679bcf0a * enum.c (enum_min, enum_max): do not ignore nil as the first element.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@8665 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-06-25 06:49:40 +00:00
nobu
10117968d4 * enum.c (enum_inject): default the result value to Qundef to use
first element as initial value if not given.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@8603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-06-09 14:36:02 +00:00
nobu
aac8fbf09f * enum.c (enum_min_by, enum_max_by): return nil if no iteration.
fixed: [ruby-dev:26245]

* eval.c (rb_need_block): ensure a block is given.

* eval.c (backtrace): skip successive frames sharing same node.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@8590 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-06-07 23:33:51 +00:00
matz
c2a9b62fd2 * string.c (rb_str_locktmp): lock string temporarily.
* string.c (str_independent): add tmplock check.

* io.c (io_write): lock output string temporarily.
  [ruby-dev:24649]

* io.c (io_write): use rb_str_locktmp().

* io.c (read_all): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7149 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-10-30 15:33:03 +00:00
matz
2ec51ee0d5 * string.c (str_gsub): reentrant check. [ruby-dev:24432]
* backport all SEGV bug fixes from CVS HEAD.  [ruby-dev:24536]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7090 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-10-20 12:47:20 +00:00
matz
860bdc3b61 * io.c (read_all): block string buffer modification during
rb_io_fread() by freezing it temporarily. [ruby-dev:24479]

* dir.c (rb_push_glob): block call at once the end of method.
  [ruby-dev:24487]

* ext/enumerator/enumerator.c (enum_each_slice): remove
  rb_gc_force_recycle() to prevent potential SEGV.
  [ruby-dev:24499]

* ext/zlib/zlib.c (zstream_expand_buffer): hide internal string
  buffer by clearing klass.  [ruby-dev:24510]

* ext/socket/socket.c (sock_s_getservbyaname): protocol string
  might be altered.  [ruby-dev:24503]

* string.c (rb_str_upto): check if return value from succ is a
  string.  [ruby-dev:24504]

* io.c (rb_io_popen): get mode string via rb_io_flags_mode() to
  avoid mode string modification.  [ruby-dev:24454]

* io.c (rb_io_getline_fast): should take delim as unsigned char to
  distinguish EOF and '\377'.  [ruby-dev:24460]

* io.c (rb_io_getline): add check for RS modification.
  [ruby-dev:24461]

* enum.c (enum_sort_by): use qsort() directly instead using
  rb_iterate().  [ruby-dev:24462]

* enum.c (enum_each_with_index): remove rb_gc_force_recycle() to
  prevent access to recycled object (via continuation for
  example).  [ruby-dev:24463]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7071 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-10-19 10:25:23 +00:00
matz
6f9dcadf6e * string.c (rb_str_sum): check was done with false pointer.
[ruby-dev:24383]

* string.c (rb_str_sum): string may be altered.  [ruby-dev:24381]

* eval.c (rb_f_eval): defer pointer retrieval to prevent unsafe
  sourcefile string modification.  [ruby-dev:24373]

* io.c (io_read): block string buffer modification during
  rb_io_fread() by freezing it temporarily. [ruby-dev:24366]

* io.c (rb_io_s_popen): mode argument may be altered.
  [ruby-dev:24375]

* file.c (rb_file_s_basename): ext argument may be altered.
  [ruby-dev:24377]

* enum.c (enum_sort_by): use NODE instead of 2 element arrays.
  [ruby-dev:24378]

* string.c (rb_str_chomp_bang): StringValue() may change the
  receiver.  [ruby-dev:24371]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@6979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-10-02 03:50:53 +00:00
nobu
e8c1c4411f * enum.c (sort_by_i): internally used object must not be changed
outside.  [ruby-dev:24368]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@6970 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-09-29 01:58:43 +00:00
matz
ba19ba779c * array.c (rb_ary_uniq_bang): element size might change during
comparison.  [ruby-dev:24298]

* enum.c (enum_sort_by): do not use qsort directly.  use
  rb_ary_sort_bang() instead.  [ruby-dev:24291]

* enum.c (enum_sort_by): pedantic type check added.
  [ruby-dev:24291]

* hash.c (rb_hash_foreach_iter): check iter_lev after each
  iteration.  [ruby-dev:24289]

* array.c (rb_ary_and): element size might change during
  comparison.  [ruby-dev:24290]

* array.c (rb_ary_or): ditto. [ruby-dev:24292]

* array.c (rb_ary_equal): wrong fix. [ruby-dev:24286]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@6940 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-09-21 09:35:29 +00:00
dave
91c9ac216a minor rdoc typo in enum#min
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@6627 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-07-14 13:02:27 +00:00
ocean
703f913426 * array.c, enum.c, pack.c: rdoc patch from Johan Holmberg
<holmberg@iar.se> [ruby-core:3132] [ruby-core:3136]

* numeric.c: rdoc patch.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@6607 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-07-09 13:38:34 +00:00
nobu
da011c8311 * array.c, enum.c, eval.c, file.c, io.c, numeric.c, object.c, prec.c,
process.c, re.c, string.c: typos in RDoc comments.  [ruby-core:02783]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@6158 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-04-14 04:06:52 +00:00
nobu
db68e1714e * enum.c (enum_find): mention about ifnone argument. [ruby-talk:90003]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@5474 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-01-16 14:07:06 +00:00
dave
d50547c22c Add RDoc for Kernel global functions, tidy array and error
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@5343 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-12-29 03:56:22 +00:00
dave
84f0b051de Annotate enum.c. Add pager support, and report on methods in included modules
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5214 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-12-18 21:08:25 +00:00
matz
fc63eb3a77 * enum.c (each_with_index_i): typo.
* eval.c (rb_yield_splat): should call svalue_to_avalue() before
  calling rb_yield_0().


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4427 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-08-22 17:43:57 +00:00
matz
7ff7bcbf9d * enum.c (inject_i): use rb_yield_values.
* enum.c (each_with_index_i): ditto.

* eval.c (rb_yield_splat): new function to call "yield *values".

* string.c (rb_str_scan): use rb_yield_splat().


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4424 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-08-22 08:09:58 +00:00
matz
82cf98939f * eval.c (rb_yield_0): give warning for multiple values for a
block parameter.

* eval.c (rb_yield_values): a function to yield multiple values.

* array.c (sort_1): use rb_yield_values.

* enum.c (min_ii, max_ii): ditto.

* hash.c (rb_hash_update_block_i, delete_if_i, select_i,
  each_pair_i, env_each, env_reject_bang, env_select,
  env_update_i): ditto.

* struct.c (rb_struct_each_pair): ditto.

* eval.c (top_include): should include module in the current self,
  not ruby_top_self. [ruby-dev:20198]

* eval.c (top_include): stop inclusion to ruby_wrapper; give
  warning.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3833 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-05-20 06:29:23 +00:00
matz
7e35911e10 * ext/pty/pty.c (pty_finalize_syswait): join (using Thread#value)
before detach pid. [ruby-talk:71519]

* eval.c (PUSH_FRAME): save outer ruby_block. [ruby-list:37677],
  [ruby-dev:20202]

* eval.c (BEGIN_CALLARGS): restore outer block by using
  ruby_block->outer.

* eval.c (block_pass): do not alter block->prev, but block->outer.

* array.c (get_inspect_tbl): warning on wrong condition.

* eval.c (localjump_xvalue): renamed exitstatus to exit_value
  since it's not exit "status" after all.

* eval.c (localjump_error): add reason to LocalJumpError.

* compar.c (rb_cmpint): raise error via rb_cmperr(), if cmp value
  is nil. now take new 2 arguments.

* time.c (time_cmp): 2003-05-16 fix was incomplete.
  (ruby-bugs-ja:PR#458)


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3823 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-05-19 15:45:46 +00:00
michal
4e13d36561 -Wall cleanups (removed unused vars, no 'code has no effect' warnings)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3346 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-01-16 07:38:40 +00:00
michal
9df466b287 Updated Copyrights of Matz to 2003.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3345 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-01-16 07:34:03 +00:00
matz
a973f9698f * enum.c (enum_all): now works without block.
* enum.c (enum_any): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3344 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-01-15 08:07:41 +00:00
matz
e2d384d628 * file.c (rb_find_file_ext): should not terminate searching with
empty path, just ignore.

* dir.c: remove <sys/parm.h> inclusion.

* compar.c (cmp_eq,cmp_gt,cmp_ge,cmp_lt,cmp_le): check using
  rb_cmpint().

* error.c (init_syserr): remove sys_nerr dependency.

* numeric.c (num_cmp): added to satisfy Comparable assumption.

* eval.c (rb_add_method): "initialize" should be public if it is a
  singleton method.

* regex.c (re_match): avoid dereferencing if size == 0.
  (ruby-bugs-ja:PR#360)

* time.c (time_cmp): should return nil if an operand is not a
  number nor time. (ruby-bugs-ja:PR#359)

* file.c (rb_stat_cmp): should return nil if an operand is not
  File::Stat.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3076 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-11-22 09:14:24 +00:00
matz
5315f0d667 * array.c (rb_ary_zip): iterates over items in the receiver.
zipped with nil if argument arrays are shorter.  if arrays are
  longer, left items are ignored.  now works with blocks.

* enum.c (zip_i): changed for new behavior.

* array.c (rb_ary_transpose): added. [new]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3064 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-11-19 08:07:51 +00:00