Skip to content

Commit 4d28e40

Browse files
authored
Improve check for broken iconv //IGNORE (#13898)
Previous check defined the symbol ICONV_BROKEN_IGNORE to 0 or 1 and the `#ifdef` macro condition in iconv.c file was always using a bypass. Even when the //IGNORE is supported (for example, on GNU Libiconv). With this change, the ICONV_BROKEN_IGNORE symbol is only defined if the //IGNORE Autoconf check fails or when cross-compiling without setting the php_cv_iconv_ignore variable. This also enables overriding the ext/iconv //IGNORE check when cross-compiling, by setting the php_cv_iconv_ignore variable to "yes" in case the iconv library is known to have a working //IGNORE (for example, GNU libiconv). These cache variables can be set at configure step, when cross-compiling ./configure php_cv_iconv_ignore=yes
1 parent 99cfedf commit 4d28e40

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

ext/iconv/config.m4

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ int main(void) {
112112
AC_MSG_RESULT(yes, cross-compiling)
113113
])
114114

115-
AC_MSG_CHECKING([if iconv supports //IGNORE])
116-
AC_RUN_IFELSE([AC_LANG_SOURCE([[
115+
AC_CACHE_CHECK([if iconv supports //IGNORE], [php_cv_iconv_ignore],
116+
[AC_RUN_IFELSE([AC_LANG_SOURCE([[
117117
#include <iconv.h>
118118
#include <stdlib.h>
119119
@@ -132,16 +132,13 @@ int main(void) {
132132
}
133133
return 0;
134134
}
135-
]])],[
136-
AC_MSG_RESULT(yes)
137-
AC_DEFINE([ICONV_BROKEN_IGNORE],0,[Whether iconv supports IGNORE])
138-
],[
139-
AC_MSG_RESULT(no)
140-
AC_DEFINE([ICONV_BROKEN_IGNORE],1,[Whether iconv supports IGNORE])
141-
],[
142-
AC_MSG_RESULT(no, cross-compiling)
143-
AC_DEFINE([ICONV_BROKEN_IGNORE],0,[Whether iconv supports IGNORE])
144-
])
135+
]])],
136+
[php_cv_iconv_ignore=yes],
137+
[php_cv_iconv_ignore=no],
138+
[php_cv_iconv_ignore=no])])
139+
140+
AS_VAR_IF([php_cv_iconv_ignore], [no],
141+
[AC_DEFINE([ICONV_BROKEN_IGNORE], [1], [Whether iconv has broken IGNORE.])])
145142

146143
LDFLAGS="$save_LDFLAGS"
147144
CFLAGS="$save_CFLAGS"

0 commit comments

Comments
 (0)