From 4f5976cbb826df462c62a0a8e72ebe91c15a7ba4 Mon Sep 17 00:00:00 2001 From: matz Date: Wed, 3 Dec 2003 17:30:09 +0000 Subject: [PATCH] * io.c (argf_read): should not terminate on empty string; wait until real EOF. [ruby-dev:21969] * io.c (argf_read): should adjust length to read, when length is specified and read spans command line argument files. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5096 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ io.c | 20 ++++++++++++++------ lib/delegate.rb | 3 ++- test/ruby/test_env.rb | 2 +- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index fca180cb57..6f290088c8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Thu Dec 4 01:45:24 2003 Yukihiro Matsumoto + + * io.c (argf_read): should not terminate on empty string; wait + until real EOF. [ruby-dev:21969] + + * io.c (argf_read): should adjust length to read, when length is + specified and read spans command line argument files. + Wed Dec 3 19:38:36 2003 Masatoshi SEKI * lib/drb/drb.rb: correct fcntl parameter. [ruby-dev:22120] diff --git a/io.c b/io.c index 7d6637e1f3..f0231567ba 100644 --- a/io.c +++ b/io.c @@ -3828,16 +3828,24 @@ argf_read(argc, argv) else { tmp = io_read(argc, argv, current_file); } - if (NIL_P(tmp) && next_p != -1) { - argf_close(current_file); - next_p = 1; - if (argc == 0) goto retry; + if (NIL_P(tmp)) { + if (next_p != -1) { + argf_close(current_file); + next_p = 1; + goto retry; + } + return str; } - if (NIL_P(tmp) || RSTRING(tmp)->len == 0) return str; else if (NIL_P(str)) str = tmp; else rb_str_append(str, tmp); if (argc == 0) goto retry; - + if (argc == 1) { + if (RSTRING(str)->len < len) { + len -= RSTRING(str)->len; + argv[0] = INT2NUM(len); + goto retry; + } + } return str; } diff --git a/lib/delegate.rb b/lib/delegate.rb index 578859fdc6..41d35477e4 100644 --- a/lib/delegate.rb +++ b/lib/delegate.rb @@ -46,6 +46,7 @@ class Delegator end end end + alias initialize_methods initialize def __getobj__ raise NotImplementedError, "need to define `__getobj__'" @@ -55,7 +56,7 @@ class Delegator __getobj__ end def marshal_load(obj) - initialize(obj) + initialize_methods(obj) end end diff --git a/test/ruby/test_env.rb b/test/ruby/test_env.rb index 6ae28dbbee..7d660f05a5 100644 --- a/test/ruby/test_env.rb +++ b/test/ruby/test_env.rb @@ -3,7 +3,7 @@ require 'test/unit' $KCODE = 'none' class TestEnv < Test::Unit::TestCase - IGNORE_CASE = /djgpp|bccwin|mswin|mingw|emx/ =~ RUBY_PLATFORM + IGNORE_CASE = /djgpp|bccwin|mswin|mingw/ =~ RUBY_PLATFORM def setup @backup = ENV['test']