Permalink
Browse files

patch 8.0.1688: some macros are used without a semicolon

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)
  • Loading branch information...
brammool committed Apr 10, 2018
1 parent d6b4f2d commit 6f4700233fd925fe122b851f937929fb5e5da707
Showing with 75 additions and 49 deletions.
  1. +1 −1 src/buffer.c
  2. +8 −1 src/dosinst.c
  3. +3 −3 src/ex_cmds.c
  4. +5 −1 src/gui_at_sb.c
  5. +4 −4 src/macros.h
  6. +1 −1 src/main.c
  7. +2 −2 src/memline.c
  8. +1 −1 src/option.c
  9. +1 −1 src/os_vms.c
  10. +14 −8 src/screen.c
  11. +2 −0 src/version.c
  12. +33 −26 src/window.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)
@@ -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 */
@@ -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
@@ -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);
@@ -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
@@ -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"
@@ -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
@@ -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
@@ -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)
/*
@@ -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
@@ -762,6 +762,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1688,
/**/
1687,
/**/
@@ -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 @@ do_window(
/* 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 @@ do_window(
/* 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 @@ do_window(
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,15 +267,15 @@ do_window(
case 'j':
case K_DOWN:
case Ctrl_J:
CHECK_CMDWIN
CHECK_CMDWIN;
win_goto_ver(FALSE, Prenum1);
break;
/* cursor to window above */
case 'k':
case K_UP:
case Ctrl_K:
CHECK_CMDWIN
CHECK_CMDWIN;
win_goto_ver(TRUE, Prenum1);
break;
@@ -277,15 +284,15 @@ do_window(
case K_LEFT:
case Ctrl_H:
case K_BS:
CHECK_CMDWIN
CHECK_CMDWIN;
win_goto_hor(TRUE, Prenum1);
break;
/* cursor to right window */
case 'l':
case K_RIGHT:
case Ctrl_L:
CHECK_CMDWIN
CHECK_CMDWIN;
win_goto_hor(FALSE, Prenum1);
break;
@@ -338,21 +345,21 @@ do_window(
/* 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 @@ do_window(
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 @@ do_window(
/* 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 @@ do_window(
/* 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 @@ do_window(
case 'F':
case Ctrl_F:
wingotofile:
CHECK_CMDWIN
CHECK_CMDWIN;
ptr = grab_file_name(Prenum1, &lnum);
if (ptr != NULL)
@@ -503,7 +510,7 @@ do_window(
/* 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 @@ do_window(
/* 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;
}

0 comments on commit 6f47002

Please sign in to comment.