* hash.c (env_delete_m): execute block only if deleting key does
not exist.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3637 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
"close" method instead. [ruby-dev:19717]
* io.c (rb_io_s_open): ditto.
* hash.c (rb_any_hash): remove DEFER_INTS. all do_hash() calls in
st.c are at the top of functions. No reentrant problem.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3551 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
object, if b has "to_ary" and b == a.
* hash.c (rb_hash_equal): a == b is true when b is non T_HASH
object, if b has "to_hash" and b == a.
* string.c (rb_str_equal): a == b is true when b is non T_STRING
object, if b has "to_str" and b == a.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3442 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* error.c (Init_Exception): "to_str" removed.
* eval.c (eval): should not rely on Exception#to_str
* eval.c (compile_error): ditto.
* error.c (err_append): ditto.
* hash.c (rb_hash_merge): Hash#merge, non destructive "update".
now there's also Hash#merge! which is an alias to "update".
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* hash.c (env_shift): ditto.
* hash.c (env_invert): ditto.
* hash.c (env_replace): ditto.
* hash.c (env_update): ditto.
* array.c (rb_ary_join): dispatch based on "to_str".
* array.c (rb_ary_times): ditto.
* array.c (rb_ary_equal): ditto.
* process.c (rb_f_exec): dispatch based on "to_ary".
* eval.c (umethod_bind): exact class match is not required. relax
the restriction to subclasses.
* eval.c (rb_eval): call "inherited" before executing class body.
* class.c (rb_define_class): call "inherited" after defining the
constant.
* class.c (rb_define_class_under): ditto.
* eval.c (massign): expand first element if RHS is an array and
its size is 1, and LHS has concrete assignment target (i.e. LHS
has target(s) other than *var).
* eval.c (massign): avoid unnecessary avalue/svalue conversion.
* eval.c (rb_yield_0): ditto
* array.c (rb_ary_update): do not allocate unused array if rpl is
nil (i.e. merely removing elements).
* io.c (io_read): should resize supplied string if it's shorter
than expected.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3307 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
st_compare_func_t, st_hash_func_t and st_each_func_t.
* st.h, st.c: Do explicit function declarations and do not rely on
implicit declarations. On such platforms as IA64, int argument
values are NOT automatically promoted to long (64bit) values, so
explicit declarations are mandatory for those functions that
take long values or pointers. This fixes miniruby's coredump on
FreeBSD/IA64.
* class.c, eval.c, gc.c, hash.c, marshal.c, parse.y, variable.c:
Add proper casts to avoid warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3303 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y (cmd_brace_block): new tLBRACE_ARG block rule
* parse.y (command): can take optional cmd_brace_block; use %prec
to resolve shift/reduce conflict. (ruby-bugs-ja PR#372)
* eval.c (ruby_finalize): trace_func should be cleared here (after
executing exit procs and finalizers).
* eval.c (rb_define_alloc_func): new allocation framework, based
on Nobu's work [ruby-dev:19116]. "allocate" method is no longer
used for object allocation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3188 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
still left; removed.
* sprintf.c (rb_f_sprintf): should not prepend '0' if width > prec
for example "%5.3d".
* process.c (Init_process): add Process.exit and Process.abort
* pack.c (utf8_to_uv): raise ArgumentError for malformed/redundant
UTF-8 sequences.
* process.c (last_status_set): add pid attribute to Process::Status.
* pack.c (uv_to_utf8): limit maximum length of the encoded string
to 6 bytes, even when the platform supports 8 bytes long integers.
* pack.c (utf8_to_uv): do not decode sequences longer than 6 bytes.
* object.c (copy_object): use "copy_object" method, not "become".
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3123 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Darwin for namespace cleanness. [ruby-core:00537]
* dln.c (dln_load): Fix Darwin support that has been disabled and
switch to using it on Darwin instead of the system dlopen().
[ruby-core:00541]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2969 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
self-assignment.
* class.c (rb_make_metaclass): metaclass of a superclass may be
NULL at boot time.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2903 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
variable table if it existes.
* class.c (rb_make_metaclass): metaclass of a metaclass is a
metaclass itself.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* eval.c (rb_alias): prohibit making an alias named "allocate" if
klass is a metaclass.
* string.c (rb_string_value_ptr): StringValuePtr() should never
return NULL pointer.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2764 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* file.c (rb_find_file_ext): ditto.
* range.c (range_eq): class check should be based on range.class,
instead of Range to work with Range.dup.
* range.c (range_eql): ditto.
* class.c (rb_mod_dup): need to preserve metaclass and flags.
* object.c (rb_cstr_to_dbl): had a buffer overrun.
* marshal.c (w_class): integrate singleton check into a funciton
to follow DRY principle.
* marshal.c (w_uclass): should check singleton method.
* object.c (rb_obj_dup): dmark and dfree functions must be match
for T_DATA type.
* object.c (rb_obj_dup): class of the duped object must be match
to the class of the original.
* re.c (rb_reg_quote): do not escape \t, \f, \r, \n, for they are
not regular expression metacharacters.
* time.c (time_s_alloc): use time_free instead of free (null check,
also serves for type mark).
* time.c (time_s_at): check dfree function too.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2748 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* hash.c (rb_hash_dup): should preserve HASH_PROC_DEFAULT and
HASH_DELETED flags.
* hash.c (rb_hash_shift): shift from empty hash should not return
its default proc.
* hash.c (rb_hash_default_proc): new method. [new]
* array.c (rb_ary_aref): no need for Bignum check.
* array.c (rb_ary_aset): explicit Bignum check removd.
* numeric.c (fix_aref): normalize bignum before bit-op.
* bignum.c (rb_big_rand): max may be Bignum zero.
* bignum.c (rb_cstr_to_inum): should normalize bignums, to avoid
returning fixable bignum value.
* bignum.c (rb_uint2big): there should be no zero sized bignum.
* ext/extmk.rb.in: extmake() that works properly for both tkutil
(tk/tkutil.so) and digest/sha1.
* hash.c (rb_hash_equal): should check HASH_PROC_DEFAULT too.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2706 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
big2dbl().
* bignum.c (Init_Bignum): rb_big_zero_p() removed. There may be
Bignum zero.
* eval.c (rb_call0): new argument added for original method name.
preserve original method name in frame->orig_func.
* eval.c (is_defined): use frame->orig_func, not last_func.
* eval.c (rb_eval): ditto.
* eval.c (method_call): supply data->oid also to rb_call0().
* object.c (rb_class_allocate_instance): call rb_obj_alloc() when
called from alias, thus invoke original "allocate".
* eval.c (remove_method): removing allocate from classes should
cause NameError.
* hash.c (rb_hash_equal): should check default values.
* ext/socket/socket.c (s_recvfrom): update RSTRING len.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2702 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
suggested by Guy Decoux.
* hash.c (rb_hash_s_create): use rb_hash_aset() instead of calling
st_insert() directly, to dup&freeze string keys.
* parse.y (yylex): proper error message for "@@0".
* parse.y (yylex): paren to parse_string() must be zero for
unparenthesized strings.
* parse.y (str_extend): broken string when unterminated "#{".
* enum.c (enum_sort_by): had a bug in 1 element enumeration.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2565 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ruby.c (proc_options): access prefixed "ruby_yydebug".
* applied modifies to pacify some of gcc -Wall warnings.
* parse.y (arg): no more ugly hack for "**", so that "-2**2" to be
parsed as "(-2)**2", whereas "- 2**2" or "-(2)**2" to be parsed
as "-(2**2)".
* parse.y (yylex): '-2' to be literal fixnum. [new]
* time.c (time_succ): new method for Range support.
* time.c (time_arg): nil test against v[6] (usec).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* eval.c (set_method_visibility): should have clear cache forq
updated visibility.
* numeric.c (flo_to_s): default format precision to be "%.16g".
* util.c (ruby_strtod): use own strtod(3) implementation to avoid
locale hell. Due to this change "0xff".to_f no longer returns 255.0
* eval.c (avalue_to_yvalue): new function to distinguish yvalue
(no-arg == Qundef) from svalue (no-arg == Qnil).
* eval.c (rb_yield_0): use avalue_to_yvalue().
* eval.c (assign): warn if val == Qundef where it means rhs is
void (e.g. yield without value or call without argument).
* parse.y (value_expr): need not to warn for WHILE and UNTIL,
since they can have return value (via valued break).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2457 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
singleton cbase.
* eval.c (is_defined): adopt new cvar behavior.
* eval.c (rb_eval): ditto.
* eval.c (assign): ditto.
* class.c (rb_mod_clone): should not call rb_obj_clone(), since
Module does not provide "allocate".
* class.c (rb_singleton_class): should crate new singleton class
if obj is a class or module and attached object is different,
which means metaclass of singleton class is sought.
* time.c (time_s_alloc): now follows allocation framework.
* eval.c (rb_eval): should initialize outer class variables from
methods in singleton class definitions.
* eval.c (assign): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2169 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
singleton methods.
* object.c (rb_mod_to_s): better description.
* hash.c (env_select): should path the assoc list.
* process.c (rb_syswait): thread kludge; should be fixed to
support native thread.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2128 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* eval.c (remove_method): should not remove a empty method to
implement "undef".
* eval.c (rb_eval): should allow singleton class def for
true/false/nil.
* parse.y (str_extend): backslash escape was done wrong.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2102 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
only, no methods.
* eval.c (is_defined): should not dump core on defined?(a::b)
where a is not a class nor a module.
* object.c (Init_Object): remove dup and clone from TrueClass,
FalseClass, and NilClass.
* array.c (rb_ary_fill): Array#fill takes block to get the value to
fill.
* string.c (rb_str_to_i): to_i(0) auto-detects base radix.
* array.c (rb_ary_initialize): fill by the block evaluation value
if block is given.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2021 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* eval.c (rb_thread_cleanup): need not to free thread stacks at
process termination.
* array.c (rb_ary_fetch): use the block to get the default value
if the block is given.
* eval.c (rb_thread_schedule): should check time only if BOTH
WAIT_SELECT and WAIT_TIME.
* eval.c (umethod_bind): should update rklass field.
* hash.c (rb_hash_update): if a block is given, yields [key,
value1, value2] to the block to resolve conflict.
* string.c (rb_str_split_m): no need to consider KANJI
characters, if the length of separator is 1 (byte).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2015 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* hash.c (rb_hash_set_default): Hash#default= should return the
new value.
* string.c (rb_str_to_i): accepts optional base argument. [new]
* numeric.c (rb_fix2str): should not handle negative fixnum values
int32 via calling sprintf() directly.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1985 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
modifying buffer is shared.
* array.c (ary_make_shared): make an internal buffer of an array
to be shared.
* array.c (rb_ary_shift): avoid sliding an internal buffer by
using shared buffer.
* array.c (rb_ary_subseq): avoid copying the buffer.
* parse.y (gettable): should freeze __LINE__ string.
* io.c (rb_io_puts): old behavoir restored. rationale: a) if you
want to call to_s for arrays, you can just call print a, "\n".
b) to_s wastes memory if array (and sum of its contents) is
huge. c) now any object that has to_ary is treated as an array,
using rb_check_convert_type().
* hash.c (rb_hash_initialize): now accepts a block to calculate
the default value. [new]
* hash.c (rb_hash_aref): call "default" method to get the value
corrensponding to the non existing key.
* hash.c (rb_hash_default): get the default value based on the
block given to 'new'. Now it takes an optinal "key" argument.
"default" became the method to get the value for non existing
key. Users may override "default" method to change the hash
behavior.
* hash.c (rb_hash_set_default): clear the flag if a block is given
to 'new'
* object.c (Init_Object): undef Data.allocate, left Data.new.
* ext/curses/curses.c (window_scrollok): use RTEST().
* ext/curses/curses.c (window_idlok): ditto.
* ext/curses/curses.c (window_keypad): ditto.
* ext/curses/curses.c (window_idlok): idlok() may return void on
some platforms; so don't use return value.
* ext/curses/curses.c (window_scrollok): ditto for consistency.
* ext/curses/curses.c: replace FIX2INT() by typechecking NUM2INT().
* parse.y (str_extend): should not process immature #$x and
#@x interpolation, e.g #@#@ etc.
* enum.c (enum_sort_by): sort_by does not have to be stable always.
* enum.c (enum_sort_by): call qsort directly to gain performance.
* util.c (ruby_qsort): ruby_qsort(qs6) is now native thread safe.
* error.c (rb_sys_fail): it must be a bug if it's called when
errno == 0.
* regex.c (WC2MBC1ST): should not pass through > 0x80 number in UTF-8.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1896 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
expression interpolation.
* pack.c (pack_unpack): should give length to utf8_to_uv().
* pack.c (utf8_to_uv): add length check.
* massages: replace "wrong #" by "wrong number".
* marshal.c (w_float): output Infinity and NaN explicitly.
* marshal.c (r_object): support new explicit float format.
* eval.c (rb_thread_wait_for): select may cause ERESTART on
Solaris.
* eval.c (rb_thread_select): ditto.
* array.c (rb_ary_join): dumped core if sep is not T_STRING nor T_NIL.
* array.c (rb_ary_join): buffer size calculattion was wrong.
* array.c (rb_ary_to_s): if rb_output_fs is nil, insert newlines
between array elements (use rb_default_rs as newline litral)
[experimental].
* gc.c (init_mark_stack): no need to clear mark_stack.
* gc.c (gc_mark_all): need to handle finalizer mark.
* gc.c (gc_mark_rest): use MEMCPY instead of memcpy.
* gc.c (rb_gc_mark): earlier const check to avoid pusing special
constants into mark stack.
* numeric.c (fix_to_s): 'to_s' now takes optional argument to
specify radix. [new]
* bignum.c (rb_big_to_s): ditto. [new]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1842 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* variable.c (rb_cvar_set): empty iv_tbl may cause infinite loop.
* variable.c (rb_cvar_get): ditto.
* variable.c (cvar_override_check): ditto.
* bignum.c (rb_big_eq): convert Bignum to Float, instead of
reverse.
* time.c (time_localtime): getting tm should not be prohibited for
frozen time objects.
* time.c (time_gmtime): ditto.
* version.c (Init_version): freeze RUBY_VERSION,
RUBY_RELEASE_DATE, and RUBY_PLATFORM.
* file.c (Init_File): freeze File::SEPARATOR, ALT_SEPARATOR and
PATH_SEPARATOR.
* file.c (rb_stat_cmp): should check operand type before calling
get_stat().
* eval.c (rb_eval_cmd): should not invoke "call" with a block on
any occasion.
* numeric.c (fix_aref): idx may be a Bignum.
* numeric.c (num_remainder): a bug in Numeric#remainder.
* eval.c (rb_exec_end_proc): END might be called within END
block.
* class.c (rb_mod_clone): should not copy class name, since clone
should remain anonymous.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1800 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* eval.c (umethod_bind): recv can be an instance of descender of
oklass if oklass is a Module.
* hash.c (rb_hash_equal): check identiry equality first.
* file.c (group_member): should check real gid only.
* file.c (eaccess): do not cache euid, since effective euid may be
changed via Process.euid=().
* file.c (eaccess): return -1 unless every specified access mode
is permitted.
* eval.c (rb_eval): while/until returns the value which is given
to break.
* parse.y (value_expr): using while/until/class/def as an
expression is now gives a warning, not an error.
* range.c (range_eqq): should compare strings based on magical
increment (using String#upto), not dictionary order.
* enum.c (enum_sort_by): new method for Schewartzian transformed
stable sort.
* variable.c (mod_av_set): detect constant overriding for built-in
classes/modules.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1707 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
and Marshal::MINOR_VERSION.
* marshal.c (marshal_load): ruby_verbose test should be wrapped by
RTEST().
* hash.c (rb_hash_index): should return nil (not the default
value) if value is not in the hash.
* numeric.c (num_div): new method added. alias to '/' which
should be preserved even if '/' is redefined (e.g. by
mathn). [new]
* bignum.c (rb_cstr2inum): "0 ff".hex should return 0, not 255.
* file.c (rb_file_s_expand_path): fixed using CharNext().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1658 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
loading.
* io.c (io_fread): use fread(3) if PENDING_COUND is available.
* class.c (rb_mod_include_p): Module#include? added. [new]
* re.c (ignorecase_setter): give warning on modifying $=.
* string.c (rb_str_casecmp): new method. [new]
* string.c (rb_str_eql): separated from rb_str_equal(), make it
always be case sensitive. [new]
* string.c (rb_str_hash): made it always be case sensitive.
* eval.c (rb_f_require): should not include path in $" value
* file.c (rb_find_file): should return 0 explicitly on failure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1642 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* gc.c (STR_NO_ORIG): STR_NO_ORIG value was different between
string.c and gc.c
* eval.c (rb_eval): should convert *non-array at the end of
arguments by using Array().
* hash.c (ruby_setenv): readline library leaves their environment
strings uncopied. "free" check revised.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1523 b2dd03c8-39d4-4d8f-98ff-823fe69b080e