mirror of
git://sourceware.org/git/glibc.git
synced 2025-01-30 12:31:53 +08:00
Use correct signedness in default implementations of wcscmp and wmemcmp
This commit is contained in:
parent
37822576b8
commit
1f1e194720
@ -1,5 +1,8 @@
|
||||
2011-10-25 Andreas Schwab <schwab@redhat.com>
|
||||
|
||||
* wcsmbs/wcscmp.c (WCSCMP): Compare as wchar_t, not wint_t.
|
||||
* wcsmbs/wmemcmp.c (WMEMCMP): Likewise.
|
||||
|
||||
* string/test-strchr.c (do_test): Don't generate NUL bytes.
|
||||
|
||||
2011-10-25 Ulrich Drepper <drepper@gmail.com>
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1995, 1996, 1997, 2011 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
|
||||
|
||||
@ -31,12 +31,12 @@ WCSCMP (s1, s2)
|
||||
const wchar_t *s1;
|
||||
const wchar_t *s2;
|
||||
{
|
||||
wint_t c1, c2;
|
||||
wchar_t c1, c2;
|
||||
|
||||
do
|
||||
{
|
||||
c1 = (wint_t) *s1++;
|
||||
c2 = (wint_t) *s2++;
|
||||
c1 = *s1++;
|
||||
c2 = *s2++;
|
||||
if (c2 == L'\0')
|
||||
return c1 - c2;
|
||||
}
|
||||
|
@ -29,25 +29,25 @@ WMEMCMP (s1, s2, n)
|
||||
const wchar_t *s2;
|
||||
size_t n;
|
||||
{
|
||||
register wint_t c1;
|
||||
register wint_t c2;
|
||||
register wchar_t c1;
|
||||
register wchar_t c2;
|
||||
|
||||
while (n >= 4)
|
||||
{
|
||||
c1 = (wint_t) s1[0];
|
||||
c2 = (wint_t) s2[0];
|
||||
c1 = s1[0];
|
||||
c2 = s2[0];
|
||||
if (c1 - c2 != 0)
|
||||
return c1 > c2 ? 1 : -1;
|
||||
c1 = (wint_t) s1[1];
|
||||
c2 = (wint_t) s2[1];
|
||||
c1 = s1[1];
|
||||
c2 = s2[1];
|
||||
if (c1 - c2 != 0)
|
||||
return c1 > c2 ? 1 : -1;
|
||||
c1 = (wint_t) s1[2];
|
||||
c2 = (wint_t) s2[2];
|
||||
c1 = s1[2];
|
||||
c2 = s2[2];
|
||||
if (c1 - c2 != 0)
|
||||
return c1 > c2 ? 1 : -1;
|
||||
c1 = (wint_t) s1[3];
|
||||
c2 = (wint_t) s2[3];
|
||||
c1 = s1[3];
|
||||
c2 = s2[3];
|
||||
if (c1 - c2 != 0)
|
||||
return c1 > c2 ? 1 : -1;
|
||||
s1 += 4;
|
||||
@ -57,8 +57,8 @@ WMEMCMP (s1, s2, n)
|
||||
|
||||
if (n > 0)
|
||||
{
|
||||
c1 = (wint_t) s1[0];
|
||||
c2 = (wint_t) s2[0];
|
||||
c1 = s1[0];
|
||||
c2 = s2[0];
|
||||
if (c1 - c2 != 0)
|
||||
return c1 > c2 ? 1 : -1;
|
||||
++s1;
|
||||
@ -67,8 +67,8 @@ WMEMCMP (s1, s2, n)
|
||||
}
|
||||
if (n > 0)
|
||||
{
|
||||
c1 = (wint_t) s1[0];
|
||||
c2 = (wint_t) s2[0];
|
||||
c1 = s1[0];
|
||||
c2 = s2[0];
|
||||
if (c1 - c2 != 0)
|
||||
return c1 > c2 ? 1 : -1;
|
||||
++s1;
|
||||
@ -77,8 +77,8 @@ WMEMCMP (s1, s2, n)
|
||||
}
|
||||
if (n > 0)
|
||||
{
|
||||
c1 = (wint_t) s1[0];
|
||||
c2 = (wint_t) s2[0];
|
||||
c1 = s1[0];
|
||||
c2 = s2[0];
|
||||
if (c1 - c2 != 0)
|
||||
return c1 > c2 ? 1 : -1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user