Merge #2228: Enable -Wconversion. (2)

Reviewed-by: oni-link <knil.ino@gmail.com>
This commit is contained in:
Eliseo Martínez 2015-04-07 19:21:50 +02:00
commit 6881d9705b
12 changed files with 656 additions and 1550 deletions

View File

@ -58,9 +58,7 @@ set(CONV_SOURCES
ex_cmds.c ex_cmds.c
ex_docmd.c ex_docmd.c
ex_getln.c ex_getln.c
farsi.c
fileio.c fileio.c
fold.c
getchar.c getchar.c
if_cscope.c if_cscope.c
mbyte.c mbyte.c
@ -68,11 +66,9 @@ set(CONV_SOURCES
menu.c menu.c
message.c message.c
misc1.c misc1.c
move.c
normal.c normal.c
ops.c ops.c
path.c path.c
popupmnu.c
quickfix.c quickfix.c
regexp.c regexp.c
screen.c screen.c

View File

@ -7354,9 +7354,9 @@ static int ins_bs(int c, int mode, int *inserted_space_p)
*inserted_space_p = FALSE; *inserted_space_p = FALSE;
if (p_sta && in_indent) if (p_sta && in_indent)
ts = (int)get_sw_value(curbuf); ts = get_sw_value(curbuf);
else else
ts = (int)get_sts_value(); ts = get_sts_value();
/* Compute the virtual column where we want to be. Since /* Compute the virtual column where we want to be. Since
* 'showbreak' may get in the way, need to get the last column of * 'showbreak' may get in the way, need to get the last column of
* the previous character. */ * the previous character. */
@ -7826,9 +7826,9 @@ static int ins_tab(void)
AppendToRedobuff((char_u *)"\t"); AppendToRedobuff((char_u *)"\t");
if (p_sta && ind) /* insert tab in indent, use 'shiftwidth' */ if (p_sta && ind) /* insert tab in indent, use 'shiftwidth' */
temp = (int)get_sw_value(curbuf); temp = get_sw_value(curbuf);
else if (curbuf->b_p_sts != 0) /* use 'softtabstop' when set */ else if (curbuf->b_p_sts != 0) /* use 'softtabstop' when set */
temp = (int)get_sts_value(); temp = get_sts_value();
else /* otherwise use 'tabstop' */ else /* otherwise use 'tabstop' */
temp = (int)curbuf->b_p_ts; temp = (int)curbuf->b_p_ts;
temp -= get_nolist_virtcol() % temp; temp -= get_nolist_virtcol() % temp;

View File

@ -1784,7 +1784,7 @@ getexmodeline (
} }
if (c1 == Ctrl_T) { if (c1 == Ctrl_T) {
long sw = get_sw_value(curbuf); int sw = get_sw_value(curbuf);
p = (char_u *)line_ga.ga_data; p = (char_u *)line_ga.ga_data;
p[line_ga.ga_len] = NUL; p[line_ga.ga_len] = NUL;

File diff suppressed because it is too large Load Diff

View File

@ -114,9 +114,9 @@ static int prev_lnum_lvl = -1;
#define DONE_ACTION 1 /* did close or open a fold */ #define DONE_ACTION 1 /* did close or open a fold */
#define DONE_FOLD 2 /* did find a fold */ #define DONE_FOLD 2 /* did find a fold */
static int foldstartmarkerlen; static size_t foldstartmarkerlen;
static char_u *foldendmarker; static char_u *foldendmarker;
static int foldendmarkerlen; static size_t foldendmarkerlen;
/* Exported folding functions. {{{1 */ /* Exported folding functions. {{{1 */
/* copyFoldingState() {{{2 */ /* copyFoldingState() {{{2 */
@ -622,7 +622,7 @@ void foldCreate(linenr_T start, linenr_T end)
if (end_rel < fp[cont - 1].fd_top + fp[cont - 1].fd_len - 1) if (end_rel < fp[cont - 1].fd_top + fp[cont - 1].fd_len - 1)
end_rel = fp[cont - 1].fd_top + fp[cont - 1].fd_len - 1; end_rel = fp[cont - 1].fd_top + fp[cont - 1].fd_len - 1;
/* Move contained folds to inside new fold. */ /* Move contained folds to inside new fold. */
memmove(fold_ga.ga_data, fp, sizeof(fold_T) * cont); memmove(fold_ga.ga_data, fp, sizeof(fold_T) * (size_t)cont);
fold_ga.ga_len += cont; fold_ga.ga_len += cont;
i += cont; i += cont;
@ -634,7 +634,7 @@ void foldCreate(linenr_T start, linenr_T end)
/* Move remaining entries to after the new fold. */ /* Move remaining entries to after the new fold. */
if (i < gap->ga_len) if (i < gap->ga_len)
memmove(fp + 1, (fold_T *)gap->ga_data + i, memmove(fp + 1, (fold_T *)gap->ga_data + i,
sizeof(fold_T) * (gap->ga_len - i)); sizeof(fold_T) * (size_t)(gap->ga_len - i));
gap->ga_len = gap->ga_len + 1 - cont; gap->ga_len = gap->ga_len + 1 - cont;
/* insert new fold */ /* insert new fold */
@ -1051,7 +1051,7 @@ static int foldFind(garray_T *gap, linenr_T lnum, fold_T **fpp)
low = 0; low = 0;
high = gap->ga_len - 1; high = gap->ga_len - 1;
while (low <= high) { while (low <= high) {
int i = (low + high) / 2; linenr_T i = (low + high) / 2;
if (fp[i].fd_top > lnum) if (fp[i].fd_top > lnum)
/* fold below lnum, adjust high */ /* fold below lnum, adjust high */
high = i - 1; high = i - 1;
@ -1292,7 +1292,6 @@ static void deleteFoldEntry(garray_T *gap, int idx, int recursive)
{ {
fold_T *fp; fold_T *fp;
int i; int i;
long moved;
fold_T *nfp; fold_T *nfp;
fp = (fold_T *)gap->ga_data + idx; fp = (fold_T *)gap->ga_data + idx;
@ -1301,12 +1300,12 @@ static void deleteFoldEntry(garray_T *gap, int idx, int recursive)
deleteFoldRecurse(&fp->fd_nested); deleteFoldRecurse(&fp->fd_nested);
--gap->ga_len; --gap->ga_len;
if (idx < gap->ga_len) if (idx < gap->ga_len)
memmove(fp, fp + 1, sizeof(fold_T) * (gap->ga_len - idx)); memmove(fp, fp + 1, sizeof(fold_T) * (size_t)(gap->ga_len - idx));
} else { } else {
/* Move nested folds one level up, to overwrite the fold that is /* Move nested folds one level up, to overwrite the fold that is
* deleted. */ * deleted. */
moved = fp->fd_nested.ga_len; int moved = fp->fd_nested.ga_len;
ga_grow(gap, (int)(moved - 1)); ga_grow(gap, moved - 1);
{ {
/* Get "fp" again, the array may have been reallocated. */ /* Get "fp" again, the array may have been reallocated. */
fp = (fold_T *)gap->ga_data + idx; fp = (fold_T *)gap->ga_data + idx;
@ -1324,9 +1323,9 @@ static void deleteFoldEntry(garray_T *gap, int idx, int recursive)
/* move the existing folds down to make room */ /* move the existing folds down to make room */
if (idx + 1 < gap->ga_len) if (idx + 1 < gap->ga_len)
memmove(fp + moved, fp + 1, memmove(fp + moved, fp + 1,
sizeof(fold_T) * (gap->ga_len - (idx + 1))); sizeof(fold_T) * (size_t)(gap->ga_len - (idx + 1)));
/* move the contained folds one level up */ /* move the contained folds one level up */
memmove(fp, nfp, (size_t)(sizeof(fold_T) * moved)); memmove(fp, nfp, sizeof(fold_T) * (size_t)moved);
free(nfp); free(nfp);
gap->ga_len += moved - 1; gap->ga_len += moved - 1;
} }
@ -1584,17 +1583,16 @@ static void foldCreateMarkers(linenr_T start, linenr_T end)
/* /*
* Add "marker[markerlen]" in 'commentstring' to line "lnum". * Add "marker[markerlen]" in 'commentstring' to line "lnum".
*/ */
static void foldAddMarker(linenr_T lnum, char_u *marker, int markerlen) static void foldAddMarker(linenr_T lnum, char_u *marker, size_t markerlen)
{ {
char_u *cms = curbuf->b_p_cms; char_u *cms = curbuf->b_p_cms;
char_u *line; char_u *line;
int line_len;
char_u *newline; char_u *newline;
char_u *p = (char_u *)strstr((char *)curbuf->b_p_cms, "%s"); char_u *p = (char_u *)strstr((char *)curbuf->b_p_cms, "%s");
/* Allocate a new line: old-line + 'cms'-start + marker + 'cms'-end */ /* Allocate a new line: old-line + 'cms'-start + marker + 'cms'-end */
line = ml_get(lnum); line = ml_get(lnum);
line_len = (int)STRLEN(line); size_t line_len = STRLEN(line);
if (u_save(lnum - 1, lnum + 1) == OK) { if (u_save(lnum - 1, lnum + 1) == OK) {
newline = xmalloc(line_len + markerlen + STRLEN(cms) + 1); newline = xmalloc(line_len + markerlen + STRLEN(cms) + 1);
@ -1629,8 +1627,8 @@ deleteFoldMarkers (
} }
} }
foldDelMarker(fp->fd_top + lnum_off, curwin->w_p_fmr, foldstartmarkerlen); foldDelMarker(fp->fd_top + lnum_off, curwin->w_p_fmr, foldstartmarkerlen);
foldDelMarker(fp->fd_top + lnum_off + fp->fd_len - 1, foldDelMarker(fp->fd_top + lnum_off + fp->fd_len - 1, foldendmarker,
foldendmarker, foldendmarkerlen); foldendmarkerlen);
} }
/* foldDelMarker() {{{2 */ /* foldDelMarker() {{{2 */
@ -1640,7 +1638,7 @@ deleteFoldMarkers (
* If the marker is not found, there is no error message. Could a missing * If the marker is not found, there is no error message. Could a missing
* close-marker. * close-marker.
*/ */
static void foldDelMarker(linenr_T lnum, char_u *marker, int markerlen) static void foldDelMarker(linenr_T lnum, char_u *marker, size_t markerlen)
{ {
char_u *newline; char_u *newline;
char_u *cms = curbuf->b_p_cms; char_u *cms = curbuf->b_p_cms;
@ -1652,7 +1650,7 @@ static void foldDelMarker(linenr_T lnum, char_u *marker, int markerlen)
continue; continue;
} }
/* Found the marker, include a digit if it's there. */ /* Found the marker, include a digit if it's there. */
int len = markerlen; size_t len = markerlen;
if (VIM_ISDIGIT(p[len])) if (VIM_ISDIGIT(p[len]))
++len; ++len;
if (*cms != NUL) { if (*cms != NUL) {
@ -1662,7 +1660,7 @@ static void foldDelMarker(linenr_T lnum, char_u *marker, int markerlen)
&& STRNCMP(p - (cms2 - cms), cms, cms2 - cms) == 0 && STRNCMP(p - (cms2 - cms), cms, cms2 - cms) == 0
&& STRNCMP(p + len, cms2 + 2, STRLEN(cms2 + 2)) == 0) { && STRNCMP(p + len, cms2 + 2, STRLEN(cms2 + 2)) == 0) {
p -= cms2 - cms; p -= cms2 - cms;
len += (int)STRLEN(cms) - 2; len += STRLEN(cms) - 2;
} }
} }
if (u_save(lnum - 1, lnum + 1) == OK) { if (u_save(lnum - 1, lnum + 1) == OK) {
@ -1781,27 +1779,23 @@ char_u *get_foldtext(win_T *wp, linenr_T lnum, linenr_T lnume,
*/ */
void foldtext_cleanup(char_u *str) void foldtext_cleanup(char_u *str)
{ {
char_u *cms_start; /* first part or the whole comment */
int cms_slen = 0; /* length of cms_start */
char_u *cms_end; /* last part of the comment or NULL */
int cms_elen = 0; /* length of cms_end */
char_u *s; char_u *s;
char_u *p; char_u *p;
int len;
int did1 = FALSE; int did1 = FALSE;
int did2 = FALSE; int did2 = FALSE;
/* Ignore leading and trailing white space in 'commentstring'. */ /* Ignore leading and trailing white space in 'commentstring'. */
cms_start = skipwhite(curbuf->b_p_cms); char_u *cms_start = skipwhite(curbuf->b_p_cms);
cms_slen = (int)STRLEN(cms_start); size_t cms_slen = STRLEN(cms_start);
while (cms_slen > 0 && vim_iswhite(cms_start[cms_slen - 1])) while (cms_slen > 0 && vim_iswhite(cms_start[cms_slen - 1]))
--cms_slen; --cms_slen;
/* locate "%s" in 'commentstring', use the part before and after it. */ /* locate "%s" in 'commentstring', use the part before and after it. */
cms_end = (char_u *)strstr((char *)cms_start, "%s"); char_u *cms_end = (char_u *)strstr((char *)cms_start, "%s");
size_t cms_elen = 0;
if (cms_end != NULL) { if (cms_end != NULL) {
cms_elen = cms_slen - (int)(cms_end - cms_start); cms_elen = cms_slen - (size_t)(cms_end - cms_start);
cms_slen = (int)(cms_end - cms_start); cms_slen = (size_t)(cms_end - cms_start);
/* exclude white space before "%s" */ /* exclude white space before "%s" */
while (cms_slen > 0 && vim_iswhite(cms_start[cms_slen - 1])) while (cms_slen > 0 && vim_iswhite(cms_start[cms_slen - 1]))
@ -1809,13 +1803,13 @@ void foldtext_cleanup(char_u *str)
/* skip "%s" and white space after it */ /* skip "%s" and white space after it */
s = skipwhite(cms_end + 2); s = skipwhite(cms_end + 2);
cms_elen -= (int)(s - cms_end); cms_elen -= (size_t)(s - cms_end);
cms_end = s; cms_end = s;
} }
parseMarker(curwin); parseMarker(curwin);
for (s = str; *s != NUL; ) { for (s = str; *s != NUL; ) {
len = 0; size_t len = 0;
if (STRNCMP(s, curwin->w_p_fmr, foldstartmarkerlen) == 0) if (STRNCMP(s, curwin->w_p_fmr, foldstartmarkerlen) == 0)
len = foldstartmarkerlen; len = foldstartmarkerlen;
else if (STRNCMP(s, foldendmarker, foldendmarkerlen) == 0) else if (STRNCMP(s, foldendmarker, foldendmarkerlen) == 0)
@ -1830,7 +1824,7 @@ void foldtext_cleanup(char_u *str)
; ;
if (p >= str + cms_slen if (p >= str + cms_slen
&& STRNCMP(p - cms_slen, cms_start, cms_slen) == 0) { && STRNCMP(p - cms_slen, cms_start, cms_slen) == 0) {
len += (int)(s - p) + cms_slen; len += (size_t)(s - p) + cms_slen;
s = p - cms_slen; s = p - cms_slen;
} }
} else if (cms_end != NULL) { } else if (cms_end != NULL) {
@ -2035,8 +2029,8 @@ static void foldUpdateIEMS(win_T *wp, linenr_T top, linenr_T bot)
if (fline.lvl > 0) { if (fline.lvl > 0) {
invalid_top = fline.lnum; invalid_top = fline.lnum;
invalid_bot = end; invalid_bot = end;
end = foldUpdateIEMSRecurse(&wp->w_folds, end = foldUpdateIEMSRecurse(&wp->w_folds, 1, start, &fline, getlevel, end,
1, start, &fline, getlevel, end, FD_LEVEL); FD_LEVEL);
start = fline.lnum; start = fline.lnum;
} else { } else {
if (fline.lnum == wp->w_buffer->b_ml.ml_line_count) if (fline.lnum == wp->w_buffer->b_ml.ml_line_count)
@ -2095,7 +2089,7 @@ static linenr_T foldUpdateIEMSRecurse(garray_T *gap, int level,
linenr_T startlnum, fline_T *flp, linenr_T startlnum, fline_T *flp,
LevelGetter getlevel, LevelGetter getlevel,
linenr_T bot, linenr_T bot,
int topflags /* flags used by containing fold */ char topflags /* containing fold flags */
) )
{ {
linenr_T ll; linenr_T ll;
@ -2333,8 +2327,8 @@ static linenr_T foldUpdateIEMSRecurse(garray_T *gap, int level,
flp->off += fp->fd_top; flp->off += fp->fd_top;
i = (int)(fp - (fold_T *)gap->ga_data); i = (int)(fp - (fold_T *)gap->ga_data);
bot = foldUpdateIEMSRecurse(&fp->fd_nested, level + 1, bot = foldUpdateIEMSRecurse(&fp->fd_nested, level + 1,
startlnum2 - fp->fd_top, flp, getlevel, startlnum2 - fp->fd_top, flp, getlevel,
bot - fp->fd_top, fp->fd_flags); bot - fp->fd_top, fp->fd_flags);
fp = (fold_T *)gap->ga_data + i; fp = (fold_T *)gap->ga_data + i;
flp->lnum += fp->fd_top; flp->lnum += fp->fd_top;
flp->lnum_save += fp->fd_top; flp->lnum_save += fp->fd_top;
@ -2468,7 +2462,7 @@ static void foldInsert(garray_T *gap, int i)
fp = (fold_T *)gap->ga_data + i; fp = (fold_T *)gap->ga_data + i;
if (i < gap->ga_len) if (i < gap->ga_len)
memmove(fp + 1, fp, sizeof(fold_T) * (gap->ga_len - i)); memmove(fp + 1, fp, sizeof(fold_T) * (size_t)(gap->ga_len - i));
++gap->ga_len; ++gap->ga_len;
ga_init(&fp->fd_nested, (int)sizeof(fold_T), 10); ga_init(&fp->fd_nested, (int)sizeof(fold_T), 10);
} }
@ -2649,9 +2643,7 @@ static void foldlevelIndent(fline_T *flp)
} else } else
flp->lvl = get_indent_buf(buf, lnum) / get_sw_value(curbuf); flp->lvl = get_indent_buf(buf, lnum) / get_sw_value(curbuf);
if (flp->lvl > flp->wp->w_p_fdn) { if (flp->lvl > flp->wp->w_p_fdn) {
flp->lvl = flp->wp->w_p_fdn; flp->lvl = (int) MAX(0, flp->wp->w_p_fdn);
if (flp->lvl < 0)
flp->lvl = 0;
} }
} }
@ -2768,8 +2760,8 @@ static void foldlevelExpr(fline_T *flp)
static void parseMarker(win_T *wp) static void parseMarker(win_T *wp)
{ {
foldendmarker = vim_strchr(wp->w_p_fmr, ','); foldendmarker = vim_strchr(wp->w_p_fmr, ',');
foldstartmarkerlen = (int)(foldendmarker++ - wp->w_p_fmr); foldstartmarkerlen = (size_t)(foldendmarker++ - wp->w_p_fmr);
foldendmarkerlen = (int)STRLEN(foldendmarker); foldendmarkerlen = STRLEN(foldendmarker);
} }
/* foldlevelMarker() {{{2 */ /* foldlevelMarker() {{{2 */
@ -2822,9 +2814,8 @@ static void foldlevelMarker(fline_T *flp)
++flp->lvl_next; ++flp->lvl_next;
++flp->start; ++flp->start;
} }
} else if (*s == cend } else if (*s == cend && STRNCMP(s + 1, foldendmarker + 1,
&& STRNCMP(s + 1, foldendmarker + 1, foldendmarkerlen - 1) == 0) {
foldendmarkerlen - 1) == 0) {
/* found endmarker: set flp->lvl_next */ /* found endmarker: set flp->lvl_next */
s += foldendmarkerlen; s += foldendmarkerlen;
if (VIM_ISDIGIT(*s)) { if (VIM_ISDIGIT(*s)) {

View File

@ -1,14 +1,16 @@
#ifndef NVIM_FOLD_H #ifndef NVIM_FOLD_H
#define NVIM_FOLD_H #define NVIM_FOLD_H
#include "nvim/pos.h"
/* /*
* Info used to pass info about a fold from the fold-detection code to the * Info used to pass info about a fold from the fold-detection code to the
* code that displays the foldcolumn. * code that displays the foldcolumn.
*/ */
typedef struct foldinfo { typedef struct foldinfo {
linenr_T fi_lnum; /* line number where fold starts */
int fi_level; /* level of the fold; when this is zero the int fi_level; /* level of the fold; when this is zero the
other fields are invalid */ other fields are invalid */
int fi_lnum; /* line number where fold starts */
int fi_low_level; /* lowest fold level that starts in the same int fi_low_level; /* lowest fold level that starts in the same
line */ line */
} foldinfo_T; } foldinfo_T;

View File

@ -1332,7 +1332,7 @@ void parse_cino(buf_T *buf)
char_u *l; char_u *l;
int divider; int divider;
int fraction = 0; int fraction = 0;
int sw = (int)get_sw_value(buf); int sw = get_sw_value(buf);
/* /*
* Set the default values. * Set the default values.

View File

@ -796,7 +796,7 @@ open_line (
) { ) {
++curwin->w_cursor.lnum; ++curwin->w_cursor.lnum;
if (did_si) { if (did_si) {
int sw = (int)get_sw_value(curbuf); int sw = get_sw_value(curbuf);
if (p_sr) if (p_sr)
newindent -= newindent % sw; newindent -= newindent % sw;

View File

@ -16,6 +16,7 @@
* The 'scrolloff' option makes this a bit complicated. * The 'scrolloff' option makes this a bit complicated.
*/ */
#include <assert.h>
#include <inttypes.h> #include <inttypes.h>
#include <stdbool.h> #include <stdbool.h>
@ -135,13 +136,13 @@ void update_topline(void)
{ {
long line_count; long line_count;
int halfheight; int halfheight;
int n; long n;
linenr_T old_topline; linenr_T old_topline;
int old_topfill; int old_topfill;
linenr_T lnum; linenr_T lnum;
int check_topline = FALSE; int check_topline = FALSE;
int check_botline = FALSE; int check_botline = FALSE;
int save_so = p_so; long save_so = p_so;
if (!screen_valid(TRUE)) if (!screen_valid(TRUE))
return; return;
@ -342,9 +343,9 @@ void update_topline_win(win_T* win)
*/ */
static int scrolljump_value(void) static int scrolljump_value(void)
{ {
if (p_sj >= 0) long result = p_sj >= 0 ? p_sj : (curwin->w_height * -p_sj) / 100;
return (int)p_sj; assert(result <= INT_MAX);
return (curwin->w_height * -p_sj) / 100; return (int)result;
} }
/* /*
@ -711,7 +712,7 @@ int win_col_off(win_T *wp)
{ {
return ((wp->w_p_nu || wp->w_p_rnu) ? number_width(wp) + 1 : 0) return ((wp->w_p_nu || wp->w_p_rnu) ? number_width(wp) + 1 : 0)
+ (cmdwin_type == 0 || wp != curwin ? 0 : 1) + (cmdwin_type == 0 || wp != curwin ? 0 : 1)
+ wp->w_p_fdc + (int)wp->w_p_fdc
+ (wp->w_buffer->b_signlist != NULL ? 2 : 0) + (wp->w_buffer->b_signlist != NULL ? 2 : 0)
; ;
} }
@ -831,9 +832,9 @@ curs_columns (
* If we get closer to the edge than 'sidescrolloff', scroll a little * If we get closer to the edge than 'sidescrolloff', scroll a little
* extra * extra
*/ */
off_left = (int)startcol - (int)curwin->w_leftcol - p_siso; assert(p_siso <= INT_MAX);
off_right = (int)endcol - (int)(curwin->w_leftcol + curwin->w_width off_left = startcol - curwin->w_leftcol - (int)p_siso;
- p_siso) + 1; off_right = endcol - curwin->w_leftcol - curwin->w_width + (int)p_siso + 1;
if (off_left < 0 || off_right > 0) { if (off_left < 0 || off_right > 0) {
if (off_left < 0) if (off_left < 0)
diff = -off_left; diff = -off_left;
@ -845,8 +846,10 @@ curs_columns (
if (p_ss == 0 || diff >= textwidth / 2 || off_right >= off_left) if (p_ss == 0 || diff >= textwidth / 2 || off_right >= off_left)
new_leftcol = curwin->w_wcol - extra - textwidth / 2; new_leftcol = curwin->w_wcol - extra - textwidth / 2;
else { else {
if (diff < p_ss) if (diff < p_ss) {
diff = p_ss; assert(p_ss <= INT_MAX);
diff = (int)p_ss;
}
if (off_left < 0) if (off_left < 0)
new_leftcol = curwin->w_leftcol - diff; new_leftcol = curwin->w_leftcol - diff;
else else
@ -902,8 +905,10 @@ curs_columns (
if (p_lines == 0) if (p_lines == 0)
p_lines = plines_win(curwin, curwin->w_cursor.lnum, FALSE); p_lines = plines_win(curwin, curwin->w_cursor.lnum, FALSE);
--p_lines; --p_lines;
if (p_lines > curwin->w_wrow + p_so) if (p_lines > curwin->w_wrow + p_so) {
n = curwin->w_wrow + p_so; assert(p_so <= INT_MAX);
n = curwin->w_wrow + (int)p_so;
}
else else
n = p_lines; n = p_lines;
if ((colnr_T)n >= curwin->w_height + curwin->w_skipcol / width) if ((colnr_T)n >= curwin->w_height + curwin->w_skipcol / width)
@ -922,7 +927,8 @@ curs_columns (
curwin->w_skipcol = n * width; curwin->w_skipcol = n * width;
} else if (extra == 1) { } else if (extra == 1) {
/* less then 'scrolloff' lines above, decrease skipcol */ /* less then 'scrolloff' lines above, decrease skipcol */
extra = (curwin->w_skipcol + p_so * width - curwin->w_virtcol assert(p_so <= INT_MAX);
extra = (curwin->w_skipcol + (int)p_so * width - curwin->w_virtcol
+ width - 1) / width; + width - 1) / width;
if (extra > 0) { if (extra > 0) {
if ((colnr_T)(extra * width) > curwin->w_skipcol) if ((colnr_T)(extra * width) > curwin->w_skipcol)
@ -974,7 +980,7 @@ scrolldown (
int byfold /* TRUE: count a closed fold as one line */ int byfold /* TRUE: count a closed fold as one line */
) )
{ {
long done = 0; /* total # of physical lines done */ int done = 0; /* total # of physical lines done */
int wrow; int wrow;
int moved = FALSE; int moved = FALSE;
@ -1331,7 +1337,8 @@ void scroll_cursor_top(int min_scroll, int always)
linenr_T old_topline = curwin->w_topline; linenr_T old_topline = curwin->w_topline;
linenr_T old_topfill = curwin->w_topfill; linenr_T old_topfill = curwin->w_topfill;
linenr_T new_topline; linenr_T new_topline;
int off = p_so; assert(p_so <= INT_MAX);
int off = (int)p_so;
if (mouse_dragging > 0) if (mouse_dragging > 0)
off = mouse_dragging - 1; off = mouse_dragging - 1;
@ -1472,7 +1479,7 @@ void scroll_cursor_bot(int min_scroll, int set_topbot)
int old_topfill = curwin->w_topfill; int old_topfill = curwin->w_topfill;
int fill_below_window; int fill_below_window;
linenr_T old_botline = curwin->w_botline; linenr_T old_botline = curwin->w_botline;
linenr_T old_valid = curwin->w_valid; int old_valid = curwin->w_valid;
int old_empty_rows = curwin->w_empty_rows; int old_empty_rows = curwin->w_empty_rows;
linenr_T cln; /* Cursor Line Number */ linenr_T cln; /* Cursor Line Number */
@ -1708,8 +1715,9 @@ void cursor_correct(void)
* How many lines we would like to have above/below the cursor depends on * How many lines we would like to have above/below the cursor depends on
* whether the first/last line of the file is on screen. * whether the first/last line of the file is on screen.
*/ */
above_wanted = p_so; assert(p_so <= INT_MAX);
below_wanted = p_so; above_wanted = (int)p_so;
below_wanted = (int)p_so;
if (mouse_dragging > 0) { if (mouse_dragging > 0) {
above_wanted = mouse_dragging - 1; above_wanted = mouse_dragging - 1;
below_wanted = mouse_dragging - 1; below_wanted = mouse_dragging - 1;
@ -2040,14 +2048,14 @@ void halfpage(bool flag, linenr_T Prenum)
{ {
long scrolled = 0; long scrolled = 0;
int i; int i;
int n;
int room; int room;
if (Prenum) if (Prenum)
curwin->w_p_scr = (Prenum > curwin->w_height) ? curwin->w_p_scr = (Prenum > curwin->w_height) ?
curwin->w_height : Prenum; curwin->w_height : Prenum;
n = (curwin->w_p_scr <= curwin->w_height) ? assert(curwin->w_p_scr <= INT_MAX);
curwin->w_p_scr : curwin->w_height; int n = curwin->w_p_scr <= curwin->w_height ? (int)curwin->w_p_scr
: curwin->w_height;
validate_botline(); validate_botline();
room = curwin->w_empty_rows; room = curwin->w_empty_rows;

View File

@ -278,7 +278,7 @@ shift_line (
{ {
int count; int count;
int i, j; int i, j;
int p_sw = (int)get_sw_value(curbuf); int p_sw = get_sw_value(curbuf);
count = get_indent(); /* get current indent */ count = get_indent(); /* get current indent */
@ -321,7 +321,7 @@ static void shift_block(oparg_T *oap, int amount)
int total; int total;
char_u *newp, *oldp; char_u *newp, *oldp;
int oldcol = curwin->w_cursor.col; int oldcol = curwin->w_cursor.col;
int p_sw = (int)get_sw_value(curbuf); int p_sw = get_sw_value(curbuf);
int p_ts = (int)curbuf->b_p_ts; int p_ts = (int)curbuf->b_p_ts;
struct block_def bd; struct block_def bd;
int incr; int incr;

View File

@ -7653,18 +7653,22 @@ int check_ff_value(char_u *p)
* Return the effective shiftwidth value for current buffer, using the * Return the effective shiftwidth value for current buffer, using the
* 'tabstop' value when 'shiftwidth' is zero. * 'tabstop' value when 'shiftwidth' is zero.
*/ */
long get_sw_value(buf_T *buf) int get_sw_value(buf_T *buf)
{ {
return buf->b_p_sw ? buf->b_p_sw : buf->b_p_ts; long result = buf->b_p_sw ? buf->b_p_sw : buf->b_p_ts;
assert(result >= 0 && result <= INT_MAX);
return (int)result;
} }
/* /*
* Return the effective softtabstop value for the current buffer, using the * Return the effective softtabstop value for the current buffer, using the
* 'tabstop' value when 'softtabstop' is negative. * 'tabstop' value when 'softtabstop' is negative.
*/ */
long get_sts_value(void) int get_sts_value(void)
{ {
return curbuf->b_p_sts < 0 ? get_sw_value(curbuf) : curbuf->b_p_sts; long result = curbuf->b_p_sts < 0 ? get_sw_value(curbuf) : curbuf->b_p_sts;
assert(result >= 0 && result <= INT_MAX);
return (int)result;
} }
/* /*

View File

@ -2,6 +2,7 @@
/// ///
/// Popup menu (PUM) /// Popup menu (PUM)
// //
#include <assert.h>
#include <inttypes.h> #include <inttypes.h>
#include <stdbool.h> #include <stdbool.h>
@ -101,7 +102,7 @@ redo:
} }
if ((p_ph > 0) && (pum_height > p_ph)) { if ((p_ph > 0) && (pum_height > p_ph)) {
pum_height = p_ph; pum_height = (int)p_ph;
} }
// Put the pum below "row" if possible. If there are few lines decide on // Put the pum below "row" if possible. If there are few lines decide on
@ -126,8 +127,8 @@ redo:
} }
if ((p_ph > 0) && (pum_height > p_ph)) { if ((p_ph > 0) && (pum_height > p_ph)) {
pum_row += pum_height - p_ph; pum_row += pum_height - (int)p_ph;
pum_height = p_ph; pum_height = (int)p_ph;
} }
} else { } else {
// pum below "row" // pum below "row"
@ -148,7 +149,7 @@ redo:
} }
if ((p_ph > 0) && (pum_height > p_ph)) { if ((p_ph > 0) && (pum_height > p_ph)) {
pum_height = p_ph; pum_height = (int)p_ph;
} }
} }
@ -219,7 +220,9 @@ redo:
if (curwin->w_p_rl) { if (curwin->w_p_rl) {
pum_width = pum_col - pum_scrollbar + 1; pum_width = pum_col - pum_scrollbar + 1;
} else { } else {
pum_width = Columns - pum_col - pum_scrollbar; assert(Columns - pum_col - pum_scrollbar >= INT_MIN
&& Columns - pum_col - pum_scrollbar <= INT_MAX);
pum_width = (int)(Columns - pum_col - pum_scrollbar);
} }
if ((pum_width > max_width + kind_width + extra_width + 1) if ((pum_width > max_width + kind_width + extra_width + 1)
@ -233,11 +236,13 @@ redo:
} else if (Columns < def_width) { } else if (Columns < def_width) {
// not enough room, will use what we have // not enough room, will use what we have
if (curwin->w_p_rl) { if (curwin->w_p_rl) {
pum_col = Columns - 1; assert(Columns - 1 >= INT_MIN);
pum_col = (int)(Columns - 1);
} else { } else {
pum_col = 0; pum_col = 0;
} }
pum_width = Columns - 1; assert(Columns - 1 >= INT_MIN);
pum_width = (int)(Columns - 1);
} else { } else {
if (max_width > PUM_DEF_WIDTH) { if (max_width > PUM_DEF_WIDTH) {
// truncate // truncate
@ -247,7 +252,8 @@ redo:
if (curwin->w_p_rl) { if (curwin->w_p_rl) {
pum_col = max_width - 1; pum_col = max_width - 1;
} else { } else {
pum_col = Columns - max_width; assert(Columns - max_width >= INT_MIN && Columns - max_width <= INT_MAX);
pum_col = (int)(Columns - max_width);
} }
pum_width = max_width - pum_scrollbar; pum_width = max_width - pum_scrollbar;
} }
@ -345,7 +351,7 @@ void pum_redraw(void)
// Display the text that fits or comes before a Tab. // Display the text that fits or comes before a Tab.
// First convert it to printable characters. // First convert it to printable characters.
char_u *st; char_u *st;
int saved = *p; char_u saved = *p;
*p = NUL; *p = NUL;
st = transstr(s); st = transstr(s);
@ -535,7 +541,7 @@ static int pum_set_selected(int n, int repeat)
g_do_tagpreview = 3; g_do_tagpreview = 3;
if ((p_pvh > 0) && (p_pvh < g_do_tagpreview)) { if ((p_pvh > 0) && (p_pvh < g_do_tagpreview)) {
g_do_tagpreview = p_pvh; g_do_tagpreview = (int)p_pvh;
} }
RedrawingDisabled++; RedrawingDisabled++;
resized = prepare_tagpreview(false); resized = prepare_tagpreview(false);