1#!/usr/bin/perl -w 2 3# 4# $FreeBSD$ 5# 6# This script compares the file iso639 (from head/share/misc) with the file 7# ISO-639-2_8859-1.txt (from 8# http://www.loc.gov/standards/iso639-2/ISO-639-2_utf-8.txt) to see if there 9# any differences. 10# 11# Created by Edwin Groothuis <edwin@FreeBSD.org> for the FreeBSD project. 12# 13 14use strict; 15use Data::Dumper; 16 17my %old = (); 18{ 19 open(FIN, "iso639") or die "Cannot open iso639 (should be in head/share/misc)"; 20 my @lines = <FIN>; 21 close(FIN); 22 chomp(@lines); 23 24 foreach my $l (@lines) { 25 next if ($l =~ /^#/); 26 next if ($l eq ""); 27 28 die "Bad line: $l\n" 29 if ($l !~ /^([a-z\-]*)[ \t]+([a-z\-]+)[ \t]+([a-z\-]+)[ \t]+(.*)/); 30 my $a2 = $1; 31 my $bib = $2; 32 my $term = $3; 33 my $name = $4; 34 35 $old{$bib}{a2} = $a2; 36 $old{$bib}{bib} = $bib; 37 $old{$bib}{term} = $term; 38 $old{$bib}{name} = $name; 39 } 40} 41 42my %new = (); 43{ 44 open(FIN, "ISO-639-2_utf-8.txt") or die "Cannot open ISO-639-2_utf-8.txt, which can be retrieved from http://www.loc.gov/standards/iso639-2/ISO-639-2_utf-8.txt"; 45 my @lines = <FIN>; 46 close(FIN); 47 chomp(@lines); 48 49 foreach my $l (@lines) { 50 my @a = split(/\|/, $l); 51 my $a2 = $a[2]; 52 my $bib = $a[0]; 53 my $term = $a[1]; 54 my $name = $a[3]; 55 56 $term = $bib if ($term eq ""); 57 58 $new{$bib}{a2} = $a2; 59 $new{$bib}{bib} = $bib; 60 $new{$bib}{term} = $term; 61 $new{$bib}{name} = $name; 62 } 63} 64 65{ 66 my $c = 0; 67 foreach my $bib (sort(keys(%old))) { 68 next if (defined $new{$bib}); 69 print "In old but not new: $old{$bib}{a2}\t$old{$bib}{bib}\t$old{$bib}{term}\t$old{$bib}{name}\n"; 70 $c++; 71 } 72 print "Found $c issues\n"; 73} 74 75{ 76 my $c = 0; 77 foreach my $bib (sort(keys(%new))) { 78 next if (defined $old{$bib}); 79 print "In new but not old: $new{$bib}{a2}\t$new{$bib}{bib}\t$new{$bib}{term}\t$new{$bib}{name}\n"; 80 $c++; 81 } 82 print "Found $c issues\n"; 83} 84 85{ 86 my $c = 0; 87 foreach my $bib (sort(keys(%old))) { 88 next if (!defined $new{$bib}); 89 next if ($old{$bib}{a2} eq $new{$bib}{a2} && 90 $old{$bib}{bib} eq $new{$bib}{bib} && 91 $old{$bib}{term} eq $new{$bib}{term} && 92 $old{$bib}{name} eq $new{$bib}{name}); 93 print "In old: $old{$bib}{a2}\t$old{$bib}{bib}\t$old{$bib}{term}\t$old{$bib}{name}\n"; 94 print "In new: $new{$bib}{a2}\t$new{$bib}{bib}\t$new{$bib}{term}\t$new{$bib}{name}\n"; 95 $c++; 96 } 97 print "Found $c issues\n"; 98} 99