Debian Codegraph @

mingw-w64-crt/ctype/wctrans.c

raw
1 /**
2 * This file has no copyright assigned and is placed in the Public Domain.
3 * This file is part of the mingw-w64 runtime package.
4 * No warranty is given; refer to the file DISCLAIMER.PD within this package.
5 */
6 /*
7 wctrans.c
8 7.25.3.2 Extensible wide-character case mapping functions
9
10 Contributed by: Danny Smith <[email protected]>
11 2005-02-24
12
13 This source code is placed in the PUBLIC DOMAIN. It is modified
14 from the Q8 package created by Doug Gwyn <[email protected]>
15 */
16
17 #include <stdlib.h>
18 #include <string.h>
19 #include <wctype.h>
20
21 /*
22 These two function go in the same translation unit so that we
23 can ensure that
24
25 towctrans(wc, wctrans("tolower")) == towlower(wc)
26 towctrans(wc, wctrans("toupper")) == towupper(wc)
27
28 It also ensures that
29
30 towctrans(wc, wctrans("")) == wc
31
32 which is not required by standard.
33 */
34
35 static const struct {
36 const char *name;
37 wctrans_t val;
38 } tmap[] = {
39 {"tolower", _LOWER},
40 {"toupper", _UPPER}
41 };
42
43 wctrans_t
44 wctrans (const char* property)
45 {
46 int i;
47 for (i = 0; i < (int) _countof (tmap); ++i)
48 if (strcmp (property, tmap[i].name) == 0)
49 return tmap[i].val;
50 return 0;
51 }
52
53 wint_t towctrans (wint_t wc, wctrans_t desc)
54 {
55 switch (desc)
56 {
57 case _LOWER:
58 return towlower (wc);
59 case _UPPER:
60 return towupper (wc);
61 default:
62 return wc;
63 }
64 }
65
66 wctrans_t (__cdecl *__MINGW_IMP_SYMBOL (wctrans)) (const char *) = wctrans;
67 wint_t (__cdecl *__MINGW_IMP_SYMBOL (towctrans)) (wint_t, wctrans_t) = towctrans;