Skip to content

Commit

Permalink
Fix horizontal line matching in 'remove' module
Browse files Browse the repository at this point in the history
  • Loading branch information
tsjensen committed Dec 17, 2023
1 parent acb6a83 commit ff6b298
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions src/remove.c
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,6 @@ static int match_horiz_line(remove_ctx_t *ctx, int hside, size_t input_line_idx,
shape_line_ctx_t *shapes_relevant = prepare_comp_shapes_horiz(hside, comp_type, shape_line_idx);
debug_print_shapes_relevant(shapes_relevant);

uint32_t *cur_pos = NULL;
bxstr_t *input_prepped1 = bxs_from_unicode(prepare_comp_input(input_line_idx, 0, comp_type, 0, NULL, NULL));
bxstr_t *input_prepped = bxs_rtrim(input_prepped1);
bxs_free(input_prepped1);
Expand All @@ -540,15 +539,23 @@ static int match_horiz_line(remove_ctx_t *ctx, int hside, size_t input_line_idx,
fprintf(stderr, " input_prepped = \"%s\"\n", out_input_prepped);
BFREE(out_input_prepped);
#endif
match_result_t *mrl = match_outer_shape(BLEF, input_prepped, shapes_relevant[0].text);
if (mrl != NULL) {
cur_pos = mrl->p + mrl->len;

uint32_t *cur_pos = input_prepped->memory;
match_result_t *mrl = NULL;
if (!ctx->empty_side[BLEF]) {
mrl = match_outer_shape(BLEF, input_prepped, shapes_relevant[0].text);
if (mrl != NULL) {
cur_pos = mrl->p + mrl->len;
}
}

uint32_t *end_pos = NULL;
match_result_t *mrr = match_outer_shape(BRIG, input_prepped, shapes_relevant[SHAPES_PER_SIDE - 1].text);
if (mrr != NULL) {
end_pos = mrr->p;
uint32_t *end_pos = bxs_last_char_ptr(input_prepped);
match_result_t *mrr = NULL;
if (!ctx->empty_side[BRIG]) {
mrr = match_outer_shape(BRIG, input_prepped, shapes_relevant[SHAPES_PER_SIDE - 1].text);
if (mrr != NULL) {
end_pos = mrr->p;
}
}
#ifdef DEBUG
char *out_cur_pos = u32_strconv_to_output(cur_pos);
Expand All @@ -559,9 +566,8 @@ static int match_horiz_line(remove_ctx_t *ctx, int hside, size_t input_line_idx,
BFREE(out_end_pos);
#endif

if (cur_pos && end_pos) {
result = hmm(shapes_relevant, cur_pos, 1, end_pos, mrl->shiftable ? 0 : 1, mrr->shiftable ? 0 : 1);
}
result = hmm(shapes_relevant, cur_pos, 1, end_pos, (mrl == NULL) || mrl->shiftable ? 0 : 1,
(mrr == NULL) || mrr->shiftable ? 0 : 1);

BFREE(mrl);
BFREE(mrr);
Expand Down

0 comments on commit ff6b298

Please sign in to comment.