xref: /netbsd-src/share/misc/make.country (revision 436b8a85c589f43c46462f338ba0843edc546afe)
1c76b1ab8Schristos#!/bin/sh
2c76b1ab8Schristos
3c76b1ab8Schristoshdr() {
4c76b1ab8Schristosecho '#' '$'NetBSD'$'
5c76b1ab8Schristoscat << _EOF
6c76b1ab8Schristos#
7c76b1ab8Schristos# ISO 3166-1 Country Codes
8c76b1ab8Schristos#
9c76b1ab8Schristos# The format of an entry is:
10c76b1ab8Schristos# <Name><TAB><Alpha-2-code><TAB><Alpha-3-code><TAB><Numeric-3-code><TAB><FIPS>
11c76b1ab8Schristos#
12c76b1ab8Schristos# Further information can be found at the ISO 3166 Maintenance Agency
13*436b8a85Sginsbach# (ISO 3166/MA) web site, <http://www.iso.org/iso/country_codes>.
14c76b1ab8Schristos#
15c76b1ab8Schristos# FIPS 10-4 codes compiled from several sources, including
16c76b1ab8Schristos# http://www.statoids.com/wab.html
17c76b1ab8Schristos#
18c76b1ab8Schristos# ISO 3166-1 entities without exactly one corresponding FIPS code have a
19c76b1ab8Schristos# blank entry in the column. FIPS 10-4 codes without a corresponding
20c76b1ab8Schristos# ISO 3166-1 entity are excluded.
21c76b1ab8Schristos#
22c76b1ab8Schristos# This list is up-to-date as of $(date +%Y-%m-%d)
23c76b1ab8Schristos#
24c76b1ab8Schristos_EOF
25c76b1ab8Schristos}
26c76b1ab8Schristos
27*436b8a85SginsbachI1=wab.html
28*436b8a85SginsbachU1=http://www.statoids.com/$I1
29c76b1ab8SchristosO1=/tmp/wab.$$
30*436b8a85SginsbachI2=country_names_and_code_elements_txt
31*436b8a85SginsbachU2=http://www.iso.org/iso/$I2
32c76b1ab8SchristosO2=/tmp/list.$$
33*436b8a85Sginsbachtrap "rm -f $I1 $I2 $O1 $O2" 0 1 2 3 15
34*436b8a85Sginsbachftp $U1
35*436b8a85Sginsbachftp $U2
36c76b1ab8Schristos
37*436b8a85Sginsbachgrep '<tr class="[oe]">' $I1 |
38c76b1ab8Schristossed -e 's,<tr class="."><td>,,g' \
39c76b1ab8Schristos    -e 's,\&nbsp;,,g' \
40c76b1ab8Schristos    -e 's,<code>,,g' \
41c76b1ab8Schristos    -e 's,</code>,,g' \
42c76b1ab8Schristos    -e 's,<br>, ,g' \
43c76b1ab8Schristos    -e 's,</td><td>,	,g' \
44c76b1ab8Schristos    -e 's,�,Aa,g' \
45c76b1ab8Schristos    -e 's,�,o,g' \
46c76b1ab8Schristos    -e 's,</td></tr>,,g' |
47c76b1ab8Schristosawk -F'\t' '{ printf("%s\t%s\t%s\t%s\t%s\n", $2, $3, $4, $6, $1); }' |
48c76b1ab8Schristosgrep -v href= |
49c76b1ab8Schristossort > $O1
50c76b1ab8Schristos
51*436b8a85Sginsbachgrep ';[A-Z][A-Z]' $I2 |
52c76b1ab8Schristostr -d '\015' |
53c76b1ab8Schristosawk -F ';' '{ print $2 }' |
54c76b1ab8Schristossort > $O2
55c76b1ab8Schristos
56c76b1ab8Schristoshdr
57c76b1ab8Schristosjoin -t '	' -o 1.5,1.1,1.2,1.3,1.4 -1 1 -2 1 $O1 $O2 | sort
58