Cygwin: mmap: allow remapping part of an existing anonymous mapping
[newlib-cygwin.git] / newlib / libc / ctype / toupper_l.c
blobb126c1e28ca5f43cfd6c8cc5d610087960a41fc4
1 #include <_ansi.h>
2 #include <ctype.h>
3 #if defined (_MB_EXTENDED_CHARSETS_ISO) \
4 || defined (_MB_EXTENDED_CHARSETS_WINDOWS)
5 #include <limits.h>
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <wctype.h>
9 #include <wchar.h>
10 #include <../locale/setlocale.h>
11 #endif
13 int
14 toupper_l (int c, struct __locale_t *locale)
16 #if defined (_MB_EXTENDED_CHARSETS_ISO) \
17 || defined (_MB_EXTENDED_CHARSETS_WINDOWS)
18 if ((unsigned char) c <= 0x7f)
19 return islower_l (c, locale) ? c - 'a' + 'A' : c;
20 else if (c != EOF && __locale_mb_cur_max_l (locale) == 1
21 && islower_l (c, locale))
23 char s[MB_LEN_MAX] = { c, '\0' };
24 wchar_t wc;
25 mbstate_t state;
27 memset (&state, 0, sizeof state);
28 if (locale->mbtowc (_REENT, &wc, s, 1, &state) >= 0
29 && locale->wctomb (_REENT, s,
30 (wchar_t) towupper_l ((wint_t) wc, locale),
31 &state) == 1)
32 c = (unsigned char) s[0];
34 return c;
35 #else
36 return islower_l (c, locale) ? c - 'a' + 'A' : c;
37 #endif