refactor: format with uncrustify #15722

This commit is contained in:
dundargoc
2021-09-19 22:07:42 +02:00
committed by GitHub
parent 6565adcbff
commit 853346a94d
16 changed files with 1806 additions and 1754 deletions

View File

@@ -1,25 +1,25 @@
// This is an open source non-commercial project. Dear PVS-Studio, please check
// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
#include <stdbool.h>
#include <inttypes.h>
#include <stdbool.h>
#include "nvim/ascii.h"
#include "nvim/assert.h"
#include "nvim/change.h"
#include "nvim/cursor.h"
#include "nvim/charset.h"
#include "nvim/cursor.h"
#include "nvim/extmark.h"
#include "nvim/fold.h"
#include "nvim/mark.h"
#include "nvim/memline.h"
#include "nvim/memory.h"
#include "nvim/misc1.h"
#include "nvim/move.h"
#include "nvim/plines.h"
#include "nvim/screen.h"
#include "nvim/extmark.h"
#include "nvim/state.h"
#include "nvim/vim.h"
#include "nvim/ascii.h"
#include "nvim/mark.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "cursor.c.generated.h"
@@ -63,7 +63,7 @@ int coladvance_force(colnr_T wcol)
if (wcol == MAXCOL) {
curwin->w_valid &= ~VALID_VIRTCOL;
} else {
/* Virtcol is valid */
// Virtcol is valid
curwin->w_valid |= VALID_VIRTCOL;
curwin->w_virtcol = wcol;
}
@@ -83,27 +83,25 @@ int coladvance(colnr_T wcol)
{
int rc = getvpos(&curwin->w_cursor, wcol);
if (wcol == MAXCOL || rc == FAIL)
if (wcol == MAXCOL || rc == FAIL) {
curwin->w_valid &= ~VALID_VIRTCOL;
else if (*get_cursor_pos_ptr() != TAB) {
/* Virtcol is valid when not on a TAB */
} else if (*get_cursor_pos_ptr() != TAB) {
// Virtcol is valid when not on a TAB
curwin->w_valid |= VALID_VIRTCOL;
curwin->w_virtcol = wcol;
}
return rc;
}
static int coladvance2(
pos_T *pos,
bool addspaces, // change the text to achieve our goal?
bool finetune, // change char offset for the exact column
colnr_T wcol_arg // column to move to (can be negative)
)
static int coladvance2(pos_T *pos, bool addspaces, // change the text to achieve our goal?
bool finetune, // change char offset for the exact column
colnr_T wcol_arg // column to move to (can be negative)
)
{
colnr_T wcol = wcol_arg;
int idx;
char_u *ptr;
char_u *line;
char_u *ptr;
char_u *line;
colnr_T col = 0;
int csize = 0;
int one_more;
@@ -121,8 +119,9 @@ static int coladvance2(
if ((addspaces || finetune) && !VIsual_active) {
curwin->w_curswant = linetabsize(line) + one_more;
if (curwin->w_curswant > 0)
if (curwin->w_curswant > 0) {
--curwin->w_curswant;
}
}
} else {
int width = curwin->w_width_inner - win_col_off(curwin);
@@ -133,8 +132,9 @@ static int coladvance2(
&& wcol >= (colnr_T)width
&& width > 0) {
csize = linetabsize(line);
if (csize > 0)
if (csize > 0) {
csize--;
}
if (wcol / width > (colnr_T)csize / width
&& ((State & INSERT) == 0 || (int)wcol > csize + 1)) {
@@ -148,7 +148,7 @@ static int coladvance2(
ptr = line;
while (col <= wcol && *ptr != NUL) {
/* Count a tab for what it's worth (if list mode not on) */
// Count a tab for what it's worth (if list mode not on)
csize = win_lbr_chartabsize(curwin, line, ptr, col, &head);
MB_PTR_ADV(ptr);
col += csize;
@@ -162,7 +162,7 @@ static int coladvance2(
*/
if (col > wcol || (!virtual_active() && one_more == 0)) {
idx -= 1;
/* Don't count the chars from 'showbreak'. */
// Don't count the chars from 'showbreak'.
csize -= head;
col -= csize;
}
@@ -175,7 +175,7 @@ static int coladvance2(
* filled with spaces. */
if (line[idx] == NUL) {
/* Append spaces */
// Append spaces
int correct = wcol - col;
size_t newline_size;
STRICT_ADD(idx, correct, &newline_size, size_t);
@@ -188,13 +188,14 @@ static int coladvance2(
idx += correct;
col = wcol;
} else {
/* Break a tab */
// Break a tab
int linelen = (int)STRLEN(line);
int correct = wcol - col - csize + 1; /* negative!! */
char_u *newline;
int correct = wcol - col - csize + 1; // negative!!
char_u *newline;
if (-correct > csize)
if (-correct > csize) {
return FAIL;
}
size_t n;
STRICT_ADD(linelen - 1, csize, &n, size_t);
@@ -216,16 +217,17 @@ static int coladvance2(
}
}
if (idx < 0)
if (idx < 0) {
pos->col = 0;
else
} else {
pos->col = idx;
}
pos->coladd = 0;
if (finetune) {
if (wcol == MAXCOL) {
/* The width of the last character is used to set coladd. */
// The width of the last character is used to set coladd.
if (!one_more) {
colnr_T scol, ecol;
@@ -319,15 +321,15 @@ void check_pos(buf_T *buf, pos_T *pos)
colnr_T len;
if (pos->lnum > buf->b_ml.ml_line_count) {
pos->lnum = buf->b_ml.ml_line_count;
pos->lnum = buf->b_ml.ml_line_count;
}
if (pos->col > 0) {
line = ml_get_buf(buf, pos->lnum, false);
len = (colnr_T)STRLEN(line);
if (pos->col > len) {
pos->col = len;
}
line = ml_get_buf(buf, pos->lnum, false);
len = (colnr_T)STRLEN(line);
if (pos->col > len) {
pos->col = len;
}
}
}
@@ -340,11 +342,13 @@ void check_cursor_lnum(void)
/* If there is a closed fold at the end of the file, put the cursor in
* its first line. Otherwise in the last line. */
if (!hasFolding(curbuf->b_ml.ml_line_count,
&curwin->w_cursor.lnum, NULL))
&curwin->w_cursor.lnum, NULL)) {
curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
}
}
if (curwin->w_cursor.lnum <= 0)
if (curwin->w_cursor.lnum <= 0) {
curwin->w_cursor.lnum = 1;
}
}
/*
@@ -430,8 +434,9 @@ void adjust_cursor_col(void)
{
if (curwin->w_cursor.col > 0
&& (!VIsual_active || *p_sel == 'o')
&& gchar_cursor() == NUL)
&& gchar_cursor() == NUL) {
--curwin->w_cursor.col;
}
}
/*
@@ -473,14 +478,15 @@ bool leftcol_changed(void)
coladvance(s - 1);
} else if (s < curwin->w_leftcol) {
retval = true;
if (coladvance(e + 1) == FAIL) { /* there isn't another character */
curwin->w_leftcol = s; /* adjust w_leftcol instead */
if (coladvance(e + 1) == FAIL) { // there isn't another character
curwin->w_leftcol = s; // adjust w_leftcol instead
changed_cline_bef_curs();
}
}
if (retval)
if (retval) {
curwin->w_set_curswant = true;
}
redraw_later(curwin, NOT_VALID);
return retval;
}