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.

80 lines
2.1 KiB

  1. /***
  2. *mbsicoll.c - Collate MBCS strings, ignoring case
  3. *
  4. * Copyright (c) 1994-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * Collate MBCS strings, ignoring case
  8. *
  9. *Revision History:
  10. * 05-12-94 CFW Module created from mbs*cmp.c
  11. * 06-03-94 CFW Allow non-_INTL.
  12. * 09-06-94 CFW Allow non-_WIN32!.
  13. * 12-21-94 CFW Remove fcntrlcomp NT 3.1 hack.
  14. * 09-26-97 BWT Fix POSIX
  15. * 04-07-98 GJF Implemented multithread support based on threadmbcinfo
  16. * structs
  17. * 05-17-99 PML Remove all Macintosh support.
  18. *
  19. *******************************************************************************/
  20. #ifdef _MBCS
  21. #include <awint.h>
  22. #include <mtdll.h>
  23. #include <cruntime.h>
  24. #include <internal.h>
  25. #include <mbdata.h>
  26. #include <mbctype.h>
  27. #include <mbstring.h>
  28. /***
  29. * _mbsicoll - Collate MBCS strings, ignoring case
  30. *
  31. *Purpose:
  32. * Collates two strings for lexical order. Strings
  33. * are collated on a character basis, not a byte basis.
  34. *
  35. *Entry:
  36. * char *s1, *s2 = strings to collate
  37. *
  38. *Exit:
  39. * returns <0 if s1 < s2
  40. * returns 0 if s1 == s2
  41. * returns >0 if s1 > s2
  42. *
  43. *Exceptions:
  44. *
  45. *******************************************************************************/
  46. int __cdecl _mbsicoll(
  47. const unsigned char *s1,
  48. const unsigned char *s2
  49. )
  50. {
  51. #if defined(_POSIX_)
  52. return _mbsicmp(s1, s2);
  53. #else
  54. int ret;
  55. #ifdef _MT
  56. pthreadmbcinfo ptmbci = _getptd()->ptmbcinfo;
  57. if ( ptmbci != __ptmbcinfo )
  58. ptmbci = __updatetmbcinfo();
  59. if ( 0 == (ret = __crtCompareStringA( ptmbci->mblcid, NORM_IGNORECASE,
  60. s1, -1, s2, -1,
  61. ptmbci->mbcodepage )) )
  62. #else
  63. if ( 0 == (ret = __crtCompareStringA( __mblcid, NORM_IGNORECASE,
  64. s1, -1, s2, -1,
  65. __mbcodepage )) )
  66. #endif
  67. return _NLSCMPERROR;
  68. return ret - 2;
  69. #endif /* _POSIX_ */
  70. }
  71. #endif /* _MBCS */