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.

103 lines
2.9 KiB

  1. /***
  2. *wcsicmp.c - contains case-insensitive wide string comp routine _wcsicmp
  3. *
  4. * Copyright (c) 1985-2001, 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. * 04-06-93 SKS Replace _CRTAPI* with __cdecl
  18. * 04-14-93 CFW Remove locale-sensitive portion.
  19. * 02-07-94 CFW POSIXify.
  20. * 10-25-94 GJF Now works in non-C locales.
  21. * 09-26-95 GJF New locking macro, and scheme, for functions which
  22. * reference the locale.
  23. * 10-11-95 BWT Fix NTSUBSET
  24. * 08-27-98 GJF Revised multithread support based on threadlocinfo
  25. * struct.
  26. *
  27. *******************************************************************************/
  28. #ifndef _POSIX_
  29. #include <cruntime.h>
  30. #include <setlocal.h>
  31. #include <string.h>
  32. #include <locale.h>
  33. #include <ctype.h>
  34. #include <setlocal.h>
  35. #include <mtdll.h>
  36. /***
  37. *int _wcsicmp(dst, src) - compare wide-character strings, ignore case
  38. *
  39. *Purpose:
  40. * _wcsicmp perform a case-insensitive wchar_t string comparision.
  41. * _wcsicmp is independent of locale.
  42. *
  43. *Entry:
  44. * wchar_t *dst, *src - strings to compare
  45. *
  46. *Return:
  47. * <0 if dst < src
  48. * 0 if dst = src
  49. * >0 if dst > src
  50. * This range of return values may differ from other *cmp/*coll functions.
  51. *
  52. *Exceptions:
  53. *
  54. *******************************************************************************/
  55. int __cdecl _wcsicmp (
  56. const wchar_t * dst,
  57. const wchar_t * src
  58. )
  59. {
  60. wchar_t f,l;
  61. #ifdef _MT
  62. pthreadlocinfo ptloci = _getptd()->ptlocinfo;
  63. if ( ptloci != __ptlocinfo )
  64. ptloci = __updatetlocinfo();
  65. #endif
  66. #ifndef _NTSUBSET_
  67. #ifdef _MT
  68. if ( ptloci->lc_handle[LC_CTYPE] == _CLOCALEHANDLE ) {
  69. #else
  70. if ( __lc_handle[LC_CTYPE] == _CLOCALEHANDLE ) {
  71. #endif
  72. #endif /* _NTSUBSET_ */
  73. do {
  74. f = __ascii_towlower(*dst);
  75. l = __ascii_towlower(*src);
  76. dst++;
  77. src++;
  78. } while ( (f) && (f == l) );
  79. #ifndef _NTSUBSET_
  80. }
  81. else {
  82. do {
  83. #ifdef _MT
  84. f = __towlower_mt( ptloci, (unsigned short)(*(dst++)) );
  85. l = __towlower_mt( ptloci, (unsigned short)(*(src++)) );
  86. #else
  87. f = towlower( (unsigned short)(*(dst++)) );
  88. l = towlower( (unsigned short)(*(src++)) );
  89. #endif
  90. } while ( (f) && (f == l) );
  91. }
  92. #endif /* _NTSUBSET_ */
  93. return (int)(f - l);
  94. }
  95. #endif /* _POSIX_ */