diff --git a/cmd-bind-key.c b/cmd-bind-key.c index 30421115..4f1b9f18 100644 --- a/cmd-bind-key.c +++ b/cmd-bind-key.c @@ -107,7 +107,7 @@ cmd_bind_key_table(struct cmd *self, struct cmd_ctx *ctx, int key) mtmp.key = key; mtmp.mode = !!args_has(args, 'c'); - if ((mbind = SPLAY_FIND(mode_key_tree, mtab->tree, &mtmp)) != NULL) { + if ((mbind = RB_FIND(mode_key_tree, mtab->tree, &mtmp)) != NULL) { mbind->cmd = cmd; return (0); } @@ -115,6 +115,6 @@ cmd_bind_key_table(struct cmd *self, struct cmd_ctx *ctx, int key) mbind->key = mtmp.key; mbind->mode = mtmp.mode; mbind->cmd = cmd; - SPLAY_INSERT(mode_key_tree, mtab->tree, mbind); + RB_INSERT(mode_key_tree, mtab->tree, mbind); return (0); } diff --git a/cmd-list-keys.c b/cmd-list-keys.c index 73ecf458..95f33023 100644 --- a/cmd-list-keys.c +++ b/cmd-list-keys.c @@ -55,7 +55,7 @@ cmd_list_keys_exec(struct cmd *self, struct cmd_ctx *ctx) width = 0; - SPLAY_FOREACH(bd, key_bindings, &key_bindings) { + RB_FOREACH(bd, key_bindings, &key_bindings) { key = key_string_lookup_key(bd->key & ~KEYC_PREFIX); if (key == NULL) continue; @@ -72,7 +72,7 @@ cmd_list_keys_exec(struct cmd *self, struct cmd_ctx *ctx) width = keywidth; } - SPLAY_FOREACH(bd, key_bindings, &key_bindings) { + RB_FOREACH(bd, key_bindings, &key_bindings) { key = key_string_lookup_key(bd->key & ~KEYC_PREFIX); if (key == NULL) continue; @@ -116,7 +116,7 @@ cmd_list_keys_table(struct cmd *self, struct cmd_ctx *ctx) width = 0; any_mode = 0; - SPLAY_FOREACH(mbind, mode_key_tree, mtab->tree) { + RB_FOREACH(mbind, mode_key_tree, mtab->tree) { key = key_string_lookup_key(mbind->key); if (key == NULL) continue; @@ -129,7 +129,7 @@ cmd_list_keys_table(struct cmd *self, struct cmd_ctx *ctx) width = keywidth; } - SPLAY_FOREACH(mbind, mode_key_tree, mtab->tree) { + RB_FOREACH(mbind, mode_key_tree, mtab->tree) { key = key_string_lookup_key(mbind->key); if (key == NULL) continue; diff --git a/cmd-unbind-key.c b/cmd-unbind-key.c index 7e8c183c..22a35ed0 100644 --- a/cmd-unbind-key.c +++ b/cmd-unbind-key.c @@ -57,8 +57,8 @@ cmd_unbind_key_exec(struct cmd *self, unused struct cmd_ctx *ctx) int key; if (args_has(args, 'a')) { - while (!SPLAY_EMPTY(&key_bindings)) { - bd = SPLAY_ROOT(&key_bindings); + while (!RB_EMPTY(&key_bindings)) { + bd = RB_ROOT(&key_bindings); key_bindings_remove(bd->key); } return (0); @@ -95,8 +95,8 @@ cmd_unbind_key_table(struct cmd *self, struct cmd_ctx *ctx, int key) mtmp.key = key; mtmp.mode = !!args_has(args, 'c'); - if ((mbind = SPLAY_FIND(mode_key_tree, mtab->tree, &mtmp)) != NULL) { - SPLAY_REMOVE(mode_key_tree, mtab->tree, mbind); + if ((mbind = RB_FIND(mode_key_tree, mtab->tree, &mtmp)) != NULL) { + RB_REMOVE(mode_key_tree, mtab->tree, mbind); xfree(mbind); } return (0); diff --git a/key-bindings.c b/key-bindings.c index fe8a7576..fb1590a5 100644 --- a/key-bindings.c +++ b/key-bindings.c @@ -24,7 +24,7 @@ #include "tmux.h" -SPLAY_GENERATE(key_bindings, key_binding, entry, key_bindings_cmp); +RB_GENERATE(key_bindings, key_binding, entry, key_bindings_cmp); struct key_bindings key_bindings; struct key_bindings dead_key_bindings; @@ -52,7 +52,7 @@ key_bindings_lookup(int key) struct key_binding bd; bd.key = key; - return (SPLAY_FIND(key_bindings, &key_bindings, &bd)); + return (RB_FIND(key_bindings, &key_bindings, &bd)); } void @@ -64,7 +64,7 @@ key_bindings_add(int key, int can_repeat, struct cmd_list *cmdlist) bd = xmalloc(sizeof *bd); bd->key = key; - SPLAY_INSERT(key_bindings, &key_bindings, bd); + RB_INSERT(key_bindings, &key_bindings, bd); bd->can_repeat = can_repeat; bd->cmdlist = cmdlist; @@ -77,8 +77,8 @@ key_bindings_remove(int key) if ((bd = key_bindings_lookup(key)) == NULL) return; - SPLAY_REMOVE(key_bindings, &key_bindings, bd); - SPLAY_INSERT(key_bindings, &dead_key_bindings, bd); + RB_REMOVE(key_bindings, &key_bindings, bd); + RB_INSERT(key_bindings, &dead_key_bindings, bd); } void @@ -86,9 +86,9 @@ key_bindings_clean(void) { struct key_binding *bd; - while (!SPLAY_EMPTY(&dead_key_bindings)) { - bd = SPLAY_ROOT(&dead_key_bindings); - SPLAY_REMOVE(key_bindings, &dead_key_bindings, bd); + while (!RB_EMPTY(&dead_key_bindings)) { + bd = RB_ROOT(&dead_key_bindings); + RB_REMOVE(key_bindings, &dead_key_bindings, bd); cmd_list_free(bd->cmdlist); xfree(bd); } @@ -179,7 +179,7 @@ key_bindings_init(void) struct cmd *cmd; struct cmd_list *cmdlist; - SPLAY_INIT(&key_bindings); + RB_INIT(&key_bindings); for (i = 0; i < nitems(table); i++) { cmdlist = xmalloc(sizeof *cmdlist); diff --git a/mode-key.c b/mode-key.c index 6115d630..43d07c0f 100644 --- a/mode-key.c +++ b/mode-key.c @@ -412,7 +412,7 @@ const struct mode_key_table mode_key_tables[] = { { NULL, NULL, NULL, NULL } }; -SPLAY_GENERATE(mode_key_tree, mode_key_binding, entry, mode_key_cmp); +RB_GENERATE(mode_key_tree, mode_key_binding, entry, mode_key_cmp); int mode_key_cmp(struct mode_key_binding *mbind1, struct mode_key_binding *mbind2) @@ -462,13 +462,13 @@ mode_key_init_trees(void) struct mode_key_binding *mbind; for (mtab = mode_key_tables; mtab->name != NULL; mtab++) { - SPLAY_INIT(mtab->tree); + RB_INIT(mtab->tree); for (ment = mtab->table; ment->mode != -1; ment++) { mbind = xmalloc(sizeof *mbind); mbind->key = ment->key; mbind->mode = ment->mode; mbind->cmd = ment->cmd; - SPLAY_INSERT(mode_key_tree, mtab->tree, mbind); + RB_INSERT(mode_key_tree, mtab->tree, mbind); } } } @@ -487,7 +487,7 @@ mode_key_lookup(struct mode_key_data *mdata, int key) mtmp.key = key; mtmp.mode = mdata->mode; - if ((mbind = SPLAY_FIND(mode_key_tree, mdata->tree, &mtmp)) == NULL) { + if ((mbind = RB_FIND(mode_key_tree, mdata->tree, &mtmp)) == NULL) { if (mdata->mode != 0) return (MODEKEY_NONE); return (MODEKEY_OTHER); diff --git a/options.c b/options.c index 6ee4bf1d..9298ab11 100644 --- a/options.c +++ b/options.c @@ -28,7 +28,7 @@ * a splay tree. */ -SPLAY_GENERATE(options_tree, options_entry, entry, options_cmp); +RB_GENERATE(options_tree, options_entry, entry, options_cmp); int options_cmp(struct options_entry *o1, struct options_entry *o2) @@ -39,7 +39,7 @@ options_cmp(struct options_entry *o1, struct options_entry *o2) void options_init(struct options *oo, struct options *parent) { - SPLAY_INIT(&oo->tree); + RB_INIT(&oo->tree); oo->parent = parent; } @@ -48,9 +48,9 @@ options_free(struct options *oo) { struct options_entry *o; - while (!SPLAY_EMPTY(&oo->tree)) { - o = SPLAY_ROOT(&oo->tree); - SPLAY_REMOVE(options_tree, &oo->tree, o); + while (!RB_EMPTY(&oo->tree)) { + o = RB_ROOT(&oo->tree); + RB_REMOVE(options_tree, &oo->tree, o); xfree(o->name); if (o->type == OPTIONS_STRING) xfree(o->str); @@ -64,7 +64,7 @@ options_find1(struct options *oo, const char *name) struct options_entry p; p.name = (char *) name; - return (SPLAY_FIND(options_tree, &oo->tree, &p)); + return (RB_FIND(options_tree, &oo->tree, &p)); } struct options_entry * @@ -73,12 +73,12 @@ options_find(struct options *oo, const char *name) struct options_entry *o, p; p.name = (char *) name; - o = SPLAY_FIND(options_tree, &oo->tree, &p); + o = RB_FIND(options_tree, &oo->tree, &p); while (o == NULL) { oo = oo->parent; if (oo == NULL) break; - o = SPLAY_FIND(options_tree, &oo->tree, &p); + o = RB_FIND(options_tree, &oo->tree, &p); } return (o); } @@ -91,7 +91,7 @@ options_remove(struct options *oo, const char *name) if ((o = options_find1(oo, name)) == NULL) return; - SPLAY_REMOVE(options_tree, &oo->tree, o); + RB_REMOVE(options_tree, &oo->tree, o); xfree(o->name); if (o->type == OPTIONS_STRING) xfree(o->str); @@ -107,7 +107,7 @@ options_set_string(struct options *oo, const char *name, const char *fmt, ...) if ((o = options_find1(oo, name)) == NULL) { o = xmalloc(sizeof *o); o->name = xstrdup(name); - SPLAY_INSERT(options_tree, &oo->tree, o); + RB_INSERT(options_tree, &oo->tree, o); } else if (o->type == OPTIONS_STRING) xfree(o->str); @@ -138,7 +138,7 @@ options_set_number(struct options *oo, const char *name, long long value) if ((o = options_find1(oo, name)) == NULL) { o = xmalloc(sizeof *o); o->name = xstrdup(name); - SPLAY_INSERT(options_tree, &oo->tree, o); + RB_INSERT(options_tree, &oo->tree, o); } else if (o->type == OPTIONS_STRING) xfree(o->str); diff --git a/tmux.h b/tmux.h index dba364fa..40721133 100644 --- a/tmux.h +++ b/tmux.h @@ -545,9 +545,9 @@ struct mode_key_binding { int mode; enum mode_key_cmd cmd; - SPLAY_ENTRY(mode_key_binding) entry; + RB_ENTRY(mode_key_binding) entry; }; -SPLAY_HEAD(mode_key_tree, mode_key_binding); +RB_HEAD(mode_key_tree, mode_key_binding); /* Command to string mapping. */ struct mode_key_cmdstr { @@ -674,11 +674,11 @@ struct options_entry { char *str; long long num; - SPLAY_ENTRY(options_entry) entry; + RB_ENTRY(options_entry) entry; }; struct options { - SPLAY_HEAD(options_tree, options_entry) tree; + RB_HEAD(options_tree, options_entry) tree; struct options *parent; }; @@ -1276,9 +1276,9 @@ struct key_binding { struct cmd_list *cmdlist; int can_repeat; - SPLAY_ENTRY(key_binding) entry; + RB_ENTRY(key_binding) entry; }; -SPLAY_HEAD(key_bindings, key_binding); +RB_HEAD(key_bindings, key_binding); /* * Option table entries. The option table is the user-visible part of the @@ -1383,7 +1383,7 @@ extern struct mode_key_tree mode_key_tree_emacs_edit; extern struct mode_key_tree mode_key_tree_emacs_choice; extern struct mode_key_tree mode_key_tree_emacs_copy; int mode_key_cmp(struct mode_key_binding *, struct mode_key_binding *); -SPLAY_PROTOTYPE(mode_key_tree, mode_key_binding, entry, mode_key_cmp); +RB_PROTOTYPE(mode_key_tree, mode_key_binding, entry, mode_key_cmp); const char *mode_key_tostring(const struct mode_key_cmdstr *, enum mode_key_cmd); enum mode_key_cmd mode_key_fromstring(const struct mode_key_cmdstr *, @@ -1395,7 +1395,7 @@ enum mode_key_cmd mode_key_lookup(struct mode_key_data *, int); /* options.c */ int options_cmp(struct options_entry *, struct options_entry *); -SPLAY_PROTOTYPE(options_tree, options_entry, entry, options_cmp); +RB_PROTOTYPE(options_tree, options_entry, entry, options_cmp); void options_init(struct options *, struct options *); void options_free(struct options *); struct options_entry *options_find1(struct options *, const char *); @@ -1657,7 +1657,7 @@ int client_main(int, char **, int); /* key-bindings.c */ extern struct key_bindings key_bindings; int key_bindings_cmp(struct key_binding *, struct key_binding *); -SPLAY_PROTOTYPE(key_bindings, key_binding, entry, key_bindings_cmp); +RB_PROTOTYPE(key_bindings, key_binding, entry, key_bindings_cmp); struct key_binding *key_bindings_lookup(int); void key_bindings_add(int, int, struct cmd_list *); void key_bindings_remove(int);