From 4110ad820dbc46ed8f88de0a0c257fcc9b950d19 Mon Sep 17 00:00:00 2001 From: Chris Frey Date: Mon, 26 Jan 2009 03:02:12 -0500 Subject: [PATCH] Added AM_ICONV automake/autoconf check to configure.ac This should take care of checking for libc or library iconv installs, and checking the iconv() prototype for whether const is needed or not. This removes the need for the template added earlier. --- ChangeLog | 5 +++++ configure.ac | 2 ++ src/Makefile.am | 2 +- src/iconv.cc | 19 ++----------------- 4 files changed, 10 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5892306e..639e83ba 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,11 @@ Release: version 0.15 - 2009/01/?? 2009/01/26 - added template wrapper for iconv() due to casting differences on various platforms... thanks to Bill Paul for FreeBSD testing + - added AM_ICONV automake/autoconf check to configure.ac + This should take care of checking for libc or library + iconv installs, and checking the iconv() prototype for whether + const is needed or not. This removes the need for the + template added earlier. 2009/01/25 - applied patch from Josh Kropf making bjavaloader's syntax more compatible with the windows version, to make cross diff --git a/configure.ac b/configure.ac index ed7f1321..bbbe287b 100644 --- a/configure.ac +++ b/configure.ac @@ -83,6 +83,8 @@ AM_CONDITIONAL([WITH_FUSE], [test "$FUSE_FOUND" = "1"]) AC_CHECK_LIB([pthread], [main]) #AC_CHECK_LIB([libusb], [libusb_init]) +AM_ICONV + # # Checks for header files. diff --git a/src/Makefile.am b/src/Makefile.am index d16403fa..d328f3f5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -142,7 +142,7 @@ libbarry_la_SOURCES = time.cc \ debug.h \ endian.h #libbarry_la_LIBADD = $(LTLIBOBJS) $(LIBUSB_LIBS) $(OPENSSL_LIBS) -libbarry_la_LIBADD = $(LTLIBOBJS) $(LIBUSB_LIBS) +libbarry_la_LIBADD = $(LTLIBOBJS) $(LIBUSB_LIBS) @LTLIBICONV@ libbarry_la_LDFLAGS = -version-info ${LIB_BARRY_VERSION} noinst_HEADERS = cbarry.h \ diff --git a/src/iconv.cc b/src/iconv.cc index 33f82dfe..8826ef80 100644 --- a/src/iconv.cc +++ b/src/iconv.cc @@ -22,6 +22,7 @@ #include "iconv.h" #include "common.h" #include "error.h" +#include "config.h" #include namespace Barry { @@ -48,22 +49,6 @@ IConverter::~IConverter() iconv_close(m_to); } -// -// Not all versions of iconv have the same prototype for the second -// argument, and since going from char** to const char** is illegal -// without an explicit cast, we use a template to do it. -// -template -size_t iconv_wrapper(size_t (*iconv_ptr)(iconv_t, T, size_t*, char**, size_t*), - iconv_t cd, - const char **inbuf, - size_t *inbytesleft, - char **outbuf, - size_t *outbytesleft) -{ - return (*iconv_ptr)(cd, (T)inbuf, inbytesleft, outbuf, outbytesleft); -} - std::string IConverter::Convert(iconv_t cd, const std::string &str) const { size_t target = str.size() * 2; @@ -81,7 +66,7 @@ std::string IConverter::Convert(iconv_t cd, const std::string &str) const outbytesleft = m_buffer.GetBufSize(); iconv(cd, NULL, NULL, NULL, NULL); // reset cd's state - size_t status = iconv_wrapper(&iconv, cd, &in, &inbytesleft, &out, &outbytesleft); + size_t status = iconv(cd, (ICONV_CONST char**) &in, &inbytesleft, &out, &outbytesleft); if( status == (size_t)(-1) ) { if( errno == E2BIG && tries < 2 ) { -- 2.11.4.GIT