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
This commit is contained in:
Benno Schulenberg 2016-01-15 14:42:07 +00:00
parent caa759be31
commit 38acacb461
3 changed files with 27 additions and 24 deletions

View File

@ -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.

View File

@ -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

View File

@ -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. */