# HG changeset patch # User Matti Hamalainen # Date 1507588378 -10800 # Node ID 112f8afa2f04aaaf08b10054294c0254cc521091 # Parent c69368f97c10d7ffb3b485be2929ee174609f626 weather: Improve "nearest" sub-command argument parsing. diff -r c69368f97c10 -r 112f8afa2f04 weather.tcl --- a/weather.tcl Tue Oct 10 01:32:25 2017 +0300 +++ b/weather.tcl Tue Oct 10 01:32:58 2017 +0300 @@ -314,16 +314,13 @@ return 0 } elseif {$rcmd == "lahin" || $rcmd == "lähin" || $rcmd == "closest" || $rcmd == "nearest"} { # List stations nearest to given coordinates - set qlist [::textutil::split::splitx [join [lrange $rarglist 1 end] " "] {\s*,\s*}] - set nlist [lsearch -all -inline -not -exact $qlist ""] - if {[llength $nlist] < 2} { + set qargs [join [lrange $rarglist 1 end] ""] + if {![regexp {^\s*@?(\d+|\d+\.\d+|\.\d+)\s*,\s*(\d+|\d+\.\d+|\.\d+)} $qargs -> d_lat d_lng]} { weather_usage $upublic $unick $uchan $weather_msg_usage_nearest return 0 } # Check argument types - set d_lat [lindex $nlist 0] - set d_lng [lindex $nlist 1] if {![string is double -strict $d_lat] || ![string is double -strict $d_lng]} { weather_msg $upublic $unick $uchan $weather_msg_usage_nearest_invalid return 0