test/testiconv.c
branchSDL-1.3
changeset 1668 4da1ee79c9af
parent 1662 782fd950bd46
     1.1 --- a/test/testiconv.c	Mon May 29 03:53:21 2006 +0000
     1.2 +++ b/test/testiconv.c	Mon May 29 04:04:35 2006 +0000
     1.3 @@ -4,7 +4,7 @@
     1.4  #include "SDL.h"
     1.5  
     1.6  static size_t
     1.7 -widelen (char *data)
     1.8 +widelen(char *data)
     1.9  {
    1.10      size_t len = 0;
    1.11      Uint32 *p = (Uint32 *) data;
    1.12 @@ -15,7 +15,7 @@
    1.13  }
    1.14  
    1.15  int
    1.16 -main (int argc, char *argv[])
    1.17 +main(int argc, char *argv[])
    1.18  {
    1.19      const char *formats[] = {
    1.20          "UTF8",
    1.21 @@ -41,33 +41,33 @@
    1.22      if (!argv[1]) {
    1.23          argv[1] = "utf8.txt";
    1.24      }
    1.25 -    file = fopen (argv[1], "rb");
    1.26 +    file = fopen(argv[1], "rb");
    1.27      if (!file) {
    1.28 -        fprintf (stderr, "Unable to open %s\n", argv[1]);
    1.29 +        fprintf(stderr, "Unable to open %s\n", argv[1]);
    1.30          return (1);
    1.31      }
    1.32  
    1.33 -    while (fgets (buffer, sizeof (buffer), file)) {
    1.34 +    while (fgets(buffer, sizeof(buffer), file)) {
    1.35          /* Convert to UCS-4 */
    1.36          size_t len;
    1.37          ucs4 =
    1.38 -            SDL_iconv_string ("UCS-4", "UTF-8", buffer,
    1.39 -                              SDL_strlen (buffer) + 1);
    1.40 -        len = (widelen (ucs4) + 1) * 4;
    1.41 -        for (i = 0; i < SDL_arraysize (formats); ++i) {
    1.42 -            test[0] = SDL_iconv_string (formats[i], "UCS-4", ucs4, len);
    1.43 -            test[1] = SDL_iconv_string ("UCS-4", formats[i], test[0], len);
    1.44 -            if (SDL_memcmp (test[1], ucs4, len) != 0) {
    1.45 -                fprintf (stderr, "FAIL: %s\n", formats[i]);
    1.46 +            SDL_iconv_string("UCS-4", "UTF-8", buffer,
    1.47 +                             SDL_strlen(buffer) + 1);
    1.48 +        len = (widelen(ucs4) + 1) * 4;
    1.49 +        for (i = 0; i < SDL_arraysize(formats); ++i) {
    1.50 +            test[0] = SDL_iconv_string(formats[i], "UCS-4", ucs4, len);
    1.51 +            test[1] = SDL_iconv_string("UCS-4", formats[i], test[0], len);
    1.52 +            if (SDL_memcmp(test[1], ucs4, len) != 0) {
    1.53 +                fprintf(stderr, "FAIL: %s\n", formats[i]);
    1.54                  ++errors;
    1.55              }
    1.56 -            SDL_free (test[0]);
    1.57 -            SDL_free (test[1]);
    1.58 +            SDL_free(test[0]);
    1.59 +            SDL_free(test[1]);
    1.60          }
    1.61 -        test[0] = SDL_iconv_string ("UTF-8", "UCS-4", ucs4, len);
    1.62 -        SDL_free (ucs4);
    1.63 -        fputs (test[0], stdout);
    1.64 -        SDL_free (test[0]);
    1.65 +        test[0] = SDL_iconv_string("UTF-8", "UCS-4", ucs4, len);
    1.66 +        SDL_free(ucs4);
    1.67 +        fputs(test[0], stdout);
    1.68 +        SDL_free(test[0]);
    1.69      }
    1.70      return (errors ? errors + 1 : 0);
    1.71  }