diff options
author | 2006-11-29 17:10:06 +0000 | |
---|---|---|
committer | 2006-11-29 17:10:06 +0000 | |
commit | d0590a44ce719cc46e121cd23b18ebba6978dc95 (patch) | |
tree | 049044b9626b4bddff35a0b1cb949537122e08d1 | |
parent | let compress filter out stuff, add method add_bases, make sure write_fh (diff) | |
download | wireguard-openbsd-d0590a44ce719cc46e121cd23b18ebba6978dc95.tar.xz wireguard-openbsd-d0590a44ce719cc46e121cd23b18ebba6978dc95.zip |
add compress_list, allows for empty lines consisting of spaces...
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PkgConfig.pm | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PkgConfig.pm b/usr.sbin/pkg_add/OpenBSD/PkgConfig.pm index 7a0a6be96a6..7f272e18934 100644 --- a/usr.sbin/pkg_add/OpenBSD/PkgConfig.pm +++ b/usr.sbin/pkg_add/OpenBSD/PkgConfig.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PkgConfig.pm,v 1.2 2006/11/29 16:54:11 espie Exp $ +# $OpenBSD: PkgConfig.pm,v 1.3 2006/11/29 17:10:06 espie Exp $ # # Copyright (c) 2004 Marc Espie <espie@openbsd.org> # @@ -65,7 +65,7 @@ sub read_fh $name = '' if !defined $name; while (<$fh>) { chomp; - next if m/^$/; + next if m/^\s*$/; next if m/^\#/; if (m/^(.*?)\=(.*)$/) { $cfg->add_variable($1, $2); @@ -110,18 +110,24 @@ sub write_file $cfg->write_fh($fh); } -sub compress +sub compress_list { my ($class, $l, $keep) = @_; my $h = {}; - my @r = (); + my $r = []; foreach my $i (@$l) { next if defined $h->{$i}; next if defined $keep && !&$keep($i); - push(@r, $i); + push(@$r, $i); $h->{$i} = 1; } - return join(' ', @r); + return $r; +} + +sub compress +{ + my ($class, $l, $keep) = @_; + return join(' ', @{$class->compress_list($l, $keep)}); } sub expanded |