Fixed bug #349
authorSam Lantinga <slouken@libsdl.org>
Wed, 04 Jul 2007 07:08:16 +0000
changeset 2142ca80c942e69c
parent 2141 e1a70460c354
child 2143 e906da4414a3
Fixed bug #349

Solaris doesn't support the LATIN1 character set alias.

Merged from 1.2 svn revision 3133f
include/SDL_stdinc.h
src/stdlib/SDL_iconv.c
test/testiconv.c
     1.1 --- a/include/SDL_stdinc.h	Tue Jul 03 09:55:29 2007 +0000
     1.2 +++ b/include/SDL_stdinc.h	Wed Jul 04 07:08:16 2007 +0000
     1.3 @@ -656,8 +656,8 @@
     1.4                                                 const char *fromcode,
     1.5                                                 const char *inbuf,
     1.6                                                 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:55:29 2007 +0000
     2.2 +++ b/src/stdlib/SDL_iconv.c	Wed Jul 04 07:08:16 2007 +0000
     2.3 @@ -110,29 +110,33 @@
     2.4      const char *name;
     2.5      int format;
     2.6  } encodings[] = {
     2.7 -    {
     2.8 -    "ASCII", ENCODING_ASCII}, {
     2.9 -    "US-ASCII", ENCODING_ASCII}, {
    2.10 -    "LATIN1", ENCODING_LATIN1}, {
    2.11 -    "ISO-8859-1", ENCODING_LATIN1}, {
    2.12 -    "UTF8", ENCODING_UTF8}, {
    2.13 -    "UTF-8", ENCODING_UTF8}, {
    2.14 -    "UTF16", ENCODING_UTF16}, {
    2.15 -    "UTF-16", ENCODING_UTF16}, {
    2.16 -    "UTF16BE", ENCODING_UTF16BE}, {
    2.17 -    "UTF-16BE", ENCODING_UTF16BE}, {
    2.18 -    "UTF16LE", ENCODING_UTF16LE}, {
    2.19 -    "UTF-16LE", ENCODING_UTF16LE}, {
    2.20 -    "UTF32", ENCODING_UTF32}, {
    2.21 -    "UTF-32", ENCODING_UTF32}, {
    2.22 -    "UTF32BE", ENCODING_UTF32BE}, {
    2.23 -    "UTF-32BE", ENCODING_UTF32BE}, {
    2.24 -    "UTF32LE", ENCODING_UTF32LE}, {
    2.25 -    "UTF-32LE", ENCODING_UTF32LE}, {
    2.26 -    "UCS2", ENCODING_UCS2}, {
    2.27 -    "UCS-2", ENCODING_UCS2}, {
    2.28 -    "UCS4", ENCODING_UCS4}, {
    2.29 -"UCS-4", ENCODING_UCS4},};
    2.30 +/* *INDENT-OFF* */
    2.31 +    { "646", ENCODING_ASCII },
    2.32 +    { "ASCII", ENCODING_ASCII },
    2.33 +    { "US-ASCII", ENCODING_ASCII },
    2.34 +    { "LATIN1", ENCODING_LATIN1 },
    2.35 +    { "8859-1", ENCODING_LATIN1 },
    2.36 +    { "ISO-8859-1", ENCODING_LATIN1 },
    2.37 +    { "UTF8", ENCODING_UTF8 },
    2.38 +    { "UTF-8", ENCODING_UTF8 },
    2.39 +    { "UTF16", ENCODING_UTF16 },
    2.40 +    { "UTF-16", ENCODING_UTF16 },
    2.41 +    { "UTF16BE", ENCODING_UTF16BE },
    2.42 +    { "UTF-16BE", ENCODING_UTF16BE },
    2.43 +    { "UTF16LE", ENCODING_UTF16LE },
    2.44 +    { "UTF-16LE", ENCODING_UTF16LE },
    2.45 +    { "UTF32", ENCODING_UTF32 },
    2.46 +    { "UTF-32", ENCODING_UTF32 },
    2.47 +    { "UTF32BE", ENCODING_UTF32BE },
    2.48 +    { "UTF-32BE", ENCODING_UTF32BE },
    2.49 +    { "UTF32LE", ENCODING_UTF32LE },
    2.50 +    { "UTF-32LE", ENCODING_UTF32LE },
    2.51 +    { "UCS2", ENCODING_UCS2 },
    2.52 +    { "UCS-2", ENCODING_UCS2 },
    2.53 +    { "UCS4", ENCODING_UCS4 },
    2.54 +    { "UCS-4", ENCODING_UCS4 },
    2.55 +/* *INDENT-ON* */
    2.56 +};
    2.57  
    2.58  SDL_iconv_t
    2.59  SDL_iconv_open(const char *tocode, const char *fromcode)
     3.1 --- a/test/testiconv.c	Tue Jul 03 09:55:29 2007 +0000
     3.2 +++ b/test/testiconv.c	Wed Jul 04 07:08:16 2007 +0000
     3.3 @@ -57,12 +57,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);