Cygwin: fetch-lc-def-codesets-from-linux: fix locale name handling

As the former call to `locale -av' has the unwanted side effect
to shorten the locale name to <= 15 chars, don't use it.  Use
`locale -a' instead and fetch the codeset from another call to
`locale' for each locale.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen 2023-02-26 20:14:54 +01:00
parent abd81bc01f
commit 5011c8cc48
1 changed files with 11 additions and 12 deletions

View File

@ -10,17 +10,16 @@
} default_codeset[] = } default_codeset[] =
{ {
EOF EOF
locale -av | \ locale -a | \
awk '/^locale:/{ awk '{
if ( index ($2, "_") == 0 ) next # No aliases if ( index ($1, "_") == 0 ) next # No aliases
if ( index ($2, ".") > 0 ) next # No explicit codesets if ( index ($1, ".") > 0 ) next # No explicit codesets
locale = gensub (/devanagar.*/, "devanagari", 1, $2); locale = $1
} cmd = "LC_CTYPE=" locale " locale -ck LC_CTYPE | grep charmap"
/codeset/ { cmd | getline codeset
if ( length (locale) == 0 ) next codeset = gensub (/charmap="(.*)"/, "\\1", 1, codeset)
codeset = gensub (/BIG5.*/, "BIG5", 1, $3); codeset = gensub (/BIG5.*/, "BIG5", 1, codeset);
printf " { \"%s\", \"%s\" },\n", locale, codeset; printf " { \"%s\", \"%s\" },\n", locale, codeset;
locale = ""; }'
}'
echo "};" echo "};"
) > lc_def_codesets.h ) > lc_def_codesets.h