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

ruby-changes:44531

From: akr <ko1@a...>
Date: Sun, 6 Nov 2016 00:19:27 +0900 (JST)
Subject: [ruby-changes:44531] akr:r56604 (trunk): fix Resolv::LOC::Coord.create.

akr	2016-11-06 00:19:21 +0900 (Sun, 06 Nov 2016)

  New Revision: 56604

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

  Log:
    fix Resolv::LOC::Coord.create.
    
    * lib/resolv.rb (Resolv::LOC::Coord.create): fixed.
      [ruby-core:72567] [Bug #11912] fixed by Eric Wong and Kazuhiro
      NISHIYAMA.

  Modified files:
    trunk/ChangeLog
    trunk/lib/resolv.rb
    trunk/test/resolv/test_resource.rb
Index: test/resolv/test_resource.rb
===================================================================
--- test/resolv/test_resource.rb	(revision 56603)
+++ test/resolv/test_resource.rb	(revision 56604)
@@ -19,4 +19,8 @@ class TestResolvResource < Test::Unit::T https://github.com/ruby/ruby/blob/trunk/test/resolv/test_resource.rb#L19
     bug10857 = '[ruby-core:68128] [Bug #10857]'
     assert_equal(@name1.hash, @name2.hash, bug10857)
   end
+
+  def test_coord
+    Resolv::LOC::Coord.create('1 2 1.1 N')
+  end
 end
Index: lib/resolv.rb
===================================================================
--- lib/resolv.rb	(revision 56603)
+++ lib/resolv.rb	(revision 56604)
@@ -2699,10 +2699,12 @@ class Resolv https://github.com/ruby/ruby/blob/trunk/lib/resolv.rb#L2699
           return arg
         when String
           coordinates = ''
-          if Regex =~ arg &&  $1<180
-            hemi = ($4[/([NE])/,1]) || ($4[/([SW])/,1]) ? 1 : -1
-            coordinates = [(($1.to_i*(36e5))+($2.to_i*(6e4))+($3.to_f*(1e3)))*hemi+(2**31)].pack("N")
-            (orientation ||= '') << $4[[/NS/],1] ? 'lat' : 'lon'
+          if Regex =~ arg && $1.to_f < 180
+            m = $~
+            hemi = (m[4][/[NE]/]) || (m[4][/[SW]/]) ? 1 : -1
+            coordinates = [ ((m[1].to_i*(36e5)) + (m[2].to_i*(6e4)) +
+                             (m[3].to_f*(1e3))) * hemi+(2**31) ].pack("N")
+            orientation = m[4][/[NS]/] ? 'lat' : 'lon'
           else
             raise ArgumentError.new("not a properly formed Coord string: " + arg)
           end
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 56603)
+++ ChangeLog	(revision 56604)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sun Nov  6 00:06:38 2016  Tanaka Akira  <akr@f...>
+
+	* lib/resolv.rb (Resolv::LOC::Coord.create): fixed.
+	  [ruby-core:72567] [Bug #11912] fixed by Eric Wong and Kazuhiro
+	  NISHIYAMA.
+
 Sun Nov  6 00:03:09 2016  NARUSE, Yui  <naruse@r...>
 
 	* configure.in (-Wimplicit-fallthrough): gcc7 introduces case

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

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