From 1199a7d3d6399d44662b9a8bea5f359d1fdd40c2 Mon Sep 17 00:00:00 2001 From: matz Date: Wed, 14 Jun 2000 08:08:50 +0000 Subject: 2000-06-14-2 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@759 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 24 +++++++++++++++++++++--- eval.c | 3 ++- io.c | 7 +++++++ rubytest.rb | 2 +- string.c | 39 ++++++++++++++++++++++++--------------- 5 files changed, 55 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index d56c886de4..31640b724d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,23 @@ +Wed Jun 14 17:01:41 2000 Katsuyuki Komatsu + + * rubytest.rb: add CONFIG['EXEEXT'] to the executable file name. + Wed Jun 14 14:50:00 2000 Yukihiro Matsumoto + * string.c (rb_f_sub): assign to $_ only if modification happens. + + * string.c (rb_f_gsub): ditto. + + * string.c (rb_f_chop): ditto. + + * string.c (rb_f_chomp): ditto. + + * io.c (io_reopen): preserve file position by ftell/fseek, if io + is a seekable. + + * eval.c (method_arity): wrong arity number for the methods with + optional arguments. + * time.c (make_time_t): opposite timezone shift (should be negative). Wed Jun 14 14:07:38 2000 WATANABE Hirofumi @@ -73,7 +91,7 @@ Fri Jun 9 15:11:35 2000 Yukihiro Matsumoto * time.c (make_time_t): supports daylight saving time. - * eval.c (rb_thread_safe_level): should retrive current $SAFE + * eval.c (rb_thread_safe_level): should retrieve current $SAFE value if a thread is the current thread. Thu Jun 8 14:25:45 2000 Hiroshi Igarashi @@ -111,7 +129,7 @@ Mon Jun 5 00:13:35 2000 WATANABE Hirofumi Sun Jun 4 03:17:36 2000 Wakou Aoyama - * lib/cig.rb: improve: CGI::pretty() + * lib/cgi.rb: improve: CGI::pretty() Sun Jun 4 02:01:10 2000 WATANABE Hirofumi @@ -381,7 +399,7 @@ May 16 19:45:32 2000 Katsuyuki Komatsu * intern.h: use EXTERN instead of extern. - * win32/ruby.h: add rb_defout, rb_stdout, ruby_errinfo, + * win32/ruby.def: add rb_defout, rb_stdout, ruby_errinfo, ruby_sourceline, ruby_sourcefile to work with eruby reported by Hiroshi Saito . Export both ruby_xmalloc and xmalloc etc. diff --git a/eval.c b/eval.c index 0057624011..f886db1215 100644 --- a/eval.c +++ b/eval.c @@ -6165,7 +6165,8 @@ method_arity(method) body = body->nd_head; if (!body) return INT2FIX(0); n = body->nd_cnt; - if (body->nd_rest >= 0) n = -n-1; + if (body->nd_opt || body->nd_rest >= 0) + n = -n-1; return INT2FIX(n); } } diff --git a/io.c b/io.c index 0d604a9fe3..a2dca1a4a0 100644 --- a/io.c +++ b/io.c @@ -1755,6 +1755,7 @@ io_reopen(io, nfile) OpenFile *fptr, *orig; char *mode; int fd; + long pos; nfile = rb_io_get_io(nfile); if (rb_safe_level() >= 4 && (!OBJ_TAINTED(io) || !OBJ_TAINTED(nfile))) { @@ -1764,6 +1765,9 @@ io_reopen(io, nfile) GetOpenFile(nfile, orig); if (fptr == orig) return io; + if (orig->mode & FMODE_READABLE) { + pos = ftell(orig->f); + } if (orig->f2) { if (fflush(orig->f2) == EOF) rb_sys_fail(orig->path); } @@ -1793,6 +1797,9 @@ io_reopen(io, nfile) if (dup2(fileno(orig->f), fd) < 0) rb_sys_fail(orig->path); fptr->f = rb_fdopen(fd, mode); + if (orig->mode & FMODE_READABLE && pos >= 0) { + fseek(fptr->f, pos, SEEK_SET); + } } if (fptr->f2) { diff --git a/rubytest.rb b/rubytest.rb index a2380e6f4c..c25155bb67 100644 --- a/rubytest.rb +++ b/rubytest.rb @@ -3,7 +3,7 @@ require 'rbconfig' include Config -unless File.exist? "./#{CONFIG['ruby_install_name']}" +unless File.exist? "./#{CONFIG['ruby_install_name']}#{CONFIG['EXEEXT']}" print "./#{CONFIG['ruby_install_name']} is not found.\n" print "Try `make' first, then `make test', please.\n" exit 0 diff --git a/string.c b/string.c index 27d51e46e3..d5de27864f 100644 --- a/string.c +++ b/string.c @@ -1313,11 +1313,13 @@ rb_f_sub(argc, argv) int argc; VALUE *argv; { - VALUE str = rb_str_dup(uscore_get()); + VALUE str = uscore_get(); + VALUE dup = rb_str_dup(str); - rb_str_sub_bang(argc, argv, str); - rb_lastline_set(str); - return str; + if (NIL_P(rb_str_sub_bang(argc, argv, dup))) + return str; + rb_lastline_set(dup); + return dup; } static VALUE @@ -1333,11 +1335,13 @@ rb_f_gsub(argc, argv) int argc; VALUE *argv; { - VALUE str = rb_str_dup(uscore_get()); + VALUE str = uscore_get(); + VALUE dup = rb_str_dup(str); - rb_str_gsub_bang(argc, argv, str); - rb_lastline_set(str); - return str; + if (NIL_P(rb_str_gsub_bang(argc, argv, dup))) + return str; + rb_lastline_set(dup); + return dup; } static VALUE @@ -2356,10 +2360,13 @@ rb_f_chop_bang(str) static VALUE rb_f_chop() { - VALUE str = rb_str_dup(uscore_get()); + VALUE str = uscore_get(); - rb_str_chop_bang(str); - rb_lastline_set(str); + if (RSTRING(str)->len > 0) { + str = rb_str_dup(str); + rb_str_chop_bang(str); + rb_lastline_set(str); + } return str; } @@ -2432,11 +2439,13 @@ rb_f_chomp(argc, argv) int argc; VALUE *argv; { - VALUE str = rb_str_dup(uscore_get()); + VALUE str = uscore_get(); + VALUE dup = rb_str_dup(str); - rb_str_chomp_bang(argc, argv, str); - rb_lastline_set(str); - return str; + if (NIL_P(rb_str_chomp_bang(argc, argv, dup))) + return str; + rb_lastline_set(dup); + return dup; } static VALUE -- cgit v1.2.3