aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/localedef
diff options
context:
space:
mode:
authorBaptiste Daroussin <bapt@FreeBSD.org>2015-08-08 21:53:02 +0000
committerBaptiste Daroussin <bapt@FreeBSD.org>2015-08-08 21:53:02 +0000
commit6131dc6a885fe2b2299e7b95aa0dfa7e3fd9f7f4 (patch)
treeae76dc6d975b4b7ee52f5129b5273cd758f909da /usr.bin/localedef
parent1fbfaeef7ecf7e332eda5f931d636096e66526e4 (diff)
downloadsrc-6131dc6a885fe2b2299e7b95aa0dfa7e3fd9f7f4.tar.gz
src-6131dc6a885fe2b2299e7b95aa0dfa7e3fd9f7f4.zip
Convert ctype generation to Red Black tree
Notes
Notes: svn path=/projects/collation/; revision=286481
Diffstat (limited to 'usr.bin/localedef')
-rw-r--r--usr.bin/localedef/ctype.c27
1 files changed, 10 insertions, 17 deletions
diff --git a/usr.bin/localedef/ctype.c b/usr.bin/localedef/ctype.c
index 8cb68135b4ee..17f18c404fae 100644
--- a/usr.bin/localedef/ctype.c
+++ b/usr.bin/localedef/ctype.c
@@ -35,7 +35,7 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include <sys/avl.h>
+#include <sys/tree.h>
#include <stdio.h>
#include <stdlib.h>
@@ -68,24 +68,20 @@ __FBSDID("$FreeBSD$");
#define _E4 0
#define _E5 _CTYPE_T
-static avl_tree_t ctypes;
-
static wchar_t last_ctype;
+static int ctype_compare(const void *n1, const void *n2);
typedef struct ctype_node {
wchar_t wc;
int32_t ctype;
int32_t toupper;
int32_t tolower;
- avl_node_t avl;
+ RB_ENTRY(ctype_node) entry;
} ctype_node_t;
-typedef struct width_node {
- wchar_t start;
- wchar_t end;
- int8_t width;
- avl_node_t avl;
-} width_node_t;
+RB_HEAD(ctypes, ctype_node) ctypes;
+RB_PROTOTYPE(ctypes, ctype_node, entry, ctype_compare);
+RB_GENERATE(ctypes, ctype_node, entry, ctype_compare);
static int
ctype_compare(const void *n1, const void *n2)
@@ -99,8 +95,7 @@ ctype_compare(const void *n1, const void *n2)
void
init_ctype(void)
{
- avl_create(&ctypes, ctype_compare, sizeof (ctype_node_t),
- offsetof(ctype_node_t, avl));
+ RB_INIT(&ctypes);
}
@@ -172,17 +167,16 @@ get_ctype(wchar_t wc)
{
ctype_node_t srch;
ctype_node_t *ctn;
- avl_index_t where;
srch.wc = wc;
- if ((ctn = avl_find(&ctypes, &srch, &where)) == NULL) {
+ if ((ctn = RB_FIND(ctypes, &ctypes, &srch)) == NULL) {
if ((ctn = calloc(1, sizeof (*ctn))) == NULL) {
errf("out of memory");
return (NULL);
}
ctn->wc = wc;
- avl_insert(&ctypes, ctn, where);
+ RB_INSERT(ctypes, &ctypes, ctn);
}
return (ctn);
}
@@ -318,10 +312,9 @@ dump_ctype(void)
rl.mapupper[wc] = wc;
}
- for (ctn = avl_first(&ctypes); ctn; ctn = AVL_NEXT(&ctypes, ctn)) {
+ RB_FOREACH(ctn, ctypes, &ctypes) {
int conflict = 0;
-
wc = ctn->wc;
/*