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

ruby-changes:24655

From: nobu <ko1@a...>
Date: Wed, 15 Aug 2012 16:23:54 +0900 (JST)
Subject: [ruby-changes:24655] nobu:r36706 (trunk): sprintf.c: coderange fix

nobu	2012-08-15 16:23:38 +0900 (Wed, 15 Aug 2012)

  New Revision: 36706

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

  Log:
    sprintf.c: coderange fix
    
    * sprintf.c (ruby__sfvwrite): set buffer length and exclude
      uninitialized garbage to get correct coderange.

  Modified files:
    trunk/ChangeLog
    trunk/sprintf.c
    trunk/test/-ext-/test_printf.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 36705)
+++ ChangeLog	(revision 36706)
@@ -1,3 +1,14 @@
+Wed Aug 15 16:23:35 2012  Nobuyoshi Nakada  <nobu@r...>
+
+	* sprintf.c (ruby__sfvwrite): set buffer length and exclude
+	  uninitialized garbage to get correct coderange.
+
+	* sprintf.c (ruby__sfvextra): the result should be infected by the
+	  given strings.
+
+	* sprintf.c (ruby__sfvwrite): set buffer length and exclude
+	  uninitialized garbage to get correct coderange.
+
 Wed Aug 15 16:20:09 2012  Nobuyoshi Nakada  <nobu@r...>
 
 	* common.mk (ID_H_TARGET): make timestamp file of id.h so that the
Index: sprintf.c
===================================================================
--- sprintf.c	(revision 36705)
+++ sprintf.c	(revision 36706)
@@ -1174,6 +1174,7 @@
 	len -= n;
     }
     fp->_p = (unsigned char *)buf;
+    rb_str_set_len(result, buf - RSTRING_PTR(result));
     return 0;
 }
 
Index: test/-ext-/test_printf.rb
===================================================================
--- test/-ext-/test_printf.rb	(revision 36705)
+++ test/-ext-/test_printf.rb	(revision 36706)
@@ -21,4 +21,11 @@
   def test_inspect
     assert_equal("{<#{self.class}:#{object_id}>}", Bug::Printf.v(self))
   end
+
+  def test_encoding
+    def self.to_s
+      "\u{3042 3044 3046 3048 304a}"
+    end
+    assert_equal("<\u{3042 3044 3046 3048 304a}>", Bug::Printf.s(self))
+  end
 end

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

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