strcmp.c 809 B

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