dist-hook::
echo $(VERSION) >$(distdir)/RELEASE
+## Additional documentation.
+EXTRA_DIST += README.org
+
## Build tools.
EXTRA_DIST += config/auto-version
EXTRA_DIST += config/confsubst
old_node = AVL_NODE(*path->p[k]); XYLA__ASSERT(old_node);
node->bt = old_node->bt;
- node->avl.f = (node->avl.f&~XYLA_AVLF_BALMASK) |
- (old_node->avl.f&XYLA_AVLF_BALMASK);
+ node->avl.f =
+ (node->avl.f&~XYLA_AVLF_BALMASK) | (old_node->avl.f&XYLA_AVLF_BALMASK);
}
void xyla_avl_ripple(struct xyla_bt_nodecls *cls,
case XYLA_AVLBAL_LBIAS: lht = ht - 1; rht = ht - 2; break;
case XYLA_AVLBAL_EVEN: lht = rht = ht - 1; break;
case XYLA_AVLBAL_RBIAS: lht = ht - 2; rht = ht - 1; break;
- default: XYLA__ASSERT(0);
+ default: XYLA__ASSERT(0); lht = rht = -1; break;
}
/* Clear the split node's links, so that it's a standalone singleton
case XYLA_AVLBAL_LBIAS: subht = ht - 1; ht++; break;
case XYLA_AVLBAL_EVEN: subht = ht; ht++; break;
case XYLA_AVLBAL_RBIAS: subht = ht + 1; ht += 2; break;
- default: XYLA__ASSERT(0);
+ default: XYLA__ASSERT(0); subht = -1; break;
}
xyla_avl_join(cls, &right, &rht,
&right, rht, &parent->bt, &sub, subht);
case XYLA_AVLBAL_LBIAS: subht = ht + 1; ht += 2; break;
case XYLA_AVLBAL_EVEN: subht = ht; ht++; break;
case XYLA_AVLBAL_RBIAS: subht = ht - 1; ht++; break;
- default: XYLA__ASSERT(0);
+ default: XYLA__ASSERT(0); subht = -1; break;
}
xyla_avl_join(cls, &left, &lht,
&sub, subht, &parent->bt, &left, lht);
case XYLA_AVLBAL_LBIAS: lht = ht - 1; rht = ht - 2; break;
case XYLA_AVLBAL_EVEN: lht = rht = ht - 1; break;
case XYLA_AVLBAL_RBIAS: lht = ht - 2; rht = ht - 1; break;
- default: XYLA__ASSERT(0);
+ default: XYLA__ASSERT(0); lht = rht = -1; break;
}
if (lht_out) *lht_out = lht;
if (rht_out) *rht_out = rht;
/*----- Header files ------------------------------------------------------*/
-#include "lib.h"
#include "bt.h"
/*----- Main code ---------------------------------------------------------*/
enum { RIGHT, JOIN };
- XYLA__ASSERT(keyfn);
-
/* This is an essentially recursive procedure based on the following
* observations. Let A and B be sets of ordered elements.
*
enum { RIGHT, JOIN };
- XYLA__ASSERT(keyfn);
-
/* This is an essentially recursive procedure, similar to `xyla_bt_unisect'
* above, based on the following observations. Let A and B be sets of
* ordered elements.
# endif
#else
# ifndef XYLA__ASSERT
-# define XYLA__ASSERT(x) do ; while (0)
+# define XYLA__ASSERT(x) do (void)(x); while (0)
# endif
#endif
#ifdef XYLA_FREESTANDING
# define XYLA_BT_COPYPATH(newpath, path, k) do { \
struct xyla_bt_node \
- ***_newpath = (newpath), **const *_path = (path); \
+ ***_newpath = (newpath), \
+ **const *_path = (path); \
int _i, _n = (k) + 1; \
\
for (_i = 0; _i < _n; _i++) _newpath[_i] = _path[_i]; \
* It's probably better to use `xyla_bt_severfirst' for this task.
*/
-
/*----- Paths -------------------------------------------------------------*/
extern void *xyla_rb_current(const struct xyla_rb_path */*path*/);
:
:;; iteration
-i
-j
+i j
:
:;; path motion and ascension
dict(type = "int", metavar = "LIMIT",
dest = "limit", default = None,
help = "exclusive limit value to store in test trees")),
- ("-s", "--seed",
- dict(type = "string", metavar = "SEED",
- dest = "seed", default = None,
- help = "force initial seed")),
("-n", "--steps",
dict(type = "int", metavar = "STEPS",
dest = "nsteps", default = None,
help = "number of steps to run before stopping")),
+ ("-s", "--seed",
+ dict(type = "string", metavar = "SEED",
+ dest = "seed", default = None,
+ help = "force initial seed")),
("-y", "--sync",
dict(type = "int", metavar = "STEP",
dest = "sync", default = None,
me.cur = stack.pop()
me.stack = stack
if opts.seed is not None and me.seed != opts.seed:
- raise ValueError("checkpointed seed `%s' /= "
- "command-line seed `%s'" % (me.seed, opts.seed))
+ raise ValueError("checkpointed seed `%s' /= "
+ "command-line seed `%s'" % (me.seed, opts.seed))
if opts.limit is not None and me.cur.limit != opts.limit:
raise ValueError("checkpointed limit %d /= command-line limit %d" %
(me.cur.limit, opts.limit))
OS.unlink(me._ckpt_file); OS.rename(new, me._ckpt_file)
def clear_ckpt(me):
try: OS.unlink(me._ckpt_file)
- except IOError as err:
+ except OSError as err:
if err.errno == E.ENOENT: pass
else: raise
@%:@0x00000001 (n = 2) (-) 4
@%:@0x00000000 (n = 1) (=) 3
],
-[XYLA-BT @%:@<root @<:@ADDR@:>@> BUG: @%:@<node 0x00000000 3> key not above lower bound
-XYLA-AVL @%:@<root @<:@ADDR@:>@> BUG: @%:@<node 0x00000001 4> incorrect balance annotation `-' /= left 0 - 1 right
+[XYLA-BT @%:@<root @<:@ADDR@:>@> BUG: @%:@<node @%:@0x00000000 3> key not above lower bound
+XYLA-AVL @%:@<root @<:@ADDR@:>@> BUG: @%:@<node @%:@0x00000001 4> incorrect balance annotation `-' /= left 0 - 1 right
BUG: check failed: tree structure invalid (input pos = 19)
])
AT_CLEANUP
@%:@0x00000002 (n = 3) ( ) 4
@%:@0x00000001 (n = 1) (*) 3
],
-[XYLA-RB @%:@<root @<:@ADDR@:>@> BUG: root @%:@<node 0x00000002 4> is red
-XYLA-RB @%:@<root @<:@ADDR@:>@> BUG: red @%:@<node 0x00000000 2> has red parent @%:@<node 0x00000002 4>
-XYLA-BT @%:@<root @<:@ADDR@:>@> BUG: @%:@<node 0x00000001 3> key not above lower bound
-XYLA-RB @%:@<root @<:@ADDR@:>@> BUG: @%:@<node 0x00000002 4> left black-height 0 /= 1 right black-height
+[XYLA-RB @%:@<root @<:@ADDR@:>@> BUG: root @%:@<node @%:@0x00000002 4> is red
+XYLA-RB @%:@<root @<:@ADDR@:>@> BUG: red @%:@<node @%:@0x00000000 2> has red parent @%:@<node @%:@0x00000002 4>
+XYLA-BT @%:@<root @<:@ADDR@:>@> BUG: @%:@<node @%:@0x00000001 3> key not above lower bound
+XYLA-RB @%:@<root @<:@ADDR@:>@> BUG: @%:@<node @%:@0x00000002 4> left black-height 0 /= 1 right black-height
BUG: check failed: tree structure invalid (input pos = 24)
])
AT_CLEANUP
@%:@0x00000001 (n = 2) (*) 4
@%:@0x00000000 (n = 1) (*) 3
],
-[XYLA-BT @%:@<root @<:@ADDR@:>@> BUG: @%:@<node 0x00000000 3> key not above lower bound
+[XYLA-BT @%:@<root @<:@ADDR@:>@> BUG: @%:@<node @%:@0x00000000 3> key not above lower bound
BUG: check failed: tree structure invalid (input pos = 17)
])
AT_CLEANUP
@%:@0x00000001 (n = 2) (*) 0x00000002$ 4
@%:@0x00000000 (n = 1) (*) 0x00000001$ 3
],
-[XYLA-TREAP @%:@<root @<:@ADDR@:>@> BUG: @%:@<node 0x00000000 0x00000001$ 3> weight 1 < 2 weight of parent @%:@<node 0x00000001 0x00000002$ 4>
-XYLA-BT @%:@<root @<:@ADDR@:>@> BUG: @%:@<node 0x00000000 0x00000001$ 3> key not above lower bound
+[XYLA-TREAP @%:@<root @<:@ADDR@:>@> BUG: @%:@<node @%:@0x00000000 0x00000001$ 3> weight 1 < 2 weight of parent @%:@<node @%:@0x00000001 0x00000002$ 4>
+XYLA-BT @%:@<root @<:@ADDR@:>@> BUG: @%:@<node @%:@0x00000000 0x00000001$ 3> key not above lower bound
BUG: check failed: tree structure invalid (input pos = 23)
])
AT_CLEANUP
#define TREE_INITRITER tree__name(initriter)
#define TREE_PREV tree__name(prev)
#define TREE_CURRENT tree__name(current)
-#define TREE_COPYPATH tree__name(copypath)
#define TREE_ROOTPATH tree__name(rootpath)
#define TREE_UPPATH tree__name(uppath)
#define TREE_LEFTPATH tree__name(leftpath)
/*----- Preliminaries -----------------------------------------------------*/
static FILE *in, *out;
-
int stop = 0;
#define BCAT_FAIL 1u
{
/* Update function to maintain node count. */
- struct my_node *mynode = MY_NODE(node),
+ struct my_node
+ *mynode = MY_NODE(node),
*left = MY_NODE(mynode->bt.left), *right = MY_NODE(mynode->bt.right);
mynode->n = (left ? left->n : 0) + (right ? right->n : 0) + 1;
const struct my_node *my_node = CONST_MY_NODE(node);
- fprintf(fp, "#<node 0x%08lx ", my_node->seq);
+ fprintf(fp, "#<node #0x%08lx ", my_node->seq);
#if TREE == TREAP
fprintf(fp, "0x%08lx$ ", (unsigned long)my_node->trp.wt);
#endif
struct my_node *mynode, *myleft;
size_t i = 0;
-#if TREE == SPLAY
- mynode = path->f ? 0 : MY_SPLAY_NODE(path->node);
-#else
- mynode = MY_NODE(*path->p[path->k]);
-#endif
+ mynode = TREE_CURRENT(path);
if (mynode) {
myleft = MY_NODE(mynode->bt.left);
if (myleft) i += myleft->n;
case -1: f = XYLA_AVLBAL_LBIAS; ht = lht + 1; break;
case 0: f = XYLA_AVLBAL_EVEN; ht = lht + 1; break;
case +1: f = XYLA_AVLBAL_RBIAS; ht = rht + 1; break;
- default: bail(BCAT_ERR, "tree is not AVL"); ht = 0; break;
+ default: bail(BCAT_ERR, "tree is not AVL");
}
}
node->my.avl.f = (node->my.avl.f&FLAGMASK) | f;
i = read_int();
do ch = getc(in); while (isspace(ch));
if (ch == '-') j = read_int();
- else { ungetc(ch, in); j = i; i = 1; }
+ else { ungetc(ch, in); j = i; i = 1; }
for (;;) {
if (!TREE_PROBE(&mycls, &cur.root, my_ordnav, &i, &path)) {
nodeu = make_node(i);
case '/': /* split */
if (sp > NSTACK - 2) bail(BCAT_ERR, "stack full");
if (!(f&f_path)) bail(BCAT_ERR, "no path");
- rc = TREE_SPLIT(&mycls,
- &stack[sp].root HARG(&stack[sp].ht),
+ rc = TREE_SPLIT(&mycls, &stack[sp].root HARG(&stack[sp].ht),
&btnode,
&cur.root HARG(&cur.ht),
&path);
case '\\': /* difference/intersection */
if (!sp) bail(BCAT_ERR, "stack empty");
if (sp >= NSTACK) bail(BCAT_ERR, "stack full");
- rc = TREE_DIFFSECT(&mycls,
- &cur.root HARG(&cur.ht),
+ rc = TREE_DIFFSECT(&mycls, &cur.root HARG(&cur.ht),
&stack[sp].root HARG(&stack[sp].ht),
&cur.root HARG(cur.ht),
&stack[sp - 1].root);
putc('>', out);
}
#endif
- putc(')', out);
- putc('\n', out);
+ putc(')', out); putc('\n', out);
}
break;
check_dump(&mycls, &cur.root HARG(cur.ht), CHKOUT_DUMP);
break;
- case 'S': /* seed */
- seed = read_int();
- break;
-
case '!': /* check */
check_dump(&mycls, &cur.root HARG(cur.ht), CHKOUT_NONE);
break;
node = 0; f &= ~(f_key | f_path | f_weight);
break;
+ case 'S': /* seed */
+ seed = read_int();
+ break;
+
case 'V': /* verbose */
V( v = 0; )
for (;;) {