mirror of
https://github.com/ruby/ruby.git
synced 2025-09-15 16:44:01 +02:00
merges r25127 from trunk into ruby_1_9_1.
-- * stringio/stringio.c (strio_read): set ASCII-8BIT encoding when length argument is given. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@25952 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
e6a97bf82d
commit
f1d6d2da33
4 changed files with 13 additions and 5 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Mon Sep 28 10:06:38 2009 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
|
* stringio/stringio.c (strio_read): set ASCII-8BIT encoding
|
||||||
|
when length argument is given.
|
||||||
|
|
||||||
Sun Sep 27 13:06:43 2009 Tanaka Akira <akr@fsij.org>
|
Sun Sep 27 13:06:43 2009 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* lib/pp.rb (PP:ObjectMixin#pretty_print): delegates has no inspect
|
* lib/pp.rb (PP:ObjectMixin#pretty_print): delegates has no inspect
|
||||||
|
|
|
@ -1137,7 +1137,7 @@ strio_read(int argc, VALUE *argv, VALUE self)
|
||||||
{
|
{
|
||||||
struct StringIO *ptr = readable(StringIO(self));
|
struct StringIO *ptr = readable(StringIO(self));
|
||||||
VALUE str = Qnil;
|
VALUE str = Qnil;
|
||||||
long len, olen;
|
long len;
|
||||||
|
|
||||||
switch (argc) {
|
switch (argc) {
|
||||||
case 2:
|
case 2:
|
||||||
|
@ -1146,7 +1146,7 @@ strio_read(int argc, VALUE *argv, VALUE self)
|
||||||
rb_str_modify(str);
|
rb_str_modify(str);
|
||||||
case 1:
|
case 1:
|
||||||
if (!NIL_P(argv[0])) {
|
if (!NIL_P(argv[0])) {
|
||||||
len = olen = NUM2LONG(argv[0]);
|
len = NUM2LONG(argv[0]);
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
rb_raise(rb_eArgError, "negative length %ld given", len);
|
rb_raise(rb_eArgError, "negative length %ld given", len);
|
||||||
}
|
}
|
||||||
|
@ -1158,7 +1158,6 @@ strio_read(int argc, VALUE *argv, VALUE self)
|
||||||
}
|
}
|
||||||
/* fall through */
|
/* fall through */
|
||||||
case 0:
|
case 0:
|
||||||
olen = -1;
|
|
||||||
len = RSTRING_LEN(ptr->string);
|
len = RSTRING_LEN(ptr->string);
|
||||||
if (len <= ptr->pos) {
|
if (len <= ptr->pos) {
|
||||||
if (NIL_P(str)) {
|
if (NIL_P(str)) {
|
||||||
|
@ -1178,6 +1177,7 @@ strio_read(int argc, VALUE *argv, VALUE self)
|
||||||
}
|
}
|
||||||
if (NIL_P(str)) {
|
if (NIL_P(str)) {
|
||||||
str = strio_substr(ptr, ptr->pos, len);
|
str = strio_substr(ptr, ptr->pos, len);
|
||||||
|
if (argc > 0) rb_enc_associate(str, rb_ascii8bit_encoding());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
long rest = RSTRING_LEN(ptr->string) - ptr->pos;
|
long rest = RSTRING_LEN(ptr->string) - ptr->pos;
|
||||||
|
|
|
@ -384,9 +384,12 @@ class TestStringIO < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_read
|
def test_read
|
||||||
f = StringIO.new("1234")
|
f = StringIO.new("\u3042\u3044")
|
||||||
assert_raise(ArgumentError) { f.read(-1) }
|
assert_raise(ArgumentError) { f.read(-1) }
|
||||||
assert_raise(ArgumentError) { f.read(1, 2, 3) }
|
assert_raise(ArgumentError) { f.read(1, 2, 3) }
|
||||||
|
assert_equal("\u3042\u3044", f.read)
|
||||||
|
f.rewind
|
||||||
|
assert_equal("\u3042\u3044".force_encoding(Encoding::ASCII_8BIT), f.read(f.size))
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_size
|
def test_size
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#define RUBY_VERSION "1.9.1"
|
#define RUBY_VERSION "1.9.1"
|
||||||
#define RUBY_PATCHLEVEL 353
|
#define RUBY_PATCHLEVEL 354
|
||||||
#define RUBY_VERSION_MAJOR 1
|
#define RUBY_VERSION_MAJOR 1
|
||||||
#define RUBY_VERSION_MINOR 9
|
#define RUBY_VERSION_MINOR 9
|
||||||
#define RUBY_VERSION_TEENY 1
|
#define RUBY_VERSION_TEENY 1
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue