nano

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

commit eb70578c5e8d13a1b33e1235b47baf5bf0df8e8c
parent 63efc5975834697cb428a7a8f3490425b7fd7f28
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Sun, 19 Jul 2020 11:31:29 +0200

tweaks: do not use 'switch' when there are just two possibilities

Also, remove an unneeded 'if', as parse_escape_sequence() is only
ever called when there are at least two bytes after the Esc code.
(If there were not, the 'for' loop after calling convert_sequence()
would use an uninitialized 'consumed' value.)

Diffstat:
Msrc/winio.c | 10+++-------
1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/src/winio.c b/src/winio.c @@ -332,10 +332,9 @@ int arrow_from_ABCD(int letter) * Assume that Escape has already been read in. */ int convert_sequence(const int *seq, size_t length, int *consumed) { - if (length > 1) { *consumed = 2; - switch (seq[0]) { - case 'O': + + if (seq[0] == 'O') { switch (seq[1]) { case '1': if (length > 4 && seq[2] == ';') { @@ -465,8 +464,7 @@ int convert_sequence(const int *seq, size_t length, int *consumed) case 'y': /* Esc O y == PageUp (9) on the same. */ return KEY_PPAGE; } - break; - case '[': + } else if (seq[0] == '[') { if (seq[1] < '9') *consumed = 3; switch (seq[1]) { @@ -808,8 +806,6 @@ int convert_sequence(const int *seq, size_t length, int *consumed) } break; } - break; - } } return FOREIGN_SEQUENCE;