From c338d868438fc4766ea2f82f39038ea13c1ba9d1 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Wed, 8 May 2019 19:17:16 +0200 Subject: [PATCH] tweaks: rename some single-letter variables to the same significant word And simply elide one of those variables. --- src/browser.c | 6 ++---- src/files.c | 12 ++++++------ src/search.c | 28 ++++++++++++++-------------- 3 files changed, 22 insertions(+), 24 deletions(-) diff --git a/src/browser.c b/src/browser.c index 61e3b572..63012369 100644 --- a/src/browser.c +++ b/src/browser.c @@ -223,11 +223,9 @@ char *do_browser(char *path) selected = filelist_len - 1; } else if (func == goto_dir_void) { /* Ask for the directory to go to. */ - int i = do_prompt(TRUE, FALSE, MGOTODIR, NULL, NULL, + if (do_prompt(TRUE, FALSE, MGOTODIR, NULL, NULL, /* TRANSLATORS: This is a prompt. */ - browser_refresh, _("Go To Directory")); - - if (i < 0) { + browser_refresh, _("Go To Directory")) < 0) { statusbar(_("Cancelled")); continue; } diff --git a/src/files.c b/src/files.c index 8950303b..ce05a4e0 100644 --- a/src/files.c +++ b/src/files.c @@ -1076,7 +1076,7 @@ char *get_next_filename(const char *name, const char *suffix) * the MULTIBUFFER flag is set. */ void do_insertfile(void) { - int i; + int response; const char *msg; char *given = mallocstrcpy(NULL, ""); /* The last answer the user typed at the statusbar prompt. */ @@ -1121,7 +1121,7 @@ void do_insertfile(void) present_path = mallocstrcpy(present_path, "./"); - i = do_prompt(TRUE, TRUE, + response = do_prompt(TRUE, TRUE, #ifndef NANO_TINY execute ? MEXTCMD : #endif @@ -1137,14 +1137,14 @@ void do_insertfile(void) /* If we're in multibuffer mode and the filename or command is * blank, open a new buffer instead of canceling. */ - if (i == -1 || (i == -2 && !ISSET(MULTIBUFFER))) { + if (response == -1 || (response == -2 && !ISSET(MULTIBUFFER))) { statusbar(_("Cancelled")); break; } else { ssize_t was_current_lineno = openfile->current->lineno; size_t was_current_x = openfile->current_x; #if !defined(NANO_TINY) || defined(ENABLE_BROWSER) || defined(ENABLE_MULTIBUFFER) - functionptrtype func = func_from_key(&i); + functionptrtype func = func_from_key(&response); #endif given = mallocstrcpy(given, answer); @@ -1178,7 +1178,7 @@ void do_insertfile(void) free(answer); answer = chosen; - i = 0; + response = 0; } #endif #ifndef NANO_TINY @@ -1189,7 +1189,7 @@ void do_insertfile(void) } #endif /* If we don't have a file yet, go back to the prompt. */ - if (i != 0 && (!ISSET(MULTIBUFFER) || i != -2)) + if (response != 0 && (!ISSET(MULTIBUFFER) || response != -2)) continue; #ifndef NANO_TINY diff --git a/src/search.c b/src/search.c index 0212a949..51bbd4a0 100644 --- a/src/search.c +++ b/src/search.c @@ -93,7 +93,7 @@ void search_init(bool replacing, bool keep_the_answer) while (TRUE) { functionptrtype func; /* Ask the user what to search for (or replace). */ - int i = do_prompt(FALSE, FALSE, + int response = do_prompt(FALSE, FALSE, inhelp ? MFINDINHELP : (replacing ? MREPLACE : MWHEREIS), answer, &search_history, /* TRANSLATORS: This is the main search prompt. */ @@ -109,13 +109,13 @@ void search_init(bool replacing, bool keep_the_answer) /* If the search was cancelled, or we have a blank answer and * nothing was searched for yet during this session, get out. */ - if (i == -1 || (i == -2 && *last_search == '\0')) { + if (response == -1 || (response == -2 && *last_search == '\0')) { statusbar(_("Cancelled")); break; } /* If Enter was pressed, prepare to do a replace or a search. */ - if (i == 0 || i == -2) { + if (response == 0 || response == -2) { /* If an actual answer was typed, remember it. */ if (*answer != '\0') { last_search = mallocstrcpy(last_search, answer); @@ -137,7 +137,7 @@ void search_init(bool replacing, bool keep_the_answer) break; } - func = func_from_key(&i); + func = func_from_key(&response); /* If we're here, one of the five toggles was pressed, or * a shortcut was executed. */ @@ -686,22 +686,22 @@ void ask_for_replacement(void) linestruct *edittop_save, *begin; size_t firstcolumn_save, begin_x; ssize_t numreplaced; - int i = do_prompt(FALSE, FALSE, MREPLACEWITH, NULL, &replace_history, + int response = do_prompt(FALSE, FALSE, MREPLACEWITH, NULL, &replace_history, /* TRANSLATORS: This is a prompt. */ edit_refresh, _("Replace with")); #ifdef ENABLE_HISTORIES /* If the replace string is not "", add it to the replace history list. */ - if (i == 0) + if (response == 0) update_history(&replace_history, answer); #endif /* When cancelled, or when a function was run, get out. */ - if (i == -1 || i > 0) { - if (i == -1) - statusbar(_("Cancelled")); + if (response == -1) { + statusbar(_("Cancelled")); + return; + } else if (response > 0) return; - } /* Save where we are. */ edittop_save = openfile->edittop; @@ -744,18 +744,18 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer, { if (interactive) { /* Ask for the line and column. */ - int i = do_prompt(FALSE, FALSE, MGOTOLINE, + int response = do_prompt(FALSE, FALSE, MGOTOLINE, use_answer ? answer : NULL, NULL, /* TRANSLATORS: This is a prompt. */ edit_refresh, _("Enter line number, column number")); /* If the user cancelled or gave a blank answer, get out. */ - if (i < 0) { + if (response < 0) { statusbar(_("Cancelled")); return; } - if (func_from_key(&i) == flip_goto) { + if (func_from_key(&response) == flip_goto) { UNSET(BACKWARDS_SEARCH); /* Retain what the user typed so far and switch to searching. */ search_init(FALSE, TRUE); @@ -763,7 +763,7 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer, } /* If a function was executed, we're done here. */ - if (i > 0) + if (response > 0) return; /* Try to extract one or two numbers from the user's response. */