1 /* $NetBSD: yacc.y,v 1.31 2010/06/13 04:14:57 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.31 2010/06/13 04:14:57 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. */
63 #include "runetype_file.h"
67 const char *locale_file
= "<stdout>";
69 rune_map maplower
= { { 0, }, };
70 rune_map mapupper
= { { 0, }, };
71 rune_map types
= { { 0, }, };
73 _FileRuneLocale new_locale
= { { 0, }, };
75 size_t rl_variable_len
= (size_t)0;
76 void *rl_variable
= NULL
;
78 __nbrune_t charsetbits
= (__nbrune_t
)0x00000000;
80 __nbrune_t charsetmask
= (__nbrune_t
)0x0000007f;
82 __nbrune_t charsetmask
= (__nbrune_t
)0xffffffff;
84 void set_map __P
((rune_map
*, rune_list
*, u_int32_t
));
85 void set_digitmap __P
((rune_map
*, rune_list
*));
86 void add_map __P
((rune_map
*, rune_list
*, u_int32_t
));
88 int main __P
((int, char *[]));
89 void usage __P
((void));
90 int yyerror __P
((const char *s
));
91 void *xmalloc __P
((unsigned int sz
));
92 u_int32_t
*xlalloc __P
((unsigned int sz
));
93 u_int32_t
*xrelalloc __P
((u_int32_t
*old
, unsigned int sz
));
94 void dump_tables __P
((void));
95 int yyparse __P
((void));
96 extern
int yylex __P
((void));
99 extern
void mklocaledb __P
((const char *, FILE *, FILE *));
119 %token
<str
> VARIABLE
140 entry
: ENCODING STRING
141 { strncpy
(new_locale.frl_encoding
, $2, sizeof
(new_locale.frl_encoding
)); }
143 { rl_variable_len
= strlen
($1) + 1;
144 rl_variable
= strdup
($1);
145 new_locale.frl_variable_len
= htonl
((u_int32_t
)rl_variable_len
);
148 { charsetbits
= $2; charsetmask
= 0x0000007f; }
150 { charsetbits
= $2; charsetmask
= $3; }
152 { int final
= $2[strlen
($2) - 1] & 0x7f;
153 charsetbits
= final
<< 24;
155 charsetmask
= 0x00007f7f;
156 if
(strchr
(",-./", $2[1]))
158 if
(0xd0 <= final
&& final
<= 0xdf)
159 charsetmask |
= 0x007f0000;
161 charsetmask
= 0x0000007f;
162 if
(strchr
(",-./", $2[0]))
164 if
(strlen
($2) == 2 && $2[0] == '!')
165 charsetbits |
= ((0x80 |
$2[0]) << 16);
171 if
(charsetbits
== ('B' << 24)
172 && charsetmask
== 0x0000007f) {
175 charsetmask
= 0x0000007f;
176 } else if
(charsetbits
== (('A' << 24) |
0x80)
177 && charsetmask
== 0x0000007f) {
180 charsetmask
= 0x0000007f;
184 { new_locale.frl_invalid_rune
= htonl
((u_int32_t
)$2); }
186 { set_map
(&types
, $2, $1); }
188 { set_map
(&maplower
, $2, 0); }
190 { set_map
(&mapupper
, $2, 0); }
192 { set_digitmap
(&types
, $2); }
197 $$
= (rune_list
*)malloc
(sizeof
(rune_list
));
198 $$
->min
= ($1 & charsetmask
) | charsetbits
;
199 $$
->max
= ($1 & charsetmask
) | charsetbits
;
204 $$
= (rune_list
*)malloc
(sizeof
(rune_list
));
205 $$
->min
= ($1 & charsetmask
) | charsetbits
;
206 $$
->max
= ($3 & charsetmask
) | charsetbits
;
211 $$
= (rune_list
*)malloc
(sizeof
(rune_list
));
212 $$
->min
= ($2 & charsetmask
) | charsetbits
;
213 $$
->max
= ($2 & charsetmask
) | charsetbits
;
216 | list RUNE THRU RUNE
218 $$
= (rune_list
*)malloc
(sizeof
(rune_list
));
219 $$
->min
= ($2 & charsetmask
) | charsetbits
;
220 $$
->max
= ($4 & charsetmask
) | charsetbits
;
225 map
: LBRK RUNE RUNE RBRK
227 $$
= (rune_list
*)malloc
(sizeof
(rune_list
));
228 $$
->min
= ($2 & charsetmask
) | charsetbits
;
229 $$
->max
= ($2 & charsetmask
) | charsetbits
;
233 | map LBRK RUNE RUNE RBRK
235 $$
= (rune_list
*)malloc
(sizeof
(rune_list
));
236 $$
->min
= ($3 & charsetmask
) | charsetbits
;
237 $$
->max
= ($3 & charsetmask
) | charsetbits
;
241 | LBRK RUNE THRU RUNE
':' RUNE RBRK
243 $$
= (rune_list
*)malloc
(sizeof
(rune_list
));
244 $$
->min
= ($2 & charsetmask
) | charsetbits
;
245 $$
->max
= ($4 & charsetmask
) | charsetbits
;
249 | map LBRK RUNE THRU RUNE
':' RUNE RBRK
251 $$
= (rune_list
*)malloc
(sizeof
(rune_list
));
252 $$
->min
= ($3 & charsetmask
) | charsetbits
;
253 $$
->max
= ($5 & charsetmask
) | charsetbits
;
269 const char *locale_type
;
275 while
((x
= getopt
(ac
, av
, "do:t:")) != EOF
) {
281 locale_file
= optarg
;
282 if
((ofile
= fopen
(locale_file
, "w")) == 0)
283 err
(1, "unable to open output file %s", locale_file
);
286 locale_type
= optarg
;
293 switch
(ac
- optind
) {
297 if
(freopen
(av
[optind
], "r", stdin
) == 0)
298 err
(1, "unable to open input file %s", av
[optind
]);
306 if
(locale_type
!= NULL
&& strcasecmp
(locale_type
, "CTYPE")) {
307 mklocaledb
(locale_type
, stdin
, ofile
);
311 for
(x
= 0; x
< _CTYPE_CACHE_SIZE
; ++x
) {
316 new_locale.frl_invalid_rune
= htonl
((u_int32_t
)_DEFAULT_INVALID_RUNE
);
317 memcpy
(new_locale.frl_magic
, _RUNECT10_MAGIC
, sizeof
(new_locale.frl_magic
));
329 "usage: mklocale [-d] [-o output] [-t type] [source]\n");
338 fprintf
(stderr
, "%s\n", s
);
347 void *r
= malloc
(sz
);
359 u_int32_t
*r
= (u_int32_t
*)malloc
(sz
* sizeof
(u_int32_t
));
372 u_int32_t
*r
= (u_int32_t
*)realloc
((char *)old
,
373 sz
* sizeof
(u_int32_t
));
382 set_map
(map
, list
, flag
)
387 list
->map
&= charsetmask
;
388 list
->map |
= charsetbits
;
390 rune_list
*nlist
= list
->next
;
391 add_map
(map
, list
, flag
);
397 set_digitmap
(map
, list
)
404 rune_list
*nlist
= list
->next
;
405 for
(i
= list
->min
; i
<= list
->max
; ++i
) {
406 if
(list
->map
+ (i
- list
->min
)) {
407 rune_list
*tmp
= (rune_list
*)xmalloc
(sizeof
(rune_list
));
410 add_map
(map
, tmp
, list
->map
+ (i
- list
->min
));
419 add_map
(map
, list
, flag
)
429 while
(list
->min
< _CTYPE_CACHE_SIZE
&& list
->min
<= list
->max
) {
431 map
->map
[list
->min
++] |
= flag
;
433 map
->map
[list
->min
++] = list
->map
++;
436 if
(list
->min
> list
->max
) {
441 run
= list
->max
- list
->min
+ 1;
443 if
(!(r
= map
->root
) ||
(list
->max
< r
->min
- 1)
444 ||
(!flag
&& list
->max
== r
->min
- 1)) {
446 list
->types
= xlalloc
(run
);
447 for
(i
= 0; i
< run
; ++i
)
448 list
->types
[i
] = flag
;
450 list
->next
= map
->root
;
455 for
(r
= map
->root
; r
&& r
->max
+ 1 < list
->min
; r
= r
->next
)
460 * We are off the end.
463 list
->types
= xlalloc
(run
);
464 for
(i
= 0; i
< run
; ++i
)
465 list
->types
[i
] = flag
;
472 if
(list
->max
< r
->min
- 1) {
474 * We come before this range and we do not intersect it.
475 * We are not before the root node, it was checked before the loop
478 list
->types
= xlalloc
(run
);
479 for
(i
= 0; i
< run
; ++i
)
480 list
->types
[i
] = flag
;
482 list
->next
= lr
->next
;
488 * At this point we have found that we at least intersect with
489 * the range pointed to by `r', we might intersect with one or
490 * more ranges beyond `r' as well.
493 if
(!flag
&& list
->map
- list
->min
!= r
->map
- r
->min
) {
495 * There are only two cases when we are doing case maps and
496 * our maps needn't have the same offset. When we are adjoining
497 * but not intersecting.
499 if
(list
->max
+ 1 == r
->min
) {
504 if
(list
->min
- 1 == r
->max
) {
505 list
->next
= r
->next
;
509 fprintf
(stderr
, "Error: conflicting map entries\n");
513 if
(list
->min
>= r
->min
&& list
->max
<= r
->max
) {
519 for
(i
= list
->min
; i
<= list
->max
; ++i
)
520 r
->types
[i
- r
->min
] |
= flag
;
525 if
(list
->min
<= r
->min
&& list
->max
>= r
->max
) {
527 * Superset case. Make him big enough to hold us.
528 * We might need to merge with the guy after him.
531 list
->types
= xlalloc
(list
->max
- list
->min
+ 1);
533 for
(i
= list
->min
; i
<= list
->max
; ++i
)
534 list
->types
[i
- list
->min
] = flag
;
536 for
(i
= r
->min
; i
<= r
->max
; ++i
)
537 list
->types
[i
- list
->min
] |
= r
->types
[i
- r
->min
];
540 r
->types
= list
->types
;
547 } else if
(list
->min
< r
->min
) {
549 * Our tail intersects his head.
552 list
->types
= xlalloc
(r
->max
- list
->min
+ 1);
554 for
(i
= r
->min
; i
<= r
->max
; ++i
)
555 list
->types
[i
- list
->min
] = r
->types
[i
- r
->min
];
557 for
(i
= list
->min
; i
< r
->min
; ++i
)
558 list
->types
[i
- list
->min
] = flag
;
560 for
(i
= r
->min
; i
<= list
->max
; ++i
)
561 list
->types
[i
- list
->min
] |
= flag
;
564 r
->types
= list
->types
;
573 * Our head intersects his tail.
574 * We might need to merge with the guy after him.
577 r
->types
= xrelalloc
(r
->types
, list
->max
- r
->min
+ 1);
579 for
(i
= list
->min
; i
<= r
->max
; ++i
)
580 r
->types
[i
- r
->min
] |
= flag
;
582 for
(i
= r
->max
+1; i
<= list
->max
; ++i
)
583 r
->types
[i
- r
->min
] = flag
;
590 * Okay, check to see if we grew into the next guy(s)
592 while
((lr
= r
->next
) && r
->max
>= lr
->min
) {
594 if
(r
->max
>= lr
->max
) {
596 * Good, we consumed all of him.
598 for
(i
= lr
->min
; i
<= lr
->max
; ++i
)
599 r
->types
[i
- r
->min
] |
= lr
->types
[i
- lr
->min
];
602 * "append" him on to the end of us.
604 r
->types
= xrelalloc
(r
->types
, lr
->max
- r
->min
+ 1);
606 for
(i
= lr
->min
; i
<= r
->max
; ++i
)
607 r
->types
[i
- r
->min
] |
= lr
->types
[i
- lr
->min
];
609 for
(i
= r
->max
+1; i
<= lr
->max
; ++i
)
610 r
->types
[i
- r
->min
] = lr
->types
[i
- lr
->min
];
615 if
(lr
->max
> r
->max
)
636 * See if we can compress some of the istype arrays
638 for
(list
= types.root
; list
; list
= list
->next
) {
639 list
->map
= list
->types
[0];
640 for
(x
= 1; x
< list
->max
- list
->min
+ 1; ++x
) {
641 if
(list
->types
[x
] != list
->map
) {
649 * Fill in our tables. Do this in network order so that
650 * diverse machines have a chance of sharing data.
651 * (Machines like Crays cannot share with little machines due to
652 * word size. Sigh. We tried.)
654 for
(x
= 0; x
< _CTYPE_CACHE_SIZE
; ++x
) {
655 new_locale.frl_runetype
[x
] = htonl
(types.map
[x
]);
656 new_locale.frl_maplower
[x
] = htonl
(maplower.map
[x
]);
657 new_locale.frl_mapupper
[x
] = htonl
(mapupper.map
[x
]);
661 * Count up how many ranges we will need for each of the extents.
665 nranges
= (u_int32_t
)0;
670 new_locale.frl_runetype_ext.frr_nranges
=
673 list
= maplower.root
;
675 nranges
= (u_int32_t
)0;
680 new_locale.frl_maplower_ext.frr_nranges
=
683 list
= mapupper.root
;
685 nranges
= (u_int32_t
)0;
690 new_locale.frl_mapupper_ext.frr_nranges
=
694 * Okay, we are now ready to write the new locale file.
698 * PART 1: The _RuneLocale structure
700 if
(fwrite
((char *)&new_locale
, sizeof
(new_locale
), 1, fp
) != 1)
701 err
(1, "writing _FileRuneLocale to %s", locale_file
);
703 * PART 2: The runetype_ext structures (not the actual tables)
705 for
(list
= types.root
, n
= 0; list
!= NULL
; list
= list
->next
, n
++) {
708 memset
(&re
, 0, sizeof
(re
));
709 re.fre_min
= htonl
(list
->min
);
710 re.fre_max
= htonl
(list
->max
);
711 re.fre_map
= htonl
(list
->map
);
713 if
(fwrite
((char *)&re
, sizeof
(re
), 1, fp
) != 1)
714 err
(1, "writing runetype_ext #%d to %s", n
, locale_file
);
717 * PART 3: The maplower_ext structures
719 for
(list
= maplower.root
, n
= 0; list
!= NULL
; list
= list
->next
, n
++) {
722 memset
(&re
, 0, sizeof
(re
));
723 re.fre_min
= htonl
(list
->min
);
724 re.fre_max
= htonl
(list
->max
);
725 re.fre_map
= htonl
(list
->map
);
727 if
(fwrite
((char *)&re
, sizeof
(re
), 1, fp
) != 1)
728 err
(1, "writing maplower_ext #%d to %s", n
, locale_file
);
731 * PART 4: The mapupper_ext structures
733 for
(list
= mapupper.root
, n
= 0; list
!= NULL
; list
= list
->next
, n
++) {
736 memset
(&re
, 0, sizeof
(re
));
737 re.fre_min
= htonl
(list
->min
);
738 re.fre_max
= htonl
(list
->max
);
739 re.fre_map
= htonl
(list
->map
);
741 if
(fwrite
((char *)&re
, sizeof
(re
), 1, fp
) != 1)
742 err
(1, "writing mapupper_ext #%d to %s", n
, locale_file
);
745 * PART 5: The runetype_ext tables
747 for
(list
= types.root
, n
= 0; list
!= NULL
; list
= list
->next
, n
++) {
748 for
(x
= 0; x
< list
->max
- list
->min
+ 1; ++x
)
749 list
->types
[x
] = htonl
(list
->types
[x
]);
752 if
(fwrite
((char *)list
->types
,
753 (list
->max
- list
->min
+ 1) * sizeof
(u_int32_t
),
755 err
(1, "writing runetype_ext table #%d to %s", n
, locale_file
);
759 * PART 5: And finally the variable data
761 if
(rl_variable_len
!= 0 &&
762 fwrite
((char *)rl_variable
, rl_variable_len
, 1, fp
) != 1)
763 err
(1, "writing variable data to %s", locale_file
);
769 if
(new_locale.frl_encoding
[0])
770 fprintf
(stderr
, "ENCODING %.*s\n",
771 (int)sizeof
(new_locale.frl_encoding
), new_locale.frl_encoding
);
773 fprintf
(stderr
, "VARIABLE %.*s\n",
774 (int)rl_variable_len
, (char *)rl_variable
);
776 fprintf
(stderr
, "\nMAPLOWER:\n\n");
778 for
(x
= 0; x
< _CTYPE_CACHE_SIZE
; ++x
) {
779 if
(isprint
(maplower.map
[x
]))
780 fprintf
(stderr
, " '%c'", (int)maplower.map
[x
]);
781 else if
(maplower.map
[x
])
782 fprintf
(stderr
, "%04x", maplower.map
[x
]);
784 fprintf
(stderr
, "%4x", 0);
785 if
((x
& 0xf) == 0xf)
786 fprintf
(stderr
, "\n");
788 fprintf
(stderr
, " ");
790 fprintf
(stderr
, "\n");
792 for
(list
= maplower.root
; list
; list
= list
->next
)
793 fprintf
(stderr
, "\t%04x - %04x : %04x\n", list
->min
, list
->max
, list
->map
);
795 fprintf
(stderr
, "\nMAPUPPER:\n\n");
797 for
(x
= 0; x
< _CTYPE_CACHE_SIZE
; ++x
) {
798 if
(isprint
(mapupper.map
[x
]))
799 fprintf
(stderr
, " '%c'", (int)mapupper.map
[x
]);
800 else if
(mapupper.map
[x
])
801 fprintf
(stderr
, "%04x", mapupper.map
[x
]);
803 fprintf
(stderr
, "%4x", 0);
804 if
((x
& 0xf) == 0xf)
805 fprintf
(stderr
, "\n");
807 fprintf
(stderr
, " ");
809 fprintf
(stderr
, "\n");
811 for
(list
= mapupper.root
; list
; list
= list
->next
)
812 fprintf
(stderr
, "\t%04x - %04x : %04x\n", list
->min
, list
->max
, list
->map
);
815 fprintf
(stderr
, "\nTYPES:\n\n");
817 for
(x
= 0; x
< _CTYPE_CACHE_SIZE
; ++x
) {
818 u_int32_t r
= types.map
[x
];
822 fprintf
(stderr
, " '%c':%2d", x
, (int)(r
& 0xff));
824 fprintf
(stderr
, "%04x:%2d", x
, (int)(r
& 0xff));
826 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_A
) ?
"alph" : "");
827 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_C
) ?
"ctrl" : "");
828 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_D
) ?
"dig" : "");
829 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_G
) ?
"graf" : "");
830 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_L
) ?
"low" : "");
831 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_P
) ?
"punc" : "");
832 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_S
) ?
"spac" : "");
833 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_U
) ?
"upp" : "");
834 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_X
) ?
"xdig" : "");
835 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_B
) ?
"blnk" : "");
836 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_R
) ?
"prnt" : "");
837 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_I
) ?
"ideo" : "");
838 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_T
) ?
"spec" : "");
839 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_Q
) ?
"phon" : "");
840 fprintf
(stderr
, "\n");
844 for
(list
= types.root
; list
; list
= list
->next
) {
845 if
(list
->map
&& list
->min
+ 3 < list
->max
) {
846 u_int32_t r
= list
->map
;
848 fprintf
(stderr
, "%04x:%2d", list
->min
, r
& 0xff);
850 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_A
) ?
"alph" : "");
851 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_C
) ?
"ctrl" : "");
852 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_D
) ?
"dig" : "");
853 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_G
) ?
"graf" : "");
854 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_L
) ?
"low" : "");
855 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_P
) ?
"punc" : "");
856 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_S
) ?
"spac" : "");
857 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_U
) ?
"upp" : "");
858 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_X
) ?
"xdig" : "");
859 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_B
) ?
"blnk" : "");
860 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_R
) ?
"prnt" : "");
861 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_I
) ?
"ideo" : "");
862 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_T
) ?
"spec" : "");
863 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_Q
) ?
"phon" : "");
864 fprintf
(stderr
, "\n...\n");
866 fprintf
(stderr
, "%04x:%2d", list
->max
, r
& 0xff);
868 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_A
) ?
"alph" : "");
869 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_C
) ?
"ctrl" : "");
870 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_D
) ?
"dig" : "");
871 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_G
) ?
"graf" : "");
872 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_L
) ?
"low" : "");
873 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_P
) ?
"punc" : "");
874 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_S
) ?
"spac" : "");
875 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_U
) ?
"upp" : "");
876 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_X
) ?
"xdig" : "");
877 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_B
) ?
"blnk" : "");
878 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_R
) ?
"prnt" : "");
879 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_I
) ?
"ideo" : "");
880 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_T
) ?
"spec" : "");
881 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_Q
) ?
"phon" : "");
882 fprintf
(stderr
, " %1u", (unsigned)((r
& _RUNETYPE_SWM
)>>_RUNETYPE_SWS
));
883 fprintf
(stderr
, "\n");
885 for
(x
= list
->min
; x
<= list
->max
; ++x
) {
886 u_int32_t r
= ntohl
(list
->types
[x
- list
->min
]);
889 fprintf
(stderr
, "%04x:%2d", x
, (int)(r
& 0xff));
891 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_A
) ?
"alph" : "");
892 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_C
) ?
"ctrl" : "");
893 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_D
) ?
"dig" : "");
894 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_G
) ?
"graf" : "");
895 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_L
) ?
"low" : "");
896 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_P
) ?
"punc" : "");
897 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_S
) ?
"spac" : "");
898 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_U
) ?
"upp" : "");
899 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_X
) ?
"xdig" : "");
900 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_B
) ?
"blnk" : "");
901 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_R
) ?
"prnt" : "");
902 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_I
) ?
"ideo" : "");
903 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_T
) ?
"spec" : "");
904 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_Q
) ?
"phon" : "");
905 fprintf
(stderr
, " %1u", (unsigned)((r
& _RUNETYPE_SWM
)>>_RUNETYPE_SWS
));
906 fprintf
(stderr
, "\n");