iconv() doesn't write to the data, just make compilers happy SDL-1.2
authorSam Lantinga
Thu, 28 Jun 2007 08:33:59 +0000
branchSDL-1.2
changeset 398700486a9c2893
parent 3986 4f73308bbb32
child 3988 3270e88063a2
iconv() doesn't write to the data, just make compilers happy
src/stdlib/SDL_iconv.c
     1.1 --- a/src/stdlib/SDL_iconv.c	Thu Jun 28 06:53:09 2007 +0000
     1.2 +++ b/src/stdlib/SDL_iconv.c	Thu Jun 28 08:33:59 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 SDL_iconv(SDL_iconv_t cd,
    1.19 @@ -35,19 +44,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) {