Explorar o código

dselect: Use looks_like_number() instead of coercion to number

Guillem Jover %!s(int64=13) %!d(string=hai) anos
pai
achega
954de84bea
Modificáronse 1 ficheiros con 5 adicións e 3 borrados
  1. 5 3
      dselect/mkcurkeys.pl

+ 5 - 3
dselect/mkcurkeys.pl

@@ -18,6 +18,8 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+use Scalar::Util qw(looks_like_number);
+
 $#ARGV == 1 || die ("usage: mkcurkeys.pl <filename> <curses.h>");
 
 open(OV,"<$ARGV[0]") || die $!;
@@ -75,9 +77,9 @@ for ($i=33; $i<=126; $i++) {
 }
 
 for $k (sort {
-    $a+0 eq $a ?
-        $b+0 eq $b ? $a <=> $b : -1
-            : $b+0 eq $b ? 1 :
+    looks_like_number($a) ?
+        looks_like_number($b) ? $a <=> $b : -1
+            : looks_like_number($b) ? 1 :
                 $a cmp $b
                 } keys %base) {
     $v= $base{$k};