lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2002 Manuel Novoa III |
| 3 | * Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org> |
| 4 | * |
| 5 | * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. |
| 6 | */ |
| 7 | |
| 8 | #include "_string.h" |
| 9 | |
| 10 | #ifdef WANT_WIDE |
| 11 | # define Wmemcmp wmemcmp |
| 12 | #else |
| 13 | # define Wmemcmp memcmp |
| 14 | #endif |
| 15 | |
| 16 | int Wmemcmp(const Wvoid *s1, const Wvoid *s2, size_t n) |
| 17 | { |
| 18 | register const Wuchar *r1 = (const Wuchar *) s1; |
| 19 | register const Wuchar *r2 = (const Wuchar *) s2; |
| 20 | |
| 21 | #ifdef WANT_WIDE |
| 22 | while (n && (*r1 == *r2)) { |
| 23 | ++r1; |
| 24 | ++r2; |
| 25 | --n; |
| 26 | } |
| 27 | |
| 28 | return (n == 0) ? 0 : ((*r1 < *r2) ? -1 : 1); |
| 29 | #else |
| 30 | int r = 0; |
| 31 | |
| 32 | while (n-- && ((r = ((int)(*r1++)) - *r2++) == 0)); |
| 33 | |
| 34 | return r; |
| 35 | #endif |
| 36 | } |
| 37 | |
| 38 | #ifndef WANT_WIDE |
| 39 | libc_hidden_def(memcmp) |
| 40 | # ifdef __UCLIBC_SUSV3_LEGACY__ |
| 41 | strong_alias(memcmp,bcmp) |
| 42 | # endif |
| 43 | #endif |