Ticket #802 (closed defect: Fixed)

Opened 3 years ago

Last modified 39 years ago

invalid call to iconv in translate.cpp

Reported by: nobody Owned by: emostar
Priority: normal Milestone:
Component: build Version: devel
Keywords: Cc:

Description

gcc 3.4.4 on SunOS 5.8 complains about invalid calls to iconv in translate.cpp (invalid conversion from char** to const char** in the second argument or some such error). The signature of iconv on this machine is:

size_t iconv (iconv_t cd,

const char* * inbuf, size_t *

inbytesleft,

char* * outbuf, size_t * outbytesleft);

I fixed it by casting it explictely to (const char**), but that is probably an ugly hack :-)

Edsko (edsko@…)

Change History

Changed 3 years ago by nobody

Logged In: NO

Same problem with GCC 3.4.2 on FreeBSD 5.4 Fixed with this patch:

--- src/translate.cpp.orig Thu Oct 13 17:09:23 2005 +++ src/translate.cpp Fri Oct 28 13:47:13 2005 @@ -242,13 +242,13 @@

tr = iconv_open("UTF-8", szFrom);

- size_t ret = iconv(tr, &szIn, &nInSize, &szOut, &nOutSize); + size_t ret = iconv(tr,const_cast<const char**>(&szIn), &nInSize, &szOut, &nOutSize);

iconv_close(tr);

if (ret == (size_t)(-1)) {

tr = iconv_open("UCS-2BE", szFrom);

- iconv(tr, &szIn, &nInSize, &szOut, &nOutSize); + iconv(tr, const_cast<const char**>(&szIn), &nInSize, &szOut, &nOutSize);

iconv_close(tr);

}

@@ -287,13 +287,13 @@

tr = iconv_open(szTo, "UTF-8");

- size_t ret = iconv(tr, &szIn, &nInSize, &szOut, &nOutSize); + size_t ret = iconv(tr, const_cast<const char**>(&szIn), &nInSize, &szOut, &nOutSize);

iconv_close(tr);

if (ret == (size_t)(-1)) {

tr = iconv_open(szTo, "UCS-2BE");

- iconv(tr, &szIn, &nInSize, &szOut, &nOutSize); + iconv(tr, const_cast<const char**>(&szIn), &nInSize, &szOut, &nOutSize);

iconv_close(tr);

}

@@ -319,7 +319,7 @@

nOutSize = nLen * 2;

tr = iconv_open("", "UCS-2BE");

- size_t ret = iconv(tr, &szIn, &nInSize, &szOut, &nOutSize); + size_t ret = iconv(tr, const_cast<const char**>(&szIn), &nInSize, &szOut, &nOutSize);

iconv_close(tr);

if (ret == (size_t)(-1))

@@ -346,7 +346,7 @@

nOutSize = nLen;

tr = iconv_open("UCS-2BE", _szEncoding);

- size_t ret = iconv(tr, &szIn, &nInSize, &szOut, &nOutSize); + size_t ret = iconv(tr, const_cast<const char**>(&szIn), &nInSize, &szOut, &nOutSize);

iconv_close(tr);

if (ret == (size_t)-1)

Changed 3 years ago by emostar

Logged In: YES user_id=21415

What is your libiconv version? The function signature has changed at some point apparently...

Changed 3 years ago by emostar

  • status changed from assigned to closed

Logged In: YES user_id=21415

This is fixed in the latest CVS version of Licq. It will be included in the next release, or you may use the CVS version. Read http://www.licq.org/daily.php

Changed 3 years ago by emostar

Logged In: YES user_id=21415

The correct fix is not this patch, it must be done at configure.in to set ICONV_CONST in config.h, then use this define when calling iconv()

Note: See TracTickets for help on using tickets.