Fix sign of input to bsloww1 (BZ #16623)
[glibc.git] / iconvdata / iso646.c
blobb450fcc9622171a92a98768468924efefe49e9d9
1 /* Conversion to and from the various ISO 646 CCS.
2 Copyright (C) 1998-2014 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 FROM_DIRECTION (dir == from_iso646)
47 #define PREPARE_LOOP \
48 enum direction dir = ((struct iso646_data *) step->__data)->dir; \
49 enum variant var = ((struct iso646_data *) step->__data)->var;
50 #define EXTRA_LOOP_ARGS , var
53 /* Direction of the transformation. */
54 enum direction
56 illegal_dir,
57 to_iso646,
58 from_iso646
61 enum variant
63 illegal_var,
64 GB, /* BS_4730 */
65 CA, /* CSA_Z243.4-1985-1 */
66 CA2, /* CSA_Z243.4-1985-2 */
67 DE, /* DIN_66003 */
68 DK, /* DS_2089 */
69 ES, /* ES */
70 ES2, /* ES2 */
71 CN, /* GB_1988-80 */
72 IT, /* IT */
73 JP, /* JIS_C6220-1969-RO */
74 JP_OCR_B, /* JIS_C6229-1984-B */
75 YU, /* JUS_I.B1.002 */
76 KR, /* KSC5636 */
77 HU, /* MSZ_7795.3 */
78 CU, /* NC_NC00-10 */
79 FR, /* NF_Z_62-010 */
80 FR1, /* NF_Z_62-010_(1973) */
81 NO, /* NS_4551-1 */
82 NO2, /* NS_4551-2 */
83 PT, /* PT */
84 PT2, /* PT2 */
85 SE, /* SEN_850200_B */
86 SE2 /* SEN_850200_C */
89 static const char *names[] =
91 [GB] = "BS_4730//",
92 [CA] = "CSA_Z243.4-1985-1//",
93 [CA2] = "CSA_Z243.4-1985-2//",
94 [DE] = "DIN_66003//",
95 [DK] = "DS_2089//",
96 [ES] = "ES//",
97 [ES2] = "ES2//",
98 [CN] = "GB_1988-80//",
99 [IT] = "IT//",
100 [JP] = "JIS_C6220-1969-RO//",
101 [JP_OCR_B] = "JIS_C6229-1984-B//",
102 [YU] = "JUS_I.B1.002//",
103 [KR] = "KSC5636//",
104 [HU] = "MSZ_7795.3//",
105 [CU] = "NC_NC00-10//",
106 [FR] = "NF_Z_62-010//",
107 [FR1] = "NF_Z_62-010_1973//", /* Note that we don't have the parenthesis
108 in the name. */
109 [NO] = "NS_4551-1//",
110 [NO2] = "NS_4551-2//",
111 [PT] = "PT//",
112 [PT2] = "PT2//",
113 [SE] = "SEN_850200_B//",
114 [SE2] = "SEN_850200_C//"
117 struct iso646_data
119 enum direction dir;
120 enum variant var;
124 extern int gconv_init (struct __gconv_step *step);
126 gconv_init (struct __gconv_step *step)
128 /* Determine which direction. */
129 struct iso646_data *new_data;
130 enum direction dir = illegal_dir;
131 enum variant var;
132 int result;
134 for (var = sizeof (names) / sizeof (names[0]) - 1; var > illegal_var; --var)
135 if (__strcasecmp (step->__from_name, names[var]) == 0)
137 dir = from_iso646;
138 break;
140 else if (__strcasecmp (step->__to_name, names[var]) == 0)
142 dir = to_iso646;
143 break;
146 result = __GCONV_NOCONV;
147 if (__builtin_expect (dir, from_iso646) != illegal_dir)
149 new_data = (struct iso646_data *) malloc (sizeof (struct iso646_data));
151 result = __GCONV_NOMEM;
152 if (new_data != NULL)
154 new_data->dir = dir;
155 new_data->var = var;
156 step->__data = new_data;
158 if (dir == from_iso646)
160 step->__min_needed_from = MIN_NEEDED_FROM;
161 step->__max_needed_from = MIN_NEEDED_FROM;
162 step->__min_needed_to = MIN_NEEDED_TO;
163 step->__max_needed_to = MIN_NEEDED_TO;
165 else
167 step->__min_needed_from = MIN_NEEDED_TO;
168 step->__max_needed_from = MIN_NEEDED_TO;
169 step->__min_needed_to = MIN_NEEDED_FROM;
170 step->__max_needed_to = MIN_NEEDED_FROM;
173 step->__stateful = 0;
175 result = __GCONV_OK;
179 return result;
183 extern void gconv_end (struct __gconv_step *data);
184 void
185 gconv_end (struct __gconv_step *data)
187 free (data->__data);
191 /* First define the conversion function from ASCII to UCS4. */
192 #define MIN_NEEDED_INPUT MIN_NEEDED_FROM
193 #define MIN_NEEDED_OUTPUT MIN_NEEDED_TO
194 #define LOOPFCT FROM_LOOP
195 #define BODY \
197 uint32_t ch; \
198 int failure = __GCONV_OK; \
200 ch = *inptr; \
201 switch (ch) \
203 case 0x23: \
204 if (var == GB || var == ES || var == IT || var == FR || var == FR1) \
205 ch = 0xa3; \
206 else if (var == NO2) \
207 ch = 0xa7; \
208 break; \
209 case 0x24: \
210 if (var == CN) \
211 ch = 0xa5; \
212 else if (var == HU || var == CU || var == SE || var == SE2) \
213 ch = 0xa4; \
214 break; \
215 case 0x40: \
216 if (var == CA || var == CA2 || var == FR || var == FR1) \
217 ch = 0xe0; \
218 else if (var == DE || var == ES || var == IT || var == PT) \
219 ch = 0xa7; \
220 else if (var == ES2) \
221 ch = 0x2022; \
222 else if (var == YU) \
223 ch = 0x17d; \
224 else if (var == HU) \
225 ch = 0xc1; \
226 else if (var == PT2) \
227 ch = 0xb4; \
228 else if (var == SE2) \
229 ch = 0xc9; \
230 break; \
231 case 0x5b: \
232 if (var == CA || var == CA2) \
233 ch = 0xe2; \
234 else if (var == DE || var == SE || var == SE2) \
235 ch = 0xc4; \
236 else if (var == DK || var == NO || var == NO2) \
237 ch = 0xc6; \
238 else if (var == ES || var == ES2 || var == CU) \
239 ch = 0xa1; \
240 else if (var == IT || var == FR || var == FR1) \
241 ch = 0xb0; \
242 else if (var == JP_OCR_B) \
243 ch = 0x2329; \
244 else if (var == YU) \
245 ch = 0x160; \
246 else if (var == HU) \
247 ch = 0xc9; \
248 else if (var == PT || var == PT2) \
249 ch = 0xc3; \
250 break; \
251 case 0x5c: \
252 if (var == CA || var == CA2 || var == IT || var == FR || var == FR1) \
253 ch = 0xe7; \
254 else if (var == DE || var == HU || var == SE || var == SE2) \
255 ch = 0xd6; \
256 else if (var == DK || var == NO || var == NO2) \
257 ch = 0xd8; \
258 else if (var == ES || var == ES2 || var == CU) \
259 ch = 0xd1; \
260 else if (var == JP || var == JP_OCR_B) \
261 ch = 0xa5; \
262 else if (var == YU) \
263 ch = 0x110; \
264 else if (var == KR) \
265 ch = 0x20a9; \
266 else if (var == PT || var == PT2) \
267 ch = 0xc7; \
268 break; \
269 case 0x5d: \
270 if (var == CA || var == CA2) \
271 ch = 0xea; \
272 else if (var == DE || var == HU) \
273 ch = 0xdc; \
274 else if (var == DK || var == NO || var == NO2 || var == SE \
275 || var == SE2) \
276 ch = 0xc5; \
277 else if (var == ES) \
278 ch = 0xbf; \
279 else if (var == ES2) \
280 ch = 0xc7; \
281 else if (var == IT) \
282 ch = 0xe9; \
283 else if (var == JP_OCR_B) \
284 ch = 0x232a; \
285 else if (var == YU) \
286 ch = 0x106; \
287 else if (var == FR || var == FR1) \
288 ch = 0xa7; \
289 else if (var == PT || var == PT2) \
290 ch = 0xd5; \
291 break; \
292 case 0x5e: \
293 if (var == CA) \
294 ch = 0xee; \
295 else if (var == CA2) \
296 ch = 0xc9; \
297 else if (var == ES2 || var == CU) \
298 ch = 0xbf; \
299 else if (var == YU) \
300 ch = 0x10c; \
301 else if (var == SE2) \
302 ch = 0xdc; \
303 break; \
304 case 0x60: \
305 if (var == CA || var == CA2) \
306 ch = 0xf4; \
307 else if (var == IT) \
308 ch = 0xf9; \
309 else if (var == JP_OCR_B) \
310 /* Illegal character. */ \
311 failure = __GCONV_ILLEGAL_INPUT; \
312 else if (var == YU) \
313 ch = 0x17e; \
314 else if (var == HU) \
315 ch = 0xe1; \
316 else if (var == FR) \
317 ch = 0xb5; \
318 else if (var == SE2) \
319 ch = 0xe9; \
320 break; \
321 case 0x7b: \
322 if (var == CA || var == CA2 || var == HU || var == FR || var == FR1) \
323 ch = 0xe9; \
324 else if (var == DE || var == SE || var == SE2) \
325 ch = 0xe4; \
326 else if (var == DK || var == NO || var == NO2) \
327 ch = 0xe6; \
328 else if (var == ES) \
329 ch = 0xb0; \
330 else if (var == ES2 || var == CU) \
331 ch = 0xb4; \
332 else if (var == IT) \
333 ch = 0xe0; \
334 else if (var == YU) \
335 ch = 0x161; \
336 else if (var == PT || var == PT2) \
337 ch = 0xe3; \
338 break; \
339 case 0x7c: \
340 if (var == CA || var == CA2 || var == FR || var == FR1) \
341 ch = 0xf9; \
342 else if (var == DE || var == HU || var == SE || var == SE2) \
343 ch = 0xf6; \
344 else if (var == DK || var == NO || var == NO2) \
345 ch = 0xf8; \
346 else if (var == ES || var == ES2 || var == CU) \
347 ch = 0xf1; \
348 else if (var == IT) \
349 ch = 0xf2; \
350 else if (var == YU) \
351 ch = 0x111; \
352 else if (var == PT || var == PT2) \
353 ch = 0xe7; \
354 break; \
355 case 0x7d: \
356 if (var == CA || var == CA2 || var == IT || var == FR || var == FR1) \
357 ch = 0xe8; \
358 else if (var == DE || var == HU) \
359 ch = 0xfc; \
360 else if (var == DK || var == NO || var == NO2 || var == SE \
361 || var == SE2) \
362 ch = 0xe5; \
363 else if (var == ES || var == ES2) \
364 ch = 0xe7; \
365 else if (var == YU) \
366 ch = 0x107; \
367 else if (var == CU) \
368 ch = 0x5b; \
369 else if (var == PT || var == PT2) \
370 ch = 0xf5; \
371 break; \
372 case 0x7e: \
373 if (var == GB || var == CN || var == JP || var == NO || var == SE) \
374 ch = 0x203e; \
375 else if (var == CA || var == CA2) \
376 ch = 0xfb; \
377 else if (var == DE) \
378 ch = 0xdf; \
379 else if (var == ES2 || var == CU || var == FR || var == FR1) \
380 ch = 0xa8; \
381 else if (var == IT) \
382 ch = 0xec; \
383 else if (var == JP_OCR_B) \
384 /* Illegal character. */ \
385 failure = __GCONV_ILLEGAL_INPUT; \
386 else if (var == YU) \
387 ch = 0x10d; \
388 else if (var == HU) \
389 ch = 0x2dd; \
390 else if (var == NO2) \
391 ch = 0x7c; \
392 else if (var == PT) \
393 ch = 0xb0; \
394 else if (var == SE2) \
395 ch = 0xfc; \
396 break; \
397 default: \
398 break; \
399 case 0x80 ... 0xff: \
400 /* Illegal character. */ \
401 failure = __GCONV_ILLEGAL_INPUT; \
402 break; \
405 /* Hopefully gcc can recognize that the following `if' is only true \
406 when we reach the default case in the `switch' statement. */ \
407 if (__builtin_expect (failure, __GCONV_OK) == __GCONV_ILLEGAL_INPUT) \
409 STANDARD_FROM_LOOP_ERR_HANDLER (1); \
411 else \
413 put32 (outptr, ch); \
414 outptr += 4; \
416 ++inptr; \
418 #define LOOP_NEED_FLAGS
419 #define EXTRA_LOOP_DECLS , enum variant var
420 #include <iconv/loop.c>
423 /* Next, define the other direction. */
424 #define MIN_NEEDED_INPUT MIN_NEEDED_TO
425 #define MIN_NEEDED_OUTPUT MIN_NEEDED_FROM
426 #define LOOPFCT TO_LOOP
427 #define BODY \
429 unsigned int ch; \
430 int failure = __GCONV_OK; \
432 ch = get32 (inptr); \
433 switch (ch) \
435 case 0x23: \
436 if (var == GB || var == ES || var == IT || var == FR || var == FR1 \
437 || var == NO2) \
438 failure = __GCONV_ILLEGAL_INPUT; \
439 break; \
440 case 0x24: \
441 if (var == CN || var == HU || var == CU || var == SE || var == SE2) \
442 failure = __GCONV_ILLEGAL_INPUT; \
443 break; \
444 case 0x40: \
445 if (var == CA || var == CA2 || var == DE || var == ES || var == ES2 \
446 || var == IT || var == YU || var == HU || var == FR || var == FR1 \
447 || var == PT || var == PT2 || var == SE2) \
448 failure = __GCONV_ILLEGAL_INPUT; \
449 break; \
450 case 0x5b: \
451 if (var == CA || var == CA2 || var == DE || var == DK || var == ES \
452 || var == ES2 || var == IT || var == JP_OCR_B || var == YU \
453 || var == HU || var == FR || var == FR1 || var == NO \
454 || var == NO2 || var == PT || var == PT2 || var == SE \
455 || var == SE2) \
456 failure = __GCONV_ILLEGAL_INPUT; \
457 else if (var == CU) \
458 ch = 0x7d; \
459 break; \
460 case 0x5c: \
461 if (var == CA || var == CA2 || var == DE || var == DK || var == ES \
462 || var == ES2 || var == IT || var == JP || var == JP_OCR_B \
463 || var == YU || var == KR || var == HU || var == CU || var == FR \
464 || var == FR1 || var == NO || var == NO2 || var == PT \
465 || var == PT2 || var == SE || var == SE2) \
466 failure = __GCONV_ILLEGAL_INPUT; \
467 break; \
468 case 0x5d: \
469 if (var == CA || var == CA2 || var == DE || var == DK || var == ES \
470 || var == ES2 || var == IT || var == JP_OCR_B || var == YU \
471 || var == HU || var == FR || var == FR1 || var == NO \
472 || var == NO2 || var == PT || var == PT2 || var == SE \
473 || var == SE2) \
474 failure = __GCONV_ILLEGAL_INPUT; \
475 break; \
476 case 0x5e: \
477 if (var == CA || var == CA2 || var == ES2 || var == YU || var == CU \
478 || var == SE2) \
479 failure = __GCONV_ILLEGAL_INPUT; \
480 break; \
481 case 0x60: \
482 if (var == CA || var == CA2 || var == IT || var == JP_OCR_B \
483 || var == YU || var == HU || var == FR || var == SE2) \
484 failure = __GCONV_ILLEGAL_INPUT; \
485 break; \
486 case 0x7b: \
487 if (var == CA || var == CA2 || var == DE || var == DK || var == ES \
488 || var == ES2 || var == IT || var == YU || var == HU \
489 || var == CU || var == FR || var == FR1 || var == NO \
490 || var == NO2 || var == PT || var == PT2 || var == SE \
491 || var == SE2) \
492 failure = __GCONV_ILLEGAL_INPUT; \
493 break; \
494 case 0x7c: \
495 if (var == CA || var == CA2 || var == DE || var == DK || var == ES \
496 || var == ES2 || var == IT || var == YU || var == HU || var == CU \
497 || var == FR || var == FR1 || var == NO || var == PT \
498 || var == PT2 || var == SE || var == SE2) \
499 failure = __GCONV_ILLEGAL_INPUT; \
500 else if (var == NO2) \
501 ch = 0x7e; \
502 break; \
503 case 0x7d: \
504 if (var == CA || var == CA2 || var == DE || var == DK || var == ES \
505 || var == ES2 || var == IT || var == YU || var == HU || var == CU \
506 || var == FR || var == FR1 || var == NO || var == NO2 \
507 || var == PT || var == PT2 || var == SE || var == SE2) \
508 failure = __GCONV_ILLEGAL_INPUT; \
509 break; \
510 case 0x7e: \
511 if (var == GB || var == CA || var == CA2 || var == DE || var == ES2 \
512 || var == CN || var == IT || var == JP || var == JP_OCR_B \
513 || var == YU || var == HU || var == CU || var == FR || var == FR1 \
514 || var == NO || var == NO2 || var == PT || var == SE \
515 || var == SE2) \
516 failure = __GCONV_ILLEGAL_INPUT; \
517 break; \
518 case 0xa1: \
519 if (var != ES && var != ES2 && var != CU) \
520 failure = __GCONV_ILLEGAL_INPUT; \
521 ch = 0x5b; \
522 break; \
523 case 0xa3: \
524 if (var != GB && var != ES && var != IT && var != FR && var != FR1) \
525 failure = __GCONV_ILLEGAL_INPUT; \
526 ch = 0x23; \
527 break; \
528 case 0xa4: \
529 if (var != HU && var != CU && var != SE && var != SE2) \
530 failure = __GCONV_ILLEGAL_INPUT; \
531 ch = 0x24; \
532 break; \
533 case 0xa5: \
534 if (var == CN) \
535 ch = 0x24; \
536 else if (var == JP || var == JP_OCR_B) \
537 ch = 0x5c; \
538 else \
539 failure = __GCONV_ILLEGAL_INPUT; \
540 break; \
541 case 0xa7: \
542 if (var == DE || var == ES || var == IT || var == PT) \
543 ch = 0x40; \
544 else if (var == FR || var == FR1) \
545 ch = 0x5d; \
546 else if (var == NO2) \
547 ch = 0x23; \
548 else \
549 failure = __GCONV_ILLEGAL_INPUT; \
550 break; \
551 case 0xa8: \
552 if (var != ES2 && var != CU && var != FR && var != FR1) \
553 failure = __GCONV_ILLEGAL_INPUT; \
554 ch = 0x7e; \
555 break; \
556 case 0xb0: \
557 if (var == ES) \
558 ch = 0x7b; \
559 else if (var == IT || var == FR || var == FR1) \
560 ch = 0x5b; \
561 else if (var == PT) \
562 ch = 0x7e; \
563 else \
564 failure = __GCONV_ILLEGAL_INPUT; \
565 break; \
566 case 0xb4: \
567 if (var == ES2 || var == CU) \
568 ch = 0x7b; \
569 else if (var == PT2) \
570 ch = 0x40; \
571 else \
572 failure = __GCONV_ILLEGAL_INPUT; \
573 break; \
574 case 0xb5: \
575 if (var != FR) \
576 failure = __GCONV_ILLEGAL_INPUT; \
577 ch = 0x60; \
578 break; \
579 case 0xbf: \
580 if (var == ES) \
581 ch = 0x5d; \
582 else if (var == ES2 || var == CU) \
583 ch = 0x5e; \
584 else \
585 failure = __GCONV_ILLEGAL_INPUT; \
586 break; \
587 case 0xc1: \
588 if (var != HU) \
589 failure = __GCONV_ILLEGAL_INPUT; \
590 ch = 0x40; \
591 break; \
592 case 0xc3: \
593 if (var != PT && var != PT2) \
594 failure = __GCONV_ILLEGAL_INPUT; \
595 ch = 0x5b; \
596 break; \
597 case 0xc4: \
598 if (var != DE && var != SE && var != SE2) \
599 failure = __GCONV_ILLEGAL_INPUT; \
600 ch = 0x5b; \
601 break; \
602 case 0xc5: \
603 if (var != DK && var != NO && var != NO2 && var != SE && var != SE2) \
604 failure = __GCONV_ILLEGAL_INPUT; \
605 ch = 0x5d; \
606 break; \
607 case 0xc6: \
608 if (var != DK && var != NO && var != NO2) \
609 failure = __GCONV_ILLEGAL_INPUT; \
610 ch = 0x5b; \
611 break; \
612 case 0xc7: \
613 if (var == ES2) \
614 ch = 0x5d; \
615 else if (var == PT || var == PT2) \
616 ch = 0x5c; \
617 else \
618 failure = __GCONV_ILLEGAL_INPUT; \
619 break; \
620 case 0xc9: \
621 if (var == CA2) \
622 ch = 0x5e; \
623 else if (var == HU) \
624 ch = 0x5b; \
625 else if (var == SE2) \
626 ch = 0x40; \
627 else \
628 failure = __GCONV_ILLEGAL_INPUT; \
629 break; \
630 case 0xd1: \
631 if (var != ES && var != ES2 && var != CU) \
632 failure = __GCONV_ILLEGAL_INPUT; \
633 ch = 0x5c; \
634 break; \
635 case 0xd5: \
636 if (var != PT && var != PT2) \
637 failure = __GCONV_ILLEGAL_INPUT; \
638 ch = 0x5d; \
639 break; \
640 case 0xd6: \
641 if (var != DE && var != HU && var != SE && var != SE2) \
642 failure = __GCONV_ILLEGAL_INPUT; \
643 ch = 0x5c; \
644 break; \
645 case 0xd8: \
646 if (var != DK && var != NO && var != NO2) \
647 failure = __GCONV_ILLEGAL_INPUT; \
648 ch = 0x5c; \
649 break; \
650 case 0xdc: \
651 if (var == DE || var == HU) \
652 ch = 0x5d; \
653 else if (var == SE2) \
654 ch = 0x5e; \
655 else \
656 failure = __GCONV_ILLEGAL_INPUT; \
657 break; \
658 case 0xdf: \
659 if (var != DE) \
660 failure = __GCONV_ILLEGAL_INPUT; \
661 ch = 0x7e; \
662 break; \
663 case 0xe0: \
664 if (var == CA || var == CA2 || var == FR || var == FR1) \
665 ch = 0x40; \
666 else if (var == IT) \
667 ch = 0x7b; \
668 else \
669 failure = __GCONV_ILLEGAL_INPUT; \
670 break; \
671 case 0xe1: \
672 if (var != HU) \
673 failure = __GCONV_ILLEGAL_INPUT; \
674 ch = 0x60; \
675 break; \
676 case 0xe2: \
677 if (var != CA && var != CA2) \
678 failure = __GCONV_ILLEGAL_INPUT; \
679 ch = 0x5b; \
680 break; \
681 case 0xe3: \
682 if (var != PT && var != PT2) \
683 failure = __GCONV_ILLEGAL_INPUT; \
684 ch = 0x7b; \
685 break; \
686 case 0xe4: \
687 if (var != DE && var != SE && var != SE2) \
688 failure = __GCONV_ILLEGAL_INPUT; \
689 ch = 0x7b; \
690 break; \
691 case 0xe5: \
692 if (var != DK && var != NO && var != NO2 && var != SE && var != SE2) \
693 failure = __GCONV_ILLEGAL_INPUT; \
694 ch = 0x7d; \
695 break; \
696 case 0xe6: \
697 if (var != DK && var != NO && var != NO2) \
698 failure = __GCONV_ILLEGAL_INPUT; \
699 ch = 0x7b; \
700 break; \
701 case 0xe7: \
702 if (var == CA || var == CA2 || var == IT || var == FR || var == FR1) \
703 ch = 0x5c; \
704 else if (var == ES || var == ES2) \
705 ch = 0x7d; \
706 else if (var == PT || var == PT2) \
707 ch = 0x7c; \
708 else \
709 failure = __GCONV_ILLEGAL_INPUT; \
710 break; \
711 case 0xe8: \
712 if (var != CA && var != CA2 && var != IT && var != FR && var != FR1) \
713 failure = __GCONV_ILLEGAL_INPUT; \
714 ch = 0x7d; \
715 break; \
716 case 0xe9: \
717 if (var == CA || var == CA2 || var == HU || var == FR || var == FR1) \
718 ch = 0x7b; \
719 else if (var == IT) \
720 ch = 0x5d; \
721 else if (var == SE2) \
722 ch = 0x60; \
723 else \
724 failure = __GCONV_ILLEGAL_INPUT; \
725 break; \
726 case 0xea: \
727 if (var != CA && var != CA2) \
728 failure = __GCONV_ILLEGAL_INPUT; \
729 ch = 0x5d; \
730 break; \
731 case 0xec: \
732 if (var != IT) \
733 failure = __GCONV_ILLEGAL_INPUT; \
734 ch = 0x7e; \
735 break; \
736 case 0xee: \
737 if (var != CA) \
738 failure = __GCONV_ILLEGAL_INPUT; \
739 ch = 0x5e; \
740 break; \
741 case 0xf1: \
742 if (var != ES && var != ES2 && var != CU) \
743 failure = __GCONV_ILLEGAL_INPUT; \
744 ch = 0x7c; \
745 break; \
746 case 0xf2: \
747 if (var != IT) \
748 failure = __GCONV_ILLEGAL_INPUT; \
749 ch = 0x7c; \
750 break; \
751 case 0xf4: \
752 if (var != CA && var != CA2) \
753 failure = __GCONV_ILLEGAL_INPUT; \
754 ch = 0x60; \
755 break; \
756 case 0xf5: \
757 if (var != PT && var != PT2) \
758 failure = __GCONV_ILLEGAL_INPUT; \
759 ch = 0x7d; \
760 break; \
761 case 0xf6: \
762 if (var != DE && var != HU && var != SE && var != SE2) \
763 failure = __GCONV_ILLEGAL_INPUT; \
764 ch = 0x7c; \
765 break; \
766 case 0xf8: \
767 if (var != DK && var != NO && var != NO2) \
768 failure = __GCONV_ILLEGAL_INPUT; \
769 ch = 0x7c; \
770 break; \
771 case 0xf9: \
772 if (var == CA || var == CA2 || var == FR || var == FR1) \
773 ch = 0x7c; \
774 else if (var == IT) \
775 ch = 0x60; \
776 else \
777 failure = __GCONV_ILLEGAL_INPUT; \
778 break; \
779 case 0xfb: \
780 if (var != CA && var != CA2) \
781 failure = __GCONV_ILLEGAL_INPUT; \
782 ch = 0x7e; \
783 break; \
784 case 0xfc: \
785 if (var == DE || var == HU) \
786 ch = 0x7d; \
787 else if (var == SE2) \
788 ch = 0x7e; \
789 else \
790 failure = __GCONV_ILLEGAL_INPUT; \
791 break; \
792 case 0x160: \
793 if (var != YU) \
794 failure = __GCONV_ILLEGAL_INPUT; \
795 ch = 0x5b; \
796 break; \
797 case 0x106: \
798 if (var != YU) \
799 failure = __GCONV_ILLEGAL_INPUT; \
800 ch = 0x5d; \
801 break; \
802 case 0x107: \
803 if (var != YU) \
804 failure = __GCONV_ILLEGAL_INPUT; \
805 ch = 0x7d; \
806 break; \
807 case 0x10c: \
808 if (var != YU) \
809 failure = __GCONV_ILLEGAL_INPUT; \
810 ch = 0x5e; \
811 break; \
812 case 0x10d: \
813 if (var != YU) \
814 failure = __GCONV_ILLEGAL_INPUT; \
815 ch = 0x7e; \
816 break; \
817 case 0x110: \
818 if (var != YU) \
819 failure = __GCONV_ILLEGAL_INPUT; \
820 ch = 0x5c; \
821 break; \
822 case 0x111: \
823 if (var != YU) \
824 failure = __GCONV_ILLEGAL_INPUT; \
825 ch = 0x7c; \
826 break; \
827 case 0x161: \
828 if (var != YU) \
829 failure = __GCONV_ILLEGAL_INPUT; \
830 ch = 0x7b; \
831 break; \
832 case 0x17d: \
833 if (var != YU) \
834 failure = __GCONV_ILLEGAL_INPUT; \
835 ch = 0x40; \
836 break; \
837 case 0x17e: \
838 if (var != YU) \
839 failure = __GCONV_ILLEGAL_INPUT; \
840 ch = 0x60; \
841 break; \
842 case 0x2dd: \
843 if (var != HU) \
844 failure = __GCONV_ILLEGAL_INPUT; \
845 ch = 0x7e; \
846 break; \
847 case 0x2022: \
848 if (var != ES2) \
849 failure = __GCONV_ILLEGAL_INPUT; \
850 ch = 0x40; \
851 break; \
852 case 0x203e: \
853 if (var != GB && var != CN && var != JP && var != NO && var != SE) \
854 failure = __GCONV_ILLEGAL_INPUT; \
855 ch = 0x7e; \
856 break; \
857 case 0x20a9: \
858 if (var != KR) \
859 failure = __GCONV_ILLEGAL_INPUT; \
860 ch = 0x5c; \
861 break; \
862 case 0x2329: \
863 if (var != JP_OCR_B) \
864 failure = __GCONV_ILLEGAL_INPUT; \
865 ch = 0x5b; \
866 break; \
867 case 0x232a: \
868 if (var != JP_OCR_B) \
869 failure = __GCONV_ILLEGAL_INPUT; \
870 ch = 0x5d; \
871 break; \
872 default: \
873 if (__glibc_unlikely (ch > 0x7f)) \
875 UNICODE_TAG_HANDLER (ch, 4); \
876 failure = __GCONV_ILLEGAL_INPUT; \
878 break; \
881 if (__builtin_expect (failure, __GCONV_OK) == __GCONV_ILLEGAL_INPUT) \
883 STANDARD_TO_LOOP_ERR_HANDLER (4); \
886 *outptr++ = (unsigned char) ch; \
887 inptr += 4; \
889 #define LOOP_NEED_FLAGS
890 #define EXTRA_LOOP_DECLS , enum variant var
891 #include <iconv/loop.c>
894 /* Now define the toplevel functions. */
895 #include <iconv/skeleton.c>