nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 16c4f5bbd08d73903eb962420bd46dc62822482a
parent e877c2406e15081af1ad832f57e9a8becc3fc5c6
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Sun,  2 Feb 2020 12:14:32 +0100

tweaks: move a function to be before the ones that call it

Diffstat:
Msrc/files.c | 22+++++++++++-----------
Msrc/proto.h | 4+++-
2 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/src/files.c b/src/files.c @@ -148,6 +148,17 @@ void set_modified(void) } #ifndef NANO_TINY +/* Delete the lockfile. Return -1 if unsuccessful, and 1 otherwise. */ +int delete_lockfile(const char *lockfilename) +{ + if (unlink(lockfilename) < 0 && errno != ENOENT) { + statusline(MILD, _("Error deleting lock file %s: %s"), + lockfilename, strerror(errno)); + return -1; + } + return 1; +} + /* Write a lockfile, under the given lockfilename. This ALWAYS annihilates * an existing version of that file. Return 1 on success, and 0 on failure. */ int write_lockfile(const char *lockfilename, const char *filename, bool modified) @@ -256,17 +267,6 @@ int write_lockfile(const char *lockfilename, const char *filename, bool modified return 1; } -/* Delete the lockfile. Return -1 if unsuccessful, and 1 otherwise. */ -int delete_lockfile(const char *lockfilename) -{ - if (unlink(lockfilename) < 0 && errno != ENOENT) { - statusline(MILD, _("Error deleting lock file %s: %s"), - lockfilename, strerror(errno)); - return -1; - } - return 1; -} - /* Deal with lockfiles. Return -1 on refusing to override the lockfile, * and 1 on successfully creating it; 0 means we were not successful in * creating the lockfile but we should continue to load the file. */ diff --git a/src/proto.h b/src/proto.h @@ -279,6 +279,9 @@ void paste_text(void); /* Most functions in files.c. */ void make_new_buffer(void); +#ifndef NANO_TINY +int delete_lockfile(const char *lockfilename); +#endif void set_modified(void); bool open_buffer(const char *filename, bool new_buffer); #ifdef ENABLE_SPELLER @@ -304,7 +307,6 @@ bool outside_of_confinement(const char *currpath, bool allow_tabcomp); #endif #ifndef NANO_TINY void init_backup_dir(void); -int delete_lockfile(const char *lockfilename); int write_lockfile(const char *lockfilename, const char *filename, bool modified); #endif int copy_file(FILE *inn, FILE *out, bool close_out);