]> git.ipfire.org Git - thirdparty/glibc.git/blame - iconvdata/iso646.c
Comment on IBM930, IBM933, IBM935, IBM937, IBM939.
[thirdparty/glibc.git] / iconvdata / iso646.c
CommitLineData
d2374599 1/* Conversion to and from the various ISO 646 CCS.
b168057a 2 Copyright (C) 1998-2015 Free Software Foundation, Inc.
d2374599
UD
3 This file is part of the GNU C Library.
4 Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
5
6 The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
d2374599
UD
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
41bdb6e2 14 Lesser General Public License for more details.
d2374599 15
41bdb6e2 16 You should have received a copy of the GNU Lesser General Public
59ba27a6
PE
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
d2374599 19
b60816b1
UD
20/* The implementation of the conversion which can be performed by this
21 module are not very sophisticated and not tuned at all. There are
22 zillions of ISO 646 derivates and supporting them all in a separate
23 module is overkill since these coded character sets are hardly ever
24 used anymore (except ANSI_X3.4-1968 == ASCII, which is compatible
25 with ISO 8859-1). The European variants are superceded by the
26 various ISO 8859-? standards and the Asian variants are embedded in
27 larger character sets. Therefore this implementation is simply
28 here to make it possible to do the conversion if it is necessary.
29 The cost in the gconv-modules file is set to `2' and therefore
30 allows one to easily provide a tuned implementation in case this
31 proofs to be necessary. */
32
55985355 33#include <dlfcn.h>
d2374599 34#include <gconv.h>
28f1c862 35#include <stdint.h>
7ef90c15 36#include <stdlib.h>
d2374599
UD
37#include <string.h>
38
28f1c862
UD
39/* Definitions used in the body of the `gconv' function. */
40#define FROM_LOOP from_ascii
41#define TO_LOOP to_ascii
42#define DEFINE_INIT 0
43#define DEFINE_FINI 0
44#define MIN_NEEDED_FROM 1
45#define MIN_NEEDED_TO 4
13e402e7
SE
46#define ONE_DIRECTION 0
47
e3e0a182 48#define FROM_DIRECTION (dir == from_iso646)
28f1c862 49#define PREPARE_LOOP \
d64b6ad0
UD
50 enum direction dir = ((struct iso646_data *) step->__data)->dir; \
51 enum variant var = ((struct iso646_data *) step->__data)->var;
28f1c862
UD
52#define EXTRA_LOOP_ARGS , var
53
54
d2374599
UD
55/* Direction of the transformation. */
56enum direction
57{
b60816b1 58 illegal_dir,
d2374599
UD
59 to_iso646,
60 from_iso646
61};
62
63enum variant
64{
b60816b1 65 illegal_var,
d2374599 66 GB, /* BS_4730 */
9b26f5c4
UD
67 CA, /* CSA_Z243.4-1985-1 */
68 CA2, /* CSA_Z243.4-1985-2 */
69 DE, /* DIN_66003 */
70 DK, /* DS_2089 */
71 ES, /* ES */
72 ES2, /* ES2 */
73 CN, /* GB_1988-80 */
74 IT, /* IT */
75 JP, /* JIS_C6220-1969-RO */
76 JP_OCR_B, /* JIS_C6229-1984-B */
77 YU, /* JUS_I.B1.002 */
78 KR, /* KSC5636 */
79 HU, /* MSZ_7795.3 */
80 CU, /* NC_NC00-10 */
81 FR, /* NF_Z_62-010 */
82 FR1, /* NF_Z_62-010_(1973) */
83 NO, /* NS_4551-1 */
84 NO2, /* NS_4551-2 */
85 PT, /* PT */
86 PT2, /* PT2 */
87 SE, /* SEN_850200_B */
88 SE2 /* SEN_850200_C */
89};
90
91static const char *names[] =
92{
9b26f5c4
UD
93 [GB] = "BS_4730//",
94 [CA] = "CSA_Z243.4-1985-1//",
95 [CA2] = "CSA_Z243.4-1985-2//",
96 [DE] = "DIN_66003//",
97 [DK] = "DS_2089//",
98 [ES] = "ES//",
99 [ES2] = "ES2//",
100 [CN] = "GB_1988-80//",
101 [IT] = "IT//",
102 [JP] = "JIS_C6220-1969-RO//",
103 [JP_OCR_B] = "JIS_C6229-1984-B//",
104 [YU] = "JUS_I.B1.002//",
105 [KR] = "KSC5636//",
106 [HU] = "MSZ_7795.3//",
107 [CU] = "NC_NC00-10//",
108 [FR] = "NF_Z_62-010//",
09376451 109 [FR1] = "NF_Z_62-010_1973//", /* Note that we don't have the parenthesis
4798763f 110 in the name. */
9b26f5c4
UD
111 [NO] = "NS_4551-1//",
112 [NO2] = "NS_4551-2//",
113 [PT] = "PT//",
114 [PT2] = "PT2//",
115 [SE] = "SEN_850200_B//",
116 [SE2] = "SEN_850200_C//"
d2374599
UD
117};
118
119struct iso646_data
120{
121 enum direction dir;
122 enum variant var;
123};
124
125
8c0b7170 126extern int gconv_init (struct __gconv_step *step);
d2374599 127int
d64b6ad0 128gconv_init (struct __gconv_step *step)
d2374599
UD
129{
130 /* Determine which direction. */
131 struct iso646_data *new_data;
9b26f5c4 132 enum direction dir = illegal_dir;
d2374599
UD
133 enum variant var;
134 int result;
135
9b26f5c4 136 for (var = sizeof (names) / sizeof (names[0]) - 1; var > illegal_var; --var)
d64b6ad0 137 if (__strcasecmp (step->__from_name, names[var]) == 0)
9b26f5c4
UD
138 {
139 dir = from_iso646;
140 break;
141 }
d64b6ad0 142 else if (__strcasecmp (step->__to_name, names[var]) == 0)
9b26f5c4
UD
143 {
144 dir = to_iso646;
145 break;
146 }
d2374599 147
d64b6ad0 148 result = __GCONV_NOCONV;
019357d2 149 if (__builtin_expect (dir, from_iso646) != illegal_dir)
d2374599 150 {
09376451 151 new_data = (struct iso646_data *) malloc (sizeof (struct iso646_data));
d2374599 152
d64b6ad0 153 result = __GCONV_NOMEM;
09376451 154 if (new_data != NULL)
918b9d72 155 {
09376451
UD
156 new_data->dir = dir;
157 new_data->var = var;
d64b6ad0 158 step->__data = new_data;
09376451 159
ae0f0dbd 160 if (dir == from_iso646)
09376451 161 {
d64b6ad0
UD
162 step->__min_needed_from = MIN_NEEDED_FROM;
163 step->__max_needed_from = MIN_NEEDED_FROM;
164 step->__min_needed_to = MIN_NEEDED_TO;
165 step->__max_needed_to = MIN_NEEDED_TO;
09376451
UD
166 }
167 else
168 {
d64b6ad0
UD
169 step->__min_needed_from = MIN_NEEDED_TO;
170 step->__max_needed_from = MIN_NEEDED_TO;
171 step->__min_needed_to = MIN_NEEDED_FROM;
172 step->__max_needed_to = MIN_NEEDED_FROM;
09376451
UD
173 }
174
d64b6ad0 175 step->__stateful = 0;
09376451 176
d64b6ad0 177 result = __GCONV_OK;
918b9d72 178 }
9b26f5c4 179 }
28f1c862 180
d2374599
UD
181 return result;
182}
183
184
8c0b7170 185extern void gconv_end (struct __gconv_step *data);
d2374599 186void
d64b6ad0 187gconv_end (struct __gconv_step *data)
d2374599 188{
d64b6ad0 189 free (data->__data);
d2374599
UD
190}
191
192
28f1c862
UD
193/* First define the conversion function from ASCII to UCS4. */
194#define MIN_NEEDED_INPUT MIN_NEEDED_FROM
195#define MIN_NEEDED_OUTPUT MIN_NEEDED_TO
196#define LOOPFCT FROM_LOOP
197#define BODY \
198 { \
199 uint32_t ch; \
d64b6ad0 200 int failure = __GCONV_OK; \
28f1c862 201 \
9b26f5c4
UD
202 ch = *inptr; \
203 switch (ch) \
28f1c862 204 { \
9b26f5c4
UD
205 case 0x23: \
206 if (var == GB || var == ES || var == IT || var == FR || var == FR1) \
28f1c862 207 ch = 0xa3; \
9b26f5c4
UD
208 else if (var == NO2) \
209 ch = 0xa7; \
210 break; \
211 case 0x24: \
212 if (var == CN) \
213 ch = 0xa5; \
214 else if (var == HU || var == CU || var == SE || var == SE2) \
215 ch = 0xa4; \
216 break; \
217 case 0x40: \
218 if (var == CA || var == CA2 || var == FR || var == FR1) \
219 ch = 0xe0; \
220 else if (var == DE || var == ES || var == IT || var == PT) \
221 ch = 0xa7; \
222 else if (var == ES2) \
223 ch = 0x2022; \
224 else if (var == YU) \
225 ch = 0x17d; \
226 else if (var == HU) \
227 ch = 0xc1; \
228 else if (var == PT2) \
229 ch = 0xb4; \
230 else if (var == SE2) \
231 ch = 0xc9; \
232 break; \
233 case 0x5b: \
234 if (var == CA || var == CA2) \
235 ch = 0xe2; \
236 else if (var == DE || var == SE || var == SE2) \
237 ch = 0xc4; \
238 else if (var == DK || var == NO || var == NO2) \
239 ch = 0xc6; \
240 else if (var == ES || var == ES2 || var == CU) \
241 ch = 0xa1; \
242 else if (var == IT || var == FR || var == FR1) \
243 ch = 0xb0; \
244 else if (var == JP_OCR_B) \
245 ch = 0x2329; \
246 else if (var == YU) \
247 ch = 0x160; \
248 else if (var == HU) \
249 ch = 0xc9; \
250 else if (var == PT || var == PT2) \
251 ch = 0xc3; \
28f1c862 252 break; \
9b26f5c4
UD
253 case 0x5c: \
254 if (var == CA || var == CA2 || var == IT || var == FR || var == FR1) \
255 ch = 0xe7; \
256 else if (var == DE || var == HU || var == SE || var == SE2) \
257 ch = 0xd6; \
258 else if (var == DK || var == NO || var == NO2) \
259 ch = 0xd8; \
260 else if (var == ES || var == ES2 || var == CU) \
261 ch = 0xd1; \
262 else if (var == JP || var == JP_OCR_B) \
263 ch = 0xa5; \
264 else if (var == YU) \
265 ch = 0x110; \
266 else if (var == KR) \
267 ch = 0x20a9; \
268 else if (var == PT || var == PT2) \
269 ch = 0xc7; \
270 break; \
271 case 0x5d: \
272 if (var == CA || var == CA2) \
273 ch = 0xea; \
274 else if (var == DE || var == HU) \
275 ch = 0xdc; \
276 else if (var == DK || var == NO || var == NO2 || var == SE \
277 || var == SE2) \
278 ch = 0xc5; \
279 else if (var == ES) \
280 ch = 0xbf; \
281 else if (var == ES2) \
282 ch = 0xc7; \
283 else if (var == IT) \
284 ch = 0xe9; \
285 else if (var == JP_OCR_B) \
286 ch = 0x232a; \
287 else if (var == YU) \
288 ch = 0x106; \
289 else if (var == FR || var == FR1) \
290 ch = 0xa7; \
291 else if (var == PT || var == PT2) \
292 ch = 0xd5; \
293 break; \
294 case 0x5e: \
295 if (var == CA) \
296 ch = 0xee; \
297 else if (var == CA2) \
298 ch = 0xc9; \
299 else if (var == ES2 || var == CU) \
300 ch = 0xbf; \
301 else if (var == YU) \
302 ch = 0x10c; \
303 else if (var == SE2) \
304 ch = 0xdc; \
305 break; \
306 case 0x60: \
307 if (var == CA || var == CA2) \
308 ch = 0xf4; \
309 else if (var == IT) \
310 ch = 0xf9; \
311 else if (var == JP_OCR_B) \
312 /* Illegal character. */ \
d64b6ad0 313 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
314 else if (var == YU) \
315 ch = 0x17e; \
316 else if (var == HU) \
317 ch = 0xe1; \
318 else if (var == FR) \
319 ch = 0xb5; \
320 else if (var == SE2) \
321 ch = 0xe9; \
322 break; \
323 case 0x7b: \
324 if (var == CA || var == CA2 || var == HU || var == FR || var == FR1) \
325 ch = 0xe9; \
326 else if (var == DE || var == SE || var == SE2) \
327 ch = 0xe4; \
328 else if (var == DK || var == NO || var == NO2) \
329 ch = 0xe6; \
330 else if (var == ES) \
331 ch = 0xb0; \
332 else if (var == ES2 || var == CU) \
333 ch = 0xb4; \
334 else if (var == IT) \
335 ch = 0xe0; \
336 else if (var == YU) \
337 ch = 0x161; \
338 else if (var == PT || var == PT2) \
339 ch = 0xe3; \
340 break; \
341 case 0x7c: \
342 if (var == CA || var == CA2 || var == FR || var == FR1) \
343 ch = 0xf9; \
344 else if (var == DE || var == HU || var == SE || var == SE2) \
345 ch = 0xf6; \
346 else if (var == DK || var == NO || var == NO2) \
347 ch = 0xf8; \
348 else if (var == ES || var == ES2 || var == CU) \
349 ch = 0xf1; \
350 else if (var == IT) \
351 ch = 0xf2; \
352 else if (var == YU) \
353 ch = 0x111; \
354 else if (var == PT || var == PT2) \
355 ch = 0xe7; \
356 break; \
357 case 0x7d: \
358 if (var == CA || var == CA2 || var == IT || var == FR || var == FR1) \
359 ch = 0xe8; \
360 else if (var == DE || var == HU) \
361 ch = 0xfc; \
362 else if (var == DK || var == NO || var == NO2 || var == SE \
363 || var == SE2) \
364 ch = 0xe5; \
365 else if (var == ES || var == ES2) \
366 ch = 0xe7; \
367 else if (var == YU) \
368 ch = 0x107; \
369 else if (var == CU) \
370 ch = 0x5b; \
371 else if (var == PT || var == PT2) \
372 ch = 0xf5; \
373 break; \
374 case 0x7e: \
375 if (var == GB || var == CN || var == JP || var == NO || var == SE) \
28f1c862 376 ch = 0x203e; \
9b26f5c4
UD
377 else if (var == CA || var == CA2) \
378 ch = 0xfb; \
379 else if (var == DE) \
380 ch = 0xdf; \
381 else if (var == ES2 || var == CU || var == FR || var == FR1) \
382 ch = 0xa8; \
383 else if (var == IT) \
384 ch = 0xec; \
385 else if (var == JP_OCR_B) \
386 /* Illegal character. */ \
d64b6ad0 387 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
388 else if (var == YU) \
389 ch = 0x10d; \
390 else if (var == HU) \
391 ch = 0x2dd; \
392 else if (var == NO2) \
393 ch = 0x7c; \
394 else if (var == PT) \
395 ch = 0xb0; \
396 else if (var == SE2) \
397 ch = 0xfc; \
28f1c862
UD
398 break; \
399 default: \
28f1c862 400 break; \
4b8f94d3 401 case 0x80 ... 0xff: \
28f1c862 402 /* Illegal character. */ \
d64b6ad0 403 failure = __GCONV_ILLEGAL_INPUT; \
28f1c862
UD
404 break; \
405 } \
406 \
407 /* Hopefully gcc can recognize that the following `if' is only true \
408 when we reach the default case in the `switch' statement. */ \
019357d2 409 if (__builtin_expect (failure, __GCONV_OK) == __GCONV_ILLEGAL_INPUT) \
28f1c862 410 { \
e438a468 411 STANDARD_FROM_LOOP_ERR_HANDLER (1); \
85830c4c
UD
412 } \
413 else \
414 { \
415 put32 (outptr, ch); \
416 outptr += 4; \
28f1c862 417 } \
28f1c862
UD
418 ++inptr; \
419 }
55985355 420#define LOOP_NEED_FLAGS
28f1c862
UD
421#define EXTRA_LOOP_DECLS , enum variant var
422#include <iconv/loop.c>
423
424
425/* Next, define the other direction. */
426#define MIN_NEEDED_INPUT MIN_NEEDED_TO
427#define MIN_NEEDED_OUTPUT MIN_NEEDED_FROM
428#define LOOPFCT TO_LOOP
429#define BODY \
430 { \
7888313d 431 unsigned int ch; \
d64b6ad0 432 int failure = __GCONV_OK; \
28f1c862 433 \
77e1d15a 434 ch = get32 (inptr); \
7888313d 435 switch (ch) \
28f1c862 436 { \
9b26f5c4
UD
437 case 0x23: \
438 if (var == GB || var == ES || var == IT || var == FR || var == FR1 \
439 || var == NO2) \
d64b6ad0 440 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
441 break; \
442 case 0x24: \
443 if (var == CN || var == HU || var == CU || var == SE || var == SE2) \
d64b6ad0 444 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
445 break; \
446 case 0x40: \
447 if (var == CA || var == CA2 || var == DE || var == ES || var == ES2 \
448 || var == IT || var == YU || var == HU || var == FR || var == FR1 \
449 || var == PT || var == PT2 || var == SE2) \
d64b6ad0 450 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
451 break; \
452 case 0x5b: \
453 if (var == CA || var == CA2 || var == DE || var == DK || var == ES \
454 || var == ES2 || var == IT || var == JP_OCR_B || var == YU \
455 || var == HU || var == FR || var == FR1 || var == NO \
456 || var == NO2 || var == PT || var == PT2 || var == SE \
457 || var == SE2) \
d64b6ad0 458 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
459 else if (var == CU) \
460 ch = 0x7d; \
461 break; \
462 case 0x5c: \
463 if (var == CA || var == CA2 || var == DE || var == DK || var == ES \
464 || var == ES2 || var == IT || var == JP || var == JP_OCR_B \
465 || var == YU || var == KR || var == HU || var == CU || var == FR \
466 || var == FR1 || var == NO || var == NO2 || var == PT \
467 || var == PT2 || var == SE || var == SE2) \
d64b6ad0 468 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
469 break; \
470 case 0x5d: \
471 if (var == CA || var == CA2 || var == DE || var == DK || var == ES \
472 || var == ES2 || var == IT || var == JP_OCR_B || var == YU \
473 || var == HU || var == FR || var == FR1 || var == NO \
474 || var == NO2 || var == PT || var == PT2 || var == SE \
475 || var == SE2) \
d64b6ad0 476 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
477 break; \
478 case 0x5e: \
479 if (var == CA || var == CA2 || var == ES2 || var == YU || var == CU \
480 || var == SE2) \
d64b6ad0 481 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
482 break; \
483 case 0x60: \
484 if (var == CA || var == CA2 || var == IT || var == JP_OCR_B \
485 || var == YU || var == HU || var == FR || var == SE2) \
d64b6ad0 486 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
487 break; \
488 case 0x7b: \
489 if (var == CA || var == CA2 || var == DE || var == DK || var == ES \
490 || var == ES2 || var == IT || var == YU || var == HU \
491 || var == CU || var == FR || var == FR1 || var == NO \
492 || var == NO2 || var == PT || var == PT2 || var == SE \
493 || var == SE2) \
d64b6ad0 494 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
495 break; \
496 case 0x7c: \
497 if (var == CA || var == CA2 || var == DE || var == DK || var == ES \
498 || var == ES2 || var == IT || var == YU || var == HU || var == CU \
499 || var == FR || var == FR1 || var == NO || var == PT \
500 || var == PT2 || var == SE || var == SE2) \
d64b6ad0 501 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
502 else if (var == NO2) \
503 ch = 0x7e; \
504 break; \
505 case 0x7d: \
506 if (var == CA || var == CA2 || var == DE || var == DK || var == ES \
507 || var == ES2 || var == IT || var == YU || var == HU || var == CU \
508 || var == FR || var == FR1 || var == NO || var == NO2 \
509 || var == PT || var == PT2 || var == SE || var == SE2) \
d64b6ad0 510 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
511 break; \
512 case 0x7e: \
513 if (var == GB || var == CA || var == CA2 || var == DE || var == ES2 \
514 || var == CN || var == IT || var == JP || var == JP_OCR_B \
515 || var == YU || var == HU || var == CU || var == FR || var == FR1 \
516 || var == NO || var == NO2 || var == PT || var == SE \
517 || var == SE2) \
d64b6ad0 518 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
519 break; \
520 case 0xa1: \
521 if (var != ES && var != ES2 && var != CU) \
d64b6ad0 522 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
523 ch = 0x5b; \
524 break; \
525 case 0xa3: \
526 if (var != GB && var != ES && var != IT && var != FR && var != FR1) \
d64b6ad0 527 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
528 ch = 0x23; \
529 break; \
530 case 0xa4: \
531 if (var != HU && var != CU && var != SE && var != SE2) \
d64b6ad0 532 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
533 ch = 0x24; \
534 break; \
535 case 0xa5: \
536 if (var == CN) \
537 ch = 0x24; \
538 else if (var == JP || var == JP_OCR_B) \
539 ch = 0x5c; \
540 else \
d64b6ad0 541 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
542 break; \
543 case 0xa7: \
544 if (var == DE || var == ES || var == IT || var == PT) \
545 ch = 0x40; \
546 else if (var == FR || var == FR1) \
547 ch = 0x5d; \
548 else if (var == NO2) \
549 ch = 0x23; \
550 else \
d64b6ad0 551 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
552 break; \
553 case 0xa8: \
554 if (var != ES2 && var != CU && var != FR && var != FR1) \
d64b6ad0 555 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
556 ch = 0x7e; \
557 break; \
558 case 0xb0: \
559 if (var == ES) \
560 ch = 0x7b; \
561 else if (var == IT || var == FR || var == FR1) \
562 ch = 0x5b; \
563 else if (var == PT) \
564 ch = 0x7e; \
565 else \
d64b6ad0 566 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
567 break; \
568 case 0xb4: \
569 if (var == ES2 || var == CU) \
570 ch = 0x7b; \
571 else if (var == PT2) \
572 ch = 0x40; \
573 else \
d64b6ad0 574 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
575 break; \
576 case 0xb5: \
577 if (var != FR) \
d64b6ad0 578 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
579 ch = 0x60; \
580 break; \
581 case 0xbf: \
582 if (var == ES) \
583 ch = 0x5d; \
584 else if (var == ES2 || var == CU) \
585 ch = 0x5e; \
586 else \
d64b6ad0 587 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
588 break; \
589 case 0xc1: \
590 if (var != HU) \
d64b6ad0 591 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
592 ch = 0x40; \
593 break; \
594 case 0xc3: \
595 if (var != PT && var != PT2) \
d64b6ad0 596 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
597 ch = 0x5b; \
598 break; \
599 case 0xc4: \
600 if (var != DE && var != SE && var != SE2) \
d64b6ad0 601 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
602 ch = 0x5b; \
603 break; \
604 case 0xc5: \
605 if (var != DK && var != NO && var != NO2 && var != SE && var != SE2) \
d64b6ad0 606 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
607 ch = 0x5d; \
608 break; \
609 case 0xc6: \
610 if (var != DK && var != NO && var != NO2) \
d64b6ad0 611 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
612 ch = 0x5b; \
613 break; \
614 case 0xc7: \
615 if (var == ES2) \
616 ch = 0x5d; \
617 else if (var == PT || var == PT2) \
618 ch = 0x5c; \
619 else \
d64b6ad0 620 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
621 break; \
622 case 0xc9: \
623 if (var == CA2) \
624 ch = 0x5e; \
625 else if (var == HU) \
626 ch = 0x5b; \
627 else if (var == SE2) \
628 ch = 0x40; \
629 else \
d64b6ad0 630 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
631 break; \
632 case 0xd1: \
633 if (var != ES && var != ES2 && var != CU) \
d64b6ad0 634 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
635 ch = 0x5c; \
636 break; \
637 case 0xd5: \
638 if (var != PT && var != PT2) \
d64b6ad0 639 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
640 ch = 0x5d; \
641 break; \
642 case 0xd6: \
643 if (var != DE && var != HU && var != SE && var != SE2) \
d64b6ad0 644 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
645 ch = 0x5c; \
646 break; \
647 case 0xd8: \
648 if (var != DK && var != NO && var != NO2) \
d64b6ad0 649 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
650 ch = 0x5c; \
651 break; \
652 case 0xdc: \
653 if (var == DE || var == HU) \
654 ch = 0x5d; \
655 else if (var == SE2) \
656 ch = 0x5e; \
657 else \
d64b6ad0 658 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
659 break; \
660 case 0xdf: \
661 if (var != DE) \
d64b6ad0 662 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
663 ch = 0x7e; \
664 break; \
665 case 0xe0: \
666 if (var == CA || var == CA2 || var == FR || var == FR1) \
667 ch = 0x40; \
668 else if (var == IT) \
669 ch = 0x7b; \
670 else \
d64b6ad0 671 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
672 break; \
673 case 0xe1: \
674 if (var != HU) \
d64b6ad0 675 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
676 ch = 0x60; \
677 break; \
678 case 0xe2: \
679 if (var != CA && var != CA2) \
d64b6ad0 680 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
681 ch = 0x5b; \
682 break; \
683 case 0xe3: \
684 if (var != PT && var != PT2) \
d64b6ad0 685 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
686 ch = 0x7b; \
687 break; \
688 case 0xe4: \
689 if (var != DE && var != SE && var != SE2) \
d64b6ad0 690 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
691 ch = 0x7b; \
692 break; \
693 case 0xe5: \
694 if (var != DK && var != NO && var != NO2 && var != SE && var != SE2) \
d64b6ad0 695 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
696 ch = 0x7d; \
697 break; \
698 case 0xe6: \
699 if (var != DK && var != NO && var != NO2) \
d64b6ad0 700 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
701 ch = 0x7b; \
702 break; \
703 case 0xe7: \
704 if (var == CA || var == CA2 || var == IT || var == FR || var == FR1) \
705 ch = 0x5c; \
706 else if (var == ES || var == ES2) \
707 ch = 0x7d; \
708 else if (var == PT || var == PT2) \
709 ch = 0x7c; \
710 else \
d64b6ad0 711 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
712 break; \
713 case 0xe8: \
714 if (var != CA && var != CA2 && var != IT && var != FR && var != FR1) \
d64b6ad0 715 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
716 ch = 0x7d; \
717 break; \
718 case 0xe9: \
719 if (var == CA || var == CA2 || var == HU || var == FR || var == FR1) \
720 ch = 0x7b; \
721 else if (var == IT) \
722 ch = 0x5d; \
723 else if (var == SE2) \
724 ch = 0x60; \
725 else \
d64b6ad0 726 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
727 break; \
728 case 0xea: \
729 if (var != CA && var != CA2) \
d64b6ad0 730 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
731 ch = 0x5d; \
732 break; \
733 case 0xec: \
734 if (var != IT) \
d64b6ad0 735 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
736 ch = 0x7e; \
737 break; \
738 case 0xee: \
739 if (var != CA) \
d64b6ad0 740 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
741 ch = 0x5e; \
742 break; \
743 case 0xf1: \
744 if (var != ES && var != ES2 && var != CU) \
d64b6ad0 745 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
746 ch = 0x7c; \
747 break; \
748 case 0xf2: \
749 if (var != IT) \
d64b6ad0 750 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
751 ch = 0x7c; \
752 break; \
753 case 0xf4: \
754 if (var != CA && var != CA2) \
d64b6ad0 755 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
756 ch = 0x60; \
757 break; \
758 case 0xf5: \
759 if (var != PT && var != PT2) \
d64b6ad0 760 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
761 ch = 0x7d; \
762 break; \
763 case 0xf6: \
764 if (var != DE && var != HU && var != SE && var != SE2) \
d64b6ad0 765 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
766 ch = 0x7c; \
767 break; \
768 case 0xf8: \
769 if (var != DK && var != NO && var != NO2) \
d64b6ad0 770 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
771 ch = 0x7c; \
772 break; \
773 case 0xf9: \
774 if (var == CA || var == CA2 || var == FR || var == FR1) \
775 ch = 0x7c; \
776 else if (var == IT) \
777 ch = 0x60; \
778 else \
d64b6ad0 779 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
780 break; \
781 case 0xfb: \
782 if (var != CA && var != CA2) \
d64b6ad0 783 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
784 ch = 0x7e; \
785 break; \
786 case 0xfc: \
787 if (var == DE || var == HU) \
788 ch = 0x7d; \
789 else if (var == SE2) \
790 ch = 0x7e; \
791 else \
d64b6ad0 792 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
793 break; \
794 case 0x160: \
795 if (var != YU) \
d64b6ad0 796 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
797 ch = 0x5b; \
798 break; \
799 case 0x106: \
800 if (var != YU) \
d64b6ad0 801 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
802 ch = 0x5d; \
803 break; \
804 case 0x107: \
805 if (var != YU) \
d64b6ad0 806 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
807 ch = 0x7d; \
808 break; \
809 case 0x10c: \
810 if (var != YU) \
d64b6ad0 811 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
812 ch = 0x5e; \
813 break; \
814 case 0x10d: \
815 if (var != YU) \
d64b6ad0 816 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
817 ch = 0x7e; \
818 break; \
819 case 0x110: \
820 if (var != YU) \
d64b6ad0 821 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
822 ch = 0x5c; \
823 break; \
824 case 0x111: \
825 if (var != YU) \
d64b6ad0 826 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
827 ch = 0x7c; \
828 break; \
829 case 0x161: \
830 if (var != YU) \
d64b6ad0 831 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
832 ch = 0x7b; \
833 break; \
834 case 0x17d: \
835 if (var != YU) \
d64b6ad0 836 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
837 ch = 0x40; \
838 break; \
839 case 0x17e: \
840 if (var != YU) \
d64b6ad0 841 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
842 ch = 0x60; \
843 break; \
844 case 0x2dd: \
845 if (var != HU) \
d64b6ad0 846 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
847 ch = 0x7e; \
848 break; \
849 case 0x2022: \
850 if (var != ES2) \
d64b6ad0 851 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
852 ch = 0x40; \
853 break; \
854 case 0x203e: \
855 if (var != GB && var != CN && var != JP && var != NO && var != SE) \
d64b6ad0 856 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
857 ch = 0x7e; \
858 break; \
859 case 0x20a9: \
860 if (var != KR) \
d64b6ad0 861 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
862 ch = 0x5c; \
863 break; \
864 case 0x2329: \
865 if (var != JP_OCR_B) \
d64b6ad0 866 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
867 ch = 0x5b; \
868 break; \
869 case 0x232a: \
870 if (var != JP_OCR_B) \
d64b6ad0 871 failure = __GCONV_ILLEGAL_INPUT; \
9b26f5c4
UD
872 ch = 0x5d; \
873 break; \
874 default: \
a1ffb40e 875 if (__glibc_unlikely (ch > 0x7f)) \
601d2942
UD
876 { \
877 UNICODE_TAG_HANDLER (ch, 4); \
878 failure = __GCONV_ILLEGAL_INPUT; \
879 } \
9b26f5c4 880 break; \
28f1c862 881 } \
28f1c862 882 \
019357d2 883 if (__builtin_expect (failure, __GCONV_OK) == __GCONV_ILLEGAL_INPUT) \
28f1c862 884 { \
e438a468 885 STANDARD_TO_LOOP_ERR_HANDLER (4); \
28f1c862 886 } \
d6204268
UD
887 \
888 *outptr++ = (unsigned char) ch; \
28f1c862
UD
889 inptr += 4; \
890 }
55985355 891#define LOOP_NEED_FLAGS
28f1c862
UD
892#define EXTRA_LOOP_DECLS , enum variant var
893#include <iconv/loop.c>
894
895
896/* Now define the toplevel functions. */
897#include <iconv/skeleton.c>