]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Correct problem with empty strings.
authorUlrich Drepper <drepper@redhat.com>
Wed, 22 Jul 1998 12:50:16 +0000 (12:50 +0000)
committerUlrich Drepper <drepper@redhat.com>
Wed, 22 Jul 1998 12:50:16 +0000 (12:50 +0000)
string/strcoll.c
string/strxfrm.c

index c147e51f4b0a67c9d9e79f96da40949f866a4d18..39fdc18d1a49688c7bc5d05b8e6aad9f15e6cb4a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
 
@@ -52,6 +52,12 @@ STRCOLL (s1, s2)
   if (collate_nrules == 0)
     return STRCMP (s1, s2);
 
+  /* Handle empty strings as a special case.  */
+  if (*s1 == '\0')
+    return *s2 == '\0' ? 0 : -1;
+  else if (*s2 == '\0')
+    return 1;
+
   /* Get full information about the strings.  This means we get
      information for all passes in a special data structure.  */
   get_string (s1, s1forw, s1backw);
index 4076ebb920c0a356a5ddb26f9d48072d45d6147a..0ea22ca1ce17cabb2f9b23f278a48a52525440bd 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
 
@@ -159,6 +159,14 @@ STRXFRM (STRING_TYPE *dest, const STRING_TYPE *src, size_t n)
       return STRLEN (src);
     }
 
+  /* Handle an empty string as a special case.  */
+  if (*src == '\0')
+    {
+      if (n != 0)
+       *dest = '\0';
+      return 1;
+    }
+
   /* Get full information about the string.  This means we get
      information for all passes in a special data structure.  */
   get_string (src, forw, backw);