0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -04:00

patch 8.1.0805: too many #ifdefs

Problem:    Too many #ifdefs.
Solution:   Graduate FEAT_MBYTE, part 1.
This commit is contained in:
Bram Moolenaar
2019-01-24 15:04:48 +01:00
parent 4b9e91f0ba
commit 135059724f
17 changed files with 234 additions and 1147 deletions

View File

@@ -15,11 +15,7 @@
#if defined(FEAT_DIGRAPHS) || defined(PROTO)
#ifdef FEAT_MBYTE
typedef int result_T;
#else
typedef char_u result_T;
#endif
typedef struct digraph
{
@@ -38,8 +34,8 @@ static garray_T user_digraphs = {0, 0, (int)sizeof(digr_T), 10, NULL};
* compilers cannot handle them (Amiga SAS/C is the most picky one).
*/
static digr_T digraphdefault[] =
#ifdef __MINT__
#ifdef __MINT__
/*
* ATARI digraphs
*/
@@ -320,137 +316,7 @@ static digr_T digraphdefault[] =
};
# else
# if defined(MACOS_X) && !defined(FEAT_MBYTE)
/*
* Macintosh digraphs
*/
{{'a', 't', 64}, /* @ */
{'A', '"', 128}, /* ~@ XX */
{'A', 'o', 129}, /* <20> */
{'C', ',', 130}, /* <20> */
{'E', '\'', 131}, /* <20> */
{'N', '~', 132}, /* <20> */
{'O', '"', 133}, /* <20> */
{'U', '"', 134}, /* <20> */
{'a', '\'', 135}, /* ~G XX */
{'a', '`', 136}, /* ~H XX */
{'a', '^', 137}, /* <20> */
{'a', '"', 138}, /* <20> */
{'a', '~', 139}, /* <20> */
{'a', 'o', 140}, /* <20> */
{'c', ',', 141}, /* <20> */
{'e', '\'', 142}, /* <20> */
{'e', '`', 143}, /* <20> */
{'e', '^', 144}, /* <20> */
{'e', '"', 145}, /* <20> */
{'i', '\'', 146}, /* <20> */
{'i', '`', 147}, /* <20> */
{'i', '^', 148}, /* <20> */
{'i', '"', 149}, /* <20> */
{'n', '~', 150}, /* <20> */
{'o', '\'', 151}, /* <20> */
{'o', '`', 152}, /* <20> */
{'o', '^', 153}, /* <20> */
{'o', '"', 154}, /* <20> */
{'o', '~', 155}, /* o */
{'u', '\'', 156}, /* <20> */
{'u', '`', 157}, /* ~] XX */
{'u', '^', 158}, /* <20> */
{'u', '"', 159}, /* <20> */
{'+', '_', 160}, /* <20> */
{'~', 'o', 161}, /* <20> */
{'c', '|', 162}, /* <20> */
{'$', '$', 163}, /* <20> */
{'p', 'a', 164}, /* <20> */
{'.', '.', 165}, /* * */
{'P', 'P', 166}, /* <20> */
{'s', 's', 167}, /* <20> */
{'r', 'O', 168}, /* <20> */
{'c', 'O', 169}, /* <20> */
{'T', 'M', 170}, /* <20> */
{'=', '/', 173}, /* <20> */
{'A', 'E', 174}, /* <20> */
{'O', '/', 175}, /* <20> */
{'0', '0', 176}, /* <20> */
{'+', '-', 177}, /* <20> */
{'<', '=', 178}, /* <20> */
{'>', '=', 179}, /* <20> */
{'Y', '-', 180}, /* <20> */
{'j', 'u', 181}, /* <20> */
{'m', 'u', 181}, /* <20> */
{'d', 'd', 182}, /* <20> */
{'S', 'S', 183}, /* <20> */
{'S', 'I', 183}, /* <20> */
{'P', 'I', 184}, /* <20> */
{'p', 'i', 185}, /* <20> */
{'I', 'I', 186}, /* <20> */
{'a', '-', 187}, /* <20> */
{'o', '-', 188}, /* <20> */
{'O', 'M', 189}, /* <20> */
{'a', 'e', 190}, /* <20> */
{'o', '/', 191}, /* <20> */
{'~', '?', 192}, /* <20> */
{'~', '!', 193}, /* <20> */
{'-', ',', 194}, /* <20> */
{'v', '-', 195}, /* ~H XX */
{'f', '-', 196}, /* <20> */
{'~', '~', 197}, /* <20> */
{'D', 'E', 198}, /* <20> */
{'<', '<', 199}, /* <20> */
{'>', '>', 200}, /* <20> */
{'.', ':', 201}, /* <20> */
{'A', '`', 203}, /* <20> */
{'A', '~', 204}, /* <20> */
{'O', '~', 205}, /* <20> */
{'O', 'E', 206}, /* <20> */
{'o', 'e', 207}, /* <20> */
{'-', '.', 208}, /* - */
{'-', '-', 209}, /* - */
{'`', '`', 210}, /* " */
{'\'', '\'', 211}, /* " */
{'`', ' ', 212}, /* ' */
{'\'', ' ', 213}, /* ' */
{'-', ':', 214}, /* <20> */
{'D', 'I', 215}, /* <20> */
{'y', ':', 216}, /* <20> */
{'Y', ':', 217}, /* <20> */
{'/', '/', 218}, /* <20> */
{'E', '=', 219}, /* <20> Euro System >=8.5 */
{'o', 'x', 219}, /* <20> Currency System <=8.1*/
{'<', ' ', 220}, /* <20> */
{'>', ' ', 221}, /* <20> */
{'f', 'i', 222}, /* <20> */
{'f', 'l', 223}, /* <20> */
{'+', '+', 224}, /* <20> */
{'~', '.', 225}, /* <20> */
{',', ' ', 226}, /* <20> */
{',', ',', 227}, /* <20> */
{'%', '.', 228}, /* <20> */
{'%', '0', 228}, /* <20> */
{'A', '^', 229}, /* <20> */
{'E', '^', 230}, /* <20> */
{'A', '\'', 231}, /* <20> */
{'E', '"', 232}, /* <20> */
{'E', '`', 233}, /* <20> */
{'I', '\'', 234}, /* <20> */
{'I', '^', 235}, /* <20> */
{'I', '"', 236}, /* <20> */
{'I', '`', 237}, /* <20> */
{'O', '\'', 238}, /* <20> */
{'O', '^', 239}, /* <20> */
{'A', 'P', 240}, /* <20> */
{'O', '`', 241}, /* <20> */
{'U', '\'', 242}, /* <20> */
{'U', '^', 243}, /* <20> */
{'U', '`', 244}, /* <20> */
{'i', '.', 245}, /* <20> */
{NUL, NUL, NUL}
};
# else /* !MACOS_X */
# ifdef OLD_DIGRAPHS
# ifdef OLD_DIGRAPHS
/*
* digraphs compatible with Vim 5.x
@@ -557,7 +423,7 @@ static digr_T digraphdefault[] =
{'y', '"', 255}, /* x XX */
{NUL, NUL, NUL}
};
# else /* OLD_DIGRAPHS */
# else /* OLD_DIGRAPHS */
/*
* digraphs for Unicode from RFC1345
@@ -792,7 +658,6 @@ static digr_T digraphdefault[] =
{'y', ':', 0xff},
{'y', '"', 0xff}, // x XX Vim 5.x compatible
# ifdef FEAT_MBYTE
# define USE_UNICODE_DIGRAPHS
{'A', '-', 0x0100},
@@ -1957,14 +1822,11 @@ static digr_T digraphdefault[] =
{'f', 'l', 0xfb02},
{'f', 't', 0xfb05},
{'s', 't', 0xfb06},
# endif /* FEAT_MBYTE */
{NUL, NUL, NUL}
};
# endif /* OLD_DIGRAPHS */
# endif /* Macintosh */
# endif /* OLD_DIGRAPHS */
# endif /* EBCDIC */
# endif /* !HPUX_DIGRAPHS */
#endif /* !__MINT__ */
@@ -2141,8 +2003,7 @@ getexactdigraph(int char1, int char2, int meta_char)
++dp;
}
}
#ifdef FEAT_MBYTE
# ifdef USE_UNICODE_DIGRAPHS
#ifdef USE_UNICODE_DIGRAPHS
if (retval != 0 && !enc_utf8)
{
char_u buf[6], *to;
@@ -2166,12 +2027,11 @@ getexactdigraph(int char1, int char2, int meta_char)
(void)convert_setup(&vc, NULL, NULL);
}
}
# endif
#endif
/* Ignore multi-byte characters when not in multi-byte mode. */
if (!has_mbyte && retval > 0xff)
retval = 0;
#endif
if (retval == 0) /* digraph deleted or not found */
{
@@ -2297,10 +2157,7 @@ listdigraphs(int use_headers)
#else
if (getexactdigraph(dp->char1, dp->char2, FALSE) == dp->result
# ifdef FEAT_MBYTE
&& (has_mbyte || dp->result <= 255)
# endif
)
&& (has_mbyte || dp->result <= 255))
printdigraph(dp, use_headers ? &previous : NULL);
#endif
++dp;
@@ -2364,11 +2221,7 @@ printdigraph(digr_T *dp, result_T *previous)
int list_width;
if ((dy_flags & DY_UHEX)
#ifdef FEAT_MBYTE
|| has_mbyte
#endif
)
if ((dy_flags & DY_UHEX) || has_mbyte)
list_width = 13;
else
list_width = 11;
@@ -2404,7 +2257,6 @@ printdigraph(digr_T *dp, result_T *previous)
*p = NUL;
msg_outtrans(buf);
p = buf;
#ifdef FEAT_MBYTE
if (has_mbyte)
{
/* add a space to draw a composing char on */
@@ -2413,7 +2265,6 @@ printdigraph(digr_T *dp, result_T *previous)
p += (*mb_char2bytes)(dp->result, p);
}
else
#endif
*p++ = (char_u)dp->result;
*p = NUL;
msg_outtrans_attr(buf, HL_ATTR(HLF_8));
@@ -2465,21 +2316,15 @@ keymap_init(void)
/* Source the keymap file. It will contain a ":loadkeymap" command
* which will call ex_loadkeymap() below. */
buflen = STRLEN(curbuf->b_p_keymap)
# ifdef FEAT_MBYTE
+ STRLEN(p_enc)
# endif
+ 14;
buflen = STRLEN(curbuf->b_p_keymap) + STRLEN(p_enc) + 14;
buf = alloc((unsigned)buflen);
if (buf == NULL)
return e_outofmem;
# ifdef FEAT_MBYTE
/* try finding "keymap/'keymap'_'encoding'.vim" in 'runtimepath' */
vim_snprintf((char *)buf, buflen, "keymap/%s_%s.vim",
curbuf->b_p_keymap, p_enc);
if (source_runtime(buf, 0) == FAIL)
# endif
{
/* try finding "keymap/'keymap'.vim" in 'runtimepath' */
vim_snprintf((char *)buf, buflen, "keymap/%s.vim",