source: trunk/libs/newlib/src/newlib/libc/ctype/toupper_l.c @ 444

Last change on this file since 444 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 987 bytes
Line 
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
12
13int
14toupper_l (int c, struct __locale_t *locale)
15{
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))
22    {
23      char s[MB_LEN_MAX] = { c, '\0' };
24      wchar_t wc;
25      mbstate_t state;
26
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];
33    }
34  return c;
35#else
36  return islower_l (c, locale) ? c - 'a' + 'A' : c;
37#endif
38}
Note: See TracBrowser for help on using the repository browser.