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.

97 lines
2.6 KiB

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