Merge #3745 from cacplate/ops_Wconversion

Enable -Wconversion in ops.c
This commit is contained in:
Justin M. Keyes
2016-06-13 04:33:30 -04:00
committed by GitHub
13 changed files with 324 additions and 324 deletions

View File

@@ -98,7 +98,6 @@ set(CONV_SOURCES
mbyte.c
memline.c
message.c
ops.c
regexp.c
screen.c
search.c

View File

@@ -6952,8 +6952,8 @@ static void ins_reg(void)
AppendCharToRedobuff(literally);
AppendCharToRedobuff(regname);
do_put(regname, NULL, BACKWARD, 1L,
(literally == Ctrl_P ? PUT_FIXINDENT : 0) | PUT_CURSEND);
do_put(regname, NULL, BACKWARD, 1,
(literally == Ctrl_P ? PUT_FIXINDENT : 0) | PUT_CURSEND);
} else if (insert_reg(regname, literally) == FAIL) {
vim_beep(BO_REG);
need_redraw = true; // remove the '"'
@@ -7701,7 +7701,7 @@ static void ins_mouse(int c)
undisplay_dollar();
tpos = curwin->w_cursor;
if (do_mouse(NULL, c, BACKWARD, 1L, 0)) {
if (do_mouse(NULL, c, BACKWARD, 1, 0)) {
win_T *new_curwin = curwin;
if (curwin != old_curwin && win_valid(old_curwin)) {

View File

@@ -1891,7 +1891,7 @@ ex_let_one (
}
}
if (p != NULL) {
write_reg_contents(*arg == '@' ? '"' : *arg, p, -1, FALSE);
write_reg_contents(*arg == '@' ? '"' : *arg, p, STRLEN(p), false);
arg_end = arg + 1;
}
xfree(ptofree);
@@ -14920,7 +14920,8 @@ static void f_setreg(typval_T *argvars, typval_T *rettv)
}
*curval++ = NULL;
write_reg_contents_lst(regname, lstval, -1, append, yank_type, block_len);
write_reg_contents_lst(regname, lstval, STRLEN(lstval),
append, yank_type, block_len);
free_lstval:
while (curallocval > allocval)
@@ -14931,7 +14932,8 @@ free_lstval:
if (strval == NULL) {
return;
}
write_reg_contents_ex(regname, strval, -1, append, yank_type, block_len);
write_reg_contents_ex(regname, strval, STRLEN(strval),
append, yank_type, block_len);
}
rettv->vval.v_number = 0;
}

View File

@@ -2010,9 +2010,7 @@ void ex_argdelete(exarg_T *eap)
maketitle();
}
/*
* ":argdo", ":windo", ":bufdo", ":tabdo", ":cdo", ":ldo", ":cfdo" and ":lfdo"
*/
/// ":argdo", ":windo", ":bufdo", ":tabdo", ":cdo", ":ldo", ":cfdo" and ":lfdo"
void ex_listdo(exarg_T *eap)
{
int i;
@@ -2060,9 +2058,9 @@ void ex_listdo(exarg_T *eap)
buf_T *buf = curbuf;
size_t qf_size = 0;
/* set pcmark now */
// set pcmark now
if (eap->cmdidx == CMD_bufdo) {
/* Advance to the first listed buffer after "eap->line1". */
// Advance to the first listed buffer after "eap->line1".
for (buf = firstbuf;
buf != NULL && (buf->b_fnum < eap->line1 || !buf->b_p_bl);
buf = buf->b_next) {

View File

@@ -1536,8 +1536,9 @@ static char_u * do_one_cmd(char_u **cmdlinep,
}
ea.cmd = skipwhite(ea.cmd);
lnum = get_address(&ea, &ea.cmd, ea.addr_type, ea.skip, ea.addr_count == 0);
if (ea.cmd == NULL) /* error detected */
if (ea.cmd == NULL) { // error detected
goto doend;
}
if (lnum == MAXLNUM) {
if (*ea.cmd == '%') { /* '%' - all lines */
++ea.cmd;
@@ -4640,14 +4641,14 @@ static struct {
char *name;
} addr_type_complete[] =
{
{ADDR_ARGUMENTS, "arguments"},
{ADDR_LINES, "lines"},
{ADDR_LOADED_BUFFERS, "loaded_buffers"},
{ADDR_TABS, "tabs"},
{ADDR_BUFFERS, "buffers"},
{ADDR_WINDOWS, "windows"},
{ADDR_QUICKFIX, "quickfix"},
{-1, NULL}
{ ADDR_ARGUMENTS, "arguments" },
{ ADDR_LINES, "lines" },
{ ADDR_LOADED_BUFFERS, "loaded_buffers" },
{ ADDR_TABS, "tabs" },
{ ADDR_BUFFERS, "buffers" },
{ ADDR_WINDOWS, "windows" },
{ ADDR_QUICKFIX, "quickfix" },
{ -1, NULL }
};
/*
@@ -7125,8 +7126,8 @@ static void ex_put(exarg_T *eap)
eap->forceit = TRUE;
}
curwin->w_cursor.lnum = eap->line2;
do_put(eap->regname, NULL, eap->forceit ? BACKWARD : FORWARD, 1L,
PUT_LINE|PUT_CURSLINE);
do_put(eap->regname, NULL, eap->forceit ? BACKWARD : FORWARD, 1,
PUT_LINE|PUT_CURSLINE);
}
/*
@@ -7135,7 +7136,7 @@ static void ex_put(exarg_T *eap)
static void ex_copymove(exarg_T *eap)
{
long n = get_address(eap, &eap->arg, eap->addr_type, false, false);
if (eap->arg == NULL) { /* error detected */
if (eap->arg == NULL) { // error detected
eap->nextcmd = NULL;
return;
}
@@ -7354,10 +7355,11 @@ static void ex_redir(exarg_T *eap)
/* Can use both "@a" and "@a>". */
if (*arg == '>')
arg++;
/* Make register empty when not using @A-@Z and the
* command is valid. */
if (*arg == NUL && !isupper(redir_reg))
write_reg_contents(redir_reg, (char_u *)"", -1, FALSE);
// Make register empty when not using @A-@Z and the
// command is valid.
if (*arg == NUL && !isupper(redir_reg)) {
write_reg_contents(redir_reg, (char_u *)"", 0, false);
}
}
}
if (*arg != NUL) {

View File

@@ -836,8 +836,8 @@ EXTERN int* (*iconv_errno)(void);
EXTERN int State INIT(= NORMAL); /* This is the current state of the
* command interpreter. */
EXTERN int finish_op INIT(= FALSE); /* TRUE while an operator is pending */
EXTERN long opcount INIT(= 0); /* count for pending operator */
EXTERN bool finish_op INIT(= false); // true while an operator is pending
EXTERN long opcount INIT(= 0); // count for pending operator
/*
* ex mode (Q) state

View File

@@ -493,10 +493,11 @@ int emsg(char_u *s)
* when the message should be ignored completely (used for the
* interrupt message).
*/
if (cause_errthrow(s, severe, &ignore) == TRUE) {
if (!ignore)
did_emsg = TRUE;
return TRUE;
if (cause_errthrow(s, severe, &ignore) == true) {
if (!ignore) {
did_emsg = true;
}
return true;
}
// set "v:errmsg", also when using ":silent! cmd"
@@ -511,41 +512,43 @@ int emsg(char_u *s)
p = get_emsg_source();
if (p != NULL) {
STRCAT(p, "\n");
redir_write(p, -1);
redir_write(p, STRLEN(p));
xfree(p);
}
p = get_emsg_lnum();
if (p != NULL) {
STRCAT(p, "\n");
redir_write(p, -1);
redir_write(p, STRLEN(p));
xfree(p);
}
redir_write(s, -1);
return TRUE;
redir_write(s, STRLEN(s));
return true;
}
/* Reset msg_silent, an error causes messages to be switched back on. */
// Reset msg_silent, an error causes messages to be switched back on.
msg_silent = 0;
cmd_silent = FALSE;
if (global_busy) /* break :global command */
++global_busy;
if (global_busy) { // break :global command
global_busy++;
}
if (p_eb)
beep_flush(); /* also includes flush_buffers() */
else
flush_buffers(FALSE); /* flush internal buffers */
did_emsg = TRUE; /* flag for DoOneCmd() */
if (p_eb) {
beep_flush(); // also includes flush_buffers()
} else {
flush_buffers(false); // flush internal buffers
}
did_emsg = true; // flag for DoOneCmd()
}
emsg_on_display = TRUE; /* remember there is an error message */
++msg_scroll; /* don't overwrite a previous message */
attr = hl_attr(HLF_E); /* set highlight mode for error messages */
if (msg_scrolled != 0)
need_wait_return = TRUE; /* needed in case emsg() is called after
* wait_return has reset need_wait_return
* and a redraw is expected because
* msg_scrolled is non-zero */
emsg_on_display = true; // remember there is an error message
msg_scroll++; // don't overwrite a previous message
attr = hl_attr(HLF_E); // set highlight mode for error messages
if (msg_scrolled != 0) {
need_wait_return = true; // needed in case emsg() is called after
} // wait_return has reset need_wait_return
// and a redraw is expected because
// msg_scrolled is non-zero
/*
* Display name and line number for the source of the error.
@@ -2401,22 +2404,27 @@ static void redir_write(char_u *str, int maxlen)
/* If the string doesn't start with CR or NL, go to msg_col */
if (*s != '\n' && *s != '\r') {
while (cur_col < msg_col) {
if (redir_reg)
write_reg_contents(redir_reg, (char_u *)" ", -1, TRUE);
else if (redir_vname)
if (redir_reg) {
write_reg_contents(redir_reg, (char_u *)" ", 1, true);
} else if (redir_vname) {
var_redir_str((char_u *)" ", -1);
else if (redir_fd != NULL)
} else if (redir_fd != NULL) {
fputs(" ", redir_fd);
if (verbose_fd != NULL)
}
if (verbose_fd != NULL) {
fputs(" ", verbose_fd);
++cur_col;
}
cur_col++;
}
}
if (redir_reg)
write_reg_contents(redir_reg, s, maxlen, TRUE);
if (redir_vname)
if (redir_reg) {
size_t len = maxlen == -1 ? STRLEN(s) : (size_t)maxlen;
write_reg_contents(redir_reg, s, len, true);
}
if (redir_vname) {
var_redir_str(s, maxlen);
}
/* Write and adjust the current column. */
while (*s != NUL && (maxlen < 0 || (int)(s - str) < maxlen)) {

View File

@@ -178,12 +178,11 @@ open_line (
if (curbuf->b_p_ai
|| do_si
) {
/*
* count white space on current line
*/
newindent = get_indent_str(saved_line, (int)curbuf->b_p_ts, FALSE);
if (newindent == 0 && !(flags & OPENLINE_COM_LIST))
newindent = second_line_indent; /* for ^^D command in insert mode */
// count white space on current line
newindent = get_indent_str(saved_line, (int)curbuf->b_p_ts, false);
if (newindent == 0 && !(flags & OPENLINE_COM_LIST)) {
newindent = second_line_indent; // for ^^D command in insert mode
}
/*
* Do smart indenting.
@@ -612,7 +611,7 @@ open_line (
if (curbuf->b_p_ai
|| do_si
)
newindent = get_indent_str(leader, (int)curbuf->b_p_ts, FALSE);
newindent = get_indent_str(leader, (int)curbuf->b_p_ts, false);
/* Add the indent offset */
if (newindent + off < 0) {

View File

@@ -1795,10 +1795,11 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank)
if (oap->line_count < 2)
oap->line_count = 2;
if (curwin->w_cursor.lnum + oap->line_count - 1 >
curbuf->b_ml.ml_line_count)
curbuf->b_ml.ml_line_count) {
beep_flush();
else {
do_join(oap->line_count, oap->op_type == OP_JOIN, true, true, true);
} else {
do_join((size_t)oap->line_count, oap->op_type == OP_JOIN,
true, true, true);
auto_format(false, true);
}
break;
@@ -7666,7 +7667,7 @@ static void nv_join(cmdarg_T *cap)
prep_redo(cap->oap->regname, cap->count0,
NUL, cap->cmdchar, NUL, NUL, cap->nchar);
do_join(cap->count0, cap->nchar == NUL, true, true, true);
do_join((size_t)cap->count0, cap->nchar == NUL, true, true, true);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -79,7 +79,7 @@ enum GRegFlags {
/// Definition of one register
typedef struct yankreg {
char_u **y_array; ///< Pointer to an array of line pointers.
linenr_T y_size; ///< Number of lines in y_array.
size_t y_size; ///< Number of lines in y_array.
MotionType y_type; ///< Register type
colnr_T y_width; ///< Register width (only valid for y_type == kBlockWise).
Timestamp timestamp; ///< Time when register was last modified.

View File

@@ -4030,15 +4030,16 @@ set_num_option (
errmsg = e_invarg;
curwin->w_p_fdc = 12;
}
}
/* 'shiftwidth' or 'tabstop' */
else if (pp == &curbuf->b_p_sw || pp == &curbuf->b_p_ts) {
if (foldmethodIsIndent(curwin))
// 'shiftwidth' or 'tabstop'
} else if (pp == &curbuf->b_p_sw || pp == (long *)&curbuf->b_p_ts) {
if (foldmethodIsIndent(curwin)) {
foldUpdateAll(curwin);
/* When 'shiftwidth' changes, or it's zero and 'tabstop' changes:
* parse 'cinoptions'. */
if (pp == &curbuf->b_p_sw || curbuf->b_p_sw == 0)
}
// When 'shiftwidth' changes, or it's zero and 'tabstop' changes:
// parse 'cinoptions'.
if (pp == &curbuf->b_p_sw || curbuf->b_p_sw == 0) {
parse_cino(curbuf);
}
}
/* 'maxcombine' */
else if (pp == &p_mco) {
@@ -5657,7 +5658,7 @@ void buf_copy_options(buf_T *buf, int flags)
buf->b_p_isk = save_p_isk;
else {
buf->b_p_isk = vim_strsave(p_isk);
did_isk = TRUE;
did_isk = true;
buf->b_p_ts = p_ts;
buf->b_help = false;
if (buf->b_p_bt[0] == 'h')

View File

@@ -1422,7 +1422,7 @@ static void shada_read(ShaDaReadDef *const sd_reader, const int flags)
}
if (!op_register_set(cur_entry.data.reg.name, (yankreg_T) {
.y_array = (char_u **) cur_entry.data.reg.contents,
.y_size = (linenr_T) cur_entry.data.reg.contents_size,
.y_size = cur_entry.data.reg.contents_size,
.y_type = cur_entry.data.reg.type,
.y_width = (colnr_T) cur_entry.data.reg.width,
.timestamp = cur_entry.timestamp,
@@ -2745,7 +2745,7 @@ static ShaDaWriteResult shada_write(ShaDaWriteDef *const sd_writer,
if (name == NUL) {
break;
}
if (limit_reg_lines && reg.y_size > max_reg_lines) {
if (limit_reg_lines && reg.y_size > (size_t)max_reg_lines) {
continue;
}
wms->registers[op_reg_index(name)] = (PossiblyFreedShadaEntry) {