Fixed bug #349 SDL-1.2
authorSam Lantinga <slouken@libsdl.org>
Wed, 04 Jul 2007 04:27:47 +0000
branchSDL-1.2
changeset 39976a4f3a32c2e6
parent 3996 5f463dddee36
child 3998 098ac044cd2f
Fixed bug #349

Solaris doesn't support the LATIN1 character set alias.
include/SDL_stdinc.h
src/stdlib/SDL_iconv.c
test/testiconv.c
     1.1 --- a/include/SDL_stdinc.h	Tue Jul 03 09:53:26 2007 +0000
     1.2 +++ b/include/SDL_stdinc.h	Wed Jul 04 04:27:47 2007 +0000
     1.3 @@ -584,8 +584,8 @@
     1.4     string that must be freed with SDL_free() or NULL on error.
     1.5  */
     1.6  extern DECLSPEC char * SDLCALL SDL_iconv_string(const char *tocode, const char *fromcode, const char *inbuf, size_t inbytesleft);
     1.7 -#define SDL_iconv_utf8_ascii(S)		SDL_iconv_string("ASCII", "UTF-8", S, SDL_strlen(S)+1)
     1.8 -#define SDL_iconv_utf8_latin1(S)	SDL_iconv_string("LATIN1", "UTF-8", S, SDL_strlen(S)+1)
     1.9 +#define SDL_iconv_utf8_ascii(S)		SDL_iconv_string("646", "UTF-8", S, SDL_strlen(S)+1)
    1.10 +#define SDL_iconv_utf8_latin1(S)	SDL_iconv_string("8859-1", "UTF-8", S, SDL_strlen(S)+1)
    1.11  #define SDL_iconv_utf8_ucs2(S)		(Uint16 *)SDL_iconv_string("UCS-2", "UTF-8", S, SDL_strlen(S)+1)
    1.12  #define SDL_iconv_utf8_ucs4(S)		(Uint32 *)SDL_iconv_string("UCS-4", "UTF-8", S, SDL_strlen(S)+1)
    1.13  
     2.1 --- a/src/stdlib/SDL_iconv.c	Tue Jul 03 09:53:26 2007 +0000
     2.2 +++ b/src/stdlib/SDL_iconv.c	Wed Jul 04 04:27:47 2007 +0000
     2.3 @@ -107,9 +107,11 @@
     2.4  	const char *name;
     2.5  	int format;
     2.6  } encodings[] = {
     2.7 +	{ "646",	ENCODING_ASCII },
     2.8  	{ "ASCII",	ENCODING_ASCII },
     2.9  	{ "US-ASCII",	ENCODING_ASCII },
    2.10  	{ "LATIN1",	ENCODING_LATIN1 },
    2.11 +	{ "8859-1",	ENCODING_LATIN1 },
    2.12  	{ "ISO-8859-1",	ENCODING_LATIN1 },
    2.13  	{ "UTF8",	ENCODING_UTF8 },
    2.14  	{ "UTF-8",	ENCODING_UTF8 },
     3.1 --- a/test/testiconv.c	Tue Jul 03 09:53:26 2007 +0000
     3.2 +++ b/test/testiconv.c	Wed Jul 04 04:27:47 2007 +0000
     3.3 @@ -53,12 +53,16 @@
     3.4  		for ( i = 0; i < SDL_arraysize(formats); ++i ) {
     3.5  			test[0] = SDL_iconv_string(formats[i], "UCS-4", ucs4, len);
     3.6  			test[1] = SDL_iconv_string("UCS-4", formats[i], test[0], len);
     3.7 -			if ( SDL_memcmp(test[1], ucs4, len) != 0 ) {
     3.8 +			if ( !test[1] || SDL_memcmp(test[1], ucs4, len) != 0 ) {
     3.9  				fprintf(stderr, "FAIL: %s\n", formats[i]);
    3.10  				++errors;
    3.11  			}
    3.12 -			SDL_free(test[0]);
    3.13 -			SDL_free(test[1]);
    3.14 +			if ( test[0] ) {
    3.15 +				SDL_free(test[0]);
    3.16 +			}
    3.17 +			if ( test[1] ) {
    3.18 +				SDL_free(test[1]);
    3.19 +			}
    3.20  		}
    3.21  		test[0] = SDL_iconv_string("UTF-8", "UCS-4", ucs4, len);
    3.22  		SDL_free(ucs4);