vim-patch:7.4.2065 (#5950)

Problem:    Compiler warns for uninitialzed variable. (John Marriott)
Solution:   Set lnum to the right value.

69aa099641
This commit is contained in:
Shougo 2017-01-15 21:09:39 +09:00 committed by Justin M. Keyes
parent 192243492d
commit cecaaa84cd
2 changed files with 22 additions and 19 deletions

View File

@ -9574,24 +9574,29 @@ static void f_foldlevel(typval_T *argvars, typval_T *rettv, FunPtr fptr)
*/ */
static void f_foldtext(typval_T *argvars, typval_T *rettv, FunPtr fptr) static void f_foldtext(typval_T *argvars, typval_T *rettv, FunPtr fptr)
{ {
linenr_T lnum; linenr_T foldstart;
linenr_T foldend;
char_u *dashes;
linenr_T lnum;
char_u *s; char_u *s;
char_u *r; char_u *r;
int len; int len;
char *txt; char *txt;
long count;
rettv->v_type = VAR_STRING; rettv->v_type = VAR_STRING;
rettv->vval.v_string = NULL; rettv->vval.v_string = NULL;
if ((linenr_T)vimvars[VV_FOLDSTART].vv_nr > 0
&& (linenr_T)vimvars[VV_FOLDEND].vv_nr foldstart = (linenr_T)get_vim_var_nr(VV_FOLDSTART);
<= curbuf->b_ml.ml_line_count foldend = (linenr_T)get_vim_var_nr(VV_FOLDEND);
&& vimvars[VV_FOLDDASHES].vv_str != NULL) { dashes = get_vim_var_str(VV_FOLDDASHES);
if (foldstart > 0 && foldend <= curbuf->b_ml.ml_line_count
&& dashes != NULL) {
/* Find first non-empty line in the fold. */ /* Find first non-empty line in the fold. */
lnum = (linenr_T)vimvars[VV_FOLDSTART].vv_nr; for (lnum = foldstart; lnum < foldend; ++lnum) {
while (lnum < (linenr_T)vimvars[VV_FOLDEND].vv_nr) { if (!linewhite(lnum)) {
if (!linewhite(lnum))
break; break;
++lnum; }
} }
/* Find interesting text in this line. */ /* Find interesting text in this line. */
@ -9599,21 +9604,19 @@ static void f_foldtext(typval_T *argvars, typval_T *rettv, FunPtr fptr)
/* skip C comment-start */ /* skip C comment-start */
if (s[0] == '/' && (s[1] == '*' || s[1] == '/')) { if (s[0] == '/' && (s[1] == '*' || s[1] == '/')) {
s = skipwhite(s + 2); s = skipwhite(s + 2);
if (*skipwhite(s) == NUL if (*skipwhite(s) == NUL && lnum + 1 < foldend) {
&& lnum + 1 < (linenr_T)vimvars[VV_FOLDEND].vv_nr) {
s = skipwhite(ml_get(lnum + 1)); s = skipwhite(ml_get(lnum + 1));
if (*s == '*') if (*s == '*')
s = skipwhite(s + 1); s = skipwhite(s + 1);
} }
} }
count = (long)(foldend - foldstart + 1);
txt = _("+-%s%3ld lines: "); txt = _("+-%s%3ld lines: ");
r = xmalloc(STRLEN(txt) r = xmalloc(STRLEN(txt)
+ STRLEN(vimvars[VV_FOLDDASHES].vv_str) // for %s + STRLEN(dashes) // for %s
+ 20 // for %3ld + 20 // for %3ld
+ STRLEN(s)); // concatenated + STRLEN(s)); // concatenated
sprintf((char *)r, txt, vimvars[VV_FOLDDASHES].vv_str, sprintf((char *)r, txt, dashes, count);
(long)((linenr_T)vimvars[VV_FOLDEND].vv_nr
- (linenr_T)vimvars[VV_FOLDSTART].vv_nr + 1));
len = (int)STRLEN(r); len = (int)STRLEN(r);
STRCAT(r, s); STRCAT(r, s);
/* remove 'foldmarker' and 'commentstring' */ /* remove 'foldmarker' and 'commentstring' */

View File

@ -375,7 +375,7 @@ static int included_patches[] = {
// 2068, // 2068,
// 2067, // 2067,
2066, 2066,
// 2065, 2065,
// 2064, // 2064,
// 2063 NA // 2063 NA
// 2062, // 2062,