1 /* $NetBSD: yacc.y,v 1.26 2009/01/02 22:08:19 tnozaki Exp $ */
6 * The Regents of the University of California. All rights reserved.
8 * This code is derived from software contributed to Berkeley by
9 * Paul Borman at Krystal Technologies.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 #if HAVE_NBTOOL_CONFIG_H
37 #include "nbtool_config.h"
40 #include <sys/cdefs.h>
43 static char sccsid
[] = "@(#)yacc.y 8.1 (Berkeley) 6/6/93";
44 static char rcsid
[] = "$FreeBSD$";
46 __RCSID
("$NetBSD: yacc.y,v 1.26 2009/01/02 22:08:19 tnozaki Exp $");
50 #include <sys/types.h>
51 #include <netinet/in.h> /* Needed by <arpa/inet.h> on NetBSD 1.5. */
52 #include <arpa/inet.h> /* Needed for htonl on POSIX systems. */
55 #include "runetype_local.h"
66 const char *locale_file
= "<stdout>";
68 rune_map maplower
= { { 0, }, };
69 rune_map mapupper
= { { 0, }, };
70 rune_map types
= { { 0, }, };
72 _NBRuneLocale new_locale
= { { 0, }, };
74 __nbrune_t charsetbits
= (__nbrune_t
)0x00000000;
76 __nbrune_t charsetmask
= (__nbrune_t
)0x0000007f;
78 __nbrune_t charsetmask
= (__nbrune_t
)0xffffffff;
80 void set_map __P
((rune_map
*, rune_list
*, u_int32_t
));
81 void set_digitmap __P
((rune_map
*, rune_list
*));
82 void add_map __P
((rune_map
*, rune_list
*, u_int32_t
));
84 int main __P
((int, char *[]));
85 void usage __P
((void));
86 int yyerror __P
((const char *s
));
87 void *xmalloc __P
((unsigned int sz
));
88 u_int32_t
*xlalloc __P
((unsigned int sz
));
89 u_int32_t
*xrelalloc __P
((u_int32_t
*old
, unsigned int sz
));
90 void dump_tables __P
((void));
91 int yyparse __P
((void));
92 extern
int yylex __P
((void));
95 extern
void mklocaledb __P
((const char *, FILE *, FILE *));
115 %token
<str
> VARIABLE
136 entry
: ENCODING STRING
137 { strncpy
(new_locale.rl_encoding
, $2, sizeof
(new_locale.rl_encoding
)); }
139 { new_locale.rl_variable_len
= strlen
($1) + 1;
140 new_locale.rl_variable
= strdup
($1);
143 { charsetbits
= $2; charsetmask
= 0x0000007f; }
145 { charsetbits
= $2; charsetmask
= $3; }
147 { int final
= $2[strlen
($2) - 1] & 0x7f;
148 charsetbits
= final
<< 24;
150 charsetmask
= 0x00007f7f;
151 if
(strchr
(",-./", $2[1]))
153 if
(0xd0 <= final
&& final
<= 0xdf)
154 charsetmask |
= 0x007f0000;
156 charsetmask
= 0x0000007f;
157 if
(strchr
(",-./", $2[0]))
159 if
(strlen
($2) == 2 && $2[0] == '!')
160 charsetbits |
= ((0x80 |
$2[0]) << 16);
166 if
(charsetbits
== ('B' << 24)
167 && charsetmask
== 0x0000007f) {
170 charsetmask
= 0x0000007f;
171 } else if
(charsetbits
== (('A' << 24) |
0x80)
172 && charsetmask
== 0x0000007f) {
175 charsetmask
= 0x0000007f;
179 { new_locale.rl_invalid_rune
= $2; }
181 { set_map
(&types
, $2, $1); }
183 { set_map
(&maplower
, $2, 0); }
185 { set_map
(&mapupper
, $2, 0); }
187 { set_digitmap
(&types
, $2); }
192 $$
= (rune_list
*)malloc
(sizeof
(rune_list
));
193 $$
->min
= ($1 & charsetmask
) | charsetbits
;
194 $$
->max
= ($1 & charsetmask
) | charsetbits
;
199 $$
= (rune_list
*)malloc
(sizeof
(rune_list
));
200 $$
->min
= ($1 & charsetmask
) | charsetbits
;
201 $$
->max
= ($3 & charsetmask
) | charsetbits
;
206 $$
= (rune_list
*)malloc
(sizeof
(rune_list
));
207 $$
->min
= ($2 & charsetmask
) | charsetbits
;
208 $$
->max
= ($2 & charsetmask
) | charsetbits
;
211 | list RUNE THRU RUNE
213 $$
= (rune_list
*)malloc
(sizeof
(rune_list
));
214 $$
->min
= ($2 & charsetmask
) | charsetbits
;
215 $$
->max
= ($4 & charsetmask
) | charsetbits
;
220 map
: LBRK RUNE RUNE RBRK
222 $$
= (rune_list
*)malloc
(sizeof
(rune_list
));
223 $$
->min
= ($2 & charsetmask
) | charsetbits
;
224 $$
->max
= ($2 & charsetmask
) | charsetbits
;
228 | map LBRK RUNE RUNE RBRK
230 $$
= (rune_list
*)malloc
(sizeof
(rune_list
));
231 $$
->min
= ($3 & charsetmask
) | charsetbits
;
232 $$
->max
= ($3 & charsetmask
) | charsetbits
;
236 | LBRK RUNE THRU RUNE
':' RUNE RBRK
238 $$
= (rune_list
*)malloc
(sizeof
(rune_list
));
239 $$
->min
= ($2 & charsetmask
) | charsetbits
;
240 $$
->max
= ($4 & charsetmask
) | charsetbits
;
244 | map LBRK RUNE THRU RUNE
':' RUNE RBRK
246 $$
= (rune_list
*)malloc
(sizeof
(rune_list
));
247 $$
->min
= ($3 & charsetmask
) | charsetbits
;
248 $$
->max
= ($5 & charsetmask
) | charsetbits
;
264 const char *locale_type
;
270 while
((x
= getopt
(ac
, av
, "do:t:")) != EOF
) {
276 locale_file
= optarg
;
277 if
((ofile
= fopen
(locale_file
, "w")) == 0)
278 err
(1, "unable to open output file %s", locale_file
);
281 locale_type
= optarg
;
288 switch
(ac
- optind
) {
292 if
(freopen
(av
[optind
], "r", stdin
) == 0)
293 err
(1, "unable to open input file %s", av
[optind
]);
301 if
(locale_type
!= NULL
&& strcasecmp
(locale_type
, "CTYPE")) {
302 mklocaledb
(locale_type
, stdin
, ofile
);
306 for
(x
= 0; x
< _NB_CACHED_RUNES
; ++x
) {
311 new_locale.rl_invalid_rune
= _NB_DEFAULT_INVALID_RUNE
;
312 memcpy
(new_locale.rl_magic
, _NB_RUNE_MAGIC_1
, sizeof
(new_locale.rl_magic
));
324 "usage: mklocale [-d] [-o output] [-t type] [source]\n");
333 fprintf
(stderr
, "%s\n", s
);
342 void *r
= malloc
(sz
);
354 u_int32_t
*r
= (u_int32_t
*)malloc
(sz
* sizeof
(u_int32_t
));
367 u_int32_t
*r
= (u_int32_t
*)realloc
((char *)old
,
368 sz
* sizeof
(u_int32_t
));
377 set_map
(map
, list
, flag
)
382 list
->map
&= charsetmask
;
383 list
->map |
= charsetbits
;
385 rune_list
*nlist
= list
->next
;
386 add_map
(map
, list
, flag
);
392 set_digitmap
(map
, list
)
399 rune_list
*nlist
= list
->next
;
400 for
(i
= list
->min
; i
<= list
->max
; ++i
) {
401 if
(list
->map
+ (i
- list
->min
)) {
402 rune_list
*tmp
= (rune_list
*)xmalloc
(sizeof
(rune_list
));
405 add_map
(map
, tmp
, list
->map
+ (i
- list
->min
));
414 add_map
(map
, list
, flag
)
424 while
(list
->min
< _NB_CACHED_RUNES
&& list
->min
<= list
->max
) {
426 map
->map
[list
->min
++] |
= flag
;
428 map
->map
[list
->min
++] = list
->map
++;
431 if
(list
->min
> list
->max
) {
436 run
= list
->max
- list
->min
+ 1;
438 if
(!(r
= map
->root
) ||
(list
->max
< r
->min
- 1)
439 ||
(!flag
&& list
->max
== r
->min
- 1)) {
441 list
->types
= xlalloc
(run
);
442 for
(i
= 0; i
< run
; ++i
)
443 list
->types
[i
] = flag
;
445 list
->next
= map
->root
;
450 for
(r
= map
->root
; r
&& r
->max
+ 1 < list
->min
; r
= r
->next
)
455 * We are off the end.
458 list
->types
= xlalloc
(run
);
459 for
(i
= 0; i
< run
; ++i
)
460 list
->types
[i
] = flag
;
467 if
(list
->max
< r
->min
- 1) {
469 * We come before this range and we do not intersect it.
470 * We are not before the root node, it was checked before the loop
473 list
->types
= xlalloc
(run
);
474 for
(i
= 0; i
< run
; ++i
)
475 list
->types
[i
] = flag
;
477 list
->next
= lr
->next
;
483 * At this point we have found that we at least intersect with
484 * the range pointed to by `r', we might intersect with one or
485 * more ranges beyond `r' as well.
488 if
(!flag
&& list
->map
- list
->min
!= r
->map
- r
->min
) {
490 * There are only two cases when we are doing case maps and
491 * our maps needn't have the same offset. When we are adjoining
492 * but not intersecting.
494 if
(list
->max
+ 1 == r
->min
) {
499 if
(list
->min
- 1 == r
->max
) {
500 list
->next
= r
->next
;
504 fprintf
(stderr
, "Error: conflicting map entries\n");
508 if
(list
->min
>= r
->min
&& list
->max
<= r
->max
) {
514 for
(i
= list
->min
; i
<= list
->max
; ++i
)
515 r
->types
[i
- r
->min
] |
= flag
;
520 if
(list
->min
<= r
->min
&& list
->max
>= r
->max
) {
522 * Superset case. Make him big enough to hold us.
523 * We might need to merge with the guy after him.
526 list
->types
= xlalloc
(list
->max
- list
->min
+ 1);
528 for
(i
= list
->min
; i
<= list
->max
; ++i
)
529 list
->types
[i
- list
->min
] = flag
;
531 for
(i
= r
->min
; i
<= r
->max
; ++i
)
532 list
->types
[i
- list
->min
] |
= r
->types
[i
- r
->min
];
535 r
->types
= list
->types
;
542 } else if
(list
->min
< r
->min
) {
544 * Our tail intersects his head.
547 list
->types
= xlalloc
(r
->max
- list
->min
+ 1);
549 for
(i
= r
->min
; i
<= r
->max
; ++i
)
550 list
->types
[i
- list
->min
] = r
->types
[i
- r
->min
];
552 for
(i
= list
->min
; i
< r
->min
; ++i
)
553 list
->types
[i
- list
->min
] = flag
;
555 for
(i
= r
->min
; i
<= list
->max
; ++i
)
556 list
->types
[i
- list
->min
] |
= flag
;
559 r
->types
= list
->types
;
568 * Our head intersects his tail.
569 * We might need to merge with the guy after him.
572 r
->types
= xrelalloc
(r
->types
, list
->max
- r
->min
+ 1);
574 for
(i
= list
->min
; i
<= r
->max
; ++i
)
575 r
->types
[i
- r
->min
] |
= flag
;
577 for
(i
= r
->max
+1; i
<= list
->max
; ++i
)
578 r
->types
[i
- r
->min
] = flag
;
585 * Okay, check to see if we grew into the next guy(s)
587 while
((lr
= r
->next
) && r
->max
>= lr
->min
) {
589 if
(r
->max
>= lr
->max
) {
591 * Good, we consumed all of him.
593 for
(i
= lr
->min
; i
<= lr
->max
; ++i
)
594 r
->types
[i
- r
->min
] |
= lr
->types
[i
- lr
->min
];
597 * "append" him on to the end of us.
599 r
->types
= xrelalloc
(r
->types
, lr
->max
- r
->min
+ 1);
601 for
(i
= lr
->min
; i
<= r
->max
; ++i
)
602 r
->types
[i
- r
->min
] |
= lr
->types
[i
- lr
->min
];
604 for
(i
= r
->max
+1; i
<= lr
->max
; ++i
)
605 r
->types
[i
- r
->min
] = lr
->types
[i
- lr
->min
];
610 if
(lr
->max
> r
->max
)
627 _FileRuneLocale file_new_locale
;
630 memset
(&file_new_locale
, 0, sizeof
(file_new_locale
));
633 * See if we can compress some of the istype arrays
635 for
(list
= types.root
; list
; list
= list
->next
) {
636 list
->map
= list
->types
[0];
637 for
(x
= 1; x
< list
->max
- list
->min
+ 1; ++x
) {
638 if
(list
->types
[x
] != list
->map
) {
645 memcpy
(&file_new_locale.frl_magic
, new_locale.rl_magic
,
646 sizeof
(file_new_locale.frl_magic
));
647 memcpy
(&file_new_locale.frl_encoding
, new_locale.rl_encoding
,
648 sizeof
(file_new_locale.frl_encoding
));
650 file_new_locale.frl_invalid_rune
= htonl
(new_locale.rl_invalid_rune
);
653 * Fill in our tables. Do this in network order so that
654 * diverse machines have a chance of sharing data.
655 * (Machines like Crays cannot share with little machines due to
656 * word size. Sigh. We tried.)
658 for
(x
= 0; x
< _NB_CACHED_RUNES
; ++x
) {
659 file_new_locale.frl_runetype
[x
] = htonl
(types.map
[x
]);
660 file_new_locale.frl_maplower
[x
] = htonl
(maplower.map
[x
]);
661 file_new_locale.frl_mapupper
[x
] = htonl
(mapupper.map
[x
]);
665 * Count up how many ranges we will need for each of the extents.
670 new_locale.rl_runetype_ext.rr_nranges
++;
673 file_new_locale.frl_runetype_ext.frr_nranges
=
674 htonl
(new_locale.rl_runetype_ext.rr_nranges
);
676 list
= maplower.root
;
679 new_locale.rl_maplower_ext.rr_nranges
++;
682 file_new_locale.frl_maplower_ext.frr_nranges
=
683 htonl
(new_locale.rl_maplower_ext.rr_nranges
);
685 list
= mapupper.root
;
688 new_locale.rl_mapupper_ext.rr_nranges
++;
691 file_new_locale.frl_mapupper_ext.frr_nranges
=
692 htonl
(new_locale.rl_mapupper_ext.rr_nranges
);
694 file_new_locale.frl_variable_len
= htonl
(new_locale.rl_variable_len
);
697 * Okay, we are now ready to write the new locale file.
701 * PART 1: The _RuneLocale structure
703 if
(fwrite
((char *)&file_new_locale
, sizeof
(file_new_locale
), 1, fp
) != 1)
704 err
(1, "writing _RuneLocale to %s", locale_file
);
706 * PART 2: The runetype_ext structures (not the actual tables)
708 for
(list
= types.root
, n
= 0; list
!= NULL
; list
= list
->next
, n
++) {
711 memset
(&re
, 0, sizeof
(re
));
712 re.fre_min
= htonl
(list
->min
);
713 re.fre_max
= htonl
(list
->max
);
714 re.fre_map
= htonl
(list
->map
);
716 if
(fwrite
((char *)&re
, sizeof
(re
), 1, fp
) != 1)
717 err
(1, "writing runetype_ext #%d to %s", n
, locale_file
);
720 * PART 3: The maplower_ext structures
722 for
(list
= maplower.root
, n
= 0; list
!= NULL
; list
= list
->next
, n
++) {
725 memset
(&re
, 0, sizeof
(re
));
726 re.fre_min
= htonl
(list
->min
);
727 re.fre_max
= htonl
(list
->max
);
728 re.fre_map
= htonl
(list
->map
);
730 if
(fwrite
((char *)&re
, sizeof
(re
), 1, fp
) != 1)
731 err
(1, "writing maplower_ext #%d to %s", n
, locale_file
);
734 * PART 4: The mapupper_ext structures
736 for
(list
= mapupper.root
, n
= 0; list
!= NULL
; list
= list
->next
, n
++) {
739 memset
(&re
, 0, sizeof
(re
));
740 re.fre_min
= htonl
(list
->min
);
741 re.fre_max
= htonl
(list
->max
);
742 re.fre_map
= htonl
(list
->map
);
744 if
(fwrite
((char *)&re
, sizeof
(re
), 1, fp
) != 1)
745 err
(1, "writing mapupper_ext #%d to %s", n
, locale_file
);
748 * PART 5: The runetype_ext tables
750 for
(list
= types.root
, n
= 0; list
!= NULL
; list
= list
->next
, n
++) {
751 for
(x
= 0; x
< list
->max
- list
->min
+ 1; ++x
)
752 list
->types
[x
] = htonl
(list
->types
[x
]);
755 if
(fwrite
((char *)list
->types
,
756 (list
->max
- list
->min
+ 1) * sizeof
(u_int32_t
),
758 err
(1, "writing runetype_ext table #%d to %s", n
, locale_file
);
762 * PART 5: And finally the variable data
764 if
(new_locale.rl_variable_len
!= 0 &&
765 fwrite
((char *)new_locale.rl_variable
,
766 new_locale.rl_variable_len
, 1, fp
) != 1)
767 err
(1, "writing variable data to %s", locale_file
);
773 if
(new_locale.rl_encoding
[0])
774 fprintf
(stderr
, "ENCODING %s\n", new_locale.rl_encoding
);
775 if
(new_locale.rl_variable
)
776 fprintf
(stderr
, "VARIABLE %s\n",
777 (char *)new_locale.rl_variable
);
779 fprintf
(stderr
, "\nMAPLOWER:\n\n");
781 for
(x
= 0; x
< _NB_CACHED_RUNES
; ++x
) {
782 if
(isprint
(maplower.map
[x
]))
783 fprintf
(stderr
, " '%c'", (int)maplower.map
[x
]);
784 else if
(maplower.map
[x
])
785 fprintf
(stderr
, "%04x", maplower.map
[x
]);
787 fprintf
(stderr
, "%4x", 0);
788 if
((x
& 0xf) == 0xf)
789 fprintf
(stderr
, "\n");
791 fprintf
(stderr
, " ");
793 fprintf
(stderr
, "\n");
795 for
(list
= maplower.root
; list
; list
= list
->next
)
796 fprintf
(stderr
, "\t%04x - %04x : %04x\n", list
->min
, list
->max
, list
->map
);
798 fprintf
(stderr
, "\nMAPUPPER:\n\n");
800 for
(x
= 0; x
< _NB_CACHED_RUNES
; ++x
) {
801 if
(isprint
(mapupper.map
[x
]))
802 fprintf
(stderr
, " '%c'", (int)mapupper.map
[x
]);
803 else if
(mapupper.map
[x
])
804 fprintf
(stderr
, "%04x", mapupper.map
[x
]);
806 fprintf
(stderr
, "%4x", 0);
807 if
((x
& 0xf) == 0xf)
808 fprintf
(stderr
, "\n");
810 fprintf
(stderr
, " ");
812 fprintf
(stderr
, "\n");
814 for
(list
= mapupper.root
; list
; list
= list
->next
)
815 fprintf
(stderr
, "\t%04x - %04x : %04x\n", list
->min
, list
->max
, list
->map
);
818 fprintf
(stderr
, "\nTYPES:\n\n");
820 for
(x
= 0; x
< _NB_CACHED_RUNES
; ++x
) {
821 u_int32_t r
= types.map
[x
];
825 fprintf
(stderr
, " '%c':%2d", x
, (int)(r
& 0xff));
827 fprintf
(stderr
, "%04x:%2d", x
, (int)(r
& 0xff));
829 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_A
) ?
"alph" : "");
830 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_C
) ?
"ctrl" : "");
831 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_D
) ?
"dig" : "");
832 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_G
) ?
"graf" : "");
833 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_L
) ?
"low" : "");
834 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_P
) ?
"punc" : "");
835 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_S
) ?
"spac" : "");
836 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_U
) ?
"upp" : "");
837 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_X
) ?
"xdig" : "");
838 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_B
) ?
"blnk" : "");
839 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_R
) ?
"prnt" : "");
840 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_I
) ?
"ideo" : "");
841 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_T
) ?
"spec" : "");
842 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_Q
) ?
"phon" : "");
843 fprintf
(stderr
, "\n");
847 for
(list
= types.root
; list
; list
= list
->next
) {
848 if
(list
->map
&& list
->min
+ 3 < list
->max
) {
849 u_int32_t r
= list
->map
;
851 fprintf
(stderr
, "%04x:%2d", list
->min
, r
& 0xff);
853 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_A
) ?
"alph" : "");
854 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_C
) ?
"ctrl" : "");
855 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_D
) ?
"dig" : "");
856 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_G
) ?
"graf" : "");
857 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_L
) ?
"low" : "");
858 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_P
) ?
"punc" : "");
859 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_S
) ?
"spac" : "");
860 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_U
) ?
"upp" : "");
861 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_X
) ?
"xdig" : "");
862 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_B
) ?
"blnk" : "");
863 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_R
) ?
"prnt" : "");
864 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_I
) ?
"ideo" : "");
865 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_T
) ?
"spec" : "");
866 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_Q
) ?
"phon" : "");
867 fprintf
(stderr
, "\n...\n");
869 fprintf
(stderr
, "%04x:%2d", list
->max
, r
& 0xff);
871 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_A
) ?
"alph" : "");
872 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_C
) ?
"ctrl" : "");
873 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_D
) ?
"dig" : "");
874 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_G
) ?
"graf" : "");
875 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_L
) ?
"low" : "");
876 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_P
) ?
"punc" : "");
877 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_S
) ?
"spac" : "");
878 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_U
) ?
"upp" : "");
879 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_X
) ?
"xdig" : "");
880 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_B
) ?
"blnk" : "");
881 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_R
) ?
"prnt" : "");
882 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_I
) ?
"ideo" : "");
883 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_T
) ?
"spec" : "");
884 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_Q
) ?
"phon" : "");
885 fprintf
(stderr
, " %1u", (unsigned)((r
& _RUNETYPE_SWM
)>>_RUNETYPE_SWS
));
886 fprintf
(stderr
, "\n");
888 for
(x
= list
->min
; x
<= list
->max
; ++x
) {
889 u_int32_t r
= ntohl
(list
->types
[x
- list
->min
]);
892 fprintf
(stderr
, "%04x:%2d", x
, (int)(r
& 0xff));
894 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_A
) ?
"alph" : "");
895 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_C
) ?
"ctrl" : "");
896 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_D
) ?
"dig" : "");
897 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_G
) ?
"graf" : "");
898 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_L
) ?
"low" : "");
899 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_P
) ?
"punc" : "");
900 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_S
) ?
"spac" : "");
901 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_U
) ?
"upp" : "");
902 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_X
) ?
"xdig" : "");
903 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_B
) ?
"blnk" : "");
904 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_R
) ?
"prnt" : "");
905 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_I
) ?
"ideo" : "");
906 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_T
) ?
"spec" : "");
907 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_Q
) ?
"phon" : "");
908 fprintf
(stderr
, " %1u", (unsigned)((r
& _RUNETYPE_SWM
)>>_RUNETYPE_SWS
));
909 fprintf
(stderr
, "\n");