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.

59 lines
1.5 KiB

  1. /***
  2. *wcscmp.c - routine to compare two wchar_t strings (for equal, less, or greater)
  3. *
  4. * Copyright (c) 1985-1992, 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. *
  13. *******************************************************************************/
  14. #include <cruntime.h>
  15. #include <string.h>
  16. /***
  17. *wcscmp - compare two wchar_t strings,
  18. * returning less than, equal to, or greater than
  19. *
  20. *Purpose:
  21. * wcscmp compares two wide-character strings and returns an integer
  22. * to indicate whether the first is less than the second, the two are
  23. * equal, or whether the first is greater than the second.
  24. *
  25. * Comparison is done wchar_t by wchar_t on an UNSIGNED basis, which is to
  26. * say that Null wchar_t(0) is less than any other character.
  27. *
  28. *Entry:
  29. * const wchar_t * src - string for left-hand side of comparison
  30. * const wchar_t * dst - string for right-hand side of comparison
  31. *
  32. *Exit:
  33. * returns -1 if src < dst
  34. * returns 0 if src == dst
  35. * returns +1 if src > dst
  36. *
  37. *Exceptions:
  38. *
  39. *******************************************************************************/
  40. int _CALLTYPE1 wcscmp (
  41. const wchar_t * src,
  42. const wchar_t * dst
  43. )
  44. {
  45. int ret = 0 ;
  46. while( ! (ret = (int)(*src - *dst)) && *dst)
  47. ++src, ++dst;
  48. if ( ret < 0 )
  49. ret = -1 ;
  50. else if ( ret > 0 )
  51. ret = 1 ;
  52. return( ret );
  53. }