Date: Wed, 17 Sep 2008 12:06:35 +1000 (EST) From: Edwin Groothuis <edwin@mavetju.org> To: FreeBSD-gnats-submit@FreeBSD.org Subject: misc/127428: [patch] Add check-script for share/misc/iso639 Message-ID: <20080917020635.083151C2@k7.mavetju> Resent-Message-ID: <200809170210.m8H2A2ji090776@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 127428 >Category: misc >Synopsis: [patch] Add check-script for share/misc/iso639 >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Wed Sep 17 02:10:01 UTC 2008 >Closed-Date: >Last-Modified: >Originator: Edwin Groothuis >Release: FreeBSD 7.0-RELEASE-p1 i386 >Organization: - >Environment: System: FreeBSD k7.mavetju 7.0-RELEASE-p1 FreeBSD 7.0-RELEASE-p1 #2: Wed May 28 08:12:56 EST 2008 edwin@k7.mavetju:/usr/src/sys/i386/compile/k7 i386 >Description: Small perl script for in head/tools/tools/iso. >How-To-Repeat: >Fix: --- share/misc/iso639.old 2008-09-17 12:04:50.000000000 +1000 +++ share/misc/iso639 2008-09-17 12:05:52.000000000 +1000 @@ -27,9 +27,17 @@ # # For general discussion about ISO language codes, write to: iso639@dkuug.dk +# +# Download the file http://www.loc.gov/standards/iso639-2/ISO-639-2_utf-8.txt +# and run head/tools/tools/iso/check-iso639.pl to see if everything is up +# to date. +# + +# # a2: ISO 639-1 Alpha-2 code # bib: ISO 639-2/B bibliographic code # term: ISO 639-2/B terminology code +# # a2 bib term name aa aar aar Afar [~/iso] edwin@k7>cat check-iso639.pl #!/usr/bin/perl -w # # $FreeBSD$ # # This script compares the file iso639 (from head/share/misc) with the file # ISO-639-2_8859-1.txt (from # http://www.loc.gov/standards/iso639-2/ISO-639-2_utf-8.txt) to see if there # any differences. # # Created by Edwin Groothuis <edwin@FreeBSD.org> for the FreeBSD project. # use strict; use Data::Dumper; my %old = (); { open(FIN, "iso639") or die "Cannot open iso639 (should be in head/share/misc)"; my @lines = <FIN>; close(FIN); chomp(@lines); foreach my $l (@lines) { next if ($l =~ /^#/); next if ($l eq ""); die "Bad line: $l\n" if ($l !~ /^([a-z\-]*)[ \t]+([a-z\-]+)[ \t]+([a-z\-]+)[ \t]+(.*)/); my $a2 = $1; my $bib = $2; my $term = $3; my $name = $4; $old{$bib}{a2} = $a2; $old{$bib}{bib} = $bib; $old{$bib}{term} = $term; $old{$bib}{name} = $name; } } my %new = (); { open(FIN, "ISO-639-2_8859-1.txt") or die "Cannot open ISO-639-2_8859-1.txt, which can be retrieved from http://www.loc.gov/standards/iso639-2/ISO-639-2_utf-8.txt"; my @lines = <FIN>; close(FIN); chomp(@lines); foreach my $l (@lines) { my @a = split(/\|/, $l); my $a2 = $a[2]; my $bib = $a[0]; my $term = $a[1]; my $name = $a[3]; $term = $bib if ($term eq ""); $new{$bib}{a2} = $a2; $new{$bib}{bib} = $bib; $new{$bib}{term} = $term; $new{$bib}{name} = $name; } } { my $c = 0; foreach my $bib (sort(keys(%old))) { next if (defined $new{$bib}); print "In old but not new: $old{$bib}{a2}\t$old{$bib}{bib}\t$old{$bib}{term}\t$old{$bib}{name}\n"; $c++; } print "Found $c issues\n"; } { my $c = 0; foreach my $bib (sort(keys(%new))) { next if (defined $old{$bib}); print "In new but not old: $new{$bib}{a2}\t$new{$bib}{bib}\t$new{$bib}{term}\t$new{$bib}{name}\n"; $c++; } print "Found $c issues\n"; } { my $c = 0; foreach my $bib (sort(keys(%old))) { next if (!defined $new{$bib}); next if ($old{$bib}{a2} eq $new{$bib}{a2} && $old{$bib}{bib} eq $new{$bib}{bib} && $old{$bib}{term} eq $new{$bib}{term} && $old{$bib}{name} eq $new{$bib}{name}); print "In old: $old{$bib}{a2}\t$old{$bib}{bib}\t$old{$bib}{term}\t$old{$bib}{name}\n"; print "In new: $new{$bib}{a2}\t$new{$bib}{bib}\t$new{$bib}{term}\t$new{$bib}{name}\n"; $c++; } print "Found $c issues\n"; } >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080917020635.083151C2>