[pure-lang-svn] SF.net SVN: pure-lang: [37] pure/trunk
Status: Beta
Brought to you by:
agraef
From: <ag...@us...> - 2008-05-03 10:48:09
|
Revision: 37 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=37&view=rev Author: agraef Date: 2008-05-03 03:48:16 -0700 (Sat, 03 May 2008) Log Message: ----------- Fix up iconv() calls for compatibility with OSX. Modified Paths: -------------- pure/trunk/ChangeLog pure/trunk/util.cc Modified: pure/trunk/ChangeLog =================================================================== --- pure/trunk/ChangeLog 2008-05-03 10:29:01 UTC (rev 36) +++ pure/trunk/ChangeLog 2008-05-03 10:48:16 UTC (rev 37) @@ -1,5 +1,8 @@ 2008-05-03 Albert Graef <Dr....@t-...> + * util.cc (myiconv): Apple's iconv takes const char** as 2nd + parameter. #ifdef that case. Reported by Ryan Schmidt. + * interpreter.cc (declare_extern): Fixed a bug in the generated wrapper code for external calls, which caused function arguments to be garbage-collected prematurely, when they were still needed Modified: pure/trunk/util.cc =================================================================== --- pure/trunk/util.cc 2008-05-03 10:29:01 UTC (rev 36) +++ pure/trunk/util.cc 2008-05-03 10:48:16 UTC (rev 37) @@ -433,6 +433,14 @@ #endif /* HAVE_LANGINFO_CODESET */ } +#ifdef __APPLE__ +#define myiconv(ic, inbuf, inbytes, outbuf, outbytes) \ + iconv(ic, (const char**)inbuf, inbytes, outbuf, outbytes) +#else +#define myiconv(ic, inbuf, inbytes, outbuf, outbytes) \ + iconv(ic, inbuf, inbytes, outbuf, outbytes) +#endif + #define CHUNKSZ 128 char * @@ -455,7 +463,7 @@ char *inbuf = (char*)s, *outbuf = t; // const char* -> char*. Ugh. size_t inbytes = l, outbytes = l; - while (iconv(ic, &inbuf, &inbytes, &outbuf, &outbytes) == + while (myiconv(ic, &inbuf, &inbytes, &outbuf, &outbytes) == (size_t)-1) if (errno == E2BIG) { /* try to enlarge the output buffer */ @@ -508,7 +516,7 @@ char *inbuf = (char*)s, *outbuf = t; // const char* -> char*. Ugh. size_t inbytes = l, outbytes = l; - while (iconv(ic, &inbuf, &inbytes, &outbuf, &outbytes) == + while (myiconv(ic, &inbuf, &inbytes, &outbuf, &outbytes) == (size_t)-1) if (errno == E2BIG) { /* try to enlarge the output buffer */ @@ -532,7 +540,7 @@ /* here we might have to deal with a stateful encoding, so make sure that we emit the closing shift sequence */ - while (iconv(ic, NULL, NULL, &outbuf, &outbytes) == + while (myiconv(ic, NULL, NULL, &outbuf, &outbytes) == (size_t)-1) if (errno == E2BIG) { /* try to enlarge the output buffer */ @@ -580,7 +588,7 @@ char *inbuf = s; wchar_t *outbuf = t; size_t inbytes = l, outbytes = l*sizeof(wchar_t); - if (iconv(myic[1], &inbuf, &inbytes, (char**)&outbuf, &outbytes) == + if (myiconv(myic[1], &inbuf, &inbytes, (char**)&outbuf, &outbytes) == (size_t)-1) return NULL; /* terminate the output string */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |