changeset 142:d87c151837f4

- Added suport for old iconv() (const char** as 2nd arg).
author jcid
date Fri, 14 Mar 2008 19:04:18 +0100
parents b2c3522b407b
children b2c94699dd6c
files ChangeLog config.h.in configure.in src/decode.c src/html.cc
diffstat 5 files changed, 67 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Mar 14 18:34:14 2008 +0100
+++ b/ChangeLog	Fri Mar 14 19:04:18 2008 +0100
@@ -99,6 +99,8 @@
    Patch: Jorge Arellano Cid, higuita
 +- Set the url resolver to escape illegal chars instead of stripping.
    Patch: Jorge Arellano Cid, Jeremy Henty
++- Added suport for old iconv() (const char** as 2nd arg).
+   Patch: Jorge Arellano Cid, Christian Kellermann
 +- Added a strndup() replacement in dw2
    Patch: Alexander Becher, Johannes Hofmann, Jorge Arellano Cid
 +- Fixed calcHashValue() to only return non-negative numbers (was SEGFAULT).
--- a/config.h.in	Fri Mar 14 18:34:14 2008 +0100
+++ b/config.h.in	Fri Mar 14 19:04:18 2008 +0100
@@ -102,5 +102,8 @@
 /* Version number of package */
 #undef VERSION
 
+/* Use char pointers for newer libiconv */
+#undef inbuf_t
+
 /* Define the real type of socklen_t */
 #undef socklen_t
--- a/configure.in	Fri Mar 14 18:34:14 2008 +0100
+++ b/configure.in	Fri Mar 14 19:04:18 2008 +0100
@@ -325,6 +325,64 @@
 fi
 
 dnl ----------------------
+dnl Check if we need to
+dnl support the old 
+dnl iconv interface
+dnl ----------------------
+if test "x$iconv_ok" = "xyes"; then
+  old_libs="$LIBS"
+  LIBS="$old_libs $LIBICONV_LIBS"
+  old_cflags="$CFLAGS"
+  CFLAGS="$CFLAGS -Werror"
+  AC_TRY_COMPILE([#include <iconv.h>],
+[
+     const char *inPtr;
+      char *outPtr;
+      size_t inLeft = 0, outRoom = 0;
+      iconv_t encoder = iconv_open("ASCII", "UTF-8");
+      iconv(encoder, &inPtr, &inLeft, &outPtr, &outRoom);
+],
+iconv_old=yes,iconv_old=no)
+  LIBS="$old_libs"
+  CLFAGS="$old_cflags"
+
+  if test "x$iconv_old" = "xyes"; then
+    AC_DEFINE([inbuf_t], [const char], [Use const char pointers for older libiconv])
+  else
+    AC_DEFINE([inbuf_t], [char], [Use char pointers for newer libiconv])
+  fi
+fi
+
+dnl ----------------------
+dnl Check if we need to
+dnl support the old 
+dnl iconv interface
+dnl ----------------------
+if test "x$iconv_ok" = "xyes"; then
+  old_libs="$LIBS"
+  LIBS="$old_libs $LIBICONV_LIBS"
+  old_cflags="$CFLAGS"
+  CFLAGS="$CFLAGS -Werror"
+  AC_TRY_COMPILE([#include <iconv.h>],
+[
+     const char *inPtr;
+      char *outPtr;
+      size_t inLeft = 0, outRoom = 0;
+      iconv_t encoder = iconv_open("ASCII", "UTF-8");
+      iconv(encoder, &inPtr, &inLeft, &outPtr, &outRoom);
+],
+iconv_old=yes,iconv_old=no)
+  LIBS="$old_libs"
+  CLFAGS="$old_cflags"
+
+  if test "x$iconv_old" = "xyes"; then
+    AC_DEFINE([inbuf_t], [const char], [Use const char pointers for older libiconv])
+  else
+    AC_DEFINE([inbuf_t], [char], [Use char pointers for newer libiconv])
+  fi
+fi
+
+dnl ----------------------
 dnl Test for POSIX threads
 dnl ----------------------
 dnl
--- a/src/decode.c	Fri Mar 14 18:34:14 2008 +0100
+++ b/src/decode.c	Fri Mar 14 19:04:18 2008 +0100
@@ -143,7 +143,8 @@
    int rc = 0;
 
    Dstr *output;
-   char *inPtr, *outPtr;
+   inbuf_t *inPtr;
+   char *outPtr;
    size_t inLeft, outRoom;
 
    output = dStr_new("");
--- a/src/html.cc	Fri Mar 14 18:34:14 2008 +0100
+++ b/src/html.cc	Fri Mar 14 19:04:18 2008 +0100
@@ -3844,7 +3844,8 @@
    int rc = 0;
    Dstr *output;
    const int bufsize = 128;
-   char *buffer, *inPtr, *outPtr;
+   inbuf_t *inPtr;
+   char *buffer, *outPtr;
    size_t inLeft, outRoom;
    bool bad_chars = false;