public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin/main] Cygwin: fetch-lc-def-codesets-from-linux: speed up
@ 2023-02-25 19:16 Corinna Vinschen
0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2023-02-25 19:16 UTC (permalink / raw)
To: cygwin-cvs
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=a31d4039d0bcf3a18c2fe2b26a810f1c399a8a9e
commit a31d4039d0bcf3a18c2fe2b26a810f1c399a8a9e
Author: Corinna Vinschen <corinna@vinschen.de>
AuthorDate: Sat Feb 25 20:15:53 2023 +0100
Commit: Corinna Vinschen <corinna@vinschen.de>
CommitDate: Sat Feb 25 20:15:53 2023 +0100
Cygwin: fetch-lc-def-codesets-from-linux: speed up
Drop shell read loop in favor of performing the locale output
evaluation inside a single awk invocation.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diff:
---
.../fetch-lc-def-codesets-from-linux | 46 ++++++----------------
1 file changed, 12 insertions(+), 34 deletions(-)
diff --git a/winsup/cygwin/linux-locale-helpers/fetch-lc-def-codesets-from-linux b/winsup/cygwin/linux-locale-helpers/fetch-lc-def-codesets-from-linux
index c8c60ecac38d..1a8afede868a 100755
--- a/winsup/cygwin/linux-locale-helpers/fetch-lc-def-codesets-from-linux
+++ b/winsup/cygwin/linux-locale-helpers/fetch-lc-def-codesets-from-linux
@@ -10,39 +10,17 @@
} default_codeset[] =
{
EOF
- while read line
- do
- locale=$(echo "${line}" | awk '/^locale:/{ print $2; }')
- if [ -z "${locale}" ]
- then
- continue
- fi
- # No aliases
- idx=$(expr index "${locale}" '_')
- if [ "${idx}" -eq 0 ]
- then
- continue
- fi
- # No explicit codesets
- idx=$(expr index "${locale}" '.')
- if [ "${idx}" -ne 0 ]
- then
- continue
- fi
- while read line2
- do
- codeset=$(echo "${line2}" | awk '/codeset/{ print $3; }')
- if [ -n "${codeset}" ]
- then
- # Translate into internal codeset names. */
- case "${codeset}" in
- BIG5*) codeset="BIG5";;
- *) ;;
- esac
- printf " { \"%s\", \"%s\" },\n" "${locale}" "${codeset}"
- break
- fi
- done
- done <<<$(locale -av)
+ locale -av | \
+ awk '/^locale:/{
+ if ( index ($2, "_") == 0 ) next # No aliases
+ if ( index ($2, ".") > 0 ) next # No explicit codesets
+ locale=$2;
+ }
+ /codeset/ {
+ if ( length (locale) == 0 ) next
+ codeset = gensub (/BIG5.*/, "BIG5", 1, $3);
+ printf " { \"%s\", \"%s\" },\n", locale, codeset;
+ locale = "";
+ }'
echo "};"
) > lc_def_codesets.h
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-02-25 19:16 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-25 19:16 [newlib-cygwin/main] Cygwin: fetch-lc-def-codesets-from-linux: speed up Corinna Vinschen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).