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 mbyte.c
memline.c memline.c
message.c message.c
ops.c
regexp.c regexp.c
screen.c screen.c
search.c search.c

View File

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

View File

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

View File

@@ -2010,9 +2010,7 @@ void ex_argdelete(exarg_T *eap)
maketitle(); 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) void ex_listdo(exarg_T *eap)
{ {
int i; int i;
@@ -2060,9 +2058,9 @@ void ex_listdo(exarg_T *eap)
buf_T *buf = curbuf; buf_T *buf = curbuf;
size_t qf_size = 0; size_t qf_size = 0;
/* set pcmark now */ // set pcmark now
if (eap->cmdidx == CMD_bufdo) { 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; for (buf = firstbuf;
buf != NULL && (buf->b_fnum < eap->line1 || !buf->b_p_bl); buf != NULL && (buf->b_fnum < eap->line1 || !buf->b_p_bl);
buf = buf->b_next) { buf = buf->b_next) {

View File

@@ -1536,8 +1536,9 @@ static char_u * do_one_cmd(char_u **cmdlinep,
} }
ea.cmd = skipwhite(ea.cmd); ea.cmd = skipwhite(ea.cmd);
lnum = get_address(&ea, &ea.cmd, ea.addr_type, ea.skip, ea.addr_count == 0); 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; goto doend;
}
if (lnum == MAXLNUM) { if (lnum == MAXLNUM) {
if (*ea.cmd == '%') { /* '%' - all lines */ if (*ea.cmd == '%') { /* '%' - all lines */
++ea.cmd; ++ea.cmd;
@@ -4640,14 +4641,14 @@ static struct {
char *name; char *name;
} addr_type_complete[] = } addr_type_complete[] =
{ {
{ADDR_ARGUMENTS, "arguments"}, { ADDR_ARGUMENTS, "arguments" },
{ADDR_LINES, "lines"}, { ADDR_LINES, "lines" },
{ADDR_LOADED_BUFFERS, "loaded_buffers"}, { ADDR_LOADED_BUFFERS, "loaded_buffers" },
{ADDR_TABS, "tabs"}, { ADDR_TABS, "tabs" },
{ADDR_BUFFERS, "buffers"}, { ADDR_BUFFERS, "buffers" },
{ADDR_WINDOWS, "windows"}, { ADDR_WINDOWS, "windows" },
{ADDR_QUICKFIX, "quickfix"}, { ADDR_QUICKFIX, "quickfix" },
{-1, NULL} { -1, NULL }
}; };
/* /*
@@ -7125,8 +7126,8 @@ static void ex_put(exarg_T *eap)
eap->forceit = TRUE; eap->forceit = TRUE;
} }
curwin->w_cursor.lnum = eap->line2; curwin->w_cursor.lnum = eap->line2;
do_put(eap->regname, NULL, eap->forceit ? BACKWARD : FORWARD, 1L, do_put(eap->regname, NULL, eap->forceit ? BACKWARD : FORWARD, 1,
PUT_LINE|PUT_CURSLINE); PUT_LINE|PUT_CURSLINE);
} }
/* /*
@@ -7135,7 +7136,7 @@ static void ex_put(exarg_T *eap)
static void ex_copymove(exarg_T *eap) static void ex_copymove(exarg_T *eap)
{ {
long n = get_address(eap, &eap->arg, eap->addr_type, false, false); 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; eap->nextcmd = NULL;
return; return;
} }
@@ -7354,10 +7355,11 @@ static void ex_redir(exarg_T *eap)
/* Can use both "@a" and "@a>". */ /* Can use both "@a" and "@a>". */
if (*arg == '>') if (*arg == '>')
arg++; arg++;
/* Make register empty when not using @A-@Z and the // Make register empty when not using @A-@Z and the
* command is valid. */ // command is valid.
if (*arg == NUL && !isupper(redir_reg)) if (*arg == NUL && !isupper(redir_reg)) {
write_reg_contents(redir_reg, (char_u *)"", -1, FALSE); write_reg_contents(redir_reg, (char_u *)"", 0, false);
}
} }
} }
if (*arg != NUL) { 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 EXTERN int State INIT(= NORMAL); /* This is the current state of the
* command interpreter. */ * command interpreter. */
EXTERN int finish_op INIT(= FALSE); /* TRUE while an operator is pending */ EXTERN bool finish_op INIT(= false); // true while an operator is pending
EXTERN long opcount INIT(= 0); /* count for pending operator */ EXTERN long opcount INIT(= 0); // count for pending operator
/* /*
* ex mode (Q) state * 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 * when the message should be ignored completely (used for the
* interrupt message). * interrupt message).
*/ */
if (cause_errthrow(s, severe, &ignore) == TRUE) { if (cause_errthrow(s, severe, &ignore) == true) {
if (!ignore) if (!ignore) {
did_emsg = TRUE; did_emsg = true;
return TRUE; }
return true;
} }
// set "v:errmsg", also when using ":silent! cmd" // set "v:errmsg", also when using ":silent! cmd"
@@ -511,41 +512,43 @@ int emsg(char_u *s)
p = get_emsg_source(); p = get_emsg_source();
if (p != NULL) { if (p != NULL) {
STRCAT(p, "\n"); STRCAT(p, "\n");
redir_write(p, -1); redir_write(p, STRLEN(p));
xfree(p); xfree(p);
} }
p = get_emsg_lnum(); p = get_emsg_lnum();
if (p != NULL) { if (p != NULL) {
STRCAT(p, "\n"); STRCAT(p, "\n");
redir_write(p, -1); redir_write(p, STRLEN(p));
xfree(p); xfree(p);
} }
redir_write(s, -1); redir_write(s, STRLEN(s));
return TRUE; 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; msg_silent = 0;
cmd_silent = FALSE; cmd_silent = FALSE;
if (global_busy) /* break :global command */ if (global_busy) { // break :global command
++global_busy; global_busy++;
}
if (p_eb) if (p_eb) {
beep_flush(); /* also includes flush_buffers() */ beep_flush(); // also includes flush_buffers()
else } else {
flush_buffers(FALSE); /* flush internal buffers */ flush_buffers(false); // flush internal buffers
did_emsg = TRUE; /* flag for DoOneCmd() */ }
did_emsg = true; // flag for DoOneCmd()
} }
emsg_on_display = TRUE; /* remember there is an error message */ emsg_on_display = true; // remember there is an error message
++msg_scroll; /* don't overwrite a previous message */ msg_scroll++; // don't overwrite a previous message
attr = hl_attr(HLF_E); /* set highlight mode for error messages */ attr = hl_attr(HLF_E); // set highlight mode for error messages
if (msg_scrolled != 0) if (msg_scrolled != 0) {
need_wait_return = TRUE; /* needed in case emsg() is called after need_wait_return = true; // needed in case emsg() is called after
* wait_return has reset need_wait_return } // wait_return has reset need_wait_return
* and a redraw is expected because // and a redraw is expected because
* msg_scrolled is non-zero */ // msg_scrolled is non-zero
/* /*
* Display name and line number for the source of the error. * 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 the string doesn't start with CR or NL, go to msg_col */
if (*s != '\n' && *s != '\r') { if (*s != '\n' && *s != '\r') {
while (cur_col < msg_col) { while (cur_col < msg_col) {
if (redir_reg) if (redir_reg) {
write_reg_contents(redir_reg, (char_u *)" ", -1, TRUE); write_reg_contents(redir_reg, (char_u *)" ", 1, true);
else if (redir_vname) } else if (redir_vname) {
var_redir_str((char_u *)" ", -1); var_redir_str((char_u *)" ", -1);
else if (redir_fd != NULL) } else if (redir_fd != NULL) {
fputs(" ", redir_fd); fputs(" ", redir_fd);
if (verbose_fd != NULL) }
if (verbose_fd != NULL) {
fputs(" ", verbose_fd); fputs(" ", verbose_fd);
++cur_col; }
cur_col++;
} }
} }
if (redir_reg) if (redir_reg) {
write_reg_contents(redir_reg, s, maxlen, TRUE); size_t len = maxlen == -1 ? STRLEN(s) : (size_t)maxlen;
if (redir_vname) write_reg_contents(redir_reg, s, len, true);
}
if (redir_vname) {
var_redir_str(s, maxlen); var_redir_str(s, maxlen);
}
/* Write and adjust the current column. */ /* Write and adjust the current column. */
while (*s != NUL && (maxlen < 0 || (int)(s - str) < maxlen)) { while (*s != NUL && (maxlen < 0 || (int)(s - str) < maxlen)) {

View File

@@ -178,12 +178,11 @@ open_line (
if (curbuf->b_p_ai if (curbuf->b_p_ai
|| do_si || do_si
) { ) {
/* // count white space on current line
* 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 = get_indent_str(saved_line, (int)curbuf->b_p_ts, FALSE); newindent = second_line_indent; // for ^^D command in insert mode
if (newindent == 0 && !(flags & OPENLINE_COM_LIST)) }
newindent = second_line_indent; /* for ^^D command in insert mode */
/* /*
* Do smart indenting. * Do smart indenting.
@@ -612,7 +611,7 @@ open_line (
if (curbuf->b_p_ai if (curbuf->b_p_ai
|| do_si || 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 */ /* Add the indent offset */
if (newindent + off < 0) { 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) if (oap->line_count < 2)
oap->line_count = 2; oap->line_count = 2;
if (curwin->w_cursor.lnum + oap->line_count - 1 > if (curwin->w_cursor.lnum + oap->line_count - 1 >
curbuf->b_ml.ml_line_count) curbuf->b_ml.ml_line_count) {
beep_flush(); beep_flush();
else { } else {
do_join(oap->line_count, oap->op_type == OP_JOIN, true, true, true); do_join((size_t)oap->line_count, oap->op_type == OP_JOIN,
true, true, true);
auto_format(false, true); auto_format(false, true);
} }
break; break;
@@ -7666,7 +7667,7 @@ static void nv_join(cmdarg_T *cap)
prep_redo(cap->oap->regname, cap->count0, prep_redo(cap->oap->regname, cap->count0,
NUL, cap->cmdchar, NUL, NUL, cap->nchar); 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 /// Definition of one register
typedef struct yankreg { typedef struct yankreg {
char_u **y_array; ///< Pointer to an array of line pointers. 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 MotionType y_type; ///< Register type
colnr_T y_width; ///< Register width (only valid for y_type == kBlockWise). colnr_T y_width; ///< Register width (only valid for y_type == kBlockWise).
Timestamp timestamp; ///< Time when register was last modified. Timestamp timestamp; ///< Time when register was last modified.

View File

@@ -4030,15 +4030,16 @@ set_num_option (
errmsg = e_invarg; errmsg = e_invarg;
curwin->w_p_fdc = 12; curwin->w_p_fdc = 12;
} }
} // 'shiftwidth' or 'tabstop'
/* 'shiftwidth' or 'tabstop' */ } else if (pp == &curbuf->b_p_sw || pp == (long *)&curbuf->b_p_ts) {
else if (pp == &curbuf->b_p_sw || pp == &curbuf->b_p_ts) { if (foldmethodIsIndent(curwin)) {
if (foldmethodIsIndent(curwin))
foldUpdateAll(curwin); foldUpdateAll(curwin);
/* When 'shiftwidth' changes, or it's zero and 'tabstop' changes: }
* parse 'cinoptions'. */ // When 'shiftwidth' changes, or it's zero and 'tabstop' changes:
if (pp == &curbuf->b_p_sw || curbuf->b_p_sw == 0) // parse 'cinoptions'.
if (pp == &curbuf->b_p_sw || curbuf->b_p_sw == 0) {
parse_cino(curbuf); parse_cino(curbuf);
}
} }
/* 'maxcombine' */ /* 'maxcombine' */
else if (pp == &p_mco) { 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; buf->b_p_isk = save_p_isk;
else { else {
buf->b_p_isk = vim_strsave(p_isk); buf->b_p_isk = vim_strsave(p_isk);
did_isk = TRUE; did_isk = true;
buf->b_p_ts = p_ts; buf->b_p_ts = p_ts;
buf->b_help = false; buf->b_help = false;
if (buf->b_p_bt[0] == 'h') 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) { if (!op_register_set(cur_entry.data.reg.name, (yankreg_T) {
.y_array = (char_u **) cur_entry.data.reg.contents, .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_type = cur_entry.data.reg.type,
.y_width = (colnr_T) cur_entry.data.reg.width, .y_width = (colnr_T) cur_entry.data.reg.width,
.timestamp = cur_entry.timestamp, .timestamp = cur_entry.timestamp,
@@ -2745,7 +2745,7 @@ static ShaDaWriteResult shada_write(ShaDaWriteDef *const sd_writer,
if (name == NUL) { if (name == NUL) {
break; break;
} }
if (limit_reg_lines && reg.y_size > max_reg_lines) { if (limit_reg_lines && reg.y_size > (size_t)max_reg_lines) {
continue; continue;
} }
wms->registers[op_reg_index(name)] = (PossiblyFreedShadaEntry) { wms->registers[op_reg_index(name)] = (PossiblyFreedShadaEntry) {