#!/usr/local/bin/perl -w

# EF 98/08/10
# This does NOT convert things in the make directory; when
# they need converting, do it by hand, directly using d2u.prl.
#

require "make/u2d.pl";
use File::Find;

BEGIN
{

   $Usage = "Usage: convert.prl u|d
            u for conversion to unix;
            d for conversion to dos.
            l to just list the files.
            ";

   ($#ARGV == 0) || die "$Usage";

   sub print_ {print $File::Find::name, "\n"; }

   %conv = (
            'u', 'd2u',
            'd', 'u2d',
            'l', 'print_'
            );
   $conv = "$conv{$ARGV[0]}" || die "$Usage";



   $b = "^\\w+\\.";

   # Start with an array to make it easier to see what we have, and change it.
   @pat = ("${b}upd\$",
           "${b}doc\$",
           "${b}prl\$",
           "${b}pl\$",
           "${b}c\$",
           "${b}m\$",
           "${b}m__\$",
           "${b}h\$",
           "${b}cnt\$",
           "${b}def\$",
           "${b}lst\$",
           "${b}txt\$",
           "makefile.*",
           "${b}mak\$");

   $pat = join('|',@pat);

   print $pat;
   sub wanted
   {
      if ($File::Find::dir =~ /make/)
      {
         $File::Find::prune = 1;
         return;
      }
      else {$File::Find::prune = 0; }
      /$pat/o && &$conv($_);
   }
}

find(\&wanted, ".");

