Bug #11912
closed[WIP] resolv: attempt to fix Resolv::LOC::Coord.create
Description
This seems to have never worked in the first place:
- "$1 < 180" where $1 is a string raises ArgumentError
- regexps in the assignment for "hemi" reset $1 and clobber $2, $3, $4
- orientation is a frozen string literal which we append to
- "$4[[/NS/],1]" has extra braces
I'm not sure if I'm fixing this properly, extra eyes appreciated.
Files
Updated by znz (Kazuhiro NISHIYAMA) over 8 years ago
()
is required, or use 0
instead of 1
.
% rbenv exec irb -r irb/completion --simple-prompt
>> "N"[/([NE])/,1]
=> "N"
>> "N"[/[NE]/,1]
=> nil
>> "N"[/[NE]/,0]
=> "N"
Updated by normalperson (Eric Wong) over 8 years ago
zn@mbf.nifty.com wrote:
()
is required, or use0
instead of1
.
Thanks, we can omit the second arg entirely.
Will squash the following changes in on top of my previous:
diff --git a/lib/resolv.rb b/lib/resolv.rb
index f598779..3b3f710 100644
--- a/lib/resolv.rb
+++ b/lib/resolv.rb
@@ -2701,10 +2701,10 @@ def self.create(arg)
coordinates = ''
if Regex =~ arg && $1.to_f < 180
m = $~
-
hemi = (m[4][/[NE]/,1]) || (m[4][/[SW]/,1]) ? 1 : -1
-
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/,1] ? 'lat' : 'lon'
-
orientation = m[4][/[NS]/] ? 'lat' : 'lon'
else
raise ArgumentError.new("not a properly formed Coord string: " + arg)
end
I guess the square brackets in the orientation assignment were
misplaced. I don't go outside much, but I don't think the
"NS" denotes a valid direction :x
Full diff here:
http://80x24.org/spew/20151231192303.26488-1-e@80x24.org/raw
Unsubscribe: mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe
http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core
Updated by akr (Akira Tanaka) over 7 years ago
- Status changed from Open to Closed
Applied in changeset r56604.
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.