From 7f3dc2de465e862279f4742e9f85dad3caa2287b Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Wed, 23 Mar 2016 20:21:36 +0000 Subject: [PATCH] Eliding an unneeded 'if' and unneeded variable. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5765 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 1 + src/proto.h | 2 +- src/winio.c | 17 ++++++----------- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1375f1e3..b81eaae1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,7 @@ * src/winio.c (reset_cursor): Remove a pointless condition, and make use of an existing intermediary variable. * src/winio.c (reset_cursor): Tidy up and rename a variable. + * src/winio.c (onekey): Elide an unneeded 'if' and unneeded variable. 2016-03-22 Thomas Rosenau * configure.ac, src/*.c: Check for the existence of the REG_ENHANCED diff --git a/src/proto.h b/src/proto.h index f4fead46..860d3120 100644 --- a/src/proto.h +++ b/src/proto.h @@ -788,7 +788,7 @@ void titlebar(const char *path); extern void set_modified(void); void statusbar(const char *msg, ...); void bottombars(int menu); -void onekey(const char *keystroke, const char *desc, size_t len); +void onekey(const char *keystroke, const char *desc, int length); void reset_cursor(void); void edit_draw(filestruct *fileptr, const char *converted, int line, size_t start); diff --git a/src/winio.c b/src/winio.c index a257405c..97e45c62 100644 --- a/src/winio.c +++ b/src/winio.c @@ -2238,33 +2238,28 @@ void bottombars(int menu) /* Write a shortcut key to the help area at the bottom of the window. * keystroke is e.g. "^G" and desc is e.g. "Get Help". We are careful - * to write at most len characters, even if len is very small and + * to write at most length characters, even if length is very small and * keystroke and desc are long. Note that waddnstr(,,(size_t)-1) adds * the whole string! We do not bother padding the entry with blanks. */ -void onekey(const char *keystroke, const char *desc, size_t len) +void onekey(const char *keystroke, const char *desc, int length) { - size_t keystroke_len = strlenpt(keystroke) + 1; - assert(keystroke != NULL && desc != NULL); if (interface_color_pair[KEY_COMBO].bright) wattron(bottomwin, A_BOLD); wattron(bottomwin, interface_color_pair[KEY_COMBO].pairnum); - waddnstr(bottomwin, keystroke, actual_x(keystroke, len)); + waddnstr(bottomwin, keystroke, actual_x(keystroke, length)); wattroff(bottomwin, A_BOLD); wattroff(bottomwin, interface_color_pair[KEY_COMBO].pairnum); - if (len > keystroke_len) - len -= keystroke_len; - else - len = 0; + length -= strlenpt(keystroke) + 1; - if (len > 0) { + if (length > 0) { waddch(bottomwin, ' '); if (interface_color_pair[FUNCTION_TAG].bright) wattron(bottomwin, A_BOLD); wattron(bottomwin, interface_color_pair[FUNCTION_TAG].pairnum); - waddnstr(bottomwin, desc, actual_x(desc, len)); + waddnstr(bottomwin, desc, actual_x(desc, length)); wattroff(bottomwin, A_BOLD); wattroff(bottomwin, interface_color_pair[FUNCTION_TAG].pairnum); } -- 2.39.5