From edwin@mavetju.org  Wed Sep 17 03:15:07 2008
Return-Path: <edwin@mavetju.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id D2C8B106566C
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 17 Sep 2008 03:15:07 +0000 (UTC)
	(envelope-from edwin@mavetju.org)
Received: from mail5out.barnet.com.au (mail5.barnet.com.au [202.83.178.78])
	by mx1.freebsd.org (Postfix) with ESMTP id 751488FC12
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 17 Sep 2008 03:15:07 +0000 (UTC)
	(envelope-from edwin@mavetju.org)
Received: by mail5out.barnet.com.au (Postfix, from userid 1001)
	id C62CB2218A69; Wed, 17 Sep 2008 13:15:06 +1000 (EST)
Received: from mail5auth.barnet.com.au (mail5.barnet.com.au [202.83.178.78])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(Client CN "mail5auth.barnet.com.au", Issuer "*.barnet.com.au" (verified OK))
	by mail5.barnet.com.au (Postfix) with ESMTP id 77D7E21B5AF8
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 17 Sep 2008 13:15:06 +1000 (EST)
Received: from k7.mavetju (ppp121-44-125-22.lns10.syd6.internode.on.net [121.44.125.22])
	by mail5auth.barnet.com.au (Postfix) with ESMTP id F18AE2218A41
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 17 Sep 2008 13:15:05 +1000 (EST)
Received: by k7.mavetju (Postfix, from userid 1001)
	id C6B19220; Wed, 17 Sep 2008 13:15:08 +1000 (EST)
Message-Id: <20080917031508.C6B19220@k7.mavetju>
Date: Wed, 17 Sep 2008 13:15:08 +1000 (EST)
From: Edwin Groothuis <edwin@mavetju.org>
Reply-To: Edwin Groothuis <edwin@mavetju.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [patch] Add check-script for share/misc/iso3166
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         127430
>Category:       misc
>Synopsis:       [patch] Add check-script for share/misc/iso3166
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    edwin
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Sep 17 03:20:01 UTC 2008
>Closed-Date:    Sat May 23 09:02:16 UTC 2009
>Last-Modified:  Sat May 23 09:10:00 UTC 2009
>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:


[~/iso] edwin@k7>cat check-iso3166.pl
#!/usr/bin/perl -w

#
# $FreeBSD$
#
# This script compares the file iso3166 (from head/share/misc) with the files
# list-en1-semic-2.txt (from
# http://www.iso.org/iso/list-en1-semic-2.txt) and iso3166-countrycodes.txt
# (from ftp://ftp.ripe.net/) 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, "iso3166") or die "Cannot open iso3166 (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]+(\d+)[ \t]+(.*)/);
		my $two = $1;
		my $three = $2;
		my $number = $3;
		my $name = $4;

		$old{$two}{two} = $two;
		$old{$two}{three} = $three;
		$old{$two}{number} = $number;
		$old{$two}{name} = $name;
	}
}

my %new1 = ();
{
	open(FIN, "iso3166-countrycodes.txt") or die "Cannot open iso3166-countrycodes.txt, which can be retrieved from ftp://ftp.ripe.net/";
	my @lines = <FIN>;
	close(FIN);
	chomp(@lines);

	my $noticed = 0;
	foreach my $l (@lines) {
		if ($l =~ /\-\-\-\-\-\-\-/) {
			$noticed = 1;
			next;
		}
		next if (!$noticed);
		next if ($l eq "");

		die "Invalid line: $l\n"
			if ($l !~ /^(.+?)[\t ][\t ]+([A-Z]{2})[\t ]+([A-Z]{3})[\t ]+(\d+)[\t ]*$/);
		my $two = $2;
		my $three = $3;
		my $number = $4;
		my $name = $1;

		$new1{$two}{two} = $two;
		$new1{$two}{three} = $three;
		$new1{$two}{number} = $number;
		$new1{$two}{name} = $name;
	}
}

my %new2 = ();
{
	open(FIN, "list-en1-semic-2.txt") or die "Cannot open list-en1-semic-2.txt, which can be retrieved from http://www.iso.org/iso/list-en1-semic-2.txt";
	my @lines = <FIN>;
	close(FIN);
	chomp(@lines);

	my $noticed = 0;
	foreach my $l (@lines) {
		$l =~ s/\x0d//g;
		if (!$noticed) {	# skip the first line
			$noticed = 1;
			next;
		}
		next if ($l eq "");

		my @a = split(/;/, $l);
		die "Invalid line: $l\n" if ($#a != 1);
		my $two = $a[1];
		my $name = $a[0];

		$new2{$two}{two} = $two;
		$new2{$two}{name} = $name;
	}
}

{
	my $c = 0;
	foreach my $two (sort(keys(%old))) {
		if (!defined $new1{$two}) {
			print "In old but not new1: $old{$two}{two}\t$old{$two}{three}\t$old{$two}{number}\t$old{$two}{name}\n";
			$c++;
		}
		if (!defined $new2{$two}) {
			print "In old but not new2: $old{$two}{two}\t$old{$two}{name}\n";
			$c++;
		}
	}
	print "Found $c issues\n";
}

{
	my $c = 0;
	foreach my $two (sort(keys(%new1))) {
		next if (defined $old{$two});
		print "In new1 but not old: $new1{$two}{two}\t$new1{$two}{three}\t$new1{$two}{number}\t$new1{$two}{name}\n";
		$c++;
	}
	print "Found $c issues\n";
}

{
	my $c = 0;
	foreach my $two (sort(keys(%new2))) {
		next if (defined $old{$two});
		print "In new2 but not old: $new2{$two}{two}\t$new2{$two}{name}\n";
		$c++;
	}
	print "Found $c issues\n";
}

{
	my $c = 0;
	foreach my $two (sort(keys(%old))) {
		if (defined $new1{$two}) {
			if ($old{$two}{two} ne $new1{$two}{two} ||
			    $old{$two}{three} ne $new1{$two}{three} ||
			    $old{$two}{number} ne $new1{$two}{number} ||
			    lc($old{$two}{name}) ne lc($new1{$two}{name})) {
				print "In old : $old{$two}{two}\t$old{$two}{three}\t$old{$two}{number}\t$old{$two}{name}\n";
				print "In new1: $new1{$two}{two}\t$new1{$two}{three}\t$new1{$two}{number}\t$new1{$two}{name}\n";
				$c++;
			}
		}
	}
	print "Found $c issues\n";
}

{
	my $c = 0;
	foreach my $two (sort(keys(%old))) {
		if (defined $new2{$two}) {
			if ($old{$two}{two} ne $new2{$two}{two} ||
			    lc($old{$two}{name}) ne lc($new2{$two}{name})) {
				print "In old : $old{$two}{two}\t$old{$two}{name}\n";
				print "In new2: $new2{$two}{two}\t$new2{$two}{name}\n";
				$c++;
			}
		}
	}
	print "Found $c issues\n";
}

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->edwin 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Wed Sep 17 03:22:07 UTC 2008 
Responsible-Changed-Why:  
Handle with mentor. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=127430 
State-Changed-From-To: open->closed 
State-Changed-By: edwin 
State-Changed-When: Sat May 23 09:02:10 UTC 2009 
State-Changed-Why:  
Commited. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=127430 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: misc/127430: commit references a PR
Date: Sat, 23 May 2009 09:01:46 +0000 (UTC)

 Author: edwin
 Date: Sat May 23 09:01:30 2009
 New Revision: 192630
 URL: http://svn.freebsd.org/changeset/base/192630
 
 Log:
   Added two tools to check the contents of /usr/share/misc/iso* with
   the data from the sources.
   
   PR:		misc/127430 and misc/misc/127428
 
 Added:
   head/tools/tools/iso/
   head/tools/tools/iso/check-iso3166.pl   (contents, props changed)
   head/tools/tools/iso/check-iso639.pl   (contents, props changed)
 Modified:
   head/tools/tools/README
 
 Modified: head/tools/tools/README
 ==============================================================================
 --- head/tools/tools/README	Sat May 23 08:49:55 2009	(r192629)
 +++ head/tools/tools/README	Sat May 23 09:01:30 2009	(r192630)
 @@ -32,6 +32,8 @@ hcomp		Compress header files by removing
  html-mv         Rename HTML generated filenames to human readable filenames.
  ifinfo		Uses the interface MIB to print out all the information
  		an interface exports in an ugly form.
 +iso             Tool to compare the iso3166 and iso639 files in
 +		/usr/share/misc with the data from the master sites.
  iwi		Tools specific to the Intel PRO/Wireless 2200BG/2225BG/2915ABG
  		support.
  kdrv		KernelDriver; add/list/remove third-party kernel driver
 
 Added: head/tools/tools/iso/check-iso3166.pl
 ==============================================================================
 --- /dev/null	00:00:00 1970	(empty, because file is newly added)
 +++ head/tools/tools/iso/check-iso3166.pl	Sat May 23 09:01:30 2009	(r192630)
 @@ -0,0 +1,164 @@
 +#!/usr/bin/perl -w
 +
 +#
 +# $FreeBSD$
 +#
 +# This script compares the file iso3166 (from head/share/misc) with the files
 +# list-en1-semic-2.txt (from
 +# http://www.iso.org/iso/list-en1-semic-2.txt) and iso3166-countrycodes.txt
 +# (from ftp://ftp.ripe.net/) 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, "iso3166") or die "Cannot open iso3166 (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]+(\d+)[ \t]+(.*)/);
 +		my $two = $1;
 +		my $three = $2;
 +		my $number = $3;
 +		my $name = $4;
 +
 +		$old{$two}{two} = $two;
 +		$old{$two}{three} = $three;
 +		$old{$two}{number} = $number;
 +		$old{$two}{name} = $name;
 +	}
 +}
 +
 +my %new1 = ();
 +{
 +	open(FIN, "iso3166-countrycodes.txt") or die "Cannot open iso3166-countrycodes.txt, which can be retrieved from ftp://ftp.ripe.net/";
 +	my @lines = <FIN>;
 +	close(FIN);
 +	chomp(@lines);
 +
 +	my $noticed = 0;
 +	foreach my $l (@lines) {
 +		if ($l =~ /\-\-\-\-\-\-\-/) {
 +			$noticed = 1;
 +			next;
 +		}
 +		next if (!$noticed);
 +		next if ($l eq "");
 +
 +		die "Invalid line: $l\n"
 +			if ($l !~ /^(.+?)[\t ][\t ]+([A-Z]{2})[\t ]+([A-Z]{3})[\t ]+(\d+)[\t ]*$/);
 +		my $two = $2;
 +		my $three = $3;
 +		my $number = $4;
 +		my $name = $1;
 +
 +		$new1{$two}{two} = $two;
 +		$new1{$two}{three} = $three;
 +		$new1{$two}{number} = $number;
 +		$new1{$two}{name} = $name;
 +	}
 +}
 +
 +my %new2 = ();
 +{
 +	open(FIN, "list-en1-semic-2.txt") or die "Cannot open list-en1-semic-2.txt, which can be retrieved from http://www.iso.org/iso/list-en1-semic-2.txt";
 +	my @lines = <FIN>;
 +	close(FIN);
 +	chomp(@lines);
 +
 +	my $noticed = 0;
 +	foreach my $l (@lines) {
 +		$l =~ s/\x0d//g;
 +		if (!$noticed) {	# skip the first line
 +			$noticed = 1;
 +			next;
 +		}
 +		next if ($l eq "");
 +
 +		my @a = split(/;/, $l);
 +		die "Invalid line: $l\n" if ($#a != 1);
 +		my $two = $a[1];
 +		my $name = $a[0];
 +
 +		$new2{$two}{two} = $two;
 +		$new2{$two}{name} = $name;
 +	}
 +}
 +
 +{
 +	my $c = 0;
 +	foreach my $two (sort(keys(%old))) {
 +		if (!defined $new1{$two}) {
 +			print "In old but not new1: $old{$two}{two}\t$old{$two}{three}\t$old{$two}{number}\t$old{$two}{name}\n";
 +			$c++;
 +		}
 +		if (!defined $new2{$two}) {
 +			print "In old but not new2: $old{$two}{two}\t$old{$two}{name}\n";
 +			$c++;
 +		}
 +	}
 +	print "Found $c issues\n";
 +}
 +
 +{
 +	my $c = 0;
 +	foreach my $two (sort(keys(%new1))) {
 +		next if (defined $old{$two});
 +		print "In new1 but not old: $new1{$two}{two}\t$new1{$two}{three}\t$new1{$two}{number}\t$new1{$two}{name}\n";
 +		$c++;
 +	}
 +	print "Found $c issues\n";
 +}
 +
 +{
 +	my $c = 0;
 +	foreach my $two (sort(keys(%new2))) {
 +		next if (defined $old{$two});
 +		print "In new2 but not old: $new2{$two}{two}\t$new2{$two}{name}\n";
 +		$c++;
 +	}
 +	print "Found $c issues\n";
 +}
 +
 +{
 +	my $c = 0;
 +	foreach my $two (sort(keys(%old))) {
 +		if (defined $new1{$two}) {
 +			if ($old{$two}{two} ne $new1{$two}{two} ||
 +			    $old{$two}{three} ne $new1{$two}{three} ||
 +			    $old{$two}{number} ne $new1{$two}{number} ||
 +			    lc($old{$two}{name}) ne lc($new1{$two}{name})) {
 +				print "In old : $old{$two}{two}\t$old{$two}{three}\t$old{$two}{number}\t$old{$two}{name}\n";
 +				print "In new1: $new1{$two}{two}\t$new1{$two}{three}\t$new1{$two}{number}\t$new1{$two}{name}\n";
 +				$c++;
 +			}
 +		}
 +	}
 +	print "Found $c issues\n";
 +}
 +
 +{
 +	my $c = 0;
 +	foreach my $two (sort(keys(%old))) {
 +		if (defined $new2{$two}) {
 +			if ($old{$two}{two} ne $new2{$two}{two} ||
 +			    lc($old{$two}{name}) ne lc($new2{$two}{name})) {
 +				print "In old : $old{$two}{two}\t$old{$two}{name}\n";
 +				print "In new2: $new2{$two}{two}\t$new2{$two}{name}\n";
 +				$c++;
 +			}
 +		}
 +	}
 +	print "Found $c issues\n";
 +}
 +
 
 Added: head/tools/tools/iso/check-iso639.pl
 ==============================================================================
 --- /dev/null	00:00:00 1970	(empty, because file is newly added)
 +++ head/tools/tools/iso/check-iso639.pl	Sat May 23 09:01:30 2009	(r192630)
 @@ -0,0 +1,98 @@
 +#!/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_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";
 +	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";
 +}
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
>Unformatted:
