From a9b5a0e0296b56f9a0d7de36390821761e5ec8d1 Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@justemail.net>
Date: Thu, 22 Dec 2016 12:02:11 +0100
Subject: [PATCH] tweaks: rename a function to something less abbrevy

Also, swap the logic around, to use less braces.
---
 src/browser.c |  2 +-
 src/global.c  | 17 ++++++++---------
 src/prompt.c  |  4 ++--
 src/proto.h   |  2 +-
 src/winio.c   |  8 ++++----
 5 files changed, 16 insertions(+), 17 deletions(-)

diff --git a/src/browser.c b/src/browser.c
index da7c173e..c39ac343 100644
--- a/src/browser.c
+++ b/src/browser.c
@@ -147,7 +147,7 @@ char *do_browser(char *path)
 		/* If we selected the same filename as last time, fake a
 		 * press of the Enter key so that the file is read in. */
 		if (old_selected == selected)
-		    unget_kbinput(sc_seq_or(do_enter, 0), FALSE);
+		    unget_kbinput(the_code_for(do_enter, 0), FALSE);
 	    }
 
 	    continue;
diff --git a/src/global.c b/src/global.c
index a24c373f..645c3668 100644
--- a/src/global.c
+++ b/src/global.c
@@ -385,18 +385,17 @@ const sc *first_sc_for(int menu, void (*func)(void))
     return NULL;
 }
 
-/* Return the given menu's first shortcut sequence, or the default value
- * (2nd arg).  Assumes currmenu for the menu to check. */
-int sc_seq_or(void (*func)(void), int defaultval)
+/* Return the first keycode that is bound to the given function in the
+ * current menu, if any; otherwise, return the given default value. */
+int the_code_for(void (*func)(void), int defaultval)
 {
     const sc *s = first_sc_for(currmenu, func);
 
-    if (s) {
-	meta_key = s->meta;
-	return s->keycode;
-    }
-    /* else */
-    return defaultval;
+    if (s == NULL)
+	return defaultval;
+
+    meta_key = s->meta;
+    return s->keycode;
 }
 
 /* Return a pointer to the function that is bound to the given key. */
diff --git a/src/prompt.c b/src/prompt.c
index 928c170b..7dbb89dd 100644
--- a/src/prompt.c
+++ b/src/prompt.c
@@ -148,7 +148,7 @@ int do_statusbar_input(bool *ran_func, bool *finished)
 	     * fake a press of Enter, and indicate that we're done. */
 	    if (got_newline) {
 		get_input(NULL, 1);
-		input = sc_seq_or(do_enter, 0);
+		input = the_code_for(do_enter, 0);
 		*finished = TRUE;
 	    }
 	} else if (s->scfunc == do_cut_text_void)
@@ -531,7 +531,7 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
 	if (func == do_tab) {
 #ifndef DISABLE_HISTORIES
 	    if (history_list != NULL) {
-		if (last_kbinput != sc_seq_or(do_tab, TAB_CODE))
+		if (last_kbinput != the_code_for(do_tab, TAB_CODE))
 		    complete_len = strlen(answer);
 
 		if (complete_len > 0) {
diff --git a/src/proto.h b/src/proto.h
index a7fe3110..189ef757 100644
--- a/src/proto.h
+++ b/src/proto.h
@@ -358,7 +358,7 @@ int check_poshistory(const char *file, ssize_t *line, ssize_t *column);
 /* Some functions in global.c. */
 size_t length_of_list(int menu);
 const sc *first_sc_for(int menu, void (*func)(void));
-int sc_seq_or(void (*func)(void), int defaultval);
+int the_code_for(void (*func)(void), int defaultval);
 functionptrtype func_from_key(int *kbinput);
 void assign_keyinfo(sc *s, const char *keystring, const int keycode);
 void print_sclist(void);
diff --git a/src/winio.c b/src/winio.c
index 1c3922a7..c06b2481 100644
--- a/src/winio.c
+++ b/src/winio.c
@@ -642,13 +642,13 @@ int parse_kbinput(WINDOW *win)
 #endif
 	case DEL_CODE:
 	    if (ISSET(REBIND_DELETE))
-		return sc_seq_or(do_delete, KEY_DC);
+		return the_code_for(do_delete, KEY_DC);
 	    else
 		return KEY_BACKSPACE;
 #ifdef KEY_SIC
 	/* Slang doesn't support KEY_SIC. */
 	case KEY_SIC:
-	    return sc_seq_or(do_insertfile_void, KEY_IC);
+	    return the_code_for(do_insertfile_void, KEY_IC);
 #endif
 #ifdef KEY_SBEG
 	/* Slang doesn't support KEY_SBEG. */
@@ -667,7 +667,7 @@ int parse_kbinput(WINDOW *win)
 #endif
 	/* Slang doesn't support KEY_CANCEL. */
 	case KEY_CANCEL:
-	    return sc_seq_or(do_cancel, 0x03);
+	    return the_code_for(do_cancel, 0x03);
 #endif
 #ifdef KEY_SUSPEND
 #ifdef KEY_SSUSPEND
@@ -676,7 +676,7 @@ int parse_kbinput(WINDOW *win)
 #endif
 	/* Slang doesn't support KEY_SUSPEND. */
 	case KEY_SUSPEND:
-	    return sc_seq_or(do_suspend_void, KEY_SUSPEND);
+	    return the_code_for(do_suspend_void, KEY_SUSPEND);
 #endif
 #ifdef PDCURSES
 	case KEY_SHIFT_L:
-- 
GitLab