#! /usr/bin/perl
# 
# $Id$
# Check for unhandled 'ListItem' fields.
# Copyright (C) 2003 Jan Kratochvil <project-www.jankratochvil.net@jankratochvil.net>
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; exactly version 2 of June 1991 is required
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA


require 5.6.0;	# at least 'use warnings;' but we need some 5.6.0+ modules anyway
use vars qw($VERSION $CVS_ID);
$VERSION=do { my @r=(q$Revision$=~/\d+/g); sprintf "%d.".("%03d"x$#r),@r; };
$CVS_ID=q$Id$;
use strict;
use warnings;

use lib qw(/home/short/lib/perl5/site_perl/5.6.0/i386-linux /home/short/lib/perl5/site_perl/5.6.0 /home/short/lib/perl5/site_perl/i386-linux /home/short/lib/perl5/site_perl /home/short/lib/perl5/5.6.0/i386-linux /home/short/lib/perl5/5.6.0 /home/short/lib/perl5/i386-linux /home/short/lib/perl5);

use lib "../";
use My::Web;

use constant ENTRIES=>"CVS/Entries";
use constant ENTRIES_LOG=>"CVS/Entries.Log";


my %dirs;
for my $ENTRIES (ENTRIES,ENTRIES_LOG) {
	local *E;
	next if !open E,$ENTRIES;
	while (<E>) {
		chomp;
		do { $dirs{$1}=1; next; } if m#^(?:A )?D/([^/]*)/#;
		next if m#^/([^/]*)/# ;
		next if /^D$/;
		warn "File $ENTRIES contains invalid line \"$_\": $!";
		}
	close E;
	}

my %item;
for my $dir (keys(%dirs)) {
	require "$dir/ListItem.pm";
	my $item=eval('\%My::Project::'.$dir.'::ListItem');
	do { warn "Broken $dir/List.pm"; next; } if !defined %$item;
	$item{$dir}=$item;
	}

open(STDOUT,">/dev/null");
while (my($key,$ListItem)=each(%item)) {
	chdir $key;
	My::Web->print_project($ListItem);
	for my $attr (qw(priority name description)) {
		delete $ListItem->{$attr};
		}
	require Data::Dumper;
	print STDERR Data::Dumper->Dump([$ListItem],[$key]) if %$ListItem;
	chdir "..";
	}
