Skip to content

Commit 92add87

Browse files
committed
Move iconv const check into autoconf
Some systems (older NetBSD pre-10, Solaris) may have a non-standard const parameter with iconv. Instead of hardcoding the OS check, move this to a feature check performed by autoconf. autoconf doesn't have a nicer way of checking this (well, except for AM_ICONV, which is part of gettext and we're presumably not using it), so we have to repeat the function signature and check for it with a mismatched signature.
1 parent 1307d30 commit 92add87

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

ext/iconv/config.m4

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,17 @@ int main(void) {
8383
AS_VAR_IF([php_cv_iconv_errno], [yes],,
8484
[AC_MSG_FAILURE([The iconv check failed, 'errno' is missing.])])
8585

86+
AC_CACHE_CHECK([if iconv input parameter is const (non-standard)], [php_cv_iconv_const],
87+
[AC_COMPILE_IFELSE([AC_LANG_SOURCE([
88+
#include <iconv.h>
89+
90+
size_t iconv(iconv_t cd, const char **src, size_t *srcleft, char **dst, size_t *dstleft);
91+
])],
92+
[php_cv_iconv_const=const],
93+
[php_cv_iconv_const=])])
94+
AC_DEFINE_UNQUOTED([ICONV_CONST], [$php_cv_iconv_const],
95+
[Define to const if iconv's input is const.])
96+
8697
AC_CACHE_CHECK([if iconv supports //IGNORE], [php_cv_iconv_ignore],
8798
[AC_RUN_IFELSE([AC_LANG_SOURCE([
8899
#include <iconv.h>

ext/iconv/config.w32

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ if (PHP_ICONV != "no") {
1111

1212
AC_DEFINE("HAVE_ICONV", 1, "Define to 1 if the PHP extension 'iconv' is available.");
1313
AC_DEFINE("HAVE_LIBICONV", 1, "Define to 1 if you have the 'libiconv' function.");
14+
AC_DEFINE("ICONV_CONST", "", "Define to const if iconv's input is const.");
1415
AC_DEFINE("ICONV_ALIASED_LIBICONV", 1, "Define to 1 if 'iconv()' is aliased to 'libiconv()'.");
1516
AC_DEFINE("PHP_ICONV_IMPL", "\"libiconv\"", "The iconv implementation.");
1617
ADD_FLAG("CFLAGS_ICONV", "/D PHP_ICONV_EXPORTS ");

ext/iconv/iconv.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,6 @@
4343
#undef iconv
4444
#endif
4545

46-
#if defined(__NetBSD__)
47-
// unfortunately, netbsd has still the old non posix conformant signature
48-
// libiconv tends to match the eventual system's iconv too.
49-
#define ICONV_CONST const
50-
#else
51-
#define ICONV_CONST
52-
#endif
53-
5446
#include "zend_smart_str.h"
5547
#include "ext/standard/base64.h"
5648
#include "ext/standard/quot_print.h"

0 commit comments

Comments
 (0)