comparison src/vim.h @ 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 dd725a8ab112
children 2dcaa860e3fc
comparison
equal deleted inserted replaced
15604:5d64befd4ab4 15605:62b3805506b3
208 # undef FEAT_CLIENTSERVER 208 # undef FEAT_CLIENTSERVER
209 # endif 209 # endif
210 #endif 210 #endif
211 211
212 /* The Mac conversion stuff doesn't work under X11. */ 212 /* The Mac conversion stuff doesn't work under X11. */
213 #if defined(FEAT_MBYTE) && defined(MACOS_X_DARWIN) 213 #if defined(MACOS_X_DARWIN)
214 # define MACOS_CONVERT 214 # define MACOS_CONVERT
215 #endif 215 #endif
216 216
217 /* Can't use "PACKAGE" here, conflicts with a Perl include file. */ 217 /* Can't use "PACKAGE" here, conflicts with a Perl include file. */
218 #ifndef VIMPACKAGE 218 #ifndef VIMPACKAGE
429 * The u8char_T can hold one decoded UTF-8 character. 429 * The u8char_T can hold one decoded UTF-8 character.
430 * We normally use 32 bits now, since some Asian characters don't fit in 16 430 * We normally use 32 bits now, since some Asian characters don't fit in 16
431 * bits. u8char_T is only used for displaying, it could be 16 bits to save 431 * bits. u8char_T is only used for displaying, it could be 16 bits to save
432 * memory. 432 * memory.
433 */ 433 */
434 #ifdef FEAT_MBYTE 434 #ifdef UNICODE16
435 # ifdef UNICODE16
436 typedef unsigned short u8char_T; /* short should be 16 bits */ 435 typedef unsigned short u8char_T; /* short should be 16 bits */
437 # else 436 #else
438 # if VIM_SIZEOF_INT >= 4 437 typedef unsigned int u8char_T; /* int is 32 bits or more */
439 typedef unsigned int u8char_T; /* int is 32 bits */
440 # else
441 typedef unsigned long u8char_T; /* long should be 32 bits or more */
442 # endif
443 # endif
444 #endif 438 #endif
445 439
446 #ifndef UNIX /* For Unix this is included in os_unix.h */ 440 #ifndef UNIX /* For Unix this is included in os_unix.h */
447 # include <stdio.h> 441 # include <stdio.h>
448 # include <ctype.h> 442 # include <ctype.h>
1514 1508
1515 #define IOSIZE (1024+1) /* file i/o and sprintf buffer size */ 1509 #define IOSIZE (1024+1) /* file i/o and sprintf buffer size */
1516 1510
1517 #define DIALOG_MSG_SIZE 1000 /* buffer size for dialog_msg() */ 1511 #define DIALOG_MSG_SIZE 1000 /* buffer size for dialog_msg() */
1518 1512
1519 #ifdef FEAT_MBYTE 1513 #define MSG_BUF_LEN 480 /* length of buffer for small messages */
1520 # define MSG_BUF_LEN 480 /* length of buffer for small messages */ 1514 #define MSG_BUF_CLEN (MSG_BUF_LEN / 6) /* cell length (worst case: utf-8
1521 # define MSG_BUF_CLEN (MSG_BUF_LEN / 6) /* cell length (worst case: utf-8
1522 takes 6 bytes for one cell) */ 1515 takes 6 bytes for one cell) */
1523 #else
1524 # define MSG_BUF_LEN 80 /* length of buffer for small messages */
1525 # define MSG_BUF_CLEN MSG_BUF_LEN /* cell length */
1526 #endif
1527 1516
1528 #define FOLD_TEXT_LEN 51 /* buffer size for get_foldtext() */ 1517 #define FOLD_TEXT_LEN 51 /* buffer size for get_foldtext() */
1529 1518
1530 /* Size of the buffer used for tgetent(). Unfortunately this is largely 1519 /* Size of the buffer used for tgetent(). Unfortunately this is largely
1531 * undocumented, some systems use 1024. Using a buffer that is too small 1520 * undocumented, some systems use 1024. Using a buffer that is too small
1607 # else 1596 # else
1608 # define STRNICMP(d, s, n) vim_strnicmp((char *)(d), (char *)(s), (size_t)(n)) 1597 # define STRNICMP(d, s, n) vim_strnicmp((char *)(d), (char *)(s), (size_t)(n))
1609 # endif 1598 # endif
1610 #endif 1599 #endif
1611 1600
1612 #ifdef FEAT_MBYTE
1613 /* We need to call mb_stricmp() even when we aren't dealing with a multi-byte 1601 /* We need to call mb_stricmp() even when we aren't dealing with a multi-byte
1614 * encoding because mb_stricmp() takes care of all ascii and non-ascii 1602 * encoding because mb_stricmp() takes care of all ascii and non-ascii
1615 * encodings, including characters with umlauts in latin1, etc., while 1603 * encodings, including characters with umlauts in latin1, etc., while
1616 * STRICMP() only handles the system locale version, which often does not 1604 * STRICMP() only handles the system locale version, which often does not
1617 * handle non-ascii properly. */ 1605 * handle non-ascii properly. */
1618 1606
1619 # define MB_STRICMP(d, s) mb_strnicmp((char_u *)(d), (char_u *)(s), (int)MAXCOL) 1607 # define MB_STRICMP(d, s) mb_strnicmp((char_u *)(d), (char_u *)(s), (int)MAXCOL)
1620 # define MB_STRNICMP(d, s, n) mb_strnicmp((char_u *)(d), (char_u *)(s), (int)(n)) 1608 # define MB_STRNICMP(d, s, n) mb_strnicmp((char_u *)(d), (char_u *)(s), (int)(n))
1621 #else
1622 # define MB_STRICMP(d, s) STRICMP((d), (s))
1623 # define MB_STRNICMP(d, s, n) STRNICMP((d), (s), (n))
1624 #endif
1625 1609
1626 #define STRCAT(d, s) strcat((char *)(d), (char *)(s)) 1610 #define STRCAT(d, s) strcat((char *)(d), (char *)(s))
1627 #define STRNCAT(d, s, n) strncat((char *)(d), (char *)(s), (size_t)(n)) 1611 #define STRNCAT(d, s, n) strncat((char *)(d), (char *)(s), (size_t)(n))
1628 1612
1629 #ifdef HAVE_STRPBRK 1613 #ifdef HAVE_STRPBRK
1764 # define DO_INIT 1748 # define DO_INIT
1765 # define COMMA , 1749 # define COMMA ,
1766 # endif 1750 # endif
1767 #endif 1751 #endif
1768 1752
1769 #ifdef FEAT_MBYTE 1753 #define MAX_MCO 6 /* maximum value for 'maxcombine' */
1770 # define MAX_MCO 6 /* maximum value for 'maxcombine' */
1771 1754
1772 /* Maximum number of bytes in a multi-byte character. It can be one 32-bit 1755 /* Maximum number of bytes in a multi-byte character. It can be one 32-bit
1773 * character of up to 6 bytes, or one 16-bit character of up to three bytes 1756 * character of up to 6 bytes, or one 16-bit character of up to three bytes
1774 * plus six following composing characters of three bytes each. */ 1757 * plus six following composing characters of three bytes each. */
1775 # define MB_MAXBYTES 21 1758 #define MB_MAXBYTES 21
1776 #else
1777 # define MB_MAXBYTES 1
1778 #endif
1779 1759
1780 #if (defined(FEAT_PROFILE) || defined(FEAT_RELTIME)) && !defined(PROTO) 1760 #if (defined(FEAT_PROFILE) || defined(FEAT_RELTIME)) && !defined(PROTO)
1781 # ifdef WIN3264 1761 # ifdef WIN3264
1782 typedef LARGE_INTEGER proftime_T; 1762 typedef LARGE_INTEGER proftime_T;
1783 # else 1763 # else
2126 # define mch_msg(str) printf("%s", (str)) 2106 # define mch_msg(str) printf("%s", (str))
2127 #else 2107 #else
2128 # define USE_MCH_ERRMSG 2108 # define USE_MCH_ERRMSG
2129 #endif 2109 #endif
2130 2110
2131 # if defined(FEAT_MBYTE) && defined(FEAT_EVAL) \ 2111 # if defined(FEAT_EVAL) \
2132 && (!defined(FEAT_GUI_W32) \ 2112 && (!defined(FEAT_GUI_W32) \
2133 || !(defined(FEAT_MBYTE_IME) || defined(GLOBAL_IME))) \ 2113 || !(defined(FEAT_MBYTE_IME) || defined(GLOBAL_IME))) \
2134 && !(defined(FEAT_GUI_MAC) && defined(MACOS_CONVERT)) 2114 && !(defined(FEAT_GUI_MAC) && defined(MACOS_CONVERT))
2135 /* Whether IME is supported by im_get_status() defined in mbyte.c. 2115 /* Whether IME is supported by im_get_status() defined in mbyte.c.
2136 * For Win32 GUI it's in gui_w32.c when FEAT_MBYTE_IME or GLOBAL_IME is defined. 2116 * For Win32 GUI it's in gui_w32.c when FEAT_MBYTE_IME or GLOBAL_IME is defined.
2137 * for Mac it is in gui_mac.c for the GUI or in os_mac_conv.c when 2117 * for Mac it is in gui_mac.c for the GUI or in os_mac_conv.c when
2138 * MACOS_CONVERT is defined. */ 2118 * MACOS_CONVERT is defined. */
2139 # define IME_WITHOUT_XIM 2119 # define IME_WITHOUT_XIM
2140 #endif 2120 #endif
2141 2121
2142 #if defined(FEAT_MBYTE) && (defined(FEAT_XIM) \ 2122 #if defined(FEAT_XIM) \
2143 || defined(IME_WITHOUT_XIM) \ 2123 || defined(IME_WITHOUT_XIM) \
2144 || (defined(FEAT_GUI_W32) \ 2124 || (defined(FEAT_GUI_W32) \
2145 && (defined(FEAT_MBYTE_IME) || defined(GLOBAL_IME))) \ 2125 && (defined(FEAT_MBYTE_IME) || defined(GLOBAL_IME))) \
2146 || defined(FEAT_GUI_MAC)) 2126 || defined(FEAT_GUI_MAC)
2147 /* im_set_active() is available */ 2127 /* im_set_active() is available */
2148 # define HAVE_INPUT_METHOD 2128 # define HAVE_INPUT_METHOD
2149 #endif
2150
2151 #ifndef FEAT_MBYTE
2152 # define after_pathsep(b, p) vim_ispathsep(*((p) - 1))
2153 # define transchar_byte(c) transchar(c)
2154 #endif 2129 #endif
2155 2130
2156 #ifndef FEAT_LINEBREAK 2131 #ifndef FEAT_LINEBREAK
2157 /* Without the 'numberwidth' option line numbers are always 7 chars. */ 2132 /* Without the 'numberwidth' option line numbers are always 7 chars. */
2158 # define number_width(x) 7 2133 # define number_width(x) 7
2159 #endif 2134 #endif
2160 2135
2161 /* This must come after including proto.h. 2136 /* This must come after including proto.h.
2162 * For VMS this is defined in macros.h. */ 2137 * For VMS this is defined in macros.h. */
2163 #if !(defined(FEAT_MBYTE) && defined(WIN3264)) && !defined(VMS) 2138 #if !defined(WIN3264) && !defined(VMS)
2164 # define mch_open(n, m, p) open((n), (m), (p)) 2139 # define mch_open(n, m, p) open((n), (m), (p))
2165 # define mch_fopen(n, p) fopen((n), (p)) 2140 # define mch_fopen(n, p) fopen((n), (p))
2166 #endif 2141 #endif
2167 2142
2168 #include "globals.h" /* global variables and messages */ 2143 #include "globals.h" /* global variables and messages */
2234 # define vim_realloc(ptr, size) mem_realloc((ptr), (size)) 2209 # define vim_realloc(ptr, size) mem_realloc((ptr), (size))
2235 #else 2210 #else
2236 # define vim_realloc(ptr, size) realloc((ptr), (size)) 2211 # define vim_realloc(ptr, size) realloc((ptr), (size))
2237 #endif 2212 #endif
2238 2213
2239 #ifdef FEAT_MBYTE
2240 /* 2214 /*
2241 * Return byte length of character that starts with byte "b". 2215 * Return byte length of character that starts with byte "b".
2242 * Returns 1 for a single-byte character. 2216 * Returns 1 for a single-byte character.
2243 * MB_BYTE2LEN_CHECK() can be used to count a special key as one byte. 2217 * MB_BYTE2LEN_CHECK() can be used to count a special key as one byte.
2244 * Don't call MB_BYTE2LEN(b) with b < 0 or b > 255! 2218 * Don't call MB_BYTE2LEN(b) with b < 0 or b > 255!
2245 */ 2219 */
2246 # define MB_BYTE2LEN(b) mb_bytelen_tab[b] 2220 #define MB_BYTE2LEN(b) mb_bytelen_tab[b]
2247 # define MB_BYTE2LEN_CHECK(b) (((b) < 0 || (b) > 255) ? 1 : mb_bytelen_tab[b]) 2221 #define MB_BYTE2LEN_CHECK(b) (((b) < 0 || (b) > 255) ? 1 : mb_bytelen_tab[b])
2248 #endif 2222
2249
2250 #if defined(FEAT_MBYTE) || defined(FEAT_POSTSCRIPT)
2251 /* properties used in enc_canon_table[] (first three mutually exclusive) */ 2223 /* properties used in enc_canon_table[] (first three mutually exclusive) */
2252 # define ENC_8BIT 0x01 2224 #define ENC_8BIT 0x01
2253 # define ENC_DBCS 0x02 2225 #define ENC_DBCS 0x02
2254 # define ENC_UNICODE 0x04 2226 #define ENC_UNICODE 0x04
2255 2227
2256 # define ENC_ENDIAN_B 0x10 /* Unicode: Big endian */ 2228 #define ENC_ENDIAN_B 0x10 /* Unicode: Big endian */
2257 # define ENC_ENDIAN_L 0x20 /* Unicode: Little endian */ 2229 #define ENC_ENDIAN_L 0x20 /* Unicode: Little endian */
2258 2230
2259 # define ENC_2BYTE 0x40 /* Unicode: UCS-2 */ 2231 #define ENC_2BYTE 0x40 /* Unicode: UCS-2 */
2260 # define ENC_4BYTE 0x80 /* Unicode: UCS-4 */ 2232 #define ENC_4BYTE 0x80 /* Unicode: UCS-4 */
2261 # define ENC_2WORD 0x100 /* Unicode: UTF-16 */ 2233 #define ENC_2WORD 0x100 /* Unicode: UTF-16 */
2262 2234
2263 # define ENC_LATIN1 0x200 /* Latin1 */ 2235 #define ENC_LATIN1 0x200 /* Latin1 */
2264 # define ENC_LATIN9 0x400 /* Latin9 */ 2236 #define ENC_LATIN9 0x400 /* Latin9 */
2265 # define ENC_MACROMAN 0x800 /* Mac Roman (not Macro Man! :-) */ 2237 #define ENC_MACROMAN 0x800 /* Mac Roman (not Macro Man! :-) */
2266 #endif 2238
2267 2239 #ifdef USE_ICONV
2268 #ifdef FEAT_MBYTE 2240 # ifndef EILSEQ
2269 # ifdef USE_ICONV 2241 # define EILSEQ 123
2270 # ifndef EILSEQ 2242 # endif
2271 # define EILSEQ 123 2243 # ifdef DYNAMIC_ICONV
2272 # endif
2273 # ifdef DYNAMIC_ICONV
2274 /* On Win32 iconv.dll is dynamically loaded. */ 2244 /* On Win32 iconv.dll is dynamically loaded. */
2275 # define ICONV_ERRNO (*iconv_errno()) 2245 # define ICONV_ERRNO (*iconv_errno())
2276 # define ICONV_E2BIG 7 2246 # define ICONV_E2BIG 7
2277 # define ICONV_EINVAL 22 2247 # define ICONV_EINVAL 22
2278 # define ICONV_EILSEQ 42 2248 # define ICONV_EILSEQ 42
2279 # else 2249 # else
2280 # define ICONV_ERRNO errno 2250 # define ICONV_ERRNO errno
2281 # define ICONV_E2BIG E2BIG 2251 # define ICONV_E2BIG E2BIG
2282 # define ICONV_EINVAL EINVAL 2252 # define ICONV_EINVAL EINVAL
2283 # define ICONV_EILSEQ EILSEQ 2253 # define ICONV_EILSEQ EILSEQ
2284 # endif 2254 # endif
2285 # endif 2255 #endif
2286
2287 #endif
2288
2289 2256
2290 #define SIGN_BYTE 1 /* byte value used where sign is displayed; 2257 #define SIGN_BYTE 1 /* byte value used where sign is displayed;
2291 attribute value is sign type */ 2258 attribute value is sign type */
2292 2259
2293 #ifdef FEAT_NETBEANS_INTG 2260 #ifdef FEAT_NETBEANS_INTG