From 82de6ace6d64b95ec495a3a9df57d5729029825f Mon Sep 17 00:00:00 2001 From: fluxgen Date: Tue, 31 Aug 2004 21:24:05 +0000 Subject: have const msg ptr to iconv --- src/FbTk/Font.cc | 25 ++++++++++++++++++++----- src/FbTk/Font.hh | 4 +++- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/FbTk/Font.cc b/src/FbTk/Font.cc index 8ba5a0a..bf07ee0 100644 --- a/src/FbTk/Font.cc +++ b/src/FbTk/Font.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -//$Id: Font.cc,v 1.15 2004/08/31 20:27:08 fluxgen Exp $ +//$Id: Font.cc,v 1.16 2004/08/31 21:24:05 fluxgen Exp $ #include "StringUtil.hh" @@ -119,8 +119,15 @@ char* recode(iconv_t cd, char *new_msg_ptr = new_msg; char *msg_ptr = strdup(msg); char *orig_msg_ptr = msg_ptr; // msg_ptr modified in iconv call + size_t result = (size_t)(-1); - if (iconv(cd, &msg_ptr, &inbytesleft, &new_msg, &outbytesleft) == -1) { +#ifdef HAVE_CONST_ICONV + result = iconv(cd, const_cast(&msg_ptr), &inbytesleft, &new_msg, &outbytesleft); +#else + result = iconv(cd, &msg_ptr, &inbytesleft, &new_msg, &outbytesleft); +#endif // HAVE_CONST_ICONV + + if (result == (size_t)(-1)) { // iconv can fail for three reasons // 1) Invalid multibyte sequence is encountered in the input // 2) An incomplete multibyte sequence @@ -143,7 +150,7 @@ char* recode(iconv_t cd, } #else -char *recode(iconv_t cd, +char *recode(int cd, const char *msg, size_t size) { return 0; } @@ -232,8 +239,13 @@ Font::Font(const char *name, bool antialias): m_antialias(false), m_rotated(false), m_shadow(false), m_shadow_color("#000000"), m_shadow_offx(1), m_shadow_offy(1), - m_halo(false), m_halo_color("#ffffff"), - m_iconv((iconv_t)-1) { + m_halo(false), m_halo_color("#ffffff") { + +#ifdef HAVE_ICONV + m_iconv = (iconv_t)(-1); +#else + m_iconv = -1; +#endif // HAVE_ICONV // MB_CUR_MAX returns the size of a char in the current locale if (MB_CUR_MAX > 1) // more than one byte, then we're multibyte @@ -252,6 +264,8 @@ Font::Font(const char *name, bool antialias): #ifdef DEBUG cerr<<"FbTk::Font: check UTF-8 convert for codeset = "<