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

master
Benno Schulenberg 2019-02-10 16:11:57 +01:00
parent ebfe752841
commit b57336ad00
2 changed files with 23 additions and 24 deletions

View File

@ -316,7 +316,7 @@ int do_lockfile(const char *filename)
size_t readtot = 0; size_t readtot = 0;
size_t readamt = 0; size_t readamt = 0;
char *lockbuf, *question, *pidstring, *postedname, *promptstr; char *lockbuf, *question, *pidstring, *postedname, *promptstr;
int room, response; int room, choice;
if ((lockfd = open(lockfilename, O_RDONLY)) < 0) { if ((lockfd = open(lockfilename, O_RDONLY)) < 0) {
statusline(MILD, _("Error opening lock file %s: %s"), statusline(MILD, _("Error opening lock file %s: %s"),
@ -374,10 +374,10 @@ int do_lockfile(const char *filename)
free(postedname); free(postedname);
free(pidstring); free(pidstring);
response = do_yesno_prompt(FALSE, promptstr); choice = do_yesno_prompt(FALSE, promptstr);
free(promptstr); free(promptstr);
if (response < 1) { if (choice < 1) {
wipe_statusbar(); wipe_statusbar();
goto free_the_name; 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'. */ * messed up and I'm blanket allowing insecure file writing operations'. */
int prompt_failed_backupwrite(const char *filename) int prompt_failed_backupwrite(const char *filename)
{ {
static int response; static int choice;
static char *prevfile = NULL; static char *prevfile = NULL;
/* The last file we were passed, so we don't keep asking this. /* The last file we were passed, so we don't keep asking this.
* Though maybe we should? */ * Though maybe we should? */
if (prevfile == NULL || strcmp(filename, prevfile)) { 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.) ")); "continue saving? (Say N if unsure.) "));
prevfile = mallocstrcpy(prevfile, filename); prevfile = mallocstrcpy(prevfile, filename);
} }
return response; return choice;
} }
/* Transform the specified backup directory to an absolute path, /* 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_mtime < st.st_mtime ||
openfile->current_stat->st_dev != st.st_dev || openfile->current_stat->st_dev != st.st_dev ||
openfile->current_stat->st_ino != st.st_ino)) { openfile->current_stat->st_ino != st.st_ino)) {
int response;
warn_and_shortly_pause(_("File on disk has changed")); 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? ")); "since you opened it; continue saving? "));
wipe_statusbar(); wipe_statusbar();
@ -2296,14 +2295,14 @@ int do_writeout(bool exiting, bool withprompt)
* overwrite the file right here when requested. */ * overwrite the file right here when requested. */
if (ISSET(TEMP_FILE) && withprompt) { if (ISSET(TEMP_FILE) && withprompt) {
free(given); free(given);
if (response == 1) if (choice == 1)
return write_file(openfile->filename, NULL, return write_file(openfile->filename, NULL,
FALSE, OVERWRITE, TRUE); FALSE, OVERWRITE, TRUE);
else if (response == 0) else if (choice == 0)
return 2; return 2;
else else
return 0; return 0;
} else if (response != 1) { } else if (choice != 1) {
free(given); free(given);
return 1; return 1;
} }

View File

@ -659,7 +659,7 @@ int do_prompt(bool allow_tabs, bool allow_files,
* TRUE when passed in), and -1 for Cancel. */ * TRUE when passed in), and -1 for Cancel. */
int do_yesno_prompt(bool all, const char *msg) 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 /* TRANSLATORS: For the next three strings, specify the starting letters
* of the translations for "Yes"/"No"/"All". The first letter of each of * 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. */ * 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 *nostr = _("Nn");
const char *allstr = _("Aa"); const char *allstr = _("Aa");
while (response == -2) { while (choice == -2) {
#ifdef ENABLE_NLS #ifdef ENABLE_NLS
char letter[MAXCHARLEN + 1]; char letter[MAXCHARLEN + 1];
int index = 0; 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. */ /* See if the typed letter is in the Yes, No, or All strings. */
if (strstr(yesstr, letter) != NULL) if (strstr(yesstr, letter) != NULL)
response = 1; choice = 1;
else if (strstr(nostr, letter) != NULL) else if (strstr(nostr, letter) != NULL)
response = 0; choice = 0;
else if (all && strstr(allstr, letter) != NULL) else if (all && strstr(allstr, letter) != NULL)
response = 2; choice = 2;
else else
#endif /* ENABLE_NLS */ #endif /* ENABLE_NLS */
if (strchr("Yy", kbinput) != NULL) if (strchr("Yy", kbinput) != NULL)
response = 1; choice = 1;
else if (strchr("Nn", kbinput) != NULL) else if (strchr("Nn", kbinput) != NULL)
response = 0; choice = 0;
else if (all && strchr("Aa", kbinput) != NULL) else if (all && strchr("Aa", kbinput) != NULL)
response = 2; choice = 2;
else if (func_from_key(&kbinput) == do_cancel) else if (func_from_key(&kbinput) == do_cancel)
response = -1; choice = -1;
#ifdef ENABLE_MOUSE #ifdef ENABLE_MOUSE
else if (kbinput == KEY_MOUSE) { else if (kbinput == KEY_MOUSE) {
int mouse_x, mouse_y; int mouse_x, mouse_y;
@ -759,14 +759,14 @@ int do_yesno_prompt(bool all, const char *msg)
int y = mouse_y - 1; int y = mouse_y - 1;
/* x == 0 means Yes or No, y == 0 means Yes or All. */ /* 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) if (choice == 2 && !all)
response = -2; choice = -2;
} }
} }
#endif /* ENABLE_MOUSE */ #endif /* ENABLE_MOUSE */
} }
return response; return choice;
} }