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.

52 lines
1.4 KiB

  1. /***
  2. *wcsncmp.c - compare first n characters of two wide character strings
  3. *
  4. * Copyright (c) 1985-1988, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * defines wcsncmp() - compare first n characters of two wide character
  8. * strings for lexical order.
  9. *
  10. *Revision History:
  11. * 04-07-91 IanJa C version created.
  12. *
  13. *******************************************************************************/
  14. #include <stdlib.h>
  15. /***
  16. *int wcsncmp(first, last, count) - compare first count wide characters of wide
  17. * character strings
  18. *
  19. *Purpose:
  20. * Compares two wide character strings for lexical order. The comparison
  21. * stops after: (1) a difference between the strings is found, (2) the end
  22. * of the strings is reached, or (3) count characters have been
  23. * compared.
  24. *
  25. *Entry:
  26. * char *first, *last - wide character strings to compare
  27. * unsigned count - maximum number of wide characters to compare
  28. *
  29. *Exit:
  30. * returns <0 if first < last
  31. * returns 0 if first == last
  32. * returns >0 if first > last
  33. *
  34. *Exceptions:
  35. *
  36. *******************************************************************************/
  37. int __cdecl wcsncmp(const wchar_t * first, const wchar_t * last, size_t count)
  38. {
  39. if (!count)
  40. return 0;
  41. while (--count && *first && *first == *last)
  42. {
  43. first++;
  44. last++;
  45. }
  46. return *first - *last;
  47. }