strcmp.c 959 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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 Wstrcmp wcscmp
  11. #else
  12. # define __Wstrcmp __strcmp
  13. # define Wstrcmp strcmp
  14. #endif
  15. int attribute_hidden __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. strong_alias(__Wstrcmp,Wstrcmp)
  33. #ifndef __UCLIBC_HAS_LOCALE__
  34. # ifdef WANT_WIDE
  35. hidden_strong_alias(__wcscmp,__wcscoll)
  36. strong_alias(__wcscmp,wcscoll)
  37. # else
  38. hidden_strong_alias(__strcmp,__strcoll)
  39. strong_alias(__strcmp,strcoll)
  40. # endif
  41. #endif