commit 52d1c20973f2ee5f18ec96a94dc64435acd7031a
parent 6898c60ba62b6cdf7a3be6ea4cd4f69a90272083
Author: Benno Schulenberg <bensberg@justemail.net>
Date: Tue, 17 Mar 2015 20:10:59 +0000
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
Diffstat:
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -1,3 +1,8 @@
+2015-03-17 Benno Schulenberg <bensberg@justemail.net>
+ * 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 <bensberg@justemail.net>
* src/text.c (do_formatter): Fix a message plus a few comments.
diff --git 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. */