lol
1--- libiconv-1.14/libcharset/lib/localcharset.c 2011-02-28 17:43:35.000000000 -0500
2+++ libiconv-1.14/libcharset/lib/localcharset.c 2011-08-28 00:16:57.238000000 -0400
3@@ -54,10 +54,6 @@
4 # include <locale.h>
5 # endif
6 # endif
7-# ifdef __CYGWIN__
8-# define WIN32_LEAN_AND_MEAN
9-# include <windows.h>
10-# endif
11 #elif defined WIN32_NATIVE
12 # define WIN32_LEAN_AND_MEAN
13 # include <windows.h>
14@@ -124,7 +120,7 @@
15 cp = charset_aliases;
16 if (cp == NULL)
17 {
18-#if !(defined DARWIN7 || defined VMS || defined WIN32_NATIVE || defined __CYGWIN__)
19+#if !(defined DARWIN7 || defined VMS || defined WIN32_NATIVE)
20 const char *dir;
21 const char *base = "charset.alias";
22 char *file_name;
23@@ -309,7 +305,7 @@
24 "DECKOREAN" "\0" "EUC-KR" "\0";
25 # endif
26
27-# if defined WIN32_NATIVE || defined __CYGWIN__
28+# if defined WIN32_NATIVE
29 /* To avoid the troubles of installing a separate file in the same
30 directory as the DLL and of retrieving the DLL's directory at
31 runtime, simply inline the aliases here. */
32@@ -365,64 +361,12 @@
33
34 # if HAVE_LANGINFO_CODESET
35
36- /* Most systems support nl_langinfo (CODESET) nowadays. */
37- codeset = nl_langinfo (CODESET);
38-
39-# ifdef __CYGWIN__
40- /* Cygwin < 1.7 does not have locales. nl_langinfo (CODESET) always
41- returns "US-ASCII". Return the suffix of the locale name from the
42- environment variables (if present) or the codepage as a number. */
43- if (codeset != NULL && strcmp (codeset, "US-ASCII") == 0)
44- {
45- const char *locale;
46- static char buf[2 + 10 + 1];
47-
48- locale = getenv ("LC_ALL");
49- if (locale == NULL || locale[0] == '\0')
50- {
51- locale = getenv ("LC_CTYPE");
52- if (locale == NULL || locale[0] == '\0')
53- locale = getenv ("LANG");
54- }
55- if (locale != NULL && locale[0] != '\0')
56- {
57- /* If the locale name contains an encoding after the dot, return
58- it. */
59- const char *dot = strchr (locale, '.');
60-
61- if (dot != NULL)
62- {
63- const char *modifier;
64-
65- dot++;
66- /* Look for the possible @... trailer and remove it, if any. */
67- modifier = strchr (dot, '@');
68- if (modifier == NULL)
69- return dot;
70- if (modifier - dot < sizeof (buf))
71- {
72- memcpy (buf, dot, modifier - dot);
73- buf [modifier - dot] = '\0';
74- return buf;
75- }
76- }
77- }
78-
79- /* Woe32 has a function returning the locale's codepage as a number:
80- GetACP(). This encoding is used by Cygwin, unless the user has set
81- the environment variable CYGWIN=codepage:oem (which very few people
82- do).
83- Output directed to console windows needs to be converted (to
84- GetOEMCP() if the console is using a raster font, or to
85- GetConsoleOutputCP() if it is using a TrueType font). Cygwin does
86- this conversion transparently (see winsup/cygwin/fhandler_console.cc),
87- converting to GetConsoleOutputCP(). This leads to correct results,
88- except when SetConsoleOutputCP has been called and a raster font is
89- in use. */
90- sprintf (buf, "CP%u", GetACP ());
91- codeset = buf;
92- }
93-# endif
94+ /* Most systems support nl_langinfo (CODESET) nowadays.
95+ POSIX allows that the returned pointer may point to a static area that
96+ may be overwritten by subsequent calls to setlocale or nl_langinfo. */
97+ static char codeset_buf[64];
98+ codeset_buf[0] = '\0';
99+ codeset = strncat (codeset_buf, nl_langinfo (CODESET), sizeof (codeset_buf));
100
101 # else
102