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

ruby-changes:25305

From: tadf <ko1@a...>
Date: Sun, 28 Oct 2012 19:16:17 +0900 (JST)
Subject: [ruby-changes:25305] tadf:r37357 (trunk): * ext/date/date_parse.c (iso8601_{ext,bas}_time): should not match

tadf	2012-10-28 19:16:02 +0900 (Sun, 28 Oct 2012)

  New Revision: 37357

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

  Log:
    * ext/date/date_parse.c (iso8601_{ext,bas}_time): should not match
      empty string.
    - ?\227?\129?\147?\227?\129?\174?\232?\161?\140?\228?\187?\165?\228?\184?\139?\227?\129?\175?\231?\132?\161?\232?\166?\150?\227?\129?\149?\227?\130?\140?\227?\129?\190?\227?\129?\153 --
    
    M    ChangeLog
    M    ext/date/date_parse.c
    M    test/date/test_date_parse.rb

  Modified files:
    trunk/ChangeLog
    trunk/ext/date/date_parse.c
    trunk/test/date/test_date_parse.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 37356)
+++ ChangeLog	(revision 37357)
@@ -1,3 +1,8 @@
+Sun Oct 28 19:12:11 2012  Tadayoshi Funaba  <tadf@d...>
+
+	* ext/date/date_parse.c (iso8601_{ext,bas}_time): should not match
+	  empty string.
+
 Sun Oct 28 18:51:33 2012  Tadayoshi Funaba  <tadf@d...>
 
 	* ext/date/date_parse.c (date__parse): revised the tight parser.
Index: ext/date/date_parse.c
===================================================================
--- ext/date/date_parse.c	(revision 37356)
+++ ext/date/date_parse.c	(revision 37357)
@@ -2440,7 +2440,7 @@
 iso8601_ext_time(VALUE str, VALUE hash)
 {
     static const char pat_source[] =
-	"\\A\\s*(?:(\\d{2}):(\\d{2})(?::(\\d{2})(?:[,.](\\d+))?)?"
+	"\\A\\s*(\\d{2}):(\\d{2})(?::(\\d{2})(?:[,.](\\d+))?"
 	"(z|[-+]\\d{2}(:?\\d{2})?)?)?\\s*\\z";
     static VALUE pat = Qnil;
 
@@ -2452,7 +2452,7 @@
 iso8601_bas_time(VALUE str, VALUE hash)
 {
     static const char pat_source[] =
-	"\\A\\s*(?:(\\d{2})(\\d{2})(?:(\\d{2})(?:[,.](\\d+))?)?"
+	"\\A\\s*(\\d{2})(\\d{2})(?:(\\d{2})(?:[,.](\\d+))?"
 	"(z|[-+]\\d{2}(\\d{2})?)?)?\\s*\\z";
     static VALUE pat = Qnil;
 
Index: test/date/test_date_parse.rb
===================================================================
--- test/date/test_date_parse.rb	(revision 37356)
+++ test/date/test_date_parse.rb	(revision 37357)
@@ -541,6 +541,9 @@
     assert_equal([2006, 333], h.values_at(:year, :yday))
     h = Date._parse('333')
     assert_equal([nil, 333], h.values_at(:year, :yday))
+
+    h = Date._parse('')
+    assert_equal({}, h)
   end
 
   def test_parse
@@ -822,6 +825,8 @@
     assert_equal([nil, nil, nil, 4, 5, 6, 3600],
 		 h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
 
+    h = Date._iso8601('')
+    assert_equal({}, h)
   end
 
   def test__rfc3339
@@ -834,6 +839,9 @@
     h = Date._rfc3339('2001-02-03T04:05:06.07+01:00')
     assert_equal([2001, 2, 3, 4, 5, 6, 3600],
 		 h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
+
+    h = Date._rfc3339('')
+    assert_equal({}, h)
   end
 
   def test__xmlschema
@@ -913,6 +921,9 @@
     h = Date._xmlschema('-92001-02-03T04:05:06.07+01:00')
     assert_equal([-92001, 2, 3, 4, 5, 6, 3600],
 		 h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
+
+    h = Date._xmlschema('')
+    assert_equal({}, h)
   end
 
   def test__rfc2822
@@ -942,6 +953,9 @@
     h1 = Date._rfc2822('Sat, 3 Feb 2001 04:05:06 UT')
     h2 = Date._rfc822('Sat, 3 Feb 2001 04:05:06 UT')
     assert_equal(h1, h2)
+
+    h = Date._rfc2822('')
+    assert_equal({}, h)
   end
 
   def test__httpdate
@@ -959,6 +973,9 @@
     h = Date._httpdate('Sat Feb 03 04:05:06 2001')
     assert_equal([2001, 2, 3, 4, 5, 6, nil],
 		 h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
+
+    h = Date._httpdate('')
+    assert_equal({}, h)
   end
 
   def test__jisx0301
@@ -984,6 +1001,9 @@
     h = Date._jisx0301('H13.02.03T04:05:06.07+0100')
     assert_equal([2001, 2, 3, 4, 5, 6, 3600],
 		 h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
+
+    h = Date._jisx0301('')
+    assert_equal({}, h)
   end
 
   def test_iso8601

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

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