summaryrefslogtreecommitdiffstats
path: root/private/crt32/mbstring/mbsupr.c
blob: 36032c1b1eb292eb8e90ac83d757f5a63669e268 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*** 
*mbsupr.c - Convert string upper case (MBCS)
*
*	Copyright (c) 1985-1992, Microsoft Corporation.  All rights reserved.
*
*Purpose:
*	Convert string upper case (MBCS)
*
*Revision History:
*	11-19-92  KRS	Ported from 16-bit sources.
*
*******************************************************************************/

#ifdef _MBCS
#include <cruntime.h>
#include <ctype.h>
#include <mbdata.h>
#include <mbstring.h>
#include <mbctype.h>


/***
* _mbsupr - Convert string upper case (MBCS)
*
*Purpose:
*	Converts all the lower case characters in a string
*	to upper case in place.   Handles MBCS chars correctly.
*
*Entry:
*	unsigned char *string = pointer to string
*
*Exit:
*	Returns a pointer to the input string; no error return.
*
*Exceptions:
*
*******************************************************************************/

unsigned char * _CRTAPI1 _mbsupr( string )
unsigned char *string;
{
	unsigned char *cp;

	for (cp=string; *cp; cp++) {

		if (_ISLEADBYTE(*cp)) {

#ifdef _MBCS_OS
			cp++;		/* bump pointer */
#else
			if ((_mbascii) && (*cp == _MBASCIILEAD)) {

			    if (   (*(cp+1) >= (_MBLOWERLOW & 0x00FF))
				&& (*(cp+1) <= (_MBLOWERHIGH & 0x00FF))
			       )
				    *(cp+1) -= _MBCASEDIFF;
			}

			cp++;
#endif

		}

		else
			/* single byte, macro version */
			*cp = (unsigned char) toupper(*cp);

	}

	return( string );
}
#endif	/* _MBCS */