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.

51 lines
1.1 KiB

  1. /*++
  2. Copyright (c) 1995-2002 Microsoft Corporation
  3. Module Name:
  4. clstrcmp.h
  5. Abstract:
  6. Replacement for wcsicmp and wcscmp that do not
  7. compare international strings correctly without
  8. resetting the locale first.
  9. We could have used lstrcmpi, but it doesn't have
  10. a corresponding "n" version.
  11. Author:
  12. GorN 20-May-2002
  13. Revision History:
  14. --*/
  15. #ifndef _CLSTRCMP_INCLUDED_
  16. #define _CLSTRCMP_INCLUDED_
  17. //
  18. // Proper case insensitive compare
  19. //
  20. __inline int ClRtlStrICmp(LPCWSTR stra, LPCWSTR strb)
  21. {
  22. return CompareStringW(LOCALE_SYSTEM_DEFAULT, NORM_IGNORECASE,
  23. stra, -1, strb, -1) - CSTR_EQUAL; // CSTR_LT < CSTR_EQUAL < CSTR_GT
  24. }
  25. //
  26. // Proper case insensitive compare
  27. //
  28. __inline int ClRtlStrNICmp(LPCWSTR stra, LPCWSTR strb, size_t n)
  29. {
  30. size_t i;
  31. for (i = 0; i < n; ++i)
  32. if (stra[i] == 0 || strb[i] == 0) {n = i+1; break;}
  33. return CompareStringW(LOCALE_SYSTEM_DEFAULT, NORM_IGNORECASE,
  34. stra, (int)n, strb, (int)n) - CSTR_EQUAL; // CSTR_LT < CSTR_EQUAL < CSTR_GT
  35. }
  36. #endif