Lines Matching +full:low +full:- +full:pass
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
53 #include "un-namespace.h"
73 {{0}, "C.UTF-8"}, 1, 0, 0, 0
83 if (table->map && (table->maplen > 0)) { in destruct_collate()
84 (void) munmap(table->map, table->maplen); in destruct_collate()
96 else if (strcmp(encoding, "C.UTF-8") == 0) in __collate_load()
103 table->header.header.destructor = destruct_collate; in __collate_load()
137 table->__collate_load_error = 1; in __collate_load_tables_l()
145 if (asprintf(&buf, "%s/%s/LC_COLLATE", _PathLocale, encoding) == -1) in __collate_load_tables_l()
176 strlcat(table->header.version, TMP, sizeof (table->header.version)); in __collate_load_tables_l()
182 if ((info->directive_count < 1) || in __collate_load_tables_l()
183 (info->directive_count >= COLL_WEIGHTS_MAX) || in __collate_load_tables_l()
184 ((chains = info->chain_count) < 0)) { in __collate_load_tables_l()
192 (sizeof (collate_large_t) * info->large_count); in __collate_load_tables_l()
193 for (z = 0; z < info->directive_count; z++) { in __collate_load_tables_l()
194 i += sizeof (collate_subst_t) * info->subst_count[z]; in __collate_load_tables_l()
196 if (i != (sbuf.st_size - (TMP - map))) { in __collate_load_tables_l()
202 if (table->map && (table->maplen > 0)) { in __collate_load_tables_l()
203 (void) munmap(table->map, table->maplen); in __collate_load_tables_l()
205 table->map = map; in __collate_load_tables_l()
206 table->maplen = sbuf.st_size; in __collate_load_tables_l()
207 table->info = info; in __collate_load_tables_l()
208 table->char_pri_table = (void *)TMP; in __collate_load_tables_l()
211 for (z = 0; z < info->directive_count; z++) { in __collate_load_tables_l()
212 if (info->subst_count[z] > 0) { in __collate_load_tables_l()
213 table->subst_table[z] = (void *)TMP; in __collate_load_tables_l()
214 TMP += info->subst_count[z] * sizeof (collate_subst_t); in __collate_load_tables_l()
216 table->subst_table[z] = NULL; in __collate_load_tables_l()
221 table->chain_pri_table = (void *)TMP; in __collate_load_tables_l()
224 table->chain_pri_table = NULL; in __collate_load_tables_l()
225 if (info->large_count > 0) in __collate_load_tables_l()
226 table->large_pri_table = (void *)TMP; in __collate_load_tables_l()
228 table->large_pri_table = NULL; in __collate_load_tables_l()
230 table->__collate_load_error = 0; in __collate_load_tables_l()
235 substsearch(struct xlocale_collate *table, const wchar_t key, int pass) in substsearch() argument
238 int n = table->info->subst_count[pass]; in substsearch()
243 if (pass >= table->info->directive_count) in substsearch()
249 p = table->subst_table[pass] + (key & ~COLLATE_SUBST_PRIORITY); in substsearch()
250 assert(p->key == key); in substsearch()
252 return (p->pri); in substsearch()
258 int low = 0; in chainsearch() local
259 int high = table->info->chain_count - 1; in chainsearch()
262 collate_chain_t *tab = table->chain_pri_table; in chainsearch()
267 while (low <= high) { in chainsearch()
268 next = (low + high) / 2; in chainsearch()
270 compar = *key - *p->str; in chainsearch()
272 l = wcsnlen(p->str, COLLATE_STR_LEN); in chainsearch()
273 compar = wcsncmp(key, p->str, l); in chainsearch()
280 low = next + 1; in chainsearch()
282 high = next - 1; in chainsearch()
290 int low = 0; in largesearch() local
291 int high = table->info->large_count - 1; in largesearch()
294 collate_large_t *tab = table->large_pri_table; in largesearch()
299 while (low <= high) { in largesearch()
300 next = (low + high) / 2; in largesearch()
302 compar = key - p->val; in largesearch()
306 low = next + 1; in largesearch()
308 high = next - 1; in largesearch()
323 * If this is the "last" pass for the UNDEFINED, then in _collate_lookup()
326 if (which >= table->info->directive_count) { in _collate_lookup()
353 * single element (aka chains or collating-elements). in _collate_lookup()
356 ((p = p2->pri[which]) >= 0)) { in _collate_lookup()
364 * Character is a small (8-bit) character. in _collate_lookup()
367 *pri = table->char_pri_table[*t].pri[which]; in _collate_lookup()
369 } else if ((table->info->large_count > 0) && in _collate_lookup()
375 *pri = match->pri.pri[which]; in _collate_lookup()
381 if (table->info->directive[which] & DIRECTIVE_UNDEFINED) { in _collate_lookup()
385 *pri = table->info->undef_pri[which]; in _collate_lookup()
425 int pass; in _collate_wxfrm() local
429 int ndir = table->info->directive_count; in _collate_wxfrm()
433 for (pass = 0; pass <= ndir; pass++) { in _collate_wxfrm()
437 if (pass != 0) { in _collate_wxfrm()
438 /* insert level separator from the previous pass */ in _collate_wxfrm()
441 room--; in _collate_wxfrm()
446 /* special pass for undefined */ in _collate_wxfrm()
447 if (pass == ndir) { in _collate_wxfrm()
450 direc = table->info->directive[pass]; in _collate_wxfrm()
463 fp = tr + wcslen(tr) - 1; in _collate_wxfrm()
467 *fp-- = c; in _collate_wxfrm()
474 _collate_lookup(table, t, &len, &pri, pass, &state); in _collate_wxfrm()
486 room--; in _collate_wxfrm()
493 _collate_lookup(table, t, &len, &pri, pass, &state); in _collate_wxfrm()
505 room--; in _collate_wxfrm()
517 return ((size_t)(-1)); in _collate_wxfrm()
521 * In the non-POSIX case, we transform each character into a string of
528 * 31-bits wide. (But: be careful using priorities where the high
529 * order bit is set -- i.e. the priority is negative. The sort order
533 * that real prioririties *except for the last UNDEFINED pass* are generally
541 #define XFRM_MASK ((1 << XFRM_SHIFT) - 1)
545 xfrm(struct xlocale_collate *table, unsigned char *p, int pri, int pass) in xfrm() argument
548 uint32_t val = (uint32_t)table->info->pri_count[pass]; in xfrm()
570 int pass; in _collate_sxfrm() local
576 int ndir = table->info->directive_count; in _collate_sxfrm()
580 for (pass = 0; pass <= ndir; pass++) { in _collate_sxfrm()
584 if (pass != 0) { in _collate_sxfrm()
585 /* insert level separator from the previous pass */ in _collate_sxfrm()
588 room--; in _collate_sxfrm()
593 /* special pass for undefined */ in _collate_sxfrm()
594 if (pass == ndir) { in _collate_sxfrm()
597 direc = table->info->directive[pass]; in _collate_sxfrm()
610 fp = tr + wcslen(tr) - 1; in _collate_sxfrm()
614 *fp-- = c; in _collate_sxfrm()
622 _collate_lookup(table, t, &len, &pri, pass, &state); in _collate_sxfrm()
633 b = xfrm(table, buf, pri, pass); in _collate_sxfrm()
637 b--; in _collate_sxfrm()
640 room--; in _collate_sxfrm()
648 _collate_lookup(table, t, &len, &pri, pass, &state); in _collate_sxfrm()
659 b = xfrm(table, buf, pri, pass); in _collate_sxfrm()
664 b--; in _collate_sxfrm()
667 room--; in _collate_sxfrm()
680 return ((size_t)(-1)); in _collate_sxfrm()
695 return (-1); in __collate_equiv_value()
699 (struct xlocale_collate*)locale->components[XLC_COLLATE]; in __collate_equiv_value()
701 if (table->__collate_load_error) in __collate_equiv_value()
702 return ((len == 1 && *str <= UCHAR_MAX) ? *str : -1); in __collate_equiv_value()
705 e = -1; in __collate_equiv_value()
707 e = table->char_pri_table[*str].pri[0]; in __collate_equiv_value()
708 else if (table->info->large_count > 0) { in __collate_equiv_value()
712 e = match_large->pri.pri[0]; in __collate_equiv_value()
718 if (table->info->chain_count > 0) { in __collate_equiv_value()
727 e = match_chain->pri[0]; in __collate_equiv_value()
730 return (e < 0 ? -e : e); in __collate_equiv_value()