Okay, apparently the newer standard specifies char** for the inbuf SDL-1.2
authorSam Lantinga <slouken@libsdl.org>
Thu, 28 Jun 2007 06:47:35 +0000
branchSDL-1.2
changeset 39852f8efcf14c83
parent 3984 b74530a1dad6
child 3986 4f73308bbb32
Okay, apparently the newer standard specifies char** for the inbuf
parameter to iconv()
(See http://lists.debian.org/debian-glibc/2004/05/msg00006.html)

I'm casting in the general case, but I added a non-const codepath in
case it matters on some platform.
src/stdlib/SDL_iconv.c
     1.1 --- a/src/stdlib/SDL_iconv.c	Thu Jun 28 05:35:50 2007 +0000
     1.2 +++ b/src/stdlib/SDL_iconv.c	Thu Jun 28 06:47:35 2007 +0000
     1.3 @@ -34,7 +34,20 @@
     1.4                   const char **inbuf, size_t *inbytesleft,
     1.5                   char **outbuf, size_t *outbytesleft)
     1.6  {
     1.7 -	size_t retCode = iconv(cd, inbuf, inbytesleft, outbuf, outbytesleft);
     1.8 +	size_t retCode;
     1.9 +#ifdef ICONV_REALLY_MODIFIES_INBUF
    1.10 +	if ( inbuf && *inbuf && inbytesleft ) {
    1.11 +		char *tmp = SDL_stack_alloc(char, *inbytesleft);
    1.12 +		char *ptr = tmp;
    1.13 +		retCode = iconv(cd, &ptr, inbytesleft, outbuf, outbytesleft);
    1.14 +		inbuf += (ptr - tmp);
    1.15 +		SDL_stack_free(tmp);
    1.16 +	} else {
    1.17 +		retCode = iconv(cd, NULL, inbytesleft, outbuf, outbytesleft);
    1.18 +	}
    1.19 +#else
    1.20 +	retCode = iconv(cd, (char **)inbuf, inbytesleft, outbuf, outbytesleft);
    1.21 +#endif
    1.22  	if ( retCode == (size_t)-1 ) {
    1.23  		switch(errno) {
    1.24  		    case E2BIG: