0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 8.1.0810: too many #ifdefs

Problem:    Too many #ifdefs.
Solution:   Graduate FEAT_MBYTE, part 4.
This commit is contained in:
Bram Moolenaar
2019-01-24 17:18:42 +01:00
parent a12a161b8c
commit 264b74fa54
25 changed files with 204 additions and 877 deletions

View File

@@ -96,17 +96,10 @@
* MB_ISLOWER() and MB_ISUPPER() are to be used on multi-byte characters. But
* don't use them for negative values!
*/
#ifdef FEAT_MBYTE
# define MB_ISLOWER(c) vim_islower(c)
# define MB_ISUPPER(c) vim_isupper(c)
# define MB_TOLOWER(c) vim_tolower(c)
# define MB_TOUPPER(c) vim_toupper(c)
#else
# define MB_ISLOWER(c) islower(c)
# define MB_ISUPPER(c) isupper(c)
# define MB_TOLOWER(c) TOLOWER_LOC(c)
# define MB_TOUPPER(c) TOUPPER_LOC(c)
#endif
#define MB_ISLOWER(c) vim_islower(c)
#define MB_ISUPPER(c) vim_isupper(c)
#define MB_TOLOWER(c) vim_tolower(c)
#define MB_TOUPPER(c) vim_toupper(c)
/* Use our own isdigit() replacement, because on MS-Windows isdigit() returns
* non-zero for superscript 1. Also avoids that isdigit() crashes for numbers
@@ -139,8 +132,7 @@
* a mapping and the langnoremap option was set.
* The do-while is just to ignore a ';' after the macro.
*/
# ifdef FEAT_MBYTE
# define LANGMAP_ADJUST(c, condition) \
# define LANGMAP_ADJUST(c, condition) \
do { \
if (*p_langmap \
&& (condition) \
@@ -154,17 +146,6 @@
c = langmap_adjust_mb(c); \
} \
} while (0)
# else
# define LANGMAP_ADJUST(c, condition) \
do { \
if (*p_langmap \
&& (condition) \
&& (p_lrm || (!p_lrm && KeyTyped)) \
&& !KeyStuffed \
&& (c) >= 0 && (c) < 256) \
c = langmap_mapchar[c]; \
} while (0)
# endif
#else
# define LANGMAP_ADJUST(c, condition) /* nop */
#endif
@@ -256,33 +237,21 @@
* MB_COPY_CHAR(f, t): copy one char from "f" to "t" and advance the pointers.
* PTR2CHAR(): get character from pointer.
*/
#ifdef FEAT_MBYTE
/* Get the length of the character p points to, including composing chars */
# define MB_PTR2LEN(p) (has_mbyte ? (*mb_ptr2len)(p) : 1)
#define MB_PTR2LEN(p) (has_mbyte ? (*mb_ptr2len)(p) : 1)
/* Advance multi-byte pointer, skip over composing chars. */
# define MB_PTR_ADV(p) p += has_mbyte ? (*mb_ptr2len)(p) : 1
#define MB_PTR_ADV(p) p += has_mbyte ? (*mb_ptr2len)(p) : 1
/* Advance multi-byte pointer, do not skip over composing chars. */
# define MB_CPTR_ADV(p) p += enc_utf8 ? utf_ptr2len(p) : has_mbyte ? (*mb_ptr2len)(p) : 1
#define MB_CPTR_ADV(p) p += enc_utf8 ? utf_ptr2len(p) : has_mbyte ? (*mb_ptr2len)(p) : 1
/* Backup multi-byte pointer. Only use with "p" > "s" ! */
# define MB_PTR_BACK(s, p) p -= has_mbyte ? ((*mb_head_off)(s, p - 1) + 1) : 1
#define MB_PTR_BACK(s, p) p -= has_mbyte ? ((*mb_head_off)(s, p - 1) + 1) : 1
/* get length of multi-byte char, not including composing chars */
# define MB_CPTR2LEN(p) (enc_utf8 ? utf_ptr2len(p) : (*mb_ptr2len)(p))
#define MB_CPTR2LEN(p) (enc_utf8 ? utf_ptr2len(p) : (*mb_ptr2len)(p))
# define MB_COPY_CHAR(f, t) if (has_mbyte) mb_copy_char(&f, &t); else *t++ = *f++
# define MB_CHARLEN(p) (has_mbyte ? mb_charlen(p) : (int)STRLEN(p))
# define MB_CHAR2LEN(c) (has_mbyte ? mb_char2len(c) : 1)
# define PTR2CHAR(p) (has_mbyte ? mb_ptr2char(p) : (int)*(p))
#else
# define MB_PTR2LEN(p) 1
# define MB_CPTR2LEN(p) 1
# define MB_PTR_ADV(p) ++p
# define MB_CPTR_ADV(p) ++p
# define MB_PTR_BACK(s, p) --p
# define MB_COPY_CHAR(f, t) *t++ = *f++
# define MB_CHARLEN(p) STRLEN(p)
# define MB_CHAR2LEN(c) 1
# define PTR2CHAR(p) ((int)*(p))
#endif
#define MB_COPY_CHAR(f, t) if (has_mbyte) mb_copy_char(&f, &t); else *t++ = *f++
#define MB_CHARLEN(p) (has_mbyte ? mb_charlen(p) : (int)STRLEN(p))
#define MB_CHAR2LEN(c) (has_mbyte ? mb_char2len(c) : 1)
#define PTR2CHAR(p) (has_mbyte ? mb_ptr2char(p) : (int)*(p))
#ifdef FEAT_AUTOCHDIR
# define DO_AUTOCHDIR do { if (p_acd) do_autochdir(); } while (0)