1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22: #include <dlfcn.h>
23: #include <stdint.h>
24:
25: struct gap
26: {
27: uint16_t start;
28: uint16_t end;
29: int32_t idx;
30: };
31:
32:
33: #include TABLES
34:
35: #ifndef NONNUL
36: # define NONNUL(c) ((c) != '\0')
37: #endif
38:
39:
40: #define FROM_LOOP from_gap
41: #define TO_LOOP to_gap
42: #define DEFINE_INIT 1
43: #define DEFINE_FINI 1
44: #define MIN_NEEDED_FROM 1
45: #define MIN_NEEDED_TO 4
46:
47:
48:
49: #define MIN_NEEDED_INPUT MIN_NEEDED_FROM
50: #define MIN_NEEDED_OUTPUT MIN_NEEDED_TO
51: #define LOOPFCT FROM_LOOP
52: #define BODY \
53: { \
54: uint32_t ch = to_ucs4[*inptr]; \
55: \
56: if (HAS_HOLES && __builtin_expect (ch == L'\0', 0) && NONNUL (*inptr)) \
57: { \
58: \
59: STANDARD_FROM_LOOP_ERR_HANDLER (1); \
60: } \
61: else \
62: { \
63: put32 (outptr, ch); \
64: outptr += 4; \
65: } \
66: \
67: ++inptr; \
68: }
69: #define LOOP_NEED_FLAGS
70: #define ONEBYTE_BODY \
71: { \
72: uint32_t ch = to_ucs4[c]; \
73: \
74: if (HAS_HOLES && __builtin_expect (ch == L'\0', 0) && NONNUL (c)) \
75: return WEOF; \
76: else \
77: return ch; \
78: }
79: #include <iconv/loop.c>
80:
81:
82:
83: #define MIN_NEEDED_INPUT MIN_NEEDED_TO
84: #define MIN_NEEDED_OUTPUT MIN_NEEDED_FROM
85: #define LOOPFCT TO_LOOP
86: #define BODY \
87: { \
88: const struct gap *rp = from_idx; \
89: uint32_t ch = get32 (inptr); \
90: unsigned char res; \
91: \
92: if (__builtin_expect (ch >= 0xffff, 0)) \
93: { \
94: UNICODE_TAG_HANDLER (ch, 4); \
95: rp = NULL; \
96: } \
97: else \
98: while (ch > rp->end) \
99: ++rp; \
100: if (__builtin_expect (rp == NULL, 0) \
101: || __builtin_expect (ch < rp->start, 0) \
102: || (res = from_ucs4[ch + rp->idx], \
103: __builtin_expect (res, '\1') == '\0' && ch != 0)) \
104: { \
105: \
106: STANDARD_TO_LOOP_ERR_HANDLER (4); \
107: } \
108: \
109: *outptr++ = res; \
110: inptr += 4; \
111: }
112: #define LOOP_NEED_FLAGS
113: #include <iconv/loop.c>
114:
115:
116:
117: #include <iconv/skeleton.c>