2015-01-05 Steve Ellcey <sellcey@imgtec.com>
[glibc.git] / iconvdata / iso646.c
blobe341267060c09faab2918b3d7636c491fcc3d926
1 /* Conversion to and from the various ISO 646 CCS.
2 Copyright (C) 1998-2015 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, see
18 <http://www.gnu.org/licenses/>. */
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. */
33 #include <dlfcn.h>
34 #include <gconv.h>
35 #include <stdint.h>
36 #include <stdlib.h>
37 #include <string.h>
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
46 #define ONE_DIRECTION 0
48 #define FROM_DIRECTION (dir == from_iso646)
49 #define PREPARE_LOOP \
50 enum direction dir = ((struct iso646_data *) step->__data)->dir; \
51 enum variant var = ((struct iso646_data *) step->__data)->var;
52 #define EXTRA_LOOP_ARGS , var
55 /* Direction of the transformation. */
56 enum direction
58 illegal_dir,
59 to_iso646,
60 from_iso646
63 enum variant
65 illegal_var,
66 GB, /* BS_4730 */
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 */
91 static const char *names[] =
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//",
109 [FR1] = "NF_Z_62-010_1973//", /* Note that we don't have the parenthesis
110 in the name. */
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//"
119 struct iso646_data
121 enum direction dir;
122 enum variant var;
126 extern int gconv_init (struct __gconv_step *step);
128 gconv_init (struct __gconv_step *step)
130 /* Determine which direction. */
131 struct iso646_data *new_data;
132 enum direction dir = illegal_dir;
133 enum variant var;
134 int result;
136 for (var = sizeof (names) / sizeof (names[0]) - 1; var > illegal_var; --var)
137 if (__strcasecmp (step->__from_name, names[var]) == 0)
139 dir = from_iso646;
140 break;
142 else if (__strcasecmp (step->__to_name, names[var]) == 0)
144 dir = to_iso646;
145 break;
148 result = __GCONV_NOCONV;
149 if (__builtin_expect (dir, from_iso646) != illegal_dir)
151 new_data = (struct iso646_data *) malloc (sizeof (struct iso646_data));
153 result = __GCONV_NOMEM;
154 if (new_data != NULL)
156 new_data->dir = dir;
157 new_data->var = var;
158 step->__data = new_data;
160 if (dir == from_iso646)
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;
167 else
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;
175 step->__stateful = 0;
177 result = __GCONV_OK;
181 return result;
185 extern void gconv_end (struct __gconv_step *data);
186 void
187 gconv_end (struct __gconv_step *data)
189 free (data->__data);
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 \
199 uint32_t ch; \
200 int failure = __GCONV_OK; \
202 ch = *inptr; \
203 switch (ch) \
205 case 0x23: \
206 if (var == GB || var == ES || var == IT || var == FR || var == FR1) \
207 ch = 0xa3; \
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; \
252 break; \
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. */ \
313 failure = __GCONV_ILLEGAL_INPUT; \
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) \
376 ch = 0x203e; \
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. */ \
387 failure = __GCONV_ILLEGAL_INPUT; \
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; \
398 break; \
399 default: \
400 break; \
401 case 0x80 ... 0xff: \
402 /* Illegal character. */ \
403 failure = __GCONV_ILLEGAL_INPUT; \
404 break; \
407 /* Hopefully gcc can recognize that the following `if' is only true \
408 when we reach the default case in the `switch' statement. */ \
409 if (__builtin_expect (failure, __GCONV_OK) == __GCONV_ILLEGAL_INPUT) \
411 STANDARD_FROM_LOOP_ERR_HANDLER (1); \
413 else \
415 put32 (outptr, ch); \
416 outptr += 4; \
418 ++inptr; \
420 #define LOOP_NEED_FLAGS
421 #define EXTRA_LOOP_DECLS , enum variant var
422 #include <iconv/loop.c>
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 \
431 unsigned int ch; \
432 int failure = __GCONV_OK; \
434 ch = get32 (inptr); \
435 switch (ch) \
437 case 0x23: \
438 if (var == GB || var == ES || var == IT || var == FR || var == FR1 \
439 || var == NO2) \
440 failure = __GCONV_ILLEGAL_INPUT; \
441 break; \
442 case 0x24: \
443 if (var == CN || var == HU || var == CU || var == SE || var == SE2) \
444 failure = __GCONV_ILLEGAL_INPUT; \
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) \
450 failure = __GCONV_ILLEGAL_INPUT; \
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) \
458 failure = __GCONV_ILLEGAL_INPUT; \
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) \
468 failure = __GCONV_ILLEGAL_INPUT; \
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) \
476 failure = __GCONV_ILLEGAL_INPUT; \
477 break; \
478 case 0x5e: \
479 if (var == CA || var == CA2 || var == ES2 || var == YU || var == CU \
480 || var == SE2) \
481 failure = __GCONV_ILLEGAL_INPUT; \
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) \
486 failure = __GCONV_ILLEGAL_INPUT; \
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) \
494 failure = __GCONV_ILLEGAL_INPUT; \
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) \
501 failure = __GCONV_ILLEGAL_INPUT; \
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) \
510 failure = __GCONV_ILLEGAL_INPUT; \
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) \
518 failure = __GCONV_ILLEGAL_INPUT; \
519 break; \
520 case 0xa1: \
521 if (var != ES && var != ES2 && var != CU) \
522 failure = __GCONV_ILLEGAL_INPUT; \
523 ch = 0x5b; \
524 break; \
525 case 0xa3: \
526 if (var != GB && var != ES && var != IT && var != FR && var != FR1) \
527 failure = __GCONV_ILLEGAL_INPUT; \
528 ch = 0x23; \
529 break; \
530 case 0xa4: \
531 if (var != HU && var != CU && var != SE && var != SE2) \
532 failure = __GCONV_ILLEGAL_INPUT; \
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 \
541 failure = __GCONV_ILLEGAL_INPUT; \
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 \
551 failure = __GCONV_ILLEGAL_INPUT; \
552 break; \
553 case 0xa8: \
554 if (var != ES2 && var != CU && var != FR && var != FR1) \
555 failure = __GCONV_ILLEGAL_INPUT; \
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 \
566 failure = __GCONV_ILLEGAL_INPUT; \
567 break; \
568 case 0xb4: \
569 if (var == ES2 || var == CU) \
570 ch = 0x7b; \
571 else if (var == PT2) \
572 ch = 0x40; \
573 else \
574 failure = __GCONV_ILLEGAL_INPUT; \
575 break; \
576 case 0xb5: \
577 if (var != FR) \
578 failure = __GCONV_ILLEGAL_INPUT; \
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 \
587 failure = __GCONV_ILLEGAL_INPUT; \
588 break; \
589 case 0xc1: \
590 if (var != HU) \
591 failure = __GCONV_ILLEGAL_INPUT; \
592 ch = 0x40; \
593 break; \
594 case 0xc3: \
595 if (var != PT && var != PT2) \
596 failure = __GCONV_ILLEGAL_INPUT; \
597 ch = 0x5b; \
598 break; \
599 case 0xc4: \
600 if (var != DE && var != SE && var != SE2) \
601 failure = __GCONV_ILLEGAL_INPUT; \
602 ch = 0x5b; \
603 break; \
604 case 0xc5: \
605 if (var != DK && var != NO && var != NO2 && var != SE && var != SE2) \
606 failure = __GCONV_ILLEGAL_INPUT; \
607 ch = 0x5d; \
608 break; \
609 case 0xc6: \
610 if (var != DK && var != NO && var != NO2) \
611 failure = __GCONV_ILLEGAL_INPUT; \
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 \
620 failure = __GCONV_ILLEGAL_INPUT; \
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 \
630 failure = __GCONV_ILLEGAL_INPUT; \
631 break; \
632 case 0xd1: \
633 if (var != ES && var != ES2 && var != CU) \
634 failure = __GCONV_ILLEGAL_INPUT; \
635 ch = 0x5c; \
636 break; \
637 case 0xd5: \
638 if (var != PT && var != PT2) \
639 failure = __GCONV_ILLEGAL_INPUT; \
640 ch = 0x5d; \
641 break; \
642 case 0xd6: \
643 if (var != DE && var != HU && var != SE && var != SE2) \
644 failure = __GCONV_ILLEGAL_INPUT; \
645 ch = 0x5c; \
646 break; \
647 case 0xd8: \
648 if (var != DK && var != NO && var != NO2) \
649 failure = __GCONV_ILLEGAL_INPUT; \
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 \
658 failure = __GCONV_ILLEGAL_INPUT; \
659 break; \
660 case 0xdf: \
661 if (var != DE) \
662 failure = __GCONV_ILLEGAL_INPUT; \
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 \
671 failure = __GCONV_ILLEGAL_INPUT; \
672 break; \
673 case 0xe1: \
674 if (var != HU) \
675 failure = __GCONV_ILLEGAL_INPUT; \
676 ch = 0x60; \
677 break; \
678 case 0xe2: \
679 if (var != CA && var != CA2) \
680 failure = __GCONV_ILLEGAL_INPUT; \
681 ch = 0x5b; \
682 break; \
683 case 0xe3: \
684 if (var != PT && var != PT2) \
685 failure = __GCONV_ILLEGAL_INPUT; \
686 ch = 0x7b; \
687 break; \
688 case 0xe4: \
689 if (var != DE && var != SE && var != SE2) \
690 failure = __GCONV_ILLEGAL_INPUT; \
691 ch = 0x7b; \
692 break; \
693 case 0xe5: \
694 if (var != DK && var != NO && var != NO2 && var != SE && var != SE2) \
695 failure = __GCONV_ILLEGAL_INPUT; \
696 ch = 0x7d; \
697 break; \
698 case 0xe6: \
699 if (var != DK && var != NO && var != NO2) \
700 failure = __GCONV_ILLEGAL_INPUT; \
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 \
711 failure = __GCONV_ILLEGAL_INPUT; \
712 break; \
713 case 0xe8: \
714 if (var != CA && var != CA2 && var != IT && var != FR && var != FR1) \
715 failure = __GCONV_ILLEGAL_INPUT; \
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 \
726 failure = __GCONV_ILLEGAL_INPUT; \
727 break; \
728 case 0xea: \
729 if (var != CA && var != CA2) \
730 failure = __GCONV_ILLEGAL_INPUT; \
731 ch = 0x5d; \
732 break; \
733 case 0xec: \
734 if (var != IT) \
735 failure = __GCONV_ILLEGAL_INPUT; \
736 ch = 0x7e; \
737 break; \
738 case 0xee: \
739 if (var != CA) \
740 failure = __GCONV_ILLEGAL_INPUT; \
741 ch = 0x5e; \
742 break; \
743 case 0xf1: \
744 if (var != ES && var != ES2 && var != CU) \
745 failure = __GCONV_ILLEGAL_INPUT; \
746 ch = 0x7c; \
747 break; \
748 case 0xf2: \
749 if (var != IT) \
750 failure = __GCONV_ILLEGAL_INPUT; \
751 ch = 0x7c; \
752 break; \
753 case 0xf4: \
754 if (var != CA && var != CA2) \
755 failure = __GCONV_ILLEGAL_INPUT; \
756 ch = 0x60; \
757 break; \
758 case 0xf5: \
759 if (var != PT && var != PT2) \
760 failure = __GCONV_ILLEGAL_INPUT; \
761 ch = 0x7d; \
762 break; \
763 case 0xf6: \
764 if (var != DE && var != HU && var != SE && var != SE2) \
765 failure = __GCONV_ILLEGAL_INPUT; \
766 ch = 0x7c; \
767 break; \
768 case 0xf8: \
769 if (var != DK && var != NO && var != NO2) \
770 failure = __GCONV_ILLEGAL_INPUT; \
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 \
779 failure = __GCONV_ILLEGAL_INPUT; \
780 break; \
781 case 0xfb: \
782 if (var != CA && var != CA2) \
783 failure = __GCONV_ILLEGAL_INPUT; \
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 \
792 failure = __GCONV_ILLEGAL_INPUT; \
793 break; \
794 case 0x160: \
795 if (var != YU) \
796 failure = __GCONV_ILLEGAL_INPUT; \
797 ch = 0x5b; \
798 break; \
799 case 0x106: \
800 if (var != YU) \
801 failure = __GCONV_ILLEGAL_INPUT; \
802 ch = 0x5d; \
803 break; \
804 case 0x107: \
805 if (var != YU) \
806 failure = __GCONV_ILLEGAL_INPUT; \
807 ch = 0x7d; \
808 break; \
809 case 0x10c: \
810 if (var != YU) \
811 failure = __GCONV_ILLEGAL_INPUT; \
812 ch = 0x5e; \
813 break; \
814 case 0x10d: \
815 if (var != YU) \
816 failure = __GCONV_ILLEGAL_INPUT; \
817 ch = 0x7e; \
818 break; \
819 case 0x110: \
820 if (var != YU) \
821 failure = __GCONV_ILLEGAL_INPUT; \
822 ch = 0x5c; \
823 break; \
824 case 0x111: \
825 if (var != YU) \
826 failure = __GCONV_ILLEGAL_INPUT; \
827 ch = 0x7c; \
828 break; \
829 case 0x161: \
830 if (var != YU) \
831 failure = __GCONV_ILLEGAL_INPUT; \
832 ch = 0x7b; \
833 break; \
834 case 0x17d: \
835 if (var != YU) \
836 failure = __GCONV_ILLEGAL_INPUT; \
837 ch = 0x40; \
838 break; \
839 case 0x17e: \
840 if (var != YU) \
841 failure = __GCONV_ILLEGAL_INPUT; \
842 ch = 0x60; \
843 break; \
844 case 0x2dd: \
845 if (var != HU) \
846 failure = __GCONV_ILLEGAL_INPUT; \
847 ch = 0x7e; \
848 break; \
849 case 0x2022: \
850 if (var != ES2) \
851 failure = __GCONV_ILLEGAL_INPUT; \
852 ch = 0x40; \
853 break; \
854 case 0x203e: \
855 if (var != GB && var != CN && var != JP && var != NO && var != SE) \
856 failure = __GCONV_ILLEGAL_INPUT; \
857 ch = 0x7e; \
858 break; \
859 case 0x20a9: \
860 if (var != KR) \
861 failure = __GCONV_ILLEGAL_INPUT; \
862 ch = 0x5c; \
863 break; \
864 case 0x2329: \
865 if (var != JP_OCR_B) \
866 failure = __GCONV_ILLEGAL_INPUT; \
867 ch = 0x5b; \
868 break; \
869 case 0x232a: \
870 if (var != JP_OCR_B) \
871 failure = __GCONV_ILLEGAL_INPUT; \
872 ch = 0x5d; \
873 break; \
874 default: \
875 if (__glibc_unlikely (ch > 0x7f)) \
877 UNICODE_TAG_HANDLER (ch, 4); \
878 failure = __GCONV_ILLEGAL_INPUT; \
880 break; \
883 if (__builtin_expect (failure, __GCONV_OK) == __GCONV_ILLEGAL_INPUT) \
885 STANDARD_TO_LOOP_ERR_HANDLER (4); \
888 *outptr++ = (unsigned char) ch; \
889 inptr += 4; \
891 #define LOOP_NEED_FLAGS
892 #define EXTRA_LOOP_DECLS , enum variant var
893 #include <iconv/loop.c>
896 /* Now define the toplevel functions. */
897 #include <iconv/skeleton.c>