From: Fabian Keil <fk@fabiankeil.de>
Date: Fri, 13 Jun 2008 15:25:03 +0000 (+0000)
Subject: Move previously inline'd Perl code for the config-file target
X-Git-Tag: v_3_0_9~45
X-Git-Url: http://www.privoxy.org/gitweb/%22https:/@default-cgi@/user-manual/faq/static/@default-cgi@send-stylesheet?a=commitdiff_plain;h=dfec72c085a85320534be2d5b7db84bd8b69c832;p=privoxy.git

Move previously inline'd Perl code for the config-file target
into a separate file, have it work with older perl releases,
clean it up a bit and fix the "underlining" code.
---

diff --git a/GNUmakefile.in b/GNUmakefile.in
index fe0d4728..5d3001c7 100644
--- a/GNUmakefile.in
+++ b/GNUmakefile.in
@@ -1,6 +1,6 @@
 # Note:  Makefile is built automatically from Makefile.in
 #
-# $Id: GNUmakefile.in,v 1.169 2008/06/09 17:28:31 fabiankeil Exp $
+# $Id: GNUmakefile.in,v 1.170 2008/06/12 16:38:50 fabiankeil Exp $
 #
 # Written by and Copyright (C) 2001 - 2007 the SourceForge
 # Privoxy team. http://www.privoxy.org/
@@ -854,27 +854,7 @@ dok-pdf: dok-shtml
 config-file: dok-release
 	cd doc/source && $(DB)-notoc -iconfig-file -V nochunks config.sgml > __tmp.html &&\
 	env -u LANG w3m -dump __tmp.html | fmt -w 70 > ../../config.new && $(RM) -r __tmp.*
-	$(PERL) -pi.bak \
-		-e 's/^1\. \@\@TITLE\@\@/     /i;'		\
-	        -e '/^\d\.\d\.\s+/ && tr/[a-z]/[A-Z]/;'		\
-	        -e 'my $$hit_header;'				\
-	        -e '$$header_len=0 unless $$hit_header;'	\
-	        -e 'if ($$hit_header) {'			\
-	        -e '	print "#  ";'				\
-	        -e '	for ($$i=1; $$i < $$header_len; $$i++)'	\
-		-e '		{print "=";}'			\
-	        -e '	print "\n";'				\
-	        -e '};'						\
-	        -e '$$hit_header=0;'				\
-	        -e '$$hit_header=1 if m/^(\d\.)(\d\.)(\d\.)?\s/ && s/^(\d\.)//;'\
-	        -e '$$header_len = length($$_);'		\
-		-e 's/^/#  /;  /^#  #{12,}/ && s/^#  #/####/;'	\
-	        -e 's/^.*$$// if $$hit_option;'			\
-	        -e '$$hit_option=0;'				\
-	        -e 's/^\n//;'					\
-		-e 's/^#\s*-{20,}//;'				\
-		-e 's/ *$$//;'					\
-	        -e '$$hit_option=1 if s/^#\s+@@//;' config.new
+	$(PERL) -i.bak utils/prepare-configfile.pl config.new
 
 	$(RM) *.bak
 	@$(ECHO)  "****************************************************"
@@ -1372,6 +1352,9 @@ coffee:
 ## end:
 
 # $Log: GNUmakefile.in,v $
+# Revision 1.170  2008/06/12 16:38:50  fabiankeil
+# Add third-level domain to URL in dok-get target.
+#
 # Revision 1.169  2008/06/09 17:28:31  fabiankeil
 # - Recommend https for releasing files.
 # - Fix a warning about datarootdir being ignored.
diff --git a/utils/prepare-configfile.pl b/utils/prepare-configfile.pl
new file mode 100755
index 00000000..e3b2b55e
--- /dev/null
+++ b/utils/prepare-configfile.pl
@@ -0,0 +1,50 @@
+#!/usr/local/bin/perl
+
+use strict;
+use warnings;
+
+sub main() {
+    my $hit_header = 0;
+    my $hit_option = 0;
+    my $header_len;
+
+    while (<>) {
+        s/^1\. \@\@TITLE\@\@/     /i;
+
+        if (m/^(\d\.)(\d\.)(\d\.)?\s/) {
+            # Remove the first digit as it's the
+            # config file section in the User Manual.
+            s/^(\d\.)//;
+
+            # If it's a section header, uppercase it.
+            $_ = uc() if (/^\d\.\s+/);
+
+            # Remember to underline it.
+            $hit_header = 1;
+            $header_len = length($_);
+        }
+
+        s/^/#  /;
+
+        # XXX: someone should figure out what this stuff
+        # is supposed to do (and if it really does that).
+        s/^#  #/####/ if /^#  #{12,}/;
+        s/^.*$// if $hit_option;
+        $hit_option = 0;
+        s/^\n//;
+        s/^#\s*-{20,}//;
+        s/ *$//;
+        $hit_option = 1 if s/^#\s+@@//;
+    
+        print;
+
+        if ($hit_header) {
+            # The previous line was a section
+            # header so we better underline it.
+            die "Invalid header length" unless defined $header_len;
+            print "#  " . "=" x $header_len . "\n";
+            $hit_header = 0;
+        };
+    }
+}
+main();