nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit c055e629c75fe3acade3f86abd9a90c12d8ee43a
parent e6f26464d7fb0d6948a883a3b816d7cab1bd0a1d
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Fri, 28 Feb 2020 19:24:31 +0100

tweaks: copy and store a deleted character in a conciser manner

Diffstat:
Msrc/text.c | 9++++-----
1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/text.c b/src/text.c @@ -1145,11 +1145,10 @@ void add_undo(undo_type action, const char *message) /* When not at the end of a line, store the deleted character; * otherwise, morph the undo item into a line join. */ if (openfile->current->data[openfile->current_x] != '\0') { - char *char_buf = charalloc(MAXCHARLEN + 1); - int charlen = collect_char(&openfile->current->data[u->head_x], - char_buf); - char_buf[charlen] = '\0'; - u->strdata = char_buf; + int charlen = char_length(openfile->current->data + u->head_x); + + u->strdata = measured_copy(openfile->current->data + u->head_x, + charlen); if (u->type == BACK) u->tail_x += charlen; break;