(%.tab): Fix previous change.
[m17n/m17n-db.git] / mapconv.in
1 #!/bin/sh
2 # mapconv -- shell script to generate a charset map to standard output
3 # Copyright (C) 2003, 2004
4 #   National Institute of Advanced Industrial Science and Technology (AIST)
5 #   Registration Number H15PRO112
6 # See the end for copying conditions.
7 #
8 # Arguments:
9 #   $1: source map file
10 #   $2: address pattern for sed (optionally with substitution command)
11 #   $3: strip off MSB or not (NOMSB or WITHMSB)
12 #   $4: dimension (1 or 2)
13 #   $5: optional awk script file (sans ".awk")
14
15 case $1 in
16 *glibc*) SOURCE=`echo $1 | sed -e 's/.*\(glibc.*$\)/\1/'`;;
17 *) SOURCE=$1;;
18 esac
19
20 if [ -n "$5" ] ; then
21   LASTFILTER="@AWK@ -f $5.awk"
22 else
23   LASTFILTER="cat"
24 fi
25
26 echo "# Generated from ${SOURCE}"
27
28 if [ "$4" = "NOMSB" ] ; then
29     if [ "$3" = 1 ] ; then
30         @CHARMAP_CAT@ $1 \
31             | sed -n -e "$2p" \
32             | sed -e 's/xa/x2/g' -e 's/xb/x3/g' -e 's/xc/x4/g' \
33                   -e 's/xd/x5/g' -e 's/xe/x6/g' -e 's/xf/x7/g' \
34                   -e 's,<U\([^>]*\)>[   ]*/x\(..\).*$,0x\2 0x\1,' \
35             | sort \
36             | ${LASTFILTER}
37     else
38         @CHARMAP_CAT@ $1 \
39             | sed -n -e "$2p" \
40             | sed -e 's/xa/x2/g' -e 's/xb/x3/g' -e 's/xc/x4/g' \
41                   -e 's/xd/x5/g' -e 's/xe/x6/g' -e 's/xf/x7/g' \
42                   -e 's,<U\([^>]*\)>[   ]*/x\(..\)/x\(..\).*$,0x\2\3 0x\1,' \
43             | sort \
44             | ${LASTFILTER}
45     fi
46 else
47     if [ "$3" = 1 ] ; then
48         @CHARMAP_CAT@ $1 | \
49             sed -n -e "$2p" \
50             | sed -e 's,<U\([^>]*\)>[   ]*/x\(..\).*$,0x\2 0x\1,' \
51             | sort \
52             | ${LASTFILTER}
53     else
54         @CHARMAP_CAT@ $1 | \
55             sed -n -e "$2p" \
56             | sed -e 's,<U\([^>]*\)>[   ]*/x\(..\)/x\(..\).*$,0x\2\3 0x\1,' \
57             | sort \
58             | ${LASTFILTER}
59     fi
60 fi
61
62 # Copyright (C) 2003, 2004
63 #   National Institute of Advanced Industrial Science and Technology (AIST)
64 #   Registration Number H15PRO112
65
66 # This file is part of the m17n database; a sub-part of the m17n
67 # library.
68
69 # The m17n library is free software; you can redistribute it and/or
70 # modify it under the terms of the GNU Lesser General Public License
71 # as published by the Free Software Foundation; either version 2.1 of
72 # the License, or (at your option) any later version.
73
74 # The m17n library is distributed in the hope that it will be useful,
75 # but WITHOUT ANY WARRANTY; without even the implied warranty of
76 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
77 # Lesser General Public License for more details.
78
79 # You should have received a copy of the GNU Lesser General Public
80 # License along with the m17n library; if not, write to the Free
81 # Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
82 # Boston, MA 02110-1301, USA.