[前][次][番号順一覧][スレッド一覧]

ruby-changes:34116

From: usa <ko1@a...>
Date: Wed, 28 May 2014 13:19:22 +0900 (JST)
Subject: [ruby-changes:34116] usa:r46197 (ruby_2_0_0): merge revision(s) 45646: [Backport #9765]

usa	2014-05-28 13:19:08 +0900 (Wed, 28 May 2014)

  New Revision: 46197

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=46197

  Log:
    merge revision(s) 45646: [Backport #9765]
    
    * ext/stringio/stringio.c (strio_putc): fix for non-ascii
      encoding, like as IO#putc.  [ruby-dev:48114] [Bug #9765]

  Modified directories:
    branches/ruby_2_0_0/
  Modified files:
    branches/ruby_2_0_0/ChangeLog
    branches/ruby_2_0_0/ext/stringio/stringio.c
    branches/ruby_2_0_0/test/stringio/test_stringio.rb
    branches/ruby_2_0_0/version.h
Index: ruby_2_0_0/ChangeLog
===================================================================
--- ruby_2_0_0/ChangeLog	(revision 46196)
+++ ruby_2_0_0/ChangeLog	(revision 46197)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ChangeLog#L1
+Wed May 28 13:18:21 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* ext/stringio/stringio.c (strio_putc): fix for non-ascii
+	  encoding, like as IO#putc.  [ruby-dev:48114] [Bug #9765]
+
 Tue May 27 13:57:41 2014  Nobuyoshi Nakada  <nobu@r...>
 
 	* lib/fileutils.rb (FileUtils#copy_entry): update rdoc about
Index: ruby_2_0_0/ext/stringio/stringio.c
===================================================================
--- ruby_2_0_0/ext/stringio/stringio.c	(revision 46196)
+++ ruby_2_0_0/ext/stringio/stringio.c	(revision 46197)
@@ -1235,17 +1235,17 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ext/stringio/stringio.c#L1235
 strio_putc(VALUE self, VALUE ch)
 {
     struct StringIO *ptr = writable(self);
-    int c = NUM2CHR(ch);
-    long olen;
+    VALUE str;
 
     check_modifiable(ptr);
-    olen = RSTRING_LEN(ptr->string);
-    if (ptr->flags & FMODE_APPEND) {
-	ptr->pos = olen;
+    if (RB_TYPE_P(ch, T_STRING)) {
+	str = rb_str_substr(ch, 0, 1);
     }
-    strio_extend(ptr, ptr->pos, 1);
-    RSTRING_PTR(ptr->string)[ptr->pos++] = c;
-    OBJ_INFECT(ptr->string, self);
+    else {
+	char c = NUM2CHR(ch);
+	str = rb_str_new(&c, 1);
+    }
+    strio_write(self, str);
     return ch;
 }
 
Index: ruby_2_0_0/version.h
===================================================================
--- ruby_2_0_0/version.h	(revision 46196)
+++ ruby_2_0_0/version.h	(revision 46197)
@@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/version.h#L1
 #define RUBY_VERSION "2.0.0"
-#define RUBY_RELEASE_DATE "2014-05-27"
-#define RUBY_PATCHLEVEL 487
+#define RUBY_RELEASE_DATE "2014-05-28"
+#define RUBY_PATCHLEVEL 488
 
 #define RUBY_RELEASE_YEAR 2014
 #define RUBY_RELEASE_MONTH 5
-#define RUBY_RELEASE_DAY 27
+#define RUBY_RELEASE_DAY 28
 
 #include "ruby/version.h"
 
Index: ruby_2_0_0/test/stringio/test_stringio.rb
===================================================================
--- ruby_2_0_0/test/stringio/test_stringio.rb	(revision 46196)
+++ ruby_2_0_0/test/stringio/test_stringio.rb	(revision 46197)
@@ -411,6 +411,22 @@ class TestStringIO < Test::Unit::TestCas https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/stringio/test_stringio.rb#L411
     assert_equal("foo123", s)
   end
 
+  def test_putc_nonascii
+    s = ""
+    f = StringIO.new(s, "w")
+    f.putc("\u{3042}")
+    f.putc(0x3044)
+    f.close
+    assert_equal("\u{3042}D", s)
+
+    s = "foo"
+    f = StringIO.new(s, "a")
+    f.putc("\u{3042}")
+    f.putc(0x3044)
+    f.close
+    assert_equal("foo\u{3042}D", s)
+  end
+
   def test_read
     f = StringIO.new("\u3042\u3044")
     assert_raise(ArgumentError) { f.read(-1) }

Property changes on: ruby_2_0_0
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r45646


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]