diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2021-01-04 19:27:57 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2021-01-04 19:27:57 +0000 |
| commit | fcca3d3e55da97e0f5298343cb3cc8fef73223cd (patch) | |
| tree | 97196e44524beea32b53487f31d8ef32e82551aa /extract.c | |
| parent | render: codespell: accomodate -> accommodate (diff) | |
| parent | extract: 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.c | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -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); |
