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.

132 lines
3.5 KiB

  1. /***
  2. *mbsupr.c - Convert string upper case (MBCS)
  3. *
  4. * Copyright (c) 1985-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * Convert string upper 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-06-93 GJF Replaced _CRTAPI1 with __cdecl.
  13. * 04-12-94 CFW Make function generic.
  14. * 04-15-93 CFW Add _MB_CP_LOCK.
  15. * 05-16-94 CFW Use _mbbtolower/upper.
  16. * 05-17-94 CFW Enable non-Win32.
  17. * 03-13-95 JCF Add (unsigned char) in _MB* compare with *(cp+1).
  18. * 05-31-95 CFW Fix horrible Mac bug.
  19. * 03-17-97 RDK Added error flag to __crtLCMapStringA.
  20. * 09-26-97 BWT Fix POSIX
  21. * 04-21-98 GJF Revised multithread support based on threadmbcinfo
  22. * structs
  23. * 05-17-99 PML Remove all Macintosh support.
  24. *
  25. *******************************************************************************/
  26. #ifdef _MBCS
  27. #include <awint.h>
  28. #include <mtdll.h>
  29. #include <cruntime.h>
  30. #include <ctype.h>
  31. #include <mbdata.h>
  32. #include <mbstring.h>
  33. #include <mbctype.h>
  34. /***
  35. * _mbsupr - Convert string upper case (MBCS)
  36. *
  37. *Purpose:
  38. * Converts all the lower case characters in a string
  39. * to upper case in place. Handles MBCS chars correctly.
  40. *
  41. *Entry:
  42. * unsigned char *string = pointer to string
  43. *
  44. *Exit:
  45. * Returns a pointer to the input string; no error return.
  46. *
  47. *Exceptions:
  48. *
  49. *******************************************************************************/
  50. unsigned char * __cdecl _mbsupr(
  51. unsigned char *string
  52. )
  53. {
  54. unsigned char *cp;
  55. #ifdef _MT
  56. pthreadmbcinfo ptmbci = _getptd()->ptmbcinfo;
  57. if ( ptmbci != __ptmbcinfo )
  58. ptmbci = __updatetmbcinfo();
  59. #endif
  60. for (cp=string; *cp; cp++)
  61. {
  62. #ifdef _MT
  63. if ( __ismbblead_mt(ptmbci, *cp) )
  64. #else
  65. if ( _ismbblead(*cp) )
  66. #endif
  67. {
  68. #if !defined(_POSIX_)
  69. int retval;
  70. unsigned char ret[4];
  71. #ifdef _MT
  72. if ( (retval = __crtLCMapStringA( ptmbci->mblcid,
  73. #else
  74. if ( (retval = __crtLCMapStringA( __mblcid,
  75. #endif
  76. LCMAP_UPPERCASE,
  77. cp,
  78. 2,
  79. ret,
  80. 2,
  81. #ifdef _MT
  82. ptmbci->mbcodepage,
  83. #else
  84. __mbcodepage,
  85. #endif
  86. TRUE )) == 0 )
  87. return NULL;
  88. *cp = ret[0];
  89. if (retval > 1)
  90. *(++cp) = ret[1];
  91. #else /* !_POSIX_ */
  92. int mbval = ((*cp) << 8) + *(cp+1);
  93. cp++;
  94. if ( mbval >= _MBLOWERLOW1
  95. && mbval <= _MBLOWERHIGH1 )
  96. *cp -= _MBCASEDIFF1;
  97. else if (mbval >= _MBLOWERLOW2
  98. && mbval <= _MBLOWERHIGH2 )
  99. *cp -= _MBCASEDIFF2;
  100. #endif /* !_POSIX_ */
  101. }
  102. else
  103. /* single byte, macro version */
  104. #ifdef _MT
  105. *cp = (unsigned char) __mbbtoupper_mt(ptmbci, *cp);
  106. #else
  107. *cp = (unsigned char) _mbbtoupper(*cp);
  108. #endif
  109. }
  110. return string ;
  111. }
  112. #endif /* _MBCS */