nano

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

commit a7c158d07d8fdebcac68b1254a5b09df07fbe61e
parent 97e9849d6c9440598a6eb73b0a996cc8e12c0876
Author: Benno Schulenberg <bensberg@justemail.net>
Date:   Thu,  5 May 2016 13:17:05 +0200

input: simplify a bit of code, reducing a four-case switch to a single if

Diffstat:
Msrc/winio.c | 17++++-------------
1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/src/winio.c b/src/winio.c @@ -346,19 +346,10 @@ int parse_kbinput(WINDOW *win) case NANO_CONTROL_3: /* Increment the escape counter. */ escapes++; - switch (escapes) { - case 1: - /* One escape: wait for more input. */ - case 2: - /* Two escapes: wait for more input. */ - case 3: - /* Three escapes: wait for more input. */ - break; - default: - /* More than three escapes: limit the escape counter - * to no more than two, and wait for more input. */ - escapes %= 3; - } + /* If there are four consecutive escapes, discard three of them. */ + if (escapes > 3) + escapes = 1; + /* Wait for more input. */ break; default: switch (escapes) {