Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion ext/iconv/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,17 @@ int main(void) {
AS_VAR_IF([php_cv_iconv_errno], [yes],,
[AC_MSG_FAILURE([The iconv check failed, 'errno' is missing.])])

dnl iconv on some platforms (NetBSD pre-10, Solaris) may have a non-standard
dnl const input parameter; libiconv may imitate this on those platforms.
AC_CACHE_CHECK([if iconv input parameter is const (non-standard)], [php_cv_iconv_const],
[AC_COMPILE_IFELSE([AC_LANG_SOURCE([
#include <iconv.h>

size_t iconv(iconv_t cd, const char **src, size_t *srcleft, char **dst, size_t *dstleft);
])],
[php_cv_iconv_const=const],
[php_cv_iconv_const=])])

AC_CACHE_CHECK([if iconv supports //IGNORE], [php_cv_iconv_ignore],
[AC_RUN_IFELSE([AC_LANG_SOURCE([
#include <iconv.h>
Expand Down Expand Up @@ -120,7 +131,7 @@ int main(void) {
PHP_NEW_EXTENSION([iconv],
[iconv.c],
[$ext_shared],,
[-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1])
[-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -DICONV_CONST=$php_cv_iconv_const])
PHP_SUBST([ICONV_SHARED_LIBADD])
PHP_INSTALL_HEADERS([ext/iconv], [php_iconv.h])
fi
10 changes: 5 additions & 5 deletions ext/iconv/iconv.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@
#undef iconv
#endif

#if defined(__NetBSD__) || (defined(__sun) && defined(__SVR4))
// unfortunately, netbsd has still the old non posix conformant signature
// libiconv tends to match the eventual system's iconv too.
#define ICONV_CONST const
#else
/* iconv can have different constiness for src on some platforms;
* this is explained in config.m4. On Windows, it's always non-const,
* but it can be awkward to set that on the command line. Do it here.
*/
#ifndef ICONV_CONST
#define ICONV_CONST
#endif

Expand Down