nano

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

commit 077d307b300ddce8ec4a49961035bbd6faeb4b70
parent 998992ddcb9b4512cc65234596b80f6afa612c5b
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Tue, 21 Jan 2020 09:41:42 +0100

tweaks: trim some excessive error checking and key-name frobbing

Also, it is clearer to say that "key name %s is invalid" than it is
to say that some unspecified key name is too short.

Diffstat:
Msrc/rcfile.c | 24++++--------------------
1 file changed, 4 insertions(+), 20 deletions(-)

diff --git a/src/rcfile.c b/src/rcfile.c @@ -719,28 +719,12 @@ void parse_binding(char *ptr, bool dobind) ptr = parse_next_word(ptr); keycopy = copy_of(keyptr); - if (keycopy[1] == '\0') { - jot_error(N_("Key name is too short")); - goto free_things; - } - - /* Uppercase only the first two or three characters of the key name. */ + /* Force the first character of the key name to uppercase. */ keycopy[0] = toupper((unsigned char)keycopy[0]); - keycopy[1] = toupper((unsigned char)keycopy[1]); - if (keycopy[0] == 'M' && keycopy[1] == '-') { - if (keycopy[2] == '\0') { - jot_error(N_("Key name is too short")); - goto free_things; - } else - keycopy[2] = toupper((unsigned char)keycopy[2]); - } - /* Allow the codes for Insert and Delete to be rebound, but apart - * from those two only Control, Meta and Function sequences. */ - if (!strcasecmp(keycopy, "Ins") || !strcasecmp(keycopy, "Del")) - keycopy[1] = tolower((unsigned char)keycopy[1]); - else if (keycopy[0] != '^' && keycopy[0] != 'M' && keycopy[0] != 'F') { - jot_error(N_("Key name must begin with \"^\", \"M\", or \"F\"")); + /* Verify that the key name is not too short, to allow the next call. */ + if (keycopy[1] == '\0' || (keycopy[0] == 'M' && keycopy[2] == '\0')) { + jot_error(N_("Key name %s is invalid"), keycopy); goto free_things; }