Rev 4872 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4349 | Serge | 1 | /* |
2 | FUNCTION |
||
3 | < |
||
4 | |||
5 | INDEX |
||
6 | toupper |
||
7 | INDEX |
||
8 | _toupper |
||
9 | |||
10 | ANSI_SYNOPSIS |
||
11 | #include |
||
12 | int toupper(int <[c]>); |
||
13 | int _toupper(int <[c]>); |
||
14 | |||
15 | TRAD_SYNOPSIS |
||
16 | #include |
||
17 | int toupper(<[c]>); |
||
18 | int _toupper(<[c]>); |
||
19 | |||
20 | |||
21 | DESCRIPTION |
||
22 | < |
||
23 | leaving all other characters unchanged. It is only defined when |
||
24 | <[c]> is an integer in the range < |
||
25 | |||
26 | You can use a compiled subroutine instead of the macro definition by |
||
27 | undefining this macro using `<<#undef toupper>>'. |
||
28 | |||
29 | <<_toupper>> performs the same conversion as < |
||
30 | only be used when <[c]> is known to be a lowercase character (<>--< |
||
31 | |||
32 | RETURNS |
||
33 | < |
||
34 | character between <> and < |
||
35 | |||
36 | <<_toupper>> returns the uppercase equivalent of <[c]> when it is a |
||
37 | character between <> and < |
||
38 | characters, the behaviour of <<_toupper>> is undefined. |
||
39 | |||
40 | PORTABILITY |
||
41 | < |
||
42 | |||
43 | No supporting OS subroutines are required. |
||
44 | */ |
||
45 | |||
46 | #include <_ansi.h> |
||
47 | #include |
||
48 | #if defined (_MB_EXTENDED_CHARSETS_ISO) || defined (_MB_EXTENDED_CHARSETS_WINDOWS) |
||
49 | #include |
||
50 | #include |
||
51 | #include |
||
52 | #include |
||
53 | #include |
||
54 | #endif |
||
55 | |||
56 | #undef toupper |
||
57 | int |
||
58 | _DEFUN(toupper,(c),int c) |
||
59 | { |
||
60 | #if defined (_MB_EXTENDED_CHARSETS_ISO) || defined (_MB_EXTENDED_CHARSETS_WINDOWS) |
||
61 | if ((unsigned char) c <= 0x7f) |
||
62 | return islower (c) ? c - 'a' + 'A' : c; |
||
63 | else if (c != EOF && MB_CUR_MAX == 1 && islower (c)) |
||
64 | { |
||
65 | char s[MB_LEN_MAX] = { c, '\0' }; |
||
66 | wchar_t wc; |
||
67 | if (mbtowc (&wc, s, 1) >= 0 |
||
68 | && wctomb (s, (wchar_t) towupper ((wint_t) wc)) == 1) |
||
69 | c = (unsigned char) s[0]; |
||
70 | } |
||
71 | return c; |
||
72 | #else |
||
73 | return islower (c) ? c - 'a' + 'A' : c; |
||
74 | #endif |
||
75 | }=><_toupper> |