mirror of
git://sourceware.org/git/glibc.git
synced 2025-04-06 14:10:30 +08:00
Correct problem with empty strings.
This commit is contained in:
parent
0b630da519
commit
f4cc44230e
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user