nano

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

commit b57336ad0011f5faeeaefd3e80b356a158963491
parent ebfe75284116173478c037a2d05821375eea8f10
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Sun, 10 Feb 2019 16:11:57 +0100

tweaks: rename some variables, to match others that have the same task

Diffstat:
Msrc/files.c | 21++++++++++-----------
Msrc/prompt.c | 26+++++++++++++-------------
2 files changed, 23 insertions(+), 24 deletions(-)

diff --git a/src/files.c b/src/files.c @@ -316,7 +316,7 @@ int do_lockfile(const char *filename) size_t readtot = 0; size_t readamt = 0; char *lockbuf, *question, *pidstring, *postedname, *promptstr; - int room, response; + int room, choice; if ((lockfd = open(lockfilename, O_RDONLY)) < 0) { statusline(MILD, _("Error opening lock file %s: %s"), @@ -374,10 +374,10 @@ int do_lockfile(const char *filename) free(postedname); free(pidstring); - response = do_yesno_prompt(FALSE, promptstr); + choice = do_yesno_prompt(FALSE, promptstr); free(promptstr); - if (response < 1) { + if (choice < 1) { wipe_statusbar(); goto free_the_name; } @@ -1514,17 +1514,17 @@ bool outside_of_confinement(const char *currpath, bool allow_tabcomp) * messed up and I'm blanket allowing insecure file writing operations'. */ int prompt_failed_backupwrite(const char *filename) { - static int response; + static int choice; static char *prevfile = NULL; /* The last file we were passed, so we don't keep asking this. * Though maybe we should? */ if (prevfile == NULL || strcmp(filename, prevfile)) { - response = do_yesno_prompt(FALSE, _("Failed to write backup file; " + choice = do_yesno_prompt(FALSE, _("Failed to write backup file; " "continue saving? (Say N if unsure.) ")); prevfile = mallocstrcpy(prevfile, filename); } - return response; + return choice; } /* Transform the specified backup directory to an absolute path, @@ -2284,11 +2284,10 @@ int do_writeout(bool exiting, bool withprompt) (openfile->current_stat->st_mtime < st.st_mtime || openfile->current_stat->st_dev != st.st_dev || openfile->current_stat->st_ino != st.st_ino)) { - int response; warn_and_shortly_pause(_("File on disk has changed")); - response = do_yesno_prompt(FALSE, _("File was modified " + choice = do_yesno_prompt(FALSE, _("File was modified " "since you opened it; continue saving? ")); wipe_statusbar(); @@ -2296,14 +2295,14 @@ int do_writeout(bool exiting, bool withprompt) * overwrite the file right here when requested. */ if (ISSET(TEMP_FILE) && withprompt) { free(given); - if (response == 1) + if (choice == 1) return write_file(openfile->filename, NULL, FALSE, OVERWRITE, TRUE); - else if (response == 0) + else if (choice == 0) return 2; else return 0; - } else if (response != 1) { + } else if (choice != 1) { free(given); return 1; } diff --git a/src/prompt.c b/src/prompt.c @@ -659,7 +659,7 @@ int do_prompt(bool allow_tabs, bool allow_files, * TRUE when passed in), and -1 for Cancel. */ int do_yesno_prompt(bool all, const char *msg) { - int response = -2, width = 16; + int choice = -2, width = 16; /* TRANSLATORS: For the next three strings, specify the starting letters * of the translations for "Yes"/"No"/"All". The first letter of each of * these strings MUST be a single-byte letter; others may be multi-byte. */ @@ -667,7 +667,7 @@ int do_yesno_prompt(bool all, const char *msg) const char *nostr = _("Nn"); const char *allstr = _("Aa"); - while (response == -2) { + while (choice == -2) { #ifdef ENABLE_NLS char letter[MAXCHARLEN + 1]; int index = 0; @@ -733,21 +733,21 @@ int do_yesno_prompt(bool all, const char *msg) /* See if the typed letter is in the Yes, No, or All strings. */ if (strstr(yesstr, letter) != NULL) - response = 1; + choice = 1; else if (strstr(nostr, letter) != NULL) - response = 0; + choice = 0; else if (all && strstr(allstr, letter) != NULL) - response = 2; + choice = 2; else #endif /* ENABLE_NLS */ if (strchr("Yy", kbinput) != NULL) - response = 1; + choice = 1; else if (strchr("Nn", kbinput) != NULL) - response = 0; + choice = 0; else if (all && strchr("Aa", kbinput) != NULL) - response = 2; + choice = 2; else if (func_from_key(&kbinput) == do_cancel) - response = -1; + choice = -1; #ifdef ENABLE_MOUSE else if (kbinput == KEY_MOUSE) { int mouse_x, mouse_y; @@ -759,14 +759,14 @@ int do_yesno_prompt(bool all, const char *msg) int y = mouse_y - 1; /* x == 0 means Yes or No, y == 0 means Yes or All. */ - response = -2 * x * y + x - y + 1; + choice = -2 * x * y + x - y + 1; - if (response == 2 && !all) - response = -2; + if (choice == 2 && !all) + choice = -2; } } #endif /* ENABLE_MOUSE */ } - return response; + return choice; }