From 3d64cc9e63755dc568232c92b6c81b0cc224f491 Mon Sep 17 00:00:00 2001 From: rudolfkoenig Date: Sat, 4 Oct 2014 14:32:17 +0000 Subject: [PATCH] fhem.pl: Fix addToAttrList (Forum #27451) git-svn-id: https://svn.fhem.de/fhem/trunk@6672 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/fhem.pl | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/fhem/fhem.pl b/fhem/fhem.pl index 7fbc45877..acac648cc 100755 --- a/fhem/fhem.pl +++ b/fhem/fhem.pl @@ -2063,7 +2063,7 @@ getAllAttr($) my $d = shift; return "" if(!$defs{$d}); - my $list = $AttrList; + my $list = $AttrList; # Global values $list .= " " . $modules{$defs{$d}{TYPE}}{AttrList} if($modules{$defs{$d}{TYPE}}{AttrList}); $list .= " " . $attr{global}{userattr} @@ -3172,21 +3172,18 @@ addToDevAttrList($$) { my ($dev,$arg) = @_; - my $ua = ""; - $ua = $attr{$dev}{userattr} if($attr{$dev}{userattr}); - my @al = split(" ", $ua); - my %hash; - foreach my $a (@al) { - $hash{$a} = 1 if(" $AttrList " !~ m/ $a /); # Cleanse old ones - } - $hash{$arg} = 1 if(" $AttrList " !~ m/ $arg /); + my $ua = $attr{$dev}{userattr}; + $ua = "" if(!$ua); + my %hash = map { ($_ => 1) } + grep { " $AttrList " !~ m/ $_ / } + split(" ", "$ua $arg"); $attr{$dev}{userattr} = join(" ", sort keys %hash); } sub addToAttrList($) { - addToDevAttrList("global", @_); + addToDevAttrList("global", shift); } sub