This source file includes following definitions.
- FUNC
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 char *
28 FUNC (const UNIT *s, size_t n, const char *iso639_language, uninorm_t nf,
29 char *resultbuf, size_t *lengthp)
30 {
31 UNIT foldedsbuf[2048 / sizeof (UNIT)];
32 UNIT *foldeds;
33 size_t foldeds_length;
34 char convsbuf[2048];
35 char *convs;
36 size_t convs_length;
37 char *result;
38
39
40 foldeds_length = sizeof (foldedsbuf) / sizeof (UNIT);
41 foldeds = U_CASEFOLD (s, n, iso639_language, nf, foldedsbuf, &foldeds_length);
42 if (foldeds == NULL)
43
44 return NULL;
45
46
47 convs_length = sizeof (convsbuf) - 1;
48 convs = U_CONV_TO_ENCODING (locale_charset (),
49 iconveh_error,
50 foldeds, foldeds_length,
51 NULL,
52 convsbuf, &convs_length);
53 if (convs == NULL)
54 {
55 if (foldeds != foldedsbuf)
56 {
57 int saved_errno = errno;
58 free (foldeds);
59 errno = saved_errno;
60 }
61 return NULL;
62 }
63
64 if (foldeds != foldedsbuf)
65 free (foldeds);
66
67
68 if (convs != convsbuf)
69 {
70 char *memory = (char *) realloc (convs, convs_length + 1);
71 if (memory == NULL)
72 {
73 free (convs);
74 errno = ENOMEM;
75 return NULL;
76 }
77 convs = memory;
78 }
79
80
81 result = amemxfrm (convs, convs_length, resultbuf, lengthp);
82 if (result == NULL)
83 {
84 if (convs != convsbuf)
85 {
86 int saved_errno = errno;
87 free (convs);
88 errno = saved_errno;
89 }
90 return NULL;
91 }
92
93 if (convs != convsbuf)
94 free (convs);
95 return result;
96 }