nano

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

commit 04a08fe6a5b3083ab60b9d3d9bcd5ff2257d6d0e
parent 69d33ec170454c1b21b05780186fb9f251e7dd59
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Sun, 21 Aug 2022 09:02:32 +0200

tweaks: rename a variable, away from an abbreviation

Diffstat:
Msrc/browser.c | 52++++++++++++++++++++++++++--------------------------
Msrc/files.c | 32++++++++++++++++----------------
Msrc/global.c | 14+++++++-------
Msrc/help.c | 34+++++++++++++++++-----------------
Msrc/prompt.c | 44++++++++++++++++++++++----------------------
Msrc/prototypes.h | 2+-
Msrc/search.c | 14+++++++-------
Msrc/text.c | 12++++++------
8 files changed, 102 insertions(+), 102 deletions(-)

diff --git a/src/browser.c b/src/browser.c @@ -461,7 +461,7 @@ char *browse(char *path) titlebar(path); while (TRUE) { - functionptrtype func; + functionptrtype function; int kbinput; lastmessage = VACUUM; @@ -510,68 +510,68 @@ char *browse(char *path) continue; } #endif - func = interpret(&kbinput); + function = interpret(&kbinput); - if (func == full_refresh) { + if (function == full_refresh) { full_refresh(); #ifndef NANO_TINY /* Simulate a terminal resize to force a directory reread. */ kbinput = KEY_WINCH; #endif - } else if (func == do_help) { + } else if (function == do_help) { do_help(); #ifndef NANO_TINY /* The terminal dimensions might have changed, so act as if. */ kbinput = KEY_WINCH; - } else if (func == do_toggle) { + } else if (function == do_toggle) { TOGGLE(NO_HELP); window_init(); kbinput = KEY_WINCH; #endif - } else if (func == do_search_backward) { + } else if (function == do_search_backward) { search_filename(BACKWARD); - } else if (func == do_search_forward) { + } else if (function == do_search_forward) { search_filename(FORWARD); - } else if (func == do_findprevious) { + } else if (function == do_findprevious) { research_filename(BACKWARD); - } else if (func == do_findnext) { + } else if (function == do_findnext) { research_filename(FORWARD); - } else if (func == do_left) { + } else if (function == do_left) { if (selected > 0) selected--; - } else if (func == do_right) { + } else if (function == do_right) { if (selected < list_length - 1) selected++; - } else if (func == to_prev_word) { + } else if (function == to_prev_word) { selected -= (selected % piles); - } else if (func == to_next_word) { + } else if (function == to_next_word) { selected += piles - 1 - (selected % piles); if (selected >= list_length) selected = list_length - 1; - } else if (func == do_up) { + } else if (function == do_up) { if (selected >= piles) selected -= piles; - } else if (func == do_down) { + } else if (function == do_down) { if (selected + piles <= list_length - 1) selected += piles; - } else if (func == to_prev_block) { + } else if (function == to_prev_block) { selected = ((selected / (usable_rows * piles)) * usable_rows * piles) + selected % piles; - } else if (func == to_next_block) { + } else if (function == to_next_block) { selected = ((selected / (usable_rows * piles)) * usable_rows * piles) + selected % piles + usable_rows * piles - piles; if (selected >= list_length) selected = (list_length / piles) * piles + selected % piles; if (selected >= list_length) selected -= piles; - } else if (func == do_page_up) { + } else if (function == do_page_up) { if (selected < piles) selected = 0; else if (selected < usable_rows * piles) selected = selected % piles; else selected -= usable_rows * piles; - } else if (func == do_page_down) { + } else if (function == do_page_down) { if (selected + piles >= list_length - 1) selected = list_length - 1; else if (selected + usable_rows * piles >= list_length) @@ -579,11 +579,11 @@ char *browse(char *path) list_length - piles; else selected += usable_rows * piles; - } else if (func == to_first_file) { + } else if (function == to_first_file) { selected = 0; - } else if (func == to_last_file) { + } else if (function == to_last_file) { selected = list_length - 1; - } else if (func == goto_dir) { + } else if (function == goto_dir) { /* Ask for the directory to go to. */ if (do_prompt(MGOTODIR, "", NULL, /* TRANSLATORS: This is a prompt. */ @@ -622,7 +622,7 @@ char *browse(char *path) /* Try opening and reading the specified directory. */ goto read_directory_contents; - } else if (func == do_enter) { + } else if (function == do_enter) { struct stat st; /* It isn't possible to move up from the root directory. */ @@ -662,14 +662,14 @@ char *browse(char *path) path = mallocstrcpy(path, filelist[selected]); goto read_directory_contents; #ifdef ENABLE_NANORC - } else if (func == (functionptrtype)implant) { - implant(first_sc_for(MBROWSER, func)->expansion); + } else if (function == (functionptrtype)implant) { + implant(first_sc_for(MBROWSER, function)->expansion); #endif #ifndef NANO_TINY } else if (kbinput == KEY_WINCH) { ; /* Gets handled below. */ #endif - } else if (func == do_exit) { + } else if (function == do_exit) { break; } else unbound_key(kbinput); diff --git a/src/files.c b/src/files.c @@ -1213,7 +1213,7 @@ void insert_a_file_or(bool execute) 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(&response); + functionptrtype function = func_from_key(&response); #endif given = mallocstrcpy(given, answer); @@ -1221,7 +1221,7 @@ void insert_a_file_or(bool execute) break; #ifdef ENABLE_MULTIBUFFER - if (func == flip_newbuffer) { + if (function == flip_newbuffer) { /* Allow toggling only when not in view mode. */ if (!ISSET(VIEW_MODE)) TOGGLE(MULTIBUFFER); @@ -1231,22 +1231,22 @@ void insert_a_file_or(bool execute) } #endif #ifndef NANO_TINY - if (func == flip_convert) { + if (function == flip_convert) { TOGGLE(NO_CONVERT); continue; } - if (func == flip_execute) { + if (function == flip_execute) { execute = !execute; continue; } - if (func == flip_pipe) { + if (function == flip_pipe) { add_or_remove_pipe_symbol_from_answer(); given = mallocstrcpy(given, answer); continue; } #endif #ifdef ENABLE_BROWSER - if (func == to_files) { + if (function == to_files) { char *chosen = browse_in(answer); /* If no file was chosen, go back to the prompt. */ @@ -2094,7 +2094,7 @@ int write_it_out(bool exiting, bool withprompt) #endif while (TRUE) { - functionptrtype func; + functionptrtype function; const char *msg; int response = 0; int choice = NO; @@ -2141,10 +2141,10 @@ int write_it_out(bool exiting, bool withprompt) return 0; } - func = func_from_key(&response); + function = func_from_key(&response); /* Upon request, abandon the buffer. */ - if (func == discard_buffer) { + if (function == discard_buffer) { free(given); return 2; } @@ -2152,7 +2152,7 @@ int write_it_out(bool exiting, bool withprompt) given = mallocstrcpy(given, answer); #ifdef ENABLE_BROWSER - if (func == to_files) { + if (function == to_files) { char *chosen = browse_in(answer); if (chosen == NULL) @@ -2163,17 +2163,17 @@ int write_it_out(bool exiting, bool withprompt) } else #endif #ifndef NANO_TINY - if (func == dos_format) { + if (function == dos_format) { openfile->fmt = (openfile->fmt == DOS_FILE) ? NIX_FILE : DOS_FILE; continue; - } else if (func == mac_format) { + } else if (function == mac_format) { openfile->fmt = (openfile->fmt == MAC_FILE) ? NIX_FILE : MAC_FILE; continue; - } else if (func == back_it_up) { + } else if (function == back_it_up) { TOGGLE(MAKE_BACKUP); continue; - } else if (func == prepend_it || func == append_it) { - if (func == prepend_it) + } else if (function == prepend_it || function == append_it) { + if (function == prepend_it) method = (method == PREPEND) ? OVERWRITE : PREPEND; else method = (method == APPEND) ? OVERWRITE : APPEND; @@ -2182,7 +2182,7 @@ int write_it_out(bool exiting, bool withprompt) continue; } else #endif - if (func == do_help) + if (function == do_help) continue; #ifdef ENABLE_EXTRA diff --git a/src/global.c b/src/global.c @@ -317,7 +317,7 @@ void discard_buffer(void) {;} void do_cancel(void) {;} /* Add a function to the linked list of functions. */ -void add_to_funcs(void (*func)(void), int menus, const char *desc, +void add_to_funcs(void (*function)(void), int menus, const char *desc, const char *help, bool blank_after) { funcstruct *f = nmalloc(sizeof(funcstruct)); @@ -329,7 +329,7 @@ void add_to_funcs(void (*func)(void), int menus, const char *desc, tailfunc = f; f->next = NULL; - f->func = func; + f->func = function; f->menus = menus; f->desc = desc; #ifdef ENABLE_HELP @@ -385,7 +385,7 @@ int keycode_from_string(const char *keystring) /* Add a key combo to the linked list of shortcuts. */ void add_to_sclist(int menus, const char *scstring, const int keycode, - void (*func)(void), int toggle) + void (*function)(void), int toggle) { static keystruct *tailsc; #ifndef NANO_TINY @@ -402,7 +402,7 @@ void add_to_sclist(int menus, const char *scstring, const int keycode, /* Fill in the data. */ sc->menus = menus; - sc->func = func; + sc->func = function; #ifndef NANO_TINY sc->toggle = toggle; /* When not the same toggle as the previous one, increment the ID. */ @@ -416,11 +416,11 @@ void add_to_sclist(int menus, const char *scstring, const int keycode, } /* Return the first shortcut in the list of shortcuts that - * matches the given func in the given menu. */ -const keystruct *first_sc_for(int menu, void (*func)(void)) + * matches the given function in the given menu. */ +const keystruct *first_sc_for(int menu, void (*function)(void)) { for (keystruct *sc = sclist; sc != NULL; sc = sc->next) - if ((sc->menus & menu) && sc->func == func && sc->keystr[0]) + if ((sc->menus & menu) && sc->func == function && sc->keystr[0]) return sc; return NULL; diff --git a/src/help.c b/src/help.c @@ -389,7 +389,7 @@ void wrap_help_text_into_buffer(void) void show_help(void) { int kbinput = ERR; - functionptrtype func; + functionptrtype function; /* The function of the key the user typed in. */ int oldmenu = currmenu; /* The menu we were called from. */ @@ -475,28 +475,28 @@ void show_help(void) continue; } #endif - func = interpret(&kbinput); + function = interpret(&kbinput); - if (func == full_refresh) { + if (function == full_refresh) { full_refresh(); - } else if (ISSET(SHOW_CURSOR) && (func == do_left || func == do_right || - func == do_up || func == do_down)) { - func(); - } else if (func == do_up || func == do_scroll_up) { + } else if (ISSET(SHOW_CURSOR) && (function == do_left || function == do_right || + function == do_up || function == do_down)) { + function(); + } else if (function == do_up || function == do_scroll_up) { do_scroll_up(); - } else if (func == do_down || func == do_scroll_down) { + } else if (function == do_down || function == do_scroll_down) { if (openfile->edittop->lineno + editwinrows - 1 < openfile->filebot->lineno) do_scroll_down(); - } else if (func == do_page_up || func == do_page_down || - func == to_first_line || func == to_last_line) { - func(); - } else if (func == do_search_backward || func == do_search_forward || - func == do_findprevious || func == do_findnext) { - func(); + } else if (function == do_page_up || function == do_page_down || + function == to_first_line || function == to_last_line) { + function(); + } else if (function == do_search_backward || function == do_search_forward || + function == do_findprevious || function == do_findnext) { + function(); bottombars(MHELP); #ifdef ENABLE_NANORC - } else if (func == (functionptrtype)implant) { - implant(first_sc_for(MHELP, func)->expansion); + } else if (function == (functionptrtype)implant) { + implant(first_sc_for(MHELP, function)->expansion); #endif #ifdef ENABLE_MOUSE } else if (kbinput == KEY_MOUSE) { @@ -507,7 +507,7 @@ void show_help(void) } else if (kbinput == KEY_WINCH) { ; /* Nothing to do. */ #endif - } else if (func == do_exit) { + } else if (function == do_exit) { break; } else unbound_key(kbinput); diff --git a/src/prompt.c b/src/prompt.c @@ -426,7 +426,7 @@ functionptrtype acquire_an_answer(int *actual, bool *listed, #endif #endif const keystruct *shortcut; - functionptrtype func; + functionptrtype function; int input; if (typing_x > strlen(answer)) @@ -459,16 +459,16 @@ functionptrtype acquire_an_answer(int *actual, bool *listed, /* Check for a shortcut in the current list. */ shortcut = get_shortcut(&input); - func = (shortcut ? shortcut->func : NULL); + function = (shortcut ? shortcut->func : NULL); - if (func == do_cancel || func == do_enter) + if (function == do_cancel || function == do_enter) break; /* When it's a normal character, add it to the answer. */ - absorb_character(input, func); + absorb_character(input, function); #ifdef ENABLE_TABCOMP - if (func == do_tab) { + if (function == do_tab) { #ifdef ENABLE_HISTORIES if (history_list != NULL) { if (!previous_was_tab) @@ -487,7 +487,7 @@ functionptrtype acquire_an_answer(int *actual, bool *listed, } else #endif #ifdef ENABLE_HISTORIES - if (func == get_older_item && history_list != NULL) { + if (function == get_older_item && history_list != NULL) { /* If this is the first step into history, start at the bottom. */ if (stored_string == NULL) reset_history_pointer_for(*history_list); @@ -502,7 +502,7 @@ functionptrtype acquire_an_answer(int *actual, bool *listed, answer = mallocstrcpy(answer, (*history_list)->data); typing_x = strlen(answer); } - } else if (func == get_newer_item && history_list != NULL) { + } else if (function == get_newer_item && history_list != NULL) { /* If there is a newer item, move to it and copy its string. */ if ((*history_list)->next != NULL) { *history_list = (*history_list)->next; @@ -517,33 +517,33 @@ functionptrtype acquire_an_answer(int *actual, bool *listed, } } else #endif /* ENABLE_HISTORIES */ - if (func == do_help || func == full_refresh) - func(); + if (function == do_help || function == full_refresh) + function(); #ifndef NANO_TINY - else if (func == do_toggle) { + else if (function == do_toggle) { TOGGLE(NO_HELP); window_init(); focusing = FALSE; refresh_func(); bottombars(currmenu); - } else if (func == do_nothing) + } else if (function == do_nothing) ; #endif #ifdef ENABLE_NANORC - else if (func == (functionptrtype)implant) + else if (function == (functionptrtype)implant) implant(shortcut->expansion); #endif - else if (func && !handle_editing(func)) { + else if (function && !handle_editing(function)) { /* When it's a permissible shortcut, run it and done. */ - if (!ISSET(VIEW_MODE) || !changes_something(func)) { - func(); + if (!ISSET(VIEW_MODE) || !changes_something(function)) { + function(); break; } else beep(); } #if defined(ENABLE_HISTORIES) && defined(ENABLE_TABCOMP) - previous_was_tab = (func == do_tab); + previous_was_tab = (function == do_tab); #endif } @@ -557,7 +557,7 @@ functionptrtype acquire_an_answer(int *actual, bool *listed, *actual = input; - return func; + return function; } /* Ask a question on the status bar. Return 0 when text was entered, @@ -567,7 +567,7 @@ functionptrtype acquire_an_answer(int *actual, bool *listed, int do_prompt(int menu, const char *provided, linestruct **history_list, void (*refresh_func)(void), const char *msg, ...) { - functionptrtype func = NULL; + functionptrtype function = NULL; bool listed = FALSE; va_list ap; int retval; @@ -592,7 +592,7 @@ int do_prompt(int menu, const char *provided, linestruct **history_list, lastmessage = VACUUM; - func = acquire_an_answer(&retval, &listed, history_list, refresh_func); + function = acquire_an_answer(&retval, &listed, history_list, refresh_func); free(prompt); prompt = saved_prompt; @@ -603,14 +603,14 @@ int do_prompt(int menu, const char *provided, linestruct **history_list, /* If we're done with this prompt, restore the x position to what * it was at a possible previous prompt. */ - if (func == do_cancel || func == do_enter) + if (function == do_cancel || function == do_enter) typing_x = was_typing_x; /* If we left the prompt via Cancel or Enter, set the return value * properly. */ - if (func == do_cancel) + if (function == do_cancel) retval = -1; - else if (func == do_enter) + else if (function == do_enter) retval = (*answer == '\0') ? -2 : 0; if (lastmessage == VACUUM) diff --git a/src/prototypes.h b/src/prototypes.h @@ -319,7 +319,7 @@ char *input_tab(char *buf, size_t *place, void (*refresh_func)(void), bool *list #endif /* Some functions in global.c. */ -const keystruct *first_sc_for(int menu, void (*func)(void)); +const keystruct *first_sc_for(int menu, void (*function)(void)); size_t shown_entries_for(int menu); const keystruct *get_shortcut(int *keycode); functionptrtype func_from_key(int *keycode); diff --git a/src/search.c b/src/search.c @@ -91,7 +91,7 @@ void search_init(bool replacing, bool retain_answer) thedefault = copy_of(""); while (TRUE) { - functionptrtype func; + functionptrtype function; /* Ask the user what to search for (or replace). */ int response = do_prompt( inhelp ? MFINDINHELP : (replacing ? MREPLACE : MWHEREIS), @@ -138,23 +138,23 @@ void search_init(bool replacing, bool retain_answer) retain_answer = TRUE; - func = func_from_key(&response); + function = func_from_key(&response); /* If we're here, one of the five toggles was pressed, or * a shortcut was executed. */ - if (func == case_sens_void) + if (function == case_sens_void) TOGGLE(CASE_SENSITIVE); - else if (func == backwards_void) + else if (function == backwards_void) TOGGLE(BACKWARDS_SEARCH); - else if (func == regexp_void) + else if (function == regexp_void) TOGGLE(USE_REGEXP); - else if (func == flip_replace) { + else if (function == flip_replace) { if (ISSET(VIEW_MODE)) { print_view_warning(); napms(600); } else replacing = !replacing; - } else if (func == flip_goto) { + } else if (function == flip_goto) { goto_line_and_column(openfile->current->lineno, openfile->placewewant + 1, TRUE, TRUE); break; diff --git a/src/text.c b/src/text.c @@ -2761,7 +2761,7 @@ void do_linter(void) while (TRUE) { int kbinput; - functionptrtype func; + functionptrtype function; struct stat lintfileinfo; if (stat(curlint->filename, &lintfileinfo) != -1 && @@ -2856,16 +2856,16 @@ void do_linter(void) if (kbinput == KEY_WINCH) continue; #endif - func = func_from_key(&kbinput); + function = func_from_key(&kbinput); tmplint = curlint; - if (func == do_cancel || func == do_enter) { + if (function == do_cancel || function == do_enter) { wipe_statusbar(); break; - } else if (func == do_help) { + } else if (function == do_help) { tmplint = NULL; do_help(); - } else if (func == do_page_up || func == to_prev_block) { + } else if (function == do_page_up || function == to_prev_block) { if (curlint->prev != NULL) curlint = curlint->prev; else if (last_wait != time(NULL)) { @@ -2875,7 +2875,7 @@ void do_linter(void) last_wait = time(NULL); statusline(NOTICE, curlint->msg); } - } else if (func == do_page_down || func == to_next_block) { + } else if (function == do_page_down || function == to_next_block) { if (curlint->next != NULL) curlint = curlint->next; else if (last_wait != time(NULL)) {