tweaks: do not use 'switch' when there are just two possibilities

Also, remove an unneeded 'if', as parse_escape_sequence() is only
ever called when there are at least two bytes after the Esc code.
(If there were not, the 'for' loop after calling convert_sequence()
would use an uninitialized 'consumed' value.)
master
Benno Schulenberg 2020-07-19 11:31:29 +02:00
parent 63efc59758
commit eb70578c5e
1 changed files with 3 additions and 7 deletions

View File

@ -332,10 +332,9 @@ int arrow_from_ABCD(int letter)
* Assume that Escape has already been read in. */
int convert_sequence(const int *seq, size_t length, int *consumed)
{
if (length > 1) {
*consumed = 2;
switch (seq[0]) {
case 'O':
if (seq[0] == 'O') {
switch (seq[1]) {
case '1':
if (length > 4 && seq[2] == ';') {
@ -465,8 +464,7 @@ int convert_sequence(const int *seq, size_t length, int *consumed)
case 'y': /* Esc O y == PageUp (9) on the same. */
return KEY_PPAGE;
}
break;
case '[':
} else if (seq[0] == '[') {
if (seq[1] < '9')
*consumed = 3;
switch (seq[1]) {
@ -808,8 +806,6 @@ int convert_sequence(const int *seq, size_t length, int *consumed)
}
break;
}
break;
}
}
return FOREIGN_SEQUENCE;