tweaks: avoid using strlen() where it is not needed
Этот коммит содержится в:
родитель
3251a216cd
Коммит
772f1029e5
@ -492,16 +492,16 @@ int keycode_from_string(const char *keystring)
|
|||||||
if (strcasecmp(keystring, "^H") == 0)
|
if (strcasecmp(keystring, "^H") == 0)
|
||||||
return KEY_BACKSPACE;
|
return KEY_BACKSPACE;
|
||||||
#endif
|
#endif
|
||||||
if (keystring[1] == '/' && strlen(keystring) == 2)
|
if (keystring[1] == '/' && keystring[2] == '\0')
|
||||||
return 31;
|
return 31;
|
||||||
if (keystring[1] <= '_' && strlen(keystring) == 2)
|
if (keystring[1] <= '_' && keystring[2] == '\0')
|
||||||
return keystring[1] - 64;
|
return keystring[1] - 64;
|
||||||
else
|
else
|
||||||
return -1;
|
return -1;
|
||||||
} else if (keystring[0] == 'M') {
|
} else if (keystring[0] == 'M') {
|
||||||
if (strcasecmp(keystring, "M-Space") == 0)
|
if (strcasecmp(keystring, "M-Space") == 0)
|
||||||
return (int)' ';
|
return (int)' ';
|
||||||
if (keystring[1] == '-' && strlen(keystring) == 3)
|
if (keystring[1] == '-' && keystring[3] == '\0')
|
||||||
return tolower((unsigned char)keystring[2]);
|
return tolower((unsigned char)keystring[2]);
|
||||||
else
|
else
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -419,7 +419,7 @@ void parse_binding(char *ptr, bool dobind)
|
|||||||
ptr = parse_next_word(ptr);
|
ptr = parse_next_word(ptr);
|
||||||
keycopy = copy_of(keyptr);
|
keycopy = copy_of(keyptr);
|
||||||
|
|
||||||
if (strlen(keycopy) < 2) {
|
if (keycopy[1] == '\0') {
|
||||||
jot_error(N_("Key name is too short"));
|
jot_error(N_("Key name is too short"));
|
||||||
goto free_things;
|
goto free_things;
|
||||||
}
|
}
|
||||||
@ -428,7 +428,7 @@ void parse_binding(char *ptr, bool dobind)
|
|||||||
keycopy[0] = toupper((unsigned char)keycopy[0]);
|
keycopy[0] = toupper((unsigned char)keycopy[0]);
|
||||||
keycopy[1] = toupper((unsigned char)keycopy[1]);
|
keycopy[1] = toupper((unsigned char)keycopy[1]);
|
||||||
if (keycopy[0] == 'M' && keycopy[1] == '-') {
|
if (keycopy[0] == 'M' && keycopy[1] == '-') {
|
||||||
if (strlen(keycopy) > 2)
|
if (keycopy[2] != '\0')
|
||||||
keycopy[2] = toupper((unsigned char)keycopy[2]);
|
keycopy[2] = toupper((unsigned char)keycopy[2]);
|
||||||
else {
|
else {
|
||||||
jot_error(N_("Key name is too short"));
|
jot_error(N_("Key name is too short"));
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user