aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordundargoc <gocdundar@gmail.com>2023-12-20 17:22:19 +0100
committerdundargoc <33953936+dundargoc@users.noreply.github.com>2023-12-24 12:36:59 +0100
commitab2aad509d6e4fc57a6afe056275405ec6451671 (patch)
tree36c34cbd5d5cd1224ec4497baaf48e0835ceb0a6
parent84f6216130b6b6bffc97e0e221a92ccfa34e381e (diff)
downloadrneovim-ab2aad509d6e4fc57a6afe056275405ec6451671.tar.gz
rneovim-ab2aad509d6e4fc57a6afe056275405ec6451671.tar.bz2
rneovim-ab2aad509d6e4fc57a6afe056275405ec6451671.zip
refactor: follow style guide
-rw-r--r--src/nvim/buffer_defs.h6
-rw-r--r--src/nvim/eval/userfunc.c11
-rw-r--r--src/nvim/input.c10
-rw-r--r--src/nvim/keycodes.c6
-rw-r--r--src/nvim/lib/queue.h6
-rw-r--r--src/nvim/match.c4
-rw-r--r--src/nvim/ops.c3
7 files changed, 14 insertions, 32 deletions
diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h
index ca6e874c1f..afe77b84f5 100644
--- a/src/nvim/buffer_defs.h
+++ b/src/nvim/buffer_defs.h
@@ -1316,9 +1316,3 @@ struct window_S {
// Size of the w_statuscol_click_defs array
size_t w_statuscol_click_defs_size;
};
-
-/// Macros defined in Vim, but not in Neovim
-// uncrustify:off
-#define CHANGEDTICK(buf) \
- (=== Include buffer.h & use buf_(get|set|inc) _changedtick ===)
-// uncrustify:on
diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c
index d0b3fe7993..5d8c173dd1 100644
--- a/src/nvim/eval/userfunc.c
+++ b/src/nvim/eval/userfunc.c
@@ -105,7 +105,6 @@ static int get_function_args(char **argp, char endchar, garray_T *newargs, int *
bool mustend = false;
char *arg = *argp;
char *p = arg;
- uint8_t c;
if (newargs != NULL) {
ga_init(newargs, (int)sizeof(char *), 3);
@@ -142,7 +141,7 @@ static int get_function_args(char **argp, char endchar, garray_T *newargs, int *
}
if (newargs != NULL) {
ga_grow(newargs, 1);
- c = (uint8_t)(*p);
+ uint8_t c = (uint8_t)(*p);
*p = NUL;
arg = xstrdup(arg);
@@ -173,7 +172,7 @@ static int get_function_args(char **argp, char endchar, garray_T *newargs, int *
while (p > expr && ascii_iswhite(p[-1])) {
p--;
}
- c = (uint8_t)(*p);
+ uint8_t c = (uint8_t)(*p);
*p = NUL;
expr = xstrdup(expr);
((char **)(default_args->ga_data))[default_args->ga_len] = expr;
@@ -325,7 +324,6 @@ int get_lambda_tv(char **arg, typval_T *rettv, evalarg_T *evalarg)
if (evaluate) {
int flags = 0;
- char *p;
garray_T newlines;
char *name = get_lambda_name();
@@ -338,7 +336,7 @@ int get_lambda_tv(char **arg, typval_T *rettv, evalarg_T *evalarg)
// Add "return " before the expression.
size_t len = (size_t)(7 + end - start + 1);
- p = xmalloc(len);
+ char *p = xmalloc(len);
((char **)(newlines.ga_data))[newlines.ga_len++] = p;
STRCPY(p, "return ");
xstrlcpy(p + 7, start, (size_t)(end - start) + 1);
@@ -918,7 +916,6 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rett
FUNC_ATTR_NONNULL_ARG(1, 3, 4)
{
bool using_sandbox = false;
- int save_did_emsg;
static int depth = 0;
dictitem_T *v;
int fixvar_idx = 0; // index in fc_fixvar[]
@@ -1167,7 +1164,7 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rett
const sctx_T save_current_sctx = current_sctx;
current_sctx = fp->uf_script_ctx;
- save_did_emsg = did_emsg;
+ int save_did_emsg = did_emsg;
did_emsg = false;
if (default_arg_err && (fp->uf_flags & FC_ABORT)) {
diff --git a/src/nvim/input.c b/src/nvim/input.c
index af66cfdcba..2dfb67acc5 100644
--- a/src/nvim/input.c
+++ b/src/nvim/input.c
@@ -221,10 +221,6 @@ int get_number(int colon, int *mouse_used)
/// the line number.
int prompt_for_number(int *mouse_used)
{
- int i;
- int save_cmdline_row;
- int save_State;
-
// When using ":silent" assume that <CR> was entered.
if (mouse_used != NULL) {
msg_puts(_("Type number and <Enter> or click with the mouse "
@@ -235,14 +231,14 @@ int prompt_for_number(int *mouse_used)
// Set the state such that text can be selected/copied/pasted and we still
// get mouse events.
- save_cmdline_row = cmdline_row;
+ int save_cmdline_row = cmdline_row;
cmdline_row = 0;
- save_State = State;
+ int save_State = State;
State = MODE_ASKMORE; // prevents a screen update when using a timer
// May show different mouse shape.
setmouse();
- i = get_number(true, mouse_used);
+ int i = get_number(true, mouse_used);
if (KeyTyped) {
// don't call wait_return() now
if (msg_row > 0) {
diff --git a/src/nvim/keycodes.c b/src/nvim/keycodes.c
index d913beeb0c..dd7a917380 100644
--- a/src/nvim/keycodes.c
+++ b/src/nvim/keycodes.c
@@ -875,9 +875,7 @@ char *replace_termcodes(const char *const from, const size_t from_len, char **co
const char *const cpo_val)
FUNC_ATTR_NONNULL_ARG(1, 3, 7)
{
- char key;
size_t dlen = 0;
- const char *src;
const char *const end = from + from_len - 1;
// backslash is a special character
@@ -891,7 +889,7 @@ char *replace_termcodes(const char *const from, const size_t from_len, char **co
const size_t buf_len = allocated ? from_len * 6 + 1 : 128;
char *result = allocated ? xmalloc(buf_len) : *bufp; // buffer for resulting string
- src = from;
+ const char *src = from;
// Copy each byte from *from to result[dlen]
while (src <= end) {
@@ -966,7 +964,7 @@ char *replace_termcodes(const char *const from, const size_t from_len, char **co
// For "from" side the CTRL-V at the end is included, for the "to"
// part it is removed.
// If 'cpoptions' does not contain 'B', also accept a backslash.
- key = *src;
+ char key = *src;
if (key == Ctrl_V || (do_backslash && key == '\\')) {
src++; // skip CTRL-V or backslash
if (src > end) {
diff --git a/src/nvim/lib/queue.h b/src/nvim/lib/queue.h
index 0c4ab7e9ed..1f113a057a 100644
--- a/src/nvim/lib/queue.h
+++ b/src/nvim/lib/queue.h
@@ -23,9 +23,9 @@
#include "nvim/func_attr.h"
-typedef struct _queue {
- struct _queue *next;
- struct _queue *prev;
+typedef struct queue {
+ struct queue *next;
+ struct queue *prev;
} QUEUE;
// Public macros.
diff --git a/src/nvim/match.c b/src/nvim/match.c
index 7543fb2b9d..013ab3e6f0 100644
--- a/src/nvim/match.c
+++ b/src/nvim/match.c
@@ -450,10 +450,8 @@ static void next_search_hl(win_T *win, match_T *search_hl, match_T *shl, linenr_
} else if (vim_strchr(p_cpo, CPO_SEARCH) == NULL
|| (shl->rm.endpos[0].lnum == 0
&& shl->rm.endpos[0].col <= shl->rm.startpos[0].col)) {
- char *ml;
-
matchcol = shl->rm.startpos[0].col;
- ml = ml_get_buf(shl->buf, lnum) + matchcol;
+ char *ml = ml_get_buf(shl->buf, lnum) + matchcol;
if (*ml == NUL) {
matchcol++;
shl->lnum = 0;
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index d0a6b2c074..8dc267cc45 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -215,7 +215,6 @@ int get_extra_op_char(int optype)
/// handle a shift operation
void op_shift(oparg_T *oap, int curs_top, int amount)
{
- int i;
int block_col = 0;
if (u_save((linenr_T)(oap->start.lnum - 1),
@@ -227,7 +226,7 @@ void op_shift(oparg_T *oap, int curs_top, int amount)
block_col = curwin->w_cursor.col;
}
- for (i = oap->line_count - 1; i >= 0; i--) {
+ for (int i = oap->line_count - 1; i >= 0; i--) {
int first_char = (uint8_t)(*get_cursor_line_ptr());
if (first_char == NUL) { // empty line
curwin->w_cursor.col = 0;