Mercurial > vim
changeset 8989:e600e696c0a1 v7.4.1780
commit https://github.com/vim/vim/commit/dc633cf82758f67f656cda7fa8ccc30414ee53f8
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Apr 23 14:33:19 2016 +0200
patch 7.4.1780
Problem: Warnings reported by cppcheck.
Solution: Fix the warnings. (Dominique Pelle)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 23 Apr 2016 14:45:05 +0200 |
parents | c9dcf5ed0b1a |
children | 9780999ee224 |
files | src/ex_cmds2.c src/json.c src/misc1.c src/ops.c src/regexp_nfa.c src/version.c |
diffstat | 6 files changed, 17 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ex_cmds2.c +++ b/src/ex_cmds2.c @@ -335,9 +335,8 @@ do_debug(char_u *cmd) get_maxbacktrace_level(void) { char *p, *q; - int maxbacktrace = 1; - - maxbacktrace = 0; + int maxbacktrace = 0; + if (sourcing_name != NULL) { p = (char *)sourcing_name;
--- a/src/json.c +++ b/src/json.c @@ -539,7 +539,6 @@ json_decode_string(js_read_T *reader, ty char_u *p; int c; long nr; - char_u buf[NUMBUFLEN]; if (res != NULL) ga_init2(&ga, 1, 200); @@ -617,6 +616,7 @@ json_decode_string(js_read_T *reader, ty if (res != NULL) { #ifdef FEAT_MBYTE + char_u buf[NUMBUFLEN]; buf[utf_char2bytes((int)nr, buf)] = NUL; ga_concat(&ga, buf); #else
--- a/src/misc1.c +++ b/src/misc1.c @@ -1197,7 +1197,7 @@ open_line( int i; int l; - for (i = 0; p[i] != NUL && i < lead_len; i += l) + for (i = 0; i < lead_len && p[i] != NUL; i += l) { l = (*mb_ptr2len)(p + i); if (vim_strnsize(p, i + l) > repl_size)
--- a/src/ops.c +++ b/src/ops.c @@ -5709,7 +5709,7 @@ do_addsub( if (buf1 == NULL) goto theend; ptr = buf1; - if (negative && (!visual || (visual && was_positive))) + if (negative && (!visual || was_positive)) { *ptr++ = '-'; }
--- a/src/regexp_nfa.c +++ b/src/regexp_nfa.c @@ -5515,14 +5515,9 @@ nfa_regmatch( int add_off = 0; int toplevel = start->c == NFA_MOPEN; #ifdef NFA_REGEXP_DEBUG_LOG - FILE *debug = fopen(NFA_REGEXP_DEBUG_LOG, "a"); - - if (debug == NULL) - { - EMSG2(_("(NFA) COULD NOT OPEN %s !"), NFA_REGEXP_DEBUG_LOG); - return FALSE; - } + FILE *debug; #endif + /* Some patterns may take a long time to match, especially when using * recursive_regmatch(). Allow interrupting them with CTRL-C. */ fast_breakcheck(); @@ -5533,6 +5528,14 @@ nfa_regmatch( return FALSE; #endif +#ifdef NFA_REGEXP_DEBUG_LOG + debug = fopen(NFA_REGEXP_DEBUG_LOG, "a"); + if (debug == NULL) + { + EMSG2(_("(NFA) COULD NOT OPEN %s !"), NFA_REGEXP_DEBUG_LOG); + return FALSE; + } +#endif nfa_match = FALSE; /* Allocate memory for the lists of nodes. */