+ if (f_more > 1)
+ {
+ /* block to block boundary in the original file. */
+ f_more = 1;
+ if (cat == pp->cat)
+ {
+ /* the resulting output is of the same category as the
+ the original
+ */
+ if (r_offset <= mb[ptr].offset +is->method->filecat[cat].mfill)
+ {
+ /* the resulting output block is too small/empty. Delete
+ the original (if any)
+ */
+ if (debug > 3)
+ yaz_log (YLOG_LOG, "isc: release A");
+ if (mb[ptr].block)
+ isamc_release_block (is, pp->cat, mb[ptr].block);
+ mb[ptr].block = pp->pos;
+ if (!mb[ptr].dirty)
+ mb[ptr].dirty = 1;
+ if (ptr > 0)
+ mb[ptr-1].dirty = 1;
+ }
+ else
+ {
+ /* indicate new boundary based on the original file */
+ mb[++ptr].block = pp->pos;
+ mb[ptr].dirty = last_dirty;
+ mb[ptr].offset = r_offset;
+ if (debug > 3)
+ yaz_log (YLOG_LOG, "isc: bound ptr=%d,offset=%d",
+ ptr, r_offset);
+ if (cat==is->max_cat && ptr >= is->method->max_blocks_mem)
+ {
+ /* We are dealing with block(s) of max size. Block(s)
+ except 1 will be flushed.
+ */
+ if (debug > 2)
+ yaz_log (YLOG_LOG, "isc: flush A %d sections", ptr);
+ flush_blocks (is, mb, ptr-1, r_buf, &firstpos, cat,
+ 0, &pp->numKeys);
+ mb[0].block = mb[ptr-1].block;
+ mb[0].dirty = mb[ptr-1].dirty;
+ memcpy (r_buf, r_buf + mb[ptr-1].offset,
+ mb[ptr].offset - mb[ptr-1].offset);
+ mb[0].offset = 0;
+
+ mb[1].block = mb[ptr].block;
+ mb[1].dirty = mb[ptr].dirty;
+ mb[1].offset = mb[ptr].offset - mb[ptr-1].offset;
+ ptr = 1;
+ r_offset = mb[ptr].offset;
+ }
+ }
+ }
+ border = get_border (is, mb, ptr, cat, firstpos);
+ }
+ last_dirty = 0;