Commit faa0eb99 authored by Benno Schulenberg's avatar Benno Schulenberg
Browse files

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: default avatarDavid Lawrence Ramsey <pooka109@gmail.com>
parent f54cd026
Showing with 11 additions and 8 deletions
+11 -8
......@@ -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();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment