iconv and libiconv.
if test "$iconv_avail" != "no"; then
iconv_cflags_save="$CFLAGS"
- CFLAGS="$CFLAGS $INCLUDES"
- AC_MSG_CHECKING([if iconv supports errno])
- AC_TRY_RUN([
-#define LIBICONV_PLUG
-#include <iconv.h>
-#include <errno.h>
-#if defined(_LIBICONV_H)
-#define icv_open(a, b) libiconv_open(a, b)
-#define icv_close(a) libiconv_close(a)
-#define icv(a, b, c, d, e) libiconv(a, b, c, d, e)
-#else
-#define icv_open(a, b) iconv_open(a, b)
-#define icv_close(a) iconv_close(a)
-#define icv(a, b, c, d, e) iconv(a, b, c, d, e)
-#endif
+ iconv_ldflags_save="$LDFLAGS"
-int main() {
- iconv_t cd;
- cd = icv_open( "*blahblah*", "*blahblah*" );
- if( cd == (iconv_t)(-1) ) {
- if( errno == EINVAL ) {
- return 0;
- } else {
- return 1;
- }
- }
- icv_close( cd );
- return 2;
-}
- ],[
- AC_MSG_RESULT(yes)
- PHP_DEFINE([ICONV_SUPPORTS_ERRNO],1)
- AC_DEFINE([ICONV_SUPPORTS_ERRNO],1,[Whether iconv supports error no or not])
- ],[
- AC_MSG_RESULT(no)
- PHP_DEFINE([ICONV_SUPPORTS_ERRNO],0)
- AC_DEFINE([ICONV_SUPPORTS_ERRNO],0,[Whether iconv supports error no or not])
- ])
+ if test -z "$ICONV_DIR"; then
+ PHP_ICONV_PREFIX="/usr"
+ else
+ PHP_ICONV_PREFIX="$ICONV_DIR"
+ fi
+
+ CFLAGS="-I$PHP_ICONV_PREFIX/include $CFLAGS"
+ LDFLAGS="-L$PHP_ICONV_PREFIX/lib $LDFLAGS"
+
+ if test -r $PHP_ICONV_PREFIX/include/giconv.h; then
+ PHP_ICONV_H_PATH="$PHP_ICONV_PREFIX/include/giconv.h"
+ else
+ PHP_ICONV_H_PATH="$PHP_ICONV_PREFIX/include/iconv.h"
+ fi
if test -z "$iconv_lib_name"; then
AC_MSG_CHECKING([if iconv is glibc's])
;;
esac
+ AC_MSG_CHECKING([if iconv supports errno])
+ AC_TRY_RUN([
+#include <$PHP_ICONV_H_PATH>
+#include <errno.h>
+
+int main() {
+ iconv_t cd;
+ cd = iconv_open( "*blahblah*", "*blahblah*" );
+ if (cd == (iconv_t)(-1)) {
+ if (errno == EINVAL) {
+ return 0;
+ } else {
+ return 1;
+ }
+ }
+ iconv_close( cd );
+ return 2;
+}
+ ],[
+ AC_MSG_RESULT(yes)
+ PHP_DEFINE([ICONV_SUPPORTS_ERRNO],1)
+ AC_DEFINE([ICONV_SUPPORTS_ERRNO],1,[Whether iconv supports error no or not])
+ ],[
+ AC_MSG_RESULT(no)
+ PHP_DEFINE([ICONV_SUPPORTS_ERRNO],0)
+ AC_DEFINE([ICONV_SUPPORTS_ERRNO],0,[Whether iconv supports error no or not])
+ ])
+
CFLAGS="$iconv_cflags_save"
+ LDFLAGS="$iconv_ldflags_save"
+
+ PHP_DEFINE([PHP_ICONV_H_PATH], [<$PHP_ICONV_H_PATH>])
+ AC_DEFINE_UNQUOTED([PHP_ICONV_H_PATH], [<$PHP_ICONV_H_PATH>], [Path to iconv.h])
PHP_NEW_EXTENSION(iconv, iconv.c, $ext_shared)
PHP_SUBST(ICONV_SHARED_LIBADD)
#ifdef HAVE_ICONV
-#ifdef HAVE_GICONV_H
-#include <giconv.h>
-#else
-#include <iconv.h>
+#ifndef PHP_ICONV_H_PATH
+#define PHP_ICONV_H_PATH <iconv.h>
#endif
+#include PHP_ICONV_H_PATH
+
#ifdef HAVE_GLIBC_ICONV
#include <gnu/libc-version.h>
#endif
-#ifdef HAVE_LIBICONV
-#define LIBICONV_PLUG
-#define icv_open(a, b) libiconv_open(a, b)
-#define icv_close(a) libiconv_close(a)
-#define icv(a, b, c, d, e) libiconv(a, b, c, d, e)
-#else
-#define icv_open(a, b) iconv_open(a, b)
-#define icv_close(a) iconv_close(a)
-#define icv(a, b, c, d, e) iconv(a, (char **) b, c, d, e)
-#endif
-
/* {{{ iconv_functions[]
*/
function_entry iconv_functions[] = {
in_size = in_len;
- cd = icv_open(out_charset, in_charset);
+ cd = icov_open(out_charset, in_charset);
if (cd == (iconv_t)(-1)) {
return PHP_ICONV_ERR_UNKNOWN;
out_buffer = (char *) emalloc(out_size + 1);
out_p = out_buffer;
- result = icv(cd, (const char **) &in_p, &in_size, (char **)
+ result = iconv(cd, (const char **) &in_p, &in_size, (char **)
&out_p, &out_left);
if (result == (size_t)(-1)) {
}
/* flush the shift-out sequences */
- result = icv(cd, NULL, NULL, &out_p, &out_left);
+ result = iconv(cd, NULL, NULL, &out_p, &out_left);
if (result == (size_t)(-1)) {
efree(out_buffer);
out_buffer[*out_len] = '\0';
*out = out_buffer;
- icv_close(cd);
+ iconv_close(cd);
return PHP_ICONV_ERR_SUCCESS;
*out = NULL;
*out_len = 0;
- cd = icv_open(out_charset, in_charset);
+ cd = iconv_open(out_charset, in_charset);
if (cd == (iconv_t)(-1)) {
if (errno == EINVAL) {
out_p = out_buf;
while (in_left > 0) {
- result = icv(cd, (const char **) &in_p, &in_left, (char **) &out_p, &out_left);
+ result = iconv(cd, (const char **) &in_p, &in_left, (char **) &out_p, &out_left);
out_size = bsz - out_left;
if (result == (size_t)(-1)) {
if (errno == E2BIG && in_left > 0) {
if (result != (size_t)(-1)) {
/* flush the shift-out sequences */
for (;;) {
- result = icv(cd, NULL, NULL, (char **) &out_p, &out_left);
+ result = iconv(cd, NULL, NULL, (char **) &out_p, &out_left);
out_size = bsz - out_left;
if (result != (size_t)(-1)) {
}
}
- icv_close(cd);
+ iconv_close(cd);
if (result == (size_t)(-1)) {
switch (errno) {
#include "php_have_bsd_iconv.h"
#include "php_iconv_supports_errno.h"
#include "php_php_iconv_impl.h"
+#include "php_php_iconv_h_path.h"
#endif