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.

131 lines
3.4 KiB

  1. /***
  2. *ismblwr - Test if character is lower case (MBCS)
  3. *
  4. * Copyright (c) 1985-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * Test if character is lower case (MBCS)
  8. *
  9. *Revision History:
  10. * 11-19-92 KRS Ported from 16-bit sources.
  11. * 09-29-93 CFW Merge _KANJI and _MBCS_OS
  12. * 10-05-93 GJF Replaced _CRTAPI1 with __cdecl.
  13. * 04-12-94 CFW Make function generic.
  14. * 04-29-94 CFW Place c in char array.
  15. * 05-17-94 CFW Enable non-Win32.
  16. * 03-16-97 RDK Added error flag to __crtGetStringTypeA.
  17. * 09-11-97 GJF Replaced __mbcodepage == 0 with _ISNOTMBCP.
  18. * 09-26-97 BWT Fix POSIX
  19. * 04-01-98 GJF Implemented multithread support based on threadmbcinfo
  20. * structs
  21. * 05-17-99 PML Remove all Macintosh support.
  22. *
  23. *******************************************************************************/
  24. #ifdef _MBCS
  25. #if !defined(_POSIX_)
  26. #include <windows.h>
  27. #include <awint.h>
  28. #endif /* !_POSIX_ */
  29. #include <mtdll.h>
  30. #include <cruntime.h>
  31. #include <ctype.h>
  32. #include <mbdata.h>
  33. #include <mbctype.h>
  34. #include <mbstring.h>
  35. /***
  36. * _ismbclower - Test if character is lower case (MBCS)
  37. *
  38. *Purpose:
  39. * Test if the supplied character is lower case or not.
  40. * Handles MBCS characters correctly.
  41. *
  42. * Note: Use test against 0x00FF instead of _ISLEADBYTE
  43. * to ensure that we don't call SBCS routine with a two-byte
  44. * value.
  45. *
  46. *Entry:
  47. * unsigned int c = character to test
  48. *
  49. *Exit:
  50. * returns TRUE if character is lower case, else FALSE
  51. *
  52. *Exceptions:
  53. *
  54. *******************************************************************************/
  55. int __cdecl _ismbclower(
  56. unsigned int c
  57. )
  58. {
  59. #ifdef _MT
  60. pthreadmbcinfo ptmbci = _getptd()->ptmbcinfo;
  61. if ( ptmbci != __ptmbcinfo )
  62. ptmbci = __updatetmbcinfo();
  63. #endif
  64. if (c > 0x00FF)
  65. {
  66. #if !defined(_POSIX_)
  67. char buf[2];
  68. unsigned short ctype[2] = {0};
  69. buf[0] = (c >> 8) & 0xFF;
  70. buf[1] = c & 0xFF;
  71. /* return FALSE if not in supported MB code page */
  72. #ifdef _MT
  73. if ( _ISNOTMBCP_MT(ptmbci) )
  74. #else
  75. if ( _ISNOTMBCP )
  76. #endif
  77. return 0;
  78. /*
  79. * Since 'c' could be two one-byte MB chars, we need room
  80. * in the ctype return array to handle this. In this case,
  81. * the second word in the return array will be nonzero.
  82. */
  83. if ( __crtGetStringTypeA( CT_CTYPE1,
  84. buf,
  85. 2,
  86. ctype,
  87. #ifdef _MT
  88. ptmbci->mbcodepage,
  89. ptmbci->mblcid,
  90. #else
  91. __mbcodepage,
  92. __mblcid,
  93. #endif
  94. TRUE ) == 0 )
  95. return 0;
  96. /* ensure single MB character and test for type */
  97. return (ctype[1] == 0 && ctype[0] & (_LOWER));
  98. #else /* !_POSIX_ */
  99. return (c >= _MBLOWERLOW1 && c <= _MBLOWERHIGH1 ||
  100. c >= _MBLOWERLOW2 && c <= _MBLOWERHIGH2);
  101. #endif /* !_POSIX_ */
  102. }
  103. else
  104. #ifdef _MT
  105. return __mbbislower_mt(ptmbci, c);
  106. #else
  107. return _mbbislower(c);
  108. #endif
  109. }
  110. #endif /* _MBCS */