patch 8.1.0806: too many #ifdefs
Problem: Too many #ifdefs.
Solution: Graduate FEAT_MBYTE, part 2.
diff --git a/src/misc2.c b/src/misc2.c
index b1cf8b5..1f5f752 100644
--- a/src/misc2.c
+++ b/src/misc2.c
@@ -73,7 +73,7 @@
* Get the screen position of character col with a coladd in the cursor line.
*/
int
-getviscol2(colnr_T col, colnr_T coladd)
+getviscol2(colnr_T col, colnr_T coladd UNUSED)
{
colnr_T x;
pos_T pos;
@@ -320,11 +320,9 @@
}
#endif
-#ifdef FEAT_MBYTE
/* prevent from moving onto a trail byte */
if (has_mbyte)
mb_adjustpos(curbuf, pos);
-#endif
if (col < wcol)
return FAIL;
@@ -358,7 +356,6 @@
p = ml_get_pos(lp);
if (*p != NUL) /* still within line, move to next char (may be NUL) */
{
-#ifdef FEAT_MBYTE
if (has_mbyte)
{
int l = (*mb_ptr2len)(p);
@@ -366,7 +363,6 @@
lp->col += l;
return ((p[l] != NUL) ? 0 : 2);
}
-#endif
lp->col++;
#ifdef FEAT_VIRTUALEDIT
lp->coladd = 0;
@@ -424,10 +420,8 @@
/* past end of line */
p = ml_get(lp->lnum);
lp->col = (colnr_T)STRLEN(p);
-#ifdef FEAT_MBYTE
if (has_mbyte)
lp->col -= (*mb_head_off)(p, p + lp->col);
-#endif
return 0;
}
@@ -435,13 +429,11 @@
{
/* still within line */
lp->col--;
-#ifdef FEAT_MBYTE
if (has_mbyte)
{
p = ml_get(lp->lnum);
lp->col -= (*mb_head_off)(p, p + lp->col);
}
-#endif
return 0;
}
@@ -451,10 +443,8 @@
lp->lnum--;
p = ml_get(lp->lnum);
lp->col = (colnr_T)STRLEN(p);
-#ifdef FEAT_MBYTE
if (has_mbyte)
lp->col -= (*mb_head_off)(p, p + lp->col);
-#endif
return 1;
}
@@ -608,11 +598,9 @@
else
{
win->w_cursor.col = len - 1;
-#ifdef FEAT_MBYTE
/* Move the cursor to the head byte. */
if (has_mbyte)
mb_adjustpos(win->w_buffer, &win->w_cursor);
-#endif
}
}
else if (win->w_cursor.col < 0)
@@ -1394,9 +1382,7 @@
char_u *p2;
char_u *escaped_string;
unsigned length;
-#ifdef FEAT_MBYTE
int l;
-#endif
/*
* First count the number of backslashes required.
@@ -1405,14 +1391,12 @@
length = 1; /* count the trailing NUL */
for (p = string; *p; p++)
{
-#ifdef FEAT_MBYTE
if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1)
{
length += l; /* count a multibyte char */
p += l - 1;
continue;
}
-#endif
if (vim_strchr(esc_chars, *p) != NULL || (bsl && rem_backslash(p)))
++length; /* count a backslash */
++length; /* count an ordinary char */
@@ -1423,7 +1407,6 @@
p2 = escaped_string;
for (p = string; *p; p++)
{
-#ifdef FEAT_MBYTE
if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1)
{
mch_memmove(p2, p, (size_t)l);
@@ -1431,7 +1414,6 @@
p += l - 1; /* skip multibyte char */
continue;
}
-#endif
if (vim_strchr(esc_chars, *p) != NULL || (bsl && rem_backslash(p)))
*p2++ = cc;
*p2++ = *p;
@@ -1642,7 +1624,6 @@
if (res != NULL)
while (*p != NUL)
{
-# ifdef FEAT_MBYTE
int l;
if (enc_utf8)
@@ -1685,7 +1666,6 @@
else if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1)
p += l; /* skip multi-byte character */
else
-# endif
{
*p = TOUPPER_LOC(*p); /* note that toupper() can be a macro */
p++;
@@ -1711,7 +1691,6 @@
if (res != NULL)
while (*p != NUL)
{
-# ifdef FEAT_MBYTE
int l;
if (enc_utf8)
@@ -1754,7 +1733,6 @@
else if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1)
p += l; /* skip multi-byte character */
else
-# endif
{
*p = TOLOWER_LOC(*p); /* note that tolower() can be a macro */
p++;
@@ -1943,7 +1921,6 @@
int b;
p = string;
-#ifdef FEAT_MBYTE
if (enc_utf8 && c >= 0x80)
{
while (*p != NUL)
@@ -1980,7 +1957,6 @@
}
return NULL;
}
-#endif
while ((b = *p) != NUL)
{
if (b == c)
@@ -2713,11 +2689,7 @@
* When not a known special key, and not a printable character, try to
* extract modifiers.
*/
- if (c > 0
-#ifdef FEAT_MBYTE
- && (*mb_char2len)(c) == 1
-#endif
- )
+ if (c > 0 && (*mb_char2len)(c) == 1)
{
if (table_idx < 0
&& (!vim_isprintc(c) || (c & 0x7f) == ' ')
@@ -2760,12 +2732,9 @@
/* Not a special key, only modifiers, output directly */
else
{
-#ifdef FEAT_MBYTE
if (has_mbyte && (*mb_char2len)(c) > 1)
idx += (*mb_char2bytes)(c, string + idx);
- else
-#endif
- if (vim_isprintc(c))
+ else if (vim_isprintc(c))
string[idx++] = c;
else
{
@@ -2825,10 +2794,8 @@
dst[dlen++] = KEY2TERMCAP0(key);
dst[dlen++] = KEY2TERMCAP1(key);
}
-#ifdef FEAT_MBYTE
else if (has_mbyte && !keycode)
dlen += (*mb_char2bytes)(key, dst + dlen);
-#endif
else if (keycode)
dlen = (int)(add_char2buf(key, dst + dlen) - dst);
else
@@ -2873,11 +2840,9 @@
last_dash = bp;
if (bp[1] != NUL)
{
-#ifdef FEAT_MBYTE
if (has_mbyte)
l = mb_ptr2len(bp + 1);
else
-#endif
l = 1;
/* Anything accepted, like <C-?>.
* <C-"> or <M-"> are not special in strings as " is
@@ -2935,11 +2900,9 @@
/* Modifier with single letter, or special key name. */
if (in_string && last_dash[1] == '\\' && last_dash[2] == '"')
off = 2;
-#ifdef FEAT_MBYTE
if (has_mbyte)
l = mb_ptr2len(last_dash + off);
else
-#endif
l = 1;
if (modifiers != 0 && last_dash[l + off] == '>')
key = PTR2CHAR(last_dash + off);
@@ -3028,10 +2991,7 @@
if (!(modifiers & MOD_MASK_CMD))
#endif
if ((modifiers & MOD_MASK_ALT) && key < 0x80
-#ifdef FEAT_MBYTE
- && !enc_dbcs /* avoid creating a lead byte */
-#endif
- )
+ && !enc_dbcs) // avoid creating a lead byte
{
key |= 0x80;
modifiers &= ~MOD_MASK_ALT; /* remove the META modifier */
@@ -3377,7 +3337,6 @@
return State;
}
-#if defined(FEAT_MBYTE) || defined(PROTO)
/*
* Return TRUE if "p" points to just after a path separator.
* Takes care of multi-byte characters.
@@ -3389,7 +3348,6 @@
return p > b && vim_ispathsep(p[-1])
&& (!has_mbyte || (*mb_head_off)(b, p - 1) == 0);
}
-#endif
/*
* Return TRUE if file names "f1" and "f2" are in the same directory.
@@ -6376,8 +6334,7 @@
#endif
-#if (defined(FEAT_MBYTE) && defined(FEAT_QUICKFIX)) \
- || defined(FEAT_SPELL) || defined(PROTO)
+#if defined(FEAT_QUICKFIX) || defined(FEAT_SPELL) || defined(PROTO)
/*
* Return TRUE if string "s" contains a non-ASCII character (128 or higher).
* When "s" is NULL FALSE is returned.