comparison src/stdlib/SDL_iconv.c @ 3985:2f8efcf14c83 SDL-1.2

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.
author Sam Lantinga <slouken@libsdl.org>
date Thu, 28 Jun 2007 06:47:35 +0000
parents b74530a1dad6
children 4f73308bbb32
comparison
equal deleted inserted replaced
3984:b74530a1dad6 3985:2f8efcf14c83
32 32
33 size_t SDL_iconv(SDL_iconv_t cd, 33 size_t SDL_iconv(SDL_iconv_t cd,
34 const char **inbuf, size_t *inbytesleft, 34 const char **inbuf, size_t *inbytesleft,
35 char **outbuf, size_t *outbytesleft) 35 char **outbuf, size_t *outbytesleft)
36 { 36 {
37 size_t retCode = iconv(cd, inbuf, inbytesleft, outbuf, outbytesleft); 37 size_t retCode;
38 #ifdef ICONV_REALLY_MODIFIES_INBUF
39 if ( inbuf && *inbuf && inbytesleft ) {
40 char *tmp = SDL_stack_alloc(char, *inbytesleft);
41 char *ptr = tmp;
42 retCode = iconv(cd, &ptr, inbytesleft, outbuf, outbytesleft);
43 inbuf += (ptr - tmp);
44 SDL_stack_free(tmp);
45 } else {
46 retCode = iconv(cd, NULL, inbytesleft, outbuf, outbytesleft);
47 }
48 #else
49 retCode = iconv(cd, (char **)inbuf, inbytesleft, outbuf, outbytesleft);
50 #endif
38 if ( retCode == (size_t)-1 ) { 51 if ( retCode == (size_t)-1 ) {
39 switch(errno) { 52 switch(errno) {
40 case E2BIG: 53 case E2BIG:
41 return SDL_ICONV_E2BIG; 54 return SDL_ICONV_E2BIG;
42 case EILSEQ: 55 case EILSEQ: