src/stdlib/SDL_iconv.c
branchSDL-1.2
changeset 3985 2f8efcf14c83
parent 3984 b74530a1dad6
child 3986 4f73308bbb32
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: