commit 38acacb4615a53b0fe788411b19a8e22e06047b4
parent caa759be31c5a979f8a4bad0f0cccadab3ceb608
Author: Benno Schulenberg <bensberg@justemail.net>
Date: Fri, 15 Jan 2016 14:42:07 +0000
Moving set_modified() to the file that has to do with files.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5566 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Diffstat:
3 files changed, 27 insertions(+), 24 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -1,5 +1,6 @@
2016-01-15 Benno Schulenberg <bensberg@justemail.net>
* src/winio.c (set_modified): Plug another memory leak.
+ * src/files.c (set_modified): Move this function to its habitat.
* src/files.c (open_file): Return the fantastic file descriptor
when opening a non-existent file for reading succeeds.
diff --git a/src/files.c b/src/files.c
@@ -101,6 +101,32 @@ void initialize_buffer_text(void)
openfile->totsize = 0;
}
+/* Mark the current file as modified if it isn't already, and then
+ * update the titlebar to display the file's new status. */
+void set_modified(void)
+{
+ if (openfile->modified)
+ return;
+
+ openfile->modified = TRUE;
+ titlebar(NULL);
+
+#ifndef NANO_TINY
+ if (!ISSET(LOCKING) || openfile->filename[0] == '\0')
+ return;
+
+ if (openfile->lock_filename == NULL) {
+ /* TRANSLATORS: Try to keep this at most 76 characters. */
+ statusbar(_("Warning: Modifying a file which is not locked,"
+ " check directory permission?"));
+ } else {
+ char *fullname = get_full_path(openfile->filename);
+ write_lockfile(openfile->lock_filename, fullname, TRUE);
+ free(fullname);
+ }
+#endif
+}
+
#ifndef NANO_TINY
/* Actually write the lockfile. This function will ALWAYS annihilate
* any previous version of the file. We'll borrow INSECURE_BACKUP here
diff --git a/src/winio.c b/src/winio.c
@@ -2093,30 +2093,6 @@ void titlebar(const char *path)
wnoutrefresh(edit);
}
-/* Mark the current file as modified if it isn't already, and then
- * update the titlebar to display the file's new status. */
-void set_modified(void)
-{
- if (!openfile->modified) {
- openfile->modified = TRUE;
- titlebar(NULL);
-#ifndef NANO_TINY
- if (ISSET(LOCKING)) {
- if (openfile->filename[0] == '\0')
- return;
- else if (openfile->lock_filename == NULL) {
- /* TRANSLATORS: Try to keep this at most 76 characters. */
- statusbar(_("Warning: Modifying a file which is not locked, check directory permission?"));
- } else {
- char *fullname = get_full_path(openfile->filename);
- write_lockfile(openfile->lock_filename, fullname, TRUE);
- free(fullname);
- }
- }
-#endif
- }
-}
-
/* Display a message on the statusbar, and set disable_cursorpos to
* TRUE, so that the message won't be immediately overwritten if
* constant cursor position display is on. */