src/stdlib/SDL_iconv.c
changeset 2136 5a1b6fe6e90f
parent 2135 0313af081a84
child 2142 ca80c942e69c
     1.1 --- a/src/stdlib/SDL_iconv.c	Thu Jun 28 06:57:08 2007 +0000
     1.2 +++ b/src/stdlib/SDL_iconv.c	Thu Jun 28 08:35:35 2007 +0000
     1.3 @@ -28,6 +28,15 @@
     1.4  
     1.5  #ifdef HAVE_ICONV
     1.6  
     1.7 +/* Depending on which standard the iconv() was implemented with,
     1.8 +   iconv() may or may not use const char ** for the inbuf param.
     1.9 +   If we get this wrong, it's just a warning, so no big deal.
    1.10 +*/
    1.11 +#if defined(_XGP6) || \
    1.12 +    defined(__GLIBC__) && ((__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2))
    1.13 +#define ICONV_INBUF_NONCONST
    1.14 +#endif
    1.15 +
    1.16  #include <errno.h>
    1.17  
    1.18  size_t
    1.19 @@ -36,19 +45,10 @@
    1.20            char **outbuf, size_t * outbytesleft)
    1.21  {
    1.22      size_t retCode;
    1.23 -#ifdef ICONV_REALLY_MODIFIES_INBUF
    1.24 -    if (inbuf && *inbuf && inbytesleft) {
    1.25 -        char *tmp = SDL_stack_alloc(char, *inbytesleft);
    1.26 -        char *ptr = tmp;
    1.27 -        SDL_memcpy(tmp, inbuf, *inbytesleft);
    1.28 -        retCode = iconv(cd, &ptr, inbytesleft, outbuf, outbytesleft);
    1.29 -        inbuf += (ptr - tmp);
    1.30 -        SDL_stack_free(tmp);
    1.31 -    } else {
    1.32 -        retCode = iconv(cd, NULL, inbytesleft, outbuf, outbytesleft);
    1.33 -    }
    1.34 +#ifdef ICONV_INBUF_NONCONST
    1.35 +    retCode = iconv(cd, (char **) inbuf, inbytesleft, outbuf, outbytesleft);
    1.36  #else
    1.37 -    retCode = iconv(cd, (char **) inbuf, inbytesleft, outbuf, outbytesleft);
    1.38 +    retCode = iconv(cd, inbuf, inbytesleft, outbuf, outbytesleft);
    1.39  #endif
    1.40      if (retCode == (size_t) - 1) {
    1.41          switch (errno) {