From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id 64C01385AC39; Sat, 25 Feb 2023 19:16:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 64C01385AC39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1677352573; bh=gakWPa9v4PXlBwgH0wRd6W0l6o35t4BXGewEOD48oQ8=; h=From:To:Subject:Date:From; b=SeiA3K7hFaLltm/dr1l76wC5Y9ZpUIGI8HB5UTGpw0z0vQE2AjRufR9oFqZb7Xs/W 7bnULDRHYF2aSVU0KCI7wU3tMHao8e8PSjui7/ELHshlSX/tISAVpJQ4dZOm/biapd W0ZpJpMNYZcPiUtVdBbLJKF539ihSu7KZpXMLR+s= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Corinna Vinschen To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin/main] Cygwin: fetch-lc-def-codesets-from-linux: speed up X-Act-Checkin: newlib-cygwin X-Git-Author: Corinna Vinschen X-Git-Refname: refs/heads/main X-Git-Oldrev: 6e6111671a1258ead1235c7e129b1f272c67f9e9 X-Git-Newrev: a31d4039d0bcf3a18c2fe2b26a810f1c399a8a9e Message-Id: <20230225191613.64C01385AC39@sourceware.org> Date: Sat, 25 Feb 2023 19:16:13 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3Da31d4039d0b= cf3a18c2fe2b26a810f1c399a8a9e commit a31d4039d0bcf3a18c2fe2b26a810f1c399a8a9e Author: Corinna Vinschen AuthorDate: Sat Feb 25 20:15:53 2023 +0100 Commit: Corinna Vinschen CommitDate: Sat Feb 25 20:15:53 2023 +0100 Cygwin: fetch-lc-def-codesets-from-linux: speed up =20 Drop shell read loop in favor of performing the locale output evaluation inside a single awk invocation. =20 Signed-off-by: Corinna Vinschen 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[] =3D { EOF - while read line - do - locale=3D$(echo "${line}" | awk '/^locale:/{ print $2; }') - if [ -z "${locale}" ] - then - continue - fi - # No aliases - idx=3D$(expr index "${locale}" '_') - if [ "${idx}" -eq 0 ] - then - continue - fi - # No explicit codesets - idx=3D$(expr index "${locale}" '.') - if [ "${idx}" -ne 0 ] - then - continue - fi - while read line2 - do - codeset=3D$(echo "${line2}" | awk '/codeset/{ print $3; }') - if [ -n "${codeset}" ] - then - # Translate into internal codeset names. */ - case "${codeset}" in - BIG5*) codeset=3D"BIG5";; - *) ;; - esac - printf " { \"%s\", \"%s\" },\n" "${locale}" "${codeset}" - break - fi - done - done <<<$(locale -av) + locale -av | \ + awk '/^locale:/{ + if ( index ($2, "_") =3D=3D 0 ) next # No aliases + if ( index ($2, ".") > 0 ) next # No explicit codesets + locale=3D$2; + } + /codeset/ { + if ( length (locale) =3D=3D 0 ) next + codeset =3D gensub (/BIG5.*/, "BIG5", 1, $3); + printf " { \"%s\", \"%s\" },\n", locale, codeset; + locale =3D ""; + }' echo "};" ) > lc_def_codesets.h