<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!/usr/bin/perl
# -*- cperl -*-

#
# Copyright Andrew M. Bishop 1996.97,98,2001,06.
#
# $Header: /home/amb/CVS/wwwoffle/doc/scripts/README.CONF-man.pl,v 1.3 2006-04-24 18:04:20 amb Exp $
#
# Usage: README.CONF-man.pl wwwoffle.conf.man.template &lt; README.CONF &gt; wwwoffle.conf.man
#

die "Usage: $0 wwwoffle.conf.man.template &lt; README.CONF\n" if($#ARGV!=0 || ! -f $ARGV[0]);

open(TEMPLATE,"&lt;$ARGV[0]");

while(&lt;TEMPLATE&gt;)
  {
   last if(m%\#\# README.CONF \#\#%);
   print;
  }

$_=&lt;STDIN&gt;;
s/^ *//;
s/ *\n//;
$title=$_;

$hr=1;
$blank=0;
$intro=-1;
$appendix=0;
$first=1;
$dl=0;

while(&lt;STDIN&gt;)
  {
   chop;

   # Separator

   if ($_ eq "--------------------------------------------------------------------------------")
     {
      $hr=1;
      $intro=0;
     }

   # Underlines

   elsif (m/^ *[-=]+ *$/)
     {
      next;
     }

   # Section heading

   elsif ($hr==1 &amp;&amp; m/^([-A-Za-z0-9]+)$/)
     {
      $section = $1;

      if ($section eq "WILDCARD")
        {
         $appendix=1;
        }

      $intro=1 if($intro==-1);

      print "\n.SH $section\n\n";

      $hr=0;
      $blank=0;
      $first=1;
     }

   # Item

   elsif (!$intro &amp;&amp; !$appendix &amp;&amp; m/^(\[?&lt;URL-SPEC&gt;\]? *)?(.?[-()a-z0-9]+)( *= *.+)?$/)
     {
      s/-/\\-/g;
      s/\./\\./g;
      s/\'/\\'/g;

      print ".TP\n.B $_\n";

      $blank=0;
      $first=1;
     }

   # Item

   elsif (!$intro &amp;&amp; !$appendix &amp;&amp; (m/^(\[!\])?URL-SPECIFICATION/ || m/^\(/))
     {
      s/-/\\-/g;
      s/\./\\./g;
      s/\'/\\'/g;

      print ".TP\n.B $_\n";

      $blank=0;
      $first=1;
     }

   # Blank

   elsif (m/^$/)
     {
      $blank=1 if(!$first);
      $dl=0;
     }

   # Text list

   elsif ($appendix &amp;&amp; m%^([-a-zA-Z0-9():?*/.]+)   +(.+)%)
     {
      $thing=$1;
      $descrip=$2;

      s/-/\\-/g;
      s/\./\\./g;
      s/\'/\\'/g;

      print ".TP\n.B $thing\n$descrip\n";

      $blank=0;
      $first=0;
      $dl=1;
     }

   # Text

   else
     {
      s/^ *//;

      s/-/\\-/g;
      s/\./\\./g;
      s/\'/\\'/g;

      s%(wwwoffle\\.conf|CHANGES\\.CONF|URL\\-SPECIFICATION|&lt;?URL\\-SPEC&gt;?|WILDCARD) *%\n.I $1\n%g;
      s%^\n%%;
      s%\n\\\. +%.\n%g;

      print ".LP\n" if($blank);
      print "$_\n";

      $blank=0;
      $first=0;
     }
  }

print "\n";

while(&lt;TEMPLATE&gt;)
  {
   print;
  }

close(TEMPLATE);
</pre></body></html>