From 8325ea4f5a95738dc5794b46e6a4782d503e552f Mon Sep 17 00:00:00 2001 From: Olivier Blin Date: Fri, 1 Jul 2005 06:46:21 +0000 Subject: remove useless grouping and rewrite code to be safer --- perl-install/network/tools.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/perl-install/network/tools.pm b/perl-install/network/tools.pm index cf93a5319..1d15b50c0 100644 --- a/perl-install/network/tools.pm +++ b/perl-install/network/tools.pm @@ -238,10 +238,10 @@ sub host_hex_to_dotted { sub get_routes() { my %routes; foreach (cat_("/proc/net/route")) { - if (/^(\w+)\s+([0-9A-F]+)\s+([0-9A-F]+)\s+(?:[0-9A-F]+)\s+\d+\s+\d+\s+(\d+)\s+([0-9A-F]+)/) { - hex($2) and $routes{$1}{network} = host_hex_to_dotted($2); - hex($3) and $routes{$1}{gateway} = host_hex_to_dotted($3); - $4 and $routes{$1}{metric} = $4; + if (/^(\w+)\s+([0-9A-F]+)\s+([0-9A-F]+)\s+[0-9A-F]+\s+\d+\s+\d+\s+(\d+)\s+([0-9A-F]+)/) { + if (hex($2)) { $routes{$1}{network} = host_hex_to_dotted($2) } + elsif (hex($3)) { $routes{$1}{gateway} = host_hex_to_dotted($3) } + elsif ($4) { $routes{$1}{metric} = $4 } } } #- TODO: handle IPv6 with /proc/net/ipv6_route -- cgit v1.2.1