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.

65 lines
1.6 KiB

  1. /***
  2. *wcscmp.c - routine to compare two wchar_t strings (for equal, less, or greater)
  3. *
  4. * Copyright (c) 1985-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * Compares two wide-character strings, determining their lexical order.
  8. *
  9. *Revision History:
  10. * 09-09-91 ETC Created from strcmp.c.
  11. * 04-07-92 KRS Updated and ripped out _INTL switches.
  12. * 04-06-93 SKS Replace _CRTAPI* with __cdecl
  13. * 02-07-94 CFW POSIXify.
  14. *
  15. *******************************************************************************/
  16. #ifndef _POSIX_
  17. #include <cruntime.h>
  18. #include <string.h>
  19. /***
  20. *wcscmp - compare two wchar_t strings,
  21. * returning less than, equal to, or greater than
  22. *
  23. *Purpose:
  24. * wcscmp compares two wide-character strings and returns an integer
  25. * to indicate whether the first is less than the second, the two are
  26. * equal, or whether the first is greater than the second.
  27. *
  28. * Comparison is done wchar_t by wchar_t on an UNSIGNED basis, which is to
  29. * say that Null wchar_t(0) is less than any other character.
  30. *
  31. *Entry:
  32. * const wchar_t * src - string for left-hand side of comparison
  33. * const wchar_t * dst - string for right-hand side of comparison
  34. *
  35. *Exit:
  36. * returns -1 if src < dst
  37. * returns 0 if src == dst
  38. * returns +1 if src > dst
  39. *
  40. *Exceptions:
  41. *
  42. *******************************************************************************/
  43. int __cdecl wcscmp (
  44. const wchar_t * src,
  45. const wchar_t * dst
  46. )
  47. {
  48. int ret = 0 ;
  49. while( ! (ret = (int)(*src - *dst)) && *dst)
  50. ++src, ++dst;
  51. if ( ret < 0 )
  52. ret = -1 ;
  53. else if ( ret > 0 )
  54. ret = 1 ;
  55. return( ret );
  56. }
  57. #endif /* _POSIX_ */