From 9b837fd5ed984f0947bc3e1f4478384b3b1691fd Mon Sep 17 00:00:00 2001
From: Joey Hess <joey@gnu.kitenet.net>
Date: Wed, 17 Dec 2008 17:05:49 -0500
Subject: [PATCH] fix default values for config settings

defaults cannot be set in getsetup, do it in checkconfig to avoid
uninitialized value warnings.
---
 IkiWiki/Plugin/comments.pm | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/IkiWiki/Plugin/comments.pm b/IkiWiki/Plugin/comments.pm
index 6184c6031..83f67869c 100644
--- a/IkiWiki/Plugin/comments.pm
+++ b/IkiWiki/Plugin/comments.pm
@@ -39,7 +39,6 @@ sub getsetup () {
 		comments_shown_pagespec => {
 			type => 'pagespec',
 			example => 'blog/*',
-			default => '',
 			description => 'PageSpec for pages where comments will be shown inline',
 			link => 'ikiwiki/PageSpec',
 			safe => 1,
@@ -48,7 +47,6 @@ sub getsetup () {
 		comments_open_pagespec => {
 			type => 'pagespec',
 			example => 'blog/* and created_after(close_old_comments)',
-			default => '',
 			description => 'PageSpec for pages where new comments can be posted',
 			link => 'ikiwiki/PageSpec',
 			safe => 1,
@@ -56,7 +54,6 @@ sub getsetup () {
 		},
 		comments_pagename => {
 			type => 'string',
-			example => 'comment_',
 			default => 'comment_',
 			description => 'Base name for comments, e.g. "comment_" for pages like "sandbox/comment_12"',
 			safe => 0, # manual page moving required
@@ -64,7 +61,6 @@ sub getsetup () {
 		},
 		comments_allowdirectives => {
 			type => 'boolean',
-			default => 0,
 			example => 0,
 			description => 'Interpret directives in comments?',
 			safe => 1,
@@ -72,7 +68,6 @@ sub getsetup () {
 		},
 		comments_allowauthor => {
 			type => 'boolean',
-			default => 0,
 			example => 0,
 			description => 'Allow anonymous commenters to set an author name?',
 			safe => 1,
@@ -81,7 +76,6 @@ sub getsetup () {
 		comments_commit => {
 			type => 'boolean',
 			example => 1,
-			default => 1,
 			description => 'commit comments to the VCS',
 			# old uncommitted comments are likely to cause
 			# confusion if this is changed
@@ -90,6 +84,17 @@ sub getsetup () {
 		},
 }
 
+sub checkconfig () {
+	$config{comments_commit} = 1
+		unless defined $config{comments_commit};
+	$config{comments_shown_pagespec} = ''
+		unless defined $config{comments_shown_pagespec};
+	$config{comments_open_pagespec} = ''
+		unless defined $config{comments_open_pagespec};
+	$config{comments_pagename} = 'comment_'
+		unless defined $config{comments_pagename};
+}
+
 sub htmlize {
 	my %params = @_;
 	return $params{content};
@@ -208,12 +213,6 @@ sub preprocess {
 	return $content;
 }
 
-sub checkconfig () {
-	$config{comments_commit} = 1 unless defined $config{comments_commit};
-	$config{comments_pagename} = 'comment_'
-		unless defined $config{comments_pagename};
-}
-
 # This is exactly the same as recentchanges_link :-(
 sub linkcgi ($) {
 	my $cgi=shift;
-- 
2.26.2