mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-01-19 04:49:25 +08:00
49 lines
1.0 KiB
Plaintext
49 lines
1.0 KiB
Plaintext
|
#!/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
|
||
|
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)
|
||
|
echo "};"
|
||
|
) > lc_def_codesets.h
|