From: Stephen L Johnson Date: Thu, 14 Dec 2000 21:18:40 +0000 (+0000) Subject: added code to preserve order of groups as in the spong.groups file in output X-Git-Tag: spong-2_7_2~43 X-Git-Url: http://git.etc.gen.nz/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7d70ea451a9034c4acfe66edadc9a74e54fcf658;p=spong.git added code to preserve order of groups as in the spong.groups file in output --- diff --git a/src/lib/Spong/HostGroups.pm b/src/lib/Spong/HostGroups.pm index da45e78..3bd7cff 100755 --- a/src/lib/Spong/HostGroups.pm +++ b/src/lib/Spong/HostGroups.pm @@ -18,7 +18,7 @@ # + add - adds a specific host group to the instance # -# $Id: HostGroups.pm,v 1.9 2000/10/26 19:06:52 sljohnson Exp $ +# $Id: HostGroups.pm,v 1.10 2000/12/14 21:18:40 sljohnson Exp $ use Spong::Host; use Spong::HostList; @@ -83,7 +83,17 @@ sub group { return $_[0]->{'group_hash'}->{$_[1]}; } sub group_names { - return keys %{$_[0]->{'group_hash'}}; + my( @grps, @ret ); + # Try to use GROUPS_LIST list order, else use sorted group names + if ( defined @main::GROUPS_LIST ) { @grps = @main::GROUPS_LIST; } + else { @grps = (sort keys %main::GROUPS ); } + # Go thru list order, in order to sort the group names + foreach my $grp ( @grps ) { + if ( defined %{$_[0]->{'group_hash'}}->{$grp} ) { + push @ret,$grp; + } + } + return (@ret); } sub groups { diff --git a/src/lib/Spong/ServiceList.pm b/src/lib/Spong/ServiceList.pm index 74c600a..c3f2a73 100755 --- a/src/lib/Spong/ServiceList.pm +++ b/src/lib/Spong/ServiceList.pm @@ -233,6 +233,7 @@ sub display_wml { my $name = $service->name(); my $color = substr($service->color(),0,2); $color =~ tr/a-z/A-Z/; + print "$color"; print ""; print " $name
\n";