X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=ucw%2Fperl%2FUCW%2FConfigure.pm;h=5d458adbb63c15e96d1011682eb1286877a0bafd;hb=d59f303c29db266d6360c38eb0b8c79e82226a60;hp=958a08422b01d16d130230cc13f9c14aa6b3d408;hpb=1cf8ac51f5495ccd5187dc220ffc69e95d6e0cfc;p=libucw.git diff --git a/ucw/perl/UCW/Configure.pm b/ucw/perl/UCW/Configure.pm index 958a0842..5d458adb 100644 --- a/ucw/perl/UCW/Configure.pm +++ b/ucw/perl/UCW/Configure.pm @@ -1,6 +1,6 @@ # Perl module for UCW Configure Scripts # -# (c) 2005--2008 Martin Mares +# (c) 2005--2010 Martin Mares # # This software may be freely distributed and used according to the terms # of the GNU Lesser General Public License. @@ -16,7 +16,7 @@ BEGIN { our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); $VERSION = 1.0; @ISA = qw(Exporter); - @EXPORT = qw(&Init &Log &Notice &Warn &Fail &IsSet &IsGiven &Set &UnSet &Append &Override &Get &Test &Include &Finish &FindFile &TryFindFile &DebugDump &PostConfig &AtWrite); + @EXPORT = qw(&Init &Log &Notice &Warn &Fail &IsSet &IsGiven &Set &UnSet &Append &Override &Get &Test &TestBool &Include &Finish &FindFile &TryFindFile &DebugDump &PostConfig &AtWrite); @EXPORT_OK = qw(); %EXPORT_TAGS = (); } @@ -89,10 +89,25 @@ sub Override($;$) { sub Test($$$) { my ($var,$msg,$sub) = @_; Log "$msg ... "; - if (!IsSet($var)) { - Set $var, &$sub(); + if (IsSet($var)) { + Log Get($var) . " (preset)\n"; + } else { + my $val = &$sub(); + Set($var, $val); + Log "$val\n"; + } +} + +sub TestBool($$$) { + my ($var,$msg,$sub) = @_; + Log "$msg ... "; + if (IsSet($var) || IsGiven($var)) { + Log ((Get($var) ? "yes" : "no") . " (set)\n"); + } else { + my ($val, $comment) = &$sub(); + Set($var, $val); + Log (($val ? "yes" : "no") . "\n"); } - Log Get($var) . "\n"; } sub TryFindFile($) {