diff options
author | Dundar Goc <gocdundar@gmail.com> | 2022-04-29 13:53:42 +0200 |
---|---|---|
committer | Dundar Goc <gocdundar@gmail.com> | 2022-04-29 14:13:06 +0200 |
commit | eef8de4df0247157e57f306062b1b86e01a41454 (patch) | |
tree | 949a172d60f0f58e04f99e18db038c435a909825 | |
parent | 0b3ae64480ea28bb57783c2269a61f0a60ffc55e (diff) | |
download | rneovim-eef8de4df0247157e57f306062b1b86e01a41454.tar.gz rneovim-eef8de4df0247157e57f306062b1b86e01a41454.tar.bz2 rneovim-eef8de4df0247157e57f306062b1b86e01a41454.zip |
refactor(uncrustify): change rules to better align with the style guide
Add space around arithmetic operators '+' and '-'.
Remove space between back-to-back parentheses, i.e. ')(' vs. ') ('.
Remove space between '((' or '))' of control statements.
Add space between ')' and '{' of control statements.
Remove space between function name and '(' on function declaration.
Collapse empty blocks between '{' and '}'.
Remove newline at the end of the file.
Remove newline between 'enum' and '{'.
Remove newline between '}' and ')' in a function invocation.
Remove newline between '}' and 'while' of 'do' statement.
91 files changed, 583 insertions, 682 deletions
diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c index 0c68325f40..9b21608ce9 100644 --- a/src/nvim/api/buffer.c +++ b/src/nvim/api/buffer.c @@ -247,7 +247,7 @@ void nvim__buf_redraw_range(Buffer buffer, Integer first, Integer last, Error *e return; } - redraw_buf_range_later(buf, (linenr_T)first+1, (linenr_T)last); + redraw_buf_range_later(buf, (linenr_T)first + 1, (linenr_T)last); } /// Gets a line-range from the buffer. @@ -495,7 +495,7 @@ void nvim_buf_set_lines(uint64_t channel_id, Buffer buffer, Integer start, Integ (long)extra, kExtmarkNOOP); - extmark_splice(curbuf, (int)start-1, 0, (int)(end-start), 0, + extmark_splice(curbuf, (int)start - 1, 0, (int)(end - start), 0, deleted_bytes, (int)new_len, 0, inserted_bytes, kExtmarkUndo); @@ -602,15 +602,15 @@ void nvim_buf_set_text(uint64_t channel_id, Buffer buffer, Integer start_row, In int64_t lnum = start_row + i; const char *bufline = (char *)ml_get_buf(buf, lnum, false); - old_byte += (bcount_t)(strlen(bufline))+1; + old_byte += (bcount_t)(strlen(bufline)) + 1; } - old_byte += (bcount_t)end_col+1; + old_byte += (bcount_t)end_col + 1; } String first_item = replacement.items[0].data.string; - String last_item = replacement.items[replacement.size-1].data.string; + String last_item = replacement.items[replacement.size - 1].data.string; - size_t firstlen = (size_t)start_col+first_item.size; + size_t firstlen = (size_t)start_col + first_item.size; size_t last_part_len = strlen(str_at_end) - (size_t)end_col; if (replacement.size == 1) { firstlen += last_part_len; @@ -618,32 +618,32 @@ void nvim_buf_set_text(uint64_t channel_id, Buffer buffer, Integer start_row, In char *first = xmallocz(firstlen); char *last = NULL; memcpy(first, str_at_start, (size_t)start_col); - memcpy(first+start_col, first_item.data, first_item.size); - memchrsub(first+start_col, NUL, NL, first_item.size); + memcpy(first + start_col, first_item.data, first_item.size); + memchrsub(first + start_col, NUL, NL, first_item.size); if (replacement.size == 1) { - memcpy(first+start_col+first_item.size, str_at_end+end_col, last_part_len); + memcpy(first + start_col + first_item.size, str_at_end + end_col, last_part_len); } else { - last = xmallocz(last_item.size+last_part_len); + last = xmallocz(last_item.size + last_part_len); memcpy(last, last_item.data, last_item.size); memchrsub(last, NUL, NL, last_item.size); - memcpy(last+last_item.size, str_at_end+end_col, last_part_len); + memcpy(last + last_item.size, str_at_end + end_col, last_part_len); } char **lines = xcalloc(new_len, sizeof(char *)); lines[0] = first; new_byte += (bcount_t)(first_item.size); - for (size_t i = 1; i < new_len-1; i++) { + for (size_t i = 1; i < new_len - 1; i++) { const String l = replacement.items[i].data.string; // Fill lines[i] with l's contents. Convert NULs to newlines as required by // NL-used-for-NUL. lines[i] = xmemdupz(l.data, l.size); memchrsub(lines[i], NUL, NL, l.size); - new_byte += (bcount_t)(l.size)+1; + new_byte += (bcount_t)(l.size) + 1; } if (replacement.size > 1) { - lines[replacement.size-1] = last; - new_byte += (bcount_t)(last_item.size)+1; + lines[replacement.size - 1] = last; + new_byte += (bcount_t)(last_item.size) + 1; } try_start(); @@ -663,7 +663,7 @@ void nvim_buf_set_text(uint64_t channel_id, Buffer buffer, Integer start_row, In } ptrdiff_t extra = 0; // lines added to text, can be negative - size_t old_len = (size_t)(end_row-start_row+1); + size_t old_len = (size_t)(end_row - start_row + 1); // If the size of the range is reducing (ie, new_len < old_len) we // need to delete some old_len. We do this at the start, by @@ -731,9 +731,9 @@ void nvim_buf_set_text(uint64_t channel_id, Buffer buffer, Integer start_row, In colnr_T col_extent = (colnr_T)(end_col - ((end_row == start_row) ? start_col : 0)); - extmark_splice(buf, (int)start_row-1, (colnr_T)start_col, - (int)(end_row-start_row), col_extent, old_byte, - (int)new_len-1, (colnr_T)last_item.size, new_byte, + extmark_splice(buf, (int)start_row - 1, (colnr_T)start_col, + (int)(end_row - start_row), col_extent, old_byte, + (int)new_len - 1, (colnr_T)last_item.size, new_byte, kExtmarkUndo); @@ -829,7 +829,7 @@ ArrayOf(String) nvim_buf_get_text(uint64_t channel_id, Buffer buffer, rv.size = (size_t)(end_row - start_row) + 1; rv.items = xcalloc(rv.size, sizeof(Object)); - rv.items[0] = STRING_OBJ(buf_get_text(buf, start_row, start_col, MAXCOL-1, replace_nl, err)); + rv.items[0] = STRING_OBJ(buf_get_text(buf, start_row, start_col, MAXCOL - 1, replace_nl, err)); if (ERROR_SET(err)) { goto end; } @@ -842,7 +842,7 @@ ArrayOf(String) nvim_buf_get_text(uint64_t channel_id, Buffer buffer, } } - rv.items[rv.size-1] = STRING_OBJ(buf_get_text(buf, end_row, 0, end_col, replace_nl, err)); + rv.items[rv.size - 1] = STRING_OBJ(buf_get_text(buf, end_row, 0, end_col, replace_nl, err)); if (ERROR_SET(err)) { goto end; } @@ -889,7 +889,7 @@ Integer nvim_buf_get_offset(Buffer buffer, Integer index, Error *err) return 0; } - return ml_find_line_or_offset(buf, (int)index+1, NULL, true); + return ml_find_line_or_offset(buf, (int)index + 1, NULL, true); } /// Gets a buffer-scoped (b:) variable. diff --git a/src/nvim/api/deprecated.c b/src/nvim/api/deprecated.c index 6a41df0aa9..f968593e47 100644 --- a/src/nvim/api/deprecated.c +++ b/src/nvim/api/deprecated.c @@ -192,7 +192,7 @@ String buffer_get_line(Buffer buffer, Integer index, Error *err) String rv = { .size = 0 }; index = convert_index(index); - Array slice = nvim_buf_get_lines(0, buffer, index, index+1, true, err); + Array slice = nvim_buf_get_lines(0, buffer, index, index + 1, true, err); if (!ERROR_SET(err) && slice.size) { rv = slice.items[0].data.string; @@ -221,7 +221,7 @@ void buffer_set_line(Buffer buffer, Integer index, String line, Error *err) Object l = STRING_OBJ(line); Array array = { .items = &l, .size = 1 }; index = convert_index(index); - nvim_buf_set_lines(0, buffer, index, index+1, true, array, err); + nvim_buf_set_lines(0, buffer, index, index + 1, true, array, err); } /// Deletes a buffer line @@ -239,7 +239,7 @@ void buffer_del_line(Buffer buffer, Integer index, Error *err) { Array array = ARRAY_DICT_INIT; index = convert_index(index); - nvim_buf_set_lines(0, buffer, index, index+1, true, array, err); + nvim_buf_set_lines(0, buffer, index, index + 1, true, array, err); } /// Retrieves a line range from the buffer diff --git a/src/nvim/api/extmark.c b/src/nvim/api/extmark.c index ff9c8f2d47..e408d88854 100644 --- a/src/nvim/api/extmark.c +++ b/src/nvim/api/extmark.c @@ -720,7 +720,7 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer line = buf->b_ml.ml_line_count; } } else if (line < buf->b_ml.ml_line_count) { - len = ephemeral ? MAXCOL : STRLEN(ml_get_buf(buf, (linenr_T)line+1, false)); + len = ephemeral ? MAXCOL : STRLEN(ml_get_buf(buf, (linenr_T)line + 1, false)); } if (col == -1) { @@ -927,7 +927,7 @@ void nvim_buf_clear_namespace(Buffer buffer, Integer ns_id, Integer line_start, } extmark_clear(buf, (ns_id < 0 ? 0 : (uint32_t)ns_id), (int)line_start, 0, - (int)line_end-1, MAXCOL); + (int)line_end - 1, MAXCOL); } /// Set or change decoration provider for a namespace diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c index 8383f29400..1c43564dca 100644 --- a/src/nvim/api/private/helpers.c +++ b/src/nvim/api/private/helpers.c @@ -1245,7 +1245,7 @@ VirtText parse_virt_text(Array chunks, Error *err, int *width) if (ERROR_SET(err)) { goto free_exit; } - if (j < arr.size-1) { + if (j < arr.size - 1) { kv_push(virt_text, ((VirtTextChunk){ .text = NULL, .hl_id = hl_id })); } diff --git a/src/nvim/api/tabpage.c b/src/nvim/api/tabpage.c index b994d18c43..b81fc3b7d7 100644 --- a/src/nvim/api/tabpage.c +++ b/src/nvim/api/tabpage.c @@ -150,4 +150,3 @@ Boolean nvim_tabpage_is_valid(Tabpage tabpage) api_clear_error(&stub); return ret; } - diff --git a/src/nvim/api/ui.c b/src/nvim/api/ui.c index 383c9c16ab..997f0c218a 100644 --- a/src/nvim/api/ui.c +++ b/src/nvim/api/ui.c @@ -475,9 +475,9 @@ static void remote_ui_grid_scroll(UI *ui, Integer grid, Integer top, Integer bot } else { Array args = ARRAY_DICT_INIT; ADD(args, INTEGER_OBJ(top)); - ADD(args, INTEGER_OBJ(bot-1)); + ADD(args, INTEGER_OBJ(bot - 1)); ADD(args, INTEGER_OBJ(left)); - ADD(args, INTEGER_OBJ(right-1)); + ADD(args, INTEGER_OBJ(right - 1)); push_call(ui, "set_scroll_region", args); args = (Array)ARRAY_DICT_INIT; @@ -488,9 +488,9 @@ static void remote_ui_grid_scroll(UI *ui, Integer grid, Integer top, Integer bot // so reset it. args = (Array)ARRAY_DICT_INIT; ADD(args, INTEGER_OBJ(0)); - ADD(args, INTEGER_OBJ(ui->height-1)); + ADD(args, INTEGER_OBJ(ui->height - 1)); ADD(args, INTEGER_OBJ(0)); - ADD(args, INTEGER_OBJ(ui->width-1)); + ADD(args, INTEGER_OBJ(ui->width - 1)); push_call(ui, "set_scroll_region", args); } } @@ -615,12 +615,12 @@ static void remote_ui_raw_line(UI *ui, Integer grid, Integer row, Integer startc ADD(args, INTEGER_OBJ(startcol)); Array cells = ARRAY_DICT_INIT; int repeat = 0; - size_t ncells = (size_t)(endcol-startcol); + size_t ncells = (size_t)(endcol - startcol); int last_hl = -1; for (size_t i = 0; i < ncells; i++) { repeat++; - if (i == ncells-1 || attrs[i] != attrs[i+1] - || STRCMP(chunk[i], chunk[i+1])) { + if (i == ncells - 1 || attrs[i] != attrs[i + 1] + || STRCMP(chunk[i], chunk[i + 1])) { Array cell = ARRAY_DICT_INIT; ADD(cell, STRING_OBJ(cstr_to_string((const char *)chunk[i]))); if (attrs[i] != last_hl || repeat > 1) { @@ -638,15 +638,15 @@ static void remote_ui_raw_line(UI *ui, Integer grid, Integer row, Integer startc Array cell = ARRAY_DICT_INIT; ADD(cell, STRING_OBJ(cstr_to_string(" "))); ADD(cell, INTEGER_OBJ(clearattr)); - ADD(cell, INTEGER_OBJ(clearcol-endcol)); + ADD(cell, INTEGER_OBJ(clearcol - endcol)); ADD(cells, ARRAY_OBJ(cell)); } ADD(args, ARRAY_OBJ(cells)); push_call(ui, "grid_line", args); } else { - for (int i = 0; i < endcol-startcol; i++) { - remote_ui_cursor_goto(ui, row, startcol+i); + for (int i = 0; i < endcol - startcol; i++) { + remote_ui_cursor_goto(ui, row, startcol + i); remote_ui_highlight_set(ui, attrs[i]); remote_ui_put(ui, (const char *)chunk[i]); if (utf_ambiguous_width(utf_ptr2char(chunk[i]))) { diff --git a/src/nvim/api/win_config.c b/src/nvim/api/win_config.c index 5e37596884..e7704f72d7 100644 --- a/src/nvim/api/win_config.c +++ b/src/nvim/api/win_config.c @@ -354,7 +354,7 @@ static void parse_border_style(Object style, FloatConfig *fconfig, Error *err) if (style.type == kObjectTypeArray) { Array arr = style.data.array; size_t size = arr.size; - if (!size || size > 8 || (size & (size-1))) { + if (!size || size > 8 || (size & (size - 1))) { api_set_error(err, kErrorTypeValidation, "invalid number of border chars"); return; @@ -392,7 +392,7 @@ static void parse_border_style(Object style, FloatConfig *fconfig, Error *err) "border chars must be one cell"); return; } - size_t len = MIN(string.size, sizeof(*chars)-1); + size_t len = MIN(string.size, sizeof(*chars) - 1); if (len) { memcpy(chars[i], string.data, len); } @@ -400,8 +400,8 @@ static void parse_border_style(Object style, FloatConfig *fconfig, Error *err) hl_ids[i] = hl_id; } while (size < 8) { - memcpy(chars+size, chars, sizeof(*chars) * size); - memcpy(hl_ids+size, hl_ids, sizeof(*hl_ids) * size); + memcpy(chars + size, chars, sizeof(*chars) * size); + memcpy(hl_ids + size, hl_ids, sizeof(*hl_ids) * size); size <<= 1; } if ((chars[7][0] && chars[1][0] && !chars[0][0]) diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c index a639364328..8830be7355 100644 --- a/src/nvim/autocmd.c +++ b/src/nvim/autocmd.c @@ -624,8 +624,7 @@ event_T event_name2nr(const char_u *start, char_u **end) int i; // the event name ends with end of line, '|', a blank or a comma - for (p = start; *p && !ascii_iswhite(*p) && *p != ',' && *p != '|'; p++) { - } + for (p = start; *p && !ascii_iswhite(*p) && *p != ',' && *p != '|'; p++) {} for (i = 0; event_names[i].name != NULL; i++) { int len = (int)event_names[i].len; if (len == p - start && STRNICMP(event_names[i].name, start, len) == 0) { @@ -2608,8 +2607,7 @@ static int arg_augroup_get(char_u **argp) char_u *arg = *argp; int group = AUGROUP_ALL; - for (p = arg; *p && !ascii_iswhite(*p) && *p != '|'; p++) { - } + for (p = arg; *p && !ascii_iswhite(*p) && *p != '|'; p++) {} if (p > arg) { char_u *group_name = vim_strnsave(arg, (size_t)(p - arg)); group = augroup_find((char *)group_name); diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 99a24464a8..5786a73f43 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -2343,9 +2343,9 @@ int ExpandBufnames(char_u *pat, int *num_file, char_u ***file, int options) // if the current buffer is first in the list, place it at the end if (matches[0].buf == curbuf) { for (int i = 1; i < count; i++) { - (*file)[i-1] = matches[i].match; + (*file)[i - 1] = matches[i].match; } - (*file)[count-1] = matches[0].match; + (*file)[count - 1] = matches[0].match; } else { for (int i = 0; i < count; i++) { (*file)[i] = matches[i].match; @@ -5410,8 +5410,8 @@ static int buf_signcols_inner(buf_T *buf, int maximum) if (sign->se_lnum > curline) { // Counted all signs, now add extmark signs if (curline > 0) { - linesum += decor_signcols(buf, &decor_state, (int)curline-1, (int)curline-1, - maximum-linesum); + linesum += decor_signcols(buf, &decor_state, (int)curline - 1, (int)curline - 1, + maximum - linesum); } curline = sign->se_lnum; if (linesum > signcols) { @@ -5429,7 +5429,8 @@ static int buf_signcols_inner(buf_T *buf, int maximum) } if (curline > 0) { - linesum += decor_signcols(buf, &decor_state, (int)curline-1, (int)curline-1, maximum-linesum); + linesum += decor_signcols(buf, &decor_state, (int)curline - 1, (int)curline - 1, + maximum - linesum); } if (linesum > signcols) { signcols = linesum; @@ -5439,7 +5440,7 @@ static int buf_signcols_inner(buf_T *buf, int maximum) } // Check extmarks between signs - linesum = decor_signcols(buf, &decor_state, 0, (int)buf->b_ml.ml_line_count-1, maximum); + linesum = decor_signcols(buf, &decor_state, 0, (int)buf->b_ml.ml_line_count - 1, maximum); if (linesum > signcols) { signcols = linesum; @@ -5511,8 +5512,8 @@ void buf_signcols_add_check(buf_T *buf, sign_entry_T *added) for (; s->se_next && s->se_lnum == s->se_next->se_lnum; s = s->se_next) { linesum++; } - linesum += decor_signcols(buf, &decor_state, (int)s->se_lnum-1, (int)s->se_lnum-1, - SIGN_SHOW_MAX-linesum); + linesum += decor_signcols(buf, &decor_state, (int)s->se_lnum - 1, (int)s->se_lnum - 1, + SIGN_SHOW_MAX - linesum); if (linesum > buf->b_signcols.size) { buf->b_signcols.size = linesum; diff --git a/src/nvim/change.c b/src/nvim/change.c index 024969415d..c751507955 100644 --- a/src/nvim/change.c +++ b/src/nvim/change.c @@ -369,7 +369,7 @@ void changed_bytes(linenr_T lnum, colnr_T col) void inserted_bytes(linenr_T lnum, colnr_T col, int old, int new) { if (curbuf_splice_pending == 0) { - extmark_splice_cols(curbuf, (int)lnum-1, col, old, new, kExtmarkUndo); + extmark_splice_cols(curbuf, (int)lnum - 1, col, old, new, kExtmarkUndo); } changed_bytes(lnum, col); @@ -1306,8 +1306,7 @@ int open_line(int dir, int flags, int second_line_indent, bool *did_do_comment) p--; } for (lead_repl = p; lead_repl > curbuf->b_p_com - && lead_repl[-1] != ':'; lead_repl--) { - } + && lead_repl[-1] != ':'; lead_repl--) {} lead_repl_len = (int)(p - lead_repl); // We can probably always add an extra space when doing "O" on @@ -1379,8 +1378,7 @@ int open_line(int dir, int flags, int second_line_indent, bool *did_do_comment) if (c == COM_RIGHT) { // right adjusted leader // find last non-white in the leader to line up with for (p = leader + lead_len - 1; p > leader - && ascii_iswhite(*p); p--) { - } + && ascii_iswhite(*p); p--) {} p++; // Compute the length of the replaced characters in @@ -1728,8 +1726,8 @@ int open_line(int dir, int flags, int second_line_indent, bool *did_do_comment) } // Always move extmarks - Here we move only the line where the // cursor is, the previous mark_adjust takes care of the lines after - int cols_added = mincol-1+less_cols_off-less_cols; - extmark_splice(curbuf, (int)lnum-1, mincol-1 - cols_spliced, + int cols_added = mincol - 1 + less_cols_off - less_cols; + extmark_splice(curbuf, (int)lnum - 1, mincol - 1 - cols_spliced, 0, less_cols_off, less_cols_off, 1, cols_added, 1 + cols_added, kExtmarkUndo); } else { @@ -1745,8 +1743,8 @@ int open_line(int dir, int flags, int second_line_indent, bool *did_do_comment) changed_lines(curwin->w_cursor.lnum, 0, curwin->w_cursor.lnum, 1L, true); // bail out and just get the final length of the line we just manipulated bcount_t extra = (bcount_t)STRLEN(ml_get(curwin->w_cursor.lnum)); - extmark_splice(curbuf, (int)curwin->w_cursor.lnum-1, 0, - 0, 0, 0, 1, 0, 1+extra, kExtmarkUndo); + extmark_splice(curbuf, (int)curwin->w_cursor.lnum - 1, 0, + 0, 0, 0, 1, 0, 1 + extra, kExtmarkUndo); } curbuf_splice_pending--; @@ -1942,8 +1940,7 @@ int get_leader_len(char_u *line, char_u **flags, bool backward, bool include_spa string++; } } - for (j = 0; string[j] != NUL && string[j] == line[i + j]; j++) { - } + for (j = 0; string[j] != NUL && string[j] == line[i + j]; j++) {} if (string[j] != NUL) { continue; // string doesn't match } @@ -2081,8 +2078,7 @@ int get_last_leader_offset(char_u *line, char_u **flags) // whitespace. Otherwise we would think we are inside a // comment if the middle part appears somewhere in the middle // of the line. E.g. for C the "*" appears often. - for (j = 0; j <= i && ascii_iswhite(line[j]); j++) { - } + for (j = 0; j <= i && ascii_iswhite(line[j]); j++) {} if (j < i) { continue; } diff --git a/src/nvim/channel.c b/src/nvim/channel.c index ac6c9cd110..cc76c6cf2d 100644 --- a/src/nvim/channel.c +++ b/src/nvim/channel.c @@ -25,7 +25,7 @@ static bool did_stdio = false; /// next free id for a job or rpc channel /// 1 is reserved for stdio channel /// 2 is reserved for stderr channel -static uint64_t next_chan_id = CHAN_STDERR+1; +static uint64_t next_chan_id = CHAN_STDERR + 1; #ifdef INCLUDE_GENERATED_DECLARATIONS # include "channel.c.generated.h" diff --git a/src/nvim/cursor_shape.c b/src/nvim/cursor_shape.c index 73adff6579..82c3a714b1 100644 --- a/src/nvim/cursor_shape.c +++ b/src/nvim/cursor_shape.c @@ -23,15 +23,15 @@ cursorentry_T shape_table[SHAPE_IDX_COUNT] = { // Values are set by 'guicursor' and 'mouseshape'. // Adjust the SHAPE_IDX_ defines when changing this! - { "normal", 0, 0, 0, 700L, 400L, 250L, 0, 0, "n", SHAPE_CURSOR+SHAPE_MOUSE }, - { "visual", 0, 0, 0, 700L, 400L, 250L, 0, 0, "v", SHAPE_CURSOR+SHAPE_MOUSE }, - { "insert", 0, 0, 0, 700L, 400L, 250L, 0, 0, "i", SHAPE_CURSOR+SHAPE_MOUSE }, - { "replace", 0, 0, 0, 700L, 400L, 250L, 0, 0, "r", SHAPE_CURSOR+SHAPE_MOUSE }, - { "cmdline_normal", 0, 0, 0, 700L, 400L, 250L, 0, 0, "c", SHAPE_CURSOR+SHAPE_MOUSE }, - { "cmdline_insert", 0, 0, 0, 700L, 400L, 250L, 0, 0, "ci", SHAPE_CURSOR+SHAPE_MOUSE }, - { "cmdline_replace", 0, 0, 0, 700L, 400L, 250L, 0, 0, "cr", SHAPE_CURSOR+SHAPE_MOUSE }, - { "operator", 0, 0, 0, 700L, 400L, 250L, 0, 0, "o", SHAPE_CURSOR+SHAPE_MOUSE }, - { "visual_select", 0, 0, 0, 700L, 400L, 250L, 0, 0, "ve", SHAPE_CURSOR+SHAPE_MOUSE }, + { "normal", 0, 0, 0, 700L, 400L, 250L, 0, 0, "n", SHAPE_CURSOR + SHAPE_MOUSE }, + { "visual", 0, 0, 0, 700L, 400L, 250L, 0, 0, "v", SHAPE_CURSOR + SHAPE_MOUSE }, + { "insert", 0, 0, 0, 700L, 400L, 250L, 0, 0, "i", SHAPE_CURSOR + SHAPE_MOUSE }, + { "replace", 0, 0, 0, 700L, 400L, 250L, 0, 0, "r", SHAPE_CURSOR + SHAPE_MOUSE }, + { "cmdline_normal", 0, 0, 0, 700L, 400L, 250L, 0, 0, "c", SHAPE_CURSOR + SHAPE_MOUSE }, + { "cmdline_insert", 0, 0, 0, 700L, 400L, 250L, 0, 0, "ci", SHAPE_CURSOR + SHAPE_MOUSE }, + { "cmdline_replace", 0, 0, 0, 700L, 400L, 250L, 0, 0, "cr", SHAPE_CURSOR + SHAPE_MOUSE }, + { "operator", 0, 0, 0, 700L, 400L, 250L, 0, 0, "o", SHAPE_CURSOR + SHAPE_MOUSE }, + { "visual_select", 0, 0, 0, 700L, 400L, 250L, 0, 0, "ve", SHAPE_CURSOR + SHAPE_MOUSE }, { "cmdline_hover", 0, 0, 0, 0L, 0L, 0L, 0, 0, "e", SHAPE_MOUSE }, { "statusline_hover", 0, 0, 0, 0L, 0L, 0L, 0, 0, "s", SHAPE_MOUSE }, { "statusline_drag", 0, 0, 0, 0L, 0L, 0L, 0, 0, "sd", SHAPE_MOUSE }, diff --git a/src/nvim/decoration.c b/src/nvim/decoration.c index ba49c7f527..c8f4b3e875 100644 --- a/src/nvim/decoration.c +++ b/src/nvim/decoration.c @@ -45,7 +45,7 @@ void bufhl_add_hl_pos_offset(buf_T *buf, int src_id, int hl_id, lpos_T pos_start // substituted text. But it would be more consistent to highlight // a space _after_ the previous line instead (like highlight EOL list // char) - hl_start = MAX(offset-1, 0); + hl_start = MAX(offset - 1, 0); end_off = 1; hl_end = 0; } else if (lnum == pos_start.lnum && lnum < pos_end.lnum) { @@ -53,14 +53,14 @@ void bufhl_add_hl_pos_offset(buf_T *buf, int src_id, int hl_id, lpos_T pos_start end_off = 1; hl_end = 0; } else if (pos_start.lnum < lnum && lnum == pos_end.lnum) { - hl_start = MAX(offset-1, 0); + hl_start = MAX(offset - 1, 0); hl_end = pos_end.col + offset; } else if (pos_start.lnum == lnum && pos_end.lnum == lnum) { hl_start = pos_start.col + offset; hl_end = pos_end.col + offset; } extmark_set(buf, (uint32_t)src_id, NULL, - (int)lnum-1, hl_start, (int)lnum-1+end_off, hl_end, + (int)lnum - 1, hl_start, (int)lnum - 1 + end_off, hl_end, &decor, true, false, kExtmarkNoUndo); } } @@ -69,17 +69,17 @@ void decor_redraw(buf_T *buf, int row1, int row2, Decoration *decor) { if (row2 >= row1) { if (!decor || decor->hl_id || decor_has_sign(decor)) { - redraw_buf_range_later(buf, row1+1, row2+1); + redraw_buf_range_later(buf, row1 + 1, row2 + 1); } } if (decor && kv_size(decor->virt_text)) { - redraw_buf_line_later(buf, row1+1); + redraw_buf_line_later(buf, row1 + 1); } if (decor && kv_size(decor->virt_lines)) { redraw_buf_line_later(buf, MIN(buf->b_ml.ml_line_count, - row1+1+(decor->virt_lines_above?0:1))); + row1 + 1 + (decor->virt_lines_above?0:1))); } } @@ -96,7 +96,7 @@ void decor_remove(buf_T *buf, int row, int row2, Decoration *decor) buf->b_signs--; } if (row2 >= row && decor->sign_text) { - buf_signcols_del_check(buf, row+1, row2+1); + buf_signcols_del_check(buf, row + 1, row2 + 1); } } decor_free(decor); @@ -256,12 +256,12 @@ static void decor_add(DecorState *state, int start_row, int start_col, int end_r kv_pushp(state->active); size_t index; - for (index = kv_size(state->active)-1; index > 0; index--) { - DecorRange item = kv_A(state->active, index-1); + for (index = kv_size(state->active) - 1; index > 0; index--) { + DecorRange item = kv_A(state->active, index - 1); if (item.decor.priority <= range.decor.priority) { break; } - kv_A(state->active, index) = kv_A(state->active, index-1); + kv_A(state->active, index) = kv_A(state->active, index - 1); } kv_A(state->active, index) = range; } @@ -279,7 +279,7 @@ int decor_redraw_col(buf_T *buf, int col, int win_col, bool hidden, DecorState * if (mark.pos.row < 0 || mark.pos.row > state->row) { break; } else if (mark.pos.row == state->row && mark.pos.col > col) { - state->col_until = mark.pos.col-1; + state->col_until = mark.pos.col - 1; break; } @@ -329,11 +329,11 @@ next_mark: || (item.start_row == state->row && item.start_col <= col)) { active = true; if (item.end_row == state->row && item.end_col > col) { - state->col_until = MIN(state->col_until, item.end_col-1); + state->col_until = MIN(state->col_until, item.end_col - 1); } } else { if (item.start_row == state->row) { - state->col_until = MIN(state->col_until, item.start_col-1); + state->col_until = MIN(state->col_until, item.start_col - 1); } } } @@ -397,7 +397,7 @@ void decor_redraw_signs(buf_T *buf, int row, int *num_signs, sign_attrs_T sattrs if (sattrs[j].sat_prio <= decor->priority) { break; } - sattrs[j] = sattrs[j-1]; + sattrs[j] = sattrs[j - 1]; } if (j < SIGN_SHOW_MAX) { memset(&sattrs[j], 0, sizeof(sign_attrs_T)); diff --git a/src/nvim/decoration_provider.c b/src/nvim/decoration_provider.c index 66ec5ba19f..ef27b2af1c 100644 --- a/src/nvim/decoration_provider.c +++ b/src/nvim/decoration_provider.c @@ -100,7 +100,7 @@ void decor_providers_invoke_win(win_T *wp, DecorProviders *providers, args.items[0] = WINDOW_OBJ(wp->handle); args.items[1] = BUFFER_OBJ(wp->w_buffer->handle); // TODO(bfredl): we are not using this, but should be first drawn line? - args.items[2] = INTEGER_OBJ(wp->w_topline-1); + args.items[2] = INTEGER_OBJ(wp->w_topline - 1); args.items[3] = INTEGER_OBJ(knownmax); if (decor_provider_invoke(p->ns_id, "win", p->redraw_win, args, true, err)) { kvi_push(*line_providers, p); @@ -228,4 +228,3 @@ void decor_free_all_mem(void) } kv_destroy(decor_providers); } - diff --git a/src/nvim/diff.c b/src/nvim/diff.c index 2fa96e4fc2..cfb1c35817 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -2558,8 +2558,7 @@ void ex_diffgetput(exarg_T *eap) p--; } - for (i = 0; ascii_isdigit(eap->arg[i]) && eap->arg + i < p; i++) { - } + for (i = 0; ascii_isdigit(eap->arg[i]) && eap->arg + i < p; i++) {} if (eap->arg + i == p) { // digits only diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 251f55c6e7..a94f7a803a 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -2003,7 +2003,7 @@ void change_indent(int type, int amount, int round, int replaced, int call_chang // TODO(bfredl): test for crazy edge cases, like we stand on a TAB or // something? does this even do the right text change then? int delta = orig_col - new_col; - extmark_splice_cols(curbuf, curwin->w_cursor.lnum-1, new_col, + extmark_splice_cols(curbuf, curwin->w_cursor.lnum - 1, new_col, delta < 0 ? -delta : 0, delta > 0 ? delta : 0, kExtmarkUndo); @@ -3962,8 +3962,7 @@ static buf_T *ins_compl_next_buf(buf_T *buf, int flag) } assert(wp); while ((wp = (wp->w_next != NULL ? wp->w_next : firstwin)) != curwin - && wp->w_buffer->b_scanned) { - } + && wp->w_buffer->b_scanned) {} buf = wp->w_buffer; } else { /* 'b' (just loaded buffers), 'u' (just non-loaded buffers) or 'U' @@ -3974,8 +3973,7 @@ static buf_T *ins_compl_next_buf(buf_T *buf, int flag) ? buf->b_p_bl : (!buf->b_p_bl || (buf->b_ml.ml_mfp == NULL) != (flag == 'u'))) - || buf->b_scanned)) { - } + || buf->b_scanned)) {} } return buf; } @@ -5178,8 +5176,7 @@ static int ins_complete(int c, bool enable_pum) if ((compl_cont_status & CONT_SOL) || ctrl_x_mode == CTRL_X_PATH_DEFINES) { if (!(compl_cont_status & CONT_ADDING)) { - while (--startcol >= 0 && vim_isIDc(line[startcol])) { - } + while (--startcol >= 0 && vim_isIDc(line[startcol])) {} compl_col += ++startcol; compl_length = curs_col - startcol; } @@ -5870,8 +5867,7 @@ void insertchar(int c, int flags, int second_indent) // Skip white space before the cursor i = curwin->w_cursor.col; - while (--i >= 0 && ascii_iswhite(line[i])) { - } + while (--i >= 0 && ascii_iswhite(line[i])) {} i++; // Skip to before the middle leader @@ -5942,7 +5938,7 @@ void insertchar(int c, int flags, int second_indent) } do_digraph(-1); // clear digraphs - do_digraph(buf[i-1]); // may be the start of a digraph + do_digraph(buf[i - 1]); // may be the start of a digraph buf[i] = NUL; ins_str(buf); if (flags & INSCHAR_CTRLV) { @@ -6459,7 +6455,7 @@ void auto_format(bool trailblank, bool prev_line) * be adjusted for the text formatting. */ saved_cursor = pos; - format_lines((linenr_T)-1, FALSE); + format_lines((linenr_T) - 1, false); curwin->w_cursor = saved_cursor; saved_cursor.lnum = 0; @@ -7717,7 +7713,7 @@ int hkmap(int c) (char_u)BET, // b (char_u)hKAF, // c (char_u)DALET, // d - (char_u)-1, // e + (char_u) - 1, // e (char_u)PEIsofit, // f (char_u)GIMEL, // g (char_u)HEI, // h @@ -7729,14 +7725,14 @@ int hkmap(int c) (char_u)NUN, // n (char_u)SAMEH, // o (char_u)PEI, // p - (char_u)-1, // q + (char_u) - 1, // q (char_u)RESH, // r (char_u)ZAIN, // s (char_u)TAV, // t (char_u)TET, // u (char_u)VAV, // v (char_u)hSHIN, // w - (char_u)-1, // x + (char_u) - 1, // x (char_u)AIN, // y (char_u)ZADI, // z }; @@ -9393,8 +9389,7 @@ static void ins_try_si(int c) ptr = ml_get(pos->lnum); i = pos->col; if (i > 0) { // skip blanks before '{' - while (--i > 0 && ascii_iswhite(ptr[i])) { - } + while (--i > 0 && ascii_iswhite(ptr[i])) {} } curwin->w_cursor.lnum = pos->lnum; curwin->w_cursor.col = i; diff --git a/src/nvim/eval.c b/src/nvim/eval.c index b7177792db..9b03af8d32 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -161,7 +161,7 @@ static struct vimvar { VV(VV_STATUSMSG, "statusmsg", VAR_STRING, 0), VV(VV_SHELL_ERROR, "shell_error", VAR_NUMBER, VV_RO), VV(VV_THIS_SESSION, "this_session", VAR_STRING, 0), - VV(VV_VERSION, "version", VAR_NUMBER, VV_COMPAT+VV_RO), + VV(VV_VERSION, "version", VAR_NUMBER, VV_COMPAT + VV_RO), VV(VV_LNUM, "lnum", VAR_NUMBER, VV_RO_SBX), VV(VV_TERMRESPONSE, "termresponse", VAR_STRING, VV_RO), VV(VV_FNAME, "fname", VAR_STRING, VV_RO), @@ -2095,8 +2095,7 @@ char_u *get_lval(char_u *const name, typval_T *const rettv, lval_T *const lp, co char_u *key = NULL; if (*p == '.') { key = p + 1; - for (len = 0; ASCII_ISALNUM(key[len]) || key[len] == '_'; len++) { - } + for (len = 0; ASCII_ISALNUM(key[len]) || key[len] == '_'; len++) {} if (len == 0) { if (!quiet) { emsg(_("E713: Cannot use empty key after .")); @@ -2444,6 +2443,7 @@ static void set_var_lval(lval_T *lp, char_u *endp, typval_T *rettv, int copy, co ? lp->ll_tv->v_lock : lp->ll_tv->vval.v_dict->dv_lock, lp->ll_name, TV_CSTRING)) { + // Skip } else if (lp->ll_range) { listitem_T *ll_li = lp->ll_li; int ll_n1 = lp->ll_n1; @@ -2774,8 +2774,7 @@ void set_context_for_expression(expand_T *xp, char_u *arg, cmdidx_T cmdidx) xp->xp_context = EXPAND_NOTHING; } else if (c == '\'') { // literal string // Trick: '' is like stopping and starting a literal string. - while ((c = *++xp->xp_pattern) != NUL && c != '\'') { - } + while ((c = *++xp->xp_pattern) != NUL && c != '\'') {} xp->xp_context = EXPAND_NOTHING; } else if (c == '|') { if (xp->xp_pattern[1] == '|') { @@ -2794,8 +2793,7 @@ void set_context_for_expression(expand_T *xp, char_u *arg, cmdidx_T cmdidx) } arg = xp->xp_pattern; if (*arg != NUL) { - while ((c = *++arg) != NUL && (c == ' ' || c == '\t')) { - } + while ((c = *++arg) != NUL && (c == ' ' || c == '\t')) {} } } @@ -4536,8 +4534,7 @@ static int eval_index(char_u **arg, typval_T *rettv, int evaluate, int verbose) * dict.name */ key = *arg + 1; - for (len = 0; ASCII_ISALNUM(key[len]) || key[len] == '_'; len++) { - } + for (len = 0; ASCII_ISALNUM(key[len]) || key[len] == '_'; len++) {} if (len == 0) { return FAIL; } @@ -5710,8 +5707,7 @@ static int get_literal_key(char_u **arg, typval_T *tv) if (!ASCII_ISALNUM(**arg) && **arg != '_' && **arg != '-') { return FAIL; } - for (p = *arg; ASCII_ISALNUM(*p) || *p == '_' || *p == '-'; p++) { - } + for (p = *arg; ASCII_ISALNUM(*p) || *p == '_' || *p == '-'; p++) {} tv->v_type = VAR_STRING; tv->vval.v_string = vim_strnsave(*arg, p - *arg); @@ -5847,7 +5843,7 @@ size_t string2float(const char *const text, float_T *const ret_value) return 3; } if (STRNICMP(text, "-inf", 3) == 0) { - *ret_value = (float_T)-INFINITY; + *ret_value = (float_T) - INFINITY; return 4; } if (STRNICMP(text, "nan", 3) == 0) { @@ -6663,7 +6659,7 @@ void get_user_input(const typval_T *const argvars, typval_T *const rettv, const if (!ui_has(kUICmdline)) { const char *lastnl = strrchr(prompt, '\n'); if (lastnl != NULL) { - p = lastnl+1; + p = lastnl + 1; msg_start(); msg_clr_eos(); msg_puts_attr_len(prompt, p - prompt, echo_attr); @@ -7948,8 +7944,7 @@ static int get_env_len(const char_u **arg) int len; const char_u *p; - for (p = *arg; vim_isIDc(*p); p++) { - } + for (p = *arg; vim_isIDc(*p); p++) {} if (p == *arg) { // No name found. return 0; } @@ -8091,8 +8086,7 @@ const char_u *find_name_end(const char_u *arg, const char_u **expr_start, const || br_nest != 0); MB_PTR_ADV(p)) { if (*p == '\'') { // skip over 'string' to avoid counting [ and ] inside it. - for (p = p + 1; *p != NUL && *p != '\''; MB_PTR_ADV(p)) { - } + for (p = p + 1; *p != NUL && *p != '\''; MB_PTR_ADV(p)) {} if (*p == NUL) { break; } @@ -8566,7 +8560,7 @@ int check_luafunc_name(const char *const str, const bool paren) if (*p != (paren ? '(' : NUL)) { return 0; } else { - return (int)(p-str); + return (int)(p - str); } } diff --git a/src/nvim/eval.h b/src/nvim/eval.h index a9ec5d47a6..83e9c6370d 100644 --- a/src/nvim/eval.h +++ b/src/nvim/eval.h @@ -235,8 +235,7 @@ typedef struct { } timer_T; /// Type of assert_* check being performed -typedef enum -{ +typedef enum { ASSERT_EQUAL, ASSERT_NOTEQUAL, ASSERT_MATCH, diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index 1665c82e1e..91a12a94fa 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -135,8 +135,7 @@ char_u *get_function_name(expand_T *xp, int idx) } } while ((size_t)++intidx < ARRAY_SIZE(functions) - && functions[intidx].name[0] == '\0') { - } + && functions[intidx].name[0] == '\0') {} if ((size_t)intidx >= ARRAY_SIZE(functions)) { return NULL; @@ -2445,7 +2444,7 @@ static void f_float2nr(typval_T *argvars, typval_T *rettv, FunPtr fptr) float_T f; if (tv_get_float_chk(argvars, &f)) { - if (f <= (float_T)-VARNUMBER_MAX + DBL_EPSILON) { + if (f <= (float_T) - VARNUMBER_MAX + DBL_EPSILON) { rettv->vval.v_number = -VARNUMBER_MAX; } else if (f >= (float_T)VARNUMBER_MAX - DBL_EPSILON) { rettv->vval.v_number = VARNUMBER_MAX; @@ -2631,8 +2630,7 @@ static void f_foldtextresult(typval_T *argvars, typval_T *rettv, FunPtr fptr) /// "foreground()" function static void f_foreground(typval_T *argvars, typval_T *rettv, FunPtr fptr) -{ -} +{} static void f_funcref(typval_T *argvars, typval_T *rettv, FunPtr fptr) { @@ -3857,8 +3855,7 @@ static void f_getwininfo(typval_T *argvars, typval_T *rettv, FunPtr fptr) /// Dummy timer callback. Used by f_wait(). static void dummy_timer_due_cb(TimeWatcher *tw, void *data) -{ -} +{} /// Dummy timer close callback. Used by f_wait(). static void dummy_timer_close_cb(TimeWatcher *tw, void *data) diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c index 11ca93cff9..5a63bbf631 100644 --- a/src/nvim/eval/userfunc.c +++ b/src/nvim/eval/userfunc.c @@ -1761,14 +1761,14 @@ char_u *trans_function_name(char_u **pp, bool skip, int flags, funcdict_T *fdp, } else if (lv.ll_tv->v_type == VAR_PARTIAL && lv.ll_tv->vval.v_partial != NULL) { if (is_luafunc(lv.ll_tv->vval.v_partial) && *end == '.') { - len = check_luafunc_name((const char *)end+1, true); + len = check_luafunc_name((const char *)end + 1, true); if (len == 0) { semsg(e_invexpr2, "v:lua"); goto theend; } name = xmallocz((size_t)len); - memcpy(name, end+1, (size_t)len); - *pp = (char_u *)end+1+len; + memcpy(name, end + 1, (size_t)len); + *pp = (char_u *)end + 1 + len; } else { name = vim_strsave(partial_name(lv.ll_tv->vval.v_partial)); *pp = (char_u *)end; @@ -2269,8 +2269,7 @@ void ex_function(exarg_T *eap) } } else { // skip ':' and blanks - for (p = theline; ascii_iswhite(*p) || *p == ':'; p++) { - } + for (p = theline; ascii_iswhite(*p) || *p == ':'; p++) {} // Check for "endfunction". if (checkforcmd(&p, "endfunction", 4) && nesting-- == 0) { diff --git a/src/nvim/event/socket.c b/src/nvim/event/socket.c index c20716496f..060b432b18 100644 --- a/src/nvim/event/socket.c +++ b/src/nvim/event/socket.c @@ -106,7 +106,7 @@ int socket_watcher_start(SocketWatcher *watcher, int backlog, socket_cb cb) : (STRUCT_CAST(struct sockaddr_in6, &sas))->sin6_port); // v:servername uses the string from watcher->addr size_t len = strlen(watcher->addr); - snprintf(watcher->addr+len, sizeof(watcher->addr)-len, ":%" PRIu16, + snprintf(watcher->addr + len, sizeof(watcher->addr) - len, ":%" PRIu16, ntohs(port)); break; } @@ -225,7 +225,7 @@ bool socket_connect(Loop *loop, Stream *stream, bool is_tcp, const char *address .ai_socktype = SOCK_STREAM, .ai_flags = AI_NUMERICSERV }; int retval = uv_getaddrinfo(&loop->uv, &addr_req, NULL, - addr, host_end+1, &hints); + addr, host_end + 1, &hints); if (retval != 0) { *error = _("failed to lookup host or port"); goto cleanup; diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 662a65d5d7..cdd27aebc7 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -343,8 +343,7 @@ static int linelen(int *has_tab) // find the character after the last non-blank character for (last = first + STRLEN(first); - last > first && ascii_iswhite(last[-1]); last--) { - } + last > first && ascii_iswhite(last[-1]); last--) {} save = *last; *last = NUL; // Get line length. @@ -487,6 +486,7 @@ void ex_sort(exarg_T *eap) for (p = eap->arg; *p != NUL; ++p) { if (ascii_iswhite(*p)) { + // Skip } else if (*p == 'i') { sort_ic = true; } else if (*p == 'l') { @@ -700,7 +700,7 @@ void ex_sort(exarg_T *eap) } if (change_occurred || deleted != 0) { - extmark_splice(curbuf, eap->line1-1, 0, + extmark_splice(curbuf, eap->line1 - 1, 0, count, 0, old_count, lnum - eap->line2, 0, new_count, kExtmarkUndo); @@ -932,9 +932,9 @@ int do_move(linenr_T line1, linenr_T line2, linenr_T dest) } bcount_t start_byte = ml_find_line_or_offset(curbuf, line1, NULL, true); - bcount_t end_byte = ml_find_line_or_offset(curbuf, line2+1, NULL, true); - bcount_t extent_byte = end_byte-start_byte; - bcount_t dest_byte = ml_find_line_or_offset(curbuf, dest+1, NULL, true); + bcount_t end_byte = ml_find_line_or_offset(curbuf, line2 + 1, NULL, true); + bcount_t extent_byte = end_byte - start_byte; + bcount_t dest_byte = ml_find_line_or_offset(curbuf, dest + 1, NULL, true); num_lines = line2 - line1 + 1; @@ -1024,9 +1024,9 @@ int do_move(linenr_T line1, linenr_T line2, linenr_T dest) smsg(NGETTEXT("1 line moved", "%" PRId64 " lines moved", num_lines), (int64_t)num_lines); } - extmark_move_region(curbuf, line1-1, 0, start_byte, - line2-line1+1, 0, extent_byte, - dest+line_off, 0, dest_byte+byte_off, + extmark_move_region(curbuf, line1 - 1, 0, start_byte, + line2 - line1 + 1, 0, extent_byte, + dest + line_off, 0, dest_byte + byte_off, kExtmarkUndo); /* @@ -3139,8 +3139,7 @@ void ex_z(exarg_T *eap) // the number of '-' and '+' multiplies the distance if (*kind == '-' || *kind == '+') { - for (x = kind + 1; *x == *kind; x++) { - } + for (x = kind + 1; *x == *kind; x++) {} } switch (*kind) { @@ -4143,8 +4142,8 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout, bool do_buf_event, handle // 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]; - for (i = 0; i < nmatch-1; i++) { - replaced_bytes += STRLEN(ml_get(lnum_start+i)) + 1; + for (i = 0; i < nmatch - 1; i++) { + replaced_bytes += STRLEN(ml_get(lnum_start + i)) + 1; } replaced_bytes += end.col - start.col; @@ -4199,9 +4198,9 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout, bool do_buf_event, handle u_save_cursor(); did_save = true; } - extmark_splice(curbuf, lnum_start-1, start_col, - end.lnum-start.lnum, matchcols, replaced_bytes, - lnum-lnum_start, subcols, sublen-1, kExtmarkUndo); + extmark_splice(curbuf, lnum_start - 1, start_col, + end.lnum - start.lnum, matchcols, replaced_bytes, + lnum - lnum_start, subcols, sublen - 1, kExtmarkUndo); } @@ -4461,8 +4460,8 @@ skip: preview_buf = show_sub(eap, old_cursor, &preview_lines, pre_hl_id, pre_src_id, bufnr); if (subsize > 0) { - extmark_clear(orig_buf, pre_src_id, eap->line1-1, 0, - kv_last(preview_lines.subresults).end.lnum-1, MAXCOL); + extmark_clear(orig_buf, pre_src_id, eap->line1 - 1, 0, + kv_last(preview_lines.subresults).end.lnum - 1, MAXCOL); } } } diff --git a/src/nvim/ex_cmds.h b/src/nvim/ex_cmds.h index 1c95b75001..a55e74a789 100644 --- a/src/nvim/ex_cmds.h +++ b/src/nvim/ex_cmds.h @@ -21,7 +21,7 @@ // for lnum argument in do_ecmd() #define ECMD_LASTL (linenr_T)0 // use last position in loaded file -#define ECMD_LAST ((linenr_T)-1) // use last position in all files +#define ECMD_LAST ((linenr_T) - 1) // use last position in all files #define ECMD_ONE (linenr_T)1 // use first line /// Previous :substitute replacement string definition diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index f3b11cc103..b442a651c0 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -668,7 +668,7 @@ int do_cmdline(char_u *cmdline, LineGetter fgetline, void *cookie, int flags) if (breakpoint != NULL) { *breakpoint = dbg_find_breakpoint(getline_equal(fgetline, cookie, getsourceline), fname, - ((wcmd_T *)lines_ga.ga_data)[current_line].lnum-1); + ((wcmd_T *)lines_ga.ga_data)[current_line].lnum - 1); *dbg_tick = debug_tick; } } else { @@ -2955,8 +2955,7 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff) // 2. skip comment lines and leading space, colons or bars const char *cmd; - for (cmd = buff; vim_strchr((const char_u *)" \t:|", *cmd) != NULL; cmd++) { - } + for (cmd = buff; vim_strchr((const char_u *)" \t:|", *cmd) != NULL; cmd++) {} xp->xp_pattern = (char_u *)cmd; if (*cmd == NUL) { @@ -3268,8 +3267,7 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff) } // Check for user names. if (*xp->xp_pattern == '~') { - for (p = (const char *)xp->xp_pattern + 1; *p != NUL && *p != '/'; p++) { - } + for (p = (const char *)xp->xp_pattern + 1; *p != NUL && *p != '/'; p++) {} // Complete ~user only if it partially matches a user name. // A full match ~user<Tab> will be replaced by user's home // directory i.e. something like ~user<Tab> -> /home/user/ @@ -6248,8 +6246,7 @@ static void do_ucmd(exarg_T *eap) end = vim_strchr(start + 1, '>'); } if (buf != NULL) { - for (ksp = p; *ksp != NUL && *ksp != K_SPECIAL; ksp++) { - } + for (ksp = p; *ksp != NUL && *ksp != K_SPECIAL; ksp++) {} if (*ksp == K_SPECIAL && (start == NULL || ksp < start || end == NULL) && (ksp[1] == KS_SPECIAL && ksp[2] == KE_FILLER)) { @@ -7415,8 +7412,7 @@ static void ex_resize(exarg_T *eap) if (eap->addr_count > 0) { n = (int)eap->line2; - for (wp = firstwin; wp->w_next != NULL && --n > 0; wp = wp->w_next) { - } + for (wp = firstwin; wp->w_next != NULL && --n > 0; wp = wp->w_next) {} } n = (int)atol((char *)eap->arg); @@ -7431,7 +7427,7 @@ static void ex_resize(exarg_T *eap) if (*eap->arg == '-' || *eap->arg == '+') { n += wp->w_height; } else if (n == 0 && eap->arg[0] == NUL) { // default is very high - n = Rows-1; + n = Rows - 1; } win_setheight_win(n, wp); } @@ -8254,8 +8250,7 @@ static void ex_undo(exarg_T *eap) for (uhp = curbuf->b_u_curhead ? curbuf->b_u_curhead : curbuf->b_u_newhead; uhp != NULL && uhp->uh_seq > step; - uhp = uhp->uh_next.ptr, ++count) { - } + uhp = uhp->uh_next.ptr, ++count) {} if (step != 0 && (uhp == NULL || uhp->uh_seq < step)) { emsg(_(e_undobang_cannot_redo_or_move_branch)); return; diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c index 102d817694..43865b1a21 100644 --- a/src/nvim/ex_eval.c +++ b/src/nvim/ex_eval.c @@ -417,7 +417,7 @@ char *get_exception_string(void *value, except_type_T type, char_u *cmdname, int STRCAT(val, mesg); // 'E123' missing or at beginning } else { // '"filename" E123: message text' - if (mesg[0] != '"' || p-2 < &mesg[1] + if (mesg[0] != '"' || p - 2 < &mesg[1] || p[-2] != '"' || p[-1] != ' ') { // "E123:" is part of the file name. continue; diff --git a/src/nvim/ex_eval.h b/src/nvim/ex_eval.h index 1cd0a47d7a..98573c7182 100644 --- a/src/nvim/ex_eval.h +++ b/src/nvim/ex_eval.h @@ -47,8 +47,7 @@ struct msglist { }; // The exception types. -typedef enum -{ +typedef enum { ET_USER, // exception caused by ":throw" command ET_ERROR, // error exception ET_INTERRUPT, // interrupt exception triggered by Ctrl-C diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 35fd900391..49e4428b5f 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -3129,7 +3129,7 @@ static void ui_ext_cmdline_show(CmdlineInfo *line) assert(chunk.end >= chunk.start); ADD(item, STRING_OBJ(cbuf_to_string((char *)line->cmdbuff + chunk.start, - (size_t)(chunk.end-chunk.start)))); + (size_t)(chunk.end - chunk.start)))); ADD(content, ARRAY_OBJ(item)); } } else { @@ -3188,7 +3188,7 @@ void cmdline_screen_cleared(void) ui_call_cmdline_block_show(copy_array(cmdline_block)); } - int prev_level = ccline.level-1; + int prev_level = ccline.level - 1; CmdlineInfo *line = ccline.prev_ccline; while (prev_level > 0 && line) { if (line->level == prev_level) { @@ -3645,7 +3645,7 @@ static void cursorcmd(void) } if (cmdmsg_rl) { - msg_row = cmdline_row + (ccline.cmdspos / (Columns - 1)); + msg_row = cmdline_row + (ccline.cmdspos / (Columns - 1)); msg_col = Columns - (ccline.cmdspos % (Columns - 1)) - 1; if (msg_row <= 0) { msg_row = Rows - 1; @@ -4460,7 +4460,7 @@ char_u *sm_gettail(char_u *s, bool eager) #endif ) { if (eager) { - t = p+1; + t = p + 1; } else { had_sep = true; } @@ -5571,7 +5571,7 @@ static int ExpandPackAddDir(char_u *pat, int *num_file, char_u ***file) for (int i = 0; i < ga.ga_len; i++) { char_u *match = ((char_u **)ga.ga_data)[i]; s = path_tail(match); - memmove(match, s, STRLEN(s)+1); + memmove(match, s, STRLEN(s) + 1); } if (GA_EMPTY(&ga)) { @@ -6256,7 +6256,7 @@ void ex_history(exarg_T *eap) if (histype1 == HIST_INVALID) { if (STRNICMP(arg, "all", end - arg) == 0) { histype1 = 0; - histype2 = HIST_COUNT-1; + histype2 = HIST_COUNT - 1; } else { emsg(_(e_trailing)); return; @@ -6282,10 +6282,10 @@ void ex_history(exarg_T *eap) j = hisidx1; k = hisidx2; if (j < 0) { - j = (-j > hislen) ? 0 : hist[(hislen+j+idx+1) % hislen].hisnum; + j = (-j > hislen) ? 0 : hist[(hislen + j + idx + 1) % hislen].hisnum; } if (k < 0) { - k = (-k > hislen) ? 0 : hist[(hislen+k+idx+1) % hislen].hisnum; + k = (-k > hislen) ? 0 : hist[(hislen + k + idx + 1) % hislen].hisnum; } if (idx >= 0 && j <= k) { for (i = idx + 1; !got_int; ++i) { diff --git a/src/nvim/ex_session.h b/src/nvim/ex_session.h index 8d3ea5b91a..7ee2894c6e 100644 --- a/src/nvim/ex_session.h +++ b/src/nvim/ex_session.h @@ -10,4 +10,3 @@ #endif #endif // NVIM_EX_SESSION_H - diff --git a/src/nvim/extmark.c b/src/nvim/extmark.c index a3fcc7d784..ffd68926f1 100644 --- a/src/nvim/extmark.c +++ b/src/nvim/extmark.c @@ -512,7 +512,7 @@ void extmark_adjust(buf_T *buf, linenr_T line1, linenr_T line2, long amount, lon bcount_t old_byte = 0, new_byte = 0; int old_row, new_row; if (amount == MAXLNUM) { - old_row = (int)(line2 - line1+1); + old_row = (int)(line2 - line1 + 1); // TODO(bfredl): ej kasta? old_byte = (bcount_t)buf->deleted_bytes2; @@ -526,11 +526,11 @@ void extmark_adjust(buf_T *buf, linenr_T line1, linenr_T line2, long amount, lon new_row = (int)amount; } if (new_row > 0) { - new_byte = ml_find_line_or_offset(buf, line1+new_row, NULL, true) + new_byte = ml_find_line_or_offset(buf, line1 + new_row, NULL, true) - start_byte; } extmark_splice_impl(buf, - (int)line1-1, 0, start_byte, + (int)line1 - 1, 0, start_byte, old_row, 0, old_byte, new_row, 0, new_byte, undo); } @@ -609,18 +609,18 @@ void extmark_splice_impl(buf_T *buf, int start_row, colnr_T start_col, bcount_t // merge algorithm later. if (old_row == 0 && new_row == 0 && kv_size(uhp->uh_extmark)) { ExtmarkUndoObject *item = &kv_A(uhp->uh_extmark, - kv_size(uhp->uh_extmark)-1); + kv_size(uhp->uh_extmark) - 1); if (item->type == kExtmarkSplice) { ExtmarkSplice *splice = &item->data.splice; if (splice->start_row == start_row && splice->old_row == 0 && splice->new_row == 0) { if (old_col == 0 && start_col >= splice->start_col - && start_col <= splice->start_col+splice->new_col) { + && start_col <= splice->start_col + splice->new_col) { splice->new_col += new_col; splice->new_byte += new_byte; merged = true; } else if (new_col == 0 - && start_col == splice->start_col+splice->new_col) { + && start_col == splice->start_col + splice->new_col) { splice->old_col += old_col; splice->old_byte += old_byte; merged = true; diff --git a/src/nvim/file_search.c b/src/nvim/file_search.c index 8a09c10908..1113459feb 100644 --- a/src/nvim/file_search.c +++ b/src/nvim/file_search.c @@ -374,20 +374,20 @@ void *vim_findfile_init(char_u *path, char_u *filename, char_u *stopdirs, int le walker = vim_strchr(walker, ';'); if (walker) { assert(walker - helper >= 0); - search_ctx->ffsc_stopdirs_v[dircount-1] = + search_ctx->ffsc_stopdirs_v[dircount - 1] = vim_strnsave(helper, (size_t)(walker - helper)); walker++; } else { /* this might be "", which means ascent till top * of directory tree. */ - search_ctx->ffsc_stopdirs_v[dircount-1] = + search_ctx->ffsc_stopdirs_v[dircount - 1] = vim_strsave(helper); } dircount++; } while (walker != NULL); - search_ctx->ffsc_stopdirs_v[dircount-1] = NULL; + search_ctx->ffsc_stopdirs_v[dircount - 1] = NULL; } search_ctx->ffsc_level = level; @@ -1698,4 +1698,3 @@ int vim_chdir(char_u *new_dir) xfree(dir_name); return r; } - diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index d8040219ca..f1195f1644 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -1528,8 +1528,7 @@ rewind_retry: // Need to reset the counters when retrying fenc. try_mac = 1; try_unix = 1; - for (; p >= ptr && *p != CAR; p--) { - } + for (; p >= ptr && *p != CAR; p--) {} if (p >= ptr) { for (p = ptr; p < ptr + size; ++p) { if (*p == NL) { diff --git a/src/nvim/fold.c b/src/nvim/fold.c index bc31fe42ba..ef2987d1ab 100644 --- a/src/nvim/fold.c +++ b/src/nvim/fold.c @@ -1640,11 +1640,11 @@ static void foldAddMarker(buf_T *buf, pos_T pos, const char_u *marker, size_t ma STRCPY(newline + line_len, cms); memcpy(newline + line_len + (p - cms), marker, markerlen); STRCPY(newline + line_len + (p - cms) + markerlen, p + 2); - added = markerlen + STRLEN(cms)-2; + added = markerlen + STRLEN(cms) - 2; } ml_replace_buf(buf, lnum, newline, false); if (added) { - extmark_splice_cols(buf, (int)lnum-1, (int)line_len, + extmark_splice_cols(buf, (int)lnum - 1, (int)line_len, 0, (int)added, kExtmarkUndo); } } @@ -1662,7 +1662,7 @@ static void deleteFoldMarkers(win_T *wp, fold_T *fp, int recursive, linenr_T lnu lnum_off + fp->fd_top); } } - foldDelMarker(wp->w_buffer, fp->fd_top+lnum_off, wp->w_p_fmr, + foldDelMarker(wp->w_buffer, fp->fd_top + lnum_off, wp->w_p_fmr, foldstartmarkerlen); foldDelMarker(wp->w_buffer, fp->fd_top + lnum_off + fp->fd_len - 1, foldendmarker, foldendmarkerlen); @@ -1710,7 +1710,7 @@ static void foldDelMarker(buf_T *buf, linenr_T lnum, char_u *marker, size_t mark memcpy(newline, line, (size_t)(p - line)); STRCPY(newline + (p - line), p + len); ml_replace_buf(buf, lnum, newline, false); - extmark_splice_cols(buf, (int)lnum-1, (int)(p - line), + extmark_splice_cols(buf, (int)lnum - 1, (int)(p - line), (int)len, 0, kExtmarkUndo); } break; @@ -1877,8 +1877,7 @@ void foldtext_cleanup(char_u *str) // May remove 'commentstring' start. Useful when it's a double // quote and we already removed a double quote. - for (p = s; p > str && ascii_iswhite(p[-1]); p--) { - } + for (p = s; p > str && ascii_iswhite(p[-1]); p--) {} if (p >= str + cms_slen && STRNCMP(p - cms_slen, cms_start, cms_slen) == 0) { len += (size_t)(s - p) + cms_slen; @@ -2547,7 +2546,7 @@ static linenr_T foldUpdateIEMSRecurse(garray_T *const gap, const int level, // Make fold that includes lnum start at lnum. foldMarkAdjustRecurse(flp->wp, &fp2->fd_nested, (linenr_T)0, (flp->lnum - fp2->fd_top - 1), - (linenr_T)MAXLNUM, (fp2->fd_top-flp->lnum)); + (linenr_T)MAXLNUM, (fp2->fd_top - flp->lnum)); fp2->fd_len -= flp->lnum - fp2->fd_top; fp2->fd_top = flp->lnum; fold_changed = true; diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index 9fc4c297f5..183e67ae12 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -430,8 +430,7 @@ void flush_buffers(flush_buffers_T flush_typeahead) init_typebuf(); start_stuff(); - while (read_readbuffers(TRUE) != NUL) { - } + while (read_readbuffers(true) != NUL) {} if (flush_typeahead == FLUSH_MINIMAL) { // remove mapped characters at the start only @@ -443,8 +442,7 @@ void flush_buffers(flush_buffers_T flush_typeahead) // We have to get all characters, because we may delete the first // part of an escape sequence. In an xterm we get one char at a // time and we have to get them all. - while (inchar(typebuf.tb_buf, typebuf.tb_buflen - 1, 10L) != 0) { - } + while (inchar(typebuf.tb_buf, typebuf.tb_buflen - 1, 10L) != 0) {} } typebuf.tb_off = MAXMAPLEN; typebuf.tb_len = 0; @@ -494,8 +492,7 @@ void CancelRedo(void) redobuff = old_redobuff; old_redobuff.bh_first.b_next = NULL; start_stuff(); - while (read_readbuffers(TRUE) != NUL) { - } + while (read_readbuffers(true) != NUL) {} } } diff --git a/src/nvim/globals.h b/src/nvim/globals.h index 5983f18bb5..1a51f60ed3 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -15,7 +15,7 @@ #include "nvim/syntax_defs.h" #include "nvim/types.h" -#define IOSIZE (1024+1) // file I/O and sprintf buffer size +#define IOSIZE (1024 + 1) // file I/O and sprintf buffer size #define MSG_BUF_LEN 480 // length of buffer for small messages #define MSG_BUF_CLEN (MSG_BUF_LEN / 6) // cell length (worst case: utf-8 diff --git a/src/nvim/grid_defs.h b/src/nvim/grid_defs.h index bf0a5d63a8..69eca5d123 100644 --- a/src/nvim/grid_defs.h +++ b/src/nvim/grid_defs.h @@ -10,7 +10,7 @@ #define MAX_MCO 6 // fixed value for 'maxcombine' // The characters and attributes drawn on grids. -typedef char_u schar_T[(MAX_MCO+1) * 4 + 1]; +typedef char_u schar_T[(MAX_MCO + 1) * 4 + 1]; typedef int sattr_T; enum { diff --git a/src/nvim/hardcopy.c b/src/nvim/hardcopy.c index 8e03a8827c..a6e7ba9fc1 100644 --- a/src/nvim/hardcopy.c +++ b/src/nvim/hardcopy.c @@ -374,8 +374,8 @@ static char *parse_list_options(char_u *option_str, option_table_T *table, size_ static uint32_t darken_rgb(uint32_t rgb) { return ((rgb >> 17) << 16) - + (((rgb & 0xff00) >> 9) << 8) - + ((rgb & 0xff) >> 1); + + (((rgb & 0xff00) >> 9) << 8) + + ((rgb & 0xff) >> 1); } static uint32_t prt_get_term_color(int colorindex) @@ -3195,4 +3195,3 @@ void mch_print_set_fg(uint32_t fgcol) prt_need_fgcol = true; } } - diff --git a/src/nvim/highlight.c b/src/nvim/highlight.c index 7d91f38d56..90ca0047bd 100644 --- a/src/nvim/highlight.c +++ b/src/nvim/highlight.c @@ -213,7 +213,7 @@ int ns_get_hl(NS ns_id, int hl_id, bool link, bool nodefault) } it.attr_id = fallback ? -1 : hl_get_syn_attr((int)ns_id, hl_id, attrs); - it.version = p->hl_valid-tmp; + it.version = p->hl_valid - tmp; it.is_default = attrs.rgb_ae_attr & HL_DEFAULT; map_put(ColorKey, ColorItem)(&ns_hl, ColorKey(ns_id, hl_id), it); } @@ -602,7 +602,7 @@ 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, b = 100 - ratio; int r1 = (rgb1 & 0xFF0000) >> 16; int g1 = (rgb1 & 0x00FF00) >> 8; int b1 = (rgb1 & 0x0000FF) >> 0; diff --git a/src/nvim/highlight_group.c b/src/nvim/highlight_group.c index 9376ce6a3b..45c7863d00 100644 --- a/src/nvim/highlight_group.c +++ b/src/nvim/highlight_group.c @@ -619,10 +619,10 @@ static int color_numbers_256[28] = { 0, 4, 2, 6, static int color_numbers_8[28] = { 0, 4, 2, 6, 1, 5, 3, 3, 7, 7, 7, 7, - 0+8, 0+8, - 4+8, 4+8, 2+8, 2+8, - 6+8, 6+8, 1+8, 1+8, 5+8, - 5+8, 3+8, 3+8, 7+8, -1 }; + 0 + 8, 0 + 8, + 4 + 8, 4 + 8, 2 + 8, 2 + 8, + 6 + 8, 6 + 8, 1 + 8, 1 + 8, 5 + 8, + 5 + 8, 3 + 8, 3 + 8, 7 + 8, -1 }; // Lookup the "cterm" value to be used for color with index "idx" in // color_names[]. @@ -964,7 +964,7 @@ void do_highlight(const char *line, const bool forceit, const bool init) if (strcmp(key, "NONE") == 0) { if (!init || HL_TABLE()[idx].sg_set == 0) { if (!init) { - HL_TABLE()[idx].sg_set |= SG_CTERM+SG_GUI; + HL_TABLE()[idx].sg_set |= SG_CTERM + SG_GUI; } highlight_clear(idx); } @@ -1385,7 +1385,7 @@ static void highlight_list_one(const int id) 0, sgp->sg_rgb_sp_name, "guisp"); didh = highlight_list_arg(id, didh, LIST_INT, - sgp->sg_blend+1, NULL, "blend"); + sgp->sg_blend + 1, NULL, "blend"); if (sgp->sg_link && !got_int) { (void)syn_list_header(didh, 0, id, true); @@ -1643,10 +1643,10 @@ static void set_hl_attr(int idx) at_en.rgb_sp_color = sgp->sg_rgb_sp_name ? sgp->sg_rgb_sp : -1; at_en.hl_blend = sgp->sg_blend; - sgp->sg_attr = hl_get_syn_attr(0, idx+1, at_en); + sgp->sg_attr = hl_get_syn_attr(0, idx + 1, at_en); // a cursor style uses this syn_id, make sure its attribute is updated. - if (cursor_mode_uses_syn_id(idx+1)) { + if (cursor_mode_uses_syn_id(idx + 1)) { ui_mode_info_set(); } } @@ -2787,7 +2787,7 @@ int name_to_ctermcolor(const char *name) int off = TOUPPER_ASC(*name); for (i = ARRAY_SIZE(color_names); --i >= 0;) { if (off == color_names[i][0] - && STRICMP(name+1, color_names[i]+1) == 0) { + && STRICMP(name + 1, color_names[i] + 1) == 0) { break; } } diff --git a/src/nvim/if_cscope.c b/src/nvim/if_cscope.c index 56517c1741..2f34c8f27b 100644 --- a/src/nvim/if_cscope.c +++ b/src/nvim/if_cscope.c @@ -460,9 +460,9 @@ staterr: if (S_ISDIR(file_info.stat.st_mode)) { fname2 = (char *)xmalloc(strlen(CSCOPE_DBFILE) + strlen(fname) + 2); - while (fname[strlen(fname)-1] == '/' + while (fname[strlen(fname) - 1] == '/' ) { - fname[strlen(fname)-1] = '\0'; + fname[strlen(fname) - 1] = '\0'; if (fname[0] == '\0') { break; } @@ -1444,8 +1444,7 @@ retry: // If the line's too long for the buffer, discard it. if ((p = strchr(buf, '\n')) == NULL) { - while ((ch = getc(csinfo[cnumber].fr_fp)) != EOF && ch != '\n') { - } + while ((ch = getc(csinfo[cnumber].fr_fp)) != EOF && ch != '\n') {} return NULL; } *p = '\0'; @@ -1594,8 +1593,7 @@ static char *cs_pathcomponents(char *path) char *s = path + strlen(path) - 1; for (int i = 0; i < p_cspc; i++) { - while (s > path && *--s != '/') { - } + while (s > path && *--s != '/') {} } if ((s > path && *s == '/')) { s++; diff --git a/src/nvim/indent.c b/src/nvim/indent.c index 59ba2c92f7..2659c2c175 100644 --- a/src/nvim/indent.c +++ b/src/nvim/indent.c @@ -356,7 +356,7 @@ int set_indent(int size, int flags) ml_replace(curwin->w_cursor.lnum, newline, false); if (!(flags & SIN_NOMARK)) { extmark_splice_cols(curbuf, - (int)curwin->w_cursor.lnum-1, + (int)curwin->w_cursor.lnum - 1, skipcols, old_offset - skipcols, new_offset - skipcols, diff --git a/src/nvim/lib/kbtree.h b/src/nvim/lib/kbtree.h index 617773a79a..aca96c9a7a 100644 --- a/src/nvim/lib/kbtree.h +++ b/src/nvim/lib/kbtree.h @@ -51,7 +51,7 @@ struct kbnode_##name##_s { \ int32_t n; \ bool is_internal; \ - key_t key[2*T-1]; \ + key_t key[2*T - 1]; \ kbnode_##name##_t *ptr[]; \ }; \ typedef struct { \ @@ -435,7 +435,7 @@ #define KBTREE_INIT(name, key_t, __cmp, T) \ KBTREE_INIT_IMPL(name, key_t, kbnode_##name##_t, __cmp, T, \ - (sizeof(kbnode_##name##_t)+(2*T)*sizeof(void *))) + (sizeof(kbnode_##name##_t) + (2*T)*sizeof(void *))) #define KBTREE_INIT_IMPL(name, key_t, kbnode_t, __cmp, T, ILEN) \ __KB_TREE_T(name, key_t, T) \ diff --git a/src/nvim/lua/converter.c b/src/nvim/lua/converter.c index ef49a03660..daf3a32a98 100644 --- a/src/nvim/lua/converter.c +++ b/src/nvim/lua/converter.c @@ -1236,7 +1236,7 @@ LuaRef nlua_pop_LuaRef(lua_State *const lstate, Error *err) type ret; \ if (lua_type(lstate, -1) != LUA_TNUMBER) { \ api_set_error(err, kErrorTypeValidation, "Expected Lua number"); \ - ret = (type)-1; \ + ret = (type) - 1; \ } else { \ ret = (type)lua_tonumber(lstate, -1); \ } \ diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c index 81396f1715..2c4d527fdf 100644 --- a/src/nvim/lua/executor.c +++ b/src/nvim/lua/executor.c @@ -332,8 +332,7 @@ static int nlua_schedule(lua_State *const lstate) // Dummy timer callback. Used by f_wait(). static void dummy_timer_due_cb(TimeWatcher *tw, void *data) -{ -} +{} // Dummy timer close callback. Used by f_wait(). static void dummy_timer_close_cb(TimeWatcher *tw, void *data) @@ -543,9 +542,9 @@ static int nlua_module_preloader(lua_State *lstate) ModuleDef def = builtin_modules[i]; char name[256]; name[0] = '@'; - size_t off = xstrlcpy(name+1, def.name, (sizeof name) - 2); - strchrsub(name+1, '.', '/'); - xstrlcpy(name+1+off, ".lua", (sizeof name)-2-off); + size_t off = xstrlcpy(name + 1, def.name, (sizeof name) - 2); + strchrsub(name + 1, '.', '/'); + xstrlcpy(name + 1 + off, ".lua", (sizeof name) - 2 - off); if (luaL_loadbuffer(lstate, (const char *)def.data, def.size - 1, name)) { return lua_error(lstate); @@ -769,7 +768,7 @@ static void nlua_common_free_all_mem(lua_State *lstate) static void nlua_print_event(void **argv) { char *str = argv[0]; - const size_t len = (size_t)(intptr_t)argv[1]-1; // exclude final NUL + const size_t len = (size_t)(intptr_t)argv[1] - 1; // exclude final NUL for (size_t i = 0; i < len;) { if (got_int) { @@ -926,7 +925,7 @@ int nlua_call(lua_State *lstate) return luaL_error(lstate, e_luv_api_disabled, "vimL function"); } - int nargs = lua_gettop(lstate)-1; + int nargs = lua_gettop(lstate) - 1; if (nargs > MAX_FUNC_ARGS) { return luaL_error(lstate, "Function called with too many arguments"); } @@ -934,10 +933,10 @@ int nlua_call(lua_State *lstate) typval_T vim_args[MAX_FUNC_ARGS + 1]; int i = 0; // also used for freeing the variables for (; i < nargs; i++) { - lua_pushvalue(lstate, i+2); + lua_pushvalue(lstate, i + 2); if (!nlua_pop_typval(lstate, &vim_args[i])) { api_set_error(&err, kErrorTypeException, - "error converting argument %d", i+1); + "error converting argument %d", i + 1); goto free_vim_args; } } @@ -994,12 +993,12 @@ static int nlua_rpc(lua_State *lstate, bool request) size_t name_len; uint64_t chan_id = (uint64_t)luaL_checkinteger(lstate, 1); const char *name = luaL_checklstring(lstate, 2, &name_len); - int nargs = lua_gettop(lstate)-2; + int nargs = lua_gettop(lstate) - 2; Error err = ERROR_INIT; Array args = ARRAY_DICT_INIT; for (int i = 0; i < nargs; i++) { - lua_pushvalue(lstate, i+3); + lua_pushvalue(lstate, i + 3); ADD(args, nlua_pop_Object(lstate, false, &err)); if (ERROR_SET(&err)) { api_free_array(args); @@ -1415,7 +1414,7 @@ void ex_lua(exarg_T *const eap) // lua nlua_typval_exec doesn't expect null terminated string so len // needs to end before null byte. char *code_buf = xmallocz(len); - vim_snprintf(code_buf, len+1, "vim.pretty_print(%s)", code+1); + vim_snprintf(code_buf, len + 1, "vim.pretty_print(%s)", code + 1); xfree(code); code = code_buf; } @@ -1820,7 +1819,7 @@ void nlua_set_sctx(sctx_T *current) is_ignored = true; } else { for (int i = 0; i < ignorelist_size; i++) { - if (strncmp(ignorelist[i], info->source+1, strlen(ignorelist[i])) == 0) { + if (strncmp(ignorelist[i], info->source + 1, strlen(ignorelist[i])) == 0) { is_ignored = true; break; } @@ -1912,4 +1911,3 @@ void nlua_do_ucmd(ucmd_T *cmd, exarg_T *eap) nlua_error(lstate, _("Error executing Lua callback: %.*s")); } } - diff --git a/src/nvim/lua/stdlib.c b/src/nvim/lua/stdlib.c index e94c61b37c..52a9a1a84f 100644 --- a/src/nvim/lua/stdlib.c +++ b/src/nvim/lua/stdlib.c @@ -59,8 +59,8 @@ static int regex_match(lua_State *lstate, regprog_T **prog, char_u *str) *prog = rm.regprog; if (match) { - lua_pushinteger(lstate, (lua_Integer)(rm.startp[0]-str)); - lua_pushinteger(lstate, (lua_Integer)(rm.endp[0]-str)); + lua_pushinteger(lstate, (lua_Integer)(rm.startp[0] - str)); + lua_pushinteger(lstate, (lua_Integer)(rm.endp[0] - str)); return 2; } return 0; @@ -110,7 +110,7 @@ static int regex_match_line(lua_State *lstate) return luaL_error(lstate, "invalid row"); } - char_u *line = ml_get_buf(buf, rownr+1, false); + char_u *line = ml_get_buf(buf, rownr + 1, false); size_t len = STRLEN(line); if (start < 0 || (size_t)start > len) { @@ -126,7 +126,7 @@ static int regex_match_line(lua_State *lstate) line[end] = NUL; } - int nret = regex_match(lstate, prog, line+start); + int nret = regex_match(lstate, prog, line + start); if (end >= 0) { line[end] = save; @@ -208,7 +208,7 @@ static int nlua_str_utf_pos(lua_State *const lstate) FUNC_ATTR_NONNULL_ALL size_t idx = 1; size_t clen; for (size_t i = 0; i < s1_len && s1[i] != NUL; i += clen) { - clen = (size_t)utf_ptr2len_len((const char_u *)(s1)+i, (int)(s1_len-i)); + clen = (size_t)utf_ptr2len_len((const char_u *)(s1) + i, (int)(s1_len - i)); lua_pushinteger(lstate, (long)i + 1); lua_rawseti(lstate, -2, (int)idx); idx++; diff --git a/src/nvim/lua/treesitter.c b/src/nvim/lua/treesitter.c index f4067ad02f..a871cd29ce 100644 --- a/src/nvim/lua/treesitter.c +++ b/src/nvim/lua/treesitter.c @@ -208,7 +208,7 @@ int tslua_inspect_lang(lua_State *L) size_t nsymbols = (size_t)ts_language_symbol_count(lang); - lua_createtable(L, nsymbols-1, 1); // [retval, symbols] + lua_createtable(L, nsymbols - 1, 1); // [retval, symbols] for (size_t i = 0; i < nsymbols; i++) { TSSymbolType t = ts_language_symbol_type(lang, i); if (t == TSSymbolTypeAuxiliary) { @@ -298,15 +298,15 @@ static const char *input_cb(void *payload, uint32_t byte_index, TSPoint position *bytes_read = 0; return ""; } - char_u *line = ml_get_buf(bp, position.row+1, false); + char_u *line = ml_get_buf(bp, position.row + 1, false); size_t len = STRLEN(line); if (position.column > len) { *bytes_read = 0; return ""; } - size_t tocopy = MIN(len-position.column, BUFSIZE); + size_t tocopy = MIN(len - position.column, BUFSIZE); - memcpy(buf, line+position.column, tocopy); + memcpy(buf, line + position.column, tocopy); // Translate embedded \n to NUL memchrsub(buf, '\n', '\0', tocopy); *bytes_read = (uint32_t)tocopy; @@ -334,7 +334,7 @@ static void push_ranges(lua_State *L, const TSRange *ranges, const unsigned int lua_pushinteger(L, ranges[i].end_point.column); lua_rawseti(L, -2, 4); - lua_rawseti(L, -2, i+1); + lua_rawseti(L, -2, i + 1); } } @@ -1037,7 +1037,7 @@ static void set_match(lua_State *L, TSQueryMatch *match, int nodeidx) { for (int i = 0; i < match->capture_count; i++) { push_node(L, match->captures[i].node, nodeidx); - lua_rawseti(L, -2, match->captures[i].index+1); + lua_rawseti(L, -2, match->captures[i].index + 1); } } @@ -1049,7 +1049,7 @@ static int query_next_match(lua_State *L) TSQuery *query = query_check(L, lua_upvalueindex(3)); TSQueryMatch match; if (ts_query_cursor_next_match(cursor, &match)) { - lua_pushinteger(L, match.pattern_index+1); // [index] + lua_pushinteger(L, match.pattern_index + 1); // [index] lua_createtable(L, ts_query_capture_count(query), 2); // [index, match] set_match(L, &match, lua_upvalueindex(2)); return 2; @@ -1082,7 +1082,7 @@ static int query_next_capture(lua_State *L) if (ts_query_cursor_next_capture(cursor, &match, &capture_index)) { TSQueryCapture capture = match.captures[capture_index]; - lua_pushinteger(L, capture.index+1); // [index] + lua_pushinteger(L, capture.index + 1); // [index] push_node(L, capture.node, lua_upvalueindex(2)); // [index, node] // Now check if we need to run the predicates @@ -1094,7 +1094,7 @@ static int query_next_capture(lua_State *L) lua_pushvalue(L, lua_upvalueindex(4)); // [index, node, match] set_match(L, &match, lua_upvalueindex(2)); - lua_pushinteger(L, match.pattern_index+1); + lua_pushinteger(L, match.pattern_index + 1); lua_setfield(L, -2, "pattern"); if (match.capture_count > 1) { @@ -1273,7 +1273,7 @@ static int query_inspect(lua_State *L) &strlen); lua_pushlstring(L, str, strlen); // [retval, patterns, pat, pred, item] } else if (step[k].type == TSQueryPredicateStepTypeCapture) { - lua_pushnumber(L, step[k].value_id+1); // [..., pat, pred, item] + lua_pushnumber(L, step[k].value_id + 1); // [..., pat, pred, item] } else { abort(); } @@ -1281,7 +1281,7 @@ static int query_inspect(lua_State *L) } // last predicate should have ended with TypeDone lua_pop(L, 1); // [retval, patters, pat] - lua_rawseti(L, -2, i+1); // [retval, patterns] + lua_rawseti(L, -2, i + 1); // [retval, patterns] } lua_setfield(L, -2, "patterns"); // [retval] @@ -1291,7 +1291,7 @@ static int query_inspect(lua_State *L) uint32_t strlen; const char *str = ts_query_capture_name_for_id(query, i, &strlen); lua_pushlstring(L, str, strlen); // [retval, captures, capture] - lua_rawseti(L, -2, i+1); + lua_rawseti(L, -2, i + 1); } lua_setfield(L, -2, "captures"); // [retval] diff --git a/src/nvim/lua/xdiff.c b/src/nvim/lua/xdiff.c index 37855630d1..71f85385b6 100644 --- a/src/nvim/lua/xdiff.c +++ b/src/nvim/lua/xdiff.c @@ -74,7 +74,7 @@ static int hunk_locations_cb(long start_a, long count_a, long start_b, long coun lua_pushinteger(lstate, count_b); lua_rawseti(lstate, -2, 4); - lua_rawseti(lstate, -2, (signed)lua_objlen(lstate, -2)+1); + lua_rawseti(lstate, -2, (signed)lua_objlen(lstate, -2) + 1); return 0; } diff --git a/src/nvim/mark.c b/src/nvim/mark.c index 0dbfb0c49f..4f4eea554a 100644 --- a/src/nvim/mark.c +++ b/src/nvim/mark.c @@ -1139,7 +1139,7 @@ static void mark_adjust_internal(linenr_T line1, linenr_T line2, long amount, lo { \ posp->lnum += lnum_amount; \ assert(col_amount > INT_MIN && col_amount <= INT_MAX); \ - if (col_amount < 0 && posp->col <= (colnr_T)-col_amount) { \ + if (col_amount < 0 && posp->col <= (colnr_T) - col_amount) { \ posp->col = 0; \ } else if (posp->col < spaces_removed) { \ posp->col = (int)col_amount + spaces_removed; \ diff --git a/src/nvim/marktree.c b/src/nvim/marktree.c index 937582572b..ff31567bf5 100644 --- a/src/nvim/marktree.c +++ b/src/nvim/marktree.c @@ -54,7 +54,7 @@ #include "nvim/marktree.h" #define T MT_BRANCH_FACTOR -#define ILEN (sizeof(mtnode_t)+(2 * T) * sizeof(void *)) +#define ILEN (sizeof(mtnode_t) + (2 * T) * sizeof(void *)) #define ID_INCR (((uint64_t)1) << 2) @@ -158,7 +158,7 @@ static inline void split_node(MarkTree *b, mtnode_t *x, const int i) z->level = y->level; z->n = T - 1; memcpy(z->key, &y->key[T], sizeof(mtkey_t) * (T - 1)); - for (int j = 0; j < T-1; j++) { + for (int j = 0; j < T - 1; j++) { refkey(b, z, j); } if (y->level) { @@ -179,11 +179,11 @@ static inline void split_node(MarkTree *b, mtnode_t *x, const int i) refkey(b, x, i); x->n++; - for (int j = 0; j < T-1; j++) { + for (int j = 0; j < T - 1; j++) { relative(x->key[i].pos, &z->key[j].pos); } if (i > 0) { - unrelative(x->key[i-1].pos, &x->key[i].pos); + unrelative(x->key[i - 1].pos, &x->key[i].pos); } } @@ -198,7 +198,7 @@ static inline void marktree_putp_aux(MarkTree *b, mtnode_t *x, mtkey_t k) (size_t)(x->n - i - 1) * sizeof(mtkey_t)); } x->key[i + 1] = k; - refkey(b, x, i+1); + refkey(b, x, i + 1); x->n++; } else { i = marktree_getp_aux(x, k, 0) + 1; @@ -209,7 +209,7 @@ static inline void marktree_putp_aux(MarkTree *b, mtnode_t *x, mtkey_t k) } } if (i > 0) { - relative(x->key[i-1].pos, &k.pos); + relative(x->key[i - 1].pos, &k.pos); } marktree_putp_aux(b, x->ptr[i], k); } @@ -247,7 +247,7 @@ void marktree_put_key(MarkTree *b, mtkey_t k) if (r->n == 2 * T - 1) { b->n_nodes++; s = (mtnode_t *)xcalloc(1, ILEN); - b->root = s; s->level = r->level+1; s->n = 0; + b->root = s; s->level = r->level + 1; s->n = 0; s->ptr[0] = r; r->parent = s; split_node(b, s, 0); @@ -304,9 +304,9 @@ void marktree_del_itr(MarkTree *b, MarkTreeIter *itr, bool rev) mtnode_t *x = itr->node; assert(x->level == 0); mtkey_t intkey = x->key[itr->i]; - if (x->n > itr->i+1) { - memmove(&x->key[itr->i], &x->key[itr->i+1], - sizeof(mtkey_t) * (size_t)(x->n - itr->i-1)); + if (x->n > itr->i + 1) { + memmove(&x->key[itr->i], &x->key[itr->i + 1], + sizeof(mtkey_t) * (size_t)(x->n - itr->i - 1)); } x->n--; @@ -315,7 +315,7 @@ void marktree_del_itr(MarkTree *b, MarkTreeIter *itr, bool rev) // abort(); // } if (adjustment == -1) { - int ilvl = itr->lvl-1; + int ilvl = itr->lvl - 1; const mtnode_t *lnode = x; do { const mtnode_t *const p = lnode->parent; @@ -325,7 +325,7 @@ void marktree_del_itr(MarkTree *b, MarkTreeIter *itr, bool rev) const int i = itr->s[ilvl].i; assert(p->ptr[i] == lnode); if (i > 0) { - unrelative(p->key[i-1].pos, &intkey.pos); + unrelative(p->key[i - 1].pos, &intkey.pos); } lnode = p; ilvl--; @@ -335,7 +335,7 @@ void marktree_del_itr(MarkTree *b, MarkTreeIter *itr, bool rev) cur->key[curi] = intkey; refkey(b, cur, curi); relative(intkey.pos, &deleted.pos); - mtnode_t *y = cur->ptr[curi+1]; + mtnode_t *y = cur->ptr[curi + 1]; if (deleted.pos.row || deleted.pos.col) { while (y) { for (int k = 0; k < y->n; k++) { @@ -352,33 +352,33 @@ void marktree_del_itr(MarkTree *b, MarkTreeIter *itr, bool rev) // 5. bool itr_dirty = false; - int rlvl = itr->lvl-1; + int rlvl = itr->lvl - 1; int *lasti = &itr->i; while (x != b->root) { assert(rlvl >= 0); mtnode_t *p = x->parent; - if (x->n >= T-1) { + if (x->n >= T - 1) { // we are done, if this node is fine the rest of the tree will be break; } int pi = itr->s[rlvl].i; assert(p->ptr[pi] == x); - if (pi > 0 && p->ptr[pi-1]->n > T-1) { + if (pi > 0 && p->ptr[pi - 1]->n > T - 1) { *lasti += 1; itr_dirty = true; // steal one key from the left neighbour - pivot_right(b, p, pi-1); + pivot_right(b, p, pi - 1); break; - } else if (pi < p->n && p->ptr[pi+1]->n > T-1) { + } else if (pi < p->n && p->ptr[pi + 1]->n > T - 1) { // steal one key from right neighbour pivot_left(b, p, pi); break; } else if (pi > 0) { // fprintf(stderr, "LEFT "); - assert(p->ptr[pi-1]->n == T-1); + assert(p->ptr[pi - 1]->n == T - 1); // merge with left neighbour *lasti += T; - x = merge_node(b, p, pi-1); + x = merge_node(b, p, pi - 1); if (lasti == &itr->i) { // TRICKY: we merged the node the iterator was on itr->node = x; @@ -387,7 +387,7 @@ void marktree_del_itr(MarkTree *b, MarkTreeIter *itr, bool rev) itr_dirty = true; } else { // fprintf(stderr, "RIGHT "); - assert(pi < p->n && p->ptr[pi+1]->n == T-1); + assert(pi < p->n && p->ptr[pi + 1]->n == T - 1); merge_node(b, p, pi); // no iter adjustment needed } @@ -399,7 +399,7 @@ void marktree_del_itr(MarkTree *b, MarkTreeIter *itr, bool rev) // 6. if (b->root->n == 0) { if (itr->lvl > 0) { - memmove(itr->s, itr->s+1, (size_t)(itr->lvl-1) * sizeof(*itr->s)); + memmove(itr->s, itr->s + 1, (size_t)(itr->lvl - 1) * sizeof(*itr->s)); itr->lvl--; } if (b->root->level) { @@ -441,26 +441,26 @@ void marktree_del_itr(MarkTree *b, MarkTreeIter *itr, bool rev) static mtnode_t *merge_node(MarkTree *b, mtnode_t *p, int i) { - mtnode_t *x = p->ptr[i], *y = p->ptr[i+1]; + mtnode_t *x = p->ptr[i], *y = p->ptr[i + 1]; x->key[x->n] = p->key[i]; refkey(b, x, x->n); if (i > 0) { - relative(p->key[i-1].pos, &x->key[x->n].pos); + relative(p->key[i - 1].pos, &x->key[x->n].pos); } - memmove(&x->key[x->n+1], y->key, (size_t)y->n * sizeof(mtkey_t)); + memmove(&x->key[x->n + 1], y->key, (size_t)y->n * sizeof(mtkey_t)); for (int k = 0; k < y->n; k++) { - refkey(b, x, x->n+1+k); - unrelative(x->key[x->n].pos, &x->key[x->n+1+k].pos); + refkey(b, x, x->n + 1 + k); + unrelative(x->key[x->n].pos, &x->key[x->n + 1 + k].pos); } if (x->level) { - memmove(&x->ptr[x->n+1], y->ptr, ((size_t)y->n + 1) * sizeof(mtnode_t *)); - for (int k = 0; k < y->n+1; k++) { - x->ptr[x->n+k+1]->parent = x; + memmove(&x->ptr[x->n + 1], y->ptr, ((size_t)y->n + 1) * sizeof(mtnode_t *)); + for (int k = 0; k < y->n + 1; k++) { + x->ptr[x->n + k + 1]->parent = x; } } - x->n += y->n+1; + x->n += y->n + 1; memmove(&p->key[i], &p->key[i + 1], (size_t)(p->n - i - 1) * sizeof(mtkey_t)); memmove(&p->ptr[i + 1], &p->ptr[i + 2], (size_t)(p->n - i - 1) * sizeof(mtkey_t *)); @@ -474,7 +474,7 @@ static mtnode_t *merge_node(MarkTree *b, mtnode_t *p, int i) // the two nodes instead of stealing just one key static void pivot_right(MarkTree *b, mtnode_t *p, int i) { - mtnode_t *x = p->ptr[i], *y = p->ptr[i+1]; + mtnode_t *x = p->ptr[i], *y = p->ptr[i + 1]; memmove(&y->key[1], y->key, (size_t)y->n * sizeof(mtkey_t)); if (y->level) { memmove(&y->ptr[1], y->ptr, ((size_t)y->n + 1) * sizeof(mtnode_t *)); @@ -490,7 +490,7 @@ static void pivot_right(MarkTree *b, mtnode_t *p, int i) x->n--; y->n++; if (i > 0) { - unrelative(p->key[i-1].pos, &p->key[i].pos); + unrelative(p->key[i - 1].pos, &p->key[i].pos); } relative(p->key[i].pos, &y->key[0].pos); for (int k = 1; k < y->n; k++) { @@ -500,7 +500,7 @@ static void pivot_right(MarkTree *b, mtnode_t *p, int i) static void pivot_left(MarkTree *b, mtnode_t *p, int i) { - mtnode_t *x = p->ptr[i], *y = p->ptr[i+1]; + mtnode_t *x = p->ptr[i], *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. @@ -509,7 +509,7 @@ static void pivot_left(MarkTree *b, mtnode_t *p, int i) } unrelative(p->key[i].pos, &y->key[0].pos); if (i > 0) { - relative(p->key[i-1].pos, &p->key[i].pos); + relative(p->key[i - 1].pos, &p->key[i].pos); } x->key[x->n] = p->key[i]; @@ -517,10 +517,10 @@ static void pivot_left(MarkTree *b, mtnode_t *p, int i) p->key[i] = y->key[0]; refkey(b, p, i); if (x->level) { - x->ptr[x->n+1] = y->ptr[0]; - x->ptr[x->n+1]->parent = x; + x->ptr[x->n + 1] = y->ptr[0]; + x->ptr[x->n + 1]->parent = x; } - memmove(y->key, &y->key[1], (size_t)(y->n-1) * sizeof(mtkey_t)); + memmove(y->key, &y->key[1], (size_t)(y->n - 1) * sizeof(mtkey_t)); if (y->level) { memmove(y->ptr, &y->ptr[1], (size_t)y->n * sizeof(mtnode_t *)); } @@ -546,7 +546,7 @@ void marktree_clear(MarkTree *b) void marktree_free_node(mtnode_t *x) { if (x->level) { - for (int i = 0; i < x->n+1; i++) { + for (int i = 0; i < x->n + 1; i++) { marktree_free_node(x->ptr[i]); } } @@ -608,7 +608,7 @@ bool marktree_itr_get_ext(MarkTree *b, mtpos_t p, MarkTreeIter *itr, bool last, oldbase[itr->lvl] = itr->pos; } while (true) { - itr->i = marktree_getp_aux(itr->node, k, 0)+1; + itr->i = marktree_getp_aux(itr->node, k, 0) + 1; if (itr->node->level == 0) { break; @@ -618,8 +618,8 @@ bool marktree_itr_get_ext(MarkTree *b, mtpos_t p, MarkTreeIter *itr, bool last, itr->s[itr->lvl].oldcol = itr->pos.col; if (itr->i > 0) { - compose(&itr->pos, itr->node->key[itr->i-1].pos); - relative(itr->node->key[itr->i-1].pos, &k.pos); + compose(&itr->pos, itr->node->key[itr->i - 1].pos); + relative(itr->node->key[itr->i - 1].pos, &k.pos); } itr->node = itr->node->ptr[itr->i]; itr->lvl++; @@ -676,7 +676,7 @@ int marktree_itr_last(MarkTree *b, MarkTreeIter *itr) itr->s[itr->lvl].oldcol = itr->pos.col; assert(itr->i > 0); - compose(&itr->pos, itr->node->key[itr->i-1].pos); + compose(&itr->pos, itr->node->key[itr->i - 1].pos); itr->node = itr->node->ptr[itr->i]; itr->lvl++; @@ -712,7 +712,7 @@ static bool marktree_itr_next_skip(MarkTree *b, MarkTreeIter *itr, bool skip, mt itr->lvl--; itr->i = itr->s[itr->lvl].i; if (itr->i > 0) { - itr->pos.row -= itr->node->key[itr->i-1].pos.row; + itr->pos.row -= itr->node->key[itr->i - 1].pos.row; itr->pos.col = itr->s[itr->lvl].oldcol; } } @@ -723,10 +723,10 @@ static bool marktree_itr_next_skip(MarkTree *b, MarkTreeIter *itr, bool skip, mt // internal key, there is always a child after if (itr->i > 0) { itr->s[itr->lvl].oldcol = itr->pos.col; - compose(&itr->pos, itr->node->key[itr->i-1].pos); + compose(&itr->pos, itr->node->key[itr->i - 1].pos); } if (oldbase && itr->i == 0) { - oldbase[itr->lvl+1] = oldbase[itr->lvl]; + oldbase[itr->lvl + 1] = oldbase[itr->lvl]; } itr->s[itr->lvl].i = itr->i; assert(itr->node->ptr[itr->i]->parent == itr->node); @@ -757,7 +757,7 @@ bool marktree_itr_prev(MarkTree *b, MarkTreeIter *itr) return false; } itr->lvl--; - itr->i = itr->s[itr->lvl].i-1; + itr->i = itr->s[itr->lvl].i - 1; if (itr->i >= 0) { itr->pos.row -= itr->node->key[itr->i].pos.row; itr->pos.col = itr->s[itr->lvl].oldcol; @@ -770,7 +770,7 @@ bool marktree_itr_prev(MarkTree *b, MarkTreeIter *itr) // internal key, there is always a child before if (itr->i > 0) { itr->s[itr->lvl].oldcol = itr->pos.col; - compose(&itr->pos, itr->node->key[itr->i-1].pos); + compose(&itr->pos, itr->node->key[itr->i - 1].pos); } itr->s[itr->lvl].i = itr->i; assert(itr->node->ptr[itr->i]->parent == itr->node); @@ -796,7 +796,7 @@ void marktree_itr_rewind(MarkTree *b, MarkTreeIter *itr) bool marktree_itr_node_done(MarkTreeIter *itr) { - return !itr->node || itr->i == itr->node->n-1; + return !itr->node || itr->i == itr->node->n - 1; } @@ -854,7 +854,7 @@ bool marktree_splice(MarkTree *b, int start_line, int start_col, int old_extent_ return false; } mtpos_t delta = { new_extent.row - old_extent.row, - new_extent.col-old_extent.col }; + new_extent.col - old_extent.col }; if (may_delete) { mtpos_t ipos = marktree_itr_pos(itr); @@ -913,13 +913,13 @@ continue_same_node: moved = true; if (itr->node->level) { - oldbase[itr->lvl+1] = rawkey(itr).pos; - unrelative(oldbase[itr->lvl], &oldbase[itr->lvl+1]); + oldbase[itr->lvl + 1] = rawkey(itr).pos; + unrelative(oldbase[itr->lvl], &oldbase[itr->lvl + 1]); rawkey(itr).pos = loc_start; marktree_itr_next_skip(b, itr, false, oldbase); } else { rawkey(itr).pos = loc_start; - if (itr->i < itr->node->n-1) { + if (itr->i < itr->node->n - 1) { itr->i++; if (!past_right) { goto continue_same_node; @@ -946,12 +946,12 @@ past_continue_same_node: rawkey(itr).pos = loc_new; moved = true; if (itr->node->level) { - oldbase[itr->lvl+1] = oldpos; - unrelative(oldbase[itr->lvl], &oldbase[itr->lvl+1]); + oldbase[itr->lvl + 1] = oldpos; + unrelative(oldbase[itr->lvl], &oldbase[itr->lvl + 1]); marktree_itr_next_skip(b, itr, false, oldbase); } else { - if (itr->i < itr->node->n-1) { + if (itr->i < itr->node->n - 1) { itr->i++; goto past_continue_same_node; } else { @@ -1056,7 +1056,7 @@ found: {} } while (n->parent != NULL) { mtnode_t *p = n->parent; - for (i = 0; i < p->n+1; i++) { + for (i = 0; i < p->n + 1; i++) { if (p->ptr[i] == n) { goto found_node; } @@ -1064,10 +1064,10 @@ found: {} abort(); found_node: if (itr) { - itr->s[b->root->level-p->level].i = i; + itr->s[b->root->level - p->level].i = i; } if (i > 0) { - unrelative(p->key[i-1].pos, &key.pos); + unrelative(p->key[i - 1].pos, &key.pos); } n = p; } @@ -1099,7 +1099,7 @@ static void marktree_itr_fix_pos(MarkTree *b, MarkTreeIter *itr) itr->s[lvl].oldcol = itr->pos.col; int i = itr->s[lvl].i; if (i > 0) { - compose(&itr->pos, x->key[i-1].pos); + compose(&itr->pos, x->key[i - 1].pos); } assert(x->level); x = x->ptr[i]; @@ -1147,7 +1147,7 @@ static size_t check_node(MarkTree *b, mtnode_t *x, mtpos_t *last, bool *last_rig { assert(x->n <= 2 * T - 1); // TODO(bfredl): too strict if checking "in repair" post-delete tree. - assert(x->n >= (x != b->root ? T-1 : 0)); + assert(x->n >= (x != b->root ? T - 1 : 0)); size_t n_keys = (size_t)x->n; for (int i = 0; i < x->n; i++) { @@ -1157,7 +1157,7 @@ static size_t check_node(MarkTree *b, mtnode_t *x, mtpos_t *last, bool *last_rig *last = (mtpos_t) { 0, 0 }; } if (i > 0) { - unrelative(x->key[i-1].pos, last); + unrelative(x->key[i - 1].pos, last); } assert(pos_leq(*last, x->key[i].pos)); if (last->row == x->key[i].pos.row && last->col == x->key[i].pos.col) { @@ -1170,18 +1170,18 @@ static size_t check_node(MarkTree *b, mtnode_t *x, mtpos_t *last, bool *last_rig if (x->level) { n_keys += check_node(b, x->ptr[x->n], last, last_right); - unrelative(x->key[x->n-1].pos, last); + unrelative(x->key[x->n - 1].pos, last); - for (int i = 0; i < x->n+1; i++) { + for (int i = 0; i < x->n + 1; i++) { assert(x->ptr[i]->parent == x); - assert(x->ptr[i]->level == x->level-1); + assert(x->ptr[i]->level == x->level - 1); // PARANOIA: check no double node ref for (int j = 0; j < i; j++) { assert(x->ptr[i] != x->ptr[j]); } } } else { - *last = x->key[x->n-1].pos; + *last = x->key[x->n - 1].pos; } return n_keys; } @@ -1209,11 +1209,10 @@ void mt_inspect_node(MarkTree *b, garray_T *ga, mtnode_t *n, mtpos_t off) snprintf((char *)buf, sizeof(buf), "%d/%d", p.row, p.col); ga_concat(ga, buf); if (n->level) { - mt_inspect_node(b, ga, n->ptr[i+1], p); + mt_inspect_node(b, ga, n->ptr[i + 1], p); } else { ga_concat(ga, ","); } } ga_concat(ga, "]"); } - diff --git a/src/nvim/marktree.h b/src/nvim/marktree.h index ae6da92106..5b3171d9aa 100644 --- a/src/nvim/marktree.h +++ b/src/nvim/marktree.h @@ -55,7 +55,7 @@ typedef struct { #define DECOR_LEVELS 4 #define MT_FLAG_DECOR_OFFSET 4 -#define MT_FLAG_DECOR_MASK (((uint16_t)(DECOR_LEVELS-1)) << MT_FLAG_DECOR_OFFSET) +#define MT_FLAG_DECOR_MASK (((uint16_t)(DECOR_LEVELS - 1)) << MT_FLAG_DECOR_OFFSET) // next flag is (((uint16_t)1) << 6) diff --git a/src/nvim/match.c b/src/nvim/match.c index afbf28c77b..86ddad0d47 100644 --- a/src/nvim/match.c +++ b/src/nvim/match.c @@ -1215,4 +1215,3 @@ void ex_match(exarg_T *eap) } eap->nextcmd = find_nextcmd(end); } - diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index 6e3c5322e7..10744a86dc 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -584,8 +584,8 @@ size_t mb_string2cells_len(const char_u *str, size_t size) { size_t clen = 0; - for (const char_u *p = str; *p != NUL && p < str+size; - p += utfc_ptr2len_len(p, size+(p-str))) { + for (const char_u *p = str; *p != NUL && p < str + size; + p += utfc_ptr2len_len(p, size + (p - str))) { clen += utf_ptr2cells(p); } @@ -808,7 +808,7 @@ int utfc_ptr2char_len(const char_u *p, int *pcc, int maxlen) int len_cc = utf_ptr2len_len(p + len, maxlen - len); safe = len_cc > 1 && len_cc <= maxlen - len; if (!safe || (pcc[i] = utf_ptr2char(p + len)) < 0x80 - || !(i == 0 ? utf_composinglike(p, p+len) : utf_iscomposing(pcc[i]))) { + || !(i == 0 ? utf_composinglike(p, p + len) : utf_iscomposing(pcc[i]))) { break; } len += len_cc; @@ -1507,10 +1507,10 @@ void mb_utflen(const char_u *s, size_t len, size_t *codepoints, size_t *codeunit size_t count = 0, extra = 0; size_t clen; for (size_t i = 0; i < len && s[i] != NUL; i += clen) { - clen = utf_ptr2len_len(s+i, len-i); + clen = utf_ptr2len_len(s + i, len - i); // NB: gets the byte value of invalid sequence bytes. // we only care whether the char fits in the BMP or not - int c = (clen > 1) ? utf_ptr2char(s+i) : s[i]; + int c = (clen > 1) ? utf_ptr2char(s + i) : s[i]; count++; if (c > 0xFFFF) { extra++; @@ -1529,16 +1529,16 @@ ssize_t mb_utf_index_to_bytes(const char_u *s, size_t len, size_t index, bool us return 0; } for (i = 0; i < len && s[i] != NUL; i += clen) { - clen = utf_ptr2len_len(s+i, len-i); + clen = utf_ptr2len_len(s + i, len - i); // NB: gets the byte value of invalid sequence bytes. // we only care whether the char fits in the BMP or not - int c = (clen > 1) ? utf_ptr2char(s+i) : s[i]; + int c = (clen > 1) ? utf_ptr2char(s + i) : s[i]; count++; if (use_utf16_units && c > 0xFFFF) { count++; } if (count >= index) { - return i+clen; + return i + clen; } } return -1; diff --git a/src/nvim/memline.c b/src/nvim/memline.c index 5c2f494450..ce6c702276 100644 --- a/src/nvim/memline.c +++ b/src/nvim/memline.c @@ -972,8 +972,7 @@ void ml_recover(bool checkext) if (b0p->b0_flags & B0_HAS_FENC) { int fnsize = B0_FNAME_SIZE_NOCRYPT; - for (p = b0p->b0_fname + fnsize; p > b0p->b0_fname && p[-1] != NUL; p--) { - } + for (p = b0p->b0_fname + fnsize; p > b0p->b0_fname && p[-1] != NUL; p--) {} b0_fenc = vim_strnsave(p, b0p->b0_fname + fnsize - p); } @@ -2438,8 +2437,8 @@ void ml_add_deleted_len_buf(buf_T *buf, char_u *ptr, ssize_t len) if (len == -1) { len = STRLEN(ptr); } - curbuf->deleted_bytes += len+1; - curbuf->deleted_bytes2 += len+1; + curbuf->deleted_bytes += len + 1; + curbuf->deleted_bytes2 += len + 1; if (curbuf->update_need_codepoints) { mb_utflen(ptr, len, &curbuf->deleted_codepoints, &curbuf->deleted_codeunits); @@ -2585,7 +2584,7 @@ static int ml_delete_int(buf_T *buf, linenr_T lnum, bool message) // Line should always have an NL char internally (represented as NUL), // even if 'noeol' is set. assert(line_size >= 1); - ml_add_deleted_len_buf(buf, (char_u *)dp + line_start, line_size-1); + ml_add_deleted_len_buf(buf, (char_u *)dp + line_start, line_size - 1); /* * special case: If there is only one line in the data block it becomes empty. diff --git a/src/nvim/memory.c b/src/nvim/memory.c index 14930238e5..19144a5dce 100644 --- a/src/nvim/memory.c +++ b/src/nvim/memory.c @@ -709,4 +709,3 @@ void free_all_mem(void) } #endif - diff --git a/src/nvim/menu.c b/src/nvim/menu.c index d2293a6923..54d3f4c55d 100644 --- a/src/nvim/menu.c +++ b/src/nvim/menu.c @@ -486,8 +486,7 @@ erret: } else { menup = &parent->parent->children; } - for (; *menup != NULL && *menup != parent; menup = &((*menup)->next)) { - } + for (; *menup != NULL && *menup != parent; menup = &((*menup)->next)) {} if (*menup == NULL) { // safety check break; } @@ -1656,4 +1655,3 @@ static char *menu_translate_tab_and_shift(char *arg_start) return arg; } - diff --git a/src/nvim/message.c b/src/nvim/message.c index 3660dc20af..66df3f8a6f 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -1022,8 +1022,7 @@ void ex_messages(void *const eap_p) c -= eap->line2; // Skip without number of messages specified - for (p = first_msg_hist; p != NULL && !got_int && c > 0; p = p->next, c--) { - } + for (p = first_msg_hist; p != NULL && !got_int && c > 0; p = p->next, c--) {} } // Display what was not skipped. @@ -2314,18 +2313,18 @@ void msg_scroll_up(bool may_throttle) msg_did_scroll = true; if (msg_use_msgsep()) { if (msg_grid_pos > 0) { - msg_grid_set_pos(msg_grid_pos-1, true); + msg_grid_set_pos(msg_grid_pos - 1, true); } else { grid_del_lines(&msg_grid, 0, 1, msg_grid.Rows, 0, msg_grid.Columns); - memmove(msg_grid.dirty_col, msg_grid.dirty_col+1, - (msg_grid.Rows-1) * sizeof(*msg_grid.dirty_col)); - msg_grid.dirty_col[msg_grid.Rows-1] = 0; + memmove(msg_grid.dirty_col, msg_grid.dirty_col + 1, + (msg_grid.Rows - 1) * sizeof(*msg_grid.dirty_col)); + msg_grid.dirty_col[msg_grid.Rows - 1] = 0; } } else { grid_del_lines(&msg_grid_adj, 0, 1, Rows, 0, Columns); } - grid_fill(&msg_grid_adj, Rows-1, Rows, 0, Columns, ' ', ' ', + grid_fill(&msg_grid_adj, Rows - 1, Rows, 0, Columns, ' ', ' ', HL_ATTR(HLF_MSG)); } @@ -2358,7 +2357,7 @@ void msg_scroll_flush(void) ui_ext_msg_set_pos(msg_grid_pos, true); } - int to_scroll = delta-pos_delta-msg_grid_scroll_discount; + int to_scroll = delta - pos_delta - msg_grid_scroll_discount; assert(to_scroll >= 0); // TODO(bfredl): msg_grid_pos should be 0 already when starting scrolling @@ -2367,8 +2366,8 @@ void msg_scroll_flush(void) ui_call_grid_scroll(msg_grid.handle, 0, Rows, 0, Columns, to_scroll, 0); } - for (int i = MAX(Rows-MAX(delta, 1), 0); i < Rows; i++) { - int row = i-msg_grid_pos; + for (int i = MAX(Rows - MAX(delta, 1), 0); i < Rows; i++) { + int row = i - msg_grid_pos; assert(row >= 0); ui_line(&msg_grid, row, 0, msg_grid.dirty_col[row], msg_grid.Columns, HL_ATTR(HLF_MSG), false); @@ -2881,7 +2880,7 @@ static int do_more_prompt(int typed_char) // scroll up, display line at bottom msg_scroll_up(true); inc_msg_scrolled(); - grid_fill(&msg_grid_adj, Rows-2, Rows-1, 0, Columns, ' ', ' ', + grid_fill(&msg_grid_adj, Rows - 2, Rows - 1, 0, Columns, ' ', ' ', HL_ATTR(HLF_MSG)); mp_last = disp_sb_line(Rows - 2, mp_last); toscroll--; @@ -3044,7 +3043,7 @@ void msg_clr_eos_force(void) HL_ATTR(HLF_MSG)); redraw_cmdline = true; // overwritten the command line - if (msg_row < Rows-1 || msg_col == (cmdmsg_rl ? Columns : 0)) { + if (msg_row < Rows - 1 || msg_col == (cmdmsg_rl ? Columns : 0)) { clear_cmdline = false; // command line has been cleared mode_displayed = false; // mode cleared or overwritten } diff --git a/src/nvim/mouse.c b/src/nvim/mouse.c index 6b27ce9d7b..4495473074 100644 --- a/src/nvim/mouse.c +++ b/src/nvim/mouse.c @@ -262,8 +262,8 @@ retnomove: } if (grid == 0) { - row -= curwin->w_grid_alloc.comp_row+curwin->w_grid.row_offset; - col -= curwin->w_grid_alloc.comp_col+curwin->w_grid.col_offset; + row -= curwin->w_grid_alloc.comp_row + curwin->w_grid.row_offset; + col -= curwin->w_grid_alloc.comp_col + curwin->w_grid.col_offset; } // When clicking beyond the end of the window, scroll the screen. @@ -512,8 +512,8 @@ static win_T *mouse_find_grid_win(int *gridp, int *rowp, int *colp) win_T *wp = get_win_by_grid_handle(*gridp); if (wp && wp->w_grid_alloc.chars && !(wp->w_floating && !wp->w_float_config.focusable)) { - *rowp = MIN(*rowp-wp->w_grid.row_offset, wp->w_grid.Rows-1); - *colp = MIN(*colp-wp->w_grid.col_offset, wp->w_grid.Columns-1); + *rowp = MIN(*rowp - wp->w_grid.row_offset, wp->w_grid.Rows - 1); + *colp = MIN(*colp - wp->w_grid.col_offset, wp->w_grid.Columns - 1); return wp; } } else if (*gridp == 0) { @@ -523,8 +523,8 @@ static win_T *mouse_find_grid_win(int *gridp, int *rowp, int *colp) continue; } *gridp = grid->handle; - *rowp -= grid->comp_row+wp->w_grid.row_offset; - *colp -= grid->comp_col+wp->w_grid.col_offset; + *rowp -= grid->comp_row + wp->w_grid.row_offset; + *colp -= grid->comp_col + wp->w_grid.col_offset; return wp; } diff --git a/src/nvim/move.c b/src/nvim/move.c index 078b873892..49fa7bbf7f 100644 --- a/src/nvim/move.c +++ b/src/nvim/move.c @@ -2300,4 +2300,3 @@ void do_check_cursorbind(void) curwin = old_curwin; curbuf = old_curbuf; } - diff --git a/src/nvim/msgpack_rpc/helpers.h b/src/nvim/msgpack_rpc/helpers.h index e5fd92374d..dab8a16b6b 100644 --- a/src/nvim/msgpack_rpc/helpers.h +++ b/src/nvim/msgpack_rpc/helpers.h @@ -21,4 +21,3 @@ #endif #endif // NVIM_MSGPACK_RPC_HELPERS_H - diff --git a/src/nvim/normal.c b/src/nvim/normal.c index c5d7e603cd..373d3cdaa6 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -2601,7 +2601,7 @@ void clear_showcmd(void) sprintf((char *)showcmd_buf, "%d-%d", chars, bytes); } } - int limit = ui_has(kUIMessages) ? SHOWCMD_BUFLEN-1 : SHOWCMD_COLS; + int limit = ui_has(kUIMessages) ? SHOWCMD_BUFLEN - 1 : SHOWCMD_COLS; showcmd_buf[limit] = NUL; // truncate showcmd_visual = true; } else { @@ -2659,7 +2659,7 @@ bool add_to_showcmd(int c) } size_t old_len = STRLEN(showcmd_buf); size_t extra_len = STRLEN(p); - size_t limit = ui_has(kUIMessages) ? SHOWCMD_BUFLEN-1 : SHOWCMD_COLS; + size_t limit = ui_has(kUIMessages) ? SHOWCMD_BUFLEN - 1 : SHOWCMD_COLS; if (old_len + extra_len > limit) { size_t overflow = old_len + extra_len - limit; memmove(showcmd_buf, showcmd_buf + overflow, old_len - overflow + 1); @@ -2887,8 +2887,7 @@ static void nv_ignore(cmdarg_T *cap) /// Command character that doesn't do anything, but unlike nv_ignore() does /// start edit(). Used for "startinsert" executed while starting up. static void nv_nop(cmdarg_T *cap) -{ -} +{} /// Command character doesn't exist. static void nv_error(cmdarg_T *cap) diff --git a/src/nvim/ops.c b/src/nvim/ops.c index d6550f38fa..36e773a82d 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -406,14 +406,14 @@ static void shift_block(oparg_T *oap, int amount) int col_pre = bd.pre_whitesp_c - (bd.startspaces != 0); bd.textcol -= col_pre; const int len = (int)STRLEN(bd.textstart) + 1; - int col = bd.textcol + i +j + len; + int col = bd.textcol + i + j + len; assert(col >= 0); newp = (char_u *)xmalloc((size_t)col); memset(newp, NUL, (size_t)col); memmove(newp, oldp, (size_t)bd.textcol); startcol = bd.textcol; - oldlen = (int)(bd.textstart-old_textstart) + col_pre; - newlen = i+j; + oldlen = (int)(bd.textstart - old_textstart) + col_pre; + newlen = i + j; memset(newp + bd.textcol, TAB, (size_t)i); memset(newp + bd.textcol + i, ' ', (size_t)j); // the end @@ -510,7 +510,7 @@ static void shift_block(oparg_T *oap, int amount) // replace the line ml_replace(curwin->w_cursor.lnum, newp, false); changed_bytes(curwin->w_cursor.lnum, bd.textcol); - extmark_splice_cols(curbuf, (int)curwin->w_cursor.lnum-1, startcol, + extmark_splice_cols(curbuf, (int)curwin->w_cursor.lnum - 1, startcol, oldlen, newlen, kExtmarkUndo); State = oldstate; @@ -615,8 +615,8 @@ static void block_insert(oparg_T *oap, char_u *s, int b_insert, struct block_def STRMOVE(newp + offset, oldp); ml_replace(lnum, newp, false); - extmark_splice_cols(curbuf, (int)lnum-1, startcol, - skipped, offset-startcol, kExtmarkUndo); + extmark_splice_cols(curbuf, (int)lnum - 1, startcol, + skipped, offset - startcol, kExtmarkUndo); if (lnum == oap->end.lnum) { // Set "']" mark to the end of the block instead of the end of @@ -943,7 +943,7 @@ int do_record(int c) } // Name of requested register, or empty string for unnamed operation. - char buf[NUMBUFLEN+2]; + char buf[NUMBUFLEN + 2]; buf[0] = (char)regname; buf[1] = NUL; (void)tv_dict_add_str(dict, S_LEN("regname"), buf); @@ -1652,8 +1652,8 @@ int op_delete(oparg_T *oap) // replace the line ml_replace(lnum, newp, false); - extmark_splice_cols(curbuf, (int)lnum-1, bd.textcol, - bd.textlen, bd.startspaces+bd.endspaces, + extmark_splice_cols(curbuf, (int)lnum - 1, bd.textcol, + bd.textlen, bd.startspaces + bd.endspaces, kExtmarkUndo); } @@ -1688,7 +1688,7 @@ int op_delete(oparg_T *oap) truncate_line(false); // delete the rest of the line extmark_splice_cols(curbuf, - (int)curwin->w_cursor.lnum-1, curwin->w_cursor.col, + (int)curwin->w_cursor.lnum - 1, curwin->w_cursor.col, old_len - curwin->w_cursor.col, 0, kExtmarkUndo); // leave cursor past last char in line @@ -1808,8 +1808,8 @@ int op_delete(oparg_T *oap) curwin->w_cursor = curpos; // restore curwin->w_cursor (void)do_join(2, false, false, false, false); curbuf_splice_pending--; - extmark_splice(curbuf, (int)startpos.lnum-1, startpos.col, - (int)oap->line_count-1, n, deleted_bytes, + extmark_splice(curbuf, (int)startpos.lnum - 1, startpos.col, + (int)oap->line_count - 1, n, deleted_bytes, 0, 0, 0, kExtmarkUndo); } if (oap->op_type == OP_DELETE) { @@ -1855,7 +1855,7 @@ static inline void pbyte(pos_T lp, int c) assert(c <= UCHAR_MAX); *(ml_get_buf(curbuf, lp.lnum, true) + lp.col) = (char_u)c; if (!curbuf_splice_pending) { - extmark_splice_cols(curbuf, (int)lp.lnum-1, lp.col, 1, 1, kExtmarkUndo); + extmark_splice_cols(curbuf, (int)lp.lnum - 1, lp.col, 1, 1, kExtmarkUndo); } } @@ -2011,9 +2011,9 @@ static int op_replace(oparg_T *oap, int c) xfree(after_p); } curbuf_splice_pending--; - extmark_splice(curbuf, (int)baselnum-1, bd.textcol, + extmark_splice(curbuf, (int)baselnum - 1, bd.textcol, 0, bd.textlen, bd.textlen, - newrows, newcols, newrows+newcols, kExtmarkUndo); + newrows, newcols, newrows + newcols, kExtmarkUndo); } } else { // Characterwise or linewise motion replace. @@ -2598,8 +2598,8 @@ int op_change(oparg_T *oap) oldp += bd.textcol; STRMOVE(newp + offset, oldp); ml_replace(linenr, newp, false); - extmark_splice_cols(curbuf, (int)linenr-1, bd.textcol, - 0, vpos.coladd+(int)ins_len, kExtmarkUndo); + extmark_splice_cols(curbuf, (int)linenr - 1, bd.textcol, + 0, vpos.coladd + (int)ins_len, kExtmarkUndo); } } check_cursor(); @@ -2938,7 +2938,7 @@ static void do_autocmd_textyankpost(oparg_T *oap, yankreg_T *reg) (void)tv_dict_add_list(dict, S_LEN("regcontents"), list); // Register type. - char buf[NUMBUFLEN+2]; + char buf[NUMBUFLEN + 2]; format_reg_type(reg->y_type, reg->y_width, buf, ARRAY_SIZE(buf)); (void)tv_dict_add_str(dict, S_LEN("regtype"), buf); @@ -3426,7 +3426,7 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags) assert(columns >= 0); memmove(ptr, oldp + bd.textcol + delcount, (size_t)columns); ml_replace(curwin->w_cursor.lnum, newp, false); - extmark_splice_cols(curbuf, (int)curwin->w_cursor.lnum-1, bd.textcol, + extmark_splice_cols(curbuf, (int)curwin->w_cursor.lnum - 1, bd.textcol, delcount, addcount, kExtmarkUndo); ++curwin->w_cursor.lnum; @@ -3555,7 +3555,7 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags) curwin->w_cursor.col += (colnr_T)(totlen - 1); } changed_bytes(lnum, col); - extmark_splice_cols(curbuf, (int)lnum-1, col, + extmark_splice_cols(curbuf, (int)lnum - 1, col, 0, (int)totlen, kExtmarkUndo); if (VIsual_active) { lnum++; @@ -3652,20 +3652,20 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags) int lastsize = 0; if (y_type == kMTCharWise || (y_type == kMTLineWise && flags & PUT_LINE_SPLIT)) { - for (i = 0; i < y_size-1; i++) { + for (i = 0; i < y_size - 1; i++) { totsize += (bcount_t)STRLEN(y_array[i]) + 1; } - lastsize = (int)STRLEN(y_array[y_size-1]); + lastsize = (int)STRLEN(y_array[y_size - 1]); totsize += lastsize; } if (y_type == kMTCharWise) { - extmark_splice(curbuf, (int)new_cursor.lnum-1, col, 0, 0, 0, - (int)y_size-1, lastsize, totsize, + extmark_splice(curbuf, (int)new_cursor.lnum - 1, col, 0, 0, 0, + (int)y_size - 1, lastsize, totsize, kExtmarkUndo); } else if (y_type == kMTLineWise && flags & PUT_LINE_SPLIT) { // Account for last pasted NL + last NL - extmark_splice(curbuf, (int)new_cursor.lnum-1, col + 1, 0, 0, 0, - (int)y_size+1, 0, totsize+2, kExtmarkUndo); + extmark_splice(curbuf, (int)new_cursor.lnum - 1, col + 1, 0, 0, 0, + (int)y_size + 1, 0, totsize + 2, kExtmarkUndo); } if (cnt == 1) { @@ -4139,8 +4139,8 @@ int do_join(size_t count, int insert_space, int save_undo, int use_formatoptions } if (t > 0 && curbuf_splice_pending == 0) { - colnr_T removed = (int)(curr- curr_start); - extmark_splice(curbuf, (int)curwin->w_cursor.lnum-1, sumsize, + colnr_T removed = (int)(curr - curr_start); + extmark_splice(curbuf, (int)curwin->w_cursor.lnum - 1, sumsize, 1, removed, removed + 1, 0, spaces[t], spaces[t], kExtmarkUndo); @@ -4313,8 +4313,7 @@ static int same_leader(linenr_T lnum, int leader1_len, char_u *leader1_flags, in * The first line has to be saved, only one line can be locked at a time. */ line1 = vim_strsave(ml_get(lnum)); - for (idx1 = 0; ascii_iswhite(line1[idx1]); ++idx1) { - } + for (idx1 = 0; ascii_iswhite(line1[idx1]); idx1++) {} line2 = ml_get(lnum + 1); for (idx2 = 0; idx2 < leader2_len; ++idx2) { if (!ascii_iswhite(line2[idx2])) { @@ -5221,13 +5220,13 @@ int do_addsub(int op_type, pos_T *pos, int length, linenr_T Prenum1) if (!pre) { if (subtract) { if (n > oldn) { - n = 1 + (n ^ (uvarnumber_T)-1); + n = 1 + (n ^ (uvarnumber_T) - 1); negative ^= true; } } else { // add if (n < oldn) { - n = (n ^ (uvarnumber_T)-1); + n = (n ^ (uvarnumber_T) - 1); negative ^= true; } } @@ -7011,9 +7010,9 @@ bool prepare_yankreg_from_object(yankreg_T *reg, String regtype, size_t lines) if (!ascii_isdigit(regtype.data[1])) { return false; } - const char *p = regtype.data+1; + const char *p = regtype.data + 1; reg->y_width = getdigits_int((char_u **)&p, false, 1) - 1; - if (regtype.size > (size_t)(p-regtype.data)) { + if (regtype.size > (size_t)(p - regtype.data)) { return false; } } @@ -7027,12 +7026,12 @@ bool prepare_yankreg_from_object(yankreg_T *reg, String regtype, size_t lines) void finish_yankreg_from_object(yankreg_T *reg, bool clipboard_adjust) { - if (reg->y_size > 0 && STRLEN(reg->y_array[reg->y_size-1]) == 0) { + if (reg->y_size > 0 && STRLEN(reg->y_array[reg->y_size - 1]) == 0) { // a known-to-be charwise yank might have a final linebreak // but otherwise there is no line after the final newline if (reg->y_type != kMTCharWise) { if (reg->y_type == kMTUnknown || clipboard_adjust) { - xfree(reg->y_array[reg->y_size-1]); + xfree(reg->y_array[reg->y_size - 1]); reg->y_size--; } if (reg->y_type == kMTUnknown) { @@ -7135,11 +7134,11 @@ static bool get_clipboard(int name, yankreg_T **target, bool quiet) reg->y_array[tv_idx++] = (char_u *)xstrdupnul((const char *)TV_LIST_ITEM_TV(li)->vval.v_string); }); - if (reg->y_size > 0 && STRLEN(reg->y_array[reg->y_size-1]) == 0) { + if (reg->y_size > 0 && STRLEN(reg->y_array[reg->y_size - 1]) == 0) { // a known-to-be charwise yank might have a final linebreak // but otherwise there is no line after the final newline if (reg->y_type != kMTCharWise) { - xfree(reg->y_array[reg->y_size-1]); + xfree(reg->y_array[reg->y_size - 1]); reg->y_size--; if (reg->y_type == kMTUnknown) { reg->y_type = kMTLineWise; @@ -7407,7 +7406,7 @@ bcount_t get_region_bytecount(buf_T *buf, linenr_T start_lnum, linenr_T end_lnum const char *first = (const char *)ml_get_buf(buf, start_lnum, false); bcount_t deleted_bytes = (bcount_t)STRLEN(first) - start_col + 1; - for (linenr_T i = 1; i <= end_lnum-start_lnum-1; i++) { + for (linenr_T i = 1; i <= end_lnum - start_lnum - 1; i++) { if (start_lnum + i > max_lnum) { return deleted_bytes; } diff --git a/src/nvim/option.c b/src/nvim/option.c index 068b779eb6..1a40bac91a 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -3858,10 +3858,10 @@ static bool parse_winhl_opt(win_T *wp) if (!colon) { return false; } - size_t nlen = (size_t)(colon-p); - char *hi = colon+1; + size_t nlen = (size_t)(colon - p); + char *hi = colon + 1; char *commap = xstrchrnul(hi, ','); - size_t len = (size_t)(commap-hi); + size_t len = (size_t)(commap - hi); int hl_id = len ? syn_check_group(hi, len) : -1; if (strncmp("Normal", p, nlen) == 0) { @@ -3879,7 +3879,7 @@ static bool parse_winhl_opt(win_T *wp) } } - p = *commap ? commap+1 : ""; + p = *commap ? commap + 1 : ""; } wp->w_hl_id_normal = w_hl_id_normal; diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c index f68a1c08c8..9941774d82 100644 --- a/src/nvim/os/input.c +++ b/src/nvim/os/input.c @@ -413,7 +413,7 @@ size_t input_enqueue_mouse(int code, uint8_t modifier, int grid, int row, int co mouse_row = row; mouse_col = col; - size_t written = 3 + (size_t)(p-buf); + size_t written = 3 + (size_t)(p - buf); rbuffer_write(input_buffer, (char *)buf, written); return written; } diff --git a/src/nvim/os/pty_process_win.c b/src/nvim/os/pty_process_win.c index 52967a85a3..6233a90638 100644 --- a/src/nvim/os/pty_process_win.c +++ b/src/nvim/os/pty_process_win.c @@ -47,9 +47,9 @@ int pty_process_spawn(PtyProcess *ptyproc) assert(proc->err.closed); - if (!os_has_conpty_working() - || (conpty_object = - os_conpty_init(&in_name, &out_name, ptyproc->width, ptyproc->height)) == NULL) { + if (!os_has_conpty_working() || (conpty_object = os_conpty_init(&in_name, + &out_name, ptyproc->width, + ptyproc->height)) == NULL) { status = UV_ENOSYS; goto cleanup; } @@ -172,13 +172,11 @@ void pty_process_close(PtyProcess *ptyproc) void pty_process_close_master(PtyProcess *ptyproc) FUNC_ATTR_NONNULL_ALL -{ -} +{} void pty_process_teardown(Loop *loop) FUNC_ATTR_NONNULL_ALL -{ -} +{} static void pty_process_connect_cb(uv_connect_t *req, int status) FUNC_ATTR_NONNULL_ALL diff --git a/src/nvim/os/shell.c b/src/nvim/os/shell.c index 5680cdbe42..9f22e303af 100644 --- a/src/nvim/os/shell.c +++ b/src/nvim/os/shell.c @@ -1099,8 +1099,8 @@ static void out_data_append_to_screen(char *output, size_t *count, bool eof) // incomplete UTF-8 sequence that could be composing with the last // complete sequence. // This will be corrected when we switch to vterm based implementation - int i = *p ? utfc_ptr2len_len((char_u *)p, (int)(end-p)) : 1; - if (!eof && i == 1 && utf8len_tab_zero[*(uint8_t *)p] > (end-p)) { + int i = *p ? utfc_ptr2len_len((char_u *)p, (int)(end - p)) : 1; + if (!eof && i == 1 && utf8len_tab_zero[*(uint8_t *)p] > (end - p)) { *count = (size_t)(p - output); goto end; } @@ -1331,4 +1331,3 @@ static char *shell_xescape_xquote(const char *cmd) return ncmd; } - diff --git a/src/nvim/path.c b/src/nvim/path.c index 66cfb3b31a..0ecdba468a 100644 --- a/src/nvim/path.c +++ b/src/nvim/path.c @@ -1528,9 +1528,8 @@ void simplify_filename(char_u *filename) if (vim_ispathsep(*p)) { relative = false; do { - ++p; - } - while (vim_ispathsep(*p)); + p++; + } while (vim_ispathsep(*p)); } start = p; // remember start after "c:/" or "/" or "///" @@ -2325,7 +2324,7 @@ int append_path(char *path, const char *to_append, size_t max_len) } // Combine the path segments, separated by a slash. - if (current_length > 0 && !vim_ispathsep_nocolon(path[current_length-1])) { + if (current_length > 0 && !vim_ispathsep_nocolon(path[current_length - 1])) { current_length += 1; // Count the trailing slash. // +1 for the NUL at the end. @@ -2378,7 +2377,7 @@ static int path_to_absolute(const char_u *fname, char_u *buf, size_t len, int fo } else { assert(p >= fname); memcpy(relative_directory, fname, (size_t)(p - fname)); - relative_directory[p-fname] = NUL; + relative_directory[p - fname] = NUL; } end_of_path = (char *)(p + 1); } else { diff --git a/src/nvim/plines.c b/src/nvim/plines.c index a572f747df..bbe1a41b00 100644 --- a/src/nvim/plines.c +++ b/src/nvim/plines.c @@ -61,7 +61,7 @@ int win_get_fill(win_T *wp, linenr_T lnum) int n = diff_check(wp, lnum); if (n > 0) { - return virt_lines+n; + return virt_lines + n; } } return virt_lines; @@ -125,7 +125,7 @@ int plines_win_nofold(win_T *wp, linenr_T lnum) } col -= (unsigned int)width; width += win_col_off2(wp); - assert(col <= INT_MAX && (int)col < INT_MAX - (width -1)); + assert(col <= INT_MAX && (int)col < INT_MAX - (width - 1)); return ((int)col + (width - 1)) / width + 1; } @@ -507,4 +507,3 @@ static int win_nolbr_chartabsize(win_T *wp, char_u *s, colnr_T col, int *headp) } return n; } - diff --git a/src/nvim/popupmnu.c b/src/nvim/popupmnu.c index e354a589a5..15d0ae6c84 100644 --- a/src/nvim/popupmnu.c +++ b/src/nvim/popupmnu.c @@ -422,7 +422,7 @@ void pum_redraw(void) pum_grid.zindex = ((State == CMDLINE) ? kZIndexCmdlinePopupMenu : kZIndexPopupMenu); - bool moved = ui_comp_put_grid(&pum_grid, pum_row, pum_col-col_off, + bool moved = ui_comp_put_grid(&pum_grid, pum_row, pum_col - col_off, pum_height, grid_width, false, true); bool invalid_grid = moved || pum_invalid; pum_invalid = false; @@ -439,7 +439,7 @@ void pum_redraw(void) const char *anchor = pum_above ? "SW" : "NW"; int row_off = pum_above ? -pum_height : 0; ui_call_win_float_pos(pum_grid.handle, -1, cstr_to_string(anchor), - pum_anchor_grid, pum_row-row_off, pum_col-col_off, + pum_anchor_grid, pum_row - row_off, pum_col - col_off, false, pum_grid.zindex); } diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 03552a0a19..c4760e91fc 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -78,8 +78,7 @@ struct qfline_S { #define INVALID_QFBUFNR (0) /// Quickfix list type. -typedef enum -{ +typedef enum { QFLT_QUICKFIX, ///< Quickfix list - global list QFLT_LOCATION, ///< Location list - per window list QFLT_INTERNAL, ///< Internal - Temporary list used by @@ -429,8 +428,7 @@ static char *scanf_fmt_to_regpat(const char **pefmp, const char *efm, int len, c } if (efmp < efm + len) { *regpat++ = *++efmp; // could be ']' - while (efmp < efm + len && (*regpat++ = *++efmp) != ']') { - } + while (efmp < efm + len && (*regpat++ = *++efmp) != ']') {} if (efmp == efm + len) { emsg(_("E374: Missing ] in format string")); return NULL; @@ -7300,4 +7298,3 @@ void ex_helpgrep(exarg_T *eap) } } } - diff --git a/src/nvim/rbuffer.c b/src/nvim/rbuffer.c index 4ac50095b3..d280e08c03 100644 --- a/src/nvim/rbuffer.c +++ b/src/nvim/rbuffer.c @@ -224,4 +224,3 @@ int rbuffer_cmp(RBuffer *buf, const char *str, size_t count) return memcmp(str + n, buf->start_ptr, count); } - diff --git a/src/nvim/runtime.c b/src/nvim/runtime.c index 1102096b32..970072a53c 100644 --- a/src/nvim/runtime.c +++ b/src/nvim/runtime.c @@ -485,7 +485,7 @@ static void expand_pack_entry(RuntimeSearchPath *search_path, Map(String, handle STRLCPY(buf, pack_entry, sizeof buf); STRLCPY(buf + pack_entry_len, start_pat[i], sizeof buf - pack_entry_len); expand_rtp_entry(search_path, rtp_used, buf, false); - size_t after_size = STRLEN(buf)+7; + size_t after_size = STRLEN(buf) + 7; char *after = xmallocz(after_size); xstrlcpy(after, buf, after_size); xstrlcat(after, "/after", after_size); @@ -499,7 +499,7 @@ static bool path_is_after(char_u *buf, size_t buflen) // vim8 considers all dirs like "foo/bar_after", "Xafter" etc, as an // "after" dir in SOME codepaths not not in ALL codepaths. return buflen >= 5 - && (!(buflen >= 6) || vim_ispathsep(buf[buflen-6])) + && (!(buflen >= 6) || vim_ispathsep(buf[buflen - 6])) && STRCMP(buf + buflen - 5, "after") == 0; } diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 807503fd00..81c8830b84 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -390,7 +390,7 @@ int update_screen(int type) // CLEAR is already handled if (type == NOT_VALID && !ui_has(kUIMultigrid) && msg_scrolled) { ui_comp_set_screen_valid(false); - for (int i = valid; i < Rows-p_ch; i++) { + for (int i = valid; i < Rows - p_ch; i++) { grid_clear_line(&default_grid, default_grid.line_offset[i], Columns, false); } @@ -409,7 +409,7 @@ int update_screen(int type) curwin->w_redr_status = true; } } - msg_grid_set_pos(Rows-p_ch, false); + msg_grid_set_pos(Rows - p_ch, false); msg_grid_invalid = false; } else if (msg_scrolled > Rows - 5) { // clearing is faster type = CLEAR; @@ -473,7 +473,7 @@ int update_screen(int type) // After disabling msgsep the grid might not have been deallocated yet, // hence we also need to check msg_grid.chars if (type == NOT_VALID && (msg_use_grid() || msg_grid.chars)) { - grid_fill(&default_grid, Rows-p_ch, Rows, 0, Columns, ' ', ' ', 0); + grid_fill(&default_grid, Rows - p_ch, Rows, 0, Columns, ' ', ' ', 0); } ui_comp_set_screen_valid(true); @@ -1953,7 +1953,7 @@ static size_t fill_foldcolumn(char_u *p, win_T *wp, foldinfo_T foldinfo, linenr_ char_counter += len; } - return MAX(char_counter + (fdc-i), (size_t)fdc); + return MAX(char_counter + (fdc - i), (size_t)fdc); } static inline void provider_err_virt_text(linenr_T lnum, char *err) @@ -1964,7 +1964,7 @@ static inline void provider_err_virt_text(linenr_T lnum, char *err) ((VirtTextChunk){ .text = provider_err, .hl_id = hl_err })); err_decor.virt_text_width = mb_string2cells((char_u *)err); - decor_add_ephemeral(lnum-1, 0, lnum-1, 0, &err_decor); + decor_add_ephemeral(lnum - 1, 0, lnum - 1, 0, &err_decor); } static inline void get_line_number_str(win_T *wp, linenr_T lnum, char_u *buf, size_t buf_len) @@ -2159,7 +2159,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc row = startrow; buf_T *buf = wp->w_buffer; - bool end_fill = (lnum == buf->b_ml.ml_line_count+1); + bool end_fill = (lnum == buf->b_ml.ml_line_count + 1); if (!number_only) { // To speed up the loop below, set extra_check when there is linebreak, @@ -2183,9 +2183,9 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc } } - has_decor = decor_redraw_line(buf, lnum-1, &decor_state); + has_decor = decor_redraw_line(buf, lnum - 1, &decor_state); - providers_invoke_line(wp, providers, lnum-1, &has_decor, &provider_err); + providers_invoke_line(wp, providers, lnum - 1, &has_decor, &provider_err); if (provider_err) { provider_err_virt_text(lnum, provider_err); @@ -2389,7 +2389,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc memset(sattrs, 0, sizeof(sattrs)); num_signs = buf_get_signattrs(wp->w_buffer, lnum, sattrs); - decor_redraw_signs(buf, lnum-1, &num_signs, sattrs); + decor_redraw_signs(buf, lnum - 1, &num_signs, sattrs); // If this line has a sign with line highlighting set line_attr. // TODO(bfredl, vigoux): this should not take priority over decoration! @@ -3340,7 +3340,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc if (has_decor && v > 0) { bool selected = (area_active || (area_highlighting && noinvcur && (colnr_T)vcol == wp->w_virtcol)); - int extmark_attr = decor_redraw_col(wp->w_buffer, (colnr_T)v-1, off, + int extmark_attr = decor_redraw_col(wp->w_buffer, (colnr_T)v - 1, off, selected, &decor_state); if (extmark_attr != 0) { if (!attr_pri) { @@ -4206,7 +4206,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc screen_adjust_grid(¤t_grid, ¤t_row, &dummy_col); // Force a redraw of the first column of the next line. - current_grid->attrs[current_grid->line_offset[current_row+1]] = -1; + current_grid->attrs[current_grid->line_offset[current_row + 1]] = -1; // Remember that the line wraps, used for modeless copy. current_grid->line_wraps[current_row] = true; @@ -4291,7 +4291,7 @@ void draw_virt_text(buf_T *buf, int col_off, int *end_col, int max_col) } else if (item->decor.virt_text_pos == kVTEndOfLine && do_eol) { item->win_col = state->eol_col; } else if (item->decor.virt_text_pos == kVTWinCol) { - item->win_col = MAX(item->decor.col+col_off, 0); + item->win_col = MAX(item->decor.col + col_off, 0); } } if (item->win_col < 0) { @@ -4299,10 +4299,10 @@ void draw_virt_text(buf_T *buf, int col_off, int *end_col, int max_col) } int col = draw_virt_text_item(buf, item->win_col, item->decor.virt_text, - item->decor.hl_mode, max_col, item->win_col-col_off); + item->decor.hl_mode, max_col, item->win_col - col_off); item->win_col = -2; // deactivate if (item->decor.virt_text_pos == kVTEndOfLine && do_eol) { - state->eol_col = col+1; + state->eol_col = col + 1; } *end_col = MAX(*end_col, col); @@ -4348,7 +4348,7 @@ static int draw_virt_text_item(buf_T *buf, int col, VirtText vt, HlMode hl_mode, } schar_T dummy[2]; int cells = line_putchar(buf, &s, through ? dummy : &linebuf_char[col], - max_col-col, false, vcol); + max_col - col, false, vcol); // if we failed to emit a char, we still need to advance cells = MAX(cells, 1); @@ -4596,8 +4596,8 @@ static void grid_put_linebuf(ScreenGrid *grid, int row, int coloff, int endcol, if (bg_attr) { for (int c = col; c < endcol; c++) { - linebuf_attr[off_from+c] = - hl_combine_attr(bg_attr, linebuf_attr[off_from+c]); + linebuf_attr[off_from + c] = + hl_combine_attr(bg_attr, linebuf_attr[off_from + c]); } } @@ -4634,7 +4634,7 @@ static void grid_put_linebuf(ScreenGrid *grid, int row, int coloff, int endcol, schar_copy(grid->chars[off_to], linebuf_char[off_from]); if (char_cells == 2) { - schar_copy(grid->chars[off_to+1], linebuf_char[off_from+1]); + schar_copy(grid->chars[off_to + 1], linebuf_char[off_from + 1]); } grid->attrs[off_to] = linebuf_attr[off_from]; @@ -4674,7 +4674,7 @@ static void grid_put_linebuf(ScreenGrid *grid, int row, int coloff, int endcol, } else if (clear_end == -1) { end_dirty = endcol; } - clear_end = col+1; + clear_end = col + 1; } col++; off_to++; @@ -4694,7 +4694,7 @@ static void grid_put_linebuf(ScreenGrid *grid, int row, int coloff, int endcol, start_dirty = end_dirty; } if (clear_end > start_dirty) { - ui_line(grid, row, coloff+start_dirty, coloff+end_dirty, coloff+clear_end, + ui_line(grid, row, coloff + start_dirty, coloff + end_dirty, coloff + clear_end, bg_attr, wrap); } } @@ -5611,39 +5611,39 @@ static void win_redr_border(win_T *wp) grid_put_schar(grid, 0, 0, chars[0], attrs[0]); } for (int i = 0; i < icol; i++) { - grid_put_schar(grid, 0, i+adj[3], chars[1], attrs[1]); + grid_put_schar(grid, 0, i + adj[3], chars[1], attrs[1]); } if (adj[1]) { - grid_put_schar(grid, 0, icol+adj[3], chars[2], attrs[2]); + grid_put_schar(grid, 0, icol + adj[3], chars[2], attrs[2]); } grid_puts_line_flush(false); } for (int i = 0; i < irow; i++) { if (adj[3]) { - grid_puts_line_start(grid, i+adj[0]); - grid_put_schar(grid, i+adj[0], 0, chars[7], attrs[7]); + grid_puts_line_start(grid, i + adj[0]); + grid_put_schar(grid, i + adj[0], 0, chars[7], attrs[7]); grid_puts_line_flush(false); } if (adj[1]) { int ic = (i == 0 && !adj[0] && chars[2][0]) ? 2 : 3; - grid_puts_line_start(grid, i+adj[0]); - grid_put_schar(grid, i+adj[0], icol+adj[3], chars[ic], attrs[ic]); + grid_puts_line_start(grid, i + adj[0]); + grid_put_schar(grid, i + adj[0], icol + adj[3], chars[ic], attrs[ic]); grid_puts_line_flush(false); } } if (adj[2]) { - grid_puts_line_start(grid, irow+adj[0]); + grid_puts_line_start(grid, irow + adj[0]); if (adj[3]) { - grid_put_schar(grid, irow+adj[0], 0, chars[6], attrs[6]); + grid_put_schar(grid, irow + adj[0], 0, chars[6], attrs[6]); } for (int i = 0; i < icol; i++) { int ic = (i == 0 && !adj[3] && chars[6][0]) ? 6 : 5; - grid_put_schar(grid, irow+adj[0], i+adj[3], chars[ic], attrs[ic]); + grid_put_schar(grid, irow + adj[0], i + adj[3], chars[ic], attrs[ic]); } if (adj[1]) { - grid_put_schar(grid, irow+adj[0], icol+adj[3], chars[4], attrs[4]); + grid_put_schar(grid, irow + adj[0], icol + adj[3], chars[4], attrs[4]); } grid_puts_line_flush(false); } @@ -5795,7 +5795,7 @@ void grid_put_schar(ScreenGrid *grid, int row, int col, char_u *schar, int attr) put_dirty_first = MIN(put_dirty_first, col); // TODO(bfredl): Y U NO DOUBLEWIDTH? - put_dirty_last = MAX(put_dirty_last, col+1); + put_dirty_last = MAX(put_dirty_last, col + 1); } } @@ -5931,7 +5931,7 @@ void grid_puts_len(ScreenGrid *grid, char_u *text, int textlen, int row, int col grid->attrs[off + 1] = attr; } put_dirty_first = MIN(put_dirty_first, col); - put_dirty_last = MAX(put_dirty_last, col+mbyte_cells); + put_dirty_last = MAX(put_dirty_last, col + mbyte_cells); } off += mbyte_cells; @@ -5961,7 +5961,7 @@ void grid_puts_line_flush(bool set_cursor) if (put_dirty_first < put_dirty_last) { if (set_cursor) { ui_grid_cursor_goto(put_dirty_grid->handle, put_dirty_row, - MIN(put_dirty_last, put_dirty_grid->Columns-1)); + MIN(put_dirty_last, put_dirty_grid->Columns - 1)); } if (!put_dirty_grid->throttled) { ui_line(put_dirty_grid, put_dirty_row, put_dirty_first, put_dirty_last, @@ -6062,7 +6062,7 @@ void grid_fill(ScreenGrid *grid, int start_row, int end_row, int start_col, int if (dirty_first == INT_MAX) { dirty_first = col; } - dirty_last = col+1; + dirty_last = col + 1; } if (col == start_col) { schar_from_char(sc, c2); @@ -6134,7 +6134,7 @@ void win_grid_alloc(win_T *wp) if (grid->Rows != rows) { wp->w_lines_valid = 0; xfree(wp->w_lines); - wp->w_lines = xcalloc(rows+1, sizeof(wline_T)); + wp->w_lines = xcalloc(rows + 1, sizeof(wline_T)); } int was_resized = false; @@ -6570,7 +6570,7 @@ void grid_ins_lines(ScreenGrid *grid, int row, int line_count, int end, int col, } if (!grid->throttled) { - ui_call_grid_scroll(grid->handle, row, end, col, col+width, -line_count, 0); + ui_call_grid_scroll(grid->handle, row, end, col, col + width, -line_count, 0); } } @@ -6620,7 +6620,7 @@ void grid_del_lines(ScreenGrid *grid, int row, int line_count, int end, int col, } if (!grid->throttled) { - ui_call_grid_scroll(grid->handle, row, end, col, col+width, line_count, 0); + ui_call_grid_scroll(grid->handle, row, end, col, col + width, line_count, 0); } } diff --git a/src/nvim/search.c b/src/nvim/search.c index 48df289831..21b0e9440c 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -2543,9 +2543,8 @@ int findsent(Direction dir, long count) if ((c = inc(&tpos)) == -1) { break; } - } - while (vim_strchr((char_u *)")]\"'", c = gchar_pos(&tpos)) - != NULL); + } while (vim_strchr((char_u *)")]\"'", c = gchar_pos(&tpos)) + != NULL); if (c == -1 || (!cpo_J && (c == ' ' || c == '\t')) || c == NUL || (cpo_J && (c == ' ' && inc(&tpos) >= 0 && gchar_pos(&tpos) == ' '))) { @@ -3673,8 +3672,7 @@ again: p = get_cursor_pos_ptr(); for (cp = p; *cp != NUL && *cp != '>' && !ascii_iswhite(*cp); - MB_PTR_ADV(cp)) { - } + MB_PTR_ADV(cp)) {} len = (int)(cp - p); if (len == 0) { curwin->w_cursor = old_pos; @@ -5497,10 +5495,8 @@ void find_pattern_in_path(char_u *ptr, Direction dir, size_t len, bool whole, bo } else { // find the file name after the end of the match for (p = incl_regmatch.endp[0]; - *p && !vim_isfilec(*p); p++) { - } - for (i = 0; vim_isfilec(p[i]); i++) { - } + *p && !vim_isfilec(*p); p++) {} + for (i = 0; vim_isfilec(p[i]); i++) {} } if (i == 0) { @@ -5709,15 +5705,15 @@ search_line: p = find_word_start(p); p = find_word_end(p); if (p > aux) { - if (*aux != ')' && IObuff[i-1] != TAB) { - if (IObuff[i-1] != ' ') { + if (*aux != ')' && IObuff[i - 1] != TAB) { + if (IObuff[i - 1] != ' ') { IObuff[i++] = ' '; } // IObuf =~ "\(\k\|\i\).* ", thus i >= 2 if (p_js - && (IObuff[i-2] == '.' - || IObuff[i-2] == '?' - || IObuff[i-2] == '!')) { + && (IObuff[i - 2] == '.' + || IObuff[i - 2] == '?' + || IObuff[i - 2] == '!')) { IObuff[i++] = ' '; } } diff --git a/src/nvim/sha256.c b/src/nvim/sha256.c index 2c6199bf8b..53c9cb7c81 100644 --- a/src/nvim/sha256.c +++ b/src/nvim/sha256.c @@ -86,7 +86,7 @@ static void sha256_process(context_sha256_T *ctx, const char_u data[SHA256_BUFFE #define F1(x, y, z) ((z) ^ ((x) & ((y) ^ (z)))) #define R(t) \ - (W[t] = S1(W[(t) - 2]) + W[(t) - 7] + S0(W[(t) - 15]) + W[(t) - 16]) + (W[t] = S1(W[(t) - 2]) + W[(t) - 7] + S0(W[(t) - 15]) + W[(t) - 16]) #define P(a, b, c, d, e, f, g, h, x, K) { \ temp1 = (h) + S3(e) + F1(e, f, g) + (K) + (x); \ @@ -184,7 +184,7 @@ void sha256_update(context_sha256_T *ctx, const char_u *input, size_t length) return; } - uint32_t left = ctx->total[0] & (SHA256_BUFFER_SIZE-1); // left < buf size + uint32_t left = ctx->total[0] & (SHA256_BUFFER_SIZE - 1); // left < buf size ctx->total[0] += (uint32_t)length; ctx->total[0] &= 0xFFFFFFFF; @@ -335,7 +335,7 @@ bool sha256_self_test(void) sha256_finish(&ctx, sha256sum); for (size_t j = 0; j < SHA256_SUM_SIZE; j++) { - snprintf(output + j * SHA_STEP, SHA_STEP+1, "%02x", sha256sum[j]); + snprintf(output + j * SHA_STEP, SHA_STEP + 1, "%02x", sha256sum[j]); } } diff --git a/src/nvim/shada.c b/src/nvim/shada.c index 76bf81ffbf..a19dbac6f3 100644 --- a/src/nvim/shada.c +++ b/src/nvim/shada.c @@ -3302,7 +3302,7 @@ static ShaDaReadResult msgpack_read_uint64(ShaDaReadDef *const sd_reader, const uint64_t buf = 0; char *buf_u8 = (char *)&buf; ShaDaReadResult fl_ret; - if ((fl_ret = fread_len(sd_reader, &(buf_u8[sizeof(buf)-length]), length)) + if ((fl_ret = fread_len(sd_reader, &(buf_u8[sizeof(buf) - length]), length)) != kSDReadStatusSuccess) { return fl_ret; } diff --git a/src/nvim/sign.c b/src/nvim/sign.c index f0712442a2..db3ce45b51 100644 --- a/src/nvim/sign.c +++ b/src/nvim/sign.c @@ -1698,8 +1698,7 @@ void free_signs(void) } } -static enum -{ +static enum { EXP_SUBCMD, // expand :sign sub-commands EXP_DEFINE, // expand :sign define {name} args EXP_PLACE, // expand :sign place {id} args diff --git a/src/nvim/spell.c b/src/nvim/spell.c index 20e1fefbb4..754d9dcb48 100644 --- a/src/nvim/spell.c +++ b/src/nvim/spell.c @@ -1647,7 +1647,7 @@ void spell_cat_line(char_u *buf, char_u *line, int maxlen) n = (int)(p - line) + 1; if (n < maxlen - 1) { memset(buf, ' ', n); - STRLCPY(buf + n, p, maxlen - n); + STRLCPY(buf + n, p, maxlen - n); } } } @@ -3420,8 +3420,7 @@ static void spell_suggest_file(suginfo_T *su, char_u *fname) *p++ = NUL; if (STRICMP(su->su_badword, line) == 0) { // Match! Isolate the good word, until CR or NL. - for (len = 0; p[len] >= ' '; ++len) { - } + for (len = 0; p[len] >= ' '; len++) {} p[len] = NUL; // If the suggestion doesn't have specific case duplicate the case @@ -3816,8 +3815,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so if (sp->ts_prefixdepth == PFD_PREFIXTREE) { // Skip over the NUL bytes, we use them later. - for (n = 0; n < len && byts[arridx + n] == 0; ++n) { - } + for (n = 0; n < len && byts[arridx + n] == 0; n++) {} sp->ts_curi += n; // Always past NUL bytes now. @@ -3890,8 +3888,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so // none this must be the first try without a prefix. n = stack[sp->ts_prefixdepth].ts_arridx; len = pbyts[n++]; - for (c = 0; c < len && pbyts[n + c] == 0; ++c) { - } + for (c = 0; c < len && pbyts[n + c] == 0; c++) {} if (c > 0) { c = valid_word_prefix(c, n, flags, tword + sp->ts_splitoff, slang, false); diff --git a/src/nvim/spellfile.c b/src/nvim/spellfile.c index 0933e6d467..f4e50778cf 100644 --- a/src/nvim/spellfile.c +++ b/src/nvim/spellfile.c @@ -5887,4 +5887,3 @@ static void set_map_str(slang_T *lp, char_u *map) } } } - diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 76bb5a0186..3be7dfe477 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -1019,8 +1019,7 @@ static void syn_stack_alloc(void) // When shrinking the array, cleanup the existing stack. // Make sure that all valid entries fit in the new array. while (syn_block->b_sst_len - syn_block->b_sst_freecount + 2 > len - && syn_stack_cleanup()) { - } + && syn_stack_cleanup()) {} if (len < syn_block->b_sst_len - syn_block->b_sst_freecount + 2) { len = syn_block->b_sst_len - syn_block->b_sst_freecount + 2; } @@ -2699,8 +2698,7 @@ static void find_endpos(int idx, lpos_T *startpos, lpos_T *m_endpos, lpos_T *hl_ // Be careful not to jump over the NUL at the end-of-line for (matchcol = regmatch.endpos[0].col; matchcol < line_len && matchcol < pos.col; - matchcol++) { - } + matchcol++) {} } // if the skip pattern includes end-of-line, break here @@ -5334,8 +5332,7 @@ static int get_id_list(char_u **const arg, const int keylen, int16_t **const lis // parse the arguments after "contains" int count = 0; do { - for (end = p; *end && !ascii_iswhite(*end) && *end != ','; end++) { - } + for (end = p; *end && !ascii_iswhite(*end) && *end != ','; end++) {} char_u *const name = xmalloc(end - p + 3); // leave room for "^$" STRLCPY(name + 1, p, end - p + 1); if (STRCMP(name + 1, "ALLBUT") == 0 @@ -5470,8 +5467,7 @@ static int16_t *copy_id_list(const int16_t *const list) } int count; - for (count = 0; list[count]; count++) { - } + for (count = 0; list[count]; count++) {} const size_t len = (count + 1) * sizeof(int16_t); int16_t *const retval = xmalloc(len); memmove(retval, list, len); @@ -5624,8 +5620,7 @@ void ex_syntax(exarg_T *eap) syn_cmdlinep = eap->cmdlinep; // isolate subcommand name - for (subcmd_end = arg; ASCII_ISALPHA(*subcmd_end); subcmd_end++) { - } + for (subcmd_end = arg; ASCII_ISALPHA(*subcmd_end); subcmd_end++) {} char_u *const subcmd_name = vim_strnsave(arg, subcmd_end - arg); if (eap->skip) { // skip error messages for all subcommands emsg_skip++; diff --git a/src/nvim/tag.c b/src/nvim/tag.c index 39c9aacad0..83eb3d1832 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -813,8 +813,7 @@ static void print_tag_list(int new_tag, int use_tagstack, int num_matches, char_ } else { for (p = tagp.command; *p && *p != '\r' && *p != '\n'; - p++) { - } + p++) {} command_end = p; } @@ -933,8 +932,7 @@ static int add_llist_tags(char_u *tag, int num_matches, char_u **matches) cmd_end = tagp.command_end; if (cmd_end == NULL) { for (p = tagp.command; - *p && *p != '\r' && *p != '\n'; p++) { - } + *p && *p != '\r' && *p != '\n'; p++) {} cmd_end = p; } @@ -1780,8 +1778,7 @@ line_read_in: if (STRNCMP(lbuf, "!_TAG_FILE_ENCODING\t", 20) == 0) { // Prepare to convert every line from the specified // encoding to 'encoding'. - for (p = lbuf + 20; *p > ' ' && *p < 127; p++) { - } + for (p = lbuf + 20; *p > ' ' && *p < 127; p++) {} *p = NUL; convert_setup(&vimconv, lbuf + 20, p_enc); } @@ -2614,15 +2611,13 @@ static int parse_match(char_u *lbuf, tagptrs_T *tagp) if (tagp->tagkind != NULL) { for (p = tagp->tagkind; *p && *p != '\t' && *p != '\r' && *p != '\n'; - MB_PTR_ADV(p)) { - } + MB_PTR_ADV(p)) {} tagp->tagkind_end = p; } if (tagp->user_data != NULL) { for (p = tagp->user_data; *p && *p != '\t' && *p != '\r' && *p != '\n'; - MB_PTR_ADV(p)) { - } + MB_PTR_ADV(p)) {} tagp->user_data_end = p; } } diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c index 5f536c0b7a..b07c3786c3 100644 --- a/src/nvim/terminal.c +++ b/src/nvim/terminal.c @@ -744,8 +744,8 @@ void terminal_get_line_attributes(Terminal *term, win_T *wp, int linenr, int *te int vt_fg_idx = ((!fg_default && fg_indexed) ? cell.fg.indexed.idx + 1 : 0); int vt_bg_idx = ((!bg_default && bg_indexed) ? cell.bg.indexed.idx + 1 : 0); - bool fg_set = vt_fg_idx && vt_fg_idx <= 16 && term->color_set[vt_fg_idx-1]; - bool bg_set = vt_bg_idx && vt_bg_idx <= 16 && term->color_set[vt_bg_idx-1]; + bool fg_set = vt_fg_idx && vt_fg_idx <= 16 && term->color_set[vt_fg_idx - 1]; + bool bg_set = vt_bg_idx && vt_bg_idx <= 16 && term->color_set[vt_bg_idx - 1]; int hl_attrs = (cell.attrs.bold ? HL_BOLD : 0) | (cell.attrs.italic ? HL_ITALIC : 0) diff --git a/src/nvim/testing.c b/src/nvim/testing.c index 1e051c945a..f0b84c0eab 100644 --- a/src/nvim/testing.c +++ b/src/nvim/testing.c @@ -559,4 +559,3 @@ void f_test_write_list_log(typval_T *const argvars, typval_T *const rettv, FunPt } list_write_log(fname); } - diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 61c6dc5ca3..6600c44537 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -897,7 +897,7 @@ static void clear_region(UI *ui, int top, int bot, int left, int right, int attr unibi_out(ui, unibi_clr_eos); } } else { - int width = right-left; + int width = right - left; // iterate through each line and clear for (int row = top; row < bot; row++) { @@ -1186,12 +1186,12 @@ static void tui_grid_scroll(UI *ui, Integer g, Integer startrow, // -V751 { TUIData *data = ui->data; UGrid *grid = &data->grid; - int top = (int)startrow, bot = (int)endrow-1; - int left = (int)startcol, right = (int)endcol-1; + int top = (int)startrow, bot = (int)endrow - 1; + int left = (int)startcol, right = (int)endcol - 1; - bool fullwidth = left == 0 && right == ui->width-1; + bool fullwidth = left == 0 && right == ui->width - 1; data->scroll_region_is_full_screen = fullwidth - && top == 0 && bot == ui->height-1; + && top == 0 && bot == ui->height - 1; ugrid_scroll(grid, top, bot, left, right, (int)rows); @@ -1294,10 +1294,10 @@ static void tui_flush(UI *ui) assert(r.bot <= grid->height && r.right <= grid->width); for (int row = r.top; row < r.bot; row++) { - int clear_attr = grid->cells[row][r.right-1].attr; + int clear_attr = grid->cells[row][r.right - 1].attr; int clear_col; for (clear_col = r.right; clear_col > 0; clear_col--) { - UCell *cell = &grid->cells[row][clear_col-1]; + UCell *cell = &grid->cells[row][clear_col - 1]; if (!(cell->data[0] == ' ' && cell->data[1] == NUL && cell->attr == clear_attr)) { break; @@ -1309,7 +1309,7 @@ static void tui_flush(UI *ui) print_cell(ui, cell); }); if (clear_col < r.right) { - clear_region(ui, row, row+1, clear_col, r.right, clear_attr); + clear_region(ui, row, row + 1, clear_col, r.right, clear_attr); } } } @@ -1389,8 +1389,7 @@ static void tui_set_title(UI *ui, String title) } static void tui_set_icon(UI *ui, String icon) -{ -} +{} static void tui_screenshot(UI *ui, String path) { @@ -1438,9 +1437,9 @@ static void tui_raw_line(UI *ui, Integer g, Integer linerow, Integer startcol, I TUIData *data = ui->data; UGrid *grid = &data->grid; for (Integer c = startcol; c < endcol; c++) { - memcpy(grid->cells[linerow][c].data, chunk[c-startcol], sizeof(schar_T)); - assert((size_t)attrs[c-startcol] < kv_size(data->attrs)); - grid->cells[linerow][c].attr = attrs[c-startcol]; + memcpy(grid->cells[linerow][c].data, chunk[c - startcol], sizeof(schar_T)); + assert((size_t)attrs[c - startcol] < kv_size(data->attrs)); + grid->cells[linerow][c].attr = attrs[c - startcol]; } UGRID_FOREACH_CELL(grid, (int)linerow, (int)startcol, (int)endcol, { cursor_goto(ui, (int)linerow, curcol); @@ -1450,7 +1449,7 @@ static void tui_raw_line(UI *ui, Integer g, Integer linerow, Integer startcol, I if (clearcol > endcol) { ugrid_clear_chunk(grid, (int)linerow, (int)endcol, (int)clearcol, (sattr_T)clearattr); - clear_region(ui, (int)linerow, (int)linerow+1, (int)endcol, (int)clearcol, + clear_region(ui, (int)linerow, (int)linerow + 1, (int)endcol, (int)clearcol, (int)clearattr); } diff --git a/src/nvim/ugrid.c b/src/nvim/ugrid.c index ef84cdf334..d96da3f2bb 100644 --- a/src/nvim/ugrid.c +++ b/src/nvim/ugrid.c @@ -39,12 +39,12 @@ void ugrid_resize(UGrid *grid, int width, int height) void ugrid_clear(UGrid *grid) { - clear_region(grid, 0, grid->height-1, 0, grid->width-1, 0); + clear_region(grid, 0, grid->height - 1, 0, grid->width - 1, 0); } void ugrid_clear_chunk(UGrid *grid, int row, int col, int endcol, sattr_T attr) { - clear_region(grid, row, row, col, endcol-1, attr); + clear_region(grid, row, row, col, endcol - 1, attr); } void ugrid_goto(UGrid *grid, int row, int col) @@ -82,7 +82,7 @@ void ugrid_scroll(UGrid *grid, int top, int bot, int left, int right, int count) static void clear_region(UGrid *grid, int top, int bot, int left, int right, sattr_T attr) { for (int row = top; row <= bot; row++) { - UGRID_FOREACH_CELL(grid, row, left, right+1, { + UGRID_FOREACH_CELL(grid, row, left, right + 1, { cell->data[0] = ' '; cell->data[1] = 0; cell->attr = attr; @@ -99,4 +99,3 @@ static void destroy_cells(UGrid *grid) XFREE_CLEAR(grid->cells); } } - diff --git a/src/nvim/ui.c b/src/nvim/ui.c index 564d8d22b4..ac20b00c71 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -453,7 +453,7 @@ void ui_line(ScreenGrid *grid, int row, int startcol, int endcol, int clearcol, if (p_wd && !(rdb_flags & RDB_COMPOSITOR)) { // If 'writedelay' is active, set the cursor to indicate what was drawn. ui_call_grid_cursor_goto(grid->handle, row, - MIN(clearcol, (int)grid->Columns-1)); + MIN(clearcol, (int)grid->Columns - 1)); ui_call_flush(); uint64_t wd = (uint64_t)labs(p_wd); os_microdelay(wd * 1000u, true); diff --git a/src/nvim/ui_bridge.c b/src/nvim/ui_bridge.c index 3402df817a..84098e9476 100644 --- a/src/nvim/ui_bridge.c +++ b/src/nvim/ui_bridge.c @@ -166,7 +166,7 @@ static void ui_bridge_raw_line(UI *ui, Integer grid, Integer row, Integer startc Integer clearcol, Integer clearattr, LineFlags flags, const schar_T *chunk, const sattr_T *attrs) { - size_t ncol = (size_t)(endcol-startcol); + size_t ncol = (size_t)(endcol - startcol); schar_T *c = xmemdup(chunk, ncol * sizeof(schar_T)); sattr_T *hl = xmemdup(attrs, ncol * sizeof(sattr_T)); UI_BRIDGE_CALL(ui, raw_line, 10, ui, INT2PTR(grid), INT2PTR(row), diff --git a/src/nvim/ui_compositor.c b/src/nvim/ui_compositor.c index e356960cc8..60ad8609a4 100644 --- a/src/nvim/ui_compositor.c +++ b/src/nvim/ui_compositor.c @@ -141,15 +141,15 @@ bool ui_comp_put_grid(ScreenGrid *grid, int row, int col, int height, int width, grid->comp_col, grid->comp_col + grid->Columns); if (grid->comp_col < col) { compose_area(MAX(row, grid->comp_row), - MIN(row+height, grid->comp_row+grid->Rows), + MIN(row + height, grid->comp_row + grid->Rows), grid->comp_col, col); } - if (col+width < grid->comp_col+grid->Columns) { + if (col + width < grid->comp_col + grid->Columns) { compose_area(MAX(row, grid->comp_row), - MIN(row+height, grid->comp_row+grid->Rows), - col+width, grid->comp_col+grid->Columns); + MIN(row + height, grid->comp_row + grid->Rows), + col + width, grid->comp_col + grid->Columns); } - compose_area(row+height, grid->comp_row+grid->Rows, + compose_area(row + height, grid->comp_row + grid->Rows, grid->comp_col, grid->comp_col + grid->Columns); grid->comp_disabled = false; } @@ -166,19 +166,19 @@ bool ui_comp_put_grid(ScreenGrid *grid, int row, int col, int height, int width, #endif size_t insert_at = kv_size(layers); - while (insert_at > 0 && kv_A(layers, insert_at-1)->zindex > grid->zindex) { + while (insert_at > 0 && kv_A(layers, insert_at - 1)->zindex > grid->zindex) { insert_at--; } - if (curwin && kv_A(layers, insert_at-1) == &curwin->w_grid_alloc - && kv_A(layers, insert_at-1)->zindex == grid->zindex + if (curwin && kv_A(layers, insert_at - 1) == &curwin->w_grid_alloc + && kv_A(layers, insert_at - 1)->zindex == grid->zindex && !on_top) { insert_at--; } // not found: new grid kv_pushp(layers); - for (size_t i = kv_size(layers)-1; i > insert_at; i--) { - kv_A(layers, i) = kv_A(layers, i-1); + for (size_t i = kv_size(layers) - 1; i > insert_at; i--) { + kv_A(layers, i) = kv_A(layers, i - 1); kv_A(layers, i)->comp_index = i; } kv_A(layers, insert_at) = grid; @@ -188,8 +188,8 @@ bool ui_comp_put_grid(ScreenGrid *grid, int row, int col, int height, int width, grid->comp_index = insert_at; } if (moved && valid && ui_comp_should_draw()) { - compose_area(grid->comp_row, grid->comp_row+grid->Rows, - grid->comp_col, grid->comp_col+grid->Columns); + compose_area(grid->comp_row, grid->comp_row + grid->Rows, + grid->comp_col, grid->comp_col + grid->Columns); } return moved; } @@ -206,8 +206,8 @@ void ui_comp_remove_grid(ScreenGrid *grid) curgrid = &default_grid; } - for (size_t i = grid->comp_index; i < kv_size(layers)-1; i++) { - kv_A(layers, i) = kv_A(layers, i+1); + for (size_t i = grid->comp_index; i < kv_size(layers) - 1; i++) { + kv_A(layers, i) = kv_A(layers, i + 1); kv_A(layers, i)->comp_index = i; } (void)kv_pop(layers); @@ -241,7 +241,7 @@ static void ui_comp_raise_grid(ScreenGrid *grid, size_t new_index) { size_t old_index = grid->comp_index; for (size_t i = old_index; i < new_index; i++) { - kv_A(layers, i) = kv_A(layers, i+1); + kv_A(layers, i) = kv_A(layers, i + 1); kv_A(layers, i)->comp_index = i; } kv_A(layers, new_index) = grid; @@ -249,10 +249,10 @@ static void ui_comp_raise_grid(ScreenGrid *grid, size_t new_index) for (size_t i = old_index; i < new_index; i++) { ScreenGrid *grid2 = kv_A(layers, i); int startcol = MAX(grid->comp_col, grid2->comp_col); - int endcol = MIN(grid->comp_col+grid->Columns, - grid2->comp_col+grid2->Columns); + int endcol = MIN(grid->comp_col + grid->Columns, + grid2->comp_col + grid2->Columns); compose_area(MAX(grid->comp_row, grid2->comp_row), - MIN(grid->comp_row+grid->Rows, grid2->comp_row+grid2->Rows), + MIN(grid->comp_row + grid->Rows, grid2->comp_row + grid2->Rows), startcol, endcol); } } @@ -262,13 +262,13 @@ static void ui_comp_grid_cursor_goto(UI *ui, Integer grid_handle, Integer r, Int if (!ui_comp_should_draw() || !ui_comp_set_grid((int)grid_handle)) { return; } - int cursor_row = curgrid->comp_row+(int)r; - int cursor_col = curgrid->comp_col+(int)c; + int cursor_row = curgrid->comp_row + (int)r; + int cursor_col = curgrid->comp_col + (int)c; // TODO(bfredl): maybe not the best time to do this, for efficiency we // should configure all grids before entering win_update() if (curgrid != &default_grid) { - size_t new_index = kv_size(layers)-1; + size_t new_index = kv_size(layers) - 1; while (new_index > 1 && kv_A(layers, new_index)->zindex > curgrid->zindex) { new_index--; @@ -289,11 +289,11 @@ static void ui_comp_grid_cursor_goto(UI *ui, Integer grid_handle, Integer r, Int ScreenGrid *ui_comp_mouse_focus(int row, int col) { - for (ssize_t i = (ssize_t)kv_size(layers)-1; i > 0; i--) { + for (ssize_t i = (ssize_t)kv_size(layers) - 1; i > 0; i--) { ScreenGrid *grid = kv_A(layers, i); if (grid->focusable - && row >= grid->comp_row && row < grid->comp_row+grid->Rows - && col >= grid->comp_col && col < grid->comp_col+grid->Columns) { + && row >= grid->comp_row && row < grid->comp_row + grid->Rows + && col >= grid->comp_col && col < grid->comp_col + grid->Columns) { return grid; } } @@ -323,9 +323,9 @@ static void compose_line(Integer row, Integer startcol, Integer endcol, LineFlag int col = (int)startcol; ScreenGrid *grid = NULL; schar_T *bg_line = &default_grid.chars[default_grid.line_offset[row] - +(size_t)startcol]; + + (size_t)startcol]; sattr_T *bg_attrs = &default_grid.attrs[default_grid.line_offset[row] - +(size_t)startcol]; + + (size_t)startcol]; int grid_width, grid_height; while (col < endcol) { @@ -355,7 +355,7 @@ static void compose_line(Integer row, Integer startcol, Integer endcol, LineFlag assert(grid != NULL); assert(until > col); assert(until <= default_grid.Columns); - size_t n = (size_t)(until-col); + size_t n = (size_t)(until - col); if (row == msg_sep_row && grid->comp_index <= msg_grid.comp_index) { // TODO(bfredl): when we implement borders around floating windows, then @@ -363,18 +363,18 @@ static void compose_line(Integer row, Integer startcol, Integer endcol, LineFlag grid = &msg_grid; sattr_T msg_sep_attr = (sattr_T)HL_ATTR(HLF_MSGSEP); for (int i = col; i < until; i++) { - memcpy(linebuf[i-startcol], msg_sep_char, sizeof(*linebuf)); - attrbuf[i-startcol] = msg_sep_attr; + memcpy(linebuf[i - startcol], msg_sep_char, sizeof(*linebuf)); + attrbuf[i - startcol] = msg_sep_attr; } } else { - size_t off = grid->line_offset[row-grid->comp_row] - + (size_t)(col-grid->comp_col); - memcpy(linebuf+(col-startcol), grid->chars+off, n * sizeof(*linebuf)); - memcpy(attrbuf+(col-startcol), grid->attrs+off, n * sizeof(*attrbuf)); - if (grid->comp_col+grid->Columns > until - && grid->chars[off+n][0] == NUL) { - linebuf[until-1-startcol][0] = ' '; - linebuf[until-1-startcol][1] = '\0'; + size_t off = grid->line_offset[row - grid->comp_row] + + (size_t)(col - grid->comp_col); + memcpy(linebuf + (col - startcol), grid->chars + off, n * sizeof(*linebuf)); + memcpy(attrbuf + (col - startcol), grid->attrs + off, n * sizeof(*attrbuf)); + if (grid->comp_col + grid->Columns > until + && grid->chars[off + n][0] == NUL) { + linebuf[until - 1 - startcol][0] = ' '; + linebuf[until - 1 - startcol][1] = '\0'; if (col == startcol && n == 1) { skipstart = 0; } @@ -384,18 +384,18 @@ static void compose_line(Integer row, Integer startcol, Integer endcol, LineFlag // 'pumblend' and 'winblend' if (grid->blending) { int width; - for (int i = col-(int)startcol; i < until-startcol; i += width) { + for (int i = col - (int)startcol; i < until - startcol; i += width) { width = 1; // negative space bool thru = strequal((char *)linebuf[i], " ") && bg_line[i][0] != NUL; - if (i+1 < endcol-startcol && bg_line[i+1][0] == NUL) { + if (i + 1 < endcol - startcol && bg_line[i + 1][0] == NUL) { width = 2; - thru &= strequal((char *)linebuf[i+1], " "); + thru &= strequal((char *)linebuf[i + 1], " "); } attrbuf[i] = (sattr_T)hl_blend_attrs(bg_attrs[i], attrbuf[i], &thru); if (width == 2) { - attrbuf[i+1] = (sattr_T)hl_blend_attrs(bg_attrs[i+1], - attrbuf[i+1], &thru); + attrbuf[i + 1] = (sattr_T)hl_blend_attrs(bg_attrs[i + 1], + attrbuf[i + 1], &thru); } if (thru) { memcpy(linebuf + i, bg_line + i, (size_t)width * sizeof(linebuf[i])); @@ -405,19 +405,19 @@ static void compose_line(Integer row, Integer startcol, Integer endcol, LineFlag // Tricky: if overlap caused a doublewidth char to get cut-off, must // replace the visible half with a space. - if (linebuf[col-startcol][0] == NUL) { - linebuf[col-startcol][0] = ' '; - linebuf[col-startcol][1] = NUL; - if (col == endcol-1) { + if (linebuf[col - startcol][0] == NUL) { + linebuf[col - startcol][0] = ' '; + linebuf[col - startcol][1] = NUL; + if (col == endcol - 1) { skipend = 0; } - } else if (n > 1 && linebuf[col-startcol+1][0] == NUL) { + } else if (n > 1 && linebuf[col - startcol + 1][0] == NUL) { skipstart = 0; } col = until; } - if (linebuf[endcol-startcol-1][0] == NUL) { + if (linebuf[endcol - startcol - 1][0] == NUL) { skipend = 0; } @@ -430,7 +430,7 @@ static void compose_line(Integer row, Integer startcol, Integer endcol, LineFlag flags = flags & ~kLineFlagWrap; } - for (int i = skipstart; i < (endcol-skipend)-startcol; i++) { + for (int i = skipstart; i < (endcol - skipend) - startcol; i++) { if (attrbuf[i] < 0) { if (rdb_flags & RDB_INVALID) { abort(); @@ -439,10 +439,10 @@ static void compose_line(Integer row, Integer startcol, Integer endcol, LineFlag } } } - ui_composed_call_raw_line(1, row, startcol+skipstart, - endcol-skipend, endcol-skipend, 0, flags, - (const schar_T *)linebuf+skipstart, - (const sattr_T *)attrbuf+skipstart); + ui_composed_call_raw_line(1, row, startcol + skipstart, + endcol - skipend, endcol - skipend, 0, flags, + (const schar_T *)linebuf + skipstart, + (const sattr_T *)attrbuf + skipstart); } static void compose_debug(Integer startrow, Integer endrow, Integer startcol, Integer endcol, @@ -464,7 +464,7 @@ static void compose_debug(Integer startrow, Integer endrow, Integer startcol, In if (delay) { - debug_delay(endrow-startrow); + debug_delay(endrow - startrow); } } @@ -497,8 +497,8 @@ static void compose_area(Integer startrow, Integer endrow, Integer startcol, Int void ui_comp_compose_grid(ScreenGrid *grid) { if (ui_comp_should_draw()) { - compose_area(grid->comp_row, grid->comp_row+grid->Rows, - grid->comp_col, grid->comp_col+grid->Columns); + compose_area(grid->comp_row, grid->comp_row + grid->Rows, + grid->comp_col, grid->comp_col + grid->Columns); } } @@ -541,13 +541,13 @@ static void ui_comp_raw_line(UI *ui, Integer grid, Integer row, Integer startcol // TODO(bfredl): eventually should just fix compose_line to respect clearing // and optimize it for uncovered lines. if (flags & kLineFlagInvalid || covered || curgrid->blending) { - compose_debug(row, row+1, startcol, clearcol, dbghl_composed, true); + compose_debug(row, row + 1, startcol, clearcol, dbghl_composed, true); compose_line(row, startcol, clearcol, flags); } else { - compose_debug(row, row+1, startcol, endcol, dbghl_normal, false); - compose_debug(row, row+1, endcol, clearcol, dbghl_clear, true); + compose_debug(row, row + 1, startcol, endcol, dbghl_normal, false); + compose_debug(row, row + 1, endcol, clearcol, dbghl_clear, true); #ifndef NDEBUG - for (int i = 0; i < endcol-startcol; i++) { + for (int i = 0; i < endcol - startcol; i++) { assert(attrs[i] >= 0); } #endif @@ -572,7 +572,7 @@ static void ui_comp_msg_set_pos(UI *ui, Integer grid, Integer row, Boolean scrol { msg_grid.comp_row = (int)row; if (scrolled && row > 0) { - msg_sep_row = (int)row-1; + msg_sep_row = (int)row - 1; if (sep_char.data) { STRLCPY(msg_sep_char, sep_char.data, sizeof(msg_sep_char)); } @@ -581,19 +581,19 @@ static void ui_comp_msg_set_pos(UI *ui, Integer grid, Integer row, Boolean scrol } if (row > msg_current_row && ui_comp_should_draw()) { - compose_area(MAX(msg_current_row-1, 0), row, 0, default_grid.Columns); + compose_area(MAX(msg_current_row - 1, 0), row, 0, default_grid.Columns); } else if (row < msg_current_row && ui_comp_should_draw() && msg_current_row < Rows) { int delta = msg_current_row - (int)row; if (msg_grid.blending) { - int first_row = MAX((int)row-(scrolled?1:0), 0); - compose_area(first_row, Rows-delta, 0, Columns); + int first_row = MAX((int)row - (scrolled?1:0), 0); + compose_area(first_row, Rows - delta, 0, Columns); } else { // scroll separator together with message text - int first_row = MAX((int)row-(msg_was_scrolled?1:0), 0); + int first_row = MAX((int)row - (msg_was_scrolled?1:0), 0); ui_composed_call_grid_scroll(1, first_row, Rows, 0, Columns, delta, 0); if (scrolled && !msg_was_scrolled && row > 0) { - compose_area(row-1, row, 0, Columns); + compose_area(row - 1, row, 0, Columns); } } } @@ -607,9 +607,9 @@ static void ui_comp_msg_set_pos(UI *ui, Integer grid, Integer row, Boolean scrol /// TODO(bfredl): currently this only handles message row static bool curgrid_covered_above(int row) { - bool above_msg = (kv_A(layers, kv_size(layers)-1) == &msg_grid - && row < msg_current_row-(msg_was_scrolled?1:0)); - return kv_size(layers)-(above_msg?1:0) > curgrid->comp_index+1; + bool above_msg = (kv_A(layers, kv_size(layers) - 1) == &msg_grid + && row < msg_current_row - (msg_was_scrolled?1:0)); + return kv_size(layers) - (above_msg?1:0) > curgrid->comp_index + 1; } static void ui_comp_grid_scroll(UI *ui, Integer grid, Integer top, Integer bot, Integer left, @@ -634,8 +634,8 @@ static void ui_comp_grid_scroll(UI *ui, Integer grid, Integer top, Integer bot, // row, where the latter might scroll invalid space created by the first. // ideally win_update() should keep track of this itself and not scroll // the invalid space. - if (curgrid->attrs[curgrid->line_offset[r-curgrid->comp_row] - +left-curgrid->comp_col] >= 0) { + if (curgrid->attrs[curgrid->line_offset[r - curgrid->comp_row] + + left - curgrid->comp_col] >= 0) { compose_line(r, left, right, 0); } } @@ -665,4 +665,3 @@ static void ui_comp_grid_resize(UI *ui, Integer grid, Integer width, Integer hei } } } - diff --git a/src/nvim/undo.c b/src/nvim/undo.c index 2d8df4cad8..007febee66 100644 --- a/src/nvim/undo.c +++ b/src/nvim/undo.c @@ -3110,7 +3110,7 @@ void u_undoline(void) oldp = u_save_line(curbuf->b_u_line_lnum); ml_replace(curbuf->b_u_line_lnum, curbuf->b_u_line_ptr, true); changed_bytes(curbuf->b_u_line_lnum, 0); - extmark_splice_cols(curbuf, (int)curbuf->b_u_line_lnum-1, 0, (colnr_T)STRLEN(oldp), + extmark_splice_cols(curbuf, (int)curbuf->b_u_line_lnum - 1, 0, (colnr_T)STRLEN(oldp), (colnr_T)STRLEN(curbuf->b_u_line_ptr), kExtmarkUndo); xfree(curbuf->b_u_line_ptr); curbuf->b_u_line_ptr = oldp; diff --git a/src/nvim/version.c b/src/nvim/version.c index 71cca52773..d5e8d435df 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -2053,7 +2053,7 @@ static void list_features(void) version_msg(_("\n\nFeatures: ")); for (int i = 0; features[i] != NULL; i++) { version_msg(features[i]); - if (features[i+1] != NULL) { + if (features[i + 1] != NULL) { version_msg(" "); } } @@ -2329,4 +2329,3 @@ void ex_intro(exarg_T *eap) intro_message(TRUE); wait_return(TRUE); } - diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c index b0fbc586b2..29d686193d 100644 --- a/src/nvim/viml/parser/expressions.c +++ b/src/nvim/viml/parser/expressions.c @@ -541,8 +541,7 @@ LexExprToken viml_pexpr_next_token(ParserState *const pstate, const int flags) ret.data.opt.len = 4; ret.len += 4; } else { - for (; p < e && ASCII_ISALPHA(*p); p++) { - } + for (; p < e && ASCII_ISALPHA(*p); p++) {} ret.data.opt.len = (size_t)(p - ret.data.opt.name); if (ret.data.opt.len == 0) { OPTNAMEMISS(ret); diff --git a/src/nvim/window.c b/src/nvim/window.c index 50921c8302..7d96532b8e 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -429,7 +429,7 @@ newwindow: // set current window height case Ctrl__: case '_': - win_setheight(Prenum ? (int)Prenum : Rows-1); + win_setheight(Prenum ? (int)Prenum : Rows - 1); break; // increase current window width @@ -881,11 +881,11 @@ void ui_ext_win_position(win_T *wp) row += row_off; col += col_off; if (c.bufpos.lnum >= 0) { - pos_T pos = { c.bufpos.lnum+1, c.bufpos.col, 0 }; + pos_T pos = { c.bufpos.lnum + 1, c.bufpos.col, 0 }; int trow, tcol, tcolc, tcole; textpos2screenpos(win, &pos, &trow, &tcol, &tcolc, &tcole, true); - row += trow-1; - col += tcol-1; + row += trow - 1; + col += tcol - 1; } } api_clear_error(&dummy); @@ -931,13 +931,13 @@ void ui_ext_win_viewport(win_T *wp) if ((wp == curwin || ui_has(kUIMultigrid)) && wp->w_viewport_invalid) { int botline = wp->w_botline; int line_count = wp->w_buffer->b_ml.ml_line_count; - if (botline == line_count+1 && wp->w_empty_rows == 0) { + if (botline == line_count + 1 && wp->w_empty_rows == 0) { // TODO(bfredl): The might be more cases to consider, like how does this // interact with incomplete final line? Diff filler lines? botline = wp->w_buffer->b_ml.ml_line_count; } - ui_call_win_viewport(wp->w_grid_alloc.handle, wp->handle, wp->w_topline-1, - botline, wp->w_cursor.lnum-1, wp->w_cursor.col, + ui_call_win_viewport(wp->w_grid_alloc.handle, wp->handle, wp->w_topline - 1, + botline, wp->w_cursor.lnum - 1, wp->w_cursor.col, line_count); wp->w_viewport_invalid = false; } @@ -1877,8 +1877,7 @@ static void win_rotate(bool upwards, int count) assert(frp->fr_parent->fr_child); // find last frame and append removed window/frame after it - for (; frp->fr_next != NULL; frp = frp->fr_next) { - } + for (; frp->fr_next != NULL; frp = frp->fr_next) {} win_append(frp->fr_win, wp1); frame_append(frp, wp1->w_frame); @@ -1886,8 +1885,7 @@ static void win_rotate(bool upwards, int count) } else { // last window becomes first window // find last window/frame in the list and remove it for (frp = curwin->w_frame; frp->fr_next != NULL; - frp = frp->fr_next) { - } + frp = frp->fr_next) {} wp1 = frp->fr_win; wp2 = wp1->w_prev; // will become last window win_remove(wp1, NULL); @@ -2957,8 +2955,7 @@ void win_close_othertab(win_T *win, int free_buf, tabpage_T *tp) // Careful: Autocommands may have closed the tab page or made it the // current tab page. - for (ptp = first_tabpage; ptp != NULL && ptp != tp; ptp = ptp->tp_next) { - } + for (ptp = first_tabpage; ptp != NULL && ptp != tp; ptp = ptp->tp_next) {} if (ptp == NULL || tp == curtab) { // If the buffer was removed from the window we have to give it any // buffer. @@ -3316,8 +3313,7 @@ static tabpage_T *alt_tabpage(void) } // Find the last but one tab page. - for (tp = first_tabpage; tp->tp_next != curtab; tp = tp->tp_next) { - } + for (tp = first_tabpage; tp->tp_next != curtab; tp = tp->tp_next) {} return tp; } @@ -3440,13 +3436,11 @@ void frame_new_height(frame_T *topfrp, int height, bool topfirst, bool wfh) if (topfirst) { do { frp = frp->fr_next; - } - while (wfh && frp != NULL && frame_fixed_height(frp)); + } while (wfh && frp != NULL && frame_fixed_height(frp)); } else { do { frp = frp->fr_prev; - } - while (wfh && frp != NULL && frame_fixed_height(frp)); + } while (wfh && frp != NULL && frame_fixed_height(frp)); } // Increase "height" if we could not reduce enough frames. if (frp == NULL) { @@ -3553,8 +3547,7 @@ static void frame_add_statusline(frame_T *frp) } else { assert(frp->fr_layout == FR_COL); // Only need to handle the last frame in the column. - for (frp = frp->fr_child; frp->fr_next != NULL; frp = frp->fr_next) { - } + for (frp = frp->fr_child; frp->fr_next != NULL; frp = frp->fr_next) {} frame_add_statusline(frp); } } @@ -3640,13 +3633,11 @@ static void frame_new_width(frame_T *topfrp, int width, bool leftfirst, bool wfw if (leftfirst) { do { frp = frp->fr_next; - } - while (wfw && frp != NULL && frame_fixed_width(frp)); + } while (wfw && frp != NULL && frame_fixed_width(frp)); } else { do { frp = frp->fr_prev; - } - while (wfw && frp != NULL && frame_fixed_width(frp)); + } while (wfw && frp != NULL && frame_fixed_width(frp)); } // Increase "width" if we could not reduce enough frames. if (frp == NULL) { @@ -4424,14 +4415,12 @@ void goto_tabpage(int n) ttp = curtab; for (i = n; i < 0; ++i) { for (tp = first_tabpage; tp->tp_next != ttp && tp->tp_next != NULL; - tp = tp->tp_next) { - } + tp = tp->tp_next) {} ttp = tp; } } else if (n == 9999) { // Go to last tab page. - for (tp = first_tabpage; tp->tp_next != NULL; tp = tp->tp_next) { - } + for (tp = first_tabpage; tp->tp_next != NULL; tp = tp->tp_next) {} } else { // Go to tab page "n". tp = find_tabpage(n); diff --git a/src/uncrustify.cfg b/src/uncrustify.cfg index c1a5380fb8..401e48d6e0 100644 --- a/src/uncrustify.cfg +++ b/src/uncrustify.cfg @@ -81,7 +81,7 @@ sp_arith = ignore # ignore/add/remove/force/not_defined # Add or remove space around arithmetic operators '+' and '-'. # # Overrides sp_arith. -sp_arith_additive = ignore # ignore/add/remove/force/not_defined +sp_arith_additive = force # ignore/add/remove/force/not_defined # Add or remove space around assignment operator '=', '+=', etc. sp_assign = ignore # ignore/add/remove/force/not_defined @@ -172,7 +172,7 @@ sp_inside_paren = remove # ignore/add/remove/force/not_defined sp_paren_paren = remove # ignore/add/remove/force/not_defined # Add or remove space between back-to-back parentheses, i.e. ')(' vs. ') ('. -sp_cparen_oparen = ignore # ignore/add/remove/force/not_defined +sp_cparen_oparen = remove # ignore/add/remove/force/not_defined # Whether to balance spaces inside nested parentheses. sp_balance_nested_parens = false # true/false @@ -343,13 +343,13 @@ sp_inside_for_open = ignore # ignore/add/remove/force/not_defined sp_inside_for_close = ignore # ignore/add/remove/force/not_defined # Add or remove space between '((' or '))' of control statements. -sp_sparen_paren = ignore # ignore/add/remove/force/not_defined +sp_sparen_paren = remove # ignore/add/remove/force/not_defined # Add or remove space after ')' of control statements. sp_after_sparen = ignore # ignore/add/remove/force/not_defined # Add or remove space between ')' and '{' of control statements. -sp_sparen_brace = ignore # ignore/add/remove/force/not_defined +sp_sparen_brace = force # ignore/add/remove/force/not_defined # Add or remove space between 'do' and '{'. sp_do_brace_open = force # ignore/add/remove/force/not_defined @@ -592,7 +592,7 @@ sp_type_func = ignore # ignore/add/remove/force/not_defined sp_type_brace_init_lst = ignore # ignore/add/remove/force/not_defined # Add or remove space between function name and '(' on function declaration. -sp_func_proto_paren = ignore # ignore/add/remove/force/not_defined +sp_func_proto_paren = remove # ignore/add/remove/force/not_defined # Add or remove space between function name and '()' on function declaration # without parameters. @@ -1507,7 +1507,7 @@ donot_indent_func_def_close_paren = false # true/false # Whether to collapse empty blocks between '{' and '}'. # If true, overrides nl_inside_empty_func -nl_collapse_empty_body = false # true/false +nl_collapse_empty_body = true # true/false # Don't split one-line braced assignments, as in 'foo_t f = { 1, 2 };'. nl_assign_leave_one_liners = false # true/false @@ -1575,11 +1575,11 @@ nl_start_of_file = ignore # ignore/add/remove/force/not_defined nl_start_of_file_min = 0 # unsigned number # Add or remove newline at the end of the file. -nl_end_of_file = ignore # ignore/add/remove/force/not_defined +nl_end_of_file = force # ignore/add/remove/force/not_defined # The minimum number of newlines at the end of the file (only used if # nl_end_of_file is 'add' or 'force'). -nl_end_of_file_min = 0 # unsigned number +nl_end_of_file_min = 1 # unsigned number # Add or remove newline between '=' and '{'. nl_assign_brace = ignore # ignore/add/remove/force/not_defined @@ -1599,7 +1599,7 @@ nl_after_square_assign = ignore # ignore/add/remove/force/not_defined nl_fcall_brace = ignore # ignore/add/remove/force/not_defined # Add or remove newline between 'enum' and '{'. -nl_enum_brace = ignore # ignore/add/remove/force/not_defined +nl_enum_brace = remove # ignore/add/remove/force/not_defined # Add or remove newline between 'enum' and 'class'. nl_enum_class = ignore # ignore/add/remove/force/not_defined @@ -1675,7 +1675,7 @@ nl_oc_brace_catch = ignore # ignore/add/remove/force/not_defined nl_brace_square = ignore # ignore/add/remove/force/not_defined # Add or remove newline between '}' and ')' in a function invocation. -nl_brace_fparen = ignore # ignore/add/remove/force/not_defined +nl_brace_fparen = remove # ignore/add/remove/force/not_defined # Add or remove newline between 'while' and '{'. nl_while_brace = ignore # ignore/add/remove/force/not_defined @@ -1700,7 +1700,7 @@ nl_brace_brace = ignore # ignore/add/remove/force/not_defined nl_do_brace = remove # ignore/add/remove/force/not_defined # Add or remove newline between '}' and 'while' of 'do' statement. -nl_brace_while = ignore # ignore/add/remove/force/not_defined +nl_brace_while = remove # ignore/add/remove/force/not_defined # Add or remove newline between 'switch' and '{'. nl_switch_brace = ignore # ignore/add/remove/force/not_defined @@ -3391,5 +3391,5 @@ set QUESTION REAL_FATTR_CONST set QUESTION REAL_FATTR_NONNULL_ALL set QUESTION REAL_FATTR_PURE set QUESTION REAL_FATTR_WARN_UNUSED_RESULT -# option(s) with 'not default' value: 86 +# option(s) with 'not default' value: 97 # |