aboutsummaryrefslogtreecommitdiff
path: root/extract.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-01-04 19:27:57 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-01-04 19:27:57 +0000
commitfcca3d3e55da97e0f5298343cb3cc8fef73223cd (patch)
tree97196e44524beea32b53487f31d8ef32e82551aa /extract.c
parentrender: codespell: accomodate -> accommodate (diff)
parentextract: finish: increase ‘idx’ when pushing new data, for consistency (diff)
Merge branch 'extend-selection-by-word'
Closes #267
Diffstat (limited to 'extract.c')
-rw-r--r--extract.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/extract.c b/extract.c
index 7b5da229..a6492716 100644
--- a/extract.c
+++ b/extract.c
@@ -69,14 +69,17 @@ extract_finish(struct extraction_context *ctx, char **text, size_t *len)
/* Selection of empty cells only */
if (!ensure_size(ctx, 1))
goto out;
- ctx->buf[ctx->idx] = L'\0';
+ ctx->buf[ctx->idx++] = L'\0';
} else {
assert(ctx->idx > 0);
- assert(ctx->idx < ctx->size);
+ assert(ctx->idx <= ctx->size);
if (ctx->buf[ctx->idx - 1] == L'\n')
ctx->buf[ctx->idx - 1] = L'\0';
- else
- ctx->buf[ctx->idx] = L'\0';
+ else {
+ if (!ensure_size(ctx, 1))
+ goto out;
+ ctx->buf[ctx->idx++] = L'\0';
+ }
}
size_t _len = wcstombs(NULL, ctx->buf, 0);