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.

63 lines
1.5 KiB

  1. /***
  2. *wcsncmp.c - compare first n characters of two wide-character strings
  3. *
  4. * Copyright (c) 1985-2001, 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. * 04-06-93 SKS Replace _CRTAPI* with __cdecl
  14. * 02-07-94 CFW POSIXify.
  15. *
  16. *******************************************************************************/
  17. #ifndef _POSIX_
  18. #include <cruntime.h>
  19. #include <string.h>
  20. /***
  21. *int wcsncmp(first, last, count) - compare first count chars of wchar_t strings
  22. *
  23. *Purpose:
  24. * Compares two strings for lexical order. The comparison stops
  25. * after: (1) a difference between the strings is found, (2) the end
  26. * of the strings is reached, or (3) count characters have been
  27. * compared (wide-character strings).
  28. *
  29. *Entry:
  30. * wchar_t *first, *last - strings to compare
  31. * size_t count - maximum number of characters to compare
  32. *
  33. *Exit:
  34. * returns <0 if first < last
  35. * returns 0 if first == last
  36. * returns >0 if first > last
  37. *
  38. *Exceptions:
  39. *
  40. *******************************************************************************/
  41. int __cdecl wcsncmp (
  42. const wchar_t * first,
  43. const wchar_t * last,
  44. size_t count
  45. )
  46. {
  47. if (!count)
  48. return(0);
  49. while (--count && *first && *first == *last)
  50. {
  51. first++;
  52. last++;
  53. }
  54. return((int)(*first - *last));
  55. }
  56. #endif /* _POSIX_ */