3 # make-uniuni -- script for creating the file uniuni.cpp
5 # Copyright (C) 2005, 2006, 2009
6 # Free Software Foundation, Inc.
7 # Written by Werner Lemberg <wl@gnu.org>
9 # This file is part of groff.
11 # groff is free software; you can redistribute it and/or modify it under
12 # the terms of the GNU General Public License as published by the Free
13 # Software Foundation, either version 3 of the License, or
14 # (at your option) any later version.
16 # groff is distributed in the hope that it will be useful, but WITHOUT ANY
17 # WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 # You should have received a copy of the GNU General Public License
22 # along with this program. If not, see <http://www.gnu.org/licenses/>.
27 # make-uniuni <version-string> < UnicodeData.txt > uniuni.cpp
29 # `UnicodeData.txt' is the central database file from the Unicode standard.
30 # Unfortunately, it doesn't contain a version number which must be thus
31 # provided manually as a parameter to the filter.
33 # This program needs a C preprocessor.
40 if test $# -ne 1; then
41 echo "usage: $0 <version-string> < UnicodeData.txt > uniuni.cpp"
47 # Remove ranges and control characters,
48 # then extract the decomposition field,
49 # then remove lines without decomposition,
50 # then remove all compatibility decompositions.
51 sed -e '/^[^;]*;</d' \
52 | sed -e 's/;[^;]*;[^;]*;[^;]*;[^;]*;\([^;]*\);.*$/;\1/' \
53 | sed -e '/^[^;]*;$/d' \
54 | sed -e '/^[^;]*;</d' > $$1
56 # Prepare input for running cpp.
58 | sed -e 's/^\([^;]*\);/#define \1 /' \
61 | sed -e 's/^\([^;]*\);.*$/\1 u\1/' >> $$2
63 # Run C preprocessor to recursively decompose.
66 # Convert it back to original format.
73 -e 's/^\([^ ]*\) /\1;/' > $$4
78 /* Copyright (C) 2002, 2003, 2004, 2005
79 Free Software Foundation, Inc.
80 Written by Werner Lemberg <wl@gnu.org>
82 This file is part of groff.
84 groff is free software; you can redistribute it and/or modify it under
85 the terms of the GNU General Public License as published by the Free
86 Software Foundation, either version 3 of the License, or
87 (at your option) any later version.
89 groff is distributed in the hope that it will be useful, but WITHOUT ANY
90 WARRANTY; without even the implied warranty of MERCHANTABILITY or
91 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
94 You should have received a copy of the GNU General Public License
95 along with this program. If not, see <http://www.gnu.org/licenses/>. */
97 // This code has been algorithmically derived from the file
98 // UnicodeData.txt, version $version_string, available from unicode.org,
99 // on `date '+%Y-%m-%d'`.
102 #include "stringclass.h"
107 struct unicode_decompose {
111 declare_ptable(unicode_decompose)
112 implement_ptable(unicode_decompose)
114 PTABLE(unicode_decompose) unicode_decompose_table;
116 // the first digit in the composite string gives the number of composites
121 } unicode_decompose_list[] = {
127 -e 's/\(.*\);\(.*_.*_.*_.*\)$/ { "\1", "4\2" },/' \
128 -e 's/\(.*\);\(.*_.*_.*\)$/ { "\1", "3\2" },/' \
129 -e 's/\(.*\);\(.*_.*\)$/ { "\1", "2\2" },/' \
130 -e 's/\(.*\);\(.*\)$/ { "\1", "1\2" },/'
136 // global constructor
138 static struct unicode_decompose_init {
139 unicode_decompose_init();
140 } _unicode_decompose_init;
142 unicode_decompose_init::unicode_decompose_init()
144 for (unsigned int i = 0;
145 i < sizeof(unicode_decompose_list)/sizeof(unicode_decompose_list[0]);
147 unicode_decompose *dec = new unicode_decompose[1];
148 dec->value = (char *)unicode_decompose_list[i].value;
149 unicode_decompose_table.define(unicode_decompose_list[i].key, dec);
153 const char *decompose_unicode(const char *s)
155 unicode_decompose *result = unicode_decompose_table.lookup(s);
156 return result ? result->value : 0;
161 # Remove temporary files.