wcscmp.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /* Copyright (C) 1995-2019 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, see
  14. <http://www.gnu.org/licenses/>. */
  15. #include <wchar.h>
  16. #ifndef WCSCMP
  17. # define WCSCMP __wcscmp
  18. #endif
  19. /* Compare S1 and S2, returning less than, equal to or
  20. greater than zero if S1 is lexicographically less than,
  21. equal to or greater than S2. */
  22. int
  23. WCSCMP (const wchar_t *s1, const wchar_t *s2)
  24. {
  25. wchar_t c1, c2;
  26. do
  27. {
  28. c1 = *s1++;
  29. c2 = *s2++;
  30. if (c2 == L'\0')
  31. return c1 - c2;
  32. }
  33. while (c1 == c2);
  34. return c1 < c2 ? -1 : 1;
  35. }
  36. libc_hidden_def (WCSCMP)
  37. weak_alias (WCSCMP, wcscmp)