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