Skip to content

Commit 0960689

Browse files
committed
Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4: Move iconv const check into autoconf (8.3) (#20247)
2 parents b35b5e0 + 0a8cb02 commit 0960689

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

ext/iconv/config.m4

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,20 @@ 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+
dnl iconv on some platforms (NetBSD pre-10, Solaris) may have a non-standard
87+
dnl const input parameter; libiconv may imitate this on those platforms.
88+
AC_CACHE_CHECK([if iconv input parameter is const (non-standard)], [php_cv_iconv_const],
89+
[AC_COMPILE_IFELSE([AC_LANG_SOURCE([
90+
#include <iconv.h>
91+
92+
size_t iconv(iconv_t cd, const char **src, size_t *srcleft, char **dst, size_t *dstleft);
93+
])],
94+
[php_cv_iconv_const=const],
95+
[php_cv_iconv_const=non-const])])
96+
dnl non-const is just used for display, set it back
97+
AS_VAR_IF([php_cv_iconv_const], [non-const],
98+
[php_cv_iconv_const=])
99+
86100
AC_CACHE_CHECK([if iconv supports //IGNORE], [php_cv_iconv_ignore],
87101
[AC_RUN_IFELSE([AC_LANG_SOURCE([
88102
#include <iconv.h>
@@ -120,7 +134,7 @@ int main(void) {
120134
PHP_NEW_EXTENSION([iconv],
121135
[iconv.c],
122136
[$ext_shared],,
123-
[-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1])
137+
[-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -DICONV_CONST=$php_cv_iconv_const])
124138
PHP_SUBST([ICONV_SHARED_LIBADD])
125139
PHP_INSTALL_HEADERS([ext/iconv], [php_iconv.h])
126140
fi

ext/iconv/iconv.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@
4343
#undef iconv
4444
#endif
4545

46-
#if defined(__NetBSD__) || (defined(__sun) && defined(__SVR4))
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
46+
/* iconv can have different constiness for src on some platforms;
47+
* this is explained in config.m4. On Windows, it's always non-const,
48+
* but it can be awkward to set that on the command line. Do it here.
49+
*/
50+
#ifndef ICONV_CONST
5151
#define ICONV_CONST
5252
#endif
5353

0 commit comments

Comments
 (0)