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 Wstrcmp wcscmp |
| 12 | # define Wstrcoll wcscoll |
| 13 | #else |
| 14 | # define Wstrcmp strcmp |
| 15 | # define Wstrcoll strcoll |
| 16 | #endif |
| 17 | |
| 18 | int Wstrcmp(register const Wchar *s1, register const Wchar *s2) |
| 19 | { |
| 20 | #ifdef WANT_WIDE |
| 21 | while (*((Wuchar *)s1) == *((Wuchar *)s2)) { |
| 22 | if (!*s1++) { |
| 23 | return 0; |
| 24 | } |
| 25 | ++s2; |
| 26 | } |
| 27 | |
| 28 | return (*((Wuchar *)s1) < *((Wuchar *)s2)) ? -1 : 1; |
| 29 | #else |
| 30 | int r; |
| 31 | |
| 32 | while (((r = ((int)(*((Wuchar *)s1))) - *((Wuchar *)s2++)) |
| 33 | == 0) && *s1++); |
| 34 | |
| 35 | return r; |
| 36 | #endif |
| 37 | } |
| 38 | libc_hidden_def(Wstrcmp) |
| 39 | |
| 40 | #ifndef __UCLIBC_HAS_LOCALE__ |
| 41 | strong_alias(Wstrcmp,Wstrcoll) |
| 42 | libc_hidden_def(Wstrcoll) |
| 43 | #endif |