maint: update copyright
[gnulib.git] / lib / uniconv / u16-conv-to-enc.c
index ba70736..1f8672b 100644 (file)
@@ -1,5 +1,5 @@
 /* Conversion from UTF-16 to legacy encodings.
-   Copyright (C) 2002, 2006-2008 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2006-2014 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify it
    under the terms of the GNU Lesser General Public License as published
@@ -31,7 +31,7 @@
 #define SIZEOF(array) (sizeof (array) / sizeof (array[0]))
 
 /* Name of UTF-16 encoding with machine dependent endianness and alignment.  */
-#if defined _LIBICONV_VERSION || (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)
+#if defined _LIBICONV_VERSION || (((__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)) && !defined __UCLIBC__)
 # ifdef WORDS_BIGENDIAN
 #  define UTF16_NAME "UTF-16BE"
 # else
@@ -81,69 +81,69 @@ FUNC (const SRC_UNIT *s, size_t n, DST_UNIT *resultbuf, size_t *lengthp)
       /* Fetch a Unicode character from the input string.  */
       count = u16_mbtoucr (&uc, s, s_end - s);
       if (count < 0)
-       {
-         if (count == -2)
-           /* Incomplete sequence of units.  */
-           break;
-         if (!(result == resultbuf || result == NULL))
-           free (result);
-         errno = EILSEQ;
-         return NULL;
-       }
+        {
+          if (count == -2)
+            /* Incomplete sequence of units.  */
+            break;
+          if (!(result == resultbuf || result == NULL))
+            free (result);
+          errno = EILSEQ;
+          return NULL;
+        }
       s += count;
 
       /* Store it in the output string.  */
       count = u8_uctomb (result + length, uc, allocated - length);
       if (count == -1)
-       {
-         if (!(result == resultbuf || result == NULL))
-           free (result);
-         errno = EILSEQ;
-         return NULL;
-       }
+        {
+          if (!(result == resultbuf || result == NULL))
+            free (result);
+          errno = EILSEQ;
+          return NULL;
+        }
       if (count == -2)
-       {
-         DST_UNIT *memory;
-
-         allocated = (allocated > 0 ? 2 * allocated : 12);
-         if (length + 6 > allocated)
-           allocated = length + 6;
-         if (result == resultbuf || result == NULL)
-           memory = (DST_UNIT *) malloc (allocated * sizeof (DST_UNIT));
-         else
-           memory =
-             (DST_UNIT *) realloc (result, allocated * sizeof (DST_UNIT));
-
-         if (memory == NULL)
-           {
-             if (!(result == resultbuf || result == NULL))
-               free (result);
-             errno = ENOMEM;
-             return NULL;
-           }
-         if (result == resultbuf && length > 0)
-           memcpy ((char *) memory, (char *) result,
-                   length * sizeof (DST_UNIT));
-         result = memory;
-         count = u8_uctomb (result + length, uc, allocated - length);
-         if (count < 0)
-           abort ();
-       }
+        {
+          DST_UNIT *memory;
+
+          allocated = (allocated > 0 ? 2 * allocated : 12);
+          if (length + 6 > allocated)
+            allocated = length + 6;
+          if (result == resultbuf || result == NULL)
+            memory = (DST_UNIT *) malloc (allocated * sizeof (DST_UNIT));
+          else
+            memory =
+              (DST_UNIT *) realloc (result, allocated * sizeof (DST_UNIT));
+
+          if (memory == NULL)
+            {
+              if (!(result == resultbuf || result == NULL))
+                free (result);
+              errno = ENOMEM;
+              return NULL;
+            }
+          if (result == resultbuf && length > 0)
+            memcpy ((char *) memory, (char *) result,
+                    length * sizeof (DST_UNIT));
+          result = memory;
+          count = u8_uctomb (result + length, uc, allocated - length);
+          if (count < 0)
+            abort ();
+        }
       length += count;
     }
 
   if (length == 0)
     {
       if (result == NULL)
-       {
-         /* Return a non-NULL value.  NULL means error.  */
-         result = (DST_UNIT *) malloc (1);
-         if (result == NULL)
-           {
-             errno = ENOMEM;
-             return NULL;
-           }
-       }
+        {
+          /* Return a non-NULL value.  NULL means error.  */
+          result = (DST_UNIT *) malloc (1);
+          if (result == NULL)
+            {
+              errno = ENOMEM;
+              return NULL;
+            }
+        }
     }
   else if (result != resultbuf && length < allocated)
     {
@@ -152,7 +152,7 @@ FUNC (const SRC_UNIT *s, size_t n, DST_UNIT *resultbuf, size_t *lengthp)
 
       memory = (DST_UNIT *) realloc (result, length * sizeof (DST_UNIT));
       if (memory != NULL)
-       result = memory;
+        result = memory;
     }
 
   *lengthp = length;