about summary refs log tree commit diff
path: root/libidn/idna.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2004-03-13 06:50:10 +0000
committerUlrich Drepper <drepper@redhat.com>2004-03-13 06:50:10 +0000
commita17256a4fa281d1e84fa56c49689bc146dd73c6e (patch)
tree310af594b3d61dceada95066f84a3f51788a1e21 /libidn/idna.c
parent4be2c5fcd8aa87878fed6e36a465179c5f246e28 (diff)
downloadglibc-a17256a4fa281d1e84fa56c49689bc146dd73c6e.tar.gz
glibc-a17256a4fa281d1e84fa56c49689bc146dd73c6e.tar.xz
glibc-a17256a4fa281d1e84fa56c49689bc146dd73c6e.zip
Update.
	* idna.c (idna_to_ascii_4z): Use strdup if available.  Unify two ifs.

	* idn-stub.c: Implement __idna_to_unicode_lzlz.  Split
	__idna_to_ascii_lz in two parts so that loading can be shared with
	the new function.
	* Versions (libcidn): Export idna_to_unicode_lzlz.
Diffstat (limited to 'libidn/idna.c')
-rw-r--r--libidn/idna.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/libidn/idna.c b/libidn/idna.c
index 69c928fc42..b89350f1f3 100644
--- a/libidn/idna.c
+++ b/libidn/idna.c
@@ -437,24 +437,21 @@ idna_to_ascii_4z (const uint32_t * input, char **output, int flags)
      U+3002 (ideographic full stop), U+FF0E (fullwidth full stop),
      U+FF61 (halfwidth ideographic full stop). */
 
-  if (input[0] == 0)
+  if (input[0] == 0
+      /* Handle explicit zero-length root label. */
+      || (DOTP (input[0]) && input[1] == 0))
     {
+#if defined HAVE_STRDUP || defined _LIBC
+      *output = strdup (input);
+      return *output == NULL ? IDNA_MALLOC_ERROR : IDNA_SUCCESS;
+#else
       /* Handle implicit zero-length root label. */
       *output = malloc (1);
       if (!*output)
 	return IDNA_MALLOC_ERROR;
-      strcpy (*output, "");
-      return IDNA_SUCCESS;
-    }
-
-  if (DOTP (input[0]) && input[1] == 0)
-    {
-      /* Handle explicit zero-length root label. */
-      *output = malloc (2);
-      if (!*output)
-	return IDNA_MALLOC_ERROR;
-      strcpy (*output, ".");
+      strcpy (*output, input);
       return IDNA_SUCCESS;
+#endif
     }
 
   *output = NULL;