diff src/search.c @ 15605:62b3805506b3 v8.1.0810

patch 8.1.0810: too many #ifdefs commit https://github.com/vim/vim/commit/264b74fa545edfb92c0d7d08a02c26331cc5b168 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Jan 24 17:18:42 2019 +0100 patch 8.1.0810: too many #ifdefs Problem: Too many #ifdefs. Solution: Graduate FEAT_MBYTE, part 4.
author Bram Moolenaar <Bram@vim.org>
date Thu, 24 Jan 2019 17:30:08 +0100
parents d89c5b339c2a
children 6f1c7e9a6393
line wrap: on
line diff
--- a/src/search.c
+++ b/src/search.c
@@ -85,10 +85,8 @@ static int last_idx = 0;	/* index in spa
 static char_u lastc[2] = {NUL, NUL};	/* last character searched for */
 static int lastcdir = FORWARD;		/* last direction of character search */
 static int last_t_cmd = TRUE;		/* last search t_cmd */
-#ifdef FEAT_MBYTE
 static char_u	lastc_bytes[MB_MAXBYTES + 1];
 static int	lastc_bytelen = 1;	/* >1 for multi-byte char */
-#endif
 
 /* copy of spats[], for keeping the search patterns while executing autocmds */
 static struct spat  saved_spats[2];
@@ -248,7 +246,6 @@ reverse_text(char_u *s)
 	rev_i = len;
 	for (s_i = 0; s_i < len; ++s_i)
 	{
-# ifdef FEAT_MBYTE
 	    if (has_mbyte)
 	    {
 		int	mb_len;
@@ -259,7 +256,6 @@ reverse_text(char_u *s)
 		s_i += mb_len - 1;
 	    }
 	    else
-# endif
 		rev[--rev_i] = s[s_i];
 
 	}
@@ -446,7 +442,6 @@ pat_has_uppercase(char_u *pat)
 
     while (*p != NUL)
     {
-#ifdef FEAT_MBYTE
 	int		l;
 
 	if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1)
@@ -455,9 +450,7 @@ pat_has_uppercase(char_u *pat)
 		return TRUE;
 	    p += l;
 	}
-	else
-#endif
-	     if (*p == '\\')
+	else if (*p == '\\')
 	{
 	    if (p[1] == '_' && p[2] != NUL)  /* skip "\_X" */
 		p += 3;
@@ -480,11 +473,7 @@ pat_has_uppercase(char_u *pat)
     char_u *
 last_csearch(void)
 {
-#ifdef FEAT_MBYTE
     return lastc_bytes;
-#else
-    return lastc;
-#endif
 }
 
     int
@@ -503,13 +492,11 @@ last_csearch_until(void)
 set_last_csearch(int c, char_u *s UNUSED, int len UNUSED)
 {
     *lastc = c;
-#ifdef FEAT_MBYTE
     lastc_bytelen = len;
     if (len)
 	memcpy(lastc_bytes, s, len);
     else
 	vim_memset(lastc_bytes, 0, sizeof(lastc_bytes));
-#endif
 }
 #endif
 
@@ -687,7 +674,6 @@ searchit(
 	 * MAXCOL + 1 is zero. */
 	if (pos->col == MAXCOL)
 	    start_char_len = 0;
-#ifdef FEAT_MBYTE
 	/* Watch out for the "col" being MAXCOL - 2, used in a closed fold. */
 	else if (has_mbyte
 		    && pos->lnum >= 1 && pos->lnum <= buf->b_ml.ml_line_count
@@ -699,7 +685,6 @@ searchit(
 	    else
 		start_char_len = (*mb_ptr2len)(ptr + pos->col);
 	}
-#endif
 	else
 	    start_char_len = 1;
 	if (dir == FORWARD)
@@ -835,12 +820,10 @@ searchit(
 				if (matchcol == matchpos.col
 						      && ptr[matchcol] != NUL)
 				{
-#ifdef FEAT_MBYTE
 				    if (has_mbyte)
 					matchcol +=
 					  (*mb_ptr2len)(ptr + matchcol);
 				    else
-#endif
 					++matchcol;
 				}
 			    }
@@ -849,12 +832,10 @@ searchit(
 				matchcol = matchpos.col;
 				if (ptr[matchcol] != NUL)
 				{
-#ifdef FEAT_MBYTE
 				    if (has_mbyte)
 					matchcol += (*mb_ptr2len)(ptr
 								  + matchcol);
 				    else
-#endif
 					++matchcol;
 				}
 			    }
@@ -946,12 +927,10 @@ searchit(
 				if (matchcol == matchpos.col
 						      && ptr[matchcol] != NUL)
 				{
-#ifdef FEAT_MBYTE
 				    if (has_mbyte)
 					matchcol +=
 					  (*mb_ptr2len)(ptr + matchcol);
 				    else
-#endif
 					++matchcol;
 				}
 			    }
@@ -963,12 +942,10 @@ searchit(
 				matchcol = matchpos.col;
 				if (ptr[matchcol] != NUL)
 				{
-#ifdef FEAT_MBYTE
 				    if (has_mbyte)
 					matchcol +=
 					  (*mb_ptr2len)(ptr + matchcol);
 				    else
-#endif
 					++matchcol;
 				}
 			    }
@@ -1029,14 +1006,12 @@ searchit(
 			else
 			{
 			    --pos->col;
-#ifdef FEAT_MBYTE
 			    if (has_mbyte
 				    && pos->lnum <= buf->b_ml.ml_line_count)
 			    {
 				ptr = ml_get_buf(buf, pos->lnum, FALSE);
 				pos->col -= (*mb_head_off)(ptr, ptr + pos->col);
 			    }
-#endif
 			}
 			if (end_pos != NULL)
 			{
@@ -1410,7 +1385,6 @@ do_search(
 	    if (msgbuf != NULL)
 	    {
 		msgbuf[0] = dirc;
-#ifdef FEAT_MBYTE
 		if (enc_utf8 && utf_iscomposing(utf_ptr2char(p)))
 		{
 		    /* Use a space to draw the composing char on. */
@@ -1418,7 +1392,6 @@ do_search(
 		    STRCPY(msgbuf + 2, p);
 		}
 		else
-#endif
 		    STRCPY(msgbuf + 1, p);
 		if (spats[0].off.line || spats[0].off.end || spats[0].off.off)
 		{
@@ -1711,7 +1684,6 @@ searchc(cmdarg_T *cap, int t_cmd)
 	    *lastc = c;
 	    set_csearch_direction(dir);
 	    set_csearch_until(t_cmd);
-#ifdef FEAT_MBYTE
 	    lastc_bytelen = (*mb_char2bytes)(c, lastc_bytes);
 	    if (cap->ncharC1 != 0)
 	    {
@@ -1721,16 +1693,11 @@ searchc(cmdarg_T *cap, int t_cmd)
 		    lastc_bytelen += (*mb_char2bytes)(cap->ncharC2,
 			    lastc_bytes + lastc_bytelen);
 	    }
-#endif
 	}
     }
     else		/* repeat previous search */
     {
-	if (*lastc == NUL
-#ifdef FEAT_MBYTE
-		&& lastc_bytelen == 1
-#endif
-		)
+	if (*lastc == NUL && lastc_bytelen == 1)
 	    return FAIL;
 	if (dir)	/* repeat in opposite direction */
 	    dir = -lastcdir;
@@ -1758,7 +1725,6 @@ searchc(cmdarg_T *cap, int t_cmd)
 
     while (count--)
     {
-#ifdef FEAT_MBYTE
 	if (has_mbyte)
 	{
 	    for (;;)
@@ -1787,7 +1753,6 @@ searchc(cmdarg_T *cap, int t_cmd)
 	    }
 	}
 	else
-#endif
 	{
 	    for (;;)
 	    {
@@ -1804,7 +1769,6 @@ searchc(cmdarg_T *cap, int t_cmd)
     {
 	/* backup to before the character (possibly double-byte) */
 	col -= dir;
-#ifdef FEAT_MBYTE
 	if (has_mbyte)
 	{
 	    if (dir < 0)
@@ -1814,7 +1778,6 @@ searchc(cmdarg_T *cap, int t_cmd)
 		/* To previous char, which may be multi-byte. */
 		col -= (*mb_head_off)(p, p + col);
 	}
-#endif
     }
     curwin->w_cursor.col = col;
 
@@ -1851,10 +1814,8 @@ check_prevcol(
     int		*prevcol)
 {
     --col;
-#ifdef FEAT_MBYTE
     if (col > 0 && has_mbyte)
 	col -= (*mb_head_off)(linep, linep + col);
-#endif
     if (prevcol)
 	*prevcol = col;
     return (col >= 0 && linep[col] == ch) ? TRUE : FALSE;
@@ -2237,10 +2198,8 @@ findmatchlimit(
 	    else
 	    {
 		--pos.col;
-#ifdef FEAT_MBYTE
 		if (has_mbyte)
 		    pos.col -= (*mb_head_off)(linep, linep + pos.col);
-#endif
 	    }
 	}
 	else				/* forward search */
@@ -2278,11 +2237,9 @@ findmatchlimit(
 	    }
 	    else
 	    {
-#ifdef FEAT_MBYTE
 		if (has_mbyte)
 		    pos.col += (*mb_ptr2len)(linep + pos.col);
 		else
-#endif
 		    ++pos.col;
 	    }
 	}
@@ -2934,10 +2891,8 @@ findpar(
 	if ((curwin->w_cursor.col = (colnr_T)STRLEN(line)) != 0)
 	{
 	    --curwin->w_cursor.col;
-#ifdef FEAT_MBYTE
 	    curwin->w_cursor.col -=
 			     (*mb_head_off)(line, line + curwin->w_cursor.col);
-#endif
 	    *pincl = TRUE;
 	}
     }
@@ -3029,7 +2984,6 @@ cls(void)
 #endif
     if (c == ' ' || c == '\t' || c == NUL)
 	return 0;
-#ifdef FEAT_MBYTE
     if (enc_dbcs != 0 && c > 0xFF)
     {
 	/* If cls_bigword, report multi-byte chars as class 1. */
@@ -3046,7 +3000,6 @@ cls(void)
 	    return 1;
 	return c;
     }
-#endif
 
     /* If cls_bigword is TRUE, report all non-blanks as class 1. */
     if (cls_bigword)
@@ -3903,7 +3856,6 @@ in_html_tag(
     int		lc = NUL;
     pos_T	pos;
 
-#ifdef FEAT_MBYTE
     if (enc_dbcs)
     {
 	char_u	*lp = NULL;
@@ -3924,7 +3876,6 @@ in_html_tag(
 	}
     }
     else
-#endif
     {
 	for (p = line + curwin->w_cursor.col; p > line; )
 	{
@@ -4371,11 +4322,9 @@ find_next_quote(
 	    ++col;
 	else if (c == quotechar)
 	    break;
-#ifdef FEAT_MBYTE
 	if (has_mbyte)
 	    col += (*mb_ptr2len)(line + col);
 	else
-#endif
 	    ++col;
     }
     return col;
@@ -4399,9 +4348,7 @@ find_prev_quote(
     while (col_start > 0)
     {
 	--col_start;
-#ifdef FEAT_MBYTE
 	col_start -= (*mb_head_off)(line, line + col_start);
-#endif
 	n = 0;
 	if (escape != NULL)
 	    while (col_start - n > 0 && vim_strchr(escape,