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

ruby-changes:37612

From: eregon <ko1@a...>
Date: Mon, 23 Feb 2015 07:27:13 +0900 (JST)
Subject: [ruby-changes:37612] eregon:r49693 (trunk): * time.c: zone encoding should be US-ASCII if all 7-bits. Fix r46907.

eregon	2015-02-23 07:26:55 +0900 (Mon, 23 Feb 2015)

  New Revision: 49693

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

  Log:
    * time.c: zone encoding should be US-ASCII if all 7-bits. Fix r46907.
    * test/ruby/test_time.rb, test/ruby/test_time_tz.rb: Update tests.

  Modified files:
    trunk/ChangeLog
    trunk/test/ruby/test_time.rb
    trunk/test/ruby/test_time_tz.rb
    trunk/time.c
Index: time.c
===================================================================
--- time.c	(revision 49692)
+++ time.c	(revision 49693)
@@ -4194,7 +4194,7 @@ time_isdst(VALUE time) https://github.com/ruby/ruby/blob/trunk/time.c#L4194
 static VALUE
 time_zone_name(const char *zone)
 {
-    VALUE name = rb_str_new_cstr(zone);
+    VALUE name = rb_usascii_str_new_cstr(zone);
     if (!rb_enc_str_asciionly_p(name)) {
 	name = rb_external_str_with_enc(name, rb_locale_encoding());
     }
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 49692)
+++ ChangeLog	(revision 49693)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon Feb 23 07:25:29 2015  Benoit Daloze  <eregontp@g...>
+
+	* time.c: Zone encoding should be US-ASCII if all 7-bits. Fix r46907.
+
+	* test/ruby/test_time.rb, test/ruby/test_time_tz.rb: Update tests.
+
 Sun Feb 22 18:33:42 2015  SHIBATA Hiroshi  <shibata.hiroshi@g...>
 
 	* common.mk: use ruby organization for rubyspec.
Index: test/ruby/test_time.rb
===================================================================
--- test/ruby/test_time.rb	(revision 49692)
+++ test/ruby/test_time.rb	(revision 49693)
@@ -527,9 +527,12 @@ class TestTime < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_time.rb#L527
   def assert_zone_encoding(time)
     zone = time.zone
     assert_predicate(zone, :valid_encoding?)
-    return if zone.ascii_only?
-    enc = Encoding.default_internal || Encoding.find('locale')
-    assert_equal(enc, zone.encoding)
+    if zone.ascii_only?
+      assert_equal(Encoding::US_ASCII, zone.encoding)
+    else
+      enc = Encoding.default_internal || Encoding.find('locale')
+      assert_equal(enc, zone.encoding)
+    end
   end
 
   def test_zone
Index: test/ruby/test_time_tz.rb
===================================================================
--- test/ruby/test_time_tz.rb	(revision 49692)
+++ test/ruby/test_time_tz.rb	(revision 49693)
@@ -267,6 +267,7 @@ class TestTimeTZ < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_time_tz.rb#L267
           assert_equal(format_gmtoff(gmtoff), t.strftime("%z"))
           assert_equal(format_gmtoff(gmtoff, true), t.strftime("%:z"))
           assert_equal(format_gmtoff2(gmtoff), t.strftime("%::z"))
+          assert_equal(Encoding::US_ASCII, t.zone.encoding)
         }
       }
     }

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

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