changeset 31752:3365a601e73b v9.0.1208

patch 9.0.1208: code is indented more than necessary Commit: https://github.com/vim/vim/commit/a41e221935edab62672a15123af48f4f14ac1c7d Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Mon Jan 16 18:19:05 2023 +0000 patch 9.0.1208: code is indented more than necessary Problem: Code is indented more than necessary. Solution: Use an early return where it makes sense. (Yegappan Lakshmanan, closes #11819)
author Bram Moolenaar <Bram@vim.org>
date Mon, 16 Jan 2023 19:30:04 +0100
parents 997105f91449
children 048ae7b3fdd6
files src/netbeans.c src/normal.c src/ops.c src/option.c src/optionstr.c src/os_amiga.c src/os_mac_conv.c src/os_mswin.c src/os_qnx.c src/os_unix.c src/os_win32.c src/version.c
diffstat 12 files changed, 1374 insertions(+), 1368 deletions(-) [+]
line wrap: on
line diff
--- a/src/netbeans.c
+++ b/src/netbeans.c
@@ -938,13 +938,13 @@ nb_partialremove(linenr_T lnum, colnr_T 
     if (lastbyte >= oldlen)
 	lastbyte = oldlen - 1;
     newtext = alloc(oldlen - (int)(lastbyte - first));
-    if (newtext != NULL)
-    {
-	mch_memmove(newtext, oldtext, first);
-	STRMOVE(newtext + first, oldtext + lastbyte + 1);
-	nbdebug(("    NEW LINE %ld: %s\n", lnum, newtext));
-	ml_replace(lnum, newtext, FALSE);
-    }
+    if (newtext == NULL)
+	return;
+
+    mch_memmove(newtext, oldtext, first);
+    STRMOVE(newtext + first, oldtext + lastbyte + 1);
+    nbdebug(("    NEW LINE %ld: %s\n", lnum, newtext));
+    ml_replace(lnum, newtext, FALSE);
 }
 
 /*
@@ -960,12 +960,12 @@ nb_joinlines(linenr_T first, linenr_T ot
     len_first = (int)STRLEN(ml_get(first));
     len_other = (int)STRLEN(ml_get(other));
     p = alloc(len_first + len_other + 1);
-    if (p != NULL)
-    {
-      mch_memmove(p, ml_get(first), len_first);
-      mch_memmove(p + len_first, ml_get(other), len_other + 1);
-      ml_replace(first, p, FALSE);
-    }
+    if (p == NULL)
+	return;
+
+    mch_memmove(p, ml_get(first), len_first);
+    mch_memmove(p + len_first, ml_get(other), len_other + 1);
+    ml_replace(first, p, FALSE);
 }
 
 #define SKIP_STOP 2
@@ -2247,13 +2247,14 @@ nb_do_cmd(
     static void
 nb_set_curbuf(buf_T *buf)
 {
-    if (curbuf != buf) {
-	if (buf_jump_open_win(buf) != NULL)
-	    return;
-	if ((swb_flags & SWB_USETAB) && buf_jump_open_tab(buf) != NULL)
-	    return;
-	set_curbuf(buf, DOBUF_GOTO);
-    }
+    if (curbuf == buf)
+	return;
+
+    if (buf_jump_open_win(buf) != NULL)
+	return;
+    if ((swb_flags & SWB_USETAB) && buf_jump_open_tab(buf) != NULL)
+	return;
+    set_curbuf(buf, DOBUF_GOTO);
 }
 
 /*
@@ -2364,14 +2365,14 @@ nb_init_graphics(void)
 {
     static int did_init = FALSE;
 
-    if (!did_init)
-    {
-	coloncmd(":highlight NBGuarded guibg=Cyan guifg=Black"
-			    " ctermbg=LightCyan ctermfg=Black");
-	coloncmd(":sign define %d linehl=NBGuarded", GUARDED);
-
-	did_init = TRUE;
-    }
+    if (did_init)
+	return;
+
+    coloncmd(":highlight NBGuarded guibg=Cyan guifg=Black"
+	    " ctermbg=LightCyan ctermfg=Black");
+    coloncmd(":sign define %d linehl=NBGuarded", GUARDED);
+
+    did_init = TRUE;
 }
 
 /*
@@ -2468,29 +2469,29 @@ netbeans_beval_cb(
     if (!can_use_beval() || !NETBEANS_OPEN)
 	return;
 
-    if (get_beval_info(beval, TRUE, &wp, &lnum, &text, &col) == OK)
+    if (get_beval_info(beval, TRUE, &wp, &lnum, &text, &col) != OK)
+	return;
+
+    // Send debugger request.  Only when the text is of reasonable
+    // length.
+    if (text != NULL && text[0] != NUL && STRLEN(text) < MAXPATHL)
     {
-	// Send debugger request.  Only when the text is of reasonable
-	// length.
-	if (text != NULL && text[0] != NUL && STRLEN(text) < MAXPATHL)
+	buf = alloc(MAXPATHL * 2 + 25);
+	if (buf != NULL)
 	{
-	    buf = alloc(MAXPATHL * 2 + 25);
-	    if (buf != NULL)
+	    p = nb_quote(text);
+	    if (p != NULL)
 	    {
-		p = nb_quote(text);
-		if (p != NULL)
-		{
-		    vim_snprintf(buf, MAXPATHL * 2 + 25,
-				     "0:balloonText=%d \"%s\"\n", r_cmdno, p);
-		    vim_free(p);
-		}
-		nbdebug(("EVT: %s", buf));
-		nb_send(buf, "netbeans_beval_cb");
-		vim_free(buf);
+		vim_snprintf(buf, MAXPATHL * 2 + 25,
+			"0:balloonText=%d \"%s\"\n", r_cmdno, p);
+		vim_free(p);
 	    }
+	    nbdebug(("EVT: %s", buf));
+	    nb_send(buf, "netbeans_beval_cb");
+	    vim_free(buf);
 	}
-	vim_free(text);
     }
+    vim_free(text);
 }
 #endif
 
@@ -2555,12 +2556,12 @@ set_ref_in_nb_channel(int copyID)
     int abort = FALSE;
     typval_T tv;
 
-    if (nb_channel != NULL)
-    {
-	tv.v_type = VAR_CHANNEL;
-	tv.vval.v_channel = nb_channel;
-	abort = set_ref_in_item(&tv, copyID, NULL, NULL);
-    }
+    if (nb_channel == NULL)
+	return FALSE;
+
+    tv.v_type = VAR_CHANNEL;
+    tv.vval.v_channel = nb_channel;
+    abort = set_ref_in_item(&tv, copyID, NULL, NULL);
     return abort;
 }
 #endif
@@ -2827,22 +2828,22 @@ netbeans_button_release(int button)
 
     bufno = nb_getbufno(curbuf);
 
-    if (bufno >= 0 && curwin != NULL && curwin->w_buffer == curbuf)
-    {
-	int col = mouse_col - curwin->w_wincol
-			      - ((curwin->w_p_nu || curwin->w_p_rnu) ? 9 : 1);
-	long off = pos2off(curbuf, &curwin->w_cursor);
-
-	// sync the cursor position
-	sprintf(buf, "%d:newDotAndMark=%d %ld %ld\n", bufno, r_cmdno, off, off);
-	nbdebug(("EVT: %s", buf));
-	nb_send(buf, "netbeans_button_release[newDotAndMark]");
-
-	sprintf(buf, "%d:buttonRelease=%d %d %ld %d\n", bufno, r_cmdno,
-				    button, (long)curwin->w_cursor.lnum, col);
-	nbdebug(("EVT: %s", buf));
-	nb_send(buf, "netbeans_button_release");
-    }
+    if (bufno < 0 || curwin == NULL || curwin->w_buffer != curbuf)
+	return;
+
+    int col = mouse_col - curwin->w_wincol
+	- ((curwin->w_p_nu || curwin->w_p_rnu) ? 9 : 1);
+    long off = pos2off(curbuf, &curwin->w_cursor);
+
+    // sync the cursor position
+    sprintf(buf, "%d:newDotAndMark=%d %ld %ld\n", bufno, r_cmdno, off, off);
+    nbdebug(("EVT: %s", buf));
+    nb_send(buf, "netbeans_button_release[newDotAndMark]");
+
+    sprintf(buf, "%d:buttonRelease=%d %d %ld %d\n", bufno, r_cmdno,
+	    button, (long)curwin->w_cursor.lnum, col);
+    nbdebug(("EVT: %s", buf));
+    nb_send(buf, "netbeans_button_release");
 }
 
 
@@ -3308,29 +3309,27 @@ get_buf_size(buf_T *bufp)
 
     if (bufp->b_ml.ml_flags & ML_EMPTY)
 	return 0;
+
+    if (get_fileformat(bufp) == EOL_DOS)
+	eol_size = 2;
     else
+	eol_size = 1;
+    for (lnum = 1; lnum <= bufp->b_ml.ml_line_count; ++lnum)
     {
-	if (get_fileformat(bufp) == EOL_DOS)
-	    eol_size = 2;
-	else
-	    eol_size = 1;
-	for (lnum = 1; lnum <= bufp->b_ml.ml_line_count; ++lnum)
+	char_count += (long)STRLEN(ml_get_buf(bufp, lnum, FALSE))
+	    + eol_size;
+	// Check for a CTRL-C every 100000 characters
+	if (char_count > last_check)
 	{
-	    char_count += (long)STRLEN(ml_get_buf(bufp, lnum, FALSE))
-								   + eol_size;
-	    // Check for a CTRL-C every 100000 characters
-	    if (char_count > last_check)
-	    {
-		ui_breakcheck();
-		if (got_int)
-		    return char_count;
-		last_check = char_count + 100000L;
-	    }
+	    ui_breakcheck();
+	    if (got_int)
+		return char_count;
+	    last_check = char_count + 100000L;
 	}
-	// Correction for when last line doesn't have an EOL.
-	if (!bufp->b_p_eol && (bufp->b_p_bin || !bufp->b_p_fixeol))
-	    char_count -= eol_size;
     }
+    // Correction for when last line doesn't have an EOL.
+    if (!bufp->b_p_eol && (bufp->b_p_bin || !bufp->b_p_fixeol))
+	char_count -= eol_size;
 
     return char_count;
 }
@@ -3393,12 +3392,12 @@ pos2off(buf_T *buf, pos_T *pos)
 {
     long	 offset = 0;
 
-    if (!(buf->b_ml.ml_flags & ML_EMPTY))
-    {
-	if ((offset = ml_find_line_or_offset(buf, pos->lnum, 0)) < 0)
-	    return 0;
-	offset += pos->col;
-    }
+    if (buf->b_ml.ml_flags & ML_EMPTY)
+	return 0;
+
+    if ((offset = ml_find_line_or_offset(buf, pos->lnum, 0)) < 0)
+	return 0;
+    offset += pos->col;
 
     return offset;
 }
--- a/src/normal.c
+++ b/src/normal.c
@@ -186,14 +186,13 @@ find_command(int cmdchar)
     static int
 check_text_locked(oparg_T *oap)
 {
-    if (text_locked())
-    {
-	if (oap != NULL)
-	    clearopbeep(oap);
-	text_locked_msg();
-	return TRUE;
-    }
-    return FALSE;
+    if (!text_locked())
+	return FALSE;
+
+    if (oap != NULL)
+	clearopbeep(oap);
+    text_locked_msg();
+    return TRUE;
 }
 
 /*
@@ -206,13 +205,13 @@ check_text_or_curbuf_locked(oparg_T *oap
 {
     if (check_text_locked(oap))
 	return TRUE;
-    if (curbuf_locked())
-    {
-	if (oap != NULL)
-	    clearop(oap);
-	return TRUE;
-    }
-    return FALSE;
+
+    if (!curbuf_locked())
+	return FALSE;
+
+    if (oap != NULL)
+	clearop(oap);
+    return TRUE;
 }
 
 /*
@@ -2030,19 +2029,19 @@ nv_addsub(cmdarg_T *cap)
     static void
 nv_page(cmdarg_T *cap)
 {
-    if (!checkclearop(cap->oap))
-    {
-	if (mod_mask & MOD_MASK_CTRL)
-	{
-	    // <C-PageUp>: tab page back; <C-PageDown>: tab page forward
-	    if (cap->arg == BACKWARD)
-		goto_tabpage(-(int)cap->count1);
-	    else
-		goto_tabpage((int)cap->count0);
-	}
+    if (checkclearop(cap->oap))
+	return;
+
+    if (mod_mask & MOD_MASK_CTRL)
+    {
+	// <C-PageUp>: tab page back; <C-PageDown>: tab page forward
+	if (cap->arg == BACKWARD)
+	    goto_tabpage(-(int)cap->count1);
 	else
-	    (void)onepage(cap->arg, cap->count1);
-    }
+	    goto_tabpage((int)cap->count0);
+    }
+    else
+	(void)onepage(cap->arg, cap->count1);
 }
 
 /*
@@ -2062,17 +2061,16 @@ nv_gd(
 								       == FAIL)
     {
 	clearopbeep(oap);
-    }
-    else
-    {
+	return;
+    }
+
 #ifdef FEAT_FOLDING
-	if ((fdo_flags & FDO_SEARCH) && KeyTyped && oap->op_type == OP_NOP)
-	    foldOpenCursor();
-#endif
-	// clear any search statistics
-	if (messaging() && !msg_silent && !shortmess(SHM_SEARCHCOUNT))
-	    clear_cmdline = TRUE;
-    }
+    if ((fdo_flags & FDO_SEARCH) && KeyTyped && oap->op_type == OP_NOP)
+	foldOpenCursor();
+#endif
+    // clear any search statistics
+    if (messaging() && !msg_silent && !shortmess(SHM_SEARCHCOUNT))
+	clear_cmdline = TRUE;
 }
 
 /*
@@ -3157,60 +3155,61 @@ nv_colon(cmdarg_T *cap)
     int	flags;
 
     if (VIsual_active && !is_cmdkey)
+    {
 	nv_operator(cap);
-    else
-    {
-	if (cap->oap->op_type != OP_NOP)
+	return;
+    }
+
+    if (cap->oap->op_type != OP_NOP)
+    {
+	// Using ":" as a movement is characterwise exclusive.
+	cap->oap->motion_type = MCHAR;
+	cap->oap->inclusive = FALSE;
+    }
+    else if (cap->count0 && !is_cmdkey)
+    {
+	// translate "count:" into ":.,.+(count - 1)"
+	stuffcharReadbuff('.');
+	if (cap->count0 > 1)
 	{
-	    // Using ":" as a movement is characterwise exclusive.
-	    cap->oap->motion_type = MCHAR;
-	    cap->oap->inclusive = FALSE;
-	}
-	else if (cap->count0 && !is_cmdkey)
-	{
-	    // translate "count:" into ":.,.+(count - 1)"
-	    stuffcharReadbuff('.');
-	    if (cap->count0 > 1)
-	    {
-		stuffReadbuff((char_u *)",.+");
-		stuffnumReadbuff((long)cap->count0 - 1L);
-	    }
+	    stuffReadbuff((char_u *)",.+");
+	    stuffnumReadbuff((long)cap->count0 - 1L);
 	}
-
-	// When typing, don't type below an old message
-	if (KeyTyped)
-	    compute_cmdrow();
-
-	old_p_im = p_im;
-
-	// get a command line and execute it
-	flags = cap->oap->op_type != OP_NOP ? DOCMD_KEEPLINE : 0;
-	if (is_cmdkey)
-	    cmd_result = do_cmdkey_command(cap->cmdchar, flags);
+    }
+
+    // When typing, don't type below an old message
+    if (KeyTyped)
+	compute_cmdrow();
+
+    old_p_im = p_im;
+
+    // get a command line and execute it
+    flags = cap->oap->op_type != OP_NOP ? DOCMD_KEEPLINE : 0;
+    if (is_cmdkey)
+	cmd_result = do_cmdkey_command(cap->cmdchar, flags);
+    else
+	cmd_result = do_cmdline(NULL, getexline, NULL, flags);
+
+    // If 'insertmode' changed, enter or exit Insert mode
+    if (p_im != old_p_im)
+    {
+	if (p_im)
+	    restart_edit = 'i';
 	else
-	    cmd_result = do_cmdline(NULL, getexline, NULL, flags);
-
-	// If 'insertmode' changed, enter or exit Insert mode
-	if (p_im != old_p_im)
-	{
-	    if (p_im)
-		restart_edit = 'i';
-	    else
-		restart_edit = 0;
-	}
-
-	if (cmd_result == FAIL)
-	    // The Ex command failed, do not execute the operator.
-	    clearop(cap->oap);
-	else if (cap->oap->op_type != OP_NOP
-		&& (cap->oap->start.lnum > curbuf->b_ml.ml_line_count
-		    || cap->oap->start.col >
-			       (colnr_T)STRLEN(ml_get(cap->oap->start.lnum))
-		    || did_emsg
-		    ))
-	    // The start of the operator has become invalid by the Ex command.
-	    clearopbeep(cap->oap);
-    }
+	    restart_edit = 0;
+    }
+
+    if (cmd_result == FAIL)
+	// The Ex command failed, do not execute the operator.
+	clearop(cap->oap);
+    else if (cap->oap->op_type != OP_NOP
+	    && (cap->oap->start.lnum > curbuf->b_ml.ml_line_count
+		|| cap->oap->start.col >
+		(colnr_T)STRLEN(ml_get(cap->oap->start.lnum))
+		|| did_emsg
+	       ))
+	// The start of the operator has become invalid by the Ex command.
+	clearopbeep(cap->oap);
 }
 
 /*
@@ -3251,28 +3250,28 @@ nv_ctrlh(cmdarg_T *cap)
     static void
 nv_clear(cmdarg_T *cap)
 {
-    if (!checkclearop(cap->oap))
-    {
+    if (checkclearop(cap->oap))
+	return;
+
 #ifdef FEAT_SYN_HL
-	// Clear all syntax states to force resyncing.
-	syn_stack_free_all(curwin->w_s);
+    // Clear all syntax states to force resyncing.
+    syn_stack_free_all(curwin->w_s);
 # ifdef FEAT_RELTIME
-	{
-	    win_T *wp;
-
-	    FOR_ALL_WINDOWS(wp)
-		wp->w_s->b_syn_slow = FALSE;
-	}
+    {
+	win_T *wp;
+
+	FOR_ALL_WINDOWS(wp)
+	    wp->w_s->b_syn_slow = FALSE;
+    }
 # endif
 #endif
-	redraw_later(UPD_CLEAR);
+    redraw_later(UPD_CLEAR);
 #if defined(MSWIN) && (!defined(FEAT_GUI_MSWIN) || defined(VIMDLL))
 # ifdef VIMDLL
-	if (!gui.in_use)
+    if (!gui.in_use)
 # endif
-	    resize_console_buf();
-#endif
-    }
+	resize_console_buf();
+#endif
 }
 
 /*
@@ -3314,20 +3313,20 @@ nv_hat(cmdarg_T *cap)
     static void
 nv_Zet(cmdarg_T *cap)
 {
-    if (!checkclearopq(cap->oap))
-    {
-	switch (cap->nchar)
-	{
-			// "ZZ": equivalent to ":x".
-	    case 'Z':	do_cmdline_cmd((char_u *)"x");
+    if (checkclearopq(cap->oap))
+	return;
+
+    switch (cap->nchar)
+    {
+	// "ZZ": equivalent to ":x".
+	case 'Z':	do_cmdline_cmd((char_u *)"x");
 			break;
 
 			// "ZQ": equivalent to ":q!" (Elvis compatible).
-	    case 'Q':	do_cmdline_cmd((char_u *)"q!");
+	case 'Q':	do_cmdline_cmd((char_u *)"q!");
 			break;
 
-	    default:	clearopbeep(cap->oap);
-	}
+	default:	clearopbeep(cap->oap);
     }
 }
 
@@ -3982,15 +3981,14 @@ nv_up(cmdarg_T *cap)
 	// <S-Up> is page up
 	cap->arg = BACKWARD;
 	nv_page(cap);
-    }
-    else
-    {
-	cap->oap->motion_type = MLINE;
-	if (cursor_up(cap->count1, cap->oap->op_type == OP_NOP) == FAIL)
-	    clearopbeep(cap->oap);
-	else if (cap->arg)
-	    beginline(BL_WHITE | BL_FIX);
-    }
+	return;
+    }
+
+    cap->oap->motion_type = MLINE;
+    if (cursor_up(cap->count1, cap->oap->op_type == OP_NOP) == FAIL)
+	clearopbeep(cap->oap);
+    else if (cap->arg)
+	beginline(BL_WHITE | BL_FIX);
 }
 
 /*
@@ -4249,27 +4247,28 @@ nv_csearch(cmdarg_T *cap)
 
     cap->oap->motion_type = MCHAR;
     if (IS_SPECIAL(cap->nchar) || searchc(cap, t_cmd) == FAIL)
+    {
 	clearopbeep(cap->oap);
+	return;
+    }
+
+    curwin->w_set_curswant = TRUE;
+    // Include a Tab for "tx" and for "dfx".
+    if (gchar_cursor() == TAB && virtual_active() && cap->arg == FORWARD
+	    && (t_cmd || cap->oap->op_type != OP_NOP))
+    {
+	colnr_T	scol, ecol;
+
+	getvcol(curwin, &curwin->w_cursor, &scol, NULL, &ecol);
+	curwin->w_cursor.coladd = ecol - scol;
+    }
     else
-    {
-	curwin->w_set_curswant = TRUE;
-	// Include a Tab for "tx" and for "dfx".
-	if (gchar_cursor() == TAB && virtual_active() && cap->arg == FORWARD
-		&& (t_cmd || cap->oap->op_type != OP_NOP))
-	{
-	    colnr_T	scol, ecol;
-
-	    getvcol(curwin, &curwin->w_cursor, &scol, NULL, &ecol);
-	    curwin->w_cursor.coladd = ecol - scol;
-	}
-	else
-	    curwin->w_cursor.coladd = 0;
-	adjust_for_sel(cap);
+	curwin->w_cursor.coladd = 0;
+    adjust_for_sel(cap);
 #ifdef FEAT_FOLDING
-	if ((fdo_flags & FDO_HOR) && KeyTyped && cap->oap->op_type == OP_NOP)
-	    foldOpenCursor();
-#endif
-    }
+    if ((fdo_flags & FDO_HOR) && KeyTyped && cap->oap->op_type == OP_NOP)
+	foldOpenCursor();
+#endif
 }
 
 /*
@@ -4654,17 +4653,18 @@ nv_brace(cmdarg_T *cap)
     curwin->w_set_curswant = TRUE;
 
     if (findsent(cap->arg, cap->count1) == FAIL)
+    {
 	clearopbeep(cap->oap);
-    else
-    {
-	// Don't leave the cursor on the NUL past end of line.
-	adjust_cursor(cap->oap);
-	curwin->w_cursor.coladd = 0;
+	return;
+    }
+
+    // Don't leave the cursor on the NUL past end of line.
+    adjust_cursor(cap->oap);
+    curwin->w_cursor.coladd = 0;
 #ifdef FEAT_FOLDING
-	if ((fdo_flags & FDO_BLOCK) && KeyTyped && cap->oap->op_type == OP_NOP)
-	    foldOpenCursor();
-#endif
-    }
+    if ((fdo_flags & FDO_BLOCK) && KeyTyped && cap->oap->op_type == OP_NOP)
+	foldOpenCursor();
+#endif
 }
 
 /*
@@ -4673,11 +4673,11 @@ nv_brace(cmdarg_T *cap)
     static void
 nv_mark(cmdarg_T *cap)
 {
-    if (!checkclearop(cap->oap))
-    {
-	if (setmark(cap->nchar) == FAIL)
-	    clearopbeep(cap->oap);
-    }
+    if (checkclearop(cap->oap))
+	return;
+
+    if (setmark(cap->nchar) == FAIL)
+	clearopbeep(cap->oap);
 }
 
 /*
@@ -4692,15 +4692,16 @@ nv_findpar(cmdarg_T *cap)
     cap->oap->use_reg_one = TRUE;
     curwin->w_set_curswant = TRUE;
     if (!findpar(&cap->oap->inclusive, cap->arg, cap->count1, NUL, FALSE))
+    {
 	clearopbeep(cap->oap);
-    else
-    {
-	curwin->w_cursor.coladd = 0;
+	return;
+    }
+
+    curwin->w_cursor.coladd = 0;
 #ifdef FEAT_FOLDING
-	if ((fdo_flags & FDO_BLOCK) && KeyTyped && cap->oap->op_type == OP_NOP)
-	    foldOpenCursor();
-#endif
-    }
+    if ((fdo_flags & FDO_BLOCK) && KeyTyped && cap->oap->op_type == OP_NOP)
+	foldOpenCursor();
+#endif
 }
 
 /*
@@ -4726,18 +4727,18 @@ nv_undo(cmdarg_T *cap)
     static void
 nv_kundo(cmdarg_T *cap)
 {
-    if (!checkclearopq(cap->oap))
-    {
+    if (checkclearopq(cap->oap))
+	return;
+
 #ifdef FEAT_JOB_CHANNEL
-	if (bt_prompt(curbuf))
-	{
-	    clearopbeep(cap->oap);
-	    return;
-	}
-#endif
-	u_undo((int)cap->count1);
-	curwin->w_set_curswant = TRUE;
-    }
+    if (bt_prompt(curbuf))
+    {
+	clearopbeep(cap->oap);
+	return;
+    }
+#endif
+    u_undo((int)cap->count1);
+    curwin->w_set_curswant = TRUE;
 }
 
 /*
@@ -5008,17 +5009,19 @@ nv_Replace(cmdarg_T *cap)
 	VIsual_mode_orig = VIsual_mode; // remember original area for gv
 	VIsual_mode = 'V';
 	nv_operator(cap);
-    }
-    else if (!checkclearopq(cap->oap))
-    {
-	if (!curbuf->b_p_ma)
-	    emsg(_(e_cannot_make_changes_modifiable_is_off));
-	else
-	{
-	    if (virtual_active())
-		coladvance(getviscol());
-	    invoke_edit(cap, FALSE, cap->arg ? 'V' : 'R', FALSE);
-	}
+	return;
+    }
+
+    if (checkclearopq(cap->oap))
+	return;
+
+    if (!curbuf->b_p_ma)
+	emsg(_(e_cannot_make_changes_modifiable_is_off));
+    else
+    {
+	if (virtual_active())
+	    coladvance(getviscol());
+	invoke_edit(cap, FALSE, cap->arg ? 'V' : 'R', FALSE);
     }
 }
 
@@ -5033,21 +5036,23 @@ nv_vreplace(cmdarg_T *cap)
 	cap->cmdchar = 'r';
 	cap->nchar = cap->extra_char;
 	nv_replace(cap);	// Do same as "r" in Visual mode for now
-    }
-    else if (!checkclearopq(cap->oap))
-    {
-	if (!curbuf->b_p_ma)
-	    emsg(_(e_cannot_make_changes_modifiable_is_off));
-	else
-	{
-	    if (cap->extra_char == Ctrl_V)	// get another character
-		cap->extra_char = get_literal(FALSE);
-	    stuffcharReadbuff(cap->extra_char);
-	    stuffcharReadbuff(ESC);
-	    if (virtual_active())
-		coladvance(getviscol());
-	    invoke_edit(cap, TRUE, 'v', FALSE);
-	}
+	return;
+    }
+
+    if (checkclearopq(cap->oap))
+	return;
+
+    if (!curbuf->b_p_ma)
+	emsg(_(e_cannot_make_changes_modifiable_is_off));
+    else
+    {
+	if (cap->extra_char == Ctrl_V)	// get another character
+	    cap->extra_char = get_literal(FALSE);
+	stuffcharReadbuff(cap->extra_char);
+	stuffcharReadbuff(ESC);
+	if (virtual_active())
+	    coladvance(getviscol());
+	invoke_edit(cap, TRUE, 'v', FALSE);
     }
 }
 
@@ -5345,44 +5350,44 @@ nv_pcmark(cmdarg_T *cap)
     int		old_KeyTyped = KeyTyped;    // getting file may reset it
 #endif
 
-    if (!checkclearopq(cap->oap))
-    {
-	if (cap->cmdchar == TAB && mod_mask == MOD_MASK_CTRL)
-	{
-	    if (goto_tabpage_lastused() == FAIL)
-		clearopbeep(cap->oap);
-	    return;
-	}
-	if (cap->cmdchar == 'g')
-	    pos = movechangelist((int)cap->count1);
+    if (checkclearopq(cap->oap))
+	return;
+
+    if (cap->cmdchar == TAB && mod_mask == MOD_MASK_CTRL)
+    {
+	if (goto_tabpage_lastused() == FAIL)
+	    clearopbeep(cap->oap);
+	return;
+    }
+    if (cap->cmdchar == 'g')
+	pos = movechangelist((int)cap->count1);
+    else
+	pos = movemark((int)cap->count1);
+    if (pos == (pos_T *)-1)		// jump to other file
+    {
+	curwin->w_set_curswant = TRUE;
+	check_cursor();
+    }
+    else if (pos != NULL)		    // can jump
+	nv_cursormark(cap, FALSE, pos);
+    else if (cap->cmdchar == 'g')
+    {
+	if (curbuf->b_changelistlen == 0)
+	    emsg(_(e_changelist_is_empty));
+	else if (cap->count1 < 0)
+	    emsg(_(e_at_start_of_changelist));
 	else
-	    pos = movemark((int)cap->count1);
-	if (pos == (pos_T *)-1)		// jump to other file
-	{
-	    curwin->w_set_curswant = TRUE;
-	    check_cursor();
-	}
-	else if (pos != NULL)		    // can jump
-	    nv_cursormark(cap, FALSE, pos);
-	else if (cap->cmdchar == 'g')
-	{
-	    if (curbuf->b_changelistlen == 0)
-		emsg(_(e_changelist_is_empty));
-	    else if (cap->count1 < 0)
-		emsg(_(e_at_start_of_changelist));
-	    else
-		emsg(_(e_at_end_of_changelist));
-	}
-	else
-	    clearopbeep(cap->oap);
+	    emsg(_(e_at_end_of_changelist));
+    }
+    else
+	clearopbeep(cap->oap);
 # ifdef FEAT_FOLDING
-	if (cap->oap->op_type == OP_NOP
-		&& (pos == (pos_T *)-1 || lnum != curwin->w_cursor.lnum)
-		&& (fdo_flags & FDO_MARK)
-		&& old_KeyTyped)
-	    foldOpenCursor();
+    if (cap->oap->op_type == OP_NOP
+	    && (pos == (pos_T *)-1 || lnum != curwin->w_cursor.lnum)
+	    && (fdo_flags & FDO_MARK)
+	    && old_KeyTyped)
+	foldOpenCursor();
 # endif
-    }
 }
 
 /*
@@ -6237,41 +6242,41 @@ n_opencmd(cmdarg_T *cap)
     linenr_T	oldline = curwin->w_cursor.lnum;
 #endif
 
-    if (!checkclearopq(cap->oap))
-    {
+    if (checkclearopq(cap->oap))
+	return;
+
 #ifdef FEAT_FOLDING
-	if (cap->cmdchar == 'O')
-	    // Open above the first line of a folded sequence of lines
-	    (void)hasFolding(curwin->w_cursor.lnum,
-						&curwin->w_cursor.lnum, NULL);
-	else
-	    // Open below the last line of a folded sequence of lines
-	    (void)hasFolding(curwin->w_cursor.lnum,
-						NULL, &curwin->w_cursor.lnum);
-#endif
-	if (u_save((linenr_T)(curwin->w_cursor.lnum -
-					       (cap->cmdchar == 'O' ? 1 : 0)),
-		   (linenr_T)(curwin->w_cursor.lnum +
-					       (cap->cmdchar == 'o' ? 1 : 0))
-		       ) == OK
-		&& open_line(cap->cmdchar == 'O' ? BACKWARD : FORWARD,
-			 has_format_option(FO_OPEN_COMS) ? OPENLINE_DO_COM : 0,
-								0, NULL) == OK)
-	{
+    if (cap->cmdchar == 'O')
+	// Open above the first line of a folded sequence of lines
+	(void)hasFolding(curwin->w_cursor.lnum,
+		&curwin->w_cursor.lnum, NULL);
+    else
+	// Open below the last line of a folded sequence of lines
+	(void)hasFolding(curwin->w_cursor.lnum,
+		NULL, &curwin->w_cursor.lnum);
+#endif
+    if (u_save((linenr_T)(curwin->w_cursor.lnum -
+		    (cap->cmdchar == 'O' ? 1 : 0)),
+		(linenr_T)(curwin->w_cursor.lnum +
+		    (cap->cmdchar == 'o' ? 1 : 0))
+	      ) == OK
+	    && open_line(cap->cmdchar == 'O' ? BACKWARD : FORWARD,
+		has_format_option(FO_OPEN_COMS) ? OPENLINE_DO_COM : 0,
+		0, NULL) == OK)
+    {
 #ifdef FEAT_CONCEAL
-	    if (curwin->w_p_cole > 0 && oldline != curwin->w_cursor.lnum)
-		redrawWinline(curwin, oldline);
+	if (curwin->w_p_cole > 0 && oldline != curwin->w_cursor.lnum)
+	    redrawWinline(curwin, oldline);
 #endif
 #ifdef FEAT_SYN_HL
-	    if (curwin->w_p_cul)
-		// force redraw of cursorline
-		curwin->w_valid &= ~VALID_CROW;
-#endif
-	    // When '#' is in 'cpoptions' ignore the count.
-	    if (vim_strchr(p_cpo, CPO_HASH) != NULL)
-		cap->count1 = 1;
-	    invoke_edit(cap, FALSE, cap->cmdchar, TRUE);
-	}
+	if (curwin->w_p_cul)
+	    // force redraw of cursorline
+	    curwin->w_valid &= ~VALID_CROW;
+#endif
+	// When '#' is in 'cpoptions' ignore the count.
+	if (vim_strchr(p_cpo, CPO_HASH) != NULL)
+	    cap->count1 = 1;
+	invoke_edit(cap, FALSE, cap->cmdchar, TRUE);
     }
 }
 
@@ -6281,14 +6286,14 @@ n_opencmd(cmdarg_T *cap)
     static void
 nv_dot(cmdarg_T *cap)
 {
-    if (!checkclearopq(cap->oap))
-    {
-	// If "restart_edit" is TRUE, the last but one command is repeated
-	// instead of the last command (inserting text). This is used for
-	// CTRL-O <.> in insert mode.
-	if (start_redo(cap->count0, restart_edit != 0 && !arrow_used) == FAIL)
-	    clearopbeep(cap->oap);
-    }
+    if (checkclearopq(cap->oap))
+	return;
+
+    // If "restart_edit" is TRUE, the last but one command is repeated
+    // instead of the last command (inserting text). This is used for
+    // CTRL-O <.> in insert mode.
+    if (start_redo(cap->count0, restart_edit != 0 && !arrow_used) == FAIL)
+	clearopbeep(cap->oap);
 }
 
 /*
@@ -6316,11 +6321,11 @@ nv_redo_or_register(cmdarg_T *cap)
 	return;
     }
 
-    if (!checkclearopq(cap->oap))
-    {
-	u_redo((int)cap->count1);
-	curwin->w_set_curswant = TRUE;
-    }
+    if (checkclearopq(cap->oap))
+	return;
+
+    u_redo((int)cap->count1);
+    curwin->w_set_curswant = TRUE;
 }
 
 /*
@@ -6336,12 +6341,14 @@ nv_Undo(cmdarg_T *cap)
 	cap->cmdchar = 'g';
 	cap->nchar = 'U';
 	nv_operator(cap);
-    }
-    else if (!checkclearopq(cap->oap))
-    {
-	u_undoline();
-	curwin->w_set_curswant = TRUE;
-    }
+	return;
+    }
+
+    if (checkclearopq(cap->oap))
+	return;
+
+    u_undoline();
+    curwin->w_set_curswant = TRUE;
 }
 
 /*
@@ -7146,25 +7153,27 @@ nv_record(cmdarg_T *cap)
 	cap->cmdchar = 'g';
 	cap->nchar = 'q';
 	nv_operator(cap);
-    }
-    else if (!checkclearop(cap->oap))
-    {
-	if (cap->nchar == ':' || cap->nchar == '/' || cap->nchar == '?')
+	return;
+    }
+
+    if (checkclearop(cap->oap))
+	return;
+
+    if (cap->nchar == ':' || cap->nchar == '/' || cap->nchar == '?')
+    {
+	if (cmdwin_type != 0)
 	{
-	    if (cmdwin_type != 0)
-	    {
-		emsg(_(e_cmdline_window_already_open));
-		return;
-	    }
-	    stuffcharReadbuff(cap->nchar);
-	    stuffcharReadbuff(K_CMDWIN);
+	    emsg(_(e_cmdline_window_already_open));
+	    return;
 	}
-	else
-	    // (stop) recording into a named register, unless executing a
-	    // register
-	    if (reg_executing == 0 && do_record(cap->nchar) == FAIL)
-		clearopbeep(cap->oap);
-    }
+	stuffcharReadbuff(cap->nchar);
+	stuffcharReadbuff(K_CMDWIN);
+    }
+    else
+	// (stop) recording into a named register, unless executing a
+	// register
+	if (reg_executing == 0 && do_record(cap->nchar) == FAIL)
+	    clearopbeep(cap->oap);
 }
 
 /*
@@ -7214,28 +7223,32 @@ nv_halfpage(cmdarg_T *cap)
 nv_join(cmdarg_T *cap)
 {
     if (VIsual_active)	// join the visual lines
+    {
 	nv_operator(cap);
-    else if (!checkclearop(cap->oap))
-    {
-	if (cap->count0 <= 1)
-	    cap->count0 = 2;	    // default for join is two lines!
-	if (curwin->w_cursor.lnum + cap->count0 - 1 >
-						   curbuf->b_ml.ml_line_count)
+	return;
+    }
+
+    if (checkclearop(cap->oap))
+	return;
+
+    if (cap->count0 <= 1)
+	cap->count0 = 2;	    // default for join is two lines!
+    if (curwin->w_cursor.lnum + cap->count0 - 1 >
+	    curbuf->b_ml.ml_line_count)
+    {
+	// can't join when on the last line
+	if (cap->count0 <= 2)
 	{
-	    // can't join when on the last line
-	    if (cap->count0 <= 2)
-	    {
-		clearopbeep(cap->oap);
-		return;
-	    }
-	    cap->count0 = curbuf->b_ml.ml_line_count
-						  - curwin->w_cursor.lnum + 1;
+	    clearopbeep(cap->oap);
+	    return;
 	}
-
-	prep_redo(cap->oap->regname, cap->count0,
-				     NUL, cap->cmdchar, NUL, NUL, cap->nchar);
-	(void)do_join(cap->count0, cap->nchar == NUL, TRUE, TRUE, TRUE);
-    }
+	cap->count0 = curbuf->b_ml.ml_line_count
+	    - curwin->w_cursor.lnum + 1;
+    }
+
+    prep_redo(cap->oap->regname, cap->count0,
+	    NUL, cap->cmdchar, NUL, NUL, cap->nchar);
+    (void)do_join(cap->count0, cap->nchar == NUL, TRUE, TRUE, TRUE);
 }
 
 /*
@@ -7273,132 +7286,133 @@ nv_put_opt(cmdarg_T *cap, int fix_indent
 	}
 	else
 #endif
-	clearopbeep(cap->oap);
-    }
+	    clearopbeep(cap->oap);
+	return;
+    }
+
 #ifdef FEAT_JOB_CHANNEL
-    else if (bt_prompt(curbuf) && !prompt_curpos_editable())
+    if (bt_prompt(curbuf) && !prompt_curpos_editable())
     {
 	clearopbeep(cap->oap);
-    }
-#endif
+	return;
+    }
+#endif
+
+    if (fix_indent)
+    {
+	dir = (cap->cmdchar == ']' && cap->nchar == 'p')
+	    ? FORWARD : BACKWARD;
+	flags |= PUT_FIXINDENT;
+    }
     else
-    {
-	if (fix_indent)
-	{
-	    dir = (cap->cmdchar == ']' && cap->nchar == 'p')
-							 ? FORWARD : BACKWARD;
-	    flags |= PUT_FIXINDENT;
-	}
-	else
-	    dir = (cap->cmdchar == 'P'
-		    || ((cap->cmdchar == 'g' || cap->cmdchar == 'z')
-			&& cap->nchar == 'P')) ? BACKWARD : FORWARD;
-	prep_redo_cmd(cap);
-	if (cap->cmdchar == 'g')
-	    flags |= PUT_CURSEND;
-	else if (cap->cmdchar == 'z')
-	    flags |= PUT_BLOCK_INNER;
-
-	if (VIsual_active)
-	{
-	    // Putting in Visual mode: The put text replaces the selected
-	    // text.  First delete the selected text, then put the new text.
-	    // Need to save and restore the registers that the delete
-	    // overwrites if the old contents is being put.
-	    was_visual = TRUE;
-	    regname = cap->oap->regname;
-	    keep_registers = cap->cmdchar == 'P';
+	dir = (cap->cmdchar == 'P'
+		|| ((cap->cmdchar == 'g' || cap->cmdchar == 'z')
+		    && cap->nchar == 'P')) ? BACKWARD : FORWARD;
+    prep_redo_cmd(cap);
+    if (cap->cmdchar == 'g')
+	flags |= PUT_CURSEND;
+    else if (cap->cmdchar == 'z')
+	flags |= PUT_BLOCK_INNER;
+
+    if (VIsual_active)
+    {
+	// Putting in Visual mode: The put text replaces the selected
+	// text.  First delete the selected text, then put the new text.
+	// Need to save and restore the registers that the delete
+	// overwrites if the old contents is being put.
+	was_visual = TRUE;
+	regname = cap->oap->regname;
+	keep_registers = cap->cmdchar == 'P';
 #ifdef FEAT_CLIPBOARD
-	    adjust_clip_reg(&regname);
-#endif
-	   if (regname == 0 || regname == '"'
-				     || VIM_ISDIGIT(regname) || regname == '-'
+	adjust_clip_reg(&regname);
+#endif
+	if (regname == 0 || regname == '"'
+		|| VIM_ISDIGIT(regname) || regname == '-'
 #ifdef FEAT_CLIPBOARD
-		    || (clip_unnamed && (regname == '*' || regname == '+'))
-#endif
-
-		    )
-	    {
-		// The delete is going to overwrite the register we want to
-		// put, save it first.
-		reg1 = get_register(regname, TRUE);
-	    }
-
-	    // Now delete the selected text. Avoid messages here.
-	    cap->cmdchar = 'd';
-	    cap->nchar = NUL;
-	    cap->oap->regname = keep_registers ? '_' : NUL;
-	    ++msg_silent;
-	    nv_operator(cap);
-	    do_pending_operator(cap, 0, FALSE);
-	    empty = (curbuf->b_ml.ml_flags & ML_EMPTY);
-	    --msg_silent;
-
-	    // delete PUT_LINE_BACKWARD;
-	    cap->oap->regname = regname;
-
-	    if (reg1 != NULL)
-	    {
-		// Delete probably changed the register we want to put, save
-		// it first. Then put back what was there before the delete.
-		reg2 = get_register(regname, FALSE);
-		put_register(regname, reg1);
-	    }
-
-	    // When deleted a linewise Visual area, put the register as
-	    // lines to avoid it joined with the next line.  When deletion was
-	    // characterwise, split a line when putting lines.
-	    if (VIsual_mode == 'V')
-		flags |= PUT_LINE;
-	    else if (VIsual_mode == 'v')
-		flags |= PUT_LINE_SPLIT;
-	    if (VIsual_mode == Ctrl_V && dir == FORWARD)
-		flags |= PUT_LINE_FORWARD;
-	    dir = BACKWARD;
-	    if ((VIsual_mode != 'V'
-			&& curwin->w_cursor.col < curbuf->b_op_start.col)
-		    || (VIsual_mode == 'V'
-			&& curwin->w_cursor.lnum < curbuf->b_op_start.lnum))
-		// cursor is at the end of the line or end of file, put
-		// forward.
-		dir = FORWARD;
-	    // May have been reset in do_put().
-	    VIsual_active = TRUE;
+		|| (clip_unnamed && (regname == '*' || regname == '+'))
+#endif
+
+	   )
+	{
+	    // The delete is going to overwrite the register we want to
+	    // put, save it first.
+	    reg1 = get_register(regname, TRUE);
+	}
+
+	// Now delete the selected text. Avoid messages here.
+	cap->cmdchar = 'd';
+	cap->nchar = NUL;
+	cap->oap->regname = keep_registers ? '_' : NUL;
+	++msg_silent;
+	nv_operator(cap);
+	do_pending_operator(cap, 0, FALSE);
+	empty = (curbuf->b_ml.ml_flags & ML_EMPTY);
+	--msg_silent;
+
+	// delete PUT_LINE_BACKWARD;
+	cap->oap->regname = regname;
+
+	if (reg1 != NULL)
+	{
+	    // Delete probably changed the register we want to put, save
+	    // it first. Then put back what was there before the delete.
+	    reg2 = get_register(regname, FALSE);
+	    put_register(regname, reg1);
 	}
-	do_put(cap->oap->regname, NULL, dir, cap->count1, flags);
-
-	// If a register was saved, put it back now.
-	if (reg2 != NULL)
-	    put_register(regname, reg2);
-
-	// What to reselect with "gv"?  Selecting the just put text seems to
-	// be the most useful, since the original text was removed.
-	if (was_visual)
+
+	// When deleted a linewise Visual area, put the register as
+	// lines to avoid it joined with the next line.  When deletion was
+	// characterwise, split a line when putting lines.
+	if (VIsual_mode == 'V')
+	    flags |= PUT_LINE;
+	else if (VIsual_mode == 'v')
+	    flags |= PUT_LINE_SPLIT;
+	if (VIsual_mode == Ctrl_V && dir == FORWARD)
+	    flags |= PUT_LINE_FORWARD;
+	dir = BACKWARD;
+	if ((VIsual_mode != 'V'
+		    && curwin->w_cursor.col < curbuf->b_op_start.col)
+		|| (VIsual_mode == 'V'
+		    && curwin->w_cursor.lnum < curbuf->b_op_start.lnum))
+	    // cursor is at the end of the line or end of file, put
+	    // forward.
+	    dir = FORWARD;
+	// May have been reset in do_put().
+	VIsual_active = TRUE;
+    }
+    do_put(cap->oap->regname, NULL, dir, cap->count1, flags);
+
+    // If a register was saved, put it back now.
+    if (reg2 != NULL)
+	put_register(regname, reg2);
+
+    // What to reselect with "gv"?  Selecting the just put text seems to
+    // be the most useful, since the original text was removed.
+    if (was_visual)
+    {
+	curbuf->b_visual.vi_start = curbuf->b_op_start;
+	curbuf->b_visual.vi_end = curbuf->b_op_end;
+	// need to adjust cursor position
+	if (*p_sel == 'e')
+	    inc(&curbuf->b_visual.vi_end);
+    }
+
+    // When all lines were selected and deleted do_put() leaves an empty
+    // line that needs to be deleted now.
+    if (empty && *ml_get(curbuf->b_ml.ml_line_count) == NUL)
+    {
+	ml_delete_flags(curbuf->b_ml.ml_line_count, ML_DEL_MESSAGE);
+	deleted_lines(curbuf->b_ml.ml_line_count + 1, 1);
+
+	// If the cursor was in that line, move it to the end of the last
+	// line.
+	if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count)
 	{
-	    curbuf->b_visual.vi_start = curbuf->b_op_start;
-	    curbuf->b_visual.vi_end = curbuf->b_op_end;
-	    // need to adjust cursor position
-	    if (*p_sel == 'e')
-		inc(&curbuf->b_visual.vi_end);
+	    curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
+	    coladvance((colnr_T)MAXCOL);
 	}
-
-	// When all lines were selected and deleted do_put() leaves an empty
-	// line that needs to be deleted now.
-	if (empty && *ml_get(curbuf->b_ml.ml_line_count) == NUL)
-	{
-	    ml_delete_flags(curbuf->b_ml.ml_line_count, ML_DEL_MESSAGE);
-	    deleted_lines(curbuf->b_ml.ml_line_count + 1, 1);
-
-	    // If the cursor was in that line, move it to the end of the last
-	    // line.
-	    if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count)
-	    {
-		curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
-		coladvance((colnr_T)MAXCOL);
-	    }
-	}
-	auto_format(FALSE, TRUE);
-    }
+    }
+    auto_format(FALSE, TRUE);
 }
 
 /*
--- a/src/ops.c
+++ b/src/ops.c
@@ -989,11 +989,11 @@ mb_adjust_opend(oparg_T *oap)
 {
     char_u	*p;
 
-    if (oap->inclusive)
-    {
-	p = ml_get(oap->end.lnum);
-	oap->end.col += mb_tail_off(p, p + oap->end.col);
-    }
+    if (!oap->inclusive)
+	return;
+
+    p = ml_get(oap->end.lnum);
+    oap->end.col += mb_tail_off(p, p + oap->end.col);
 }
 
 /*
@@ -1869,22 +1869,23 @@ adjust_cursor_eol(void)
 {
     unsigned int cur_ve_flags = get_ve_flags();
 
-    if (curwin->w_cursor.col > 0
-	    && gchar_cursor() == NUL
-	    && (cur_ve_flags & VE_ONEMORE) == 0
-	    && !(restart_edit || (State & MODE_INSERT)))
+    int adj_cursor = (curwin->w_cursor.col > 0
+				&& gchar_cursor() == NUL
+				&& (cur_ve_flags & VE_ONEMORE) == 0
+				&& !(restart_edit || (State & MODE_INSERT)));
+    if (!adj_cursor)
+	return;
+
+    // Put the cursor on the last character in the line.
+    dec_cursor();
+
+    if (cur_ve_flags == VE_ALL)
     {
-	// Put the cursor on the last character in the line.
-	dec_cursor();
-
-	if (cur_ve_flags == VE_ALL)
-	{
-	    colnr_T	    scol, ecol;
-
-	    // Coladd is set to the width of the last character.
-	    getvcol(curwin, &curwin->w_cursor, &scol, NULL, &ecol);
-	    curwin->w_cursor.coladd = ecol - scol + 1;
-	}
+	colnr_T	    scol, ecol;
+
+	// Coladd is set to the width of the last character.
+	getvcol(curwin, &curwin->w_cursor, &scol, NULL, &ecol);
+	curwin->w_cursor.coladd = ecol - scol + 1;
     }
 }
 
@@ -2235,12 +2236,12 @@ reset_lbr(void)
     static void
 restore_lbr(int lbr_saved)
 {
-    if (!curwin->w_p_lbr && lbr_saved)
-    {
-	// changing 'linebreak' may require w_virtcol to be updated
-	curwin->w_p_lbr = TRUE;
-	curwin->w_valid &= ~(VALID_WROW|VALID_WCOL|VALID_VIRTCOL);
-    }
+    if (curwin->w_p_lbr || !lbr_saved)
+	return;
+
+    // changing 'linebreak' may require w_virtcol to be updated
+    curwin->w_p_lbr = TRUE;
+    curwin->w_valid &= ~(VALID_WROW|VALID_WCOL|VALID_VIRTCOL);
 }
 #endif
 
--- a/src/option.c
+++ b/src/option.c
@@ -672,17 +672,17 @@ set_string_default_esc(char *name, char_
 	p = vim_strsave_escaped(val, (char_u *)" ");
     else
 	p = vim_strsave(val);
-    if (p != NULL)		// we don't want a NULL
-    {
-	opt_idx = findoption((char_u *)name);
-	if (opt_idx >= 0)
-	{
-	    if (options[opt_idx].flags & P_DEF_ALLOCED)
-		vim_free(options[opt_idx].def_val[VI_DEFAULT]);
-	    options[opt_idx].def_val[VI_DEFAULT] = p;
-	    options[opt_idx].flags |= P_DEF_ALLOCED;
-	}
-    }
+    if (p == NULL)		// we don't want a NULL
+	return;
+
+    opt_idx = findoption((char_u *)name);
+    if (opt_idx < 0)
+	return;
+
+    if (options[opt_idx].flags & P_DEF_ALLOCED)
+	vim_free(options[opt_idx].def_val[VI_DEFAULT]);
+    options[opt_idx].def_val[VI_DEFAULT] = p;
+    options[opt_idx].flags |= P_DEF_ALLOCED;
 }
 
     void
@@ -1112,31 +1112,31 @@ set_helplang_default(char_u *lang)
     if (lang == NULL || STRLEN(lang) < 2)	// safety check
 	return;
     idx = findoption((char_u *)"hlg");
-    if (idx >= 0 && !(options[idx].flags & P_WAS_SET))
-    {
-	if (options[idx].flags & P_ALLOCED)
-	    free_string_option(p_hlg);
-	p_hlg = vim_strsave(lang);
-	if (p_hlg == NULL)
-	    p_hlg = empty_option;
-	else
-	{
-	    // zh_CN becomes "cn", zh_TW becomes "tw"
-	    if (STRNICMP(p_hlg, "zh_", 3) == 0 && STRLEN(p_hlg) >= 5)
-	    {
-		p_hlg[0] = TOLOWER_ASC(p_hlg[3]);
-		p_hlg[1] = TOLOWER_ASC(p_hlg[4]);
-	    }
-	    // any C like setting, such as C.UTF-8, becomes "en"
-	    else if (STRLEN(p_hlg) >= 1 && *p_hlg == 'C')
-	    {
-		p_hlg[0] = 'e';
-		p_hlg[1] = 'n';
-	    }
-	    p_hlg[2] = NUL;
-	}
-	options[idx].flags |= P_ALLOCED;
-    }
+    if (idx < 0 || (options[idx].flags & P_WAS_SET))
+	return;
+
+    if (options[idx].flags & P_ALLOCED)
+	free_string_option(p_hlg);
+    p_hlg = vim_strsave(lang);
+    if (p_hlg == NULL)
+	p_hlg = empty_option;
+    else
+    {
+	// zh_CN becomes "cn", zh_TW becomes "tw"
+	if (STRNICMP(p_hlg, "zh_", 3) == 0 && STRLEN(p_hlg) >= 5)
+	{
+	    p_hlg[0] = TOLOWER_ASC(p_hlg[3]);
+	    p_hlg[1] = TOLOWER_ASC(p_hlg[4]);
+	}
+	// any C like setting, such as C.UTF-8, becomes "en"
+	else if (STRLEN(p_hlg) >= 1 && *p_hlg == 'C')
+	{
+	    p_hlg[0] = 'e';
+	    p_hlg[1] = 'n';
+	}
+	p_hlg[2] = NUL;
+    }
+    options[idx].flags |= P_ALLOCED;
 }
 #endif
 
@@ -1171,17 +1171,19 @@ set_title_defaults(void)
 	p_title = val;
     }
     idx1 = findoption((char_u *)"icon");
-    if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET))
-    {
+    if (idx1 < 0 || (options[idx1].flags & P_WAS_SET))
+    {
+	return;
+    }
+
 #ifdef FEAT_GUI
-	if (gui.starting || gui.in_use)
-	    val = TRUE;
-	else
-#endif
-	    val = mch_can_restore_icon();
-	options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
-	p_icon = val;
-    }
+    if (gui.starting || gui.in_use)
+	val = TRUE;
+    else
+#endif
+	val = mch_can_restore_icon();
+    options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
+    p_icon = val;
 }
 
     void
@@ -7084,12 +7086,11 @@ reset_option_was_set(char_u *name)
 {
     int idx = findoption(name);
 
-    if (idx >= 0)
-    {
-	options[idx].flags &= ~P_WAS_SET;
-	return OK;
-    }
-    return FAIL;
+    if (idx < 0)
+	return FAIL;
+
+    options[idx].flags &= ~P_WAS_SET;
+    return OK;
 }
 
 /*
--- a/src/optionstr.c
+++ b/src/optionstr.c
@@ -155,42 +155,42 @@ trigger_optionset_string(
 	char_u  *newval)
 {
     // Don't do this recursively.
-    if (oldval != NULL && newval != NULL
-				    && *get_vim_var_str(VV_OPTION_TYPE) == NUL)
-    {
-	char_u buf_type[7];
+    if (oldval == NULL || newval == NULL
+				    || *get_vim_var_str(VV_OPTION_TYPE) != NUL)
+	return;
 
-	sprintf((char *)buf_type, "%s",
+    char_u buf_type[7];
+
+    sprintf((char *)buf_type, "%s",
 	    (opt_flags & OPT_LOCAL) ? "local" : "global");
-	set_vim_var_string(VV_OPTION_OLD, oldval, -1);
-	set_vim_var_string(VV_OPTION_NEW, newval, -1);
-	set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
-	if (opt_flags & OPT_LOCAL)
-	{
-	    set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"setlocal", -1);
-	    set_vim_var_string(VV_OPTION_OLDLOCAL, oldval, -1);
-	}
-	if (opt_flags & OPT_GLOBAL)
-	{
-	    set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"setglobal", -1);
-	    set_vim_var_string(VV_OPTION_OLDGLOBAL, oldval, -1);
-	}
-	if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
-	{
-	    set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"set", -1);
-	    set_vim_var_string(VV_OPTION_OLDLOCAL, oldval_l, -1);
-	    set_vim_var_string(VV_OPTION_OLDGLOBAL, oldval_g, -1);
-	}
-	if (opt_flags & OPT_MODELINE)
-	{
-	    set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"modeline", -1);
-	    set_vim_var_string(VV_OPTION_OLDLOCAL, oldval, -1);
-	}
-	apply_autocmds(EVENT_OPTIONSET,
-		       get_option_fullname(opt_idx), NULL, FALSE,
-		       NULL);
-	reset_v_option_vars();
+    set_vim_var_string(VV_OPTION_OLD, oldval, -1);
+    set_vim_var_string(VV_OPTION_NEW, newval, -1);
+    set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
+    if (opt_flags & OPT_LOCAL)
+    {
+	set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"setlocal", -1);
+	set_vim_var_string(VV_OPTION_OLDLOCAL, oldval, -1);
+    }
+    if (opt_flags & OPT_GLOBAL)
+    {
+	set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"setglobal", -1);
+	set_vim_var_string(VV_OPTION_OLDGLOBAL, oldval, -1);
     }
+    if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
+    {
+	set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"set", -1);
+	set_vim_var_string(VV_OPTION_OLDLOCAL, oldval_l, -1);
+	set_vim_var_string(VV_OPTION_OLDGLOBAL, oldval_g, -1);
+    }
+    if (opt_flags & OPT_MODELINE)
+    {
+	set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"modeline", -1);
+	set_vim_var_string(VV_OPTION_OLDLOCAL, oldval, -1);
+    }
+    apply_autocmds(EVENT_OPTIONSET,
+	    get_option_fullname(opt_idx), NULL, FALSE,
+	    NULL);
+    reset_v_option_vars();
 }
 #endif
 
@@ -387,45 +387,45 @@ set_string_option_direct(
 	return;
 
     s = vim_strsave(val);
-    if (s != NULL)
-    {
-	varp = (char_u **)get_option_varp_scope(idx,
-					       both ? OPT_LOCAL : opt_flags);
-	if ((opt_flags & OPT_FREE) && (get_option_flags(idx) & P_ALLOCED))
-	    free_string_option(*varp);
-	*varp = s;
+    if (s == NULL)
+	return;
+
+    varp = (char_u **)get_option_varp_scope(idx,
+	    both ? OPT_LOCAL : opt_flags);
+    if ((opt_flags & OPT_FREE) && (get_option_flags(idx) & P_ALLOCED))
+	free_string_option(*varp);
+    *varp = s;
+
+    // For buffer/window local option may also set the global value.
+    if (both)
+	set_string_option_global(idx, varp);
+
+    set_option_flag(idx, P_ALLOCED);
 
-	// For buffer/window local option may also set the global value.
-	if (both)
-	    set_string_option_global(idx, varp);
+    // When setting both values of a global option with a local value,
+    // make the local value empty, so that the global value is used.
+    if (is_global_local_option(idx) && both)
+    {
+	free_string_option(*varp);
+	*varp = empty_option;
+    }
+# ifdef FEAT_EVAL
+    if (set_sid != SID_NONE)
+    {
+	sctx_T script_ctx;
 
-	set_option_flag(idx, P_ALLOCED);
-
-	// When setting both values of a global option with a local value,
-	// make the local value empty, so that the global value is used.
-	if (is_global_local_option(idx) && both)
+	if (set_sid == 0)
+	    script_ctx = current_sctx;
+	else
 	{
-	    free_string_option(*varp);
-	    *varp = empty_option;
+	    script_ctx.sc_sid = set_sid;
+	    script_ctx.sc_seq = 0;
+	    script_ctx.sc_lnum = 0;
+	    script_ctx.sc_version = 1;
 	}
-# ifdef FEAT_EVAL
-	if (set_sid != SID_NONE)
-	{
-	    sctx_T script_ctx;
-
-	    if (set_sid == 0)
-		script_ctx = current_sctx;
-	    else
-	    {
-		script_ctx.sc_sid = set_sid;
-		script_ctx.sc_seq = 0;
-		script_ctx.sc_lnum = 0;
-		script_ctx.sc_version = 1;
-	    }
-	    set_option_sctx_idx(idx, opt_flags, script_ctx);
-	}
+	set_option_sctx_idx(idx, opt_flags, script_ctx);
+    }
 # endif
-    }
 }
 
 /*
@@ -507,54 +507,54 @@ set_string_option(
 	return NULL;
 
     s = vim_strsave(value == NULL ? (char_u *)"" : value);
-    if (s != NULL)
+    if (s == NULL)
+	return NULL;
+
+    varp = (char_u **)get_option_varp_scope(opt_idx,
+	    (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
+	    ? (is_global_local_option(opt_idx)
+		? OPT_GLOBAL : OPT_LOCAL)
+	    : opt_flags);
+    oldval = *varp;
+#if defined(FEAT_EVAL)
+    if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
     {
-	varp = (char_u **)get_option_varp_scope(opt_idx,
-		(opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
-		    ? (is_global_local_option(opt_idx)
-			? OPT_GLOBAL : OPT_LOCAL)
-		    : opt_flags);
-	oldval = *varp;
-#if defined(FEAT_EVAL)
-	if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
-	{
-	    oldval_l = *(char_u **)get_option_varp_scope(opt_idx, OPT_LOCAL);
-	    oldval_g = *(char_u **)get_option_varp_scope(opt_idx, OPT_GLOBAL);
-	}
+	oldval_l = *(char_u **)get_option_varp_scope(opt_idx, OPT_LOCAL);
+	oldval_g = *(char_u **)get_option_varp_scope(opt_idx, OPT_GLOBAL);
+    }
 #endif
-	*varp = s;
+    *varp = s;
 
 #if defined(FEAT_EVAL)
-	if (!starting
+    if (!starting
 # ifdef FEAT_CRYPT
-		&& !is_crypt_key_option(opt_idx)
+	    && !is_crypt_key_option(opt_idx)
 # endif
-		)
-	{
-	    if (oldval_l != NULL)
-		saved_oldval_l = vim_strsave(oldval_l);
-	    if (oldval_g != NULL)
-		saved_oldval_g = vim_strsave(oldval_g);
-	    saved_oldval = vim_strsave(oldval);
-	    saved_newval = vim_strsave(s);
-	}
+       )
+    {
+	if (oldval_l != NULL)
+	    saved_oldval_l = vim_strsave(oldval_l);
+	if (oldval_g != NULL)
+	    saved_oldval_g = vim_strsave(oldval_g);
+	saved_oldval = vim_strsave(oldval);
+	saved_newval = vim_strsave(s);
+    }
 #endif
-	if ((errmsg = did_set_string_option(opt_idx, varp, oldval, NULL,
-					   opt_flags, &value_checked)) == NULL)
-	    did_set_option(opt_idx, opt_flags, TRUE, value_checked);
+    if ((errmsg = did_set_string_option(opt_idx, varp, oldval, NULL,
+		    opt_flags, &value_checked)) == NULL)
+	did_set_option(opt_idx, opt_flags, TRUE, value_checked);
 
 #if defined(FEAT_EVAL)
-	// call autocommand after handling side effects
-	if (errmsg == NULL)
-	    trigger_optionset_string(opt_idx, opt_flags,
-				   saved_oldval, saved_oldval_l,
-				   saved_oldval_g, saved_newval);
-	vim_free(saved_oldval);
-	vim_free(saved_oldval_l);
-	vim_free(saved_oldval_g);
-	vim_free(saved_newval);
+    // call autocommand after handling side effects
+    if (errmsg == NULL)
+	trigger_optionset_string(opt_idx, opt_flags,
+		saved_oldval, saved_oldval_l,
+		saved_oldval_g, saved_newval);
+    vim_free(saved_oldval);
+    vim_free(saved_oldval_l);
+    vim_free(saved_oldval_g);
+    vim_free(saved_newval);
 #endif
-    }
     return errmsg;
 }
 
--- a/src/os_amiga.c
+++ b/src/os_amiga.c
@@ -234,13 +234,13 @@ mch_delay(long msec, int flags)
     void	    Delay(long);
 #endif
 
-    if (msec > 0)
-    {
-	if (flags & MCH_DELAY_IGNOREINPUT)
-	    Delay(msec / 20L);	    // Delay works with 20 msec intervals
-	else
-	    WaitForChar(raw_in, msec * 1000L);
-    }
+    if (msec <= 0)
+	return;
+
+    if (flags & MCH_DELAY_IGNOREINPUT)
+	Delay(msec / 20L);	    // Delay works with 20 msec intervals
+    else
+	WaitForChar(raw_in, msec * 1000L);
 }
 
 /*
@@ -577,18 +577,18 @@ fname_case(
     size_t		    flen;
 
     fib = get_fib(name);
-    if (fib != NULL)
-    {
-	flen = STRLEN(name);
-	// TODO: Check if this fix applies to AmigaOS < 4 too.
+    if (fib == NULL)
+	return;
+
+    flen = STRLEN(name);
+    // TODO: Check if this fix applies to AmigaOS < 4 too.
 #ifdef __amigaos4__
-	if (fib->fib_DirEntryType == ST_ROOT)
-	    strcat(fib->fib_FileName, ":");
+    if (fib->fib_DirEntryType == ST_ROOT)
+	strcat(fib->fib_FileName, ":");
 #endif
-	if (flen == strlen(fib->fib_FileName))	// safety check
-	    mch_memmove(name, fib->fib_FileName, flen);
-	free_fib(fib);
-    }
+    if (flen == strlen(fib->fib_FileName))	// safety check
+	mch_memmove(name, fib->fib_FileName, flen);
+    free_fib(fib);
 }
 
 /*
@@ -609,17 +609,17 @@ get_fib(char_u *fname)
 #else
     fib = ALLOC_ONE(struct FileInfoBlock);
 #endif
-    if (fib != NULL)
+    if (fib == NULL)
+	return;
+
+    flock = Lock((UBYTE *)fname, (long)ACCESS_READ);
+    if (flock == (BPTR)NULL || !Examine(flock, fib))
     {
-	flock = Lock((UBYTE *)fname, (long)ACCESS_READ);
-	if (flock == (BPTR)NULL || !Examine(flock, fib))
-	{
-	    free_fib(fib);  // in case of an error the memory is freed here
-	    fib = NULL;
-	}
-	if (flock)
-	    UnLock(flock);
+	free_fib(fib);  // in case of an error the memory is freed here
+	fib = NULL;
     }
+    if (flock)
+	UnLock(flock);
     return fib;
 }
 
@@ -815,11 +815,11 @@ mch_getperm(char_u *name)
     long		    retval = -1;
 
     fib = get_fib(name);
-    if (fib != NULL)
-    {
-	retval = fib->fib_Protection;
-	free_fib(fib);
-    }
+    if (fib == NULL)
+	return -1;
+
+    retval = fib->fib_Protection;
+    free_fib(fib);
     return retval;
 }
 
@@ -856,15 +856,15 @@ mch_isdir(char_u *name)
     int			    retval = FALSE;
 
     fib = get_fib(name);
-    if (fib != NULL)
-    {
+    if (fib == NULL)
+	return FALSE;
+
 #ifdef __amigaos4__
-	retval = (FIB_IS_DRAWER(fib)) ? TRUE : FALSE;
+    retval = (FIB_IS_DRAWER(fib)) ? TRUE : FALSE;
 #else
-	retval = ((fib->fib_DirEntryType >= 0) ? TRUE : FALSE);
+    retval = ((fib->fib_DirEntryType >= 0) ? TRUE : FALSE);
 #endif
-	free_fib(fib);
-    }
+    free_fib(fib);
     return retval;
 }
 
@@ -877,12 +877,11 @@ mch_mkdir(char_u *name)
     BPTR	lock;
 
     lock = CreateDir(name);
-    if (lock != NULL)
-    {
-	UnLock(lock);
-	return 0;
-    }
-    return -1;
+    if (lock == NULL)
+	return -1;
+
+    UnLock(lock);
+    return 0;
 }
 
 /*
@@ -1173,17 +1172,17 @@ out:
     void
 mch_set_shellsize(void)
 {
-    if (term_console)
-    {
-	size_set = TRUE;
-	out_char(CSI);
-	out_num((long)Rows);
-	out_char('t');
-	out_char(CSI);
-	out_num((long)Columns);
-	out_char('u');
-	out_flush();
-    }
+    if (!term_console)
+	return;
+
+    size_set = TRUE;
+    out_char(CSI);
+    out_num((long)Rows);
+    out_char('t');
+    out_char(CSI);
+    out_num((long)Columns);
+    out_char('u');
+    out_flush();
 }
 
 /*
--- a/src/os_mac_conv.c
+++ b/src/os_mac_conv.c
@@ -568,28 +568,28 @@ mac_utf8_to_utf16(
     void
 mac_lang_init(void)
 {
-    if (mch_getenv((char_u *)"LANG") == NULL)
-    {
-	char	buf[50];
+    if (mch_getenv((char_u *)"LANG") != NULL)
+	return;
+
+    char	buf[50];
 
-	// $LANG is not set, either because it was unset or Vim was started
-	// from the Dock.  Query the system locale.
-	if (LocaleRefGetPartString(NULL,
-		    kLocaleLanguageMask | kLocaleLanguageVariantMask |
-		    kLocaleRegionMask | kLocaleRegionVariantMask,
-		    sizeof(buf) - 10, buf) == noErr && *buf)
-	{
-	    if (strcasestr(buf, "utf-8") == NULL)
-		strcat(buf, ".UTF-8");
-	    vim_setenv((char_u *)"LANG", (char_u *)buf);
+    // $LANG is not set, either because it was unset or Vim was started
+    // from the Dock.  Query the system locale.
+    if (LocaleRefGetPartString(NULL,
+		kLocaleLanguageMask | kLocaleLanguageVariantMask |
+		kLocaleRegionMask | kLocaleRegionVariantMask,
+		sizeof(buf) - 10, buf) == noErr && *buf)
+    {
+	if (strcasestr(buf, "utf-8") == NULL)
+	    strcat(buf, ".UTF-8");
+	vim_setenv((char_u *)"LANG", (char_u *)buf);
 #   ifdef HAVE_LOCALE_H
-	    setlocale(LC_ALL, "");
+	setlocale(LC_ALL, "");
 #   endif
 #   if defined(LC_NUMERIC)
-	    // Make sure strtod() uses a decimal point, not a comma.
-	    setlocale(LC_NUMERIC, "C");
+	// Make sure strtod() uses a decimal point, not a comma.
+	setlocale(LC_NUMERIC, "C");
 #   endif
-	}
     }
 }
 #endif // MACOS_CONVERT
--- a/src/os_mswin.c
+++ b/src/os_mswin.c
@@ -835,24 +835,24 @@ check_str_len(char_u *str)
     GetSystemInfo(&si);
 
     // get memory information
-    if (VirtualQuery(str, &mbi, sizeof(mbi)))
-    {
-	// pre cast these (typing savers)
-	long_u dwStr = (long_u)str;
-	long_u dwBaseAddress = (long_u)mbi.BaseAddress;
-
-	// get start address of page that str is on
-	long_u strPage = dwStr - (dwStr - dwBaseAddress) % si.dwPageSize;
-
-	// get length from str to end of page
-	long_u pageLength = si.dwPageSize - (dwStr - strPage);
-
-	for (p = str; !IsBadReadPtr(p, (UINT)pageLength);
-				  p += pageLength, pageLength = si.dwPageSize)
-	    for (i = 0; i < pageLength; ++i, ++length)
-		if (p[i] == NUL)
-		    return length + 1;
-    }
+    if (!VirtualQuery(str, &mbi, sizeof(mbi)))
+	return 0;
+
+    // pre cast these (typing savers)
+    long_u dwStr = (long_u)str;
+    long_u dwBaseAddress = (long_u)mbi.BaseAddress;
+
+    // get start address of page that str is on
+    long_u strPage = dwStr - (dwStr - dwBaseAddress) % si.dwPageSize;
+
+    // get length from str to end of page
+    long_u pageLength = si.dwPageSize - (dwStr - strPage);
+
+    for (p = str; !IsBadReadPtr(p, (UINT)pageLength);
+	    p += pageLength, pageLength = si.dwPageSize)
+	for (i = 0; i < pageLength; ++i, ++length)
+	    if (p[i] == NUL)
+		return length + 1;
 
     return 0;
 }
@@ -1213,43 +1213,43 @@ PrintHookProc(
     RECT	rc, rcDlg, rcOwner;
     PRINTDLGW	*pPD;
 
-    if (uiMsg == WM_INITDIALOG)
-    {
-	// Get the owner window and dialog box rectangles.
-	if ((hwndOwner = GetParent(hDlg)) == NULL)
-	    hwndOwner = GetDesktopWindow();
-
-	GetWindowRect(hwndOwner, &rcOwner);
-	GetWindowRect(hDlg, &rcDlg);
-	CopyRect(&rc, &rcOwner);
-
-	// Offset the owner and dialog box rectangles so that
-	// right and bottom values represent the width and
-	// height, and then offset the owner again to discard
-	// space taken up by the dialog box.
-
-	OffsetRect(&rcDlg, -rcDlg.left, -rcDlg.top);
-	OffsetRect(&rc, -rc.left, -rc.top);
-	OffsetRect(&rc, -rcDlg.right, -rcDlg.bottom);
-
-	// The new position is the sum of half the remaining
-	// space and the owner's original position.
-
-	SetWindowPos(hDlg,
-		HWND_TOP,
-		rcOwner.left + (rc.right / 2),
-		rcOwner.top + (rc.bottom / 2),
-		0, 0,		// ignores size arguments
-		SWP_NOSIZE);
-
-	//  tackle the printdlg copiesctrl problem
-	pPD = (PRINTDLGW *)lParam;
-	pPD->nCopies = (WORD)pPD->lCustData;
-	SetDlgItemInt( hDlg, edt3, pPD->nCopies, FALSE );
-	//  Bring the window to top
-	BringWindowToTop(GetParent(hDlg));
-	SetForegroundWindow(hDlg);
-    }
+    if (uiMsg != WM_INITDIALOG)
+	return FALSE;
+
+    // Get the owner window and dialog box rectangles.
+    if ((hwndOwner = GetParent(hDlg)) == NULL)
+	hwndOwner = GetDesktopWindow();
+
+    GetWindowRect(hwndOwner, &rcOwner);
+    GetWindowRect(hDlg, &rcDlg);
+    CopyRect(&rc, &rcOwner);
+
+    // Offset the owner and dialog box rectangles so that
+    // right and bottom values represent the width and
+    // height, and then offset the owner again to discard
+    // space taken up by the dialog box.
+
+    OffsetRect(&rcDlg, -rcDlg.left, -rcDlg.top);
+    OffsetRect(&rc, -rc.left, -rc.top);
+    OffsetRect(&rc, -rcDlg.right, -rcDlg.bottom);
+
+    // The new position is the sum of half the remaining
+    // space and the owner's original position.
+
+    SetWindowPos(hDlg,
+	    HWND_TOP,
+	    rcOwner.left + (rc.right / 2),
+	    rcOwner.top + (rc.bottom / 2),
+	    0, 0,		// ignores size arguments
+	    SWP_NOSIZE);
+
+    //  tackle the printdlg copiesctrl problem
+    pPD = (PRINTDLGW *)lParam;
+    pPD->nCopies = (WORD)pPD->lCustData;
+    SetDlgItemInt( hDlg, edt3, pPD->nCopies, FALSE );
+    //  Bring the window to top
+    BringWindowToTop(GetParent(hDlg));
+    SetForegroundWindow(hDlg);
 
     return FALSE;
 }
@@ -1571,29 +1571,27 @@ mch_print_init(prt_settings_T *psettings
     return TRUE;
 
 init_fail_dlg:
+    DWORD err = CommDlgExtendedError();
+
+    if (err)
     {
-	DWORD err = CommDlgExtendedError();
-
-	if (err)
-	{
-	    char_u *buf;
-
-	    // I suspect FormatMessage() doesn't work for values returned by
-	    // CommDlgExtendedError().  What does?
-	    FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
-			  FORMAT_MESSAGE_FROM_SYSTEM |
-			  FORMAT_MESSAGE_IGNORE_INSERTS,
-			  NULL, err, 0, (LPTSTR)(&buf), 0, NULL);
-	    semsg(_(e_print_error_str),
-				  buf == NULL ? (char_u *)_("Unknown") : buf);
-	    LocalFree((LPVOID)(buf));
-	}
-	else
-	    msg_clr_eos(); // Maybe canceled
-
-	mch_print_cleanup();
-	return FALSE;
+	char_u *buf;
+
+	// I suspect FormatMessage() doesn't work for values returned by
+	// CommDlgExtendedError().  What does?
+	FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
+		FORMAT_MESSAGE_FROM_SYSTEM |
+		FORMAT_MESSAGE_IGNORE_INSERTS,
+		NULL, err, 0, (LPTSTR)(&buf), 0, NULL);
+	semsg(_(e_print_error_str),
+		buf == NULL ? (char_u *)_("Unknown") : buf);
+	LocalFree((LPVOID)(buf));
     }
+    else
+	msg_clr_eos(); // Maybe canceled
+
+    mch_print_cleanup();
+    return FALSE;
 }
 
 
@@ -1999,11 +1997,11 @@ serverSendEnc(HWND target)
     static void
 CleanUpMessaging(void)
 {
-    if (message_window != 0)
-    {
-	DestroyWindow(message_window);
-	message_window = 0;
-    }
+    if (message_window == 0)
+	return;
+
+    DestroyWindow(message_window);
+    message_window = 0;
 }
 
 static int save_reply(HWND server, char_u *reply, int expr);
--- a/src/os_qnx.c
+++ b/src/os_qnx.c
@@ -67,38 +67,38 @@ clip_mch_request_selection(Clipboard_T *
     char_u	    *clip_text = NULL;
 
     cbdata = PhClipboardPasteStart(PhInputGroup(NULL));
-    if (cbdata != NULL)
-    {
-	// Look for the vim specific clip first
-	clip_header = PhClipboardPasteType(cbdata, CLIP_TYPE_VIM);
-	if (clip_header != NULL && clip_header->data != NULL)
-	{
-	    switch(*(char *) clip_header->data)
-	    {
-		default: // fallthrough to line type
-		case 'L': type = MLINE; break;
-		case 'C': type = MCHAR; break;
-		case 'B': type = MBLOCK; break;
-	    }
-	    is_type_set = TRUE;
-	}
+    if (cbdata == NULL)
+	return;
 
-	// Try for just normal text
-	clip_header = PhClipboardPasteType(cbdata, CLIP_TYPE_TEXT);
-	if (clip_header != NULL)
+    // Look for the vim specific clip first
+    clip_header = PhClipboardPasteType(cbdata, CLIP_TYPE_VIM);
+    if (clip_header != NULL && clip_header->data != NULL)
+    {
+	switch(*(char *) clip_header->data)
 	{
-	    clip_text = clip_header->data;
-	    clip_length  = clip_header->length - 1;
+	    default: // fallthrough to line type
+	    case 'L': type = MLINE; break;
+	    case 'C': type = MCHAR; break;
+	    case 'B': type = MBLOCK; break;
+	}
+	is_type_set = TRUE;
+    }
 
-	    if (clip_text != NULL && is_type_set == FALSE)
-		type = MAUTO;
-	}
+    // Try for just normal text
+    clip_header = PhClipboardPasteType(cbdata, CLIP_TYPE_TEXT);
+    if (clip_header != NULL)
+    {
+	clip_text = clip_header->data;
+	clip_length  = clip_header->length - 1;
 
-	if ((clip_text != NULL) && (clip_length > 0))
-	    clip_yank_selection(type, clip_text, clip_length, cbd);
+	if (clip_text != NULL && is_type_set == FALSE)
+	    type = MAUTO;
+    }
 
-	PhClipboardPasteFinish(cbdata);
-    }
+    if ((clip_text != NULL) && (clip_length > 0))
+	clip_yank_selection(type, clip_text, clip_length, cbd);
+
+    PhClipboardPasteFinish(cbdata);
 }
 
 void
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -780,16 +780,16 @@ get_stack_limit(void)
     int
 mch_stackcheck(char *p)
 {
-    if (stack_limit != NULL)
-    {
-	if (stack_grows_downwards)
-	{
-	    if (p < stack_limit)
-		return FAIL;
-	}
-	else if (p > stack_limit)
+    if (stack_limit == NULL)
+	return OK;
+
+    if (stack_grows_downwards)
+    {
+	if (p < stack_limit)
 	    return FAIL;
     }
+    else if (p > stack_limit)
+	return FAIL;
     return OK;
 }
 #endif
@@ -837,25 +837,25 @@ static char *signal_stack;
     static void
 init_signal_stack(void)
 {
-    if (signal_stack != NULL)
-    {
+    if (signal_stack == NULL)
+	return;
+
 # ifdef HAVE_SIGALTSTACK
 #  ifdef HAVE_SS_BASE
-	sigstk.ss_base = signal_stack;
+    sigstk.ss_base = signal_stack;
 #  else
-	sigstk.ss_sp = signal_stack;
+    sigstk.ss_sp = signal_stack;
 #  endif
-	sigstk.ss_size = get_signal_stack_size();
-	sigstk.ss_flags = 0;
-	(void)sigaltstack(&sigstk, NULL);
+    sigstk.ss_size = get_signal_stack_size();
+    sigstk.ss_flags = 0;
+    (void)sigaltstack(&sigstk, NULL);
 # else
-	sigstk.ss_sp = signal_stack;
-	if (stack_grows_downwards)
-	    sigstk.ss_sp += get_signal_stack_size() - 1;
-	sigstk.ss_onstack = 0;
-	(void)sigstack(&sigstk, NULL);
-# endif
-    }
+    sigstk.ss_sp = signal_stack;
+    if (stack_grows_downwards)
+	sigstk.ss_sp += get_signal_stack_size() - 1;
+    sigstk.ss_onstack = 0;
+    (void)sigstack(&sigstk, NULL);
+# endif
 }
 #endif
 
@@ -2020,91 +2020,90 @@ get_x11_thing(
     int			retval = FALSE;
     Status		status;
 
-    if (get_x11_windis() == OK)
-    {
-	// Get window/icon name if any
+    if (get_x11_windis() != OK)
+	return FALSE;
+
+    // Get window/icon name if any
+    if (get_title)
+	status = XGetWMName(x11_display, x11_window, &text_prop);
+    else
+	status = XGetWMIconName(x11_display, x11_window, &text_prop);
+
+    /*
+     * If terminal is xterm, then x11_window may be a child window of the
+     * outer xterm window that actually contains the window/icon name, so
+     * keep traversing up the tree until a window with a title/icon is
+     * found.
+     */
+    // Previously this was only done for xterm and alike.  I don't see a
+    // reason why it would fail for other terminal emulators.
+    // if (term_is_xterm)
+    Window	    root;
+    Window	    parent;
+    Window	    win = x11_window;
+    Window	   *children;
+    unsigned int    num_children;
+
+    while (!status || text_prop.value == NULL)
+    {
+	if (!XQueryTree(x11_display, win, &root, &parent, &children,
+		    &num_children))
+	    break;
+	if (children)
+	    XFree((void *)children);
+	if (parent == root || parent == 0)
+	    break;
+
+	win = parent;
 	if (get_title)
-	    status = XGetWMName(x11_display, x11_window, &text_prop);
+	    status = XGetWMName(x11_display, win, &text_prop);
 	else
-	    status = XGetWMIconName(x11_display, x11_window, &text_prop);
-
-	/*
-	 * If terminal is xterm, then x11_window may be a child window of the
-	 * outer xterm window that actually contains the window/icon name, so
-	 * keep traversing up the tree until a window with a title/icon is
-	 * found.
-	 */
-	// Previously this was only done for xterm and alike.  I don't see a
-	// reason why it would fail for other terminal emulators.
-	// if (term_is_xterm)
+	    status = XGetWMIconName(x11_display, win, &text_prop);
+    }
+
+    if (status && text_prop.value != NULL)
+    {
+	retval = TRUE;
+	if (!test_only)
 	{
-	    Window	    root;
-	    Window	    parent;
-	    Window	    win = x11_window;
-	    Window	   *children;
-	    unsigned int    num_children;
-
-	    while (!status || text_prop.value == NULL)
-	    {
-		if (!XQueryTree(x11_display, win, &root, &parent, &children,
-							       &num_children))
-		    break;
-		if (children)
-		    XFree((void *)children);
-		if (parent == root || parent == 0)
-		    break;
-
-		win = parent;
-		if (get_title)
-		    status = XGetWMName(x11_display, win, &text_prop);
-		else
-		    status = XGetWMIconName(x11_display, win, &text_prop);
-	    }
-	}
-	if (status && text_prop.value != NULL)
-	{
-	    retval = TRUE;
-	    if (!test_only)
+	    if (get_title)
+		vim_free(oldtitle);
+	    else
+		vim_free(oldicon);
+	    if (text_prop.encoding == XA_STRING && !has_mbyte)
 	    {
 		if (get_title)
-		    vim_free(oldtitle);
+		    oldtitle = vim_strsave((char_u *)text_prop.value);
 		else
-		    vim_free(oldicon);
-		if (text_prop.encoding == XA_STRING && !has_mbyte)
+		    oldicon = vim_strsave((char_u *)text_prop.value);
+	    }
+	    else
+	    {
+		char    **cl;
+		Status  transform_status;
+		int	    n = 0;
+
+		transform_status = XmbTextPropertyToTextList(x11_display,
+			&text_prop,
+			&cl, &n);
+		if (transform_status >= Success && n > 0 && cl[0])
+		{
+		    if (get_title)
+			oldtitle = vim_strsave((char_u *) cl[0]);
+		    else
+			oldicon = vim_strsave((char_u *) cl[0]);
+		    XFreeStringList(cl);
+		}
+		else
 		{
 		    if (get_title)
 			oldtitle = vim_strsave((char_u *)text_prop.value);
 		    else
 			oldicon = vim_strsave((char_u *)text_prop.value);
 		}
-		else
-		{
-		    char    **cl;
-		    Status  transform_status;
-		    int	    n = 0;
-
-		    transform_status = XmbTextPropertyToTextList(x11_display,
-								 &text_prop,
-								 &cl, &n);
-		    if (transform_status >= Success && n > 0 && cl[0])
-		    {
-			if (get_title)
-			    oldtitle = vim_strsave((char_u *) cl[0]);
-			else
-			    oldicon = vim_strsave((char_u *) cl[0]);
-			XFreeStringList(cl);
-		    }
-		    else
-		    {
-			if (get_title)
-			    oldtitle = vim_strsave((char_u *)text_prop.value);
-			else
-			    oldicon = vim_strsave((char_u *)text_prop.value);
-		    }
-		}
 	    }
-	    XFree((void *)text_prop.value);
 	}
+	XFree((void *)text_prop.value);
     }
     return retval;
 }
@@ -2772,52 +2771,52 @@ fname_case(
     DIR		*dirp;
     struct dirent *dp;
 
-    if (mch_lstat((char *)name, &st) >= 0)
-    {
-	// Open the directory where the file is located.
-	slash = vim_strrchr(name, '/');
-	if (slash == NULL)
+    if (mch_lstat((char *)name, &st) < 0)
+	return;
+
+    // Open the directory where the file is located.
+    slash = vim_strrchr(name, '/');
+    if (slash == NULL)
+    {
+	dirp = opendir(".");
+	tail = name;
+    }
+    else
+    {
+	*slash = NUL;
+	dirp = opendir((char *)name);
+	*slash = '/';
+	tail = slash + 1;
+    }
+
+    if (dirp == NULL)
+	return;
+
+    while ((dp = readdir(dirp)) != NULL)
+    {
+	// Only accept names that differ in case and are the same byte
+	// length. TODO: accept different length name.
+	if (STRICMP(tail, dp->d_name) == 0
+		&& STRLEN(tail) == STRLEN(dp->d_name))
 	{
-	    dirp = opendir(".");
-	    tail = name;
-	}
-	else
-	{
-	    *slash = NUL;
-	    dirp = opendir((char *)name);
-	    *slash = '/';
-	    tail = slash + 1;
-	}
-
-	if (dirp != NULL)
-	{
-	    while ((dp = readdir(dirp)) != NULL)
+	    char_u	newname[MAXPATHL + 1];
+	    struct stat st2;
+
+	    // Verify the inode is equal.
+	    vim_strncpy(newname, name, MAXPATHL);
+	    vim_strncpy(newname + (tail - name), (char_u *)dp->d_name,
+		    MAXPATHL - (tail - name));
+	    if (mch_lstat((char *)newname, &st2) >= 0
+		    && st.st_ino == st2.st_ino
+		    && st.st_dev == st2.st_dev)
 	    {
-		// Only accept names that differ in case and are the same byte
-		// length. TODO: accept different length name.
-		if (STRICMP(tail, dp->d_name) == 0
-			&& STRLEN(tail) == STRLEN(dp->d_name))
-		{
-		    char_u	newname[MAXPATHL + 1];
-		    struct stat st2;
-
-		    // Verify the inode is equal.
-		    vim_strncpy(newname, name, MAXPATHL);
-		    vim_strncpy(newname + (tail - name), (char_u *)dp->d_name,
-						    MAXPATHL - (tail - name));
-		    if (mch_lstat((char *)newname, &st2) >= 0
-			    && st.st_ino == st2.st_ino
-			    && st.st_dev == st2.st_dev)
-		    {
-			STRCPY(tail, dp->d_name);
-			break;
-		    }
-		}
+		STRCPY(tail, dp->d_name);
+		break;
 	    }
-
-	    closedir(dirp);
 	}
     }
+
+    closedir(dirp);
 }
 #endif
 
@@ -2902,46 +2901,46 @@ mch_copy_sec(char_u *from_file, char_u *
     if (selinux_enabled == -1)
 	selinux_enabled = is_selinux_enabled();
 
-    if (selinux_enabled > 0)
-    {
-	// Use "char *" instead of "security_context_t" to avoid a deprecation
-	// warning.
-	char *from_context = NULL;
-	char *to_context = NULL;
-
-	if (getfilecon((char *)from_file, &from_context) < 0)
+    if (selinux_enabled <= 0)
+	return;
+
+    // Use "char *" instead of "security_context_t" to avoid a deprecation
+    // warning.
+    char *from_context = NULL;
+    char *to_context = NULL;
+
+    if (getfilecon((char *)from_file, &from_context) < 0)
+    {
+	// If the filesystem doesn't support extended attributes,
+	// the original had no special security context and the
+	// target cannot have one either.
+	if (errno == EOPNOTSUPP)
+	    return;
+
+	msg_puts(_("\nCould not get security context for "));
+	msg_outtrans(from_file);
+	msg_putchar('\n');
+	return;
+    }
+    if (getfilecon((char *)to_file, &to_context) < 0)
+    {
+	msg_puts(_("\nCould not get security context for "));
+	msg_outtrans(to_file);
+	msg_putchar('\n');
+	freecon (from_context);
+	return ;
+    }
+    if (strcmp(from_context, to_context) != 0)
+    {
+	if (setfilecon((char *)to_file, from_context) < 0)
 	{
-	    // If the filesystem doesn't support extended attributes,
-	    // the original had no special security context and the
-	    // target cannot have one either.
-	    if (errno == EOPNOTSUPP)
-		return;
-
-	    msg_puts(_("\nCould not get security context for "));
-	    msg_outtrans(from_file);
-	    msg_putchar('\n');
-	    return;
-	}
-	if (getfilecon((char *)to_file, &to_context) < 0)
-	{
-	    msg_puts(_("\nCould not get security context for "));
+	    msg_puts(_("\nCould not set security context for "));
 	    msg_outtrans(to_file);
 	    msg_putchar('\n');
-	    freecon (from_context);
-	    return ;
 	}
-	if (strcmp(from_context, to_context) != 0)
-	{
-	    if (setfilecon((char *)to_file, from_context) < 0)
-	    {
-		msg_puts(_("\nCould not set security context for "));
-		msg_outtrans(to_file);
-		msg_putchar('\n');
-	    }
-	}
-	freecon(to_context);
-	freecon(from_context);
-    }
+    }
+    freecon(to_context);
+    freecon(from_context);
 }
 #endif // HAVE_SELINUX
 
@@ -3549,21 +3548,21 @@ mch_tcgetattr(int fd, void *term)
     int		retval = -1;
 
     tty_fd = get_tty_fd(fd);
-    if (tty_fd >= 0)
-    {
+    if (tty_fd < 0)
+	return -1;
+
 #ifdef NEW_TTY_SYSTEM
 # ifdef HAVE_TERMIOS_H
-	retval = tcgetattr(tty_fd, (struct termios *)term);
+    retval = tcgetattr(tty_fd, (struct termios *)term);
 # else
-	retval = ioctl(tty_fd, TCGETA, (struct termio *)term);
+    retval = ioctl(tty_fd, TCGETA, (struct termio *)term);
 # endif
 #else
-	// for "old" tty systems
-	retval = ioctl(tty_fd, TIOCGETP, (struct sgttyb *)term);
-#endif
-	if (tty_fd != fd)
-	    close(tty_fd);
-    }
+    // for "old" tty systems
+    retval = ioctl(tty_fd, TIOCGETP, (struct sgttyb *)term);
+#endif
+    if (tty_fd != fd)
+	close(tty_fd);
     return retval;
 }
 
@@ -3682,18 +3681,18 @@ get_stty(void)
     char_u	buf[2];
     char_u	*p;
 
-    if (get_tty_info(read_cmd_fd, &info) == OK)
-    {
-	intr_char = info.interrupt;
-	buf[0] = info.backspace;
-	buf[1] = NUL;
-	add_termcode((char_u *)"kb", buf, FALSE);
-
-	// If <BS> and <DEL> are now the same, redefine <DEL>.
-	p = find_termcode((char_u *)"kD");
-	if (p != NULL && p[0] == buf[0] && p[1] == buf[1])
-	    do_fixdel(NULL);
-    }
+    if (get_tty_info(read_cmd_fd, &info) != OK)
+	return;
+
+    intr_char = info.interrupt;
+    buf[0] = info.backspace;
+    buf[1] = NUL;
+    add_termcode((char_u *)"kb", buf, FALSE);
+
+    // If <BS> and <DEL> are now the same, redefine <DEL>.
+    p = find_termcode((char_u *)"kD");
+    if (p != NULL && p[0] == buf[0] && p[1] == buf[1])
+	do_fixdel(NULL);
 }
 
 /*
@@ -4160,30 +4159,30 @@ mch_report_winsize(int fd, int rows, int
     int		retval = -1;
 
     tty_fd = get_tty_fd(fd);
-    if (tty_fd >= 0)
-    {
+    if (tty_fd < 0)
+	return FAIL;
+
 # if defined(TIOCSWINSZ)
-	struct winsize ws;
-
-	ws.ws_col = cols;
-	ws.ws_row = rows;
-	ws.ws_xpixel = cols * 5;
-	ws.ws_ypixel = rows * 10;
-	retval = ioctl(tty_fd, TIOCSWINSZ, &ws);
-	ch_log(NULL, "ioctl(TIOCSWINSZ) %s",
-					  retval == 0 ? "success" : "failed");
+    struct winsize ws;
+
+    ws.ws_col = cols;
+    ws.ws_row = rows;
+    ws.ws_xpixel = cols * 5;
+    ws.ws_ypixel = rows * 10;
+    retval = ioctl(tty_fd, TIOCSWINSZ, &ws);
+    ch_log(NULL, "ioctl(TIOCSWINSZ) %s",
+	    retval == 0 ? "success" : "failed");
 # elif defined(TIOCSSIZE)
-	struct ttysize ts;
-
-	ts.ts_cols = cols;
-	ts.ts_lines = rows;
-	retval = ioctl(tty_fd, TIOCSSIZE, &ts);
-	ch_log(NULL, "ioctl(TIOCSSIZE) %s",
-					  retval == 0 ? "success" : "failed");
-# endif
-	if (tty_fd != fd)
-	    close(tty_fd);
-    }
+    struct ttysize ts;
+
+    ts.ts_cols = cols;
+    ts.ts_lines = rows;
+    retval = ioctl(tty_fd, TIOCSSIZE, &ts);
+    ch_log(NULL, "ioctl(TIOCSSIZE) %s",
+	    retval == 0 ? "success" : "failed");
+# endif
+    if (tty_fd != fd)
+	close(tty_fd);
     return retval == 0 ? OK : FAIL;
 }
 #endif
@@ -4362,28 +4361,28 @@ open_pty(int *pty_master_fd, int *pty_sl
 	*name2 = NULL;
 
     *pty_master_fd = mch_openpty(&tty_name);	    // open pty
-    if (*pty_master_fd >= 0)
-    {
-	// Leaving out O_NOCTTY may lead to waitpid() always returning
-	// 0 on Mac OS X 10.7 thereby causing freezes. Let's assume
-	// adding O_NOCTTY always works when defined.
+    if (*pty_master_fd < 0)
+	return;
+
+    // Leaving out O_NOCTTY may lead to waitpid() always returning
+    // 0 on Mac OS X 10.7 thereby causing freezes. Let's assume
+    // adding O_NOCTTY always works when defined.
 #ifdef O_NOCTTY
-	*pty_slave_fd = open(tty_name, O_RDWR | O_NOCTTY | O_EXTRA, 0);
+    *pty_slave_fd = open(tty_name, O_RDWR | O_NOCTTY | O_EXTRA, 0);
 #else
-	*pty_slave_fd = open(tty_name, O_RDWR | O_EXTRA, 0);
-#endif
-	if (*pty_slave_fd < 0)
-	{
-	    close(*pty_master_fd);
-	    *pty_master_fd = -1;
-	}
-	else
-	{
-	    if (name1 != NULL)
-		*name1 = vim_strsave((char_u *)tty_name);
-	    if (name2 != NULL)
-		*name2 = vim_strsave((char_u *)tty_name);
-	}
+    *pty_slave_fd = open(tty_name, O_RDWR | O_EXTRA, 0);
+#endif
+    if (*pty_slave_fd < 0)
+    {
+	close(*pty_master_fd);
+	*pty_master_fd = -1;
+    }
+    else
+    {
+	if (name1 != NULL)
+	    *name1 = vim_strsave((char_u *)tty_name);
+	if (name2 != NULL)
+	    *name2 = vim_strsave((char_u *)tty_name);
     }
 }
 #endif
@@ -7250,29 +7249,28 @@ gpm_open(void)
 	return 0;
 #endif
 
-    if (!gpm_flag)
-    {
-	gpm_connect.eventMask = (GPM_UP | GPM_DRAG | GPM_DOWN);
-	gpm_connect.defaultMask = ~GPM_HARD;
-	// Default handling for mouse move
-	gpm_connect.minMod = 0; // Handle any modifier keys
-	gpm_connect.maxMod = 0xffff;
-	if (Gpm_Open(&gpm_connect, 0) > 0)
-	{
-	    // gpm library tries to handling TSTP causes
-	    // problems. Anyways, we close connection to Gpm whenever
-	    // we are going to suspend or starting an external process
-	    // so we shouldn't  have problem with this
+    if (gpm_flag)
+	return 1; // already open
+
+    gpm_connect.eventMask = (GPM_UP | GPM_DRAG | GPM_DOWN);
+    gpm_connect.defaultMask = ~GPM_HARD;
+    // Default handling for mouse move
+    gpm_connect.minMod = 0; // Handle any modifier keys
+    gpm_connect.maxMod = 0xffff;
+    if (Gpm_Open(&gpm_connect, 0) > 0)
+    {
+	// gpm library tries to handling TSTP causes
+	// problems. Anyways, we close connection to Gpm whenever
+	// we are going to suspend or starting an external process
+	// so we shouldn't  have problem with this
 # ifdef SIGTSTP
-	    signal(SIGTSTP, restricted ? SIG_IGN : (void (*)())sig_tstp);
-# endif
-	    return 1; // succeed
-	}
-	if (gpm_fd == -2)
-	    Gpm_Close(); // We don't want to talk to xterm via gpm
-	return 0;
-    }
-    return 1; // already open
+	signal(SIGTSTP, restricted ? SIG_IGN : (void (*)())sig_tstp);
+# endif
+	return 1; // succeed
+    }
+    if (gpm_fd == -2)
+	Gpm_Close(); // We don't want to talk to xterm via gpm
+    return 0;
 }
 
 /*
@@ -7395,14 +7393,13 @@ sysmouse_open(void)
     mouse.operation = MOUSE_MODE;
     mouse.u.mode.mode = 0;
     mouse.u.mode.signal = SIGUSR2;
-    if (ioctl(1, CONS_MOUSECTL, &mouse) != -1)
-    {
-	signal(SIGUSR2, (void (*)())sig_sysmouse);
-	mouse.operation = MOUSE_SHOW;
-	ioctl(1, CONS_MOUSECTL, &mouse);
-	return OK;
-    }
-    return FAIL;
+    if (ioctl(1, CONS_MOUSECTL, &mouse) == -1)
+	return FAIL;
+
+    signal(SIGUSR2, (void (*)())sig_sysmouse);
+    mouse.operation = MOUSE_SHOW;
+    ioctl(1, CONS_MOUSECTL, &mouse);
+    return OK;
 }
 
 /*
@@ -8243,14 +8240,14 @@ xsmp_init(void)
     void
 xsmp_close(void)
 {
-    if (xsmp_icefd != -1)
-    {
-	SmcCloseConnection(xsmp.smcconn, 0, NULL);
-	if (xsmp.clientid != NULL)
-	    free(xsmp.clientid);
-	xsmp.clientid = NULL;
-	xsmp_icefd = -1;
-    }
+    if (xsmp_icefd == -1)
+	return;
+
+    SmcCloseConnection(xsmp.smcconn, 0, NULL);
+    if (xsmp.clientid != NULL)
+	free(xsmp.clientid);
+    xsmp.clientid = NULL;
+    xsmp_icefd = -1;
 }
 #endif // USE_XSMP
 
@@ -8348,11 +8345,11 @@ start_timeout(long msec)
     void
 delete_timer(void)
 {
-    if (timer_created)
-    {
-	timer_delete(timer_id);
-	timer_created = FALSE;
-    }
+    if (!timer_created)
+	return;
+
+    timer_delete(timer_id);
+    timer_created = FALSE;
 }
 
 # else // HAVE_TIMER_CREATE
--- a/src/os_win32.c
+++ b/src/os_win32.c
@@ -278,15 +278,15 @@ get_build_number(void)
 
     osver.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
     hNtdll = GetModuleHandle("ntdll.dll");
-    if (hNtdll != NULL)
-    {
-	pRtlGetVersion =
-	    (PfnRtlGetVersion)GetProcAddress(hNtdll, "RtlGetVersion");
-	pRtlGetVersion(&osver);
-	ver = MAKE_VER(min(osver.dwMajorVersion, 255),
-		       min(osver.dwMinorVersion, 255),
-		       min(osver.dwBuildNumber, 32767));
-    }
+    if (hNtdll == NULL)
+	return ver;
+
+    pRtlGetVersion =
+	(PfnRtlGetVersion)GetProcAddress(hNtdll, "RtlGetVersion");
+    pRtlGetVersion(&osver);
+    ver = MAKE_VER(min(osver.dwMajorVersion, 255),
+	    min(osver.dwMinorVersion, 255),
+	    min(osver.dwBuildNumber, 32767));
     return ver;
 }
 
@@ -478,29 +478,29 @@ get_exe_name(void)
 	    exe_name = FullName_save((char_u *)temp, FALSE);
     }
 
-    if (exe_path == NULL && exe_name != NULL)
-    {
-	exe_path = vim_strnsave(exe_name, gettail_sep(exe_name) - exe_name);
-	if (exe_path != NULL)
-	{
-	    // Append our starting directory to $PATH, so that when doing
-	    // "!xxd" it's found in our starting directory.  Needed because
-	    // SearchPath() also looks there.
-	    p = mch_getenv("PATH");
-	    if (p == NULL
-		       || STRLEN(p) + STRLEN(exe_path) + 2 < MAX_ENV_PATH_LEN)
-	    {
-		if (p == NULL || *p == NUL)
-		    temp[0] = NUL;
-		else
-		{
-		    STRCPY(temp, p);
-		    STRCAT(temp, ";");
-		}
-		STRCAT(temp, exe_path);
-		vim_setenv((char_u *)"PATH", (char_u *)temp);
-	    }
-	}
+    if (exe_path != NULL || exe_name == NULL)
+	return;
+
+    exe_path = vim_strnsave(exe_name, gettail_sep(exe_name) - exe_name);
+    if (exe_path == NULL)
+	return;
+
+    // Append our starting directory to $PATH, so that when doing
+    // "!xxd" it's found in our starting directory.  Needed because
+    // SearchPath() also looks there.
+    p = mch_getenv("PATH");
+    if (p == NULL
+	    || STRLEN(p) + STRLEN(exe_path) + 2 < MAX_ENV_PATH_LEN)
+    {
+	if (p == NULL || *p == NUL)
+	    temp[0] = NUL;
+	else
+	{
+	    STRCPY(temp, p);
+	    STRCAT(temp, ";");
+	}
+	STRCAT(temp, exe_path);
+	vim_setenv((char_u *)"PATH", (char_u *)temp);
     }
 }
 
@@ -533,27 +533,27 @@ vimLoadLib(const char *name)
 
     // No need to load any library when registering OLE.
     if (found_register_arg)
-	return dll;
+	return NULL;
 
     // NOTE: Do not use mch_dirname() and mch_chdir() here, they may call
     // vimLoadLib() recursively, which causes a stack overflow.
     if (exe_path == NULL)
 	get_exe_name();
-    if (exe_path != NULL)
-    {
-	WCHAR old_dirw[MAXPATHL];
-
-	if (GetCurrentDirectoryW(MAXPATHL, old_dirw) != 0)
-	{
-	    // Change directory to where the executable is, both to make
-	    // sure we find a .dll there and to avoid looking for a .dll
-	    // in the current directory.
-	    SetCurrentDirectory((LPCSTR)exe_path);
-	    dll = LoadLibrary(name);
-	    SetCurrentDirectoryW(old_dirw);
-	    return dll;
-	}
-    }
+
+    if (exe_path == NULL)
+	return NULL;
+
+    WCHAR old_dirw[MAXPATHL];
+
+    if (GetCurrentDirectoryW(MAXPATHL, old_dirw) == 0)
+	return NULL;
+
+    // Change directory to where the executable is, both to make
+    // sure we find a .dll there and to avoid looking for a .dll
+    // in the current directory.
+    SetCurrentDirectory((LPCSTR)exe_path);
+    dll = LoadLibrary(name);
+    SetCurrentDirectoryW(old_dirw);
     return dll;
 }
 
@@ -907,31 +907,31 @@ PlatformId(void)
 {
     static int done = FALSE;
 
-    if (!done)
-    {
-	OSVERSIONINFO ovi;
-
-	ovi.dwOSVersionInfoSize = sizeof(ovi);
-	GetVersionEx(&ovi);
+    if (done)
+	return;
+
+    OSVERSIONINFO ovi;
+
+    ovi.dwOSVersionInfoSize = sizeof(ovi);
+    GetVersionEx(&ovi);
 
 #ifdef FEAT_EVAL
-	vim_snprintf(windowsVersion, sizeof(windowsVersion), "%d.%d",
-		(int)ovi.dwMajorVersion, (int)ovi.dwMinorVersion);
+    vim_snprintf(windowsVersion, sizeof(windowsVersion), "%d.%d",
+	    (int)ovi.dwMajorVersion, (int)ovi.dwMinorVersion);
 #endif
-	if ((ovi.dwMajorVersion == 6 && ovi.dwMinorVersion >= 2)
-		|| ovi.dwMajorVersion > 6)
-	    win8_or_later = TRUE;
-
-	if ((ovi.dwMajorVersion == 10 && ovi.dwBuildNumber >= 19045)
-		|| ovi.dwMajorVersion > 10)
-	    win10_22H2_or_later = TRUE;
+    if ((ovi.dwMajorVersion == 6 && ovi.dwMinorVersion >= 2)
+	    || ovi.dwMajorVersion > 6)
+	win8_or_later = TRUE;
+
+    if ((ovi.dwMajorVersion == 10 && ovi.dwBuildNumber >= 19045)
+	    || ovi.dwMajorVersion > 10)
+	win10_22H2_or_later = TRUE;
 
 #ifdef HAVE_ACL
-	// Enable privilege for getting or setting SACLs.
-	win32_enable_privilege(SE_SECURITY_NAME, TRUE);
+    // Enable privilege for getting or setting SACLs.
+    win32_enable_privilege(SE_SECURITY_NAME, TRUE);
 #endif
-	done = TRUE;
-    }
+    done = TRUE;
 }
 #ifdef _MSC_VER
 # pragma warning(pop)
@@ -3051,40 +3051,38 @@ FitConsoleWindow(
     COORD dwWindowSize;
     BOOL NeedAdjust = FALSE;
 
-    if (GetConsoleScreenBufferInfo(g_hConOut, &csbi))
-    {
-	/*
-	 * A buffer resize will fail if the current console window does
-	 * not lie completely within that buffer.  To avoid this, we might
-	 * have to move and possibly shrink the window.
-	 */
-	if (csbi.srWindow.Right >= dwBufferSize.X)
-	{
-	    dwWindowSize.X = SRWIDTH(csbi.srWindow);
-	    if (dwWindowSize.X > dwBufferSize.X)
-		dwWindowSize.X = dwBufferSize.X;
-	    csbi.srWindow.Right = dwBufferSize.X - 1;
-	    csbi.srWindow.Left = dwBufferSize.X - dwWindowSize.X;
-	    NeedAdjust = TRUE;
-	}
-	if (csbi.srWindow.Bottom >= dwBufferSize.Y)
-	{
-	    dwWindowSize.Y = SRHEIGHT(csbi.srWindow);
-	    if (dwWindowSize.Y > dwBufferSize.Y)
-		dwWindowSize.Y = dwBufferSize.Y;
-	    csbi.srWindow.Bottom = dwBufferSize.Y - 1;
-	    csbi.srWindow.Top = dwBufferSize.Y - dwWindowSize.Y;
-	    NeedAdjust = TRUE;
-	}
-	if (NeedAdjust && WantAdjust)
-	{
-	    if (!SetConsoleWindowInfo(g_hConOut, TRUE, &csbi.srWindow))
-		return FALSE;
-	}
-	return TRUE;
-    }
-
-    return FALSE;
+    if (!GetConsoleScreenBufferInfo(g_hConOut, &csbi))
+	return FALSE;
+
+    /*
+     * A buffer resize will fail if the current console window does
+     * not lie completely within that buffer.  To avoid this, we might
+     * have to move and possibly shrink the window.
+     */
+    if (csbi.srWindow.Right >= dwBufferSize.X)
+    {
+	dwWindowSize.X = SRWIDTH(csbi.srWindow);
+	if (dwWindowSize.X > dwBufferSize.X)
+	    dwWindowSize.X = dwBufferSize.X;
+	csbi.srWindow.Right = dwBufferSize.X - 1;
+	csbi.srWindow.Left = dwBufferSize.X - dwWindowSize.X;
+	NeedAdjust = TRUE;
+    }
+    if (csbi.srWindow.Bottom >= dwBufferSize.Y)
+    {
+	dwWindowSize.Y = SRHEIGHT(csbi.srWindow);
+	if (dwWindowSize.Y > dwBufferSize.Y)
+	    dwWindowSize.Y = dwBufferSize.Y;
+	csbi.srWindow.Bottom = dwBufferSize.Y - 1;
+	csbi.srWindow.Top = dwBufferSize.Y - dwWindowSize.Y;
+	NeedAdjust = TRUE;
+    }
+    if (NeedAdjust && WantAdjust)
+    {
+	if (!SetConsoleWindowInfo(g_hConOut, TRUE, &csbi.srWindow))
+	    return FALSE;
+    }
+    return TRUE;
 }
 
 typedef struct ConsoleBufferStruct
@@ -3674,17 +3672,15 @@ mch_get_host_name(
     WCHAR wszHostName[256 + 1];
     DWORD wcch = ARRAY_LENGTH(wszHostName);
 
-    if (GetComputerNameW(wszHostName, &wcch))
-    {
-	char_u  *p = utf16_to_enc(wszHostName, NULL);
-
-	if (p != NULL)
-	{
-	    vim_strncpy(s, p, len - 1);
-	    vim_free(p);
-	    return;
-	}
-    }
+    if (!GetComputerNameW(wszHostName, &wcch))
+	return;
+
+    char_u  *p = utf16_to_enc(wszHostName, NULL);
+    if (p == NULL)
+	return;
+
+    vim_strncpy(s, p, len - 1);
+    vim_free(p);
 }
 
 
@@ -3732,32 +3728,31 @@ mch_dirname(
      * But the Win32s known bug list says that getcwd() doesn't work
      * so use the Win32 system call instead. <Negri>
      */
-    if (GetCurrentDirectoryW(_MAX_PATH, wbuf) != 0)
-    {
-	WCHAR   wcbuf[_MAX_PATH + 1];
-	char_u  *p = NULL;
-
-	if (GetLongPathNameW(wbuf, wcbuf, _MAX_PATH) != 0)
-	{
-	    p = utf16_to_enc(wcbuf, NULL);
-	    if (STRLEN(p) >= (size_t)len)
-	    {
-		// long path name is too long, fall back to short one
-		vim_free(p);
-		p = NULL;
-	    }
-	}
-	if (p == NULL)
-	    p = utf16_to_enc(wbuf, NULL);
-
-	if (p != NULL)
-	{
-	    vim_strncpy(buf, p, len - 1);
+    if (GetCurrentDirectoryW(_MAX_PATH, wbuf) == 0)
+	return FAIL;
+
+    WCHAR   wcbuf[_MAX_PATH + 1];
+    char_u  *p = NULL;
+
+    if (GetLongPathNameW(wbuf, wcbuf, _MAX_PATH) != 0)
+    {
+	p = utf16_to_enc(wcbuf, NULL);
+	if (STRLEN(p) >= (size_t)len)
+	{
+	    // long path name is too long, fall back to short one
 	    vim_free(p);
-	    return OK;
-	}
-    }
-    return FAIL;
+	    p = NULL;
+	}
+    }
+    if (p == NULL)
+	p = utf16_to_enc(wbuf, NULL);
+
+    if (p == NULL)
+	return FAIL;
+
+    vim_strncpy(buf, p, len - 1);
+    vim_free(p);
+    return OK;
 }
 
 /*
@@ -3974,14 +3969,14 @@ win32_fileinfo(char_u *fname, BY_HANDLE_
 	    NULL);		// handle to template file
     vim_free(wn);
 
-    if (hFile != INVALID_HANDLE_VALUE)
-    {
-	if (GetFileInformationByHandle(hFile, info) != 0)
-	    res = FILEINFO_OK;
-	else
-	    res = FILEINFO_INFO_FAIL;
-	CloseHandle(hFile);
-    }
+    if (hFile == INVALID_HANDLE_VALUE)
+	return FILEINFO_READ_FAIL;
+
+    if (GetFileInformationByHandle(hFile, info) != 0)
+	res = FILEINFO_OK;
+    else
+	res = FILEINFO_INFO_FAIL;
+    CloseHandle(hFile);
 
     return res;
 }
@@ -6170,12 +6165,12 @@ mch_signal_job(job_T *job, char_u *how)
     void
 mch_clear_job(job_T *job)
 {
-    if (job->jv_status != JOB_FAILED)
-    {
-	if (job->jv_job_object != NULL)
-	    CloseHandle(job->jv_job_object);
-	CloseHandle(job->jv_proc_info.hProcess);
-    }
+    if (job->jv_status == JOB_FAILED)
+	return;
+
+    if (job->jv_job_object != NULL)
+	CloseHandle(job->jv_job_object);
+    CloseHandle(job->jv_proc_info.hProcess);
 }
 #endif
 
@@ -7988,32 +7983,32 @@ load_ntdll(void)
 {
     static int	loaded = -1;
 
-    if (loaded == -1)
-    {
-	HMODULE hNtdll = GetModuleHandle("ntdll.dll");
-	if (hNtdll != NULL)
-	{
-	    pNtOpenFile = (PfnNtOpenFile) GetProcAddress(hNtdll, "NtOpenFile");
-	    pNtClose = (PfnNtClose) GetProcAddress(hNtdll, "NtClose");
-	    pNtSetEaFile = (PfnNtSetEaFile)
-		GetProcAddress(hNtdll, "NtSetEaFile");
-	    pNtQueryEaFile = (PfnNtQueryEaFile)
-		GetProcAddress(hNtdll, "NtQueryEaFile");
-	    pNtQueryInformationFile = (PfnNtQueryInformationFile)
-		GetProcAddress(hNtdll, "NtQueryInformationFile");
-	    pRtlInitUnicodeString = (PfnRtlInitUnicodeString)
-		GetProcAddress(hNtdll, "RtlInitUnicodeString");
-	}
-	if (pNtOpenFile == NULL
-		|| pNtClose == NULL
-		|| pNtSetEaFile == NULL
-		|| pNtQueryEaFile == NULL
-		|| pNtQueryInformationFile == NULL
-		|| pRtlInitUnicodeString == NULL)
-	    loaded = FALSE;
-	else
-	    loaded = TRUE;
-    }
+    if (loaded != -1)
+	return (BOOL) loaded;
+
+    HMODULE hNtdll = GetModuleHandle("ntdll.dll");
+    if (hNtdll != NULL)
+    {
+	pNtOpenFile = (PfnNtOpenFile) GetProcAddress(hNtdll, "NtOpenFile");
+	pNtClose = (PfnNtClose) GetProcAddress(hNtdll, "NtClose");
+	pNtSetEaFile = (PfnNtSetEaFile)
+	    GetProcAddress(hNtdll, "NtSetEaFile");
+	pNtQueryEaFile = (PfnNtQueryEaFile)
+	    GetProcAddress(hNtdll, "NtQueryEaFile");
+	pNtQueryInformationFile = (PfnNtQueryInformationFile)
+	    GetProcAddress(hNtdll, "NtQueryInformationFile");
+	pRtlInitUnicodeString = (PfnRtlInitUnicodeString)
+	    GetProcAddress(hNtdll, "RtlInitUnicodeString");
+    }
+    if (pNtOpenFile == NULL
+	    || pNtClose == NULL
+	    || pNtSetEaFile == NULL
+	    || pNtQueryEaFile == NULL
+	    || pNtQueryInformationFile == NULL
+	    || pRtlInitUnicodeString == NULL)
+	loaded = FALSE;
+    else
+	loaded = TRUE;
     return (BOOL) loaded;
 }
 
@@ -8190,11 +8185,11 @@ get_cmd_argsW(char ***argvp)
     void
 free_cmd_argsW(void)
 {
-    if (ArglistW != NULL)
-    {
-	GlobalFree(ArglistW);
-	ArglistW = NULL;
-    }
+    if (ArglistW == NULL)
+	return;
+
+    GlobalFree(ArglistW);
+    ArglistW = NULL;
 }
 
 /*
@@ -8899,20 +8894,20 @@ resize_console_buf(void)
     COORD coord;
     SMALL_RECT newsize;
 
-    if (GetConsoleScreenBufferInfo(g_hConOut, &csbi))
-    {
-	coord.X = SRWIDTH(csbi.srWindow);
-	coord.Y = SRHEIGHT(csbi.srWindow);
-	SetConsoleScreenBufferSize(g_hConOut, coord);
-
-	newsize.Left = 0;
-	newsize.Top = 0;
-	newsize.Right = coord.X - 1;
-	newsize.Bottom = coord.Y - 1;
-	SetConsoleWindowInfo(g_hConOut, TRUE, &newsize);
-
-	SetConsoleScreenBufferSize(g_hConOut, coord);
-    }
+    if (!GetConsoleScreenBufferInfo(g_hConOut, &csbi))
+	return;
+
+    coord.X = SRWIDTH(csbi.srWindow);
+    coord.Y = SRHEIGHT(csbi.srWindow);
+    SetConsoleScreenBufferSize(g_hConOut, coord);
+
+    newsize.Left = 0;
+    newsize.Top = 0;
+    newsize.Right = coord.X - 1;
+    newsize.Bottom = coord.Y - 1;
+    SetConsoleWindowInfo(g_hConOut, TRUE, &newsize);
+
+    SetConsoleScreenBufferSize(g_hConOut, coord);
 }
 #endif
 
@@ -8926,14 +8921,14 @@ GetWin32Error(void)
 	    NULL, GetLastError(), 0, (LPSTR)&msg, 0, NULL);
     if (oldmsg != NULL)
 	LocalFree(oldmsg);
-    if (msg != NULL)
-    {
-	// remove trailing \r\n
-	char *pcrlf = strstr(msg, "\r\n");
-	if (pcrlf != NULL)
-	    *pcrlf = '\0';
-	oldmsg = msg;
-    }
+    if (msg == NULL)
+	return NULL;
+
+    // remove trailing \r\n
+    char *pcrlf = strstr(msg, "\r\n");
+    if (pcrlf != NULL)
+	*pcrlf = '\0';
+    oldmsg = msg;
     return msg;
 }
 
--- 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 */
 /**/
+    1208,
+/**/
     1207,
 /**/
     1206,