From 52d1c20973f2ee5f18ec96a94dc64435acd7031a Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Tue, 17 Mar 2015 20:10:59 +0000 Subject: [PATCH] Not setting the modified flag when an external spell checker didn't make any changes. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5140 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 5 +++++ src/text.c | 15 +++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index fdd412f1..5085a5fe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2015-03-17 Benno Schulenberg + * src/text.c (do_alt_speller): Do not set the modified flag when + an external spell checker didn't make any changes. This fixes + Savannah bug #44320, reported by Cody A. Taylor. + 2015-03-14 Benno Schulenberg * src/text.c (do_formatter): Fix a message plus a few comments. diff --git a/src/text.c b/src/text.c index 332555e8..b096fdba 100644 --- a/src/text.c +++ b/src/text.c @@ -2664,6 +2664,8 @@ const char *do_alt_speller(char *tempfile_name) size_t pww_save = openfile->placewewant; ssize_t current_y_save = openfile->current_y; ssize_t lineno_save = openfile->current->lineno; + struct stat spellfileinfo; + __time_t timestamp; pid_t pid_spell; char *ptr; static int arglen = 3; @@ -2699,6 +2701,10 @@ const char *do_alt_speller(char *tempfile_name) return NULL; } + /* Get the timestamp of the temporary file. */ + stat(tempfile_name, &spellfileinfo); + timestamp = spellfileinfo.st_mtime; + endwin(); /* Set up an argument list to pass execvp(). */ @@ -2841,9 +2847,14 @@ const char *do_alt_speller(char *tempfile_name) } #endif - /* Go back to the old position, and mark the file as modified. */ + /* Go back to the old position. */ do_gotopos(lineno_save, current_x_save, current_y_save, pww_save); - set_modified(); + + /* Stat the temporary file again, and mark the buffer as modified only + * if this file was changed since it was written. */ + stat(tempfile_name, &spellfileinfo); + if (spellfileinfo.st_mtime != timestamp) + set_modified(); #ifndef NANO_TINY /* Handle a pending SIGWINCH again. */ -- 2.39.5