coverity/155507: remove condition where both branches were identical

`keylen` was always set to 0 from both branches of an if-statement. This
condition is removed, and the code is simplified based on the fact that
`keylen` is always 0 in this code. Also updated the surrounding comments,
some of which were outdated.
This commit is contained in:
Sander Bosma 2017-03-11 18:59:51 +01:00
parent e66c6dd9d5
commit 10a5825b95

View File

@ -1913,59 +1913,30 @@ static int vgetorpeek(int advance)
if ((mp == NULL || max_mlen >= mp_match_len) if ((mp == NULL || max_mlen >= mp_match_len)
&& keylen != KEYLEN_PART_MAP) { && keylen != KEYLEN_PART_MAP) {
// When no matching mapping found or found a non-matching mapping // No matching mapping found or found a non-matching mapping that
// that matches at least what the matching mapping matched: // matches at least what the matching mapping matched
// Check if we have a terminal code, when: keylen = 0;
// mapping is allowed, // If there was no mapping, use the character from the typeahead
// keys have not been mapped, // buffer right here. Otherwise, use the mapping (loop around).
// and not an ESC sequence, not in insert mode, if (mp == NULL) {
// and when not timed out. // get a character: 2. from the typeahead buffer
if ((no_mapping == 0 || allow_keys != 0) c = typebuf.tb_buf[typebuf.tb_off] & 255;
&& (typebuf.tb_maplen == 0 if (advance) { // remove chars from tb_buf
|| (p_remap && typebuf.tb_noremap[ cmd_silent = (typebuf.tb_silent > 0);
typebuf.tb_off] == RM_YES)) if (typebuf.tb_maplen > 0) {
&& !timedout) { KeyTyped = false;
keylen = 0; } else {
} else KeyTyped = true;
keylen = 0; // write char to script file(s)
if (keylen == 0) { /* no matching terminal code */ gotchars(typebuf.tb_buf + typebuf.tb_off, 1);
/* When there was a matching mapping and no
* termcode could be replaced after another one,
* use that mapping (loop around). If there was
* no mapping use the character from the
* typeahead buffer right here. */
if (mp == NULL) {
/*
* get a character: 2. from the typeahead buffer
*/
c = typebuf.tb_buf[typebuf.tb_off] & 255;
if (advance) { /* remove chars from tb_buf */
cmd_silent = (typebuf.tb_silent > 0);
if (typebuf.tb_maplen > 0)
KeyTyped = FALSE;
else {
KeyTyped = TRUE;
/* write char to script file(s) */
gotchars(typebuf.tb_buf
+ typebuf.tb_off, 1);
}
KeyNoremap = typebuf.tb_noremap[
typebuf.tb_off];
del_typebuf(1, 0);
} }
break; /* got character, break for loop */ KeyNoremap = typebuf.tb_noremap[typebuf.tb_off];
del_typebuf(1, 0);
} }
} break; // got character, break for loop
if (keylen > 0) { /* full matching terminal code */ } else {
continue; /* try mapping again */
}
/* Partial match: get some more characters. When a
* matching mapping was found use that one. */
if (mp == NULL || keylen < 0)
keylen = KEYLEN_PART_KEY;
else
keylen = mp_match_len; keylen = mp_match_len;
}
} }
/* complete match */ /* complete match */