test-framework-sh: Fix side effect on dfa tests (regression 2024-06-11).
[gnulib.git] / m4 / iconv_open.m4
blob61e62ece7b9526b0af946300c0a058f3ba0e5a04
1 # iconv_open.m4
2 # serial 17
3 dnl Copyright (C) 2007-2024 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
8 AC_DEFUN([gl_FUNC_ICONV_OPEN],
10   AC_REQUIRE([AM_ICONV])
11   AC_REQUIRE([AC_CANONICAL_HOST])
12   AC_REQUIRE([gl_ICONV_H_DEFAULTS])
13   if test "$am_cv_func_iconv" = yes; then
14     dnl Provide the <iconv.h> override, for the sake of the C++ aliases.
15     gl_REPLACE_ICONV_H
16     dnl Test whether iconv_open accepts standardized encoding names.
17     dnl We know that GNU libiconv and GNU libc do.
18     AC_EGREP_CPP([gnu_iconv], [
19       #include <iconv.h>
20       #if (defined _LIBICONV_VERSION && !(_LIBICONV_VERSION == 0x10b && defined __APPLE__)) \
21           || (defined __GLIBC__ && !defined __UCLIBC__)
22        gnu_iconv
23       #endif
24       ], [gl_func_iconv_gnu=yes], [gl_func_iconv_gnu=no])
25     if test $gl_func_iconv_gnu = no; then
26       iconv_flavor=
27       case "$host_os" in
28         aix*)         iconv_flavor=ICONV_FLAVOR_AIX ;;
29         irix*)        iconv_flavor=ICONV_FLAVOR_IRIX ;;
30         hpux*)        iconv_flavor=ICONV_FLAVOR_HPUX ;;
31         osf*)         iconv_flavor=ICONV_FLAVOR_OSF ;;
32         solaris*)     iconv_flavor=ICONV_FLAVOR_SOLARIS ;;
33         openedition*) iconv_flavor=ICONV_FLAVOR_ZOS ;;
34       esac
35       if test -n "$iconv_flavor"; then
36         AC_DEFINE_UNQUOTED([ICONV_FLAVOR], [$iconv_flavor],
37           [Define to a symbolic name denoting the flavor of iconv_open()
38            implementation.])
39         gl_REPLACE_ICONV_OPEN
40       fi
41     fi
42     m4_ifdef([gl_FUNC_ICONV_OPEN_UTF_SUPPORT], [
43       gl_FUNC_ICONV_OPEN_UTF_SUPPORT
44       case "$gl_cv_func_iconv_supports_utf" in
45         *yes) ;;
46         *)
47           REPLACE_ICONV_UTF=1
48           AC_DEFINE([REPLACE_ICONV_UTF], [1],
49             [Define if the iconv() functions are enhanced to handle the UTF-{16,32}{BE,LE} encodings.])
50           REPLACE_ICONV=1
51           gl_REPLACE_ICONV_OPEN
52           ;;
53       esac
54     ])
55   fi
58 AC_DEFUN([gl_REPLACE_ICONV_OPEN],
60   gl_REPLACE_ICONV_H
61   REPLACE_ICONV_OPEN=1