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.

80 lines
2.0 KiB

  1. /***
  2. *mbscoll.c - Collate MBCS strings
  3. *
  4. * Copyright (c) 1994-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * Collate MBCS strings
  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-06-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 <string.h>
  28. #include <mbstring.h>
  29. /***
  30. * _mbscoll - Collate MBCS strings
  31. *
  32. *Purpose:
  33. * Collates two strings for lexical order. Strings
  34. * are collated on a character basis, not a byte basis.
  35. *
  36. *Entry:
  37. * char *s1, *s2 = strings to collate
  38. *
  39. *Exit:
  40. * returns <0 if s1 < s2
  41. * returns 0 if s1 == s2
  42. * returns >0 if s1 > s2
  43. *
  44. *Exceptions:
  45. *
  46. *******************************************************************************/
  47. int __cdecl _mbscoll(
  48. const unsigned char *s1,
  49. const unsigned char *s2
  50. )
  51. {
  52. #if defined(_POSIX_)
  53. return _mbscmp(s1, s2);
  54. #else
  55. int ret;
  56. #ifdef _MT
  57. pthreadmbcinfo ptmbci = _getptd()->ptmbcinfo;
  58. if ( ptmbci != __ptmbcinfo )
  59. ptmbci = __updatetmbcinfo();
  60. if (0 == (ret = __crtCompareStringA( ptmbci->mblcid, 0, s1, -1, s2, -1,
  61. ptmbci->mbcodepage )))
  62. #else
  63. if (0 == (ret = __crtCompareStringA( __mblcid, 0, s1, -1, s2, -1,
  64. __mbcodepage )))
  65. #endif
  66. return _NLSCMPERROR;
  67. return ret - 2;
  68. #endif /* _POSIX_ */
  69. }
  70. #endif /* _MBCS */