From ac69c3ee90e23482bdf84d68d2a401ef0d2ec6b4 Mon Sep 17 00:00:00 2001 From: Thomas Hochstein Date: Tue, 13 Apr 2010 23:59:43 +0200 Subject: [PATCH] readconfig(): Make mid-format optional. Set defaults for expires and mid-format when they're invalid (defaults were already set in postfaq() if undefined). Change documentation accordingly; make it more clear if parameters are optional or mandatory. Signed-off-by: Thomas Hochstein --- yapfaq.pl | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/yapfaq.pl b/yapfaq.pl index cbcea37..dd5e57b 100644 --- a/yapfaq.pl +++ b/yapfaq.pl @@ -207,10 +207,12 @@ sub readconfig{ $Error .= "E: The Posting-frequency for your project \"$$Config[$i]{'name'}\" is invalid.\n" } unless(!$$Config[$i]{'expires'} || $$Config[$i]{'expires'} =~ /^\s*\d+\s*[dwmy]\s*$/) { - warn "$0: W: The Expires for your project \"$$Config[$i]{'name'}\" is invalid - set to 3 month.\n"; + warn "$0: W: The Expires for your project \"$$Config[$i]{'name'}\" is invalid - set to 3 month.\n"; + $$Config[$i]{'expires'} = '3m'; # set default (3 month) if expires is unset or invalid } - unless(defined($$Config[$i]{'mid-format'}) && $$Config[$i]{'mid-format'} =~ /^<\S+\@\S{2,}\.\S{2,}>$/) { - warn "$0: W: The Message-ID format for your project \"$$Config[$i]{'name'}\" seems to be undefined or invalid - set to default.\n"; + unless(!$$Config[$i]{'mid-format'} || $$Config[$i]{'mid-format'} =~ /^<\S+\@\S{2,}\.\S{2,}>$/) { + warn "$0: W: The Message-ID format for your project \"$$Config[$i]{'name'}\" seems to be invalid - set to default.\n"; + $$Config[$i]{'mid-format'} = '<%n-%d.%m.%y@'.hostfqdn.'>'; # set default if mid-format is invalid } } $Error .= "-" x 25 . 'program terminated' . "-" x 25 . "\n" if $Error; @@ -264,7 +266,7 @@ sub postfaq { $$TDD = ($$TDD < 10 && $$TDD !~ /^0/) ? "0" . $$TDD : $$TDD; $MID = $$MIDF; - $MID = '<%n-%d.%m.%y@'.hostfqdn.'>' if !defined($MID); + $MID = '<%n-%d.%m.%y@'.hostfqdn.'>' if !defined($MID); # set to default if unset $MID =~ s/\%n/$$ActName/g; $MID =~ s/\%d/$$TDD/g; $MID =~ s/\%m/$$TDM/g; @@ -635,7 +637,7 @@ or Ionths> or Iears>. This value must be set. -=item B = I