]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.1529: code style test doesn't check for space after "if" v9.0.1529
authorBram Moolenaar <Bram@vim.org>
Tue, 9 May 2023 14:00:00 +0000 (15:00 +0100)
committerBram Moolenaar <Bram@vim.org>
Tue, 9 May 2023 14:00:00 +0000 (15:00 +0100)
Problem:    Code style test doesn't check for space after "if".
Solution:   Add a test for space.

src/cindent.c
src/ex_cmds2.c
src/gui_w32.c
src/macros.h
src/os_amiga.c
src/os_win32.c
src/regexp_nfa.c
src/testdir/test_codestyle.vim
src/version.c

index 176bc05282c0acabcdad2a1fa1b38a144930eef9..9b2b6442a61b0092077b4c59ec69f38a21ed1407 100644 (file)
@@ -1854,8 +1854,8 @@ parse_cino(buf_T *buf)
     // Handle C++ namespace.
     buf->b_ind_cpp_namespace = 0;
 
-    // Handle continuation lines containing conditions of if(), for() and
-    // while().
+    // Handle continuation lines containing conditions of if (), for () and
+    // while ().
     buf->b_ind_if_for_while = 0;
 
     // indentation for # comments
@@ -3317,7 +3317,7 @@ get_c_indent(void)
                        }
 
                        // Special trick: when expecting the while () after a
-                       // do, line up with the while()
+                       // do, line up with the while ()
                        //     do
                        //          x = 1;
                        // ->  here
index 567b839cdb43be18895151882d85eaaec386b76a..45ccb5237696bec3530d2e1c0a064a4f589742f6 100644 (file)
@@ -508,7 +508,7 @@ ex_listdo(exarg_T *eap)
                    i++;
                break;
            case CMD_tabdo:
-               for( ; tp != NULL && i + 1 < eap->line1; tp = tp->tp_next)
+               for ( ; tp != NULL && i + 1 < eap->line1; tp = tp->tp_next)
                    i++;
                break;
            case CMD_argdo:
index 7a1203266e54fd615e37819c78887d31291d3d5e..8e36f8d5a979ac222b72d3c23094102f3d2f1e34 100644 (file)
@@ -8736,7 +8736,7 @@ test_gui_w32_sendevent_keyboard(dict_T *args)
        // If there are modifiers in the args, and it is not a keyup event and
        // vkCode is not a modifier key, then we generate virtual modifier key
        // messages before sending the actual key message.
-       if(mods && STRICMP(event, "keydown") == 0 && !isModKey)
+       if (mods && STRICMP(event, "keydown") == 0 && !isModKey)
        {
            int n = 0;
            if (mods & MOD_MASK_SHIFT)
@@ -8769,7 +8769,7 @@ test_gui_w32_sendevent_keyboard(dict_T *args)
        if (STRICMP(event, "keyup") == 0)
        {
            inputs[0].ki.dwFlags = KEYEVENTF_KEYUP;
-           if(!isModKey)
+           if (!isModKey)
                unwrapMods = TRUE;
        }
 
index a8c6e43d3c604100ded57a370928d5720a60f0cb..b41a81827e85b96e2c2229a07e491397a05b1d22 100644 (file)
 #define MB_CHARLEN(p)      (has_mbyte ? mb_charlen(p) : (int)STRLEN(p))
 #define MB_CHAR2LEN(c)     (has_mbyte ? mb_char2len(c) : 1)
 #define PTR2CHAR(p)        (has_mbyte ? mb_ptr2char(p) : (int)*(p))
-#define MB_CHAR2BYTES(c, b) do { if (has_mbyte) (b) += (*mb_char2bytes)((c), (b)); else *(b)++ = (c); } while(0)
+#define MB_CHAR2BYTES(c, b) do { if (has_mbyte) (b) += (*mb_char2bytes)((c), (b)); else *(b)++ = (c); } while (0)
 
 #ifdef FEAT_AUTOCHDIR
 # define DO_AUTOCHDIR do { if (p_acd) do_autochdir(); } while (0)
index bc4ecc9610190863fe657c7c38d3d5af1e6c7fff..d09974f949f535b07238785fa71b3e95701fe25a 100644 (file)
@@ -921,8 +921,8 @@ mch_can_exe(char_u *name, char_u **path UNUSED, int use_path)
        struct PathNode *head = DupCmdPathList(NULL);
 
        // For each entry, recur to check for executable.
-       for(struct PathNode *tail = head; !exe && tail;
-               tail = (struct PathNode *) BADDR(tail->pn_Next))
+       for (struct PathNode *tail = head; !exe && tail;
+                              tail = (struct PathNode *) BADDR(tail->pn_Next))
        {
            SetCurrentDir(tail->pn_Lock);
            exe = mch_can_exe(name, path, 0);
index c43a31afcb640e9ee09119c05c86cbb9aafc104d..869f02f65a98973d6821607088a18099dd5c22cc 100644 (file)
@@ -6863,7 +6863,7 @@ write_chars(
            vim_free(unicodebuf);
            unicodebuf = length ? LALLOC_MULT(WCHAR, length) : NULL;
            unibuflen = unibuflen ? 0 : length;
-       } while(1);
+       } while (TRUE);
        cells = mb_string2cells(pchBuf, cbToWrite);
     }
     else // cbToWrite == 1 && *pchBuf == ' ' && enc_utf8
index 406a0e449654ad3a4343dde41b0174b776e6c23d..b7bfc86c082ce8fb57715f835327a5b2131c46b5 100644 (file)
@@ -3822,7 +3822,7 @@ post2nfa(int *postfix, int *end, int nfa_calc_size)
 
        } // switch(*p)
 
-    } // for(p = postfix; *p; ++p)
+    } // for (p = postfix; *p; ++p)
 
     if (nfa_calc_size == TRUE)
     {
index ec476c038b546c8749bbeb2bc0ade6ba4e386dc2..35530634945df320e5dc47be9bb970e9c79405dc 100644 (file)
@@ -36,6 +36,10 @@ def Test_source_files()
     cursor(1, 1)
     lnum = search('else\s*{', '', 0, 0, skip)
     assert_equal(0, lnum, fname .. ': curly after "else"')
+
+    cursor(1, 1)
+    lnum = search('\<\(if\|while\|for\)(', '', 0, 0, skip)
+    assert_equal(0, lnum, fname .. ': missing white space after "if"/"while"/"for"')
   endfor
 
   bwipe!
index 5af78a53c35be938426b60a27982ed6a5c075433..1745dcd030ff73a213fb948595c6494e0806eb76 100644 (file)
@@ -695,6 +695,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1529,
 /**/
     1528,
 /**/