1 /* $NetBSD: src/usr.bin/mklocale/yacc.y,v 1.24 2004/01/05 23:23:36 jmmv Exp $ */
2 /* $DragonFly: src/usr.bin/mklocale/yacc.y,v 1.8 2008/07/10 18:29:52 swildner Exp $ */
7 * The Regents of the University of California. All rights reserved.
9 * This code is derived from software contributed to Berkeley by
10 * Paul Borman at Krystal Technologies.
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * 3. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 #include <sys/types.h>
38 #include <netinet/in.h> /* Needed for htonl on POSIX systems. */
48 #include "locale/runetype.h"
52 const char *locale_file
= "<stdout>";
54 rune_map maplower
= { { 0, }, NULL
};
55 rune_map mapupper
= { { 0, }, NULL
};
56 rune_map types
= { { 0, }, NULL
};
58 _NBRuneLocale new_locale
;
60 __nbrune_t charsetbits
= (__nbrune_t
)0x00000000;
62 __nbrune_t charsetmask
= (__nbrune_t
)0x0000007f;
64 __nbrune_t charsetmask
= (__nbrune_t
)0xffffffff;
66 void set_map
(rune_map
*, rune_list
*, uint32_t);
67 void set_digitmap
(rune_map
*, rune_list
*);
68 void add_map
(rune_map
*, rune_list
*, uint32_t);
70 int main
(int, char *[]);
71 int yyerror(const char *s
);
72 void *xmalloc
(unsigned int sz
);
73 uint32_t *xlalloc
(unsigned int sz
);
74 uint32_t *xrelalloc
(uint32_t *old
, unsigned int sz
);
75 void dump_tables
(void);
77 extern
int yylex(void);
117 entry
: ENCODING STRING
118 { strncpy
(new_locale.rl_encoding
, $2, sizeof
(new_locale.rl_encoding
)); }
120 { new_locale.rl_variable_len
= strlen
($1) + 1;
121 new_locale.rl_variable
= strdup
($1);
124 { charsetbits
= $2; charsetmask
= 0x0000007f; }
126 { charsetbits
= $2; charsetmask
= $3; }
128 { int final
= $2[strlen
($2) - 1] & 0x7f;
129 charsetbits
= final
<< 24;
131 charsetmask
= 0x00007f7f;
132 if
(strchr
(",-./", $2[1]))
134 if
(0xd0 <= final
&& final
<= 0xdf)
135 charsetmask |
= 0x007f0000;
137 charsetmask
= 0x0000007f;
138 if
(strchr
(",-./", $2[0]))
140 if
(strlen
($2) == 2 && $2[0] == '!')
141 charsetbits |
= ((0x80 |
$2[0]) << 16);
147 if
(charsetbits
== ('B' << 24)
148 && charsetmask
== 0x0000007f) {
151 charsetmask
= 0x0000007f;
152 } else if
(charsetbits
== (('A' << 24) |
0x80)
153 && charsetmask
== 0x0000007f) {
156 charsetmask
= 0x0000007f;
160 { new_locale.rl_invalid_rune
= $2; }
162 { set_map
(&types
, $2, $1); }
164 { set_map
(&maplower
, $2, 0); }
166 { set_map
(&mapupper
, $2, 0); }
168 { set_digitmap
(&types
, $2); }
173 $$
= (rune_list
*)malloc
(sizeof
(rune_list
));
174 $$
->min
= ($1 & charsetmask
) | charsetbits
;
175 $$
->max
= ($1 & charsetmask
) | charsetbits
;
180 $$
= (rune_list
*)malloc
(sizeof
(rune_list
));
181 $$
->min
= ($1 & charsetmask
) | charsetbits
;
182 $$
->max
= ($3 & charsetmask
) | charsetbits
;
187 $$
= (rune_list
*)malloc
(sizeof
(rune_list
));
188 $$
->min
= ($2 & charsetmask
) | charsetbits
;
189 $$
->max
= ($2 & charsetmask
) | charsetbits
;
192 | list RUNE THRU RUNE
194 $$
= (rune_list
*)malloc
(sizeof
(rune_list
));
195 $$
->min
= ($2 & charsetmask
) | charsetbits
;
196 $$
->max
= ($4 & charsetmask
) | charsetbits
;
201 map
: LBRK RUNE RUNE RBRK
203 $$
= (rune_list
*)malloc
(sizeof
(rune_list
));
204 $$
->min
= ($2 & charsetmask
) | charsetbits
;
205 $$
->max
= ($2 & charsetmask
) | charsetbits
;
209 | map LBRK RUNE RUNE RBRK
211 $$
= (rune_list
*)malloc
(sizeof
(rune_list
));
212 $$
->min
= ($3 & charsetmask
) | charsetbits
;
213 $$
->max
= ($3 & charsetmask
) | charsetbits
;
217 | LBRK RUNE THRU RUNE
':' RUNE RBRK
219 $$
= (rune_list
*)malloc
(sizeof
(rune_list
));
220 $$
->min
= ($2 & charsetmask
) | charsetbits
;
221 $$
->max
= ($4 & charsetmask
) | charsetbits
;
225 | map LBRK RUNE THRU RUNE
':' RUNE RBRK
227 $$
= (rune_list
*)malloc
(sizeof
(rune_list
));
228 $$
->min
= ($3 & charsetmask
) | charsetbits
;
229 $$
->max
= ($5 & charsetmask
) | charsetbits
;
240 main
(int ac
, char *av
[])
244 while
((x
= getopt
(ac
, av
, "do:")) != -1) {
250 locale_file
= optarg
;
251 if
((ofile
= fopen
(locale_file
, "w")) == 0)
252 err
(1, "unable to open output file %s", locale_file
);
256 fprintf
(stderr
, "usage: mklocale [-d] [-o output] [source]\n");
261 switch
(ac
- optind
) {
265 if
(freopen
(av
[optind
], "r", stdin
) == 0)
266 err
(1, "unable to open input file %s", av
[optind
]);
271 for
(x
= 0; x
< _NB_CACHED_RUNES
; ++x
) {
275 new_locale.rl_invalid_rune
= _NB_DEFAULT_INVALID_RUNE
;
276 memcpy
(new_locale.rl_magic
, _NB_RUNE_MAGIC_1
, sizeof
(new_locale.rl_magic
));
284 yyerror(const char *s
)
286 fprintf
(stderr
, "%s\n", s
);
292 xmalloc
(unsigned int sz
)
294 void *r
= malloc
(sz
);
303 xlalloc
(unsigned int sz
)
305 uint32_t *r
= (uint32_t *)malloc
(sz
* sizeof
(uint32_t));
314 xrelalloc
(uint32_t *old
, unsigned int sz
)
316 uint32_t *r
= (uint32_t *)realloc
((char *)old
, sz
* sizeof
(uint32_t));
325 set_map
(rune_map
*map
, rune_list
*list
, uint32_t flag
)
327 list
->map
&= charsetmask
;
328 list
->map |
= charsetbits
;
330 rune_list
*nlist
= list
->next
;
331 add_map
(map
, list
, flag
);
337 set_digitmap
(rune_map
*map
, rune_list
*list
)
342 rune_list
*nlist
= list
->next
;
343 for
(i
= list
->min
; i
<= list
->max
; ++i
) {
344 if
(list
->map
+ (i
- list
->min
)) {
345 rune_list
*tmp
= (rune_list
*)xmalloc
(sizeof
(rune_list
));
348 add_map
(map
, tmp
, list
->map
+ (i
- list
->min
));
357 add_map
(rune_map
*map
, rune_list
*list
, uint32_t flag
)
364 while
(list
->min
< _NB_CACHED_RUNES
&& list
->min
<= list
->max
) {
366 map
->map
[list
->min
++] |
= flag
;
368 map
->map
[list
->min
++] = list
->map
++;
371 if
(list
->min
> list
->max
) {
376 run
= list
->max
- list
->min
+ 1;
378 if
(!(r
= map
->root
) ||
(list
->max
< r
->min
- 1)
379 ||
(!flag
&& list
->max
== r
->min
- 1)) {
381 list
->types
= xlalloc
(run
);
382 for
(i
= 0; i
< run
; ++i
)
383 list
->types
[i
] = flag
;
385 list
->next
= map
->root
;
390 for
(r
= map
->root
; r
&& r
->max
+ 1 < list
->min
; r
= r
->next
)
395 * We are off the end.
398 list
->types
= xlalloc
(run
);
399 for
(i
= 0; i
< run
; ++i
)
400 list
->types
[i
] = flag
;
407 if
(list
->max
< r
->min
- 1) {
409 * We come before this range and we do not intersect it.
410 * We are not before the root node, it was checked before the loop
413 list
->types
= xlalloc
(run
);
414 for
(i
= 0; i
< run
; ++i
)
415 list
->types
[i
] = flag
;
417 list
->next
= lr
->next
;
423 * At this point we have found that we at least intersect with
424 * the range pointed to by `r', we might intersect with one or
425 * more ranges beyond `r' as well.
428 if
(!flag
&& list
->map
- list
->min
!= r
->map
- r
->min
) {
430 * There are only two cases when we are doing case maps and
431 * our maps needn't have the same offset. When we are adjoining
432 * but not intersecting.
434 if
(list
->max
+ 1 == r
->min
) {
439 if
(list
->min
- 1 == r
->max
) {
440 list
->next
= r
->next
;
444 fprintf
(stderr
, "Error: conflicting map entries\n");
448 if
(list
->min
>= r
->min
&& list
->max
<= r
->max
) {
454 for
(i
= list
->min
; i
<= list
->max
; ++i
)
455 r
->types
[i
- r
->min
] |
= flag
;
460 if
(list
->min
<= r
->min
&& list
->max
>= r
->max
) {
462 * Superset case. Make him big enough to hold us.
463 * We might need to merge with the guy after him.
466 list
->types
= xlalloc
(list
->max
- list
->min
+ 1);
468 for
(i
= list
->min
; i
<= list
->max
; ++i
)
469 list
->types
[i
- list
->min
] = flag
;
471 for
(i
= r
->min
; i
<= r
->max
; ++i
)
472 list
->types
[i
- list
->min
] |
= r
->types
[i
- r
->min
];
475 r
->types
= list
->types
;
482 } else if
(list
->min
< r
->min
) {
484 * Our tail intersects his head.
487 list
->types
= xlalloc
(r
->max
- list
->min
+ 1);
489 for
(i
= r
->min
; i
<= r
->max
; ++i
)
490 list
->types
[i
- list
->min
] = r
->types
[i
- r
->min
];
492 for
(i
= list
->min
; i
< r
->min
; ++i
)
493 list
->types
[i
- list
->min
] = flag
;
495 for
(i
= r
->min
; i
<= list
->max
; ++i
)
496 list
->types
[i
- list
->min
] |
= flag
;
499 r
->types
= list
->types
;
508 * Our head intersects his tail.
509 * We might need to merge with the guy after him.
512 r
->types
= xrelalloc
(r
->types
, list
->max
- r
->min
+ 1);
514 for
(i
= list
->min
; i
<= r
->max
; ++i
)
515 r
->types
[i
- r
->min
] |
= flag
;
517 for
(i
= r
->max
+1; i
<= list
->max
; ++i
)
518 r
->types
[i
- r
->min
] = flag
;
525 * Okay, check to see if we grew into the next guy(s)
527 while
((lr
= r
->next
) && r
->max
>= lr
->min
) {
529 if
(r
->max
>= lr
->max
) {
531 * Good, we consumed all of him.
533 for
(i
= lr
->min
; i
<= lr
->max
; ++i
)
534 r
->types
[i
- r
->min
] |
= lr
->types
[i
- lr
->min
];
537 * "append" him on to the end of us.
539 r
->types
= xrelalloc
(r
->types
, lr
->max
- r
->min
+ 1);
541 for
(i
= lr
->min
; i
<= r
->max
; ++i
)
542 r
->types
[i
- r
->min
] |
= lr
->types
[i
- lr
->min
];
544 for
(i
= r
->max
+1; i
<= lr
->max
; ++i
)
545 r
->types
[i
- r
->min
] = lr
->types
[i
- lr
->min
];
550 if
(lr
->max
> r
->max
)
568 _FileRuneLocale file_new_locale
;
569 FILE *fp
= (ofile ? ofile
: stdout
);
571 memset
(&file_new_locale
, 0, sizeof
(file_new_locale
));
574 * See if we can compress some of the istype arrays
576 for
(list
= types.root
; list
; list
= list
->next
) {
577 list
->map
= list
->types
[0];
578 for
(x
= 1; x
< list
->max
- list
->min
+ 1; ++x
) {
579 if
(list
->types
[x
] != list
->map
) {
586 memcpy
(&file_new_locale.frl_magic
, new_locale.rl_magic
,
587 sizeof
(file_new_locale.frl_magic
));
588 memcpy
(&file_new_locale.frl_encoding
, new_locale.rl_encoding
,
589 sizeof
(file_new_locale.frl_encoding
));
591 file_new_locale.frl_invalid_rune
= htonl
(new_locale.rl_invalid_rune
);
594 * Fill in our tables. Do this in network order so that
595 * diverse machines have a chance of sharing data.
596 * (Machines like Crays cannot share with little machines due to
597 * word size. Sigh. We tried.)
599 for
(x
= 0; x
< _NB_CACHED_RUNES
; ++x
) {
600 file_new_locale.frl_runetype
[x
] = htonl
(types.map
[x
]);
601 file_new_locale.frl_maplower
[x
] = htonl
(maplower.map
[x
]);
602 file_new_locale.frl_mapupper
[x
] = htonl
(mapupper.map
[x
]);
606 * Count up how many ranges we will need for each of the extents.
611 new_locale.rl_runetype_ext.rr_nranges
++;
614 file_new_locale.frl_runetype_ext.frr_nranges
=
615 htonl
(new_locale.rl_runetype_ext.rr_nranges
);
617 list
= maplower.root
;
620 new_locale.rl_maplower_ext.rr_nranges
++;
623 file_new_locale.frl_maplower_ext.frr_nranges
=
624 htonl
(new_locale.rl_maplower_ext.rr_nranges
);
626 list
= mapupper.root
;
629 new_locale.rl_mapupper_ext.rr_nranges
++;
632 file_new_locale.frl_mapupper_ext.frr_nranges
=
633 htonl
(new_locale.rl_mapupper_ext.rr_nranges
);
635 file_new_locale.frl_variable_len
= htonl
(new_locale.rl_variable_len
);
638 * Okay, we are now ready to write the new locale file.
642 * PART 1: The _RuneLocale structure
644 if
(fwrite
((char *)&file_new_locale
, sizeof
(file_new_locale
), 1, fp
) != 1)
645 err
(1, "writing _RuneLocale to %s", locale_file
);
647 * PART 2: The runetype_ext structures (not the actual tables)
649 for
(list
= types.root
, n
= 0; list
!= NULL
; list
= list
->next
, n
++) {
652 memset
(&re
, 0, sizeof
(re
));
653 re.fre_min
= htonl
(list
->min
);
654 re.fre_max
= htonl
(list
->max
);
655 re.fre_map
= htonl
(list
->map
);
657 if
(fwrite
((char *)&re
, sizeof
(re
), 1, fp
) != 1)
658 err
(1, "writing runetype_ext #%d to %s", n
, locale_file
);
661 * PART 3: The maplower_ext structures
663 for
(list
= maplower.root
, n
= 0; list
!= NULL
; list
= list
->next
, n
++) {
666 memset
(&re
, 0, sizeof
(re
));
667 re.fre_min
= htonl
(list
->min
);
668 re.fre_max
= htonl
(list
->max
);
669 re.fre_map
= htonl
(list
->map
);
671 if
(fwrite
((char *)&re
, sizeof
(re
), 1, fp
) != 1)
672 err
(1, "writing maplower_ext #%d to %s", n
, locale_file
);
675 * PART 4: The mapupper_ext structures
677 for
(list
= mapupper.root
, n
= 0; list
!= NULL
; list
= list
->next
, n
++) {
680 memset
(&re
, 0, sizeof
(re
));
681 re.fre_min
= htonl
(list
->min
);
682 re.fre_max
= htonl
(list
->max
);
683 re.fre_map
= htonl
(list
->map
);
685 if
(fwrite
((char *)&re
, sizeof
(re
), 1, fp
) != 1)
686 err
(1, "writing mapupper_ext #%d to %s", n
, locale_file
);
689 * PART 5: The runetype_ext tables
691 for
(list
= types.root
, n
= 0; list
!= NULL
; list
= list
->next
, n
++) {
692 for
(x
= 0; x
< list
->max
- list
->min
+ 1; ++x
)
693 list
->types
[x
] = htonl
(list
->types
[x
]);
696 if
(fwrite
((char *)list
->types
,
697 (list
->max
- list
->min
+ 1) * sizeof
(uint32_t),
699 err
(1, "writing runetype_ext table #%d to %s", n
, locale_file
);
703 * PART 5: And finally the variable data
705 if
(new_locale.rl_variable_len
!= 0 &&
706 fwrite
((char *)new_locale.rl_variable
,
707 new_locale.rl_variable_len
, 1, fp
) != 1)
708 err
(1, "writing variable data to %s", locale_file
);
714 if
(new_locale.rl_encoding
[0])
715 fprintf
(stderr
, "ENCODING %s\n", new_locale.rl_encoding
);
716 if
(new_locale.rl_variable
)
717 fprintf
(stderr
, "VARIABLE %s\n",
718 (char *)new_locale.rl_variable
);
720 fprintf
(stderr
, "\nMAPLOWER:\n\n");
722 for
(x
= 0; x
< _NB_CACHED_RUNES
; ++x
) {
723 if
(isprint
(maplower.map
[x
]))
724 fprintf
(stderr
, " '%c'", (int)maplower.map
[x
]);
725 else if
(maplower.map
[x
])
726 fprintf
(stderr
, "%04x", maplower.map
[x
]);
728 fprintf
(stderr
, "%4x", 0);
729 if
((x
& 0xf) == 0xf)
730 fprintf
(stderr
, "\n");
732 fprintf
(stderr
, " ");
734 fprintf
(stderr
, "\n");
736 for
(list
= maplower.root
; list
; list
= list
->next
)
737 fprintf
(stderr
, "\t%04x - %04x : %04x\n", list
->min
, list
->max
, list
->map
);
739 fprintf
(stderr
, "\nMAPUPPER:\n\n");
741 for
(x
= 0; x
< _NB_CACHED_RUNES
; ++x
) {
742 if
(isprint
(mapupper.map
[x
]))
743 fprintf
(stderr
, " '%c'", (int)mapupper.map
[x
]);
744 else if
(mapupper.map
[x
])
745 fprintf
(stderr
, "%04x", mapupper.map
[x
]);
747 fprintf
(stderr
, "%4x", 0);
748 if
((x
& 0xf) == 0xf)
749 fprintf
(stderr
, "\n");
751 fprintf
(stderr
, " ");
753 fprintf
(stderr
, "\n");
755 for
(list
= mapupper.root
; list
; list
= list
->next
)
756 fprintf
(stderr
, "\t%04x - %04x : %04x\n", list
->min
, list
->max
, list
->map
);
759 fprintf
(stderr
, "\nTYPES:\n\n");
761 for
(x
= 0; x
< _NB_CACHED_RUNES
; ++x
) {
762 uint32_t r
= types.map
[x
];
766 fprintf
(stderr
, " '%c':%2d", x
, (int)(r
& 0xff));
768 fprintf
(stderr
, "%04x:%2d", x
, (int)(r
& 0xff));
770 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_A
) ?
"alph" : "");
771 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_C
) ?
"ctrl" : "");
772 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_D
) ?
"dig" : "");
773 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_G
) ?
"graf" : "");
774 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_L
) ?
"low" : "");
775 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_P
) ?
"punc" : "");
776 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_S
) ?
"spac" : "");
777 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_U
) ?
"upp" : "");
778 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_X
) ?
"xdig" : "");
779 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_B
) ?
"blnk" : "");
780 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_R
) ?
"prnt" : "");
781 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_I
) ?
"ideo" : "");
782 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_T
) ?
"spec" : "");
783 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_Q
) ?
"phon" : "");
784 fprintf
(stderr
, "\n");
788 for
(list
= types.root
; list
; list
= list
->next
) {
789 if
(list
->map
&& list
->min
+ 3 < list
->max
) {
790 uint32_t r
= list
->map
;
792 fprintf
(stderr
, "%04x:%2d", list
->min
, r
& 0xff);
794 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_A
) ?
"alph" : "");
795 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_C
) ?
"ctrl" : "");
796 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_D
) ?
"dig" : "");
797 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_G
) ?
"graf" : "");
798 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_L
) ?
"low" : "");
799 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_P
) ?
"punc" : "");
800 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_S
) ?
"spac" : "");
801 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_U
) ?
"upp" : "");
802 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_X
) ?
"xdig" : "");
803 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_B
) ?
"blnk" : "");
804 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_R
) ?
"prnt" : "");
805 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_I
) ?
"ideo" : "");
806 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_T
) ?
"spec" : "");
807 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_Q
) ?
"phon" : "");
808 fprintf
(stderr
, "\n...\n");
810 fprintf
(stderr
, "%04x:%2d", list
->max
, r
& 0xff);
812 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_A
) ?
"alph" : "");
813 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_C
) ?
"ctrl" : "");
814 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_D
) ?
"dig" : "");
815 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_G
) ?
"graf" : "");
816 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_L
) ?
"low" : "");
817 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_P
) ?
"punc" : "");
818 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_S
) ?
"spac" : "");
819 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_U
) ?
"upp" : "");
820 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_X
) ?
"xdig" : "");
821 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_B
) ?
"blnk" : "");
822 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_R
) ?
"prnt" : "");
823 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_I
) ?
"ideo" : "");
824 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_T
) ?
"spec" : "");
825 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_Q
) ?
"phon" : "");
826 fprintf
(stderr
, " %1u", (unsigned)((r
& _RUNETYPE_SWM
)>>_RUNETYPE_SWS
));
827 fprintf
(stderr
, "\n");
829 for
(x
= list
->min
; x
<= list
->max
; ++x
) {
830 uint32_t r
= ntohl
(list
->types
[x
- list
->min
]);
833 fprintf
(stderr
, "%04x:%2d", x
, (int)(r
& 0xff));
835 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_A
) ?
"alph" : "");
836 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_C
) ?
"ctrl" : "");
837 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_D
) ?
"dig" : "");
838 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_G
) ?
"graf" : "");
839 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_L
) ?
"low" : "");
840 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_P
) ?
"punc" : "");
841 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_S
) ?
"spac" : "");
842 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_U
) ?
"upp" : "");
843 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_X
) ?
"xdig" : "");
844 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_B
) ?
"blnk" : "");
845 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_R
) ?
"prnt" : "");
846 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_I
) ?
"ideo" : "");
847 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_T
) ?
"spec" : "");
848 fprintf
(stderr
, " %4s", (r
& _RUNETYPE_Q
) ?
"phon" : "");
849 fprintf
(stderr
, " %1u", (unsigned)((r
& _RUNETYPE_SWM
)>>_RUNETYPE_SWS
));
850 fprintf
(stderr
, "\n");