From: Ulrich Drepper Date: Wed, 22 Jul 1998 12:50:16 +0000 (+0000) Subject: Correct problem with empty strings. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f4cc44230e0d61cfd9de6db69c912af84ff05cb9;p=thirdparty%2Fglibc.git Correct problem with empty strings. --- diff --git a/string/strcoll.c b/string/strcoll.c index c147e51f4b0..39fdc18d1a4 100644 --- a/string/strcoll.c +++ b/string/strcoll.c @@ -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 , 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); diff --git a/string/strxfrm.c b/string/strxfrm.c index 4076ebb920c..0ea22ca1ce1 100644 --- a/string/strxfrm.c +++ b/string/strxfrm.c @@ -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 , 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);