aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/textformat.c
diff options
context:
space:
mode:
authordundargoc <gocdundar@gmail.com>2023-11-13 23:40:37 +0100
committerdundargoc <33953936+dundargoc@users.noreply.github.com>2023-11-19 15:08:35 +0100
commitac1113ded5f8f09dd99a9894d7a7e795626fb728 (patch)
tree9cf615d03efafe2c44e539cb45f1b3df171b3e85 /src/nvim/textformat.c
parent1798a4b5e9f0ae56cd800095f79423fea5cae8ca (diff)
downloadrneovim-ac1113ded5f8f09dd99a9894d7a7e795626fb728.tar.gz
rneovim-ac1113ded5f8f09dd99a9894d7a7e795626fb728.tar.bz2
rneovim-ac1113ded5f8f09dd99a9894d7a7e795626fb728.zip
refactor: follow style guide
- reduce variable scope - prefer initialization over declaration and assignment
Diffstat (limited to 'src/nvim/textformat.c')
-rw-r--r--src/nvim/textformat.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/nvim/textformat.c b/src/nvim/textformat.c
index 58037fef36..bf7044c663 100644
--- a/src/nvim/textformat.c
+++ b/src/nvim/textformat.c
@@ -516,9 +516,8 @@ static bool ends_in_white(linenr_T lnum)
static bool same_leader(linenr_T lnum, int leader1_len, char *leader1_flags, int leader2_len,
char *leader2_flags)
{
- int idx1 = 0, idx2 = 0;
- char *line1;
- char *line2;
+ int idx1 = 0;
+ int idx2 = 0;
if (leader1_len == 0) {
return leader2_len == 0;
@@ -557,9 +556,9 @@ static bool same_leader(linenr_T lnum, int leader1_len, char *leader1_flags, int
// Get current line and next line, compare the leaders.
// The first line has to be saved, only one line can be locked at a time.
- line1 = xstrdup(ml_get(lnum));
+ char *line1 = xstrdup(ml_get(lnum));
for (idx1 = 0; ascii_iswhite(line1[idx1]); idx1++) {}
- line2 = ml_get(lnum + 1);
+ char *line2 = ml_get(lnum + 1);
for (idx2 = 0; idx2 < leader2_len; idx2++) {
if (!ascii_iswhite(line2[idx2])) {
if (line1[idx1++] != line2[idx2]) {
@@ -582,7 +581,6 @@ static bool same_leader(linenr_T lnum, int leader1_len, char *leader1_flags, int
/// false when the previous line is in the same paragraph.
static bool paragraph_start(linenr_T lnum)
{
- char *p;
int leader_len = 0; // leader len of current line
char *leader_flags = NULL; // flags for leader of current line
int next_leader_len = 0; // leader len of next line
@@ -591,7 +589,7 @@ static bool paragraph_start(linenr_T lnum)
if (lnum <= 1) {
return true; // start of the file
}
- p = ml_get(lnum - 1);
+ char *p = ml_get(lnum - 1);
if (*p == NUL) {
return true; // after empty line
}