4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-01-21 05:49:19 +08:00
newlib-cygwin/winsup/cygwin/linux-locale-helpers/fetch-lc-def-codesets-from-linux
Corinna Vinschen abd81bc01f Cygwin: locale: fix devanagari modifier
Effectively revert commit 57bac33359db.  The fact that the
devanagari modifier was called devanagar (missing the trailing 'i')
is a result of `locale -av' shortening the locale name to a maximum
of 15 characters.

D'oh.  I guess we need a better way to do this...

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-02-26 17:17:33 +01:00

27 lines
718 B
Bash
Executable File

#!/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 $(date +%F) */
struct default_codeset_t
{
const char *locale;
const char *codeset;
} default_codeset[] =
{
EOF
locale -av | \
awk '/^locale:/{
if ( index ($2, "_") == 0 ) next # No aliases
if ( index ($2, ".") > 0 ) next # No explicit codesets
locale = gensub (/devanagar.*/, "devanagari", 1, $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