Revision: 2670
          http://tmux.svn.sourceforge.net/tmux/?rev=2670&view=rev
Author:   tcunha
Date:     2012-01-21 19:38:26 +0000 (Sat, 21 Jan 2012)
Log Message:
-----------
Sync OpenBSD patchset 1008:

Use RB trees not SPLAY.

Modified Paths:
--------------
    trunk/cmd-bind-key.c
    trunk/cmd-list-keys.c
    trunk/cmd-unbind-key.c
    trunk/key-bindings.c
    trunk/mode-key.c
    trunk/options.c
    trunk/tmux.h

Modified: trunk/cmd-bind-key.c
===================================================================
--- trunk/cmd-bind-key.c        2012-01-21 19:36:40 UTC (rev 2669)
+++ trunk/cmd-bind-key.c        2012-01-21 19:38:26 UTC (rev 2670)
@@ -107,7 +107,7 @@
 
        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 @@
        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);
 }

Modified: trunk/cmd-list-keys.c
===================================================================
--- trunk/cmd-list-keys.c       2012-01-21 19:36:40 UTC (rev 2669)
+++ trunk/cmd-list-keys.c       2012-01-21 19:38:26 UTC (rev 2670)
@@ -55,7 +55,7 @@
 
        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 @@
                        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 @@
 
        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 @@
                        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;

Modified: trunk/cmd-unbind-key.c
===================================================================
--- trunk/cmd-unbind-key.c      2012-01-21 19:36:40 UTC (rev 2669)
+++ trunk/cmd-unbind-key.c      2012-01-21 19:38:26 UTC (rev 2670)
@@ -57,8 +57,8 @@
        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 @@
 
        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);

Modified: trunk/key-bindings.c
===================================================================
--- trunk/key-bindings.c        2012-01-21 19:36:40 UTC (rev 2669)
+++ trunk/key-bindings.c        2012-01-21 19:38:26 UTC (rev 2670)
@@ -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 @@
        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 @@
 
        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 @@
 
        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 @@
 {
        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 @@
        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);

Modified: trunk/mode-key.c
===================================================================
--- trunk/mode-key.c    2012-01-21 19:36:40 UTC (rev 2669)
+++ trunk/mode-key.c    2012-01-21 19:38:26 UTC (rev 2670)
@@ -412,7 +412,7 @@
        { 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 @@
        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 @@
 
        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);

Modified: trunk/options.c
===================================================================
--- trunk/options.c     2012-01-21 19:36:40 UTC (rev 2669)
+++ trunk/options.c     2012-01-21 19:38:26 UTC (rev 2670)
@@ -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 @@
 void
 options_init(struct options *oo, struct options *parent)
 {
-       SPLAY_INIT(&oo->tree);
+       RB_INIT(&oo->tree);
        oo->parent = parent;
 }
 
@@ -48,9 +48,9 @@
 {
        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 @@
        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 @@
        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 @@
        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 @@
        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 @@
        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);
 

Modified: trunk/tmux.h
===================================================================
--- trunk/tmux.h        2012-01-21 19:36:40 UTC (rev 2669)
+++ trunk/tmux.h        2012-01-21 19:38:26 UTC (rev 2670)
@@ -541,9 +541,9 @@
        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 {
@@ -670,11 +670,11 @@
        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;
 };
 
@@ -1272,9 +1272,9 @@
        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
@@ -1379,7 +1379,7 @@
 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 *,
@@ -1391,7 +1391,7 @@
 
 /* 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 *);
@@ -1653,7 +1653,7 @@
 /* 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);

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
tmux-cvs mailing list
tmux-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-cvs

Reply via email to