diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-11-23 19:52:03 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2022-11-23 19:59:38 +0800 |
commit | e339376cca2faf18da7a03f93958ef926f856643 (patch) | |
tree | 1b57f92ce9b2edde02bfa67fcb288522347deebe | |
parent | f1b88ced07a5dcc62cd847cade2ed97e23fffbf9 (diff) | |
download | rneovim-e339376cca2faf18da7a03f93958ef926f856643.tar.gz rneovim-e339376cca2faf18da7a03f93958ef926f856643.tar.bz2 rneovim-e339376cca2faf18da7a03f93958ef926f856643.zip |
vim-patch:9.0.0925: two conditions are always false
Problem: Two conditions are always false.
Solution: Remove the conditions. Update return value types to make clear
what could be returned. (closes vim/vim#11593)
https://github.com/vim/vim/commit/df3c0eb41e1f48596c85af88b42fed22e3cca328
-rw-r--r-- | src/nvim/tag.c | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/src/nvim/tag.c b/src/nvim/tag.c index 8be343b055..7e4677e502 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -1475,7 +1475,7 @@ static bool findtags_in_help_init(findtags_state_T *st) { int i; - // Keep 'en' as the language if the file extension is '.txt' + // Keep "en" as the language if the file extension is ".txt" if (st->is_txt) { STRCPY(st->help_lang, "en"); } else { @@ -1724,6 +1724,14 @@ static bool findtags_start_state_handler(findtags_state_T *st, bool *sortic, } /// Parse a tag line read from a tags file. +/// Also compares the tag name in "tagpp->tagname" with a search pattern in +/// "st->orgpat->head" as a quick check if the tag may match. +/// Returns: +/// - TAG_MATCH_SUCCESS if the tag may match +/// - TAG_MATCH_FAIL if the tag doesn't match +/// - TAG_MATCH_NEXT to look for the next matching tag (used in a binary search) +/// - TAG_MATCH_STOP if all the tags are processed without a match. +/// Uses the values in "margs" for doing the comparison. static tagmatch_status_T findtags_parse_line(findtags_state_T *st, tagptrs_T *tagpp, findtags_match_args_T *margs, tagsearch_info_T *sinfo_p) @@ -1875,13 +1883,10 @@ static void findtags_matchargs_init(findtags_match_args_T *margs, int flags) } /// Compares the tag name in "tagpp->tagname" with a search pattern in -/// "st->orgpat.head". -/// Returns TAG_MATCH_SUCCESS if the tag matches, TAG_MATCH_FAIL if the tag -/// doesn't match, TAG_MATCH_NEXT to look for the next matching tag (used in a -/// binary search) and TAG_MATCH_STOP if all the tags are processed without a -/// match. Uses the values in "margs" for doing the comparison. -static tagmatch_status_T findtags_match_tag(findtags_state_T *st, tagptrs_T *tagpp, - findtags_match_args_T *margs) +/// "st->orgpat->pat". +/// Returns true if the tag matches, false if the tag doesn't match. +/// Uses the values in "margs" for doing the comparison. +static bool findtags_match_tag(findtags_state_T *st, tagptrs_T *tagpp, findtags_match_args_T *margs) { bool match = false; @@ -1925,7 +1930,7 @@ static tagmatch_status_T findtags_match_tag(findtags_state_T *st, tagptrs_T *tag margs->match_re = true; } - return match ? TAG_MATCH_SUCCESS : TAG_MATCH_FAIL; + return match; } /// Convert the encoding of a line read from a tags file in "st->lbuf". @@ -2182,16 +2187,8 @@ line_read_in: return; } - retval = (int)findtags_match_tag(st, &tagp, margs); - if (retval == TAG_MATCH_NEXT) { - continue; - } - if (retval == TAG_MATCH_STOP) { - break; - } - // If a match is found, add it to ht_match[] and ga_match[]. - if (retval == TAG_MATCH_SUCCESS) { + if (findtags_match_tag(st, &tagp, margs)) { findtags_add_match(st, &tagp, margs, buf_ffname, &hash); } } // forever |