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.

57 lines
1.3 KiB

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