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,60 +1913,31 @@ 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:
// mapping is allowed,
// keys have not been mapped,
// and not an ESC sequence, not in insert mode,
// and when not timed out.
if ((no_mapping == 0 || allow_keys != 0)
&& (typebuf.tb_maplen == 0
|| (p_remap && typebuf.tb_noremap[
typebuf.tb_off] == RM_YES))
&& !timedout) {
keylen = 0; keylen = 0;
} else // If there was no mapping, use the character from the typeahead
keylen = 0; // buffer right here. Otherwise, use the mapping (loop around).
if (keylen == 0) { /* no matching terminal code */
/* 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) { if (mp == NULL) {
/* // get a character: 2. from the typeahead buffer
* get a character: 2. from the typeahead buffer
*/
c = typebuf.tb_buf[typebuf.tb_off] & 255; c = typebuf.tb_buf[typebuf.tb_off] & 255;
if (advance) { /* remove chars from tb_buf */ if (advance) { // remove chars from tb_buf
cmd_silent = (typebuf.tb_silent > 0); cmd_silent = (typebuf.tb_silent > 0);
if (typebuf.tb_maplen > 0) if (typebuf.tb_maplen > 0) {
KeyTyped = FALSE; KeyTyped = false;
else { } else {
KeyTyped = TRUE; KeyTyped = true;
/* write char to script file(s) */ // write char to script file(s)
gotchars(typebuf.tb_buf gotchars(typebuf.tb_buf + typebuf.tb_off, 1);
+ typebuf.tb_off, 1);
} }
KeyNoremap = typebuf.tb_noremap[ KeyNoremap = typebuf.tb_noremap[typebuf.tb_off];
typebuf.tb_off];
del_typebuf(1, 0); del_typebuf(1, 0);
} }
break; /* got character, break for loop */ break; // got character, break for loop
} } else {
}
if (keylen > 0) { /* full matching terminal code */
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 */
if (keylen >= 0 && keylen <= typebuf.tb_len) { if (keylen >= 0 && keylen <= typebuf.tb_len) {