From 27366e7151d7e024586d85afee05ea638c151169 Mon Sep 17 00:00:00 2001 From: fredrik Date: Thu, 15 May 2008 18:08:19 +0000 Subject: [PATCH] Check for PBX numbers in tel2name. git-svn-id: svn+ssh://svn.dolda2000.com/srv/svn/repos/src/utils@1111 959494ce-11ee-0310-bf91-de5d638817bd --- tel2name | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/tel2name b/tel2name index 562b133..f9744bc 100755 --- a/tel2name +++ b/tel2name @@ -25,9 +25,7 @@ sub yplookup { } push @matches, $match; } - for $match (@matches) { - print "$match\n"; - } + return @matches; } sub wplookup { @@ -49,9 +47,7 @@ sub wplookup { } push @matches, $match; } - for $match (@matches) { - print "$match\n"; - } + return @matches; } $tel = $ARGV[0]; @@ -68,12 +64,27 @@ if(open NT, $ENV{"HOME"} . "/phone/nametab") { $yppid = open YP, "-|"; if($yppid == 0) { - yplookup $tel; + $mod = 0; + bt: while(1) { + if(@matches = yplookup $tel) { + for $match (@matches) { + print $match; + print " ($tel)" if $mod; + print "\n"; + } + last bt; + } + last bt if !($tel =~ /(.+)[^0](0*)$/); + $tel = $1 . "0" . $2; + $mod = 1; + } exit 0; } $wppid = open WP, "-|"; if($wppid == 0) { - wplookup $tel; + for $match (wplookup $tel) { + print "$match\n"; + } exit 0; } binmode(YP, ":utf8"); -- 2.11.0