+static int isamb_pp_on_right_node(ISAMB_PP pp, int level, const void *untilbuf)
+{ /* looks one node higher to see if we should be on this node at all */
+ /* useful in backing off quickly, and in avoiding tail descends */
+ /* call with pp->level to begin with */
+ struct ISAMB_block *p;
+ int cmp;
+ char *src;
+ int item_len;
+ assert(level>=0);
+ if ( level == 0) {
+#if ISAMB_DEBUG
+ logf(LOG_DEBUG,"isamb_pp_on_right returning true for root");
+#endif
+ return 1; /* we can never skip the root node */
+ }
+ level--;
+ p=pp->block[level];
+ assert(p->offset <= p->size);
+ if (p->offset < p->size )
+ {
+ assert(p->offset>0);
+ src=p->bytes + p->offset;
+ decode_ptr(&src,&item_len);
+#if ISAMB_DEBUG
+ (*pp->isamb->method->log_item)(LOG_DEBUG,untilbuf,"on_leaf: until");
+ (*pp->isamb->method->log_item)(LOG_DEBUG,src,"on_leaf: value");
+#endif
+ cmp=(*pp->isamb->method->compare_item)(untilbuf,src);
+ if (cmp<2) {
+#if ISAMB_DEBUG
+ logf(LOG_DEBUG,"isamb_pp_on_right returning true "
+ "cmp=%d lev=%d ofs=%d",cmp,level,p->offset);
+#endif
+ return 1;
+ }
+ else {
+#if ISAMB_DEBUG
+ logf(LOG_DEBUG,"isamb_pp_on_right returning false "
+ "cmp=%d lev=%d ofs=%d",cmp,level,p->offset);
+#endif
+ return 0;
+ }
+ }
+ else {
+#if ISAMB_DEBUG
+ logf(LOG_DEBUG,"isamb_pp_on_right at tail, looking higher "
+ "lev=%d",level);
+#endif
+ return isamb_pp_on_right_node(pp, level, untilbuf);
+ }
+} /* isamb_pp_on_right_node */