X-Git-Url: http://www.privoxy.org/gitweb/?a=blobdiff_plain;f=utils%2Fprepare-configfile.pl;h=f7483a4703ae43746e61c887941f7a15b1199965;hb=326600a782369081c39955e976cfbf2cdf999b62;hp=7156342c67b688415b15937eaacc861ac89fde6a;hpb=3a9f57f2f4342f267af2caed311fd1cc17f7ea6a;p=privoxy.git diff --git a/utils/prepare-configfile.pl b/utils/prepare-configfile.pl index 7156342c..f7483a47 100755 --- a/utils/prepare-configfile.pl +++ b/utils/prepare-configfile.pl @@ -12,11 +12,26 @@ sub main() { my $hit_header = 0; my $hit_option = 0; my $header_len; + my $unfold_mode = 0; + my $unfolding_enabled = 0; + my $windows_section_reached = 0; while (<>) { + + if (!$unfolding_enabled and m/=========/) { + # We passed the table of contents + # and can try to unfold unintentional + # line breaks; + $unfolding_enabled = 1; + } + if (m/specific to the Windows GUI/) { + # The Windows section is formatted differently. + $windows_section_reached = 1; + } + s/^1\. \@\@TITLE\@\@/ /i; - if (m/^(\d\.)(\d\.)(\d\.)?\s/) { + if (m/^(\d*\.){1,3}\s/) { # Remove the first digit as it's the # config file section in the User Manual. s/^(\d\.)//; @@ -29,7 +44,16 @@ sub main() { $header_len = length($_); } - s/^/# /; + if ($unfold_mode) { + s/^\s+/ /; + $unfold_mode = 0; + } else { + s/^/# /; + } + if ($unfolding_enabled and m/(\s+#)\s*$/) { + $unfold_mode = 1; + chomp; + } # XXX: someone should figure out what this stuff # is supposed to do (and if it really does that). @@ -40,8 +64,13 @@ sub main() { s/^#\s*-{20,}//; s/ *$//; $hit_option = 1 if s/^#\s+@@//; - - print; + + if ($windows_section_reached) { + # Do not drop empty lines in the Windows section + s/^\s*$/#\n/; + } + + print unless (/^\s*$/); if ($hit_header) { # The previous line was a section