changeset 32395:2ed95122d59c v9.0.1529

patch 9.0.1529: code style test doesn't check for space after "if" Commit: https://github.com/vim/vim/commit/c9471b18728b1b37c04845ca2bc59fc981308b2d Author: Bram Moolenaar <Bram@vim.org> Date: Tue May 9 15:00:00 2023 +0100 patch 9.0.1529: code style test doesn't check for space after "if" Problem: Code style test doesn't check for space after "if". Solution: Add a test for space.
author Bram Moolenaar <Bram@vim.org>
date Tue, 09 May 2023 16:15:05 +0200
parents 0db2ebbe7711
children 9feee1b0b58a
files 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
diffstat 9 files changed, 17 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/cindent.c
+++ b/src/cindent.c
@@ -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
--- a/src/ex_cmds2.c
+++ b/src/ex_cmds2.c
@@ -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:
--- a/src/gui_w32.c
+++ b/src/gui_w32.c
@@ -8736,7 +8736,7 @@ test_gui_w32_sendevent_keyboard(dict_T *
 	// 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 *
 	if (STRICMP(event, "keyup") == 0)
 	{
 	    inputs[0].ki.dwFlags = KEYEVENTF_KEYUP;
-	    if(!isModKey)
+	    if (!isModKey)
 		unwrapMods = TRUE;
 	}
 
--- a/src/macros.h
+++ b/src/macros.h
@@ -240,7 +240,7 @@
 #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)
--- a/src/os_amiga.c
+++ b/src/os_amiga.c
@@ -921,8 +921,8 @@ mch_can_exe(char_u *name, char_u **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);
--- a/src/os_win32.c
+++ b/src/os_win32.c
@@ -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
--- a/src/regexp_nfa.c
+++ b/src/regexp_nfa.c
@@ -3822,7 +3822,7 @@ post2nfa(int *postfix, int *end, int nfa
 
 	} // switch(*p)
 
-    } // for(p = postfix; *p; ++p)
+    } // for (p = postfix; *p; ++p)
 
     if (nfa_calc_size == TRUE)
     {
--- a/src/testdir/test_codestyle.vim
+++ b/src/testdir/test_codestyle.vim
@@ -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!
--- a/src/version.c
+++ b/src/version.c
@@ -696,6 +696,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1529,
+/**/
     1528,
 /**/
     1527,