blob: 2bd45859efdf4f566343065e77251177d4f5bb63 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
|
From: "P. J. McDermott" <pjm@nac.net>
Description: Replace locale/gen-translit.pl with a shell script
If a Perl interpreter isn't found, run the shell script instead.
diff -Naur src.orig/libc/locale/gen-translit.sh src/libc/locale/gen-translit.sh
--- src.orig/libc/locale/gen-translit.sh 1969-12-31 19:00:00.000000000 -0500
+++ src/libc/locale/gen-translit.sh 2013-06-21 18:04:13.414351956 -0400
@@ -0,0 +1,197 @@
+#!/bin/sh
+# A POSIX.1 shell command language translation of gen-translit.pl.
+
+set -e
+
+LF='
+'
+
+die() {
+ printf '%s\n' "${*}"
+ exit 1
+}
+
+substr() {
+ str="${1}"
+ off=${2}
+ len=${3}
+
+ while [ ${off} -gt 0 ]; do
+ str="${str#?}"
+ off=$(($off - 1))
+ done
+ while [ ${#str} -gt ${len} ]; do
+ str="${str%?}"
+ done
+
+ printf '%s\n' "${str}"
+}
+
+cstrlen() {
+ str="${*}"
+ len=${#str}
+ cnt=0
+ res=0
+
+ while [ ${cnt} -lt $len ]; do
+ if [ "x$(substr "${str}" ${cnt} 1)" = 'x\' ]; then
+ # Recognize the escape sequence.
+ if [ "x$(substr "${str}" $(($cnt + 1)) 1)" = 'xx' ]; then
+ inner=$(($cnt + 2))
+ while [ ${inner} -lt ${len} \
+ -a ${inner} -lt $(($cnt + 10)) ]; do
+ ch="$(substr "${str}" ${inner} 1)"
+ if [ "x${ch}" != "x${ch#[0-9a-fA-F]}" ]; then
+ inner=$(($inner + 1))
+ continue
+ fi
+ break
+ inner=$(($inner + 1))
+ done
+ cnt=${inner}
+ res=$(($res + 1))
+ else
+ if [ $(($cnt + 1)) -ge ${len} ]; then
+ die 'Invalid input'
+ fi
+ res=$(($res + 1))
+ cnt=$(($cnt + 1))
+ fi
+ else
+ res=$(($res + 1))
+ fi
+ cnt=$(($cnt + 1))
+ done
+
+ printf '%d\n' ${res}
+}
+
+ntranslit=0
+while read -r line; do
+ [ "x${line}" != "x${line#\#}" ] && continue
+ [ -z "${line}" ] && continue
+
+ line="${line#\"}"
+ line="${line%\"}"
+ from="${line%%\"[ ]*}"
+ to="${line##*[ ]\"}"
+ fromlen="$(cstrlen "${from}")"
+ tolen="$(cstrlen "${to}")"
+
+ froms="${froms}${from}${LF}"
+ fromlens="${fromlens}${fromlen}${LF}"
+ tos="${tos}${to}${LF}"
+ tolens="${tolens}${tolen}${LF}"
+
+ ntranslit=$(($ntranslit + 1))
+done <<EOF
+$(cat C-translit.h.in | gcc -E - || die 'Cannot preprocess input file')
+EOF
+
+printf '#include <stdint.h>\n'
+
+printf '#define NTRANSLIT %d\n' ${ntranslit}
+
+printf 'static const uint32_t translit_from_idx[] =\n{\n '
+col=2
+total=0
+cnt=0
+while [ ${cnt} -lt ${ntranslit} ]; do
+ fromlen="${fromlens%%${LF}*}"
+ fromlens="${fromlens#*${LF}}"
+ if [ ${cnt} -ne 0 ]; then
+ if [ $(($col + 7)) -ge 79 ]; then
+ printf ',\n '
+ col=2
+ else
+ printf ', '
+ col=$(($col + 2))
+ fi
+ fi
+ printf '%4d' ${total}
+ total=$(($total + $fromlen + 1))
+ col=$(($col + 4))
+ cnt=$(($cnt + 1))
+done
+printf '\n};\n'
+
+printf 'static const wchar_t translit_from_tbl[] =\n '
+col=1
+cnt=0
+while [ ${cnt} -lt ${ntranslit} ]; do
+ from="${froms%%${LF}*}"
+ froms="${froms#*${LF}}"
+ fromlen=${#from}
+ if [ ${cnt} -ne 0 ]; then
+ if [ $(($col + 6)) -ge 79 ]; then
+ printf '\n '
+ col=1
+ fi
+ printf ' L"\\0"'
+ col=$(($col + 6))
+ fi
+ if [ ${col} -gt 2 -a $(($col + $fromlen + 4)) -ge 79 ]; then
+ printf '\n '
+ col=2
+ else
+ printf ' '
+ col=$(($col + 1))
+ fi
+ printf 'L"%s"' "${from}"
+ col=$(($col + $fromlen + 3))
+ cnt=$(($cnt + 1))
+done
+printf ';\n'
+
+printf 'static const uint32_t translit_to_idx[] =\n{\n '
+col=2
+total=0
+cnt=0
+while [ ${cnt} -lt ${ntranslit} ]; do
+ tolen="${tolens%%${LF}*}"
+ tolens="${tolens#*${LF}}"
+ if [ ${cnt} -ne 0 ]; then
+ if [ $(($col + 7)) -ge 79 ]; then
+ printf ',\n '
+ col=2
+ else
+ printf ', '
+ col=$(($col + 2))
+ fi
+ fi
+ printf '%4d' ${total}
+ total=$(($total + $tolen + 2))
+ col=$(($col + 4))
+ cnt=$(($cnt + 1))
+done
+printf '\n};\n'
+
+printf 'static const wchar_t translit_to_tbl[] =\n '
+col=1
+cnt=0
+while [ ${cnt} -lt ${ntranslit} ]; do
+ to="${tos%%${LF}*}"
+ tos="${tos#*${LF}}"
+ tolen=${#to}
+ if [ ${cnt} -ne 0 ]; then
+ if [ $(($col + 6)) -ge 79 ]; then
+ printf '\n '
+ col=1
+ fi
+ printf ' L"\\0"'
+ col=$(($col + 6))
+ fi
+ if [ ${col} -gt 2 -a $(($col + $tolen + 6)) -ge 79 ]; then
+ printf '\n '
+ col=2
+ else
+ printf ' '
+ col=$(($col + 1))
+ fi
+ printf 'L"%s\\0"' "${to}"
+ col=$(($col + $tolen + 5))
+ cnt=$(($cnt + 1))
+done
+printf ';\n'
+
+exit 0
diff -Naur src.orig/libc/locale/Makefile src/libc/locale/Makefile
--- src.orig/libc/locale/Makefile 2012-11-17 12:50:14.000000000 -0500
+++ src/libc/locale/Makefile 2013-06-21 18:10:15.525446048 -0400
@@ -87,7 +87,11 @@
$(objpfx)localedef $(objpfx)locale: $(lib-modules:%=$(objpfx)%.o)
C-translit.h: C-translit.h.in gen-translit.pl
+ifneq ($(PERL),no)
$(PERL) gen-translit.pl < $< > $@.tmp
+else
+ /bin/sh gen-translit.sh < $< > $@.tmp
+endif
mv -f $@.tmp $@
localepath = "$(localedir):$(i18ndir)"
|