diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2000-02-29 08:05:32 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2000-02-29 08:05:32 +0000 |
commit | 4890f3a684aff94d93a5cc3f68fa8c67c1da6c19 (patch) | |
tree | 3e43148d3114380fff1418aa3ff6d01b157a97e4 | |
parent | 0c123a83f0446204d974318b578236c949e5a01f (diff) |
2000-02-29
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@629 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 40 | ||||
-rw-r--r-- | ToDo | 3 | ||||
-rw-r--r-- | array.c | 50 | ||||
-rw-r--r-- | config.sub | 4 | ||||
-rw-r--r-- | config_s.dj | 2 | ||||
-rw-r--r-- | dir.c | 43 | ||||
-rw-r--r-- | ext/socket/socket.c | 3 | ||||
-rw-r--r-- | hash.c | 47 | ||||
-rw-r--r-- | io.c | 10 | ||||
-rw-r--r-- | lib/debug.rb | 7 | ||||
-rw-r--r-- | lib/singleton.rb | 2 | ||||
-rw-r--r-- | lib/tempfile.rb | 10 | ||||
-rw-r--r-- | object.c | 6 | ||||
-rw-r--r-- | range.c | 28 | ||||
-rw-r--r-- | ruby.h | 2 | ||||
-rw-r--r-- | string.c | 71 | ||||
-rw-r--r-- | time.c | 20 | ||||
-rw-r--r-- | top.sed | 2 | ||||
-rw-r--r-- | version.h | 4 | ||||
-rw-r--r-- | win32/ruby.def | 21 |
20 files changed, 241 insertions, 134 deletions
@@ -1,6 +1,44 @@ +Tue Feb 29 01:08:26 2000 Yukihiro Matsumoto <[email protected]> + + * range.c (range_initialize): initialization done in `initialize'; + `initialize; should not be called more than once. + + * object.c (Init_Object): default `initialize' should take zero + argument. + + * time.c (time_s_new): call `initialize' in Time::new. + +Sat Feb 26 22:39:31 2000 EGUCHI Osamu <[email protected]> + + * Fix String#* with huge string. + +Sat Feb 26 00:14:59 2000 Yukihiro Matsumoto <[email protected]> + + * dir.c (dir_s_new): call `initialize' in Dir::new. + +Fri Feb 25 23:01:49 2000 Katsuyuki Komatsu <[email protected]> + + * ruby.h: export ruby_safe_level by EXTERN for mswin32. + * win32/ruby.def: regular maintenance. + +Fri Feb 25 22:12:46 2000 Yukihiro Matsumoto <[email protected]> + + * io.c (rb_io_reopen): IO#reopen should accept path as well. + + * string.c (rb_str_s_new): call `initialize' in String::new. + + * hash.c (rb_hash_s_new): call `initialize' in Hash::new. + + * array.c (rb_ary_s_new): call `initialize' in Array::new. + Fri Feb 25 12:50:20 2000 Yukihiro Matsumoto <[email protected]> - * eval.c (rb_thread_start_timer): interval made 10ms from 50ms. + * eval.c (rb_thread_start_timer): interval changed to 10ms from 50ms. + +Fri Feb 25 06:42:26 2000 GOTOU YUUZOU <[email protected]> + + * ext/socket/socket.c (ip_addrsetup): hostp should remain NULL if + host is nil. Thu Feb 24 16:53:47 2000 Yukihiro Matsumoto <[email protected]> @@ -20,6 +20,7 @@ Language Spec. * def Foo::Bar::baz() .. end ?? * I18N (or M17N) script/string/regexp * Fixnum 0 as false ???? +* discourage use of symbol variable (e.g. $/, etc.) in manual Hacking Interpreter @@ -56,6 +57,7 @@ Standard Libraries - Thread::start gives arguments, not a thread object to the block - regexp: (?>..), \G - Struct::new([name,]member,...) +- IO#reopen accepts path as well * String#scanf(?) * Object#fmt(?) * Integer#{bin,oct,hex,heX} @@ -67,6 +69,7 @@ Standard Libraries * optional stepsize argument for succ() * performance tune for String's non-bang methods. * Ruby module -- Ruby::Version, Ruby::Interpreter +* call initialize for builtin class too Extension Libraries @@ -167,33 +167,42 @@ rb_ary_s_new(argc, argv, klass) VALUE *argv; VALUE klass; { - long len = 0; - VALUE size, val; - NEWOBJ(ary, struct RArray); + VALUE ary = rb_ary_new(); OBJSETUP(ary, klass, T_ARRAY); + rb_obj_call_init(ary, argc, argv); + + return ary; +} + +static VALUE +rb_ary_initialize(argc, argv, ary) + int argc; + VALUE *argv; + VALUE ary; +{ + long len; + VALUE size, val; - ary->len = 0; - ary->ptr = 0; if (rb_scan_args(argc, argv, "02", &size, &val) == 0) { - ary->capa = ARY_DEFAULT_SIZE; + return ary; } - else { - long capa = NUM2LONG(size); - if (capa < 0) { - rb_raise(rb_eArgError, "negative array size"); - } - if (capa > 0 && capa*sizeof(VALUE) <= 0) { - rb_raise(rb_eArgError, "array size too big"); - } - ary->capa = capa; - len = capa; + rb_ary_modify(ary); + len = NUM2LONG(size); + if (len < 0) { + rb_raise(rb_eArgError, "negative array size"); } - ary->ptr = ALLOC_N(VALUE, ary->capa); - memfill(ary->ptr, len, val); - ary->len = len; + if (len > 0 && len*sizeof(VALUE) <= 0) { + rb_raise(rb_eArgError, "array size too big"); + } + if (len > RARRAY(ary)->capa) { + RARRAY(ary)->capa = len; + REALLOC_N(RARRAY(ary)->ptr, VALUE, RARRAY(ary)->capa); + } + memfill(RARRAY(ary)->ptr, len, val); + RARRAY(ary)->len = len; - return (VALUE)ary; + return ary; } static VALUE @@ -1544,6 +1553,7 @@ Init_Array() rb_define_singleton_method(rb_cArray, "new", rb_ary_s_new, -1); rb_define_singleton_method(rb_cArray, "[]", rb_ary_s_create, -1); + rb_define_method(rb_cArray, "initialize", rb_ary_initialize, -1); rb_define_method(rb_cArray, "to_s", rb_ary_to_s, 0); rb_define_method(rb_cArray, "inspect", rb_ary_inspect, 0); rb_define_method(rb_cArray, "to_a", rb_ary_to_a, 0); diff --git a/config.sub b/config.sub index f853351cc4..3c591de61b 100644 --- a/config.sub +++ b/config.sub @@ -68,7 +68,7 @@ esac # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in - linux-gnu*) + linux*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; @@ -891,7 +891,7 @@ case $os in os=-sysv4.2uw ;; -gnu/linux*) - os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` + os=`echo $os | sed -e 's|gnu/linux|linux|'` ;; # First accept the basic system types. # The portable systems comes first. diff --git a/config_s.dj b/config_s.dj index 7ba18e4376..6f77b7f738 100644 --- a/config_s.dj +++ b/config_s.dj @@ -32,7 +32,7 @@ s%@AR@%ar%g s%@INSTALL_PROGRAM@%${INSTALL}%g s%@INSTALL_DATA@%${INSTALL} -m 644%g s%@SET_MAKE@%%g -s%@LIBOBJS@% crypt.o flock.o fnmatch.o snprintf.o%g +s%@LIBOBJS@% crypt.o flock.o snprintf.o%g s%@ALLOCA@%%g s%@DEFAULT_KCODE@%%g s%@EXEEXT@%.exe%g @@ -233,14 +233,31 @@ free_dir(dir) static VALUE dir_close _((VALUE)); static VALUE -dir_s_open(dir_class, dirname) - VALUE dir_class, dirname; +dir_s_new(argc, argv, klass) + int argc; + VALUE *argv; + VALUE klass; +{ + VALUE obj = Data_Wrap_Struct(klass, 0, free_dir, 0); + + rb_obj_call_init(obj, argc, argv); + + if (rb_iterator_p()) { + rb_ensure(rb_yield, obj, dir_close, obj); + } + + return obj; +} + +static VALUE +dir_initialize(dir, dirname) + VALUE dir, dirname; { - VALUE obj; DIR *dirp; Check_SafeStr(dirname); - + if (DATA_PTR(dir)) closedir(DATA_PTR(dir)); + DATA_PTR(dir) = NULL; dirp = opendir(RSTRING(dirname)->ptr); if (dirp == NULL) { if (errno == EMFILE || errno == ENFILE) { @@ -251,14 +268,15 @@ dir_s_open(dir_class, dirname) rb_sys_fail(RSTRING(dirname)->ptr); } } + DATA_PTR(dir) = dirp; + return dir; +} - obj = Data_Wrap_Struct(dir_class, 0, free_dir, dirp); - - if (rb_iterator_p()) { - return rb_ensure(rb_yield, obj, dir_close, obj); - } - - return obj; +static VALUE +dir_s_open(klass, dirname) + VALUE klass, dirname; +{ + return dir_s_new(1, &dirname, klass); } static void @@ -781,11 +799,12 @@ Init_Dir() rb_include_module(rb_cDir, rb_mEnumerable); - rb_define_singleton_method(rb_cDir, "new", dir_s_open, 1); + rb_define_singleton_method(rb_cDir, "new", dir_s_new, -1); rb_define_singleton_method(rb_cDir, "open", dir_s_open, 1); rb_define_singleton_method(rb_cDir, "foreach", dir_foreach, 1); rb_define_singleton_method(rb_cDir, "entries", dir_entries, 1); + rb_define_method(rb_cDir,"initialize", dir_initialize, 1); rb_define_method(rb_cDir,"read", dir_read, 0); rb_define_method(rb_cDir,"each", dir_each, 0); rb_define_method(rb_cDir,"rewind", dir_rewind, 0); diff --git a/ext/socket/socket.c b/ext/socket/socket.c index e7d2300b18..7838b151a3 100644 --- a/ext/socket/socket.c +++ b/ext/socket/socket.c @@ -519,6 +519,7 @@ ip_addrsetup(host, port) long i = NUM2LONG(host); mkinetaddr(htonl(i), hbuf, sizeof(hbuf)); + hostp = hbuf; } else { char *name = STR2CSTR(host); @@ -532,8 +533,8 @@ ip_addrsetup(host, port) else { strcpy(hbuf, name); } + hostp = hbuf; } - hostp = hbuf; if (NIL_P(port)) { portp = 0; } @@ -171,47 +171,51 @@ rb_hash_foreach(hash, func, farg) } static VALUE -rb_hash_s_new(argc, argv, klass) - int argc; - VALUE *argv; +rb_hash_new2(klass) VALUE klass; { - VALUE ifnone; - NEWOBJ(hash, struct RHash); OBJSETUP(hash, klass, T_HASH); hash->iter_lev = 0; hash->ifnone = Qnil; hash->tbl = 0; /* avoid GC crashing */ - - rb_scan_args(argc, argv, "01", &ifnone); - - hash->ifnone = ifnone; hash->tbl = st_init_table(&objhash); return (VALUE)hash; } +VALUE +rb_hash_new() +{ + return rb_hash_new2(rb_cHash); +} + static VALUE -rb_hash_new2(klass) +rb_hash_s_new(argc, argv, klass) + int argc; + VALUE *argv; VALUE klass; { - NEWOBJ(hash, struct RHash); - OBJSETUP(hash, klass, T_HASH); + VALUE hash = rb_hash_new2(klass); - hash->iter_lev = 0; - hash->ifnone = Qnil; - hash->tbl = 0; /* avoid GC crashing */ - hash->tbl = st_init_table(&objhash); - - return (VALUE)hash; + rb_obj_call_init(hash, argc, argv); + return hash; } -VALUE -rb_hash_new() +static VALUE +rb_hash_initialize(argc, argv, hash) + int argc; + VALUE *argv; + VALUE hash; { - return rb_hash_new2(rb_cHash); + VALUE ifnone; + + rb_scan_args(argc, argv, "01", &ifnone); + rb_hash_modify(hash); + RHASH(hash)->ifnone = ifnone; + + return hash; } static VALUE @@ -1382,6 +1386,7 @@ Init_Hash() rb_define_singleton_method(rb_cHash, "new", rb_hash_s_new, -1); rb_define_singleton_method(rb_cHash, "[]", rb_hash_s_create, -1); + rb_define_method(rb_cHash,"initialize", rb_hash_initialize, -1); rb_define_method(rb_cHash,"clone", rb_hash_clone, 0); rb_define_method(rb_cHash,"dup", rb_hash_dup, 0); @@ -1707,7 +1707,7 @@ rb_io_mode_string(fptr) } static VALUE -rb_io_reopen(io, nfile) +io_reopen(io, nfile) VALUE io, nfile; { OpenFile *fptr, *orig; @@ -1775,7 +1775,7 @@ rb_io_reopen(io, nfile) } static VALUE -rb_file_reopen(argc, argv, file) +rb_io_reopen(argc, argv, file) int argc; VALUE *argv; VALUE file; @@ -1787,7 +1787,7 @@ rb_file_reopen(argc, argv, file) rb_secure(4); if (rb_scan_args(argc, argv, "11", &fname, &nmode) == 1) { if (TYPE(fname) == T_FILE) { /* fname must be IO */ - return rb_io_reopen(file, fname); + return io_reopen(file, fname); } } @@ -3248,7 +3248,7 @@ Init_IO() rb_define_virtual_variable("$_", rb_lastline_get, rb_lastline_set); rb_define_method(rb_cIO, "clone", rb_io_clone, 0); - rb_define_method(rb_cIO, "reopen", rb_io_reopen, 1); + rb_define_method(rb_cIO, "reopen", rb_io_reopen, -1); rb_define_method(rb_cIO, "print", rb_io_print, -1); rb_define_method(rb_cIO, "putc", rb_io_putc, 1); @@ -3372,8 +3372,6 @@ Init_IO() Init_File(); - rb_define_method(rb_cFile, "reopen", rb_file_reopen, -1); - rb_define_singleton_method(rb_cFile, "new", rb_file_s_open, -1); rb_define_singleton_method(rb_cFile, "open", rb_file_s_open, -1); diff --git a/lib/debug.rb b/lib/debug.rb index 7807ebd4da..4497fd161d 100644 --- a/lib/debug.rb +++ b/lib/debug.rb @@ -383,11 +383,12 @@ class DEBUGGER__ binding, binding_file, binding_line = @frames[frame_pos] stdout.printf "#%d %s:%s\n", frame_pos, binding_file, binding_line - when /^\s*fi(?:nish)?$/ - if frame_pos == 0 + when /^\s*fin(?:ish)?$/ + if frame_pos == @frames.size stdout.print "\"finish\" not meaningful in the outermost frame.\n" else @finish_pos = @frames.size - frame_pos + p @finish_pos frame_pos = 0 return end @@ -563,10 +564,10 @@ class DEBUGGER__ @frames.unshift [binding, file, line, id] when 'return', 'end' - @frames.shift if @frames.size == @finish_pos @stop_next = 1 end + @frames.shift when 'end' @frames.shift diff --git a/lib/singleton.rb b/lib/singleton.rb index 2785c77134..235ba898fd 100644 --- a/lib/singleton.rb +++ b/lib/singleton.rb @@ -16,8 +16,8 @@ module Singleton klass.instance_eval %{ @__instance__ = nil def instance + Thread.critical = true unless @__instance__ - Thread.critical = true begin @__instance__ = new ensure diff --git a/lib/tempfile.rb b/lib/tempfile.rb index 11a8fba979..c432285309 100644 --- a/lib/tempfile.rb +++ b/lib/tempfile.rb @@ -15,9 +15,10 @@ require 'final' class Tempfile < SimpleDelegator Max_try = 10 - def Tempfile.callback(path) + def Tempfile.callback(path, data) lambda{ print "removing ", path, "..." if $DEBUG + data[0].close if data[0] if File.exist?(path) File.unlink(path) end @@ -47,10 +48,12 @@ class Tempfile < SimpleDelegator n += 1 end - @clean_files = Tempfile.callback(tmpname) + @protect = [] + @clean_files = Tempfile.callback(tmpname, @protect) ObjectSpace.define_finalizer(self, @clean_files) @tmpfile = File.open(tmpname, 'w+') + @protect[0] = @tmpfile @tmpname = tmpname super(@tmpfile) Dir.rmdir(lock) @@ -66,12 +69,13 @@ class Tempfile < SimpleDelegator def open @tmpfile.close if @tmpfile @tmpfile = File.open(@tmpname, 'r+') + @protect[0] = @tmpfile __setobj__(@tmpfile) end def close(real=false) @tmpfile.close if @tmpfile - @tmpfile = nil + @protect[0] = @tmpfile = nil if real @clean_files.call ObjectSpace.undefine_finalizer(self) @@ -266,8 +266,7 @@ rb_obj_is_kind_of(obj, c) } static VALUE -rb_obj_dummy(obj) - VALUE obj; +rb_obj_dummy() { return Qnil; } @@ -587,6 +586,7 @@ rb_mod_cmp(mod, arg) static VALUE rb_module_s_new(klass) + VALUE klass; { VALUE mod = rb_module_new(); @@ -979,7 +979,7 @@ Init_Object() rb_mKernel = rb_define_module("Kernel"); rb_include_module(rb_cObject, rb_mKernel); - rb_define_private_method(rb_cObject, "initialize", rb_obj_dummy, -1); + rb_define_private_method(rb_cObject, "initialize", rb_obj_dummy, 0); rb_define_private_method(rb_cClass, "inherited", rb_obj_dummy, 1); /* @@ -33,12 +33,11 @@ range_failed() return Qnil; /* dummy */ } -static VALUE -range_new(klass, beg, end, exclude_end) - VALUE klass, beg, end; +static void +range_init(obj, beg, end, exclude_end) + VALUE obj, beg, end; int exclude_end; { - VALUE obj; VALUE args[2]; args[0] = beg; args[1] = end; @@ -46,15 +45,12 @@ range_new(klass, beg, end, exclude_end) rb_rescue(range_check, (VALUE)args, range_failed, 0); } - obj = rb_obj_alloc(klass); if (exclude_end) { SET_EXCL(obj); } rb_ivar_set(obj, id_beg, beg); rb_ivar_set(obj, id_end, end); - - return obj; } VALUE @@ -62,19 +58,27 @@ rb_range_new(beg, end, exclude_end) VALUE beg, end; int exclude_end; { - return range_new(rb_cRange, beg, end, exclude_end); + VALUE obj = rb_obj_alloc(rb_cRange); + + range_init(obj, beg, end, exclude_end); + return obj; } static VALUE -range_s_new(argc, argv, klass) +range_initialize(argc, argv, obj) int argc; VALUE *argv; - VALUE klass; + VALUE obj; { VALUE beg, end, flag; rb_scan_args(argc, argv, "21", &beg, &end, &flag); - return range_new(klass, beg, end, RTEST(flag)); + /* Ranges are immutable, so that they should be initialized only once. */ + if (rb_ivar_defined(obj, id_beg)) { + rb_raise(rb_eNameError, "`initialize' called twice"); + } + range_init(obj, beg, end, RTEST(flag)); + return Qnil; } static VALUE @@ -328,7 +332,7 @@ Init_Range() { rb_cRange = rb_define_class("Range", rb_cObject); rb_include_module(rb_cRange, rb_mEnumerable); - rb_define_singleton_method(rb_cRange, "new", range_s_new, -1); + rb_define_method(rb_cRange, "initialize", range_initialize, -1); rb_define_method(rb_cRange, "===", range_eqq, 1); rb_define_method(rb_cRange, "each", range_each, 0); rb_define_method(rb_cRange, "first", range_first, 0); @@ -179,7 +179,7 @@ void rb_check_safe_str _((VALUE)); #define Check_SafeStr(v) rb_check_safe_str((VALUE)(v)) void rb_secure _((int)); -extern int ruby_safe_level; +EXTERN int ruby_safe_level; #define rb_safe_level() (ruby_safe_level) void rb_set_safe_level _((int)); @@ -191,27 +191,16 @@ rb_str_dup(str) } static VALUE -rb_str_s_new(klass, orig) +rb_str_s_new(argc, argv, klass) + int argc; + VALUE *argv; VALUE klass; - VALUE orig; { - NEWOBJ(str, struct RString); + VALUE str = rb_str_new(0, 0); OBJSETUP(str, klass, T_STRING); - str->orig = 0; - orig = rb_obj_as_string(orig); - str->len = RSTRING(orig)->len; - if (RSTRING(orig)->ptr) { - str->ptr = ALLOC_N(char, RSTRING(orig)->len+1); - memcpy(str->ptr, RSTRING(orig)->ptr, RSTRING(orig)->len); - str->ptr[RSTRING(orig)->len] = '\0'; - } - - if (rb_safe_level() >= 3) { - OBJ_TAINT(str); - } - - return (VALUE)str; + rb_obj_call_init(str, argc, argv); + return str; } static VALUE @@ -257,9 +246,13 @@ rb_str_times(str, times) long i, len; len = NUM2LONG(times); + if (len == 0) return rb_str_new(0,0); if (len < 0) { rb_raise(rb_eArgError, "negative argument"); } + if (LONG_MAX/len < RSTRING(str)->len) { + rb_raise(rb_eArgError, "argument too big"); + } str2 = rb_str_new(0, RSTRING(str)->len*len); for (i=0; i<len; i++) { @@ -811,6 +804,7 @@ rb_str_aref(str, indx) case T_FIXNUM: idx = FIX2LONG(indx); + num_index: if (idx < 0) { idx = RSTRING(str)->len + idx; } @@ -841,7 +835,8 @@ rb_str_aref(str, indx) return rb_str_substr(str, beg, len); } } - rb_raise(rb_eIndexError, "invalid index for string"); + idx = NUM2LONG(indx); + goto num_index; } return Qnil; /* not reached */ } @@ -863,8 +858,8 @@ rb_str_aref_m(argc, argv, str) static void rb_str_replace(str, beg, len, val) VALUE str, val; - int beg; - int len; + long beg; + long len; { if (len < RSTRING(val)->len) { /* expand string */ @@ -891,12 +886,12 @@ rb_str_aset(str, indx, val) VALUE str; VALUE indx, val; { - int idx; - int beg; + long idx, beg; switch (TYPE(indx)) { case T_FIXNUM: - beg = idx = NUM2INT(indx); + num_index: + idx = NUM2INT(indx); if (idx < 0) { idx += RSTRING(str)->len; } @@ -943,7 +938,8 @@ rb_str_aset(str, indx, val) return val; } } - rb_raise(rb_eIndexError, "invalid index for string"); + idx = NUM2LONG(indx); + goto num_index; } } @@ -955,7 +951,7 @@ rb_str_aset_m(argc, argv, str) { rb_str_modify(str); if (argc == 3) { - int beg, len; + long beg, len; if (TYPE(argv[2]) != T_STRING) argv[2] = rb_str_to_str(argv[2]); beg = NUM2INT(argv[0]); @@ -1049,7 +1045,7 @@ rb_str_sub_bang(argc, argv, str) VALUE pat, repl, match; struct re_registers *regs; int iter = 0; - int plen; + long plen; if (argc == 1 && rb_iterator_p()) { iter = 1; @@ -1113,10 +1109,10 @@ rb_str_gsub_bang(argc, argv, str) { VALUE pat, val, repl, match; struct re_registers *regs; - int beg, n; + long beg, n; + long offset, blen, len; int iter = 0; char *buf, *bp, *cp; - int offset, blen, len; int tainted = 0; if (argc == 1 && rb_iterator_p()) { @@ -1462,7 +1458,7 @@ static VALUE rb_str_dump(str) VALUE str; { - int len; + long len; char *p, *pend; char *q, *qend; VALUE result; @@ -2038,7 +2034,7 @@ rb_str_split_m(argc, argv, str) VALUE spat; VALUE limit; int char_sep = -1; - int beg, end, i; + long beg, end, i; int lim = 0; VALUE result, tmp; @@ -2078,7 +2074,7 @@ rb_str_split_m(argc, argv, str) beg = 0; if (char_sep >= 0) { char *ptr = RSTRING(str)->ptr; - int len = RSTRING(str)->len; + long len = RSTRING(str)->len; char *eptr = ptr + len; if (char_sep == ' ') { /* AWK emulation */ @@ -2120,9 +2116,9 @@ rb_str_split_m(argc, argv, str) } } else { - int start = beg; + long start = beg; + long idx; int last_null = 0; - int idx; struct re_registers *regs; while ((end = rb_reg_search(spat, str, start, 0)) >= 0) { @@ -2198,7 +2194,7 @@ rb_str_each_line(argc, argv, str) int rslen; char *p = RSTRING(str)->ptr, *pend = p + RSTRING(str)->len, *s; char *ptr = p; - int len = RSTRING(str)->len; + long len = RSTRING(str)->len; VALUE line; if (rb_scan_args(argc, argv, "01", &rs) == 0) { @@ -2251,7 +2247,7 @@ static VALUE rb_str_each_byte(str) VALUE str; { - int i; + long i; for (i=0; i<RSTRING(str)->len; i++) { rb_yield(INT2FIX(RSTRING(str)->ptr[i] & 0xff)); @@ -2314,7 +2310,7 @@ rb_str_chomp_bang(argc, argv, str) int newline; int rslen; char *p = RSTRING(str)->ptr; - int len = RSTRING(str)->len; + long len = RSTRING(str)->len; if (rb_scan_args(argc, argv, "01", &rs) == 0) { rs = rb_rs; @@ -2654,7 +2650,8 @@ Init_String() rb_cString = rb_define_class("String", rb_cObject); rb_include_module(rb_cString, rb_mComparable); rb_include_module(rb_cString, rb_mEnumerable); - rb_define_singleton_method(rb_cString, "new", rb_str_s_new, 1); + rb_define_singleton_method(rb_cString, "new", rb_str_s_new, -1); + rb_define_method(rb_cString, "initialize", rb_str_replace_m, 1); rb_define_method(rb_cString, "clone", rb_str_clone, 0); rb_define_method(rb_cString, "dup", rb_str_dup, 0); rb_define_method(rb_cString, "<=>", rb_str_cmp_m, 1); @@ -74,6 +74,24 @@ time_s_now(klass) } static VALUE +time_s_new(argc, argv, klass) + int argc; + VALUE *argv; + VALUE klass; +{ + VALUE obj = time_s_now(klass); + + rb_obj_call_init(obj, argc, argv); + return obj; +} + +static VALUE +time_initialize() +{ + return Qnil; +} + +static VALUE time_new_internal(klass, sec, usec) VALUE klass; time_t sec, usec; @@ -983,7 +1001,7 @@ Init_Time() rb_include_module(rb_cTime, rb_mComparable); rb_define_singleton_method(rb_cTime, "now", time_s_now, 0); - rb_define_singleton_method(rb_cTime, "new", time_s_now, 0); + rb_define_singleton_method(rb_cTime, "new", time_s_new, -1); rb_define_singleton_method(rb_cTime, "at", time_s_at, -1); rb_define_singleton_method(rb_cTime, "gm", time_s_timegm, -1); rb_define_singleton_method(rb_cTime, "local", time_s_timelocal, -1); @@ -33,7 +33,7 @@ s%@AR@%ar%g s%@INSTALL_PROGRAM@%${INSTALL}%g s%@INSTALL_DATA@%${INSTALL} -m 644%g s%@SET_MAKE@%%g -s%@LIBOBJS@% crypt.o flock.o fnmatch.o vsnprintf.o%g +s%@LIBOBJS@% crypt.o flock.o vsnprintf.o%g s%@ALLOCA@%%g s%@DEFAULT_KCODE@%%g s%@EXEEXT@%.exe%g @@ -1,4 +1,4 @@ #define RUBY_VERSION "1.5.2" -#define RUBY_RELEASE_DATE "2000-02-25" +#define RUBY_RELEASE_DATE "2000-02-29" #define RUBY_VERSION_CODE 152 -#define RUBY_RELEASE_CODE 20000225 +#define RUBY_RELEASE_CODE 20000229 diff --git a/win32/ruby.def b/win32/ruby.def index 8f1fc4800c..9c50400ab9 100644 --- a/win32/ruby.def +++ b/win32/ruby.def @@ -34,6 +34,7 @@ EXPORTS ruby_nerrs ;eval.c rb_cProc + ruby_safe_level ruby_frame rb_cThread rb_thread_tick @@ -133,6 +134,7 @@ EXPORTS mygetservbyname mygetservbyport myget_osfhandle + win32_getcwd win32_getenv ;array.c rb_mem_clear @@ -172,6 +174,7 @@ EXPORTS rb_int2big rb_uint2inum rb_int2inum + rb_cstr2inum rb_str2inum rb_big2str rb_big2ulong @@ -224,7 +227,6 @@ EXPORTS dln_find_file ;enum.c rb_each - rb_enum_length ;error.c rb_compile_error rb_compile_error_append @@ -250,10 +252,9 @@ EXPORTS rb_method_boundp rb_attr rb_dvar_defined + rb_dvar_curr rb_dvar_ref rb_dvar_push - rb_dvar_asgn - rb_safe_level rb_set_safe_level rb_check_safe_str rb_secure @@ -323,8 +324,12 @@ EXPORTS ;file.c eaccess rb_file_s_expand_path + rb_file_const + rb_find_file + rb_path_check ;gc.c xmalloc + xfree xcalloc xrealloc rb_global_variable @@ -356,6 +361,7 @@ EXPORTS rb_io_check_closed rb_io_check_readable rb_io_check_writable + rb_read_pending rb_read_check rb_io_write rb_io_eof @@ -372,7 +378,7 @@ EXPORTS rb_fdopen rb_file_open rb_file_sysopen - rb_io_synchronized + rb_io_synchronized rb_p rb_gets rb_str_setter @@ -432,7 +438,9 @@ EXPORTS rb_range_beg_len ;re.c rb_str_cicmp + rb_reg_mbclen2 rb_match_busy + rb_reg_adjust_startpos rb_reg_search rb_reg_nth_defined rb_reg_nth_match @@ -518,10 +526,10 @@ EXPORTS rb_class_of rb_type rb_special_const_p - rb_test_false_or_nil ruby_scan_oct ruby_scan_hex ruby_mktemp + ruby_add_suffix ruby_qsort ;variable.c rb_mod_name @@ -542,7 +550,8 @@ EXPORTS rb_f_untrace_var rb_gvar_get rb_gvar_set - rb_gvar_set2 + rb_gv_set + rb_gv_get rb_gvar_defined rb_f_global_variables rb_alias_variable |