summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-03-09 00:55:01 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-03-09 00:55:01 +0000
commitd9ce3805d6c0e24e7e9ad66aa0444f397fa81170 (patch)
treebf271985c702cf39c837a7a0aee46bb8bd69dfee
parent0b85e2a0a7d95a7572fff1650d0217d66d7defda (diff)
merge revision(s) 21913:
* io.c (io_getpartial): fflush after read for updating pos in FILE. not portable, I guess. [ruby-core:21561] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@22838 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--io.c2
-rw-r--r--test/ruby/test_io.rb20
-rw-r--r--version.h2
4 files changed, 28 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index f554c613fc..2753abaa2a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Mon Mar 9 09:52:53 2009 Tanaka Akira <akr@fsij.org>
+
+ * io.c (io_getpartial): fflush after read for updating pos in FILE.
+ not portable, I guess. [ruby-core:21561]
+
Mon Mar 9 09:04:39 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* gc.c (define_final): cannot define finalizer for immediate
diff --git a/io.c b/io.c
index 7663733d1e..8b0e51b460 100644
--- a/io.c
+++ b/io.c
@@ -1283,6 +1283,8 @@ io_getpartial(int argc, VALUE *argv, VALUE io, int nonblock)
goto again;
rb_sys_fail(fptr->path);
}
+ if (fptr->f) /* update pos in FILE structure [ruby-core:21561] */
+ fflush(fptr->f);
}
rb_str_resize(str, n);
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb
index 642c8f4430..19b4f0ebf6 100644
--- a/test/ruby/test_io.rb
+++ b/test/ruby/test_io.rb
@@ -1,6 +1,15 @@
require 'test/unit'
+require 'tmpdir'
class TestIO < Test::Unit::TestCase
+ def mkcdtmpdir
+ Dir.mktmpdir {|d|
+ Dir.chdir(d) {
+ yield
+ }
+ }
+ end
+
def test_gets_rs
r, w = IO.pipe
w.print "\377xyz"
@@ -8,4 +17,15 @@ class TestIO < Test::Unit::TestCase
assert_equal("\377", r.gets("\377"), "[ruby-dev:24460]")
r.close
end
+
+ def test_readpartial_pos
+ mkcdtmpdir {
+ open("foo", "w") {|f| f << "abc" }
+ open("foo") {|f|
+ f.seek(0)
+ assert_equal("ab", f.readpartial(2))
+ assert_equal(2, f.pos)
+ }
+ }
+ end
end
diff --git a/version.h b/version.h
index 6c4059b527..de5d2589ed 100644
--- a/version.h
+++ b/version.h
@@ -2,7 +2,7 @@
#define RUBY_RELEASE_DATE "2009-03-09"
#define RUBY_VERSION_CODE 187
#define RUBY_RELEASE_CODE 20090309
-#define RUBY_PATCHLEVEL 146
+#define RUBY_PATCHLEVEL 147
#define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 8