diff --git a/ChangeLog b/ChangeLog index 0d32c040..db8ae682 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,6 @@ 2016-01-15 Benno Schulenberg * 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 index 1b89c0e9..b324f6ae 100644 --- 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 index 8f1c79a6..385b3588 100644 --- 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. */