annotate admin/charsets/mapconv @ 89666:7d38a63951c0

(make_conversion_work_buffer): Delete extern. (code_conversion_save): Extern it.
author Kenichi Handa <handa@m17n.org>
date Tue, 02 Dec 2003 01:42:47 +0000
parents 375f2633d815
children a750cf193ec6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
88123
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1 #!/bin/sh
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2 #
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3 # Copyright (C) 2003
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
4 # National Institute of Advanced Industrial Science and Technology (AIST)
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
5 # Registration Number H13PRO009
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
6 #
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
7 # This file is part of GNU Emacs.
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
8 #
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
9 # GNU Emacs is free software; you can redistribute it and/or modify
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
10 # it under the terms of the GNU General Public License as published by
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
11 # the Free Software Foundation; either version 2, or (at your option)
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
12 # any later version.
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
13 #
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
14 # GNU Emacs is distributed in the hope that it will be useful,
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
17 # GNU General Public License for more details.
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
18 #
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
19 # You should have received a copy of the GNU General Public License
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
20 # along with GNU Emacs; see the file COPYING. If not, write to the
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
21 # Free Software Foundation, Inc., 59 Temple Place - Suite 330,
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
22 # Boston, MA 02111-1307, USA.
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
23
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
24 # Comment:
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
25 # Convert charset map of various format into this:
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
26 # 0xXX 0xYYYY
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
27 # where,
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
28 # XX is a code point of the charset in hexa-decimal,
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
29 # YYYY is the corresponding Unicode character code in hexa-decimal.
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
30 # Arguments are:
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
31 # $1: source map file
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
32 # $2: address pattern for sed (optionally with substitution command)
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
33 # $3: format of source map file
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
34 # GLIBC-1 GLIBC-2 GLIBC-2-7 CZYBORRA IANA UNICODE YASUOKA MICROSOFT
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
35 # $4: awk script
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
36
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
37 BASE=`basename $1`
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
38
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
39 case "$3" in
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
40 GLIBC*)
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
41 SOURCE=`echo $1 | sed 's/.*\(glibc.*$\)/\1/'`;;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
42 CZYBORRA)
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
43 SOURCE="http://czyborra.com/charsets/${BASE}";;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
44 IANA)
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
45 SOURCE="http://www.iana.org/assignments/charset-reg/${BASE}";;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
46 UNICODE)
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
47 SOURCE="http://www.unicode.org/Public/MAPPINGS/.../${BASE}";;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
48 YASUOKA)
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
49 SOURCE="http://kanji.zinbun.kyoto-u.ac.jp/~yasuoka/.../${BASE}";;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
50 MICROSOFT)
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
51 SOURCE="http://www.microsoft.com/globaldev/reference/oem/${BASE}";;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
52 *)
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
53 echo "Unknown file type: $3";
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
54 exit 1;;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
55 esac
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
56
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
57 echo "# Generated from $SOURCE"
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
58
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
59 if [ -n "$4" ] ; then
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
60 if [ -f "$4" ] ; then
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
61 AWKPROG="gawk -f $4"
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
62 else
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
63 echo "Awk program does not exist: $4"
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
64 exit 1
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
65 fi
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
66 else
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
67 AWKPROG=cat
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
68 fi
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
69
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
70 if [ "$3" == "GLIBC-1" ] ; then
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
71 # Source format is:
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
72 # <UYYYY> /xXX
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
73 sed -n -e "$2 p" < $1 \
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
74 | sed -e 's,<U\([^>]*\)>[ ]*/x\(..\).*,0x\2 0x\1,' \
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
75 | sort | ${AWKPROG}
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
76 elif [ "$3" == "GLIBC-2" ] ; then
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
77 # Source format is:
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
78 # <UYYYY> /xXX/xZZ
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
79 sed -n -e "$2 p" < $1 \
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
80 | sed -e 's,<U\([^>]*\)>[ ]*/x\(..\)/x\(..\).*,0x\2\3 0x\1,' \
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
81 | sort | ${AWKPROG}
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
82 elif [ "$3" == "GLIBC-2-7" ] ; then
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
83 # Source format is:
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
84 # <UYYYY> /xXX/xZZ
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
85 # We must drop MSBs of XX and ZZ
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
86 sed -n -e "$2 p" < $1 \
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
87 | sed -e 's/xa/x2/g' -e 's/xb/x3/g' -e 's/xc/x4/g' \
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
88 -e 's/xd/x5/g' -e 's/xe/x6/g' -e 's/xf/x7/g' \
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
89 -e 's,<U\([^>]*\)>[ ]*/x\(..\)/x\(..\).*,0x\2\3 0x\1,' \
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
90 | tee temp \
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
91 | sort | ${AWKPROG}
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
92 elif [ "$3" == "CZYBORRA" ] ; then
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
93 # Source format is:
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
94 # =XX U+YYYY
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
95 zcat $1 | sed -n -e "$2 p" \
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
96 | sed -e 's/=\(..\)[^U]*U+\([0-9A-F]*\).*/0x\1 0x\2/' \
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
97 | sort | ${AWKPROG}
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
98 elif [ "$3" == "IANA" ] ; then
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
99 # Source format is:
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
100 # 0xXX 0xYYYY
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
101 sed -n -e "$2 p" < $1 \
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
102 | sed -e 's/\(0x[0-9A-Fa-f]*\)[^0]*\(0x[0-9A-Fa-f]*\).*/\1 \2/' \
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
103 | sort | ${AWKPROG}
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
104 elif [ "$3" == "UNICODE" ] ; then
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
105 # Source format is:
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
106 # YYYY XX
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
107 sed -n -e "$2 p" < $1 \
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
108 | sed -e 's/\([0-9A-F]*\)[^0-9A-F]*\([0-9A-F]*\).*/0x\2 0x\1/' \
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
109 | sort | ${AWKPROG}
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
110 elif [ "$3" == "YASUOKA" ] ; then
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
111 # Source format is:
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
112 # YYYY 0-XXXX (XXXX is a Kuten code)
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
113 sed -n -e "$2 p" < $1 \
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
114 | sed -e 's/\([0-9A-F]*\)[^0]*0-\([0-9]*\).*/0x\2 0x\1/' \
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
115 | sort | ${AWKPROG}
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
116 elif [ "$3" == "MICROSOFT" ] ; then
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
117 # Source format is:
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
118 # XX = U+YYYY
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
119 sed -n -e "$2 p" < $1 \
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
120 | sed -e 's/\([0-9A-F]*\).*U+\([0-9A-F]*\).*/0x\1 0x\2/' \
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
121 | sort | ${AWKPROG}
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
122 else
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
123 echo "Invalid arguments"
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
124 exit 1
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
125 fi