forked from aniani/vim
patch 8.2.4704: using "else" after return or break increases indent
Problem: Using "else" after return or break increases indent. Solution: Remove "else" and reduce indent. (Goc Dundar, closes #10099)
This commit is contained in:
committed by
Bram Moolenaar
parent
cb49a1d934
commit
f26c16144d
43
src/fileio.c
43
src/fileio.c
@@ -1245,30 +1245,29 @@ retry:
|
|||||||
read_buf_col += n;
|
read_buf_col += n;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
// Append whole line and new-line. Change NL
|
||||||
|
// to NUL to reverse the effect done below.
|
||||||
|
for (ni = 0; ni < n; ++ni)
|
||||||
{
|
{
|
||||||
// Append whole line and new-line. Change NL
|
if (p[ni] == NL)
|
||||||
// to NUL to reverse the effect done below.
|
ptr[tlen++] = NUL;
|
||||||
for (ni = 0; ni < n; ++ni)
|
else
|
||||||
{
|
ptr[tlen++] = p[ni];
|
||||||
if (p[ni] == NL)
|
|
||||||
ptr[tlen++] = NUL;
|
|
||||||
else
|
|
||||||
ptr[tlen++] = p[ni];
|
|
||||||
}
|
|
||||||
ptr[tlen++] = NL;
|
|
||||||
read_buf_col = 0;
|
|
||||||
if (++read_buf_lnum > from)
|
|
||||||
{
|
|
||||||
// When the last line didn't have an
|
|
||||||
// end-of-line don't add it now either.
|
|
||||||
if (!curbuf->b_p_eol)
|
|
||||||
--tlen;
|
|
||||||
size = tlen;
|
|
||||||
eof = TRUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
ptr[tlen++] = NL;
|
||||||
|
read_buf_col = 0;
|
||||||
|
if (++read_buf_lnum > from)
|
||||||
|
{
|
||||||
|
// When the last line didn't have an
|
||||||
|
// end-of-line don't add it now either.
|
||||||
|
if (!curbuf->b_p_eol)
|
||||||
|
--tlen;
|
||||||
|
size = tlen;
|
||||||
|
eof = TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
159
src/memline.c
159
src/memline.c
@@ -3165,94 +3165,93 @@ ml_append_int(
|
|||||||
*/
|
*/
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else // pointer block full
|
// pointer block full
|
||||||
|
/*
|
||||||
|
* split the pointer block
|
||||||
|
* allocate a new pointer block
|
||||||
|
* move some of the pointer into the new block
|
||||||
|
* prepare for updating the parent block
|
||||||
|
*/
|
||||||
|
for (;;) // do this twice when splitting block 1
|
||||||
{
|
{
|
||||||
/*
|
hp_new = ml_new_ptr(mfp);
|
||||||
* split the pointer block
|
if (hp_new == NULL) // TODO: try to fix tree
|
||||||
* allocate a new pointer block
|
goto theend;
|
||||||
* move some of the pointer into the new block
|
pp_new = (PTR_BL *)(hp_new->bh_data);
|
||||||
* prepare for updating the parent block
|
|
||||||
*/
|
|
||||||
for (;;) // do this twice when splitting block 1
|
|
||||||
{
|
|
||||||
hp_new = ml_new_ptr(mfp);
|
|
||||||
if (hp_new == NULL) // TODO: try to fix tree
|
|
||||||
goto theend;
|
|
||||||
pp_new = (PTR_BL *)(hp_new->bh_data);
|
|
||||||
|
|
||||||
if (hp->bh_bnum != 1)
|
if (hp->bh_bnum != 1)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/*
|
|
||||||
* if block 1 becomes full the tree is given an extra level
|
|
||||||
* The pointers from block 1 are moved into the new block.
|
|
||||||
* block 1 is updated to point to the new block
|
|
||||||
* then continue to split the new block
|
|
||||||
*/
|
|
||||||
mch_memmove(pp_new, pp, (size_t)page_size);
|
|
||||||
pp->pb_count = 1;
|
|
||||||
pp->pb_pointer[0].pe_bnum = hp_new->bh_bnum;
|
|
||||||
pp->pb_pointer[0].pe_line_count = buf->b_ml.ml_line_count;
|
|
||||||
pp->pb_pointer[0].pe_old_lnum = 1;
|
|
||||||
pp->pb_pointer[0].pe_page_count = 1;
|
|
||||||
mf_put(mfp, hp, TRUE, FALSE); // release block 1
|
|
||||||
hp = hp_new; // new block is to be split
|
|
||||||
pp = pp_new;
|
|
||||||
CHECK(stack_idx != 0, _("stack_idx should be 0"));
|
|
||||||
ip->ip_index = 0;
|
|
||||||
++stack_idx; // do block 1 again later
|
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
* move the pointers after the current one to the new block
|
* if block 1 becomes full the tree is given an extra level
|
||||||
* If there are none, the new entry will be in the new block.
|
* The pointers from block 1 are moved into the new block.
|
||||||
|
* block 1 is updated to point to the new block
|
||||||
|
* then continue to split the new block
|
||||||
*/
|
*/
|
||||||
total_moved = pp->pb_count - pb_idx - 1;
|
mch_memmove(pp_new, pp, (size_t)page_size);
|
||||||
if (total_moved)
|
pp->pb_count = 1;
|
||||||
{
|
pp->pb_pointer[0].pe_bnum = hp_new->bh_bnum;
|
||||||
mch_memmove(&pp_new->pb_pointer[0],
|
pp->pb_pointer[0].pe_line_count = buf->b_ml.ml_line_count;
|
||||||
|
pp->pb_pointer[0].pe_old_lnum = 1;
|
||||||
|
pp->pb_pointer[0].pe_page_count = 1;
|
||||||
|
mf_put(mfp, hp, TRUE, FALSE); // release block 1
|
||||||
|
hp = hp_new; // new block is to be split
|
||||||
|
pp = pp_new;
|
||||||
|
CHECK(stack_idx != 0, _("stack_idx should be 0"));
|
||||||
|
ip->ip_index = 0;
|
||||||
|
++stack_idx; // do block 1 again later
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* move the pointers after the current one to the new block
|
||||||
|
* If there are none, the new entry will be in the new block.
|
||||||
|
*/
|
||||||
|
total_moved = pp->pb_count - pb_idx - 1;
|
||||||
|
if (total_moved)
|
||||||
|
{
|
||||||
|
mch_memmove(&pp_new->pb_pointer[0],
|
||||||
&pp->pb_pointer[pb_idx + 1],
|
&pp->pb_pointer[pb_idx + 1],
|
||||||
(size_t)(total_moved) * sizeof(PTR_EN));
|
(size_t)(total_moved) * sizeof(PTR_EN));
|
||||||
pp_new->pb_count = total_moved;
|
pp_new->pb_count = total_moved;
|
||||||
pp->pb_count -= total_moved - 1;
|
pp->pb_count -= total_moved - 1;
|
||||||
pp->pb_pointer[pb_idx + 1].pe_bnum = bnum_right;
|
pp->pb_pointer[pb_idx + 1].pe_bnum = bnum_right;
|
||||||
pp->pb_pointer[pb_idx + 1].pe_line_count = line_count_right;
|
pp->pb_pointer[pb_idx + 1].pe_line_count = line_count_right;
|
||||||
pp->pb_pointer[pb_idx + 1].pe_page_count = page_count_right;
|
pp->pb_pointer[pb_idx + 1].pe_page_count = page_count_right;
|
||||||
if (lnum_right)
|
if (lnum_right)
|
||||||
pp->pb_pointer[pb_idx + 1].pe_old_lnum = lnum_right;
|
pp->pb_pointer[pb_idx + 1].pe_old_lnum = lnum_right;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pp_new->pb_count = 1;
|
|
||||||
pp_new->pb_pointer[0].pe_bnum = bnum_right;
|
|
||||||
pp_new->pb_pointer[0].pe_line_count = line_count_right;
|
|
||||||
pp_new->pb_pointer[0].pe_page_count = page_count_right;
|
|
||||||
pp_new->pb_pointer[0].pe_old_lnum = lnum_right;
|
|
||||||
}
|
|
||||||
pp->pb_pointer[pb_idx].pe_bnum = bnum_left;
|
|
||||||
pp->pb_pointer[pb_idx].pe_line_count = line_count_left;
|
|
||||||
pp->pb_pointer[pb_idx].pe_page_count = page_count_left;
|
|
||||||
if (lnum_left)
|
|
||||||
pp->pb_pointer[pb_idx].pe_old_lnum = lnum_left;
|
|
||||||
lnum_left = 0;
|
|
||||||
lnum_right = 0;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* recompute line counts
|
|
||||||
*/
|
|
||||||
line_count_right = 0;
|
|
||||||
for (i = 0; i < (int)pp_new->pb_count; ++i)
|
|
||||||
line_count_right += pp_new->pb_pointer[i].pe_line_count;
|
|
||||||
line_count_left = 0;
|
|
||||||
for (i = 0; i < (int)pp->pb_count; ++i)
|
|
||||||
line_count_left += pp->pb_pointer[i].pe_line_count;
|
|
||||||
|
|
||||||
bnum_left = hp->bh_bnum;
|
|
||||||
bnum_right = hp_new->bh_bnum;
|
|
||||||
page_count_left = 1;
|
|
||||||
page_count_right = 1;
|
|
||||||
mf_put(mfp, hp, TRUE, FALSE);
|
|
||||||
mf_put(mfp, hp_new, TRUE, FALSE);
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pp_new->pb_count = 1;
|
||||||
|
pp_new->pb_pointer[0].pe_bnum = bnum_right;
|
||||||
|
pp_new->pb_pointer[0].pe_line_count = line_count_right;
|
||||||
|
pp_new->pb_pointer[0].pe_page_count = page_count_right;
|
||||||
|
pp_new->pb_pointer[0].pe_old_lnum = lnum_right;
|
||||||
|
}
|
||||||
|
pp->pb_pointer[pb_idx].pe_bnum = bnum_left;
|
||||||
|
pp->pb_pointer[pb_idx].pe_line_count = line_count_left;
|
||||||
|
pp->pb_pointer[pb_idx].pe_page_count = page_count_left;
|
||||||
|
if (lnum_left)
|
||||||
|
pp->pb_pointer[pb_idx].pe_old_lnum = lnum_left;
|
||||||
|
lnum_left = 0;
|
||||||
|
lnum_right = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* recompute line counts
|
||||||
|
*/
|
||||||
|
line_count_right = 0;
|
||||||
|
for (i = 0; i < (int)pp_new->pb_count; ++i)
|
||||||
|
line_count_right += pp_new->pb_pointer[i].pe_line_count;
|
||||||
|
line_count_left = 0;
|
||||||
|
for (i = 0; i < (int)pp->pb_count; ++i)
|
||||||
|
line_count_left += pp->pb_pointer[i].pe_line_count;
|
||||||
|
|
||||||
|
bnum_left = hp->bh_bnum;
|
||||||
|
bnum_right = hp_new->bh_bnum;
|
||||||
|
page_count_left = 1;
|
||||||
|
page_count_right = 1;
|
||||||
|
mf_put(mfp, hp, TRUE, FALSE);
|
||||||
|
mf_put(mfp, hp_new, TRUE, FALSE);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
48
src/option.c
48
src/option.c
@@ -4384,38 +4384,36 @@ set_option_value(
|
|||||||
#endif
|
#endif
|
||||||
if (flags & P_STRING)
|
if (flags & P_STRING)
|
||||||
return set_string_option(opt_idx, string, opt_flags);
|
return set_string_option(opt_idx, string, opt_flags);
|
||||||
else
|
|
||||||
|
varp = get_varp_scope(&(options[opt_idx]), opt_flags);
|
||||||
|
if (varp != NULL) // hidden option is not changed
|
||||||
{
|
{
|
||||||
varp = get_varp_scope(&(options[opt_idx]), opt_flags);
|
if (number == 0 && string != NULL)
|
||||||
if (varp != NULL) // hidden option is not changed
|
|
||||||
{
|
{
|
||||||
if (number == 0 && string != NULL)
|
int idx;
|
||||||
|
|
||||||
|
// Either we are given a string or we are setting option
|
||||||
|
// to zero.
|
||||||
|
for (idx = 0; string[idx] == '0'; ++idx)
|
||||||
|
;
|
||||||
|
if (string[idx] != NUL || idx == 0)
|
||||||
{
|
{
|
||||||
int idx;
|
// There's another character after zeros or the string
|
||||||
|
// is empty. In both cases, we are trying to set a
|
||||||
|
// num option using a string.
|
||||||
|
semsg(_(e_number_required_after_str_equal_str),
|
||||||
|
name, string);
|
||||||
|
return NULL; // do nothing as we hit an error
|
||||||
|
|
||||||
// Either we are given a string or we are setting option
|
|
||||||
// to zero.
|
|
||||||
for (idx = 0; string[idx] == '0'; ++idx)
|
|
||||||
;
|
|
||||||
if (string[idx] != NUL || idx == 0)
|
|
||||||
{
|
|
||||||
// There's another character after zeros or the string
|
|
||||||
// is empty. In both cases, we are trying to set a
|
|
||||||
// num option using a string.
|
|
||||||
semsg(_(e_number_required_after_str_equal_str),
|
|
||||||
name, string);
|
|
||||||
return NULL; // do nothing as we hit an error
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (flags & P_NUM)
|
|
||||||
return set_num_option(opt_idx, varp, number,
|
|
||||||
NULL, 0, opt_flags);
|
|
||||||
else
|
|
||||||
return set_bool_option(opt_idx, varp, (int)number,
|
|
||||||
opt_flags);
|
|
||||||
}
|
}
|
||||||
|
if (flags & P_NUM)
|
||||||
|
return set_num_option(opt_idx, varp, number,
|
||||||
|
NULL, 0, opt_flags);
|
||||||
|
else
|
||||||
|
return set_bool_option(opt_idx, varp, (int)number, opt_flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
86
src/syntax.c
86
src/syntax.c
@@ -2504,55 +2504,53 @@ check_state_ends(void)
|
|||||||
next_match_col = MAXCOL;
|
next_match_col = MAXCOL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
// handle next_list, unless at end of line and no "skipnl" or
|
||||||
|
// "skipempty"
|
||||||
|
current_next_list = cur_si->si_next_list;
|
||||||
|
current_next_flags = cur_si->si_flags;
|
||||||
|
if (!(current_next_flags & (HL_SKIPNL | HL_SKIPEMPTY))
|
||||||
|
&& syn_getcurline()[current_col] == NUL)
|
||||||
|
current_next_list = NULL;
|
||||||
|
|
||||||
|
// When the ended item has "extend", another item with
|
||||||
|
// "keepend" now needs to check for its end.
|
||||||
|
had_extend = (cur_si->si_flags & HL_EXTEND);
|
||||||
|
|
||||||
|
pop_current_state();
|
||||||
|
|
||||||
|
if (current_state.ga_len == 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (had_extend && keepend_level >= 0)
|
||||||
{
|
{
|
||||||
// handle next_list, unless at end of line and no "skipnl" or
|
syn_update_ends(FALSE);
|
||||||
// "skipempty"
|
|
||||||
current_next_list = cur_si->si_next_list;
|
|
||||||
current_next_flags = cur_si->si_flags;
|
|
||||||
if (!(current_next_flags & (HL_SKIPNL | HL_SKIPEMPTY))
|
|
||||||
&& syn_getcurline()[current_col] == NUL)
|
|
||||||
current_next_list = NULL;
|
|
||||||
|
|
||||||
// When the ended item has "extend", another item with
|
|
||||||
// "keepend" now needs to check for its end.
|
|
||||||
had_extend = (cur_si->si_flags & HL_EXTEND);
|
|
||||||
|
|
||||||
pop_current_state();
|
|
||||||
|
|
||||||
if (current_state.ga_len == 0)
|
if (current_state.ga_len == 0)
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (had_extend && keepend_level >= 0)
|
cur_si = &CUR_STATE(current_state.ga_len - 1);
|
||||||
{
|
|
||||||
syn_update_ends(FALSE);
|
|
||||||
if (current_state.ga_len == 0)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
cur_si = &CUR_STATE(current_state.ga_len - 1);
|
/*
|
||||||
|
* Only for a region the search for the end continues after
|
||||||
/*
|
* the end of the contained item. If the contained match
|
||||||
* Only for a region the search for the end continues after
|
* included the end-of-line, break here, the region continues.
|
||||||
* the end of the contained item. If the contained match
|
* Don't do this when:
|
||||||
* included the end-of-line, break here, the region continues.
|
* - "keepend" is used for the contained item
|
||||||
* Don't do this when:
|
* - not at the end of the line (could be end="x$"me=e-1).
|
||||||
* - "keepend" is used for the contained item
|
* - "excludenl" is used (HL_HAS_EOL won't be set)
|
||||||
* - not at the end of the line (could be end="x$"me=e-1).
|
*/
|
||||||
* - "excludenl" is used (HL_HAS_EOL won't be set)
|
if (cur_si->si_idx >= 0
|
||||||
*/
|
&& SYN_ITEMS(syn_block)[cur_si->si_idx].sp_type
|
||||||
if (cur_si->si_idx >= 0
|
== SPTYPE_START
|
||||||
&& SYN_ITEMS(syn_block)[cur_si->si_idx].sp_type
|
&& !(cur_si->si_flags & (HL_MATCH | HL_KEEPEND)))
|
||||||
== SPTYPE_START
|
{
|
||||||
&& !(cur_si->si_flags & (HL_MATCH | HL_KEEPEND)))
|
update_si_end(cur_si, (int)current_col, TRUE);
|
||||||
{
|
check_keepend();
|
||||||
update_si_end(cur_si, (int)current_col, TRUE);
|
if ((current_next_flags & HL_HAS_EOL)
|
||||||
check_keepend();
|
&& keepend_level < 0
|
||||||
if ((current_next_flags & HL_HAS_EOL)
|
&& syn_getcurline()[current_col] == NUL)
|
||||||
&& keepend_level < 0
|
break;
|
||||||
&& syn_getcurline()[current_col] == NUL)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@@ -746,6 +746,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
4704,
|
||||||
/**/
|
/**/
|
||||||
4703,
|
4703,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user