poe

Уређивач .po фајлова
git clone https://git.sr.ht/~strahinja/poe
Дневник | Датотеке | Референце | ПРОЧИТАЈМЕ | ЛИЦЕНЦА

чување e13adf8dee14534582c625c675e8ea35f449889a
родитељ 748d8870293f6e2dfa8615d0acc9840f4b1c682c
Аутор: Страхиња Радић <sr@strahinja.org>
Датум:   Tue, 31 Mar 2026 13:52:15 +0000

poe.c(erase_prev_word): Bugfix: Pressing C-W and typing didn't zero-terminate

Diffstat:
Mpoe.c | 31++++++++++++-------------------
измењених датотека: 1, додавања: 12(+), брисања: 19(-)

diff --git a/poe.c b/poe.c @@ -503,9 +503,7 @@ erase_prev_word(struct DrawState* state) state->input_buffer[state->coord.row].length = len; pline[len] = 0; state->coord.col = i; - state->input_display_column - = display_length(state->input_buffer[state->coord.row].text, - state->coord.col); + state->input_display_column = display_length(pline, state->coord.col); if (state->input_display_column < state->input_first_shown.col) state->input_first_shown.col = state->input_display_column; state->edit_dirty = 1; @@ -865,29 +863,24 @@ insert_char(struct DrawState* state, uint32_t ch) struct BufferLine* buffer_line; uint32_t* temp = NULL; ssize_t i, len, size; - int add_null; assert((state != NULL) && (state->input_buffer != NULL)); if (state->edit_info_focused) return 1; + + ENSURE_SIZE(state->input_buffer[state->coord.row].text, temp, + state->input_buffer[state->coord.row].size, + state->input_buffer[state->coord.row].length + 2, + state->input_buffer[state->coord.row].size + LINE_ALLOC_DELTA, + insert_char_alloc_error, uint32_t); + buffer_line = &state->input_buffer[state->coord.row]; len = buffer_line->length; size = buffer_line->size; + i = len; - if (len + 1 > size) - { - size += LINE_ALLOC_DELTA; - buffer_line->size = size; - temp = realloc(buffer_line->text, size * sizeof(uint32_t)); - if (!temp) - goto insert_char_alloc_error; - buffer_line->text = temp; - } - - i = len; - add_null = buffer_line->text[state->coord.col] == 0; assert(buffer_line->text != NULL); - while (i + 1 <= size && i > state->coord.col) + while (i + 1 < size && i > state->coord.col) { buffer_line->text[i] = buffer_line->text[i - 1]; i--; @@ -895,8 +888,8 @@ insert_char(struct DrawState* state, uint32_t ch) buffer_line->text[state->coord.col] = ch; buffer_line->length++; position_to(state, state->coord.row, state->coord.col + 1); - if (add_null) - buffer_line->text[state->coord.col] = 0; + buffer_line->text[buffer_line->length] = 0; + state->edit_dirty = 1; return 0;