diff options
author | 2006-04-25 01:17:03 +0000 | |
---|---|---|
committer | 2006-04-25 01:17:03 +0000 | |
commit | b05ce3d64861142588263fd5682eca01e78cc382 (patch) | |
tree | b0d9b0f9080d9df02458f747c5f1620f8dd606a6 | |
parent | if user hasnt setup /etc/locale.gen but they have left over cruft in /etc/loc... (diff) | |
download | locale-gen-b05ce3d64861142588263fd5682eca01e78cc382.tar.gz locale-gen-b05ce3d64861142588263fd5682eca01e78cc382.tar.bz2 locale-gen-b05ce3d64861142588263fd5682eca01e78cc382.zip |
rewrite code a bit so we run sed once for all locales instead of two or three times for every locale (much faster)
-rwxr-xr-x | locale-gen | 46 |
1 files changed, 28 insertions, 18 deletions
@@ -41,7 +41,7 @@ show_usage() { exit 1 } show_version() { - local cvsver="$Header: /var/cvsroot/gentoo/src/patchsets/glibc/extra/locale/locale-gen,v 1.7 2006/04/25 00:43:06 vapier Exp $" + local cvsver="$Header: /var/cvsroot/gentoo/src/patchsets/glibc/extra/locale/locale-gen,v 1.8 2006/04/25 01:17:03 vapier Exp $" cvsver=${cvsver##*locale-gen-} echo "locale-gen-${cvsver%%,v *}" exit 0 @@ -115,12 +115,13 @@ then ewarn "and then remove /etc/locales.build when you're done.\n" fi -locales_to_generate=$(sed \ - -e 's:#.*::' \ - -e '/^[[:space:]]*$/d' \ - "${LOCALEGEN}") -set -- ${locales_to_generate} -total=$(($#/2)) +locales_to_generate="" +if [[ -e ${LOCALEGEN} ]] ; then + locales_to_generate=$(sed \ + -e 's:#.*::' \ + -e '/^[[:space:]]*$/d' \ + "${LOCALEGEN}") +fi if [[ -z ${locales_to_generate} ]] ; then # Maybe they have /etc/locales.build setup still ... @@ -131,8 +132,6 @@ if [[ -z ${locales_to_generate} ]] ; then -e '/^[[:space:]]*$/d' \ -e 's:/: :g' \ "${LOCALEGEN}") - set -- ${locales_to_generate} - total=$(($#/2)) if [[ -n ${locales_to_generate} ]] && \ [[ ${QUIET} -eq 0 ]] && [[ -z ${JUST_LIST} ]] then @@ -167,6 +166,20 @@ normalize() { fi } +# These funky sed's are based on the stuff in glibc's localedata/Makefile +# Basically we want to rewrite the display like so: +# <locale without a . or @>.<charmap>[@extra stuff after the @ in the locale] +# en_US ISO-8859-1 -> en_US.ISO-8859-1 +# en_US.UTF-8 UTF-8 -> en_US.UTF-8 +# de_DE@euro ISO-8859-15 -> de_DE.ISO-8859-15@euro +locales_disp=$(echo "${locales_to_generate}" | sed \ + -e '/\@/s:\([^\@ ]*\)\([^ ]*\) \(.*\):\1.\3\2:' \ + -e '/[^\@]/s:\([^. ]*\)\([^ ]*\) \(.*\):\1.\3:') + +eval declare -a locales_disp=(${locales_disp}) +eval declare -a locales_to_generate=(${locales_to_generate}) +total=$((${#locales_to_generate[*]}/2)) + [[ ${QUIET} -eq 0 ]] && [[ -z ${JUST_LIST} ]] && \ einfo "Generating ${total} locales (this might take a while)" @@ -178,11 +191,11 @@ if [[ -n ${UPDATE} ]] ; then existing_locales=" $(echo $(locale -a)) " fi -while [[ -n $1 ]] ; do +lidx=0 +while [[ -n ${locales_to_generate[${lidx}]} ]] ; do ((++cnt)) - locale=$1 - charmap=$2 - shift ; shift + locale=${locales_to_generate[$((lidx++))]} + charmap=${locales_to_generate[$((lidx++))]} # XXX: if we wanted to, we could check existence of # ${LOCALES}/${locale} and ${CHARMAPS}/${charmap} @@ -195,10 +208,7 @@ while [[ -n $1 ]] ; do continue fi - # These funky sed's are copied from the glibc localedata/Makefile - disp=$(echo ${locale} | sed 's/\([^.\@]*\).*/\1/') - disp=${disp}.${charmap} - disp=${disp}$(echo ${locale} | sed 's/\([^\@]*\)\(\@.*\)*/\2/') + disp=${locales_disp[$((cnt-1))]} if [[ -n ${UPDATE} ]] && \ [[ ${existing_locales} == *" $(normalize ${locale}) "* ]] @@ -211,7 +221,7 @@ while [[ -n $1 ]] ; do if [[ -f ${LOCALES}/${locale} ]] ; then input=${locale} else - input=$(echo ${locale} | sed 's/\([^.]*\)[^@]*\(.*\)/\1\2/') + input=${locale%%.*} fi if [[ -z ${JUST_LIST} ]] ; then |