nano

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

commit 7f3dc2de465e862279f4742e9f85dad3caa2287b
parent 344fe558b6937880f298ecfdc97cd089803d747e
Author: Benno Schulenberg <bensberg@justemail.net>
Date:   Wed, 23 Mar 2016 20:21:36 +0000

Eliding an unneeded 'if' and unneeded variable.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5765 35c25a1d-7b9e-4130-9fde-d3aeb78583b8

Diffstat:
MChangeLog | 1+
Msrc/proto.h | 2+-
Msrc/winio.c | 17++++++-----------
3 files changed, 8 insertions(+), 12 deletions(-)

diff --git 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 <thomasr@fantasymail.de> * configure.ac, src/*.c: Check for the existence of the REG_ENHANCED diff --git 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 @@ -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); }