X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fstriconv.c;h=85c5577e40d92f29382cf92f826a8c95c23a0030;hb=7ef6c64e210ac0979d7e8ac69bc5b5208c2405ab;hp=9b1c7f44d81846db05139b5faea44279eb639a8a;hpb=2d4d7d9d00fe33b6f5291e00a30b6c1016775b74;p=gnulib.git
diff --git a/lib/striconv.c b/lib/striconv.c
index 9b1c7f44d..85c5577e4 100644
--- a/lib/striconv.c
+++ b/lib/striconv.c
@@ -1,5 +1,5 @@
/* Charset conversion.
- Copyright (C) 2001-2007 Free Software Foundation, Inc.
+ Copyright (C) 2001-2007, 2010-2014 Free Software Foundation, Inc.
Written by Bruno Haible and Simon Josefsson.
This program is free software; you can redistribute it and/or modify
@@ -13,8 +13,7 @@
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. */
+ along with this program; if not, see . */
#include
@@ -50,7 +49,8 @@ mem_cd_iconv (const char *src, size_t srclen, iconv_t cd,
/* Avoid glibc-2.1 bug and Solaris 2.7-2.9 bug. */
# if defined _LIBICONV_VERSION \
- || !((__GLIBC__ - 0 == 2 && __GLIBC_MINOR__ - 0 <= 1) || defined __sun)
+ || !(((__GLIBC__ == 2 && __GLIBC_MINOR__ <= 1) && !defined __UCLIBC__) \
+ || defined __sun)
/* Set to the initial state. */
iconv (cd, NULL, NULL, NULL, NULL);
# endif
@@ -82,7 +82,7 @@ mem_cd_iconv (const char *src, size_t srclen, iconv_t cd,
else
return -1;
}
-# if !defined _LIBICONV_VERSION && !defined __GLIBC__
+# if !defined _LIBICONV_VERSION && !(defined __GLIBC__ && !defined __UCLIBC__)
/* Irix iconv() inserts a NUL byte if it cannot convert.
NetBSD iconv() inserts a question mark if it cannot convert.
Only GNU libiconv and GNU libc are known to prefer to fail rather
@@ -97,7 +97,8 @@ mem_cd_iconv (const char *src, size_t srclen, iconv_t cd,
}
/* Avoid glibc-2.1 bug and Solaris 2.7 bug. */
# if defined _LIBICONV_VERSION \
- || !((__GLIBC__ - 0 == 2 && __GLIBC_MINOR__ - 0 <= 1) || defined __sun)
+ || !(((__GLIBC__ == 2 && __GLIBC_MINOR__ <= 1) && !defined __UCLIBC__) \
+ || defined __sun)
{
char *outptr = tmpbuf;
size_t outsize = tmpbufsize;
@@ -131,7 +132,8 @@ mem_cd_iconv (const char *src, size_t srclen, iconv_t cd,
/* Avoid glibc-2.1 bug and Solaris 2.7-2.9 bug. */
# if defined _LIBICONV_VERSION \
- || !((__GLIBC__ - 0 == 2 && __GLIBC_MINOR__ - 0 <= 1) || defined __sun)
+ || !(((__GLIBC__ == 2 && __GLIBC_MINOR__ <= 1) && !defined __UCLIBC__) \
+ || defined __sun)
/* Return to the initial state. */
iconv (cd, NULL, NULL, NULL, NULL);
# endif
@@ -156,7 +158,7 @@ mem_cd_iconv (const char *src, size_t srclen, iconv_t cd,
else
goto fail;
}
-# if !defined _LIBICONV_VERSION && !defined __GLIBC__
+# if !defined _LIBICONV_VERSION && !(defined __GLIBC__ && !defined __UCLIBC__)
/* Irix iconv() inserts a NUL byte if it cannot convert.
NetBSD iconv() inserts a question mark if it cannot convert.
Only GNU libiconv and GNU libc are known to prefer to fail rather
@@ -170,7 +172,8 @@ mem_cd_iconv (const char *src, size_t srclen, iconv_t cd,
}
/* Avoid glibc-2.1 bug and Solaris 2.7 bug. */
# if defined _LIBICONV_VERSION \
- || !((__GLIBC__ - 0 == 2 && __GLIBC_MINOR__ - 0 <= 1) || defined __sun)
+ || !(((__GLIBC__ == 2 && __GLIBC_MINOR__ <= 1) && !defined __UCLIBC__) \
+ || defined __sun)
{
size_t res = iconv (cd, NULL, NULL, &outptr, &outsize);
@@ -207,7 +210,7 @@ str_cd_iconv (const char *src, iconv_t cd)
to a trailing NUL byte in the output. But not for UTF-7. So that this
function is usable for UTF-7, we have to exclude the NUL byte from the
conversion and add it by hand afterwards. */
-# if !defined _LIBICONV_VERSION && !defined __GLIBC__
+# if !defined _LIBICONV_VERSION && !(defined __GLIBC__ && !defined __UCLIBC__)
/* Irix iconv() inserts a NUL byte if it cannot convert.
NetBSD iconv() inserts a question mark if it cannot convert.
Only GNU libiconv and GNU libc are known to prefer to fail rather
@@ -233,8 +236,7 @@ str_cd_iconv (const char *src, iconv_t cd)
(result != NULL ? realloc (result, length + 1) : malloc (length + 1));
if (final_result == NULL)
{
- if (result != NULL)
- free (result);
+ free (result);
errno = ENOMEM;
return NULL;
}
@@ -273,7 +275,8 @@ str_cd_iconv (const char *src, iconv_t cd)
/* Avoid glibc-2.1 bug and Solaris 2.7-2.9 bug. */
# if defined _LIBICONV_VERSION \
- || !((__GLIBC__ - 0 == 2 && __GLIBC_MINOR__ - 0 <= 1) || defined __sun)
+ || !(((__GLIBC__ == 2 && __GLIBC_MINOR__ <= 1) && !defined __UCLIBC__) \
+ || defined __sun)
/* Set to the initial state. */
iconv (cd, NULL, NULL, NULL, NULL);
# endif
@@ -325,7 +328,8 @@ str_cd_iconv (const char *src, iconv_t cd)
}
/* Avoid glibc-2.1 bug and Solaris 2.7 bug. */
# if defined _LIBICONV_VERSION \
- || !((__GLIBC__ - 0 == 2 && __GLIBC_MINOR__ - 0 <= 1) || defined __sun)
+ || !(((__GLIBC__ == 2 && __GLIBC_MINOR__ <= 1) && !defined __UCLIBC__) \
+ || defined __sun)
for (;;)
{
/* Here outptr + outbytes_remaining = result + result_size - 1. */
@@ -411,7 +415,8 @@ str_iconv (const char *src, const char *from_codeset, const char *to_codeset)
char *result;
/* Avoid glibc-2.1 bug with EUC-KR. */
-# if (__GLIBC__ - 0 == 2 && __GLIBC_MINOR__ - 0 <= 1) && !defined _LIBICONV_VERSION
+# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ <= 1) && !defined __UCLIBC__) \
+ && !defined _LIBICONV_VERSION
if (c_strcasecmp (from_codeset, "EUC-KR") == 0
|| c_strcasecmp (to_codeset, "EUC-KR") == 0)
{