]> git.ipfire.org Git - thirdparty/glibc.git/blame - wcsmbs/wmemcmp.c
Update copyright notices with scripts/update-copyrights
[thirdparty/glibc.git] / wcsmbs / wmemcmp.c
CommitLineData
d4697bc9 1/* Copyright (C) 1996-2014 Free Software Foundation, Inc.
33a934a3
UD
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996.
30de3b18 4
33a934a3 5 The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
30de3b18 9
33a934a3
UD
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
41bdb6e2 13 Lesser General Public License for more details.
30de3b18 14
41bdb6e2 15 You should have received a copy of the GNU Lesser General Public
59ba27a6
PE
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
30de3b18
RM
18
19#include <wchar.h>
20
be13f7bf 21#ifndef WMEMCMP
b468825a 22# define WMEMCMP wmemcmp
be13f7bf 23#endif
30de3b18
RM
24
25int
be13f7bf 26WMEMCMP (s1, s2, n)
30de3b18
RM
27 const wchar_t *s1;
28 const wchar_t *s2;
29 size_t n;
30{
2e09a79a
JM
31 wchar_t c1;
32 wchar_t c2;
30de3b18
RM
33
34 while (n >= 4)
35 {
1f1e1947
AS
36 c1 = s1[0];
37 c2 = s2[0];
30de3b18 38 if (c1 - c2 != 0)
be13f7bf 39 return c1 > c2 ? 1 : -1;
1f1e1947
AS
40 c1 = s1[1];
41 c2 = s2[1];
30de3b18 42 if (c1 - c2 != 0)
be13f7bf 43 return c1 > c2 ? 1 : -1;
1f1e1947
AS
44 c1 = s1[2];
45 c2 = s2[2];
30de3b18 46 if (c1 - c2 != 0)
be13f7bf 47 return c1 > c2 ? 1 : -1;
1f1e1947
AS
48 c1 = s1[3];
49 c2 = s2[3];
30de3b18 50 if (c1 - c2 != 0)
be13f7bf 51 return c1 > c2 ? 1 : -1;
30de3b18
RM
52 s1 += 4;
53 s2 += 4;
54 n -= 4;
55 }
56
57 if (n > 0)
58 {
1f1e1947
AS
59 c1 = s1[0];
60 c2 = s2[0];
30de3b18 61 if (c1 - c2 != 0)
be13f7bf 62 return c1 > c2 ? 1 : -1;
30de3b18
RM
63 ++s1;
64 ++s2;
65 --n;
66 }
67 if (n > 0)
68 {
1f1e1947
AS
69 c1 = s1[0];
70 c2 = s2[0];
30de3b18 71 if (c1 - c2 != 0)
be13f7bf 72 return c1 > c2 ? 1 : -1;
30de3b18
RM
73 ++s1;
74 ++s2;
75 --n;
76 }
77 if (n > 0)
78 {
1f1e1947
AS
79 c1 = s1[0];
80 c2 = s2[0];
30de3b18 81 if (c1 - c2 != 0)
be13f7bf 82 return c1 > c2 ? 1 : -1;
30de3b18
RM
83 }
84
85 return 0;
86}