mirror of
git://git.sv.gnu.org/nano.git
synced 2024-11-23 21:29:39 +03:00
tweaks: avoid using strlen() where it is not needed
This commit is contained in:
parent
3251a216cd
commit
772f1029e5
@ -492,16 +492,16 @@ int keycode_from_string(const char *keystring)
|
||||
if (strcasecmp(keystring, "^H") == 0)
|
||||
return KEY_BACKSPACE;
|
||||
#endif
|
||||
if (keystring[1] == '/' && strlen(keystring) == 2)
|
||||
if (keystring[1] == '/' && keystring[2] == '\0')
|
||||
return 31;
|
||||
if (keystring[1] <= '_' && strlen(keystring) == 2)
|
||||
if (keystring[1] <= '_' && keystring[2] == '\0')
|
||||
return keystring[1] - 64;
|
||||
else
|
||||
return -1;
|
||||
} else if (keystring[0] == 'M') {
|
||||
if (strcasecmp(keystring, "M-Space") == 0)
|
||||
return (int)' ';
|
||||
if (keystring[1] == '-' && strlen(keystring) == 3)
|
||||
if (keystring[1] == '-' && keystring[3] == '\0')
|
||||
return tolower((unsigned char)keystring[2]);
|
||||
else
|
||||
return -1;
|
||||
|
@ -419,7 +419,7 @@ void parse_binding(char *ptr, bool dobind)
|
||||
ptr = parse_next_word(ptr);
|
||||
keycopy = copy_of(keyptr);
|
||||
|
||||
if (strlen(keycopy) < 2) {
|
||||
if (keycopy[1] == '\0') {
|
||||
jot_error(N_("Key name is too short"));
|
||||
goto free_things;
|
||||
}
|
||||
@ -428,7 +428,7 @@ void parse_binding(char *ptr, bool dobind)
|
||||
keycopy[0] = toupper((unsigned char)keycopy[0]);
|
||||
keycopy[1] = toupper((unsigned char)keycopy[1]);
|
||||
if (keycopy[0] == 'M' && keycopy[1] == '-') {
|
||||
if (strlen(keycopy) > 2)
|
||||
if (keycopy[2] != '\0')
|
||||
keycopy[2] = toupper((unsigned char)keycopy[2]);
|
||||
else {
|
||||
jot_error(N_("Key name is too short"));
|
||||
|
Loading…
Reference in New Issue
Block a user