Update.
[glibc.git] / iconvdata / iso646.c
blobaf1479a34777a65b0e3d94bf14d2aa245b686b8f
1 /* Conversion to and from the various ISO 646 CCS.
2 Copyright (C) 1998 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 Library General Public License as
8 published by the Free Software Foundation; either version 2 of the
9 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 Library General Public License for more details.
16 You should have received a copy of the GNU Library General Public
17 License along with the GNU C Library; see the file COPYING.LIB. If not,
18 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 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 <gconv.h>
35 #include <stdint.h>
36 #include <string.h>
38 /* Definitions used in the body of the `gconv' function. */
39 #define FROM_LOOP from_ascii
40 #define TO_LOOP to_ascii
41 #define DEFINE_INIT 0
42 #define DEFINE_FINI 0
43 #define MIN_NEEDED_FROM 1
44 #define MIN_NEEDED_TO 4
45 #define FROM_DIRECTION (dir == from_iso646)
46 #define PREPARE_LOOP \
47 enum direction dir = ((struct iso646_data *) step->data)->dir; \
48 enum variant var = ((struct iso646_data *) step->data)->var;
49 #define EXTRA_LOOP_ARGS , var
52 /* Direction of the transformation. */
53 enum direction
55 illegal_dir,
56 to_iso646,
57 from_iso646
60 enum variant
62 illegal_var,
63 US, /* ANSI_X3.4-1968 */
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 [US] = "ANSI_X3.4-1968//",
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)//",
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;
125 gconv_init (struct gconv_step *step)
127 /* Determine which direction. */
128 struct iso646_data *new_data;
129 enum direction dir = illegal_dir;
130 enum variant var;
131 int result;
133 for (var = sizeof (names) / sizeof (names[0]) - 1; var > illegal_var; --var)
134 if (__strcasecmp (step->from_name, names[var]) == 0)
136 dir = from_iso646;
137 break;
139 else if (__strcasecmp (step->to_name, names[var]) == 0)
141 dir = to_iso646;
142 break;
145 result = GCONV_NOCONV;
146 if (dir != illegal_dir
147 && ((new_data
148 = (struct iso646_data *) malloc (sizeof (struct iso646_data)))
149 != NULL))
151 new_data->dir = dir;
152 new_data->var = var;
153 step->data = new_data;
155 if (var == from_iso646)
157 step->min_needed_from = MIN_NEEDED_FROM;
158 step->max_needed_from = MIN_NEEDED_FROM;
159 step->min_needed_to = MIN_NEEDED_TO;
160 step->max_needed_to = MIN_NEEDED_TO;
162 else
164 step->min_needed_from = MIN_NEEDED_TO;
165 step->max_needed_from = MIN_NEEDED_TO;
166 step->min_needed_to = MIN_NEEDED_FROM;
167 step->max_needed_to = MIN_NEEDED_FROM;
170 step->stateful = 0;
172 result = GCONV_OK;
175 return result;
179 void
180 gconv_end (struct gconv_step *data)
182 free (data->data);
186 /* First define the conversion function from ASCII to UCS4. */
187 #define MIN_NEEDED_INPUT MIN_NEEDED_FROM
188 #define MIN_NEEDED_OUTPUT MIN_NEEDED_TO
189 #define LOOPFCT FROM_LOOP
190 #define BODY \
192 uint32_t ch; \
193 int failure = GCONV_OK; \
195 ch = *inptr; \
196 switch (ch) \
198 case 0x23: \
199 if (var == GB || var == ES || var == IT || var == FR || var == FR1) \
200 ch = 0xa3; \
201 else if (var == NO2) \
202 ch = 0xa7; \
203 break; \
204 case 0x24: \
205 if (var == CN) \
206 ch = 0xa5; \
207 else if (var == HU || var == CU || var == SE || var == SE2) \
208 ch = 0xa4; \
209 break; \
210 case 0x40: \
211 if (var == CA || var == CA2 || var == FR || var == FR1) \
212 ch = 0xe0; \
213 else if (var == DE || var == ES || var == IT || var == PT) \
214 ch = 0xa7; \
215 else if (var == ES2) \
216 ch = 0x2022; \
217 else if (var == YU) \
218 ch = 0x17d; \
219 else if (var == HU) \
220 ch = 0xc1; \
221 else if (var == PT2) \
222 ch = 0xb4; \
223 else if (var == SE2) \
224 ch = 0xc9; \
225 break; \
226 case 0x5b: \
227 if (var == CA || var == CA2) \
228 ch = 0xe2; \
229 else if (var == DE || var == SE || var == SE2) \
230 ch = 0xc4; \
231 else if (var == DK || var == NO || var == NO2) \
232 ch = 0xc6; \
233 else if (var == ES || var == ES2 || var == CU) \
234 ch = 0xa1; \
235 else if (var == IT || var == FR || var == FR1) \
236 ch = 0xb0; \
237 else if (var == JP_OCR_B) \
238 ch = 0x2329; \
239 else if (var == YU) \
240 ch = 0x160; \
241 else if (var == HU) \
242 ch = 0xc9; \
243 else if (var == PT || var == PT2) \
244 ch = 0xc3; \
245 break; \
246 case 0x5c: \
247 if (var == CA || var == CA2 || var == IT || var == FR || var == FR1) \
248 ch = 0xe7; \
249 else if (var == DE || var == HU || var == SE || var == SE2) \
250 ch = 0xd6; \
251 else if (var == DK || var == NO || var == NO2) \
252 ch = 0xd8; \
253 else if (var == ES || var == ES2 || var == CU) \
254 ch = 0xd1; \
255 else if (var == JP || var == JP_OCR_B) \
256 ch = 0xa5; \
257 else if (var == YU) \
258 ch = 0x110; \
259 else if (var == KR) \
260 ch = 0x20a9; \
261 else if (var == PT || var == PT2) \
262 ch = 0xc7; \
263 break; \
264 case 0x5d: \
265 if (var == CA || var == CA2) \
266 ch = 0xea; \
267 else if (var == DE || var == HU) \
268 ch = 0xdc; \
269 else if (var == DK || var == NO || var == NO2 || var == SE \
270 || var == SE2) \
271 ch = 0xc5; \
272 else if (var == ES) \
273 ch = 0xbf; \
274 else if (var == ES2) \
275 ch = 0xc7; \
276 else if (var == IT) \
277 ch = 0xe9; \
278 else if (var == JP_OCR_B) \
279 ch = 0x232a; \
280 else if (var == YU) \
281 ch = 0x106; \
282 else if (var == FR || var == FR1) \
283 ch = 0xa7; \
284 else if (var == PT || var == PT2) \
285 ch = 0xd5; \
286 break; \
287 case 0x5e: \
288 if (var == CA) \
289 ch = 0xee; \
290 else if (var == CA2) \
291 ch = 0xc9; \
292 else if (var == ES2 || var == CU) \
293 ch = 0xbf; \
294 else if (var == YU) \
295 ch = 0x10c; \
296 else if (var == SE2) \
297 ch = 0xdc; \
298 break; \
299 case 0x60: \
300 if (var == CA || var == CA2) \
301 ch = 0xf4; \
302 else if (var == IT) \
303 ch = 0xf9; \
304 else if (var == JP_OCR_B) \
305 /* Illegal character. */ \
306 failure = GCONV_ILLEGAL_INPUT; \
307 else if (var == YU) \
308 ch = 0x17e; \
309 else if (var == HU) \
310 ch = 0xe1; \
311 else if (var == FR) \
312 ch = 0xb5; \
313 else if (var == SE2) \
314 ch = 0xe9; \
315 break; \
316 case 0x7b: \
317 if (var == CA || var == CA2 || var == HU || var == FR || var == FR1) \
318 ch = 0xe9; \
319 else if (var == DE || var == SE || var == SE2) \
320 ch = 0xe4; \
321 else if (var == DK || var == NO || var == NO2) \
322 ch = 0xe6; \
323 else if (var == ES) \
324 ch = 0xb0; \
325 else if (var == ES2 || var == CU) \
326 ch = 0xb4; \
327 else if (var == IT) \
328 ch = 0xe0; \
329 else if (var == YU) \
330 ch = 0x161; \
331 else if (var == PT || var == PT2) \
332 ch = 0xe3; \
333 break; \
334 case 0x7c: \
335 if (var == CA || var == CA2 || var == FR || var == FR1) \
336 ch = 0xf9; \
337 else if (var == DE || var == HU || var == SE || var == SE2) \
338 ch = 0xf6; \
339 else if (var == DK || var == NO || var == NO2) \
340 ch = 0xf8; \
341 else if (var == ES || var == ES2 || var == CU) \
342 ch = 0xf1; \
343 else if (var == IT) \
344 ch = 0xf2; \
345 else if (var == YU) \
346 ch = 0x111; \
347 else if (var == PT || var == PT2) \
348 ch = 0xe7; \
349 break; \
350 case 0x7d: \
351 if (var == CA || var == CA2 || var == IT || var == FR || var == FR1) \
352 ch = 0xe8; \
353 else if (var == DE || var == HU) \
354 ch = 0xfc; \
355 else if (var == DK || var == NO || var == NO2 || var == SE \
356 || var == SE2) \
357 ch = 0xe5; \
358 else if (var == ES || var == ES2) \
359 ch = 0xe7; \
360 else if (var == YU) \
361 ch = 0x107; \
362 else if (var == CU) \
363 ch = 0x5b; \
364 else if (var == PT || var == PT2) \
365 ch = 0xf5; \
366 break; \
367 case 0x7e: \
368 if (var == GB || var == CN || var == JP || var == NO || var == SE) \
369 ch = 0x203e; \
370 else if (var == CA || var == CA2) \
371 ch = 0xfb; \
372 else if (var == DE) \
373 ch = 0xdf; \
374 else if (var == ES2 || var == CU || var == FR || var == FR1) \
375 ch = 0xa8; \
376 else if (var == IT) \
377 ch = 0xec; \
378 else if (var == JP_OCR_B) \
379 /* Illegal character. */ \
380 failure = GCONV_ILLEGAL_INPUT; \
381 else if (var == YU) \
382 ch = 0x10d; \
383 else if (var == HU) \
384 ch = 0x2dd; \
385 else if (var == NO2) \
386 ch = 0x7c; \
387 else if (var == PT) \
388 ch = 0xb0; \
389 else if (var == SE2) \
390 ch = 0xfc; \
391 break; \
392 default: \
393 break; \
394 case 0x80 ... 0xff: \
395 /* Illegal character. */ \
396 failure = GCONV_ILLEGAL_INPUT; \
397 break; \
400 /* Hopefully gcc can recognize that the following `if' is only true \
401 when we reach the default case in the `switch' statement. */ \
402 if (failure == GCONV_ILLEGAL_INPUT) \
404 /* Exit the loop with an error. */ \
405 result = failure; \
406 break; \
408 *((uint32_t *) outptr)++ = ch; \
409 ++inptr; \
411 #define EXTRA_LOOP_DECLS , enum variant var
412 #include <iconv/loop.c>
415 /* Next, define the other direction. */
416 #define MIN_NEEDED_INPUT MIN_NEEDED_TO
417 #define MIN_NEEDED_OUTPUT MIN_NEEDED_FROM
418 #define LOOPFCT TO_LOOP
419 #define BODY \
421 unsigned char ch; \
422 int failure = GCONV_OK; \
424 ch = *((uint32_t *) inptr); \
425 switch (*((uint32_t *) inptr)) \
427 case 0x23: \
428 if (var == GB || var == ES || var == IT || var == FR || var == FR1 \
429 || var == NO2) \
430 failure = GCONV_ILLEGAL_INPUT; \
431 break; \
432 case 0x24: \
433 if (var == CN || var == HU || var == CU || var == SE || var == SE2) \
434 failure = GCONV_ILLEGAL_INPUT; \
435 break; \
436 case 0x40: \
437 if (var == CA || var == CA2 || var == DE || var == ES || var == ES2 \
438 || var == IT || var == YU || var == HU || var == FR || var == FR1 \
439 || var == PT || var == PT2 || var == SE2) \
440 failure = GCONV_ILLEGAL_INPUT; \
441 break; \
442 case 0x5b: \
443 if (var == CA || var == CA2 || var == DE || var == DK || var == ES \
444 || var == ES2 || var == IT || var == JP_OCR_B || var == YU \
445 || var == HU || var == FR || var == FR1 || var == NO \
446 || var == NO2 || var == PT || var == PT2 || var == SE \
447 || var == SE2) \
448 failure = GCONV_ILLEGAL_INPUT; \
449 else if (var == CU) \
450 ch = 0x7d; \
451 break; \
452 case 0x5c: \
453 if (var == CA || var == CA2 || var == DE || var == DK || var == ES \
454 || var == ES2 || var == IT || var == JP || var == JP_OCR_B \
455 || var == YU || var == KR || var == HU || var == CU || var == FR \
456 || var == FR1 || var == NO || var == NO2 || var == PT \
457 || var == PT2 || var == SE || var == SE2) \
458 failure = GCONV_ILLEGAL_INPUT; \
459 break; \
460 case 0x5d: \
461 if (var == CA || var == CA2 || var == DE || var == DK || var == ES \
462 || var == ES2 || var == IT || var == JP_OCR_B || var == YU \
463 || var == HU || var == FR || var == FR1 || var == NO \
464 || var == NO2 || var == PT || var == PT2 || var == SE \
465 || var == SE2) \
466 failure = GCONV_ILLEGAL_INPUT; \
467 break; \
468 case 0x5e: \
469 if (var == CA || var == CA2 || var == ES2 || var == YU || var == CU \
470 || var == SE2) \
471 failure = GCONV_ILLEGAL_INPUT; \
472 break; \
473 case 0x60: \
474 if (var == CA || var == CA2 || var == IT || var == JP_OCR_B \
475 || var == YU || var == HU || var == FR || var == SE2) \
476 failure = GCONV_ILLEGAL_INPUT; \
477 break; \
478 case 0x7b: \
479 if (var == CA || var == CA2 || var == DE || var == DK || var == ES \
480 || var == ES2 || var == IT || var == YU || var == HU \
481 || var == CU || var == FR || var == FR1 || var == NO \
482 || var == NO2 || var == PT || var == PT2 || var == SE \
483 || var == SE2) \
484 failure = GCONV_ILLEGAL_INPUT; \
485 break; \
486 case 0x7c: \
487 if (var == CA || var == CA2 || var == DE || var == DK || var == ES \
488 || var == ES2 || var == IT || var == YU || var == HU || var == CU \
489 || var == FR || var == FR1 || var == NO || var == PT \
490 || var == PT2 || var == SE || var == SE2) \
491 failure = GCONV_ILLEGAL_INPUT; \
492 else if (var == NO2) \
493 ch = 0x7e; \
494 break; \
495 case 0x7d: \
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 == NO2 \
499 || var == PT || var == PT2 || var == SE || var == SE2) \
500 failure = GCONV_ILLEGAL_INPUT; \
501 break; \
502 case 0x7e: \
503 if (var == GB || var == CA || var == CA2 || var == DE || var == ES2 \
504 || var == CN || var == IT || var == JP || var == JP_OCR_B \
505 || var == YU || var == HU || var == CU || var == FR || var == FR1 \
506 || var == NO || var == NO2 || var == PT || var == SE \
507 || var == SE2) \
508 failure = GCONV_ILLEGAL_INPUT; \
509 break; \
510 case 0xa1: \
511 if (var != ES && var != ES2 && var != CU) \
512 failure = GCONV_ILLEGAL_INPUT; \
513 ch = 0x5b; \
514 break; \
515 case 0xa3: \
516 if (var != GB && var != ES && var != IT && var != FR && var != FR1) \
517 failure = GCONV_ILLEGAL_INPUT; \
518 ch = 0x23; \
519 break; \
520 case 0xa4: \
521 if (var != HU && var != CU && var != SE && var != SE2) \
522 failure = GCONV_ILLEGAL_INPUT; \
523 ch = 0x24; \
524 break; \
525 case 0xa5: \
526 if (var == CN) \
527 ch = 0x24; \
528 else if (var == JP || var == JP_OCR_B) \
529 ch = 0x5c; \
530 else \
531 failure = GCONV_ILLEGAL_INPUT; \
532 break; \
533 case 0xa7: \
534 if (var == DE || var == ES || var == IT || var == PT) \
535 ch = 0x40; \
536 else if (var == FR || var == FR1) \
537 ch = 0x5d; \
538 else if (var == NO2) \
539 ch = 0x23; \
540 else \
541 failure = GCONV_ILLEGAL_INPUT; \
542 break; \
543 case 0xa8: \
544 if (var != ES2 && var != CU && var != FR && var != FR1) \
545 failure = GCONV_ILLEGAL_INPUT; \
546 ch = 0x7e; \
547 break; \
548 case 0xb0: \
549 if (var == ES) \
550 ch = 0x7b; \
551 else if (var == IT || var == FR || var == FR1) \
552 ch = 0x5b; \
553 else if (var == PT) \
554 ch = 0x7e; \
555 else \
556 failure = GCONV_ILLEGAL_INPUT; \
557 break; \
558 case 0xb4: \
559 if (var == ES2 || var == CU) \
560 ch = 0x7b; \
561 else if (var == PT2) \
562 ch = 0x40; \
563 else \
564 failure = GCONV_ILLEGAL_INPUT; \
565 break; \
566 case 0xb5: \
567 if (var != FR) \
568 failure = GCONV_ILLEGAL_INPUT; \
569 ch = 0x60; \
570 break; \
571 case 0xbf: \
572 if (var == ES) \
573 ch = 0x5d; \
574 else if (var == ES2 || var == CU) \
575 ch = 0x5e; \
576 else \
577 failure = GCONV_ILLEGAL_INPUT; \
578 break; \
579 case 0xc1: \
580 if (var != HU) \
581 failure = GCONV_ILLEGAL_INPUT; \
582 ch = 0x40; \
583 break; \
584 case 0xc3: \
585 if (var != PT && var != PT2) \
586 failure = GCONV_ILLEGAL_INPUT; \
587 ch = 0x5b; \
588 break; \
589 case 0xc4: \
590 if (var != DE && var != SE && var != SE2) \
591 failure = GCONV_ILLEGAL_INPUT; \
592 ch = 0x5b; \
593 break; \
594 case 0xc5: \
595 if (var != DK && var != NO && var != NO2 && var != SE && var != SE2) \
596 failure = GCONV_ILLEGAL_INPUT; \
597 ch = 0x5d; \
598 break; \
599 case 0xc6: \
600 if (var != DK && var != NO && var != NO2) \
601 failure = GCONV_ILLEGAL_INPUT; \
602 ch = 0x5b; \
603 break; \
604 case 0xc7: \
605 if (var == ES2) \
606 ch = 0x5d; \
607 else if (var == PT || var == PT2) \
608 ch = 0x5c; \
609 else \
610 failure = GCONV_ILLEGAL_INPUT; \
611 break; \
612 case 0xc9: \
613 if (var == CA2) \
614 ch = 0x5e; \
615 else if (var == HU) \
616 ch = 0x5b; \
617 else if (var == SE2) \
618 ch = 0x40; \
619 else \
620 failure = GCONV_ILLEGAL_INPUT; \
621 break; \
622 case 0xd1: \
623 if (var != ES && var != ES2 && var != CU) \
624 failure = GCONV_ILLEGAL_INPUT; \
625 ch = 0x5c; \
626 break; \
627 case 0xd5: \
628 if (var != PT && var != PT2) \
629 failure = GCONV_ILLEGAL_INPUT; \
630 ch = 0x5d; \
631 break; \
632 case 0xd6: \
633 if (var != DE && var != HU && var != SE && var != SE2) \
634 failure = GCONV_ILLEGAL_INPUT; \
635 ch = 0x5c; \
636 break; \
637 case 0xd8: \
638 if (var != DK && var != NO && var != NO2) \
639 failure = GCONV_ILLEGAL_INPUT; \
640 ch = 0x5c; \
641 break; \
642 case 0xdc: \
643 if (var == DE || var == HU) \
644 ch = 0x5d; \
645 else if (var == SE2) \
646 ch = 0x5e; \
647 else \
648 failure = GCONV_ILLEGAL_INPUT; \
649 break; \
650 case 0xdf: \
651 if (var != DE) \
652 failure = GCONV_ILLEGAL_INPUT; \
653 ch = 0x7e; \
654 break; \
655 case 0xe0: \
656 if (var == CA || var == CA2 || var == FR || var == FR1) \
657 ch = 0x40; \
658 else if (var == IT) \
659 ch = 0x7b; \
660 else \
661 failure = GCONV_ILLEGAL_INPUT; \
662 break; \
663 case 0xe1: \
664 if (var != HU) \
665 failure = GCONV_ILLEGAL_INPUT; \
666 ch = 0x60; \
667 break; \
668 case 0xe2: \
669 if (var != CA && var != CA2) \
670 failure = GCONV_ILLEGAL_INPUT; \
671 ch = 0x5b; \
672 break; \
673 case 0xe3: \
674 if (var != PT && var != PT2) \
675 failure = GCONV_ILLEGAL_INPUT; \
676 ch = 0x7b; \
677 break; \
678 case 0xe4: \
679 if (var != DE && var != SE && var != SE2) \
680 failure = GCONV_ILLEGAL_INPUT; \
681 ch = 0x7b; \
682 break; \
683 case 0xe5: \
684 if (var != DK && var != NO && var != NO2 && var != SE && var != SE2) \
685 failure = GCONV_ILLEGAL_INPUT; \
686 ch = 0x7d; \
687 break; \
688 case 0xe6: \
689 if (var != DK && var != NO && var != NO2) \
690 failure = GCONV_ILLEGAL_INPUT; \
691 ch = 0x7b; \
692 break; \
693 case 0xe7: \
694 if (var == CA || var == CA2 || var == IT || var == FR || var == FR1) \
695 ch = 0x5c; \
696 else if (var == ES || var == ES2) \
697 ch = 0x7d; \
698 else if (var == PT || var == PT2) \
699 ch = 0x7c; \
700 else \
701 failure = GCONV_ILLEGAL_INPUT; \
702 break; \
703 case 0xe8: \
704 if (var != CA && var != CA2 && var != IT && var != FR && var != FR1) \
705 failure = GCONV_ILLEGAL_INPUT; \
706 ch = 0x7d; \
707 break; \
708 case 0xe9: \
709 if (var == CA || var == CA2 || var == HU || var == FR || var == FR1) \
710 ch = 0x7b; \
711 else if (var == IT) \
712 ch = 0x5d; \
713 else if (var == SE2) \
714 ch = 0x60; \
715 else \
716 failure = GCONV_ILLEGAL_INPUT; \
717 break; \
718 case 0xea: \
719 if (var != CA && var != CA2) \
720 failure = GCONV_ILLEGAL_INPUT; \
721 ch = 0x5d; \
722 break; \
723 case 0xec: \
724 if (var != IT) \
725 failure = GCONV_ILLEGAL_INPUT; \
726 ch = 0x7e; \
727 break; \
728 case 0xee: \
729 if (var != CA) \
730 failure = GCONV_ILLEGAL_INPUT; \
731 ch = 0x5e; \
732 break; \
733 case 0xf1: \
734 if (var != ES && var != ES2 && var != CU) \
735 failure = GCONV_ILLEGAL_INPUT; \
736 ch = 0x7c; \
737 break; \
738 case 0xf2: \
739 if (var != IT) \
740 failure = GCONV_ILLEGAL_INPUT; \
741 ch = 0x7c; \
742 break; \
743 case 0xf4: \
744 if (var != CA && var != CA2) \
745 failure = GCONV_ILLEGAL_INPUT; \
746 ch = 0x60; \
747 break; \
748 case 0xf5: \
749 if (var != PT && var != PT2) \
750 failure = GCONV_ILLEGAL_INPUT; \
751 ch = 0x7d; \
752 break; \
753 case 0xf6: \
754 if (var != DE && var != HU && var != SE && var != SE2) \
755 failure = GCONV_ILLEGAL_INPUT; \
756 ch = 0x7c; \
757 break; \
758 case 0xf8: \
759 if (var != DK && var != NO && var != NO2) \
760 failure = GCONV_ILLEGAL_INPUT; \
761 ch = 0x7c; \
762 break; \
763 case 0xf9: \
764 if (var == CA || var == CA2 || var == FR || var == FR1) \
765 ch = 0x7c; \
766 else if (var == IT) \
767 ch = 0x60; \
768 else \
769 failure = GCONV_ILLEGAL_INPUT; \
770 break; \
771 case 0xfb: \
772 if (var != CA && var != CA2) \
773 failure = GCONV_ILLEGAL_INPUT; \
774 ch = 0x7e; \
775 break; \
776 case 0xfc: \
777 if (var == DE || var == HU) \
778 ch = 0x7d; \
779 else if (var == SE2) \
780 ch = 0x7e; \
781 else \
782 failure = GCONV_ILLEGAL_INPUT; \
783 break; \
784 case 0x160: \
785 if (var != YU) \
786 failure = GCONV_ILLEGAL_INPUT; \
787 ch = 0x5b; \
788 break; \
789 case 0x106: \
790 if (var != YU) \
791 failure = GCONV_ILLEGAL_INPUT; \
792 ch = 0x5d; \
793 break; \
794 case 0x107: \
795 if (var != YU) \
796 failure = GCONV_ILLEGAL_INPUT; \
797 ch = 0x7d; \
798 break; \
799 case 0x10c: \
800 if (var != YU) \
801 failure = GCONV_ILLEGAL_INPUT; \
802 ch = 0x5e; \
803 break; \
804 case 0x10d: \
805 if (var != YU) \
806 failure = GCONV_ILLEGAL_INPUT; \
807 ch = 0x7e; \
808 break; \
809 case 0x110: \
810 if (var != YU) \
811 failure = GCONV_ILLEGAL_INPUT; \
812 ch = 0x5c; \
813 break; \
814 case 0x111: \
815 if (var != YU) \
816 failure = GCONV_ILLEGAL_INPUT; \
817 ch = 0x7c; \
818 break; \
819 case 0x161: \
820 if (var != YU) \
821 failure = GCONV_ILLEGAL_INPUT; \
822 ch = 0x7b; \
823 break; \
824 case 0x17d: \
825 if (var != YU) \
826 failure = GCONV_ILLEGAL_INPUT; \
827 ch = 0x40; \
828 break; \
829 case 0x17e: \
830 if (var != YU) \
831 failure = GCONV_ILLEGAL_INPUT; \
832 ch = 0x60; \
833 break; \
834 case 0x2dd: \
835 if (var != HU) \
836 failure = GCONV_ILLEGAL_INPUT; \
837 ch = 0x7e; \
838 break; \
839 case 0x2022: \
840 if (var != ES2) \
841 failure = GCONV_ILLEGAL_INPUT; \
842 ch = 0x40; \
843 break; \
844 case 0x203e: \
845 if (var != GB && var != CN && var != JP && var != NO && var != SE) \
846 failure = GCONV_ILLEGAL_INPUT; \
847 ch = 0x7e; \
848 break; \
849 case 0x20a9: \
850 if (var != KR) \
851 failure = GCONV_ILLEGAL_INPUT; \
852 ch = 0x5c; \
853 break; \
854 case 0x2329: \
855 if (var != JP_OCR_B) \
856 failure = GCONV_ILLEGAL_INPUT; \
857 ch = 0x5b; \
858 break; \
859 case 0x232a: \
860 if (var != JP_OCR_B) \
861 failure = GCONV_ILLEGAL_INPUT; \
862 ch = 0x5d; \
863 break; \
864 default: \
865 if (*((uint32_t *) inptr) > 0x7f) \
866 failure = GCONV_ILLEGAL_INPUT; \
867 break; \
870 if (failure == GCONV_ILLEGAL_INPUT) \
872 /* Exit the loop with an error. */ \
873 result = failure; \
874 break; \
876 *outptr++ = (unsigned char) ch; \
877 inptr += 4; \
879 #define EXTRA_LOOP_DECLS , enum variant var
880 #include <iconv/loop.c>
883 /* Now define the toplevel functions. */
884 #include <iconv/skeleton.c>