mirror of
https://github.com/neovim/neovim.git
synced 2024-12-24 13:15:09 -07:00
docs: add style rule regarding initialization
Specifically, specify that each initialization should be done on a separate line.
This commit is contained in:
parent
8c173cec29
commit
6cb78e2d1c
@ -73,6 +73,24 @@ should be used instead of declaration and assignment, e.g. >c
|
||||
int j = g(); // GOOD: declaration has initialization.
|
||||
|
||||
|
||||
Initialization ~
|
||||
|
||||
Multiple declarations can be defined in one line if they aren't initialized,
|
||||
but each initialization should be done on a separate line.
|
||||
|
||||
>c
|
||||
int i;
|
||||
int j; // GOOD
|
||||
|
||||
int i, j; // GOOD: multiple declarations, no initialization.
|
||||
|
||||
int i = 0;
|
||||
int j = 0; // GOOD: one initialization per line.
|
||||
|
||||
int i = 0, j; // BAD: multiple declarations with initialization.
|
||||
|
||||
int i = 0, j = 0; // BAD: multiple declarations with initialization.
|
||||
|
||||
==============================================================================
|
||||
Nvim-Specific Magic
|
||||
|
||||
|
@ -2121,10 +2121,8 @@ int get_last_leader_offset(char *line, char **flags)
|
||||
int result = -1;
|
||||
int j;
|
||||
int lower_check_bound = 0;
|
||||
char *string;
|
||||
char *com_leader;
|
||||
char *com_flags;
|
||||
char *list;
|
||||
char part_buf[COM_MAX_LEN]; // buffer for one option part
|
||||
|
||||
// Repeat to match several nested comment strings.
|
||||
@ -2132,13 +2130,13 @@ int get_last_leader_offset(char *line, char **flags)
|
||||
while (--i >= lower_check_bound) {
|
||||
// scan through the 'comments' option for a match
|
||||
int found_one = false;
|
||||
for (list = curbuf->b_p_com; *list;) {
|
||||
for (char *list = curbuf->b_p_com; *list;) {
|
||||
char *flags_save = list;
|
||||
|
||||
// Get one option part into part_buf[]. Advance list to next one.
|
||||
// put string at start of string.
|
||||
(void)copy_option_part(&list, part_buf, COM_MAX_LEN, ",");
|
||||
string = vim_strchr(part_buf, ':');
|
||||
char *string = vim_strchr(part_buf, ':');
|
||||
if (string == NULL) { // If everything is fine, this cannot actually
|
||||
// happen.
|
||||
continue;
|
||||
@ -2216,14 +2214,14 @@ int get_last_leader_offset(char *line, char **flags)
|
||||
}
|
||||
int len1 = (int)strlen(com_leader);
|
||||
|
||||
for (list = curbuf->b_p_com; *list;) {
|
||||
for (char *list = curbuf->b_p_com; *list;) {
|
||||
char *flags_save = list;
|
||||
|
||||
(void)copy_option_part(&list, part_buf2, COM_MAX_LEN, ",");
|
||||
if (flags_save == com_flags) {
|
||||
continue;
|
||||
}
|
||||
string = vim_strchr(part_buf2, ':');
|
||||
char *string = vim_strchr(part_buf2, ':');
|
||||
string++;
|
||||
while (ascii_iswhite(*string)) {
|
||||
string++;
|
||||
|
@ -928,7 +928,6 @@ int showmode(void)
|
||||
|
||||
bool can_show_mode = (p_ch != 0 || ui_has(kUIMessages));
|
||||
if ((do_mode || reg_recording != 0) && can_show_mode) {
|
||||
int sub_attr;
|
||||
if (skip_showmode()) {
|
||||
return 0; // show mode later
|
||||
}
|
||||
@ -955,6 +954,7 @@ int showmode(void)
|
||||
lines_left = 0;
|
||||
|
||||
if (do_mode) {
|
||||
int sub_attr;
|
||||
msg_puts_attr("--", attr);
|
||||
// CTRL-X in Insert mode
|
||||
if (edit_submode != NULL && !shortmess(SHM_COMPLETIONMENU)) {
|
||||
|
@ -3008,7 +3008,6 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty)
|
||||
int try_match;
|
||||
int try_match_word;
|
||||
char *p;
|
||||
char *line;
|
||||
bool icase;
|
||||
|
||||
if (keytyped == NUL) {
|
||||
@ -3150,7 +3149,7 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty)
|
||||
|
||||
// Just completed a word, check if it starts with "look".
|
||||
// search back for the start of a word.
|
||||
line = get_cursor_line_ptr();
|
||||
char *line = get_cursor_line_ptr();
|
||||
for (s = line + curwin->w_cursor.col; s > line; s = n) {
|
||||
n = mb_prevptr(line, s);
|
||||
if (!vim_iswordp(n)) {
|
||||
@ -3169,7 +3168,7 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty)
|
||||
if (keytyped == (int)(uint8_t)p[-1]
|
||||
|| (icase && keytyped < 256
|
||||
&& TOLOWER_LOC(keytyped) == TOLOWER_LOC((uint8_t)p[-1]))) {
|
||||
line = get_cursor_pos_ptr();
|
||||
char *line = get_cursor_pos_ptr();
|
||||
assert(p >= look && (uintmax_t)(p - look) <= SIZE_MAX);
|
||||
if ((curwin->w_cursor.col == (colnr_T)(p - look)
|
||||
|| !vim_iswordc((uint8_t)line[-(p - look) - 1]))
|
||||
|
@ -2863,7 +2863,8 @@ static int eval5(char **arg, typval_T *rettv, evalarg_T *const evalarg)
|
||||
} else {
|
||||
bool error = false;
|
||||
varnumber_T n1, n2;
|
||||
float_T f1 = 0, f2 = 0;
|
||||
float_T f1 = 0;
|
||||
float_T f2 = 0;
|
||||
|
||||
if (rettv->v_type == VAR_FLOAT) {
|
||||
f1 = rettv->vval.v_float;
|
||||
@ -2954,7 +2955,8 @@ static int eval6(char **arg, typval_T *rettv, evalarg_T *const evalarg, bool wan
|
||||
}
|
||||
|
||||
varnumber_T n1, n2;
|
||||
float_T f1 = 0, f2 = 0;
|
||||
float_T f1 = 0;
|
||||
float_T f2 = 0;
|
||||
bool error = false;
|
||||
const bool evaluate = evalarg == NULL ? 0 : (evalarg->eval_flags & EVAL_EVALUATE);
|
||||
if (evaluate) {
|
||||
|
@ -4054,8 +4054,8 @@ static void f_jobstart(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
bool clear_env = false;
|
||||
bool overlapped = false;
|
||||
ChannelStdinMode stdin_mode = kChannelStdinPipe;
|
||||
CallbackReader on_stdout = CALLBACK_READER_INIT,
|
||||
on_stderr = CALLBACK_READER_INIT;
|
||||
CallbackReader on_stdout = CALLBACK_READER_INIT;
|
||||
CallbackReader on_stderr = CALLBACK_READER_INIT;
|
||||
Callback on_exit = CALLBACK_NONE;
|
||||
char *cwd = NULL;
|
||||
dictitem_T *job_env = NULL;
|
||||
@ -4118,7 +4118,8 @@ static void f_jobstart(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t width = 0, height = 0;
|
||||
uint16_t width = 0;
|
||||
uint16_t height = 0;
|
||||
char *term_name = NULL;
|
||||
|
||||
if (pty) {
|
||||
@ -8553,8 +8554,8 @@ static void f_termopen(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
return;
|
||||
}
|
||||
|
||||
CallbackReader on_stdout = CALLBACK_READER_INIT,
|
||||
on_stderr = CALLBACK_READER_INIT;
|
||||
CallbackReader on_stdout = CALLBACK_READER_INIT;
|
||||
CallbackReader on_stderr = CALLBACK_READER_INIT;
|
||||
Callback on_exit = CALLBACK_NONE;
|
||||
dict_T *job_opts = NULL;
|
||||
const char *cwd = ".";
|
||||
|
@ -105,7 +105,6 @@ static int get_function_args(char **argp, char endchar, garray_T *newargs, int *
|
||||
char *arg = *argp;
|
||||
char *p = arg;
|
||||
uint8_t c;
|
||||
int i;
|
||||
|
||||
if (newargs != NULL) {
|
||||
ga_init(newargs, (int)sizeof(char *), 3);
|
||||
@ -147,7 +146,7 @@ static int get_function_args(char **argp, char endchar, garray_T *newargs, int *
|
||||
arg = xstrdup(arg);
|
||||
|
||||
// Check for duplicate argument name.
|
||||
for (i = 0; i < newargs->ga_len; i++) {
|
||||
for (int i = 0; i < newargs->ga_len; i++) {
|
||||
if (strcmp(((char **)(newargs->ga_data))[i], arg) == 0) {
|
||||
semsg(_("E853: Duplicate argument name: %s"), arg);
|
||||
xfree(arg);
|
||||
@ -922,7 +921,6 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rett
|
||||
static int depth = 0;
|
||||
dictitem_T *v;
|
||||
int fixvar_idx = 0; // index in fc_fixvar[]
|
||||
int ai;
|
||||
bool islambda = false;
|
||||
char numbuf[NUMBUFLEN];
|
||||
char *name;
|
||||
@ -1025,7 +1023,7 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rett
|
||||
bool isdefault = false;
|
||||
typval_T def_rettv;
|
||||
|
||||
ai = i - fp->uf_args.ga_len;
|
||||
int ai = i - fp->uf_args.ga_len;
|
||||
if (ai < 0) {
|
||||
// named argument a:name
|
||||
name = FUNCARG(fp, i);
|
||||
|
@ -710,7 +710,8 @@ void f_win_splitmove(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
return;
|
||||
}
|
||||
|
||||
int flags = 0, size = 0;
|
||||
int flags = 0;
|
||||
int size = 0;
|
||||
|
||||
if (argvars[2].v_type != VAR_UNKNOWN) {
|
||||
dict_T *d;
|
||||
|
@ -618,7 +618,8 @@ void ex_sort(exarg_T *eap)
|
||||
goto sortend;
|
||||
}
|
||||
|
||||
bcount_t old_count = 0, new_count = 0;
|
||||
bcount_t old_count = 0;
|
||||
bcount_t new_count = 0;
|
||||
|
||||
// Insert the lines in the sorted order below the last one.
|
||||
linenr_T lnum = eap->line2;
|
||||
@ -3303,7 +3304,8 @@ static int do_sub(exarg_T *eap, const proftime_T timeout, const int cmdpreview_n
|
||||
.do_number = false,
|
||||
.do_ic = kSubHonorOptions
|
||||
};
|
||||
char *pat = NULL, *sub = NULL; // init for GCC
|
||||
char *pat = NULL;
|
||||
char *sub = NULL; // init for GCC
|
||||
int delimiter;
|
||||
bool has_second_delim = false;
|
||||
int sublen;
|
||||
@ -3501,7 +3503,8 @@ static int do_sub(exarg_T *eap, const proftime_T timeout, const int cmdpreview_n
|
||||
colnr_T copycol;
|
||||
colnr_T matchcol;
|
||||
colnr_T prev_matchcol = MAXCOL;
|
||||
char *new_end, *new_start = NULL;
|
||||
char *new_end;
|
||||
char *new_start = NULL;
|
||||
int new_start_len = 0;
|
||||
char *p1;
|
||||
bool did_sub = false;
|
||||
@ -3971,7 +3974,8 @@ static int do_sub(exarg_T *eap, const proftime_T timeout, const int cmdpreview_n
|
||||
|
||||
// TODO(bfredl): this has some robustness issues, look into later.
|
||||
bcount_t replaced_bytes = 0;
|
||||
lpos_T start = regmatch.startpos[0], end = regmatch.endpos[0];
|
||||
lpos_T start = regmatch.startpos[0];
|
||||
lpos_T end = regmatch.endpos[0];
|
||||
for (i = 0; i < nmatch - 1; i++) {
|
||||
replaced_bytes += (bcount_t)strlen(ml_get((linenr_T)(lnum_start + i))) + 1;
|
||||
}
|
||||
|
@ -435,8 +435,10 @@ void extmark_adjust(buf_T *buf, linenr_T line1, linenr_T line2, linenr_T amount,
|
||||
return;
|
||||
}
|
||||
bcount_t start_byte = ml_find_line_or_offset(buf, line1, NULL, true);
|
||||
bcount_t old_byte = 0, new_byte = 0;
|
||||
int old_row, new_row;
|
||||
bcount_t old_byte = 0;
|
||||
bcount_t new_byte = 0;
|
||||
int old_row;
|
||||
int new_row;
|
||||
if (amount == MAXLNUM) {
|
||||
old_row = line2 - line1 + 1;
|
||||
// TODO(bfredl): ej kasta?
|
||||
|
@ -849,7 +849,6 @@ void foldUpdateAll(win_T *win)
|
||||
int foldMoveTo(const bool updown, const int dir, const int count)
|
||||
{
|
||||
int retval = FAIL;
|
||||
linenr_T lnum;
|
||||
fold_T *fp;
|
||||
|
||||
checkupdate(curwin);
|
||||
@ -908,7 +907,7 @@ int foldMoveTo(const bool updown, const int dir, const int count)
|
||||
if (dir == FORWARD) {
|
||||
// to start of next fold if there is one
|
||||
if (fp + 1 - (fold_T *)gap->ga_data < gap->ga_len) {
|
||||
lnum = fp[1].fd_top + lnum_off;
|
||||
linenr_T lnum = fp[1].fd_top + lnum_off;
|
||||
if (lnum > curwin->w_cursor.lnum) {
|
||||
lnum_found = lnum;
|
||||
}
|
||||
@ -916,7 +915,7 @@ int foldMoveTo(const bool updown, const int dir, const int count)
|
||||
} else {
|
||||
// to end of previous fold if there is one
|
||||
if (fp > (fold_T *)gap->ga_data) {
|
||||
lnum = fp[-1].fd_top + lnum_off + fp[-1].fd_len - 1;
|
||||
linenr_T lnum = fp[-1].fd_top + lnum_off + fp[-1].fd_len - 1;
|
||||
if (lnum < curwin->w_cursor.lnum) {
|
||||
lnum_found = lnum;
|
||||
}
|
||||
@ -926,12 +925,12 @@ int foldMoveTo(const bool updown, const int dir, const int count)
|
||||
// Open fold found, set cursor to its start/end and then check
|
||||
// nested folds.
|
||||
if (dir == FORWARD) {
|
||||
lnum = fp->fd_top + lnum_off + fp->fd_len - 1;
|
||||
linenr_T lnum = fp->fd_top + lnum_off + fp->fd_len - 1;
|
||||
if (lnum > curwin->w_cursor.lnum) {
|
||||
lnum_found = lnum;
|
||||
}
|
||||
} else {
|
||||
lnum = fp->fd_top + lnum_off;
|
||||
linenr_T lnum = fp->fd_top + lnum_off;
|
||||
if (lnum < curwin->w_cursor.lnum) {
|
||||
lnum_found = lnum;
|
||||
}
|
||||
@ -999,7 +998,6 @@ void foldAdjustVisual(void)
|
||||
}
|
||||
|
||||
pos_T *start, *end;
|
||||
char *ptr;
|
||||
|
||||
if (ltoreq(VIsual, curwin->w_cursor)) {
|
||||
start = &VIsual;
|
||||
@ -1016,7 +1014,7 @@ void foldAdjustVisual(void)
|
||||
return;
|
||||
}
|
||||
|
||||
ptr = ml_get(end->lnum);
|
||||
char *ptr = ml_get(end->lnum);
|
||||
end->col = (colnr_T)strlen(ptr);
|
||||
if (end->col > 0 && *p_sel == 'o') {
|
||||
end->col--;
|
||||
@ -2802,7 +2800,8 @@ void foldMoveRange(win_T *const wp, garray_T *gap, const linenr_T line1, const l
|
||||
// Case 5 or 6: changes rely on whether there are folds between the end of
|
||||
// this fold and "dest".
|
||||
size_t move_start = FOLD_INDEX(fp, gap);
|
||||
size_t move_end = 0, dest_index = 0;
|
||||
size_t move_end = 0;
|
||||
size_t dest_index = 0;
|
||||
for (; VALID_FOLD(fp, gap) && fp->fd_top <= dest; fp++) {
|
||||
if (fp->fd_top <= line2) {
|
||||
// 5, or 6
|
||||
|
@ -124,7 +124,7 @@ EXTERN bool redraw_cmdline INIT( = false); // cmdline must be redrawn
|
||||
EXTERN bool redraw_mode INIT( = false); // mode must be redrawn
|
||||
EXTERN bool clear_cmdline INIT( = false); // cmdline must be cleared
|
||||
EXTERN bool mode_displayed INIT( = false); // mode is being displayed
|
||||
EXTERN int cmdline_star INIT( = false); // cmdline is encrypted
|
||||
EXTERN int cmdline_star INIT( = 0); // cmdline is encrypted
|
||||
EXTERN bool redrawing_cmdline INIT( = false); // cmdline is being redrawn
|
||||
EXTERN bool cmdline_was_last_drawn INIT( = false); // cmdline was last drawn
|
||||
|
||||
@ -591,9 +591,9 @@ EXTERN int reg_executing INIT( = 0); // register being executed or zero
|
||||
EXTERN bool pending_end_reg_executing INIT( = false);
|
||||
EXTERN int reg_recorded INIT( = 0); // last recorded register or zero
|
||||
|
||||
EXTERN int no_mapping INIT( = false); // currently no mapping allowed
|
||||
EXTERN int no_mapping INIT( = 0); // currently no mapping allowed
|
||||
EXTERN int no_zero_mapping INIT( = 0); // mapping zero not allowed
|
||||
EXTERN int allow_keys INIT( = false); // allow key codes when no_mapping is set
|
||||
EXTERN int allow_keys INIT( = 0); // allow key codes when no_mapping is set
|
||||
EXTERN int no_u_sync INIT( = 0); // Don't call u_sync()
|
||||
EXTERN int u_sync_once INIT( = 0); // Call u_sync() once when evaluating
|
||||
// an expression.
|
||||
|
@ -538,7 +538,8 @@ void grid_line_flush_if_valid_row(void)
|
||||
void grid_fill(ScreenGrid *grid, int start_row, int end_row, int start_col, int end_col, int c1,
|
||||
int c2, int attr)
|
||||
{
|
||||
int row_off = 0, col_off = 0;
|
||||
int row_off = 0;
|
||||
int col_off = 0;
|
||||
grid_adjust(&grid, &row_off, &col_off);
|
||||
start_row += row_off;
|
||||
end_row += row_off;
|
||||
@ -650,8 +651,6 @@ void grid_put_linebuf(ScreenGrid *grid, int row, int coloff, int col, int endcol
|
||||
{
|
||||
bool redraw_next; // redraw_this for next character
|
||||
bool clear_next = false;
|
||||
int char_cells; // 1: normal char
|
||||
// 2: occupies two display cells
|
||||
assert(0 <= row && row < grid->rows);
|
||||
// TODO(bfredl): check all callsites and eliminate
|
||||
// Check for illegal col, just in case
|
||||
@ -703,10 +702,12 @@ void grid_put_linebuf(ScreenGrid *grid, int row, int coloff, int col, int endcol
|
||||
|
||||
redraw_next = grid_char_needs_redraw(grid, col, (size_t)col + off_to, endcol - col);
|
||||
|
||||
int start_dirty = -1, end_dirty = 0;
|
||||
int start_dirty = -1;
|
||||
int end_dirty = 0;
|
||||
|
||||
while (col < endcol) {
|
||||
char_cells = 1;
|
||||
int char_cells = 1; // 1: normal char
|
||||
// 2: occupies two display cells
|
||||
if (col + 1 < endcol && linebuf_char[col + 1] == 0) {
|
||||
char_cells = 2;
|
||||
}
|
||||
|
@ -713,7 +713,8 @@ int hl_blend_attrs(int back_attr, int front_attr, bool *through)
|
||||
|
||||
static int rgb_blend(int ratio, int rgb1, int rgb2)
|
||||
{
|
||||
int a = ratio, b = 100 - ratio;
|
||||
int a = ratio;
|
||||
int b = 100 - ratio;
|
||||
int r1 = (rgb1 & 0xFF0000) >> 16;
|
||||
int g1 = (rgb1 & 0x00FF00) >> 8;
|
||||
int b1 = (rgb1 & 0x0000FF) >> 0;
|
||||
@ -940,7 +941,11 @@ HlAttrs dict2hlattrs(Dict(highlight) *dict, bool use_rgb, int *link_id, Error *e
|
||||
{
|
||||
#define HAS_KEY_X(d, key) HAS_KEY(d, highlight, key)
|
||||
HlAttrs hlattrs = HLATTRS_INIT;
|
||||
int32_t fg = -1, bg = -1, ctermfg = -1, ctermbg = -1, sp = -1;
|
||||
int32_t fg = -1;
|
||||
int32_t bg = -1;
|
||||
int32_t ctermfg = -1;
|
||||
int32_t ctermbg = -1;
|
||||
int32_t sp = -1;
|
||||
int blend = -1;
|
||||
int16_t mask = 0;
|
||||
int16_t cterm_mask = 0;
|
||||
|
@ -53,15 +53,13 @@
|
||||
bool tabstop_set(char *var, colnr_T **array)
|
||||
{
|
||||
int valcount = 1;
|
||||
int t;
|
||||
char *cp;
|
||||
|
||||
if (var[0] == NUL || (var[0] == '0' && var[1] == NUL)) {
|
||||
*array = NULL;
|
||||
return true;
|
||||
}
|
||||
|
||||
for (cp = var; *cp != NUL; cp++) {
|
||||
for (char *cp = var; *cp != NUL; cp++) {
|
||||
if (cp == var || cp[-1] == ',') {
|
||||
char *end;
|
||||
|
||||
@ -89,8 +87,8 @@ bool tabstop_set(char *var, colnr_T **array)
|
||||
*array = (colnr_T *)xmalloc((unsigned)(valcount + 1) * sizeof(int));
|
||||
(*array)[0] = (colnr_T)valcount;
|
||||
|
||||
t = 1;
|
||||
for (cp = var; *cp != NUL;) {
|
||||
int t = 1;
|
||||
for (char *cp = var; *cp != NUL;) {
|
||||
int n = atoi(cp);
|
||||
|
||||
// Catch negative values, overflow and ridiculous big values.
|
||||
@ -171,14 +169,13 @@ int tabstop_at(colnr_T col, OptInt ts, const colnr_T *vts)
|
||||
colnr_T tabstop_start(colnr_T col, int ts, colnr_T *vts)
|
||||
{
|
||||
colnr_T tabcol = 0;
|
||||
int t;
|
||||
|
||||
if (vts == NULL || vts[0] == 0) {
|
||||
return ((col / ts) * ts);
|
||||
}
|
||||
|
||||
const int tabcount = vts[0];
|
||||
for (t = 1; t <= tabcount; t++) {
|
||||
for (int t = 1; t <= tabcount; t++) {
|
||||
tabcol += vts[t];
|
||||
if (tabcol > col) {
|
||||
return (tabcol - vts[t]);
|
||||
@ -258,8 +255,6 @@ void tabstop_fromto(colnr_T start_col, colnr_T end_col, int ts_arg, const colnr_
|
||||
/// See if two tabstop arrays contain the same values.
|
||||
bool tabstop_eq(const colnr_T *ts1, const colnr_T *ts2)
|
||||
{
|
||||
int t;
|
||||
|
||||
if ((ts1 == 0 && ts2) || (ts1 && ts2 == 0)) {
|
||||
return false;
|
||||
}
|
||||
@ -270,7 +265,7 @@ bool tabstop_eq(const colnr_T *ts1, const colnr_T *ts2)
|
||||
return false;
|
||||
}
|
||||
|
||||
for (t = 1; t <= ts1[0]; t++) {
|
||||
for (int t = 1; t <= ts1[0]; t++) {
|
||||
if (ts1[t] != ts2[t]) {
|
||||
return false;
|
||||
}
|
||||
@ -282,15 +277,12 @@ bool tabstop_eq(const colnr_T *ts1, const colnr_T *ts2)
|
||||
/// Copy a tabstop array, allocating space for the new array.
|
||||
int *tabstop_copy(const int *oldts)
|
||||
{
|
||||
int *newts;
|
||||
int t;
|
||||
|
||||
if (oldts == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
newts = xmalloc((unsigned)(oldts[0] + 1) * sizeof(int));
|
||||
for (t = 0; t <= oldts[0]; t++) {
|
||||
int *newts = xmalloc((unsigned)(oldts[0] + 1) * sizeof(int));
|
||||
for (int t = 0; t <= oldts[0]; t++) {
|
||||
newts[t] = oldts[t];
|
||||
}
|
||||
|
||||
@ -431,25 +423,22 @@ int get_indent_str_vtab(const char *ptr, OptInt ts, colnr_T *vts, bool list)
|
||||
return count;
|
||||
}
|
||||
|
||||
// Set the indent of the current line.
|
||||
// Leaves the cursor on the first non-blank in the line.
|
||||
// Caller must take care of undo.
|
||||
// "flags":
|
||||
// SIN_CHANGED: call changed_bytes() if the line was changed.
|
||||
// SIN_INSERT: insert the indent in front of the line.
|
||||
// SIN_UNDO: save line for undo before changing it.
|
||||
// SIN_NOMARK: don't move extmarks (because just after ml_append or something)
|
||||
// @param size measured in spaces
|
||||
// Returns true if the line was changed.
|
||||
/// Set the indent of the current line.
|
||||
/// Leaves the cursor on the first non-blank in the line.
|
||||
/// Caller must take care of undo.
|
||||
/// "flags":
|
||||
/// SIN_CHANGED: call changed_bytes() if the line was changed.
|
||||
/// SIN_INSERT: insert the indent in front of the line.
|
||||
/// SIN_UNDO: save line for undo before changing it.
|
||||
/// SIN_NOMARK: don't move extmarks (because just after ml_append or something)
|
||||
/// @param size measured in spaces
|
||||
///
|
||||
/// @return true if the line was changed.
|
||||
int set_indent(int size, int flags)
|
||||
{
|
||||
char *p;
|
||||
char *newline;
|
||||
char *oldline;
|
||||
char *s;
|
||||
int todo;
|
||||
int ind_len; // Measured in characters.
|
||||
int line_len;
|
||||
int doit = false;
|
||||
int ind_done = 0; // Measured in spaces.
|
||||
int tab_pad;
|
||||
@ -460,9 +449,9 @@ int set_indent(int size, int flags)
|
||||
|
||||
// First check if there is anything to do and compute the number of
|
||||
// characters needed for the indent.
|
||||
todo = size;
|
||||
ind_len = 0;
|
||||
p = oldline = get_cursor_line_ptr();
|
||||
int todo = size;
|
||||
int ind_len = 0; // Measured in characters.
|
||||
char *p = oldline = get_cursor_line_ptr();
|
||||
|
||||
// Calculate the buffer size for the new indent, and check to see if it
|
||||
// isn't already set.
|
||||
@ -560,7 +549,7 @@ int set_indent(int size, int flags)
|
||||
} else {
|
||||
p = skipwhite(p);
|
||||
}
|
||||
line_len = (int)strlen(p) + 1;
|
||||
int line_len = (int)strlen(p) + 1;
|
||||
|
||||
// If 'preserveindent' and 'expandtab' are both set keep the original
|
||||
// characters and allocate accordingly. We will fill the rest with spaces
|
||||
@ -933,23 +922,18 @@ static void emsg_text_too_long(void)
|
||||
/// ":retab".
|
||||
void ex_retab(exarg_T *eap)
|
||||
{
|
||||
linenr_T lnum;
|
||||
bool got_tab = false;
|
||||
int num_spaces = 0;
|
||||
int num_tabs;
|
||||
int len;
|
||||
int start_col = 0; // For start of white-space string
|
||||
int64_t start_vcol = 0; // For start of white-space string
|
||||
int old_len;
|
||||
char *new_line = (char *)1; // init to non-NULL
|
||||
colnr_T *new_vts_array = NULL;
|
||||
char *new_ts_str; // string value of tab argument
|
||||
|
||||
int save_list;
|
||||
linenr_T first_line = 0; // first changed line
|
||||
linenr_T last_line = 0; // last changed line
|
||||
|
||||
save_list = curwin->w_p_list;
|
||||
int save_list = curwin->w_p_list;
|
||||
curwin->w_p_list = 0; // don't want list mode here
|
||||
|
||||
new_ts_str = eap->arg;
|
||||
@ -969,7 +953,7 @@ void ex_retab(exarg_T *eap)
|
||||
} else {
|
||||
new_ts_str = xmemdupz(new_ts_str, (size_t)(eap->arg - new_ts_str));
|
||||
}
|
||||
for (lnum = eap->line1; !got_int && lnum <= eap->line2; lnum++) {
|
||||
for (linenr_T lnum = eap->line1; !got_int && lnum <= eap->line2; lnum++) {
|
||||
char *ptr = ml_get(lnum);
|
||||
int col = 0;
|
||||
int64_t vcol = 0;
|
||||
@ -991,8 +975,8 @@ void ex_retab(exarg_T *eap)
|
||||
// Retabulate this string of white-space
|
||||
|
||||
// len is virtual length of white string
|
||||
len = num_spaces = (int)(vcol - start_vcol);
|
||||
num_tabs = 0;
|
||||
int len = num_spaces = (int)(vcol - start_vcol);
|
||||
int num_tabs = 0;
|
||||
if (!curbuf->b_p_et) {
|
||||
int t, s;
|
||||
|
||||
@ -1014,7 +998,7 @@ void ex_retab(exarg_T *eap)
|
||||
|
||||
// len is actual number of white characters used
|
||||
len = num_spaces + num_tabs;
|
||||
old_len = (int)strlen(ptr);
|
||||
int old_len = (int)strlen(ptr);
|
||||
const int new_len = old_len - col + start_col + len + 1;
|
||||
if (new_len <= 0 || new_len >= MAXCOL) {
|
||||
emsg_text_too_long();
|
||||
@ -1110,19 +1094,14 @@ void ex_retab(exarg_T *eap)
|
||||
/// Get indent level from 'indentexpr'.
|
||||
int get_expr_indent(void)
|
||||
{
|
||||
int indent = -1;
|
||||
pos_T save_pos;
|
||||
colnr_T save_curswant;
|
||||
int save_set_curswant;
|
||||
int save_State;
|
||||
int use_sandbox = was_set_insecurely(curwin, kOptIndentexpr, OPT_LOCAL);
|
||||
const sctx_T save_sctx = current_sctx;
|
||||
|
||||
// Save and restore cursor position and curswant, in case it was changed
|
||||
// * via :normal commands.
|
||||
save_pos = curwin->w_cursor;
|
||||
save_curswant = curwin->w_curswant;
|
||||
save_set_curswant = curwin->w_set_curswant;
|
||||
pos_T save_pos = curwin->w_cursor;
|
||||
colnr_T save_curswant = curwin->w_curswant;
|
||||
int save_set_curswant = curwin->w_set_curswant;
|
||||
set_vim_var_nr(VV_LNUM, (varnumber_T)curwin->w_cursor.lnum);
|
||||
|
||||
if (use_sandbox) {
|
||||
@ -1134,7 +1113,7 @@ int get_expr_indent(void)
|
||||
// Need to make a copy, the 'indentexpr' option could be changed while
|
||||
// evaluating it.
|
||||
char *inde_copy = xstrdup(curbuf->b_p_inde);
|
||||
indent = (int)eval_to_number(inde_copy);
|
||||
int indent = (int)eval_to_number(inde_copy);
|
||||
xfree(inde_copy);
|
||||
|
||||
if (use_sandbox) {
|
||||
@ -1146,7 +1125,7 @@ int get_expr_indent(void)
|
||||
// Restore the cursor position so that 'indentexpr' doesn't need to.
|
||||
// Pretend to be in Insert mode, allow cursor past end of line for "o"
|
||||
// command.
|
||||
save_State = State;
|
||||
int save_State = State;
|
||||
State = MODE_INSERT;
|
||||
curwin->w_cursor = save_pos;
|
||||
curwin->w_curswant = save_curswant;
|
||||
@ -1187,7 +1166,6 @@ int get_lisp_indent(void)
|
||||
pos_T *pos;
|
||||
pos_T paren;
|
||||
int amount;
|
||||
char *that;
|
||||
|
||||
// Set vi_lisp to use the vi-compatible method.
|
||||
int vi_lisp = (vim_strchr(p_cpo, CPO_LISP) != NULL);
|
||||
@ -1217,7 +1195,7 @@ int get_lisp_indent(void)
|
||||
continue;
|
||||
}
|
||||
|
||||
for (that = get_cursor_line_ptr(); *that != NUL; that++) {
|
||||
for (char *that = get_cursor_line_ptr(); *that != NUL; that++) {
|
||||
if (*that == ';') {
|
||||
while (*(that + 1) != NUL) {
|
||||
that++;
|
||||
@ -1267,7 +1245,7 @@ int get_lisp_indent(void)
|
||||
curwin->w_cursor.col = pos->col;
|
||||
colnr_T col = pos->col;
|
||||
|
||||
that = get_cursor_line_ptr();
|
||||
char *that = get_cursor_line_ptr();
|
||||
|
||||
if (vi_lisp && (get_indent() == 0)) {
|
||||
amount = 2;
|
||||
|
@ -597,7 +597,6 @@ static char *ins_compl_infercase_gettext(const char *str, int char_len, int comp
|
||||
int min_len, char **tofree)
|
||||
{
|
||||
bool has_lower = false;
|
||||
bool was_letter = false;
|
||||
|
||||
// Allocate wide character array for the completion and fill it.
|
||||
int *const wca = xmalloc((size_t)char_len * sizeof(*wca));
|
||||
@ -629,6 +628,7 @@ static char *ins_compl_infercase_gettext(const char *str, int char_len, int comp
|
||||
// Rule 2: No lower case, 2nd consecutive letter converted to
|
||||
// upper case.
|
||||
if (!has_lower) {
|
||||
bool was_letter = false;
|
||||
const char *p = compl_orig_text;
|
||||
for (int i = 0; i < min_len; i++) {
|
||||
const int c = mb_ptr2char_adv(&p);
|
||||
|
@ -1058,7 +1058,8 @@ char *vim_strsave_escape_ks(char *p)
|
||||
/// vim_strsave_escape_ks(). Works in-place.
|
||||
void vim_unescape_ks(char *p)
|
||||
{
|
||||
uint8_t *s = (uint8_t *)p, *d = (uint8_t *)p;
|
||||
uint8_t *s = (uint8_t *)p;
|
||||
uint8_t *d = (uint8_t *)p;
|
||||
|
||||
while (*s != NUL) {
|
||||
if (s[0] == K_SPECIAL && s[1] == KS_SPECIAL && s[2] == KE_FILLER) {
|
||||
|
@ -82,7 +82,8 @@ static int regex_match_line(lua_State *lstate)
|
||||
|
||||
handle_T bufnr = (handle_T)luaL_checkinteger(lstate, 2);
|
||||
linenr_T rownr = (linenr_T)luaL_checkinteger(lstate, 3);
|
||||
int start = 0, end = -1;
|
||||
int start = 0;
|
||||
int end = -1;
|
||||
if (narg >= 4) {
|
||||
start = (int)luaL_checkinteger(lstate, 4);
|
||||
}
|
||||
@ -177,7 +178,8 @@ int nlua_str_utfindex(lua_State *const lstate) FUNC_ATTR_NONNULL_ALL
|
||||
}
|
||||
}
|
||||
|
||||
size_t codepoints = 0, codeunits = 0;
|
||||
size_t codepoints = 0;
|
||||
size_t codeunits = 0;
|
||||
mb_utflen(s1, (size_t)idx, &codepoints, &codeunits);
|
||||
|
||||
lua_pushinteger(lstate, (lua_Integer)codepoints);
|
||||
|
@ -74,7 +74,8 @@ static void get_linematch_results(lua_State *lstate, mmfile_t *ma, mmfile_t *mb,
|
||||
int *decisions = NULL;
|
||||
size_t decisions_length = linematch_nbuffers(diff_begin, diff_length, 2, &decisions, iwhite);
|
||||
|
||||
int lnuma = start_a, lnumb = start_b;
|
||||
int lnuma = start_a;
|
||||
int lnumb = start_b;
|
||||
|
||||
int hunkstarta = lnuma;
|
||||
int hunkstartb = lnumb;
|
||||
|
@ -146,7 +146,8 @@ static inline int marktree_getp_aux(const MTNode *x, MTKey k, bool *match)
|
||||
bool dummy_match;
|
||||
bool *m = match ? match : &dummy_match;
|
||||
|
||||
int begin = 0, end = x->n;
|
||||
int begin = 0;
|
||||
int end = x->n;
|
||||
if (x->n == 0) {
|
||||
*m = false;
|
||||
return -1;
|
||||
@ -303,7 +304,8 @@ void marktree_put(MarkTree *b, MTKey key, int end_row, int end_col, bool end_rig
|
||||
|(uint16_t)(end_right ? MT_FLAG_RIGHT_GRAVITY : 0));
|
||||
end_key.pos = (MTPos){ end_row, end_col };
|
||||
marktree_put_key(b, end_key);
|
||||
MarkTreeIter itr[1] = { 0 }, end_itr[1] = { 0 };
|
||||
MarkTreeIter itr[1] = { 0 };
|
||||
MarkTreeIter end_itr[1] = { 0 };
|
||||
marktree_lookup(b, mt_lookup_key(key), itr);
|
||||
marktree_lookup(b, mt_lookup_key(end_key), end_itr);
|
||||
|
||||
@ -684,8 +686,10 @@ uint64_t marktree_del_itr(MarkTree *b, MarkTreeIter *itr, bool rev)
|
||||
static void intersect_merge(Intersection *restrict m, Intersection *restrict x,
|
||||
Intersection *restrict y)
|
||||
{
|
||||
size_t xi = 0, yi = 0;
|
||||
size_t xn = 0, yn = 0;
|
||||
size_t xi = 0;
|
||||
size_t yi = 0;
|
||||
size_t xn = 0;
|
||||
size_t yn = 0;
|
||||
while (xi < kv_size(*x) && yi < kv_size(*y)) {
|
||||
if (kv_A(*x, xi) == kv_A(*y, yi)) {
|
||||
// TODO(bfredl): kvi_pushp is actually quite complex, break out kvi_resize() to a function?
|
||||
@ -717,8 +721,10 @@ static void intersect_merge(Intersection *restrict m, Intersection *restrict x,
|
||||
static void intersect_mov(Intersection *restrict x, Intersection *restrict y,
|
||||
Intersection *restrict w, Intersection *restrict d)
|
||||
{
|
||||
size_t wi = 0, yi = 0;
|
||||
size_t wn = 0, yn = 0;
|
||||
size_t wi = 0;
|
||||
size_t yi = 0;
|
||||
size_t wn = 0;
|
||||
size_t yn = 0;
|
||||
size_t xi = 0;
|
||||
while (wi < kv_size(*w) || xi < kv_size(*x)) {
|
||||
if (wi < kv_size(*w) && (xi >= kv_size(*x) || kv_A(*x, xi) >= kv_A(*w, wi))) {
|
||||
@ -810,7 +816,8 @@ bool intersect_mov_test(const uint64_t *x, size_t nx, const uint64_t *y, size_t
|
||||
/// intersection: i = x & y
|
||||
static void intersect_common(Intersection *i, Intersection *x, Intersection *y)
|
||||
{
|
||||
size_t xi = 0, yi = 0;
|
||||
size_t xi = 0;
|
||||
size_t yi = 0;
|
||||
while (xi < kv_size(*x) && yi < kv_size(*y)) {
|
||||
if (kv_A(*x, xi) == kv_A(*y, yi)) {
|
||||
kvi_push(*i, kv_A(*x, xi));
|
||||
@ -827,7 +834,8 @@ static void intersect_common(Intersection *i, Intersection *x, Intersection *y)
|
||||
// inplace union: x |= y
|
||||
static void intersect_add(Intersection *x, Intersection *y)
|
||||
{
|
||||
size_t xi = 0, yi = 0;
|
||||
size_t xi = 0;
|
||||
size_t yi = 0;
|
||||
while (xi < kv_size(*x) && yi < kv_size(*y)) {
|
||||
if (kv_A(*x, xi) == kv_A(*y, yi)) {
|
||||
xi++;
|
||||
@ -854,7 +862,8 @@ static void intersect_add(Intersection *x, Intersection *y)
|
||||
// inplace asymmetric difference: x &= ~y
|
||||
static void intersect_sub(Intersection *restrict x, Intersection *restrict y)
|
||||
{
|
||||
size_t xi = 0, yi = 0;
|
||||
size_t xi = 0;
|
||||
size_t yi = 0;
|
||||
size_t xn = 0;
|
||||
while (xi < kv_size(*x) && yi < kv_size(*y)) {
|
||||
if (kv_A(*x, xi) == kv_A(*y, yi)) {
|
||||
@ -898,7 +907,8 @@ static void bubble_up(MTNode *x)
|
||||
|
||||
static MTNode *merge_node(MarkTree *b, MTNode *p, int i)
|
||||
{
|
||||
MTNode *x = p->ptr[i], *y = p->ptr[i + 1];
|
||||
MTNode *x = p->ptr[i];
|
||||
MTNode *y = p->ptr[i + 1];
|
||||
Intersection m;
|
||||
kvi_init(m);
|
||||
|
||||
@ -975,7 +985,8 @@ void kvi_move(Intersection *dest, Intersection *src)
|
||||
// key inside x, if x is the first leaf)
|
||||
static void pivot_right(MarkTree *b, MTPos p_pos, MTNode *p, const int i)
|
||||
{
|
||||
MTNode *x = p->ptr[i], *y = p->ptr[i + 1];
|
||||
MTNode *x = p->ptr[i];
|
||||
MTNode *y = p->ptr[i + 1];
|
||||
memmove(&y->key[1], y->key, (size_t)y->n * sizeof(MTKey));
|
||||
if (y->level) {
|
||||
memmove(&y->ptr[1], y->ptr, ((size_t)y->n + 1) * sizeof(MTNode *));
|
||||
@ -1040,7 +1051,8 @@ static void pivot_right(MarkTree *b, MTPos p_pos, MTNode *p, const int i)
|
||||
|
||||
static void pivot_left(MarkTree *b, MTPos p_pos, MTNode *p, int i)
|
||||
{
|
||||
MTNode *x = p->ptr[i], *y = p->ptr[i + 1];
|
||||
MTNode *x = p->ptr[i];
|
||||
MTNode *y = p->ptr[i + 1];
|
||||
|
||||
// reverse from how we "always" do it. but pivot_left
|
||||
// is just the inverse of pivot_right, so reverse it literally.
|
||||
@ -1603,7 +1615,8 @@ static void swap_keys(MarkTree *b, MarkTreeIter *itr1, MarkTreeIter *itr2, Damag
|
||||
|
||||
static int damage_cmp(const void *s1, const void *s2)
|
||||
{
|
||||
Damage *d1 = (Damage *)s1, *d2 = (Damage *)s2;
|
||||
Damage *d1 = (Damage *)s1;
|
||||
Damage *d2 = (Damage *)s2;
|
||||
assert(d1->id != d2->id);
|
||||
return d1->id > d2->id ? 1 : -1;
|
||||
}
|
||||
@ -1619,7 +1632,8 @@ bool marktree_splice(MarkTree *b, int32_t start_line, int start_col, int old_ext
|
||||
bool same_line = old_extent.row == 0 && new_extent.row == 0;
|
||||
unrelative(start, &old_extent);
|
||||
unrelative(start, &new_extent);
|
||||
MarkTreeIter itr[1] = { 0 }, enditr[1] = { 0 };
|
||||
MarkTreeIter itr[1] = { 0 };
|
||||
MarkTreeIter enditr[1] = { 0 };
|
||||
|
||||
MTPos oldbase[MT_MAX_DEPTH] = { 0 };
|
||||
|
||||
@ -1824,7 +1838,8 @@ past_continue_same_node:
|
||||
void marktree_move_region(MarkTree *b, int start_row, colnr_T start_col, int extent_row,
|
||||
colnr_T extent_col, int new_row, colnr_T new_col)
|
||||
{
|
||||
MTPos start = { start_row, start_col }, size = { extent_row, extent_col };
|
||||
MTPos start = { start_row, start_col };
|
||||
MTPos size = { extent_row, extent_col };
|
||||
MTPos end = size;
|
||||
unrelative(start, &end);
|
||||
MarkTreeIter itr[1] = { 0 };
|
||||
|
@ -1422,7 +1422,8 @@ int utf16_to_utf8(const wchar_t *utf16, int utf16len, char **utf8)
|
||||
void mb_utflen(const char *s, size_t len, size_t *codepoints, size_t *codeunits)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
size_t count = 0, extra = 0;
|
||||
size_t count = 0;
|
||||
size_t extra = 0;
|
||||
size_t clen;
|
||||
for (size_t i = 0; i < len; i += clen) {
|
||||
clen = (size_t)utf_ptr2len_len(s + i, (int)(len - i));
|
||||
|
@ -286,7 +286,8 @@ void strchrsub(char *str, char c, char x)
|
||||
void memchrsub(void *data, char c, char x, size_t len)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
char *p = data, *end = (char *)data + len;
|
||||
char *p = data;
|
||||
char *end = (char *)data + len;
|
||||
while ((p = memchr(p, c, (size_t)(end - p)))) {
|
||||
*p++ = x;
|
||||
}
|
||||
@ -321,7 +322,8 @@ size_t memcnt(const void *data, char c, size_t len)
|
||||
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_PURE
|
||||
{
|
||||
size_t cnt = 0;
|
||||
const char *ptr = data, *end = ptr + len;
|
||||
const char *ptr = data;
|
||||
const char *end = ptr + len;
|
||||
while ((ptr = memchr(ptr, c, (size_t)(end - ptr))) != NULL) {
|
||||
cnt++;
|
||||
ptr++; // Skip the instance of c.
|
||||
|
@ -1037,7 +1037,9 @@ void curs_columns(win_T *wp, int may_scroll)
|
||||
void textpos2screenpos(win_T *wp, pos_T *pos, int *rowp, int *scolp, int *ccolp, int *ecolp,
|
||||
bool local)
|
||||
{
|
||||
colnr_T scol = 0, ccol = 0, ecol = 0;
|
||||
colnr_T scol = 0;
|
||||
colnr_T ccol = 0;
|
||||
colnr_T ecol = 0;
|
||||
int row = 0;
|
||||
colnr_T coloff = 0;
|
||||
bool visible_row = false;
|
||||
@ -1129,7 +1131,9 @@ void f_screenpos(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
pos.col = 0;
|
||||
}
|
||||
int row = 0;
|
||||
int scol = 0, ccol = 0, ecol = 0;
|
||||
int scol = 0;
|
||||
int ccol = 0;
|
||||
int ecol = 0;
|
||||
textpos2screenpos(wp, &pos, &row, &scol, &ccol, &ecol, false);
|
||||
|
||||
tv_dict_add_nr(dict, S_LEN("row"), row);
|
||||
|
@ -390,7 +390,8 @@ static void shift_block(oparg_T *oap, int amount)
|
||||
bd.start_vcol = cts.cts_vcol;
|
||||
clear_chartabsize_arg(&cts);
|
||||
|
||||
int tabs = 0, spaces = 0;
|
||||
int tabs = 0;
|
||||
int spaces = 0;
|
||||
// OK, now total=all the VWS reqd, and textstart points at the 1st
|
||||
// non-ws char in the block.
|
||||
if (!curbuf->b_p_et) {
|
||||
@ -1891,7 +1892,8 @@ static int op_replace(oparg_T *oap, int c)
|
||||
size_t after_p_len = 0;
|
||||
int col = oldlen - bd.textcol - bd.textlen + 1;
|
||||
assert(col >= 0);
|
||||
int newrows = 0, newcols = 0;
|
||||
int newrows = 0;
|
||||
int newcols = 0;
|
||||
if (had_ctrl_v_cr || (c != '\r' && c != '\n')) {
|
||||
// strlen(newp) at this point
|
||||
int newp_len = bd.textcol + bd.startspaces;
|
||||
@ -2040,11 +2042,9 @@ void op_tilde(oparg_T *oap)
|
||||
pos_T pos = oap->start;
|
||||
if (oap->motion_type == kMTBlockWise) { // Visual block mode
|
||||
for (; pos.lnum <= oap->end.lnum; pos.lnum++) {
|
||||
int one_change;
|
||||
|
||||
block_prep(oap, &bd, pos.lnum, false);
|
||||
pos.col = bd.textcol;
|
||||
one_change = swapchars(oap->op_type, &pos, bd.textlen);
|
||||
int one_change = swapchars(oap->op_type, &pos, bd.textlen);
|
||||
did_change |= one_change;
|
||||
}
|
||||
if (did_change) {
|
||||
@ -2636,7 +2636,8 @@ static void op_yank_reg(oparg_T *oap, bool message, yankreg_T *reg, bool append)
|
||||
break;
|
||||
|
||||
case kMTCharWise: {
|
||||
colnr_T startcol = 0, endcol = MAXCOL;
|
||||
colnr_T startcol = 0;
|
||||
colnr_T endcol = MAXCOL;
|
||||
int is_oneChar = false;
|
||||
colnr_T cs, ce;
|
||||
char *p = ml_get(lnum);
|
||||
@ -2685,8 +2686,7 @@ static void op_yank_reg(oparg_T *oap, bool message, yankreg_T *reg, bool append)
|
||||
if (endcol == MAXCOL) {
|
||||
endcol = (colnr_T)strlen(p);
|
||||
}
|
||||
if (startcol > endcol
|
||||
|| is_oneChar) {
|
||||
if (startcol > endcol || is_oneChar) {
|
||||
bd.textlen = 0;
|
||||
} else {
|
||||
bd.textlen = endcol - startcol + oap->inclusive;
|
||||
|
@ -2815,7 +2815,8 @@ static const char *set_chars_option(win_T *wp, const char *value, const bool is_
|
||||
if (c1 == 0 || char2cells(c1) > 1) {
|
||||
return e_invarg;
|
||||
}
|
||||
int c2 = 0, c3 = 0;
|
||||
int c2 = 0;
|
||||
int c3 = 0;
|
||||
if (tab[i].cp == &lcs_chars.tab2) {
|
||||
if (*s == NUL) {
|
||||
return e_invarg;
|
||||
|
@ -415,7 +415,8 @@ static unsigned handle_mouse_event(const char **ptr, uint8_t *buf, unsigned bufs
|
||||
size_t input_enqueue_mouse(int code, uint8_t modifier, int grid, int row, int col)
|
||||
{
|
||||
modifier |= check_multiclick(code, grid, row, col);
|
||||
uint8_t buf[7], *p = buf;
|
||||
uint8_t buf[7];
|
||||
uint8_t *p = buf;
|
||||
if (modifier) {
|
||||
p[0] = K_SPECIAL;
|
||||
p[1] = KS_MODIFIER;
|
||||
|
@ -671,7 +671,8 @@ char *shell_argv_to_str(char **const argv)
|
||||
int os_call_shell(char *cmd, ShellOpts opts, char *extra_args)
|
||||
{
|
||||
DynamicBuffer input = DYNAMIC_BUFFER_INIT;
|
||||
char *output = NULL, **output_ptr = NULL;
|
||||
char *output = NULL;
|
||||
char **output_ptr = NULL;
|
||||
int current_state = State;
|
||||
bool forward_output = true;
|
||||
|
||||
@ -1123,7 +1124,8 @@ static void out_data_ring(char *output, size_t size)
|
||||
static void out_data_append_to_screen(char *output, size_t *count, bool eof)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
char *p = output, *end = output + *count;
|
||||
char *p = output;
|
||||
char *end = output + *count;
|
||||
while (p < end) {
|
||||
if (*p == '\n' || *p == '\r' || *p == TAB || *p == BELL) {
|
||||
msg_putchar_attr((uint8_t)(*p), 0);
|
||||
@ -1236,7 +1238,8 @@ static size_t word_length(const char *str)
|
||||
/// before we finish writing.
|
||||
static void read_input(DynamicBuffer *buf)
|
||||
{
|
||||
size_t written = 0, len = 0;
|
||||
size_t written = 0;
|
||||
size_t len = 0;
|
||||
linenr_T lnum = curbuf->b_op_start.lnum;
|
||||
char *lp = ml_get(lnum);
|
||||
|
||||
|
@ -1358,9 +1358,13 @@ int vim_vsnprintf_typval(char *str, size_t str_m, const char *fmt, va_list ap_st
|
||||
assert(n <= SIZE_MAX - str_l);
|
||||
str_l += n;
|
||||
} else {
|
||||
size_t min_field_width = 0, precision = 0;
|
||||
int zero_padding = 0, precision_specified = 0, justify_left = 0;
|
||||
int alternate_form = 0, force_sign = 0;
|
||||
size_t min_field_width = 0;
|
||||
size_t precision = 0;
|
||||
int zero_padding = 0;
|
||||
int precision_specified = 0;
|
||||
int justify_left = 0;
|
||||
int alternate_form = 0;
|
||||
int force_sign = 0;
|
||||
|
||||
// if both ' ' and '+' flags appear, ' ' flag should be ignored
|
||||
int space_for_positive = 1;
|
||||
|
@ -279,13 +279,12 @@ void terminal_open(Terminal **termpp, buf_T *buf, TerminalOptions opts)
|
||||
// - g:terminal_color_{NUM}
|
||||
// - the VTerm instance
|
||||
for (int i = 0; i < 16; i++) {
|
||||
RgbValue color_val = -1;
|
||||
char var[64];
|
||||
snprintf(var, sizeof(var), "terminal_color_%d", i);
|
||||
char *name = get_config_string(var);
|
||||
if (name) {
|
||||
int dummy;
|
||||
color_val = name_to_color(name, &dummy);
|
||||
RgbValue color_val = name_to_color(name, &dummy);
|
||||
xfree(name);
|
||||
|
||||
if (color_val != -1) {
|
||||
@ -390,7 +389,8 @@ void terminal_check_size(Terminal *term)
|
||||
|
||||
int curwidth, curheight;
|
||||
vterm_get_size(term->vt, &curheight, &curwidth);
|
||||
uint16_t width = 0, height = 0;
|
||||
uint16_t width = 0;
|
||||
uint16_t height = 0;
|
||||
|
||||
// Check if there is a window that displays the terminal and find the maximum width and height.
|
||||
// Skip the autocommand window which isn't actually displayed.
|
||||
@ -1430,7 +1430,9 @@ static void mouse_action(Terminal *term, int button, int row, int col, bool pres
|
||||
// terminal should lose focus
|
||||
static bool send_mouse_event(Terminal *term, int c)
|
||||
{
|
||||
int row = mouse_row, col = mouse_col, grid = mouse_grid;
|
||||
int row = mouse_row;
|
||||
int col = mouse_col;
|
||||
int grid = mouse_grid;
|
||||
win_T *mouse_win = mouse_find_win(&grid, &row, &col);
|
||||
if (mouse_win == NULL) {
|
||||
goto end;
|
||||
|
@ -1223,8 +1223,10 @@ void tui_grid_scroll(TUIData *tui, Integer g, Integer startrow, Integer endrow,
|
||||
Integer endcol, Integer rows, Integer cols FUNC_ATTR_UNUSED)
|
||||
{
|
||||
UGrid *grid = &tui->grid;
|
||||
int top = (int)startrow, bot = (int)endrow - 1;
|
||||
int left = (int)startcol, right = (int)endcol - 1;
|
||||
int top = (int)startrow;
|
||||
int bot = (int)endrow - 1;
|
||||
int left = (int)startcol;
|
||||
int right = (int)endcol - 1;
|
||||
|
||||
bool fullwidth = left == 0 && right == tui->width - 1;
|
||||
tui->scroll_region_is_full_screen = fullwidth
|
||||
@ -1565,7 +1567,8 @@ static void invalidate(TUIData *tui, int top, int bot, int left, int right)
|
||||
/// application (i.e., the host terminal).
|
||||
void tui_guess_size(TUIData *tui)
|
||||
{
|
||||
int width = 0, height = 0;
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
|
||||
// 1 - try from a system call(ioctl/TIOCGWINSZ on unix)
|
||||
if (tui->out_isatty
|
||||
|
@ -198,7 +198,8 @@ void ui_refresh(void)
|
||||
return;
|
||||
}
|
||||
|
||||
int width = INT_MAX, height = INT_MAX;
|
||||
int width = INT_MAX;
|
||||
int height = INT_MAX;
|
||||
bool ext_widgets[kUIExtCount];
|
||||
for (UIExtension i = 0; (int)i < kUIExtCount; i++) {
|
||||
ext_widgets[i] = true;
|
||||
|
@ -203,7 +203,9 @@ void ui_client_event_grid_line(Array args)
|
||||
|
||||
void ui_client_event_raw_line(GridLineEvent *g)
|
||||
{
|
||||
int grid = g->args[0], row = g->args[1], startcol = g->args[2];
|
||||
int grid = g->args[0];
|
||||
int row = g->args[1];
|
||||
int startcol = g->args[2];
|
||||
Integer endcol = startcol + g->coloff;
|
||||
Integer clearcol = endcol + g->clear_width;
|
||||
LineFlags lineflags = g->wrap ? kLineFlagWrap : 0;
|
||||
|
@ -305,7 +305,8 @@ static void compose_line(Integer row, Integer startcol, Integer endcol, LineFlag
|
||||
startcol = MAX(startcol, 0);
|
||||
// in case we start on the right half of a double-width char, we need to
|
||||
// check the left half. But skip it in output if it wasn't doublewidth.
|
||||
int skipstart = 0, skipend = 0;
|
||||
int skipstart = 0;
|
||||
int skipend = 0;
|
||||
if (startcol > 0 && (flags & kLineFlagInvalid)) {
|
||||
startcol--;
|
||||
skipstart = 1;
|
||||
|
@ -963,12 +963,11 @@ static u_header_T *unserialize_uhp(bufinfo_T *bi, const char *file_name)
|
||||
}
|
||||
|
||||
// Unserialize all extmark undo information
|
||||
ExtmarkUndoObject *extup;
|
||||
kv_init(uhp->uh_extmark);
|
||||
|
||||
while ((c = undo_read_2c(bi)) == UF_ENTRY_MAGIC) {
|
||||
bool error = false;
|
||||
extup = unserialize_extmark(bi, &error, file_name);
|
||||
ExtmarkUndoObject *extup = unserialize_extmark(bi, &error, file_name);
|
||||
if (error) {
|
||||
kv_destroy(uhp->uh_extmark);
|
||||
xfree(extup);
|
||||
@ -1553,7 +1552,9 @@ void u_read_undo(char *name, const uint8_t *hash, const char *orig_name FUNC_ATT
|
||||
// We have put all of the headers into a table. Now we iterate through the
|
||||
// table and swizzle each sequence number we have stored in uh_*_seq into
|
||||
// a pointer corresponding to the header with that sequence number.
|
||||
int16_t old_idx = -1, new_idx = -1, cur_idx = -1;
|
||||
int16_t old_idx = -1;
|
||||
int16_t new_idx = -1;
|
||||
int16_t cur_idx = -1;
|
||||
for (int i = 0; i < num_head; i++) {
|
||||
u_header_T *uhp = uhp_table[i];
|
||||
if (uhp == NULL) {
|
||||
|
@ -759,7 +759,8 @@ void ui_ext_win_position(win_T *wp, bool validate)
|
||||
FloatConfig c = wp->w_float_config;
|
||||
if (!c.external) {
|
||||
ScreenGrid *grid = &default_grid;
|
||||
Float row = c.row, col = c.col;
|
||||
Float row = c.row;
|
||||
Float col = c.col;
|
||||
if (c.relative == kFloatRelativeWindow) {
|
||||
Error dummy = ERROR_INIT;
|
||||
win_T *win = find_window_by_handle(c.window, &dummy);
|
||||
@ -771,7 +772,8 @@ void ui_ext_win_position(win_T *wp, bool validate)
|
||||
ui_ext_win_position(win, validate);
|
||||
}
|
||||
grid = &win->w_grid;
|
||||
int row_off = 0, col_off = 0;
|
||||
int row_off = 0;
|
||||
int col_off = 0;
|
||||
grid_adjust(&grid, &row_off, &col_off);
|
||||
row += row_off;
|
||||
col += col_off;
|
||||
@ -5463,7 +5465,8 @@ void may_trigger_win_scrolled_resized(void)
|
||||
}
|
||||
|
||||
int size_count = 0;
|
||||
win_T *first_scroll_win = NULL, *first_size_win = NULL;
|
||||
win_T *first_scroll_win = NULL;
|
||||
win_T *first_size_win = NULL;
|
||||
int cwsr = check_window_scroll_resize(&size_count,
|
||||
&first_scroll_win, &first_size_win,
|
||||
NULL, NULL);
|
||||
@ -7404,7 +7407,8 @@ void win_get_tabwin(handle_T id, int *tabnr, int *winnr)
|
||||
*tabnr = 0;
|
||||
*winnr = 0;
|
||||
|
||||
int tnum = 1, wnum = 1;
|
||||
int tnum = 1;
|
||||
int wnum = 1;
|
||||
FOR_ALL_TABS(tp) {
|
||||
FOR_ALL_WINDOWS_IN_TAB(wp, tp) {
|
||||
if (wp->handle == id) {
|
||||
|
@ -146,7 +146,9 @@ void win_config_float(win_T *wp, FloatConfig fconfig)
|
||||
fconfig.col += curwin->w_wcol;
|
||||
fconfig.window = curwin->handle;
|
||||
} else if (fconfig.relative == kFloatRelativeMouse) {
|
||||
int row = mouse_row, col = mouse_col, grid = mouse_grid;
|
||||
int row = mouse_row;
|
||||
int col = mouse_col;
|
||||
int grid = mouse_grid;
|
||||
win_T *mouse_win = mouse_find_win(&grid, &row, &col);
|
||||
if (mouse_win != NULL) {
|
||||
fconfig.relative = kFloatRelativeWindow;
|
||||
@ -197,7 +199,8 @@ void win_config_float(win_T *wp, FloatConfig fconfig)
|
||||
row += parent->w_winrow;
|
||||
col += parent->w_wincol;
|
||||
ScreenGrid *grid = &parent->w_grid;
|
||||
int row_off = 0, col_off = 0;
|
||||
int row_off = 0;
|
||||
int col_off = 0;
|
||||
grid_adjust(&grid, &row_off, &col_off);
|
||||
row += row_off;
|
||||
col += col_off;
|
||||
|
Loading…
Reference in New Issue
Block a user