]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.0124: code has more indent than needed v9.0.0124
authorzeertzjq <zeertzjq@outlook.com>
Sun, 31 Jul 2022 17:34:32 +0000 (18:34 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 31 Jul 2022 17:34:32 +0000 (18:34 +0100)
Problem:    Code has more indent than needed.
Solution:   Use continue and return statements. (closes #10824)

src/arglist.c
src/diff.c
src/edit.c
src/help.c
src/normal.c
src/syntax.c
src/version.c
src/window.c

index 5c2236927e0760f2e182651e83e9621a73189241..9e8925a25e52e20fc7db8bfa8595262006f12813 100644 (file)
@@ -1241,32 +1241,31 @@ arg_all(void)
        for (idx = 0; idx < ARGCOUNT; ++idx)
        {
            p = alist_name(&ARGLIST[idx]);
-           if (p != NULL)
+           if (p == NULL)
+               continue;
+           if (len > 0)
            {
-               if (len > 0)
-               {
-                   // insert a space in between names
-                   if (retval != NULL)
-                       retval[len] = ' ';
-                   ++len;
-               }
-               for ( ; *p != NUL; ++p)
-               {
-                   if (*p == ' '
+               // insert a space in between names
+               if (retval != NULL)
+                   retval[len] = ' ';
+               ++len;
+           }
+           for ( ; *p != NUL; ++p)
+           {
+               if (*p == ' '
 #ifndef BACKSLASH_IN_FILENAME
-                           || *p == '\\'
+                       || *p == '\\'
 #endif
-                           || *p == '`')
-                   {
-                       // insert a backslash
-                       if (retval != NULL)
-                           retval[len] = '\\';
-                       ++len;
-                   }
+                       || *p == '`')
+               {
+                   // insert a backslash
                    if (retval != NULL)
-                       retval[len] = *p;
+                       retval[len] = '\\';
                    ++len;
                }
+               if (retval != NULL)
+                   retval[len] = *p;
+               ++len;
            }
        }
 
index fb43eee844cd89a5aa7f01280c9e82396a570027..43feb2a8b3f47455af73d970265dbf16619e8430 100644 (file)
@@ -678,34 +678,36 @@ diff_redraw(
 
     need_diff_redraw = FALSE;
     FOR_ALL_WINDOWS(wp)
+    {
        // when closing windows or wiping buffers skip invalid window
-       if (wp->w_p_diff && buf_valid(wp->w_buffer))
-       {
-           redraw_win_later(wp, SOME_VALID);
-           if (wp != curwin)
-               wp_other = wp;
+       if (!wp->w_p_diff || !buf_valid(wp->w_buffer))
+           continue;
+
+       redraw_win_later(wp, SOME_VALID);
+       if (wp != curwin)
+           wp_other = wp;
 #ifdef FEAT_FOLDING
-           if (dofold && foldmethodIsDiff(wp))
-               foldUpdateAll(wp);
+       if (dofold && foldmethodIsDiff(wp))
+           foldUpdateAll(wp);
 #endif
-           // A change may have made filler lines invalid, need to take care
-           // of that for other windows.
-           n = diff_check(wp, wp->w_topline);
-           if ((wp != curwin && wp->w_topfill > 0) || n > 0)
+       // A change may have made filler lines invalid, need to take care of
+       // that for other windows.
+       n = diff_check(wp, wp->w_topline);
+       if ((wp != curwin && wp->w_topfill > 0) || n > 0)
+       {
+           if (wp->w_topfill > n)
+               wp->w_topfill = (n < 0 ? 0 : n);
+           else if (n > 0 && n > wp->w_topfill)
            {
-               if (wp->w_topfill > n)
-                   wp->w_topfill = (n < 0 ? 0 : n);
-               else if (n > 0 && n > wp->w_topfill)
-               {
-                   wp->w_topfill = n;
-                   if (wp == curwin)
-                       used_max_fill_curwin = TRUE;
-                   else if (wp_other != NULL)
-                       used_max_fill_other = TRUE;
-               }
-               check_topfill(wp, FALSE);
+               wp->w_topfill = n;
+               if (wp == curwin)
+                   used_max_fill_curwin = TRUE;
+               else if (wp_other != NULL)
+                   used_max_fill_other = TRUE;
            }
+           check_topfill(wp, FALSE);
        }
+    }
 
     if (wp_other != NULL && curwin->w_p_scb)
     {
index 54c53ffc0082e9614f9a0b2f575baca2ba2d509d..0e715c2d1b0fa5eeb27b625079e6eb14ab80d5ca 100644 (file)
@@ -3749,51 +3749,52 @@ ins_ctrl_(void)
     static int
 ins_start_select(int c)
 {
-    if (km_startsel)
-       switch (c)
-       {
-           case K_KHOME:
-           case K_KEND:
-           case K_PAGEUP:
-           case K_KPAGEUP:
-           case K_PAGEDOWN:
-           case K_KPAGEDOWN:
+    if (!km_startsel)
+       return FALSE;
+    switch (c)
+    {
+       case K_KHOME:
+       case K_KEND:
+       case K_PAGEUP:
+       case K_KPAGEUP:
+       case K_PAGEDOWN:
+       case K_KPAGEDOWN:
 # ifdef MACOS_X
-           case K_LEFT:
-           case K_RIGHT:
-           case K_UP:
-           case K_DOWN:
-           case K_END:
-           case K_HOME:
+       case K_LEFT:
+       case K_RIGHT:
+       case K_UP:
+       case K_DOWN:
+       case K_END:
+       case K_HOME:
 # endif
-               if (!(mod_mask & MOD_MASK_SHIFT))
-                   break;
-               // FALLTHROUGH
-           case K_S_LEFT:
-           case K_S_RIGHT:
-           case K_S_UP:
-           case K_S_DOWN:
-           case K_S_END:
-           case K_S_HOME:
-               // Start selection right away, the cursor can move with
-               // CTRL-O when beyond the end of the line.
-               start_selection();
-
-               // Execute the key in (insert) Select mode.
-               stuffcharReadbuff(Ctrl_O);
-               if (mod_mask)
-               {
-                   char_u          buf[4];
+           if (!(mod_mask & MOD_MASK_SHIFT))
+               break;
+           // FALLTHROUGH
+       case K_S_LEFT:
+       case K_S_RIGHT:
+       case K_S_UP:
+       case K_S_DOWN:
+       case K_S_END:
+       case K_S_HOME:
+           // Start selection right away, the cursor can move with CTRL-O when
+           // beyond the end of the line.
+           start_selection();
 
-                   buf[0] = K_SPECIAL;
-                   buf[1] = KS_MODIFIER;
-                   buf[2] = mod_mask;
-                   buf[3] = NUL;
-                   stuffReadbuff(buf);
-               }
-               stuffcharReadbuff(c);
-               return TRUE;
-       }
+           // Execute the key in (insert) Select mode.
+           stuffcharReadbuff(Ctrl_O);
+           if (mod_mask)
+           {
+               char_u      buf[4];
+
+               buf[0] = K_SPECIAL;
+               buf[1] = KS_MODIFIER;
+               buf[2] = mod_mask;
+               buf[3] = NUL;
+               stuffReadbuff(buf);
+           }
+           stuffcharReadbuff(c);
+           return TRUE;
+    }
     return FALSE;
 }
 
index 0f43c0063c4b1ac239c1098c404e17fea4f4a732..9dbd2561f564260cb158c26c957bcbf794700afa 100644 (file)
@@ -1220,38 +1220,38 @@ do_helptags(char_u *dirname, int add_help_tags, int ignore_writeerr)
     for (i = 0; i < filecount; ++i)
     {
        len = (int)STRLEN(files[i]);
-       if (len > 4)
+       if (len <= 4)
+           continue;
+
+       if (STRICMP(files[i] + len - 4, ".txt") == 0)
        {
-           if (STRICMP(files[i] + len - 4, ".txt") == 0)
-           {
-               // ".txt" -> language "en"
-               lang[0] = 'e';
-               lang[1] = 'n';
-           }
-           else if (files[i][len - 4] == '.'
-                   && ASCII_ISALPHA(files[i][len - 3])
-                   && ASCII_ISALPHA(files[i][len - 2])
-                   && TOLOWER_ASC(files[i][len - 1]) == 'x')
-           {
-               // ".abx" -> language "ab"
-               lang[0] = TOLOWER_ASC(files[i][len - 3]);
-               lang[1] = TOLOWER_ASC(files[i][len - 2]);
-           }
-           else
-               continue;
+           // ".txt" -> language "en"
+           lang[0] = 'e';
+           lang[1] = 'n';
+       }
+       else if (files[i][len - 4] == '.'
+               && ASCII_ISALPHA(files[i][len - 3])
+               && ASCII_ISALPHA(files[i][len - 2])
+               && TOLOWER_ASC(files[i][len - 1]) == 'x')
+       {
+           // ".abx" -> language "ab"
+           lang[0] = TOLOWER_ASC(files[i][len - 3]);
+           lang[1] = TOLOWER_ASC(files[i][len - 2]);
+       }
+       else
+           continue;
 
-           // Did we find this language already?
-           for (j = 0; j < ga.ga_len; j += 2)
-               if (STRNCMP(lang, ((char_u *)ga.ga_data) + j, 2) == 0)
-                   break;
-           if (j == ga.ga_len)
-           {
-               // New language, add it.
-               if (ga_grow(&ga, 2) == FAIL)
-                   break;
-               ((char_u *)ga.ga_data)[ga.ga_len++] = lang[0];
-               ((char_u *)ga.ga_data)[ga.ga_len++] = lang[1];
-           }
+       // Did we find this language already?
+       for (j = 0; j < ga.ga_len; j += 2)
+           if (STRNCMP(lang, ((char_u *)ga.ga_data) + j, 2) == 0)
+               break;
+       if (j == ga.ga_len)
+       {
+           // New language, add it.
+           if (ga_grow(&ga, 2) == FAIL)
+               break;
+           ((char_u *)ga.ga_data)[ga.ga_len++] = lang[0];
+           ((char_u *)ga.ga_data)[ga.ga_len++] = lang[1];
        }
     }
 
index 4033d7d9b828a869954932a33e60edd0a6a3f999..63423d070b7e46744c31f305b0084410f206aa09 100644 (file)
@@ -1916,45 +1916,45 @@ check_scrollbind(linenr_T topline_diff, long leftcol_diff)
     FOR_ALL_WINDOWS(curwin)
     {
        curbuf = curwin->w_buffer;
-       // skip original window  and windows with 'noscrollbind'
-       if (curwin != old_curwin && curwin->w_p_scb)
+       // skip original window and windows with 'noscrollbind'
+       if (curwin == old_curwin || !curwin->w_p_scb)
+           continue;
+
+       // do the vertical scroll
+       if (want_ver)
        {
-           // do the vertical scroll
-           if (want_ver)
-           {
 #ifdef FEAT_DIFF
-               if (old_curwin->w_p_diff && curwin->w_p_diff)
-               {
-                   diff_set_topline(old_curwin, curwin);
-               }
-               else
-#endif
-               {
-                   curwin->w_scbind_pos += topline_diff;
-                   topline = curwin->w_scbind_pos;
-                   if (topline > curbuf->b_ml.ml_line_count)
-                       topline = curbuf->b_ml.ml_line_count;
-                   if (topline < 1)
-                       topline = 1;
-
-                   y = topline - curwin->w_topline;
-                   if (y > 0)
-                       scrollup(y, FALSE);
-                   else
-                       scrolldown(-y, FALSE);
-               }
-
-               redraw_later(VALID);
-               cursor_correct();
-               curwin->w_redr_status = TRUE;
+           if (old_curwin->w_p_diff && curwin->w_p_diff)
+           {
+               diff_set_topline(old_curwin, curwin);
            }
-
-           // do the horizontal scroll
-           if (want_hor && curwin->w_leftcol != tgt_leftcol)
+           else
+#endif
            {
-               curwin->w_leftcol = tgt_leftcol;
-               leftcol_changed();
+               curwin->w_scbind_pos += topline_diff;
+               topline = curwin->w_scbind_pos;
+               if (topline > curbuf->b_ml.ml_line_count)
+                   topline = curbuf->b_ml.ml_line_count;
+               if (topline < 1)
+                   topline = 1;
+
+               y = topline - curwin->w_topline;
+               if (y > 0)
+                   scrollup(y, FALSE);
+               else
+                   scrolldown(-y, FALSE);
            }
+
+           redraw_later(VALID);
+           cursor_correct();
+           curwin->w_redr_status = TRUE;
+       }
+
+       // do the horizontal scroll
+       if (want_hor && curwin->w_leftcol != tgt_leftcol)
+       {
+           curwin->w_leftcol = tgt_leftcol;
+           leftcol_changed();
        }
     }
 
index c2e83e6904e724d74de626e38ea8205f9e18e8e8..14cb29db2a4638603aac61b532a5a250fea415f4 100644 (file)
@@ -1485,58 +1485,50 @@ syn_stack_equal(synstate_T *sp)
     reg_extmatch_T     *six, *bsx;
 
     // First a quick check if the stacks have the same size end nextlist.
-    if (sp->sst_stacksize == current_state.ga_len
-           && sp->sst_next_list == current_next_list)
-    {
-       // Need to compare all states on both stacks.
-       if (sp->sst_stacksize > SST_FIX_STATES)
-           bp = SYN_STATE_P(&(sp->sst_union.sst_ga));
-       else
-           bp = sp->sst_union.sst_stack;
+    if (sp->sst_stacksize != current_state.ga_len
+           || sp->sst_next_list != current_next_list)
+       return FALSE;
 
-       for (i = current_state.ga_len; --i >= 0; )
+    // Need to compare all states on both stacks.
+    if (sp->sst_stacksize > SST_FIX_STATES)
+       bp = SYN_STATE_P(&(sp->sst_union.sst_ga));
+    else
+       bp = sp->sst_union.sst_stack;
+
+    for (i = current_state.ga_len; --i >= 0; )
+    {
+       // If the item has another index the state is different.
+       if (bp[i].bs_idx != CUR_STATE(i).si_idx)
+           break;
+       if (bp[i].bs_extmatch == CUR_STATE(i).si_extmatch)
+           continue;
+       // When the extmatch pointers are different, the strings in them can
+       // still be the same.  Check if the extmatch references are equal.
+       bsx = bp[i].bs_extmatch;
+       six = CUR_STATE(i).si_extmatch;
+       // If one of the extmatch pointers is NULL the states are different.
+       if (bsx == NULL || six == NULL)
+           break;
+       for (j = 0; j < NSUBEXP; ++j)
        {
-           // If the item has another index the state is different.
-           if (bp[i].bs_idx != CUR_STATE(i).si_idx)
-               break;
-           if (bp[i].bs_extmatch != CUR_STATE(i).si_extmatch)
+           // Check each referenced match string. They must all be equal.
+           if (bsx->matches[j] != six->matches[j])
            {
-               // When the extmatch pointers are different, the strings in
-               // them can still be the same.  Check if the extmatch
-               // references are equal.
-               bsx = bp[i].bs_extmatch;
-               six = CUR_STATE(i).si_extmatch;
-               // If one of the extmatch pointers is NULL the states are
-               // different.
-               if (bsx == NULL || six == NULL)
+               // If the pointer is different it can still be the same text.
+               // Compare the strings, ignore case when the start item has the
+               // sp_ic flag set.
+               if (bsx->matches[j] == NULL || six->matches[j] == NULL)
                    break;
-               for (j = 0; j < NSUBEXP; ++j)
-               {
-                   // Check each referenced match string. They must all be
-                   // equal.
-                   if (bsx->matches[j] != six->matches[j])
-                   {
-                       // If the pointer is different it can still be the
-                       // same text.  Compare the strings, ignore case when
-                       // the start item has the sp_ic flag set.
-                       if (bsx->matches[j] == NULL
-                               || six->matches[j] == NULL)
-                           break;
-                       if ((SYN_ITEMS(syn_block)[CUR_STATE(i).si_idx]).sp_ic
-                               ? MB_STRICMP(bsx->matches[j],
-                                                        six->matches[j]) != 0
-                               : STRCMP(bsx->matches[j], six->matches[j]) != 0)
-                           break;
-                   }
-               }
-               if (j != NSUBEXP)
+               if ((SYN_ITEMS(syn_block)[CUR_STATE(i).si_idx]).sp_ic
+                       ? MB_STRICMP(bsx->matches[j], six->matches[j]) != 0
+                       : STRCMP(bsx->matches[j], six->matches[j]) != 0)
                    break;
            }
        }
-       if (i < 0)
-           return TRUE;
+       if (j != NSUBEXP)
+           break;
     }
-    return FALSE;
+    return i < 0 ? TRUE : FALSE;
 }
 
 /*
index 118a38ba3f9e5c8bc397dd7dc679cb2b5e3c0e95..212688ca09c072db2a485c0542a1fc0d04530e65 100644 (file)
@@ -735,6 +735,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    124,
 /**/
     123,
 /**/
index e418f11598cf55d0bf5a9b5d9f33abed85c8fab2..58a9ff9c683882c2210a6aedf0b451d8e0572cd0 100644 (file)
@@ -2004,32 +2004,30 @@ win_equal_rec(
                next_curwin_size = -1;
                FOR_ALL_FRAMES(fr, topfr->fr_child)
                {
-                   // If 'winfixwidth' set keep the window width if
-                   // possible.
+                   if (!frame_fixed_width(fr))
+                       continue;
+                   // If 'winfixwidth' set keep the window width if possible.
                    // Watch out for this window being the next_curwin.
-                   if (frame_fixed_width(fr))
+                   n = frame_minwidth(fr, NOWIN);
+                   new_size = fr->fr_width;
+                   if (frame_has_win(fr, next_curwin))
                    {
-                       n = frame_minwidth(fr, NOWIN);
-                       new_size = fr->fr_width;
-                       if (frame_has_win(fr, next_curwin))
-                       {
-                           room += p_wiw - p_wmw;
-                           next_curwin_size = 0;
-                           if (new_size < p_wiw)
-                               new_size = p_wiw;
-                       }
-                       else
-                           // These windows don't use up room.
-                           totwincount -= (n + (fr->fr_next == NULL
-                                             ? extra_sep : 0)) / (p_wmw + 1);
-                       room -= new_size - n;
-                       if (room < 0)
-                       {
-                           new_size += room;
-                           room = 0;
-                       }
-                       fr->fr_newwidth = new_size;
+                       room += p_wiw - p_wmw;
+                       next_curwin_size = 0;
+                       if (new_size < p_wiw)
+                           new_size = p_wiw;
                    }
+                   else
+                       // These windows don't use up room.
+                       totwincount -= (n + (fr->fr_next == NULL
+                                              ? extra_sep : 0)) / (p_wmw + 1);
+                   room -= new_size - n;
+                   if (room < 0)
+                   {
+                       new_size += room;
+                       room = 0;
+                   }
+                   fr->fr_newwidth = new_size;
                }
                if (next_curwin_size == -1)
                {
@@ -2145,32 +2143,31 @@ win_equal_rec(
                next_curwin_size = -1;
                FOR_ALL_FRAMES(fr, topfr->fr_child)
                {
+                   if (!frame_fixed_height(fr))
+                       continue;
                    // If 'winfixheight' set keep the window height if
                    // possible.
                    // Watch out for this window being the next_curwin.
-                   if (frame_fixed_height(fr))
+                   n = frame_minheight(fr, NOWIN);
+                   new_size = fr->fr_height;
+                   if (frame_has_win(fr, next_curwin))
                    {
-                       n = frame_minheight(fr, NOWIN);
-                       new_size = fr->fr_height;
-                       if (frame_has_win(fr, next_curwin))
-                       {
-                           room += p_wh - p_wmh;
-                           next_curwin_size = 0;
-                           if (new_size < p_wh)
-                               new_size = p_wh;
-                       }
-                       else
-                           // These windows don't use up room.
-                           totwincount -= (n + (fr->fr_next == NULL
-                                             ? extra_sep : 0)) / (p_wmh + 1);
-                       room -= new_size - n;
-                       if (room < 0)
-                       {
-                           new_size += room;
-                           room = 0;
-                       }
-                       fr->fr_newheight = new_size;
+                       room += p_wh - p_wmh;
+                       next_curwin_size = 0;
+                       if (new_size < p_wh)
+                           new_size = p_wh;
+                   }
+                   else
+                       // These windows don't use up room.
+                       totwincount -= (n + (fr->fr_next == NULL
+                                              ? extra_sep : 0)) / (p_wmh + 1);
+                   room -= new_size - n;
+                   if (room < 0)
+                   {
+                       new_size += room;
+                       room = 0;
                    }
+                   fr->fr_newheight = new_size;
                }
                if (next_curwin_size == -1)
                {
@@ -3752,36 +3749,34 @@ close_others(
     for (wp = firstwin; win_valid(wp); wp = nextwp)
     {
        nextwp = wp->w_next;
-       if (wp != curwin)               // don't close current window
-       {
+       if (wp == curwin)               // don't close current window
+           continue;
 
-           // Check if it's allowed to abandon this window
-           r = can_abandon(wp->w_buffer, forceit);
-           if (!win_valid(wp))         // autocommands messed wp up
-           {
-               nextwp = firstwin;
-               continue;
-           }
-           if (!r)
-           {
+       // Check if it's allowed to abandon this window
+       r = can_abandon(wp->w_buffer, forceit);
+       if (!win_valid(wp))             // autocommands messed wp up
+       {
+           nextwp = firstwin;
+           continue;
+       }
+       if (!r)
+       {
 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
-               if (message && (p_confirm
-                            || (cmdmod.cmod_flags & CMOD_CONFIRM)) && p_write)
+           if (message && (p_confirm
+                        || (cmdmod.cmod_flags & CMOD_CONFIRM)) && p_write)
+           {
+               dialog_changed(wp->w_buffer, FALSE);
+               if (!win_valid(wp))             // autocommands messed wp up
                {
-                   dialog_changed(wp->w_buffer, FALSE);
-                   if (!win_valid(wp))         // autocommands messed wp up
-                   {
-                       nextwp = firstwin;
-                       continue;
-                   }
-               }
-               if (bufIsChanged(wp->w_buffer))
-#endif
+                   nextwp = firstwin;
                    continue;
+               }
            }
-           win_close(wp, !buf_hide(wp->w_buffer)
-                                              && !bufIsChanged(wp->w_buffer));
+           if (bufIsChanged(wp->w_buffer))
+#endif
+               continue;
        }
+       win_close(wp, !buf_hide(wp->w_buffer) && !bufIsChanged(wp->w_buffer));
     }
 
     if (message && !ONE_WINDOW)
@@ -5708,6 +5703,7 @@ frame_setheight(frame_T *curfrp, int height)
 
     if (curfrp->fr_parent == NULL)
     {
+       // topframe: can only change the command line
        if (height > ROWS_AVAIL)
            // If height is greater than the available space, try to create
            // space for the frame by reducing 'cmdheight' if possible, while