1
1

tweaks: reshuffle a few lines, for brevity or speed or consistency

Also, don't compare case-insensitively where it is not needed.
Этот коммит содержится в:
Benno Schulenberg 2019-12-12 12:34:56 +01:00
родитель 772f1029e5
Коммит ef7c78910c
2 изменённых файлов: 9 добавлений и 14 удалений

Просмотреть файл

@ -489,7 +489,7 @@ int keycode_from_string(const char *keystring)
if (strcasecmp(keystring, "^Space") == 0) if (strcasecmp(keystring, "^Space") == 0)
return 0; return 0;
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__APPLE__) #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__APPLE__)
if (strcasecmp(keystring, "^H") == 0) if (strcmp(keystring, "^H") == 0)
return KEY_BACKSPACE; return KEY_BACKSPACE;
#endif #endif
if (keystring[1] == '/' && keystring[2] == '\0') if (keystring[1] == '/' && keystring[2] == '\0')
@ -499,10 +499,10 @@ int keycode_from_string(const char *keystring)
else else
return -1; return -1;
} else if (keystring[0] == 'M') { } else if (keystring[0] == 'M') {
if (strcasecmp(keystring, "M-Space") == 0)
return (int)' ';
if (keystring[1] == '-' && keystring[3] == '\0') if (keystring[1] == '-' && keystring[3] == '\0')
return tolower((unsigned char)keystring[2]); return tolower((unsigned char)keystring[2]);
if (strcasecmp(keystring, "M-Space") == 0)
return (int)' ';
else else
return -1; return -1;
} else if (keystring[0] == 'F') { } else if (keystring[0] == 'F') {
@ -510,9 +510,9 @@ int keycode_from_string(const char *keystring)
if (fn < 1 || fn > 24) if (fn < 1 || fn > 24)
return -1; return -1;
return KEY_F0 + fn; return KEY_F0 + fn;
} else if (!strcasecmp(keystring, "Ins")) } else if (strcasecmp(keystring, "Ins") == 0)
return KEY_IC; return KEY_IC;
else if (!strcasecmp(keystring, "Del")) else if (strcasecmp(keystring, "Del") == 0)
return KEY_DC; return KEY_DC;
else else
return -1; return -1;
@ -523,11 +523,7 @@ void assign_keyinfo(keystruct *s, const char *keystring, const int keycode)
{ {
s->keystr = keystring; s->keystr = keystring;
s->meta = (keystring[0] == 'M' && keycode == 0); s->meta = (keystring[0] == 'M' && keycode == 0);
s->keycode = (keycode ? keycode : keycode_from_string(keystring));
if (keycode)
s->keycode = keycode;
else
s->keycode = keycode_from_string(keystring);
} }
/* These two tags are used elsewhere too, so they are global. */ /* These two tags are used elsewhere too, so they are global. */

Просмотреть файл

@ -428,12 +428,11 @@ 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 (keycopy[2] != '\0') if (keycopy[2] == '\0') {
keycopy[2] = toupper((unsigned char)keycopy[2]);
else {
jot_error(N_("Key name is too short")); jot_error(N_("Key name is too short"));
goto free_things; goto free_things;
} } else
keycopy[2] = toupper((unsigned char)keycopy[2]);
} }
/* Allow the codes for Insert and Delete to be rebound, but apart /* Allow the codes for Insert and Delete to be rebound, but apart