aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFelipe Oliveira Carvalho <felipekde@gmail.com>2014-12-13 10:56:17 -0300
committerFelipe Oliveira Carvalho <felipekde@gmail.com>2014-12-13 23:36:11 -0300
commit0bc40e660c0a74776ace86ad5e393755523c3803 (patch)
tree94fd08577b5eed003b6f7eb3a7bcafcac7f20a66 /src
parent77135447e09903b45d1482da45869946212f7904 (diff)
downloadrneovim-0bc40e660c0a74776ace86ad5e393755523c3803.tar.gz
rneovim-0bc40e660c0a74776ace86ad5e393755523c3803.tar.bz2
rneovim-0bc40e660c0a74776ace86ad5e393755523c3803.zip
Simple refatorings that didn't fit the pattern of the last commit
Diffstat (limited to 'src')
-rw-r--r--src/nvim/buffer.c8
-rw-r--r--src/nvim/ex_cmds.c9
-rw-r--r--src/nvim/ex_eval.c40
-rw-r--r--src/nvim/indent_c.c4
-rw-r--r--src/nvim/screen.c7
-rw-r--r--src/nvim/syntax.c46
6 files changed, 49 insertions, 65 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index b8dbb413ba..f84e25cdfb 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -2105,14 +2105,10 @@ void get_winopts(buf_T *buf)
*/
pos_T *buflist_findfpos(buf_T *buf)
{
- wininfo_T *wip;
static pos_T no_position = INIT_POS_T(1, 0, 0);
- wip = find_wininfo(buf, FALSE);
- if (wip != NULL)
- return &(wip->wi_fpos);
- else
- return &no_position;
+ wininfo_T *wip = find_wininfo(buf, FALSE);
+ return (wip == NULL) ? &no_position : &(wip->wi_fpos);
}
/*
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index 78386dda45..1c6aa536b3 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -3329,12 +3329,11 @@ void ex_z(exarg_T *eap)
if (!VIM_ISDIGIT(*x)) {
EMSG(_("E144: non-numeric argument to :z"));
return;
- } else {
- bigness = atoi((char *)x);
- p_window = bigness;
- if (*kind == '=')
- bigness += 2;
}
+ bigness = atoi((char *)x);
+ p_window = bigness;
+ if (*kind == '=')
+ bigness += 2;
}
/* the number of '-' and '+' multiplies the distance */
diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c
index 196f8e6136..b0c4e14f46 100644
--- a/src/nvim/ex_eval.c
+++ b/src/nvim/ex_eval.c
@@ -246,28 +246,24 @@ int cause_errthrow(char_u *mesg, int severe, int *ignore)
plist = &(*plist)->next;
elem = xmalloc(sizeof(struct msglist));
- {
- elem->msg = vim_strsave(mesg);
- {
- elem->next = NULL;
- elem->throw_msg = NULL;
- *plist = elem;
- if (plist == msg_list || severe) {
- char_u *tmsg;
-
- /* Skip the extra "Vim " prefix for message "E458". */
- tmsg = elem->msg;
- if (STRNCMP(tmsg, "Vim E", 5) == 0
- && VIM_ISDIGIT(tmsg[5])
- && VIM_ISDIGIT(tmsg[6])
- && VIM_ISDIGIT(tmsg[7])
- && tmsg[8] == ':'
- && tmsg[9] == ' ')
- (*msg_list)->throw_msg = &tmsg[4];
- else
- (*msg_list)->throw_msg = tmsg;
- }
- }
+ elem->msg = vim_strsave(mesg);
+ elem->next = NULL;
+ elem->throw_msg = NULL;
+ *plist = elem;
+ if (plist == msg_list || severe) {
+ char_u *tmsg;
+
+ /* Skip the extra "Vim " prefix for message "E458". */
+ tmsg = elem->msg;
+ if (STRNCMP(tmsg, "Vim E", 5) == 0
+ && VIM_ISDIGIT(tmsg[5])
+ && VIM_ISDIGIT(tmsg[6])
+ && VIM_ISDIGIT(tmsg[7])
+ && tmsg[8] == ':'
+ && tmsg[9] == ' ')
+ (*msg_list)->throw_msg = &tmsg[4];
+ else
+ (*msg_list)->throw_msg = tmsg;
}
}
return TRUE;
diff --git a/src/nvim/indent_c.c b/src/nvim/indent_c.c
index 4eeefd6c09..6648a9f7c6 100644
--- a/src/nvim/indent_c.c
+++ b/src/nvim/indent_c.c
@@ -233,9 +233,7 @@ static int cin_islabel_skip(char_u **s)
*/
int cin_islabel(void)
{ /* XXX */
- char_u *s;
-
- s = cin_skipcomment(get_cursor_line_ptr());
+ char_u *s = cin_skipcomment(get_cursor_line_ptr());
/*
* Exclude "default" from labels, since it should be indented
diff --git a/src/nvim/screen.c b/src/nvim/screen.c
index 9e21676b2a..0148979335 100644
--- a/src/nvim/screen.c
+++ b/src/nvim/screen.c
@@ -4283,7 +4283,7 @@ static int comp_char_differs(int off_from, int off_to)
*/
static int char_needs_redraw(int off_from, int off_to, int cols)
{
- if (cols > 0
+ return (cols > 0
&& ((ScreenLines[off_from] != ScreenLines[off_to]
|| ScreenAttrs[off_from] != ScreenAttrs[off_to])
@@ -4299,10 +4299,7 @@ static int char_needs_redraw(int off_from, int off_to, int cols)
&& comp_char_differs(off_from, off_to))
|| ((*mb_off2cells)(off_from, off_from + cols) > 1
&& ScreenLines[off_from + 1]
- != ScreenLines[off_to + 1])))
- ))
- return TRUE;
- return FALSE;
+ != ScreenLines[off_to + 1])))));
}
/*
diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c
index c8a1a1a7c7..b7a485598b 100644
--- a/src/nvim/syntax.c
+++ b/src/nvim/syntax.c
@@ -1513,33 +1513,31 @@ syn_finish_line (
stateitem_T *cur_si;
colnr_T prev_current_col;
- if (!current_finished) {
- while (!current_finished) {
- (void)syn_current_attr(syncing, FALSE, NULL, FALSE);
+ while (!current_finished) {
+ (void)syn_current_attr(syncing, FALSE, NULL, FALSE);
+ /*
+ * When syncing, and found some item, need to check the item.
+ */
+ if (syncing && current_state.ga_len) {
/*
- * When syncing, and found some item, need to check the item.
+ * Check for match with sync item.
*/
- if (syncing && current_state.ga_len) {
- /*
- * Check for match with sync item.
- */
- cur_si = &CUR_STATE(current_state.ga_len - 1);
- if (cur_si->si_idx >= 0
- && (SYN_ITEMS(syn_block)[cur_si->si_idx].sp_flags
- & (HL_SYNC_HERE|HL_SYNC_THERE)))
- return TRUE;
-
- /* syn_current_attr() will have skipped the check for an item
- * that ends here, need to do that now. Be careful not to go
- * past the NUL. */
- prev_current_col = current_col;
- if (syn_getcurline()[current_col] != NUL)
- ++current_col;
- check_state_ends();
- current_col = prev_current_col;
- }
- ++current_col;
+ cur_si = &CUR_STATE(current_state.ga_len - 1);
+ if (cur_si->si_idx >= 0
+ && (SYN_ITEMS(syn_block)[cur_si->si_idx].sp_flags
+ & (HL_SYNC_HERE|HL_SYNC_THERE)))
+ return TRUE;
+
+ /* syn_current_attr() will have skipped the check for an item
+ * that ends here, need to do that now. Be careful not to go
+ * past the NUL. */
+ prev_current_col = current_col;
+ if (syn_getcurline()[current_col] != NUL)
+ ++current_col;
+ check_state_ends();
+ current_col = prev_current_col;
}
+ ++current_col;
}
return FALSE;
}