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

#
# Copyright Andrew M. Bishop 1996.97,98,2001.
#
# $Header: /home/amb/CVS/wwwoffle/doc/scripts/README.CONF-conf.pl,v 1.3 2003-06-15 11:08:22 amb Exp $
#
# Usage: README.CONF-man.pl wwwoffle.conf.template &lt; README.CONF &gt; wwwoffle.conf
#

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

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

while(&lt;TEMPLATE&gt;)
  {
   last if(m%^$%);
   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/^ *[-=]+ *$/)
     {
      print "# $_\n" if(m/-+/);
      next;
     }

   # Section heading

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

      if (!$intro)
        {
         print "\n$prevsection\n" if($prevsection);

         while (&lt;TEMPLATE&gt;)
           {
            chop;
            $inbracket=1 if(m%^{%);
            $inbracket=0 if(m%^}%);
            next if(!$inbracket &amp;&amp; m%^$%);
            last if(m%^($section)$%);
            print "$_\n";
           }
         $prevsection=$section;
        }

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

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

      print "\n\n#\n# $section\n";

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

   # Item

   elsif (!$intro &amp;&amp; !$appendix &amp;&amp; m/^(\[?&lt;URL-SPEC&gt;\]? *)?(.?[-()a-z0-9]+)( *= *.+)?$/)
     {
      print "# $_\n";

      $blank=0;
      $first=1;
     }

   # Item

   elsif (!$intro &amp;&amp; !$appendix &amp;&amp; (m/^(\[!\])?URL-SPECIFICATION/ || m/^\(/))
     {
      print "# $_\n";

      $blank=0;
      $first=1;
     }

   # Blank

   elsif (m/^$/)
     {
      print "#\n" if(!$blank);
      $blank=1 if(!$first);
      $dl=0;
     }

   # Text list

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

      print "# $thing\n#         $descrip\n";

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

   # Text

   else
     {
      if ($dl)
        {
         s/^ *//;
         print "#         $_\n";
        }
      else
        {
         print "# $_\n";
        }

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

print "#\n";

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