# HG changeset patch # User Sam Lantinga # Date 1183019639 0 # Node ID 00486a9c2893b2ef732ccaf8ae2d4613b4f4b70e # Parent 4f73308bbb32beb56a1b534fb41f0b896a9be312 iconv() doesn't write to the data, just make compilers happy diff -r 4f73308bbb32 -r 00486a9c2893 src/stdlib/SDL_iconv.c --- a/src/stdlib/SDL_iconv.c Thu Jun 28 06:53:09 2007 +0000 +++ b/src/stdlib/SDL_iconv.c Thu Jun 28 08:33:59 2007 +0000 @@ -28,6 +28,15 @@ #ifdef HAVE_ICONV +/* 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(__GLIBC__) && ((__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)) +#define ICONV_INBUF_NONCONST +#endif + #include size_t SDL_iconv(SDL_iconv_t cd, @@ -35,19 +44,10 @@ char **outbuf, size_t *outbytesleft) { size_t retCode; -#ifdef ICONV_REALLY_MODIFIES_INBUF - if ( inbuf && *inbuf && inbytesleft ) { - char *tmp = SDL_stack_alloc(char, *inbytesleft); - char *ptr = tmp; - SDL_memcpy(tmp, inbuf, *inbytesleft); - retCode = iconv(cd, &ptr, inbytesleft, outbuf, outbytesleft); - inbuf += (ptr - tmp); - SDL_stack_free(tmp); - } else { - retCode = iconv(cd, NULL, inbytesleft, outbuf, outbytesleft); - } +#ifdef ICONV_INBUF_NONCONST + retCode = iconv(cd, (char **)inbuf, inbytesleft, outbuf, outbytesleft); #else - retCode = iconv(cd, (char **)inbuf, inbytesleft, outbuf, outbytesleft); + retCode = iconv(cd, inbuf, inbytesleft, outbuf, outbytesleft); #endif if ( retCode == (size_t)-1 ) { switch(errno) {