#!/usr/bin/perl

# perl script to maketag(and emaketag)
# on/off の選択肢は tagfile.dkc を使うので jnl1/wnn1 あたりは手動で
# 調整が必要

open(SESAME, "ls *.tgz |");
@files = <SESAME>;
close(SESAME);
for $i ( 0 .. $#files){
    $files[$i] =~ s/\.tgz\n//;
}

foreach $i ('tagfile', 'tagfile.dkc', 'tagfile.dkw', 'tagfile.min', 'tagfile.nox', 'tagfile.ntc' ,'tagfile.ntw') {
    open(TAGS, $i) || die "cannot open $i";
    undef %tag;
    while(<TAGS>){
	if (! /^#/){
	  chomp;
	  ($pkg, $inst) = split(/:/);
	  $tag{$pkg} = $inst;
        }
    }
    close(TAGS);
    for $ii ( 0 .. $#files) {
	$check = 0;
	for $j (keys %tag){
	    if ($files[$ii] eq $j) { $check = 1 ; next; }
	}
	if (!$check){print " $files[$ii] is not in $i\n";}
    }
    for $ii (keys %tag) {
        $check = 0;
        for $j ( 0 .. $#files ){
            if ($files[$j] eq $ii) { $check = 1; next;}
	}
	if (!$check){print "$i needs $ii \n";}
    }
	
}

