I've figured out at least one way to get binutils to detect that iconv
is available on my system when compiling windres.  In reading about
how autoconf works I found that the gcc code follows recommended
practice better than binutils does, and also noted that gcc tests for
HAVE_ICONV rather than HAVE_ICONV_H.  So while adding a test for
iconv.h to configure.ac didn't work, changing the tests to HAVE_ICONV
did.  No change to configure.ac was required.

I also had to cast a const char* to a char*.  That's because
/usr/include/iconv.h on my system (Debian Testing) declares iconv()
like this:

extern size_t iconv (iconv_t __cd, char **__restrict __inbuf,
                     size_t *__restrict __inbytesleft,
                     char **__restrict __outbuf,
                     size_t *__restrict __outbytesleft);

I'm not sure if that's the right solution, but it was needed to get it
to compile.  Certainly the input ptr *should* be const.

With this patch applied, utf-8 formatted .rc files produce .dlls that
contain utf-16 strings that are correctly translated from the input.
I've confirmed this with Polish, which includes characters in the
range that requires iconv.

The patch that follows was generated against
https://cegcc.svn.sourceforge.net/svnroot/cegcc/tags/cegcc-0.55.
Unfortunately, WinMo .exes produced from this tree don't work for me,
but I'm able to mix the resource-only .dlls it produces with .exes
built on an older cegcc.  The fix for .exe generation is probably in
the email archives; I haven't had time to look.

I'm not sure how to proceed with getting this fixed upstream.  The
whole mingw world seems behind on Linux.  Somewhere I saw a comment
that suggested they're focussing on cygwin/Windows until the gcc-4xx
transition settles down.  I couldn't get the trunk of mingw to compile
on Debian testing (but didn't try that hard).  The version of mingw in
Debian is too old to include any of their iconv changes.  I've filed a
bug about this.  No response yet, but I wouldn't be surprised if the
maintainer were also waiting for them to get things working on Linux
again.  I'll see what more I can learn.

Thanks,

--Eric

Index: src/binutils/binutils/winduni.c
===================================================================
--- src/binutils/binutils/winduni.c     (revision 1340)
+++ src/binutils/binutils/winduni.c     (working copy)
@@ -42,7 +42,7 @@
 #include "winduni.h"
 #include "safe-ctype.h"
 
-#if HAVE_ICONV_H
+#if HAVE_ICONV
 #include <iconv.h>
 #endif
 
@@ -616,7 +616,7 @@
     *length = len;
 }
 
-#ifdef HAVE_ICONV_H
+#ifdef HAVE_ICONV
 static int
 iconv_onechar (iconv_t cd, const char *s, char *d, int d_len, const char 
**n_s, char **n_d)
 {
@@ -625,7 +625,7 @@
   for (i = 1; i <= 32; i++)
     {
       char *tmp_d = d;
-      const char *tmp_s = s;
+      char *tmp_s = (char*)s;
       size_t ret;
       size_t s_left = (size_t) i;
       size_t d_left = (size_t) d_len;
@@ -652,7 +652,7 @@
     return NULL;
   return lim->iconv_name;
 }
-#endif /* HAVE_ICONV_H */
+#endif /* HAVE_ICONV */
 
 static rc_uint_type
 wind_MultiByteToWideChar (rc_uint_type cp, const char *mb,
@@ -666,7 +666,7 @@
   /* Convert to bytes. */
   ret *= sizeof (unichar);
 
-#elif defined (HAVE_ICONV_H)
+#elif defined (HAVE_ICONV)
   int first = 1;
   char tmp[32];
   char *p_tmp;
@@ -739,7 +739,7 @@
 
   ret = (rc_uint_type) WideCharToMultiByte (cp, 0, u, -1, mb, mb_len,
                                            NULL, & used_def);
-#elif defined (HAVE_ICONV_H)
+#elif defined (HAVE_ICONV)
   int first = 1;
   char tmp[32];
   char *p_tmp;

-- 
******************************************************************************
* From the desktop of: Eric House, xwo...@eehouse.org                        *
*       Crosswords 4.2 for MS Smartphone and PocketPC is OUT: xwords.sf.net  *
******************************************************************************

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Cegcc-devel mailing list
Cegcc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cegcc-devel

Reply via email to