]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.1234: the code style has to be checked manually v9.0.1234
authorBram Moolenaar <Bram@vim.org>
Sun, 22 Jan 2023 21:14:53 +0000 (21:14 +0000)
committerBram Moolenaar <Bram@vim.org>
Sun, 22 Jan 2023 21:14:53 +0000 (21:14 +0000)
Problem:    The code style has to be checked manually.
Solution:   Add basic code style checks in a test.  Fix or avoid uncovered
            problems.

34 files changed:
src/blowfish.c
src/cindent.c
src/crypt_zip.c
src/diff.c
src/digraph.c
src/ex_cmds.c
src/ex_cmds.h
src/gui_beval.c
src/gui_motif.c
src/gui_photon.c
src/gui_x11.c
src/gui_xmebw.c
src/if_cscope.c
src/if_lua.c
src/if_python3.c
src/insexpand.c
src/macros.h
src/nbdebug.c
src/nbdebug.h
src/nv_cmds.h
src/optiondefs.h
src/os_amiga.c
src/os_mac_conv.c
src/os_vms.c
src/quickfix.c
src/regexp_bt.c
src/regexp_nfa.c
src/search.c
src/termlib.c
src/testdir/Make_all.mak
src/testdir/test_codestyle.vim [new file with mode: 0644]
src/uninstall.c
src/version.c
src/vim.h

index dc977db4283b46113f98fdfc27cbe10136403f0f..88d4bce9e81c29798bba7ea93f2371c4ed9e205e 100644 (file)
@@ -517,7 +517,8 @@ bf_self_test(void)
 
     // We can't simply use sizeof(UINT32_T), it would generate a compiler
     // warning.
-    if (ui != 0xffffffffUL || ui + 1 != 0) {
+    if (ui != 0xffffffffUL || ui + 1 != 0)
+    {
        err++;
        emsg(_(e_sizeof_uint32_isnot_four));
     }
@@ -573,13 +574,15 @@ bf_cfb_init(
     }
 }
 
-#define BF_CFB_UPDATE(bfs, c) { \
+#define BF_CFB_UPDATE(bfs, c) \
+{ \
     bfs->cfb_buffer[bfs->update_offset] ^= (char_u)c; \
     if (++bfs->update_offset == bfs->cfb_len) \
        bfs->update_offset = 0; \
 }
 
-#define BF_RANBYTE(bfs, t) { \
+#define BF_RANBYTE(bfs, t) \
+{ \
     if ((bfs->randbyte_offset & BF_BLOCK_MASK) == 0) \
        bf_e_cblock(bfs, &(bfs->cfb_buffer[bfs->randbyte_offset])); \
     t = bfs->cfb_buffer[bfs->randbyte_offset]; \
index bc71cc092f48030a37f236d956a3d1ef6244c131..e8e255feb35f76b0e46f6127a1e595afa41d8295 100644 (file)
@@ -2641,7 +2641,7 @@ get_c_indent(void)
 
            // It could have been something like
            //     case 1: if (asdf &&
-           //                  ldfd) {
+           //                  condition) {
            //              }
            if ((curbuf->b_ind_js || curbuf->b_ind_keep_case_label)
                           && cin_iscase(skipwhite(ml_get_curline()), FALSE))
@@ -3275,7 +3275,7 @@ get_c_indent(void)
                    }
 
                    // Check if we are after an "if", "while", etc.
-                   // Also allow "   } else".
+                   // Also allow "} else".
                    if (cin_is_cinword(l) || cin_iselse(skipwhite(l)))
                    {
                        // Found an unterminated line after an if (), line up
@@ -3335,7 +3335,7 @@ get_c_indent(void)
                        {
                            // If we're looking at "} else", let's make sure we
                            // find the opening brace of the enclosing scope,
-                           // not the one from "if () {".
+                           // not the one from "if (condition) {".
                            if (*l == '}')
                                curwin->w_cursor.col =
                                          (colnr_T)(l - ml_get_curline()) + 1;
@@ -3680,7 +3680,7 @@ term_again:
     // line needs to be indented as a function type spec.
     // Don't do this if the current line looks like a comment or if the
     // current line is terminated, ie. ends in ';', or if the current line
-    // contains { or }: "void f() {\n if (1)"
+    // contains { or }: "void f(condition) {\n if (1)"
     if (cur_curpos.lnum < curbuf->b_ml.ml_line_count
            && !cin_nocode(theline)
            && vim_strchr(theline, '{') == NULL
index b11d7a329fd5a0add7c09ecebd5f0177e3e17de1..91bbd7ba100ecbe96d1799e90fb7c9f6694e9a5b 100644 (file)
@@ -60,7 +60,8 @@ make_crc_tab(void)
 /*
  * Return the next byte in the pseudo-random sequence.
  */
-#define DECRYPT_BYTE_ZIP(keys, t) { \
+#define DECRYPT_BYTE_ZIP(keys, t) \
+{ \
     short_u temp = (short_u)keys[2] | 2; \
     t = (int)(((unsigned)(temp * (temp ^ 1U)) >> 8) & 0xff); \
 }
index ec8c8f175de4087ee944643669c7f00c6eba3b41..a155c5eae430cc8ee9ee08fe0e58d8556fde2068 100644 (file)
@@ -1680,9 +1680,8 @@ diff_read(
     {
        if (dio->dio_internal)
        {
-           if (line_idx >= dout->dout_ga.ga_len) {
+           if (line_idx >= dout->dout_ga.ga_len)
                break;      // did last line
-           }
            hunk = ((diffhunk_T **)dout->dout_ga.ga_data)[line_idx++];
        }
        else
index 97a72e1d55281d8b598ee436b1b72f6d393e1626..ac51d50a79cc1f60743889f1bf410d7049cda1f7 100644 (file)
@@ -2093,7 +2093,8 @@ f_digraph_get(typval_T *argvars, typval_T *rettv)
 
     if (has_mbyte)
        buf[(*mb_char2bytes)(code, buf)] = NUL;
-    else {
+    else
+    {
        buf[0] = code;
        buf[1] = NUL;
     }
index 32c72879cc4226fe7cae5df57cc187e8b6830026..7fd095268a4b55a02185cf8d5aa32ca247c88a90 100644 (file)
@@ -722,7 +722,8 @@ do_move(linenr_T line1, linenr_T line2, linenr_T dest)
     {
        mark_adjust_nofold(line2 + 1, dest, -num_lines, 0L);
 #ifdef FEAT_FOLDING
-       FOR_ALL_TAB_WINDOWS(tp, win) {
+       FOR_ALL_TAB_WINDOWS(tp, win)
+       {
            if (win->w_buffer == curbuf)
                foldMoveRange(&win->w_folds, line1, line2, dest);
        }
@@ -737,7 +738,8 @@ do_move(linenr_T line1, linenr_T line2, linenr_T dest)
     {
        mark_adjust_nofold(dest + 1, line1 - 1, num_lines, 0L);
 #ifdef FEAT_FOLDING
-       FOR_ALL_TAB_WINDOWS(tp, win) {
+       FOR_ALL_TAB_WINDOWS(tp, win)
+       {
            if (win->w_buffer == curbuf)
                foldMoveRange(&win->w_folds, dest + 1, line1 - 1, line2);
        }
index 1c71bd31a34f49752707f84c7da14ec0abf69554..8f8efe7cc8ed75386963af985c5fc667af3fcb60 100644 (file)
@@ -98,7 +98,8 @@ typedef struct exarg exarg_T;
  * Not supported commands are included to avoid ambiguities.
  */
 #ifdef DO_DECLARE_EXCMD
-# define EXCMD(a, b, c, d, e)  {(char_u *)b, c, (long_u)(d), e}
+# define EXCMD(a, b, c, d, e) \
+       {(char_u *)b, c, (long_u)(d), e}
 
 typedef void (*ex_func_T) (exarg_T *eap);
 
index daeac8f3b7409aa1106d7985fd7074445a9d351b..9d85d90e0056388d44aa9525a0f5ce7e3d491e9a 100644 (file)
@@ -645,7 +645,8 @@ pointerEvent(BalloonEval *beval, XEvent *event)
 
                XtTranslateKeycode(gui.dpy, event->xkey.keycode,
                                event->xkey.state, &modifier, &keysym);
-               if ((keysym == XK_Shift_L) || (keysym == XK_Shift_R)) {
+               if ((keysym == XK_Shift_L) || (keysym == XK_Shift_R))
+               {
                    beval->showState = ShS_UPDATE_PENDING;
                    (*beval->msgCB)(beval, 0);
                }
index 5e18f20c8e4eb421619a0cb232a41d07d93d95f0..b25b99186d25d02fb88c79f93e902ecdae64b799 100644 (file)
@@ -167,16 +167,17 @@ tabline_scroller_clicked(
     Dimension  width, height;
 
     tab_scroll_w = XtNameToWidget(tabLine, scroller_name);
-    if (tab_scroll_w != (Widget)0) {
+    if (tab_scroll_w != (Widget)0)
+    {
        XtVaGetValues(tab_scroll_w, XmNx, &pos_x, XmNy, &pos_y, XmNwidth,
                      &width, XmNheight, &height, NULL);
-       if (pos_x >= 0) {
+       if (pos_x >= 0)
+       {
            // Tab scroller (next) is visible
-           if ((event->x >= pos_x) && (event->x <= pos_x + width) &&
-               (event->y >= pos_y) && (event->y <= pos_y + height)) {
+           if (event->x >= pos_x && event->x <= pos_x + width
+                   && event->y >= pos_y && event->y <= pos_y + height)
                // Clicked on the scroller
                return TRUE;
-           }
        }
     }
     return FALSE;
index 5671890470546e855c3b92d3e015be03f5aa3b63..a17b4f5d03091bfc7e397035cd3d8637897e228b 100644 (file)
@@ -361,7 +361,8 @@ gui_ph_handle_window_cb(PtWidget_t *widget, void *data, PtCallbackInfo_t *info)
     PhWindowEvent_t *we = info->cbdata;
     ushort_t *width, *height;
 
-    switch (we->event_f) {
+    switch (we->event_f)
+    {
        case Ph_WM_CLOSE:
            gui_shell_closed();
            break;
index a239e0b547449cc17c5ef4a99474e8ec84c4fd6a..540f143e2ad5d1dae052b73fbc7064e23d88c148 100644 (file)
@@ -3095,10 +3095,13 @@ gui_mch_getmouse(int *x, int *y)
     unsigned int mask;
 
     if (gui.wid && XQueryPointer(gui.dpy, gui.wid, &root, &child,
-                                        &rootx, &rooty, &winx, &winy, &mask)) {
+                                        &rootx, &rooty, &winx, &winy, &mask))
+    {
        *x = winx;
        *y = winy;
-    } else {
+    }
+    else
+    {
        *x = -1;
        *y = -1;
     }
index 7ffa6f3fb4c8c4690559aa511b5d6bf4568b9acd..3d9519eeb077ab7ae99ea05e7c75da18046436f0 100644 (file)
@@ -281,21 +281,21 @@ static char * blank_xpm[] =
 // width height ncolors cpp [x_hot y_hot]
 "12 12 4 1 0 0",
 // colors
-"      s iconColor1    m black c #000000",
+"#     s iconColor1    m black c #000000",
 ".     s none  m none  c none",
 "X     s topShadowColor        m none  c #DCDEE5",
 "o     s bottomShadowColor     m black c #5D6069",
 // pixels
-"          ..",
-" XXXXXXXX ..",
-" X....... o.",
-" X....... o.",
-" X....... o.",
-" X....... o.",
-" X....... o.",
-" X....... o.",
-" X....... o.",
-"          o.",
+"##########..",
+"#XXXXXXXX#..",
+"#X.......#o.",
+"#X.......#o.",
+"#X.......#o.",
+"#X.......#o.",
+"#X.......#o.",
+"#X.......#o.",
+"#X.......#o.",
+"##########o.",
 "..ooooooooo.",
 "............"};
 
index ffb1784e1b7071138ee88ad259030bf49ad14c2e..309bddcab63714942348d3f8cb37846b86fdd45a 100644 (file)
@@ -1463,7 +1463,8 @@ cs_insert_filelist(
            return -1;
        }
        (void)strcpy(csinfo[i].ppath, (const char *)ppath);
-    } else
+    }
+    else
        csinfo[i].ppath = NULL;
 
     if (flags != NULL)
@@ -1475,7 +1476,8 @@ cs_insert_filelist(
            return -1;
        }
        (void)strcpy(csinfo[i].flags, (const char *)flags);
-    } else
+    }
+    else
        csinfo[i].flags = NULL;
 
 #if defined(UNIX)
index 6941789b91d38383f50a80c5290f10db0f3d0abb..45f233fdecb0b5d49dc503f804ad18f7e74b4b1a 100644 (file)
@@ -657,9 +657,11 @@ luaV_totypval(lua_State *L, int pos, typval_T *tv)
 
            lua_pushvalue(L, pos);
            lua_tableref = luaL_ref(L, LUA_REGISTRYINDEX);
-           if (lua_getmetatable(L, pos)) {
+           if (lua_getmetatable(L, pos))
+           {
                lua_getfield(L, -1, LUA___CALL);
-               if (lua_isfunction(L, -1)) {
+               if (lua_isfunction(L, -1))
+               {
                    char_u *name;
                    int lua_funcref = luaL_ref(L, LUA_REGISTRYINDEX);
                    luaV_CFuncState *state = ALLOC_CLEAR_ONE(luaV_CFuncState);
@@ -827,7 +829,8 @@ luaV_msgfunc(lua_State *L, msgfunc_T mf)
        luatyp *o = NULL; \
        if (obj == NULL) \
            lua_pushnil(L); \
-       else { \
+       else \
+       { \
            luaV_getudata(L, obj); \
            if (lua_isnil(L, -1)) /* not interned? */ \
            { \
index 270e1a9e25f9bc99726866a45de9f6c4f641a66b..240b88fac7d888ab54d8eeefc3b11a76e45ad3d9 100644 (file)
@@ -1505,7 +1505,8 @@ BufferSubscript(PyObject *self, PyObject* idx)
     {
        long _idx = PyLong_AsLong(idx);
        return BufferItem((BufferObject *)(self), _idx);
-    } else if (PySlice_Check(idx))
+    }
+    else if (PySlice_Check(idx))
     {
        Py_ssize_t start, stop, step, slicelen;
 
@@ -1539,7 +1540,8 @@ BufferAsSubscript(PyObject *self, PyObject* idx, PyObject* val)
        return RBAsItem((BufferObject *)(self), n, val, 1,
                    (Py_ssize_t)((BufferObject *)(self))->buf->b_ml.ml_line_count,
                    NULL);
-    } else if (PySlice_Check(idx))
+    }
+    else if (PySlice_Check(idx))
     {
        Py_ssize_t start, stop, step, slicelen;
 
@@ -1623,7 +1625,8 @@ RangeSubscript(PyObject *self, PyObject* idx)
     {
        long _idx = PyLong_AsLong(idx);
        return RangeItem((RangeObject *)(self), _idx);
-    } else if (PySlice_Check(idx))
+    }
+    else if (PySlice_Check(idx))
     {
        Py_ssize_t start, stop, step, slicelen;
 
index c5d0bf286b7844d4f89aafa9936fb0e22c835c18..2351ac65c91393563e6fc18914b6186f52b37bae 100644 (file)
@@ -263,27 +263,39 @@ ins_ctrl_x(void)
 /*
  * Functions to check the current CTRL-X mode.
  */
-int ctrl_x_mode_none(void) { return ctrl_x_mode == 0; }
-int ctrl_x_mode_normal(void) { return ctrl_x_mode == CTRL_X_NORMAL; }
-int ctrl_x_mode_scroll(void) { return ctrl_x_mode == CTRL_X_SCROLL; }
-int ctrl_x_mode_whole_line(void) { return ctrl_x_mode == CTRL_X_WHOLE_LINE; }
-int ctrl_x_mode_files(void) { return ctrl_x_mode == CTRL_X_FILES; }
-int ctrl_x_mode_tags(void) { return ctrl_x_mode == CTRL_X_TAGS; }
-int ctrl_x_mode_path_patterns(void) {
-                                 return ctrl_x_mode == CTRL_X_PATH_PATTERNS; }
-int ctrl_x_mode_path_defines(void) {
-                                  return ctrl_x_mode == CTRL_X_PATH_DEFINES; }
-int ctrl_x_mode_dictionary(void) { return ctrl_x_mode == CTRL_X_DICTIONARY; }
-int ctrl_x_mode_thesaurus(void) { return ctrl_x_mode == CTRL_X_THESAURUS; }
-int ctrl_x_mode_cmdline(void) {
-       return ctrl_x_mode == CTRL_X_CMDLINE
+int ctrl_x_mode_none(void)
+    { return ctrl_x_mode == 0; }
+int ctrl_x_mode_normal(void)
+    { return ctrl_x_mode == CTRL_X_NORMAL; }
+int ctrl_x_mode_scroll(void)
+    { return ctrl_x_mode == CTRL_X_SCROLL; }
+int ctrl_x_mode_whole_line(void)
+    { return ctrl_x_mode == CTRL_X_WHOLE_LINE; }
+int ctrl_x_mode_files(void)
+    { return ctrl_x_mode == CTRL_X_FILES; }
+int ctrl_x_mode_tags(void)
+    { return ctrl_x_mode == CTRL_X_TAGS; }
+int ctrl_x_mode_path_patterns(void)
+    { return ctrl_x_mode == CTRL_X_PATH_PATTERNS; }
+int ctrl_x_mode_path_defines(void)
+    { return ctrl_x_mode == CTRL_X_PATH_DEFINES; }
+int ctrl_x_mode_dictionary(void)
+    { return ctrl_x_mode == CTRL_X_DICTIONARY; }
+int ctrl_x_mode_thesaurus(void)
+    { return ctrl_x_mode == CTRL_X_THESAURUS; }
+int ctrl_x_mode_cmdline(void)
+    { return ctrl_x_mode == CTRL_X_CMDLINE
                || ctrl_x_mode == CTRL_X_CMDLINE_CTRL_X; }
-int ctrl_x_mode_function(void) { return ctrl_x_mode == CTRL_X_FUNCTION; }
-int ctrl_x_mode_omni(void) { return ctrl_x_mode == CTRL_X_OMNI; }
-int ctrl_x_mode_spell(void) { return ctrl_x_mode == CTRL_X_SPELL; }
-static int ctrl_x_mode_eval(void) { return ctrl_x_mode == CTRL_X_EVAL; }
-int ctrl_x_mode_line_or_eval(void) {
-       return ctrl_x_mode == CTRL_X_WHOLE_LINE || ctrl_x_mode == CTRL_X_EVAL; }
+int ctrl_x_mode_function(void)
+    { return ctrl_x_mode == CTRL_X_FUNCTION; }
+int ctrl_x_mode_omni(void)
+    { return ctrl_x_mode == CTRL_X_OMNI; }
+int ctrl_x_mode_spell(void)
+    { return ctrl_x_mode == CTRL_X_SPELL; }
+static int ctrl_x_mode_eval(void)
+    { return ctrl_x_mode == CTRL_X_EVAL; }
+int ctrl_x_mode_line_or_eval(void)
+    { return ctrl_x_mode == CTRL_X_WHOLE_LINE || ctrl_x_mode == CTRL_X_EVAL; }
 
 /*
  * Whether other than default completion has been selected.
index cb97d438331509b5c5271334a4e767a010e18d68..4f3ad43f2512fd0e4ccba0b22921ca7c5422fdd0 100644 (file)
 #  ifdef MSWIN
 #   ifndef isnan
 #    define isnan(x) _isnan(x)
-     static __inline int isinf(double x) { return !_finite(x) && !_isnan(x); }
+     static __inline int isinf(double x)
+       { return !_finite(x) && !_isnan(x); }
 #   endif
 #  else
 #   ifndef HAVE_ISNAN
-     static inline int isnan(double x) { return x != x; }
+     static inline int isnan(double x)
+       { return x != x; }
 #   endif
 #   ifndef HAVE_ISINF
-     static inline int isinf(double x) { return !isnan(x) && isnan(x - x); }
+     static inline int isinf(double x)
+       { return !isnan(x) && isnan(x - x); }
 #   endif
 #  endif
 #  if !defined(INFINITY)
  */
 #define VIM_CLEAR(p) \
     do { \
-       if ((p) != NULL) { \
+       if ((p) != NULL) \
+       { \
            vim_free(p); \
            (p) = NULL; \
        } \
index c79081bea74fa06c9a5ca43fa188b1ea5d5cb527..58fcad3ef85f5b2312d36930fe5cde099913e626 100644 (file)
@@ -59,13 +59,19 @@ nbdebug_wait(
 #endif
 
        // for debugging purposes only
-       if (wait_flags & WT_ENV && wait_var && getenv(wait_var) != NULL) {
+       if (wait_flags & WT_ENV && wait_var && getenv(wait_var) != NULL)
+       {
                sleep(atoi(getenv(wait_var)));
-       } else if (wait_flags & WT_WAIT && lookup("~/.gvimwait")) {
+       }
+       else if (wait_flags & WT_WAIT && lookup("~/.gvimwait"))
+       {
                sleep(wait_secs > 0 && wait_secs < 120 ? wait_secs : 20);
-       } else if (wait_flags & WT_STOP && lookup("~/.gvimstop")) {
+       }
+       else if (wait_flags & WT_STOP && lookup("~/.gvimstop"))
+       {
                int w = 1;
-               while (w) {
+               while (w)
+               {
                        ;
                }
        }
@@ -86,9 +92,12 @@ nbdebug_log_init(
                nb_debug = fopen(file, "a");
                time(&now);
                fprintf(nb_debug, "%s", get_ctime(now, TRUE));
-               if (level_var && (cp = getenv(level_var)) != NULL) {
+               if (level_var && (cp = getenv(level_var)) != NULL)
+               {
                        nb_dlevel = strtoul(cp, NULL, 0);
-               } else {
+               }
+               else
+               {
                        nb_dlevel = NB_TRACE;   // default level
                }
 #ifdef USE_NB_ERRORHANDLER
@@ -103,7 +112,8 @@ nbdbg(char *fmt, ...)
 {
        va_list          ap;
 
-       if (nb_debug != NULL && nb_dlevel & NB_TRACE) {
+       if (nb_debug != NULL && nb_dlevel & NB_TRACE)
+       {
                va_start(ap, fmt);
                vfprintf(nb_debug, fmt, ap);
                va_end(ap);
@@ -144,7 +154,8 @@ errorHandler(
            "XRequest", buf, "Unknown", msg, sizeof(msg));
        nbdbg("\tMajor opcode of failed request: %d (%s)\n",
            err->request_code, msg);
-       if (err->request_code > 128) {
+       if (err->request_code > 128)
+       {
                nbdbg("\tMinor opcode of failed request: %d\n",
                    err->minor_code);
        }
index 9a47c3a890b97e8c2d7c63d90060d4d7ffc1876a..20bbb049e288ddc0bdd7784c531ef7937ee8145b 100644 (file)
@@ -15,7 +15,8 @@
 
 # ifndef ASSERT
 #  define ASSERT(c) \
-    if (!(c)) { \
+    if (!(c)) \
+    { \
        fprintf(stderr, "Assertion failed: line %d, file %s\n", \
                __LINE__, __FILE__); \
        fflush(stderr); \
index d4b2c95c84dc9e292f3129736302887ee78ef16c..aa68b686b5bf99036595e49cac3b07c591287a94 100644 (file)
@@ -25,7 +25,8 @@
 /*
  * Used when building Vim.
  */
-# define NVCMD(a, b, c, d)  {a, b, c, d}
+# define NVCMD(a, b, c, d) \
+       {a, b, c, d}
 
 #ifdef FEAT_GUI
 #define NV_VER_SCROLLBAR       nv_ver_scrollbar
index 4d12e25c62c00000ae868c88d45e25e249d8ddba..7ec4847d0140e2f7fb01e5cfa09f374bc462d6fb 100644 (file)
@@ -2849,7 +2849,8 @@ static struct vimoption options[] =
                            {(char_u *)TRUE, (char_u *)0L} SCTX_INIT},
 
 // terminal output codes
-#define p_term(sss, vvv)   {sss, NULL, P_STRING|P_VI_DEF|P_RALL|P_SECURE, \
+#define p_term(sss, vvv) \
+                           {sss, NULL, P_STRING|P_VI_DEF|P_RALL|P_SECURE, \
                            (char_u *)&vvv, PV_NONE, \
                            {(char_u *)"", (char_u *)0L} SCTX_INIT},
 
index 16a64afbb6a285e410c13d1546c245f4288c2e4a..0e0fa77834ec689482e210c8089c2f8dbde66f13 100644 (file)
@@ -1250,7 +1250,8 @@ dos_packet(
     // Allocate space for a packet, make it public and clear it
     packet = (struct StandardPacket *)
        AllocMem((long) sizeof(struct StandardPacket), MEMF_PUBLIC | MEMF_CLEAR);
-    if (!packet) {
+    if (!packet)
+    {
        DeletePort(replyport);
        return (0);
     }
index 18e5547b489925b4d29b9234d705e15ec1070c06..3a93649b9d3fbadc42ab58429fd82ddd1bae9d0b 100644 (file)
@@ -107,7 +107,8 @@ mac_string_convert(
     //  Determine output buffer size
     CFStringGetBytes(cfstr, convertRange, to, NULL, FALSE, NULL, 0, (CFIndex *)&buflen);
     retval = (buflen > 0) ? alloc(buflen) : NULL;
-    if (retval == NULL) {
+    if (retval == NULL)
+    {
        CFRelease(cfstr);
        return NULL;
     }
@@ -543,7 +544,8 @@ mac_utf8_to_utf16(
     utf8_str = CFStringCreateWithBytes(NULL, from, fromLen,
            kCFStringEncodingUTF8, FALSE);
 
-    if (utf8_str == NULL) {
+    if (utf8_str == NULL)
+    {
        if (actualLen)
            *actualLen = 0;
        return NULL;
index afecc3593e081d643a18bda61c65e2257a57424b..23854dd3f04208a87c23e51c8dd132d968b4ddf0 100644 (file)
@@ -118,7 +118,8 @@ mch_settmode(tmode_T tmode)
 
     if ( tmode == TMODE_RAW )
        set_tty(0, 0);
-    else{
+    else
+    {
        switch (orgmode.width)
        {
            case 132:   OUT_STR_NF((char_u *)"\033[?3h\033>");  break;
@@ -379,16 +380,19 @@ vms_wproc(char *name, int val)
        return 1;
 
     // accept all DECC$K_FILE and DECC$K_DIRECTORY
-    if (vms_match_num == 0) {
+    if (vms_match_num == 0)
+    {
        // first time through, setup some things
-       if (NULL == vms_fmatch) {
+       if (NULL == vms_fmatch)
+       {
            vms_fmatch = ALLOC_MULT(char_u *, EXPL_ALLOC_INC);
            if (!vms_fmatch)
                return 0;
            vms_match_alloced = EXPL_ALLOC_INC;
            vms_match_free = EXPL_ALLOC_INC;
        }
-       else {
+       else
+       {
            // re-use existing space
            vms_match_free = vms_match_alloced;
        }
@@ -399,11 +403,13 @@ vms_wproc(char *name, int val)
     name=vms_tolower(name);
 
     // if name already exists, don't add it
-    for (i = 0; i<vms_match_num; i++) {
+    for (i = 0; i<vms_match_num; i++)
+    {
        if (0 == STRCMP((char_u *)name,vms_fmatch[i]))
            return 1;
     }
-    if (--vms_match_free == 0) {
+    if (--vms_match_free == 0)
+    {
        char_u **old_vms_fmatch = vms_fmatch;
 
        // add more space to store matches
@@ -464,9 +470,12 @@ mch_expand_wildcards(int num_pat, char_u **pat, int *num_file, char_u ***file, i
 
        vms_match_num = 0; // reset collection counter
        result = decc$translate_vms(vms_fixfilename(buf));
-       if ( (int) result == 0 || (int) result == -1  ) {
+       if ( (int) result == 0 || (int) result == -1  )
+       {
            cnt = 0;
-       } else {
+       }
+       else
+       {
            cnt = decc$to_vms(result, vms_wproc, 1 /*allow wild*/ , (flags & EW_DIR ? 0:1 ) /*allow directory*/) ;
        }
        if (cnt > 0)
@@ -524,9 +533,12 @@ mch_expandpath(garray_T *gap, char_u *path, int flags)
     // the result from the decc$translate_vms needs to be handled
     // otherwise it might create ACCVIO error in decc$to_vms
     result = decc$translate_vms(vms_fixfilename(path));
-    if ( (int) result == 0 || (int) result == -1  ) {
+    if ( (int) result == 0 || (int) result == -1  )
+    {
        cnt = 0;
-    } else {
+    }
+    else
+    {
        cnt = decc$to_vms(result, vms_wproc, 1 /*allow_wild*/, (flags & EW_DIR ? 0:1 ) /*allow directory*/);
     }
     if (cnt > 0)
@@ -554,7 +566,8 @@ vms_unix_mixed_filespec(char *in, char *out)
     // copy vms filename portion up to last colon
     // (node and/or disk)
     lastcolon = strrchr(in, ':');   // find last colon
-    if (lastcolon != NULL) {
+    if (lastcolon != NULL)
+    {
        len = lastcolon - in + 1;
        strncpy(out, in, len);
        out += len;
@@ -565,25 +578,34 @@ vms_unix_mixed_filespec(char *in, char *out)
 
     // start of directory portion
     ch = *in;
-    if ((ch == '[') || (ch == '/') || (ch == '<')) {   // start of directory(s) ?
+    if ((ch == '[') || (ch == '/') || (ch == '<')) // start of directory(s) ?
+    {
        ch = '[';
        SKIP_FOLLOWING_SLASHES(in);
-    } else if (EQN(in, "../", 3)) { // Unix parent directory?
+    }
+    else if (EQN(in, "../", 3)) // Unix parent directory?
+    {
        *out++ = '[';
        *out++ = '-';
        end_of_dir = out;
        ch = '.';
        in += 2;
        SKIP_FOLLOWING_SLASHES(in);
-    } else {               // not a special character
-       while (EQN(in, "./", 2)) {      // Ignore Unix "current dir"
+    }
+    else
+    {              // not a special character
+       while (EQN(in, "./", 2))        // Ignore Unix "current dir"
+       {
            in += 2;
            SKIP_FOLLOWING_SLASHES(in);
     }
-    if (strchr(in, '/') == NULL) {  // any more Unix directories ?
+    if (strchr(in, '/') == NULL)  // any more Unix directories ?
+    {
        strcpy(out, in);        // No - get rest of the spec
        return;
-    } else {
+    }
+    else
+    {
        *out++ = '[';       // Yes, denote a Vms subdirectory
        ch = '.';
        --in;
@@ -596,26 +618,31 @@ vms_unix_mixed_filespec(char *in, char *out)
     *out++ = ch;
     ++in;
 
-    while (*in != '\0') {
+    while (*in != '\0')
+    {
        ch = *in;
-       if ((ch == ']') || (ch == '/') || (ch == '>') ) {       // end of (sub)directory ?
+       if ((ch == ']') || (ch == '/') || (ch == '>') ) // end of (sub)directory ?
+       {
            end_of_dir = out;
            ch = '.';
            SKIP_FOLLOWING_SLASHES(in);
            }
-       else if (EQN(in, "../", 3)) {   // Unix parent directory?
+       else if (EQN(in, "../", 3))     // Unix parent directory?
+       {
            *out++ = '-';
            end_of_dir = out;
            ch = '.';
            in += 2;
            SKIP_FOLLOWING_SLASHES(in);
            }
-       else {
-           while (EQN(in, "./", 2)) {  // Ignore Unix "current dir"
-           end_of_dir = out;
-           in += 2;
-           SKIP_FOLLOWING_SLASHES(in);
-           ch = *in;
+       else
+       {
+           while (EQN(in, "./", 2))  // Ignore Unix "current dir"
+           {
+               end_of_dir = out;
+               in += 2;
+               SKIP_FOLLOWING_SLASHES(in);
+               ch = *in;
            }
        }
 
@@ -709,9 +736,12 @@ vms_remove_version(void * fname)
        *cp = '\0';
     else if ((cp = vim_strrchr( fname, '.')) != NULL )
     {
-       if      ((fp = vim_strrchr( fname, ']')) != NULL ) {;}
-       else if ((fp = vim_strrchr( fname, '>')) != NULL ) {;}
-       else fp = fname;
+       if      ((fp = vim_strrchr( fname, ']')) != NULL )
+           {;}
+       else if ((fp = vim_strrchr( fname, '>')) != NULL )
+           {;}
+       else
+           fp = fname;
 
        while ( *fp != '\0' && fp < cp )
            if ( *fp++ == '.' )
@@ -750,7 +780,8 @@ RealWaitForChar(
     if (!iochan)
        get_tty();
 
-    if (sec > 0) {
+    if (sec > 0)
+    {
        // time-out specified; convert it to absolute time
        // sec>0 requirement of lib$cvtf_to_internal_time()
 
@@ -780,7 +811,8 @@ RealWaitForChar(
            return 0; // error
     }
 
-    while (TRUE) {
+    while (TRUE)
+    {
        // select()
        status = sys$qiow(0, iochan, IO$_SENSEMODE | IO$M_TYPEAHDCNT, iosb,
                0, 0, &typeahead, 8, 0, 0, 0, 0);
@@ -791,13 +823,18 @@ RealWaitForChar(
            return 1; // ready to read
 
        // there's nothing to read; what now?
-       if (msec == 0) {
+       if (msec == 0)
+       {
            // immediate time-out; return impatiently
            return 0;
-       } else if (msec < 0) {
+       }
+       else if (msec < 0)
+       {
            // no time-out; wait on indefinitely
            return 1; // fakeout to force a wait in vms_read()
-       } else {
+       }
+       else
+       {
            // time-out needs to be checked
            status = sys$gettim(&time_curr);
            if (status != SS$_NORMAL)
index 1454280ee70b5e5d4c99bb6d70b1d44106098e3d..e6989ae14e3ccfda41e29cab3599c8ccc4848cb7 100644 (file)
@@ -283,7 +283,7 @@ static struct fmtpattern
        {'m', ".\\+"},          // 7
 #define FMT_PATTERN_R 8
        {'r', ".*"},            // 8
-       {'p', "[-       .]*"},  // 9
+       {'p', "[-        .]*"}, // 9
        {'v', "\\d\\+"},        // 10
        {'s', ".\\+"},          // 11
        {'o', ".\\+"}           // 12
@@ -3623,7 +3623,8 @@ qf_list_entry(qfline_T *qfp, int qf_idx, int cursel)
     if (qfp->qf_module != NULL && *qfp->qf_module != NUL)
        vim_snprintf((char *)IObuff, IOSIZE, "%2d %s", qf_idx,
                                                (char *)qfp->qf_module);
-    else {
+    else
+    {
        if (qfp->qf_fnum != 0
                && (buf = buflist_findnr(qfp->qf_fnum)) != NULL)
        {
index 33af278bf624f9f6217781560f9782b98b5869ba..4749cfae6f3ac59e766b22ffe8cca0ebc3ff2faa 100644 (file)
@@ -2696,11 +2696,13 @@ reg_save_equal(regsave_T *save)
     REG_MULTI ? save_se_multi((savep), (posp)) : save_se_one((savep), (pp))
 
 // After a failed match restore the sub-expressions.
-#define restore_se(savep, posp, pp) { \
+#define restore_se(savep, posp, pp) \
+{ \
     if (REG_MULTI) \
        *(posp) = (savep)->se_u.pos; \
     else \
-       *(pp) = (savep)->se_u.ptr; }
+       *(pp) = (savep)->se_u.ptr; \
+}
 
 /*
  * Tentatively set the sub-expression start to the current position (after
index 619cd15d2083bb471820ecf768554ed2c0c73c55..92475ad94a06991c5a0169340c965b1615e5e4fc 100644 (file)
@@ -5799,10 +5799,11 @@ nfa_regmatch(
        goto theend;
     }
 
-#define        ADD_STATE_IF_MATCH(state)                       \
-    if (result) {                                      \
-       add_state = state->out;                         \
-       add_off = clen;                                 \
+#define        ADD_STATE_IF_MATCH(state)       \
+    if (result)                                \
+    {                                  \
+       add_state = state->out;         \
+       add_off = clen;                 \
     }
 
     /*
index 219afd5755c075df7afac94e4a9a0f007a846acf..8809f5de32cca99504bccce9978794633588cf9c 100644 (file)
@@ -161,7 +161,7 @@ search_regcomp(
        add_to_history(HIST_SEARCH, pat, TRUE, NUL);
 
     if (used_pat)
-            *used_pat = pat;
+       *used_pat = pat;
 
     vim_free(mr_pattern);
 #ifdef FEAT_RIGHTLEFT
@@ -2641,7 +2641,7 @@ findmatchlimit(
             * (actually, we skip #\( et al)
             */
            if (curbuf->b_p_lisp
-                   && vim_strchr((char_u *)"(){}[]", c) != NULL
+                   && vim_strchr((char_u *)"{}()[]", c) != NULL
                    && pos.col > 1
                    && check_prevcol(linep, pos.col, '\\', NULL)
                    && check_prevcol(linep, pos.col - 1, '#', NULL))
index 7c845c5c364337d41b6b6067409169afc3a8a078..ad5165a3ce3c2889a9fedff6e2e56d8635d347b0 100644 (file)
@@ -286,15 +286,19 @@ tgetstr(char *id, char **buf)
        if (!*tmp)
            break;
 
-       if (_match(id, tmp) == len) {
+       if (_match(id, tmp) == len)
+       {
            tmp += len;                         // find '=' '@' or '#'
            if (*tmp == '@')                    // :xx@: entry for tc
                return 0;                       // deleted entry
            hold= *buf;
-           while (*++tmp && *tmp != ':') {     // not at end of field
-               switch(*tmp) {
+           while (*++tmp && *tmp != ':')       // not at end of field
+               {
+               switch(*tmp)
+               {
                case '\\':                      // Expand escapes here
-                   switch(*++tmp) {
+                   switch(*++tmp)
+                   {
                    case 0:                     // ignore backslashes
                        tmp--;                  // at end of entry
                        break;                  // shouldn't happen
@@ -401,11 +405,16 @@ tgoto(
     bufp = buffer;
     ptr = cm;
 
-    while (*ptr) {
-       if ((c = *ptr++) != '%') {              // normal char
+    while (*ptr)
+    {
+       if ((c = *ptr++) != '%')                // normal char
+       {
            *bufp++ = c;
-       } else {                                // % escape
-           switch(c = *ptr++) {
+       }
+       else
+       {                               // % escape
+           switch(c = *ptr++)
+           {
            case 'd':                           // decimal
                bufp = _addfmt(bufp, "%d", line);
                line = col;
@@ -430,7 +439,8 @@ tgoto(
                if (line == '\t' ||             // these are
                   line == '\n' ||              // chars that
                   line == '\004' ||            // UNIX hates
-                  line == '\0') {
+                  line == '\0')
+               {
                    line++;                     // so go to next pos
                    if (reverse == (line == col))
                        addup=1;                // and mark UP
@@ -472,7 +482,8 @@ tgoto(
     }
 
     if (addup)                                 // add upline
-       if (UP) {
+       if (UP)
+       {
            ptr=UP;
            while (VIM_ISDIGIT(*ptr) || *ptr == '.')
                ptr++;
@@ -483,7 +494,8 @@ tgoto(
        }
 
     if (addbak)                                        // add backspace
-       if (BC) {
+       if (BC)
+       {
            ptr=BC;
            while (VIM_ISDIGIT(*ptr) || *ptr == '.')
                ptr++;
@@ -536,17 +548,20 @@ tputs(
        counter,                        // digits
        atol(const char *);
 
-    if (VIM_ISDIGIT(*cp)) {
+    if (VIM_ISDIGIT(*cp))
+    {
        counter = 0;
        frac = 1000;
        while (VIM_ISDIGIT(*cp))
            counter = counter * 10L + (long)(*cp++ - '0');
        if (*cp == '.')
-           while (VIM_ISDIGIT(*++cp)) {
+           while (VIM_ISDIGIT(*++cp))
+           {
                counter = counter * 10L + (long)(*cp++ - '0');
                frac = frac * 10;
            }
-       if (*cp!='*') {                 // multiply by affected lines
+       if (*cp!='*')                   // multiply by affected lines
+       {
            if (affcnt>1) affcnt = 1;
        }
        else
index fdca9f41939ce3c3c10048a59cb01a36a8e152c5..f1982171696ffa5fecf2f744f63c8ce9d61c7ab5 100644 (file)
@@ -97,6 +97,7 @@ NEW_TESTS = \
        test_cmdline \
        test_cmdmods \
        test_cmdwin \
+       test_codestyle \
        test_command_count \
        test_comments \
        test_comparators \
@@ -359,6 +360,7 @@ NEW_TESTS_RES = \
        test_cmdline.res \
        test_cmdmods.res \
        test_cmdwin.res \
+       test_codestyle.res \
        test_command_count.res \
        test_comments.res \
        test_comparators.res \
diff --git a/src/testdir/test_codestyle.vim b/src/testdir/test_codestyle.vim
new file mode 100644 (file)
index 0000000..beb4a68
--- /dev/null
@@ -0,0 +1,45 @@
+" Test for checking the source code style.
+
+def Test_source_files()
+  for fname in glob('../*.[ch]', 0, 1)
+    exe 'edit ' .. fname
+
+    cursor(1, 1)
+    var lnum = search(' \t')
+    assert_equal(0, lnum, fname .. ': space before tab')
+
+    cursor(1, 1)
+    lnum = search('\s$')
+    assert_equal(0, lnum, fname .. ': trailing white space')
+
+    # some files don't stick to the Vim style rules
+    if fname =~ 'iscygpty.c'
+      continue
+    endif
+
+    # Examples in comments use "condition) {", skip them.
+    # Skip if a double quote or digit comes after the "{".
+    # Skip specific string used in os_unix.c.
+    # Also skip fold markers.
+    var skip = 'getline(".") =~ "condition) {" || getline(".") =~ "vimglob_func" || getline(".") =~ "{\"" || getline(".") =~ "{\\d" || getline(".") =~ "{{{"'
+    cursor(1, 1)
+    lnum = search(')\s*{', '', 0, 0, skip)
+    assert_equal(0, lnum, fname .. ': curly after closing paren')
+
+    cursor(1, 1)
+    # Examples in comments use double quotes.
+    skip = "getline('.') =~ '\"'"
+    # Avoid examples that contain: "} else
+    lnum = search('[^"]}\s*else', '', 0, 0, skip)
+    assert_equal(0, lnum, fname .. ': curly before "else"')
+
+    cursor(1, 1)
+    lnum = search('else\s*{', '', 0, 0, skip)
+    assert_equal(0, lnum, fname .. ': curly after "else"')
+  endfor
+
+  bwipe!
+enddef
+
+
+" vim: shiftwidth=2 sts=2 expandtab
index e9a9aac3272cce72563781ad2fed35a431a9ed2d..c84189f56424943ff4926559392678ebb48ef8f3 100644 (file)
@@ -49,7 +49,8 @@ reg_delete_key(HKEY hRootKey, const char *key, DWORD flag)
        if (advapi_lib != NULL)
            delete_key_ex = (LONG (WINAPI *)(HKEY, LPCTSTR, REGSAM, DWORD))GetProcAddress(advapi_lib, "RegDeleteKeyExA");
     }
-    if (delete_key_ex != NULL) {
+    if (delete_key_ex != NULL)
+    {
        return (*delete_key_ex)(hRootKey, key, flag, 0);
     }
     return RegDeleteKey(hRootKey, key);
index 293e17626383fa82ad7d669d7519db4a8f600a2f..831b64373920e5d3c3cbd6414ffc26fc5e962572 100644 (file)
@@ -695,6 +695,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1234,
 /**/
     1233,
 /**/
index ec08f63b71a0a34abf892362fa4b3e0654d7675a..258c8955b72b0d7346909a463ed5ac8ca501382e 100644 (file)
--- a/src/vim.h
+++ b/src/vim.h
@@ -2498,24 +2498,34 @@ typedef enum {
 #  define gtk_widget_set_window(wid, win) \
     do { (wid)->window = (win); } while (0)
 #  define gtk_widget_set_can_default(wid, can) \
-    do { if (can) { GTK_WIDGET_SET_FLAGS(wid, GTK_CAN_DEFAULT); } \
-       else { GTK_WIDGET_UNSET_FLAGS(wid, GTK_CAN_DEFAULT); } } while (0)
+    do { if (can) \
+           { GTK_WIDGET_SET_FLAGS(wid, GTK_CAN_DEFAULT); } \
+       else \
+           { GTK_WIDGET_UNSET_FLAGS(wid, GTK_CAN_DEFAULT); } } while (0)
 #  define gtk_widget_set_can_focus(wid, can) \
-    do { if (can) { GTK_WIDGET_SET_FLAGS(wid, GTK_CAN_FOCUS); } \
-       else { GTK_WIDGET_UNSET_FLAGS(wid, GTK_CAN_FOCUS); } } while (0)
+    do { if (can) \
+           { GTK_WIDGET_SET_FLAGS(wid, GTK_CAN_FOCUS); } \
+       else \
+           { GTK_WIDGET_UNSET_FLAGS(wid, GTK_CAN_FOCUS); } } while (0)
 #  define gtk_widget_set_visible(wid, vis) \
-    do { if (vis) { gtk_widget_show(wid); } \
-       else { gtk_widget_hide(wid); } } while (0)
+    do { if (vis) \
+           { gtk_widget_show(wid); } \
+       else \
+           { gtk_widget_hide(wid); } } while (0)
 # endif
 # if !GTK_CHECK_VERSION(2,20,0)
 #  define gtk_widget_get_mapped(wid)   GTK_WIDGET_MAPPED(wid)
 #  define gtk_widget_get_realized(wid) GTK_WIDGET_REALIZED(wid)
 #  define gtk_widget_set_mapped(wid, map) \
-    do { if (map) { GTK_WIDGET_SET_FLAGS(wid, GTK_MAPPED); } \
-       else { GTK_WIDGET_UNSET_FLAGS(wid, GTK_MAPPED); } } while (0)
+    do { if (map) \
+           { GTK_WIDGET_SET_FLAGS(wid, GTK_MAPPED); } \
+       else \
+           { GTK_WIDGET_UNSET_FLAGS(wid, GTK_MAPPED); } } while (0)
 #  define gtk_widget_set_realized(wid, rea) \
-    do { if (rea) { GTK_WIDGET_SET_FLAGS(wid, GTK_REALIZED); } \
-       else { GTK_WIDGET_UNSET_FLAGS(wid, GTK_REALIZED); } } while (0)
+    do { if (rea) \
+           { GTK_WIDGET_SET_FLAGS(wid, GTK_REALIZED); } \
+       else \
+           { GTK_WIDGET_UNSET_FLAGS(wid, GTK_REALIZED); } } while (0)
 # endif
 #endif