stdlib: just cast iconv()'s 2nd arg to void *.
This makes the compiler happy (enough) regardless of whether the C runtime headers think this argument should be const or not. Fixes #4966.main
parent
4b8d69a416
commit
8df045cc7d
|
@ -36,18 +36,6 @@
|
|||
#define LIBICONV_PLUG 1
|
||||
#endif
|
||||
#include <iconv.h>
|
||||
|
||||
/* Depending on which standard the iconv() was implemented with,
|
||||
iconv() may or may not use const char ** for the inbuf param.
|
||||
If we get this wrong, it's just a warning, so no big deal.
|
||||
*/
|
||||
#if defined(_XGP6) || defined(__APPLE__) || defined(__RISCOS__) || defined(__FREEBSD__) || \
|
||||
defined(__EMSCRIPTEN__) || \
|
||||
(defined(__GLIBC__) && ((__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)) || \
|
||||
(defined(_NEWLIB_VERSION)))
|
||||
#define ICONV_INBUF_NONCONST
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
SDL_COMPILE_TIME_ASSERT(iconv_t, sizeof (iconv_t) <= sizeof (SDL_iconv_t));
|
||||
|
@ -69,12 +57,9 @@ SDL_iconv(SDL_iconv_t cd,
|
|||
const char **inbuf, size_t * inbytesleft,
|
||||
char **outbuf, size_t * outbytesleft)
|
||||
{
|
||||
size_t retCode;
|
||||
#ifdef ICONV_INBUF_NONCONST
|
||||
retCode = iconv((iconv_t) ((uintptr_t) cd), (char **) inbuf, inbytesleft, outbuf, outbytesleft);
|
||||
#else
|
||||
retCode = iconv((iconv_t) ((uintptr_t) cd), inbuf, inbytesleft, outbuf, outbytesleft);
|
||||
#endif
|
||||
/* iconv's second parameter may or may not be `const char const *` depending on the
|
||||
C runtime's whims. Casting to void * seems to make everyone happy, though. */
|
||||
const size_t retCode = iconv((iconv_t) ((uintptr_t) cd), (void *) inbuf, inbytesleft, outbuf, outbytesleft);
|
||||
if (retCode == (size_t) - 1) {
|
||||
switch (errno) {
|
||||
case E2BIG:
|
||||
|
|
Loading…
Reference in New Issue