Leaked source code of windows server 2003
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.

70 lines
1.7 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. #if defined(_M_IA64)
  20. #pragma warning(disable:4163)
  21. #pragma function(wcscmp)
  22. #endif
  23. /***
  24. *wcscmp - compare two wchar_t strings,
  25. * returning less than, equal to, or greater than
  26. *
  27. *Purpose:
  28. * wcscmp compares two wide-character strings and returns an integer
  29. * to indicate whether the first is less than the second, the two are
  30. * equal, or whether the first is greater than the second.
  31. *
  32. * Comparison is done wchar_t by wchar_t on an UNSIGNED basis, which is to
  33. * say that Null wchar_t(0) is less than any other character.
  34. *
  35. *Entry:
  36. * const wchar_t * src - string for left-hand side of comparison
  37. * const wchar_t * dst - string for right-hand side of comparison
  38. *
  39. *Exit:
  40. * returns -1 if src < dst
  41. * returns 0 if src == dst
  42. * returns +1 if src > dst
  43. *
  44. *Exceptions:
  45. *
  46. *******************************************************************************/
  47. int __cdecl wcscmp (
  48. const wchar_t * src,
  49. const wchar_t * dst
  50. )
  51. {
  52. int ret = 0 ;
  53. while( ! (ret = (int)(*src - *dst)) && *dst)
  54. ++src, ++dst;
  55. if ( ret < 0 )
  56. ret = -1 ;
  57. else if ( ret > 0 )
  58. ret = 1 ;
  59. return( ret );
  60. }
  61. #endif /* _POSIX_ */