projects
/
debian
/
gzip
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
prepare to upload
[debian/gzip]
/
lib
/
localcharset.c
diff --git
a/lib/localcharset.c
b/lib/localcharset.c
index 4255174418b5b14cde8935f6df3f38bd86413ac0..953cc1e706fad22f152e10c6f7ee176e596e3a4c 100644
(file)
--- a/
lib/localcharset.c
+++ b/
lib/localcharset.c
@@
-1,8
+1,6
@@
-/* -*- buffer-read-only: t -*- vi: set ro: */
-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* Determine a canonical name for the current locale's character encoding.
/* Determine a canonical name for the current locale's character encoding.
- Copyright (C) 2000-2006, 2008-201
0
Free Software Foundation, Inc.
+ Copyright (C) 2000-2006, 2008-201
3
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
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
@@
-15,8
+13,7
@@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation,
- Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+ with this program; if not, see <http://www.gnu.org/licenses/>. */
/* Written by Bruno Haible <bruno@clisp.org>. */
/* Written by Bruno Haible <bruno@clisp.org>. */
@@
-32,11
+29,11
@@
#include <stdlib.h>
#if defined __APPLE__ && defined __MACH__ && HAVE_LANGINFO_CODESET
#include <stdlib.h>
#if defined __APPLE__ && defined __MACH__ && HAVE_LANGINFO_CODESET
-# define DARWIN7 /* Darwin 7 or newer, i.e. MacOS X 10.3 or newer */
+# define DARWIN7 /* Darwin 7 or newer, i.e. Mac
OS X 10.3 or newer */
#endif
#if defined _WIN32 || defined __WIN32__
#endif
#if defined _WIN32 || defined __WIN32__
-# define WIN
32
_NATIVE
+# define WIN
DOWS
_NATIVE
#endif
#if defined __EMX__
#endif
#if defined __EMX__
@@
-46,7
+43,7
@@
# endif
#endif
# endif
#endif
-#if !defined WIN
32
_NATIVE
+#if !defined WIN
DOWS
_NATIVE
# include <unistd.h>
# if HAVE_LANGINFO_CODESET
# include <langinfo.h>
# include <unistd.h>
# if HAVE_LANGINFO_CODESET
# include <langinfo.h>
@@
-59,7
+56,7
@@
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
# endif
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
# endif
-#elif defined WIN
32
_NATIVE
+#elif defined WIN
DOWS
_NATIVE
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
#endif
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
#endif
@@
-85,7
+82,7
@@
#endif
#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__
#endif
#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__
- /*
Win32
, Cygwin, OS/2, DOS */
+ /*
Native Windows
, Cygwin, OS/2, DOS */
# define ISSLASH(C) ((C) == '/' || (C) == '\\')
#endif
# define ISSLASH(C) ((C) == '/' || (C) == '\\')
#endif
@@
-125,7
+122,7
@@
get_charset_aliases (void)
cp = charset_aliases;
if (cp == NULL)
{
cp = charset_aliases;
if (cp == NULL)
{
-#if !(defined DARWIN7 || defined VMS || defined WIN
32
_NATIVE || defined __CYGWIN__)
+#if !(defined DARWIN7 || defined VMS || defined WIN
DOWS
_NATIVE || defined __CYGWIN__)
const char *dir;
const char *base = "charset.alias";
char *file_name;
const char *dir;
const char *base = "charset.alias";
char *file_name;
@@
-230,8
+227,7
@@
get_charset_aliases (void)
{
/* Out of memory. */
res_size = 0;
{
/* Out of memory. */
res_size = 0;
- if (old_res_ptr != NULL)
- free (old_res_ptr);
+ free (old_res_ptr);
break;
}
strcpy (res_ptr + res_size - (l2 + 1) - (l1 + 1), buf1);
break;
}
strcpy (res_ptr + res_size - (l2 + 1) - (l1 + 1), buf1);
@@
-311,7
+307,7
@@
get_charset_aliases (void)
"DECKOREAN" "\0" "EUC-KR" "\0";
# endif
"DECKOREAN" "\0" "EUC-KR" "\0";
# endif
-# if defined WIN
32
_NATIVE || defined __CYGWIN__
+# if defined WIN
DOWS
_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. */
/* 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. */
@@
-363,7
+359,7
@@
locale_charset (void)
const char *codeset;
const char *aliases;
const char *codeset;
const char *aliases;
-#if !(defined WIN
32
_NATIVE || defined OS2)
+#if !(defined WIN
DOWS
_NATIVE || defined OS2)
# if HAVE_LANGINFO_CODESET
# if HAVE_LANGINFO_CODESET
@@
-371,10
+367,9
@@
locale_charset (void)
codeset = nl_langinfo (CODESET);
# ifdef __CYGWIN__
codeset = nl_langinfo (CODESET);
# ifdef __CYGWIN__
- /* Cygwin 1.5.x 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. */
+ /* Cygwin < 1.7 does not have locales. nl_langinfo (CODESET) always
+ returns "US-ASCII". 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;
if (codeset != NULL && strcmp (codeset, "US-ASCII") == 0)
{
const char *locale;
@@
-411,10
+406,10
@@
locale_charset (void)
}
}
}
}
- /*
Woe32 has a function returning the locale's codepage as a number:
- GetACP(). This encoding is used by Cygwin, unless the user has set
- the environment variable CYGWIN=codepage:oem (which very few people
- do).
+ /*
The Windows API has a function returning the locale's codepage as a
+ number: GetACP(). This encoding is used by Cygwin, unless the user
+ has set the environment variable CYGWIN=codepage:oem (which very few
+
people
do).
Output directed to console windows needs to be converted (to
GetOEMCP() if the console is using a raster font, or to
GetConsoleOutputCP() if it is using a TrueType font). Cygwin does
Output directed to console windows needs to be converted (to
GetOEMCP() if the console is using a raster font, or to
GetConsoleOutputCP() if it is using a TrueType font). Cygwin does
@@
-457,12
+452,12
@@
locale_charset (void)
# endif
# endif
-#elif defined WIN
32
_NATIVE
+#elif defined WIN
DOWS
_NATIVE
static char buf[2 + 10 + 1];
static char buf[2 + 10 + 1];
- /*
Woe32 has a function returning the locale's codepage as a number:
- GetACP().
+ /*
The Windows API has a function returning the locale's codepage as a
+
number:
GetACP().
When the output goes to a console window, it needs to be provided in
GetOEMCP() encoding if the console is using a raster font, or in
GetConsoleOutputCP() encoding if it is using a TrueType font.
When the output goes to a console window, it needs to be provided in
GetOEMCP() encoding if the console is using a raster font, or in
GetConsoleOutputCP() encoding if it is using a TrueType font.
@@
-547,5
+542,12
@@
locale_charset (void)
if (codeset[0] == '\0')
codeset = "ASCII";
if (codeset[0] == '\0')
codeset = "ASCII";
+#ifdef DARWIN7
+ /* Mac OS X sets MB_CUR_MAX to 1 when LC_ALL=C, and "UTF-8"
+ (the default codeset) does not work when MB_CUR_MAX is 1. */
+ if (strcmp (codeset, "UTF-8") == 0 && MB_CUR_MAX <= 1)
+ codeset = "ASCII";
+#endif
+
return codeset;
}
return codeset;
}