+2006-06-17 Bruno Haible <bruno@clisp.org>
+
+ * config.charset: Update for NetBSD 3.0.
+
+2006-05-17 Bruno Haible <bruno@clisp.org>
+
+ Cygwin portability.
+ * localcharset.c (WIN32_NATIVE): Renamed from WIN32.
+
+2006-05-16 Bruno Haible <bruno@clisp.org>
+
+ * localcharset.c [CYGWIN]: Include <windows.h>.
+ (get_charset_aliases): For Cygwin, return the same CPxxx aliases list
+ as under WIN32.
+ (locale_charset) [CYGWIN]: Try to retrieve the encoding from the
+ environment variables. Fall back to GetACP().
+
+2006-04-05 Bruno Haible <bruno@clisp.org>
+
+ * config.charset: Update Juan Manuel Guerrero's address.
+
2005-02-12 Bruno Haible <bruno@clisp.org>
* allocsa.h: Add extern "C" for C++.
#! /bin/sh
# Output a system dependent table of character encoding aliases.
#
-# Copyright (C) 2000-2004 Free Software Foundation, Inc.
+# Copyright (C) 2000-2004, 2006 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# The current list of GNU canonical charset names is as follows.
#
# name MIME? used by which systems
-# ASCII, ANSI_X3.4-1968 glibc solaris freebsd darwin
-# ISO-8859-1 Y glibc aix hpux irix osf solaris freebsd darwin
-# ISO-8859-2 Y glibc aix hpux irix osf solaris freebsd darwin
+# ASCII, ANSI_X3.4-1968 glibc solaris freebsd netbsd darwin
+# ISO-8859-1 Y glibc aix hpux irix osf solaris freebsd netbsd darwin
+# ISO-8859-2 Y glibc aix hpux irix osf solaris freebsd netbsd darwin
# ISO-8859-3 Y glibc solaris
-# ISO-8859-4 Y osf solaris freebsd darwin
-# ISO-8859-5 Y glibc aix hpux irix osf solaris freebsd darwin
+# ISO-8859-4 Y osf solaris freebsd netbsd darwin
+# ISO-8859-5 Y glibc aix hpux irix osf solaris freebsd netbsd darwin
# ISO-8859-6 Y glibc aix hpux solaris
-# ISO-8859-7 Y glibc aix hpux irix osf solaris darwin
+# ISO-8859-7 Y glibc aix hpux irix osf solaris netbsd darwin
# ISO-8859-8 Y glibc aix hpux osf solaris
# ISO-8859-9 Y glibc aix hpux irix osf solaris darwin
-# ISO-8859-13 glibc darwin
+# ISO-8859-13 glibc netbsd darwin
# ISO-8859-14 glibc
# ISO-8859-15 glibc aix osf solaris freebsd darwin
-# KOI8-R Y glibc solaris freebsd darwin
-# KOI8-U Y glibc freebsd darwin
+# KOI8-R Y glibc solaris freebsd netbsd darwin
+# KOI8-U Y glibc freebsd netbsd darwin
# KOI8-T glibc
# CP437 dos
# CP775 dos
# CP862 dos
# CP864 dos
# CP865 dos
-# CP866 freebsd darwin dos
+# CP866 freebsd netbsd darwin dos
# CP869 dos
# CP874 woe32 dos
# CP922 aix
# CP1125 dos
# CP1129 aix
# CP1250 woe32
-# CP1251 glibc solaris darwin woe32
+# CP1251 glibc solaris netbsd darwin woe32
# CP1252 aix woe32
# CP1253 woe32
# CP1254 woe32
# CP1255 glibc woe32
# CP1256 woe32
# CP1257 woe32
-# GB2312 Y glibc aix hpux irix solaris freebsd darwin
-# EUC-JP Y glibc aix hpux irix osf solaris freebsd darwin
-# EUC-KR Y glibc aix hpux irix osf solaris freebsd darwin
-# EUC-TW glibc aix hpux irix osf solaris
-# BIG5 Y glibc aix hpux osf solaris freebsd darwin
+# GB2312 Y glibc aix hpux irix solaris freebsd netbsd darwin
+# EUC-JP Y glibc aix hpux irix osf solaris freebsd netbsd darwin
+# EUC-KR Y glibc aix hpux irix osf solaris freebsd netbsd darwin
+# EUC-TW glibc aix hpux irix osf solaris netbsd
+# BIG5 Y glibc aix hpux osf solaris freebsd netbsd darwin
# BIG5-HKSCS glibc solaris
# GBK glibc aix osf solaris woe32 dos
-# GB18030 glibc solaris
-# SHIFT_JIS Y hpux osf solaris freebsd darwin
+# GB18030 glibc solaris netbsd
+# SHIFT_JIS Y hpux osf solaris freebsd netbsd darwin
# JOHAB glibc solaris woe32
# TIS-620 glibc aix hpux osf solaris
# VISCII Y glibc
# HP-KANA8 hpux
# DEC-KANJI osf
# DEC-HANYU osf
-# UTF-8 Y glibc aix hpux osf solaris darwin
+# UTF-8 Y glibc aix hpux osf solaris netbsd darwin
#
# Note: Names which are not marked as being a MIME name should not be used in
# Internet protocols for information interchange (mail, news, etc.).
echo "ISO8859-2 ISO-8859-2"
echo "ISO8859-4 ISO-8859-4"
echo "ISO8859-5 ISO-8859-5"
+ echo "ISO8859-7 ISO-8859-7"
+ echo "ISO8859-13 ISO-8859-13"
echo "ISO8859-15 ISO-8859-15"
echo "eucCN GB2312"
echo "eucJP EUC-JP"
echo "# If you find that the encoding given for your language and"
echo "# country is not the one your DOS machine actually uses, just"
echo "# correct it in this file, and send a mail to"
- echo "# Juan Manuel Guerrero <st001906@hrz1.hrz.tu-darmstadt.de>"
+ echo "# Juan Manuel Guerrero <juan.guerrero@gmx.de>"
echo "# and Bruno Haible <bruno@clisp.org>."
echo "#"
echo "C ASCII"
#endif
#if defined _WIN32 || defined __WIN32__
-# undef WIN32 /* avoid warning on mingw32 */
-# define WIN32
+# define WIN32_NATIVE
#endif
#if defined __EMX__
# define OS2
#endif
-#if !defined WIN32
+#if !defined WIN32_NATIVE
# if HAVE_LANGINFO_CODESET
# include <langinfo.h>
# else
# include <locale.h>
# endif
# endif
-#elif defined WIN32
+# ifdef __CYGWIN__
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h>
+# endif
+#elif defined WIN32_NATIVE
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
#endif
cp = charset_aliases;
if (cp == NULL)
{
-#if !(defined VMS || defined WIN32)
+#if !(defined VMS || defined WIN32_NATIVE || defined __CYGWIN__)
FILE *fp;
const char *dir;
const char *base = "charset.alias";
"DECKOREAN" "\0" "EUC-KR" "\0";
# endif
-# if defined WIN32
+# if defined WIN32_NATIVE || defined __CYGWIN__
/* To avoid the troubles of installing a separate file in the same
directory as the DLL and of retrieving the DLL's directory at
runtime, simply inline the aliases here. */
const char *codeset;
const char *aliases;
-#if !(defined WIN32 || defined OS2)
+#if !(defined WIN32_NATIVE || defined OS2)
# if HAVE_LANGINFO_CODESET
/* Most systems support nl_langinfo (CODESET) nowadays. */
codeset = nl_langinfo (CODESET);
+# ifdef __CYGWIN__
+ /* Cygwin 2006 does not have locales. nl_langinfo (CODESET) always
+ returns "US-ASCII". As long as this is not fixed, return the suffix
+ of the locale name from the environment variables (if present) or
+ the codepage as a number. */
+ if (codeset != NULL && strcmp (codeset, "US-ASCII") == 0)
+ {
+ const char *locale;
+ static char buf[2 + 10 + 1];
+
+ locale = getenv ("LC_ALL");
+ if (locale == NULL || locale[0] == '\0')
+ {
+ locale = getenv ("LC_CTYPE");
+ if (locale == NULL || locale[0] == '\0')
+ locale = getenv ("LANG");
+ }
+ if (locale != NULL && locale[0] != '\0')
+ {
+ /* If the locale name contains an encoding after the dot, return
+ it. */
+ const char *dot = strchr (locale, '.');
+
+ if (dot != NULL)
+ {
+ const char *modifier;
+
+ dot++;
+ /* Look for the possible @... trailer and remove it, if any. */
+ modifier = strchr (dot, '@');
+ if (modifier == NULL)
+ return dot;
+ if (modifier - dot < sizeof (buf))
+ {
+ memcpy (buf, dot, modifier - dot);
+ buf [modifier - dot] = '\0';
+ return buf;
+ }
+ }
+ }
+
+ /* Woe32 has a function returning the locale's codepage as a number. */
+ sprintf (buf, "CP%u", GetACP ());
+ codeset = buf;
+ }
+# endif
+
# else
/* On old systems which lack it, use setlocale or getenv. */
# endif
-#elif defined WIN32
+#elif defined WIN32_NATIVE
static char buf[2 + 10 + 1];