summaryrefslogtreecommitdiffstats
path: root/patches
diff options
context:
space:
mode:
Diffstat (limited to 'patches')
-rw-r--r--patches/07_noperl-gen-translit.patch218
1 files changed, 218 insertions, 0 deletions
diff --git a/patches/07_noperl-gen-translit.patch b/patches/07_noperl-gen-translit.patch
new file mode 100644
index 0000000..cffc8cd
--- /dev/null
+++ b/patches/07_noperl-gen-translit.patch
@@ -0,0 +1,218 @@
+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,195 @@
++#!/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 '#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
+@@ -88,7 +88,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)"