Move to u16-mbtouc-unsafe.
[gnulib.git] / lib / striconveh.c
index 7feb768..56c0c04 100644 (file)
 
 #if HAVE_ICONV
 # include <iconv.h>
-# include "utf8-ucs4-safe.h"
+# include "utf8-ucs4.h"
 # include "ucs4-utf8.h"
 # include "unistr.h"
 #endif
 
-#include "strdup.h"
 #include "c-strcase.h"
+#include "c-strcaseeq.h"
 
 #ifndef SIZE_MAX
 # define SIZE_MAX ((size_t) -1)
@@ -200,7 +200,7 @@ mem_cd_iconveh_internal (const char *src, size_t srclen,
   size_t length;
   size_t last_length = (size_t)(-1); /* only needed if offsets != NULL */
 
-  if (*lengthp >= sizeof (tmpbuf))
+  if (*resultp != NULL && *lengthp >= sizeof (tmpbuf))
     {
       initial_result = *resultp;
       allocated = *lengthp;
@@ -481,7 +481,7 @@ mem_cd_iconveh_internal (const char *src, size_t srclen,
                    int n;
                    int m;
 
-                   n = u8_mbtouc_safe (&uc, (const uint8_t *) in1ptr, in1size);
+                   n = u8_mbtouc (&uc, (const uint8_t *) in1ptr, in1size);
                    if (uc == 0xfffd
                        && !(n >= 3
                             && (uint8_t)in1ptr[0] == 0xEF
@@ -643,8 +643,8 @@ mem_cd_iconveh_internal (const char *src, size_t srclen,
                            int n;
                            if (in2size == 0)
                              abort ();
-                           n = u8_mbtouc (&uc, (const uint8_t *) in2ptr,
-                                          in2size);
+                           n = u8_mbtouc_unsafe (&uc, (const uint8_t *) in2ptr,
+                                                 in2size);
                            in2ptr += n;
                            in2size -= n;
                          }
@@ -929,7 +929,7 @@ mem_iconveh (const char *src, size_t srclen,
       if (cd == (iconv_t)(-1))
        return -1;
 
-      if (c_strcasecmp (from_codeset, "UTF-8") == 0)
+      if (STRCASEEQ (from_codeset, "UTF-8", 'U','T','F','-','8',0,0,0,0))
        cd1 = (iconv_t)(-1);
       else
        {
@@ -943,7 +943,7 @@ mem_iconveh (const char *src, size_t srclen,
            }
        }
 
-      if (c_strcasecmp (to_codeset, "UTF-8") == 0)
+      if (STRCASEEQ (to_codeset, "UTF-8", 'U','T','F','-','8',0,0,0,0))
        cd2 = (iconv_t)(-1);
       else
        {
@@ -1062,7 +1062,7 @@ str_iconveh (const char *src,
       if (cd == (iconv_t)(-1))
        return NULL;
 
-      if (c_strcasecmp (from_codeset, "UTF-8") == 0)
+      if (STRCASEEQ (from_codeset, "UTF-8", 'U','T','F','-','8',0,0,0,0))
        cd1 = (iconv_t)(-1);
       else
        {
@@ -1076,7 +1076,7 @@ str_iconveh (const char *src,
            }
        }
 
-      if (c_strcasecmp (to_codeset, "UTF-8") == 0)
+      if (STRCASEEQ (to_codeset, "UTF-8", 'U','T','F','-','8',0,0,0,0))
        cd2 = (iconv_t)(-1);
       else
        {