Skip to content

Move iconv const check into autoconf #16847

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion ext/iconv/config.w32
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ if (PHP_ICONV != "no") {
AC_DEFINE("HAVE_LIBICONV", 1, "Define to 1 if you have the 'libiconv' function.");
AC_DEFINE("ICONV_ALIASED_LIBICONV", 1, "Define to 1 if 'iconv()' is aliased to 'libiconv()'.");
AC_DEFINE("PHP_ICONV_IMPL", "\"libiconv\"", "The iconv implementation.");
ADD_FLAG("CFLAGS_ICONV", "/D PHP_ICONV_EXPORTS ");
ADD_FLAG("CFLAGS_ICONV", "/D PHP_ICONV_EXPORTS /D ICONV_CONST ");
if (!PHP_ICONV_SHARED) {
ADD_DEF_FILE("ext\\iconv\\php_iconv.def");
}
Expand Down
8 changes: 0 additions & 8 deletions ext/iconv/iconv.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,6 @@
#undef iconv
#endif

#if defined(__NetBSD__)
// 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
#define ICONV_CONST
#endif

#include "zend_smart_str.h"
#include "ext/standard/base64.h"
#include "ext/standard/quot_print.h"
Expand Down
Loading