Re: segfaults with option trimblanks in 2.9.2
Benno Schulenberg <[email protected]>
| Newsgroups | gmane.editors.nano.devel,gmane.editors.nano.general |
|---|---|
| Message-ID | <[email protected]> |
Op 22-01-18 om 14:15 schreef Andreas Schamanek: > I reported the bug in https://savannah.gnu.org/bugs/index.php?52948 > Thanks a lot for the patch. The crash is gone! Thanks for testing. An improved patch (attached) went into git: http://git.savannah.gnu.org/cgit/nano.git/commit/?id=91073be4 Benno _______________________________________________ Nano-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/nano-devel
0001-wrapping-don-t-trim-a-blank-character-that-the-user-.patch
(text/x-patch, 1.1 KB)
From 91073be49c5d23c7e54ba4e09098d5b56d7a22e3 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg <[email protected]> Date: Mon, 22 Jan 2018 11:33:19 +0100 Subject: [PATCH 1/2] wrapping: don't trim a blank character that the user just typed Trimming trailing spaces is good, but we should not trim the space (or tab or other blank) that the user just typed and that caused the hard-wrapping to occur. This fixes https://savannah.gnu.org/bugs/?52948. Reported-by: Andreas Schamanek <[email protected]> --- src/text.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/text.c b/src/text.c index 28c26d59..4de48bde 100644 --- a/src/text.c +++ b/src/text.c @@ -1619,8 +1619,9 @@ bool do_wrap(filestruct *line) /* When requested, snip trailing blanks off the wrapped line. */ if (ISSET(TRIM_BLANKS)) { size_t cur_x = move_mbleft(line->data, wrap_loc); + size_t typed_x = move_mbleft(line->data, old_x); - while (is_blank_mbchar(line->data + cur_x)) { + while (is_blank_mbchar(line->data + cur_x) && cur_x != typed_x) { openfile->current_x = cur_x; do_delete(); cur_x = move_mbleft(line->data, cur_x); -- 2.14.3