diff --git a/ChangeLog b/ChangeLog index 1375f1e3f5468a09415a7bde7e2efb48553a2472..b81eaae152ead7259f7aec8564a9c8e7742d5272 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 <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 index f4fead463264c62e13729e2222c99fc7f04136db..860d3120fd2b0e9acc1395d320661bea5c7d56e3 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 a257405caaadaa22d3685b6f7084f5f464f3fed0..97e45c62c4a74876dfff4343b570314b3dab694c 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); }