6 # This script compares the file iso3166 (from head/share/misc) with the files
7 # list-en1-semic-3.txt (from
8 # http://www.iso.org/iso/list-en1-semic-3.txt) and iso3166-countrycodes.txt
9 # (from ftp://ftp.ripe.net/) to see if there any differences.
11 # Created by Edwin Groothuis <edwin@FreeBSD.org> for the FreeBSD project.
19 open(FIN, "iso3166") or die "Cannot open iso3166 (should be in head/share/misc)";
24 foreach my $l (@lines) {
29 if ($l !~ /^([A-Z\-]*)[ \t]+([A-Z\-]+)[ \t]+(\d+)[ \t]+(.*)/);
35 $old{$two}{two} = $two;
36 $old{$two}{three} = $three;
37 $old{$two}{number} = $number;
38 $old{$two}{name} = $name;
44 open(FIN, "iso3166-countrycodes.txt") or die "Cannot open iso3166-countrycodes.txt, which can be retrieved from ftp://ftp.ripe.net/iso3166-countrycodes.txt";
50 foreach my $l (@lines) {
51 if ($l =~ /\-\-\-\-\-\-\-/) {
58 die "Invalid line: $l\n"
59 if ($l !~ /^(.+?)[\t ]+([A-Z]{2})[\t ]+([A-Z]{3})[\t ]+(\d+)[\t ]*$/);
65 $new1{$two}{two} = $two;
66 $new1{$two}{three} = $three;
67 $new1{$two}{number} = $number;
68 $new1{$two}{name} = $name;
74 open(FIN, "list-en1-semic-3.txt") or die "Cannot open list-en1-semic-3.txt, which can be retrieved from http://www.iso.org/iso/list-en1-semic-3.txt";
80 foreach my $l (@lines) {
82 if (!$noticed) { # skip the first line
88 my @a = split(/;/, $l);
89 die "Invalid line: $l\n" if ($#a != 1);
93 $new2{$two}{two} = $two;
94 $new2{$two}{name} = $name;
100 foreach my $two (sort(keys(%old))) {
101 if (!defined $new1{$two}) {
102 print "In old but not new1: $old{$two}{two}\t$old{$two}{three}\t$old{$two}{number}\t$old{$two}{name}\n";
105 if (!defined $new2{$two}) {
106 print "In old but not new2: $old{$two}{two}\t$old{$two}{name}\n";
110 print "Found $c issues\n";
115 foreach my $two (sort(keys(%new1))) {
116 next if (defined $old{$two});
117 print "In new1 but not old: $new1{$two}{two}\t$new1{$two}{three}\t$new1{$two}{number}\t$new1{$two}{name}\n";
120 print "Found $c issues\n";
125 foreach my $two (sort(keys(%new2))) {
126 next if (defined $old{$two});
127 print "In new2 but not old: $new2{$two}{two}\t$new2{$two}{name}\n";
130 print "Found $c issues\n";
135 foreach my $two (sort(keys(%old))) {
136 if (defined $new1{$two}) {
137 if ($old{$two}{two} ne $new1{$two}{two} ||
138 $old{$two}{three} ne $new1{$two}{three} ||
139 $old{$two}{number} ne $new1{$two}{number} ||
140 lc($old{$two}{name}) ne lc($new1{$two}{name})) {
141 print "In old : $old{$two}{two}\t$old{$two}{three}\t$old{$two}{number}\t$old{$two}{name}\n";
142 print "In new1: $new1{$two}{two}\t$new1{$two}{three}\t$new1{$two}{number}\t$new1{$two}{name}\n";
147 print "Found $c issues\n";
152 foreach my $two (sort(keys(%old))) {
153 if (defined $new2{$two}) {
154 if ($old{$two}{two} ne $new2{$two}{two} ||
155 lc($old{$two}{name}) ne lc($new2{$two}{name})) {
156 print "In old : $old{$two}{two}\t$old{$two}{name}\n";
157 print "In new2: $new2{$two}{two}\t$new2{$two}{name}\n";
162 print "Found $c issues\n";