stuart: server/perl-kolab/Kolab-Conf Conf.pm,1.37,1.38
cvs at intevation.de
cvs at intevation.de
Thu Sep 16 16:31:43 CEST 2004
Author: stuart
Update of /kolabrepository/server/perl-kolab/Kolab-Conf
In directory doto:/tmp/cvs-serv17980
Modified Files:
Conf.pm
Log Message:
Add the ability to handle multiple @@@ variable substitutions on a single line (obviously no-one uses ProFTP or else this would have come up before :-)
Index: Conf.pm
===================================================================
RCS file: /kolabrepository/server/perl-kolab/Kolab-Conf/Conf.pm,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -d -r1.37 -r1.38
--- Conf.pm 5 Sep 2004 21:50:22 -0000 1.37
+++ Conf.pm 16 Sep 2004 14:31:40 -0000 1.38
@@ -115,39 +115,41 @@
my $skip = 0;
while (<$template>) {
- if (/\@{3}if (\S+?)\@{3}/) {
- if ($Kolab::config{$1} && lc($Kolab::config{$1}) ne "false" ) {
- # Keep text
- } else {
- # Skip text
- $skip++;
+ if (/\@{3}if (\S+?)\@{3}/) {
+ if ($Kolab::config{$1} && lc($Kolab::config{$1}) ne "false" ) {
+ # Keep text
+ } else {
+ # Skip text
+ $skip++;
+ }
+ s/\@{3}if (\S+?)\@{3}\n?//;
+ } elsif (/\@{3}endif\@{3}/) {
+ ($skip > 0) && $skip--;
+ s/\@{3}endif\@{3}\n?//;
+ } else {
+ while (/\@{3}(\S+?)(\|.+?)?\@{3}/) {
+ my $attr = $1;
+ my $opt = $2;
+ #print STDERR "attr=$attr, opt=$opt\n";
+ if ($Kolab::config{$attr}) {
+ my $val = "";
+ if (ref $Kolab::config{$attr} eq "ARRAY") {
+ if ($opt && $opt =~ /\|join(.*)/) {
+ $val = join $1, @{$Kolab::config{$attr}};
+ } else {
+ $val = $Kolab::config{$attr}->[0];
+ }
+ } else {
+ $val = $Kolab::config{$attr};
+ }
+ s/\@{3}(\S+?)(\|.+?)?\@{3}/$val/;
+ } else {
+ Kolab::log('T', "No configuration variable corresponding to `$1' exists", KOLAB_WARN);
+ s/\@{3}(\S+?)\@{3}//;
+ }
+ }
}
- s/\@{3}if (\S+?)\@{3}\n?//;
- } elsif (/\@{3}endif\@{3}/) {
- ( $skip > 0 ) && $skip--;
- s/\@{3}endif\@{3}\n?//;
- } elsif (/\@{3}(\S+?)(\|.+?)?\@{3}/) {
- my $attr = $1;
- my $opt = $2;
- #print STDERR "attr=$attr, opt=$opt\n";
- if ($Kolab::config{$attr}) {
- my $val = "";
- if( ref $Kolab::config{$attr} eq "ARRAY" ) {
- if( $opt && $opt =~ /\|join(.*)/ ) {
- $val = join $1, @{$Kolab::config{$attr}};
- } else {
- $val = $Kolab::config{$attr}->[0];
- }
- } else {
- $val = $Kolab::config{$attr};
- }
- s/\@{3}(\S+?)(\|.+?)?\@{3}/$val/;
- } else {
- Kolab::log('T', "No configuration variable corresponding to `$1' exists", KOLAB_WARN);
- s/\@{3}(\S+?)\@{3}//;
- }
- }
- ( $skip == 0 ) && print $config $_;
+ ($skip == 0) && print $config $_;
}
$template->close;
More information about the commits
mailing list