2 * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
4 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
17 #include "include/bits/uClibc_charclass.h"
19 /* 0x9 : space blank */
24 /* 0x20 : space blank */
25 /* 0x1680 : space blank */
26 /* 0x2000 : space blank */
27 /* 0x2001 : space blank */
28 /* 0x2002 : space blank */
29 /* 0x2003 : space blank */
30 /* 0x2004 : space blank */
31 /* 0x2005 : space blank */
32 /* 0x2006 : space blank */
33 /* 0x2008 : space blank */
34 /* 0x2009 : space blank */
35 /* 0x200a : space blank */
36 /* 0x200b : space blank */
39 /* 0x3000 : space blank */
41 /* typecount[ 0] = 88670 C_alpha_nonupper_nonlower */
42 /* typecount[ 1] = 742 C_alpha_lower */
43 /* typecount[ 2] = 4 C_alpha_upper_lower */
44 /* typecount[ 3] = 731 C_alpha_upper */
45 /* typecount[ 4] = 10 C_digit */
46 /* typecount[ 5] = 10270 C_punct */
47 /* typecount[ 6] = 0 C_graph */
48 /* typecount[ 7] = 0 C_print_space_nonblank */
49 /* typecount[ 8] = 14 C_print_space_blank */
50 /* typecount[ 9] = 0 C_space_nonblank_noncntrl */
51 /* typecount[10] = 0 C_space_blank_noncntrl */
52 /* typecount[11] = 6 C_cntrl_space_nonblank */
53 /* typecount[12] = 1 C_cntrl_space_blank */
54 /* typecount[13] = 60 C_cntrl_nonspace */
55 /* typecount[14] = 96100 C_unclassified */
56 /* typecount[15] = 0 empty_slot */
59 /* Set to #if 0 to restrict wchars to 16 bits. */
61 #define RANGE 0x2ffffUL
63 #define RANGE 0x1ffffUL
65 #define RANGE 0xffffUL /* Restrict for 16-bit wchar_t... */
68 /* Some macros that test for various (w)ctype classes when passed one of the
69 * designator values enumerated above. */
70 #define mywalnum(D,C) ((unsigned)(D - 1) <= (__CTYPE_digit - 1))
71 #define mywalpha(D,C) ((unsigned)(D - 1) <= (__CTYPE_alpha_upper - 1))
72 #define mywblank(D,C) ((unsigned)(D - __CTYPE_print_space_nonblank) <= 5 && (D & 1))
73 #define mywcntrl(D,C) ((unsigned)(D - __CTYPE_cntrl_space_nonblank) <= 2)
74 #define mywdigit(D,C) (D == __CTYPE_digit)
75 #define mywgraph(D,C) ((unsigned)(D - 1) <= (__CTYPE_graph - 1))
76 #define mywlower(D,C) ((unsigned)(D - __CTYPE_alpha_lower) <= 1)
77 #define mywprint(D,C) ((unsigned)(D - 1) <= (__CTYPE_print_space_blank - 1))
78 #define mywpunct(D,C) (D == __CTYPE_punct)
79 #define mywspace(D,C) ((unsigned)(D - __CTYPE_print_space_nonblank) <= 5)
80 #define mywupper(D,C) ((unsigned)(D - __CTYPE_alpha_upper_lower) <= 1)
81 /* #define mywxdigit(D,C) -- isxdigit is untestable this way.
82 * But that's ok as isxdigit() (and isdigit() too) are locale-invariant. */
83 #define mywxdigit(D,C) (mywdigit(D,C) || (unsigned)(((C) | 0x20) - 'a') <= 5)
95 unsigned char ii_shift
;
96 unsigned char ti_shift
;
103 static unsigned verbose
;
104 #define verbose_msg(msg...) if (verbose) fprintf(stderr, msg)
106 void output_table(const char *name
, table_data
*tbl
)
110 printf("#define __LOCALE_DATA_WC%s_II_LEN %7u\n", name
, tbl
->ii_len
);
111 printf("#define __LOCALE_DATA_WC%s_TI_LEN %7u\n", name
, tbl
->ti_len
);
112 printf("#define __LOCALE_DATA_WC%s_UT_LEN %7u\n", name
, tbl
->ut_len
);
114 printf("#define __LOCALE_DATA_WC%s_II_SHIFT %7u\n", name
, tbl
->ii_shift
);
115 printf("#define __LOCALE_DATA_WC%s_TI_SHIFT %7u\n", name
, tbl
->ti_shift
);
117 printf("\n#ifdef WANT_WC%s_data\n", name
);
119 i
= tbl
->ii_len
+ tbl
->ti_len
+ tbl
->ut_len
;
120 printf("\nstatic const unsigned char __LOCALE_DATA_WC%s_data[%zu] = {", name
, i
);
121 for (i
= 0; i
< tbl
->ii_len
; i
++) {
125 printf(" %#04x,", tbl
->ii
[i
]);
127 for (i
= 0; i
< tbl
->ti_len
; i
++) {
131 printf(" %#04x,", tbl
->ti
[i
]);
133 for (i
= 0; i
< tbl
->ut_len
; i
++) {
137 printf(" %#04x,", tbl
->ut
[i
]);
141 printf("#endif /* WANT_WC%s_data */\n\n", name
);
144 static void dump_table_data(table_data
*tbl
)
146 verbose_msg("ii_shift = %d ti_shift = %d\n"
147 "ii_len = %d ti_len = %d ut_len = %d\n"
149 tbl
->ii_shift
, tbl
->ti_shift
,
150 tbl
->ii_len
, tbl
->ti_len
, tbl
->ut_len
,
151 (int) tbl
->ii_len
+ (int) tbl
->ti_len
+ (int) tbl
->ut_len
);
154 /* For sorting the blocks of unsigned chars. */
155 static size_t nu_val
;
157 int nu_memcmp(const void *a
, const void *b
)
159 return memcmp(*(unsigned char**)a
, *(unsigned char**)b
, nu_val
);
162 static size_t newopt(unsigned char *ut
, size_t usize
, int shift
, table_data
*tbl
);
164 #define MAXTO 255 /* Restrict to minimal unsigned char max. */
166 int main(int argc
, char **argv
)
174 uldiff_entry uldiff
[MAXTO
];
178 table_data combtable
;
179 table_data widthtable
;
180 long int last_comb
= 0;
182 unsigned char wct
[(RANGE
/2)+1]; /* wctype table (nibble per wchar) */
183 unsigned char ult
[RANGE
+1]; /* upper/lower table */
184 unsigned char combt
[(RANGE
/4)+1]; /* combining */
185 unsigned char widtht
[(RANGE
/4)+1]; /* width */
187 wctype_t is_comb
, is_comb3
;
189 long int typecount
[16];
190 const char *typename
[16];
191 static const char empty_slot
[] = "empty_slot";
194 #define INIT_TYPENAME(X) typename[__CTYPE_##X] = "C_" #X
196 for (i
= 0; i
< 16; i
++) {
197 typename
[i
] = empty_slot
;
200 INIT_TYPENAME(unclassified
);
201 INIT_TYPENAME(alpha_nonupper_nonlower
);
202 INIT_TYPENAME(alpha_lower
);
203 INIT_TYPENAME(alpha_upper_lower
);
204 INIT_TYPENAME(alpha_upper
);
205 INIT_TYPENAME(digit
);
206 INIT_TYPENAME(punct
);
207 INIT_TYPENAME(graph
);
208 INIT_TYPENAME(print_space_nonblank
);
209 INIT_TYPENAME(print_space_blank
);
210 INIT_TYPENAME(space_nonblank_noncntrl
);
211 INIT_TYPENAME(space_blank_noncntrl
);
212 INIT_TYPENAME(cntrl_space_nonblank
);
213 INIT_TYPENAME(cntrl_space_blank
);
214 INIT_TYPENAME(cntrl_nonspace
);
216 memset(&cttable
, 0, sizeof(table_data
));
217 memset(&ultable
, 0, sizeof(table_data
));
219 memset(combtable
, 0, sizeof(table_data
));
220 memset(widthtable
, 0, sizeof(table_data
));
222 setvbuf(stdout
, NULL
, _IONBF
, 0);
226 if (!strcmp(*argv
, "-v")) {
230 if (!setlocale(LC_CTYPE
, *argv
)) {
231 verbose_msg("setlocale(LC_CTYPE,%s) failed! Skipping this locale...\n", *argv
);
235 if (!(totitle
= wctrans("totitle"))) {
236 verbose_msg("no totitle transformation.\n");
238 if (!(is_comb
= wctype("combining"))) {
239 verbose_msg("no combining wctype.\n");
241 if (!(is_comb3
= wctype("combining_level3"))) {
242 verbose_msg("no combining_level3 wctype.\n");
248 uldiff
[0].u
= uldiff
[0].l
= 0;
250 memset(wct
, 0, sizeof(wct
));
251 memset(combt
, 0, sizeof(combt
));
252 memset(widtht
, 0, sizeof(widtht
));
254 for (i
= 0; i
< 16; i
++) {
258 for (c
= 0; c
<= RANGE
; c
++) {
261 } else if (iswalpha(c
)) {
262 d
= __CTYPE_alpha_nonupper_nonlower
;
264 d
= __CTYPE_alpha_lower
;
266 d
= __CTYPE_alpha_upper_lower
;
268 } else if (iswupper(c
)) {
269 d
= __CTYPE_alpha_upper
;
271 } else if (iswpunct(c
)) {
273 } else if (iswgraph(c
)) {
275 } else if (iswprint(c
)) {
276 d
= __CTYPE_print_space_nonblank
;
278 d
= __CTYPE_print_space_blank
;
280 } else if (iswspace(c
) && !iswcntrl(c
)) {
281 d
= __CTYPE_space_nonblank_noncntrl
;
283 d
= __CTYPE_space_blank_noncntrl
;
285 } else if (iswcntrl(c
)) {
286 d
= __CTYPE_cntrl_nonspace
;
288 d
= __CTYPE_cntrl_space_nonblank
;
290 d
= __CTYPE_cntrl_space_blank
;
294 d
= __CTYPE_unclassified
;
301 verbose_msg("%#8x : space blank\n", c
);
303 verbose_msg("%#8x : space\n", c
);
312 if (isalnum(c
)) ++glibc
; glibc
<<= 1;
313 if (isalpha(c
)) ++glibc
; glibc
<<= 1;
314 if (isblank(c
)) ++glibc
; glibc
<<= 1;
315 if (iscntrl(c
)) ++glibc
; glibc
<<= 1;
316 if (isdigit(c
)) ++glibc
; glibc
<<= 1;
317 if (isgraph(c
)) ++glibc
; glibc
<<= 1;
318 if (islower(c
)) ++glibc
; glibc
<<= 1;
319 if (isprint(c
)) ++glibc
; glibc
<<= 1;
320 if (ispunct(c
)) ++glibc
; glibc
<<= 1;
321 if (isspace(c
)) ++glibc
; glibc
<<= 1;
322 if (isupper(c
)) ++glibc
; glibc
<<= 1;
323 if (isxdigit(c
)) ++glibc
;
324 verbose_msg("%#8x : ctype %#4x\n", c
, glibc
);
328 /* Paranoid checking... */
334 if (iswalnum(c
)) ++glibc
; glibc
<<= 1;
335 if (iswalpha(c
)) ++glibc
; glibc
<<= 1;
336 if (iswblank(c
)) ++glibc
; glibc
<<= 1;
337 if (iswcntrl(c
)) ++glibc
; glibc
<<= 1;
338 if (iswdigit(c
)) ++glibc
; glibc
<<= 1;
339 if (iswgraph(c
)) ++glibc
; glibc
<<= 1;
340 if (iswlower(c
)) ++glibc
; glibc
<<= 1;
341 if (iswprint(c
)) ++glibc
; glibc
<<= 1;
342 if (iswpunct(c
)) ++glibc
; glibc
<<= 1;
343 if (iswspace(c
)) ++glibc
; glibc
<<= 1;
344 if (iswupper(c
)) ++glibc
; glibc
<<= 1;
345 if (iswxdigit(c
)) ++glibc
;
348 if (mywalnum(d
,c
)) ++mine
; mine
<<= 1;
349 if (mywalpha(d
,c
)) ++mine
; mine
<<= 1;
350 if (mywblank(d
,c
)) ++mine
; mine
<<= 1;
351 if (mywcntrl(d
,c
)) ++mine
; mine
<<= 1;
352 if (mywdigit(d
,c
)) ++mine
; mine
<<= 1;
353 if (mywgraph(d
,c
)) ++mine
; mine
<<= 1;
354 if (mywlower(d
,c
)) ++mine
; mine
<<= 1;
355 if (mywprint(d
,c
)) ++mine
; mine
<<= 1;
356 if (mywpunct(d
,c
)) ++mine
; mine
<<= 1;
357 if (mywspace(d
,c
)) ++mine
; mine
<<= 1;
358 if (mywupper(d
,c
)) ++mine
; mine
<<= 1;
359 if (mywxdigit(d
,c
)) ++mine
;
362 verbose_msg("%#8x : glibc %#4x != %#4x mine %u\n", c
, glibc
, mine
, d
);
366 if (iswctype(c
,is_comb
) || iswctype(c
,is_comb3
)) {
367 /* if (!iswpunct(c)) { */
368 verbose_msg("%#8x : %d %d %#4x\n",
369 c
, iswctype(c
,is_comb
),iswctype(c
,is_comb3
), glibc
);
374 if (iswctype(c
,is_comb
) || iswctype(c
,is_comb3
)) {
376 verbose_msg("%#8x - ", c
);
378 } else if (last_comb
+ 1 < c
) {
379 verbose_msg("%#8x\n%#8x - ", last_comb
, c
);
389 combt
[c
/4] |= ((((!!iswctype(c
,is_comb
)) << 1) | !!iswctype(c
,is_comb3
))
391 /* comb3t[c/8] |= ((!!iswctype(c,is_comb3)) << (c & 7)); */
393 /* widtht[c/4] |= (wcwidth(c) << ((c & 3) << 1)); */
395 if (c
& 1) { /* Use the high nibble for odd numbered wchars. */
400 l
= (long)(int) towlower(c
) - c
;
401 u
= (long)(int) towupper(c
) - c
;
404 if ((l
!= (short)l
) || (u
!= (short)u
)) {
405 verbose_msg("range assumption error! %x %ld %ld\n", c
, l
, u
);
408 for (i
= 0; i
< ul_count
; i
++) {
409 if ((l
== uldiff
[i
].l
) && (u
== uldiff
[i
].u
)) {
413 uldiff
[ul_count
].l
= l
;
414 uldiff
[ul_count
].u
= u
;
416 if (ul_count
> MAXTO
) {
417 verbose_msg("too many touppers/tolowers!\n");
425 for (i
= 0; i
< 16; i
++) {
426 verbose_msg("typecount[%2d] = %8ld %s\n", i
, typecount
[i
], typename
[i
]);
429 verbose_msg("optimizing is* table..\n");
433 for (i
= 0; i
< 14; i
++) {
434 t
= newopt(wct
, (RANGE
/2)+1, i
, &cttable
);
442 verbose_msg("smallest = %zu\n", smallest
);
443 if (!(cttable
.ii
= malloc(smallest
))) {
444 verbose_msg("couldn't allocate space!\n");
448 newopt(wct
, (RANGE
/2)+1, n
, &cttable
);
449 ++cttable
.ti_shift
; /* correct for nibble mode */
451 verbose_msg("optimizing u/l-to table..\n");
454 for (i
= 0; i
< 14; i
++) {
455 t
= newopt(ult
, RANGE
+1, i
, &ultable
);
463 verbose_msg("%lu (smallest) + %lu (u/l diffs) = %lu\n",
464 (unsigned long) smallest
,
465 (unsigned long) (4 * ul_count
),
466 (unsigned long) (smallest
+ 4 * ul_count
)
468 verbose_msg("smallest = %zu\n", smallest
);
469 if (!(ultable
.ii
= malloc(smallest
))) {
470 verbose_msg("couldn't allocate space!\n");
474 newopt(ult
, RANGE
+1, n
, &ultable
);
476 verbose_msg("optimizing comb table..\n");
479 for (i
= 0; i
< 14; i
++) {
480 t
= newopt(combt
, sizeof(combt
), i
, &combtable
);
488 verbose_msg("smallest = %zu\n", smallest
);
489 if (!(combtable
.ii
= malloc(smallest
))) {
490 verbose_msg("couldn't allocate space!\n");
494 newopt(combt
, sizeof(combt
), n
, &combtable
);
495 combtable
.ti_shift
+= 4; /* correct for 4 entries per */
498 verbose_msg("optimizing width table..\n");
500 widthtable
.ii
= NULL
;
501 for (i
= 0; i
< 14; i
++) {
502 t
= newopt(widtht
, sizeof(widtht
), i
, &widthtable
);
510 verbose_msg("smallest = %zu\n", smallest
);
511 if (!(widthtable
.ii
= malloc(smallest
))) {
512 verbose_msg("couldn't allocate space!\n");
516 newopt(widtht
, sizeof(widtht
), n
, &widthtable
);
517 widthtable
.ti_shift
+= 4; /* correct for 4 entries per */
520 verbose_msg("optimizing comb3 table..\n");
522 comb3table
.ii
= NULL
;
523 for (i
= 0; i
< 14; i
++) {
524 t
= newopt(comb3t
, sizeof(comb3t
), i
, &comb3table
);
532 verbose_msg("smallest = %zu\n", smallest
);
533 if (!(comb3table
.ii
= malloc(smallest
))) {
534 verbose_msg("couldn't allocate space!\n");
538 newopt(comb3t
, sizeof(comb3t
), n
, &comb3table
);
539 comb3table
.ti_shift
+= 8; /* correct for 4 entries per */
542 dump_table_data(&cttable
);
543 dump_table_data(&ultable
);
545 dump_table_data(&combtable
);
549 verbose_msg("verifying for %s...\n", *argv
);
551 for (c
= 0; c
<= 0xffffUL
; c
++)
553 for (c
= 0; c
<= 0x10ffffUL
; c
++)
558 unsigned int upper
, lower
;
561 #if RANGE < 0x10000UL
562 if (c
== 0x10000UL
) {
563 c
= 0x30000UL
; /* skip 1st and 2nd sup planes */
565 #elif RANGE < 0x20000UL
566 if (c
== 0x20000UL
) {
567 c
= 0x30000UL
; /* skip 2nd sup planes */
572 if (iswalnum(c
)) ++glibc
; glibc
<<= 1;
573 if (iswalpha(c
)) ++glibc
; glibc
<<= 1;
574 if (iswblank(c
)) ++glibc
; glibc
<<= 1;
575 if (iswcntrl(c
)) ++glibc
; glibc
<<= 1;
576 if (iswdigit(c
)) ++glibc
; glibc
<<= 1;
577 if (iswgraph(c
)) ++glibc
; glibc
<<= 1;
578 if (iswlower(c
)) ++glibc
; glibc
<<= 1;
579 if (iswprint(c
)) ++glibc
; glibc
<<= 1;
580 if (iswpunct(c
)) ++glibc
; glibc
<<= 1;
581 if (iswspace(c
)) ++glibc
; glibc
<<= 1;
582 if (iswupper(c
)) ++glibc
; glibc
<<= 1;
583 if (iswxdigit(c
)) ++glibc
;
587 int n
= 0, sc
= 0; /* = 0 for verbose_msg only */
592 sc
= u
& ((1 << cttable
.ti_shift
) - 1);
593 u
>>= cttable
.ti_shift
;
594 n
= u
& ((1 << cttable
.ii_shift
) - 1);
595 u
>>= cttable
.ii_shift
;
598 i0
<<= cttable
.ii_shift
;
599 i1
= cttable
.ti
[i0
+ n
];
600 i1
<<= (cttable
.ti_shift
- 1);
601 d
= cttable
.ut
[i1
+ (sc
>> 1)];
607 } else if (((unsigned)(c
- 0xe0020UL
) <= 0x5f) || (c
== 0xe0001UL
)) {
609 } else if ((unsigned)(c
- 0xf0000UL
) < 0x20000UL
) {
610 if ((c
& 0xffffU
) <= 0xfffdU
) {
613 d
= __CTYPE_unclassified
;
616 d
= __CTYPE_unclassified
;
620 if (mywalnum(d
,c
)) ++mine
; mine
<<= 1;
621 if (mywalpha(d
,c
)) ++mine
; mine
<<= 1;
622 if (mywblank(d
,c
)) ++mine
; mine
<<= 1;
623 if (mywcntrl(d
,c
)) ++mine
; mine
<<= 1;
624 if (mywdigit(d
,c
)) ++mine
; mine
<<= 1;
625 if (mywgraph(d
,c
)) ++mine
; mine
<<= 1;
626 if (mywlower(d
,c
)) ++mine
; mine
<<= 1;
627 if (mywprint(d
,c
)) ++mine
; mine
<<= 1;
628 if (mywpunct(d
,c
)) ++mine
; mine
<<= 1;
629 if (mywspace(d
,c
)) ++mine
; mine
<<= 1;
630 if (mywupper(d
,c
)) ++mine
; mine
<<= 1;
631 if (mywxdigit(d
,c
)) ++mine
;
634 verbose_msg("%#8x : glibc %#4x != %#4x mine %d\n", c
, glibc
, mine
, d
);
636 verbose_msg("sc=%#x u=%#x n=%#x i0=%#x i1=%#x\n", sc
, u
, n
, i0
, i1
);
640 upper
= lower
= u
= c
;
642 sc
= u
& ((1 << ultable
.ti_shift
) - 1);
643 u
>>= ultable
.ti_shift
;
644 n
= u
& ((1 << ultable
.ii_shift
) - 1);
645 u
>>= ultable
.ii_shift
;
648 i0
<<= ultable
.ii_shift
;
649 i1
= ultable
.ti
[i0
+ n
];
650 i1
<<= (ultable
.ti_shift
);
653 upper
= c
+ uldiff
[i0
].u
;
654 lower
= c
+ uldiff
[i0
].l
;
657 if (towupper(c
) != upper
) {
658 verbose_msg("%#8x : towupper glibc %#4x != %#4x mine\n",
659 c
, towupper(c
), upper
);
662 if (towlower(c
) != lower
) {
663 verbose_msg("%#8x : towlower glibc %#4x != %#4x mine i0 = %d\n",
664 c
, towlower(c
), lower
, i0
);
667 if (totitle
&& ((tt
= towctrans(c
, totitle
)) != upper
)) {
668 verbose_msg("%#8x : totitle glibc %#4lx != %#4x mine i0 = %d\n",
673 if ((c
& 0xfff) == 0xfff) verbose_msg(".");
675 verbose_msg("done\n");
679 printf("#define __LOCALE_DATA_WC_TABLE_DOMAIN_MAX %#8lx\n\n",
680 (unsigned long) RANGE
);
681 output_table("ctype", &cttable
);
682 output_table("uplow", &ultable
);
684 #warning fix the upper bound on the upper/lower tables... save 200 bytes or so
685 printf("#define __LOCALE_DATA_WCuplow_diffs %7u\n", ul_count
);
686 printf("\n#ifdef WANT_WCuplow_diff_data\n\n");
687 printf("\nstatic const short __LOCALE_DATA_WCuplow_diff_data[%zu] = {",
688 2 * (size_t) ul_count
);
689 for (i
= 0; i
< ul_count
; i
++) {
693 printf(" %6d, %6d,", uldiff
[i
].u
, uldiff
[i
].l
);
696 printf("#endif /* WANT_WCuplow_diff_data */\n\n");
698 /* output_table("comb", &combtable); */
699 /* output_table("width", &widthtable); */
705 size_t newopt(unsigned char *ut
, size_t usize
, int shift
, table_data
*tbl
)
708 unsigned char *ti
[RANGE
+1]; /* table index */
714 unsigned char *ii_save
;
716 unsigned char uit
[RANGE
+1];
719 memset(uniqblock
, 0x00, sizeof(uniqblock
));
722 blocksize
= 1 << shift
;
723 numblocks
= usize
>> shift
;
725 /* init table index */
726 for (i
=j
= 0; i
< numblocks
; i
++) {
733 qsort(ti
, numblocks
, sizeof(unsigned char *), nu_memcmp
);
736 uit
[(ti
[0]-ut
)/blocksize
] = 0;
737 for (i
=1; i
< numblocks
; i
++) {
738 if (memcmp(ti
[i
-1], ti
[i
], blocksize
) < 0) {
742 uniqblock
[uniq
- 1] = i
;
745 else if (memcmp(ti
[i
-1], ti
[i
], blocksize
) > 0) {
746 verbose_msg("bad sort %li!\n", (long) i
);
750 uit
[(ti
[i
]-ut
)/blocksize
] = uniq
- 1;
759 smallest
= numblocks
+ uniq
* blocksize
;
762 for (j
=1; j
< 14; j
++) {
763 if ((numblocks
>> j
) < 2) break;
768 if ((t
= newopt(uit
, numblocks
, j
, tbl
)) < SIZE_MAX
) {
769 t
+= uniq
* blocksize
;
778 verbose_msg("ishift %u tshift %u size %lu\n",
779 shift2
, shift
, (unsigned long) t
);
790 tbl
->ii_shift
= shift
;
791 tbl
->ii_len
= numblocks
;
792 memcpy(tbl
->ii
, uit
, numblocks
);
793 tbl
->ti
= tbl
->ii
+ tbl
->ii_len
;
794 tbl
->ti_len
= uniq
* blocksize
;
795 for (i
= 0; i
< uniq
; i
++) {
796 memcpy(tbl
->ti
+ i
* blocksize
, ti
[uniqblock
[i
]], blocksize
);
800 verbose_msg("setting ishift %u tshift %u\n",
802 newopt(uit
, numblocks
, shift2
, tbl
);
804 tbl
->ti_shift
= shift
;
805 tbl
->ut_len
= uniq
* blocksize
;
806 tbl
->ut
= tbl
->ti
+ tbl
->ti_len
;
807 for (i
= 0; i
< uniq
; i
++) {
808 memcpy(tbl
->ut
+ i
* blocksize
, ti
[uniqblock
[i
]], blocksize
);
814 /* vi: set sw=4 ts=4: */