nano

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

commit faa0eb991ef418ecf70425ed3763458281584c63
parent f54cd0265288147e7a550bd9d63ac7e1672d05a9
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Wed, 25 Apr 2018 11:33:22 +0200

speller: don't add an extra newline when saving the text to a tempfile

Set the NO_NEWLINES flag to achieve this.  And move the saving and
restoring of the global flags to the main speller routine, so the
flags aren't saved and restored for each internal spell fix.

This fixes https://savannah.gnu.org/bugs/?53742.

Acked-by: David Lawrence Ramsey <pooka109@gmail.com>

Diffstat:
Msrc/text.c | 19+++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/src/text.c b/src/text.c @@ -2536,8 +2536,6 @@ bool fix_spello(const char *word) /* The return value of this function. */ bool result; /* The return value of searching for a misspelled word. */ - unsigned stash[sizeof(flags) / sizeof(flags[0])]; - /* A storage place for the current flag settings. */ #ifndef NANO_TINY bool right_side_up = FALSE; /* TRUE if (mark_begin, mark_begin_x) is the top of the mark, @@ -2546,9 +2544,6 @@ bool fix_spello(const char *word) size_t top_x, bot_x; #endif - /* Save the settings of the global flags. */ - memcpy(stash, flags, sizeof(flags)); - /* Do the spell checking case sensitive, forward, and without regexes. */ SET(CASE_SENSITIVE); UNSET(BACKWARDS_SEARCH); @@ -2645,9 +2640,6 @@ bool fix_spello(const char *word) openfile->edittop = edittop_save; openfile->firstcolumn = firstcolumn_save; - /* Restore the settings of the global flags. */ - memcpy(flags, stash, sizeof(flags)); - return proceed; } @@ -2944,6 +2936,8 @@ void do_spell(void) bool status; FILE *temp_file; char *temp; + unsigned stash[sizeof(flags) / sizeof(flags[0])]; + /* A storage place for the current flag settings. */ const char *spell_msg; if (ISSET(RESTRICTED)) { @@ -2958,6 +2952,12 @@ void do_spell(void) return; } + /* Save the settings of the global flags. */ + memcpy(stash, flags, sizeof(flags)); + + /* Don't add an extra newline when writing out the (selected) text. */ + SET(NO_NEWLINES); + #ifndef NANO_TINY if (openfile->mark) status = write_marked_file(temp, temp_file, TRUE, OVERWRITE); @@ -2979,6 +2979,9 @@ void do_spell(void) unlink(temp); free(temp); + /* Restore the settings of the global flags. */ + memcpy(flags, stash, sizeof(flags)); + /* If the spell-checker printed any error messages onscreen, make * sure that they're cleared off. */ total_refresh();