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.

91 lines
2.3 KiB

  1. /***
  2. *wcsicmp.c - contains case-insensitive wide string comp routine _wcsicmp
  3. *
  4. * Copyright (c) 1985-1992, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * contains _wcsicmp()
  8. *
  9. *Revision History:
  10. * 09-09-91 ETC Created from stricmp.c.
  11. * 12-09-91 ETC Use C for neutral locale.
  12. * 04-07-92 KRS Updated and ripped out _INTL switches.
  13. * 08-19-92 KRS Actived use of CompareStringW.
  14. * 08-22-92 SRW Allow INTL definition to be conditional for building ntcrt.lib
  15. * 09-02-92 SRW Get _INTL definition via ..\crt32.def
  16. * 12-15-92 KRS Added robustness to non-_INTL code. Optimize.
  17. * 06-02-93 SRW ignore _INTL if _NTSUBSET_ defined.
  18. *
  19. *******************************************************************************/
  20. #include <windows.h>
  21. #include <cruntime.h>
  22. #include <string.h>
  23. #include <locale.h>
  24. #include <ctype.h>
  25. #include <setlocal.h>
  26. #include <os2dll.h>
  27. /***
  28. *int _wcsicmp(dst, src) - compare wide-character strings, ignore case
  29. *
  30. *Purpose:
  31. * _wcsicmp perform a case-insensitive wchar_t string comparision.
  32. * _wcsicmp is independent of locale.
  33. *
  34. * *** NOTE: the comparison should be done in a neutral locale,
  35. * provided by the NLSAPI. ****
  36. *
  37. *Entry:
  38. * wchar_t *dst, *src - strings to compare
  39. *
  40. *Return:
  41. * <0 if dst < src
  42. * 0 if dst = src
  43. * >0 if dst > src
  44. * This range of return values may differ from other *cmp/*coll functions.
  45. *
  46. *Exceptions:
  47. *
  48. *******************************************************************************/
  49. int _CALLTYPE1 _wcsicmp (
  50. const wchar_t * dst,
  51. const wchar_t * src
  52. )
  53. {
  54. wchar_t f,l;
  55. int ret;
  56. #if defined(_INTL) && !defined(_NTSUBSET_)
  57. /* _mlock (_LC_CTYPE_LOCK); */
  58. if ((_lc_handle[LC_CTYPE] == _CLOCALEHANDLE) &&
  59. (_lc_codepage == _CLOCALECP))
  60. {
  61. #endif /* _INTL */
  62. do {
  63. f = ((*dst <= L'Z') && (*dst >= L'A'))
  64. ? *dst + ((wchar_t)(L'a' - L'A'))
  65. : *dst;
  66. l = ((*src <= L'Z') && (*src >= L'A'))
  67. ? *src + ((wchar_t)(L'a' - L'A'))
  68. : *src;
  69. dst++;
  70. src++;
  71. } while ((f) && (f == l));
  72. ret = (int)((unsigned int)f - (unsigned int)l);
  73. #if defined(_INTL) && !defined(_NTSUBSET_)
  74. }
  75. else
  76. {
  77. ret = CompareStringW(LANG_NEUTRAL,NORM_IGNORECASE,dst,-1,src,-1);
  78. /* map return into normal CMP area (-1,0, 1 or ERROR) */
  79. ret = (ret) ? (ret-2) : NLSCMPERROR;
  80. }
  81. /* _munlock (_LC_CTYPE_LOCK); */
  82. #endif /* _INTL */
  83. return ret;
  84. }