src/stdlib/SDL_iconv.c
branchSDL-1.3
changeset 1668 4da1ee79c9af
parent 1662 782fd950bd46
     1.1 --- a/src/stdlib/SDL_iconv.c	Mon May 29 03:53:21 2006 +0000
     1.2 +++ b/src/stdlib/SDL_iconv.c	Mon May 29 04:04:35 2006 +0000
     1.3 @@ -31,11 +31,11 @@
     1.4  #include <errno.h>
     1.5  
     1.6  size_t
     1.7 -SDL_iconv (SDL_iconv_t cd,
     1.8 -           char **inbuf, size_t * inbytesleft,
     1.9 -           char **outbuf, size_t * outbytesleft)
    1.10 +SDL_iconv(SDL_iconv_t cd,
    1.11 +          char **inbuf, size_t * inbytesleft,
    1.12 +          char **outbuf, size_t * outbytesleft)
    1.13  {
    1.14 -    size_t retCode = iconv (cd, inbuf, inbytesleft, outbuf, outbytesleft);
    1.15 +    size_t retCode = iconv(cd, inbuf, inbytesleft, outbuf, outbytesleft);
    1.16      if (retCode == (size_t) - 1) {
    1.17          switch (errno) {
    1.18          case E2BIG:
    1.19 @@ -121,20 +121,20 @@
    1.20  "UCS-4", ENCODING_UCS4},};
    1.21  
    1.22  SDL_iconv_t
    1.23 -SDL_iconv_open (const char *tocode, const char *fromcode)
    1.24 +SDL_iconv_open(const char *tocode, const char *fromcode)
    1.25  {
    1.26      int src_fmt = ENCODING_UNKNOWN;
    1.27      int dst_fmt = ENCODING_UNKNOWN;
    1.28      int i;
    1.29  
    1.30 -    for (i = 0; i < SDL_arraysize (encodings); ++i) {
    1.31 -        if (SDL_strcasecmp (fromcode, encodings[i].name) == 0) {
    1.32 +    for (i = 0; i < SDL_arraysize(encodings); ++i) {
    1.33 +        if (SDL_strcasecmp(fromcode, encodings[i].name) == 0) {
    1.34              src_fmt = encodings[i].format;
    1.35              if (dst_fmt != ENCODING_UNKNOWN) {
    1.36                  break;
    1.37              }
    1.38          }
    1.39 -        if (SDL_strcasecmp (tocode, encodings[i].name) == 0) {
    1.40 +        if (SDL_strcasecmp(tocode, encodings[i].name) == 0) {
    1.41              dst_fmt = encodings[i].format;
    1.42              if (src_fmt != ENCODING_UNKNOWN) {
    1.43                  break;
    1.44 @@ -142,7 +142,7 @@
    1.45          }
    1.46      }
    1.47      if (src_fmt != ENCODING_UNKNOWN && dst_fmt != ENCODING_UNKNOWN) {
    1.48 -        SDL_iconv_t cd = (SDL_iconv_t) SDL_malloc (sizeof (*cd));
    1.49 +        SDL_iconv_t cd = (SDL_iconv_t) SDL_malloc(sizeof(*cd));
    1.50          if (cd) {
    1.51              cd->src_fmt = src_fmt;
    1.52              cd->dst_fmt = dst_fmt;
    1.53 @@ -153,9 +153,9 @@
    1.54  }
    1.55  
    1.56  size_t
    1.57 -SDL_iconv (SDL_iconv_t cd,
    1.58 -           char **inbuf, size_t * inbytesleft,
    1.59 -           char **outbuf, size_t * outbytesleft)
    1.60 +SDL_iconv(SDL_iconv_t cd,
    1.61 +          char **inbuf, size_t * inbytesleft,
    1.62 +          char **outbuf, size_t * outbytesleft)
    1.63  {
    1.64      /* For simplicity, we'll convert everything to and from UCS-4 */
    1.65      char *src, *dst;
    1.66 @@ -744,10 +744,10 @@
    1.67  }
    1.68  
    1.69  int
    1.70 -SDL_iconv_close (SDL_iconv_t cd)
    1.71 +SDL_iconv_close(SDL_iconv_t cd)
    1.72  {
    1.73      if (cd && cd != (SDL_iconv_t) - 1) {
    1.74 -        SDL_free (cd);
    1.75 +        SDL_free(cd);
    1.76      }
    1.77      return 0;
    1.78  }
    1.79 @@ -755,8 +755,8 @@
    1.80  #endif /* !HAVE_ICONV */
    1.81  
    1.82  char *
    1.83 -SDL_iconv_string (const char *tocode, const char *fromcode, char *inbuf,
    1.84 -                  size_t inbytesleft)
    1.85 +SDL_iconv_string(const char *tocode, const char *fromcode, char *inbuf,
    1.86 +                 size_t inbytesleft)
    1.87  {
    1.88      SDL_iconv_t cd;
    1.89      char *string;
    1.90 @@ -765,37 +765,36 @@
    1.91      size_t outbytesleft;
    1.92      size_t retCode = 0;
    1.93  
    1.94 -    cd = SDL_iconv_open (tocode, fromcode);
    1.95 +    cd = SDL_iconv_open(tocode, fromcode);
    1.96      if (cd == (SDL_iconv_t) - 1) {
    1.97          return NULL;
    1.98      }
    1.99  
   1.100      stringsize = inbytesleft > 4 ? inbytesleft : 4;
   1.101 -    string = SDL_malloc (stringsize);
   1.102 +    string = SDL_malloc(stringsize);
   1.103      if (!string) {
   1.104 -        SDL_iconv_close (cd);
   1.105 +        SDL_iconv_close(cd);
   1.106          return NULL;
   1.107      }
   1.108      outbuf = string;
   1.109      outbytesleft = stringsize;
   1.110 -    SDL_memset (outbuf, 0, 4);
   1.111 +    SDL_memset(outbuf, 0, 4);
   1.112  
   1.113      while (inbytesleft > 0) {
   1.114 -        retCode =
   1.115 -            SDL_iconv (cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
   1.116 +        retCode = SDL_iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
   1.117          switch (retCode) {
   1.118          case SDL_ICONV_E2BIG:
   1.119              {
   1.120                  char *oldstring = string;
   1.121                  stringsize *= 2;
   1.122 -                string = SDL_realloc (string, stringsize);
   1.123 +                string = SDL_realloc(string, stringsize);
   1.124                  if (!string) {
   1.125 -                    SDL_iconv_close (cd);
   1.126 +                    SDL_iconv_close(cd);
   1.127                      return NULL;
   1.128                  }
   1.129                  outbuf = string + (outbuf - oldstring);
   1.130                  outbytesleft = stringsize - (outbuf - string);
   1.131 -                SDL_memset (outbuf, 0, 4);
   1.132 +                SDL_memset(outbuf, 0, 4);
   1.133              }
   1.134              break;
   1.135          case SDL_ICONV_EILSEQ:
   1.136 @@ -810,7 +809,7 @@
   1.137              break;
   1.138          }
   1.139      }
   1.140 -    SDL_iconv_close (cd);
   1.141 +    SDL_iconv_close(cd);
   1.142  
   1.143      return string;
   1.144  }