2000-05-01 05:42:38 -04:00
|
|
|
/**********************************************************************
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
array.c -
|
|
|
|
|
|
|
|
$Author$
|
|
|
|
$Date$
|
|
|
|
created at: Fri Aug 6 09:46:12 JST 1993
|
|
|
|
|
2003-01-16 02:34:03 -05:00
|
|
|
Copyright (C) 1993-2003 Yukihiro Matsumoto
|
2000-05-01 05:42:38 -04:00
|
|
|
Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
|
2000-05-09 00:53:16 -04:00
|
|
|
Copyright (C) 2000 Information-technology Promotion Agency, Japan
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2000-05-01 05:42:38 -04:00
|
|
|
**********************************************************************/
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
#include "ruby.h"
|
1999-01-19 23:59:39 -05:00
|
|
|
#include "util.h"
|
2000-12-05 04:36:54 -05:00
|
|
|
#include "st.h"
|
* array.c: replace rb_protect_inspect() and rb_inspecting_p() by
rb_exec_recursive() in eval.c.
* eval.c (rb_exec_recursive): new function.
* array.c (rb_ary_join): use rb_exec_recursive().
* array.c (rb_ary_inspect, rb_ary_hash): ditto.
* file.c (rb_file_join): ditto.
* hash.c (rb_hash_inspect, rb_hash_to_s, rb_hash_hash): ditto.
* io.c (rb_io_puts): ditto.
* object.c (rb_obj_inspect): ditto
* struct.c (rb_struct_inspect): ditto.
* lib/set.rb (SortedSet::setup): a hack to shut up warning.
[ruby-talk:132866]
* lib/time.rb (Time::strptime): add new function. inspired by
[ruby-talk:132815].
* lib/parsedate.rb (ParseDate::strptime): ditto.
* regparse.c: move st_*_strend() functions from st.c. fixed some
potential memory leaks.
* exception error messages updated. [ruby-core:04497]
* ext/socket/socket.c (Init_socket): add bunch of Socket
constants. Patch from Sam Roberts <sroberts@uniserve.com>.
[ruby-core:04409]
* array.c (rb_ary_s_create): no need for negative argc check.
[ruby-core:04463]
* array.c (rb_ary_unshift_m): ditto.
* lib/xmlrpc/parser.rb (XMLRPC::FaultException): make it subclass
of StandardError class, not Exception class. [ruby-core:04429]
* parse.y (fcall_gen): lvar(arg) will be evaluated as
lvar.call(arg) when lvar is a defined local variable. [new]
* object.c (rb_class_initialize): call inherited method before
calling initializing block.
* eval.c (rb_thread_start_1): initialize newly pushed frame.
* lib/open3.rb (Open3::popen3): $? should not be EXIT_FAILURE.
fixed: [ruby-core:04444]
* eval.c (is_defined): NODE_IASGN is an assignment.
* ext/readline/readline.c (Readline.readline): use rl_outstream
and rl_instream. [ruby-dev:25699]
* ext/etc/etc.c (Init_etc): sGroup needs HAVE_ST_GR_PASSWD check
[ruby-dev:25675]
* misc/ruby-mode.el: [ruby-core:04415]
* lib/rdoc/generators/html_generator.rb: [ruby-core:04412]
* lib/rdoc/generators/ri_generator.rb: ditto.
* struct.c (make_struct): fixed: [ruby-core:04402]
* ext/curses/curses.c (window_color_set): [ruby-core:04393]
* ext/socket/socket.c (Init_socket): SO_REUSEPORT added.
[ruby-talk:130092]
* object.c: [ruby-doc:818]
* parse.y (open_args): fix too verbose warnings for the space
before argument parentheses. [ruby-dev:25492]
* parse.y (parser_yylex): ditto.
* parse.y (parser_yylex): the first expression in the parentheses
should not be a command. [ruby-dev:25492]
* lib/irb/context.rb (IRB::Context::initialize): [ruby-core:04330]
* object.c (Init_Object): remove Object#type. [ruby-core:04335]
* st.c (st_foreach): report success/failure by return value.
[ruby-Bugs-1396]
* parse.y: forgot to initialize parser struct. [ruby-dev:25492]
* parse.y (parser_yylex): no tLABEL on EXPR_BEG.
[ruby-talk:127711]
* document updates - [ruby-core:04296], [ruby-core:04301],
[ruby-core:04302], [ruby-core:04307]
* dir.c (rb_push_glob): should work for NUL delimited patterns.
* dir.c (rb_glob2): should aware of offset in the pattern.
* string.c (rb_str_new4): should propagate taintedness.
* env.h: rename member names in struct FRAME; last_func -> callee,
orig_func -> this_func, last_class -> this_class.
* struct.c (rb_struct_set): use original method name, not callee
name, to retrieve member slot. [ruby-core:04268]
* time.c (time_strftime): protect from format modification from GC
finalizers.
* object.c (Init_Object): remove rb_obj_id_obsolete()
* eval.c (rb_mod_define_method): incomplete subclass check.
[ruby-dev:25464]
* gc.c (rb_data_object_alloc): klass may be NULL.
[ruby-list:40498]
* bignum.c (rb_big_rand): should return positive random number.
[ruby-dev:25401]
* bignum.c (rb_big_rand): do not use rb_big_modulo to generate
random bignums. [ruby-dev:25396]
* variable.c (rb_autoload): [ruby-dev:25373]
* eval.c (svalue_to_avalue): [ruby-dev:25366]
* string.c (rb_str_justify): [ruby-dev:25367]
* io.c (rb_f_select): [ruby-dev:25312]
* ext/socket/socket.c (sock_s_getservbyport): [ruby-talk:124072]
* struct.c (make_struct): [ruby-dev:25249]
* dir.c (dir_open_dir): new function. [ruby-dev:25242]
* io.c (rb_f_open): add type check for return value from to_open.
* lib/pstore.rb (PStore#transaction): Use the empty content when a
file is not found. [ruby-dev:24561]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-03-04 01:47:45 -05:00
|
|
|
#include "node.h"
|
1998-01-16 07:13:05 -05:00
|
|
|
|
* sprintf.c (rb_str_format): allow %c to print one character
string (e.g. ?x).
* lib/tempfile.rb (Tempfile::make_tmpname): put dot between
basename and pid. [ruby-talk:196272]
* parse.y (do_block): remove -> style block.
* parse.y (parser_yylex): remove tLAMBDA_ARG.
* eval.c (rb_call0): binding for the return event hook should have
consistent scope. [ruby-core:07928]
* eval.c (proc_invoke): return behavior should depend whether it
is surrounded by a lambda or a mere block.
* eval.c (formal_assign): handles post splat arguments.
* eval.c (rb_call0): ditto.
* st.c (strhash): use FNV-1a hash.
* parse.y (parser_yylex): removed experimental ';;' terminator.
* eval.c (rb_node_arity): should be aware of post splat arguments.
* eval.c (rb_proc_arity): ditto.
* parse.y (f_args): syntax rule enhanced to support arguments
after the splat.
* parse.y (block_param): ditto for block parameters.
* parse.y (f_post_arg): mandatory formal arguments after the splat
argument.
* parse.y (new_args_gen): generate nodes for mandatory formal
arguments after the splat argument.
* eval.c (rb_eval): dispatch mandatory formal arguments after the
splat argument.
* parse.y (args): allow more than one splat in the argument list.
* parse.y (method_call): allow aref [] to accept all kind of
method argument, including assocs, splat, and block argument.
* eval.c (SETUP_ARGS0): prepare block argument as well.
* lib/mathn.rb (Integer): remove Integer#gcd2. [ruby-core:07931]
* eval.c (error_line): print receivers true/false/nil specially.
* eval.c (rb_proc_yield): handles parameters in yield semantics.
* eval.c (nil_yield): gives LocalJumpError to denote no block
error.
* io.c (rb_io_getc): now takes one-character string.
* string.c (rb_str_hash): use FNV-1a hash from Fowler/Noll/Vo
hashing algorithm.
* string.c (rb_str_aref): str[0] now returns 1 character string,
instead of a fixnum. [Ruby2]
* parse.y (parser_yylex): ?c now returns 1 character string,
instead of a fixnum. [Ruby2]
* string.c (rb_str_aset): no longer support fixnum insertion.
* eval.c (umethod_bind): should not update original class.
[ruby-dev:28636]
* eval.c (ev_const_get): should support constant access from
within instance_eval(). [ruby-dev:28327]
* time.c (time_timeval): should round for usec floating
number. [ruby-core:07896]
* time.c (time_add): ditto.
* dir.c (sys_warning): should not call a vararg function
rb_sys_warning() indirectly. [ruby-core:07886]
* numeric.c (flo_divmod): the first element of Float#divmod should
be an integer. [ruby-dev:28589]
* test/ruby/test_float.rb: add tests for divmod, div, modulo and remainder.
* re.c (rb_reg_initialize): should not allow modifying literal
regexps. frozen check moved from rb_reg_initialize_m as well.
* re.c (rb_reg_initialize): should not modify untainted objects in
safe levels higher than 3.
* re.c (rb_memcmp): type change from char* to const void*.
* dir.c (dir_close): should not close untainted dir stream.
* dir.c (GetDIR): add tainted/frozen check for each dir operation.
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_symbol_arg):
typo fixed. a patch from Florian Gross <florg at florg.net>.
* eval.c (EXEC_EVENT_HOOK): trace_func may remove itself from
event_hooks. no guarantee for arbitrary hook deletion.
[ruby-dev:28632]
* util.c (ruby_strtod): differ addition to minimize error.
[ruby-dev:28619]
* util.c (ruby_strtod): should not raise ERANGE when the input
string does not have any digits. [ruby-dev:28629]
* eval.c (proc_invoke): should restore old ruby_frame->block.
thanks to ts <decoux at moulon.inra.fr>. [ruby-core:07833]
also fix [ruby-dev:28614] as well.
* signal.c (trap): sig should be less then NSIG. Coverity found
this bug. a patch from Kevin Tew <tewk at tewk.com>.
[ruby-core:07823]
* math.c (math_log2): add new method inspired by
[ruby-talk:191237].
* math.c (math_log): add optional base argument to Math::log().
[ruby-talk:191308]
* ext/syck/emitter.c (syck_scan_scalar): avoid accessing
uninitialized array element. a patch from Pat Eyler
<rubypate at gmail.com>. [ruby-core:07809]
* array.c (rb_ary_fill): initialize local variables first. a
patch from Pat Eyler <rubypate at gmail.com>. [ruby-core:07810]
* ext/syck/yaml2byte.c (syck_yaml2byte_handler): need to free
type_tag. a patch from Pat Eyler <rubypate at gmail.com>.
[ruby-core:07808]
* ext/socket/socket.c (make_hostent_internal): accept ai_family
check from Sam Roberts <sroberts at uniserve.com>.
[ruby-core:07691]
* util.c (ruby_strtod): should not cut off 18 digits for no
reason. [ruby-core:07796]
* array.c (rb_ary_fill): internalize local variable "beg" to
pacify Coverity. [ruby-core:07770]
* pack.c (pack_unpack): now supports CRLF newlines. a patch from
<tommy at tmtm.org>. [ruby-dev:28601]
* applied code clean-up patch from Stefan Huehner
<stefan at huehner.org>. [ruby-core:07764]
* lib/jcode.rb (String::tr_s): should have translated non
squeezing character sequence (i.e. a character) as well. thanks
to Hiroshi Ichikawa <gimite at gimite.ddo.jp> [ruby-list:42090]
* ext/socket/socket.c: document update patch from Sam Roberts
<sroberts at uniserve.com>. [ruby-core:07701]
* lib/mathn.rb (Integer): need not to remove gcd2. a patch from
NARUSE, Yui <naruse at airemix.com>. [ruby-dev:28570]
* parse.y (arg): too much NEW_LIST()
* eval.c (SETUP_ARGS0): remove unnecessary access to nd_alen.
* eval.c (rb_eval): use ARGSCAT for NODE_OP_ASGN1.
[ruby-dev:28585]
* parse.y (arg): use NODE_ARGSCAT for placeholder.
* lib/getoptlong.rb (GetoptLong::get): RDoc update patch from
mathew <meta at pobox.com>. [ruby-core:07738]
* variable.c (rb_const_set): raise error when no target klass is
supplied. [ruby-dev:28582]
* prec.c (prec_prec_f): documentation patch from
<gerardo.santana at gmail.com>. [ruby-core:07689]
* bignum.c (rb_big_pow): second operand may be too big even if
it's a Fixnum. [ruby-talk:187984]
* README.EXT: update symbol description. [ruby-talk:188104]
* COPYING: explicitly note GPLv2. [ruby-talk:187922]
* parse.y: remove some obsolete syntax rules (unparenthesized
method calls in argument list).
* eval.c (rb_call0): insecure calling should be checked for non
NODE_SCOPE method invocations too.
* eval.c (rb_alias): should preserve the current safe level as
well as method definition.
* process.c (rb_f_sleep): remove RDoc description about SIGALRM
which is not valid on the current implementation. [ruby-dev:28464]
Thu Mar 23 21:40:47 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
* eval.c (method_missing): should support argument splat in
super. a bug in combination of super, splat and
method_missing. [ruby-talk:185438]
* configure.in: Solaris SunPro compiler -rapth patch from
<kuwa at labs.fujitsu.com>. [ruby-dev:28443]
* configure.in: remove enable_rpath=no for Solaris.
[ruby-dev:28440]
* ext/win32ole/win32ole.c (ole_val2olevariantdata): change behavior
of converting OLE Variant object with VT_ARRAY|VT_UI1 and Ruby
String object.
* ruby.1: a clarification patch from David Lutterkort
<dlutter at redhat.com>. [ruby-core:7508]
* lib/rdoc/ri/ri_paths.rb (RI::Paths): adding paths from rubygems
directories. a patch from Eric Hodel <drbrain at segment7.net>.
[ruby-core:07423]
* eval.c (rb_clear_cache_by_class): clearing wrong cache.
* ext/extmk.rb: use :remove_destination to install extension libraries
to avoid SEGV. [ruby-dev:28417]
* eval.c (rb_thread_fd_writable): should not re-schedule output
from KILLED thread (must be error printing).
* array.c (rb_ary_flatten_bang): allow specifying recursion
level. [ruby-talk:182170]
* array.c (rb_ary_flatten): ditto.
* gc.c (add_heap): a heap_slots may overflow. a patch from Stefan
Weil <weil at mail.berlios.de>.
* eval.c (rb_call): use separate cache for fcall/vcall
invocation.
* eval.c (rb_eval): NODE_FCALL, NODE_VCALL can call local
functions.
* eval.c (rb_mod_local): a new method to specify newly added
visibility "local".
* eval.c (search_method): search for local methods which are
visible only from the current class.
* class.c (rb_class_local_methods): a method to list local methods.
* object.c (Init_Object): add BasicObject class as a top level
BlankSlate class.
* ruby.h (SYM2ID): should not cast to signed long.
[ruby-core:07414]
* class.c (rb_include_module): allow module duplication.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-09 17:20:17 -04:00
|
|
|
VALUE rb_cArray;
|
2004-04-06 22:51:05 -04:00
|
|
|
|
2001-12-10 02:18:16 -05:00
|
|
|
static ID id_cmp;
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
#define ARY_DEFAULT_SIZE 16
|
|
|
|
|
|
|
|
void
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_mem_clear(register VALUE *mem, register long size)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
|
|
|
while (size--) {
|
|
|
|
*mem++ = Qnil;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-06-16 03:05:24 -04:00
|
|
|
static inline void
|
2005-09-10 09:34:53 -04:00
|
|
|
memfill(register VALUE *mem, register long size, register VALUE val)
|
1999-01-19 23:59:39 -05:00
|
|
|
{
|
|
|
|
while (size--) {
|
|
|
|
*mem++ = val;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
* array.c (ary_iter_check): should check modification (size
change) during iteration.
* array.c (rb_ary_initialize, rb_ary_shift, rb_ary_unshift,
rb_ary_splice, rb_ary_reverse, rb_ary_sort, rb_ary_delete,
rb_ary_delete_at, rb_ary_reject_bang, rb_ary_replace,
rb_ary_clear, rb_ary_fill, rb_ary_uniq_bang, rb_ary_compact,
rb_ary_shuffle): add iteration check.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-12-29 14:25:11 -05:00
|
|
|
#define ARY_ITERLOCK FL_USER1
|
|
|
|
static void
|
|
|
|
ary_iter_check(VALUE ary)
|
|
|
|
{
|
|
|
|
if (FL_TEST(ary, ARY_ITERLOCK)) {
|
2006-12-31 10:02:22 -05:00
|
|
|
rb_raise(rb_eRuntimeError, "can't modify array during iteration");
|
* array.c (ary_iter_check): should check modification (size
change) during iteration.
* array.c (rb_ary_initialize, rb_ary_shift, rb_ary_unshift,
rb_ary_splice, rb_ary_reverse, rb_ary_sort, rb_ary_delete,
rb_ary_delete_at, rb_ary_reject_bang, rb_ary_replace,
rb_ary_clear, rb_ary_fill, rb_ary_uniq_bang, rb_ary_compact,
rb_ary_shuffle): add iteration check.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-12-29 14:25:11 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#define ARY_SORTLOCK FL_USER3
|
2006-09-02 10:42:08 -04:00
|
|
|
#define ARY_SHARED_P(a) FL_TEST(a, ELTS_SHARED)
|
|
|
|
|
|
|
|
#define ARY_SET_LEN(ary, n) do { \
|
2006-11-01 09:42:39 -05:00
|
|
|
RARRAY(ary)->len = (n);\
|
2006-09-02 10:42:08 -04:00
|
|
|
} while (0)
|
|
|
|
|
2006-11-01 09:42:39 -05:00
|
|
|
#define ARY_CAPA(ary) RARRAY(ary)->aux.capa
|
2006-09-02 10:42:08 -04:00
|
|
|
#define RESIZE_CAPA(ary,capacity) do {\
|
2006-11-01 19:19:57 -05:00
|
|
|
REALLOC_N(RARRAY(ary)->ptr, VALUE, (capacity));\
|
|
|
|
RARRAY(ary)->aux.capa = (capacity);\
|
2006-09-02 10:42:08 -04:00
|
|
|
} while (0)
|
|
|
|
|
* array.c (ary_iter_check): should check modification (size
change) during iteration.
* array.c (rb_ary_initialize, rb_ary_shift, rb_ary_unshift,
rb_ary_splice, rb_ary_reverse, rb_ary_sort, rb_ary_delete,
rb_ary_delete_at, rb_ary_reject_bang, rb_ary_replace,
rb_ary_clear, rb_ary_fill, rb_ary_uniq_bang, rb_ary_compact,
rb_ary_shuffle): add iteration check.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-12-29 14:25:11 -05:00
|
|
|
#define ITERATE(func, ary) do { \
|
|
|
|
FL_SET(ary, ARY_ITERLOCK); \
|
|
|
|
return rb_ensure(func, (ary), each_unlock, (ary));\
|
|
|
|
} while (0)
|
|
|
|
|
2006-09-02 10:42:08 -04:00
|
|
|
static VALUE *
|
|
|
|
rb_ary_ptr(VALUE ary)
|
|
|
|
{
|
|
|
|
return RARRAY_PTR(ary);
|
|
|
|
}
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2003-01-08 01:05:08 -05:00
|
|
|
static inline void
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_modify_check(VALUE ary)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
2000-01-31 22:12:21 -05:00
|
|
|
if (OBJ_FROZEN(ary)) rb_error_frozen("array");
|
* array.c (ary_iter_check): should check modification (size
change) during iteration.
* array.c (rb_ary_initialize, rb_ary_shift, rb_ary_unshift,
rb_ary_splice, rb_ary_reverse, rb_ary_sort, rb_ary_delete,
rb_ary_delete_at, rb_ary_reject_bang, rb_ary_replace,
rb_ary_clear, rb_ary_fill, rb_ary_uniq_bang, rb_ary_compact,
rb_ary_shuffle): add iteration check.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-12-29 14:25:11 -05:00
|
|
|
if (FL_TEST(ary, ARY_SORTLOCK))
|
|
|
|
rb_raise(rb_eRuntimeError, "can't modify array during sort");
|
1999-12-14 01:50:43 -05:00
|
|
|
if (!OBJ_TAINTED(ary) && rb_safe_level() >= 4)
|
1999-01-19 23:59:39 -05:00
|
|
|
rb_raise(rb_eSecurityError, "Insecure: can't modify array");
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2001-12-10 02:18:16 -05:00
|
|
|
static void
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_modify(VALUE ary)
|
2001-12-10 02:18:16 -05:00
|
|
|
{
|
|
|
|
VALUE *ptr;
|
|
|
|
|
|
|
|
rb_ary_modify_check(ary);
|
2006-09-02 10:42:08 -04:00
|
|
|
if (ARY_SHARED_P(ary)) {
|
|
|
|
ptr = ALLOC_N(VALUE, RARRAY_LEN(ary));
|
2002-05-21 01:39:19 -04:00
|
|
|
FL_UNSET(ary, ELTS_SHARED);
|
2006-11-01 09:42:39 -05:00
|
|
|
RARRAY(ary)->aux.capa = RARRAY_LEN(ary);
|
2006-09-02 10:42:08 -04:00
|
|
|
MEMCPY(ptr, RARRAY_PTR(ary), VALUE, RARRAY_LEN(ary));
|
2006-11-01 09:42:39 -05:00
|
|
|
RARRAY(ary)->ptr = ptr;
|
2002-05-21 01:39:19 -04:00
|
|
|
}
|
2001-12-10 02:18:16 -05:00
|
|
|
}
|
2004-06-16 03:05:24 -04:00
|
|
|
|
2000-02-17 02:11:22 -05:00
|
|
|
VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_freeze(VALUE ary)
|
2000-02-17 02:11:22 -05:00
|
|
|
{
|
|
|
|
return rb_obj_freeze(ary);
|
|
|
|
}
|
|
|
|
|
2003-12-28 21:02:08 -05:00
|
|
|
/*
|
2004-07-13 12:21:23 -04:00
|
|
|
* call-seq:
|
|
|
|
* array.frozen? -> true or false
|
2003-12-28 21:02:08 -05:00
|
|
|
*
|
2004-07-13 12:21:23 -04:00
|
|
|
* Return <code>true</code> if this array is frozen (or temporarily frozen
|
|
|
|
* while being sorted).
|
2003-12-28 21:02:08 -05:00
|
|
|
*/
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
static VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_frozen_p(VALUE ary)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
2003-11-14 18:54:06 -05:00
|
|
|
if (OBJ_FROZEN(ary)) return Qtrue;
|
* array.c (ary_iter_check): should check modification (size
change) during iteration.
* array.c (rb_ary_initialize, rb_ary_shift, rb_ary_unshift,
rb_ary_splice, rb_ary_reverse, rb_ary_sort, rb_ary_delete,
rb_ary_delete_at, rb_ary_reject_bang, rb_ary_replace,
rb_ary_clear, rb_ary_fill, rb_ary_uniq_bang, rb_ary_compact,
rb_ary_shuffle): add iteration check.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-12-29 14:25:11 -05:00
|
|
|
if (FL_TEST(ary, ARY_SORTLOCK)) return Qtrue;
|
1999-01-19 23:59:39 -05:00
|
|
|
return Qfalse;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2001-10-03 03:19:19 -04:00
|
|
|
static VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
ary_alloc(VALUE klass)
|
2001-10-03 03:19:19 -04:00
|
|
|
{
|
|
|
|
NEWOBJ(ary, struct RArray);
|
2001-10-05 02:30:42 -04:00
|
|
|
OBJSETUP(ary, klass, T_ARRAY);
|
2001-10-03 03:19:19 -04:00
|
|
|
|
2006-11-01 09:42:39 -05:00
|
|
|
ary->len = 0;
|
|
|
|
ary->ptr = 0;
|
|
|
|
ary->aux.capa = 0;
|
2001-10-03 03:19:19 -04:00
|
|
|
|
|
|
|
return (VALUE)ary;
|
|
|
|
}
|
|
|
|
|
2001-12-10 02:18:16 -05:00
|
|
|
static VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
ary_new(VALUE klass, long len)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
2004-06-16 03:05:24 -04:00
|
|
|
VALUE ary;
|
1998-01-16 07:13:05 -05:00
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
if (len < 0) {
|
|
|
|
rb_raise(rb_eArgError, "negative array size (or size too big)");
|
|
|
|
}
|
2002-08-19 01:56:09 -04:00
|
|
|
if (len > 0 && len * sizeof(VALUE) <= len) {
|
1999-01-19 23:59:39 -05:00
|
|
|
rb_raise(rb_eArgError, "array size too big");
|
|
|
|
}
|
2004-06-16 03:05:24 -04:00
|
|
|
ary = ary_alloc(klass);
|
2006-12-31 10:02:22 -05:00
|
|
|
if (len == 0) len++;
|
2006-11-01 09:42:39 -05:00
|
|
|
RARRAY(ary)->ptr = ALLOC_N(VALUE, len);
|
|
|
|
RARRAY(ary)->aux.capa = len;
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2001-10-03 03:19:19 -04:00
|
|
|
return ary;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2001-10-15 23:27:23 -04:00
|
|
|
VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_new2(long len)
|
2001-10-15 23:27:23 -04:00
|
|
|
{
|
2001-12-10 02:18:16 -05:00
|
|
|
return ary_new(rb_cArray, len);
|
2001-10-15 23:27:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_new(void)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
1999-01-19 23:59:39 -05:00
|
|
|
return rb_ary_new2(ARY_DEFAULT_SIZE);
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
#include <stdarg.h>
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
VALUE
|
1999-08-13 01:45:20 -04:00
|
|
|
rb_ary_new3(long n, ...)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
|
|
|
va_list ar;
|
1998-01-16 07:19:22 -05:00
|
|
|
VALUE ary;
|
1999-08-13 01:45:20 -04:00
|
|
|
long i;
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2002-05-21 01:39:19 -04:00
|
|
|
ary = rb_ary_new2(n);
|
1998-01-16 07:13:05 -05:00
|
|
|
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
va_start(ar, n);
|
1998-01-16 07:13:05 -05:00
|
|
|
for (i=0; i<n; i++) {
|
2006-09-02 10:42:08 -04:00
|
|
|
RARRAY_PTR(ary)[i] = va_arg(ar, VALUE);
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
va_end(ar);
|
|
|
|
|
2006-11-01 09:42:39 -05:00
|
|
|
RARRAY(ary)->len = n;
|
1998-01-16 07:19:22 -05:00
|
|
|
return ary;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_new4(long n, const VALUE *elts)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
1998-01-16 07:19:22 -05:00
|
|
|
VALUE ary;
|
1998-01-16 07:13:05 -05:00
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
ary = rb_ary_new2(n);
|
2001-10-03 03:19:19 -04:00
|
|
|
if (n > 0 && elts) {
|
2006-09-02 10:42:08 -04:00
|
|
|
MEMCPY(RARRAY_PTR(ary), elts, VALUE, n);
|
2006-11-01 09:42:39 -05:00
|
|
|
RARRAY(ary)->len = n;
|
1999-01-19 23:59:39 -05:00
|
|
|
}
|
1998-01-16 07:13:05 -05:00
|
|
|
|
1998-01-16 07:19:22 -05:00
|
|
|
return ary;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2006-09-26 18:46:16 -04:00
|
|
|
void
|
|
|
|
rb_ary_free(VALUE ary)
|
|
|
|
{
|
2006-11-01 09:42:39 -05:00
|
|
|
if (!ARY_SHARED_P(ary)) {
|
2006-11-01 19:19:57 -05:00
|
|
|
xfree(RARRAY(ary)->ptr);
|
2006-09-26 18:46:16 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-09-24 01:53:43 -04:00
|
|
|
static VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
ary_make_shared(VALUE ary)
|
2004-05-07 04:44:24 -04:00
|
|
|
{
|
2006-09-02 10:42:08 -04:00
|
|
|
if (ARY_SHARED_P(ary)) {
|
2006-11-01 09:42:39 -05:00
|
|
|
return RARRAY(ary)->aux.shared;
|
2006-09-02 10:42:08 -04:00
|
|
|
}
|
|
|
|
else {
|
2004-05-07 04:44:24 -04:00
|
|
|
NEWOBJ(shared, struct RArray);
|
2006-09-02 10:42:08 -04:00
|
|
|
OBJSETUP(shared, 0, T_ARRAY);
|
2004-05-07 04:44:24 -04:00
|
|
|
|
2006-11-01 09:42:39 -05:00
|
|
|
shared->len = RARRAY(ary)->len;
|
|
|
|
shared->ptr = RARRAY(ary)->ptr;
|
|
|
|
shared->aux.capa = RARRAY(ary)->aux.capa;
|
|
|
|
RARRAY(ary)->aux.shared = (VALUE)shared;
|
2004-05-07 04:44:24 -04:00
|
|
|
FL_SET(ary, ELTS_SHARED);
|
2004-09-24 01:53:43 -04:00
|
|
|
OBJ_FREEZE(shared);
|
|
|
|
return (VALUE)shared;
|
|
|
|
}
|
2004-05-07 04:44:24 -04:00
|
|
|
}
|
|
|
|
|
2004-04-06 22:51:05 -04:00
|
|
|
VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_assoc_new(VALUE car, VALUE cdr)
|
2004-04-06 22:51:05 -04:00
|
|
|
{
|
* sprintf.c (rb_str_format): allow %c to print one character
string (e.g. ?x).
* lib/tempfile.rb (Tempfile::make_tmpname): put dot between
basename and pid. [ruby-talk:196272]
* parse.y (do_block): remove -> style block.
* parse.y (parser_yylex): remove tLAMBDA_ARG.
* eval.c (rb_call0): binding for the return event hook should have
consistent scope. [ruby-core:07928]
* eval.c (proc_invoke): return behavior should depend whether it
is surrounded by a lambda or a mere block.
* eval.c (formal_assign): handles post splat arguments.
* eval.c (rb_call0): ditto.
* st.c (strhash): use FNV-1a hash.
* parse.y (parser_yylex): removed experimental ';;' terminator.
* eval.c (rb_node_arity): should be aware of post splat arguments.
* eval.c (rb_proc_arity): ditto.
* parse.y (f_args): syntax rule enhanced to support arguments
after the splat.
* parse.y (block_param): ditto for block parameters.
* parse.y (f_post_arg): mandatory formal arguments after the splat
argument.
* parse.y (new_args_gen): generate nodes for mandatory formal
arguments after the splat argument.
* eval.c (rb_eval): dispatch mandatory formal arguments after the
splat argument.
* parse.y (args): allow more than one splat in the argument list.
* parse.y (method_call): allow aref [] to accept all kind of
method argument, including assocs, splat, and block argument.
* eval.c (SETUP_ARGS0): prepare block argument as well.
* lib/mathn.rb (Integer): remove Integer#gcd2. [ruby-core:07931]
* eval.c (error_line): print receivers true/false/nil specially.
* eval.c (rb_proc_yield): handles parameters in yield semantics.
* eval.c (nil_yield): gives LocalJumpError to denote no block
error.
* io.c (rb_io_getc): now takes one-character string.
* string.c (rb_str_hash): use FNV-1a hash from Fowler/Noll/Vo
hashing algorithm.
* string.c (rb_str_aref): str[0] now returns 1 character string,
instead of a fixnum. [Ruby2]
* parse.y (parser_yylex): ?c now returns 1 character string,
instead of a fixnum. [Ruby2]
* string.c (rb_str_aset): no longer support fixnum insertion.
* eval.c (umethod_bind): should not update original class.
[ruby-dev:28636]
* eval.c (ev_const_get): should support constant access from
within instance_eval(). [ruby-dev:28327]
* time.c (time_timeval): should round for usec floating
number. [ruby-core:07896]
* time.c (time_add): ditto.
* dir.c (sys_warning): should not call a vararg function
rb_sys_warning() indirectly. [ruby-core:07886]
* numeric.c (flo_divmod): the first element of Float#divmod should
be an integer. [ruby-dev:28589]
* test/ruby/test_float.rb: add tests for divmod, div, modulo and remainder.
* re.c (rb_reg_initialize): should not allow modifying literal
regexps. frozen check moved from rb_reg_initialize_m as well.
* re.c (rb_reg_initialize): should not modify untainted objects in
safe levels higher than 3.
* re.c (rb_memcmp): type change from char* to const void*.
* dir.c (dir_close): should not close untainted dir stream.
* dir.c (GetDIR): add tainted/frozen check for each dir operation.
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_symbol_arg):
typo fixed. a patch from Florian Gross <florg at florg.net>.
* eval.c (EXEC_EVENT_HOOK): trace_func may remove itself from
event_hooks. no guarantee for arbitrary hook deletion.
[ruby-dev:28632]
* util.c (ruby_strtod): differ addition to minimize error.
[ruby-dev:28619]
* util.c (ruby_strtod): should not raise ERANGE when the input
string does not have any digits. [ruby-dev:28629]
* eval.c (proc_invoke): should restore old ruby_frame->block.
thanks to ts <decoux at moulon.inra.fr>. [ruby-core:07833]
also fix [ruby-dev:28614] as well.
* signal.c (trap): sig should be less then NSIG. Coverity found
this bug. a patch from Kevin Tew <tewk at tewk.com>.
[ruby-core:07823]
* math.c (math_log2): add new method inspired by
[ruby-talk:191237].
* math.c (math_log): add optional base argument to Math::log().
[ruby-talk:191308]
* ext/syck/emitter.c (syck_scan_scalar): avoid accessing
uninitialized array element. a patch from Pat Eyler
<rubypate at gmail.com>. [ruby-core:07809]
* array.c (rb_ary_fill): initialize local variables first. a
patch from Pat Eyler <rubypate at gmail.com>. [ruby-core:07810]
* ext/syck/yaml2byte.c (syck_yaml2byte_handler): need to free
type_tag. a patch from Pat Eyler <rubypate at gmail.com>.
[ruby-core:07808]
* ext/socket/socket.c (make_hostent_internal): accept ai_family
check from Sam Roberts <sroberts at uniserve.com>.
[ruby-core:07691]
* util.c (ruby_strtod): should not cut off 18 digits for no
reason. [ruby-core:07796]
* array.c (rb_ary_fill): internalize local variable "beg" to
pacify Coverity. [ruby-core:07770]
* pack.c (pack_unpack): now supports CRLF newlines. a patch from
<tommy at tmtm.org>. [ruby-dev:28601]
* applied code clean-up patch from Stefan Huehner
<stefan at huehner.org>. [ruby-core:07764]
* lib/jcode.rb (String::tr_s): should have translated non
squeezing character sequence (i.e. a character) as well. thanks
to Hiroshi Ichikawa <gimite at gimite.ddo.jp> [ruby-list:42090]
* ext/socket/socket.c: document update patch from Sam Roberts
<sroberts at uniserve.com>. [ruby-core:07701]
* lib/mathn.rb (Integer): need not to remove gcd2. a patch from
NARUSE, Yui <naruse at airemix.com>. [ruby-dev:28570]
* parse.y (arg): too much NEW_LIST()
* eval.c (SETUP_ARGS0): remove unnecessary access to nd_alen.
* eval.c (rb_eval): use ARGSCAT for NODE_OP_ASGN1.
[ruby-dev:28585]
* parse.y (arg): use NODE_ARGSCAT for placeholder.
* lib/getoptlong.rb (GetoptLong::get): RDoc update patch from
mathew <meta at pobox.com>. [ruby-core:07738]
* variable.c (rb_const_set): raise error when no target klass is
supplied. [ruby-dev:28582]
* prec.c (prec_prec_f): documentation patch from
<gerardo.santana at gmail.com>. [ruby-core:07689]
* bignum.c (rb_big_pow): second operand may be too big even if
it's a Fixnum. [ruby-talk:187984]
* README.EXT: update symbol description. [ruby-talk:188104]
* COPYING: explicitly note GPLv2. [ruby-talk:187922]
* parse.y: remove some obsolete syntax rules (unparenthesized
method calls in argument list).
* eval.c (rb_call0): insecure calling should be checked for non
NODE_SCOPE method invocations too.
* eval.c (rb_alias): should preserve the current safe level as
well as method definition.
* process.c (rb_f_sleep): remove RDoc description about SIGALRM
which is not valid on the current implementation. [ruby-dev:28464]
Thu Mar 23 21:40:47 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
* eval.c (method_missing): should support argument splat in
super. a bug in combination of super, splat and
method_missing. [ruby-talk:185438]
* configure.in: Solaris SunPro compiler -rapth patch from
<kuwa at labs.fujitsu.com>. [ruby-dev:28443]
* configure.in: remove enable_rpath=no for Solaris.
[ruby-dev:28440]
* ext/win32ole/win32ole.c (ole_val2olevariantdata): change behavior
of converting OLE Variant object with VT_ARRAY|VT_UI1 and Ruby
String object.
* ruby.1: a clarification patch from David Lutterkort
<dlutter at redhat.com>. [ruby-core:7508]
* lib/rdoc/ri/ri_paths.rb (RI::Paths): adding paths from rubygems
directories. a patch from Eric Hodel <drbrain at segment7.net>.
[ruby-core:07423]
* eval.c (rb_clear_cache_by_class): clearing wrong cache.
* ext/extmk.rb: use :remove_destination to install extension libraries
to avoid SEGV. [ruby-dev:28417]
* eval.c (rb_thread_fd_writable): should not re-schedule output
from KILLED thread (must be error printing).
* array.c (rb_ary_flatten_bang): allow specifying recursion
level. [ruby-talk:182170]
* array.c (rb_ary_flatten): ditto.
* gc.c (add_heap): a heap_slots may overflow. a patch from Stefan
Weil <weil at mail.berlios.de>.
* eval.c (rb_call): use separate cache for fcall/vcall
invocation.
* eval.c (rb_eval): NODE_FCALL, NODE_VCALL can call local
functions.
* eval.c (rb_mod_local): a new method to specify newly added
visibility "local".
* eval.c (search_method): search for local methods which are
visible only from the current class.
* class.c (rb_class_local_methods): a method to list local methods.
* object.c (Init_Object): add BasicObject class as a top level
BlankSlate class.
* ruby.h (SYM2ID): should not cast to signed long.
[ruby-core:07414]
* class.c (rb_include_module): allow module duplication.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-09 17:20:17 -04:00
|
|
|
return rb_ary_new3(2, car, cdr);
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2001-10-02 00:31:23 -04:00
|
|
|
static VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
to_ary(VALUE ary)
|
2001-10-02 00:31:23 -04:00
|
|
|
{
|
|
|
|
return rb_convert_type(ary, T_ARRAY, "Array", "to_ary");
|
|
|
|
}
|
|
|
|
|
2004-03-20 11:45:41 -05:00
|
|
|
static VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
to_a(VALUE ary)
|
2004-03-20 11:45:41 -05:00
|
|
|
{
|
|
|
|
return rb_convert_type(ary, T_ARRAY, "Array", "to_a");
|
|
|
|
}
|
|
|
|
|
2002-12-19 04:20:20 -05:00
|
|
|
VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_check_array_type(VALUE ary)
|
2002-12-19 04:20:20 -05:00
|
|
|
{
|
|
|
|
return rb_check_convert_type(ary, T_ARRAY, "Array", "to_ary");
|
|
|
|
}
|
|
|
|
|
2004-07-13 12:21:23 -04:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* Array.new(size=0, obj=nil)
|
|
|
|
* Array.new(array)
|
|
|
|
* Array.new(size) {|index| block }
|
|
|
|
*
|
|
|
|
* Returns a new array. In the first form, the new array is
|
|
|
|
* empty. In the second it is created with _size_ copies of _obj_
|
|
|
|
* (that is, _size_ references to the same
|
|
|
|
* _obj_). The third form creates a copy of the array
|
|
|
|
* passed as a parameter (the array is generated by calling
|
|
|
|
* to_ary on the parameter). In the last form, an array
|
|
|
|
* of the given size is created. Each element in this array is
|
|
|
|
* calculated by passing the element's index to the given block and
|
|
|
|
* storing the return value.
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
2004-07-13 12:21:23 -04:00
|
|
|
* Array.new
|
|
|
|
* Array.new(2)
|
|
|
|
* Array.new(5, "A")
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
2004-07-13 12:21:23 -04:00
|
|
|
* # only one copy of the object is created
|
|
|
|
* a = Array.new(2, Hash.new)
|
|
|
|
* a[0]['cat'] = 'feline'
|
|
|
|
* a
|
|
|
|
* a[1]['cat'] = 'Felix'
|
|
|
|
* a
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
2004-07-13 12:21:23 -04:00
|
|
|
* # here multiple copies are created
|
|
|
|
* a = Array.new(2) { Hash.new }
|
|
|
|
* a[0]['cat'] = 'feline'
|
|
|
|
* a
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
2004-07-13 12:21:23 -04:00
|
|
|
* squares = Array.new(5) {|i| i*i}
|
|
|
|
* squares
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
2004-07-13 12:21:23 -04:00
|
|
|
* copy = Array.new(squares)
|
2003-12-16 15:28:44 -05:00
|
|
|
*/
|
|
|
|
|
2000-02-29 03:05:32 -05:00
|
|
|
static VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_initialize(int argc, VALUE *argv, VALUE ary)
|
2000-02-29 03:05:32 -05:00
|
|
|
{
|
|
|
|
long len;
|
|
|
|
VALUE size, val;
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2006-09-02 10:42:08 -04:00
|
|
|
rb_ary_modify(ary);
|
* array.c (ary_iter_check): should check modification (size
change) during iteration.
* array.c (rb_ary_initialize, rb_ary_shift, rb_ary_unshift,
rb_ary_splice, rb_ary_reverse, rb_ary_sort, rb_ary_delete,
rb_ary_delete_at, rb_ary_reject_bang, rb_ary_replace,
rb_ary_clear, rb_ary_fill, rb_ary_uniq_bang, rb_ary_compact,
rb_ary_shuffle): add iteration check.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-12-29 14:25:11 -05:00
|
|
|
ary_iter_check(ary);
|
1999-01-19 23:59:39 -05:00
|
|
|
if (rb_scan_args(argc, argv, "02", &size, &val) == 0) {
|
2006-11-01 09:42:39 -05:00
|
|
|
if (RARRAY_PTR(ary) && !ARY_SHARED_P(ary)) {
|
|
|
|
free(RARRAY(ary)->ptr);
|
2006-09-02 10:42:08 -04:00
|
|
|
}
|
2006-11-01 09:42:39 -05:00
|
|
|
RARRAY(ary)->len = 0;
|
2002-01-28 03:44:45 -05:00
|
|
|
if (rb_block_given_p()) {
|
|
|
|
rb_warning("given block not used");
|
|
|
|
}
|
2001-10-02 00:31:23 -04:00
|
|
|
return ary;
|
|
|
|
}
|
|
|
|
|
2002-01-28 03:44:45 -05:00
|
|
|
if (argc == 1 && !FIXNUM_P(size)) {
|
2002-12-19 04:20:20 -05:00
|
|
|
val = rb_check_array_type(size);
|
2002-01-28 03:44:45 -05:00
|
|
|
if (!NIL_P(val)) {
|
|
|
|
rb_ary_replace(ary, val);
|
|
|
|
return ary;
|
|
|
|
}
|
1999-01-19 23:59:39 -05:00
|
|
|
}
|
|
|
|
|
2000-02-29 03:05:32 -05:00
|
|
|
len = NUM2LONG(size);
|
|
|
|
if (len < 0) {
|
|
|
|
rb_raise(rb_eArgError, "negative array size");
|
1999-01-19 23:59:39 -05:00
|
|
|
}
|
2002-08-19 01:56:09 -04:00
|
|
|
if (len > 0 && len * (long)sizeof(VALUE) <= len) {
|
2000-02-29 03:05:32 -05:00
|
|
|
rb_raise(rb_eArgError, "array size too big");
|
|
|
|
}
|
2004-11-17 22:45:23 -05:00
|
|
|
rb_ary_modify(ary);
|
2006-12-31 10:02:22 -05:00
|
|
|
RESIZE_CAPA(ary, len);
|
2002-01-28 03:44:45 -05:00
|
|
|
if (rb_block_given_p()) {
|
|
|
|
long i;
|
|
|
|
|
2003-11-04 04:13:57 -05:00
|
|
|
if (argc == 2) {
|
|
|
|
rb_warn("block supersedes default value argument");
|
2002-01-28 03:44:45 -05:00
|
|
|
}
|
|
|
|
for (i=0; i<len; i++) {
|
2004-09-20 23:08:33 -04:00
|
|
|
rb_ary_store(ary, i, rb_yield(LONG2NUM(i)));
|
2006-11-01 09:42:39 -05:00
|
|
|
RARRAY(ary)->len = i + 1;
|
2002-01-28 03:44:45 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2006-09-02 10:42:08 -04:00
|
|
|
memfill(RARRAY_PTR(ary), len, val);
|
2006-11-01 09:42:39 -05:00
|
|
|
RARRAY(ary)->len = len;
|
2002-01-28 03:44:45 -05:00
|
|
|
}
|
2000-02-29 03:05:32 -05:00
|
|
|
return ary;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2003-12-16 15:28:44 -05:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Returns a new array populated with the given objects.
|
|
|
|
*
|
|
|
|
* Array.[]( 1, 'a', /^A/ )
|
|
|
|
* Array[ 1, 'a', /^A/ ]
|
|
|
|
* [ 1, 'a', /^A/ ]
|
|
|
|
*/
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
static VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_s_create(int argc, VALUE *argv, VALUE klass)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
2002-12-20 03:33:17 -05:00
|
|
|
VALUE ary = ary_alloc(klass);
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2006-09-02 10:42:08 -04:00
|
|
|
if (argc < 0) {
|
|
|
|
rb_raise(rb_eArgError, "negative array size");
|
|
|
|
}
|
2006-11-01 09:42:39 -05:00
|
|
|
RARRAY(ary)->ptr = ALLOC_N(VALUE, argc);
|
|
|
|
RARRAY(ary)->aux.capa = argc;
|
2006-09-02 10:42:08 -04:00
|
|
|
MEMCPY(RARRAY_PTR(ary), argv, VALUE, argc);
|
2006-11-01 09:42:39 -05:00
|
|
|
RARRAY(ary)->len = argc;
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2001-10-03 03:19:19 -04:00
|
|
|
return ary;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_store(VALUE ary, long idx, VALUE val)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
|
|
|
if (idx < 0) {
|
2006-09-02 10:42:08 -04:00
|
|
|
idx += RARRAY_LEN(ary);
|
1999-01-19 23:59:39 -05:00
|
|
|
if (idx < 0) {
|
2002-05-28 14:11:07 -04:00
|
|
|
rb_raise(rb_eIndexError, "index %ld out of array",
|
2006-09-02 10:42:08 -04:00
|
|
|
idx - RARRAY_LEN(ary));
|
1999-01-19 23:59:39 -05:00
|
|
|
}
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2004-11-17 22:45:23 -05:00
|
|
|
rb_ary_modify(ary);
|
2006-09-02 10:42:08 -04:00
|
|
|
if (idx >= ARY_CAPA(ary)) {
|
|
|
|
long new_capa = ARY_CAPA(ary) / 2;
|
2002-08-13 05:21:18 -04:00
|
|
|
|
|
|
|
if (new_capa < ARY_DEFAULT_SIZE) {
|
|
|
|
new_capa = ARY_DEFAULT_SIZE;
|
1999-08-13 01:45:20 -04:00
|
|
|
}
|
2006-09-02 10:42:08 -04:00
|
|
|
if (new_capa + idx < new_capa) {
|
|
|
|
rb_raise(rb_eArgError, "index too big");
|
|
|
|
}
|
2002-08-13 05:21:18 -04:00
|
|
|
new_capa += idx;
|
2002-08-19 01:56:09 -04:00
|
|
|
if (new_capa * (long)sizeof(VALUE) <= new_capa) {
|
2002-08-13 05:21:18 -04:00
|
|
|
rb_raise(rb_eArgError, "index too big");
|
|
|
|
}
|
2006-09-02 10:42:08 -04:00
|
|
|
RESIZE_CAPA(ary, new_capa);
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
2006-09-02 10:42:08 -04:00
|
|
|
if (idx > RARRAY_LEN(ary)) {
|
|
|
|
rb_mem_clear(RARRAY_PTR(ary) + RARRAY_LEN(ary),
|
|
|
|
idx-RARRAY_LEN(ary) + 1);
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2006-09-02 10:42:08 -04:00
|
|
|
if (idx >= RARRAY_LEN(ary)) {
|
2006-11-01 09:42:39 -05:00
|
|
|
RARRAY(ary)->len = idx + 1;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
2006-09-02 10:42:08 -04:00
|
|
|
RARRAY_PTR(ary)[idx] = val;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2004-06-16 03:05:24 -04:00
|
|
|
static VALUE
|
2006-09-02 10:42:08 -04:00
|
|
|
ary_shared_array(VALUE klass, VALUE ary)
|
|
|
|
{
|
|
|
|
VALUE val = ary_alloc(klass);
|
|
|
|
|
|
|
|
ary_make_shared(ary);
|
2006-11-01 09:42:39 -05:00
|
|
|
RARRAY(val)->ptr = RARRAY(ary)->ptr;
|
|
|
|
RARRAY(val)->len = RARRAY(ary)->len;
|
|
|
|
RARRAY(val)->aux.shared = RARRAY(ary)->aux.shared;
|
2006-09-02 10:42:08 -04:00
|
|
|
FL_SET(val, ELTS_SHARED);
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
static VALUE
|
|
|
|
ary_shared_first(int argc, VALUE *argv, VALUE ary, int last)
|
2004-06-16 03:05:24 -04:00
|
|
|
{
|
|
|
|
VALUE nv, result;
|
|
|
|
long n;
|
2006-09-02 10:42:08 -04:00
|
|
|
long offset = 0;
|
2004-06-16 03:05:24 -04:00
|
|
|
|
|
|
|
rb_scan_args(argc, argv, "1", &nv);
|
|
|
|
n = NUM2LONG(nv);
|
2006-09-02 10:42:08 -04:00
|
|
|
if (n > RARRAY_LEN(ary)) {
|
|
|
|
n = RARRAY_LEN(ary);
|
2004-06-16 03:05:24 -04:00
|
|
|
}
|
|
|
|
else if (n < 0) {
|
|
|
|
rb_raise(rb_eArgError, "negative array size");
|
|
|
|
}
|
2006-09-02 10:42:08 -04:00
|
|
|
if (last) {
|
|
|
|
offset = RARRAY_LEN(ary) - n;
|
|
|
|
}
|
2006-11-01 09:42:39 -05:00
|
|
|
result = ary_shared_array(rb_cArray, ary);
|
|
|
|
RARRAY(result)->ptr += offset;
|
|
|
|
RARRAY(result)->len = n;
|
|
|
|
|
2004-06-16 03:05:24 -04:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2004-07-13 12:21:23 -04:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* array << obj -> array
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
2004-07-13 12:21:23 -04:00
|
|
|
* Append---Pushes the given object on to the end of this array. This
|
|
|
|
* expression returns the array itself, so several appends
|
|
|
|
* may be chained together.
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
|
|
|
* [ 1, 2 ] << "c" << "d" << [ 3, 4 ]
|
|
|
|
* #=> [ 1, 2, "c", "d", [ 3, 4 ] ]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_push(VALUE ary, VALUE item)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
2006-09-02 10:42:08 -04:00
|
|
|
rb_ary_store(ary, RARRAY_LEN(ary), item);
|
1998-01-16 07:19:22 -05:00
|
|
|
return ary;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2003-12-16 15:28:44 -05:00
|
|
|
/*
|
2004-07-13 12:21:23 -04:00
|
|
|
* call-seq:
|
|
|
|
* array.push(obj, ... ) -> array
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
2004-07-13 12:21:23 -04:00
|
|
|
* Append---Pushes the given object(s) on to the end of this array. This
|
|
|
|
* expression returns the array itself, so several appends
|
|
|
|
* may be chained together.
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
|
|
|
* a = [ "a", "b", "c" ]
|
|
|
|
* a.push("d", "e", "f")
|
|
|
|
* #=> ["a", "b", "c", "d", "e", "f"]
|
|
|
|
*/
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
static VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_push_m(int argc, VALUE *argv, VALUE ary)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
2002-05-21 01:39:19 -04:00
|
|
|
while (argc--) {
|
|
|
|
rb_ary_push(ary, *argv++);
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
1998-01-16 07:19:22 -05:00
|
|
|
return ary;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_pop(VALUE ary)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
2006-09-02 10:42:08 -04:00
|
|
|
long n;
|
2001-12-10 02:18:16 -05:00
|
|
|
rb_ary_modify_check(ary);
|
2006-09-02 10:42:08 -04:00
|
|
|
if (RARRAY_LEN(ary) == 0) return Qnil;
|
2006-10-16 10:35:51 -04:00
|
|
|
if (!ARY_SHARED_P(ary) &&
|
|
|
|
RARRAY_LEN(ary) * 3 < ARY_CAPA(ary) &&
|
|
|
|
ARY_CAPA(ary) > ARY_DEFAULT_SIZE)
|
|
|
|
{
|
2006-09-02 10:42:08 -04:00
|
|
|
RESIZE_CAPA(ary, RARRAY_LEN(ary) * 2);
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
2006-09-02 10:42:08 -04:00
|
|
|
n = RARRAY_LEN(ary)-1;
|
2006-11-01 09:42:39 -05:00
|
|
|
RARRAY(ary)->len = n;
|
2006-09-02 10:42:08 -04:00
|
|
|
return RARRAY_PTR(ary)[n];
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2003-12-16 15:28:44 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
2004-07-13 11:34:34 -04:00
|
|
|
* array.pop -> obj or nil
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
2004-06-16 03:05:24 -04:00
|
|
|
* Removes the last element from <i>self</i> and returns it, or
|
|
|
|
* <code>nil</code> if the array is empty.
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
2004-06-16 08:52:59 -04:00
|
|
|
* a = [ "a", "b", "c", "d" ]
|
|
|
|
* a.pop #=> "d"
|
|
|
|
* a.pop(2) #=> ["b", "c"]
|
|
|
|
* a #=> ["a"]
|
2003-12-16 15:28:44 -05:00
|
|
|
*/
|
|
|
|
|
2004-06-16 03:05:24 -04:00
|
|
|
static VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_pop_m(int argc, VALUE *argv, VALUE ary)
|
2004-06-16 03:05:24 -04:00
|
|
|
{
|
|
|
|
VALUE result;
|
|
|
|
|
|
|
|
if (argc == 0) {
|
|
|
|
return rb_ary_pop(ary);
|
|
|
|
}
|
|
|
|
|
|
|
|
rb_ary_modify_check(ary);
|
2006-09-02 10:42:08 -04:00
|
|
|
result = ary_shared_first(argc, argv, ary, Qtrue);
|
2006-11-01 09:42:39 -05:00
|
|
|
RARRAY(ary)->len -= RARRAY_LEN(result);
|
2004-06-16 03:05:24 -04:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_shift(VALUE ary)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
|
|
|
VALUE top;
|
|
|
|
|
2001-12-10 02:18:16 -05:00
|
|
|
rb_ary_modify_check(ary);
|
* array.c (ary_iter_check): should check modification (size
change) during iteration.
* array.c (rb_ary_initialize, rb_ary_shift, rb_ary_unshift,
rb_ary_splice, rb_ary_reverse, rb_ary_sort, rb_ary_delete,
rb_ary_delete_at, rb_ary_reject_bang, rb_ary_replace,
rb_ary_clear, rb_ary_fill, rb_ary_uniq_bang, rb_ary_compact,
rb_ary_shuffle): add iteration check.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-12-29 14:25:11 -05:00
|
|
|
ary_iter_check(ary);
|
2006-09-02 10:42:08 -04:00
|
|
|
if (RARRAY_LEN(ary) == 0) return Qnil;
|
|
|
|
top = RARRAY_PTR(ary)[0];
|
2006-09-26 18:46:16 -04:00
|
|
|
if (!ARY_SHARED_P(ary)) {
|
2006-11-01 19:19:57 -05:00
|
|
|
if (RARRAY_LEN(ary) < ARY_DEFAULT_SIZE) {
|
2006-12-31 10:02:22 -05:00
|
|
|
MEMMOVE(RARRAY_PTR(ary), RARRAY_PTR(ary)+1, VALUE, RARRAY_LEN(ary)-1);
|
2006-11-01 19:19:57 -05:00
|
|
|
RARRAY(ary)->len--;
|
2006-12-31 10:02:22 -05:00
|
|
|
return top;
|
|
|
|
}
|
2006-11-01 19:19:57 -05:00
|
|
|
RARRAY_PTR(ary)[0] = Qnil;
|
|
|
|
ary_make_shared(ary);
|
2006-09-02 10:42:08 -04:00
|
|
|
}
|
2006-11-01 19:19:57 -05:00
|
|
|
RARRAY(ary)->ptr++; /* shift ptr */
|
2006-11-01 09:42:39 -05:00
|
|
|
RARRAY(ary)->len--;
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
return top;
|
|
|
|
}
|
|
|
|
|
2004-06-16 03:05:24 -04:00
|
|
|
/*
|
|
|
|
* call-seq:
|
2004-07-13 11:34:34 -04:00
|
|
|
* array.shift -> obj or nil
|
2004-06-16 03:05:24 -04:00
|
|
|
*
|
|
|
|
* Returns the first element of <i>self</i> and removes it (shifting all
|
|
|
|
* other elements down by one). Returns <code>nil</code> if the array
|
|
|
|
* is empty.
|
|
|
|
*
|
|
|
|
* args = [ "-m", "-q", "filename" ]
|
|
|
|
* args.shift #=> "-m"
|
|
|
|
* args #=> ["-q", "filename"]
|
|
|
|
*
|
|
|
|
* args = [ "-m", "-q", "filename" ]
|
|
|
|
* args.shift(2) #=> ["-m", "-q"]
|
|
|
|
* args #=> ["filename"]
|
|
|
|
*/
|
|
|
|
|
|
|
|
static VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_shift_m(int argc, VALUE *argv, VALUE ary)
|
2004-06-16 03:05:24 -04:00
|
|
|
{
|
|
|
|
VALUE result;
|
|
|
|
long n;
|
|
|
|
|
|
|
|
if (argc == 0) {
|
|
|
|
return rb_ary_shift(ary);
|
|
|
|
}
|
|
|
|
|
|
|
|
rb_ary_modify_check(ary);
|
* array.c (ary_iter_check): should check modification (size
change) during iteration.
* array.c (rb_ary_initialize, rb_ary_shift, rb_ary_unshift,
rb_ary_splice, rb_ary_reverse, rb_ary_sort, rb_ary_delete,
rb_ary_delete_at, rb_ary_reject_bang, rb_ary_replace,
rb_ary_clear, rb_ary_fill, rb_ary_uniq_bang, rb_ary_compact,
rb_ary_shuffle): add iteration check.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-12-29 14:25:11 -05:00
|
|
|
ary_iter_check(ary);
|
2006-09-02 10:42:08 -04:00
|
|
|
result = ary_shared_first(argc, argv, ary, Qfalse);
|
|
|
|
n = RARRAY_LEN(result);
|
|
|
|
if (ARY_SHARED_P(ary)) {
|
2006-11-01 09:42:39 -05:00
|
|
|
RARRAY(ary)->ptr += n;
|
|
|
|
RARRAY(ary)->len -= n;
|
2006-12-31 10:02:22 -05:00
|
|
|
}
|
2006-09-02 10:42:08 -04:00
|
|
|
else {
|
|
|
|
MEMMOVE(RARRAY_PTR(ary), RARRAY_PTR(ary)+n, VALUE, RARRAY_LEN(ary)-n);
|
2006-11-01 09:42:39 -05:00
|
|
|
RARRAY(ary)->len -= n;
|
2006-09-02 10:42:08 -04:00
|
|
|
}
|
2004-06-16 03:05:24 -04:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2003-12-16 15:28:44 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
2004-07-13 11:34:34 -04:00
|
|
|
* array.unshift(obj, ...) -> array
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
|
|
|
* Prepends objects to the front of <i>array</i>.
|
|
|
|
* other elements up one.
|
|
|
|
*
|
|
|
|
* a = [ "b", "c", "d" ]
|
|
|
|
* a.unshift("a") #=> ["a", "b", "c", "d"]
|
|
|
|
* a.unshift(1, 2) #=> [ 1, 2, "a", "b", "c", "d"]
|
|
|
|
*/
|
|
|
|
|
2000-05-01 05:42:38 -04:00
|
|
|
static VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_unshift_m(int argc, VALUE *argv, VALUE ary)
|
2000-05-01 05:42:38 -04:00
|
|
|
{
|
2006-11-01 19:19:57 -05:00
|
|
|
long len = RARRAY(ary)->len;
|
2006-10-16 10:35:51 -04:00
|
|
|
|
2003-06-23 13:40:14 -04:00
|
|
|
if (argc == 0) return ary;
|
2006-11-01 19:19:57 -05:00
|
|
|
rb_ary_modify(ary);
|
* array.c (ary_iter_check): should check modification (size
change) during iteration.
* array.c (rb_ary_initialize, rb_ary_shift, rb_ary_unshift,
rb_ary_splice, rb_ary_reverse, rb_ary_sort, rb_ary_delete,
rb_ary_delete_at, rb_ary_reject_bang, rb_ary_replace,
rb_ary_clear, rb_ary_fill, rb_ary_uniq_bang, rb_ary_compact,
rb_ary_shuffle): add iteration check.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-12-29 14:25:11 -05:00
|
|
|
ary_iter_check(ary);
|
2006-11-01 19:19:57 -05:00
|
|
|
if (RARRAY(ary)->aux.capa <= RARRAY_LEN(ary)+argc) {
|
|
|
|
RESIZE_CAPA(ary, RARRAY(ary)->aux.capa + ARY_DEFAULT_SIZE);
|
2006-09-26 18:46:16 -04:00
|
|
|
}
|
|
|
|
|
2006-11-01 19:19:57 -05:00
|
|
|
/* sliding items */
|
|
|
|
MEMMOVE(RARRAY(ary)->ptr + argc, RARRAY(ary)->ptr, VALUE, len);
|
|
|
|
MEMCPY(RARRAY(ary)->ptr, argv, VALUE, argc);
|
|
|
|
RARRAY(ary)->len += argc;
|
|
|
|
|
2000-05-01 05:42:38 -04:00
|
|
|
return ary;
|
|
|
|
}
|
|
|
|
|
2006-09-26 18:46:16 -04:00
|
|
|
VALUE
|
|
|
|
rb_ary_unshift(VALUE ary, VALUE item)
|
|
|
|
{
|
|
|
|
return rb_ary_unshift_m(1,&item,ary);
|
|
|
|
}
|
|
|
|
|
2004-09-20 23:08:33 -04:00
|
|
|
/* faster version - use this if you don't need to treat negative offset */
|
|
|
|
static inline VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_elt(VALUE ary, long offset)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
2006-09-02 10:42:08 -04:00
|
|
|
if (RARRAY_LEN(ary) == 0) return Qnil;
|
|
|
|
if (offset < 0 || RARRAY_LEN(ary) <= offset) {
|
1998-01-16 07:13:05 -05:00
|
|
|
return Qnil;
|
|
|
|
}
|
2006-09-02 10:42:08 -04:00
|
|
|
return RARRAY_PTR(ary)[offset];
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2004-09-20 23:08:33 -04:00
|
|
|
VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_entry(VALUE ary, long offset)
|
2004-09-20 23:08:33 -04:00
|
|
|
{
|
|
|
|
if (offset < 0) {
|
2006-09-02 10:42:08 -04:00
|
|
|
offset += RARRAY_LEN(ary);
|
2004-09-20 23:08:33 -04:00
|
|
|
}
|
|
|
|
return rb_ary_elt(ary, offset);
|
|
|
|
}
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
static VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_subseq(VALUE ary, long beg, long len)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
2004-09-24 01:53:43 -04:00
|
|
|
VALUE klass, ary2, shared;
|
|
|
|
VALUE *ptr;
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2006-09-02 10:42:08 -04:00
|
|
|
if (beg > RARRAY_LEN(ary)) return Qnil;
|
2000-11-20 02:31:55 -05:00
|
|
|
if (beg < 0 || len < 0) return Qnil;
|
|
|
|
|
2006-09-02 10:42:08 -04:00
|
|
|
if (beg + len > RARRAY_LEN(ary)) {
|
|
|
|
len = RARRAY_LEN(ary) - beg;
|
2002-05-21 01:39:19 -04:00
|
|
|
if (len < 0)
|
|
|
|
len = 0;
|
1999-01-19 23:59:39 -05:00
|
|
|
}
|
2001-10-15 23:27:23 -04:00
|
|
|
klass = rb_obj_class(ary);
|
2002-05-21 01:39:19 -04:00
|
|
|
if (len == 0) return ary_new(klass, 0);
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2006-11-01 09:42:39 -05:00
|
|
|
shared = ary_make_shared(ary);
|
2006-12-31 10:02:22 -05:00
|
|
|
ptr = RARRAY_PTR(ary);
|
2006-11-01 09:42:39 -05:00
|
|
|
ary2 = ary_alloc(klass);
|
|
|
|
RARRAY(ary2)->ptr = ptr + beg;
|
|
|
|
RARRAY(ary2)->len = len;
|
|
|
|
RARRAY(ary2)->aux.shared = shared;
|
|
|
|
FL_SET(ary2, ELTS_SHARED);
|
|
|
|
|
|
|
|
return ary2;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2003-12-16 15:28:44 -05:00
|
|
|
/*
|
2004-07-13 12:21:23 -04:00
|
|
|
* call-seq:
|
|
|
|
* array[index] -> obj or nil
|
|
|
|
* array[start, length] -> an_array or nil
|
|
|
|
* array[range] -> an_array or nil
|
|
|
|
* array.slice(index) -> obj or nil
|
|
|
|
* array.slice(start, length) -> an_array or nil
|
|
|
|
* array.slice(range) -> an_array or nil
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
2004-07-13 12:21:23 -04:00
|
|
|
* Element Reference---Returns the element at _index_,
|
|
|
|
* or returns a subarray starting at _start_ and
|
|
|
|
* continuing for _length_ elements, or returns a subarray
|
|
|
|
* specified by _range_.
|
|
|
|
* Negative indices count backward from the end of the
|
2004-07-24 05:48:21 -04:00
|
|
|
* array (-1 is the last element). Returns nil if the index
|
|
|
|
* (or starting index) are out of range.
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
|
|
|
* a = [ "a", "b", "c", "d", "e" ]
|
|
|
|
* a[2] + a[0] + a[1] #=> "cab"
|
|
|
|
* a[6] #=> nil
|
|
|
|
* a[1, 2] #=> [ "b", "c" ]
|
|
|
|
* a[1..3] #=> [ "b", "c", "d" ]
|
|
|
|
* a[4..7] #=> [ "e" ]
|
|
|
|
* a[6..10] #=> nil
|
|
|
|
* a[-3, 3] #=> [ "c", "d", "e" ]
|
|
|
|
* # special cases
|
|
|
|
* a[5] #=> nil
|
|
|
|
* a[5, 1] #=> []
|
|
|
|
* a[5..10] #=> []
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
1998-01-16 07:19:22 -05:00
|
|
|
VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_aref(int argc, VALUE *argv, VALUE ary)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
2001-07-02 04:46:28 -04:00
|
|
|
VALUE arg;
|
1999-08-13 01:45:20 -04:00
|
|
|
long beg, len;
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2001-07-02 04:46:28 -04:00
|
|
|
if (argc == 2) {
|
|
|
|
beg = NUM2LONG(argv[0]);
|
|
|
|
len = NUM2LONG(argv[1]);
|
1999-01-19 23:59:39 -05:00
|
|
|
if (beg < 0) {
|
2006-09-02 10:42:08 -04:00
|
|
|
beg += RARRAY_LEN(ary);
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
2000-01-31 22:12:21 -05:00
|
|
|
return rb_ary_subseq(ary, beg, len);
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
2001-07-02 04:46:28 -04:00
|
|
|
if (argc != 1) {
|
|
|
|
rb_scan_args(argc, argv, "11", 0, 0);
|
|
|
|
}
|
|
|
|
arg = argv[0];
|
1998-01-16 07:13:05 -05:00
|
|
|
/* special case - speeding up */
|
2001-07-02 04:46:28 -04:00
|
|
|
if (FIXNUM_P(arg)) {
|
|
|
|
return rb_ary_entry(ary, FIX2LONG(arg));
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
2002-05-21 01:39:19 -04:00
|
|
|
/* check if idx is Range */
|
2006-09-02 10:42:08 -04:00
|
|
|
switch (rb_range_beg_len(arg, &beg, &len, RARRAY_LEN(ary), 0)) {
|
2002-05-21 01:39:19 -04:00
|
|
|
case Qfalse:
|
|
|
|
break;
|
|
|
|
case Qnil:
|
|
|
|
return Qnil;
|
|
|
|
default:
|
|
|
|
return rb_ary_subseq(ary, beg, len);
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
2001-07-02 04:46:28 -04:00
|
|
|
return rb_ary_entry(ary, NUM2LONG(arg));
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2003-12-16 15:28:44 -05:00
|
|
|
/*
|
2004-07-13 12:21:23 -04:00
|
|
|
* call-seq:
|
|
|
|
* array.at(index) -> obj or nil
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
2004-07-13 12:21:23 -04:00
|
|
|
* Returns the element at _index_. A
|
|
|
|
* negative index counts from the end of _self_. Returns +nil+
|
|
|
|
* if the index is out of range. See also <code>Array#[]</code>.
|
|
|
|
* (<code>Array#at</code> is slightly faster than <code>Array#[]</code>,
|
|
|
|
* as it does not accept ranges and so on.)
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
|
|
|
* a = [ "a", "b", "c", "d", "e" ]
|
|
|
|
* a.at(0) #=> "a"
|
|
|
|
* a.at(-1) #=> "e"
|
|
|
|
*/
|
|
|
|
|
1999-10-13 02:44:42 -04:00
|
|
|
static VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_at(VALUE ary, VALUE pos)
|
1999-10-13 02:44:42 -04:00
|
|
|
{
|
|
|
|
return rb_ary_entry(ary, NUM2LONG(pos));
|
|
|
|
}
|
|
|
|
|
2003-12-16 15:28:44 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
2004-07-13 11:34:34 -04:00
|
|
|
* array.first -> obj or nil
|
2006-12-31 10:02:22 -05:00
|
|
|
* array.first(n) -> an_array
|
|
|
|
*
|
2005-11-14 03:39:34 -05:00
|
|
|
* Returns the first element, or the first +n+ elements, of the array.
|
|
|
|
* If the array is empty, the first form returns <code>nil</code>, and the
|
|
|
|
* second form returns an empty array.
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
|
|
|
* a = [ "q", "r", "s", "t" ]
|
2004-06-16 03:05:24 -04:00
|
|
|
* a.first #=> "q"
|
|
|
|
* a.first(2) #=> ["q", "r"]
|
2003-12-16 15:28:44 -05:00
|
|
|
*/
|
|
|
|
|
1999-10-13 02:44:42 -04:00
|
|
|
static VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_first(int argc, VALUE *argv, VALUE ary)
|
1999-10-13 02:44:42 -04:00
|
|
|
{
|
2003-06-06 05:24:59 -04:00
|
|
|
if (argc == 0) {
|
2006-09-02 10:42:08 -04:00
|
|
|
if (RARRAY_LEN(ary) == 0) return Qnil;
|
|
|
|
return RARRAY_PTR(ary)[0];
|
2003-06-06 05:24:59 -04:00
|
|
|
}
|
|
|
|
else {
|
2006-09-02 10:42:08 -04:00
|
|
|
return ary_shared_first(argc, argv, ary, Qfalse);
|
2003-06-06 05:24:59 -04:00
|
|
|
}
|
1999-10-13 02:44:42 -04:00
|
|
|
}
|
|
|
|
|
2003-12-16 15:28:44 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
2004-07-13 11:34:34 -04:00
|
|
|
* array.last -> obj or nil
|
|
|
|
* array.last(n) -> an_array
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
|
|
|
* Returns the last element(s) of <i>self</i>. If the array is empty,
|
|
|
|
* the first form returns <code>nil</code>.
|
|
|
|
*
|
2004-06-16 03:05:24 -04:00
|
|
|
* a = [ "w", "x", "y", "z" ]
|
|
|
|
* a.last #=> "z"
|
|
|
|
* a.last(2) #=> ["y", "z"]
|
2003-12-16 15:28:44 -05:00
|
|
|
*/
|
|
|
|
|
1999-10-13 02:44:42 -04:00
|
|
|
static VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_last(int argc, VALUE *argv, VALUE ary)
|
1999-10-13 02:44:42 -04:00
|
|
|
{
|
2003-06-06 05:24:59 -04:00
|
|
|
if (argc == 0) {
|
2006-09-02 10:42:08 -04:00
|
|
|
if (RARRAY_LEN(ary) == 0) return Qnil;
|
|
|
|
return RARRAY_PTR(ary)[RARRAY_LEN(ary)-1];
|
2003-06-06 05:24:59 -04:00
|
|
|
}
|
|
|
|
else {
|
2006-09-02 10:42:08 -04:00
|
|
|
return ary_shared_first(argc, argv, ary, Qtrue);
|
2003-06-06 05:24:59 -04:00
|
|
|
}
|
1999-10-13 02:44:42 -04:00
|
|
|
}
|
|
|
|
|
2003-12-16 15:28:44 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
2004-07-13 11:34:34 -04:00
|
|
|
* array.fetch(index) -> obj
|
|
|
|
* array.fetch(index, default ) -> obj
|
|
|
|
* array.fetch(index) {|index| block } -> obj
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
|
|
|
* Tries to return the element at position <i>index</i>. If the index
|
|
|
|
* lies outside the array, the first form throws an
|
|
|
|
* <code>IndexError</code> exception, the second form returns
|
|
|
|
* <i>default</i>, and the third form returns the value of invoking
|
2003-12-23 16:19:03 -05:00
|
|
|
* the block, passing in the index. Negative values of <i>index</i>
|
2003-12-16 15:28:44 -05:00
|
|
|
* count from the end of the array.
|
|
|
|
*
|
|
|
|
* a = [ 11, 22, 33, 44 ]
|
|
|
|
* a.fetch(1) #=> 22
|
|
|
|
* a.fetch(-1) #=> 44
|
|
|
|
* a.fetch(4, 'cat') #=> "cat"
|
|
|
|
* a.fetch(4) { |i| i*i } #=> 16
|
|
|
|
*/
|
|
|
|
|
2001-02-02 06:38:20 -05:00
|
|
|
static VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_fetch(int argc, VALUE *argv, VALUE ary)
|
2001-02-02 06:38:20 -05:00
|
|
|
{
|
|
|
|
VALUE pos, ifnone;
|
2003-11-06 02:22:39 -05:00
|
|
|
long block_given;
|
2001-02-02 06:38:20 -05:00
|
|
|
long idx;
|
|
|
|
|
|
|
|
rb_scan_args(argc, argv, "11", &pos, &ifnone);
|
2003-11-06 02:22:39 -05:00
|
|
|
block_given = rb_block_given_p();
|
|
|
|
if (block_given && argc == 2) {
|
|
|
|
rb_warn("block supersedes default value argument");
|
|
|
|
}
|
2001-02-02 06:38:20 -05:00
|
|
|
idx = NUM2LONG(pos);
|
|
|
|
|
|
|
|
if (idx < 0) {
|
2006-09-02 10:42:08 -04:00
|
|
|
idx += RARRAY_LEN(ary);
|
2001-02-02 06:38:20 -05:00
|
|
|
}
|
2006-09-02 10:42:08 -04:00
|
|
|
if (idx < 0 || RARRAY_LEN(ary) <= idx) {
|
2003-11-06 02:22:39 -05:00
|
|
|
if (block_given) return rb_yield(pos);
|
2002-01-25 03:22:11 -05:00
|
|
|
if (argc == 1) {
|
2002-05-28 14:11:07 -04:00
|
|
|
rb_raise(rb_eIndexError, "index %ld out of array", idx);
|
2002-01-25 03:22:11 -05:00
|
|
|
}
|
|
|
|
return ifnone;
|
2001-02-02 06:38:20 -05:00
|
|
|
}
|
2006-09-02 10:42:08 -04:00
|
|
|
return RARRAY_PTR(ary)[idx];
|
2001-02-02 06:38:20 -05:00
|
|
|
}
|
|
|
|
|
2003-12-16 15:28:44 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
2004-10-04 21:37:46 -04:00
|
|
|
* array.index(obj) -> int or nil
|
|
|
|
* array.index {|item| block} -> int or nil
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
2004-10-04 21:37:46 -04:00
|
|
|
* Returns the index of the first object in <i>self</i> such that is
|
|
|
|
* <code>==</code> to <i>obj</i>. If a block is given instead of an
|
|
|
|
* argument, returns first object for which <em>block</em> is true.
|
|
|
|
* Returns <code>nil</code> if no match is found.
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
|
|
|
* a = [ "a", "b", "c" ]
|
2004-10-04 21:37:46 -04:00
|
|
|
* a.index("b") #=> 1
|
|
|
|
* a.index("z") #=> nil
|
2004-10-06 22:33:37 -04:00
|
|
|
* a.index{|x|x=="b"} #=> 1
|
2003-12-16 15:28:44 -05:00
|
|
|
*/
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
static VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_index(int argc, VALUE *argv, VALUE ary)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
2004-10-04 21:37:46 -04:00
|
|
|
VALUE val;
|
1999-08-13 01:45:20 -04:00
|
|
|
long i;
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2004-10-04 21:37:46 -04:00
|
|
|
if (rb_scan_args(argc, argv, "01", &val) == 0) {
|
2005-08-30 10:49:51 -04:00
|
|
|
RETURN_ENUMERATOR(ary, 0, 0);
|
2006-09-02 10:42:08 -04:00
|
|
|
for (i=0; i<RARRAY_LEN(ary); i++) {
|
|
|
|
if (RTEST(rb_yield(RARRAY_PTR(ary)[i]))) {
|
2004-10-04 21:37:46 -04:00
|
|
|
return LONG2NUM(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2006-09-02 10:42:08 -04:00
|
|
|
for (i=0; i<RARRAY_LEN(ary); i++) {
|
|
|
|
if (rb_equal(RARRAY_PTR(ary)[i], val))
|
2004-10-04 21:37:46 -04:00
|
|
|
return LONG2NUM(i);
|
|
|
|
}
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
return Qnil;
|
|
|
|
}
|
|
|
|
|
2003-12-16 15:28:44 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
2004-07-13 11:34:34 -04:00
|
|
|
* array.rindex(obj) -> int or nil
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
2004-10-04 21:37:46 -04:00
|
|
|
* Returns the index of the last object in <i>array</i>
|
|
|
|
* <code>==</code> to <i>obj</i>. If a block is given instead of an
|
|
|
|
* argument, returns first object for which <em>block</em> is
|
|
|
|
* true. Returns <code>nil</code> if no match is found.
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
|
|
|
* a = [ "a", "b", "b", "b", "c" ]
|
2004-10-04 21:37:46 -04:00
|
|
|
* a.rindex("b") #=> 3
|
|
|
|
* a.rindex("z") #=> nil
|
2004-10-06 22:33:37 -04:00
|
|
|
* a.rindex{|x|x=="b"} #=> 3
|
2003-12-16 15:28:44 -05:00
|
|
|
*/
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
static VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_rindex(int argc, VALUE *argv, VALUE ary)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
2004-10-04 21:37:46 -04:00
|
|
|
VALUE val;
|
2006-09-02 10:42:08 -04:00
|
|
|
long i = RARRAY_LEN(ary);
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2004-10-04 21:37:46 -04:00
|
|
|
if (rb_scan_args(argc, argv, "01", &val) == 0) {
|
2006-12-31 10:02:22 -05:00
|
|
|
RETURN_ENUMERATOR(ary, 0, 0);
|
2004-10-04 21:37:46 -04:00
|
|
|
while (i--) {
|
2006-09-02 10:42:08 -04:00
|
|
|
if (RTEST(rb_yield(RARRAY_PTR(ary)[i])))
|
2004-10-04 21:37:46 -04:00
|
|
|
return LONG2NUM(i);
|
2006-09-02 10:42:08 -04:00
|
|
|
if (i > RARRAY_LEN(ary)) {
|
|
|
|
i = RARRAY_LEN(ary);
|
2004-10-04 21:37:46 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
while (i--) {
|
2006-09-02 10:42:08 -04:00
|
|
|
if (rb_equal(RARRAY_PTR(ary)[i], val))
|
2004-10-04 21:37:46 -04:00
|
|
|
return LONG2NUM(i);
|
2006-09-02 10:42:08 -04:00
|
|
|
if (i > RARRAY_LEN(ary)) {
|
|
|
|
i = RARRAY_LEN(ary);
|
2004-10-04 21:37:46 -04:00
|
|
|
}
|
2004-09-20 23:08:33 -04:00
|
|
|
}
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
1999-01-19 23:59:39 -05:00
|
|
|
return Qnil;
|
|
|
|
}
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2001-10-02 00:31:23 -04:00
|
|
|
VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_to_ary(VALUE obj)
|
2001-10-02 00:31:23 -04:00
|
|
|
{
|
|
|
|
if (TYPE(obj) == T_ARRAY) {
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
if (rb_respond_to(obj, rb_intern("to_ary"))) {
|
2004-03-18 01:59:04 -05:00
|
|
|
return to_ary(obj);
|
2001-10-02 00:31:23 -04:00
|
|
|
}
|
|
|
|
return rb_ary_new3(1, obj);
|
|
|
|
}
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
static void
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_splice(VALUE ary, long beg, long len, VALUE rpl)
|
2001-05-02 00:22:21 -04:00
|
|
|
{
|
2001-05-06 11:06:00 -04:00
|
|
|
long rlen;
|
|
|
|
|
2002-05-28 14:11:07 -04:00
|
|
|
if (len < 0) rb_raise(rb_eIndexError, "negative length (%ld)", len);
|
1999-08-13 01:45:20 -04:00
|
|
|
if (beg < 0) {
|
2006-09-02 10:42:08 -04:00
|
|
|
beg += RARRAY_LEN(ary);
|
2002-05-21 01:39:19 -04:00
|
|
|
if (beg < 0) {
|
2006-09-02 10:42:08 -04:00
|
|
|
beg -= RARRAY_LEN(ary);
|
2002-05-28 14:11:07 -04:00
|
|
|
rb_raise(rb_eIndexError, "index %ld out of array", beg);
|
2002-05-21 01:39:19 -04:00
|
|
|
}
|
1999-08-13 01:45:20 -04:00
|
|
|
}
|
2006-09-02 10:42:08 -04:00
|
|
|
if (beg + len > RARRAY_LEN(ary)) {
|
|
|
|
len = RARRAY_LEN(ary) - beg;
|
1999-01-19 23:59:39 -05:00
|
|
|
}
|
|
|
|
|
2004-10-30 02:56:18 -04:00
|
|
|
if (rpl == Qundef) {
|
2003-01-07 02:36:40 -05:00
|
|
|
rlen = 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rpl = rb_ary_to_ary(rpl);
|
2006-09-02 10:42:08 -04:00
|
|
|
rlen = RARRAY_LEN(rpl);
|
2003-01-07 02:36:40 -05:00
|
|
|
}
|
2004-11-15 11:45:03 -05:00
|
|
|
rb_ary_modify(ary);
|
* array.c (ary_iter_check): should check modification (size
change) during iteration.
* array.c (rb_ary_initialize, rb_ary_shift, rb_ary_unshift,
rb_ary_splice, rb_ary_reverse, rb_ary_sort, rb_ary_delete,
rb_ary_delete_at, rb_ary_reject_bang, rb_ary_replace,
rb_ary_clear, rb_ary_fill, rb_ary_uniq_bang, rb_ary_compact,
rb_ary_shuffle): add iteration check.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-12-29 14:25:11 -05:00
|
|
|
ary_iter_check(ary);
|
2006-09-02 10:42:08 -04:00
|
|
|
if (beg >= RARRAY_LEN(ary)) {
|
2000-10-25 00:48:41 -04:00
|
|
|
len = beg + rlen;
|
2006-09-02 10:42:08 -04:00
|
|
|
if (len >= ARY_CAPA(ary)) {
|
|
|
|
RESIZE_CAPA(ary, len);
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
2006-09-02 10:42:08 -04:00
|
|
|
rb_mem_clear(RARRAY_PTR(ary) + RARRAY_LEN(ary), beg - RARRAY_LEN(ary));
|
2003-01-07 02:36:40 -05:00
|
|
|
if (rlen > 0) {
|
2006-09-02 10:42:08 -04:00
|
|
|
MEMCPY(RARRAY_PTR(ary) + beg, RARRAY_PTR(rpl), VALUE, rlen);
|
2003-01-07 02:36:40 -05:00
|
|
|
}
|
2006-11-01 09:42:39 -05:00
|
|
|
RARRAY(ary)->len = len;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
else {
|
1999-08-13 01:45:20 -04:00
|
|
|
long alen;
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2006-09-02 10:42:08 -04:00
|
|
|
if (beg + len > RARRAY_LEN(ary)) {
|
|
|
|
len = RARRAY_LEN(ary) - beg;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2006-09-02 10:42:08 -04:00
|
|
|
alen = RARRAY_LEN(ary) + rlen - len;
|
|
|
|
if (alen >= ARY_CAPA(ary)) {
|
|
|
|
RESIZE_CAPA(ary, alen);
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2001-05-02 00:22:21 -04:00
|
|
|
if (len != rlen) {
|
2006-09-02 10:42:08 -04:00
|
|
|
MEMMOVE(RARRAY_PTR(ary) + beg + rlen, RARRAY_PTR(ary) + beg + len,
|
|
|
|
VALUE, RARRAY_LEN(ary) - (beg + len));
|
2006-11-01 09:42:39 -05:00
|
|
|
RARRAY(ary)->len = alen;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
2003-01-07 02:36:40 -05:00
|
|
|
if (rlen > 0) {
|
2006-09-02 10:42:08 -04:00
|
|
|
MEMMOVE(RARRAY_PTR(ary) + beg, RARRAY_PTR(rpl), VALUE, rlen);
|
2003-01-07 02:36:40 -05:00
|
|
|
}
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-12-16 15:28:44 -05:00
|
|
|
/*
|
2004-07-13 12:21:23 -04:00
|
|
|
* call-seq:
|
|
|
|
* array[index] = obj -> obj
|
|
|
|
* array[start, length] = obj or an_array or nil -> obj or an_array or nil
|
|
|
|
* array[range] = obj or an_array or nil -> obj or an_array or nil
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
2004-07-13 12:21:23 -04:00
|
|
|
* Element Assignment---Sets the element at _index_,
|
|
|
|
* or replaces a subarray starting at _start_ and
|
|
|
|
* continuing for _length_ elements, or replaces a subarray
|
|
|
|
* specified by _range_. If indices are greater than
|
|
|
|
* the current capacity of the array, the array grows
|
|
|
|
* automatically. A negative indices will count backward
|
|
|
|
* from the end of the array. Inserts elements if _length_ is
|
2004-11-11 03:59:20 -05:00
|
|
|
* zero. An +IndexError+ is raised if a negative index points
|
|
|
|
* past the beginning of the array. See also
|
2004-07-13 12:21:23 -04:00
|
|
|
* <code>Array#push</code>, and <code>Array#unshift</code>.
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
|
|
|
* a = Array.new
|
2004-07-13 11:34:34 -04:00
|
|
|
* a[4] = "4"; #=> [nil, nil, nil, nil, "4"]
|
|
|
|
* a[0, 3] = [ 'a', 'b', 'c' ] #=> ["a", "b", "c", nil, "4"]
|
|
|
|
* a[1..2] = [ 1, 2 ] #=> ["a", 1, 2, nil, "4"]
|
|
|
|
* a[0, 2] = "?" #=> ["?", 2, nil, "4"]
|
|
|
|
* a[0..2] = "A" #=> ["A", "4"]
|
|
|
|
* a[-1] = "Z" #=> ["A", "Z"]
|
2004-11-11 03:59:20 -05:00
|
|
|
* a[1..-1] = nil #=> ["A", nil]
|
|
|
|
* a[1..-1] = [] #=> ["A"]
|
2003-12-16 15:28:44 -05:00
|
|
|
*/
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
static VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_aset(int argc, VALUE *argv, VALUE ary)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
1999-08-13 01:45:20 -04:00
|
|
|
long offset, beg, len;
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2000-05-24 00:34:26 -04:00
|
|
|
if (argc == 3) {
|
2004-11-17 22:45:23 -05:00
|
|
|
rb_ary_splice(ary, NUM2LONG(argv[0]), NUM2LONG(argv[1]), argv[2]);
|
2000-05-24 00:34:26 -04:00
|
|
|
return argv[2];
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
2000-05-24 00:34:26 -04:00
|
|
|
if (argc != 2) {
|
2002-05-21 01:39:19 -04:00
|
|
|
rb_raise(rb_eArgError, "wrong number of arguments (%d for 2)", argc);
|
2000-05-24 00:34:26 -04:00
|
|
|
}
|
|
|
|
if (FIXNUM_P(argv[0])) {
|
|
|
|
offset = FIX2LONG(argv[0]);
|
1998-01-16 07:13:05 -05:00
|
|
|
goto fixnum;
|
|
|
|
}
|
2006-09-02 10:42:08 -04:00
|
|
|
if (rb_range_beg_len(argv[0], &beg, &len, RARRAY_LEN(ary), 1)) {
|
1998-01-16 07:13:05 -05:00
|
|
|
/* check if idx is Range */
|
2004-11-17 22:45:23 -05:00
|
|
|
rb_ary_splice(ary, beg, len, argv[1]);
|
2000-05-24 00:34:26 -04:00
|
|
|
return argv[1];
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2000-05-24 00:34:26 -04:00
|
|
|
offset = NUM2LONG(argv[0]);
|
2002-05-21 01:39:19 -04:00
|
|
|
fixnum:
|
2000-05-24 00:34:26 -04:00
|
|
|
rb_ary_store(ary, offset, argv[1]);
|
|
|
|
return argv[1];
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2003-12-16 15:28:44 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
2004-07-13 11:34:34 -04:00
|
|
|
* array.insert(index, obj...) -> array
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
|
|
|
* Inserts the given values before the element with the given index
|
|
|
|
* (which may be negative).
|
|
|
|
*
|
|
|
|
* a = %w{ a b c d }
|
|
|
|
* a.insert(2, 99) #=> ["a", "b", 99, "c", "d"]
|
|
|
|
* a.insert(-2, 1, 2, 3) #=> ["a", "b", 99, "c", 1, 2, 3, "d"]
|
|
|
|
*/
|
|
|
|
|
2001-05-02 00:22:21 -04:00
|
|
|
static VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_insert(int argc, VALUE *argv, VALUE ary)
|
2001-05-02 00:22:21 -04:00
|
|
|
{
|
2001-05-06 11:06:00 -04:00
|
|
|
long pos;
|
|
|
|
|
2005-11-15 00:42:36 -05:00
|
|
|
if (argc == 1) return ary;
|
2003-05-02 02:41:33 -04:00
|
|
|
if (argc < 1) {
|
|
|
|
rb_raise(rb_eArgError, "wrong number of arguments (at least 1)");
|
2001-05-02 00:22:21 -04:00
|
|
|
}
|
2001-05-06 11:06:00 -04:00
|
|
|
pos = NUM2LONG(argv[0]);
|
|
|
|
if (pos == -1) {
|
2006-09-02 10:42:08 -04:00
|
|
|
pos = RARRAY_LEN(ary);
|
2001-05-06 11:06:00 -04:00
|
|
|
}
|
2005-11-15 00:42:36 -05:00
|
|
|
if (pos < 0) {
|
2001-05-06 11:06:00 -04:00
|
|
|
pos++;
|
|
|
|
}
|
2004-11-17 22:45:23 -05:00
|
|
|
rb_ary_splice(ary, pos, 0, rb_ary_new4(argc - 1, argv + 1));
|
2001-05-02 00:22:21 -04:00
|
|
|
return ary;
|
|
|
|
}
|
|
|
|
|
* array.c (ary_iter_check): should check modification (size
change) during iteration.
* array.c (rb_ary_initialize, rb_ary_shift, rb_ary_unshift,
rb_ary_splice, rb_ary_reverse, rb_ary_sort, rb_ary_delete,
rb_ary_delete_at, rb_ary_reject_bang, rb_ary_replace,
rb_ary_clear, rb_ary_fill, rb_ary_uniq_bang, rb_ary_compact,
rb_ary_shuffle): add iteration check.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-12-29 14:25:11 -05:00
|
|
|
static VALUE
|
|
|
|
each_unlock(VALUE ary)
|
|
|
|
{
|
|
|
|
FL_UNSET(ary, ARY_ITERLOCK);
|
|
|
|
return ary;
|
|
|
|
}
|
|
|
|
|
|
|
|
static VALUE
|
|
|
|
each_i(VALUE ary)
|
|
|
|
{
|
|
|
|
long i;
|
|
|
|
|
|
|
|
for (i=0; i<RARRAY_LEN(ary); i++) {
|
|
|
|
rb_yield(RARRAY_PTR(ary)[i]);
|
|
|
|
}
|
|
|
|
return ary;
|
|
|
|
}
|
|
|
|
|
2003-12-16 15:28:44 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
2004-07-13 11:34:34 -04:00
|
|
|
* array.each {|item| block } -> array
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
|
|
|
* Calls <i>block</i> once for each element in <i>self</i>, passing that
|
|
|
|
* element as a parameter.
|
|
|
|
*
|
|
|
|
* a = [ "a", "b", "c" ]
|
|
|
|
* a.each {|x| print x, " -- " }
|
|
|
|
*
|
|
|
|
* produces:
|
|
|
|
*
|
|
|
|
* a -- b -- c --
|
|
|
|
*/
|
|
|
|
|
2006-12-31 10:02:22 -05:00
|
|
|
VALUE yarv_invoke_Array_each_special_block(VALUE ary);
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_each(VALUE ary)
|
* array.c (ary_iter_check): should check modification (size
change) during iteration.
* array.c (rb_ary_initialize, rb_ary_shift, rb_ary_unshift,
rb_ary_splice, rb_ary_reverse, rb_ary_sort, rb_ary_delete,
rb_ary_delete_at, rb_ary_reject_bang, rb_ary_replace,
rb_ary_clear, rb_ary_fill, rb_ary_uniq_bang, rb_ary_compact,
rb_ary_shuffle): add iteration check.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-12-29 14:25:11 -05:00
|
|
|
{
|
2006-12-31 10:02:22 -05:00
|
|
|
long i;
|
|
|
|
VALUE val;
|
|
|
|
|
* array.c (ary_iter_check): should check modification (size
change) during iteration.
* array.c (rb_ary_initialize, rb_ary_shift, rb_ary_unshift,
rb_ary_splice, rb_ary_reverse, rb_ary_sort, rb_ary_delete,
rb_ary_delete_at, rb_ary_reject_bang, rb_ary_replace,
rb_ary_clear, rb_ary_fill, rb_ary_uniq_bang, rb_ary_compact,
rb_ary_shuffle): add iteration check.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-12-29 14:25:11 -05:00
|
|
|
RETURN_ENUMERATOR(ary, 0, 0);
|
2006-12-31 10:02:22 -05:00
|
|
|
|
|
|
|
val = yarv_invoke_Array_each_special_block(ary);
|
|
|
|
if(val != Qundef){
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
* array.c (ary_iter_check): should check modification (size
change) during iteration.
* array.c (rb_ary_initialize, rb_ary_shift, rb_ary_unshift,
rb_ary_splice, rb_ary_reverse, rb_ary_sort, rb_ary_delete,
rb_ary_delete_at, rb_ary_reject_bang, rb_ary_replace,
rb_ary_clear, rb_ary_fill, rb_ary_uniq_bang, rb_ary_compact,
rb_ary_shuffle): add iteration check.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-12-29 14:25:11 -05:00
|
|
|
ITERATE(each_i, ary);
|
2006-12-31 10:02:22 -05:00
|
|
|
return ary;
|
* array.c (ary_iter_check): should check modification (size
change) during iteration.
* array.c (rb_ary_initialize, rb_ary_shift, rb_ary_unshift,
rb_ary_splice, rb_ary_reverse, rb_ary_sort, rb_ary_delete,
rb_ary_delete_at, rb_ary_reject_bang, rb_ary_replace,
rb_ary_clear, rb_ary_fill, rb_ary_uniq_bang, rb_ary_compact,
rb_ary_shuffle): add iteration check.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-12-29 14:25:11 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static VALUE
|
|
|
|
each_index_i(VALUE ary)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
2006-10-11 04:06:16 -04:00
|
|
|
long i;
|
|
|
|
|
|
|
|
for (i=0; i<RARRAY_LEN(ary); i++) {
|
2006-12-31 10:02:22 -05:00
|
|
|
rb_yield(LONG2NUM(i));
|
2006-10-11 04:06:16 -04:00
|
|
|
}
|
1999-08-13 01:45:20 -04:00
|
|
|
return ary;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2003-12-16 15:28:44 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
2004-07-13 11:34:34 -04:00
|
|
|
* array.each_index {|index| block } -> array
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
|
|
|
* Same as <code>Array#each</code>, but passes the index of the element
|
|
|
|
* instead of the element itself.
|
|
|
|
*
|
|
|
|
* a = [ "a", "b", "c" ]
|
|
|
|
* a.each_index {|x| print x, " -- " }
|
|
|
|
*
|
|
|
|
* produces:
|
|
|
|
*
|
|
|
|
* 0 -- 1 -- 2 --
|
|
|
|
*/
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
static VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_each_index(VALUE ary)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
2005-08-30 10:49:51 -04:00
|
|
|
RETURN_ENUMERATOR(ary, 0, 0);
|
* array.c (ary_iter_check): should check modification (size
change) during iteration.
* array.c (rb_ary_initialize, rb_ary_shift, rb_ary_unshift,
rb_ary_splice, rb_ary_reverse, rb_ary_sort, rb_ary_delete,
rb_ary_delete_at, rb_ary_reject_bang, rb_ary_replace,
rb_ary_clear, rb_ary_fill, rb_ary_uniq_bang, rb_ary_compact,
rb_ary_shuffle): add iteration check.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-12-29 14:25:11 -05:00
|
|
|
ITERATE(each_index_i, ary);
|
|
|
|
}
|
|
|
|
|
|
|
|
static VALUE
|
|
|
|
reverse_each_i(VALUE ary)
|
|
|
|
{
|
|
|
|
long len = RARRAY_LEN(ary);
|
|
|
|
|
|
|
|
while (len--) {
|
|
|
|
rb_yield(RARRAY_PTR(ary)[len]);
|
|
|
|
if (RARRAY_LEN(ary) < len) {
|
|
|
|
len = RARRAY_LEN(ary);
|
|
|
|
}
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
1999-08-13 01:45:20 -04:00
|
|
|
return ary;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2003-12-16 15:28:44 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* array.reverse_each {|item| block }
|
|
|
|
*
|
|
|
|
* Same as <code>Array#each</code>, but traverses <i>self</i> in reverse
|
|
|
|
* order.
|
|
|
|
*
|
|
|
|
* a = [ "a", "b", "c" ]
|
|
|
|
* a.reverse_each {|x| print x, " " }
|
|
|
|
*
|
|
|
|
* produces:
|
|
|
|
*
|
|
|
|
* c b a
|
|
|
|
*/
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
static VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_reverse_each(VALUE ary)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
2005-08-30 10:49:51 -04:00
|
|
|
RETURN_ENUMERATOR(ary, 0, 0);
|
* array.c (ary_iter_check): should check modification (size
change) during iteration.
* array.c (rb_ary_initialize, rb_ary_shift, rb_ary_unshift,
rb_ary_splice, rb_ary_reverse, rb_ary_sort, rb_ary_delete,
rb_ary_delete_at, rb_ary_reject_bang, rb_ary_replace,
rb_ary_clear, rb_ary_fill, rb_ary_uniq_bang, rb_ary_compact,
rb_ary_shuffle): add iteration check.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-12-29 14:25:11 -05:00
|
|
|
ITERATE(reverse_each_i, ary);
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2003-12-16 15:28:44 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* array.length -> int
|
|
|
|
*
|
|
|
|
* Returns the number of elements in <i>self</i>. May be zero.
|
|
|
|
*
|
|
|
|
* [ 1, 2, 3, 4, 5 ].length #=> 5
|
|
|
|
*/
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
static VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_length(VALUE ary)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
2006-09-02 10:42:08 -04:00
|
|
|
long len = RARRAY_LEN(ary);
|
|
|
|
return LONG2NUM(len);
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2003-12-16 15:28:44 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
2004-07-13 11:34:34 -04:00
|
|
|
* array.empty? -> true or false
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
|
|
|
* Returns <code>true</code> if <i>self</i> array contains no elements.
|
|
|
|
*
|
|
|
|
* [].empty? #=> true
|
|
|
|
*/
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
static VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_empty_p(VALUE ary)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
2006-09-02 10:42:08 -04:00
|
|
|
if (RARRAY_LEN(ary) == 0)
|
1999-01-19 23:59:39 -05:00
|
|
|
return Qtrue;
|
|
|
|
return Qfalse;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2001-07-14 11:17:19 -04:00
|
|
|
VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_dup(VALUE ary)
|
2001-07-14 11:17:19 -04:00
|
|
|
{
|
2006-09-02 10:42:08 -04:00
|
|
|
VALUE dup = rb_ary_new2(RARRAY_LEN(ary));
|
|
|
|
|
|
|
|
MEMCPY(RARRAY_PTR(dup), RARRAY_PTR(ary), VALUE, RARRAY_LEN(ary));
|
2006-11-01 09:42:39 -05:00
|
|
|
RARRAY(dup)->len = RARRAY_LEN(ary);
|
2006-09-02 10:42:08 -04:00
|
|
|
OBJ_INFECT(dup, ary);
|
2001-07-14 11:17:19 -04:00
|
|
|
|
|
|
|
return dup;
|
|
|
|
}
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
extern VALUE rb_output_fs;
|
|
|
|
|
|
|
|
static VALUE
|
2005-10-11 08:30:48 -04:00
|
|
|
recursive_join(VALUE ary, VALUE argp, int recur)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
2005-10-11 08:30:48 -04:00
|
|
|
VALUE *arg = (VALUE *)argp;
|
* array.c: replace rb_protect_inspect() and rb_inspecting_p() by
rb_exec_recursive() in eval.c.
* eval.c (rb_exec_recursive): new function.
* array.c (rb_ary_join): use rb_exec_recursive().
* array.c (rb_ary_inspect, rb_ary_hash): ditto.
* file.c (rb_file_join): ditto.
* hash.c (rb_hash_inspect, rb_hash_to_s, rb_hash_hash): ditto.
* io.c (rb_io_puts): ditto.
* object.c (rb_obj_inspect): ditto
* struct.c (rb_struct_inspect): ditto.
* lib/set.rb (SortedSet::setup): a hack to shut up warning.
[ruby-talk:132866]
* lib/time.rb (Time::strptime): add new function. inspired by
[ruby-talk:132815].
* lib/parsedate.rb (ParseDate::strptime): ditto.
* regparse.c: move st_*_strend() functions from st.c. fixed some
potential memory leaks.
* exception error messages updated. [ruby-core:04497]
* ext/socket/socket.c (Init_socket): add bunch of Socket
constants. Patch from Sam Roberts <sroberts@uniserve.com>.
[ruby-core:04409]
* array.c (rb_ary_s_create): no need for negative argc check.
[ruby-core:04463]
* array.c (rb_ary_unshift_m): ditto.
* lib/xmlrpc/parser.rb (XMLRPC::FaultException): make it subclass
of StandardError class, not Exception class. [ruby-core:04429]
* parse.y (fcall_gen): lvar(arg) will be evaluated as
lvar.call(arg) when lvar is a defined local variable. [new]
* object.c (rb_class_initialize): call inherited method before
calling initializing block.
* eval.c (rb_thread_start_1): initialize newly pushed frame.
* lib/open3.rb (Open3::popen3): $? should not be EXIT_FAILURE.
fixed: [ruby-core:04444]
* eval.c (is_defined): NODE_IASGN is an assignment.
* ext/readline/readline.c (Readline.readline): use rl_outstream
and rl_instream. [ruby-dev:25699]
* ext/etc/etc.c (Init_etc): sGroup needs HAVE_ST_GR_PASSWD check
[ruby-dev:25675]
* misc/ruby-mode.el: [ruby-core:04415]
* lib/rdoc/generators/html_generator.rb: [ruby-core:04412]
* lib/rdoc/generators/ri_generator.rb: ditto.
* struct.c (make_struct): fixed: [ruby-core:04402]
* ext/curses/curses.c (window_color_set): [ruby-core:04393]
* ext/socket/socket.c (Init_socket): SO_REUSEPORT added.
[ruby-talk:130092]
* object.c: [ruby-doc:818]
* parse.y (open_args): fix too verbose warnings for the space
before argument parentheses. [ruby-dev:25492]
* parse.y (parser_yylex): ditto.
* parse.y (parser_yylex): the first expression in the parentheses
should not be a command. [ruby-dev:25492]
* lib/irb/context.rb (IRB::Context::initialize): [ruby-core:04330]
* object.c (Init_Object): remove Object#type. [ruby-core:04335]
* st.c (st_foreach): report success/failure by return value.
[ruby-Bugs-1396]
* parse.y: forgot to initialize parser struct. [ruby-dev:25492]
* parse.y (parser_yylex): no tLABEL on EXPR_BEG.
[ruby-talk:127711]
* document updates - [ruby-core:04296], [ruby-core:04301],
[ruby-core:04302], [ruby-core:04307]
* dir.c (rb_push_glob): should work for NUL delimited patterns.
* dir.c (rb_glob2): should aware of offset in the pattern.
* string.c (rb_str_new4): should propagate taintedness.
* env.h: rename member names in struct FRAME; last_func -> callee,
orig_func -> this_func, last_class -> this_class.
* struct.c (rb_struct_set): use original method name, not callee
name, to retrieve member slot. [ruby-core:04268]
* time.c (time_strftime): protect from format modification from GC
finalizers.
* object.c (Init_Object): remove rb_obj_id_obsolete()
* eval.c (rb_mod_define_method): incomplete subclass check.
[ruby-dev:25464]
* gc.c (rb_data_object_alloc): klass may be NULL.
[ruby-list:40498]
* bignum.c (rb_big_rand): should return positive random number.
[ruby-dev:25401]
* bignum.c (rb_big_rand): do not use rb_big_modulo to generate
random bignums. [ruby-dev:25396]
* variable.c (rb_autoload): [ruby-dev:25373]
* eval.c (svalue_to_avalue): [ruby-dev:25366]
* string.c (rb_str_justify): [ruby-dev:25367]
* io.c (rb_f_select): [ruby-dev:25312]
* ext/socket/socket.c (sock_s_getservbyport): [ruby-talk:124072]
* struct.c (make_struct): [ruby-dev:25249]
* dir.c (dir_open_dir): new function. [ruby-dev:25242]
* io.c (rb_f_open): add type check for return value from to_open.
* lib/pstore.rb (PStore#transaction): Use the empty content when a
file is not found. [ruby-dev:24561]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-03-04 01:47:45 -05:00
|
|
|
if (recur) {
|
|
|
|
return rb_str_new2("[...]");
|
|
|
|
}
|
1999-01-19 23:59:39 -05:00
|
|
|
return rb_ary_join(arg[0], arg[1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_join(VALUE ary, VALUE sep)
|
1999-01-19 23:59:39 -05:00
|
|
|
{
|
2002-05-21 01:39:19 -04:00
|
|
|
long len = 1, i;
|
|
|
|
int taint = Qfalse;
|
1998-01-16 07:13:05 -05:00
|
|
|
VALUE result, tmp;
|
2000-01-04 23:41:21 -05:00
|
|
|
|
2006-09-02 10:42:08 -04:00
|
|
|
if (RARRAY_LEN(ary) == 0) return rb_str_new(0, 0);
|
2002-05-21 01:39:19 -04:00
|
|
|
if (OBJ_TAINTED(ary) || OBJ_TAINTED(sep)) taint = Qtrue;
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2006-09-02 10:42:08 -04:00
|
|
|
for (i=0; i<RARRAY_LEN(ary); i++) {
|
|
|
|
tmp = rb_check_string_type(RARRAY_PTR(ary)[i]);
|
2006-08-31 04:24:36 -04:00
|
|
|
len += NIL_P(tmp) ? 10 : RSTRING_LEN(tmp);
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
2001-11-15 10:56:08 -05:00
|
|
|
if (!NIL_P(sep)) {
|
|
|
|
StringValue(sep);
|
2006-09-02 10:42:08 -04:00
|
|
|
len += RSTRING_LEN(sep) * (RARRAY_LEN(ary) - 1);
|
2001-05-16 05:05:54 -04:00
|
|
|
}
|
2001-05-30 05:12:34 -04:00
|
|
|
result = rb_str_buf_new(len);
|
2006-09-02 10:42:08 -04:00
|
|
|
for (i=0; i<RARRAY_LEN(ary); i++) {
|
|
|
|
tmp = RARRAY_PTR(ary)[i];
|
1998-01-16 07:13:05 -05:00
|
|
|
switch (TYPE(tmp)) {
|
|
|
|
case T_STRING:
|
|
|
|
break;
|
|
|
|
case T_ARRAY:
|
* array.c: replace rb_protect_inspect() and rb_inspecting_p() by
rb_exec_recursive() in eval.c.
* eval.c (rb_exec_recursive): new function.
* array.c (rb_ary_join): use rb_exec_recursive().
* array.c (rb_ary_inspect, rb_ary_hash): ditto.
* file.c (rb_file_join): ditto.
* hash.c (rb_hash_inspect, rb_hash_to_s, rb_hash_hash): ditto.
* io.c (rb_io_puts): ditto.
* object.c (rb_obj_inspect): ditto
* struct.c (rb_struct_inspect): ditto.
* lib/set.rb (SortedSet::setup): a hack to shut up warning.
[ruby-talk:132866]
* lib/time.rb (Time::strptime): add new function. inspired by
[ruby-talk:132815].
* lib/parsedate.rb (ParseDate::strptime): ditto.
* regparse.c: move st_*_strend() functions from st.c. fixed some
potential memory leaks.
* exception error messages updated. [ruby-core:04497]
* ext/socket/socket.c (Init_socket): add bunch of Socket
constants. Patch from Sam Roberts <sroberts@uniserve.com>.
[ruby-core:04409]
* array.c (rb_ary_s_create): no need for negative argc check.
[ruby-core:04463]
* array.c (rb_ary_unshift_m): ditto.
* lib/xmlrpc/parser.rb (XMLRPC::FaultException): make it subclass
of StandardError class, not Exception class. [ruby-core:04429]
* parse.y (fcall_gen): lvar(arg) will be evaluated as
lvar.call(arg) when lvar is a defined local variable. [new]
* object.c (rb_class_initialize): call inherited method before
calling initializing block.
* eval.c (rb_thread_start_1): initialize newly pushed frame.
* lib/open3.rb (Open3::popen3): $? should not be EXIT_FAILURE.
fixed: [ruby-core:04444]
* eval.c (is_defined): NODE_IASGN is an assignment.
* ext/readline/readline.c (Readline.readline): use rl_outstream
and rl_instream. [ruby-dev:25699]
* ext/etc/etc.c (Init_etc): sGroup needs HAVE_ST_GR_PASSWD check
[ruby-dev:25675]
* misc/ruby-mode.el: [ruby-core:04415]
* lib/rdoc/generators/html_generator.rb: [ruby-core:04412]
* lib/rdoc/generators/ri_generator.rb: ditto.
* struct.c (make_struct): fixed: [ruby-core:04402]
* ext/curses/curses.c (window_color_set): [ruby-core:04393]
* ext/socket/socket.c (Init_socket): SO_REUSEPORT added.
[ruby-talk:130092]
* object.c: [ruby-doc:818]
* parse.y (open_args): fix too verbose warnings for the space
before argument parentheses. [ruby-dev:25492]
* parse.y (parser_yylex): ditto.
* parse.y (parser_yylex): the first expression in the parentheses
should not be a command. [ruby-dev:25492]
* lib/irb/context.rb (IRB::Context::initialize): [ruby-core:04330]
* object.c (Init_Object): remove Object#type. [ruby-core:04335]
* st.c (st_foreach): report success/failure by return value.
[ruby-Bugs-1396]
* parse.y: forgot to initialize parser struct. [ruby-dev:25492]
* parse.y (parser_yylex): no tLABEL on EXPR_BEG.
[ruby-talk:127711]
* document updates - [ruby-core:04296], [ruby-core:04301],
[ruby-core:04302], [ruby-core:04307]
* dir.c (rb_push_glob): should work for NUL delimited patterns.
* dir.c (rb_glob2): should aware of offset in the pattern.
* string.c (rb_str_new4): should propagate taintedness.
* env.h: rename member names in struct FRAME; last_func -> callee,
orig_func -> this_func, last_class -> this_class.
* struct.c (rb_struct_set): use original method name, not callee
name, to retrieve member slot. [ruby-core:04268]
* time.c (time_strftime): protect from format modification from GC
finalizers.
* object.c (Init_Object): remove rb_obj_id_obsolete()
* eval.c (rb_mod_define_method): incomplete subclass check.
[ruby-dev:25464]
* gc.c (rb_data_object_alloc): klass may be NULL.
[ruby-list:40498]
* bignum.c (rb_big_rand): should return positive random number.
[ruby-dev:25401]
* bignum.c (rb_big_rand): do not use rb_big_modulo to generate
random bignums. [ruby-dev:25396]
* variable.c (rb_autoload): [ruby-dev:25373]
* eval.c (svalue_to_avalue): [ruby-dev:25366]
* string.c (rb_str_justify): [ruby-dev:25367]
* io.c (rb_f_select): [ruby-dev:25312]
* ext/socket/socket.c (sock_s_getservbyport): [ruby-talk:124072]
* struct.c (make_struct): [ruby-dev:25249]
* dir.c (dir_open_dir): new function. [ruby-dev:25242]
* io.c (rb_f_open): add type check for return value from to_open.
* lib/pstore.rb (PStore#transaction): Use the empty content when a
file is not found. [ruby-dev:24561]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-03-04 01:47:45 -05:00
|
|
|
{
|
1999-01-19 23:59:39 -05:00
|
|
|
VALUE args[2];
|
|
|
|
|
|
|
|
args[0] = tmp;
|
|
|
|
args[1] = sep;
|
* array.c: replace rb_protect_inspect() and rb_inspecting_p() by
rb_exec_recursive() in eval.c.
* eval.c (rb_exec_recursive): new function.
* array.c (rb_ary_join): use rb_exec_recursive().
* array.c (rb_ary_inspect, rb_ary_hash): ditto.
* file.c (rb_file_join): ditto.
* hash.c (rb_hash_inspect, rb_hash_to_s, rb_hash_hash): ditto.
* io.c (rb_io_puts): ditto.
* object.c (rb_obj_inspect): ditto
* struct.c (rb_struct_inspect): ditto.
* lib/set.rb (SortedSet::setup): a hack to shut up warning.
[ruby-talk:132866]
* lib/time.rb (Time::strptime): add new function. inspired by
[ruby-talk:132815].
* lib/parsedate.rb (ParseDate::strptime): ditto.
* regparse.c: move st_*_strend() functions from st.c. fixed some
potential memory leaks.
* exception error messages updated. [ruby-core:04497]
* ext/socket/socket.c (Init_socket): add bunch of Socket
constants. Patch from Sam Roberts <sroberts@uniserve.com>.
[ruby-core:04409]
* array.c (rb_ary_s_create): no need for negative argc check.
[ruby-core:04463]
* array.c (rb_ary_unshift_m): ditto.
* lib/xmlrpc/parser.rb (XMLRPC::FaultException): make it subclass
of StandardError class, not Exception class. [ruby-core:04429]
* parse.y (fcall_gen): lvar(arg) will be evaluated as
lvar.call(arg) when lvar is a defined local variable. [new]
* object.c (rb_class_initialize): call inherited method before
calling initializing block.
* eval.c (rb_thread_start_1): initialize newly pushed frame.
* lib/open3.rb (Open3::popen3): $? should not be EXIT_FAILURE.
fixed: [ruby-core:04444]
* eval.c (is_defined): NODE_IASGN is an assignment.
* ext/readline/readline.c (Readline.readline): use rl_outstream
and rl_instream. [ruby-dev:25699]
* ext/etc/etc.c (Init_etc): sGroup needs HAVE_ST_GR_PASSWD check
[ruby-dev:25675]
* misc/ruby-mode.el: [ruby-core:04415]
* lib/rdoc/generators/html_generator.rb: [ruby-core:04412]
* lib/rdoc/generators/ri_generator.rb: ditto.
* struct.c (make_struct): fixed: [ruby-core:04402]
* ext/curses/curses.c (window_color_set): [ruby-core:04393]
* ext/socket/socket.c (Init_socket): SO_REUSEPORT added.
[ruby-talk:130092]
* object.c: [ruby-doc:818]
* parse.y (open_args): fix too verbose warnings for the space
before argument parentheses. [ruby-dev:25492]
* parse.y (parser_yylex): ditto.
* parse.y (parser_yylex): the first expression in the parentheses
should not be a command. [ruby-dev:25492]
* lib/irb/context.rb (IRB::Context::initialize): [ruby-core:04330]
* object.c (Init_Object): remove Object#type. [ruby-core:04335]
* st.c (st_foreach): report success/failure by return value.
[ruby-Bugs-1396]
* parse.y: forgot to initialize parser struct. [ruby-dev:25492]
* parse.y (parser_yylex): no tLABEL on EXPR_BEG.
[ruby-talk:127711]
* document updates - [ruby-core:04296], [ruby-core:04301],
[ruby-core:04302], [ruby-core:04307]
* dir.c (rb_push_glob): should work for NUL delimited patterns.
* dir.c (rb_glob2): should aware of offset in the pattern.
* string.c (rb_str_new4): should propagate taintedness.
* env.h: rename member names in struct FRAME; last_func -> callee,
orig_func -> this_func, last_class -> this_class.
* struct.c (rb_struct_set): use original method name, not callee
name, to retrieve member slot. [ruby-core:04268]
* time.c (time_strftime): protect from format modification from GC
finalizers.
* object.c (Init_Object): remove rb_obj_id_obsolete()
* eval.c (rb_mod_define_method): incomplete subclass check.
[ruby-dev:25464]
* gc.c (rb_data_object_alloc): klass may be NULL.
[ruby-list:40498]
* bignum.c (rb_big_rand): should return positive random number.
[ruby-dev:25401]
* bignum.c (rb_big_rand): do not use rb_big_modulo to generate
random bignums. [ruby-dev:25396]
* variable.c (rb_autoload): [ruby-dev:25373]
* eval.c (svalue_to_avalue): [ruby-dev:25366]
* string.c (rb_str_justify): [ruby-dev:25367]
* io.c (rb_f_select): [ruby-dev:25312]
* ext/socket/socket.c (sock_s_getservbyport): [ruby-talk:124072]
* struct.c (make_struct): [ruby-dev:25249]
* dir.c (dir_open_dir): new function. [ruby-dev:25242]
* io.c (rb_f_open): add type check for return value from to_open.
* lib/pstore.rb (PStore#transaction): Use the empty content when a
file is not found. [ruby-dev:24561]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-03-04 01:47:45 -05:00
|
|
|
tmp = rb_exec_recursive(recursive_join, ary, (VALUE)args);
|
1999-01-19 23:59:39 -05:00
|
|
|
}
|
1998-01-16 07:13:05 -05:00
|
|
|
break;
|
|
|
|
default:
|
1999-01-19 23:59:39 -05:00
|
|
|
tmp = rb_obj_as_string(tmp);
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
2001-05-30 05:12:34 -04:00
|
|
|
if (i > 0 && !NIL_P(sep))
|
|
|
|
rb_str_buf_append(result, sep);
|
|
|
|
rb_str_buf_append(result, tmp);
|
2002-05-21 01:39:19 -04:00
|
|
|
if (OBJ_TAINTED(tmp)) taint = Qtrue;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2000-01-04 23:41:21 -05:00
|
|
|
if (taint) OBJ_TAINT(result);
|
1998-01-16 07:13:05 -05:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2003-12-16 15:28:44 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
2004-07-13 11:34:34 -04:00
|
|
|
* array.join(sep=$,) -> str
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
|
|
|
* Returns a string created by converting each element of the array to
|
|
|
|
* a string, separated by <i>sep</i>.
|
|
|
|
*
|
|
|
|
* [ "a", "b", "c" ].join #=> "abc"
|
|
|
|
* [ "a", "b", "c" ].join("-") #=> "a-b-c"
|
|
|
|
*/
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
static VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_join_m(int argc, VALUE *argv, VALUE ary)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
|
|
|
VALUE sep;
|
|
|
|
|
|
|
|
rb_scan_args(argc, argv, "01", &sep);
|
1999-01-19 23:59:39 -05:00
|
|
|
if (NIL_P(sep)) sep = rb_output_fs;
|
2002-05-21 01:39:19 -04:00
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
return rb_ary_join(ary, sep);
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
inspect_ary(VALUE ary, VALUE dummy, int recur)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
2000-02-23 00:23:12 -05:00
|
|
|
int tainted = OBJ_TAINTED(ary);
|
2002-05-21 01:39:19 -04:00
|
|
|
long i;
|
1998-01-16 07:13:05 -05:00
|
|
|
VALUE s, str;
|
|
|
|
|
* array.c: replace rb_protect_inspect() and rb_inspecting_p() by
rb_exec_recursive() in eval.c.
* eval.c (rb_exec_recursive): new function.
* array.c (rb_ary_join): use rb_exec_recursive().
* array.c (rb_ary_inspect, rb_ary_hash): ditto.
* file.c (rb_file_join): ditto.
* hash.c (rb_hash_inspect, rb_hash_to_s, rb_hash_hash): ditto.
* io.c (rb_io_puts): ditto.
* object.c (rb_obj_inspect): ditto
* struct.c (rb_struct_inspect): ditto.
* lib/set.rb (SortedSet::setup): a hack to shut up warning.
[ruby-talk:132866]
* lib/time.rb (Time::strptime): add new function. inspired by
[ruby-talk:132815].
* lib/parsedate.rb (ParseDate::strptime): ditto.
* regparse.c: move st_*_strend() functions from st.c. fixed some
potential memory leaks.
* exception error messages updated. [ruby-core:04497]
* ext/socket/socket.c (Init_socket): add bunch of Socket
constants. Patch from Sam Roberts <sroberts@uniserve.com>.
[ruby-core:04409]
* array.c (rb_ary_s_create): no need for negative argc check.
[ruby-core:04463]
* array.c (rb_ary_unshift_m): ditto.
* lib/xmlrpc/parser.rb (XMLRPC::FaultException): make it subclass
of StandardError class, not Exception class. [ruby-core:04429]
* parse.y (fcall_gen): lvar(arg) will be evaluated as
lvar.call(arg) when lvar is a defined local variable. [new]
* object.c (rb_class_initialize): call inherited method before
calling initializing block.
* eval.c (rb_thread_start_1): initialize newly pushed frame.
* lib/open3.rb (Open3::popen3): $? should not be EXIT_FAILURE.
fixed: [ruby-core:04444]
* eval.c (is_defined): NODE_IASGN is an assignment.
* ext/readline/readline.c (Readline.readline): use rl_outstream
and rl_instream. [ruby-dev:25699]
* ext/etc/etc.c (Init_etc): sGroup needs HAVE_ST_GR_PASSWD check
[ruby-dev:25675]
* misc/ruby-mode.el: [ruby-core:04415]
* lib/rdoc/generators/html_generator.rb: [ruby-core:04412]
* lib/rdoc/generators/ri_generator.rb: ditto.
* struct.c (make_struct): fixed: [ruby-core:04402]
* ext/curses/curses.c (window_color_set): [ruby-core:04393]
* ext/socket/socket.c (Init_socket): SO_REUSEPORT added.
[ruby-talk:130092]
* object.c: [ruby-doc:818]
* parse.y (open_args): fix too verbose warnings for the space
before argument parentheses. [ruby-dev:25492]
* parse.y (parser_yylex): ditto.
* parse.y (parser_yylex): the first expression in the parentheses
should not be a command. [ruby-dev:25492]
* lib/irb/context.rb (IRB::Context::initialize): [ruby-core:04330]
* object.c (Init_Object): remove Object#type. [ruby-core:04335]
* st.c (st_foreach): report success/failure by return value.
[ruby-Bugs-1396]
* parse.y: forgot to initialize parser struct. [ruby-dev:25492]
* parse.y (parser_yylex): no tLABEL on EXPR_BEG.
[ruby-talk:127711]
* document updates - [ruby-core:04296], [ruby-core:04301],
[ruby-core:04302], [ruby-core:04307]
* dir.c (rb_push_glob): should work for NUL delimited patterns.
* dir.c (rb_glob2): should aware of offset in the pattern.
* string.c (rb_str_new4): should propagate taintedness.
* env.h: rename member names in struct FRAME; last_func -> callee,
orig_func -> this_func, last_class -> this_class.
* struct.c (rb_struct_set): use original method name, not callee
name, to retrieve member slot. [ruby-core:04268]
* time.c (time_strftime): protect from format modification from GC
finalizers.
* object.c (Init_Object): remove rb_obj_id_obsolete()
* eval.c (rb_mod_define_method): incomplete subclass check.
[ruby-dev:25464]
* gc.c (rb_data_object_alloc): klass may be NULL.
[ruby-list:40498]
* bignum.c (rb_big_rand): should return positive random number.
[ruby-dev:25401]
* bignum.c (rb_big_rand): do not use rb_big_modulo to generate
random bignums. [ruby-dev:25396]
* variable.c (rb_autoload): [ruby-dev:25373]
* eval.c (svalue_to_avalue): [ruby-dev:25366]
* string.c (rb_str_justify): [ruby-dev:25367]
* io.c (rb_f_select): [ruby-dev:25312]
* ext/socket/socket.c (sock_s_getservbyport): [ruby-talk:124072]
* struct.c (make_struct): [ruby-dev:25249]
* dir.c (dir_open_dir): new function. [ruby-dev:25242]
* io.c (rb_f_open): add type check for return value from to_open.
* lib/pstore.rb (PStore#transaction): Use the empty content when a
file is not found. [ruby-dev:24561]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-03-04 01:47:45 -05:00
|
|
|
if (recur) return rb_tainted_str_new2("[...]");
|
2001-05-30 05:12:34 -04:00
|
|
|
str = rb_str_buf_new2("[");
|
2006-09-02 10:42:08 -04:00
|
|
|
for (i=0; i<RARRAY_LEN(ary); i++) {
|
|
|
|
s = rb_inspect(RARRAY_PTR(ary)[i]);
|
2002-05-21 01:39:19 -04:00
|
|
|
if (OBJ_TAINTED(s)) tainted = Qtrue;
|
2001-05-30 05:12:34 -04:00
|
|
|
if (i > 0) rb_str_buf_cat2(str, ", ");
|
|
|
|
rb_str_buf_append(str, s);
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
2001-05-30 05:12:34 -04:00
|
|
|
rb_str_buf_cat2(str, "]");
|
2000-02-23 00:23:12 -05:00
|
|
|
if (tainted) OBJ_TAINT(str);
|
1998-01-16 07:13:05 -05:00
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
2003-12-28 21:02:08 -05:00
|
|
|
/*
|
2004-07-13 12:21:23 -04:00
|
|
|
* call-seq:
|
2006-09-07 12:33:08 -04:00
|
|
|
* array.to_s -> string
|
2004-07-13 12:21:23 -04:00
|
|
|
* array.inspect -> string
|
2003-12-28 21:02:08 -05:00
|
|
|
*
|
2004-07-13 12:21:23 -04:00
|
|
|
* Create a printable version of <i>array</i>.
|
2003-12-28 21:02:08 -05:00
|
|
|
*/
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
static VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_inspect(VALUE ary)
|
1999-01-19 23:59:39 -05:00
|
|
|
{
|
2006-09-02 10:42:08 -04:00
|
|
|
if (RARRAY_LEN(ary) == 0) return rb_str_new2("[]");
|
* array.c: replace rb_protect_inspect() and rb_inspecting_p() by
rb_exec_recursive() in eval.c.
* eval.c (rb_exec_recursive): new function.
* array.c (rb_ary_join): use rb_exec_recursive().
* array.c (rb_ary_inspect, rb_ary_hash): ditto.
* file.c (rb_file_join): ditto.
* hash.c (rb_hash_inspect, rb_hash_to_s, rb_hash_hash): ditto.
* io.c (rb_io_puts): ditto.
* object.c (rb_obj_inspect): ditto
* struct.c (rb_struct_inspect): ditto.
* lib/set.rb (SortedSet::setup): a hack to shut up warning.
[ruby-talk:132866]
* lib/time.rb (Time::strptime): add new function. inspired by
[ruby-talk:132815].
* lib/parsedate.rb (ParseDate::strptime): ditto.
* regparse.c: move st_*_strend() functions from st.c. fixed some
potential memory leaks.
* exception error messages updated. [ruby-core:04497]
* ext/socket/socket.c (Init_socket): add bunch of Socket
constants. Patch from Sam Roberts <sroberts@uniserve.com>.
[ruby-core:04409]
* array.c (rb_ary_s_create): no need for negative argc check.
[ruby-core:04463]
* array.c (rb_ary_unshift_m): ditto.
* lib/xmlrpc/parser.rb (XMLRPC::FaultException): make it subclass
of StandardError class, not Exception class. [ruby-core:04429]
* parse.y (fcall_gen): lvar(arg) will be evaluated as
lvar.call(arg) when lvar is a defined local variable. [new]
* object.c (rb_class_initialize): call inherited method before
calling initializing block.
* eval.c (rb_thread_start_1): initialize newly pushed frame.
* lib/open3.rb (Open3::popen3): $? should not be EXIT_FAILURE.
fixed: [ruby-core:04444]
* eval.c (is_defined): NODE_IASGN is an assignment.
* ext/readline/readline.c (Readline.readline): use rl_outstream
and rl_instream. [ruby-dev:25699]
* ext/etc/etc.c (Init_etc): sGroup needs HAVE_ST_GR_PASSWD check
[ruby-dev:25675]
* misc/ruby-mode.el: [ruby-core:04415]
* lib/rdoc/generators/html_generator.rb: [ruby-core:04412]
* lib/rdoc/generators/ri_generator.rb: ditto.
* struct.c (make_struct): fixed: [ruby-core:04402]
* ext/curses/curses.c (window_color_set): [ruby-core:04393]
* ext/socket/socket.c (Init_socket): SO_REUSEPORT added.
[ruby-talk:130092]
* object.c: [ruby-doc:818]
* parse.y (open_args): fix too verbose warnings for the space
before argument parentheses. [ruby-dev:25492]
* parse.y (parser_yylex): ditto.
* parse.y (parser_yylex): the first expression in the parentheses
should not be a command. [ruby-dev:25492]
* lib/irb/context.rb (IRB::Context::initialize): [ruby-core:04330]
* object.c (Init_Object): remove Object#type. [ruby-core:04335]
* st.c (st_foreach): report success/failure by return value.
[ruby-Bugs-1396]
* parse.y: forgot to initialize parser struct. [ruby-dev:25492]
* parse.y (parser_yylex): no tLABEL on EXPR_BEG.
[ruby-talk:127711]
* document updates - [ruby-core:04296], [ruby-core:04301],
[ruby-core:04302], [ruby-core:04307]
* dir.c (rb_push_glob): should work for NUL delimited patterns.
* dir.c (rb_glob2): should aware of offset in the pattern.
* string.c (rb_str_new4): should propagate taintedness.
* env.h: rename member names in struct FRAME; last_func -> callee,
orig_func -> this_func, last_class -> this_class.
* struct.c (rb_struct_set): use original method name, not callee
name, to retrieve member slot. [ruby-core:04268]
* time.c (time_strftime): protect from format modification from GC
finalizers.
* object.c (Init_Object): remove rb_obj_id_obsolete()
* eval.c (rb_mod_define_method): incomplete subclass check.
[ruby-dev:25464]
* gc.c (rb_data_object_alloc): klass may be NULL.
[ruby-list:40498]
* bignum.c (rb_big_rand): should return positive random number.
[ruby-dev:25401]
* bignum.c (rb_big_rand): do not use rb_big_modulo to generate
random bignums. [ruby-dev:25396]
* variable.c (rb_autoload): [ruby-dev:25373]
* eval.c (svalue_to_avalue): [ruby-dev:25366]
* string.c (rb_str_justify): [ruby-dev:25367]
* io.c (rb_f_select): [ruby-dev:25312]
* ext/socket/socket.c (sock_s_getservbyport): [ruby-talk:124072]
* struct.c (make_struct): [ruby-dev:25249]
* dir.c (dir_open_dir): new function. [ruby-dev:25242]
* io.c (rb_f_open): add type check for return value from to_open.
* lib/pstore.rb (PStore#transaction): Use the empty content when a
file is not found. [ruby-dev:24561]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-03-04 01:47:45 -05:00
|
|
|
return rb_exec_recursive(inspect_ary, ary, 0);
|
1999-01-19 23:59:39 -05:00
|
|
|
}
|
|
|
|
|
2006-09-07 12:33:08 -04:00
|
|
|
VALUE
|
|
|
|
rb_ary_to_s(VALUE ary)
|
|
|
|
{
|
|
|
|
return rb_ary_inspect(ary);
|
|
|
|
}
|
|
|
|
|
2003-12-16 15:28:44 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
2004-07-13 11:34:34 -04:00
|
|
|
* array.to_a -> array
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
|
|
|
* Returns _self_. If called on a subclass of Array, converts
|
|
|
|
* the receiver to an Array object.
|
|
|
|
*/
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
static VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_to_a(VALUE ary)
|
2003-02-10 04:40:13 -05:00
|
|
|
{
|
|
|
|
if (rb_obj_class(ary) != rb_cArray) {
|
2006-09-02 10:42:08 -04:00
|
|
|
VALUE dup = rb_ary_new2(RARRAY_LEN(ary));
|
2003-02-10 04:40:13 -05:00
|
|
|
rb_ary_replace(dup, ary);
|
|
|
|
return dup;
|
|
|
|
}
|
|
|
|
return ary;
|
|
|
|
}
|
|
|
|
|
2003-12-16 15:28:44 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* array.to_ary -> array
|
|
|
|
*
|
|
|
|
* Returns _self_.
|
|
|
|
*/
|
|
|
|
|
2003-02-10 04:40:13 -05:00
|
|
|
static VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_to_ary_m(VALUE ary)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
|
|
|
return ary;
|
|
|
|
}
|
|
|
|
|
|
|
|
VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_reverse(VALUE ary)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
|
|
|
VALUE *p1, *p2;
|
|
|
|
VALUE tmp;
|
|
|
|
|
1999-10-18 05:03:16 -04:00
|
|
|
rb_ary_modify(ary);
|
* array.c (ary_iter_check): should check modification (size
change) during iteration.
* array.c (rb_ary_initialize, rb_ary_shift, rb_ary_unshift,
rb_ary_splice, rb_ary_reverse, rb_ary_sort, rb_ary_delete,
rb_ary_delete_at, rb_ary_reject_bang, rb_ary_replace,
rb_ary_clear, rb_ary_fill, rb_ary_uniq_bang, rb_ary_compact,
rb_ary_shuffle): add iteration check.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-12-29 14:25:11 -05:00
|
|
|
ary_iter_check(ary);
|
2006-09-02 10:42:08 -04:00
|
|
|
if (RARRAY_LEN(ary) > 1) {
|
|
|
|
p1 = RARRAY_PTR(ary);
|
|
|
|
p2 = p1 + RARRAY_LEN(ary) - 1; /* points last item */
|
2003-09-05 01:07:54 -04:00
|
|
|
|
|
|
|
while (p1 < p2) {
|
|
|
|
tmp = *p1;
|
|
|
|
*p1++ = *p2;
|
|
|
|
*p2-- = tmp;
|
|
|
|
}
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
1998-01-16 07:19:22 -05:00
|
|
|
return ary;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2003-12-16 15:28:44 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
2004-07-13 11:34:34 -04:00
|
|
|
* array.reverse! -> array
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
|
|
|
* Reverses _self_ in place.
|
|
|
|
*
|
|
|
|
* a = [ "a", "b", "c" ]
|
|
|
|
* a.reverse! #=> ["c", "b", "a"]
|
|
|
|
* a #=> ["c", "b", "a"]
|
|
|
|
*/
|
|
|
|
|
2000-08-24 02:21:43 -04:00
|
|
|
static VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_reverse_bang(VALUE ary)
|
2000-08-24 02:21:43 -04:00
|
|
|
{
|
|
|
|
return rb_ary_reverse(ary);
|
|
|
|
}
|
|
|
|
|
2003-12-16 15:28:44 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* array.reverse -> an_array
|
|
|
|
*
|
|
|
|
* Returns a new array containing <i>self</i>'s elements in reverse order.
|
|
|
|
*
|
|
|
|
* [ "a", "b", "c" ].reverse #=> ["c", "b", "a"]
|
|
|
|
* [ 1 ].reverse #=> [1]
|
|
|
|
*/
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
static VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_reverse_m(VALUE ary)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
2002-08-27 04:31:08 -04:00
|
|
|
return rb_ary_reverse(rb_ary_dup(ary));
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2004-09-20 23:08:33 -04:00
|
|
|
struct ary_sort_data {
|
|
|
|
VALUE ary;
|
|
|
|
VALUE *ptr;
|
|
|
|
long len;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
2005-09-10 09:34:53 -04:00
|
|
|
ary_sort_check(struct ary_sort_data *data)
|
2004-09-20 23:08:33 -04:00
|
|
|
{
|
2006-09-02 10:42:08 -04:00
|
|
|
if (RARRAY_PTR(data->ary) != data->ptr || RARRAY_LEN(data->ary) != data->len) {
|
2004-10-30 02:56:18 -04:00
|
|
|
rb_raise(rb_eRuntimeError, "array modified during sort");
|
2004-09-20 23:08:33 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
static int
|
2005-10-11 08:30:48 -04:00
|
|
|
sort_1(const void *ap, const void *bp, void *data)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
2005-10-11 08:30:48 -04:00
|
|
|
VALUE a = *(const VALUE *)ap, b = *(const VALUE *)bp;
|
|
|
|
VALUE retval = rb_yield_values(2, a, b);
|
2004-09-22 20:51:32 -04:00
|
|
|
int n;
|
2004-09-20 23:08:33 -04:00
|
|
|
|
2005-10-11 08:30:48 -04:00
|
|
|
n = rb_cmpint(retval, a, b);
|
|
|
|
ary_sort_check((struct ary_sort_data *)data);
|
2004-09-22 20:51:32 -04:00
|
|
|
return n;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2005-10-11 08:30:48 -04:00
|
|
|
sort_2(const void *ap, const void *bp, void *data)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
|
|
|
VALUE retval;
|
2005-10-11 08:30:48 -04:00
|
|
|
VALUE a = *(const VALUE *)ap, b = *(const VALUE *)bp;
|
2004-09-22 20:51:32 -04:00
|
|
|
int n;
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2002-08-19 01:56:09 -04:00
|
|
|
if (FIXNUM_P(a) && FIXNUM_P(b)) {
|
2004-09-22 20:51:32 -04:00
|
|
|
if ((long)a > (long)b) return 1;
|
|
|
|
if ((long)a < (long)b) return -1;
|
2002-08-19 02:41:02 -04:00
|
|
|
return 0;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
2005-07-05 10:23:38 -04:00
|
|
|
if (TYPE(a) == T_STRING) {
|
|
|
|
if (TYPE(b) == T_STRING) return rb_str_cmp(a, b);
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2002-08-19 01:56:09 -04:00
|
|
|
retval = rb_funcall(a, id_cmp, 1, b);
|
2004-09-22 20:51:32 -04:00
|
|
|
n = rb_cmpint(retval, a, b);
|
2005-10-11 08:30:48 -04:00
|
|
|
ary_sort_check((struct ary_sort_data *)data);
|
2004-09-22 20:51:32 -04:00
|
|
|
|
|
|
|
return n;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
static VALUE
|
* array.c (ary_iter_check): should check modification (size
change) during iteration.
* array.c (rb_ary_initialize, rb_ary_shift, rb_ary_unshift,
rb_ary_splice, rb_ary_reverse, rb_ary_sort, rb_ary_delete,
rb_ary_delete_at, rb_ary_reject_bang, rb_ary_replace,
rb_ary_clear, rb_ary_fill, rb_ary_uniq_bang, rb_ary_compact,
rb_ary_shuffle): add iteration check.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-12-29 14:25:11 -05:00
|
|
|
sort_i(VALUE ary)
|
1999-01-19 23:59:39 -05:00
|
|
|
{
|
2004-09-20 23:08:33 -04:00
|
|
|
struct ary_sort_data data;
|
|
|
|
|
|
|
|
data.ary = ary;
|
2006-09-02 10:42:08 -04:00
|
|
|
data.ptr = RARRAY_PTR(ary); data.len = RARRAY_LEN(ary);
|
|
|
|
ruby_qsort(RARRAY_PTR(ary), RARRAY_LEN(ary), sizeof(VALUE),
|
2006-12-31 10:02:22 -05:00
|
|
|
rb_block_given_p()?sort_1:sort_2, &data);
|
1999-01-19 23:59:39 -05:00
|
|
|
return ary;
|
|
|
|
}
|
|
|
|
|
2006-10-11 04:06:16 -04:00
|
|
|
static VALUE
|
|
|
|
sort_unlock(VALUE ary)
|
|
|
|
{
|
* array.c (ary_iter_check): should check modification (size
change) during iteration.
* array.c (rb_ary_initialize, rb_ary_shift, rb_ary_unshift,
rb_ary_splice, rb_ary_reverse, rb_ary_sort, rb_ary_delete,
rb_ary_delete_at, rb_ary_reject_bang, rb_ary_replace,
rb_ary_clear, rb_ary_fill, rb_ary_uniq_bang, rb_ary_compact,
rb_ary_shuffle): add iteration check.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-12-29 14:25:11 -05:00
|
|
|
FL_UNSET(ary, ARY_SORTLOCK);
|
2006-10-11 04:06:16 -04:00
|
|
|
return ary;
|
|
|
|
}
|
|
|
|
|
2003-12-16 15:28:44 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
2004-07-13 11:34:34 -04:00
|
|
|
* array.sort! -> array
|
|
|
|
* array.sort! {| a,b | block } -> array
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
|
|
|
* Sorts _self_. Comparisons for
|
|
|
|
* the sort will be done using the <code><=></code> operator or using
|
|
|
|
* an optional code block. The block implements a comparison between
|
|
|
|
* <i>a</i> and <i>b</i>, returning -1, 0, or +1. See also
|
|
|
|
* <code>Enumerable#sort_by</code>.
|
|
|
|
*
|
|
|
|
* a = [ "d", "a", "e", "c", "b" ]
|
|
|
|
* a.sort #=> ["a", "b", "c", "d", "e"]
|
|
|
|
* a.sort {|x,y| y <=> x } #=> ["e", "d", "c", "b", "a"]
|
|
|
|
*/
|
|
|
|
|
2003-12-28 21:02:08 -05:00
|
|
|
VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_sort_bang(VALUE ary)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
1999-10-16 06:33:06 -04:00
|
|
|
rb_ary_modify(ary);
|
* array.c (ary_iter_check): should check modification (size
change) during iteration.
* array.c (rb_ary_initialize, rb_ary_shift, rb_ary_unshift,
rb_ary_splice, rb_ary_reverse, rb_ary_sort, rb_ary_delete,
rb_ary_delete_at, rb_ary_reject_bang, rb_ary_replace,
rb_ary_clear, rb_ary_fill, rb_ary_uniq_bang, rb_ary_compact,
rb_ary_shuffle): add iteration check.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-12-29 14:25:11 -05:00
|
|
|
ary_iter_check(ary);
|
2006-09-02 10:42:08 -04:00
|
|
|
if (RARRAY_LEN(ary) > 1) {
|
* array.c (ary_iter_check): should check modification (size
change) during iteration.
* array.c (rb_ary_initialize, rb_ary_shift, rb_ary_unshift,
rb_ary_splice, rb_ary_reverse, rb_ary_sort, rb_ary_delete,
rb_ary_delete_at, rb_ary_reject_bang, rb_ary_replace,
rb_ary_clear, rb_ary_fill, rb_ary_uniq_bang, rb_ary_compact,
rb_ary_shuffle): add iteration check.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-12-29 14:25:11 -05:00
|
|
|
FL_SET(ary, ARY_SORTLOCK); /* prohibit modification during sort */
|
|
|
|
rb_ensure(sort_i, ary, sort_unlock, ary);
|
2003-09-05 01:07:54 -04:00
|
|
|
}
|
1998-01-16 07:19:22 -05:00
|
|
|
return ary;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2003-12-16 15:28:44 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
2004-07-13 11:34:34 -04:00
|
|
|
* array.sort -> an_array
|
|
|
|
* array.sort {| a,b | block } -> an_array
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
|
|
|
* Returns a new array created by sorting <i>self</i>. Comparisons for
|
|
|
|
* the sort will be done using the <code><=></code> operator or using
|
|
|
|
* an optional code block. The block implements a comparison between
|
|
|
|
* <i>a</i> and <i>b</i>, returning -1, 0, or +1. See also
|
|
|
|
* <code>Enumerable#sort_by</code>.
|
|
|
|
*
|
|
|
|
* a = [ "d", "a", "e", "c", "b" ]
|
|
|
|
* a.sort #=> ["a", "b", "c", "d", "e"]
|
|
|
|
* a.sort {|x,y| y <=> x } #=> ["e", "d", "c", "b", "a"]
|
|
|
|
*/
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_sort(VALUE ary)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
2002-08-27 04:31:08 -04:00
|
|
|
ary = rb_ary_dup(ary);
|
1999-10-20 03:10:23 -04:00
|
|
|
rb_ary_sort_bang(ary);
|
|
|
|
return ary;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
* array.c (ary_iter_check): should check modification (size
change) during iteration.
* array.c (rb_ary_initialize, rb_ary_shift, rb_ary_unshift,
rb_ary_splice, rb_ary_reverse, rb_ary_sort, rb_ary_delete,
rb_ary_delete_at, rb_ary_reject_bang, rb_ary_replace,
rb_ary_clear, rb_ary_fill, rb_ary_uniq_bang, rb_ary_compact,
rb_ary_shuffle): add iteration check.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-12-29 14:25:11 -05:00
|
|
|
|
|
|
|
static VALUE
|
|
|
|
collect_i(VALUE ary)
|
|
|
|
{
|
|
|
|
long i;
|
|
|
|
VALUE collect;
|
|
|
|
|
|
|
|
collect = rb_ary_new2(RARRAY_LEN(ary));
|
|
|
|
for (i = 0; i < RARRAY_LEN(ary); i++) {
|
|
|
|
rb_ary_push(collect, rb_yield(RARRAY_PTR(ary)[i]));
|
|
|
|
}
|
|
|
|
return collect;
|
|
|
|
}
|
|
|
|
|
2003-12-16 15:28:44 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
2004-07-13 11:34:34 -04:00
|
|
|
* array.collect {|item| block } -> an_array
|
|
|
|
* array.map {|item| block } -> an_array
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
|
|
|
* Invokes <i>block</i> once for each element of <i>self</i>. Creates a
|
|
|
|
* new array containing the values returned by the block.
|
2004-02-26 08:50:40 -05:00
|
|
|
* See also <code>Enumerable#collect</code>.
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
|
|
|
* a = [ "a", "b", "c", "d" ]
|
|
|
|
* a.collect {|x| x + "!" } #=> ["a!", "b!", "c!", "d!"]
|
|
|
|
* a #=> ["a", "b", "c", "d"]
|
|
|
|
*/
|
|
|
|
|
1999-10-29 05:25:48 -04:00
|
|
|
static VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_collect(VALUE ary)
|
* array.c (ary_iter_check): should check modification (size
change) during iteration.
* array.c (rb_ary_initialize, rb_ary_shift, rb_ary_unshift,
rb_ary_splice, rb_ary_reverse, rb_ary_sort, rb_ary_delete,
rb_ary_delete_at, rb_ary_reject_bang, rb_ary_replace,
rb_ary_clear, rb_ary_fill, rb_ary_uniq_bang, rb_ary_compact,
rb_ary_shuffle): add iteration check.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-12-29 14:25:11 -05:00
|
|
|
{
|
|
|
|
RETURN_ENUMERATOR(ary, 0, 0);
|
|
|
|
ITERATE(collect_i, ary);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static VALUE
|
|
|
|
collect_bang_i(VALUE ary)
|
1999-10-29 05:25:48 -04:00
|
|
|
{
|
2003-07-31 02:30:35 -04:00
|
|
|
long i;
|
1999-10-29 05:25:48 -04:00
|
|
|
|
* array.c (ary_iter_check): should check modification (size
change) during iteration.
* array.c (rb_ary_initialize, rb_ary_shift, rb_ary_unshift,
rb_ary_splice, rb_ary_reverse, rb_ary_sort, rb_ary_delete,
rb_ary_delete_at, rb_ary_reject_bang, rb_ary_replace,
rb_ary_clear, rb_ary_fill, rb_ary_uniq_bang, rb_ary_compact,
rb_ary_shuffle): add iteration check.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-12-29 14:25:11 -05:00
|
|
|
rb_ary_modify(ary);
|
2006-09-02 10:42:08 -04:00
|
|
|
for (i = 0; i < RARRAY_LEN(ary); i++) {
|
* array.c (ary_iter_check): should check modification (size
change) during iteration.
* array.c (rb_ary_initialize, rb_ary_shift, rb_ary_unshift,
rb_ary_splice, rb_ary_reverse, rb_ary_sort, rb_ary_delete,
rb_ary_delete_at, rb_ary_reject_bang, rb_ary_replace,
rb_ary_clear, rb_ary_fill, rb_ary_uniq_bang, rb_ary_compact,
rb_ary_shuffle): add iteration check.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-12-29 14:25:11 -05:00
|
|
|
RARRAY_PTR(ary)[i] = rb_yield(RARRAY_PTR(ary)[i]);
|
1999-10-29 05:25:48 -04:00
|
|
|
}
|
* array.c (ary_iter_check): should check modification (size
change) during iteration.
* array.c (rb_ary_initialize, rb_ary_shift, rb_ary_unshift,
rb_ary_splice, rb_ary_reverse, rb_ary_sort, rb_ary_delete,
rb_ary_delete_at, rb_ary_reject_bang, rb_ary_replace,
rb_ary_clear, rb_ary_fill, rb_ary_uniq_bang, rb_ary_compact,
rb_ary_shuffle): add iteration check.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-12-29 14:25:11 -05:00
|
|
|
return ary;
|
1999-10-29 05:25:48 -04:00
|
|
|
}
|
|
|
|
|
2003-12-16 15:28:44 -05:00
|
|
|
/*
|
2004-07-13 12:21:23 -04:00
|
|
|
* call-seq:
|
|
|
|
* array.collect! {|item| block } -> array
|
|
|
|
* array.map! {|item| block } -> array
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
2004-07-13 12:21:23 -04:00
|
|
|
* Invokes the block once for each element of _self_, replacing the
|
|
|
|
* element with the value returned by _block_.
|
|
|
|
* See also <code>Enumerable#collect</code>.
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
|
|
|
* a = [ "a", "b", "c", "d" ]
|
|
|
|
* a.collect! {|x| x + "!" }
|
|
|
|
* a #=> [ "a!", "b!", "c!", "d!" ]
|
|
|
|
*/
|
|
|
|
|
2000-05-01 05:42:38 -04:00
|
|
|
static VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_collect_bang(VALUE ary)
|
2000-05-01 05:42:38 -04:00
|
|
|
{
|
2005-08-30 10:49:51 -04:00
|
|
|
RETURN_ENUMERATOR(ary, 0, 0);
|
* array.c (ary_iter_check): should check modification (size
change) during iteration.
* array.c (rb_ary_initialize, rb_ary_shift, rb_ary_unshift,
rb_ary_splice, rb_ary_reverse, rb_ary_sort, rb_ary_delete,
rb_ary_delete_at, rb_ary_reject_bang, rb_ary_replace,
rb_ary_clear, rb_ary_fill, rb_ary_uniq_bang, rb_ary_compact,
rb_ary_shuffle): add iteration check.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-12-29 14:25:11 -05:00
|
|
|
ITERATE(collect_bang_i, ary);
|
2000-05-01 05:42:38 -04:00
|
|
|
}
|
|
|
|
|
2003-07-03 07:02:53 -04:00
|
|
|
VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_get_values_at(VALUE obj, long olen, int argc, VALUE *argv, VALUE (*func) (VALUE, long))
|
2003-06-02 00:49:46 -04:00
|
|
|
{
|
2003-07-03 07:02:53 -04:00
|
|
|
VALUE result = rb_ary_new2(argc);
|
|
|
|
long beg, len, i, j;
|
2003-06-02 00:49:46 -04:00
|
|
|
|
2003-07-03 07:02:53 -04:00
|
|
|
for (i=0; i<argc; i++) {
|
|
|
|
if (FIXNUM_P(argv[i])) {
|
|
|
|
rb_ary_push(result, (*func)(obj, FIX2LONG(argv[i])));
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
/* check if idx is Range */
|
|
|
|
switch (rb_range_beg_len(argv[i], &beg, &len, olen, 0)) {
|
|
|
|
case Qfalse:
|
|
|
|
break;
|
|
|
|
case Qnil:
|
|
|
|
continue;
|
|
|
|
default:
|
|
|
|
for (j=0; j<len; j++) {
|
|
|
|
rb_ary_push(result, (*func)(obj, j+beg));
|
|
|
|
}
|
|
|
|
continue;
|
2003-06-02 00:49:46 -04:00
|
|
|
}
|
2003-07-03 07:02:53 -04:00
|
|
|
rb_ary_push(result, (*func)(obj, NUM2LONG(argv[i])));
|
2003-06-02 00:49:46 -04:00
|
|
|
}
|
2003-07-03 07:02:53 -04:00
|
|
|
return result;
|
2003-06-02 00:49:46 -04:00
|
|
|
}
|
|
|
|
|
2003-12-16 15:28:44 -05:00
|
|
|
/*
|
2004-07-13 12:21:23 -04:00
|
|
|
* call-seq:
|
|
|
|
* array.values_at(selector,... ) -> an_array
|
2004-07-09 09:38:34 -04:00
|
|
|
*
|
2004-07-13 12:21:23 -04:00
|
|
|
* Returns an array containing the elements in
|
|
|
|
* _self_ corresponding to the given selector(s). The selectors
|
|
|
|
* may be either integer indices or ranges.
|
|
|
|
* See also <code>Array#select</code>.
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
2004-07-13 12:21:23 -04:00
|
|
|
* a = %w{ a b c d e f }
|
|
|
|
* a.values_at(1, 3, 5)
|
|
|
|
* a.values_at(1, 3, 5, 7)
|
|
|
|
* a.values_at(-1, -3, -5, -7)
|
|
|
|
* a.values_at(1..3, 2...5)
|
2003-12-16 15:28:44 -05:00
|
|
|
*/
|
|
|
|
|
2003-05-04 12:03:24 -04:00
|
|
|
static VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_values_at(int argc, VALUE *argv, VALUE ary)
|
2003-05-04 12:03:24 -04:00
|
|
|
{
|
2006-09-02 10:42:08 -04:00
|
|
|
return rb_get_values_at(ary, RARRAY_LEN(ary), argc, argv, rb_ary_entry);
|
2003-05-04 12:03:24 -04:00
|
|
|
}
|
|
|
|
|
* array.c (ary_iter_check): should check modification (size
change) during iteration.
* array.c (rb_ary_initialize, rb_ary_shift, rb_ary_unshift,
rb_ary_splice, rb_ary_reverse, rb_ary_sort, rb_ary_delete,
rb_ary_delete_at, rb_ary_reject_bang, rb_ary_replace,
rb_ary_clear, rb_ary_fill, rb_ary_uniq_bang, rb_ary_compact,
rb_ary_shuffle): add iteration check.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-12-29 14:25:11 -05:00
|
|
|
|
|
|
|
static VALUE
|
|
|
|
select_i(VALUE ary)
|
|
|
|
{
|
|
|
|
VALUE result;
|
|
|
|
long i;
|
|
|
|
|
|
|
|
result = rb_ary_new2(RARRAY_LEN(ary));
|
|
|
|
for (i = 0; i < RARRAY_LEN(ary); i++) {
|
|
|
|
if (RTEST(rb_yield(RARRAY_PTR(ary)[i]))) {
|
|
|
|
rb_ary_push(result, rb_ary_elt(ary, i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2003-12-16 15:28:44 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
2004-07-13 11:34:34 -04:00
|
|
|
* array.select {|item| block } -> an_array
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
2004-07-13 11:34:34 -04:00
|
|
|
* Invokes the block passing in successive elements from <i>array</i>,
|
2003-12-16 15:28:44 -05:00
|
|
|
* returning an array containing those elements for which the block
|
|
|
|
* returns a true value (equivalent to <code>Enumerable#select</code>).
|
|
|
|
*
|
|
|
|
* a = %w{ a b c d e f }
|
|
|
|
* a.select {|v| v =~ /[aeiou]/} #=> ["a", "e"]
|
|
|
|
*/
|
|
|
|
|
2001-12-10 22:48:08 -05:00
|
|
|
static VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_select(VALUE ary)
|
2001-12-10 22:48:08 -05:00
|
|
|
{
|
2005-08-30 10:49:51 -04:00
|
|
|
RETURN_ENUMERATOR(ary, 0, 0);
|
* array.c (ary_iter_check): should check modification (size
change) during iteration.
* array.c (rb_ary_initialize, rb_ary_shift, rb_ary_unshift,
rb_ary_splice, rb_ary_reverse, rb_ary_sort, rb_ary_delete,
rb_ary_delete_at, rb_ary_reject_bang, rb_ary_replace,
rb_ary_clear, rb_ary_fill, rb_ary_uniq_bang, rb_ary_compact,
rb_ary_shuffle): add iteration check.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-12-29 14:25:11 -05:00
|
|
|
ITERATE(select_i, ary);
|
2001-12-10 22:48:08 -05:00
|
|
|
}
|
|
|
|
|
2003-12-16 15:28:44 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
2004-07-13 11:34:34 -04:00
|
|
|
* array.delete(obj) -> obj or nil
|
|
|
|
* array.delete(obj) { block } -> obj or nil
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
|
|
|
* Deletes items from <i>self</i> that are equal to <i>obj</i>. If
|
|
|
|
* the item is not found, returns <code>nil</code>. If the optional
|
|
|
|
* code block is given, returns the result of <i>block</i> if the item
|
|
|
|
* is not found.
|
|
|
|
*
|
|
|
|
* a = [ "a", "b", "b", "b", "c" ]
|
|
|
|
* a.delete("b") #=> "b"
|
|
|
|
* a #=> ["a", "c"]
|
|
|
|
* a.delete("z") #=> nil
|
|
|
|
* a.delete("z") { "not found" } #=> "not found"
|
|
|
|
*/
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_delete(VALUE ary, VALUE item)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
1999-08-13 01:45:20 -04:00
|
|
|
long i1, i2;
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2006-09-02 10:42:08 -04:00
|
|
|
for (i1 = i2 = 0; i1 < RARRAY_LEN(ary); i1++) {
|
|
|
|
VALUE e = RARRAY_PTR(ary)[i1];
|
2004-09-20 23:08:33 -04:00
|
|
|
|
|
|
|
if (rb_equal(e, item)) continue;
|
1998-01-16 07:13:05 -05:00
|
|
|
if (i1 != i2) {
|
2004-09-29 01:15:33 -04:00
|
|
|
rb_ary_store(ary, i2, e);
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
i2++;
|
|
|
|
}
|
2006-09-02 10:42:08 -04:00
|
|
|
if (RARRAY_LEN(ary) == i2) {
|
2000-05-24 00:34:26 -04:00
|
|
|
if (rb_block_given_p()) {
|
1999-01-19 23:59:39 -05:00
|
|
|
return rb_yield(item);
|
|
|
|
}
|
1998-01-16 07:13:05 -05:00
|
|
|
return Qnil;
|
|
|
|
}
|
2002-05-21 01:39:19 -04:00
|
|
|
|
2004-11-17 22:45:23 -05:00
|
|
|
rb_ary_modify(ary);
|
* array.c (ary_iter_check): should check modification (size
change) during iteration.
* array.c (rb_ary_initialize, rb_ary_shift, rb_ary_unshift,
rb_ary_splice, rb_ary_reverse, rb_ary_sort, rb_ary_delete,
rb_ary_delete_at, rb_ary_reject_bang, rb_ary_replace,
rb_ary_clear, rb_ary_fill, rb_ary_uniq_bang, rb_ary_compact,
rb_ary_shuffle): add iteration check.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-12-29 14:25:11 -05:00
|
|
|
ary_iter_check(ary);
|
2006-09-02 10:42:08 -04:00
|
|
|
if (RARRAY_LEN(ary) > i2) {
|
2006-11-01 09:42:39 -05:00
|
|
|
RARRAY(ary)->len = i2;
|
2006-09-02 10:42:08 -04:00
|
|
|
if (i2 * 2 < ARY_CAPA(ary) &&
|
|
|
|
ARY_CAPA(ary) > ARY_DEFAULT_SIZE) {
|
|
|
|
RESIZE_CAPA(ary, i2*2);
|
2004-09-29 01:15:33 -04:00
|
|
|
}
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
|
|
|
VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_delete_at(VALUE ary, long pos)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
2006-09-02 10:42:08 -04:00
|
|
|
long i, len = RARRAY_LEN(ary);
|
2002-05-21 01:39:19 -04:00
|
|
|
VALUE del;
|
1998-01-16 07:13:05 -05:00
|
|
|
|
1999-10-13 02:44:42 -04:00
|
|
|
if (pos >= len) return Qnil;
|
2002-05-21 01:39:19 -04:00
|
|
|
if (pos < 0) {
|
|
|
|
pos += len;
|
|
|
|
if (pos < 0) return Qnil;
|
|
|
|
}
|
1999-10-13 02:44:42 -04:00
|
|
|
|
2004-11-17 22:45:23 -05:00
|
|
|
rb_ary_modify(ary);
|
* array.c (ary_iter_check): should check modification (size
change) during iteration.
* array.c (rb_ary_initialize, rb_ary_shift, rb_ary_unshift,
rb_ary_splice, rb_ary_reverse, rb_ary_sort, rb_ary_delete,
rb_ary_delete_at, rb_ary_reject_bang, rb_ary_replace,
rb_ary_clear, rb_ary_fill, rb_ary_uniq_bang, rb_ary_compact,
rb_ary_shuffle): add iteration check.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-12-29 14:25:11 -05:00
|
|
|
ary_iter_check(ary);
|
2006-09-02 10:42:08 -04:00
|
|
|
del = RARRAY_PTR(ary)[pos];
|
2006-10-16 10:35:51 -04:00
|
|
|
MEMMOVE(RARRAY_PTR(ary)+pos, RARRAY_PTR(ary)+pos+1, VALUE,
|
|
|
|
RARRAY_LEN(ary)-pos-1);
|
2006-11-01 09:42:39 -05:00
|
|
|
RARRAY(ary)->len--;
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
return del;
|
|
|
|
}
|
|
|
|
|
2003-12-16 15:28:44 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* array.delete_at(index) -> obj or nil
|
|
|
|
*
|
|
|
|
* Deletes the element at the specified index, returning that element,
|
|
|
|
* or <code>nil</code> if the index is out of range. See also
|
|
|
|
* <code>Array#slice!</code>.
|
|
|
|
*
|
|
|
|
* a = %w( ant bat cat dog )
|
|
|
|
* a.delete_at(2) #=> "cat"
|
|
|
|
* a #=> ["ant", "bat", "dog"]
|
|
|
|
* a.delete_at(99) #=> nil
|
|
|
|
*/
|
|
|
|
|
2001-03-13 00:45:13 -05:00
|
|
|
static VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_delete_at_m(VALUE ary, VALUE pos)
|
2000-05-30 00:24:17 -04:00
|
|
|
{
|
|
|
|
return rb_ary_delete_at(ary, NUM2LONG(pos));
|
|
|
|
}
|
|
|
|
|
2003-12-16 15:28:44 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
2004-07-13 11:34:34 -04:00
|
|
|
* array.slice!(index) -> obj or nil
|
|
|
|
* array.slice!(start, length) -> sub_array or nil
|
|
|
|
* array.slice!(range) -> sub_array or nil
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
|
|
|
* Deletes the element(s) given by an index (optionally with a length)
|
|
|
|
* or by a range. Returns the deleted object, subarray, or
|
|
|
|
* <code>nil</code> if the index is out of range. Equivalent to:
|
|
|
|
*
|
|
|
|
* def slice!(*args)
|
|
|
|
* result = self[*args]
|
|
|
|
* self[*args] = nil
|
|
|
|
* result
|
|
|
|
* end
|
|
|
|
*
|
|
|
|
* a = [ "a", "b", "c" ]
|
|
|
|
* a.slice!(1) #=> "b"
|
|
|
|
* a #=> ["a", "c"]
|
|
|
|
* a.slice!(-1) #=> "c"
|
|
|
|
* a #=> ["a"]
|
|
|
|
* a.slice!(100) #=> nil
|
|
|
|
* a #=> ["a"]
|
|
|
|
*/
|
|
|
|
|
2000-01-04 23:41:21 -05:00
|
|
|
static VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_slice_bang(int argc, VALUE *argv, VALUE ary)
|
2000-01-04 23:41:21 -05:00
|
|
|
{
|
|
|
|
VALUE arg1, arg2;
|
2002-05-21 01:39:19 -04:00
|
|
|
long pos, len;
|
2000-01-04 23:41:21 -05:00
|
|
|
|
|
|
|
if (rb_scan_args(argc, argv, "11", &arg1, &arg2) == 2) {
|
|
|
|
pos = NUM2LONG(arg1);
|
|
|
|
len = NUM2LONG(arg2);
|
2002-05-22 01:57:08 -04:00
|
|
|
delete_pos_len:
|
2000-01-04 23:41:21 -05:00
|
|
|
if (pos < 0) {
|
2006-09-02 10:42:08 -04:00
|
|
|
pos = RARRAY_LEN(ary) + pos;
|
2000-01-04 23:41:21 -05:00
|
|
|
}
|
2000-01-31 22:12:21 -05:00
|
|
|
arg2 = rb_ary_subseq(ary, pos, len);
|
2004-11-17 22:45:23 -05:00
|
|
|
rb_ary_splice(ary, pos, len, Qundef); /* Qnil/rb_ary_new2(0) */
|
2000-01-04 23:41:21 -05:00
|
|
|
return arg2;
|
|
|
|
}
|
|
|
|
|
2006-09-02 10:42:08 -04:00
|
|
|
if (!FIXNUM_P(arg1) && rb_range_beg_len(arg1, &pos, &len, RARRAY_LEN(ary), 1)) {
|
2000-01-04 23:41:21 -05:00
|
|
|
goto delete_pos_len;
|
|
|
|
}
|
|
|
|
|
2002-05-22 01:57:08 -04:00
|
|
|
return rb_ary_delete_at(ary, NUM2LONG(arg1));
|
2000-01-04 23:41:21 -05:00
|
|
|
}
|
2000-01-31 22:12:21 -05:00
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
static VALUE
|
* array.c (ary_iter_check): should check modification (size
change) during iteration.
* array.c (rb_ary_initialize, rb_ary_shift, rb_ary_unshift,
rb_ary_splice, rb_ary_reverse, rb_ary_sort, rb_ary_delete,
rb_ary_delete_at, rb_ary_reject_bang, rb_ary_replace,
rb_ary_clear, rb_ary_fill, rb_ary_uniq_bang, rb_ary_compact,
rb_ary_shuffle): add iteration check.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-12-29 14:25:11 -05:00
|
|
|
reject_bang_i(VALUE ary)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
1999-08-13 01:45:20 -04:00
|
|
|
long i1, i2;
|
1998-01-16 07:13:05 -05:00
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
rb_ary_modify(ary);
|
2006-09-02 10:42:08 -04:00
|
|
|
for (i1 = i2 = 0; i1 < RARRAY_LEN(ary); i1++) {
|
|
|
|
VALUE v = RARRAY_PTR(ary)[i1];
|
2004-09-21 20:19:15 -04:00
|
|
|
if (RTEST(rb_yield(v))) continue;
|
1998-01-16 07:13:05 -05:00
|
|
|
if (i1 != i2) {
|
2004-09-21 20:19:15 -04:00
|
|
|
rb_ary_store(ary, i2, v);
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
i2++;
|
|
|
|
}
|
2006-12-31 10:02:22 -05:00
|
|
|
|
2006-09-02 10:42:08 -04:00
|
|
|
if (RARRAY_LEN(ary) == i2) return Qnil;
|
|
|
|
if (i2 < RARRAY_LEN(ary))
|
2006-11-01 09:42:39 -05:00
|
|
|
RARRAY(ary)->len = i2;
|
1998-01-16 07:19:22 -05:00
|
|
|
return ary;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
* array.c (ary_iter_check): should check modification (size
change) during iteration.
* array.c (rb_ary_initialize, rb_ary_shift, rb_ary_unshift,
rb_ary_splice, rb_ary_reverse, rb_ary_sort, rb_ary_delete,
rb_ary_delete_at, rb_ary_reject_bang, rb_ary_replace,
rb_ary_clear, rb_ary_fill, rb_ary_uniq_bang, rb_ary_compact,
rb_ary_shuffle): add iteration check.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-12-29 14:25:11 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* array.reject! {|item| block } -> array or nil
|
|
|
|
*
|
|
|
|
* Equivalent to <code>Array#delete_if</code>, deleting elements from
|
|
|
|
* _self_ for which the block evaluates to true, but returns
|
|
|
|
* <code>nil</code> if no changes were made. Also see
|
|
|
|
* <code>Enumerable#reject</code>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static VALUE
|
|
|
|
rb_ary_reject_bang(VALUE ary)
|
|
|
|
{
|
|
|
|
RETURN_ENUMERATOR(ary, 0, 0);
|
|
|
|
ary_iter_check(ary);
|
|
|
|
ITERATE(reject_bang_i, ary);
|
|
|
|
}
|
|
|
|
|
2003-12-16 15:28:44 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
2004-07-13 11:34:34 -04:00
|
|
|
* array.reject {|item| block } -> an_array
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
|
|
|
* Returns a new array containing the items in _self_
|
|
|
|
* for which the block is not true.
|
|
|
|
*/
|
|
|
|
|
2001-10-15 23:27:23 -04:00
|
|
|
static VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_reject(VALUE ary)
|
2001-10-15 23:27:23 -04:00
|
|
|
{
|
2005-08-30 10:49:51 -04:00
|
|
|
RETURN_ENUMERATOR(ary, 0, 0);
|
2006-12-31 02:24:56 -05:00
|
|
|
ary = rb_ary_dup(ary);
|
|
|
|
rb_ary_reject_bang(ary);
|
|
|
|
return ary;
|
2001-10-15 23:27:23 -04:00
|
|
|
}
|
|
|
|
|
2003-12-16 15:28:44 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* array.delete_if {|item| block } -> array
|
|
|
|
*
|
|
|
|
* Deletes every element of <i>self</i> for which <i>block</i> evaluates
|
|
|
|
* to <code>true</code>.
|
|
|
|
*
|
|
|
|
* a = [ "a", "b", "c" ]
|
|
|
|
* a.delete_if {|x| x >= "b" } #=> ["a"]
|
|
|
|
*/
|
|
|
|
|
2000-08-07 01:05:04 -04:00
|
|
|
static VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_delete_if(VALUE ary)
|
2000-08-07 01:05:04 -04:00
|
|
|
{
|
|
|
|
rb_ary_reject_bang(ary);
|
|
|
|
return ary;
|
|
|
|
}
|
|
|
|
|
2003-12-16 15:28:44 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* array.zip(arg, ...) -> an_array
|
|
|
|
* array.zip(arg, ...) {| arr | block } -> nil
|
|
|
|
*
|
|
|
|
* Converts any arguments to arrays, then merges elements of
|
|
|
|
* <i>self</i> with corresponding elements from each argument. This
|
2004-07-13 11:34:34 -04:00
|
|
|
* generates a sequence of <code>self.size</code> <em>n</em>-element
|
2003-12-16 15:28:44 -05:00
|
|
|
* arrays, where <em>n</em> is one more that the count of arguments. If
|
2004-07-13 11:34:34 -04:00
|
|
|
* the size of any argument is less than <code>enumObj.size</code>,
|
2003-12-16 15:28:44 -05:00
|
|
|
* <code>nil</code> values are supplied. If a block given, it is
|
|
|
|
* invoked for each output array, otherwise an array of arrays is
|
|
|
|
* returned.
|
|
|
|
*
|
|
|
|
* a = [ 4, 5, 6 ]
|
|
|
|
* b = [ 7, 8, 9 ]
|
|
|
|
*
|
|
|
|
* [1,2,3].zip(a, b) #=> [[1, 4, 7], [2, 5, 8], [3, 6, 9]]
|
|
|
|
* [1,2].zip(a,b) #=> [[1, 4, 7], [2, 5, 8]]
|
|
|
|
* a.zip([1,2],[8]) #=> [[4,1,8], [5,2,nil], [6,nil,nil]]
|
|
|
|
*/
|
|
|
|
|
2002-11-03 06:04:35 -05:00
|
|
|
static VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_zip(int argc, VALUE *argv, VALUE ary)
|
2002-11-03 06:04:35 -05:00
|
|
|
{
|
2002-11-19 03:07:51 -05:00
|
|
|
int i, j;
|
|
|
|
long len;
|
2002-11-03 06:04:35 -05:00
|
|
|
VALUE result;
|
|
|
|
|
* array.c (ary_iter_check): should check modification (size
change) during iteration.
* array.c (rb_ary_initialize, rb_ary_shift, rb_ary_unshift,
rb_ary_splice, rb_ary_reverse, rb_ary_sort, rb_ary_delete,
rb_ary_delete_at, rb_ary_reject_bang, rb_ary_replace,
rb_ary_clear, rb_ary_fill, rb_ary_uniq_bang, rb_ary_compact,
rb_ary_shuffle): add iteration check.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-12-29 14:25:11 -05:00
|
|
|
RETURN_ENUMERATOR(ary, argc, argv);
|
2002-11-03 06:04:35 -05:00
|
|
|
for (i=0; i<argc; i++) {
|
2004-03-20 11:45:41 -05:00
|
|
|
argv[i] = to_a(argv[i]);
|
2002-11-19 03:07:51 -05:00
|
|
|
}
|
|
|
|
if (rb_block_given_p()) {
|
2006-09-02 10:42:08 -04:00
|
|
|
for (i=0; i<RARRAY_LEN(ary); i++) {
|
2002-11-19 03:07:51 -05:00
|
|
|
VALUE tmp = rb_ary_new2(argc+1);
|
|
|
|
|
2004-09-20 23:08:33 -04:00
|
|
|
rb_ary_push(tmp, rb_ary_elt(ary, i));
|
2002-11-19 03:07:51 -05:00
|
|
|
for (j=0; j<argc; j++) {
|
2004-09-20 23:08:33 -04:00
|
|
|
rb_ary_push(tmp, rb_ary_elt(argv[j], i));
|
2002-11-19 03:07:51 -05:00
|
|
|
}
|
|
|
|
rb_yield(tmp);
|
|
|
|
}
|
|
|
|
return Qnil;
|
2002-11-03 06:04:35 -05:00
|
|
|
}
|
2006-09-02 10:42:08 -04:00
|
|
|
len = RARRAY_LEN(ary);
|
2002-11-03 06:04:35 -05:00
|
|
|
result = rb_ary_new2(len);
|
|
|
|
for (i=0; i<len; i++) {
|
|
|
|
VALUE tmp = rb_ary_new2(argc+1);
|
|
|
|
|
2004-09-20 23:08:33 -04:00
|
|
|
rb_ary_push(tmp, rb_ary_elt(ary, i));
|
2002-11-03 06:04:35 -05:00
|
|
|
for (j=0; j<argc; j++) {
|
2004-09-20 23:08:33 -04:00
|
|
|
rb_ary_push(tmp, rb_ary_elt(argv[j], i));
|
2002-11-03 06:04:35 -05:00
|
|
|
}
|
|
|
|
rb_ary_push(result, tmp);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2003-12-16 15:28:44 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* array.transpose -> an_array
|
|
|
|
*
|
|
|
|
* Assumes that <i>self</i> is an array of arrays and transposes the
|
|
|
|
* rows and columns.
|
|
|
|
*
|
|
|
|
* a = [[1,2], [3,4], [5,6]]
|
|
|
|
* a.transpose #=> [[1, 3, 5], [2, 4, 6]]
|
|
|
|
*/
|
|
|
|
|
2002-11-19 03:07:51 -05:00
|
|
|
static VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_transpose(VALUE ary)
|
2002-11-19 03:07:51 -05:00
|
|
|
{
|
|
|
|
long elen = -1, alen, i, j;
|
2003-07-24 14:33:50 -04:00
|
|
|
VALUE tmp, result = 0;
|
2002-11-19 03:07:51 -05:00
|
|
|
|
2006-09-02 10:42:08 -04:00
|
|
|
alen = RARRAY_LEN(ary);
|
2002-11-19 03:07:51 -05:00
|
|
|
if (alen == 0) return rb_ary_dup(ary);
|
|
|
|
for (i=0; i<alen; i++) {
|
2004-09-20 23:08:33 -04:00
|
|
|
tmp = to_ary(rb_ary_elt(ary, i));
|
2002-11-19 03:07:51 -05:00
|
|
|
if (elen < 0) { /* first element */
|
2006-09-02 10:42:08 -04:00
|
|
|
elen = RARRAY_LEN(tmp);
|
2002-11-19 03:07:51 -05:00
|
|
|
result = rb_ary_new2(elen);
|
|
|
|
for (j=0; j<elen; j++) {
|
|
|
|
rb_ary_store(result, j, rb_ary_new2(alen));
|
|
|
|
}
|
|
|
|
}
|
2006-09-02 10:42:08 -04:00
|
|
|
else if (elen != RARRAY_LEN(tmp)) {
|
2005-09-23 20:17:43 -04:00
|
|
|
rb_raise(rb_eIndexError, "element size differs (%ld should be %ld)",
|
2006-09-02 10:42:08 -04:00
|
|
|
RARRAY_LEN(tmp), elen);
|
2002-11-19 03:07:51 -05:00
|
|
|
}
|
|
|
|
for (j=0; j<elen; j++) {
|
2004-09-20 23:08:33 -04:00
|
|
|
rb_ary_store(rb_ary_elt(result, j), i, rb_ary_elt(tmp, j));
|
2002-11-19 03:07:51 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2003-12-16 15:28:44 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
2004-07-13 11:34:34 -04:00
|
|
|
* array.replace(other_array) -> array
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
|
|
|
* Replaces the contents of <i>self</i> with the contents of
|
|
|
|
* <i>other_array</i>, truncating or expanding if necessary.
|
|
|
|
*
|
|
|
|
* a = [ "a", "b", "c", "d", "e" ]
|
|
|
|
* a.replace([ "x", "y", "z" ]) #=> ["x", "y", "z"]
|
|
|
|
* a #=> ["x", "y", "z"]
|
|
|
|
*/
|
|
|
|
|
2006-12-31 10:02:22 -05:00
|
|
|
VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_replace(VALUE copy, VALUE orig)
|
1999-01-19 23:59:39 -05:00
|
|
|
{
|
2004-09-24 01:53:43 -04:00
|
|
|
VALUE shared;
|
2006-11-01 09:42:39 -05:00
|
|
|
VALUE *ptr;
|
2004-09-24 01:53:43 -04:00
|
|
|
|
2002-09-03 01:20:14 -04:00
|
|
|
orig = to_ary(orig);
|
2007-01-09 10:11:01 -05:00
|
|
|
rb_ary_modify_check(copy);
|
|
|
|
ary_iter_check(copy);
|
2002-09-03 01:20:14 -04:00
|
|
|
if (copy == orig) return copy;
|
2004-09-24 01:53:43 -04:00
|
|
|
shared = ary_make_shared(orig);
|
2007-01-09 10:11:01 -05:00
|
|
|
if (!ARY_SHARED_P(copy)) {
|
|
|
|
ptr = RARRAY(copy)->ptr;
|
2006-12-31 10:02:22 -05:00
|
|
|
xfree(ptr);
|
2007-01-09 10:11:01 -05:00
|
|
|
}
|
|
|
|
RARRAY(copy)->ptr = RARRAY(orig)->ptr;
|
|
|
|
RARRAY(copy)->len = RARRAY(orig)->len;
|
2006-11-01 09:42:39 -05:00
|
|
|
RARRAY(copy)->aux.shared = shared;
|
2002-09-03 01:20:14 -04:00
|
|
|
FL_SET(copy, ELTS_SHARED);
|
|
|
|
|
|
|
|
return copy;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2003-12-16 15:28:44 -05:00
|
|
|
/*
|
2004-07-13 11:34:34 -04:00
|
|
|
* call-seq:
|
|
|
|
* array.clear -> array
|
|
|
|
*
|
|
|
|
* Removes all elements from _self_.
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
|
|
|
* a = [ "a", "b", "c", "d", "e" ]
|
|
|
|
* a.clear #=> [ ]
|
|
|
|
*/
|
|
|
|
|
2001-03-13 00:45:13 -05:00
|
|
|
VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_clear(VALUE ary)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
1999-10-18 05:03:16 -04:00
|
|
|
rb_ary_modify(ary);
|
* array.c (ary_iter_check): should check modification (size
change) during iteration.
* array.c (rb_ary_initialize, rb_ary_shift, rb_ary_unshift,
rb_ary_splice, rb_ary_reverse, rb_ary_sort, rb_ary_delete,
rb_ary_delete_at, rb_ary_reject_bang, rb_ary_replace,
rb_ary_clear, rb_ary_fill, rb_ary_uniq_bang, rb_ary_compact,
rb_ary_shuffle): add iteration check.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-12-29 14:25:11 -05:00
|
|
|
ary_iter_check(ary);
|
2006-11-01 09:42:39 -05:00
|
|
|
RARRAY(ary)->len = 0;
|
2006-09-02 10:42:08 -04:00
|
|
|
if (ARY_DEFAULT_SIZE * 2 < ARY_CAPA(ary)) {
|
|
|
|
RESIZE_CAPA(ary, ARY_DEFAULT_SIZE * 2);
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
1998-01-16 07:19:22 -05:00
|
|
|
return ary;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2003-12-16 15:28:44 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
2004-07-13 11:34:34 -04:00
|
|
|
* array.fill(obj) -> array
|
|
|
|
* array.fill(obj, start [, length]) -> array
|
|
|
|
* array.fill(obj, range ) -> array
|
|
|
|
* array.fill {|index| block } -> array
|
|
|
|
* array.fill(start [, length] ) {|index| block } -> array
|
|
|
|
* array.fill(range) {|index| block } -> array
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
|
|
|
* The first three forms set the selected elements of <i>self</i> (which
|
|
|
|
* may be the entire array) to <i>obj</i>. A <i>start</i> of
|
|
|
|
* <code>nil</code> is equivalent to zero. A <i>length</i> of
|
2004-07-13 11:34:34 -04:00
|
|
|
* <code>nil</code> is equivalent to <i>self.length</i>. The last three
|
2003-12-16 15:28:44 -05:00
|
|
|
* forms fill the array with the value of the block. The block is
|
|
|
|
* passed the absolute index of each element to be filled.
|
|
|
|
*
|
|
|
|
* a = [ "a", "b", "c", "d" ]
|
|
|
|
* a.fill("x") #=> ["x", "x", "x", "x"]
|
|
|
|
* a.fill("z", 2, 2) #=> ["x", "x", "z", "z"]
|
|
|
|
* a.fill("y", 0..1) #=> ["y", "y", "z", "z"]
|
|
|
|
* a.fill {|i| i*i} #=> [0, 1, 4, 9]
|
|
|
|
* a.fill(-2) {|i| i*i*i} #=> [0, 1, 8, 27]
|
|
|
|
*/
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
static VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_fill(int argc, VALUE *argv, VALUE ary)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
|
|
|
VALUE item, arg1, arg2;
|
* sprintf.c (rb_str_format): allow %c to print one character
string (e.g. ?x).
* lib/tempfile.rb (Tempfile::make_tmpname): put dot between
basename and pid. [ruby-talk:196272]
* parse.y (do_block): remove -> style block.
* parse.y (parser_yylex): remove tLAMBDA_ARG.
* eval.c (rb_call0): binding for the return event hook should have
consistent scope. [ruby-core:07928]
* eval.c (proc_invoke): return behavior should depend whether it
is surrounded by a lambda or a mere block.
* eval.c (formal_assign): handles post splat arguments.
* eval.c (rb_call0): ditto.
* st.c (strhash): use FNV-1a hash.
* parse.y (parser_yylex): removed experimental ';;' terminator.
* eval.c (rb_node_arity): should be aware of post splat arguments.
* eval.c (rb_proc_arity): ditto.
* parse.y (f_args): syntax rule enhanced to support arguments
after the splat.
* parse.y (block_param): ditto for block parameters.
* parse.y (f_post_arg): mandatory formal arguments after the splat
argument.
* parse.y (new_args_gen): generate nodes for mandatory formal
arguments after the splat argument.
* eval.c (rb_eval): dispatch mandatory formal arguments after the
splat argument.
* parse.y (args): allow more than one splat in the argument list.
* parse.y (method_call): allow aref [] to accept all kind of
method argument, including assocs, splat, and block argument.
* eval.c (SETUP_ARGS0): prepare block argument as well.
* lib/mathn.rb (Integer): remove Integer#gcd2. [ruby-core:07931]
* eval.c (error_line): print receivers true/false/nil specially.
* eval.c (rb_proc_yield): handles parameters in yield semantics.
* eval.c (nil_yield): gives LocalJumpError to denote no block
error.
* io.c (rb_io_getc): now takes one-character string.
* string.c (rb_str_hash): use FNV-1a hash from Fowler/Noll/Vo
hashing algorithm.
* string.c (rb_str_aref): str[0] now returns 1 character string,
instead of a fixnum. [Ruby2]
* parse.y (parser_yylex): ?c now returns 1 character string,
instead of a fixnum. [Ruby2]
* string.c (rb_str_aset): no longer support fixnum insertion.
* eval.c (umethod_bind): should not update original class.
[ruby-dev:28636]
* eval.c (ev_const_get): should support constant access from
within instance_eval(). [ruby-dev:28327]
* time.c (time_timeval): should round for usec floating
number. [ruby-core:07896]
* time.c (time_add): ditto.
* dir.c (sys_warning): should not call a vararg function
rb_sys_warning() indirectly. [ruby-core:07886]
* numeric.c (flo_divmod): the first element of Float#divmod should
be an integer. [ruby-dev:28589]
* test/ruby/test_float.rb: add tests for divmod, div, modulo and remainder.
* re.c (rb_reg_initialize): should not allow modifying literal
regexps. frozen check moved from rb_reg_initialize_m as well.
* re.c (rb_reg_initialize): should not modify untainted objects in
safe levels higher than 3.
* re.c (rb_memcmp): type change from char* to const void*.
* dir.c (dir_close): should not close untainted dir stream.
* dir.c (GetDIR): add tainted/frozen check for each dir operation.
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_symbol_arg):
typo fixed. a patch from Florian Gross <florg at florg.net>.
* eval.c (EXEC_EVENT_HOOK): trace_func may remove itself from
event_hooks. no guarantee for arbitrary hook deletion.
[ruby-dev:28632]
* util.c (ruby_strtod): differ addition to minimize error.
[ruby-dev:28619]
* util.c (ruby_strtod): should not raise ERANGE when the input
string does not have any digits. [ruby-dev:28629]
* eval.c (proc_invoke): should restore old ruby_frame->block.
thanks to ts <decoux at moulon.inra.fr>. [ruby-core:07833]
also fix [ruby-dev:28614] as well.
* signal.c (trap): sig should be less then NSIG. Coverity found
this bug. a patch from Kevin Tew <tewk at tewk.com>.
[ruby-core:07823]
* math.c (math_log2): add new method inspired by
[ruby-talk:191237].
* math.c (math_log): add optional base argument to Math::log().
[ruby-talk:191308]
* ext/syck/emitter.c (syck_scan_scalar): avoid accessing
uninitialized array element. a patch from Pat Eyler
<rubypate at gmail.com>. [ruby-core:07809]
* array.c (rb_ary_fill): initialize local variables first. a
patch from Pat Eyler <rubypate at gmail.com>. [ruby-core:07810]
* ext/syck/yaml2byte.c (syck_yaml2byte_handler): need to free
type_tag. a patch from Pat Eyler <rubypate at gmail.com>.
[ruby-core:07808]
* ext/socket/socket.c (make_hostent_internal): accept ai_family
check from Sam Roberts <sroberts at uniserve.com>.
[ruby-core:07691]
* util.c (ruby_strtod): should not cut off 18 digits for no
reason. [ruby-core:07796]
* array.c (rb_ary_fill): internalize local variable "beg" to
pacify Coverity. [ruby-core:07770]
* pack.c (pack_unpack): now supports CRLF newlines. a patch from
<tommy at tmtm.org>. [ruby-dev:28601]
* applied code clean-up patch from Stefan Huehner
<stefan at huehner.org>. [ruby-core:07764]
* lib/jcode.rb (String::tr_s): should have translated non
squeezing character sequence (i.e. a character) as well. thanks
to Hiroshi Ichikawa <gimite at gimite.ddo.jp> [ruby-list:42090]
* ext/socket/socket.c: document update patch from Sam Roberts
<sroberts at uniserve.com>. [ruby-core:07701]
* lib/mathn.rb (Integer): need not to remove gcd2. a patch from
NARUSE, Yui <naruse at airemix.com>. [ruby-dev:28570]
* parse.y (arg): too much NEW_LIST()
* eval.c (SETUP_ARGS0): remove unnecessary access to nd_alen.
* eval.c (rb_eval): use ARGSCAT for NODE_OP_ASGN1.
[ruby-dev:28585]
* parse.y (arg): use NODE_ARGSCAT for placeholder.
* lib/getoptlong.rb (GetoptLong::get): RDoc update patch from
mathew <meta at pobox.com>. [ruby-core:07738]
* variable.c (rb_const_set): raise error when no target klass is
supplied. [ruby-dev:28582]
* prec.c (prec_prec_f): documentation patch from
<gerardo.santana at gmail.com>. [ruby-core:07689]
* bignum.c (rb_big_pow): second operand may be too big even if
it's a Fixnum. [ruby-talk:187984]
* README.EXT: update symbol description. [ruby-talk:188104]
* COPYING: explicitly note GPLv2. [ruby-talk:187922]
* parse.y: remove some obsolete syntax rules (unparenthesized
method calls in argument list).
* eval.c (rb_call0): insecure calling should be checked for non
NODE_SCOPE method invocations too.
* eval.c (rb_alias): should preserve the current safe level as
well as method definition.
* process.c (rb_f_sleep): remove RDoc description about SIGALRM
which is not valid on the current implementation. [ruby-dev:28464]
Thu Mar 23 21:40:47 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
* eval.c (method_missing): should support argument splat in
super. a bug in combination of super, splat and
method_missing. [ruby-talk:185438]
* configure.in: Solaris SunPro compiler -rapth patch from
<kuwa at labs.fujitsu.com>. [ruby-dev:28443]
* configure.in: remove enable_rpath=no for Solaris.
[ruby-dev:28440]
* ext/win32ole/win32ole.c (ole_val2olevariantdata): change behavior
of converting OLE Variant object with VT_ARRAY|VT_UI1 and Ruby
String object.
* ruby.1: a clarification patch from David Lutterkort
<dlutter at redhat.com>. [ruby-core:7508]
* lib/rdoc/ri/ri_paths.rb (RI::Paths): adding paths from rubygems
directories. a patch from Eric Hodel <drbrain at segment7.net>.
[ruby-core:07423]
* eval.c (rb_clear_cache_by_class): clearing wrong cache.
* ext/extmk.rb: use :remove_destination to install extension libraries
to avoid SEGV. [ruby-dev:28417]
* eval.c (rb_thread_fd_writable): should not re-schedule output
from KILLED thread (must be error printing).
* array.c (rb_ary_flatten_bang): allow specifying recursion
level. [ruby-talk:182170]
* array.c (rb_ary_flatten): ditto.
* gc.c (add_heap): a heap_slots may overflow. a patch from Stefan
Weil <weil at mail.berlios.de>.
* eval.c (rb_call): use separate cache for fcall/vcall
invocation.
* eval.c (rb_eval): NODE_FCALL, NODE_VCALL can call local
functions.
* eval.c (rb_mod_local): a new method to specify newly added
visibility "local".
* eval.c (search_method): search for local methods which are
visible only from the current class.
* class.c (rb_class_local_methods): a method to list local methods.
* object.c (Init_Object): add BasicObject class as a top level
BlankSlate class.
* ruby.h (SYM2ID): should not cast to signed long.
[ruby-core:07414]
* class.c (rb_include_module): allow module duplication.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-09 17:20:17 -04:00
|
|
|
long beg = 0, end = 0, len = 0;
|
1998-01-16 07:13:05 -05:00
|
|
|
VALUE *p, *pend;
|
2002-01-28 05:18:14 -05:00
|
|
|
int block_p = Qfalse;
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2002-01-28 03:44:45 -05:00
|
|
|
if (rb_block_given_p()) {
|
|
|
|
block_p = Qtrue;
|
|
|
|
rb_scan_args(argc, argv, "02", &arg1, &arg2);
|
|
|
|
argc += 1; /* hackish */
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rb_scan_args(argc, argv, "12", &item, &arg1, &arg2);
|
|
|
|
}
|
1999-08-13 01:45:20 -04:00
|
|
|
switch (argc) {
|
|
|
|
case 1:
|
|
|
|
beg = 0;
|
2006-09-02 10:42:08 -04:00
|
|
|
len = RARRAY_LEN(ary);
|
1999-08-13 01:45:20 -04:00
|
|
|
break;
|
|
|
|
case 2:
|
2006-09-02 10:42:08 -04:00
|
|
|
if (rb_range_beg_len(arg1, &beg, &len, RARRAY_LEN(ary), 1)) {
|
1999-08-13 01:45:20 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* fall through */
|
|
|
|
case 3:
|
2002-05-21 01:39:19 -04:00
|
|
|
beg = NIL_P(arg1) ? 0 : NUM2LONG(arg1);
|
1998-01-16 07:13:05 -05:00
|
|
|
if (beg < 0) {
|
2006-09-02 10:42:08 -04:00
|
|
|
beg = RARRAY_LEN(ary) + beg;
|
1998-01-16 07:13:05 -05:00
|
|
|
if (beg < 0) beg = 0;
|
|
|
|
}
|
2006-09-02 10:42:08 -04:00
|
|
|
len = NIL_P(arg2) ? RARRAY_LEN(ary) - beg : NUM2LONG(arg2);
|
1999-08-13 01:45:20 -04:00
|
|
|
break;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
1999-01-19 23:59:39 -05:00
|
|
|
rb_ary_modify(ary);
|
* array.c (ary_iter_check): should check modification (size
change) during iteration.
* array.c (rb_ary_initialize, rb_ary_shift, rb_ary_unshift,
rb_ary_splice, rb_ary_reverse, rb_ary_sort, rb_ary_delete,
rb_ary_delete_at, rb_ary_reject_bang, rb_ary_replace,
rb_ary_clear, rb_ary_fill, rb_ary_uniq_bang, rb_ary_compact,
rb_ary_shuffle): add iteration check.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-12-29 14:25:11 -05:00
|
|
|
ary_iter_check(ary);
|
1998-01-16 07:13:05 -05:00
|
|
|
end = beg + len;
|
2006-09-02 10:42:08 -04:00
|
|
|
if (end > RARRAY_LEN(ary)) {
|
|
|
|
if (end >= ARY_CAPA(ary)) {
|
|
|
|
RESIZE_CAPA(ary, end);
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
2006-09-02 10:42:08 -04:00
|
|
|
rb_mem_clear(RARRAY_PTR(ary) + RARRAY_LEN(ary), end - RARRAY_LEN(ary));
|
2006-11-01 09:42:39 -05:00
|
|
|
RARRAY(ary)->len = end;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2002-01-28 03:44:45 -05:00
|
|
|
if (block_p) {
|
2003-07-31 22:52:21 -04:00
|
|
|
VALUE v;
|
|
|
|
long i;
|
|
|
|
|
2004-09-29 01:15:33 -04:00
|
|
|
for (i=beg; i<end; i++) {
|
2003-08-06 17:50:06 -04:00
|
|
|
v = rb_yield(LONG2NUM(i));
|
2006-09-02 10:42:08 -04:00
|
|
|
if (i>=RARRAY_LEN(ary)) break;
|
|
|
|
RARRAY_PTR(ary)[i] = v;
|
2002-01-28 03:44:45 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2006-09-02 10:42:08 -04:00
|
|
|
p = RARRAY_PTR(ary) + beg;
|
2003-07-31 22:52:21 -04:00
|
|
|
pend = p + len;
|
2002-01-28 03:44:45 -05:00
|
|
|
while (p < pend) {
|
|
|
|
*p++ = item;
|
|
|
|
}
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
1998-01-16 07:19:22 -05:00
|
|
|
return ary;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2003-12-16 15:28:44 -05:00
|
|
|
/*
|
2004-07-13 12:21:23 -04:00
|
|
|
* call-seq:
|
|
|
|
* array + other_array -> an_array
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
2004-07-13 12:21:23 -04:00
|
|
|
* Concatenation---Returns a new array built by concatenating the
|
|
|
|
* two arrays together to produce a third array.
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
|
|
|
* [ 1, 2, 3 ] + [ 4, 5 ] #=> [ 1, 2, 3, 4, 5 ]
|
|
|
|
*/
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_plus(VALUE x, VALUE y)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
2005-08-09 21:39:24 -04:00
|
|
|
VALUE z;
|
2002-05-21 01:39:19 -04:00
|
|
|
long len;
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2005-08-09 21:39:24 -04:00
|
|
|
y = to_ary(y);
|
2006-09-02 10:42:08 -04:00
|
|
|
len = RARRAY_LEN(x) + RARRAY_LEN(y);
|
2002-05-21 01:39:19 -04:00
|
|
|
z = rb_ary_new2(len);
|
2006-09-02 10:42:08 -04:00
|
|
|
MEMCPY(RARRAY_PTR(z), RARRAY_PTR(x), VALUE, RARRAY_LEN(x));
|
|
|
|
MEMCPY(RARRAY_PTR(z) + RARRAY_LEN(x), RARRAY_PTR(y), VALUE, RARRAY_LEN(y));
|
2006-11-01 09:42:39 -05:00
|
|
|
RARRAY(z)->len = len;
|
1998-01-16 07:19:22 -05:00
|
|
|
return z;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2003-12-16 15:28:44 -05:00
|
|
|
/*
|
2004-07-13 12:21:23 -04:00
|
|
|
* call-seq:
|
|
|
|
* array.concat(other_array) -> array
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
|
|
|
* Appends the elements in other_array to _self_.
|
|
|
|
*
|
|
|
|
* [ "a", "b" ].concat( ["c", "d"] ) #=> [ "a", "b", "c", "d" ]
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_concat(VALUE x, VALUE y)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
2000-10-10 03:03:36 -04:00
|
|
|
y = to_ary(y);
|
2006-09-02 10:42:08 -04:00
|
|
|
if (RARRAY_LEN(y) > 0) {
|
|
|
|
rb_ary_splice(x, RARRAY_LEN(x), 0, y);
|
2000-10-10 03:03:36 -04:00
|
|
|
}
|
1998-01-16 07:19:22 -05:00
|
|
|
return x;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2003-12-16 15:28:44 -05:00
|
|
|
|
|
|
|
/*
|
2004-07-13 12:21:23 -04:00
|
|
|
* call-seq:
|
2004-07-13 11:34:34 -04:00
|
|
|
* array * int -> an_array
|
|
|
|
* array * str -> a_string
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
2004-07-13 12:21:23 -04:00
|
|
|
* Repetition---With a String argument, equivalent to
|
|
|
|
* self.join(str). Otherwise, returns a new array
|
|
|
|
* built by concatenating the _int_ copies of _self_.
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* [ 1, 2, 3 ] * 3 #=> [ 1, 2, 3, 1, 2, 3, 1, 2, 3 ]
|
2004-07-13 11:34:34 -04:00
|
|
|
* [ 1, 2, 3 ] * "," #=> "1,2,3"
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
static VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_times(VALUE ary, VALUE times)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
2003-01-07 02:36:40 -05:00
|
|
|
VALUE ary2, tmp;
|
1999-08-13 01:45:20 -04:00
|
|
|
long i, len;
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2003-01-07 02:36:40 -05:00
|
|
|
tmp = rb_check_string_type(times);
|
|
|
|
if (!NIL_P(tmp)) {
|
|
|
|
return rb_ary_join(ary, tmp);
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
1999-08-13 01:45:20 -04:00
|
|
|
len = NUM2LONG(times);
|
2004-10-19 15:17:33 -04:00
|
|
|
if (len == 0) return ary_new(rb_obj_class(ary), 0);
|
1998-01-16 07:13:05 -05:00
|
|
|
if (len < 0) {
|
1999-01-19 23:59:39 -05:00
|
|
|
rb_raise(rb_eArgError, "negative argument");
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
2006-09-02 10:42:08 -04:00
|
|
|
if (LONG_MAX/len < RARRAY_LEN(ary)) {
|
2003-04-10 05:48:15 -04:00
|
|
|
rb_raise(rb_eArgError, "argument too big");
|
|
|
|
}
|
2006-09-02 10:42:08 -04:00
|
|
|
len *= RARRAY_LEN(ary);
|
1999-01-19 23:59:39 -05:00
|
|
|
|
2001-12-10 02:18:16 -05:00
|
|
|
ary2 = ary_new(rb_obj_class(ary), len);
|
2006-11-01 09:42:39 -05:00
|
|
|
RARRAY(ary2)->len = len;
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2006-09-02 10:42:08 -04:00
|
|
|
for (i=0; i<len; i+=RARRAY_LEN(ary)) {
|
|
|
|
MEMCPY(RARRAY_PTR(ary2)+i, RARRAY_PTR(ary), VALUE, RARRAY_LEN(ary));
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
2001-10-02 00:31:23 -04:00
|
|
|
OBJ_INFECT(ary2, ary);
|
1998-01-16 07:13:05 -05:00
|
|
|
|
1998-01-16 07:19:22 -05:00
|
|
|
return ary2;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2003-12-16 15:28:44 -05:00
|
|
|
/*
|
2004-07-13 12:21:23 -04:00
|
|
|
* call-seq:
|
2004-07-13 11:34:34 -04:00
|
|
|
* array.assoc(obj) -> an_array or nil
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
2004-07-13 12:21:23 -04:00
|
|
|
* Searches through an array whose elements are also arrays
|
|
|
|
* comparing _obj_ with the first element of each contained array
|
|
|
|
* using obj.==.
|
|
|
|
* Returns the first contained array that matches (that
|
|
|
|
* is, the first associated array),
|
|
|
|
* or +nil+ if no match is found.
|
|
|
|
* See also <code>Array#rassoc</code>.
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
|
|
|
* s1 = [ "colors", "red", "blue", "green" ]
|
|
|
|
* s2 = [ "letters", "a", "b", "c" ]
|
|
|
|
* s3 = "foo"
|
|
|
|
* a = [ s1, s2, s3 ]
|
|
|
|
* a.assoc("letters") #=> [ "letters", "a", "b", "c" ]
|
|
|
|
* a.assoc("foo") #=> nil
|
|
|
|
*/
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_assoc(VALUE ary, VALUE key)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
2004-09-17 05:24:13 -04:00
|
|
|
long i;
|
|
|
|
VALUE v;
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2006-09-02 10:42:08 -04:00
|
|
|
for (i = 0; i < RARRAY_LEN(ary); ++i) {
|
|
|
|
v = RARRAY_PTR(ary)[i];
|
2004-09-17 05:24:13 -04:00
|
|
|
if (TYPE(v) == T_ARRAY &&
|
2006-09-02 10:42:08 -04:00
|
|
|
RARRAY_LEN(v) > 0 &&
|
|
|
|
rb_equal(RARRAY_PTR(v)[0], key))
|
2004-09-17 05:24:13 -04:00
|
|
|
return v;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
return Qnil;
|
|
|
|
}
|
|
|
|
|
2003-12-16 15:28:44 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* array.rassoc(key) -> an_array or nil
|
|
|
|
*
|
|
|
|
* Searches through the array whose elements are also arrays. Compares
|
|
|
|
* <em>key</em> with the second element of each contained array using
|
|
|
|
* <code>==</code>. Returns the first contained array that matches. See
|
|
|
|
* also <code>Array#assoc</code>.
|
|
|
|
*
|
|
|
|
* a = [ [ 1, "one"], [2, "two"], [3, "three"], ["ii", "two"] ]
|
|
|
|
* a.rassoc("two") #=> [2, "two"]
|
|
|
|
* a.rassoc("four") #=> nil
|
|
|
|
*/
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_rassoc(VALUE ary, VALUE value)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
2004-09-17 05:24:13 -04:00
|
|
|
long i;
|
|
|
|
VALUE v;
|
|
|
|
|
2006-09-02 10:42:08 -04:00
|
|
|
for (i = 0; i < RARRAY_LEN(ary); ++i) {
|
|
|
|
v = RARRAY_PTR(ary)[i];
|
2004-09-17 05:24:13 -04:00
|
|
|
if (TYPE(v) == T_ARRAY &&
|
2006-09-02 10:42:08 -04:00
|
|
|
RARRAY_LEN(v) > 1 &&
|
|
|
|
rb_equal(RARRAY_PTR(v)[1], value))
|
2004-09-17 05:24:13 -04:00
|
|
|
return v;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
return Qnil;
|
|
|
|
}
|
|
|
|
|
2003-12-16 15:28:44 -05:00
|
|
|
/*
|
2004-07-13 12:21:23 -04:00
|
|
|
* call-seq:
|
|
|
|
* array == other_array -> bool
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
2004-07-13 12:21:23 -04:00
|
|
|
* Equality---Two arrays are equal if they contain the same number
|
|
|
|
* of elements and if each element is equal to (according to
|
|
|
|
* Object.==) the corresponding element in the other array.
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
|
|
|
* [ "a", "c" ] == [ "a", "c", 7 ] #=> false
|
|
|
|
* [ "a", "c", 7 ] == [ "a", "c", 7 ] #=> true
|
|
|
|
* [ "a", "c", 7 ] == [ "a", "d", "f" ] #=> false
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
static VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_equal(VALUE ary1, VALUE ary2)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
1999-08-13 01:45:20 -04:00
|
|
|
long i;
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2001-08-29 02:28:51 -04:00
|
|
|
if (ary1 == ary2) return Qtrue;
|
2003-02-04 02:27:43 -05:00
|
|
|
if (TYPE(ary2) != T_ARRAY) {
|
2003-02-04 02:40:52 -05:00
|
|
|
if (!rb_respond_to(ary2, rb_intern("to_ary"))) {
|
2003-02-04 02:27:43 -05:00
|
|
|
return Qfalse;
|
|
|
|
}
|
|
|
|
return rb_equal(ary2, ary1);
|
|
|
|
}
|
2006-09-02 10:42:08 -04:00
|
|
|
if (RARRAY_LEN(ary1) != RARRAY_LEN(ary2)) return Qfalse;
|
|
|
|
for (i=0; i<RARRAY_LEN(ary1); i++) {
|
2004-09-20 23:08:33 -04:00
|
|
|
if (!rb_equal(rb_ary_elt(ary1, i), rb_ary_elt(ary2, i)))
|
1999-01-19 23:59:39 -05:00
|
|
|
return Qfalse;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
1999-01-19 23:59:39 -05:00
|
|
|
return Qtrue;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2003-12-28 21:02:08 -05:00
|
|
|
/*
|
2004-07-13 12:21:23 -04:00
|
|
|
* call-seq:
|
|
|
|
* array.eql?(other) -> true or false
|
2003-12-28 21:02:08 -05:00
|
|
|
*
|
2004-07-13 12:21:23 -04:00
|
|
|
* Returns <code>true</code> if _array_ and _other_ are the same object,
|
|
|
|
* or are both arrays with the same content.
|
2003-12-28 21:02:08 -05:00
|
|
|
*/
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
static VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_eql(VALUE ary1, VALUE ary2)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
1999-08-13 01:45:20 -04:00
|
|
|
long i;
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2003-01-07 02:36:40 -05:00
|
|
|
if (ary1 == ary2) return Qtrue;
|
2003-02-03 03:45:26 -05:00
|
|
|
if (TYPE(ary2) != T_ARRAY) return Qfalse;
|
2006-09-02 10:42:08 -04:00
|
|
|
if (RARRAY_LEN(ary1) != RARRAY_LEN(ary2)) return Qfalse;
|
|
|
|
for (i=0; i<RARRAY_LEN(ary1); i++) {
|
2004-09-21 20:19:15 -04:00
|
|
|
if (!rb_eql(rb_ary_elt(ary1, i), rb_ary_elt(ary2, i)))
|
1999-01-19 23:59:39 -05:00
|
|
|
return Qfalse;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
1999-01-19 23:59:39 -05:00
|
|
|
return Qtrue;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
recursive_hash(VALUE ary, VALUE dummy, int recur)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
2002-08-23 03:48:48 -04:00
|
|
|
long i, h;
|
2000-11-20 02:31:55 -05:00
|
|
|
VALUE n;
|
1998-01-16 07:13:05 -05:00
|
|
|
|
* array.c: replace rb_protect_inspect() and rb_inspecting_p() by
rb_exec_recursive() in eval.c.
* eval.c (rb_exec_recursive): new function.
* array.c (rb_ary_join): use rb_exec_recursive().
* array.c (rb_ary_inspect, rb_ary_hash): ditto.
* file.c (rb_file_join): ditto.
* hash.c (rb_hash_inspect, rb_hash_to_s, rb_hash_hash): ditto.
* io.c (rb_io_puts): ditto.
* object.c (rb_obj_inspect): ditto
* struct.c (rb_struct_inspect): ditto.
* lib/set.rb (SortedSet::setup): a hack to shut up warning.
[ruby-talk:132866]
* lib/time.rb (Time::strptime): add new function. inspired by
[ruby-talk:132815].
* lib/parsedate.rb (ParseDate::strptime): ditto.
* regparse.c: move st_*_strend() functions from st.c. fixed some
potential memory leaks.
* exception error messages updated. [ruby-core:04497]
* ext/socket/socket.c (Init_socket): add bunch of Socket
constants. Patch from Sam Roberts <sroberts@uniserve.com>.
[ruby-core:04409]
* array.c (rb_ary_s_create): no need for negative argc check.
[ruby-core:04463]
* array.c (rb_ary_unshift_m): ditto.
* lib/xmlrpc/parser.rb (XMLRPC::FaultException): make it subclass
of StandardError class, not Exception class. [ruby-core:04429]
* parse.y (fcall_gen): lvar(arg) will be evaluated as
lvar.call(arg) when lvar is a defined local variable. [new]
* object.c (rb_class_initialize): call inherited method before
calling initializing block.
* eval.c (rb_thread_start_1): initialize newly pushed frame.
* lib/open3.rb (Open3::popen3): $? should not be EXIT_FAILURE.
fixed: [ruby-core:04444]
* eval.c (is_defined): NODE_IASGN is an assignment.
* ext/readline/readline.c (Readline.readline): use rl_outstream
and rl_instream. [ruby-dev:25699]
* ext/etc/etc.c (Init_etc): sGroup needs HAVE_ST_GR_PASSWD check
[ruby-dev:25675]
* misc/ruby-mode.el: [ruby-core:04415]
* lib/rdoc/generators/html_generator.rb: [ruby-core:04412]
* lib/rdoc/generators/ri_generator.rb: ditto.
* struct.c (make_struct): fixed: [ruby-core:04402]
* ext/curses/curses.c (window_color_set): [ruby-core:04393]
* ext/socket/socket.c (Init_socket): SO_REUSEPORT added.
[ruby-talk:130092]
* object.c: [ruby-doc:818]
* parse.y (open_args): fix too verbose warnings for the space
before argument parentheses. [ruby-dev:25492]
* parse.y (parser_yylex): ditto.
* parse.y (parser_yylex): the first expression in the parentheses
should not be a command. [ruby-dev:25492]
* lib/irb/context.rb (IRB::Context::initialize): [ruby-core:04330]
* object.c (Init_Object): remove Object#type. [ruby-core:04335]
* st.c (st_foreach): report success/failure by return value.
[ruby-Bugs-1396]
* parse.y: forgot to initialize parser struct. [ruby-dev:25492]
* parse.y (parser_yylex): no tLABEL on EXPR_BEG.
[ruby-talk:127711]
* document updates - [ruby-core:04296], [ruby-core:04301],
[ruby-core:04302], [ruby-core:04307]
* dir.c (rb_push_glob): should work for NUL delimited patterns.
* dir.c (rb_glob2): should aware of offset in the pattern.
* string.c (rb_str_new4): should propagate taintedness.
* env.h: rename member names in struct FRAME; last_func -> callee,
orig_func -> this_func, last_class -> this_class.
* struct.c (rb_struct_set): use original method name, not callee
name, to retrieve member slot. [ruby-core:04268]
* time.c (time_strftime): protect from format modification from GC
finalizers.
* object.c (Init_Object): remove rb_obj_id_obsolete()
* eval.c (rb_mod_define_method): incomplete subclass check.
[ruby-dev:25464]
* gc.c (rb_data_object_alloc): klass may be NULL.
[ruby-list:40498]
* bignum.c (rb_big_rand): should return positive random number.
[ruby-dev:25401]
* bignum.c (rb_big_rand): do not use rb_big_modulo to generate
random bignums. [ruby-dev:25396]
* variable.c (rb_autoload): [ruby-dev:25373]
* eval.c (svalue_to_avalue): [ruby-dev:25366]
* string.c (rb_str_justify): [ruby-dev:25367]
* io.c (rb_f_select): [ruby-dev:25312]
* ext/socket/socket.c (sock_s_getservbyport): [ruby-talk:124072]
* struct.c (make_struct): [ruby-dev:25249]
* dir.c (dir_open_dir): new function. [ruby-dev:25242]
* io.c (rb_f_open): add type check for return value from to_open.
* lib/pstore.rb (PStore#transaction): Use the empty content when a
file is not found. [ruby-dev:24561]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-03-04 01:47:45 -05:00
|
|
|
if (recur) {
|
|
|
|
return LONG2FIX(0);
|
|
|
|
}
|
2006-09-02 10:42:08 -04:00
|
|
|
h = RARRAY_LEN(ary);
|
|
|
|
for (i=0; i<RARRAY_LEN(ary); i++) {
|
2002-05-21 01:39:19 -04:00
|
|
|
h = (h << 1) | (h<0 ? 1 : 0);
|
2006-09-02 10:42:08 -04:00
|
|
|
n = rb_hash(RARRAY_PTR(ary)[i]);
|
1999-01-19 23:59:39 -05:00
|
|
|
h ^= NUM2LONG(n);
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
2002-05-21 01:39:19 -04:00
|
|
|
return LONG2FIX(h);
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
* array.c: replace rb_protect_inspect() and rb_inspecting_p() by
rb_exec_recursive() in eval.c.
* eval.c (rb_exec_recursive): new function.
* array.c (rb_ary_join): use rb_exec_recursive().
* array.c (rb_ary_inspect, rb_ary_hash): ditto.
* file.c (rb_file_join): ditto.
* hash.c (rb_hash_inspect, rb_hash_to_s, rb_hash_hash): ditto.
* io.c (rb_io_puts): ditto.
* object.c (rb_obj_inspect): ditto
* struct.c (rb_struct_inspect): ditto.
* lib/set.rb (SortedSet::setup): a hack to shut up warning.
[ruby-talk:132866]
* lib/time.rb (Time::strptime): add new function. inspired by
[ruby-talk:132815].
* lib/parsedate.rb (ParseDate::strptime): ditto.
* regparse.c: move st_*_strend() functions from st.c. fixed some
potential memory leaks.
* exception error messages updated. [ruby-core:04497]
* ext/socket/socket.c (Init_socket): add bunch of Socket
constants. Patch from Sam Roberts <sroberts@uniserve.com>.
[ruby-core:04409]
* array.c (rb_ary_s_create): no need for negative argc check.
[ruby-core:04463]
* array.c (rb_ary_unshift_m): ditto.
* lib/xmlrpc/parser.rb (XMLRPC::FaultException): make it subclass
of StandardError class, not Exception class. [ruby-core:04429]
* parse.y (fcall_gen): lvar(arg) will be evaluated as
lvar.call(arg) when lvar is a defined local variable. [new]
* object.c (rb_class_initialize): call inherited method before
calling initializing block.
* eval.c (rb_thread_start_1): initialize newly pushed frame.
* lib/open3.rb (Open3::popen3): $? should not be EXIT_FAILURE.
fixed: [ruby-core:04444]
* eval.c (is_defined): NODE_IASGN is an assignment.
* ext/readline/readline.c (Readline.readline): use rl_outstream
and rl_instream. [ruby-dev:25699]
* ext/etc/etc.c (Init_etc): sGroup needs HAVE_ST_GR_PASSWD check
[ruby-dev:25675]
* misc/ruby-mode.el: [ruby-core:04415]
* lib/rdoc/generators/html_generator.rb: [ruby-core:04412]
* lib/rdoc/generators/ri_generator.rb: ditto.
* struct.c (make_struct): fixed: [ruby-core:04402]
* ext/curses/curses.c (window_color_set): [ruby-core:04393]
* ext/socket/socket.c (Init_socket): SO_REUSEPORT added.
[ruby-talk:130092]
* object.c: [ruby-doc:818]
* parse.y (open_args): fix too verbose warnings for the space
before argument parentheses. [ruby-dev:25492]
* parse.y (parser_yylex): ditto.
* parse.y (parser_yylex): the first expression in the parentheses
should not be a command. [ruby-dev:25492]
* lib/irb/context.rb (IRB::Context::initialize): [ruby-core:04330]
* object.c (Init_Object): remove Object#type. [ruby-core:04335]
* st.c (st_foreach): report success/failure by return value.
[ruby-Bugs-1396]
* parse.y: forgot to initialize parser struct. [ruby-dev:25492]
* parse.y (parser_yylex): no tLABEL on EXPR_BEG.
[ruby-talk:127711]
* document updates - [ruby-core:04296], [ruby-core:04301],
[ruby-core:04302], [ruby-core:04307]
* dir.c (rb_push_glob): should work for NUL delimited patterns.
* dir.c (rb_glob2): should aware of offset in the pattern.
* string.c (rb_str_new4): should propagate taintedness.
* env.h: rename member names in struct FRAME; last_func -> callee,
orig_func -> this_func, last_class -> this_class.
* struct.c (rb_struct_set): use original method name, not callee
name, to retrieve member slot. [ruby-core:04268]
* time.c (time_strftime): protect from format modification from GC
finalizers.
* object.c (Init_Object): remove rb_obj_id_obsolete()
* eval.c (rb_mod_define_method): incomplete subclass check.
[ruby-dev:25464]
* gc.c (rb_data_object_alloc): klass may be NULL.
[ruby-list:40498]
* bignum.c (rb_big_rand): should return positive random number.
[ruby-dev:25401]
* bignum.c (rb_big_rand): do not use rb_big_modulo to generate
random bignums. [ruby-dev:25396]
* variable.c (rb_autoload): [ruby-dev:25373]
* eval.c (svalue_to_avalue): [ruby-dev:25366]
* string.c (rb_str_justify): [ruby-dev:25367]
* io.c (rb_f_select): [ruby-dev:25312]
* ext/socket/socket.c (sock_s_getservbyport): [ruby-talk:124072]
* struct.c (make_struct): [ruby-dev:25249]
* dir.c (dir_open_dir): new function. [ruby-dev:25242]
* io.c (rb_f_open): add type check for return value from to_open.
* lib/pstore.rb (PStore#transaction): Use the empty content when a
file is not found. [ruby-dev:24561]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-03-04 01:47:45 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* array.hash -> fixnum
|
|
|
|
*
|
|
|
|
* Compute a hash-code for this array. Two arrays with the same content
|
|
|
|
* will have the same hash code (and will compare using <code>eql?</code>).
|
|
|
|
*/
|
|
|
|
|
|
|
|
static VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_hash(VALUE ary)
|
* array.c: replace rb_protect_inspect() and rb_inspecting_p() by
rb_exec_recursive() in eval.c.
* eval.c (rb_exec_recursive): new function.
* array.c (rb_ary_join): use rb_exec_recursive().
* array.c (rb_ary_inspect, rb_ary_hash): ditto.
* file.c (rb_file_join): ditto.
* hash.c (rb_hash_inspect, rb_hash_to_s, rb_hash_hash): ditto.
* io.c (rb_io_puts): ditto.
* object.c (rb_obj_inspect): ditto
* struct.c (rb_struct_inspect): ditto.
* lib/set.rb (SortedSet::setup): a hack to shut up warning.
[ruby-talk:132866]
* lib/time.rb (Time::strptime): add new function. inspired by
[ruby-talk:132815].
* lib/parsedate.rb (ParseDate::strptime): ditto.
* regparse.c: move st_*_strend() functions from st.c. fixed some
potential memory leaks.
* exception error messages updated. [ruby-core:04497]
* ext/socket/socket.c (Init_socket): add bunch of Socket
constants. Patch from Sam Roberts <sroberts@uniserve.com>.
[ruby-core:04409]
* array.c (rb_ary_s_create): no need for negative argc check.
[ruby-core:04463]
* array.c (rb_ary_unshift_m): ditto.
* lib/xmlrpc/parser.rb (XMLRPC::FaultException): make it subclass
of StandardError class, not Exception class. [ruby-core:04429]
* parse.y (fcall_gen): lvar(arg) will be evaluated as
lvar.call(arg) when lvar is a defined local variable. [new]
* object.c (rb_class_initialize): call inherited method before
calling initializing block.
* eval.c (rb_thread_start_1): initialize newly pushed frame.
* lib/open3.rb (Open3::popen3): $? should not be EXIT_FAILURE.
fixed: [ruby-core:04444]
* eval.c (is_defined): NODE_IASGN is an assignment.
* ext/readline/readline.c (Readline.readline): use rl_outstream
and rl_instream. [ruby-dev:25699]
* ext/etc/etc.c (Init_etc): sGroup needs HAVE_ST_GR_PASSWD check
[ruby-dev:25675]
* misc/ruby-mode.el: [ruby-core:04415]
* lib/rdoc/generators/html_generator.rb: [ruby-core:04412]
* lib/rdoc/generators/ri_generator.rb: ditto.
* struct.c (make_struct): fixed: [ruby-core:04402]
* ext/curses/curses.c (window_color_set): [ruby-core:04393]
* ext/socket/socket.c (Init_socket): SO_REUSEPORT added.
[ruby-talk:130092]
* object.c: [ruby-doc:818]
* parse.y (open_args): fix too verbose warnings for the space
before argument parentheses. [ruby-dev:25492]
* parse.y (parser_yylex): ditto.
* parse.y (parser_yylex): the first expression in the parentheses
should not be a command. [ruby-dev:25492]
* lib/irb/context.rb (IRB::Context::initialize): [ruby-core:04330]
* object.c (Init_Object): remove Object#type. [ruby-core:04335]
* st.c (st_foreach): report success/failure by return value.
[ruby-Bugs-1396]
* parse.y: forgot to initialize parser struct. [ruby-dev:25492]
* parse.y (parser_yylex): no tLABEL on EXPR_BEG.
[ruby-talk:127711]
* document updates - [ruby-core:04296], [ruby-core:04301],
[ruby-core:04302], [ruby-core:04307]
* dir.c (rb_push_glob): should work for NUL delimited patterns.
* dir.c (rb_glob2): should aware of offset in the pattern.
* string.c (rb_str_new4): should propagate taintedness.
* env.h: rename member names in struct FRAME; last_func -> callee,
orig_func -> this_func, last_class -> this_class.
* struct.c (rb_struct_set): use original method name, not callee
name, to retrieve member slot. [ruby-core:04268]
* time.c (time_strftime): protect from format modification from GC
finalizers.
* object.c (Init_Object): remove rb_obj_id_obsolete()
* eval.c (rb_mod_define_method): incomplete subclass check.
[ruby-dev:25464]
* gc.c (rb_data_object_alloc): klass may be NULL.
[ruby-list:40498]
* bignum.c (rb_big_rand): should return positive random number.
[ruby-dev:25401]
* bignum.c (rb_big_rand): do not use rb_big_modulo to generate
random bignums. [ruby-dev:25396]
* variable.c (rb_autoload): [ruby-dev:25373]
* eval.c (svalue_to_avalue): [ruby-dev:25366]
* string.c (rb_str_justify): [ruby-dev:25367]
* io.c (rb_f_select): [ruby-dev:25312]
* ext/socket/socket.c (sock_s_getservbyport): [ruby-talk:124072]
* struct.c (make_struct): [ruby-dev:25249]
* dir.c (dir_open_dir): new function. [ruby-dev:25242]
* io.c (rb_f_open): add type check for return value from to_open.
* lib/pstore.rb (PStore#transaction): Use the empty content when a
file is not found. [ruby-dev:24561]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-03-04 01:47:45 -05:00
|
|
|
{
|
|
|
|
return rb_exec_recursive(recursive_hash, ary, 0);
|
|
|
|
}
|
|
|
|
|
2003-12-16 15:28:44 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
2004-07-13 11:34:34 -04:00
|
|
|
* array.include?(obj) -> true or false
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
|
|
|
* Returns <code>true</code> if the given object is present in
|
|
|
|
* <i>self</i> (that is, if any object <code>==</code> <i>anObject</i>),
|
|
|
|
* <code>false</code> otherwise.
|
|
|
|
*
|
|
|
|
* a = [ "a", "b", "c" ]
|
|
|
|
* a.include?("b") #=> true
|
|
|
|
* a.include?("z") #=> false
|
|
|
|
*/
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_includes(VALUE ary, VALUE item)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
1999-08-13 01:45:20 -04:00
|
|
|
long i;
|
2002-08-23 03:48:48 -04:00
|
|
|
|
2006-09-02 10:42:08 -04:00
|
|
|
for (i=0; i<RARRAY_LEN(ary); i++) {
|
|
|
|
if (rb_equal(RARRAY_PTR(ary)[i], item)) {
|
1999-01-19 23:59:39 -05:00
|
|
|
return Qtrue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return Qfalse;
|
|
|
|
}
|
|
|
|
|
2003-12-16 15:28:44 -05:00
|
|
|
|
|
|
|
/*
|
2004-07-13 12:21:23 -04:00
|
|
|
* call-seq:
|
|
|
|
* array <=> other_array -> -1, 0, +1
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
2004-07-13 12:21:23 -04:00
|
|
|
* Comparison---Returns an integer (-1, 0,
|
|
|
|
* or +1) if this array is less than, equal to, or greater than
|
|
|
|
* other_array. Each object in each array is compared
|
|
|
|
* (using <=>). If any value isn't
|
|
|
|
* equal, then that inequality is the return value. If all the
|
|
|
|
* values found are equal, then the return is based on a
|
|
|
|
* comparison of the array lengths. Thus, two arrays are
|
|
|
|
* ``equal'' according to <code>Array#<=></code> if and only if they have
|
|
|
|
* the same length and the value of each element is equal to the
|
|
|
|
* value of the corresponding element in the other array.
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
|
|
|
* [ "a", "a", "c" ] <=> [ "a", "b", "c" ] #=> -1
|
|
|
|
* [ 1, 2, 3, 4, 5, 6 ] <=> [ 1, 2 ] #=> +1
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2001-08-23 02:02:15 -04:00
|
|
|
VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_cmp(VALUE ary1, VALUE ary2)
|
1999-01-19 23:59:39 -05:00
|
|
|
{
|
1999-08-13 01:45:20 -04:00
|
|
|
long i, len;
|
1999-01-19 23:59:39 -05:00
|
|
|
|
2002-08-23 03:48:48 -04:00
|
|
|
ary2 = to_ary(ary2);
|
2006-09-02 10:42:08 -04:00
|
|
|
len = RARRAY_LEN(ary1);
|
|
|
|
if (len > RARRAY_LEN(ary2)) {
|
|
|
|
len = RARRAY_LEN(ary2);
|
1999-01-19 23:59:39 -05:00
|
|
|
}
|
|
|
|
for (i=0; i<len; i++) {
|
2004-09-21 20:19:15 -04:00
|
|
|
VALUE v = rb_funcall(rb_ary_elt(ary1, i), id_cmp, 1, rb_ary_elt(ary2, i));
|
1999-01-19 23:59:39 -05:00
|
|
|
if (v != INT2FIX(0)) {
|
|
|
|
return v;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
}
|
2006-09-02 10:42:08 -04:00
|
|
|
len = RARRAY_LEN(ary1) - RARRAY_LEN(ary2);
|
1999-01-19 23:59:39 -05:00
|
|
|
if (len == 0) return INT2FIX(0);
|
|
|
|
if (len > 0) return INT2FIX(1);
|
|
|
|
return INT2FIX(-1);
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2000-12-08 02:10:38 -05:00
|
|
|
static VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
ary_make_hash(VALUE ary1, VALUE ary2)
|
2000-12-05 04:36:54 -05:00
|
|
|
{
|
2000-12-08 02:10:38 -05:00
|
|
|
VALUE hash = rb_hash_new();
|
2002-08-23 03:48:48 -04:00
|
|
|
long i;
|
2000-12-05 04:36:54 -05:00
|
|
|
|
2006-09-02 10:42:08 -04:00
|
|
|
for (i=0; i<RARRAY_LEN(ary1); i++) {
|
|
|
|
rb_hash_aset(hash, RARRAY_PTR(ary1)[i], Qtrue);
|
2000-12-05 04:36:54 -05:00
|
|
|
}
|
|
|
|
if (ary2) {
|
2006-09-02 10:42:08 -04:00
|
|
|
for (i=0; i<RARRAY_LEN(ary2); i++) {
|
|
|
|
rb_hash_aset(hash, RARRAY_PTR(ary2)[i], Qtrue);
|
2000-12-05 04:36:54 -05:00
|
|
|
}
|
|
|
|
}
|
2000-12-08 02:10:38 -05:00
|
|
|
return hash;
|
2000-12-05 04:36:54 -05:00
|
|
|
}
|
|
|
|
|
2003-12-16 15:28:44 -05:00
|
|
|
/*
|
2004-07-13 12:21:23 -04:00
|
|
|
* call-seq:
|
2004-07-13 11:34:34 -04:00
|
|
|
* array - other_array -> an_array
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
2004-07-13 12:21:23 -04:00
|
|
|
* Array Difference---Returns a new array that is a copy of
|
|
|
|
* the original array, removing any items that also appear in
|
|
|
|
* other_array. (If you need set-like behavior, see the
|
|
|
|
* library class Set.)
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
|
|
|
* [ 1, 1, 2, 2, 3, 3, 4, 5 ] - [ 1, 2, 4 ] #=> [ 3, 3, 5 ]
|
|
|
|
*/
|
|
|
|
|
2003-02-03 00:34:16 -05:00
|
|
|
static VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_diff(VALUE ary1, VALUE ary2)
|
2003-02-03 00:34:16 -05:00
|
|
|
{
|
2005-12-12 11:47:17 -05:00
|
|
|
VALUE ary3;
|
|
|
|
volatile VALUE hash;
|
2003-02-03 00:34:16 -05:00
|
|
|
long i;
|
|
|
|
|
2005-08-09 21:39:24 -04:00
|
|
|
hash = ary_make_hash(to_ary(ary2), 0);
|
2003-02-03 00:34:16 -05:00
|
|
|
ary3 = rb_ary_new();
|
|
|
|
|
2006-09-02 10:42:08 -04:00
|
|
|
for (i=0; i<RARRAY_LEN(ary1); i++) {
|
|
|
|
if (st_lookup(RHASH(hash)->tbl, RARRAY_PTR(ary1)[i], 0)) continue;
|
2004-09-20 23:08:33 -04:00
|
|
|
rb_ary_push(ary3, rb_ary_elt(ary1, i));
|
2003-02-03 00:34:16 -05:00
|
|
|
}
|
|
|
|
return ary3;
|
|
|
|
}
|
|
|
|
|
2003-12-16 15:28:44 -05:00
|
|
|
/*
|
2004-07-13 12:21:23 -04:00
|
|
|
* call-seq:
|
|
|
|
* array & other_array
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
2004-07-13 12:21:23 -04:00
|
|
|
* Set Intersection---Returns a new array
|
|
|
|
* containing elements common to the two arrays, with no duplicates.
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
2004-07-13 12:21:23 -04:00
|
|
|
* [ 1, 1, 3, 5 ] & [ 1, 2, 3 ] #=> [ 1, 3 ]
|
2003-12-16 15:28:44 -05:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
static VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_and(VALUE ary1, VALUE ary2)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
2004-11-03 06:34:57 -05:00
|
|
|
VALUE hash, ary3, v, vv;
|
1999-08-13 01:45:20 -04:00
|
|
|
long i;
|
2000-12-08 02:10:38 -05:00
|
|
|
|
2005-08-09 21:39:24 -04:00
|
|
|
ary2 = to_ary(ary2);
|
2006-09-02 10:42:08 -04:00
|
|
|
ary3 = rb_ary_new2(RARRAY_LEN(ary1) < RARRAY_LEN(ary2) ?
|
|
|
|
RARRAY_LEN(ary1) : RARRAY_LEN(ary2));
|
2000-12-08 02:10:38 -05:00
|
|
|
hash = ary_make_hash(ary2, 0);
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2006-09-02 10:42:08 -04:00
|
|
|
for (i=0; i<RARRAY_LEN(ary1); i++) {
|
2004-11-03 06:34:57 -05:00
|
|
|
v = vv = rb_ary_elt(ary1, i);
|
|
|
|
if (st_delete(RHASH(hash)->tbl, (st_data_t*)&vv, 0)) {
|
2004-09-20 23:08:33 -04:00
|
|
|
rb_ary_push(ary3, v);
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
}
|
2000-12-05 04:36:54 -05:00
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
return ary3;
|
|
|
|
}
|
|
|
|
|
2003-12-16 15:28:44 -05:00
|
|
|
/*
|
2004-07-13 12:21:23 -04:00
|
|
|
* call-seq:
|
|
|
|
* array | other_array -> an_array
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
|
|
|
* Set Union---Returns a new array by joining this array with
|
|
|
|
* other_array, removing duplicates.
|
|
|
|
*
|
2004-07-13 12:21:23 -04:00
|
|
|
* [ "a", "b", "c" ] | [ "c", "d", "a" ]
|
2003-12-16 15:28:44 -05:00
|
|
|
* #=> [ "a", "b", "c", "d" ]
|
|
|
|
*/
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
static VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_or(VALUE ary1, VALUE ary2)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
2002-08-23 03:48:48 -04:00
|
|
|
VALUE hash, ary3;
|
2004-11-03 06:34:57 -05:00
|
|
|
VALUE v, vv;
|
1999-08-13 01:45:20 -04:00
|
|
|
long i;
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2005-08-09 21:39:24 -04:00
|
|
|
ary2 = to_ary(ary2);
|
2006-09-02 10:42:08 -04:00
|
|
|
ary3 = rb_ary_new2(RARRAY_LEN(ary1)+RARRAY_LEN(ary2));
|
2000-12-08 02:10:38 -05:00
|
|
|
hash = ary_make_hash(ary1, ary2);
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2006-09-02 10:42:08 -04:00
|
|
|
for (i=0; i<RARRAY_LEN(ary1); i++) {
|
2004-11-03 06:34:57 -05:00
|
|
|
v = vv = rb_ary_elt(ary1, i);
|
|
|
|
if (st_delete(RHASH(hash)->tbl, (st_data_t*)&vv, 0)) {
|
2004-09-20 23:08:33 -04:00
|
|
|
rb_ary_push(ary3, v);
|
2000-12-05 04:36:54 -05:00
|
|
|
}
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
2006-09-02 10:42:08 -04:00
|
|
|
for (i=0; i<RARRAY_LEN(ary2); i++) {
|
2004-11-03 06:34:57 -05:00
|
|
|
v = vv = rb_ary_elt(ary2, i);
|
|
|
|
if (st_delete(RHASH(hash)->tbl, (st_data_t*)&vv, 0)) {
|
2004-09-20 23:08:33 -04:00
|
|
|
rb_ary_push(ary3, v);
|
2000-12-05 04:36:54 -05:00
|
|
|
}
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
return ary3;
|
|
|
|
}
|
|
|
|
|
2003-12-16 15:28:44 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
2004-07-13 11:34:34 -04:00
|
|
|
* array.uniq! -> array or nil
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
|
|
|
* Removes duplicate elements from _self_.
|
|
|
|
* Returns <code>nil</code> if no changes are made (that is, no
|
|
|
|
* duplicates are found).
|
|
|
|
*
|
|
|
|
* a = [ "a", "a", "b", "b", "c" ]
|
|
|
|
* a.uniq! #=> ["a", "b", "c"]
|
|
|
|
* b = [ "a", "b", "c" ]
|
|
|
|
* b.uniq! #=> nil
|
|
|
|
*/
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
static VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_uniq_bang(VALUE ary)
|
1999-01-19 23:59:39 -05:00
|
|
|
{
|
2004-11-03 06:34:57 -05:00
|
|
|
VALUE hash, v, vv;
|
2004-09-21 20:19:15 -04:00
|
|
|
long i, j;
|
1999-01-19 23:59:39 -05:00
|
|
|
|
* array.c (ary_iter_check): should check modification (size
change) during iteration.
* array.c (rb_ary_initialize, rb_ary_shift, rb_ary_unshift,
rb_ary_splice, rb_ary_reverse, rb_ary_sort, rb_ary_delete,
rb_ary_delete_at, rb_ary_reject_bang, rb_ary_replace,
rb_ary_clear, rb_ary_fill, rb_ary_uniq_bang, rb_ary_compact,
rb_ary_shuffle): add iteration check.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-12-29 14:25:11 -05:00
|
|
|
ary_iter_check(ary);
|
2002-08-23 03:48:48 -04:00
|
|
|
hash = ary_make_hash(ary, 0);
|
|
|
|
|
2006-09-02 10:42:08 -04:00
|
|
|
if (RARRAY_LEN(ary) == RHASH(hash)->tbl->num_entries) {
|
2000-12-05 04:36:54 -05:00
|
|
|
return Qnil;
|
|
|
|
}
|
2006-09-02 10:42:08 -04:00
|
|
|
for (i=j=0; i<RARRAY_LEN(ary); i++) {
|
2004-11-03 06:34:57 -05:00
|
|
|
v = vv = rb_ary_elt(ary, i);
|
|
|
|
if (st_delete(RHASH(hash)->tbl, (st_data_t*)&vv, 0)) {
|
2004-09-21 20:19:15 -04:00
|
|
|
rb_ary_store(ary, j++, v);
|
1999-01-19 23:59:39 -05:00
|
|
|
}
|
|
|
|
}
|
2006-11-01 09:42:39 -05:00
|
|
|
RARRAY(ary)->len = j;
|
1999-01-19 23:59:39 -05:00
|
|
|
|
|
|
|
return ary;
|
|
|
|
}
|
|
|
|
|
2003-12-16 15:28:44 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
2004-07-13 11:34:34 -04:00
|
|
|
* array.uniq -> an_array
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
|
|
|
* Returns a new array by removing duplicate values in <i>self</i>.
|
|
|
|
*
|
|
|
|
* a = [ "a", "a", "b", "b", "c" ]
|
|
|
|
* a.uniq #=> ["a", "b", "c"]
|
|
|
|
*/
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
static VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_uniq(VALUE ary)
|
1999-01-19 23:59:39 -05:00
|
|
|
{
|
2002-08-27 04:31:08 -04:00
|
|
|
ary = rb_ary_dup(ary);
|
1999-10-20 03:10:23 -04:00
|
|
|
rb_ary_uniq_bang(ary);
|
|
|
|
return ary;
|
1999-01-19 23:59:39 -05:00
|
|
|
}
|
|
|
|
|
2003-12-16 15:28:44 -05:00
|
|
|
/*
|
2004-07-13 12:21:23 -04:00
|
|
|
* call-seq:
|
|
|
|
* array.compact! -> array or nil
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
|
|
|
* Removes +nil+ elements from array.
|
2004-07-13 11:34:34 -04:00
|
|
|
* Returns +nil+ if no changes were made.
|
2004-07-13 12:21:23 -04:00
|
|
|
*
|
2003-12-16 15:28:44 -05:00
|
|
|
* [ "a", nil, "b", nil, "c" ].compact! #=> [ "a", "b", "c" ]
|
|
|
|
* [ "a", "b", "c" ].compact! #=> nil
|
|
|
|
*/
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
static VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_compact_bang(VALUE ary)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
|
|
|
VALUE *p, *t, *end;
|
2006-09-02 10:42:08 -04:00
|
|
|
long n;
|
1998-01-16 07:13:05 -05:00
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
rb_ary_modify(ary);
|
* array.c (ary_iter_check): should check modification (size
change) during iteration.
* array.c (rb_ary_initialize, rb_ary_shift, rb_ary_unshift,
rb_ary_splice, rb_ary_reverse, rb_ary_sort, rb_ary_delete,
rb_ary_delete_at, rb_ary_reject_bang, rb_ary_replace,
rb_ary_clear, rb_ary_fill, rb_ary_uniq_bang, rb_ary_compact,
rb_ary_shuffle): add iteration check.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-12-29 14:25:11 -05:00
|
|
|
ary_iter_check(ary);
|
2006-09-02 10:42:08 -04:00
|
|
|
p = t = RARRAY_PTR(ary);
|
|
|
|
end = p + RARRAY_LEN(ary);
|
2002-05-21 01:39:19 -04:00
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
while (t < end) {
|
|
|
|
if (NIL_P(*t)) t++;
|
|
|
|
else *p++ = *t++;
|
|
|
|
}
|
2006-09-02 10:42:08 -04:00
|
|
|
if (RARRAY_LEN(ary) == (p - RARRAY_PTR(ary))) {
|
1999-01-19 23:59:39 -05:00
|
|
|
return Qnil;
|
|
|
|
}
|
2006-09-02 10:42:08 -04:00
|
|
|
n = p - RARRAY_PTR(ary);
|
|
|
|
RESIZE_CAPA(ary, n);
|
2006-11-01 09:42:39 -05:00
|
|
|
RARRAY(ary)->len = n;
|
1998-01-16 07:13:05 -05:00
|
|
|
|
1998-01-16 07:19:22 -05:00
|
|
|
return ary;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2004-07-13 12:21:23 -04:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* array.compact -> an_array
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
2004-07-13 12:21:23 -04:00
|
|
|
* Returns a copy of _self_ with all +nil+ elements removed.
|
|
|
|
*
|
|
|
|
* [ "a", nil, "b", nil, "c", nil ].compact
|
2003-12-16 15:28:44 -05:00
|
|
|
* #=> [ "a", "b", "c" ]
|
|
|
|
*/
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
static VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_compact(VALUE ary)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
2002-08-27 04:31:08 -04:00
|
|
|
ary = rb_ary_dup(ary);
|
1999-10-20 03:10:23 -04:00
|
|
|
rb_ary_compact_bang(ary);
|
|
|
|
return ary;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2003-12-16 15:28:44 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* array.nitems -> int
|
2005-06-07 23:30:56 -04:00
|
|
|
* array.nitems { |item| block } -> int
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
|
|
|
* Returns the number of non-<code>nil</code> elements in _self_.
|
2005-06-07 23:30:56 -04:00
|
|
|
* If a block is given, the elements yielding a true value are
|
|
|
|
* counted.
|
|
|
|
*
|
2003-12-16 15:28:44 -05:00
|
|
|
* May be zero.
|
|
|
|
*
|
|
|
|
* [ 1, nil, 3, nil, 5 ].nitems #=> 3
|
2005-06-07 23:30:56 -04:00
|
|
|
* [5,6,7,8,9].nitems { |x| x % 2 != 0 } #=> 3
|
2003-12-16 15:28:44 -05:00
|
|
|
*/
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
static VALUE
|
2005-09-10 09:34:53 -04:00
|
|
|
rb_ary_nitems(VALUE ary)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
1999-08-13 01:45:20 -04:00
|
|
|
long n = 0;
|
2005-06-07 23:30:56 -04:00
|
|
|
|
|
|
|
if (rb_block_given_p()) {
|
|
|
|
long i;
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2006-09-02 10:42:08 -04:00
|
|
|
for (i=0; i<RARRAY_LEN(ary); i++) {
|
|
|
|
VALUE v = RARRAY_PTR(ary)[i];
|
2005-06-07 23:30:56 -04:00
|
|
|
if (RTEST(rb_yield(v))) n++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2006-09-02 10:42:08 -04:00
|
|
|
VALUE *p = RARRAY_PTR(ary);
|
|
|
|
VALUE *pend = p + RARRAY_LEN(ary);
|
2002-05-21 01:39:19 -04:00
|
|
|
|
2005-06-07 23:30:56 -04:00
|
|
|
while (p < pend) {
|
|
|
|
if (!NIL_P(*p)) n++;
|
|
|
|
p++;
|
|
|
|
}
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
2002-08-21 11:47:54 -04:00
|
|
|
return LONG2NUM(n);
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2002-05-21 01:39:19 -04:00
|
|
|
static long
|
* sprintf.c (rb_str_format): allow %c to print one character
string (e.g. ?x).
* lib/tempfile.rb (Tempfile::make_tmpname): put dot between
basename and pid. [ruby-talk:196272]
* parse.y (do_block): remove -> style block.
* parse.y (parser_yylex): remove tLAMBDA_ARG.
* eval.c (rb_call0): binding for the return event hook should have
consistent scope. [ruby-core:07928]
* eval.c (proc_invoke): return behavior should depend whether it
is surrounded by a lambda or a mere block.
* eval.c (formal_assign): handles post splat arguments.
* eval.c (rb_call0): ditto.
* st.c (strhash): use FNV-1a hash.
* parse.y (parser_yylex): removed experimental ';;' terminator.
* eval.c (rb_node_arity): should be aware of post splat arguments.
* eval.c (rb_proc_arity): ditto.
* parse.y (f_args): syntax rule enhanced to support arguments
after the splat.
* parse.y (block_param): ditto for block parameters.
* parse.y (f_post_arg): mandatory formal arguments after the splat
argument.
* parse.y (new_args_gen): generate nodes for mandatory formal
arguments after the splat argument.
* eval.c (rb_eval): dispatch mandatory formal arguments after the
splat argument.
* parse.y (args): allow more than one splat in the argument list.
* parse.y (method_call): allow aref [] to accept all kind of
method argument, including assocs, splat, and block argument.
* eval.c (SETUP_ARGS0): prepare block argument as well.
* lib/mathn.rb (Integer): remove Integer#gcd2. [ruby-core:07931]
* eval.c (error_line): print receivers true/false/nil specially.
* eval.c (rb_proc_yield): handles parameters in yield semantics.
* eval.c (nil_yield): gives LocalJumpError to denote no block
error.
* io.c (rb_io_getc): now takes one-character string.
* string.c (rb_str_hash): use FNV-1a hash from Fowler/Noll/Vo
hashing algorithm.
* string.c (rb_str_aref): str[0] now returns 1 character string,
instead of a fixnum. [Ruby2]
* parse.y (parser_yylex): ?c now returns 1 character string,
instead of a fixnum. [Ruby2]
* string.c (rb_str_aset): no longer support fixnum insertion.
* eval.c (umethod_bind): should not update original class.
[ruby-dev:28636]
* eval.c (ev_const_get): should support constant access from
within instance_eval(). [ruby-dev:28327]
* time.c (time_timeval): should round for usec floating
number. [ruby-core:07896]
* time.c (time_add): ditto.
* dir.c (sys_warning): should not call a vararg function
rb_sys_warning() indirectly. [ruby-core:07886]
* numeric.c (flo_divmod): the first element of Float#divmod should
be an integer. [ruby-dev:28589]
* test/ruby/test_float.rb: add tests for divmod, div, modulo and remainder.
* re.c (rb_reg_initialize): should not allow modifying literal
regexps. frozen check moved from rb_reg_initialize_m as well.
* re.c (rb_reg_initialize): should not modify untainted objects in
safe levels higher than 3.
* re.c (rb_memcmp): type change from char* to const void*.
* dir.c (dir_close): should not close untainted dir stream.
* dir.c (GetDIR): add tainted/frozen check for each dir operation.
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_symbol_arg):
typo fixed. a patch from Florian Gross <florg at florg.net>.
* eval.c (EXEC_EVENT_HOOK): trace_func may remove itself from
event_hooks. no guarantee for arbitrary hook deletion.
[ruby-dev:28632]
* util.c (ruby_strtod): differ addition to minimize error.
[ruby-dev:28619]
* util.c (ruby_strtod): should not raise ERANGE when the input
string does not have any digits. [ruby-dev:28629]
* eval.c (proc_invoke): should restore old ruby_frame->block.
thanks to ts <decoux at moulon.inra.fr>. [ruby-core:07833]
also fix [ruby-dev:28614] as well.
* signal.c (trap): sig should be less then NSIG. Coverity found
this bug. a patch from Kevin Tew <tewk at tewk.com>.
[ruby-core:07823]
* math.c (math_log2): add new method inspired by
[ruby-talk:191237].
* math.c (math_log): add optional base argument to Math::log().
[ruby-talk:191308]
* ext/syck/emitter.c (syck_scan_scalar): avoid accessing
uninitialized array element. a patch from Pat Eyler
<rubypate at gmail.com>. [ruby-core:07809]
* array.c (rb_ary_fill): initialize local variables first. a
patch from Pat Eyler <rubypate at gmail.com>. [ruby-core:07810]
* ext/syck/yaml2byte.c (syck_yaml2byte_handler): need to free
type_tag. a patch from Pat Eyler <rubypate at gmail.com>.
[ruby-core:07808]
* ext/socket/socket.c (make_hostent_internal): accept ai_family
check from Sam Roberts <sroberts at uniserve.com>.
[ruby-core:07691]
* util.c (ruby_strtod): should not cut off 18 digits for no
reason. [ruby-core:07796]
* array.c (rb_ary_fill): internalize local variable "beg" to
pacify Coverity. [ruby-core:07770]
* pack.c (pack_unpack): now supports CRLF newlines. a patch from
<tommy at tmtm.org>. [ruby-dev:28601]
* applied code clean-up patch from Stefan Huehner
<stefan at huehner.org>. [ruby-core:07764]
* lib/jcode.rb (String::tr_s): should have translated non
squeezing character sequence (i.e. a character) as well. thanks
to Hiroshi Ichikawa <gimite at gimite.ddo.jp> [ruby-list:42090]
* ext/socket/socket.c: document update patch from Sam Roberts
<sroberts at uniserve.com>. [ruby-core:07701]
* lib/mathn.rb (Integer): need not to remove gcd2. a patch from
NARUSE, Yui <naruse at airemix.com>. [ruby-dev:28570]
* parse.y (arg): too much NEW_LIST()
* eval.c (SETUP_ARGS0): remove unnecessary access to nd_alen.
* eval.c (rb_eval): use ARGSCAT for NODE_OP_ASGN1.
[ruby-dev:28585]
* parse.y (arg): use NODE_ARGSCAT for placeholder.
* lib/getoptlong.rb (GetoptLong::get): RDoc update patch from
mathew <meta at pobox.com>. [ruby-core:07738]
* variable.c (rb_const_set): raise error when no target klass is
supplied. [ruby-dev:28582]
* prec.c (prec_prec_f): documentation patch from
<gerardo.santana at gmail.com>. [ruby-core:07689]
* bignum.c (rb_big_pow): second operand may be too big even if
it's a Fixnum. [ruby-talk:187984]
* README.EXT: update symbol description. [ruby-talk:188104]
* COPYING: explicitly note GPLv2. [ruby-talk:187922]
* parse.y: remove some obsolete syntax rules (unparenthesized
method calls in argument list).
* eval.c (rb_call0): insecure calling should be checked for non
NODE_SCOPE method invocations too.
* eval.c (rb_alias): should preserve the current safe level as
well as method definition.
* process.c (rb_f_sleep): remove RDoc description about SIGALRM
which is not valid on the current implementation. [ruby-dev:28464]
Thu Mar 23 21:40:47 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
* eval.c (method_missing): should support argument splat in
super. a bug in combination of super, splat and
method_missing. [ruby-talk:185438]
* configure.in: Solaris SunPro compiler -rapth patch from
<kuwa at labs.fujitsu.com>. [ruby-dev:28443]
* configure.in: remove enable_rpath=no for Solaris.
[ruby-dev:28440]
* ext/win32ole/win32ole.c (ole_val2olevariantdata): change behavior
of converting OLE Variant object with VT_ARRAY|VT_UI1 and Ruby
String object.
* ruby.1: a clarification patch from David Lutterkort
<dlutter at redhat.com>. [ruby-core:7508]
* lib/rdoc/ri/ri_paths.rb (RI::Paths): adding paths from rubygems
directories. a patch from Eric Hodel <drbrain at segment7.net>.
[ruby-core:07423]
* eval.c (rb_clear_cache_by_class): clearing wrong cache.
* ext/extmk.rb: use :remove_destination to install extension libraries
to avoid SEGV. [ruby-dev:28417]
* eval.c (rb_thread_fd_writable): should not re-schedule output
from KILLED thread (must be error printing).
* array.c (rb_ary_flatten_bang): allow specifying recursion
level. [ruby-talk:182170]
* array.c (rb_ary_flatten): ditto.
* gc.c (add_heap): a heap_slots may overflow. a patch from Stefan
Weil <weil at mail.berlios.de>.
* eval.c (rb_call): use separate cache for fcall/vcall
invocation.
* eval.c (rb_eval): NODE_FCALL, NODE_VCALL can call local
functions.
* eval.c (rb_mod_local): a new method to specify newly added
visibility "local".
* eval.c (search_method): search for local methods which are
visible only from the current class.
* class.c (rb_class_local_methods): a method to list local methods.
* object.c (Init_Object): add BasicObject class as a top level
BlankSlate class.
* ruby.h (SYM2ID): should not cast to signed long.
[ruby-core:07414]
* class.c (rb_include_module): allow module duplication.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-09 17:20:17 -04:00
|
|
|
flatten(VALUE ary, long idx, VALUE ary2, VALUE memo, int level)
|
2001-05-02 00:22:21 -04:00
|
|
|
{
|
|
|
|
VALUE id;
|
|
|
|
long i = idx;
|
2006-09-02 10:42:08 -04:00
|
|
|
long n, lim = idx + RARRAY_LEN(ary2);
|
2001-05-02 00:22:21 -04:00
|
|
|
|
* sprintf.c (rb_str_format): allow %c to print one character
string (e.g. ?x).
* lib/tempfile.rb (Tempfile::make_tmpname): put dot between
basename and pid. [ruby-talk:196272]
* parse.y (do_block): remove -> style block.
* parse.y (parser_yylex): remove tLAMBDA_ARG.
* eval.c (rb_call0): binding for the return event hook should have
consistent scope. [ruby-core:07928]
* eval.c (proc_invoke): return behavior should depend whether it
is surrounded by a lambda or a mere block.
* eval.c (formal_assign): handles post splat arguments.
* eval.c (rb_call0): ditto.
* st.c (strhash): use FNV-1a hash.
* parse.y (parser_yylex): removed experimental ';;' terminator.
* eval.c (rb_node_arity): should be aware of post splat arguments.
* eval.c (rb_proc_arity): ditto.
* parse.y (f_args): syntax rule enhanced to support arguments
after the splat.
* parse.y (block_param): ditto for block parameters.
* parse.y (f_post_arg): mandatory formal arguments after the splat
argument.
* parse.y (new_args_gen): generate nodes for mandatory formal
arguments after the splat argument.
* eval.c (rb_eval): dispatch mandatory formal arguments after the
splat argument.
* parse.y (args): allow more than one splat in the argument list.
* parse.y (method_call): allow aref [] to accept all kind of
method argument, including assocs, splat, and block argument.
* eval.c (SETUP_ARGS0): prepare block argument as well.
* lib/mathn.rb (Integer): remove Integer#gcd2. [ruby-core:07931]
* eval.c (error_line): print receivers true/false/nil specially.
* eval.c (rb_proc_yield): handles parameters in yield semantics.
* eval.c (nil_yield): gives LocalJumpError to denote no block
error.
* io.c (rb_io_getc): now takes one-character string.
* string.c (rb_str_hash): use FNV-1a hash from Fowler/Noll/Vo
hashing algorithm.
* string.c (rb_str_aref): str[0] now returns 1 character string,
instead of a fixnum. [Ruby2]
* parse.y (parser_yylex): ?c now returns 1 character string,
instead of a fixnum. [Ruby2]
* string.c (rb_str_aset): no longer support fixnum insertion.
* eval.c (umethod_bind): should not update original class.
[ruby-dev:28636]
* eval.c (ev_const_get): should support constant access from
within instance_eval(). [ruby-dev:28327]
* time.c (time_timeval): should round for usec floating
number. [ruby-core:07896]
* time.c (time_add): ditto.
* dir.c (sys_warning): should not call a vararg function
rb_sys_warning() indirectly. [ruby-core:07886]
* numeric.c (flo_divmod): the first element of Float#divmod should
be an integer. [ruby-dev:28589]
* test/ruby/test_float.rb: add tests for divmod, div, modulo and remainder.
* re.c (rb_reg_initialize): should not allow modifying literal
regexps. frozen check moved from rb_reg_initialize_m as well.
* re.c (rb_reg_initialize): should not modify untainted objects in
safe levels higher than 3.
* re.c (rb_memcmp): type change from char* to const void*.
* dir.c (dir_close): should not close untainted dir stream.
* dir.c (GetDIR): add tainted/frozen check for each dir operation.
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_symbol_arg):
typo fixed. a patch from Florian Gross <florg at florg.net>.
* eval.c (EXEC_EVENT_HOOK): trace_func may remove itself from
event_hooks. no guarantee for arbitrary hook deletion.
[ruby-dev:28632]
* util.c (ruby_strtod): differ addition to minimize error.
[ruby-dev:28619]
* util.c (ruby_strtod): should not raise ERANGE when the input
string does not have any digits. [ruby-dev:28629]
* eval.c (proc_invoke): should restore old ruby_frame->block.
thanks to ts <decoux at moulon.inra.fr>. [ruby-core:07833]
also fix [ruby-dev:28614] as well.
* signal.c (trap): sig should be less then NSIG. Coverity found
this bug. a patch from Kevin Tew <tewk at tewk.com>.
[ruby-core:07823]
* math.c (math_log2): add new method inspired by
[ruby-talk:191237].
* math.c (math_log): add optional base argument to Math::log().
[ruby-talk:191308]
* ext/syck/emitter.c (syck_scan_scalar): avoid accessing
uninitialized array element. a patch from Pat Eyler
<rubypate at gmail.com>. [ruby-core:07809]
* array.c (rb_ary_fill): initialize local variables first. a
patch from Pat Eyler <rubypate at gmail.com>. [ruby-core:07810]
* ext/syck/yaml2byte.c (syck_yaml2byte_handler): need to free
type_tag. a patch from Pat Eyler <rubypate at gmail.com>.
[ruby-core:07808]
* ext/socket/socket.c (make_hostent_internal): accept ai_family
check from Sam Roberts <sroberts at uniserve.com>.
[ruby-core:07691]
* util.c (ruby_strtod): should not cut off 18 digits for no
reason. [ruby-core:07796]
* array.c (rb_ary_fill): internalize local variable "beg" to
pacify Coverity. [ruby-core:07770]
* pack.c (pack_unpack): now supports CRLF newlines. a patch from
<tommy at tmtm.org>. [ruby-dev:28601]
* applied code clean-up patch from Stefan Huehner
<stefan at huehner.org>. [ruby-core:07764]
* lib/jcode.rb (String::tr_s): should have translated non
squeezing character sequence (i.e. a character) as well. thanks
to Hiroshi Ichikawa <gimite at gimite.ddo.jp> [ruby-list:42090]
* ext/socket/socket.c: document update patch from Sam Roberts
<sroberts at uniserve.com>. [ruby-core:07701]
* lib/mathn.rb (Integer): need not to remove gcd2. a patch from
NARUSE, Yui <naruse at airemix.com>. [ruby-dev:28570]
* parse.y (arg): too much NEW_LIST()
* eval.c (SETUP_ARGS0): remove unnecessary access to nd_alen.
* eval.c (rb_eval): use ARGSCAT for NODE_OP_ASGN1.
[ruby-dev:28585]
* parse.y (arg): use NODE_ARGSCAT for placeholder.
* lib/getoptlong.rb (GetoptLong::get): RDoc update patch from
mathew <meta at pobox.com>. [ruby-core:07738]
* variable.c (rb_const_set): raise error when no target klass is
supplied. [ruby-dev:28582]
* prec.c (prec_prec_f): documentation patch from
<gerardo.santana at gmail.com>. [ruby-core:07689]
* bignum.c (rb_big_pow): second operand may be too big even if
it's a Fixnum. [ruby-talk:187984]
* README.EXT: update symbol description. [ruby-talk:188104]
* COPYING: explicitly note GPLv2. [ruby-talk:187922]
* parse.y: remove some obsolete syntax rules (unparenthesized
method calls in argument list).
* eval.c (rb_call0): insecure calling should be checked for non
NODE_SCOPE method invocations too.
* eval.c (rb_alias): should preserve the current safe level as
well as method definition.
* process.c (rb_f_sleep): remove RDoc description about SIGALRM
which is not valid on the current implementation. [ruby-dev:28464]
Thu Mar 23 21:40:47 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
* eval.c (method_missing): should support argument splat in
super. a bug in combination of super, splat and
method_missing. [ruby-talk:185438]
* configure.in: Solaris SunPro compiler -rapth patch from
<kuwa at labs.fujitsu.com>. [ruby-dev:28443]
* configure.in: remove enable_rpath=no for Solaris.
[ruby-dev:28440]
* ext/win32ole/win32ole.c (ole_val2olevariantdata): change behavior
of converting OLE Variant object with VT_ARRAY|VT_UI1 and Ruby
String object.
* ruby.1: a clarification patch from David Lutterkort
<dlutter at redhat.com>. [ruby-core:7508]
* lib/rdoc/ri/ri_paths.rb (RI::Paths): adding paths from rubygems
directories. a patch from Eric Hodel <drbrain at segment7.net>.
[ruby-core:07423]
* eval.c (rb_clear_cache_by_class): clearing wrong cache.
* ext/extmk.rb: use :remove_destination to install extension libraries
to avoid SEGV. [ruby-dev:28417]
* eval.c (rb_thread_fd_writable): should not re-schedule output
from KILLED thread (must be error printing).
* array.c (rb_ary_flatten_bang): allow specifying recursion
level. [ruby-talk:182170]
* array.c (rb_ary_flatten): ditto.
* gc.c (add_heap): a heap_slots may overflow. a patch from Stefan
Weil <weil at mail.berlios.de>.
* eval.c (rb_call): use separate cache for fcall/vcall
invocation.
* eval.c (rb_eval): NODE_FCALL, NODE_VCALL can call local
functions.
* eval.c (rb_mod_local): a new method to specify newly added
visibility "local".
* eval.c (search_method): search for local methods which are
visible only from the current class.
* class.c (rb_class_local_methods): a method to list local methods.
* object.c (Init_Object): add BasicObject class as a top level
BlankSlate class.
* ruby.h (SYM2ID): should not cast to signed long.
[ruby-core:07414]
* class.c (rb_include_module): allow module duplication.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-09 17:20:17 -04:00
|
|
|
level--;
|
2001-05-02 00:22:21 -04:00
|
|
|
id = rb_obj_id(ary2);
|
|
|
|
if (rb_ary_includes(memo, id)) {
|
|
|
|
rb_raise(rb_eArgError, "tried to flatten recursive array");
|
|
|
|
}
|
|
|
|
rb_ary_push(memo, id);
|
2004-11-17 22:45:23 -05:00
|
|
|
rb_ary_splice(ary, idx, 1, ary2);
|
* sprintf.c (rb_str_format): allow %c to print one character
string (e.g. ?x).
* lib/tempfile.rb (Tempfile::make_tmpname): put dot between
basename and pid. [ruby-talk:196272]
* parse.y (do_block): remove -> style block.
* parse.y (parser_yylex): remove tLAMBDA_ARG.
* eval.c (rb_call0): binding for the return event hook should have
consistent scope. [ruby-core:07928]
* eval.c (proc_invoke): return behavior should depend whether it
is surrounded by a lambda or a mere block.
* eval.c (formal_assign): handles post splat arguments.
* eval.c (rb_call0): ditto.
* st.c (strhash): use FNV-1a hash.
* parse.y (parser_yylex): removed experimental ';;' terminator.
* eval.c (rb_node_arity): should be aware of post splat arguments.
* eval.c (rb_proc_arity): ditto.
* parse.y (f_args): syntax rule enhanced to support arguments
after the splat.
* parse.y (block_param): ditto for block parameters.
* parse.y (f_post_arg): mandatory formal arguments after the splat
argument.
* parse.y (new_args_gen): generate nodes for mandatory formal
arguments after the splat argument.
* eval.c (rb_eval): dispatch mandatory formal arguments after the
splat argument.
* parse.y (args): allow more than one splat in the argument list.
* parse.y (method_call): allow aref [] to accept all kind of
method argument, including assocs, splat, and block argument.
* eval.c (SETUP_ARGS0): prepare block argument as well.
* lib/mathn.rb (Integer): remove Integer#gcd2. [ruby-core:07931]
* eval.c (error_line): print receivers true/false/nil specially.
* eval.c (rb_proc_yield): handles parameters in yield semantics.
* eval.c (nil_yield): gives LocalJumpError to denote no block
error.
* io.c (rb_io_getc): now takes one-character string.
* string.c (rb_str_hash): use FNV-1a hash from Fowler/Noll/Vo
hashing algorithm.
* string.c (rb_str_aref): str[0] now returns 1 character string,
instead of a fixnum. [Ruby2]
* parse.y (parser_yylex): ?c now returns 1 character string,
instead of a fixnum. [Ruby2]
* string.c (rb_str_aset): no longer support fixnum insertion.
* eval.c (umethod_bind): should not update original class.
[ruby-dev:28636]
* eval.c (ev_const_get): should support constant access from
within instance_eval(). [ruby-dev:28327]
* time.c (time_timeval): should round for usec floating
number. [ruby-core:07896]
* time.c (time_add): ditto.
* dir.c (sys_warning): should not call a vararg function
rb_sys_warning() indirectly. [ruby-core:07886]
* numeric.c (flo_divmod): the first element of Float#divmod should
be an integer. [ruby-dev:28589]
* test/ruby/test_float.rb: add tests for divmod, div, modulo and remainder.
* re.c (rb_reg_initialize): should not allow modifying literal
regexps. frozen check moved from rb_reg_initialize_m as well.
* re.c (rb_reg_initialize): should not modify untainted objects in
safe levels higher than 3.
* re.c (rb_memcmp): type change from char* to const void*.
* dir.c (dir_close): should not close untainted dir stream.
* dir.c (GetDIR): add tainted/frozen check for each dir operation.
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_symbol_arg):
typo fixed. a patch from Florian Gross <florg at florg.net>.
* eval.c (EXEC_EVENT_HOOK): trace_func may remove itself from
event_hooks. no guarantee for arbitrary hook deletion.
[ruby-dev:28632]
* util.c (ruby_strtod): differ addition to minimize error.
[ruby-dev:28619]
* util.c (ruby_strtod): should not raise ERANGE when the input
string does not have any digits. [ruby-dev:28629]
* eval.c (proc_invoke): should restore old ruby_frame->block.
thanks to ts <decoux at moulon.inra.fr>. [ruby-core:07833]
also fix [ruby-dev:28614] as well.
* signal.c (trap): sig should be less then NSIG. Coverity found
this bug. a patch from Kevin Tew <tewk at tewk.com>.
[ruby-core:07823]
* math.c (math_log2): add new method inspired by
[ruby-talk:191237].
* math.c (math_log): add optional base argument to Math::log().
[ruby-talk:191308]
* ext/syck/emitter.c (syck_scan_scalar): avoid accessing
uninitialized array element. a patch from Pat Eyler
<rubypate at gmail.com>. [ruby-core:07809]
* array.c (rb_ary_fill): initialize local variables first. a
patch from Pat Eyler <rubypate at gmail.com>. [ruby-core:07810]
* ext/syck/yaml2byte.c (syck_yaml2byte_handler): need to free
type_tag. a patch from Pat Eyler <rubypate at gmail.com>.
[ruby-core:07808]
* ext/socket/socket.c (make_hostent_internal): accept ai_family
check from Sam Roberts <sroberts at uniserve.com>.
[ruby-core:07691]
* util.c (ruby_strtod): should not cut off 18 digits for no
reason. [ruby-core:07796]
* array.c (rb_ary_fill): internalize local variable "beg" to
pacify Coverity. [ruby-core:07770]
* pack.c (pack_unpack): now supports CRLF newlines. a patch from
<tommy at tmtm.org>. [ruby-dev:28601]
* applied code clean-up patch from Stefan Huehner
<stefan at huehner.org>. [ruby-core:07764]
* lib/jcode.rb (String::tr_s): should have translated non
squeezing character sequence (i.e. a character) as well. thanks
to Hiroshi Ichikawa <gimite at gimite.ddo.jp> [ruby-list:42090]
* ext/socket/socket.c: document update patch from Sam Roberts
<sroberts at uniserve.com>. [ruby-core:07701]
* lib/mathn.rb (Integer): need not to remove gcd2. a patch from
NARUSE, Yui <naruse at airemix.com>. [ruby-dev:28570]
* parse.y (arg): too much NEW_LIST()
* eval.c (SETUP_ARGS0): remove unnecessary access to nd_alen.
* eval.c (rb_eval): use ARGSCAT for NODE_OP_ASGN1.
[ruby-dev:28585]
* parse.y (arg): use NODE_ARGSCAT for placeholder.
* lib/getoptlong.rb (GetoptLong::get): RDoc update patch from
mathew <meta at pobox.com>. [ruby-core:07738]
* variable.c (rb_const_set): raise error when no target klass is
supplied. [ruby-dev:28582]
* prec.c (prec_prec_f): documentation patch from
<gerardo.santana at gmail.com>. [ruby-core:07689]
* bignum.c (rb_big_pow): second operand may be too big even if
it's a Fixnum. [ruby-talk:187984]
* README.EXT: update symbol description. [ruby-talk:188104]
* COPYING: explicitly note GPLv2. [ruby-talk:187922]
* parse.y: remove some obsolete syntax rules (unparenthesized
method calls in argument list).
* eval.c (rb_call0): insecure calling should be checked for non
NODE_SCOPE method invocations too.
* eval.c (rb_alias): should preserve the current safe level as
well as method definition.
* process.c (rb_f_sleep): remove RDoc description about SIGALRM
which is not valid on the current implementation. [ruby-dev:28464]
Thu Mar 23 21:40:47 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
* eval.c (method_missing): should support argument splat in
super. a bug in combination of super, splat and
method_missing. [ruby-talk:185438]
* configure.in: Solaris SunPro compiler -rapth patch from
<kuwa at labs.fujitsu.com>. [ruby-dev:28443]
* configure.in: remove enable_rpath=no for Solaris.
[ruby-dev:28440]
* ext/win32ole/win32ole.c (ole_val2olevariantdata): change behavior
of converting OLE Variant object with VT_ARRAY|VT_UI1 and Ruby
String object.
* ruby.1: a clarification patch from David Lutterkort
<dlutter at redhat.com>. [ruby-core:7508]
* lib/rdoc/ri/ri_paths.rb (RI::Paths): adding paths from rubygems
directories. a patch from Eric Hodel <drbrain at segment7.net>.
[ruby-core:07423]
* eval.c (rb_clear_cache_by_class): clearing wrong cache.
* ext/extmk.rb: use :remove_destination to install extension libraries
to avoid SEGV. [ruby-dev:28417]
* eval.c (rb_thread_fd_writable): should not re-schedule output
from KILLED thread (must be error printing).
* array.c (rb_ary_flatten_bang): allow specifying recursion
level. [ruby-talk:182170]
* array.c (rb_ary_flatten): ditto.
* gc.c (add_heap): a heap_slots may overflow. a patch from Stefan
Weil <weil at mail.berlios.de>.
* eval.c (rb_call): use separate cache for fcall/vcall
invocation.
* eval.c (rb_eval): NODE_FCALL, NODE_VCALL can call local
functions.
* eval.c (rb_mod_local): a new method to specify newly added
visibility "local".
* eval.c (search_method): search for local methods which are
visible only from the current class.
* class.c (rb_class_local_methods): a method to list local methods.
* object.c (Init_Object): add BasicObject class as a top level
BlankSlate class.
* ruby.h (SYM2ID): should not cast to signed long.
[ruby-core:07414]
* class.c (rb_include_module): allow module duplication.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-09 17:20:17 -04:00
|
|
|
if (level != 0) {
|
2006-12-31 10:02:22 -05:00
|
|
|
while (i < lim) {
|
|
|
|
VALUE tmp;
|
* sprintf.c (rb_str_format): allow %c to print one character
string (e.g. ?x).
* lib/tempfile.rb (Tempfile::make_tmpname): put dot between
basename and pid. [ruby-talk:196272]
* parse.y (do_block): remove -> style block.
* parse.y (parser_yylex): remove tLAMBDA_ARG.
* eval.c (rb_call0): binding for the return event hook should have
consistent scope. [ruby-core:07928]
* eval.c (proc_invoke): return behavior should depend whether it
is surrounded by a lambda or a mere block.
* eval.c (formal_assign): handles post splat arguments.
* eval.c (rb_call0): ditto.
* st.c (strhash): use FNV-1a hash.
* parse.y (parser_yylex): removed experimental ';;' terminator.
* eval.c (rb_node_arity): should be aware of post splat arguments.
* eval.c (rb_proc_arity): ditto.
* parse.y (f_args): syntax rule enhanced to support arguments
after the splat.
* parse.y (block_param): ditto for block parameters.
* parse.y (f_post_arg): mandatory formal arguments after the splat
argument.
* parse.y (new_args_gen): generate nodes for mandatory formal
arguments after the splat argument.
* eval.c (rb_eval): dispatch mandatory formal arguments after the
splat argument.
* parse.y (args): allow more than one splat in the argument list.
* parse.y (method_call): allow aref [] to accept all kind of
method argument, including assocs, splat, and block argument.
* eval.c (SETUP_ARGS0): prepare block argument as well.
* lib/mathn.rb (Integer): remove Integer#gcd2. [ruby-core:07931]
* eval.c (error_line): print receivers true/false/nil specially.
* eval.c (rb_proc_yield): handles parameters in yield semantics.
* eval.c (nil_yield): gives LocalJumpError to denote no block
error.
* io.c (rb_io_getc): now takes one-character string.
* string.c (rb_str_hash): use FNV-1a hash from Fowler/Noll/Vo
hashing algorithm.
* string.c (rb_str_aref): str[0] now returns 1 character string,
instead of a fixnum. [Ruby2]
* parse.y (parser_yylex): ?c now returns 1 character string,
instead of a fixnum. [Ruby2]
* string.c (rb_str_aset): no longer support fixnum insertion.
* eval.c (umethod_bind): should not update original class.
[ruby-dev:28636]
* eval.c (ev_const_get): should support constant access from
within instance_eval(). [ruby-dev:28327]
* time.c (time_timeval): should round for usec floating
number. [ruby-core:07896]
* time.c (time_add): ditto.
* dir.c (sys_warning): should not call a vararg function
rb_sys_warning() indirectly. [ruby-core:07886]
* numeric.c (flo_divmod): the first element of Float#divmod should
be an integer. [ruby-dev:28589]
* test/ruby/test_float.rb: add tests for divmod, div, modulo and remainder.
* re.c (rb_reg_initialize): should not allow modifying literal
regexps. frozen check moved from rb_reg_initialize_m as well.
* re.c (rb_reg_initialize): should not modify untainted objects in
safe levels higher than 3.
* re.c (rb_memcmp): type change from char* to const void*.
* dir.c (dir_close): should not close untainted dir stream.
* dir.c (GetDIR): add tainted/frozen check for each dir operation.
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_symbol_arg):
typo fixed. a patch from Florian Gross <florg at florg.net>.
* eval.c (EXEC_EVENT_HOOK): trace_func may remove itself from
event_hooks. no guarantee for arbitrary hook deletion.
[ruby-dev:28632]
* util.c (ruby_strtod): differ addition to minimize error.
[ruby-dev:28619]
* util.c (ruby_strtod): should not raise ERANGE when the input
string does not have any digits. [ruby-dev:28629]
* eval.c (proc_invoke): should restore old ruby_frame->block.
thanks to ts <decoux at moulon.inra.fr>. [ruby-core:07833]
also fix [ruby-dev:28614] as well.
* signal.c (trap): sig should be less then NSIG. Coverity found
this bug. a patch from Kevin Tew <tewk at tewk.com>.
[ruby-core:07823]
* math.c (math_log2): add new method inspired by
[ruby-talk:191237].
* math.c (math_log): add optional base argument to Math::log().
[ruby-talk:191308]
* ext/syck/emitter.c (syck_scan_scalar): avoid accessing
uninitialized array element. a patch from Pat Eyler
<rubypate at gmail.com>. [ruby-core:07809]
* array.c (rb_ary_fill): initialize local variables first. a
patch from Pat Eyler <rubypate at gmail.com>. [ruby-core:07810]
* ext/syck/yaml2byte.c (syck_yaml2byte_handler): need to free
type_tag. a patch from Pat Eyler <rubypate at gmail.com>.
[ruby-core:07808]
* ext/socket/socket.c (make_hostent_internal): accept ai_family
check from Sam Roberts <sroberts at uniserve.com>.
[ruby-core:07691]
* util.c (ruby_strtod): should not cut off 18 digits for no
reason. [ruby-core:07796]
* array.c (rb_ary_fill): internalize local variable "beg" to
pacify Coverity. [ruby-core:07770]
* pack.c (pack_unpack): now supports CRLF newlines. a patch from
<tommy at tmtm.org>. [ruby-dev:28601]
* applied code clean-up patch from Stefan Huehner
<stefan at huehner.org>. [ruby-core:07764]
* lib/jcode.rb (String::tr_s): should have translated non
squeezing character sequence (i.e. a character) as well. thanks
to Hiroshi Ichikawa <gimite at gimite.ddo.jp> [ruby-list:42090]
* ext/socket/socket.c: document update patch from Sam Roberts
<sroberts at uniserve.com>. [ruby-core:07701]
* lib/mathn.rb (Integer): need not to remove gcd2. a patch from
NARUSE, Yui <naruse at airemix.com>. [ruby-dev:28570]
* parse.y (arg): too much NEW_LIST()
* eval.c (SETUP_ARGS0): remove unnecessary access to nd_alen.
* eval.c (rb_eval): use ARGSCAT for NODE_OP_ASGN1.
[ruby-dev:28585]
* parse.y (arg): use NODE_ARGSCAT for placeholder.
* lib/getoptlong.rb (GetoptLong::get): RDoc update patch from
mathew <meta at pobox.com>. [ruby-core:07738]
* variable.c (rb_const_set): raise error when no target klass is
supplied. [ruby-dev:28582]
* prec.c (prec_prec_f): documentation patch from
<gerardo.santana at gmail.com>. [ruby-core:07689]
* bignum.c (rb_big_pow): second operand may be too big even if
it's a Fixnum. [ruby-talk:187984]
* README.EXT: update symbol description. [ruby-talk:188104]
* COPYING: explicitly note GPLv2. [ruby-talk:187922]
* parse.y: remove some obsolete syntax rules (unparenthesized
method calls in argument list).
* eval.c (rb_call0): insecure calling should be checked for non
NODE_SCOPE method invocations too.
* eval.c (rb_alias): should preserve the current safe level as
well as method definition.
* process.c (rb_f_sleep): remove RDoc description about SIGALRM
which is not valid on the current implementation. [ruby-dev:28464]
Thu Mar 23 21:40:47 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
* eval.c (method_missing): should support argument splat in
super. a bug in combination of super, splat and
method_missing. [ruby-talk:185438]
* configure.in: Solaris SunPro compiler -rapth patch from
<kuwa at labs.fujitsu.com>. [ruby-dev:28443]
* configure.in: remove enable_rpath=no for Solaris.
[ruby-dev:28440]
* ext/win32ole/win32ole.c (ole_val2olevariantdata): change behavior
of converting OLE Variant object with VT_ARRAY|VT_UI1 and Ruby
String object.
* ruby.1: a clarification patch from David Lutterkort
<dlutter at redhat.com>. [ruby-core:7508]
* lib/rdoc/ri/ri_paths.rb (RI::Paths): adding paths from rubygems
directories. a patch from Eric Hodel <drbrain at segment7.net>.
[ruby-core:07423]
* eval.c (rb_clear_cache_by_class): clearing wrong cache.
* ext/extmk.rb: use :remove_destination to install extension libraries
to avoid SEGV. [ruby-dev:28417]
* eval.c (rb_thread_fd_writable): should not re-schedule output
from KILLED thread (must be error printing).
* array.c (rb_ary_flatten_bang): allow specifying recursion
level. [ruby-talk:182170]
* array.c (rb_ary_flatten): ditto.
* gc.c (add_heap): a heap_slots may overflow. a patch from Stefan
Weil <weil at mail.berlios.de>.
* eval.c (rb_call): use separate cache for fcall/vcall
invocation.
* eval.c (rb_eval): NODE_FCALL, NODE_VCALL can call local
functions.
* eval.c (rb_mod_local): a new method to specify newly added
visibility "local".
* eval.c (search_method): search for local methods which are
visible only from the current class.
* class.c (rb_class_local_methods): a method to list local methods.
* object.c (Init_Object): add BasicObject class as a top level
BlankSlate class.
* ruby.h (SYM2ID): should not cast to signed long.
[ruby-core:07414]
* class.c (rb_include_module): allow module duplication.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-09 17:20:17 -04:00
|
|
|
|
2006-12-31 10:02:22 -05:00
|
|
|
tmp = rb_check_array_type(rb_ary_elt(ary, i));
|
|
|
|
if (!NIL_P(tmp)) {
|
* sprintf.c (rb_str_format): allow %c to print one character
string (e.g. ?x).
* lib/tempfile.rb (Tempfile::make_tmpname): put dot between
basename and pid. [ruby-talk:196272]
* parse.y (do_block): remove -> style block.
* parse.y (parser_yylex): remove tLAMBDA_ARG.
* eval.c (rb_call0): binding for the return event hook should have
consistent scope. [ruby-core:07928]
* eval.c (proc_invoke): return behavior should depend whether it
is surrounded by a lambda or a mere block.
* eval.c (formal_assign): handles post splat arguments.
* eval.c (rb_call0): ditto.
* st.c (strhash): use FNV-1a hash.
* parse.y (parser_yylex): removed experimental ';;' terminator.
* eval.c (rb_node_arity): should be aware of post splat arguments.
* eval.c (rb_proc_arity): ditto.
* parse.y (f_args): syntax rule enhanced to support arguments
after the splat.
* parse.y (block_param): ditto for block parameters.
* parse.y (f_post_arg): mandatory formal arguments after the splat
argument.
* parse.y (new_args_gen): generate nodes for mandatory formal
arguments after the splat argument.
* eval.c (rb_eval): dispatch mandatory formal arguments after the
splat argument.
* parse.y (args): allow more than one splat in the argument list.
* parse.y (method_call): allow aref [] to accept all kind of
method argument, including assocs, splat, and block argument.
* eval.c (SETUP_ARGS0): prepare block argument as well.
* lib/mathn.rb (Integer): remove Integer#gcd2. [ruby-core:07931]
* eval.c (error_line): print receivers true/false/nil specially.
* eval.c (rb_proc_yield): handles parameters in yield semantics.
* eval.c (nil_yield): gives LocalJumpError to denote no block
error.
* io.c (rb_io_getc): now takes one-character string.
* string.c (rb_str_hash): use FNV-1a hash from Fowler/Noll/Vo
hashing algorithm.
* string.c (rb_str_aref): str[0] now returns 1 character string,
instead of a fixnum. [Ruby2]
* parse.y (parser_yylex): ?c now returns 1 character string,
instead of a fixnum. [Ruby2]
* string.c (rb_str_aset): no longer support fixnum insertion.
* eval.c (umethod_bind): should not update original class.
[ruby-dev:28636]
* eval.c (ev_const_get): should support constant access from
within instance_eval(). [ruby-dev:28327]
* time.c (time_timeval): should round for usec floating
number. [ruby-core:07896]
* time.c (time_add): ditto.
* dir.c (sys_warning): should not call a vararg function
rb_sys_warning() indirectly. [ruby-core:07886]
* numeric.c (flo_divmod): the first element of Float#divmod should
be an integer. [ruby-dev:28589]
* test/ruby/test_float.rb: add tests for divmod, div, modulo and remainder.
* re.c (rb_reg_initialize): should not allow modifying literal
regexps. frozen check moved from rb_reg_initialize_m as well.
* re.c (rb_reg_initialize): should not modify untainted objects in
safe levels higher than 3.
* re.c (rb_memcmp): type change from char* to const void*.
* dir.c (dir_close): should not close untainted dir stream.
* dir.c (GetDIR): add tainted/frozen check for each dir operation.
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_symbol_arg):
typo fixed. a patch from Florian Gross <florg at florg.net>.
* eval.c (EXEC_EVENT_HOOK): trace_func may remove itself from
event_hooks. no guarantee for arbitrary hook deletion.
[ruby-dev:28632]
* util.c (ruby_strtod): differ addition to minimize error.
[ruby-dev:28619]
* util.c (ruby_strtod): should not raise ERANGE when the input
string does not have any digits. [ruby-dev:28629]
* eval.c (proc_invoke): should restore old ruby_frame->block.
thanks to ts <decoux at moulon.inra.fr>. [ruby-core:07833]
also fix [ruby-dev:28614] as well.
* signal.c (trap): sig should be less then NSIG. Coverity found
this bug. a patch from Kevin Tew <tewk at tewk.com>.
[ruby-core:07823]
* math.c (math_log2): add new method inspired by
[ruby-talk:191237].
* math.c (math_log): add optional base argument to Math::log().
[ruby-talk:191308]
* ext/syck/emitter.c (syck_scan_scalar): avoid accessing
uninitialized array element. a patch from Pat Eyler
<rubypate at gmail.com>. [ruby-core:07809]
* array.c (rb_ary_fill): initialize local variables first. a
patch from Pat Eyler <rubypate at gmail.com>. [ruby-core:07810]
* ext/syck/yaml2byte.c (syck_yaml2byte_handler): need to free
type_tag. a patch from Pat Eyler <rubypate at gmail.com>.
[ruby-core:07808]
* ext/socket/socket.c (make_hostent_internal): accept ai_family
check from Sam Roberts <sroberts at uniserve.com>.
[ruby-core:07691]
* util.c (ruby_strtod): should not cut off 18 digits for no
reason. [ruby-core:07796]
* array.c (rb_ary_fill): internalize local variable "beg" to
pacify Coverity. [ruby-core:07770]
* pack.c (pack_unpack): now supports CRLF newlines. a patch from
<tommy at tmtm.org>. [ruby-dev:28601]
* applied code clean-up patch from Stefan Huehner
<stefan at huehner.org>. [ruby-core:07764]
* lib/jcode.rb (String::tr_s): should have translated non
squeezing character sequence (i.e. a character) as well. thanks
to Hiroshi Ichikawa <gimite at gimite.ddo.jp> [ruby-list:42090]
* ext/socket/socket.c: document update patch from Sam Roberts
<sroberts at uniserve.com>. [ruby-core:07701]
* lib/mathn.rb (Integer): need not to remove gcd2. a patch from
NARUSE, Yui <naruse at airemix.com>. [ruby-dev:28570]
* parse.y (arg): too much NEW_LIST()
* eval.c (SETUP_ARGS0): remove unnecessary access to nd_alen.
* eval.c (rb_eval): use ARGSCAT for NODE_OP_ASGN1.
[ruby-dev:28585]
* parse.y (arg): use NODE_ARGSCAT for placeholder.
* lib/getoptlong.rb (GetoptLong::get): RDoc update patch from
mathew <meta at pobox.com>. [ruby-core:07738]
* variable.c (rb_const_set): raise error when no target klass is
supplied. [ruby-dev:28582]
* prec.c (prec_prec_f): documentation patch from
<gerardo.santana at gmail.com>. [ruby-core:07689]
* bignum.c (rb_big_pow): second operand may be too big even if
it's a Fixnum. [ruby-talk:187984]
* README.EXT: update symbol description. [ruby-talk:188104]
* COPYING: explicitly note GPLv2. [ruby-talk:187922]
* parse.y: remove some obsolete syntax rules (unparenthesized
method calls in argument list).
* eval.c (rb_call0): insecure calling should be checked for non
NODE_SCOPE method invocations too.
* eval.c (rb_alias): should preserve the current safe level as
well as method definition.
* process.c (rb_f_sleep): remove RDoc description about SIGALRM
which is not valid on the current implementation. [ruby-dev:28464]
Thu Mar 23 21:40:47 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
* eval.c (method_missing): should support argument splat in
super. a bug in combination of super, splat and
method_missing. [ruby-talk:185438]
* configure.in: Solaris SunPro compiler -rapth patch from
<kuwa at labs.fujitsu.com>. [ruby-dev:28443]
* configure.in: remove enable_rpath=no for Solaris.
[ruby-dev:28440]
* ext/win32ole/win32ole.c (ole_val2olevariantdata): change behavior
of converting OLE Variant object with VT_ARRAY|VT_UI1 and Ruby
String object.
* ruby.1: a clarification patch from David Lutterkort
<dlutter at redhat.com>. [ruby-core:7508]
* lib/rdoc/ri/ri_paths.rb (RI::Paths): adding paths from rubygems
directories. a patch from Eric Hodel <drbrain at segment7.net>.
[ruby-core:07423]
* eval.c (rb_clear_cache_by_class): clearing wrong cache.
* ext/extmk.rb: use :remove_destination to install extension libraries
to avoid SEGV. [ruby-dev:28417]
* eval.c (rb_thread_fd_writable): should not re-schedule output
from KILLED thread (must be error printing).
* array.c (rb_ary_flatten_bang): allow specifying recursion
level. [ruby-talk:182170]
* array.c (rb_ary_flatten): ditto.
* gc.c (add_heap): a heap_slots may overflow. a patch from Stefan
Weil <weil at mail.berlios.de>.
* eval.c (rb_call): use separate cache for fcall/vcall
invocation.
* eval.c (rb_eval): NODE_FCALL, NODE_VCALL can call local
functions.
* eval.c (rb_mod_local): a new method to specify newly added
visibility "local".
* eval.c (search_method): search for local methods which are
visible only from the current class.
* class.c (rb_class_local_methods): a method to list local methods.
* object.c (Init_Object): add BasicObject class as a top level
BlankSlate class.
* ruby.h (SYM2ID): should not cast to signed long.
[ruby-core:07414]
* class.c (rb_include_module): allow module duplication.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-09 17:20:17 -04:00
|
|
|
n = flatten(ary, i, tmp, memo, level);
|
2006-12-31 10:02:22 -05:00
|
|
|
i += n; lim += n;
|
2001-05-02 00:22:21 -04:00
|
|
|
}
|
2006-12-31 10:02:22 -05:00
|
|
|
i++;
|
|
|
|
}
|
2001-05-02 00:22:21 -04:00
|
|
|
}
|
|
|
|
rb_ary_pop(memo);
|
|
|
|
|
|
|
|
return lim - idx - 1; /* returns number of increased items */
|
|
|
|
}
|
|
|
|
|
2003-12-16 15:28:44 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
2006-12-31 10:02:22 -05:00
|
|
|
* array.flatten! -> array or nil
|
* sprintf.c (rb_str_format): allow %c to print one character
string (e.g. ?x).
* lib/tempfile.rb (Tempfile::make_tmpname): put dot between
basename and pid. [ruby-talk:196272]
* parse.y (do_block): remove -> style block.
* parse.y (parser_yylex): remove tLAMBDA_ARG.
* eval.c (rb_call0): binding for the return event hook should have
consistent scope. [ruby-core:07928]
* eval.c (proc_invoke): return behavior should depend whether it
is surrounded by a lambda or a mere block.
* eval.c (formal_assign): handles post splat arguments.
* eval.c (rb_call0): ditto.
* st.c (strhash): use FNV-1a hash.
* parse.y (parser_yylex): removed experimental ';;' terminator.
* eval.c (rb_node_arity): should be aware of post splat arguments.
* eval.c (rb_proc_arity): ditto.
* parse.y (f_args): syntax rule enhanced to support arguments
after the splat.
* parse.y (block_param): ditto for block parameters.
* parse.y (f_post_arg): mandatory formal arguments after the splat
argument.
* parse.y (new_args_gen): generate nodes for mandatory formal
arguments after the splat argument.
* eval.c (rb_eval): dispatch mandatory formal arguments after the
splat argument.
* parse.y (args): allow more than one splat in the argument list.
* parse.y (method_call): allow aref [] to accept all kind of
method argument, including assocs, splat, and block argument.
* eval.c (SETUP_ARGS0): prepare block argument as well.
* lib/mathn.rb (Integer): remove Integer#gcd2. [ruby-core:07931]
* eval.c (error_line): print receivers true/false/nil specially.
* eval.c (rb_proc_yield): handles parameters in yield semantics.
* eval.c (nil_yield): gives LocalJumpError to denote no block
error.
* io.c (rb_io_getc): now takes one-character string.
* string.c (rb_str_hash): use FNV-1a hash from Fowler/Noll/Vo
hashing algorithm.
* string.c (rb_str_aref): str[0] now returns 1 character string,
instead of a fixnum. [Ruby2]
* parse.y (parser_yylex): ?c now returns 1 character string,
instead of a fixnum. [Ruby2]
* string.c (rb_str_aset): no longer support fixnum insertion.
* eval.c (umethod_bind): should not update original class.
[ruby-dev:28636]
* eval.c (ev_const_get): should support constant access from
within instance_eval(). [ruby-dev:28327]
* time.c (time_timeval): should round for usec floating
number. [ruby-core:07896]
* time.c (time_add): ditto.
* dir.c (sys_warning): should not call a vararg function
rb_sys_warning() indirectly. [ruby-core:07886]
* numeric.c (flo_divmod): the first element of Float#divmod should
be an integer. [ruby-dev:28589]
* test/ruby/test_float.rb: add tests for divmod, div, modulo and remainder.
* re.c (rb_reg_initialize): should not allow modifying literal
regexps. frozen check moved from rb_reg_initialize_m as well.
* re.c (rb_reg_initialize): should not modify untainted objects in
safe levels higher than 3.
* re.c (rb_memcmp): type change from char* to const void*.
* dir.c (dir_close): should not close untainted dir stream.
* dir.c (GetDIR): add tainted/frozen check for each dir operation.
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_symbol_arg):
typo fixed. a patch from Florian Gross <florg at florg.net>.
* eval.c (EXEC_EVENT_HOOK): trace_func may remove itself from
event_hooks. no guarantee for arbitrary hook deletion.
[ruby-dev:28632]
* util.c (ruby_strtod): differ addition to minimize error.
[ruby-dev:28619]
* util.c (ruby_strtod): should not raise ERANGE when the input
string does not have any digits. [ruby-dev:28629]
* eval.c (proc_invoke): should restore old ruby_frame->block.
thanks to ts <decoux at moulon.inra.fr>. [ruby-core:07833]
also fix [ruby-dev:28614] as well.
* signal.c (trap): sig should be less then NSIG. Coverity found
this bug. a patch from Kevin Tew <tewk at tewk.com>.
[ruby-core:07823]
* math.c (math_log2): add new method inspired by
[ruby-talk:191237].
* math.c (math_log): add optional base argument to Math::log().
[ruby-talk:191308]
* ext/syck/emitter.c (syck_scan_scalar): avoid accessing
uninitialized array element. a patch from Pat Eyler
<rubypate at gmail.com>. [ruby-core:07809]
* array.c (rb_ary_fill): initialize local variables first. a
patch from Pat Eyler <rubypate at gmail.com>. [ruby-core:07810]
* ext/syck/yaml2byte.c (syck_yaml2byte_handler): need to free
type_tag. a patch from Pat Eyler <rubypate at gmail.com>.
[ruby-core:07808]
* ext/socket/socket.c (make_hostent_internal): accept ai_family
check from Sam Roberts <sroberts at uniserve.com>.
[ruby-core:07691]
* util.c (ruby_strtod): should not cut off 18 digits for no
reason. [ruby-core:07796]
* array.c (rb_ary_fill): internalize local variable "beg" to
pacify Coverity. [ruby-core:07770]
* pack.c (pack_unpack): now supports CRLF newlines. a patch from
<tommy at tmtm.org>. [ruby-dev:28601]
* applied code clean-up patch from Stefan Huehner
<stefan at huehner.org>. [ruby-core:07764]
* lib/jcode.rb (String::tr_s): should have translated non
squeezing character sequence (i.e. a character) as well. thanks
to Hiroshi Ichikawa <gimite at gimite.ddo.jp> [ruby-list:42090]
* ext/socket/socket.c: document update patch from Sam Roberts
<sroberts at uniserve.com>. [ruby-core:07701]
* lib/mathn.rb (Integer): need not to remove gcd2. a patch from
NARUSE, Yui <naruse at airemix.com>. [ruby-dev:28570]
* parse.y (arg): too much NEW_LIST()
* eval.c (SETUP_ARGS0): remove unnecessary access to nd_alen.
* eval.c (rb_eval): use ARGSCAT for NODE_OP_ASGN1.
[ruby-dev:28585]
* parse.y (arg): use NODE_ARGSCAT for placeholder.
* lib/getoptlong.rb (GetoptLong::get): RDoc update patch from
mathew <meta at pobox.com>. [ruby-core:07738]
* variable.c (rb_const_set): raise error when no target klass is
supplied. [ruby-dev:28582]
* prec.c (prec_prec_f): documentation patch from
<gerardo.santana at gmail.com>. [ruby-core:07689]
* bignum.c (rb_big_pow): second operand may be too big even if
it's a Fixnum. [ruby-talk:187984]
* README.EXT: update symbol description. [ruby-talk:188104]
* COPYING: explicitly note GPLv2. [ruby-talk:187922]
* parse.y: remove some obsolete syntax rules (unparenthesized
method calls in argument list).
* eval.c (rb_call0): insecure calling should be checked for non
NODE_SCOPE method invocations too.
* eval.c (rb_alias): should preserve the current safe level as
well as method definition.
* process.c (rb_f_sleep): remove RDoc description about SIGALRM
which is not valid on the current implementation. [ruby-dev:28464]
Thu Mar 23 21:40:47 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
* eval.c (method_missing): should support argument splat in
super. a bug in combination of super, splat and
method_missing. [ruby-talk:185438]
* configure.in: Solaris SunPro compiler -rapth patch from
<kuwa at labs.fujitsu.com>. [ruby-dev:28443]
* configure.in: remove enable_rpath=no for Solaris.
[ruby-dev:28440]
* ext/win32ole/win32ole.c (ole_val2olevariantdata): change behavior
of converting OLE Variant object with VT_ARRAY|VT_UI1 and Ruby
String object.
* ruby.1: a clarification patch from David Lutterkort
<dlutter at redhat.com>. [ruby-core:7508]
* lib/rdoc/ri/ri_paths.rb (RI::Paths): adding paths from rubygems
directories. a patch from Eric Hodel <drbrain at segment7.net>.
[ruby-core:07423]
* eval.c (rb_clear_cache_by_class): clearing wrong cache.
* ext/extmk.rb: use :remove_destination to install extension libraries
to avoid SEGV. [ruby-dev:28417]
* eval.c (rb_thread_fd_writable): should not re-schedule output
from KILLED thread (must be error printing).
* array.c (rb_ary_flatten_bang): allow specifying recursion
level. [ruby-talk:182170]
* array.c (rb_ary_flatten): ditto.
* gc.c (add_heap): a heap_slots may overflow. a patch from Stefan
Weil <weil at mail.berlios.de>.
* eval.c (rb_call): use separate cache for fcall/vcall
invocation.
* eval.c (rb_eval): NODE_FCALL, NODE_VCALL can call local
functions.
* eval.c (rb_mod_local): a new method to specify newly added
visibility "local".
* eval.c (search_method): search for local methods which are
visible only from the current class.
* class.c (rb_class_local_methods): a method to list local methods.
* object.c (Init_Object): add BasicObject class as a top level
BlankSlate class.
* ruby.h (SYM2ID): should not cast to signed long.
[ruby-core:07414]
* class.c (rb_include_module): allow module duplication.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-09 17:20:17 -04:00
|
|
|
* array.flatten!(level) -> array or nil
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
|
|
|
* Flattens _self_ in place.
|
|
|
|
* Returns <code>nil</code> if no modifications were made (i.e.,
|
* sprintf.c (rb_str_format): allow %c to print one character
string (e.g. ?x).
* lib/tempfile.rb (Tempfile::make_tmpname): put dot between
basename and pid. [ruby-talk:196272]
* parse.y (do_block): remove -> style block.
* parse.y (parser_yylex): remove tLAMBDA_ARG.
* eval.c (rb_call0): binding for the return event hook should have
consistent scope. [ruby-core:07928]
* eval.c (proc_invoke): return behavior should depend whether it
is surrounded by a lambda or a mere block.
* eval.c (formal_assign): handles post splat arguments.
* eval.c (rb_call0): ditto.
* st.c (strhash): use FNV-1a hash.
* parse.y (parser_yylex): removed experimental ';;' terminator.
* eval.c (rb_node_arity): should be aware of post splat arguments.
* eval.c (rb_proc_arity): ditto.
* parse.y (f_args): syntax rule enhanced to support arguments
after the splat.
* parse.y (block_param): ditto for block parameters.
* parse.y (f_post_arg): mandatory formal arguments after the splat
argument.
* parse.y (new_args_gen): generate nodes for mandatory formal
arguments after the splat argument.
* eval.c (rb_eval): dispatch mandatory formal arguments after the
splat argument.
* parse.y (args): allow more than one splat in the argument list.
* parse.y (method_call): allow aref [] to accept all kind of
method argument, including assocs, splat, and block argument.
* eval.c (SETUP_ARGS0): prepare block argument as well.
* lib/mathn.rb (Integer): remove Integer#gcd2. [ruby-core:07931]
* eval.c (error_line): print receivers true/false/nil specially.
* eval.c (rb_proc_yield): handles parameters in yield semantics.
* eval.c (nil_yield): gives LocalJumpError to denote no block
error.
* io.c (rb_io_getc): now takes one-character string.
* string.c (rb_str_hash): use FNV-1a hash from Fowler/Noll/Vo
hashing algorithm.
* string.c (rb_str_aref): str[0] now returns 1 character string,
instead of a fixnum. [Ruby2]
* parse.y (parser_yylex): ?c now returns 1 character string,
instead of a fixnum. [Ruby2]
* string.c (rb_str_aset): no longer support fixnum insertion.
* eval.c (umethod_bind): should not update original class.
[ruby-dev:28636]
* eval.c (ev_const_get): should support constant access from
within instance_eval(). [ruby-dev:28327]
* time.c (time_timeval): should round for usec floating
number. [ruby-core:07896]
* time.c (time_add): ditto.
* dir.c (sys_warning): should not call a vararg function
rb_sys_warning() indirectly. [ruby-core:07886]
* numeric.c (flo_divmod): the first element of Float#divmod should
be an integer. [ruby-dev:28589]
* test/ruby/test_float.rb: add tests for divmod, div, modulo and remainder.
* re.c (rb_reg_initialize): should not allow modifying literal
regexps. frozen check moved from rb_reg_initialize_m as well.
* re.c (rb_reg_initialize): should not modify untainted objects in
safe levels higher than 3.
* re.c (rb_memcmp): type change from char* to const void*.
* dir.c (dir_close): should not close untainted dir stream.
* dir.c (GetDIR): add tainted/frozen check for each dir operation.
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_symbol_arg):
typo fixed. a patch from Florian Gross <florg at florg.net>.
* eval.c (EXEC_EVENT_HOOK): trace_func may remove itself from
event_hooks. no guarantee for arbitrary hook deletion.
[ruby-dev:28632]
* util.c (ruby_strtod): differ addition to minimize error.
[ruby-dev:28619]
* util.c (ruby_strtod): should not raise ERANGE when the input
string does not have any digits. [ruby-dev:28629]
* eval.c (proc_invoke): should restore old ruby_frame->block.
thanks to ts <decoux at moulon.inra.fr>. [ruby-core:07833]
also fix [ruby-dev:28614] as well.
* signal.c (trap): sig should be less then NSIG. Coverity found
this bug. a patch from Kevin Tew <tewk at tewk.com>.
[ruby-core:07823]
* math.c (math_log2): add new method inspired by
[ruby-talk:191237].
* math.c (math_log): add optional base argument to Math::log().
[ruby-talk:191308]
* ext/syck/emitter.c (syck_scan_scalar): avoid accessing
uninitialized array element. a patch from Pat Eyler
<rubypate at gmail.com>. [ruby-core:07809]
* array.c (rb_ary_fill): initialize local variables first. a
patch from Pat Eyler <rubypate at gmail.com>. [ruby-core:07810]
* ext/syck/yaml2byte.c (syck_yaml2byte_handler): need to free
type_tag. a patch from Pat Eyler <rubypate at gmail.com>.
[ruby-core:07808]
* ext/socket/socket.c (make_hostent_internal): accept ai_family
check from Sam Roberts <sroberts at uniserve.com>.
[ruby-core:07691]
* util.c (ruby_strtod): should not cut off 18 digits for no
reason. [ruby-core:07796]
* array.c (rb_ary_fill): internalize local variable "beg" to
pacify Coverity. [ruby-core:07770]
* pack.c (pack_unpack): now supports CRLF newlines. a patch from
<tommy at tmtm.org>. [ruby-dev:28601]
* applied code clean-up patch from Stefan Huehner
<stefan at huehner.org>. [ruby-core:07764]
* lib/jcode.rb (String::tr_s): should have translated non
squeezing character sequence (i.e. a character) as well. thanks
to Hiroshi Ichikawa <gimite at gimite.ddo.jp> [ruby-list:42090]
* ext/socket/socket.c: document update patch from Sam Roberts
<sroberts at uniserve.com>. [ruby-core:07701]
* lib/mathn.rb (Integer): need not to remove gcd2. a patch from
NARUSE, Yui <naruse at airemix.com>. [ruby-dev:28570]
* parse.y (arg): too much NEW_LIST()
* eval.c (SETUP_ARGS0): remove unnecessary access to nd_alen.
* eval.c (rb_eval): use ARGSCAT for NODE_OP_ASGN1.
[ruby-dev:28585]
* parse.y (arg): use NODE_ARGSCAT for placeholder.
* lib/getoptlong.rb (GetoptLong::get): RDoc update patch from
mathew <meta at pobox.com>. [ruby-core:07738]
* variable.c (rb_const_set): raise error when no target klass is
supplied. [ruby-dev:28582]
* prec.c (prec_prec_f): documentation patch from
<gerardo.santana at gmail.com>. [ruby-core:07689]
* bignum.c (rb_big_pow): second operand may be too big even if
it's a Fixnum. [ruby-talk:187984]
* README.EXT: update symbol description. [ruby-talk:188104]
* COPYING: explicitly note GPLv2. [ruby-talk:187922]
* parse.y: remove some obsolete syntax rules (unparenthesized
method calls in argument list).
* eval.c (rb_call0): insecure calling should be checked for non
NODE_SCOPE method invocations too.
* eval.c (rb_alias): should preserve the current safe level as
well as method definition.
* process.c (rb_f_sleep): remove RDoc description about SIGALRM
which is not valid on the current implementation. [ruby-dev:28464]
Thu Mar 23 21:40:47 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
* eval.c (method_missing): should support argument splat in
super. a bug in combination of super, splat and
method_missing. [ruby-talk:185438]
* configure.in: Solaris SunPro compiler -rapth patch from
<kuwa at labs.fujitsu.com>. [ruby-dev:28443]
* configure.in: remove enable_rpath=no for Solaris.
[ruby-dev:28440]
* ext/win32ole/win32ole.c (ole_val2olevariantdata): change behavior
of converting OLE Variant object with VT_ARRAY|VT_UI1 and Ruby
String object.
* ruby.1: a clarification patch from David Lutterkort
<dlutter at redhat.com>. [ruby-core:7508]
* lib/rdoc/ri/ri_paths.rb (RI::Paths): adding paths from rubygems
directories. a patch from Eric Hodel <drbrain at segment7.net>.
[ruby-core:07423]
* eval.c (rb_clear_cache_by_class): clearing wrong cache.
* ext/extmk.rb: use :remove_destination to install extension libraries
to avoid SEGV. [ruby-dev:28417]
* eval.c (rb_thread_fd_writable): should not re-schedule output
from KILLED thread (must be error printing).
* array.c (rb_ary_flatten_bang): allow specifying recursion
level. [ruby-talk:182170]
* array.c (rb_ary_flatten): ditto.
* gc.c (add_heap): a heap_slots may overflow. a patch from Stefan
Weil <weil at mail.berlios.de>.
* eval.c (rb_call): use separate cache for fcall/vcall
invocation.
* eval.c (rb_eval): NODE_FCALL, NODE_VCALL can call local
functions.
* eval.c (rb_mod_local): a new method to specify newly added
visibility "local".
* eval.c (search_method): search for local methods which are
visible only from the current class.
* class.c (rb_class_local_methods): a method to list local methods.
* object.c (Init_Object): add BasicObject class as a top level
BlankSlate class.
* ruby.h (SYM2ID): should not cast to signed long.
[ruby-core:07414]
* class.c (rb_include_module): allow module duplication.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-09 17:20:17 -04:00
|
|
|
* <i>array</i> contains no subarrays.) If the optional <i>level</i>
|
|
|
|
* argument determins the level of recursion to flatten.
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
|
|
|
* a = [ 1, 2, [3, [4, 5] ] ]
|
2006-12-31 10:02:22 -05:00
|
|
|
* a.flatten! #=> [1, 2, 3, 4, 5]
|
|
|
|
* a.flatten! #=> nil
|
|
|
|
* a #=> [1, 2, 3, 4, 5]
|
* sprintf.c (rb_str_format): allow %c to print one character
string (e.g. ?x).
* lib/tempfile.rb (Tempfile::make_tmpname): put dot between
basename and pid. [ruby-talk:196272]
* parse.y (do_block): remove -> style block.
* parse.y (parser_yylex): remove tLAMBDA_ARG.
* eval.c (rb_call0): binding for the return event hook should have
consistent scope. [ruby-core:07928]
* eval.c (proc_invoke): return behavior should depend whether it
is surrounded by a lambda or a mere block.
* eval.c (formal_assign): handles post splat arguments.
* eval.c (rb_call0): ditto.
* st.c (strhash): use FNV-1a hash.
* parse.y (parser_yylex): removed experimental ';;' terminator.
* eval.c (rb_node_arity): should be aware of post splat arguments.
* eval.c (rb_proc_arity): ditto.
* parse.y (f_args): syntax rule enhanced to support arguments
after the splat.
* parse.y (block_param): ditto for block parameters.
* parse.y (f_post_arg): mandatory formal arguments after the splat
argument.
* parse.y (new_args_gen): generate nodes for mandatory formal
arguments after the splat argument.
* eval.c (rb_eval): dispatch mandatory formal arguments after the
splat argument.
* parse.y (args): allow more than one splat in the argument list.
* parse.y (method_call): allow aref [] to accept all kind of
method argument, including assocs, splat, and block argument.
* eval.c (SETUP_ARGS0): prepare block argument as well.
* lib/mathn.rb (Integer): remove Integer#gcd2. [ruby-core:07931]
* eval.c (error_line): print receivers true/false/nil specially.
* eval.c (rb_proc_yield): handles parameters in yield semantics.
* eval.c (nil_yield): gives LocalJumpError to denote no block
error.
* io.c (rb_io_getc): now takes one-character string.
* string.c (rb_str_hash): use FNV-1a hash from Fowler/Noll/Vo
hashing algorithm.
* string.c (rb_str_aref): str[0] now returns 1 character string,
instead of a fixnum. [Ruby2]
* parse.y (parser_yylex): ?c now returns 1 character string,
instead of a fixnum. [Ruby2]
* string.c (rb_str_aset): no longer support fixnum insertion.
* eval.c (umethod_bind): should not update original class.
[ruby-dev:28636]
* eval.c (ev_const_get): should support constant access from
within instance_eval(). [ruby-dev:28327]
* time.c (time_timeval): should round for usec floating
number. [ruby-core:07896]
* time.c (time_add): ditto.
* dir.c (sys_warning): should not call a vararg function
rb_sys_warning() indirectly. [ruby-core:07886]
* numeric.c (flo_divmod): the first element of Float#divmod should
be an integer. [ruby-dev:28589]
* test/ruby/test_float.rb: add tests for divmod, div, modulo and remainder.
* re.c (rb_reg_initialize): should not allow modifying literal
regexps. frozen check moved from rb_reg_initialize_m as well.
* re.c (rb_reg_initialize): should not modify untainted objects in
safe levels higher than 3.
* re.c (rb_memcmp): type change from char* to const void*.
* dir.c (dir_close): should not close untainted dir stream.
* dir.c (GetDIR): add tainted/frozen check for each dir operation.
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_symbol_arg):
typo fixed. a patch from Florian Gross <florg at florg.net>.
* eval.c (EXEC_EVENT_HOOK): trace_func may remove itself from
event_hooks. no guarantee for arbitrary hook deletion.
[ruby-dev:28632]
* util.c (ruby_strtod): differ addition to minimize error.
[ruby-dev:28619]
* util.c (ruby_strtod): should not raise ERANGE when the input
string does not have any digits. [ruby-dev:28629]
* eval.c (proc_invoke): should restore old ruby_frame->block.
thanks to ts <decoux at moulon.inra.fr>. [ruby-core:07833]
also fix [ruby-dev:28614] as well.
* signal.c (trap): sig should be less then NSIG. Coverity found
this bug. a patch from Kevin Tew <tewk at tewk.com>.
[ruby-core:07823]
* math.c (math_log2): add new method inspired by
[ruby-talk:191237].
* math.c (math_log): add optional base argument to Math::log().
[ruby-talk:191308]
* ext/syck/emitter.c (syck_scan_scalar): avoid accessing
uninitialized array element. a patch from Pat Eyler
<rubypate at gmail.com>. [ruby-core:07809]
* array.c (rb_ary_fill): initialize local variables first. a
patch from Pat Eyler <rubypate at gmail.com>. [ruby-core:07810]
* ext/syck/yaml2byte.c (syck_yaml2byte_handler): need to free
type_tag. a patch from Pat Eyler <rubypate at gmail.com>.
[ruby-core:07808]
* ext/socket/socket.c (make_hostent_internal): accept ai_family
check from Sam Roberts <sroberts at uniserve.com>.
[ruby-core:07691]
* util.c (ruby_strtod): should not cut off 18 digits for no
reason. [ruby-core:07796]
* array.c (rb_ary_fill): internalize local variable "beg" to
pacify Coverity. [ruby-core:07770]
* pack.c (pack_unpack): now supports CRLF newlines. a patch from
<tommy at tmtm.org>. [ruby-dev:28601]
* applied code clean-up patch from Stefan Huehner
<stefan at huehner.org>. [ruby-core:07764]
* lib/jcode.rb (String::tr_s): should have translated non
squeezing character sequence (i.e. a character) as well. thanks
to Hiroshi Ichikawa <gimite at gimite.ddo.jp> [ruby-list:42090]
* ext/socket/socket.c: document update patch from Sam Roberts
<sroberts at uniserve.com>. [ruby-core:07701]
* lib/mathn.rb (Integer): need not to remove gcd2. a patch from
NARUSE, Yui <naruse at airemix.com>. [ruby-dev:28570]
* parse.y (arg): too much NEW_LIST()
* eval.c (SETUP_ARGS0): remove unnecessary access to nd_alen.
* eval.c (rb_eval): use ARGSCAT for NODE_OP_ASGN1.
[ruby-dev:28585]
* parse.y (arg): use NODE_ARGSCAT for placeholder.
* lib/getoptlong.rb (GetoptLong::get): RDoc update patch from
mathew <meta at pobox.com>. [ruby-core:07738]
* variable.c (rb_const_set): raise error when no target klass is
supplied. [ruby-dev:28582]
* prec.c (prec_prec_f): documentation patch from
<gerardo.santana at gmail.com>. [ruby-core:07689]
* bignum.c (rb_big_pow): second operand may be too big even if
it's a Fixnum. [ruby-talk:187984]
* README.EXT: update symbol description. [ruby-talk:188104]
* COPYING: explicitly note GPLv2. [ruby-talk:187922]
* parse.y: remove some obsolete syntax rules (unparenthesized
method calls in argument list).
* eval.c (rb_call0): insecure calling should be checked for non
NODE_SCOPE method invocations too.
* eval.c (rb_alias): should preserve the current safe level as
well as method definition.
* process.c (rb_f_sleep): remove RDoc description about SIGALRM
which is not valid on the current implementation. [ruby-dev:28464]
Thu Mar 23 21:40:47 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
* eval.c (method_missing): should support argument splat in
super. a bug in combination of super, splat and
method_missing. [ruby-talk:185438]
* configure.in: Solaris SunPro compiler -rapth patch from
<kuwa at labs.fujitsu.com>. [ruby-dev:28443]
* configure.in: remove enable_rpath=no for Solaris.
[ruby-dev:28440]
* ext/win32ole/win32ole.c (ole_val2olevariantdata): change behavior
of converting OLE Variant object with VT_ARRAY|VT_UI1 and Ruby
String object.
* ruby.1: a clarification patch from David Lutterkort
<dlutter at redhat.com>. [ruby-core:7508]
* lib/rdoc/ri/ri_paths.rb (RI::Paths): adding paths from rubygems
directories. a patch from Eric Hodel <drbrain at segment7.net>.
[ruby-core:07423]
* eval.c (rb_clear_cache_by_class): clearing wrong cache.
* ext/extmk.rb: use :remove_destination to install extension libraries
to avoid SEGV. [ruby-dev:28417]
* eval.c (rb_thread_fd_writable): should not re-schedule output
from KILLED thread (must be error printing).
* array.c (rb_ary_flatten_bang): allow specifying recursion
level. [ruby-talk:182170]
* array.c (rb_ary_flatten): ditto.
* gc.c (add_heap): a heap_slots may overflow. a patch from Stefan
Weil <weil at mail.berlios.de>.
* eval.c (rb_call): use separate cache for fcall/vcall
invocation.
* eval.c (rb_eval): NODE_FCALL, NODE_VCALL can call local
functions.
* eval.c (rb_mod_local): a new method to specify newly added
visibility "local".
* eval.c (search_method): search for local methods which are
visible only from the current class.
* class.c (rb_class_local_methods): a method to list local methods.
* object.c (Init_Object): add BasicObject class as a top level
BlankSlate class.
* ruby.h (SYM2ID): should not cast to signed long.
[ruby-core:07414]
* class.c (rb_include_module): allow module duplication.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-09 17:20:17 -04:00
|
|
|
* a = [ 1, 2, [3, [4, 5] ] ]
|
|
|
|
* a.flatten!(1) #=> [1, 2, 3, [4, 5]]
|
2003-12-16 15:28:44 -05:00
|
|
|
*/
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
static VALUE
|
* sprintf.c (rb_str_format): allow %c to print one character
string (e.g. ?x).
* lib/tempfile.rb (Tempfile::make_tmpname): put dot between
basename and pid. [ruby-talk:196272]
* parse.y (do_block): remove -> style block.
* parse.y (parser_yylex): remove tLAMBDA_ARG.
* eval.c (rb_call0): binding for the return event hook should have
consistent scope. [ruby-core:07928]
* eval.c (proc_invoke): return behavior should depend whether it
is surrounded by a lambda or a mere block.
* eval.c (formal_assign): handles post splat arguments.
* eval.c (rb_call0): ditto.
* st.c (strhash): use FNV-1a hash.
* parse.y (parser_yylex): removed experimental ';;' terminator.
* eval.c (rb_node_arity): should be aware of post splat arguments.
* eval.c (rb_proc_arity): ditto.
* parse.y (f_args): syntax rule enhanced to support arguments
after the splat.
* parse.y (block_param): ditto for block parameters.
* parse.y (f_post_arg): mandatory formal arguments after the splat
argument.
* parse.y (new_args_gen): generate nodes for mandatory formal
arguments after the splat argument.
* eval.c (rb_eval): dispatch mandatory formal arguments after the
splat argument.
* parse.y (args): allow more than one splat in the argument list.
* parse.y (method_call): allow aref [] to accept all kind of
method argument, including assocs, splat, and block argument.
* eval.c (SETUP_ARGS0): prepare block argument as well.
* lib/mathn.rb (Integer): remove Integer#gcd2. [ruby-core:07931]
* eval.c (error_line): print receivers true/false/nil specially.
* eval.c (rb_proc_yield): handles parameters in yield semantics.
* eval.c (nil_yield): gives LocalJumpError to denote no block
error.
* io.c (rb_io_getc): now takes one-character string.
* string.c (rb_str_hash): use FNV-1a hash from Fowler/Noll/Vo
hashing algorithm.
* string.c (rb_str_aref): str[0] now returns 1 character string,
instead of a fixnum. [Ruby2]
* parse.y (parser_yylex): ?c now returns 1 character string,
instead of a fixnum. [Ruby2]
* string.c (rb_str_aset): no longer support fixnum insertion.
* eval.c (umethod_bind): should not update original class.
[ruby-dev:28636]
* eval.c (ev_const_get): should support constant access from
within instance_eval(). [ruby-dev:28327]
* time.c (time_timeval): should round for usec floating
number. [ruby-core:07896]
* time.c (time_add): ditto.
* dir.c (sys_warning): should not call a vararg function
rb_sys_warning() indirectly. [ruby-core:07886]
* numeric.c (flo_divmod): the first element of Float#divmod should
be an integer. [ruby-dev:28589]
* test/ruby/test_float.rb: add tests for divmod, div, modulo and remainder.
* re.c (rb_reg_initialize): should not allow modifying literal
regexps. frozen check moved from rb_reg_initialize_m as well.
* re.c (rb_reg_initialize): should not modify untainted objects in
safe levels higher than 3.
* re.c (rb_memcmp): type change from char* to const void*.
* dir.c (dir_close): should not close untainted dir stream.
* dir.c (GetDIR): add tainted/frozen check for each dir operation.
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_symbol_arg):
typo fixed. a patch from Florian Gross <florg at florg.net>.
* eval.c (EXEC_EVENT_HOOK): trace_func may remove itself from
event_hooks. no guarantee for arbitrary hook deletion.
[ruby-dev:28632]
* util.c (ruby_strtod): differ addition to minimize error.
[ruby-dev:28619]
* util.c (ruby_strtod): should not raise ERANGE when the input
string does not have any digits. [ruby-dev:28629]
* eval.c (proc_invoke): should restore old ruby_frame->block.
thanks to ts <decoux at moulon.inra.fr>. [ruby-core:07833]
also fix [ruby-dev:28614] as well.
* signal.c (trap): sig should be less then NSIG. Coverity found
this bug. a patch from Kevin Tew <tewk at tewk.com>.
[ruby-core:07823]
* math.c (math_log2): add new method inspired by
[ruby-talk:191237].
* math.c (math_log): add optional base argument to Math::log().
[ruby-talk:191308]
* ext/syck/emitter.c (syck_scan_scalar): avoid accessing
uninitialized array element. a patch from Pat Eyler
<rubypate at gmail.com>. [ruby-core:07809]
* array.c (rb_ary_fill): initialize local variables first. a
patch from Pat Eyler <rubypate at gmail.com>. [ruby-core:07810]
* ext/syck/yaml2byte.c (syck_yaml2byte_handler): need to free
type_tag. a patch from Pat Eyler <rubypate at gmail.com>.
[ruby-core:07808]
* ext/socket/socket.c (make_hostent_internal): accept ai_family
check from Sam Roberts <sroberts at uniserve.com>.
[ruby-core:07691]
* util.c (ruby_strtod): should not cut off 18 digits for no
reason. [ruby-core:07796]
* array.c (rb_ary_fill): internalize local variable "beg" to
pacify Coverity. [ruby-core:07770]
* pack.c (pack_unpack): now supports CRLF newlines. a patch from
<tommy at tmtm.org>. [ruby-dev:28601]
* applied code clean-up patch from Stefan Huehner
<stefan at huehner.org>. [ruby-core:07764]
* lib/jcode.rb (String::tr_s): should have translated non
squeezing character sequence (i.e. a character) as well. thanks
to Hiroshi Ichikawa <gimite at gimite.ddo.jp> [ruby-list:42090]
* ext/socket/socket.c: document update patch from Sam Roberts
<sroberts at uniserve.com>. [ruby-core:07701]
* lib/mathn.rb (Integer): need not to remove gcd2. a patch from
NARUSE, Yui <naruse at airemix.com>. [ruby-dev:28570]
* parse.y (arg): too much NEW_LIST()
* eval.c (SETUP_ARGS0): remove unnecessary access to nd_alen.
* eval.c (rb_eval): use ARGSCAT for NODE_OP_ASGN1.
[ruby-dev:28585]
* parse.y (arg): use NODE_ARGSCAT for placeholder.
* lib/getoptlong.rb (GetoptLong::get): RDoc update patch from
mathew <meta at pobox.com>. [ruby-core:07738]
* variable.c (rb_const_set): raise error when no target klass is
supplied. [ruby-dev:28582]
* prec.c (prec_prec_f): documentation patch from
<gerardo.santana at gmail.com>. [ruby-core:07689]
* bignum.c (rb_big_pow): second operand may be too big even if
it's a Fixnum. [ruby-talk:187984]
* README.EXT: update symbol description. [ruby-talk:188104]
* COPYING: explicitly note GPLv2. [ruby-talk:187922]
* parse.y: remove some obsolete syntax rules (unparenthesized
method calls in argument list).
* eval.c (rb_call0): insecure calling should be checked for non
NODE_SCOPE method invocations too.
* eval.c (rb_alias): should preserve the current safe level as
well as method definition.
* process.c (rb_f_sleep): remove RDoc description about SIGALRM
which is not valid on the current implementation. [ruby-dev:28464]
Thu Mar 23 21:40:47 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
* eval.c (method_missing): should support argument splat in
super. a bug in combination of super, splat and
method_missing. [ruby-talk:185438]
* configure.in: Solaris SunPro compiler -rapth patch from
<kuwa at labs.fujitsu.com>. [ruby-dev:28443]
* configure.in: remove enable_rpath=no for Solaris.
[ruby-dev:28440]
* ext/win32ole/win32ole.c (ole_val2olevariantdata): change behavior
of converting OLE Variant object with VT_ARRAY|VT_UI1 and Ruby
String object.
* ruby.1: a clarification patch from David Lutterkort
<dlutter at redhat.com>. [ruby-core:7508]
* lib/rdoc/ri/ri_paths.rb (RI::Paths): adding paths from rubygems
directories. a patch from Eric Hodel <drbrain at segment7.net>.
[ruby-core:07423]
* eval.c (rb_clear_cache_by_class): clearing wrong cache.
* ext/extmk.rb: use :remove_destination to install extension libraries
to avoid SEGV. [ruby-dev:28417]
* eval.c (rb_thread_fd_writable): should not re-schedule output
from KILLED thread (must be error printing).
* array.c (rb_ary_flatten_bang): allow specifying recursion
level. [ruby-talk:182170]
* array.c (rb_ary_flatten): ditto.
* gc.c (add_heap): a heap_slots may overflow. a patch from Stefan
Weil <weil at mail.berlios.de>.
* eval.c (rb_call): use separate cache for fcall/vcall
invocation.
* eval.c (rb_eval): NODE_FCALL, NODE_VCALL can call local
functions.
* eval.c (rb_mod_local): a new method to specify newly added
visibility "local".
* eval.c (search_method): search for local methods which are
visible only from the current class.
* class.c (rb_class_local_methods): a method to list local methods.
* object.c (Init_Object): add BasicObject class as a top level
BlankSlate class.
* ruby.h (SYM2ID): should not cast to signed long.
[ruby-core:07414]
* class.c (rb_include_module): allow module duplication.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-09 17:20:17 -04:00
|
|
|
rb_ary_flatten_bang(int argc, VALUE *argv, VALUE ary)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
2001-05-02 00:22:21 -04:00
|
|
|
long i = 0;
|
1999-01-19 23:59:39 -05:00
|
|
|
int mod = 0;
|
* sprintf.c (rb_str_format): allow %c to print one character
string (e.g. ?x).
* lib/tempfile.rb (Tempfile::make_tmpname): put dot between
basename and pid. [ruby-talk:196272]
* parse.y (do_block): remove -> style block.
* parse.y (parser_yylex): remove tLAMBDA_ARG.
* eval.c (rb_call0): binding for the return event hook should have
consistent scope. [ruby-core:07928]
* eval.c (proc_invoke): return behavior should depend whether it
is surrounded by a lambda or a mere block.
* eval.c (formal_assign): handles post splat arguments.
* eval.c (rb_call0): ditto.
* st.c (strhash): use FNV-1a hash.
* parse.y (parser_yylex): removed experimental ';;' terminator.
* eval.c (rb_node_arity): should be aware of post splat arguments.
* eval.c (rb_proc_arity): ditto.
* parse.y (f_args): syntax rule enhanced to support arguments
after the splat.
* parse.y (block_param): ditto for block parameters.
* parse.y (f_post_arg): mandatory formal arguments after the splat
argument.
* parse.y (new_args_gen): generate nodes for mandatory formal
arguments after the splat argument.
* eval.c (rb_eval): dispatch mandatory formal arguments after the
splat argument.
* parse.y (args): allow more than one splat in the argument list.
* parse.y (method_call): allow aref [] to accept all kind of
method argument, including assocs, splat, and block argument.
* eval.c (SETUP_ARGS0): prepare block argument as well.
* lib/mathn.rb (Integer): remove Integer#gcd2. [ruby-core:07931]
* eval.c (error_line): print receivers true/false/nil specially.
* eval.c (rb_proc_yield): handles parameters in yield semantics.
* eval.c (nil_yield): gives LocalJumpError to denote no block
error.
* io.c (rb_io_getc): now takes one-character string.
* string.c (rb_str_hash): use FNV-1a hash from Fowler/Noll/Vo
hashing algorithm.
* string.c (rb_str_aref): str[0] now returns 1 character string,
instead of a fixnum. [Ruby2]
* parse.y (parser_yylex): ?c now returns 1 character string,
instead of a fixnum. [Ruby2]
* string.c (rb_str_aset): no longer support fixnum insertion.
* eval.c (umethod_bind): should not update original class.
[ruby-dev:28636]
* eval.c (ev_const_get): should support constant access from
within instance_eval(). [ruby-dev:28327]
* time.c (time_timeval): should round for usec floating
number. [ruby-core:07896]
* time.c (time_add): ditto.
* dir.c (sys_warning): should not call a vararg function
rb_sys_warning() indirectly. [ruby-core:07886]
* numeric.c (flo_divmod): the first element of Float#divmod should
be an integer. [ruby-dev:28589]
* test/ruby/test_float.rb: add tests for divmod, div, modulo and remainder.
* re.c (rb_reg_initialize): should not allow modifying literal
regexps. frozen check moved from rb_reg_initialize_m as well.
* re.c (rb_reg_initialize): should not modify untainted objects in
safe levels higher than 3.
* re.c (rb_memcmp): type change from char* to const void*.
* dir.c (dir_close): should not close untainted dir stream.
* dir.c (GetDIR): add tainted/frozen check for each dir operation.
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_symbol_arg):
typo fixed. a patch from Florian Gross <florg at florg.net>.
* eval.c (EXEC_EVENT_HOOK): trace_func may remove itself from
event_hooks. no guarantee for arbitrary hook deletion.
[ruby-dev:28632]
* util.c (ruby_strtod): differ addition to minimize error.
[ruby-dev:28619]
* util.c (ruby_strtod): should not raise ERANGE when the input
string does not have any digits. [ruby-dev:28629]
* eval.c (proc_invoke): should restore old ruby_frame->block.
thanks to ts <decoux at moulon.inra.fr>. [ruby-core:07833]
also fix [ruby-dev:28614] as well.
* signal.c (trap): sig should be less then NSIG. Coverity found
this bug. a patch from Kevin Tew <tewk at tewk.com>.
[ruby-core:07823]
* math.c (math_log2): add new method inspired by
[ruby-talk:191237].
* math.c (math_log): add optional base argument to Math::log().
[ruby-talk:191308]
* ext/syck/emitter.c (syck_scan_scalar): avoid accessing
uninitialized array element. a patch from Pat Eyler
<rubypate at gmail.com>. [ruby-core:07809]
* array.c (rb_ary_fill): initialize local variables first. a
patch from Pat Eyler <rubypate at gmail.com>. [ruby-core:07810]
* ext/syck/yaml2byte.c (syck_yaml2byte_handler): need to free
type_tag. a patch from Pat Eyler <rubypate at gmail.com>.
[ruby-core:07808]
* ext/socket/socket.c (make_hostent_internal): accept ai_family
check from Sam Roberts <sroberts at uniserve.com>.
[ruby-core:07691]
* util.c (ruby_strtod): should not cut off 18 digits for no
reason. [ruby-core:07796]
* array.c (rb_ary_fill): internalize local variable "beg" to
pacify Coverity. [ruby-core:07770]
* pack.c (pack_unpack): now supports CRLF newlines. a patch from
<tommy at tmtm.org>. [ruby-dev:28601]
* applied code clean-up patch from Stefan Huehner
<stefan at huehner.org>. [ruby-core:07764]
* lib/jcode.rb (String::tr_s): should have translated non
squeezing character sequence (i.e. a character) as well. thanks
to Hiroshi Ichikawa <gimite at gimite.ddo.jp> [ruby-list:42090]
* ext/socket/socket.c: document update patch from Sam Roberts
<sroberts at uniserve.com>. [ruby-core:07701]
* lib/mathn.rb (Integer): need not to remove gcd2. a patch from
NARUSE, Yui <naruse at airemix.com>. [ruby-dev:28570]
* parse.y (arg): too much NEW_LIST()
* eval.c (SETUP_ARGS0): remove unnecessary access to nd_alen.
* eval.c (rb_eval): use ARGSCAT for NODE_OP_ASGN1.
[ruby-dev:28585]
* parse.y (arg): use NODE_ARGSCAT for placeholder.
* lib/getoptlong.rb (GetoptLong::get): RDoc update patch from
mathew <meta at pobox.com>. [ruby-core:07738]
* variable.c (rb_const_set): raise error when no target klass is
supplied. [ruby-dev:28582]
* prec.c (prec_prec_f): documentation patch from
<gerardo.santana at gmail.com>. [ruby-core:07689]
* bignum.c (rb_big_pow): second operand may be too big even if
it's a Fixnum. [ruby-talk:187984]
* README.EXT: update symbol description. [ruby-talk:188104]
* COPYING: explicitly note GPLv2. [ruby-talk:187922]
* parse.y: remove some obsolete syntax rules (unparenthesized
method calls in argument list).
* eval.c (rb_call0): insecure calling should be checked for non
NODE_SCOPE method invocations too.
* eval.c (rb_alias): should preserve the current safe level as
well as method definition.
* process.c (rb_f_sleep): remove RDoc description about SIGALRM
which is not valid on the current implementation. [ruby-dev:28464]
Thu Mar 23 21:40:47 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
* eval.c (method_missing): should support argument splat in
super. a bug in combination of super, splat and
method_missing. [ruby-talk:185438]
* configure.in: Solaris SunPro compiler -rapth patch from
<kuwa at labs.fujitsu.com>. [ruby-dev:28443]
* configure.in: remove enable_rpath=no for Solaris.
[ruby-dev:28440]
* ext/win32ole/win32ole.c (ole_val2olevariantdata): change behavior
of converting OLE Variant object with VT_ARRAY|VT_UI1 and Ruby
String object.
* ruby.1: a clarification patch from David Lutterkort
<dlutter at redhat.com>. [ruby-core:7508]
* lib/rdoc/ri/ri_paths.rb (RI::Paths): adding paths from rubygems
directories. a patch from Eric Hodel <drbrain at segment7.net>.
[ruby-core:07423]
* eval.c (rb_clear_cache_by_class): clearing wrong cache.
* ext/extmk.rb: use :remove_destination to install extension libraries
to avoid SEGV. [ruby-dev:28417]
* eval.c (rb_thread_fd_writable): should not re-schedule output
from KILLED thread (must be error printing).
* array.c (rb_ary_flatten_bang): allow specifying recursion
level. [ruby-talk:182170]
* array.c (rb_ary_flatten): ditto.
* gc.c (add_heap): a heap_slots may overflow. a patch from Stefan
Weil <weil at mail.berlios.de>.
* eval.c (rb_call): use separate cache for fcall/vcall
invocation.
* eval.c (rb_eval): NODE_FCALL, NODE_VCALL can call local
functions.
* eval.c (rb_mod_local): a new method to specify newly added
visibility "local".
* eval.c (search_method): search for local methods which are
visible only from the current class.
* class.c (rb_class_local_methods): a method to list local methods.
* object.c (Init_Object): add BasicObject class as a top level
BlankSlate class.
* ruby.h (SYM2ID): should not cast to signed long.
[ruby-core:07414]
* class.c (rb_include_module): allow module duplication.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-09 17:20:17 -04:00
|
|
|
int level = -1;
|
2001-05-02 00:22:21 -04:00
|
|
|
VALUE memo = Qnil;
|
* sprintf.c (rb_str_format): allow %c to print one character
string (e.g. ?x).
* lib/tempfile.rb (Tempfile::make_tmpname): put dot between
basename and pid. [ruby-talk:196272]
* parse.y (do_block): remove -> style block.
* parse.y (parser_yylex): remove tLAMBDA_ARG.
* eval.c (rb_call0): binding for the return event hook should have
consistent scope. [ruby-core:07928]
* eval.c (proc_invoke): return behavior should depend whether it
is surrounded by a lambda or a mere block.
* eval.c (formal_assign): handles post splat arguments.
* eval.c (rb_call0): ditto.
* st.c (strhash): use FNV-1a hash.
* parse.y (parser_yylex): removed experimental ';;' terminator.
* eval.c (rb_node_arity): should be aware of post splat arguments.
* eval.c (rb_proc_arity): ditto.
* parse.y (f_args): syntax rule enhanced to support arguments
after the splat.
* parse.y (block_param): ditto for block parameters.
* parse.y (f_post_arg): mandatory formal arguments after the splat
argument.
* parse.y (new_args_gen): generate nodes for mandatory formal
arguments after the splat argument.
* eval.c (rb_eval): dispatch mandatory formal arguments after the
splat argument.
* parse.y (args): allow more than one splat in the argument list.
* parse.y (method_call): allow aref [] to accept all kind of
method argument, including assocs, splat, and block argument.
* eval.c (SETUP_ARGS0): prepare block argument as well.
* lib/mathn.rb (Integer): remove Integer#gcd2. [ruby-core:07931]
* eval.c (error_line): print receivers true/false/nil specially.
* eval.c (rb_proc_yield): handles parameters in yield semantics.
* eval.c (nil_yield): gives LocalJumpError to denote no block
error.
* io.c (rb_io_getc): now takes one-character string.
* string.c (rb_str_hash): use FNV-1a hash from Fowler/Noll/Vo
hashing algorithm.
* string.c (rb_str_aref): str[0] now returns 1 character string,
instead of a fixnum. [Ruby2]
* parse.y (parser_yylex): ?c now returns 1 character string,
instead of a fixnum. [Ruby2]
* string.c (rb_str_aset): no longer support fixnum insertion.
* eval.c (umethod_bind): should not update original class.
[ruby-dev:28636]
* eval.c (ev_const_get): should support constant access from
within instance_eval(). [ruby-dev:28327]
* time.c (time_timeval): should round for usec floating
number. [ruby-core:07896]
* time.c (time_add): ditto.
* dir.c (sys_warning): should not call a vararg function
rb_sys_warning() indirectly. [ruby-core:07886]
* numeric.c (flo_divmod): the first element of Float#divmod should
be an integer. [ruby-dev:28589]
* test/ruby/test_float.rb: add tests for divmod, div, modulo and remainder.
* re.c (rb_reg_initialize): should not allow modifying literal
regexps. frozen check moved from rb_reg_initialize_m as well.
* re.c (rb_reg_initialize): should not modify untainted objects in
safe levels higher than 3.
* re.c (rb_memcmp): type change from char* to const void*.
* dir.c (dir_close): should not close untainted dir stream.
* dir.c (GetDIR): add tainted/frozen check for each dir operation.
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_symbol_arg):
typo fixed. a patch from Florian Gross <florg at florg.net>.
* eval.c (EXEC_EVENT_HOOK): trace_func may remove itself from
event_hooks. no guarantee for arbitrary hook deletion.
[ruby-dev:28632]
* util.c (ruby_strtod): differ addition to minimize error.
[ruby-dev:28619]
* util.c (ruby_strtod): should not raise ERANGE when the input
string does not have any digits. [ruby-dev:28629]
* eval.c (proc_invoke): should restore old ruby_frame->block.
thanks to ts <decoux at moulon.inra.fr>. [ruby-core:07833]
also fix [ruby-dev:28614] as well.
* signal.c (trap): sig should be less then NSIG. Coverity found
this bug. a patch from Kevin Tew <tewk at tewk.com>.
[ruby-core:07823]
* math.c (math_log2): add new method inspired by
[ruby-talk:191237].
* math.c (math_log): add optional base argument to Math::log().
[ruby-talk:191308]
* ext/syck/emitter.c (syck_scan_scalar): avoid accessing
uninitialized array element. a patch from Pat Eyler
<rubypate at gmail.com>. [ruby-core:07809]
* array.c (rb_ary_fill): initialize local variables first. a
patch from Pat Eyler <rubypate at gmail.com>. [ruby-core:07810]
* ext/syck/yaml2byte.c (syck_yaml2byte_handler): need to free
type_tag. a patch from Pat Eyler <rubypate at gmail.com>.
[ruby-core:07808]
* ext/socket/socket.c (make_hostent_internal): accept ai_family
check from Sam Roberts <sroberts at uniserve.com>.
[ruby-core:07691]
* util.c (ruby_strtod): should not cut off 18 digits for no
reason. [ruby-core:07796]
* array.c (rb_ary_fill): internalize local variable "beg" to
pacify Coverity. [ruby-core:07770]
* pack.c (pack_unpack): now supports CRLF newlines. a patch from
<tommy at tmtm.org>. [ruby-dev:28601]
* applied code clean-up patch from Stefan Huehner
<stefan at huehner.org>. [ruby-core:07764]
* lib/jcode.rb (String::tr_s): should have translated non
squeezing character sequence (i.e. a character) as well. thanks
to Hiroshi Ichikawa <gimite at gimite.ddo.jp> [ruby-list:42090]
* ext/socket/socket.c: document update patch from Sam Roberts
<sroberts at uniserve.com>. [ruby-core:07701]
* lib/mathn.rb (Integer): need not to remove gcd2. a patch from
NARUSE, Yui <naruse at airemix.com>. [ruby-dev:28570]
* parse.y (arg): too much NEW_LIST()
* eval.c (SETUP_ARGS0): remove unnecessary access to nd_alen.
* eval.c (rb_eval): use ARGSCAT for NODE_OP_ASGN1.
[ruby-dev:28585]
* parse.y (arg): use NODE_ARGSCAT for placeholder.
* lib/getoptlong.rb (GetoptLong::get): RDoc update patch from
mathew <meta at pobox.com>. [ruby-core:07738]
* variable.c (rb_const_set): raise error when no target klass is
supplied. [ruby-dev:28582]
* prec.c (prec_prec_f): documentation patch from
<gerardo.santana at gmail.com>. [ruby-core:07689]
* bignum.c (rb_big_pow): second operand may be too big even if
it's a Fixnum. [ruby-talk:187984]
* README.EXT: update symbol description. [ruby-talk:188104]
* COPYING: explicitly note GPLv2. [ruby-talk:187922]
* parse.y: remove some obsolete syntax rules (unparenthesized
method calls in argument list).
* eval.c (rb_call0): insecure calling should be checked for non
NODE_SCOPE method invocations too.
* eval.c (rb_alias): should preserve the current safe level as
well as method definition.
* process.c (rb_f_sleep): remove RDoc description about SIGALRM
which is not valid on the current implementation. [ruby-dev:28464]
Thu Mar 23 21:40:47 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
* eval.c (method_missing): should support argument splat in
super. a bug in combination of super, splat and
method_missing. [ruby-talk:185438]
* configure.in: Solaris SunPro compiler -rapth patch from
<kuwa at labs.fujitsu.com>. [ruby-dev:28443]
* configure.in: remove enable_rpath=no for Solaris.
[ruby-dev:28440]
* ext/win32ole/win32ole.c (ole_val2olevariantdata): change behavior
of converting OLE Variant object with VT_ARRAY|VT_UI1 and Ruby
String object.
* ruby.1: a clarification patch from David Lutterkort
<dlutter at redhat.com>. [ruby-core:7508]
* lib/rdoc/ri/ri_paths.rb (RI::Paths): adding paths from rubygems
directories. a patch from Eric Hodel <drbrain at segment7.net>.
[ruby-core:07423]
* eval.c (rb_clear_cache_by_class): clearing wrong cache.
* ext/extmk.rb: use :remove_destination to install extension libraries
to avoid SEGV. [ruby-dev:28417]
* eval.c (rb_thread_fd_writable): should not re-schedule output
from KILLED thread (must be error printing).
* array.c (rb_ary_flatten_bang): allow specifying recursion
level. [ruby-talk:182170]
* array.c (rb_ary_flatten): ditto.
* gc.c (add_heap): a heap_slots may overflow. a patch from Stefan
Weil <weil at mail.berlios.de>.
* eval.c (rb_call): use separate cache for fcall/vcall
invocation.
* eval.c (rb_eval): NODE_FCALL, NODE_VCALL can call local
functions.
* eval.c (rb_mod_local): a new method to specify newly added
visibility "local".
* eval.c (search_method): search for local methods which are
visible only from the current class.
* class.c (rb_class_local_methods): a method to list local methods.
* object.c (Init_Object): add BasicObject class as a top level
BlankSlate class.
* ruby.h (SYM2ID): should not cast to signed long.
[ruby-core:07414]
* class.c (rb_include_module): allow module duplication.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-09 17:20:17 -04:00
|
|
|
VALUE lv;
|
1998-01-16 07:13:05 -05:00
|
|
|
|
* sprintf.c (rb_str_format): allow %c to print one character
string (e.g. ?x).
* lib/tempfile.rb (Tempfile::make_tmpname): put dot between
basename and pid. [ruby-talk:196272]
* parse.y (do_block): remove -> style block.
* parse.y (parser_yylex): remove tLAMBDA_ARG.
* eval.c (rb_call0): binding for the return event hook should have
consistent scope. [ruby-core:07928]
* eval.c (proc_invoke): return behavior should depend whether it
is surrounded by a lambda or a mere block.
* eval.c (formal_assign): handles post splat arguments.
* eval.c (rb_call0): ditto.
* st.c (strhash): use FNV-1a hash.
* parse.y (parser_yylex): removed experimental ';;' terminator.
* eval.c (rb_node_arity): should be aware of post splat arguments.
* eval.c (rb_proc_arity): ditto.
* parse.y (f_args): syntax rule enhanced to support arguments
after the splat.
* parse.y (block_param): ditto for block parameters.
* parse.y (f_post_arg): mandatory formal arguments after the splat
argument.
* parse.y (new_args_gen): generate nodes for mandatory formal
arguments after the splat argument.
* eval.c (rb_eval): dispatch mandatory formal arguments after the
splat argument.
* parse.y (args): allow more than one splat in the argument list.
* parse.y (method_call): allow aref [] to accept all kind of
method argument, including assocs, splat, and block argument.
* eval.c (SETUP_ARGS0): prepare block argument as well.
* lib/mathn.rb (Integer): remove Integer#gcd2. [ruby-core:07931]
* eval.c (error_line): print receivers true/false/nil specially.
* eval.c (rb_proc_yield): handles parameters in yield semantics.
* eval.c (nil_yield): gives LocalJumpError to denote no block
error.
* io.c (rb_io_getc): now takes one-character string.
* string.c (rb_str_hash): use FNV-1a hash from Fowler/Noll/Vo
hashing algorithm.
* string.c (rb_str_aref): str[0] now returns 1 character string,
instead of a fixnum. [Ruby2]
* parse.y (parser_yylex): ?c now returns 1 character string,
instead of a fixnum. [Ruby2]
* string.c (rb_str_aset): no longer support fixnum insertion.
* eval.c (umethod_bind): should not update original class.
[ruby-dev:28636]
* eval.c (ev_const_get): should support constant access from
within instance_eval(). [ruby-dev:28327]
* time.c (time_timeval): should round for usec floating
number. [ruby-core:07896]
* time.c (time_add): ditto.
* dir.c (sys_warning): should not call a vararg function
rb_sys_warning() indirectly. [ruby-core:07886]
* numeric.c (flo_divmod): the first element of Float#divmod should
be an integer. [ruby-dev:28589]
* test/ruby/test_float.rb: add tests for divmod, div, modulo and remainder.
* re.c (rb_reg_initialize): should not allow modifying literal
regexps. frozen check moved from rb_reg_initialize_m as well.
* re.c (rb_reg_initialize): should not modify untainted objects in
safe levels higher than 3.
* re.c (rb_memcmp): type change from char* to const void*.
* dir.c (dir_close): should not close untainted dir stream.
* dir.c (GetDIR): add tainted/frozen check for each dir operation.
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_symbol_arg):
typo fixed. a patch from Florian Gross <florg at florg.net>.
* eval.c (EXEC_EVENT_HOOK): trace_func may remove itself from
event_hooks. no guarantee for arbitrary hook deletion.
[ruby-dev:28632]
* util.c (ruby_strtod): differ addition to minimize error.
[ruby-dev:28619]
* util.c (ruby_strtod): should not raise ERANGE when the input
string does not have any digits. [ruby-dev:28629]
* eval.c (proc_invoke): should restore old ruby_frame->block.
thanks to ts <decoux at moulon.inra.fr>. [ruby-core:07833]
also fix [ruby-dev:28614] as well.
* signal.c (trap): sig should be less then NSIG. Coverity found
this bug. a patch from Kevin Tew <tewk at tewk.com>.
[ruby-core:07823]
* math.c (math_log2): add new method inspired by
[ruby-talk:191237].
* math.c (math_log): add optional base argument to Math::log().
[ruby-talk:191308]
* ext/syck/emitter.c (syck_scan_scalar): avoid accessing
uninitialized array element. a patch from Pat Eyler
<rubypate at gmail.com>. [ruby-core:07809]
* array.c (rb_ary_fill): initialize local variables first. a
patch from Pat Eyler <rubypate at gmail.com>. [ruby-core:07810]
* ext/syck/yaml2byte.c (syck_yaml2byte_handler): need to free
type_tag. a patch from Pat Eyler <rubypate at gmail.com>.
[ruby-core:07808]
* ext/socket/socket.c (make_hostent_internal): accept ai_family
check from Sam Roberts <sroberts at uniserve.com>.
[ruby-core:07691]
* util.c (ruby_strtod): should not cut off 18 digits for no
reason. [ruby-core:07796]
* array.c (rb_ary_fill): internalize local variable "beg" to
pacify Coverity. [ruby-core:07770]
* pack.c (pack_unpack): now supports CRLF newlines. a patch from
<tommy at tmtm.org>. [ruby-dev:28601]
* applied code clean-up patch from Stefan Huehner
<stefan at huehner.org>. [ruby-core:07764]
* lib/jcode.rb (String::tr_s): should have translated non
squeezing character sequence (i.e. a character) as well. thanks
to Hiroshi Ichikawa <gimite at gimite.ddo.jp> [ruby-list:42090]
* ext/socket/socket.c: document update patch from Sam Roberts
<sroberts at uniserve.com>. [ruby-core:07701]
* lib/mathn.rb (Integer): need not to remove gcd2. a patch from
NARUSE, Yui <naruse at airemix.com>. [ruby-dev:28570]
* parse.y (arg): too much NEW_LIST()
* eval.c (SETUP_ARGS0): remove unnecessary access to nd_alen.
* eval.c (rb_eval): use ARGSCAT for NODE_OP_ASGN1.
[ruby-dev:28585]
* parse.y (arg): use NODE_ARGSCAT for placeholder.
* lib/getoptlong.rb (GetoptLong::get): RDoc update patch from
mathew <meta at pobox.com>. [ruby-core:07738]
* variable.c (rb_const_set): raise error when no target klass is
supplied. [ruby-dev:28582]
* prec.c (prec_prec_f): documentation patch from
<gerardo.santana at gmail.com>. [ruby-core:07689]
* bignum.c (rb_big_pow): second operand may be too big even if
it's a Fixnum. [ruby-talk:187984]
* README.EXT: update symbol description. [ruby-talk:188104]
* COPYING: explicitly note GPLv2. [ruby-talk:187922]
* parse.y: remove some obsolete syntax rules (unparenthesized
method calls in argument list).
* eval.c (rb_call0): insecure calling should be checked for non
NODE_SCOPE method invocations too.
* eval.c (rb_alias): should preserve the current safe level as
well as method definition.
* process.c (rb_f_sleep): remove RDoc description about SIGALRM
which is not valid on the current implementation. [ruby-dev:28464]
Thu Mar 23 21:40:47 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
* eval.c (method_missing): should support argument splat in
super. a bug in combination of super, splat and
method_missing. [ruby-talk:185438]
* configure.in: Solaris SunPro compiler -rapth patch from
<kuwa at labs.fujitsu.com>. [ruby-dev:28443]
* configure.in: remove enable_rpath=no for Solaris.
[ruby-dev:28440]
* ext/win32ole/win32ole.c (ole_val2olevariantdata): change behavior
of converting OLE Variant object with VT_ARRAY|VT_UI1 and Ruby
String object.
* ruby.1: a clarification patch from David Lutterkort
<dlutter at redhat.com>. [ruby-core:7508]
* lib/rdoc/ri/ri_paths.rb (RI::Paths): adding paths from rubygems
directories. a patch from Eric Hodel <drbrain at segment7.net>.
[ruby-core:07423]
* eval.c (rb_clear_cache_by_class): clearing wrong cache.
* ext/extmk.rb: use :remove_destination to install extension libraries
to avoid SEGV. [ruby-dev:28417]
* eval.c (rb_thread_fd_writable): should not re-schedule output
from KILLED thread (must be error printing).
* array.c (rb_ary_flatten_bang): allow specifying recursion
level. [ruby-talk:182170]
* array.c (rb_ary_flatten): ditto.
* gc.c (add_heap): a heap_slots may overflow. a patch from Stefan
Weil <weil at mail.berlios.de>.
* eval.c (rb_call): use separate cache for fcall/vcall
invocation.
* eval.c (rb_eval): NODE_FCALL, NODE_VCALL can call local
functions.
* eval.c (rb_mod_local): a new method to specify newly added
visibility "local".
* eval.c (search_method): search for local methods which are
visible only from the current class.
* class.c (rb_class_local_methods): a method to list local methods.
* object.c (Init_Object): add BasicObject class as a top level
BlankSlate class.
* ruby.h (SYM2ID): should not cast to signed long.
[ruby-core:07414]
* class.c (rb_include_module): allow module duplication.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-09 17:20:17 -04:00
|
|
|
rb_scan_args(argc, argv, "01", &lv);
|
|
|
|
if (!NIL_P(lv)) level = FIX2INT(lv);
|
|
|
|
if (level == 0) return ary;
|
2006-09-02 10:42:08 -04:00
|
|
|
while (i<RARRAY_LEN(ary)) {
|
|
|
|
VALUE ary2 = RARRAY_PTR(ary)[i];
|
2004-09-24 01:53:43 -04:00
|
|
|
VALUE tmp;
|
2001-05-02 00:22:21 -04:00
|
|
|
|
2004-09-24 01:53:43 -04:00
|
|
|
tmp = rb_check_array_type(ary2);
|
|
|
|
if (!NIL_P(tmp)) {
|
2001-05-02 00:22:21 -04:00
|
|
|
if (NIL_P(memo)) {
|
|
|
|
memo = rb_ary_new();
|
2000-01-31 22:12:21 -05:00
|
|
|
}
|
* sprintf.c (rb_str_format): allow %c to print one character
string (e.g. ?x).
* lib/tempfile.rb (Tempfile::make_tmpname): put dot between
basename and pid. [ruby-talk:196272]
* parse.y (do_block): remove -> style block.
* parse.y (parser_yylex): remove tLAMBDA_ARG.
* eval.c (rb_call0): binding for the return event hook should have
consistent scope. [ruby-core:07928]
* eval.c (proc_invoke): return behavior should depend whether it
is surrounded by a lambda or a mere block.
* eval.c (formal_assign): handles post splat arguments.
* eval.c (rb_call0): ditto.
* st.c (strhash): use FNV-1a hash.
* parse.y (parser_yylex): removed experimental ';;' terminator.
* eval.c (rb_node_arity): should be aware of post splat arguments.
* eval.c (rb_proc_arity): ditto.
* parse.y (f_args): syntax rule enhanced to support arguments
after the splat.
* parse.y (block_param): ditto for block parameters.
* parse.y (f_post_arg): mandatory formal arguments after the splat
argument.
* parse.y (new_args_gen): generate nodes for mandatory formal
arguments after the splat argument.
* eval.c (rb_eval): dispatch mandatory formal arguments after the
splat argument.
* parse.y (args): allow more than one splat in the argument list.
* parse.y (method_call): allow aref [] to accept all kind of
method argument, including assocs, splat, and block argument.
* eval.c (SETUP_ARGS0): prepare block argument as well.
* lib/mathn.rb (Integer): remove Integer#gcd2. [ruby-core:07931]
* eval.c (error_line): print receivers true/false/nil specially.
* eval.c (rb_proc_yield): handles parameters in yield semantics.
* eval.c (nil_yield): gives LocalJumpError to denote no block
error.
* io.c (rb_io_getc): now takes one-character string.
* string.c (rb_str_hash): use FNV-1a hash from Fowler/Noll/Vo
hashing algorithm.
* string.c (rb_str_aref): str[0] now returns 1 character string,
instead of a fixnum. [Ruby2]
* parse.y (parser_yylex): ?c now returns 1 character string,
instead of a fixnum. [Ruby2]
* string.c (rb_str_aset): no longer support fixnum insertion.
* eval.c (umethod_bind): should not update original class.
[ruby-dev:28636]
* eval.c (ev_const_get): should support constant access from
within instance_eval(). [ruby-dev:28327]
* time.c (time_timeval): should round for usec floating
number. [ruby-core:07896]
* time.c (time_add): ditto.
* dir.c (sys_warning): should not call a vararg function
rb_sys_warning() indirectly. [ruby-core:07886]
* numeric.c (flo_divmod): the first element of Float#divmod should
be an integer. [ruby-dev:28589]
* test/ruby/test_float.rb: add tests for divmod, div, modulo and remainder.
* re.c (rb_reg_initialize): should not allow modifying literal
regexps. frozen check moved from rb_reg_initialize_m as well.
* re.c (rb_reg_initialize): should not modify untainted objects in
safe levels higher than 3.
* re.c (rb_memcmp): type change from char* to const void*.
* dir.c (dir_close): should not close untainted dir stream.
* dir.c (GetDIR): add tainted/frozen check for each dir operation.
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_symbol_arg):
typo fixed. a patch from Florian Gross <florg at florg.net>.
* eval.c (EXEC_EVENT_HOOK): trace_func may remove itself from
event_hooks. no guarantee for arbitrary hook deletion.
[ruby-dev:28632]
* util.c (ruby_strtod): differ addition to minimize error.
[ruby-dev:28619]
* util.c (ruby_strtod): should not raise ERANGE when the input
string does not have any digits. [ruby-dev:28629]
* eval.c (proc_invoke): should restore old ruby_frame->block.
thanks to ts <decoux at moulon.inra.fr>. [ruby-core:07833]
also fix [ruby-dev:28614] as well.
* signal.c (trap): sig should be less then NSIG. Coverity found
this bug. a patch from Kevin Tew <tewk at tewk.com>.
[ruby-core:07823]
* math.c (math_log2): add new method inspired by
[ruby-talk:191237].
* math.c (math_log): add optional base argument to Math::log().
[ruby-talk:191308]
* ext/syck/emitter.c (syck_scan_scalar): avoid accessing
uninitialized array element. a patch from Pat Eyler
<rubypate at gmail.com>. [ruby-core:07809]
* array.c (rb_ary_fill): initialize local variables first. a
patch from Pat Eyler <rubypate at gmail.com>. [ruby-core:07810]
* ext/syck/yaml2byte.c (syck_yaml2byte_handler): need to free
type_tag. a patch from Pat Eyler <rubypate at gmail.com>.
[ruby-core:07808]
* ext/socket/socket.c (make_hostent_internal): accept ai_family
check from Sam Roberts <sroberts at uniserve.com>.
[ruby-core:07691]
* util.c (ruby_strtod): should not cut off 18 digits for no
reason. [ruby-core:07796]
* array.c (rb_ary_fill): internalize local variable "beg" to
pacify Coverity. [ruby-core:07770]
* pack.c (pack_unpack): now supports CRLF newlines. a patch from
<tommy at tmtm.org>. [ruby-dev:28601]
* applied code clean-up patch from Stefan Huehner
<stefan at huehner.org>. [ruby-core:07764]
* lib/jcode.rb (String::tr_s): should have translated non
squeezing character sequence (i.e. a character) as well. thanks
to Hiroshi Ichikawa <gimite at gimite.ddo.jp> [ruby-list:42090]
* ext/socket/socket.c: document update patch from Sam Roberts
<sroberts at uniserve.com>. [ruby-core:07701]
* lib/mathn.rb (Integer): need not to remove gcd2. a patch from
NARUSE, Yui <naruse at airemix.com>. [ruby-dev:28570]
* parse.y (arg): too much NEW_LIST()
* eval.c (SETUP_ARGS0): remove unnecessary access to nd_alen.
* eval.c (rb_eval): use ARGSCAT for NODE_OP_ASGN1.
[ruby-dev:28585]
* parse.y (arg): use NODE_ARGSCAT for placeholder.
* lib/getoptlong.rb (GetoptLong::get): RDoc update patch from
mathew <meta at pobox.com>. [ruby-core:07738]
* variable.c (rb_const_set): raise error when no target klass is
supplied. [ruby-dev:28582]
* prec.c (prec_prec_f): documentation patch from
<gerardo.santana at gmail.com>. [ruby-core:07689]
* bignum.c (rb_big_pow): second operand may be too big even if
it's a Fixnum. [ruby-talk:187984]
* README.EXT: update symbol description. [ruby-talk:188104]
* COPYING: explicitly note GPLv2. [ruby-talk:187922]
* parse.y: remove some obsolete syntax rules (unparenthesized
method calls in argument list).
* eval.c (rb_call0): insecure calling should be checked for non
NODE_SCOPE method invocations too.
* eval.c (rb_alias): should preserve the current safe level as
well as method definition.
* process.c (rb_f_sleep): remove RDoc description about SIGALRM
which is not valid on the current implementation. [ruby-dev:28464]
Thu Mar 23 21:40:47 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
* eval.c (method_missing): should support argument splat in
super. a bug in combination of super, splat and
method_missing. [ruby-talk:185438]
* configure.in: Solaris SunPro compiler -rapth patch from
<kuwa at labs.fujitsu.com>. [ruby-dev:28443]
* configure.in: remove enable_rpath=no for Solaris.
[ruby-dev:28440]
* ext/win32ole/win32ole.c (ole_val2olevariantdata): change behavior
of converting OLE Variant object with VT_ARRAY|VT_UI1 and Ruby
String object.
* ruby.1: a clarification patch from David Lutterkort
<dlutter at redhat.com>. [ruby-core:7508]
* lib/rdoc/ri/ri_paths.rb (RI::Paths): adding paths from rubygems
directories. a patch from Eric Hodel <drbrain at segment7.net>.
[ruby-core:07423]
* eval.c (rb_clear_cache_by_class): clearing wrong cache.
* ext/extmk.rb: use :remove_destination to install extension libraries
to avoid SEGV. [ruby-dev:28417]
* eval.c (rb_thread_fd_writable): should not re-schedule output
from KILLED thread (must be error printing).
* array.c (rb_ary_flatten_bang): allow specifying recursion
level. [ruby-talk:182170]
* array.c (rb_ary_flatten): ditto.
* gc.c (add_heap): a heap_slots may overflow. a patch from Stefan
Weil <weil at mail.berlios.de>.
* eval.c (rb_call): use separate cache for fcall/vcall
invocation.
* eval.c (rb_eval): NODE_FCALL, NODE_VCALL can call local
functions.
* eval.c (rb_mod_local): a new method to specify newly added
visibility "local".
* eval.c (search_method): search for local methods which are
visible only from the current class.
* class.c (rb_class_local_methods): a method to list local methods.
* object.c (Init_Object): add BasicObject class as a top level
BlankSlate class.
* ruby.h (SYM2ID): should not cast to signed long.
[ruby-core:07414]
* class.c (rb_include_module): allow module duplication.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-09 17:20:17 -04:00
|
|
|
i += flatten(ary, i, tmp, memo, level);
|
1999-01-19 23:59:39 -05:00
|
|
|
mod = 1;
|
|
|
|
}
|
2001-05-02 00:22:21 -04:00
|
|
|
i++;
|
1999-01-19 23:59:39 -05:00
|
|
|
}
|
|
|
|
if (mod == 0) return Qnil;
|
|
|
|
return ary;
|
|
|
|
}
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2003-12-16 15:28:44 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* array.flatten -> an_array
|
* sprintf.c (rb_str_format): allow %c to print one character
string (e.g. ?x).
* lib/tempfile.rb (Tempfile::make_tmpname): put dot between
basename and pid. [ruby-talk:196272]
* parse.y (do_block): remove -> style block.
* parse.y (parser_yylex): remove tLAMBDA_ARG.
* eval.c (rb_call0): binding for the return event hook should have
consistent scope. [ruby-core:07928]
* eval.c (proc_invoke): return behavior should depend whether it
is surrounded by a lambda or a mere block.
* eval.c (formal_assign): handles post splat arguments.
* eval.c (rb_call0): ditto.
* st.c (strhash): use FNV-1a hash.
* parse.y (parser_yylex): removed experimental ';;' terminator.
* eval.c (rb_node_arity): should be aware of post splat arguments.
* eval.c (rb_proc_arity): ditto.
* parse.y (f_args): syntax rule enhanced to support arguments
after the splat.
* parse.y (block_param): ditto for block parameters.
* parse.y (f_post_arg): mandatory formal arguments after the splat
argument.
* parse.y (new_args_gen): generate nodes for mandatory formal
arguments after the splat argument.
* eval.c (rb_eval): dispatch mandatory formal arguments after the
splat argument.
* parse.y (args): allow more than one splat in the argument list.
* parse.y (method_call): allow aref [] to accept all kind of
method argument, including assocs, splat, and block argument.
* eval.c (SETUP_ARGS0): prepare block argument as well.
* lib/mathn.rb (Integer): remove Integer#gcd2. [ruby-core:07931]
* eval.c (error_line): print receivers true/false/nil specially.
* eval.c (rb_proc_yield): handles parameters in yield semantics.
* eval.c (nil_yield): gives LocalJumpError to denote no block
error.
* io.c (rb_io_getc): now takes one-character string.
* string.c (rb_str_hash): use FNV-1a hash from Fowler/Noll/Vo
hashing algorithm.
* string.c (rb_str_aref): str[0] now returns 1 character string,
instead of a fixnum. [Ruby2]
* parse.y (parser_yylex): ?c now returns 1 character string,
instead of a fixnum. [Ruby2]
* string.c (rb_str_aset): no longer support fixnum insertion.
* eval.c (umethod_bind): should not update original class.
[ruby-dev:28636]
* eval.c (ev_const_get): should support constant access from
within instance_eval(). [ruby-dev:28327]
* time.c (time_timeval): should round for usec floating
number. [ruby-core:07896]
* time.c (time_add): ditto.
* dir.c (sys_warning): should not call a vararg function
rb_sys_warning() indirectly. [ruby-core:07886]
* numeric.c (flo_divmod): the first element of Float#divmod should
be an integer. [ruby-dev:28589]
* test/ruby/test_float.rb: add tests for divmod, div, modulo and remainder.
* re.c (rb_reg_initialize): should not allow modifying literal
regexps. frozen check moved from rb_reg_initialize_m as well.
* re.c (rb_reg_initialize): should not modify untainted objects in
safe levels higher than 3.
* re.c (rb_memcmp): type change from char* to const void*.
* dir.c (dir_close): should not close untainted dir stream.
* dir.c (GetDIR): add tainted/frozen check for each dir operation.
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_symbol_arg):
typo fixed. a patch from Florian Gross <florg at florg.net>.
* eval.c (EXEC_EVENT_HOOK): trace_func may remove itself from
event_hooks. no guarantee for arbitrary hook deletion.
[ruby-dev:28632]
* util.c (ruby_strtod): differ addition to minimize error.
[ruby-dev:28619]
* util.c (ruby_strtod): should not raise ERANGE when the input
string does not have any digits. [ruby-dev:28629]
* eval.c (proc_invoke): should restore old ruby_frame->block.
thanks to ts <decoux at moulon.inra.fr>. [ruby-core:07833]
also fix [ruby-dev:28614] as well.
* signal.c (trap): sig should be less then NSIG. Coverity found
this bug. a patch from Kevin Tew <tewk at tewk.com>.
[ruby-core:07823]
* math.c (math_log2): add new method inspired by
[ruby-talk:191237].
* math.c (math_log): add optional base argument to Math::log().
[ruby-talk:191308]
* ext/syck/emitter.c (syck_scan_scalar): avoid accessing
uninitialized array element. a patch from Pat Eyler
<rubypate at gmail.com>. [ruby-core:07809]
* array.c (rb_ary_fill): initialize local variables first. a
patch from Pat Eyler <rubypate at gmail.com>. [ruby-core:07810]
* ext/syck/yaml2byte.c (syck_yaml2byte_handler): need to free
type_tag. a patch from Pat Eyler <rubypate at gmail.com>.
[ruby-core:07808]
* ext/socket/socket.c (make_hostent_internal): accept ai_family
check from Sam Roberts <sroberts at uniserve.com>.
[ruby-core:07691]
* util.c (ruby_strtod): should not cut off 18 digits for no
reason. [ruby-core:07796]
* array.c (rb_ary_fill): internalize local variable "beg" to
pacify Coverity. [ruby-core:07770]
* pack.c (pack_unpack): now supports CRLF newlines. a patch from
<tommy at tmtm.org>. [ruby-dev:28601]
* applied code clean-up patch from Stefan Huehner
<stefan at huehner.org>. [ruby-core:07764]
* lib/jcode.rb (String::tr_s): should have translated non
squeezing character sequence (i.e. a character) as well. thanks
to Hiroshi Ichikawa <gimite at gimite.ddo.jp> [ruby-list:42090]
* ext/socket/socket.c: document update patch from Sam Roberts
<sroberts at uniserve.com>. [ruby-core:07701]
* lib/mathn.rb (Integer): need not to remove gcd2. a patch from
NARUSE, Yui <naruse at airemix.com>. [ruby-dev:28570]
* parse.y (arg): too much NEW_LIST()
* eval.c (SETUP_ARGS0): remove unnecessary access to nd_alen.
* eval.c (rb_eval): use ARGSCAT for NODE_OP_ASGN1.
[ruby-dev:28585]
* parse.y (arg): use NODE_ARGSCAT for placeholder.
* lib/getoptlong.rb (GetoptLong::get): RDoc update patch from
mathew <meta at pobox.com>. [ruby-core:07738]
* variable.c (rb_const_set): raise error when no target klass is
supplied. [ruby-dev:28582]
* prec.c (prec_prec_f): documentation patch from
<gerardo.santana at gmail.com>. [ruby-core:07689]
* bignum.c (rb_big_pow): second operand may be too big even if
it's a Fixnum. [ruby-talk:187984]
* README.EXT: update symbol description. [ruby-talk:188104]
* COPYING: explicitly note GPLv2. [ruby-talk:187922]
* parse.y: remove some obsolete syntax rules (unparenthesized
method calls in argument list).
* eval.c (rb_call0): insecure calling should be checked for non
NODE_SCOPE method invocations too.
* eval.c (rb_alias): should preserve the current safe level as
well as method definition.
* process.c (rb_f_sleep): remove RDoc description about SIGALRM
which is not valid on the current implementation. [ruby-dev:28464]
Thu Mar 23 21:40:47 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
* eval.c (method_missing): should support argument splat in
super. a bug in combination of super, splat and
method_missing. [ruby-talk:185438]
* configure.in: Solaris SunPro compiler -rapth patch from
<kuwa at labs.fujitsu.com>. [ruby-dev:28443]
* configure.in: remove enable_rpath=no for Solaris.
[ruby-dev:28440]
* ext/win32ole/win32ole.c (ole_val2olevariantdata): change behavior
of converting OLE Variant object with VT_ARRAY|VT_UI1 and Ruby
String object.
* ruby.1: a clarification patch from David Lutterkort
<dlutter at redhat.com>. [ruby-core:7508]
* lib/rdoc/ri/ri_paths.rb (RI::Paths): adding paths from rubygems
directories. a patch from Eric Hodel <drbrain at segment7.net>.
[ruby-core:07423]
* eval.c (rb_clear_cache_by_class): clearing wrong cache.
* ext/extmk.rb: use :remove_destination to install extension libraries
to avoid SEGV. [ruby-dev:28417]
* eval.c (rb_thread_fd_writable): should not re-schedule output
from KILLED thread (must be error printing).
* array.c (rb_ary_flatten_bang): allow specifying recursion
level. [ruby-talk:182170]
* array.c (rb_ary_flatten): ditto.
* gc.c (add_heap): a heap_slots may overflow. a patch from Stefan
Weil <weil at mail.berlios.de>.
* eval.c (rb_call): use separate cache for fcall/vcall
invocation.
* eval.c (rb_eval): NODE_FCALL, NODE_VCALL can call local
functions.
* eval.c (rb_mod_local): a new method to specify newly added
visibility "local".
* eval.c (search_method): search for local methods which are
visible only from the current class.
* class.c (rb_class_local_methods): a method to list local methods.
* object.c (Init_Object): add BasicObject class as a top level
BlankSlate class.
* ruby.h (SYM2ID): should not cast to signed long.
[ruby-core:07414]
* class.c (rb_include_module): allow module duplication.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-09 17:20:17 -04:00
|
|
|
* array.flatten(level) -> an_array
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
|
|
|
* Returns a new array that is a one-dimensional flattening of this
|
|
|
|
* array (recursively). That is, for every element that is an array,
|
* sprintf.c (rb_str_format): allow %c to print one character
string (e.g. ?x).
* lib/tempfile.rb (Tempfile::make_tmpname): put dot between
basename and pid. [ruby-talk:196272]
* parse.y (do_block): remove -> style block.
* parse.y (parser_yylex): remove tLAMBDA_ARG.
* eval.c (rb_call0): binding for the return event hook should have
consistent scope. [ruby-core:07928]
* eval.c (proc_invoke): return behavior should depend whether it
is surrounded by a lambda or a mere block.
* eval.c (formal_assign): handles post splat arguments.
* eval.c (rb_call0): ditto.
* st.c (strhash): use FNV-1a hash.
* parse.y (parser_yylex): removed experimental ';;' terminator.
* eval.c (rb_node_arity): should be aware of post splat arguments.
* eval.c (rb_proc_arity): ditto.
* parse.y (f_args): syntax rule enhanced to support arguments
after the splat.
* parse.y (block_param): ditto for block parameters.
* parse.y (f_post_arg): mandatory formal arguments after the splat
argument.
* parse.y (new_args_gen): generate nodes for mandatory formal
arguments after the splat argument.
* eval.c (rb_eval): dispatch mandatory formal arguments after the
splat argument.
* parse.y (args): allow more than one splat in the argument list.
* parse.y (method_call): allow aref [] to accept all kind of
method argument, including assocs, splat, and block argument.
* eval.c (SETUP_ARGS0): prepare block argument as well.
* lib/mathn.rb (Integer): remove Integer#gcd2. [ruby-core:07931]
* eval.c (error_line): print receivers true/false/nil specially.
* eval.c (rb_proc_yield): handles parameters in yield semantics.
* eval.c (nil_yield): gives LocalJumpError to denote no block
error.
* io.c (rb_io_getc): now takes one-character string.
* string.c (rb_str_hash): use FNV-1a hash from Fowler/Noll/Vo
hashing algorithm.
* string.c (rb_str_aref): str[0] now returns 1 character string,
instead of a fixnum. [Ruby2]
* parse.y (parser_yylex): ?c now returns 1 character string,
instead of a fixnum. [Ruby2]
* string.c (rb_str_aset): no longer support fixnum insertion.
* eval.c (umethod_bind): should not update original class.
[ruby-dev:28636]
* eval.c (ev_const_get): should support constant access from
within instance_eval(). [ruby-dev:28327]
* time.c (time_timeval): should round for usec floating
number. [ruby-core:07896]
* time.c (time_add): ditto.
* dir.c (sys_warning): should not call a vararg function
rb_sys_warning() indirectly. [ruby-core:07886]
* numeric.c (flo_divmod): the first element of Float#divmod should
be an integer. [ruby-dev:28589]
* test/ruby/test_float.rb: add tests for divmod, div, modulo and remainder.
* re.c (rb_reg_initialize): should not allow modifying literal
regexps. frozen check moved from rb_reg_initialize_m as well.
* re.c (rb_reg_initialize): should not modify untainted objects in
safe levels higher than 3.
* re.c (rb_memcmp): type change from char* to const void*.
* dir.c (dir_close): should not close untainted dir stream.
* dir.c (GetDIR): add tainted/frozen check for each dir operation.
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_symbol_arg):
typo fixed. a patch from Florian Gross <florg at florg.net>.
* eval.c (EXEC_EVENT_HOOK): trace_func may remove itself from
event_hooks. no guarantee for arbitrary hook deletion.
[ruby-dev:28632]
* util.c (ruby_strtod): differ addition to minimize error.
[ruby-dev:28619]
* util.c (ruby_strtod): should not raise ERANGE when the input
string does not have any digits. [ruby-dev:28629]
* eval.c (proc_invoke): should restore old ruby_frame->block.
thanks to ts <decoux at moulon.inra.fr>. [ruby-core:07833]
also fix [ruby-dev:28614] as well.
* signal.c (trap): sig should be less then NSIG. Coverity found
this bug. a patch from Kevin Tew <tewk at tewk.com>.
[ruby-core:07823]
* math.c (math_log2): add new method inspired by
[ruby-talk:191237].
* math.c (math_log): add optional base argument to Math::log().
[ruby-talk:191308]
* ext/syck/emitter.c (syck_scan_scalar): avoid accessing
uninitialized array element. a patch from Pat Eyler
<rubypate at gmail.com>. [ruby-core:07809]
* array.c (rb_ary_fill): initialize local variables first. a
patch from Pat Eyler <rubypate at gmail.com>. [ruby-core:07810]
* ext/syck/yaml2byte.c (syck_yaml2byte_handler): need to free
type_tag. a patch from Pat Eyler <rubypate at gmail.com>.
[ruby-core:07808]
* ext/socket/socket.c (make_hostent_internal): accept ai_family
check from Sam Roberts <sroberts at uniserve.com>.
[ruby-core:07691]
* util.c (ruby_strtod): should not cut off 18 digits for no
reason. [ruby-core:07796]
* array.c (rb_ary_fill): internalize local variable "beg" to
pacify Coverity. [ruby-core:07770]
* pack.c (pack_unpack): now supports CRLF newlines. a patch from
<tommy at tmtm.org>. [ruby-dev:28601]
* applied code clean-up patch from Stefan Huehner
<stefan at huehner.org>. [ruby-core:07764]
* lib/jcode.rb (String::tr_s): should have translated non
squeezing character sequence (i.e. a character) as well. thanks
to Hiroshi Ichikawa <gimite at gimite.ddo.jp> [ruby-list:42090]
* ext/socket/socket.c: document update patch from Sam Roberts
<sroberts at uniserve.com>. [ruby-core:07701]
* lib/mathn.rb (Integer): need not to remove gcd2. a patch from
NARUSE, Yui <naruse at airemix.com>. [ruby-dev:28570]
* parse.y (arg): too much NEW_LIST()
* eval.c (SETUP_ARGS0): remove unnecessary access to nd_alen.
* eval.c (rb_eval): use ARGSCAT for NODE_OP_ASGN1.
[ruby-dev:28585]
* parse.y (arg): use NODE_ARGSCAT for placeholder.
* lib/getoptlong.rb (GetoptLong::get): RDoc update patch from
mathew <meta at pobox.com>. [ruby-core:07738]
* variable.c (rb_const_set): raise error when no target klass is
supplied. [ruby-dev:28582]
* prec.c (prec_prec_f): documentation patch from
<gerardo.santana at gmail.com>. [ruby-core:07689]
* bignum.c (rb_big_pow): second operand may be too big even if
it's a Fixnum. [ruby-talk:187984]
* README.EXT: update symbol description. [ruby-talk:188104]
* COPYING: explicitly note GPLv2. [ruby-talk:187922]
* parse.y: remove some obsolete syntax rules (unparenthesized
method calls in argument list).
* eval.c (rb_call0): insecure calling should be checked for non
NODE_SCOPE method invocations too.
* eval.c (rb_alias): should preserve the current safe level as
well as method definition.
* process.c (rb_f_sleep): remove RDoc description about SIGALRM
which is not valid on the current implementation. [ruby-dev:28464]
Thu Mar 23 21:40:47 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
* eval.c (method_missing): should support argument splat in
super. a bug in combination of super, splat and
method_missing. [ruby-talk:185438]
* configure.in: Solaris SunPro compiler -rapth patch from
<kuwa at labs.fujitsu.com>. [ruby-dev:28443]
* configure.in: remove enable_rpath=no for Solaris.
[ruby-dev:28440]
* ext/win32ole/win32ole.c (ole_val2olevariantdata): change behavior
of converting OLE Variant object with VT_ARRAY|VT_UI1 and Ruby
String object.
* ruby.1: a clarification patch from David Lutterkort
<dlutter at redhat.com>. [ruby-core:7508]
* lib/rdoc/ri/ri_paths.rb (RI::Paths): adding paths from rubygems
directories. a patch from Eric Hodel <drbrain at segment7.net>.
[ruby-core:07423]
* eval.c (rb_clear_cache_by_class): clearing wrong cache.
* ext/extmk.rb: use :remove_destination to install extension libraries
to avoid SEGV. [ruby-dev:28417]
* eval.c (rb_thread_fd_writable): should not re-schedule output
from KILLED thread (must be error printing).
* array.c (rb_ary_flatten_bang): allow specifying recursion
level. [ruby-talk:182170]
* array.c (rb_ary_flatten): ditto.
* gc.c (add_heap): a heap_slots may overflow. a patch from Stefan
Weil <weil at mail.berlios.de>.
* eval.c (rb_call): use separate cache for fcall/vcall
invocation.
* eval.c (rb_eval): NODE_FCALL, NODE_VCALL can call local
functions.
* eval.c (rb_mod_local): a new method to specify newly added
visibility "local".
* eval.c (search_method): search for local methods which are
visible only from the current class.
* class.c (rb_class_local_methods): a method to list local methods.
* object.c (Init_Object): add BasicObject class as a top level
BlankSlate class.
* ruby.h (SYM2ID): should not cast to signed long.
[ruby-core:07414]
* class.c (rb_include_module): allow module duplication.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-09 17:20:17 -04:00
|
|
|
* extract its elements into the new array. If the optional
|
|
|
|
* <i>level</i> argument determins the level of recursion to flatten.
|
2003-12-16 15:28:44 -05:00
|
|
|
*
|
|
|
|
* s = [ 1, 2, 3 ] #=> [1, 2, 3]
|
|
|
|
* t = [ 4, 5, 6, [7, 8] ] #=> [4, 5, 6, [7, 8]]
|
|
|
|
* a = [ s, t, 9, 10 ] #=> [[1, 2, 3], [4, 5, 6, [7, 8]], 9, 10]
|
|
|
|
* a.flatten #=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10
|
* sprintf.c (rb_str_format): allow %c to print one character
string (e.g. ?x).
* lib/tempfile.rb (Tempfile::make_tmpname): put dot between
basename and pid. [ruby-talk:196272]
* parse.y (do_block): remove -> style block.
* parse.y (parser_yylex): remove tLAMBDA_ARG.
* eval.c (rb_call0): binding for the return event hook should have
consistent scope. [ruby-core:07928]
* eval.c (proc_invoke): return behavior should depend whether it
is surrounded by a lambda or a mere block.
* eval.c (formal_assign): handles post splat arguments.
* eval.c (rb_call0): ditto.
* st.c (strhash): use FNV-1a hash.
* parse.y (parser_yylex): removed experimental ';;' terminator.
* eval.c (rb_node_arity): should be aware of post splat arguments.
* eval.c (rb_proc_arity): ditto.
* parse.y (f_args): syntax rule enhanced to support arguments
after the splat.
* parse.y (block_param): ditto for block parameters.
* parse.y (f_post_arg): mandatory formal arguments after the splat
argument.
* parse.y (new_args_gen): generate nodes for mandatory formal
arguments after the splat argument.
* eval.c (rb_eval): dispatch mandatory formal arguments after the
splat argument.
* parse.y (args): allow more than one splat in the argument list.
* parse.y (method_call): allow aref [] to accept all kind of
method argument, including assocs, splat, and block argument.
* eval.c (SETUP_ARGS0): prepare block argument as well.
* lib/mathn.rb (Integer): remove Integer#gcd2. [ruby-core:07931]
* eval.c (error_line): print receivers true/false/nil specially.
* eval.c (rb_proc_yield): handles parameters in yield semantics.
* eval.c (nil_yield): gives LocalJumpError to denote no block
error.
* io.c (rb_io_getc): now takes one-character string.
* string.c (rb_str_hash): use FNV-1a hash from Fowler/Noll/Vo
hashing algorithm.
* string.c (rb_str_aref): str[0] now returns 1 character string,
instead of a fixnum. [Ruby2]
* parse.y (parser_yylex): ?c now returns 1 character string,
instead of a fixnum. [Ruby2]
* string.c (rb_str_aset): no longer support fixnum insertion.
* eval.c (umethod_bind): should not update original class.
[ruby-dev:28636]
* eval.c (ev_const_get): should support constant access from
within instance_eval(). [ruby-dev:28327]
* time.c (time_timeval): should round for usec floating
number. [ruby-core:07896]
* time.c (time_add): ditto.
* dir.c (sys_warning): should not call a vararg function
rb_sys_warning() indirectly. [ruby-core:07886]
* numeric.c (flo_divmod): the first element of Float#divmod should
be an integer. [ruby-dev:28589]
* test/ruby/test_float.rb: add tests for divmod, div, modulo and remainder.
* re.c (rb_reg_initialize): should not allow modifying literal
regexps. frozen check moved from rb_reg_initialize_m as well.
* re.c (rb_reg_initialize): should not modify untainted objects in
safe levels higher than 3.
* re.c (rb_memcmp): type change from char* to const void*.
* dir.c (dir_close): should not close untainted dir stream.
* dir.c (GetDIR): add tainted/frozen check for each dir operation.
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_symbol_arg):
typo fixed. a patch from Florian Gross <florg at florg.net>.
* eval.c (EXEC_EVENT_HOOK): trace_func may remove itself from
event_hooks. no guarantee for arbitrary hook deletion.
[ruby-dev:28632]
* util.c (ruby_strtod): differ addition to minimize error.
[ruby-dev:28619]
* util.c (ruby_strtod): should not raise ERANGE when the input
string does not have any digits. [ruby-dev:28629]
* eval.c (proc_invoke): should restore old ruby_frame->block.
thanks to ts <decoux at moulon.inra.fr>. [ruby-core:07833]
also fix [ruby-dev:28614] as well.
* signal.c (trap): sig should be less then NSIG. Coverity found
this bug. a patch from Kevin Tew <tewk at tewk.com>.
[ruby-core:07823]
* math.c (math_log2): add new method inspired by
[ruby-talk:191237].
* math.c (math_log): add optional base argument to Math::log().
[ruby-talk:191308]
* ext/syck/emitter.c (syck_scan_scalar): avoid accessing
uninitialized array element. a patch from Pat Eyler
<rubypate at gmail.com>. [ruby-core:07809]
* array.c (rb_ary_fill): initialize local variables first. a
patch from Pat Eyler <rubypate at gmail.com>. [ruby-core:07810]
* ext/syck/yaml2byte.c (syck_yaml2byte_handler): need to free
type_tag. a patch from Pat Eyler <rubypate at gmail.com>.
[ruby-core:07808]
* ext/socket/socket.c (make_hostent_internal): accept ai_family
check from Sam Roberts <sroberts at uniserve.com>.
[ruby-core:07691]
* util.c (ruby_strtod): should not cut off 18 digits for no
reason. [ruby-core:07796]
* array.c (rb_ary_fill): internalize local variable "beg" to
pacify Coverity. [ruby-core:07770]
* pack.c (pack_unpack): now supports CRLF newlines. a patch from
<tommy at tmtm.org>. [ruby-dev:28601]
* applied code clean-up patch from Stefan Huehner
<stefan at huehner.org>. [ruby-core:07764]
* lib/jcode.rb (String::tr_s): should have translated non
squeezing character sequence (i.e. a character) as well. thanks
to Hiroshi Ichikawa <gimite at gimite.ddo.jp> [ruby-list:42090]
* ext/socket/socket.c: document update patch from Sam Roberts
<sroberts at uniserve.com>. [ruby-core:07701]
* lib/mathn.rb (Integer): need not to remove gcd2. a patch from
NARUSE, Yui <naruse at airemix.com>. [ruby-dev:28570]
* parse.y (arg): too much NEW_LIST()
* eval.c (SETUP_ARGS0): remove unnecessary access to nd_alen.
* eval.c (rb_eval): use ARGSCAT for NODE_OP_ASGN1.
[ruby-dev:28585]
* parse.y (arg): use NODE_ARGSCAT for placeholder.
* lib/getoptlong.rb (GetoptLong::get): RDoc update patch from
mathew <meta at pobox.com>. [ruby-core:07738]
* variable.c (rb_const_set): raise error when no target klass is
supplied. [ruby-dev:28582]
* prec.c (prec_prec_f): documentation patch from
<gerardo.santana at gmail.com>. [ruby-core:07689]
* bignum.c (rb_big_pow): second operand may be too big even if
it's a Fixnum. [ruby-talk:187984]
* README.EXT: update symbol description. [ruby-talk:188104]
* COPYING: explicitly note GPLv2. [ruby-talk:187922]
* parse.y: remove some obsolete syntax rules (unparenthesized
method calls in argument list).
* eval.c (rb_call0): insecure calling should be checked for non
NODE_SCOPE method invocations too.
* eval.c (rb_alias): should preserve the current safe level as
well as method definition.
* process.c (rb_f_sleep): remove RDoc description about SIGALRM
which is not valid on the current implementation. [ruby-dev:28464]
Thu Mar 23 21:40:47 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
* eval.c (method_missing): should support argument splat in
super. a bug in combination of super, splat and
method_missing. [ruby-talk:185438]
* configure.in: Solaris SunPro compiler -rapth patch from
<kuwa at labs.fujitsu.com>. [ruby-dev:28443]
* configure.in: remove enable_rpath=no for Solaris.
[ruby-dev:28440]
* ext/win32ole/win32ole.c (ole_val2olevariantdata): change behavior
of converting OLE Variant object with VT_ARRAY|VT_UI1 and Ruby
String object.
* ruby.1: a clarification patch from David Lutterkort
<dlutter at redhat.com>. [ruby-core:7508]
* lib/rdoc/ri/ri_paths.rb (RI::Paths): adding paths from rubygems
directories. a patch from Eric Hodel <drbrain at segment7.net>.
[ruby-core:07423]
* eval.c (rb_clear_cache_by_class): clearing wrong cache.
* ext/extmk.rb: use :remove_destination to install extension libraries
to avoid SEGV. [ruby-dev:28417]
* eval.c (rb_thread_fd_writable): should not re-schedule output
from KILLED thread (must be error printing).
* array.c (rb_ary_flatten_bang): allow specifying recursion
level. [ruby-talk:182170]
* array.c (rb_ary_flatten): ditto.
* gc.c (add_heap): a heap_slots may overflow. a patch from Stefan
Weil <weil at mail.berlios.de>.
* eval.c (rb_call): use separate cache for fcall/vcall
invocation.
* eval.c (rb_eval): NODE_FCALL, NODE_VCALL can call local
functions.
* eval.c (rb_mod_local): a new method to specify newly added
visibility "local".
* eval.c (search_method): search for local methods which are
visible only from the current class.
* class.c (rb_class_local_methods): a method to list local methods.
* object.c (Init_Object): add BasicObject class as a top level
BlankSlate class.
* ruby.h (SYM2ID): should not cast to signed long.
[ruby-core:07414]
* class.c (rb_include_module): allow module duplication.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-09 17:20:17 -04:00
|
|
|
* a = [ 1, 2, [3, [4, 5] ] ]
|
|
|
|
* a.flatten(1) #=> [1, 2, 3, [4, 5]]
|
2003-12-16 15:28:44 -05:00
|
|
|
*/
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
static VALUE
|
* sprintf.c (rb_str_format): allow %c to print one character
string (e.g. ?x).
* lib/tempfile.rb (Tempfile::make_tmpname): put dot between
basename and pid. [ruby-talk:196272]
* parse.y (do_block): remove -> style block.
* parse.y (parser_yylex): remove tLAMBDA_ARG.
* eval.c (rb_call0): binding for the return event hook should have
consistent scope. [ruby-core:07928]
* eval.c (proc_invoke): return behavior should depend whether it
is surrounded by a lambda or a mere block.
* eval.c (formal_assign): handles post splat arguments.
* eval.c (rb_call0): ditto.
* st.c (strhash): use FNV-1a hash.
* parse.y (parser_yylex): removed experimental ';;' terminator.
* eval.c (rb_node_arity): should be aware of post splat arguments.
* eval.c (rb_proc_arity): ditto.
* parse.y (f_args): syntax rule enhanced to support arguments
after the splat.
* parse.y (block_param): ditto for block parameters.
* parse.y (f_post_arg): mandatory formal arguments after the splat
argument.
* parse.y (new_args_gen): generate nodes for mandatory formal
arguments after the splat argument.
* eval.c (rb_eval): dispatch mandatory formal arguments after the
splat argument.
* parse.y (args): allow more than one splat in the argument list.
* parse.y (method_call): allow aref [] to accept all kind of
method argument, including assocs, splat, and block argument.
* eval.c (SETUP_ARGS0): prepare block argument as well.
* lib/mathn.rb (Integer): remove Integer#gcd2. [ruby-core:07931]
* eval.c (error_line): print receivers true/false/nil specially.
* eval.c (rb_proc_yield): handles parameters in yield semantics.
* eval.c (nil_yield): gives LocalJumpError to denote no block
error.
* io.c (rb_io_getc): now takes one-character string.
* string.c (rb_str_hash): use FNV-1a hash from Fowler/Noll/Vo
hashing algorithm.
* string.c (rb_str_aref): str[0] now returns 1 character string,
instead of a fixnum. [Ruby2]
* parse.y (parser_yylex): ?c now returns 1 character string,
instead of a fixnum. [Ruby2]
* string.c (rb_str_aset): no longer support fixnum insertion.
* eval.c (umethod_bind): should not update original class.
[ruby-dev:28636]
* eval.c (ev_const_get): should support constant access from
within instance_eval(). [ruby-dev:28327]
* time.c (time_timeval): should round for usec floating
number. [ruby-core:07896]
* time.c (time_add): ditto.
* dir.c (sys_warning): should not call a vararg function
rb_sys_warning() indirectly. [ruby-core:07886]
* numeric.c (flo_divmod): the first element of Float#divmod should
be an integer. [ruby-dev:28589]
* test/ruby/test_float.rb: add tests for divmod, div, modulo and remainder.
* re.c (rb_reg_initialize): should not allow modifying literal
regexps. frozen check moved from rb_reg_initialize_m as well.
* re.c (rb_reg_initialize): should not modify untainted objects in
safe levels higher than 3.
* re.c (rb_memcmp): type change from char* to const void*.
* dir.c (dir_close): should not close untainted dir stream.
* dir.c (GetDIR): add tainted/frozen check for each dir operation.
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_symbol_arg):
typo fixed. a patch from Florian Gross <florg at florg.net>.
* eval.c (EXEC_EVENT_HOOK): trace_func may remove itself from
event_hooks. no guarantee for arbitrary hook deletion.
[ruby-dev:28632]
* util.c (ruby_strtod): differ addition to minimize error.
[ruby-dev:28619]
* util.c (ruby_strtod): should not raise ERANGE when the input
string does not have any digits. [ruby-dev:28629]
* eval.c (proc_invoke): should restore old ruby_frame->block.
thanks to ts <decoux at moulon.inra.fr>. [ruby-core:07833]
also fix [ruby-dev:28614] as well.
* signal.c (trap): sig should be less then NSIG. Coverity found
this bug. a patch from Kevin Tew <tewk at tewk.com>.
[ruby-core:07823]
* math.c (math_log2): add new method inspired by
[ruby-talk:191237].
* math.c (math_log): add optional base argument to Math::log().
[ruby-talk:191308]
* ext/syck/emitter.c (syck_scan_scalar): avoid accessing
uninitialized array element. a patch from Pat Eyler
<rubypate at gmail.com>. [ruby-core:07809]
* array.c (rb_ary_fill): initialize local variables first. a
patch from Pat Eyler <rubypate at gmail.com>. [ruby-core:07810]
* ext/syck/yaml2byte.c (syck_yaml2byte_handler): need to free
type_tag. a patch from Pat Eyler <rubypate at gmail.com>.
[ruby-core:07808]
* ext/socket/socket.c (make_hostent_internal): accept ai_family
check from Sam Roberts <sroberts at uniserve.com>.
[ruby-core:07691]
* util.c (ruby_strtod): should not cut off 18 digits for no
reason. [ruby-core:07796]
* array.c (rb_ary_fill): internalize local variable "beg" to
pacify Coverity. [ruby-core:07770]
* pack.c (pack_unpack): now supports CRLF newlines. a patch from
<tommy at tmtm.org>. [ruby-dev:28601]
* applied code clean-up patch from Stefan Huehner
<stefan at huehner.org>. [ruby-core:07764]
* lib/jcode.rb (String::tr_s): should have translated non
squeezing character sequence (i.e. a character) as well. thanks
to Hiroshi Ichikawa <gimite at gimite.ddo.jp> [ruby-list:42090]
* ext/socket/socket.c: document update patch from Sam Roberts
<sroberts at uniserve.com>. [ruby-core:07701]
* lib/mathn.rb (Integer): need not to remove gcd2. a patch from
NARUSE, Yui <naruse at airemix.com>. [ruby-dev:28570]
* parse.y (arg): too much NEW_LIST()
* eval.c (SETUP_ARGS0): remove unnecessary access to nd_alen.
* eval.c (rb_eval): use ARGSCAT for NODE_OP_ASGN1.
[ruby-dev:28585]
* parse.y (arg): use NODE_ARGSCAT for placeholder.
* lib/getoptlong.rb (GetoptLong::get): RDoc update patch from
mathew <meta at pobox.com>. [ruby-core:07738]
* variable.c (rb_const_set): raise error when no target klass is
supplied. [ruby-dev:28582]
* prec.c (prec_prec_f): documentation patch from
<gerardo.santana at gmail.com>. [ruby-core:07689]
* bignum.c (rb_big_pow): second operand may be too big even if
it's a Fixnum. [ruby-talk:187984]
* README.EXT: update symbol description. [ruby-talk:188104]
* COPYING: explicitly note GPLv2. [ruby-talk:187922]
* parse.y: remove some obsolete syntax rules (unparenthesized
method calls in argument list).
* eval.c (rb_call0): insecure calling should be checked for non
NODE_SCOPE method invocations too.
* eval.c (rb_alias): should preserve the current safe level as
well as method definition.
* process.c (rb_f_sleep): remove RDoc description about SIGALRM
which is not valid on the current implementation. [ruby-dev:28464]
Thu Mar 23 21:40:47 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
* eval.c (method_missing): should support argument splat in
super. a bug in combination of super, splat and
method_missing. [ruby-talk:185438]
* configure.in: Solaris SunPro compiler -rapth patch from
<kuwa at labs.fujitsu.com>. [ruby-dev:28443]
* configure.in: remove enable_rpath=no for Solaris.
[ruby-dev:28440]
* ext/win32ole/win32ole.c (ole_val2olevariantdata): change behavior
of converting OLE Variant object with VT_ARRAY|VT_UI1 and Ruby
String object.
* ruby.1: a clarification patch from David Lutterkort
<dlutter at redhat.com>. [ruby-core:7508]
* lib/rdoc/ri/ri_paths.rb (RI::Paths): adding paths from rubygems
directories. a patch from Eric Hodel <drbrain at segment7.net>.
[ruby-core:07423]
* eval.c (rb_clear_cache_by_class): clearing wrong cache.
* ext/extmk.rb: use :remove_destination to install extension libraries
to avoid SEGV. [ruby-dev:28417]
* eval.c (rb_thread_fd_writable): should not re-schedule output
from KILLED thread (must be error printing).
* array.c (rb_ary_flatten_bang): allow specifying recursion
level. [ruby-talk:182170]
* array.c (rb_ary_flatten): ditto.
* gc.c (add_heap): a heap_slots may overflow. a patch from Stefan
Weil <weil at mail.berlios.de>.
* eval.c (rb_call): use separate cache for fcall/vcall
invocation.
* eval.c (rb_eval): NODE_FCALL, NODE_VCALL can call local
functions.
* eval.c (rb_mod_local): a new method to specify newly added
visibility "local".
* eval.c (search_method): search for local methods which are
visible only from the current class.
* class.c (rb_class_local_methods): a method to list local methods.
* object.c (Init_Object): add BasicObject class as a top level
BlankSlate class.
* ruby.h (SYM2ID): should not cast to signed long.
[ruby-core:07414]
* class.c (rb_include_module): allow module duplication.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-09 17:20:17 -04:00
|
|
|
rb_ary_flatten(int argc, VALUE *argv, VALUE ary)
|
1999-01-19 23:59:39 -05:00
|
|
|
{
|
2002-08-27 04:31:08 -04:00
|
|
|
ary = rb_ary_dup(ary);
|
* sprintf.c (rb_str_format): allow %c to print one character
string (e.g. ?x).
* lib/tempfile.rb (Tempfile::make_tmpname): put dot between
basename and pid. [ruby-talk:196272]
* parse.y (do_block): remove -> style block.
* parse.y (parser_yylex): remove tLAMBDA_ARG.
* eval.c (rb_call0): binding for the return event hook should have
consistent scope. [ruby-core:07928]
* eval.c (proc_invoke): return behavior should depend whether it
is surrounded by a lambda or a mere block.
* eval.c (formal_assign): handles post splat arguments.
* eval.c (rb_call0): ditto.
* st.c (strhash): use FNV-1a hash.
* parse.y (parser_yylex): removed experimental ';;' terminator.
* eval.c (rb_node_arity): should be aware of post splat arguments.
* eval.c (rb_proc_arity): ditto.
* parse.y (f_args): syntax rule enhanced to support arguments
after the splat.
* parse.y (block_param): ditto for block parameters.
* parse.y (f_post_arg): mandatory formal arguments after the splat
argument.
* parse.y (new_args_gen): generate nodes for mandatory formal
arguments after the splat argument.
* eval.c (rb_eval): dispatch mandatory formal arguments after the
splat argument.
* parse.y (args): allow more than one splat in the argument list.
* parse.y (method_call): allow aref [] to accept all kind of
method argument, including assocs, splat, and block argument.
* eval.c (SETUP_ARGS0): prepare block argument as well.
* lib/mathn.rb (Integer): remove Integer#gcd2. [ruby-core:07931]
* eval.c (error_line): print receivers true/false/nil specially.
* eval.c (rb_proc_yield): handles parameters in yield semantics.
* eval.c (nil_yield): gives LocalJumpError to denote no block
error.
* io.c (rb_io_getc): now takes one-character string.
* string.c (rb_str_hash): use FNV-1a hash from Fowler/Noll/Vo
hashing algorithm.
* string.c (rb_str_aref): str[0] now returns 1 character string,
instead of a fixnum. [Ruby2]
* parse.y (parser_yylex): ?c now returns 1 character string,
instead of a fixnum. [Ruby2]
* string.c (rb_str_aset): no longer support fixnum insertion.
* eval.c (umethod_bind): should not update original class.
[ruby-dev:28636]
* eval.c (ev_const_get): should support constant access from
within instance_eval(). [ruby-dev:28327]
* time.c (time_timeval): should round for usec floating
number. [ruby-core:07896]
* time.c (time_add): ditto.
* dir.c (sys_warning): should not call a vararg function
rb_sys_warning() indirectly. [ruby-core:07886]
* numeric.c (flo_divmod): the first element of Float#divmod should
be an integer. [ruby-dev:28589]
* test/ruby/test_float.rb: add tests for divmod, div, modulo and remainder.
* re.c (rb_reg_initialize): should not allow modifying literal
regexps. frozen check moved from rb_reg_initialize_m as well.
* re.c (rb_reg_initialize): should not modify untainted objects in
safe levels higher than 3.
* re.c (rb_memcmp): type change from char* to const void*.
* dir.c (dir_close): should not close untainted dir stream.
* dir.c (GetDIR): add tainted/frozen check for each dir operation.
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_symbol_arg):
typo fixed. a patch from Florian Gross <florg at florg.net>.
* eval.c (EXEC_EVENT_HOOK): trace_func may remove itself from
event_hooks. no guarantee for arbitrary hook deletion.
[ruby-dev:28632]
* util.c (ruby_strtod): differ addition to minimize error.
[ruby-dev:28619]
* util.c (ruby_strtod): should not raise ERANGE when the input
string does not have any digits. [ruby-dev:28629]
* eval.c (proc_invoke): should restore old ruby_frame->block.
thanks to ts <decoux at moulon.inra.fr>. [ruby-core:07833]
also fix [ruby-dev:28614] as well.
* signal.c (trap): sig should be less then NSIG. Coverity found
this bug. a patch from Kevin Tew <tewk at tewk.com>.
[ruby-core:07823]
* math.c (math_log2): add new method inspired by
[ruby-talk:191237].
* math.c (math_log): add optional base argument to Math::log().
[ruby-talk:191308]
* ext/syck/emitter.c (syck_scan_scalar): avoid accessing
uninitialized array element. a patch from Pat Eyler
<rubypate at gmail.com>. [ruby-core:07809]
* array.c (rb_ary_fill): initialize local variables first. a
patch from Pat Eyler <rubypate at gmail.com>. [ruby-core:07810]
* ext/syck/yaml2byte.c (syck_yaml2byte_handler): need to free
type_tag. a patch from Pat Eyler <rubypate at gmail.com>.
[ruby-core:07808]
* ext/socket/socket.c (make_hostent_internal): accept ai_family
check from Sam Roberts <sroberts at uniserve.com>.
[ruby-core:07691]
* util.c (ruby_strtod): should not cut off 18 digits for no
reason. [ruby-core:07796]
* array.c (rb_ary_fill): internalize local variable "beg" to
pacify Coverity. [ruby-core:07770]
* pack.c (pack_unpack): now supports CRLF newlines. a patch from
<tommy at tmtm.org>. [ruby-dev:28601]
* applied code clean-up patch from Stefan Huehner
<stefan at huehner.org>. [ruby-core:07764]
* lib/jcode.rb (String::tr_s): should have translated non
squeezing character sequence (i.e. a character) as well. thanks
to Hiroshi Ichikawa <gimite at gimite.ddo.jp> [ruby-list:42090]
* ext/socket/socket.c: document update patch from Sam Roberts
<sroberts at uniserve.com>. [ruby-core:07701]
* lib/mathn.rb (Integer): need not to remove gcd2. a patch from
NARUSE, Yui <naruse at airemix.com>. [ruby-dev:28570]
* parse.y (arg): too much NEW_LIST()
* eval.c (SETUP_ARGS0): remove unnecessary access to nd_alen.
* eval.c (rb_eval): use ARGSCAT for NODE_OP_ASGN1.
[ruby-dev:28585]
* parse.y (arg): use NODE_ARGSCAT for placeholder.
* lib/getoptlong.rb (GetoptLong::get): RDoc update patch from
mathew <meta at pobox.com>. [ruby-core:07738]
* variable.c (rb_const_set): raise error when no target klass is
supplied. [ruby-dev:28582]
* prec.c (prec_prec_f): documentation patch from
<gerardo.santana at gmail.com>. [ruby-core:07689]
* bignum.c (rb_big_pow): second operand may be too big even if
it's a Fixnum. [ruby-talk:187984]
* README.EXT: update symbol description. [ruby-talk:188104]
* COPYING: explicitly note GPLv2. [ruby-talk:187922]
* parse.y: remove some obsolete syntax rules (unparenthesized
method calls in argument list).
* eval.c (rb_call0): insecure calling should be checked for non
NODE_SCOPE method invocations too.
* eval.c (rb_alias): should preserve the current safe level as
well as method definition.
* process.c (rb_f_sleep): remove RDoc description about SIGALRM
which is not valid on the current implementation. [ruby-dev:28464]
Thu Mar 23 21:40:47 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
* eval.c (method_missing): should support argument splat in
super. a bug in combination of super, splat and
method_missing. [ruby-talk:185438]
* configure.in: Solaris SunPro compiler -rapth patch from
<kuwa at labs.fujitsu.com>. [ruby-dev:28443]
* configure.in: remove enable_rpath=no for Solaris.
[ruby-dev:28440]
* ext/win32ole/win32ole.c (ole_val2olevariantdata): change behavior
of converting OLE Variant object with VT_ARRAY|VT_UI1 and Ruby
String object.
* ruby.1: a clarification patch from David Lutterkort
<dlutter at redhat.com>. [ruby-core:7508]
* lib/rdoc/ri/ri_paths.rb (RI::Paths): adding paths from rubygems
directories. a patch from Eric Hodel <drbrain at segment7.net>.
[ruby-core:07423]
* eval.c (rb_clear_cache_by_class): clearing wrong cache.
* ext/extmk.rb: use :remove_destination to install extension libraries
to avoid SEGV. [ruby-dev:28417]
* eval.c (rb_thread_fd_writable): should not re-schedule output
from KILLED thread (must be error printing).
* array.c (rb_ary_flatten_bang): allow specifying recursion
level. [ruby-talk:182170]
* array.c (rb_ary_flatten): ditto.
* gc.c (add_heap): a heap_slots may overflow. a patch from Stefan
Weil <weil at mail.berlios.de>.
* eval.c (rb_call): use separate cache for fcall/vcall
invocation.
* eval.c (rb_eval): NODE_FCALL, NODE_VCALL can call local
functions.
* eval.c (rb_mod_local): a new method to specify newly added
visibility "local".
* eval.c (search_method): search for local methods which are
visible only from the current class.
* class.c (rb_class_local_methods): a method to list local methods.
* object.c (Init_Object): add BasicObject class as a top level
BlankSlate class.
* ruby.h (SYM2ID): should not cast to signed long.
[ruby-core:07414]
* class.c (rb_include_module): allow module duplication.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-09 17:20:17 -04:00
|
|
|
rb_ary_flatten_bang(argc, argv, ary);
|
1999-10-20 03:10:23 -04:00
|
|
|
return ary;
|
1999-01-19 23:59:39 -05:00
|
|
|
}
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2006-08-31 04:24:36 -04:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* array.shuffle! -> array or
|
|
|
|
*
|
|
|
|
* Shuffles elements in _self_ in place.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
static VALUE
|
|
|
|
rb_ary_shuffle_bang(VALUE ary)
|
|
|
|
{
|
2006-09-02 10:42:08 -04:00
|
|
|
long i = RARRAY_LEN(ary);
|
2006-08-31 04:24:36 -04:00
|
|
|
|
* array.c (ary_iter_check): should check modification (size
change) during iteration.
* array.c (rb_ary_initialize, rb_ary_shift, rb_ary_unshift,
rb_ary_splice, rb_ary_reverse, rb_ary_sort, rb_ary_delete,
rb_ary_delete_at, rb_ary_reject_bang, rb_ary_replace,
rb_ary_clear, rb_ary_fill, rb_ary_uniq_bang, rb_ary_compact,
rb_ary_shuffle): add iteration check.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-12-29 14:25:11 -05:00
|
|
|
rb_ary_modify(ary);
|
|
|
|
ary_iter_check(ary);
|
2006-08-31 04:24:36 -04:00
|
|
|
while (i) {
|
|
|
|
long j = genrand_real()*i;
|
2006-09-02 10:42:08 -04:00
|
|
|
VALUE tmp = RARRAY_PTR(ary)[--i];
|
|
|
|
RARRAY_PTR(ary)[i] = RARRAY_PTR(ary)[j];
|
|
|
|
RARRAY_PTR(ary)[j] = tmp;
|
2006-08-31 04:24:36 -04:00
|
|
|
}
|
|
|
|
return ary;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* array.shuffle -> an_array
|
|
|
|
*
|
2006-09-01 09:07:05 -04:00
|
|
|
* Returns a new array with elements of this array shuffled.
|
2006-08-31 04:24:36 -04:00
|
|
|
*
|
2006-09-01 01:24:05 -04:00
|
|
|
* a = [ 1, 2, 3 ] #=> [1, 2, 3]
|
|
|
|
* a.shuffle #=> [2, 3, 1]
|
2006-08-31 04:24:36 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
static VALUE
|
|
|
|
rb_ary_shuffle(VALUE ary)
|
|
|
|
{
|
|
|
|
ary = rb_ary_dup(ary);
|
|
|
|
rb_ary_shuffle_bang(ary);
|
|
|
|
return ary;
|
|
|
|
}
|
|
|
|
|
2003-12-16 15:28:44 -05:00
|
|
|
|
|
|
|
/* Arrays are ordered, integer-indexed collections of any object.
|
|
|
|
* Array indexing starts at 0, as in C or Java. A negative index is
|
|
|
|
* assumed to be relative to the end of the array---that is, an index of -1
|
|
|
|
* indicates the last element of the array, -2 is the next to last
|
|
|
|
* element in the array, and so on.
|
|
|
|
*/
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
void
|
2005-09-10 09:34:53 -04:00
|
|
|
Init_Array(void)
|
1999-01-19 23:59:39 -05:00
|
|
|
{
|
|
|
|
rb_cArray = rb_define_class("Array", rb_cObject);
|
|
|
|
rb_include_module(rb_cArray, rb_mEnumerable);
|
|
|
|
|
2002-12-20 03:33:17 -05:00
|
|
|
rb_define_alloc_func(rb_cArray, ary_alloc);
|
1999-01-19 23:59:39 -05:00
|
|
|
rb_define_singleton_method(rb_cArray, "[]", rb_ary_s_create, -1);
|
2000-02-29 03:05:32 -05:00
|
|
|
rb_define_method(rb_cArray, "initialize", rb_ary_initialize, -1);
|
2003-05-19 01:41:08 -04:00
|
|
|
rb_define_method(rb_cArray, "initialize_copy", rb_ary_replace, 1);
|
2003-04-03 00:25:00 -05:00
|
|
|
|
2006-09-07 12:33:08 -04:00
|
|
|
rb_define_method(rb_cArray, "to_s", rb_ary_inspect, 0);
|
1999-01-19 23:59:39 -05:00
|
|
|
rb_define_method(rb_cArray, "inspect", rb_ary_inspect, 0);
|
|
|
|
rb_define_method(rb_cArray, "to_a", rb_ary_to_a, 0);
|
2006-10-02 13:39:57 -04:00
|
|
|
rb_define_method(rb_cArray, "to_splat", rb_ary_to_a, 0);
|
2003-02-10 04:40:13 -05:00
|
|
|
rb_define_method(rb_cArray, "to_ary", rb_ary_to_ary_m, 0);
|
1999-01-19 23:59:39 -05:00
|
|
|
rb_define_method(rb_cArray, "frozen?", rb_ary_frozen_p, 0);
|
|
|
|
|
|
|
|
rb_define_method(rb_cArray, "==", rb_ary_equal, 1);
|
|
|
|
rb_define_method(rb_cArray, "eql?", rb_ary_eql, 1);
|
|
|
|
rb_define_method(rb_cArray, "hash", rb_ary_hash, 0);
|
|
|
|
|
|
|
|
rb_define_method(rb_cArray, "[]", rb_ary_aref, -1);
|
|
|
|
rb_define_method(rb_cArray, "[]=", rb_ary_aset, -1);
|
1999-10-13 02:44:42 -04:00
|
|
|
rb_define_method(rb_cArray, "at", rb_ary_at, 1);
|
2001-02-02 06:38:20 -05:00
|
|
|
rb_define_method(rb_cArray, "fetch", rb_ary_fetch, -1);
|
2003-06-06 05:24:59 -04:00
|
|
|
rb_define_method(rb_cArray, "first", rb_ary_first, -1);
|
|
|
|
rb_define_method(rb_cArray, "last", rb_ary_last, -1);
|
1999-01-19 23:59:39 -05:00
|
|
|
rb_define_method(rb_cArray, "concat", rb_ary_concat, 1);
|
|
|
|
rb_define_method(rb_cArray, "<<", rb_ary_push, 1);
|
2000-01-04 23:41:21 -05:00
|
|
|
rb_define_method(rb_cArray, "push", rb_ary_push_m, -1);
|
2004-06-16 03:05:24 -04:00
|
|
|
rb_define_method(rb_cArray, "pop", rb_ary_pop_m, -1);
|
|
|
|
rb_define_method(rb_cArray, "shift", rb_ary_shift_m, -1);
|
2000-05-01 05:42:38 -04:00
|
|
|
rb_define_method(rb_cArray, "unshift", rb_ary_unshift_m, -1);
|
2001-05-02 00:22:21 -04:00
|
|
|
rb_define_method(rb_cArray, "insert", rb_ary_insert, -1);
|
1999-01-19 23:59:39 -05:00
|
|
|
rb_define_method(rb_cArray, "each", rb_ary_each, 0);
|
|
|
|
rb_define_method(rb_cArray, "each_index", rb_ary_each_index, 0);
|
|
|
|
rb_define_method(rb_cArray, "reverse_each", rb_ary_reverse_each, 0);
|
|
|
|
rb_define_method(rb_cArray, "length", rb_ary_length, 0);
|
|
|
|
rb_define_alias(rb_cArray, "size", "length");
|
|
|
|
rb_define_method(rb_cArray, "empty?", rb_ary_empty_p, 0);
|
2004-10-04 21:37:46 -04:00
|
|
|
rb_define_method(rb_cArray, "index", rb_ary_index, -1);
|
|
|
|
rb_define_method(rb_cArray, "rindex", rb_ary_rindex, -1);
|
2000-01-04 23:41:21 -05:00
|
|
|
rb_define_method(rb_cArray, "join", rb_ary_join_m, -1);
|
|
|
|
rb_define_method(rb_cArray, "reverse", rb_ary_reverse_m, 0);
|
2000-08-24 02:21:43 -04:00
|
|
|
rb_define_method(rb_cArray, "reverse!", rb_ary_reverse_bang, 0);
|
1999-01-19 23:59:39 -05:00
|
|
|
rb_define_method(rb_cArray, "sort", rb_ary_sort, 0);
|
|
|
|
rb_define_method(rb_cArray, "sort!", rb_ary_sort_bang, 0);
|
1999-10-29 05:25:48 -04:00
|
|
|
rb_define_method(rb_cArray, "collect", rb_ary_collect, 0);
|
2000-05-01 05:42:38 -04:00
|
|
|
rb_define_method(rb_cArray, "collect!", rb_ary_collect_bang, 0);
|
2001-07-14 11:17:19 -04:00
|
|
|
rb_define_method(rb_cArray, "map", rb_ary_collect, 0);
|
2000-05-01 05:42:38 -04:00
|
|
|
rb_define_method(rb_cArray, "map!", rb_ary_collect_bang, 0);
|
2004-06-16 03:05:24 -04:00
|
|
|
rb_define_method(rb_cArray, "select", rb_ary_select, 0);
|
2003-05-04 12:03:24 -04:00
|
|
|
rb_define_method(rb_cArray, "values_at", rb_ary_values_at, -1);
|
1999-01-19 23:59:39 -05:00
|
|
|
rb_define_method(rb_cArray, "delete", rb_ary_delete, 1);
|
2000-05-30 00:24:17 -04:00
|
|
|
rb_define_method(rb_cArray, "delete_at", rb_ary_delete_at_m, 1);
|
1999-01-19 23:59:39 -05:00
|
|
|
rb_define_method(rb_cArray, "delete_if", rb_ary_delete_if, 0);
|
2001-10-15 23:27:23 -04:00
|
|
|
rb_define_method(rb_cArray, "reject", rb_ary_reject, 0);
|
2000-08-07 01:05:04 -04:00
|
|
|
rb_define_method(rb_cArray, "reject!", rb_ary_reject_bang, 0);
|
2002-11-03 06:04:35 -05:00
|
|
|
rb_define_method(rb_cArray, "zip", rb_ary_zip, -1);
|
2002-11-19 03:07:51 -05:00
|
|
|
rb_define_method(rb_cArray, "transpose", rb_ary_transpose, 0);
|
2001-05-06 11:06:00 -04:00
|
|
|
rb_define_method(rb_cArray, "replace", rb_ary_replace, 1);
|
1999-01-19 23:59:39 -05:00
|
|
|
rb_define_method(rb_cArray, "clear", rb_ary_clear, 0);
|
|
|
|
rb_define_method(rb_cArray, "fill", rb_ary_fill, -1);
|
|
|
|
rb_define_method(rb_cArray, "include?", rb_ary_includes, 1);
|
|
|
|
rb_define_method(rb_cArray, "<=>", rb_ary_cmp, 1);
|
|
|
|
|
2000-01-31 22:12:21 -05:00
|
|
|
rb_define_method(rb_cArray, "slice", rb_ary_aref, -1);
|
2000-05-24 00:34:26 -04:00
|
|
|
rb_define_method(rb_cArray, "slice!", rb_ary_slice_bang, -1);
|
2000-01-31 22:12:21 -05:00
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
rb_define_method(rb_cArray, "assoc", rb_ary_assoc, 1);
|
|
|
|
rb_define_method(rb_cArray, "rassoc", rb_ary_rassoc, 1);
|
|
|
|
|
|
|
|
rb_define_method(rb_cArray, "+", rb_ary_plus, 1);
|
|
|
|
rb_define_method(rb_cArray, "*", rb_ary_times, 1);
|
|
|
|
|
|
|
|
rb_define_method(rb_cArray, "-", rb_ary_diff, 1);
|
|
|
|
rb_define_method(rb_cArray, "&", rb_ary_and, 1);
|
|
|
|
rb_define_method(rb_cArray, "|", rb_ary_or, 1);
|
|
|
|
|
|
|
|
rb_define_method(rb_cArray, "uniq", rb_ary_uniq, 0);
|
|
|
|
rb_define_method(rb_cArray, "uniq!", rb_ary_uniq_bang, 0);
|
|
|
|
rb_define_method(rb_cArray, "compact", rb_ary_compact, 0);
|
|
|
|
rb_define_method(rb_cArray, "compact!", rb_ary_compact_bang, 0);
|
* sprintf.c (rb_str_format): allow %c to print one character
string (e.g. ?x).
* lib/tempfile.rb (Tempfile::make_tmpname): put dot between
basename and pid. [ruby-talk:196272]
* parse.y (do_block): remove -> style block.
* parse.y (parser_yylex): remove tLAMBDA_ARG.
* eval.c (rb_call0): binding for the return event hook should have
consistent scope. [ruby-core:07928]
* eval.c (proc_invoke): return behavior should depend whether it
is surrounded by a lambda or a mere block.
* eval.c (formal_assign): handles post splat arguments.
* eval.c (rb_call0): ditto.
* st.c (strhash): use FNV-1a hash.
* parse.y (parser_yylex): removed experimental ';;' terminator.
* eval.c (rb_node_arity): should be aware of post splat arguments.
* eval.c (rb_proc_arity): ditto.
* parse.y (f_args): syntax rule enhanced to support arguments
after the splat.
* parse.y (block_param): ditto for block parameters.
* parse.y (f_post_arg): mandatory formal arguments after the splat
argument.
* parse.y (new_args_gen): generate nodes for mandatory formal
arguments after the splat argument.
* eval.c (rb_eval): dispatch mandatory formal arguments after the
splat argument.
* parse.y (args): allow more than one splat in the argument list.
* parse.y (method_call): allow aref [] to accept all kind of
method argument, including assocs, splat, and block argument.
* eval.c (SETUP_ARGS0): prepare block argument as well.
* lib/mathn.rb (Integer): remove Integer#gcd2. [ruby-core:07931]
* eval.c (error_line): print receivers true/false/nil specially.
* eval.c (rb_proc_yield): handles parameters in yield semantics.
* eval.c (nil_yield): gives LocalJumpError to denote no block
error.
* io.c (rb_io_getc): now takes one-character string.
* string.c (rb_str_hash): use FNV-1a hash from Fowler/Noll/Vo
hashing algorithm.
* string.c (rb_str_aref): str[0] now returns 1 character string,
instead of a fixnum. [Ruby2]
* parse.y (parser_yylex): ?c now returns 1 character string,
instead of a fixnum. [Ruby2]
* string.c (rb_str_aset): no longer support fixnum insertion.
* eval.c (umethod_bind): should not update original class.
[ruby-dev:28636]
* eval.c (ev_const_get): should support constant access from
within instance_eval(). [ruby-dev:28327]
* time.c (time_timeval): should round for usec floating
number. [ruby-core:07896]
* time.c (time_add): ditto.
* dir.c (sys_warning): should not call a vararg function
rb_sys_warning() indirectly. [ruby-core:07886]
* numeric.c (flo_divmod): the first element of Float#divmod should
be an integer. [ruby-dev:28589]
* test/ruby/test_float.rb: add tests for divmod, div, modulo and remainder.
* re.c (rb_reg_initialize): should not allow modifying literal
regexps. frozen check moved from rb_reg_initialize_m as well.
* re.c (rb_reg_initialize): should not modify untainted objects in
safe levels higher than 3.
* re.c (rb_memcmp): type change from char* to const void*.
* dir.c (dir_close): should not close untainted dir stream.
* dir.c (GetDIR): add tainted/frozen check for each dir operation.
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_symbol_arg):
typo fixed. a patch from Florian Gross <florg at florg.net>.
* eval.c (EXEC_EVENT_HOOK): trace_func may remove itself from
event_hooks. no guarantee for arbitrary hook deletion.
[ruby-dev:28632]
* util.c (ruby_strtod): differ addition to minimize error.
[ruby-dev:28619]
* util.c (ruby_strtod): should not raise ERANGE when the input
string does not have any digits. [ruby-dev:28629]
* eval.c (proc_invoke): should restore old ruby_frame->block.
thanks to ts <decoux at moulon.inra.fr>. [ruby-core:07833]
also fix [ruby-dev:28614] as well.
* signal.c (trap): sig should be less then NSIG. Coverity found
this bug. a patch from Kevin Tew <tewk at tewk.com>.
[ruby-core:07823]
* math.c (math_log2): add new method inspired by
[ruby-talk:191237].
* math.c (math_log): add optional base argument to Math::log().
[ruby-talk:191308]
* ext/syck/emitter.c (syck_scan_scalar): avoid accessing
uninitialized array element. a patch from Pat Eyler
<rubypate at gmail.com>. [ruby-core:07809]
* array.c (rb_ary_fill): initialize local variables first. a
patch from Pat Eyler <rubypate at gmail.com>. [ruby-core:07810]
* ext/syck/yaml2byte.c (syck_yaml2byte_handler): need to free
type_tag. a patch from Pat Eyler <rubypate at gmail.com>.
[ruby-core:07808]
* ext/socket/socket.c (make_hostent_internal): accept ai_family
check from Sam Roberts <sroberts at uniserve.com>.
[ruby-core:07691]
* util.c (ruby_strtod): should not cut off 18 digits for no
reason. [ruby-core:07796]
* array.c (rb_ary_fill): internalize local variable "beg" to
pacify Coverity. [ruby-core:07770]
* pack.c (pack_unpack): now supports CRLF newlines. a patch from
<tommy at tmtm.org>. [ruby-dev:28601]
* applied code clean-up patch from Stefan Huehner
<stefan at huehner.org>. [ruby-core:07764]
* lib/jcode.rb (String::tr_s): should have translated non
squeezing character sequence (i.e. a character) as well. thanks
to Hiroshi Ichikawa <gimite at gimite.ddo.jp> [ruby-list:42090]
* ext/socket/socket.c: document update patch from Sam Roberts
<sroberts at uniserve.com>. [ruby-core:07701]
* lib/mathn.rb (Integer): need not to remove gcd2. a patch from
NARUSE, Yui <naruse at airemix.com>. [ruby-dev:28570]
* parse.y (arg): too much NEW_LIST()
* eval.c (SETUP_ARGS0): remove unnecessary access to nd_alen.
* eval.c (rb_eval): use ARGSCAT for NODE_OP_ASGN1.
[ruby-dev:28585]
* parse.y (arg): use NODE_ARGSCAT for placeholder.
* lib/getoptlong.rb (GetoptLong::get): RDoc update patch from
mathew <meta at pobox.com>. [ruby-core:07738]
* variable.c (rb_const_set): raise error when no target klass is
supplied. [ruby-dev:28582]
* prec.c (prec_prec_f): documentation patch from
<gerardo.santana at gmail.com>. [ruby-core:07689]
* bignum.c (rb_big_pow): second operand may be too big even if
it's a Fixnum. [ruby-talk:187984]
* README.EXT: update symbol description. [ruby-talk:188104]
* COPYING: explicitly note GPLv2. [ruby-talk:187922]
* parse.y: remove some obsolete syntax rules (unparenthesized
method calls in argument list).
* eval.c (rb_call0): insecure calling should be checked for non
NODE_SCOPE method invocations too.
* eval.c (rb_alias): should preserve the current safe level as
well as method definition.
* process.c (rb_f_sleep): remove RDoc description about SIGALRM
which is not valid on the current implementation. [ruby-dev:28464]
Thu Mar 23 21:40:47 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
* eval.c (method_missing): should support argument splat in
super. a bug in combination of super, splat and
method_missing. [ruby-talk:185438]
* configure.in: Solaris SunPro compiler -rapth patch from
<kuwa at labs.fujitsu.com>. [ruby-dev:28443]
* configure.in: remove enable_rpath=no for Solaris.
[ruby-dev:28440]
* ext/win32ole/win32ole.c (ole_val2olevariantdata): change behavior
of converting OLE Variant object with VT_ARRAY|VT_UI1 and Ruby
String object.
* ruby.1: a clarification patch from David Lutterkort
<dlutter at redhat.com>. [ruby-core:7508]
* lib/rdoc/ri/ri_paths.rb (RI::Paths): adding paths from rubygems
directories. a patch from Eric Hodel <drbrain at segment7.net>.
[ruby-core:07423]
* eval.c (rb_clear_cache_by_class): clearing wrong cache.
* ext/extmk.rb: use :remove_destination to install extension libraries
to avoid SEGV. [ruby-dev:28417]
* eval.c (rb_thread_fd_writable): should not re-schedule output
from KILLED thread (must be error printing).
* array.c (rb_ary_flatten_bang): allow specifying recursion
level. [ruby-talk:182170]
* array.c (rb_ary_flatten): ditto.
* gc.c (add_heap): a heap_slots may overflow. a patch from Stefan
Weil <weil at mail.berlios.de>.
* eval.c (rb_call): use separate cache for fcall/vcall
invocation.
* eval.c (rb_eval): NODE_FCALL, NODE_VCALL can call local
functions.
* eval.c (rb_mod_local): a new method to specify newly added
visibility "local".
* eval.c (search_method): search for local methods which are
visible only from the current class.
* class.c (rb_class_local_methods): a method to list local methods.
* object.c (Init_Object): add BasicObject class as a top level
BlankSlate class.
* ruby.h (SYM2ID): should not cast to signed long.
[ruby-core:07414]
* class.c (rb_include_module): allow module duplication.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-09 17:20:17 -04:00
|
|
|
rb_define_method(rb_cArray, "flatten", rb_ary_flatten, -1);
|
|
|
|
rb_define_method(rb_cArray, "flatten!", rb_ary_flatten_bang, -1);
|
1999-01-19 23:59:39 -05:00
|
|
|
rb_define_method(rb_cArray, "nitems", rb_ary_nitems, 0);
|
2006-08-31 04:24:36 -04:00
|
|
|
rb_define_method(rb_cArray, "shuffle!", rb_ary_shuffle_bang, 0);
|
|
|
|
rb_define_method(rb_cArray, "shuffle", rb_ary_shuffle, 0);
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2001-12-10 02:18:16 -05:00
|
|
|
id_cmp = rb_intern("<=>");
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|