From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id 65168385559E; Sat, 25 Feb 2023 15:25:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 65168385559E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1677338704; bh=bkNe66hkrU8F6oGcyG7tGbNF3HbE1o6vg1m09iw0f14=; h=From:To:Subject:Date:From; b=dfR/+PxWAtmfwuXOSStWTzOwGU4j/k03I7kmO9f5UW+2ET79iOt8qTrpMFk9Fohiu cVz0ra4JZnBxBRgDwsHFry3dOYfhdAR1cRGPrKy96i/JyoZJR2U++OdzpOpowY0aa9 oqRatyNQNjRLM6b1DY2whpZPjXN33mczTxdmAcO8= 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: locale: new script creating linux default codeset mapping X-Act-Checkin: newlib-cygwin X-Git-Author: Corinna Vinschen X-Git-Refname: refs/heads/main X-Git-Oldrev: 57bac33359db23ea74f3d84374dea1da536ed1e6 X-Git-Newrev: 7b591704b886ab60a6c31363bd776acafb32ed09 Message-Id: <20230225152504.65168385559E@sourceware.org> Date: Sat, 25 Feb 2023 15:25:04 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D7b591704b88= 6ab60a6c31363bd776acafb32ed09 commit 7b591704b886ab60a6c31363bd776acafb32ed09 Author: Corinna Vinschen AuthorDate: Sat Feb 25 16:06:34 2023 +0100 Commit: Corinna Vinschen CommitDate: Sat Feb 25 16:12:51 2023 +0100 Cygwin: locale: new script creating linux default codeset mapping =20 New script creating a mapping table from locale to default codeset for this locale. We use that in Cygwin now to generate the own default codeset mapping based on Linux locale names. =20 Signed-off-by: Corinna Vinschen Diff: --- .../fetch-lc-def-codesets-from-linux | 48 ++++++++++++++++++= ++++ 1 file changed, 48 insertions(+) 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 new file mode 100755 index 000000000000..c8c60ecac38d --- /dev/null +++ b/winsup/cygwin/linux-locale-helpers/fetch-lc-def-codesets-from-linux @@ -0,0 +1,48 @@ +#!/bin/bash +( + cat <<-EOF + /* This struct of default codesets has been generated by fetching + locale data from a Linux system using $(rpm -q glibc | head -1) on $(d= ate +%F) */ + struct default_codeset_t + { + const char *locale; + const char *codeset; + } 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) + echo "};" +) > lc_def_codesets.h