Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.5 KiB

  1. /***
  2. *wcscmp.c - routine to compare 2 wide character strings (equal/less/greater)
  3. *
  4. * Copyright (c) 1985-1988, Microsoft Corporation. All Rights Reserved.
  5. *
  6. *Purpose:
  7. * Compares two wide character strings, determining their lexical order.
  8. *
  9. *Revision History:
  10. * 04-07-91 IanJa C version created.
  11. *
  12. *******************************************************************************/
  13. #include <stdlib.h>
  14. /***
  15. *wcscmp - compare two wide character strings, returning less than, equal to,
  16. * or greater than
  17. *
  18. *Purpose:
  19. * WCSCMP compares two wide character strings and returns an integer
  20. * to indicate whether the first is less than the second, the two are
  21. * equal, or whether the first is greater than the second.
  22. *
  23. * Comparison is done byte by byte on an UNSIGNED basis, which is to
  24. * say that Null (0) is less than any other character (1-0xffff).
  25. *
  26. *Entry:
  27. * const wchar_t * src - string for left-hand side of comparison
  28. * const wchar_t * dst - string for right-hand side of comparison
  29. *
  30. *Exit:
  31. * returns -1 if src < dst
  32. * returns 0 if src == dst
  33. * returns +1 if src > dst
  34. *
  35. *Exceptions:
  36. *
  37. *******************************************************************************/
  38. int __cdecl wcscmp(const wchar_t * src, const wchar_t * dst)
  39. {
  40. int ret = 0 ;
  41. while( ! (ret = *src - *dst) && *dst)
  42. ++src, ++dst;
  43. if ( ret < 0 )
  44. ret = -1 ;
  45. else if ( ret > 0 )
  46. ret = 1 ;
  47. return ret;
  48. }