strcmp.c 866 B

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