[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
iconv.m4 macro updates
From: |
Jeffrey Walton |
Subject: |
iconv.m4 macro updates |
Date: |
Sun, 12 May 2019 05:29:44 -0400 |
Hi Everyone,
I think the m4 macro for iconv should be updated. The current tests do
not close the iconv_t handles opened for configuration tests. It
causes failures when testing with Asan. Also see
https://dev.gnupg.org/T4498 .
This patch tested OK (diff -u):
--- m4/iconv.m4
+++ m4/iconv.m4
@@ -68,11 +68,12 @@
#include <string.h>
int main ()
{
+ iconv_t cd;
/* Test against AIX 5.1 bug: Failures are not distinguishable from successful
returns. */
{
- iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8");
- if (cd_utf8_to_88591 != (iconv_t)(-1))
+ cd = iconv_open ("ISO8859-1", "UTF-8");
+ if (cd != (iconv_t)(-1))
{
static const char input[] = "\342\202\254"; /* EURO SIGN */
char buf[10];
@@ -80,9 +81,10 @@
size_t inbytesleft = strlen (input);
char *outptr = buf;
size_t outbytesleft = sizeof (buf);
- size_t res = iconv (cd_utf8_to_88591,
+ size_t res = iconv (cd,
(char **) &inptr, &inbytesleft,
&outptr, &outbytesleft);
+ iconv_close(cd);
if (res == 0)
return 1;
}
@@ -90,8 +92,8 @@
#if 0 /* This bug could be worked around by the caller. */
/* Test against HP-UX 11.11 bug: Positive return value instead of 0. */
{
- iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591");
- if (cd_88591_to_utf8 != (iconv_t)(-1))
+ cd = iconv_open ("utf8", "iso88591");
+ if (cd != (iconv_t)(-1))
{
static const char input[] = "\304rger mit b\366sen B\374bchen
ohne Augenma\337";
char buf[50];
@@ -99,9 +101,10 @@
size_t inbytesleft = strlen (input);
char *outptr = buf;
size_t outbytesleft = sizeof (buf);
- size_t res = iconv (cd_88591_to_utf8,
+ size_t res = iconv (cd,
(char **) &inptr, &inbytesleft,
&outptr, &outbytesleft);
+ iconv_close(cd);
if ((int)res > 0)
return 1;
}
@@ -110,14 +113,15 @@
/* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is
provided. */
if (/* Try standardized names. */
- iconv_open ("UTF-8", "EUC-JP") == (iconv_t)(-1)
+ (cd = iconv_open ("UTF-8", "EUC-JP")) == (iconv_t)(-1)
/* Try IRIX, OSF/1 names. */
- && iconv_open ("UTF-8", "eucJP") == (iconv_t)(-1)
+ && (cd = iconv_open ("UTF-8", "eucJP")) == (iconv_t)(-1)
/* Try AIX names. */
- && iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1)
+ && (cd = iconv_open ("UTF-8", "IBM-eucJP")) == (iconv_t)(-1)
/* Try HP-UX names. */
- && iconv_open ("utf8", "eucJP") == (iconv_t)(-1))
+ && (cd = iconv_open ("utf8", "eucJP")) == (iconv_t)(-1))
return 1;
+ iconv_close(cd);
return 0;
}], [am_cv_func_iconv_works=yes], [am_cv_func_iconv_works=no],
[case "$host_os" in
Jeff
- iconv.m4 macro updates,
Jeffrey Walton <=