- /* In case we ended on a whole block match. */
- if (ctx->have_match == -1) {
- size_t final;
-
- final = final_block_match(ctx);
- if (!final) {
- /* This is how many bytes we're about to consume. */
- ret = buffer_size(ctx);
- ctx->buffer_start += ret;
- ctx->literal_bytes -= ret;
+ /* We might have ended right on a matched block. */
+ if (ctx->have_match != -1) {
+ ctx->literal_bytes -= ctx->block_size;
+ assert(ctx->literal_bytes == 0);
+ ret = -ctx->have_match-1;
+ ctx->have_match = -1;
+ ctx->running_crc = 0;
+ /* Nothing more in the buffer. */
+ ctx->buffer_start = ctx->buffer_end;
+ return ret;
+ }