diff options
author | Bram Moolenaar <Bram@vim.org> | 2018-04-10 18:47:20 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2018-04-10 18:47:20 +0200 |
commit | 6f4700233fd925fe122b851f937929fb5e5da707 (patch) | |
tree | 5c5397f70fc4a320ce0c38adba21a1de7ed7b10d /src | |
parent | d6b4f2dd760b425c63c359b9ff299f73448f8854 (diff) | |
download | vim-git-6f4700233fd925fe122b851f937929fb5e5da707.tar.gz |
patch 8.0.1688: some macros are used without a semicolonv8.0.1688
Problem: Some macros are used without a semicolon, causing auto-indent to be
wrong.
Solution: Use the do-while(0) trick. (Ozaki Kiichi, closes #2729)
Diffstat (limited to 'src')
-rw-r--r-- | src/buffer.c | 2 | ||||
-rw-r--r-- | src/dosinst.c | 9 | ||||
-rw-r--r-- | src/ex_cmds.c | 6 | ||||
-rw-r--r-- | src/gui_at_sb.c | 6 | ||||
-rw-r--r-- | src/macros.h | 8 | ||||
-rw-r--r-- | src/main.c | 2 | ||||
-rw-r--r-- | src/memline.c | 4 | ||||
-rw-r--r-- | src/option.c | 2 | ||||
-rw-r--r-- | src/os_vms.c | 2 | ||||
-rw-r--r-- | src/screen.c | 22 | ||||
-rw-r--r-- | src/version.c | 2 | ||||
-rw-r--r-- | src/window.c | 59 |
12 files changed, 75 insertions, 49 deletions
diff --git a/src/buffer.c b/src/buffer.c index 0e13e1f5d..4563736b4 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -1764,7 +1764,7 @@ enter_buffer(buf_T *buf) #endif /* Change directories when the 'acd' option is set. */ - DO_AUTOCHDIR + DO_AUTOCHDIR; #ifdef FEAT_KEYMAP if (curbuf->b_kmap_state & KEYMAP_INIT) diff --git a/src/dosinst.c b/src/dosinst.c index 6a12e3dc8..ae5517da9 100644 --- a/src/dosinst.c +++ b/src/dosinst.c @@ -23,7 +23,14 @@ #define GVIMEXT32_PATH "GvimExt32\\gvimext.dll" /* Macro to do an error check I was typing over and over */ -#define CHECK_REG_ERROR(code) if (code != ERROR_SUCCESS) { printf("%ld error number: %ld\n", (long)__LINE__, (long)code); return 1; } +#define CHECK_REG_ERROR(code) \ + do { \ + if (code != ERROR_SUCCESS) \ + { \ + printf("%ld error number: %ld\n", (long)__LINE__, (long)code); \ + return 1; \ + } \ + } while (0) int has_vim = 0; /* installable vim.exe exists */ int has_gvim = 0; /* installable gvim.exe exists */ diff --git a/src/ex_cmds.c b/src/ex_cmds.c index e13d34cc0..111fe01d2 100644 --- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -2996,7 +2996,7 @@ rename_buffer(char_u *new_fname) apply_autocmds(EVENT_BUFFILEPOST, NULL, NULL, FALSE, curbuf); /* Change directories when the 'acd' option is set. */ - DO_AUTOCHDIR + DO_AUTOCHDIR; return OK; } @@ -3254,7 +3254,7 @@ do_write(exarg_T *eap) * got changed or set. */ if (eap->cmdidx == CMD_saveas || name_was_missing) { - DO_AUTOCHDIR + DO_AUTOCHDIR; } } @@ -4147,7 +4147,7 @@ do_ecmd( #endif /* Change directories when the 'acd' option is set. */ - DO_AUTOCHDIR + DO_AUTOCHDIR; /* * Careful: open_buffer() and apply_autocmds() may change the current diff --git a/src/gui_at_sb.c b/src/gui_at_sb.c index 659e93463..1816daa09 100644 --- a/src/gui_at_sb.c +++ b/src/gui_at_sb.c @@ -645,7 +645,11 @@ Redisplay(Widget w, XEvent *event, Region region) static Boolean CompareEvents(XEvent *oldEvent, XEvent *newEvent) { -#define Check(field) if (newEvent->field != oldEvent->field) return False; +#define Check(field) \ + do { \ + if (newEvent->field != oldEvent->field) \ + return False; \ + } while (0) Check(xany.display); Check(xany.type); diff --git a/src/macros.h b/src/macros.h index f5440b17e..fcd1a829d 100644 --- a/src/macros.h +++ b/src/macros.h @@ -230,9 +230,9 @@ #endif #ifdef STARTUPTIME -# define TIME_MSG(s) { if (time_fd != NULL) time_msg(s, NULL); } +# define TIME_MSG(s) do { if (time_fd != NULL) time_msg(s, NULL); } while (0) #else -# define TIME_MSG(s) +# define TIME_MSG(s) do { /**/ } while (0) #endif #ifdef FEAT_VREPLACE @@ -289,9 +289,9 @@ #endif #ifdef FEAT_AUTOCHDIR -# define DO_AUTOCHDIR if (p_acd) do_autochdir(); +# define DO_AUTOCHDIR do { if (p_acd) do_autochdir(); } while (0) #else -# define DO_AUTOCHDIR +# define DO_AUTOCHDIR do { /**/ } while (0) #endif #define RESET_BINDING(wp) (wp)->w_p_scb = FALSE; (wp)->w_p_crb = FALSE diff --git a/src/main.c b/src/main.c index 0b0fac60b..6d351b6ff 100644 --- a/src/main.c +++ b/src/main.c @@ -824,7 +824,7 @@ vim_main2(void) no_wait_return = FALSE; /* 'autochdir' has been postponed */ - DO_AUTOCHDIR + DO_AUTOCHDIR; #ifdef FEAT_TERMRESPONSE /* Requesting the termresponse is postponed until here, so that a "-c q" diff --git a/src/memline.c b/src/memline.c index 5ecb32c10..4be1036f0 100644 --- a/src/memline.c +++ b/src/memline.c @@ -8,8 +8,8 @@ */ /* for debugging */ -/* #define CHECK(c, s) if (c) EMSG(s) */ -#define CHECK(c, s) +/* #define CHECK(c, s) do { if (c) EMSG(s); } while (0) */ +#define CHECK(c, s) do { /**/ } while (0) /* * memline.c: Contains the functions for appending, deleting and changing the diff --git a/src/option.c b/src/option.c index 084e5e1a6..48432bb32 100644 --- a/src/option.c +++ b/src/option.c @@ -8456,7 +8456,7 @@ set_bool_option( else if ((int *)varp == &p_acd) { /* Change directories when the 'acd' option is set now. */ - DO_AUTOCHDIR + DO_AUTOCHDIR; } #endif diff --git a/src/os_vms.c b/src/os_vms.c index 02c594c5b..84f84ac71 100644 --- a/src/os_vms.c +++ b/src/os_vms.c @@ -83,7 +83,7 @@ static void set_tty(int row, int col); #define EXPL_ALLOC_INC 64 #define EQN(S1,S2,LN) (strncmp(S1,S2,LN) == 0) -#define SKIP_FOLLOWING_SLASHES(Str) while (Str[1] == '/') ++Str +#define SKIP_FOLLOWING_SLASHES(Str) do { while (Str[1] == '/') ++Str; } while (0) /* diff --git a/src/screen.c b/src/screen.c index 77a3c1895..bcfaabed1 100644 --- a/src/screen.c +++ b/src/screen.c @@ -2705,15 +2705,21 @@ fold_line( } #ifdef FEAT_RIGHTLEFT -# define RL_MEMSET(p, v, l) if (wp->w_p_rl) \ - for (ri = 0; ri < l; ++ri) \ - ScreenAttrs[off + (wp->w_width - (p) - (l)) + ri] = v; \ - else \ - for (ri = 0; ri < l; ++ri) \ - ScreenAttrs[off + (p) + ri] = v +# define RL_MEMSET(p, v, l) \ + do { \ + if (wp->w_p_rl) \ + for (ri = 0; ri < l; ++ri) \ + ScreenAttrs[off + (wp->w_width - (p) - (l)) + ri] = v; \ + else \ + for (ri = 0; ri < l; ++ri) \ + ScreenAttrs[off + (p) + ri] = v; \ + } while (0) #else -# define RL_MEMSET(p, v, l) for (ri = 0; ri < l; ++ri) \ - ScreenAttrs[off + (p) + ri] = v +# define RL_MEMSET(p, v, l) \ + do { \ + for (ri = 0; ri < l; ++ri) \ + ScreenAttrs[off + (p) + ri] = v; \ + } while (0) #endif /* Set all attributes of the 'number' or 'relativenumber' column and the diff --git a/src/version.c b/src/version.c index 4fc5de022..63c274fa6 100644 --- a/src/version.c +++ b/src/version.c @@ -763,6 +763,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1688, +/**/ 1687, /**/ 1686, diff --git a/src/window.c b/src/window.c index 337f84dee..a1b2a45cc 100644 --- a/src/window.c +++ b/src/window.c @@ -99,9 +99,16 @@ do_window( Prenum1 = Prenum; #ifdef FEAT_CMDWIN -# define CHECK_CMDWIN if (cmdwin_type != 0) { EMSG(_(e_cmdwin)); break; } +# define CHECK_CMDWIN \ + do { \ + if (cmdwin_type != 0) \ + { \ + EMSG(_(e_cmdwin)); \ + return; \ + } \ + } while (0) #else -# define CHECK_CMDWIN +# define CHECK_CMDWIN do { /**/ } while (0) #endif switch (nchar) @@ -110,7 +117,7 @@ do_window( case 'S': case Ctrl_S: case 's': - CHECK_CMDWIN + CHECK_CMDWIN; reset_VIsual_and_resel(); /* stop Visual mode */ #ifdef FEAT_QUICKFIX /* When splitting the quickfix window open a new buffer in it, @@ -127,7 +134,7 @@ do_window( /* split current window in two parts, vertically */ case Ctrl_V: case 'v': - CHECK_CMDWIN + CHECK_CMDWIN; reset_VIsual_and_resel(); /* stop Visual mode */ #ifdef FEAT_QUICKFIX /* When splitting the quickfix window open a new buffer in it, @@ -144,7 +151,7 @@ do_window( /* split current window and edit alternate file */ case Ctrl_HAT: case '^': - CHECK_CMDWIN + CHECK_CMDWIN; reset_VIsual_and_resel(); /* stop Visual mode */ cmd_with_count("split #", cbuf, sizeof(cbuf), Prenum); do_cmdline_cmd(cbuf); @@ -153,7 +160,7 @@ do_window( /* open new window */ case Ctrl_N: case 'n': - CHECK_CMDWIN + CHECK_CMDWIN; reset_VIsual_and_resel(); /* stop Visual mode */ #ifdef FEAT_QUICKFIX newwindow: @@ -191,7 +198,7 @@ newwindow: /* close preview window */ case Ctrl_Z: case 'z': - CHECK_CMDWIN + CHECK_CMDWIN; reset_VIsual_and_resel(); /* stop Visual mode */ do_cmdline_cmd((char_u *)"pclose"); break; @@ -211,7 +218,7 @@ newwindow: /* close all but current window */ case Ctrl_O: case 'o': - CHECK_CMDWIN + CHECK_CMDWIN; reset_VIsual_and_resel(); /* stop Visual mode */ cmd_with_count("only", cbuf, sizeof(cbuf), Prenum); do_cmdline_cmd(cbuf); @@ -222,7 +229,7 @@ newwindow: case 'w': /* cursor to previous window with wrap around */ case 'W': - CHECK_CMDWIN + CHECK_CMDWIN; if (ONE_WINDOW && Prenum != 1) /* just one window */ beep_flush(); else @@ -260,7 +267,7 @@ newwindow: case 'j': case K_DOWN: case Ctrl_J: - CHECK_CMDWIN + CHECK_CMDWIN; win_goto_ver(FALSE, Prenum1); break; @@ -268,7 +275,7 @@ newwindow: case 'k': case K_UP: case Ctrl_K: - CHECK_CMDWIN + CHECK_CMDWIN; win_goto_ver(TRUE, Prenum1); break; @@ -277,7 +284,7 @@ newwindow: case K_LEFT: case Ctrl_H: case K_BS: - CHECK_CMDWIN + CHECK_CMDWIN; win_goto_hor(TRUE, Prenum1); break; @@ -285,7 +292,7 @@ newwindow: case 'l': case K_RIGHT: case Ctrl_L: - CHECK_CMDWIN + CHECK_CMDWIN; win_goto_hor(FALSE, Prenum1); break; @@ -338,21 +345,21 @@ newwindow: /* exchange current and next window */ case 'x': case Ctrl_X: - CHECK_CMDWIN + CHECK_CMDWIN; win_exchange(Prenum); break; /* rotate windows downwards */ case Ctrl_R: case 'r': - CHECK_CMDWIN + CHECK_CMDWIN; reset_VIsual_and_resel(); /* stop Visual mode */ win_rotate(FALSE, (int)Prenum1); /* downwards */ break; /* rotate windows upwards */ case 'R': - CHECK_CMDWIN + CHECK_CMDWIN; reset_VIsual_and_resel(); /* stop Visual mode */ win_rotate(TRUE, (int)Prenum1); /* upwards */ break; @@ -362,7 +369,7 @@ newwindow: case 'J': case 'H': case 'L': - CHECK_CMDWIN + CHECK_CMDWIN; win_totop((int)Prenum, ((nchar == 'H' || nchar == 'L') ? WSP_VERT : 0) | ((nchar == 'H' || nchar == 'K') ? WSP_TOP : WSP_BOT)); @@ -428,7 +435,7 @@ newwindow: /* jump to tag and split window if tag exists (in preview window) */ #if defined(FEAT_QUICKFIX) case '}': - CHECK_CMDWIN + CHECK_CMDWIN; if (Prenum) g_do_tagpreview = Prenum; else @@ -437,7 +444,7 @@ newwindow: /* FALLTHROUGH */ case ']': case Ctrl_RSB: - CHECK_CMDWIN + CHECK_CMDWIN; /* keep Visual mode, can select words to use as a tag */ if (Prenum) postponed_split = Prenum; @@ -459,7 +466,7 @@ newwindow: case 'F': case Ctrl_F: wingotofile: - CHECK_CMDWIN + CHECK_CMDWIN; ptr = grab_file_name(Prenum1, &lnum); if (ptr != NULL) @@ -503,7 +510,7 @@ wingotofile: /* FALLTHROUGH */ case 'd': /* Go to definition, using 'define' */ case Ctrl_D: - CHECK_CMDWIN + CHECK_CMDWIN; if ((len = find_ident_under_cursor(&ptr, FIND_IDENT)) == 0) break; find_pattern_in_path(ptr, 0, len, TRUE, @@ -534,7 +541,7 @@ wingotofile: /* CTRL-W g extended commands */ case 'g': case Ctrl_G: - CHECK_CMDWIN + CHECK_CMDWIN; #ifdef USE_ON_FLY_SCROLL dont_scroll = TRUE; /* disallow scrolling here */ #endif @@ -4273,9 +4280,9 @@ win_enter_ext( win_T *wp, int undo_sync, int curwin_invalid, - int trigger_new_autocmds UNUSED, - int trigger_enter_autocmds UNUSED, - int trigger_leave_autocmds UNUSED) + int trigger_new_autocmds, + int trigger_enter_autocmds, + int trigger_leave_autocmds) { int other_buffer = FALSE; @@ -4385,7 +4392,7 @@ win_enter_ext( #endif /* Change directories when the 'acd' option is set. */ - DO_AUTOCHDIR + DO_AUTOCHDIR; } |