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

ruby-changes:17839

From: naruse <ko1@a...>
Date: Mon, 22 Nov 2010 14:27:09 +0900 (JST)
Subject: [ruby-changes:17839] Ruby:r29851 (trunk): * time.c (time_zone): use rb_locale_str_new_cstr to set encoding

naruse	2010-11-22 14:25:15 +0900 (Mon, 22 Nov 2010)

  New Revision: 29851

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

  Log:
    * time.c (time_zone): use rb_locale_str_new_cstr to set encoding
      as locale and convert its content to internal encoding.
      [ruby-core:33278]

  Modified files:
    trunk/ChangeLog
    trunk/test/ruby/test_time.rb
    trunk/time.c

Index: time.c
===================================================================
--- time.c	(revision 29850)
+++ time.c	(revision 29851)
@@ -4189,11 +4189,11 @@
     MAKE_TM(time, tobj);
 
     if (TIME_UTC_P(tobj)) {
-	return rb_str_new2("UTC");
+	return rb_obj_untaint(rb_locale_str_new_cstr("UTC"));
     }
     if (tobj->vtm.zone == NULL)
         return Qnil;
-    return rb_str_new2(tobj->vtm.zone);
+    return rb_obj_untaint(rb_locale_str_new_cstr(tobj->vtm.zone));
 }
 
 /*
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 29850)
+++ ChangeLog	(revision 29851)
@@ -1,3 +1,9 @@
+Mon Nov 22 14:22:45 2010  NARUSE, Yui  <naruse@r...>
+
+	* time.c (time_zone): use rb_locale_str_new_cstr to set encoding
+	  as locale and convert its content to internal encoding.
+	  [ruby-core:33278]
+
 Mon Nov 22 11:58:11 2010  NARUSE, Yui  <naruse@r...>
 
 	* string.c (rb_str_concat): set ENC_CODERANGE_VALID when the
Index: test/ruby/test_time.rb
===================================================================
--- test/ruby/test_time.rb	(revision 29850)
+++ test/ruby/test_time.rb	(revision 29851)
@@ -465,6 +465,7 @@
     assert_equal(1, T2000.yday)
     assert_equal(false, T2000.isdst)
     assert_equal("UTC", T2000.zone)
+    assert_equal(Encoding.find("locale"), T2000.zone.encoding)
     assert_equal(0, T2000.gmt_offset)
     assert(!T2000.sunday?)
     assert(!T2000.monday?)
@@ -486,6 +487,7 @@
     assert_equal(t.yday, Time.at(946684800).yday)
     assert_equal(t.isdst, Time.at(946684800).isdst)
     assert_equal(t.zone, Time.at(946684800).zone)
+    assert_equal(Encoding.find("locale"), Time.at(946684800).zone.encoding)
     assert_equal(t.gmt_offset, Time.at(946684800).gmt_offset)
     assert_equal(t.sunday?, Time.at(946684800).sunday?)
     assert_equal(t.monday?, Time.at(946684800).monday?)

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

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