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

@@ -1789,10 +1789,8 @@ struct exarg
int force_bin; /* 0, FORCE_BIN or FORCE_NOBIN */ int force_bin; /* 0, FORCE_BIN or FORCE_NOBIN */
int read_edit; /* ++edit argument */ int read_edit; /* ++edit argument */
int force_ff; /* ++ff= argument (first char of argument) */ int force_ff; /* ++ff= argument (first char of argument) */
#ifdef FEAT_MBYTE
int force_enc; /* ++enc= argument (index in cmd[]) */ int force_enc; /* ++enc= argument (index in cmd[]) */
int bad_char; /* BAD_KEEP, BAD_DROP or replacement byte */ int bad_char; /* BAD_KEEP, BAD_DROP or replacement byte */
#endif
#ifdef FEAT_USR_CMDS #ifdef FEAT_USR_CMDS
int useridx; /* user command index */ int useridx; /* user command index */
#endif #endif

View File

@@ -291,14 +291,11 @@ add_num_buff(buffheader_T *buf, long n)
static void static void
add_char_buff(buffheader_T *buf, int c) add_char_buff(buffheader_T *buf, int c)
{ {
#ifdef FEAT_MBYTE
char_u bytes[MB_MAXBYTES + 1]; char_u bytes[MB_MAXBYTES + 1];
int len; int len;
int i; int i;
#endif
char_u temp[4]; char_u temp[4];
#ifdef FEAT_MBYTE
if (IS_SPECIAL(c)) if (IS_SPECIAL(c))
len = 1; len = 1;
else else
@@ -307,7 +304,6 @@ add_char_buff(buffheader_T *buf, int c)
{ {
if (!IS_SPECIAL(c)) if (!IS_SPECIAL(c))
c = bytes[i]; c = bytes[i];
#endif
if (IS_SPECIAL(c) || c == K_SPECIAL || c == NUL) if (IS_SPECIAL(c) || c == K_SPECIAL || c == NUL)
{ {
@@ -333,9 +329,7 @@ add_char_buff(buffheader_T *buf, int c)
temp[1] = NUL; temp[1] = NUL;
} }
add_buff(buf, temp, -1L); add_buff(buf, temp, -1L);
#ifdef FEAT_MBYTE
} }
#endif
} }
/* First read ahead buffer. Used for translated commands. */ /* First read ahead buffer. Used for translated commands. */
@@ -596,12 +590,10 @@ AppendToRedobuffLit(
break; break;
/* Handle a special or multibyte character. */ /* Handle a special or multibyte character. */
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
/* Handle composing chars separately. */ /* Handle composing chars separately. */
c = mb_cptr2char_adv(&s); c = mb_cptr2char_adv(&s);
else else
#endif
c = *s++; c = *s++;
if (c < ' ' || c == DEL || (*s == NUL && (c == '0' || c == '^'))) if (c < ' ' || c == DEL || (*s == NUL && (c == '0' || c == '^')))
add_char_buff(&redobuff, Ctrl_V); add_char_buff(&redobuff, Ctrl_V);
@@ -686,11 +678,7 @@ stuffReadbuffSpec(char_u *s)
} }
else else
{ {
#ifdef FEAT_MBYTE
c = mb_ptr2char_adv(&s); c = mb_ptr2char_adv(&s);
#else
c = *s++;
#endif
if (c == CAR || c == NL || c == ESC) if (c == CAR || c == NL || c == ESC)
c = ' '; c = ' ';
stuffcharReadbuff(c); stuffcharReadbuff(c);
@@ -732,11 +720,9 @@ read_redo(int init, int old_redo)
static buffblock_T *bp; static buffblock_T *bp;
static char_u *p; static char_u *p;
int c; int c;
#ifdef FEAT_MBYTE
int n; int n;
char_u buf[MB_MAXBYTES + 1]; char_u buf[MB_MAXBYTES + 1];
int i; int i;
#endif
if (init) if (init)
{ {
@@ -752,7 +738,6 @@ read_redo(int init, int old_redo)
if ((c = *p) != NUL) if ((c = *p) != NUL)
{ {
/* Reverse the conversion done by add_char_buff() */ /* Reverse the conversion done by add_char_buff() */
#ifdef FEAT_MBYTE
/* For a multi-byte character get all the bytes and return the /* For a multi-byte character get all the bytes and return the
* converted character. */ * converted character. */
if (has_mbyte && (c != K_SPECIAL || p[1] == KS_SPECIAL)) if (has_mbyte && (c != K_SPECIAL || p[1] == KS_SPECIAL))
@@ -760,7 +745,6 @@ read_redo(int init, int old_redo)
else else
n = 1; n = 1;
for (i = 0; ; ++i) for (i = 0; ; ++i)
#endif
{ {
if (c == K_SPECIAL) /* special key or escaped K_SPECIAL */ if (c == K_SPECIAL) /* special key or escaped K_SPECIAL */
{ {
@@ -776,7 +760,6 @@ read_redo(int init, int old_redo)
bp = bp->b_next; bp = bp->b_next;
p = bp->b_str; p = bp->b_str;
} }
#ifdef FEAT_MBYTE
buf[i] = c; buf[i] = c;
if (i == n - 1) /* last byte of a character */ if (i == n - 1) /* last byte of a character */
{ {
@@ -787,7 +770,6 @@ read_redo(int init, int old_redo)
c = *p; c = *p;
if (c == NUL) /* cannot happen? */ if (c == NUL) /* cannot happen? */
break; break;
#endif
} }
} }
@@ -1093,11 +1075,7 @@ ins_typebuf(
void void
ins_char_typebuf(int c) ins_char_typebuf(int c)
{ {
#ifdef FEAT_MBYTE
char_u buf[MB_MAXBYTES + 1]; char_u buf[MB_MAXBYTES + 1];
#else
char_u buf[4];
#endif
if (IS_SPECIAL(c)) if (IS_SPECIAL(c))
{ {
buf[0] = K_SPECIAL; buf[0] = K_SPECIAL;
@@ -1106,14 +1084,7 @@ ins_char_typebuf(int c)
buf[3] = NUL; buf[3] = NUL;
} }
else else
{
#ifdef FEAT_MBYTE
buf[(*mb_char2bytes)(c, buf)] = NUL; buf[(*mb_char2bytes)(c, buf)] = NUL;
#else
buf[0] = c;
buf[1] = NUL;
#endif
}
(void)ins_typebuf(buf, KeyNoremap, 0, !KeyTyped, cmd_silent); (void)ins_typebuf(buf, KeyNoremap, 0, !KeyTyped, cmd_silent);
} }
@@ -1579,11 +1550,9 @@ updatescript(int c)
vgetc(void) vgetc(void)
{ {
int c, c2; int c, c2;
#ifdef FEAT_MBYTE
int n; int n;
char_u buf[MB_MAXBYTES + 1]; char_u buf[MB_MAXBYTES + 1];
int i; int i;
#endif
#ifdef FEAT_EVAL #ifdef FEAT_EVAL
/* Do garbage collection when garbagecollect() was called previously and /* Do garbage collection when garbagecollect() was called previously and
@@ -1763,7 +1732,6 @@ vgetc(void)
case K_XRIGHT: c = K_RIGHT; break; case K_XRIGHT: c = K_RIGHT; break;
} }
#ifdef FEAT_MBYTE
/* For a multi-byte character get all the bytes and return the /* For a multi-byte character get all the bytes and return the
* converted character. * converted character.
* Note: This will loop until enough bytes are received! * Note: This will loop until enough bytes are received!
@@ -1794,7 +1762,6 @@ vgetc(void)
--no_mapping; --no_mapping;
c = (*mb_ptr2char)(buf); c = (*mb_ptr2char)(buf);
} }
#endif
break; break;
} }
@@ -2212,7 +2179,6 @@ vgetorpeek(int advance)
break; break;
} }
#ifdef FEAT_MBYTE
/* Don't allow mapping the first byte(s) of a /* Don't allow mapping the first byte(s) of a
* multi-byte char. Happens when mapping * multi-byte char. Happens when mapping
* <M-a> and then changing 'encoding'. Beware * <M-a> and then changing 'encoding'. Beware
@@ -2225,7 +2191,6 @@ vgetorpeek(int advance)
&& MB_BYTE2LEN(c1) > MB_PTR2LEN(p2)) && MB_BYTE2LEN(c1) > MB_PTR2LEN(p2))
mlen = 0; mlen = 0;
} }
#endif
/* /*
* Check an entry whether it matches. * Check an entry whether it matches.
* - Full match: mlen == keylen * - Full match: mlen == keylen
@@ -2685,38 +2650,29 @@ vgetorpeek(int advance)
curwin->w_wcol = vcol; curwin->w_wcol = vcol;
vcol += lbr_chartabsize(ptr, ptr + col, vcol += lbr_chartabsize(ptr, ptr + col,
(colnr_T)vcol); (colnr_T)vcol);
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
col += (*mb_ptr2len)(ptr + col); col += (*mb_ptr2len)(ptr + col);
else else
#endif
++col; ++col;
} }
curwin->w_wrow = curwin->w_cline_row curwin->w_wrow = curwin->w_cline_row
+ curwin->w_wcol / curwin->w_width; + curwin->w_wcol / curwin->w_width;
curwin->w_wcol %= curwin->w_width; curwin->w_wcol %= curwin->w_width;
curwin->w_wcol += curwin_col_off(); curwin->w_wcol += curwin_col_off();
#ifdef FEAT_MBYTE
col = 0; /* no correction needed */ col = 0; /* no correction needed */
#endif
} }
else else
{ {
--curwin->w_wcol; --curwin->w_wcol;
#ifdef FEAT_MBYTE
col = curwin->w_cursor.col - 1; col = curwin->w_cursor.col - 1;
#endif
} }
} }
else if (curwin->w_p_wrap && curwin->w_wrow) else if (curwin->w_p_wrap && curwin->w_wrow)
{ {
--curwin->w_wrow; --curwin->w_wrow;
curwin->w_wcol = curwin->w_width - 1; curwin->w_wcol = curwin->w_width - 1;
#ifdef FEAT_MBYTE
col = curwin->w_cursor.col - 1; col = curwin->w_cursor.col - 1;
#endif
} }
#ifdef FEAT_MBYTE
if (has_mbyte && col > 0 && curwin->w_wcol > 0) if (has_mbyte && col > 0 && curwin->w_wcol > 0)
{ {
/* Correct when the cursor is on the right halve /* Correct when the cursor is on the right halve
@@ -2726,7 +2682,6 @@ vgetorpeek(int advance)
if ((*mb_ptr2cells)(ptr + col) > 1) if ((*mb_ptr2cells)(ptr + col) > 1)
--curwin->w_wcol; --curwin->w_wcol;
} }
#endif
} }
setcursor(); setcursor();
out_flush(); out_flush();
@@ -3434,7 +3389,6 @@ do_map(
* Otherwise we won't be able to find the start of it in a * Otherwise we won't be able to find the start of it in a
* vi-compatible way. * vi-compatible way.
*/ */
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
int first, last; int first, last;
@@ -3458,9 +3412,7 @@ do_map(
goto theend; goto theend;
} }
} }
else else if (vim_iswordc(keys[len - 1])) // ends in keyword char
#endif
if (vim_iswordc(keys[len - 1])) /* ends in keyword char */
for (n = 0; n < len - 2; ++n) for (n = 0; n < len - 2; ++n)
if (vim_iswordc(keys[n]) != vim_iswordc(keys[len - 2])) if (vim_iswordc(keys[n]) != vim_iswordc(keys[len - 2]))
{ {
@@ -4458,9 +4410,7 @@ check_abbr(
#ifdef FEAT_LOCALMAP #ifdef FEAT_LOCALMAP
mapblock_T *mp2; mapblock_T *mp2;
#endif #endif
#ifdef FEAT_MBYTE
int clen = 0; /* length in characters */ int clen = 0; /* length in characters */
#endif
int is_id = TRUE; int is_id = TRUE;
int vim_abbr; int vim_abbr;
@@ -4480,7 +4430,6 @@ check_abbr(
if (col == 0) /* cannot be an abbr. */ if (col == 0) /* cannot be an abbr. */
return FALSE; return FALSE;
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
char_u *p; char_u *p;
@@ -4508,7 +4457,6 @@ check_abbr(
scol = (int)(p - ptr); scol = (int)(p - ptr);
} }
else else
#endif
{ {
if (!vim_iswordc(ptr[col - 1])) if (!vim_iswordc(ptr[col - 1]))
vim_abbr = TRUE; /* Vim added abbr. */ vim_abbr = TRUE; /* Vim added abbr. */
@@ -4601,7 +4549,6 @@ check_abbr(
{ {
if (c < ABBR_OFF && (c < ' ' || c > '~')) if (c < ABBR_OFF && (c < ' ' || c > '~'))
tb[j++] = Ctrl_V; /* special char needs CTRL-V */ tb[j++] = Ctrl_V; /* special char needs CTRL-V */
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
/* if ABBR_OFF has been added, remove it here */ /* if ABBR_OFF has been added, remove it here */
@@ -4610,7 +4557,6 @@ check_abbr(
j += (*mb_char2bytes)(c, tb + j); j += (*mb_char2bytes)(c, tb + j);
} }
else else
#endif
tb[j++] = c; tb[j++] = c;
} }
tb[j] = NUL; tb[j] = NUL;
@@ -4637,10 +4583,8 @@ check_abbr(
tb[0] = Ctrl_H; tb[0] = Ctrl_H;
tb[1] = NUL; tb[1] = NUL;
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
len = clen; /* Delete characters instead of bytes */ len = clen; /* Delete characters instead of bytes */
#endif
while (len-- > 0) /* delete the from string */ while (len-- > 0) /* delete the from string */
(void)ins_typebuf(tb, 1, 0, TRUE, mp->m_silent); (void)ins_typebuf(tb, 1, 0, TRUE, mp->m_silent);
return TRUE; return TRUE;
@@ -4715,13 +4659,7 @@ vim_strsave_escape_csi(
/* Need a buffer to hold up to three times as much. Four in case of an /* Need a buffer to hold up to three times as much. Four in case of an
* illegal utf-8 byte: * illegal utf-8 byte:
* 0xc0 -> 0xc3 0x80 -> 0xc3 K_SPECIAL KS_SPECIAL KE_FILLER */ * 0xc0 -> 0xc3 0x80 -> 0xc3 K_SPECIAL KS_SPECIAL KE_FILLER */
res = alloc((unsigned)(STRLEN(p) * res = alloc((unsigned)(STRLEN(p) * 4) + 1);
#ifdef FEAT_MBYTE
4
#else
3
#endif
) + 1);
if (res != NULL) if (res != NULL)
{ {
d = res; d = res;
@@ -5012,7 +4950,6 @@ put_escstr(FILE *fd, char_u *strstart, int what)
for ( ; *str != NUL; ++str) for ( ; *str != NUL; ++str)
{ {
#ifdef FEAT_MBYTE
char_u *p; char_u *p;
/* Check for a multi-byte character, which may contain escaped /* Check for a multi-byte character, which may contain escaped
@@ -5026,7 +4963,6 @@ put_escstr(FILE *fd, char_u *strstart, int what)
--str; --str;
continue; continue;
} }
#endif
c = *str; c = *str;
/* /*

View File

@@ -134,7 +134,7 @@ global_ime_DefWindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
if (pIApp == NULL || pIApp->OnDefWindowProc(hWnd, Msg, if (pIApp == NULL || pIApp->OnDefWindowProc(hWnd, Msg,
wParam, lParam, &lResult) != S_OK) wParam, lParam, &lResult) != S_OK)
{ {
#if defined(WIN3264) && defined(FEAT_MBYTE) #if defined(WIN3264)
if (wide_WindowProc) if (wide_WindowProc)
lResult = DefWindowProcW(hWnd, Msg, wParam, lParam); lResult = DefWindowProcW(hWnd, Msg, wParam, lParam);
else else

View File

@@ -44,7 +44,6 @@ EXTERN sattr_T *ScreenAttrs INIT(= NULL);
EXTERN unsigned *LineOffset INIT(= NULL); EXTERN unsigned *LineOffset INIT(= NULL);
EXTERN char_u *LineWraps INIT(= NULL); /* line wraps to next line */ EXTERN char_u *LineWraps INIT(= NULL); /* line wraps to next line */
#ifdef FEAT_MBYTE
/* /*
* When using Unicode characters (in UTF-8 encoding) the character in * When using Unicode characters (in UTF-8 encoding) the character in
* ScreenLinesUC[] contains the Unicode for the character at this position, or * ScreenLinesUC[] contains the Unicode for the character at this position, or
@@ -61,7 +60,6 @@ EXTERN int Screen_mco INIT(= 0); /* value of p_mco used when
/* Only used for euc-jp: Second byte of a character that starts with 0x8e. /* Only used for euc-jp: Second byte of a character that starts with 0x8e.
* These are single-width. */ * These are single-width. */
EXTERN schar_T *ScreenLines2 INIT(= NULL); EXTERN schar_T *ScreenLines2 INIT(= NULL);
#endif
/* /*
* Indexes for tab page line: * Indexes for tab page line:
@@ -798,41 +796,38 @@ EXTERN int vr_lines_changed INIT(= 0); /* #Lines changed by "gR" so far */
EXTERN JMP_BUF x_jump_env; EXTERN JMP_BUF x_jump_env;
#endif #endif
#if defined(FEAT_MBYTE) || defined(FEAT_POSTSCRIPT)
/* /*
* These flags are set based upon 'fileencoding'. * These flags are set based upon 'fileencoding'.
* Note that "enc_utf8" is also set for "unicode", because the characters are * Note that "enc_utf8" is also set for "unicode", because the characters are
* internally stored as UTF-8 (to avoid trouble with NUL bytes). * internally stored as UTF-8 (to avoid trouble with NUL bytes).
*/ */
# define DBCS_JPN 932 /* japan */ #define DBCS_JPN 932 /* japan */
# define DBCS_JPNU 9932 /* euc-jp */ #define DBCS_JPNU 9932 /* euc-jp */
# define DBCS_KOR 949 /* korea */ #define DBCS_KOR 949 /* korea */
# define DBCS_KORU 9949 /* euc-kr */ #define DBCS_KORU 9949 /* euc-kr */
# define DBCS_CHS 936 /* chinese */ #define DBCS_CHS 936 /* chinese */
# define DBCS_CHSU 9936 /* euc-cn */ #define DBCS_CHSU 9936 /* euc-cn */
# define DBCS_CHT 950 /* taiwan */ #define DBCS_CHT 950 /* taiwan */
# define DBCS_CHTU 9950 /* euc-tw */ #define DBCS_CHTU 9950 /* euc-tw */
# define DBCS_2BYTE 1 /* 2byte- */ #define DBCS_2BYTE 1 /* 2byte- */
# define DBCS_DEBUG -1 #define DBCS_DEBUG -1
#endif
#ifdef FEAT_MBYTE
EXTERN int enc_dbcs INIT(= 0); /* One of DBCS_xxx values if EXTERN int enc_dbcs INIT(= 0); /* One of DBCS_xxx values if
DBCS encoding */ DBCS encoding */
EXTERN int enc_unicode INIT(= 0); /* 2: UCS-2 or UTF-16, 4: UCS-4 */ EXTERN int enc_unicode INIT(= 0); /* 2: UCS-2 or UTF-16, 4: UCS-4 */
EXTERN int enc_utf8 INIT(= FALSE); /* UTF-8 encoded Unicode */ EXTERN int enc_utf8 INIT(= FALSE); /* UTF-8 encoded Unicode */
EXTERN int enc_latin1like INIT(= TRUE); /* 'encoding' is latin1 comp. */ EXTERN int enc_latin1like INIT(= TRUE); /* 'encoding' is latin1 comp. */
# if defined(WIN3264) || defined(FEAT_CYGWIN_WIN32_CLIPBOARD) #if defined(WIN3264) || defined(FEAT_CYGWIN_WIN32_CLIPBOARD)
/* Codepage nr of 'encoding'. Negative means it's not been set yet, zero /* Codepage nr of 'encoding'. Negative means it's not been set yet, zero
* means 'encoding' is not a valid codepage. */ * means 'encoding' is not a valid codepage. */
EXTERN int enc_codepage INIT(= -1); EXTERN int enc_codepage INIT(= -1);
EXTERN int enc_latin9 INIT(= FALSE); /* 'encoding' is latin9 */ EXTERN int enc_latin9 INIT(= FALSE); /* 'encoding' is latin9 */
# endif #endif
EXTERN int has_mbyte INIT(= 0); /* any multi-byte encoding */ EXTERN int has_mbyte INIT(= 0); /* any multi-byte encoding */
# if defined(WIN3264) && defined(FEAT_MBYTE) #if defined(WIN3264)
EXTERN int wide_WindowProc INIT(= FALSE); /* use wide WindowProc() */ EXTERN int wide_WindowProc INIT(= FALSE); /* use wide WindowProc() */
# endif #endif
/* /*
* To speed up BYTELEN() we fill a table with the byte lengths whenever * To speed up BYTELEN() we fill a table with the byte lengths whenever
@@ -875,7 +870,6 @@ EXTERN int (*iconvctl) (iconv_t cd, int request, void *argument);
EXTERN int* (*iconv_errno) (void); EXTERN int* (*iconv_errno) (void);
# endif # endif
#endif /* FEAT_MBYTE */
#ifdef FEAT_XIM #ifdef FEAT_XIM
# ifdef FEAT_GUI_GTK # ifdef FEAT_GUI_GTK

View File

@@ -303,13 +303,11 @@ typedef struct Gui
GuiFont menu_font; /* menu item font */ GuiFont menu_font; /* menu item font */
# endif # endif
#endif #endif
#ifdef FEAT_MBYTE
GuiFont wide_font; /* Normal 'guifontwide' font */ GuiFont wide_font; /* Normal 'guifontwide' font */
# ifndef FEAT_GUI_GTK #ifndef FEAT_GUI_GTK
GuiFont wide_bold_font; /* Bold 'guifontwide' font */ GuiFont wide_bold_font; /* Bold 'guifontwide' font */
GuiFont wide_ital_font; /* Italic 'guifontwide' font */ GuiFont wide_ital_font; /* Italic 'guifontwide' font */
GuiFont wide_boldital_font; /* Bold-Italic 'guifontwide' font */ GuiFont wide_boldital_font; /* Bold-Italic 'guifontwide' font */
# endif
#endif #endif
#ifdef FEAT_XFONTSET #ifdef FEAT_XFONTSET
GuiFontset fontset; /* set of fonts for multi-byte chars */ GuiFontset fontset; /* set of fonts for multi-byte chars */

View File

@@ -24,11 +24,7 @@ static char_u e_py_systemexit[] = "E880: Can't handle SystemExit of %s exception
typedef int Py_ssize_t; /* Python 2.4 and earlier don't have this type. */ typedef int Py_ssize_t; /* Python 2.4 and earlier don't have this type. */
#endif #endif
#ifdef FEAT_MBYTE #define ENC_OPT ((char *)p_enc)
# define ENC_OPT ((char *)p_enc)
#else
# define ENC_OPT "latin1"
#endif
#define DOPY_FUNC "_vim_pydo" #define DOPY_FUNC "_vim_pydo"
static const char *vim_special_path = "_vim_path_"; static const char *vim_special_path = "_vim_path_";
@@ -985,11 +981,7 @@ VimStrwidth(PyObject *self UNUSED, PyObject *string)
if (!(str = StringToChars(string, &todecref))) if (!(str = StringToChars(string, &todecref)))
return NULL; return NULL;
#ifdef FEAT_MBYTE
len = mb_string2cells(str, (int)STRLEN(str)); len = mb_string2cells(str, (int)STRLEN(str));
#else
len = STRLEN(str);
#endif
Py_XDECREF(todecref); Py_XDECREF(todecref);

View File

@@ -96,17 +96,10 @@
* MB_ISLOWER() and MB_ISUPPER() are to be used on multi-byte characters. But * MB_ISLOWER() and MB_ISUPPER() are to be used on multi-byte characters. But
* don't use them for negative values! * don't use them for negative values!
*/ */
#ifdef FEAT_MBYTE #define MB_ISLOWER(c) vim_islower(c)
# define MB_ISLOWER(c) vim_islower(c) #define MB_ISUPPER(c) vim_isupper(c)
# define MB_ISUPPER(c) vim_isupper(c) #define MB_TOLOWER(c) vim_tolower(c)
# define MB_TOLOWER(c) vim_tolower(c) #define MB_TOUPPER(c) vim_toupper(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
/* Use our own isdigit() replacement, because on MS-Windows isdigit() returns /* Use our own isdigit() replacement, because on MS-Windows isdigit() returns
* non-zero for superscript 1. Also avoids that isdigit() crashes for numbers * non-zero for superscript 1. Also avoids that isdigit() crashes for numbers
@@ -139,7 +132,6 @@
* a mapping and the langnoremap option was set. * a mapping and the langnoremap option was set.
* The do-while is just to ignore a ';' after the macro. * 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 { \ do { \
if (*p_langmap \ if (*p_langmap \
@@ -154,17 +146,6 @@
c = langmap_adjust_mb(c); \ c = langmap_adjust_mb(c); \
} \ } \
} while (0) } 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 #else
# define LANGMAP_ADJUST(c, condition) /* nop */ # define LANGMAP_ADJUST(c, condition) /* nop */
#endif #endif
@@ -256,33 +237,21 @@
* MB_COPY_CHAR(f, t): copy one char from "f" to "t" and advance the pointers. * MB_COPY_CHAR(f, t): copy one char from "f" to "t" and advance the pointers.
* PTR2CHAR(): get character from pointer. * PTR2CHAR(): get character from pointer.
*/ */
#ifdef FEAT_MBYTE
/* Get the length of the character p points to, including composing chars */ /* 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. */ /* 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. */ /* 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" ! */ /* 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 */ /* 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_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_CHARLEN(p) (has_mbyte ? mb_charlen(p) : (int)STRLEN(p))
# define MB_CHAR2LEN(c) (has_mbyte ? mb_char2len(c) : 1) #define MB_CHAR2LEN(c) (has_mbyte ? mb_char2len(c) : 1)
# define PTR2CHAR(p) (has_mbyte ? mb_ptr2char(p) : (int)*(p)) #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
#ifdef FEAT_AUTOCHDIR #ifdef FEAT_AUTOCHDIR
# define DO_AUTOCHDIR do { if (p_acd) do_autochdir(); } while (0) # define DO_AUTOCHDIR do { if (p_acd) do_autochdir(); } while (0)

View File

@@ -69,13 +69,11 @@
#endif #endif
#ifdef FEAT_MBYTE
/* Possible values for 'encoding' */ /* Possible values for 'encoding' */
# define ENC_UCSBOM "ucs-bom" /* check for BOM at start of file */ #define ENC_UCSBOM "ucs-bom" /* check for BOM at start of file */
/* default value for 'encoding' */ /* default value for 'encoding' */
# define ENC_DFLT "latin1" #define ENC_DFLT "latin1"
#endif
/* end-of-line style */ /* end-of-line style */
#define EOL_UNKNOWN -1 /* not defined yet */ #define EOL_UNKNOWN -1 /* not defined yet */
@@ -315,10 +313,8 @@ EXTERN long p_aleph; /* 'aleph' */
#ifdef FEAT_AUTOCHDIR #ifdef FEAT_AUTOCHDIR
EXTERN int p_acd; /* 'autochdir' */ EXTERN int p_acd; /* 'autochdir' */
#endif #endif
#ifdef FEAT_MBYTE
EXTERN char_u *p_ambw; /* 'ambiwidth' */ EXTERN char_u *p_ambw; /* 'ambiwidth' */
EXTERN char_u *p_emoji; /* 'emoji' */ EXTERN char_u *p_emoji; /* 'emoji' */
#endif
#if defined(FEAT_GUI) && defined(MACOS_X) #if defined(FEAT_GUI) && defined(MACOS_X)
EXTERN int *p_antialias; /* 'antialias' */ EXTERN int *p_antialias; /* 'antialias' */
#endif #endif
@@ -395,21 +391,17 @@ EXTERN char_u *p_bsdir; /* 'browsedir' */
#ifdef FEAT_LINEBREAK #ifdef FEAT_LINEBREAK
EXTERN char_u *p_breakat; /* 'breakat' */ EXTERN char_u *p_breakat; /* 'breakat' */
#endif #endif
#ifdef FEAT_MBYTE
EXTERN char_u *p_cmp; /* 'casemap' */ EXTERN char_u *p_cmp; /* 'casemap' */
EXTERN unsigned cmp_flags; EXTERN unsigned cmp_flags;
# ifdef IN_OPTION_C #ifdef IN_OPTION_C
static char *(p_cmp_values[]) = {"internal", "keepascii", NULL}; static char *(p_cmp_values[]) = {"internal", "keepascii", NULL};
# endif
# define CMP_INTERNAL 0x001
# define CMP_KEEPASCII 0x002
#endif #endif
#ifdef FEAT_MBYTE #define CMP_INTERNAL 0x001
#define CMP_KEEPASCII 0x002
EXTERN char_u *p_enc; /* 'encoding' */ EXTERN char_u *p_enc; /* 'encoding' */
EXTERN int p_deco; /* 'delcombine' */ EXTERN int p_deco; /* 'delcombine' */
# ifdef FEAT_EVAL #ifdef FEAT_EVAL
EXTERN char_u *p_ccv; /* 'charconvert' */ EXTERN char_u *p_ccv; /* 'charconvert' */
# endif
#endif #endif
#ifdef FEAT_CMDWIN #ifdef FEAT_CMDWIN
EXTERN char_u *p_cedit; /* 'cedit' */ EXTERN char_u *p_cedit; /* 'cedit' */
@@ -482,9 +474,7 @@ EXTERN char_u *p_gp; /* 'grepprg' */
EXTERN char_u *p_ei; /* 'eventignore' */ EXTERN char_u *p_ei; /* 'eventignore' */
EXTERN int p_ek; /* 'esckeys' */ EXTERN int p_ek; /* 'esckeys' */
EXTERN int p_exrc; /* 'exrc' */ EXTERN int p_exrc; /* 'exrc' */
#ifdef FEAT_MBYTE
EXTERN char_u *p_fencs; /* 'fileencodings' */ EXTERN char_u *p_fencs; /* 'fileencodings' */
#endif
EXTERN char_u *p_ffs; /* 'fileformats' */ EXTERN char_u *p_ffs; /* 'fileformats' */
EXTERN long p_fic; /* 'fileignorecase' */ EXTERN long p_fic; /* 'fileignorecase' */
#ifdef FEAT_FOLDING #ifdef FEAT_FOLDING
@@ -519,11 +509,9 @@ EXTERN char_u *p_pdev; /* 'printdevice' */
# ifdef FEAT_POSTSCRIPT # ifdef FEAT_POSTSCRIPT
EXTERN char_u *p_penc; /* 'printencoding' */ EXTERN char_u *p_penc; /* 'printencoding' */
EXTERN char_u *p_pexpr; /* 'printexpr' */ EXTERN char_u *p_pexpr; /* 'printexpr' */
# ifdef FEAT_MBYTE
EXTERN char_u *p_pmfn; /* 'printmbfont' */ EXTERN char_u *p_pmfn; /* 'printmbfont' */
EXTERN char_u *p_pmcs; /* 'printmbcharset' */ EXTERN char_u *p_pmcs; /* 'printmbcharset' */
# endif # endif
# endif
EXTERN char_u *p_pfn; /* 'printfont' */ EXTERN char_u *p_pfn; /* 'printfont' */
EXTERN char_u *p_popt; /* 'printoptions' */ EXTERN char_u *p_popt; /* 'printoptions' */
EXTERN char_u *p_header; /* 'printheader' */ EXTERN char_u *p_header; /* 'printheader' */
@@ -534,9 +522,7 @@ EXTERN char_u *p_guifont; /* 'guifont' */
# ifdef FEAT_XFONTSET # ifdef FEAT_XFONTSET
EXTERN char_u *p_guifontset; /* 'guifontset' */ EXTERN char_u *p_guifontset; /* 'guifontset' */
# endif # endif
# ifdef FEAT_MBYTE
EXTERN char_u *p_guifontwide; /* 'guifontwide' */ EXTERN char_u *p_guifontwide; /* 'guifontwide' */
# endif
EXTERN int p_guipty; /* 'guipty' */ EXTERN int p_guipty; /* 'guipty' */
#endif #endif
#if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11) #if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11)
@@ -586,14 +572,12 @@ EXTERN char_u *p_imak; /* 'imactivatekey' */
#define IM_OVER_THE_SPOT 1L #define IM_OVER_THE_SPOT 1L
EXTERN long p_imst; /* 'imstyle' */ EXTERN long p_imst; /* 'imstyle' */
#endif #endif
#if defined(FEAT_EVAL) && defined(FEAT_MBYTE) #if defined(FEAT_EVAL)
EXTERN char_u *p_imaf; /* 'imactivatefunc' */ EXTERN char_u *p_imaf; /* 'imactivatefunc' */
EXTERN char_u *p_imsf; /* 'imstatusfunc' */ EXTERN char_u *p_imsf; /* 'imstatusfunc' */
#endif #endif
#ifdef FEAT_MBYTE
EXTERN int p_imcmdline; /* 'imcmdline' */ EXTERN int p_imcmdline; /* 'imcmdline' */
EXTERN int p_imdisable; /* 'imdisable' */ EXTERN int p_imdisable; /* 'imdisable' */
#endif
EXTERN int p_is; /* 'incsearch' */ EXTERN int p_is; /* 'incsearch' */
EXTERN int p_im; /* 'insertmode' */ EXTERN int p_im; /* 'insertmode' */
EXTERN char_u *p_isf; /* 'isfname' */ EXTERN char_u *p_isf; /* 'isfname' */
@@ -629,9 +613,7 @@ EXTERN char_u *p_luadll; /* 'luadll' */
EXTERN int p_macatsui; /* 'macatsui' */ EXTERN int p_macatsui; /* 'macatsui' */
#endif #endif
EXTERN int p_magic; /* 'magic' */ EXTERN int p_magic; /* 'magic' */
#ifdef FEAT_MBYTE
EXTERN char_u *p_menc; /* 'makeencoding' */ EXTERN char_u *p_menc; /* 'makeencoding' */
#endif
#ifdef FEAT_QUICKFIX #ifdef FEAT_QUICKFIX
EXTERN char_u *p_mef; /* 'makeef' */ EXTERN char_u *p_mef; /* 'makeef' */
EXTERN char_u *p_mp; /* 'makeprg' */ EXTERN char_u *p_mp; /* 'makeprg' */
@@ -644,9 +626,7 @@ EXTERN char_u *p_cc; /* 'colorcolumn' */
EXTERN int p_cc_cols[256]; /* array for 'colorcolumn' columns */ EXTERN int p_cc_cols[256]; /* array for 'colorcolumn' columns */
#endif #endif
EXTERN long p_mat; /* 'matchtime' */ EXTERN long p_mat; /* 'matchtime' */
#ifdef FEAT_MBYTE
EXTERN long p_mco; /* 'maxcombine' */ EXTERN long p_mco; /* 'maxcombine' */
#endif
#ifdef FEAT_EVAL #ifdef FEAT_EVAL
EXTERN long p_mfd; /* 'maxfuncdepth' */ EXTERN long p_mfd; /* 'maxfuncdepth' */
#endif #endif
@@ -850,9 +830,7 @@ EXTERN char_u *p_tcldll; /* 'tcldll' */
#ifdef FEAT_ARABIC #ifdef FEAT_ARABIC
EXTERN int p_tbidi; /* 'termbidi' */ EXTERN int p_tbidi; /* 'termbidi' */
#endif #endif
#ifdef FEAT_MBYTE
EXTERN char_u *p_tenc; /* 'termencoding' */ EXTERN char_u *p_tenc; /* 'termencoding' */
#endif
#ifdef FEAT_TERMGUICOLORS #ifdef FEAT_TERMGUICOLORS
EXTERN int p_tgc; /* 'termguicolors' */ EXTERN int p_tgc; /* 'termguicolors' */
#endif #endif
@@ -1001,9 +979,7 @@ enum
#endif #endif
, BV_BIN , BV_BIN
, BV_BL , BV_BL
#ifdef FEAT_MBYTE
, BV_BOMB , BV_BOMB
#endif
, BV_CI , BV_CI
#ifdef FEAT_CINDENT #ifdef FEAT_CINDENT
, BV_CIN , BV_CIN
@@ -1068,9 +1044,7 @@ enum
, BV_LISP , BV_LISP
, BV_LW , BV_LW
#endif #endif
#ifdef FEAT_MBYTE
, BV_MENC , BV_MENC
#endif
, BV_MA , BV_MA
, BV_ML , BV_ML
, BV_MOD , BV_MOD

View File

@@ -37,9 +37,7 @@
# include <Memory.h> # include <Memory.h>
# include <OSUtils.h> # include <OSUtils.h>
# include <Files.h> # include <Files.h>
# ifdef FEAT_MBYTE
# include <Script.h> # include <Script.h>
# endif
#endif #endif
/* /*

View File

@@ -213,14 +213,7 @@ Trace(char *pszFormat, ...);
#endif #endif
/* Enable common dialogs input unicode from IME if possible. */ /* Enable common dialogs input unicode from IME if possible. */
#ifdef FEAT_MBYTE #define pDispatchMessage DispatchMessageW
# define pDispatchMessage DispatchMessageW #define pGetMessage GetMessageW
# define pGetMessage GetMessageW #define pIsDialogMessage IsDialogMessageW
# define pIsDialogMessage IsDialogMessageW #define pPeekMessage PeekMessageW
# define pPeekMessage PeekMessageW
#else
# define pDispatchMessage DispatchMessage
# define pGetMessage GetMessage
# define pIsDialogMessage IsDialogMessage
# define pPeekMessage PeekMessage
#endif

View File

@@ -168,10 +168,7 @@ char_u *vim_strpbrk(char_u *s, char_u *charset);
void qsort(void *base, size_t elm_count, size_t elm_size, int (*cmp)(const void *, const void *)); void qsort(void *base, size_t elm_count, size_t elm_size, int (*cmp)(const void *, const void *));
#endif #endif
# include "move.pro" # include "move.pro"
# if defined(FEAT_MBYTE) || defined(FEAT_XIM) || defined(FEAT_KEYMAP) \
|| defined(FEAT_POSTSCRIPT)
# include "mbyte.pro" # include "mbyte.pro"
# endif
# include "normal.pro" # include "normal.pro"
# include "ops.pro" # include "ops.pro"
# include "option.pro" # include "option.pro"

View File

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

View File

@@ -820,7 +820,6 @@ sign_define_init_text(sign_T *sp, char_u *text)
} }
// Count cells and check for non-printable chars // Count cells and check for non-printable chars
# ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
cells = 0; cells = 0;
@@ -832,7 +831,6 @@ sign_define_init_text(sign_T *sp, char_u *text)
} }
} }
else else
# endif
{ {
for (s = text; s < endp; ++s) for (s = text; s < endp; ++s)
if (!vim_isprintc(*s)) if (!vim_isprintc(*s))

View File

@@ -224,12 +224,8 @@ typedef struct matchinf_S
affixID/condition */ affixID/condition */
int mi_prefcnt; /* number of entries at mi_prefarridx */ int mi_prefcnt; /* number of entries at mi_prefarridx */
int mi_prefixlen; /* byte length of prefix */ int mi_prefixlen; /* byte length of prefix */
#ifdef FEAT_MBYTE
int mi_cprefixlen; /* byte length of prefix in original int mi_cprefixlen; /* byte length of prefix in original
case */ case */
#else
# define mi_cprefixlen mi_prefixlen /* it's the same value */
#endif
/* for when checking a compound word */ /* for when checking a compound word */
int mi_compoff; /* start of following word offset */ int mi_compoff; /* start of following word offset */
@@ -249,9 +245,7 @@ typedef struct matchinf_S
static int spell_iswordp(char_u *p, win_T *wp); static int spell_iswordp(char_u *p, win_T *wp);
#ifdef FEAT_MBYTE
static int spell_mb_isword_class(int cl, win_T *wp); static int spell_mb_isword_class(int cl, win_T *wp);
#endif
/* /*
* For finding suggestions: At each node in the tree these states are tried: * For finding suggestions: At each node in the tree these states are tried:
@@ -295,12 +289,10 @@ typedef struct trystate_S
char_u ts_prefixdepth; /* stack depth for end of prefix or char_u ts_prefixdepth; /* stack depth for end of prefix or
* PFD_PREFIXTREE or PFD_NOPREFIX */ * PFD_PREFIXTREE or PFD_NOPREFIX */
char_u ts_flags; /* TSF_ flags */ char_u ts_flags; /* TSF_ flags */
#ifdef FEAT_MBYTE
char_u ts_tcharlen; /* number of bytes in tword character */ char_u ts_tcharlen; /* number of bytes in tword character */
char_u ts_tcharidx; /* current byte index in tword character */ char_u ts_tcharidx; /* current byte index in tword character */
char_u ts_isdiff; /* DIFF_ values */ char_u ts_isdiff; /* DIFF_ values */
char_u ts_fcharstart; /* index in fword where badword char started */ char_u ts_fcharstart; /* index in fword where badword char started */
#endif
char_u ts_prewordlen; /* length of word in "preword[]" */ char_u ts_prewordlen; /* length of word in "preword[]" */
char_u ts_splitoff; /* index in "tword" after last split */ char_u ts_splitoff; /* index in "tword" after last split */
char_u ts_splitfidx; /* "ts_fidx" at word split */ char_u ts_splitfidx; /* "ts_fidx" at word split */
@@ -358,9 +350,7 @@ static void suggest_try_special(suginfo_T *su);
static void suggest_try_change(suginfo_T *su); static void suggest_try_change(suginfo_T *su);
static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, int soundfold); static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, int soundfold);
static void go_deeper(trystate_T *stack, int depth, int score_add); static void go_deeper(trystate_T *stack, int depth, int score_add);
#ifdef FEAT_MBYTE
static int nofold_len(char_u *fword, int flen, char_u *word); static int nofold_len(char_u *fword, int flen, char_u *word);
#endif
static void find_keepcap_word(slang_T *slang, char_u *fword, char_u *kword); static void find_keepcap_word(slang_T *slang, char_u *fword, char_u *kword);
static void score_comp_sal(suginfo_T *su); static void score_comp_sal(suginfo_T *su);
static void score_combine(suginfo_T *su); static void score_combine(suginfo_T *su);
@@ -380,15 +370,11 @@ static void rescore_one(suginfo_T *su, suggest_T *stp);
static int cleanup_suggestions(garray_T *gap, int maxscore, int keep); static int cleanup_suggestions(garray_T *gap, int maxscore, int keep);
static void spell_soundfold_sofo(slang_T *slang, char_u *inword, char_u *res); static void spell_soundfold_sofo(slang_T *slang, char_u *inword, char_u *res);
static void spell_soundfold_sal(slang_T *slang, char_u *inword, char_u *res); static void spell_soundfold_sal(slang_T *slang, char_u *inword, char_u *res);
#ifdef FEAT_MBYTE
static void spell_soundfold_wsal(slang_T *slang, char_u *inword, char_u *res); static void spell_soundfold_wsal(slang_T *slang, char_u *inword, char_u *res);
#endif
static int soundalike_score(char_u *goodsound, char_u *badsound); static int soundalike_score(char_u *goodsound, char_u *badsound);
static int spell_edit_score(slang_T *slang, char_u *badword, char_u *goodword); static int spell_edit_score(slang_T *slang, char_u *badword, char_u *goodword);
static int spell_edit_score_limit(slang_T *slang, char_u *badword, char_u *goodword, int limit); static int spell_edit_score_limit(slang_T *slang, char_u *badword, char_u *goodword, int limit);
#ifdef FEAT_MBYTE
static int spell_edit_score_limit_w(slang_T *slang, char_u *badword, char_u *goodword, int limit); static int spell_edit_score_limit_w(slang_T *slang, char_u *badword, char_u *goodword, int limit);
#endif
static void dump_word(slang_T *slang, char_u *word, char_u *pat, int *dir, int round, int flags, linenr_T lnum); static void dump_word(slang_T *slang, char_u *word, char_u *pat, int *dir, int round, int flags, linenr_T lnum);
static linenr_T dump_prefixes(slang_T *slang, char_u *word, char_u *pat, int *dir, int round, int flags, linenr_T startlnum); static linenr_T dump_prefixes(slang_T *slang, char_u *word, char_u *pat, int *dir, int round, int flags, linenr_T startlnum);
@@ -565,10 +551,8 @@ spell_check(
*capcol = (int)(regmatch.endp[0] - ptr); *capcol = (int)(regmatch.endp[0] - ptr);
} }
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
return (*mb_ptr2len)(ptr); return (*mb_ptr2len)(ptr);
#endif
return 1; return 1;
} }
else if (mi.mi_end == ptr) else if (mi.mi_end == ptr)
@@ -646,9 +630,7 @@ find_word(matchinf_T *mip, int mode)
int c; int c;
char_u *ptr; char_u *ptr;
idx_T lo, hi, m; idx_T lo, hi, m;
#ifdef FEAT_MBYTE
char_u *s; char_u *s;
#endif
char_u *p; char_u *p;
int res = SP_BAD; int res = SP_BAD;
slang_T *slang = mip->mi_lp->lp_slang; slang_T *slang = mip->mi_lp->lp_slang;
@@ -794,10 +776,8 @@ find_word(matchinf_T *mip, int mode)
arridx = endidx[endidxcnt]; arridx = endidx[endidxcnt];
wlen = endlen[endidxcnt]; wlen = endlen[endidxcnt];
#ifdef FEAT_MBYTE
if ((*mb_head_off)(ptr, ptr + wlen) > 0) if ((*mb_head_off)(ptr, ptr + wlen) > 0)
continue; /* not at first byte of character */ continue; /* not at first byte of character */
#endif
if (spell_iswordp(ptr + wlen, mip->mi_win)) if (spell_iswordp(ptr + wlen, mip->mi_win))
{ {
if (slang->sl_compprog == NULL && !slang->sl_nobreak) if (slang->sl_compprog == NULL && !slang->sl_nobreak)
@@ -810,7 +790,6 @@ find_word(matchinf_T *mip, int mode)
* has been found we try compound flags. */ * has been found we try compound flags. */
prefix_found = FALSE; prefix_found = FALSE;
#ifdef FEAT_MBYTE
if (mode != FIND_KEEPWORD && has_mbyte) if (mode != FIND_KEEPWORD && has_mbyte)
{ {
/* Compute byte length in original word, length may change /* Compute byte length in original word, length may change
@@ -824,7 +803,6 @@ find_word(matchinf_T *mip, int mode)
wlen = (int)(p - mip->mi_word); wlen = (int)(p - mip->mi_word);
} }
} }
#endif
/* Check flags and region. For FIND_PREFIX check the condition and /* Check flags and region. For FIND_PREFIX check the condition and
* prefix ID. * prefix ID.
@@ -896,7 +874,6 @@ find_word(matchinf_T *mip, int mode)
if (((unsigned)flags >> 24) == 0 if (((unsigned)flags >> 24) == 0
|| wlen - mip->mi_compoff < slang->sl_compminlen) || wlen - mip->mi_compoff < slang->sl_compminlen)
continue; continue;
#ifdef FEAT_MBYTE
/* For multi-byte chars check character length against /* For multi-byte chars check character length against
* COMPOUNDMIN. */ * COMPOUNDMIN. */
if (has_mbyte if (has_mbyte
@@ -904,7 +881,6 @@ find_word(matchinf_T *mip, int mode)
&& mb_charlen_len(mip->mi_word + mip->mi_compoff, && mb_charlen_len(mip->mi_word + mip->mi_compoff,
wlen - mip->mi_compoff) < slang->sl_compminlen) wlen - mip->mi_compoff) < slang->sl_compminlen)
continue; continue;
#endif
/* Limit the number of compound words to COMPOUNDWORDMAX if no /* Limit the number of compound words to COMPOUNDWORDMAX if no
* maximum for syllables is specified. */ * maximum for syllables is specified. */
@@ -938,7 +914,6 @@ find_word(matchinf_T *mip, int mode)
/* Need to check the caps type of the appended compound /* Need to check the caps type of the appended compound
* word. */ * word. */
#ifdef FEAT_MBYTE
if (has_mbyte && STRNCMP(ptr, mip->mi_word, if (has_mbyte && STRNCMP(ptr, mip->mi_word,
mip->mi_compoff) != 0) mip->mi_compoff) != 0)
{ {
@@ -948,7 +923,6 @@ find_word(matchinf_T *mip, int mode)
MB_PTR_ADV(p); MB_PTR_ADV(p);
} }
else else
#endif
p = mip->mi_word + mip->mi_compoff; p = mip->mi_word + mip->mi_compoff;
capflags = captype(p, mip->mi_word + wlen); capflags = captype(p, mip->mi_word + wlen);
if (capflags == WF_KEEPCAP || (capflags == WF_ALLCAP if (capflags == WF_KEEPCAP || (capflags == WF_ALLCAP
@@ -1020,7 +994,6 @@ find_word(matchinf_T *mip, int mode)
/* Find following word in case-folded tree. */ /* Find following word in case-folded tree. */
mip->mi_compoff = endlen[endidxcnt]; mip->mi_compoff = endlen[endidxcnt];
#ifdef FEAT_MBYTE
if (has_mbyte && mode == FIND_KEEPWORD) if (has_mbyte && mode == FIND_KEEPWORD)
{ {
/* Compute byte length in case-folded word from "wlen": /* Compute byte length in case-folded word from "wlen":
@@ -1035,7 +1008,6 @@ find_word(matchinf_T *mip, int mode)
mip->mi_compoff = (int)(p - mip->mi_fword); mip->mi_compoff = (int)(p - mip->mi_fword);
} }
} }
#endif
#if 0 /* Disabled, see below */ #if 0 /* Disabled, see below */
c = mip->mi_compoff; c = mip->mi_compoff;
#endif #endif
@@ -1186,15 +1158,12 @@ match_checkcompoundpattern(
static int static int
can_compound(slang_T *slang, char_u *word, char_u *flags) can_compound(slang_T *slang, char_u *word, char_u *flags)
{ {
#ifdef FEAT_MBYTE
char_u uflags[MAXWLEN * 2]; char_u uflags[MAXWLEN * 2];
int i; int i;
#endif
char_u *p; char_u *p;
if (slang->sl_compprog == NULL) if (slang->sl_compprog == NULL)
return FALSE; return FALSE;
#ifdef FEAT_MBYTE
if (enc_utf8) if (enc_utf8)
{ {
/* Need to convert the single byte flags to utf8 characters. */ /* Need to convert the single byte flags to utf8 characters. */
@@ -1205,7 +1174,6 @@ can_compound(slang_T *slang, char_u *word, char_u *flags)
p = uflags; p = uflags;
} }
else else
#endif
p = flags; p = flags;
if (!vim_regexec_prog(&slang->sl_compprog, FALSE, p, 0)) if (!vim_regexec_prog(&slang->sl_compprog, FALSE, p, 0))
return FALSE; return FALSE;
@@ -1434,7 +1402,6 @@ find_prefix(matchinf_T *mip, int mode)
/* Skip over the previously found word(s). */ /* Skip over the previously found word(s). */
mip->mi_prefixlen += mip->mi_compoff; mip->mi_prefixlen += mip->mi_compoff;
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
/* Case-folded length may differ from original length. */ /* Case-folded length may differ from original length. */
@@ -1443,7 +1410,6 @@ find_prefix(matchinf_T *mip, int mode)
} }
else else
mip->mi_cprefixlen = mip->mi_prefixlen; mip->mi_cprefixlen = mip->mi_prefixlen;
#endif
find_word(mip, FIND_PREFIX); find_word(mip, FIND_PREFIX);
@@ -1912,10 +1878,8 @@ spell_load_lang(char_u *lang)
spell_enc(void) spell_enc(void)
{ {
#ifdef FEAT_MBYTE
if (STRLEN(p_enc) < 60 && STRCMP(p_enc, "iso-8859-15") != 0) if (STRLEN(p_enc) < 60 && STRCMP(p_enc, "iso-8859-15") != 0)
return p_enc; return p_enc;
#endif
return (char_u *)"latin1"; return (char_u *)"latin1";
} }
@@ -2015,11 +1979,9 @@ slang_clear(slang_T *lp)
vim_free(smp->sm_lead); vim_free(smp->sm_lead);
/* Don't free sm_oneof and sm_rules, they point into sm_lead. */ /* Don't free sm_oneof and sm_rules, they point into sm_lead. */
vim_free(smp->sm_to); vim_free(smp->sm_to);
#ifdef FEAT_MBYTE
vim_free(smp->sm_lead_w); vim_free(smp->sm_lead_w);
vim_free(smp->sm_oneof_w); vim_free(smp->sm_oneof_w);
vim_free(smp->sm_to_w); vim_free(smp->sm_to_w);
#endif
} }
ga_clear(gap); ga_clear(gap);
@@ -2046,9 +2008,7 @@ slang_clear(slang_T *lp)
hash_clear_all(&lp->sl_wordcount, WC_KEY_OFF); hash_clear_all(&lp->sl_wordcount, WC_KEY_OFF);
hash_init(&lp->sl_wordcount); hash_init(&lp->sl_wordcount);
#ifdef FEAT_MBYTE
hash_clear_all(&lp->sl_map_hash, 0); hash_clear_all(&lp->sl_map_hash, 0);
#endif
/* Clear info from .sug file. */ /* Clear info from .sug file. */
slang_clear_sug(lp); slang_clear_sug(lp);
@@ -2284,13 +2244,8 @@ count_syllables(slang_T *slang, char_u *word)
else else
{ {
/* No recognized syllable item, at least a syllable char then? */ /* No recognized syllable item, at least a syllable char then? */
#ifdef FEAT_MBYTE
c = mb_ptr2char(p); c = mb_ptr2char(p);
len = (*mb_ptr2len)(p); len = (*mb_ptr2len)(p);
#else
c = *p;
len = 1;
#endif
if (vim_strchr(slang->sl_syllable, c) == NULL) if (vim_strchr(slang->sl_syllable, c) == NULL)
skip = FALSE; /* No, search for next syllable */ skip = FALSE; /* No, search for next syllable */
else if (!skip) else if (!skip)
@@ -2352,9 +2307,7 @@ did_set_spelllang(win_T *wp)
if (spl_copy == NULL) if (spl_copy == NULL)
goto theend; goto theend;
#ifdef FEAT_MBYTE
wp->w_s->b_cjk = 0; wp->w_s->b_cjk = 0;
#endif
/* Loop over comma separated language names. */ /* Loop over comma separated language names. */
for (splp = spl_copy; *splp != NUL; ) for (splp = spl_copy; *splp != NUL; )
@@ -2366,9 +2319,7 @@ did_set_spelllang(win_T *wp)
if (STRCMP(lang, "cjk") == 0) if (STRCMP(lang, "cjk") == 0)
{ {
#ifdef FEAT_MBYTE
wp->w_s->b_cjk = 1; wp->w_s->b_cjk = 1;
#endif
continue; continue;
} }
@@ -2633,9 +2584,7 @@ theend:
clear_midword(win_T *wp) clear_midword(win_T *wp)
{ {
vim_memset(wp->w_s->b_spell_ismw, 0, 256); vim_memset(wp->w_s->b_spell_ismw, 0, 256);
#ifdef FEAT_MBYTE
VIM_CLEAR(wp->w_s->b_spell_ismw_mb); VIM_CLEAR(wp->w_s->b_spell_ismw_mb);
#endif
} }
/* /*
@@ -2651,7 +2600,6 @@ use_midword(slang_T *lp, win_T *wp)
return; return;
for (p = lp->sl_midword; *p != NUL; ) for (p = lp->sl_midword; *p != NUL; )
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
int c, l, n; int c, l, n;
@@ -2679,7 +2627,6 @@ use_midword(slang_T *lp, win_T *wp)
p += l; p += l;
} }
else else
#endif
wp->w_s->b_spell_ismw[*p++] = TRUE; wp->w_s->b_spell_ismw[*p++] = TRUE;
} }
@@ -2725,11 +2672,9 @@ captype(
for (p = word; !spell_iswordp_nmw(p, curwin); MB_PTR_ADV(p)) for (p = word; !spell_iswordp_nmw(p, curwin); MB_PTR_ADV(p))
if (end == NULL ? *p == NUL : p >= end) if (end == NULL ? *p == NUL : p >= end)
return 0; /* only non-word characters, illegal word */ return 0; /* only non-word characters, illegal word */
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
c = mb_ptr2char_adv(&p); c = mb_ptr2char_adv(&p);
else else
#endif
c = *p++; c = *p++;
firstcap = allcap = SPELL_ISUPPER(c); firstcap = allcap = SPELL_ISUPPER(c);
@@ -2825,7 +2770,6 @@ spell_delete_wordlist(void)
} }
} }
#if defined(FEAT_MBYTE) || defined(EXITFREE) || defined(PROTO)
/* /*
* Free all languages. * Free all languages.
*/ */
@@ -2851,9 +2795,7 @@ spell_free_all(void)
VIM_CLEAR(repl_to); VIM_CLEAR(repl_to);
VIM_CLEAR(repl_from); VIM_CLEAR(repl_from);
} }
#endif
#if defined(FEAT_MBYTE) || defined(PROTO)
/* /*
* Clear all spelling tables and reload them. * Clear all spelling tables and reload them.
* Used after 'encoding' is set and when ":mkspell" was used. * Used after 'encoding' is set and when ":mkspell" was used.
@@ -2884,7 +2826,6 @@ spell_reload(void)
} }
} }
} }
#endif
/* /*
* Opposite of offset2bytes(). * Opposite of offset2bytes().
@@ -3016,7 +2957,6 @@ init_spell_chartab(void)
did_set_spelltab = FALSE; did_set_spelltab = FALSE;
clear_spell_chartab(&spelltab); clear_spell_chartab(&spelltab);
#ifdef FEAT_MBYTE
if (enc_dbcs) if (enc_dbcs)
{ {
/* DBCS: assume double-wide characters are word characters. */ /* DBCS: assume double-wide characters are word characters. */
@@ -3041,7 +2981,6 @@ init_spell_chartab(void)
} }
} }
else else
#endif
{ {
/* Rough guess: use locale-dependent library functions. */ /* Rough guess: use locale-dependent library functions. */
for (i = 128; i < 256; ++i) for (i = 128; i < 256; ++i)
@@ -3073,7 +3012,6 @@ spell_iswordp(
char_u *p, char_u *p,
win_T *wp) /* buffer used */ win_T *wp) /* buffer used */
{ {
#ifdef FEAT_MBYTE
char_u *s; char_u *s;
int l; int l;
int c; int c;
@@ -3102,7 +3040,6 @@ spell_iswordp(
return spell_mb_isword_class(mb_get_class(s), wp); return spell_mb_isword_class(mb_get_class(s), wp);
return spelltab.st_isw[c]; return spelltab.st_isw[c];
} }
#endif
return spelltab.st_isw[wp->w_s->b_spell_ismw[*p] ? p[1] : p[0]]; return spelltab.st_isw[wp->w_s->b_spell_ismw[*p] ? p[1] : p[0]];
} }
@@ -3114,7 +3051,6 @@ spell_iswordp(
int int
spell_iswordp_nmw(char_u *p, win_T *wp) spell_iswordp_nmw(char_u *p, win_T *wp)
{ {
#ifdef FEAT_MBYTE
int c; int c;
if (has_mbyte) if (has_mbyte)
@@ -3124,11 +3060,9 @@ spell_iswordp_nmw(char_u *p, win_T *wp)
return spell_mb_isword_class(mb_get_class(p), wp); return spell_mb_isword_class(mb_get_class(p), wp);
return spelltab.st_isw[c]; return spelltab.st_isw[c];
} }
#endif
return spelltab.st_isw[*p]; return spelltab.st_isw[*p];
} }
#ifdef FEAT_MBYTE
/* /*
* Return TRUE if word class indicates a word character. * Return TRUE if word class indicates a word character.
* Only for characters above 255. * Only for characters above 255.
@@ -3171,7 +3105,6 @@ spell_iswordp_w(int *p, win_T *wp)
} }
return spelltab.st_isw[*s]; return spelltab.st_isw[*s];
} }
#endif
/* /*
* Case-fold "str[len]" into "buf[buflen]". The result is NUL terminated. * Case-fold "str[len]" into "buf[buflen]". The result is NUL terminated.
@@ -3194,7 +3127,6 @@ spell_casefold(
return FAIL; /* result will not fit */ return FAIL; /* result will not fit */
} }
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
int outi = 0; int outi = 0;
@@ -3215,7 +3147,6 @@ spell_casefold(
buf[outi] = NUL; buf[outi] = NUL;
} }
else else
#endif
{ {
/* Be quick for non-multibyte encodings. */ /* Be quick for non-multibyte encodings. */
for (i = 0; i < len; ++i) for (i = 0; i < len; ++i)
@@ -4072,21 +4003,17 @@ onecap_copy(
int l; int l;
p = word; p = word;
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
c = mb_cptr2char_adv(&p); c = mb_cptr2char_adv(&p);
else else
#endif
c = *p++; c = *p++;
if (upper) if (upper)
c = SPELL_TOUPPER(c); c = SPELL_TOUPPER(c);
else else
c = SPELL_TOFOLD(c); c = SPELL_TOFOLD(c);
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
l = mb_char2bytes(c, wcopy); l = mb_char2bytes(c, wcopy);
else else
#endif
{ {
l = 1; l = 1;
wcopy[0] = c; wcopy[0] = c;
@@ -4108,14 +4035,11 @@ allcap_copy(char_u *word, char_u *wcopy)
d = wcopy; d = wcopy;
for (s = word; *s != NUL; ) for (s = word; *s != NUL; )
{ {
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
c = mb_cptr2char_adv(&s); c = mb_cptr2char_adv(&s);
else else
#endif
c = *s++; c = *s++;
#ifdef FEAT_MBYTE
/* We only change 0xdf to SS when we are certain latin1 is used. It /* We only change 0xdf to SS when we are certain latin1 is used. It
* would cause weird errors in other 8-bit encodings. */ * would cause weird errors in other 8-bit encodings. */
if (enc_latin1like && c == 0xdf) if (enc_latin1like && c == 0xdf)
@@ -4126,10 +4050,8 @@ allcap_copy(char_u *word, char_u *wcopy)
*d++ = c; *d++ = c;
} }
else else
#endif
c = SPELL_TOUPPER(c); c = SPELL_TOUPPER(c);
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
if (d - wcopy >= MAXWLEN - MB_MAXBYTES) if (d - wcopy >= MAXWLEN - MB_MAXBYTES)
@@ -4137,7 +4059,6 @@ allcap_copy(char_u *word, char_u *wcopy)
d += mb_char2bytes(c, d); d += mb_char2bytes(c, d);
} }
else else
#endif
{ {
if (d - wcopy >= MAXWLEN - 1) if (d - wcopy >= MAXWLEN - 1)
break; break;
@@ -4434,11 +4355,9 @@ suggest_trie_walk(
{ {
/* Set su->su_badflags to the caps type at this position. /* Set su->su_badflags to the caps type at this position.
* Use the caps type until here for the prefix itself. */ * Use the caps type until here for the prefix itself. */
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
n = nofold_len(fword, sp->ts_fidx, su->su_badptr); n = nofold_len(fword, sp->ts_fidx, su->su_badptr);
else else
#endif
n = sp->ts_fidx; n = sp->ts_fidx;
flags = badword_captype(su->su_badptr, su->su_badptr + n); flags = badword_captype(su->su_badptr, su->su_badptr + n);
su->su_badflags = badword_captype(su->su_badptr + n, su->su_badflags = badword_captype(su->su_badptr + n,
@@ -4568,7 +4487,6 @@ suggest_trie_walk(
|| sp->ts_twordlen - sp->ts_splitoff || sp->ts_twordlen - sp->ts_splitoff
< slang->sl_compminlen) < slang->sl_compminlen)
break; break;
#ifdef FEAT_MBYTE
/* For multi-byte chars check character length against /* For multi-byte chars check character length against
* COMPOUNDMIN. */ * COMPOUNDMIN. */
if (has_mbyte if (has_mbyte
@@ -4576,7 +4494,6 @@ suggest_trie_walk(
&& mb_charlen(tword + sp->ts_splitoff) && mb_charlen(tword + sp->ts_splitoff)
< slang->sl_compminlen) < slang->sl_compminlen)
break; break;
#endif
compflags[sp->ts_complen] = ((unsigned)flags >> 24); compflags[sp->ts_complen] = ((unsigned)flags >> 24);
compflags[sp->ts_complen + 1] = NUL; compflags[sp->ts_complen + 1] = NUL;
@@ -4625,12 +4542,7 @@ suggest_trie_walk(
* allcap and it's only one char long use onecap. */ * allcap and it's only one char long use onecap. */
c = su->su_badflags; c = su->su_badflags;
if ((c & WF_ALLCAP) if ((c & WF_ALLCAP)
#ifdef FEAT_MBYTE && su->su_badlen == (*mb_ptr2len)(su->su_badptr))
&& su->su_badlen == (*mb_ptr2len)(su->su_badptr)
#else
&& su->su_badlen == 1
#endif
)
c = WF_ONECAP; c = WF_ONECAP;
c |= flags; c |= flags;
@@ -4752,11 +4664,8 @@ suggest_trie_walk(
* Try word split and/or compounding. * Try word split and/or compounding.
*/ */
if ((sp->ts_fidx >= sp->ts_fidxtry || fword_ends) if ((sp->ts_fidx >= sp->ts_fidxtry || fword_ends)
#ifdef FEAT_MBYTE
/* Don't split halfway a character. */ /* Don't split halfway a character. */
&& (!has_mbyte || sp->ts_tcharlen == 0) && (!has_mbyte || sp->ts_tcharlen == 0))
#endif
)
{ {
int try_compound; int try_compound;
int try_split; int try_split;
@@ -4789,12 +4698,10 @@ suggest_trie_walk(
&& ((unsigned)flags >> 24) != 0 && ((unsigned)flags >> 24) != 0
&& sp->ts_twordlen - sp->ts_splitoff && sp->ts_twordlen - sp->ts_splitoff
>= slang->sl_compminlen >= slang->sl_compminlen
#ifdef FEAT_MBYTE
&& (!has_mbyte && (!has_mbyte
|| slang->sl_compminlen == 0 || slang->sl_compminlen == 0
|| mb_charlen(tword + sp->ts_splitoff) || mb_charlen(tword + sp->ts_splitoff)
>= slang->sl_compminlen) >= slang->sl_compminlen)
#endif
&& (slang->sl_compsylmax < MAXWLEN && (slang->sl_compsylmax < MAXWLEN
|| sp->ts_complen + 1 - sp->ts_compsplit || sp->ts_complen + 1 - sp->ts_compsplit
< slang->sl_compmax) < slang->sl_compmax)
@@ -4921,11 +4828,9 @@ suggest_trie_walk(
/* set su->su_badflags to the caps type at this /* set su->su_badflags to the caps type at this
* position */ * position */
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
n = nofold_len(fword, sp->ts_fidx, su->su_badptr); n = nofold_len(fword, sp->ts_fidx, su->su_badptr);
else else
#endif
n = sp->ts_fidx; n = sp->ts_fidx;
su->su_badflags = badword_captype(su->su_badptr + n, su->su_badflags = badword_captype(su->su_badptr + n,
su->su_badptr + su->su_badlen); su->su_badptr + su->su_badlen);
@@ -4963,11 +4868,7 @@ suggest_trie_walk(
case STATE_ENDNUL: case STATE_ENDNUL:
/* Past the NUL bytes in the node. */ /* Past the NUL bytes in the node. */
su->su_badflags = sp->ts_save_badflags; su->su_badflags = sp->ts_save_badflags;
if (fword[sp->ts_fidx] == NUL if (fword[sp->ts_fidx] == NUL && sp->ts_tcharlen == 0)
#ifdef FEAT_MBYTE
&& sp->ts_tcharlen == 0
#endif
)
{ {
/* The badword ends, can't use STATE_PLAIN. */ /* The badword ends, can't use STATE_PLAIN. */
PROF_STORE(sp->ts_state) PROF_STORE(sp->ts_state)
@@ -5005,10 +4906,7 @@ suggest_trie_walk(
* just deleted this byte, accepting it is always cheaper than * just deleted this byte, accepting it is always cheaper than
* delete + substitute. */ * delete + substitute. */
if (c == fword[sp->ts_fidx] if (c == fword[sp->ts_fidx]
#ifdef FEAT_MBYTE || (sp->ts_tcharlen > 0 && sp->ts_isdiff != DIFF_NONE))
|| (sp->ts_tcharlen > 0 && sp->ts_isdiff != DIFF_NONE)
#endif
)
newscore = 0; newscore = 0;
else else
newscore = SCORE_SUBST; newscore = SCORE_SUBST;
@@ -5034,7 +4932,6 @@ suggest_trie_walk(
++sp->ts_fidx; ++sp->ts_fidx;
tword[sp->ts_twordlen++] = c; tword[sp->ts_twordlen++] = c;
sp->ts_arridx = idxs[arridx]; sp->ts_arridx = idxs[arridx];
#ifdef FEAT_MBYTE
if (newscore == SCORE_SUBST) if (newscore == SCORE_SUBST)
sp->ts_isdiff = DIFF_YES; sp->ts_isdiff = DIFF_YES;
if (has_mbyte) if (has_mbyte)
@@ -5122,7 +5019,6 @@ suggest_trie_walk(
} }
} }
else else
#endif
{ {
/* If we found a similar char adjust the score. /* If we found a similar char adjust the score.
* We do this after calling go_deeper() because * We do this after calling go_deeper() because
@@ -5139,7 +5035,6 @@ suggest_trie_walk(
break; break;
case STATE_DEL: case STATE_DEL:
#ifdef FEAT_MBYTE
/* When past the first byte of a multi-byte char don't try /* When past the first byte of a multi-byte char don't try
* delete/insert/swap a character. */ * delete/insert/swap a character. */
if (has_mbyte && sp->ts_tcharlen > 0) if (has_mbyte && sp->ts_tcharlen > 0)
@@ -5148,7 +5043,6 @@ suggest_trie_walk(
sp->ts_state = STATE_FINAL; sp->ts_state = STATE_FINAL;
break; break;
} }
#endif
/* /*
* Try skipping one character in the bad word (delete it). * Try skipping one character in the bad word (delete it).
*/ */
@@ -5181,7 +5075,6 @@ suggest_trie_walk(
* score if the same character is following "nn" -> "n". It's * score if the same character is following "nn" -> "n". It's
* a bit illogical for soundfold tree but it does give better * a bit illogical for soundfold tree but it does give better
* results. */ * results. */
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
c = mb_ptr2char(fword + sp->ts_fidx); c = mb_ptr2char(fword + sp->ts_fidx);
@@ -5192,7 +5085,6 @@ suggest_trie_walk(
stack[depth].ts_score -= SCORE_DEL - SCORE_DELDUP; stack[depth].ts_score -= SCORE_DEL - SCORE_DELDUP;
} }
else else
#endif
{ {
++stack[depth].ts_fidx; ++stack[depth].ts_fidx;
if (fword[sp->ts_fidx] == fword[sp->ts_fidx + 1]) if (fword[sp->ts_fidx] == fword[sp->ts_fidx + 1])
@@ -5274,7 +5166,6 @@ suggest_trie_walk(
sp = &stack[depth]; sp = &stack[depth];
tword[sp->ts_twordlen++] = c; tword[sp->ts_twordlen++] = c;
sp->ts_arridx = idxs[n]; sp->ts_arridx = idxs[n];
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
fl = MB_BYTE2LEN(c); fl = MB_BYTE2LEN(c);
@@ -5291,7 +5182,6 @@ suggest_trie_walk(
else else
fl = 1; fl = 1;
if (fl == 1) if (fl == 1)
#endif
{ {
/* If the previous character was the same, thus doubling a /* If the previous character was the same, thus doubling a
* character, give a bonus to the score. Also for * character, give a bonus to the score. Also for
@@ -5329,7 +5219,6 @@ suggest_trie_walk(
break; break;
} }
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
n = MB_CPTR2LEN(p); n = MB_CPTR2LEN(p);
@@ -5342,7 +5231,6 @@ suggest_trie_walk(
c2 = mb_ptr2char(p + n); c2 = mb_ptr2char(p + n);
} }
else else
#endif
{ {
if (p[1] == NUL) if (p[1] == NUL)
c2 = NUL; c2 = NUL;
@@ -5379,7 +5267,6 @@ suggest_trie_walk(
PROF_STORE(sp->ts_state) PROF_STORE(sp->ts_state)
sp->ts_state = STATE_UNSWAP; sp->ts_state = STATE_UNSWAP;
++depth; ++depth;
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
fl = mb_char2len(c2); fl = mb_char2len(c2);
@@ -5388,7 +5275,6 @@ suggest_trie_walk(
stack[depth].ts_fidxtry = sp->ts_fidx + n + fl; stack[depth].ts_fidxtry = sp->ts_fidx + n + fl;
} }
else else
#endif
{ {
p[0] = c2; p[0] = c2;
p[1] = c; p[1] = c;
@@ -5406,7 +5292,6 @@ suggest_trie_walk(
case STATE_UNSWAP: case STATE_UNSWAP:
/* Undo the STATE_SWAP swap: "21" -> "12". */ /* Undo the STATE_SWAP swap: "21" -> "12". */
p = fword + sp->ts_fidx; p = fword + sp->ts_fidx;
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
n = MB_PTR2LEN(p); n = MB_PTR2LEN(p);
@@ -5415,7 +5300,6 @@ suggest_trie_walk(
mb_char2bytes(c, p); mb_char2bytes(c, p);
} }
else else
#endif
{ {
c = *p; c = *p;
*p = p[1]; *p = p[1];
@@ -5427,7 +5311,6 @@ suggest_trie_walk(
/* Swap two bytes, skipping one: "123" -> "321". We change /* Swap two bytes, skipping one: "123" -> "321". We change
* "fword" here, it's changed back afterwards at STATE_UNSWAP3. */ * "fword" here, it's changed back afterwards at STATE_UNSWAP3. */
p = fword + sp->ts_fidx; p = fword + sp->ts_fidx;
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
n = MB_CPTR2LEN(p); n = MB_CPTR2LEN(p);
@@ -5440,7 +5323,6 @@ suggest_trie_walk(
c3 = mb_ptr2char(p + n + fl); c3 = mb_ptr2char(p + n + fl);
} }
else else
#endif
{ {
c = *p; c = *p;
c2 = p[1]; c2 = p[1];
@@ -5473,7 +5355,6 @@ suggest_trie_walk(
PROF_STORE(sp->ts_state) PROF_STORE(sp->ts_state)
sp->ts_state = STATE_UNSWAP3; sp->ts_state = STATE_UNSWAP3;
++depth; ++depth;
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
tl = mb_char2len(c3); tl = mb_char2len(c3);
@@ -5483,7 +5364,6 @@ suggest_trie_walk(
stack[depth].ts_fidxtry = sp->ts_fidx + n + fl + tl; stack[depth].ts_fidxtry = sp->ts_fidx + n + fl + tl;
} }
else else
#endif
{ {
p[0] = p[2]; p[0] = p[2];
p[2] = c; p[2] = c;
@@ -5500,7 +5380,6 @@ suggest_trie_walk(
case STATE_UNSWAP3: case STATE_UNSWAP3:
/* Undo STATE_SWAP3: "321" -> "123" */ /* Undo STATE_SWAP3: "321" -> "123" */
p = fword + sp->ts_fidx; p = fword + sp->ts_fidx;
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
n = MB_PTR2LEN(p); n = MB_PTR2LEN(p);
@@ -5514,7 +5393,6 @@ suggest_trie_walk(
p = p + tl; p = p + tl;
} }
else else
#endif
{ {
c = *p; c = *p;
*p = p[2]; *p = p[2];
@@ -5546,7 +5424,6 @@ suggest_trie_walk(
sp->ts_state = STATE_UNROT3L; sp->ts_state = STATE_UNROT3L;
++depth; ++depth;
p = fword + sp->ts_fidx; p = fword + sp->ts_fidx;
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
n = MB_CPTR2LEN(p); n = MB_CPTR2LEN(p);
@@ -5558,7 +5435,6 @@ suggest_trie_walk(
stack[depth].ts_fidxtry = sp->ts_fidx + n + fl; stack[depth].ts_fidxtry = sp->ts_fidx + n + fl;
} }
else else
#endif
{ {
c = *p; c = *p;
*p = p[1]; *p = p[1];
@@ -5577,7 +5453,6 @@ suggest_trie_walk(
case STATE_UNROT3L: case STATE_UNROT3L:
/* Undo ROT3L: "231" -> "123" */ /* Undo ROT3L: "231" -> "123" */
p = fword + sp->ts_fidx; p = fword + sp->ts_fidx;
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
n = MB_PTR2LEN(p); n = MB_PTR2LEN(p);
@@ -5588,7 +5463,6 @@ suggest_trie_walk(
mb_char2bytes(c, p); mb_char2bytes(c, p);
} }
else else
#endif
{ {
c = p[2]; c = p[2];
p[2] = p[1]; p[2] = p[1];
@@ -5611,7 +5485,6 @@ suggest_trie_walk(
sp->ts_state = STATE_UNROT3R; sp->ts_state = STATE_UNROT3R;
++depth; ++depth;
p = fword + sp->ts_fidx; p = fword + sp->ts_fidx;
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
n = MB_CPTR2LEN(p); n = MB_CPTR2LEN(p);
@@ -5623,7 +5496,6 @@ suggest_trie_walk(
stack[depth].ts_fidxtry = sp->ts_fidx + n + tl; stack[depth].ts_fidxtry = sp->ts_fidx + n + tl;
} }
else else
#endif
{ {
c = p[2]; c = p[2];
p[2] = p[1]; p[2] = p[1];
@@ -5642,7 +5514,6 @@ suggest_trie_walk(
case STATE_UNROT3R: case STATE_UNROT3R:
/* Undo ROT3R: "312" -> "123" */ /* Undo ROT3R: "312" -> "123" */
p = fword + sp->ts_fidx; p = fword + sp->ts_fidx;
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
c = mb_ptr2char(p); c = mb_ptr2char(p);
@@ -5653,7 +5524,6 @@ suggest_trie_walk(
mb_char2bytes(c, p + n); mb_char2bytes(c, p + n);
} }
else else
#endif
{ {
c = *p; c = *p;
*p = p[1]; *p = p[1];
@@ -5738,9 +5608,7 @@ suggest_trie_walk(
} }
mch_memmove(p, ftp->ft_to, tl); mch_memmove(p, ftp->ft_to, tl);
stack[depth].ts_fidxtry = sp->ts_fidx + tl; stack[depth].ts_fidxtry = sp->ts_fidx + tl;
#ifdef FEAT_MBYTE
stack[depth].ts_tcharlen = 0; stack[depth].ts_tcharlen = 0;
#endif
break; break;
} }
} }
@@ -5809,7 +5677,6 @@ go_deeper(trystate_T *stack, int depth, int score_add)
stack[depth + 1].ts_flags = 0; stack[depth + 1].ts_flags = 0;
} }
#ifdef FEAT_MBYTE
/* /*
* Case-folding may change the number of bytes: Count nr of chars in * Case-folding may change the number of bytes: Count nr of chars in
* fword[flen] and return the byte length of that many chars in "word". * fword[flen] and return the byte length of that many chars in "word".
@@ -5826,7 +5693,6 @@ nofold_len(char_u *fword, int flen, char_u *word)
--i; --i;
return (int)(p - word); return (int)(p - word);
} }
#endif
/* /*
* "fword" is a good word with case folded. Find the matching keep-case * "fword" is a good word with case folded. Find the matching keep-case
@@ -5905,14 +5771,12 @@ find_keepcap_word(slang_T *slang, char_u *fword, char_u *kword)
* round[depth] == 1: Try using the folded-case character. * round[depth] == 1: Try using the folded-case character.
* round[depth] == 2: Try using the upper-case character. * round[depth] == 2: Try using the upper-case character.
*/ */
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
flen = MB_CPTR2LEN(fword + fwordidx[depth]); flen = MB_CPTR2LEN(fword + fwordidx[depth]);
ulen = MB_CPTR2LEN(uword + uwordidx[depth]); ulen = MB_CPTR2LEN(uword + uwordidx[depth]);
} }
else else
#endif
ulen = flen = 1; ulen = flen = 1;
if (round[depth] == 1) if (round[depth] == 1)
{ {
@@ -6627,7 +6491,6 @@ make_case_word(char_u *fword, char_u *cword, int flags)
similar_chars(slang_T *slang, int c1, int c2) similar_chars(slang_T *slang, int c1, int c2)
{ {
int m1, m2; int m1, m2;
#ifdef FEAT_MBYTE
char_u buf[MB_MAXBYTES + 1]; char_u buf[MB_MAXBYTES + 1];
hashitem_T *hi; hashitem_T *hi;
@@ -6641,13 +6504,11 @@ similar_chars(slang_T *slang, int c1, int c2)
m1 = mb_ptr2char(hi->hi_key + STRLEN(hi->hi_key) + 1); m1 = mb_ptr2char(hi->hi_key + STRLEN(hi->hi_key) + 1);
} }
else else
#endif
m1 = slang->sl_map_array[c1]; m1 = slang->sl_map_array[c1];
if (m1 == 0) if (m1 == 0)
return FALSE; return FALSE;
#ifdef FEAT_MBYTE
if (c2 >= 256) if (c2 >= 256)
{ {
buf[mb_char2bytes(c2, buf)] = 0; buf[mb_char2bytes(c2, buf)] = 0;
@@ -6658,7 +6519,6 @@ similar_chars(slang_T *slang, int c1, int c2)
m2 = mb_ptr2char(hi->hi_key + STRLEN(hi->hi_key) + 1); m2 = mb_ptr2char(hi->hi_key + STRLEN(hi->hi_key) + 1);
} }
else else
#endif
m2 = slang->sl_map_array[c2]; m2 = slang->sl_map_array[c2];
return m1 == m2; return m1 == m2;
@@ -6700,15 +6560,12 @@ add_suggestion(
break; break;
MB_PTR_BACK(goodword, pgood); MB_PTR_BACK(goodword, pgood);
MB_PTR_BACK(su->su_badptr, pbad); MB_PTR_BACK(su->su_badptr, pbad);
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
if (mb_ptr2char(pgood) != mb_ptr2char(pbad)) if (mb_ptr2char(pgood) != mb_ptr2char(pbad))
break; break;
} }
else else if (*pgood != *pbad)
#endif
if (*pgood != *pbad)
break; break;
} }
@@ -7028,11 +6885,9 @@ spell_soundfold(
word = fword; word = fword;
} }
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
spell_soundfold_wsal(slang, word, res); spell_soundfold_wsal(slang, word, res);
else else
#endif
spell_soundfold_sal(slang, word, res); spell_soundfold_sal(slang, word, res);
} }
} }
@@ -7048,7 +6903,6 @@ spell_soundfold_sofo(slang_T *slang, char_u *inword, char_u *res)
int ri = 0; int ri = 0;
int c; int c;
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
int prevc = 0; int prevc = 0;
@@ -7095,7 +6949,6 @@ spell_soundfold_sofo(slang_T *slang, char_u *inword, char_u *res)
} }
} }
else else
#endif
{ {
/* The sl_sal_first[] table contains the translation. */ /* The sl_sal_first[] table contains the translation. */
for (s = inword; (c = *s) != NUL; ++s) for (s = inword; (c = *s) != NUL; ++s)
@@ -7385,7 +7238,6 @@ spell_soundfold_sal(slang_T *slang, char_u *inword, char_u *res)
res[reslen] = NUL; res[reslen] = NUL;
} }
#ifdef FEAT_MBYTE
/* /*
* Turn "inword" into its sound-a-like equivalent in "res[MAXWLEN]". * Turn "inword" into its sound-a-like equivalent in "res[MAXWLEN]".
* Multi-byte version of spell_soundfold(). * Multi-byte version of spell_soundfold().
@@ -7698,7 +7550,6 @@ spell_soundfold_wsal(slang_T *slang, char_u *inword, char_u *res)
} }
res[l] = NUL; res[l] = NUL;
} }
#endif
/* /*
* Compute a score for two sound-a-like words. * Compute a score for two sound-a-like words.
@@ -7953,7 +7804,6 @@ spell_edit_score(
int t; int t;
int bc, gc; int bc, gc;
int pbc, pgc; int pbc, pgc;
#ifdef FEAT_MBYTE
char_u *p; char_u *p;
int wbadword[MAXWLEN]; int wbadword[MAXWLEN];
int wgoodword[MAXWLEN]; int wgoodword[MAXWLEN];
@@ -7970,7 +7820,6 @@ spell_edit_score(
wgoodword[goodlen++] = 0; wgoodword[goodlen++] = 0;
} }
else else
#endif
{ {
badlen = (int)STRLEN(badword) + 1; badlen = (int)STRLEN(badword) + 1;
goodlen = (int)STRLEN(goodword) + 1; goodlen = (int)STRLEN(goodword) + 1;
@@ -7992,14 +7841,12 @@ spell_edit_score(
CNT(i, 0) = CNT(i - 1, 0) + SCORE_DEL; CNT(i, 0) = CNT(i - 1, 0) + SCORE_DEL;
for (j = 1; j <= goodlen; ++j) for (j = 1; j <= goodlen; ++j)
{ {
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
bc = wbadword[i - 1]; bc = wbadword[i - 1];
gc = wgoodword[j - 1]; gc = wgoodword[j - 1];
} }
else else
#endif
{ {
bc = badword[i - 1]; bc = badword[i - 1];
gc = goodword[j - 1]; gc = goodword[j - 1];
@@ -8024,14 +7871,12 @@ spell_edit_score(
if (i > 1 && j > 1) if (i > 1 && j > 1)
{ {
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
pbc = wbadword[i - 2]; pbc = wbadword[i - 2];
pgc = wgoodword[j - 2]; pgc = wgoodword[j - 2];
} }
else else
#endif
{ {
pbc = badword[i - 2]; pbc = badword[i - 2];
pgc = goodword[j - 2]; pgc = goodword[j - 2];
@@ -8090,12 +7935,10 @@ spell_edit_score_limit(
int minscore; int minscore;
int round; int round;
#ifdef FEAT_MBYTE
/* Multi-byte characters require a bit more work, use a different function /* Multi-byte characters require a bit more work, use a different function
* to avoid testing "has_mbyte" quite often. */ * to avoid testing "has_mbyte" quite often. */
if (has_mbyte) if (has_mbyte)
return spell_edit_score_limit_w(slang, badword, goodword, limit); return spell_edit_score_limit_w(slang, badword, goodword, limit);
#endif
/* /*
* The idea is to go from start to end over the words. So long as * The idea is to go from start to end over the words. So long as
@@ -8250,7 +8093,6 @@ pop:
return minscore; return minscore;
} }
#ifdef FEAT_MBYTE
/* /*
* Multi-byte version of spell_edit_score_limit(). * Multi-byte version of spell_edit_score_limit().
* Keep it in sync with the above! * Keep it in sync with the above!
@@ -8439,7 +8281,6 @@ pop:
return SCORE_MAXMAX; return SCORE_MAXMAX;
return minscore; return minscore;
} }
#endif
/* /*
* ":spellinfo" * ":spellinfo"
@@ -8554,13 +8395,7 @@ spell_dump_compl(
n = captype(pat, NULL); n = captype(pat, NULL);
if (n == WF_ONECAP) if (n == WF_ONECAP)
dumpflags |= DUMPFLAG_ONECAP; dumpflags |= DUMPFLAG_ONECAP;
else if (n == WF_ALLCAP else if (n == WF_ALLCAP && (int)STRLEN(pat) > mb_ptr2len(pat))
#ifdef FEAT_MBYTE
&& (int)STRLEN(pat) > mb_ptr2len(pat)
#else
&& (int)STRLEN(pat) > 1
#endif
)
dumpflags |= DUMPFLAG_ALLCAP; dumpflags |= DUMPFLAG_ALLCAP;
} }
} }

View File

@@ -44,11 +44,7 @@ typedef int idx_T;
typedef long idx_T; typedef long idx_T;
#endif #endif
#ifdef FEAT_MBYTE
typedef int salfirst_T; typedef int salfirst_T;
#else
typedef short salfirst_T;
#endif
/* /*
* Structure used to store words and other info for one language, loaded from * Structure used to store words and other info for one language, loaded from
@@ -132,12 +128,8 @@ struct slang_S
load */ load */
int sl_has_map; /* TRUE if there is a MAP line */ int sl_has_map; /* TRUE if there is a MAP line */
#ifdef FEAT_MBYTE
hashtab_T sl_map_hash; /* MAP for multi-byte chars */ hashtab_T sl_map_hash; /* MAP for multi-byte chars */
int sl_map_array[256]; /* MAP for first 256 chars */ int sl_map_array[256]; /* MAP for first 256 chars */
#else
char_u sl_map_array[256]; /* MAP for first 256 chars */
#endif
hashtab_T sl_sounddone; /* table with soundfolded words that have hashtab_T sl_sounddone; /* table with soundfolded words that have
handled, see add_sound_suggest() */ handled, see add_sound_suggest() */
}; };
@@ -213,11 +205,9 @@ typedef struct salitem_S
char_u *sm_oneof; /* letters from () or NULL */ char_u *sm_oneof; /* letters from () or NULL */
char_u *sm_rules; /* rules like ^, $, priority */ char_u *sm_rules; /* rules like ^, $, priority */
char_u *sm_to; /* replacement. */ char_u *sm_to; /* replacement. */
#ifdef FEAT_MBYTE
int *sm_lead_w; /* wide character copy of "sm_lead" */ int *sm_lead_w; /* wide character copy of "sm_lead" */
int *sm_oneof_w; /* wide character copy of "sm_oneof" */ int *sm_oneof_w; /* wide character copy of "sm_oneof" */
int *sm_to_w; /* wide character copy of "sm_to" */ int *sm_to_w; /* wide character copy of "sm_to" */
#endif
} salitem_T; } salitem_T;
/* Values for SP_*ERROR are negative, positive values are used by /* Values for SP_*ERROR are negative, positive values are used by
@@ -260,41 +250,34 @@ typedef struct spelltab_S
* differ from what the .spl file uses. * differ from what the .spl file uses.
* These must not be called with negative number! * These must not be called with negative number!
*/ */
#ifndef FEAT_MBYTE #if defined(HAVE_WCHAR_H)
/* Non-multi-byte implementation. */
# define SPELL_TOFOLD(c) ((c) < 256 ? (int)spelltab.st_fold[c] : (c))
# define SPELL_TOUPPER(c) ((c) < 256 ? (int)spelltab.st_upper[c] : (c))
# define SPELL_ISUPPER(c) ((c) < 256 ? spelltab.st_isu[c] : FALSE)
#else
# if defined(HAVE_WCHAR_H)
# include <wchar.h> /* for towupper() and towlower() */ # include <wchar.h> /* for towupper() and towlower() */
# endif #endif
/* Multi-byte implementation. For Unicode we can call utf_*(), but don't do /* Multi-byte implementation. For Unicode we can call utf_*(), but don't do
* that for ASCII, because we don't want to use 'casemap' here. Otherwise use * that for ASCII, because we don't want to use 'casemap' here. Otherwise use
* the "w" library function for characters above 255 if available. */ * the "w" library function for characters above 255 if available. */
# ifdef HAVE_TOWLOWER #ifdef HAVE_TOWLOWER
# define SPELL_TOFOLD(c) (enc_utf8 && (c) >= 128 ? utf_fold(c) \ # define SPELL_TOFOLD(c) (enc_utf8 && (c) >= 128 ? utf_fold(c) \
: (c) < 256 ? (int)spelltab.st_fold[c] : (int)towlower(c)) : (c) < 256 ? (int)spelltab.st_fold[c] : (int)towlower(c))
# else #else
# define SPELL_TOFOLD(c) (enc_utf8 && (c) >= 128 ? utf_fold(c) \ # define SPELL_TOFOLD(c) (enc_utf8 && (c) >= 128 ? utf_fold(c) \
: (c) < 256 ? (int)spelltab.st_fold[c] : (c)) : (c) < 256 ? (int)spelltab.st_fold[c] : (c))
# endif #endif
# ifdef HAVE_TOWUPPER #ifdef HAVE_TOWUPPER
# define SPELL_TOUPPER(c) (enc_utf8 && (c) >= 128 ? utf_toupper(c) \ # define SPELL_TOUPPER(c) (enc_utf8 && (c) >= 128 ? utf_toupper(c) \
: (c) < 256 ? (int)spelltab.st_upper[c] : (int)towupper(c)) : (c) < 256 ? (int)spelltab.st_upper[c] : (int)towupper(c))
# else #else
# define SPELL_TOUPPER(c) (enc_utf8 && (c) >= 128 ? utf_toupper(c) \ # define SPELL_TOUPPER(c) (enc_utf8 && (c) >= 128 ? utf_toupper(c) \
: (c) < 256 ? (int)spelltab.st_upper[c] : (c)) : (c) < 256 ? (int)spelltab.st_upper[c] : (c))
# endif #endif
# ifdef HAVE_ISWUPPER #ifdef HAVE_ISWUPPER
# define SPELL_ISUPPER(c) (enc_utf8 && (c) >= 128 ? utf_isupper(c) \ # define SPELL_ISUPPER(c) (enc_utf8 && (c) >= 128 ? utf_isupper(c) \
: (c) < 256 ? spelltab.st_isu[c] : iswupper(c)) : (c) < 256 ? spelltab.st_isu[c] : iswupper(c))
# else #else
# define SPELL_ISUPPER(c) (enc_utf8 && (c) >= 128 ? utf_isupper(c) \ # define SPELL_ISUPPER(c) (enc_utf8 && (c) >= 128 ? utf_isupper(c) \
: (c) < 256 ? spelltab.st_isu[c] : (FALSE)) : (c) < 256 ? spelltab.st_isu[c] : (FALSE))
# endif
#endif #endif
#ifdef FEAT_SPELL #ifdef FEAT_SPELL

View File

@@ -306,9 +306,7 @@ static int read_sofo_section(FILE *fd, slang_T *slang);
static int read_compound(FILE *fd, slang_T *slang, int len); static int read_compound(FILE *fd, slang_T *slang, int len);
static int set_sofo(slang_T *lp, char_u *from, char_u *to); static int set_sofo(slang_T *lp, char_u *from, char_u *to);
static void set_sal_first(slang_T *lp); static void set_sal_first(slang_T *lp);
#ifdef FEAT_MBYTE
static int *mb_str2wide(char_u *s); static int *mb_str2wide(char_u *s);
#endif
static int spell_read_tree(FILE *fd, char_u **bytsp, idx_T **idxsp, int prefixtree, int prefixcnt); static int spell_read_tree(FILE *fd, char_u **bytsp, idx_T **idxsp, int prefixtree, int prefixcnt);
static idx_T read_tree_node(FILE *fd, char_u *byts, idx_T *idxs, int maxidx, idx_T startidx, int prefixtree, int maxprefcondnr); static idx_T read_tree_node(FILE *fd, char_u *byts, idx_T *idxs, int maxidx, idx_T startidx, int prefixtree, int maxprefcondnr);
static void set_spell_charflags(char_u *flags, int cnt, char_u *upp); static void set_spell_charflags(char_u *flags, int cnt, char_u *upp);
@@ -1062,7 +1060,6 @@ read_sal_section(FILE *fd, slang_T *slang)
return ccnt; return ccnt;
} }
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
/* convert the multi-byte strings to wide char strings */ /* convert the multi-byte strings to wide char strings */
@@ -1088,7 +1085,6 @@ read_sal_section(FILE *fd, slang_T *slang)
return SP_OTHERERROR; return SP_OTHERERROR;
} }
} }
#endif
} }
if (gap->ga_len > 0) if (gap->ga_len > 0)
@@ -1104,7 +1100,6 @@ read_sal_section(FILE *fd, slang_T *slang)
smp->sm_oneof = NULL; smp->sm_oneof = NULL;
smp->sm_rules = p; smp->sm_rules = p;
smp->sm_to = NULL; smp->sm_to = NULL;
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
smp->sm_lead_w = mb_str2wide(smp->sm_lead); smp->sm_lead_w = mb_str2wide(smp->sm_lead);
@@ -1112,7 +1107,6 @@ read_sal_section(FILE *fd, slang_T *slang)
smp->sm_oneof_w = NULL; smp->sm_oneof_w = NULL;
smp->sm_to_w = NULL; smp->sm_to_w = NULL;
} }
#endif
++gap->ga_len; ++gap->ga_len;
} }
@@ -1268,10 +1262,8 @@ read_compound(FILE *fd, slang_T *slang, int len)
* Inserting backslashes may double the length, "^\(\)$<Nul>" is 7 bytes. * Inserting backslashes may double the length, "^\(\)$<Nul>" is 7 bytes.
* Conversion to utf-8 may double the size. */ * Conversion to utf-8 may double the size. */
c = todo * 2 + 7; c = todo * 2 + 7;
#ifdef FEAT_MBYTE
if (enc_utf8) if (enc_utf8)
c += todo * 2; c += todo * 2;
#endif
pat = alloc((unsigned)c); pat = alloc((unsigned)c);
if (pat == NULL) if (pat == NULL)
return SP_OTHERERROR; return SP_OTHERERROR;
@@ -1367,11 +1359,9 @@ read_compound(FILE *fd, slang_T *slang, int len)
{ {
if (c == '?' || c == '+' || c == '~') if (c == '?' || c == '+' || c == '~')
*pp++ = '\\'; /* "a?" becomes "a\?", "a+" becomes "a\+" */ *pp++ = '\\'; /* "a?" becomes "a\?", "a+" becomes "a\+" */
#ifdef FEAT_MBYTE
if (enc_utf8) if (enc_utf8)
pp += mb_char2bytes(c, pp); pp += mb_char2bytes(c, pp);
else else
#endif
*pp++ = c; *pp++ = c;
} }
} }
@@ -1401,7 +1391,6 @@ set_sofo(slang_T *lp, char_u *from, char_u *to)
{ {
int i; int i;
#ifdef FEAT_MBYTE
garray_T *gap; garray_T *gap;
char_u *s; char_u *s;
char_u *p; char_u *p;
@@ -1468,7 +1457,6 @@ set_sofo(slang_T *lp, char_u *from, char_u *to)
} }
} }
else else
#endif
{ {
/* mapping bytes to bytes is done in sl_sal_first[] */ /* mapping bytes to bytes is done in sl_sal_first[] */
if (STRLEN(from) != STRLEN(to)) if (STRLEN(from) != STRLEN(to))
@@ -1500,19 +1488,16 @@ set_sal_first(slang_T *lp)
smp = (salitem_T *)gap->ga_data; smp = (salitem_T *)gap->ga_data;
for (i = 0; i < gap->ga_len; ++i) for (i = 0; i < gap->ga_len; ++i)
{ {
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
/* Use the lowest byte of the first character. For latin1 it's /* Use the lowest byte of the first character. For latin1 it's
* the character, for other encodings it should differ for most * the character, for other encodings it should differ for most
* characters. */ * characters. */
c = *smp[i].sm_lead_w & 0xff; c = *smp[i].sm_lead_w & 0xff;
else else
#endif
c = *smp[i].sm_lead; c = *smp[i].sm_lead;
if (sfirst[c] == -1) if (sfirst[c] == -1)
{ {
sfirst[c] = i; sfirst[c] = i;
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
int n; int n;
@@ -1540,12 +1525,10 @@ set_sal_first(slang_T *lp)
smp[i] = tsal; smp[i] = tsal;
} }
} }
#endif
} }
} }
} }
#ifdef FEAT_MBYTE
/* /*
* Turn a multi-byte string into a wide character string. * Turn a multi-byte string into a wide character string.
* Return it in allocated memory (NULL for out-of-memory) * Return it in allocated memory (NULL for out-of-memory)
@@ -1566,7 +1549,6 @@ mb_str2wide(char_u *s)
} }
return res; return res;
} }
#endif
/* /*
* Read a tree from the .spl or .sug file. * Read a tree from the .spl or .sug file.
@@ -1820,11 +1802,7 @@ struct affentry_S
char ae_comppermit; /* COMPOUNDPERMITFLAG found */ char ae_comppermit; /* COMPOUNDPERMITFLAG found */
}; };
#ifdef FEAT_MBYTE #define AH_KEY_LEN 17 /* 2 x 8 bytes + NUL */
# define AH_KEY_LEN 17 /* 2 x 8 bytes + NUL */
#else
# define AH_KEY_LEN 7 /* 6 digits + NUL */
#endif
/* Affix header from ".aff" file. Used for af_pref and af_suff. */ /* Affix header from ".aff" file. Used for af_pref and af_suff. */
typedef struct affheader_S typedef struct affheader_S
@@ -2271,7 +2249,6 @@ spell_read_aff(spellinfo_T *spin, char_u *fname)
/* Convert from "SET" to 'encoding' when needed. */ /* Convert from "SET" to 'encoding' when needed. */
vim_free(pc); vim_free(pc);
#ifdef FEAT_MBYTE
if (spin->si_conv.vc_type != CONV_NONE) if (spin->si_conv.vc_type != CONV_NONE)
{ {
pc = string_convert(&spin->si_conv, rline, NULL); pc = string_convert(&spin->si_conv, rline, NULL);
@@ -2284,7 +2261,6 @@ spell_read_aff(spellinfo_T *spin, char_u *fname)
line = pc; line = pc;
} }
else else
#endif
{ {
pc = NULL; pc = NULL;
line = rline; line = rline;
@@ -2319,7 +2295,6 @@ spell_read_aff(spellinfo_T *spin, char_u *fname)
{ {
if (is_aff_rule(items, itemcnt, "SET", 2) && aff->af_enc == NULL) if (is_aff_rule(items, itemcnt, "SET", 2) && aff->af_enc == NULL)
{ {
#ifdef FEAT_MBYTE
/* Setup for conversion from "ENC" to 'encoding'. */ /* Setup for conversion from "ENC" to 'encoding'. */
aff->af_enc = enc_canonize(items[1]); aff->af_enc = enc_canonize(items[1]);
if (aff->af_enc != NULL && !spin->si_ascii if (aff->af_enc != NULL && !spin->si_ascii
@@ -2328,9 +2303,6 @@ spell_read_aff(spellinfo_T *spin, char_u *fname)
smsg(_("Conversion in %s not supported: from %s to %s"), smsg(_("Conversion in %s not supported: from %s to %s"),
fname, aff->af_enc, p_enc); fname, aff->af_enc, p_enc);
spin->si_conv.vc_fail = TRUE; spin->si_conv.vc_fail = TRUE;
#else
smsg(_("Conversion in %s not supported"), fname);
#endif
} }
else if (is_aff_rule(items, itemcnt, "FLAG", 2) else if (is_aff_rule(items, itemcnt, "FLAG", 2)
&& aff->af_flagtype == AFT_CHAR) && aff->af_flagtype == AFT_CHAR)
@@ -2772,13 +2744,8 @@ spell_read_aff(spellinfo_T *spin, char_u *fname)
* be empty or start with the same letter. */ * be empty or start with the same letter. */
if (aff_entry->ae_chop != NULL if (aff_entry->ae_chop != NULL
&& aff_entry->ae_add != NULL && aff_entry->ae_add != NULL
#ifdef FEAT_MBYTE
&& aff_entry->ae_chop[(*mb_ptr2len)( && aff_entry->ae_chop[(*mb_ptr2len)(
aff_entry->ae_chop)] == NUL aff_entry->ae_chop)] == NUL)
#else
&& aff_entry->ae_chop[1] == NUL
#endif
)
{ {
int c, c_up; int c, c_up;
@@ -2803,7 +2770,7 @@ spell_read_aff(spellinfo_T *spin, char_u *fname)
if (aff_entry->ae_cond != NULL) if (aff_entry->ae_cond != NULL)
{ {
char_u buf[MAXLINELEN]; char_u buf[MAXLINELEN];
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
onecap_copy(items[4], buf, TRUE); onecap_copy(items[4], buf, TRUE);
@@ -2811,7 +2778,6 @@ spell_read_aff(spellinfo_T *spin, char_u *fname)
spin, buf); spin, buf);
} }
else else
#endif
*aff_entry->ae_cond = c_up; *aff_entry->ae_cond = c_up;
if (aff_entry->ae_cond != NULL) if (aff_entry->ae_cond != NULL)
{ {
@@ -2947,11 +2913,7 @@ spell_read_aff(spellinfo_T *spin, char_u *fname)
/* Check that every character appears only once. */ /* Check that every character appears only once. */
for (p = items[1]; *p != NUL; ) for (p = items[1]; *p != NUL; )
{ {
#ifdef FEAT_MBYTE
c = mb_ptr2char_adv(&p); c = mb_ptr2char_adv(&p);
#else
c = *p++;
#endif
if ((spin->si_map.ga_len > 0 if ((spin->si_map.ga_len > 0
&& vim_strchr(spin->si_map.ga_data, c) && vim_strchr(spin->si_map.ga_data, c)
!= NULL) != NULL)
@@ -3034,11 +2996,7 @@ spell_read_aff(spellinfo_T *spin, char_u *fname)
* Don't write one for utf-8 either, we use utf_*() and * Don't write one for utf-8 either, we use utf_*() and
* mb_get_class(), the list of chars in the file will be incomplete. * mb_get_class(), the list of chars in the file will be incomplete.
*/ */
if (!spin->si_ascii if (!spin->si_ascii && !enc_utf8)
#ifdef FEAT_MBYTE
&& !enc_utf8
#endif
)
{ {
if (fol == NULL || low == NULL || upp == NULL) if (fol == NULL || low == NULL || upp == NULL)
smsg(_("Missing FOL/LOW/UPP line in %s"), fname); smsg(_("Missing FOL/LOW/UPP line in %s"), fname);
@@ -3243,21 +3201,13 @@ get_affitem(int flagtype, char_u **pp)
} }
else else
{ {
#ifdef FEAT_MBYTE
res = mb_ptr2char_adv(pp); res = mb_ptr2char_adv(pp);
#else
res = *(*pp)++;
#endif
if (flagtype == AFT_LONG || (flagtype == AFT_CAPLONG if (flagtype == AFT_LONG || (flagtype == AFT_CAPLONG
&& res >= 'A' && res <= 'Z')) && res >= 'A' && res <= 'Z'))
{ {
if (**pp == NUL) if (**pp == NUL)
return 0; return 0;
#ifdef FEAT_MBYTE
res = mb_ptr2char_adv(pp) + (res << 16); res = mb_ptr2char_adv(pp) + (res << 16);
#else
res = *(*pp)++ + (res << 16);
#endif
} }
} }
return res; return res;
@@ -3381,18 +3331,10 @@ flag_in_afflist(int flagtype, char_u *afflist, unsigned flag)
case AFT_LONG: case AFT_LONG:
for (p = afflist; *p != NUL; ) for (p = afflist; *p != NUL; )
{ {
#ifdef FEAT_MBYTE
n = mb_ptr2char_adv(&p); n = mb_ptr2char_adv(&p);
#else
n = *p++;
#endif
if ((flagtype == AFT_LONG || (n >= 'A' && n <= 'Z')) if ((flagtype == AFT_LONG || (n >= 'A' && n <= 'Z'))
&& *p != NUL) && *p != NUL)
#ifdef FEAT_MBYTE
n = mb_ptr2char_adv(&p) + (n << 16); n = mb_ptr2char_adv(&p) + (n << 16);
#else
n = *p++ + (n << 16);
#endif
if (n == flag) if (n == flag)
return TRUE; return TRUE;
} }
@@ -3589,7 +3531,6 @@ spell_read_dic(spellinfo_T *spin, char_u *fname, afffile_T *affile)
continue; /* empty line */ continue; /* empty line */
line[l] = NUL; line[l] = NUL;
#ifdef FEAT_MBYTE
/* Convert from "SET" to 'encoding' when needed. */ /* Convert from "SET" to 'encoding' when needed. */
if (spin->si_conv.vc_type != CONV_NONE) if (spin->si_conv.vc_type != CONV_NONE)
{ {
@@ -3603,7 +3544,6 @@ spell_read_dic(spellinfo_T *spin, char_u *fname, afffile_T *affile)
w = pc; w = pc;
} }
else else
#endif
{ {
pc = NULL; pc = NULL;
w = line; w = line;
@@ -3930,7 +3870,6 @@ store_aff_word(
if (ae->ae_chop != NULL) if (ae->ae_chop != NULL)
{ {
/* Skip chop string. */ /* Skip chop string. */
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
i = mb_charlen(ae->ae_chop); i = mb_charlen(ae->ae_chop);
@@ -3938,7 +3877,6 @@ store_aff_word(
MB_PTR_ADV(p); MB_PTR_ADV(p);
} }
else else
#endif
p += STRLEN(ae->ae_chop); p += STRLEN(ae->ae_chop);
} }
STRCAT(newword, p); STRCAT(newword, p);
@@ -4162,7 +4100,6 @@ spell_read_wordfile(spellinfo_T *spin, char_u *fname)
/* Convert from "/encoding={encoding}" to 'encoding' when needed. */ /* Convert from "/encoding={encoding}" to 'encoding' when needed. */
vim_free(pc); vim_free(pc);
#ifdef FEAT_MBYTE
if (spin->si_conv.vc_type != CONV_NONE) if (spin->si_conv.vc_type != CONV_NONE)
{ {
pc = string_convert(&spin->si_conv, rline, NULL); pc = string_convert(&spin->si_conv, rline, NULL);
@@ -4175,7 +4112,6 @@ spell_read_wordfile(spellinfo_T *spin, char_u *fname)
line = pc; line = pc;
} }
else else
#endif
{ {
pc = NULL; pc = NULL;
line = rline; line = rline;
@@ -4194,7 +4130,6 @@ spell_read_wordfile(spellinfo_T *spin, char_u *fname)
fname, lnum, line - 1); fname, lnum, line - 1);
else else
{ {
#ifdef FEAT_MBYTE
char_u *enc; char_u *enc;
/* Setup for conversion to 'encoding'. */ /* Setup for conversion to 'encoding'. */
@@ -4207,9 +4142,6 @@ spell_read_wordfile(spellinfo_T *spin, char_u *fname)
fname, line, p_enc); fname, line, p_enc);
vim_free(enc); vim_free(enc);
spin->si_conv.vc_fail = TRUE; spin->si_conv.vc_fail = TRUE;
#else
smsg(_("Conversion in %s not supported"), fname);
#endif
} }
continue; continue;
} }
@@ -4981,11 +4913,9 @@ write_vim_spell(spellinfo_T *spin, char_u *fname)
l = 0; l = 0;
for (i = 128; i < 256; ++i) for (i = 128; i < 256; ++i)
{ {
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
l += mb_char2bytes(spelltab.st_fold[i], folchars + l); l += mb_char2bytes(spelltab.st_fold[i], folchars + l);
else else
#endif
folchars[l++] = spelltab.st_fold[i]; folchars[l++] = spelltab.st_fold[i];
} }
put_bytes(fd, (long_u)(1 + 128 + 2 + l), 4); /* <sectionlen> */ put_bytes(fd, (long_u)(1 + 128 + 2 + l), 4); /* <sectionlen> */
@@ -6112,10 +6042,8 @@ mkspell(
error = TRUE; error = TRUE;
} }
#ifdef FEAT_MBYTE
/* Free any conversion stuff. */ /* Free any conversion stuff. */
convert_setup(&spin.si_conv, NULL, NULL); convert_setup(&spin.si_conv, NULL, NULL);
#endif
} }
if (spin.si_compflags != NULL && spin.si_nobreak) if (spin.si_compflags != NULL && spin.si_nobreak)
@@ -6488,15 +6416,10 @@ set_spell_chartab(char_u *fol, char_u *low, char_u *upp)
emsg(_(e_affform)); emsg(_(e_affform));
return FAIL; return FAIL;
} }
#ifdef FEAT_MBYTE
f = mb_ptr2char_adv(&pf); f = mb_ptr2char_adv(&pf);
l = mb_ptr2char_adv(&pl); l = mb_ptr2char_adv(&pl);
u = mb_ptr2char_adv(&pu); u = mb_ptr2char_adv(&pu);
#else
f = *pf++;
l = *pl++;
u = *pu++;
#endif
/* Every character that appears is a word character. */ /* Every character that appears is a word character. */
if (f < 256) if (f < 256)
new_st.st_isw[f] = TRUE; new_st.st_isw[f] = TRUE;
@@ -6570,11 +6493,7 @@ set_spell_charflags(
if (*p != NUL) if (*p != NUL)
{ {
#ifdef FEAT_MBYTE
c = mb_ptr2char_adv(&p); c = mb_ptr2char_adv(&p);
#else
c = *p++;
#endif
new_st.st_fold[i + 128] = c; new_st.st_fold[i + 128] = c;
if (i + 128 != c && new_st.st_isu[i + 128] && c < 256) if (i + 128 != c && new_st.st_isu[i + 128] && c < 256)
new_st.st_upper[c] = i + 128; new_st.st_upper[c] = i + 128;
@@ -6675,9 +6594,7 @@ set_map_str(slang_T *lp, char_u *map)
/* Init the array and hash tables empty. */ /* Init the array and hash tables empty. */
for (i = 0; i < 256; ++i) for (i = 0; i < 256; ++i)
lp->sl_map_array[i] = 0; lp->sl_map_array[i] = 0;
#ifdef FEAT_MBYTE
hash_init(&lp->sl_map_hash); hash_init(&lp->sl_map_hash);
#endif
/* /*
* The similar characters are stored separated with slashes: * The similar characters are stored separated with slashes:
@@ -6686,11 +6603,7 @@ set_map_str(slang_T *lp, char_u *map)
*/ */
for (p = map; *p != NUL; ) for (p = map; *p != NUL; )
{ {
#ifdef FEAT_MBYTE
c = mb_cptr2char_adv(&p); c = mb_cptr2char_adv(&p);
#else
c = *p++;
#endif
if (c == '/') if (c == '/')
headc = 0; headc = 0;
else else
@@ -6698,7 +6611,6 @@ set_map_str(slang_T *lp, char_u *map)
if (headc == 0) if (headc == 0)
headc = c; headc = c;
#ifdef FEAT_MBYTE
/* Characters above 255 don't fit in sl_map_array[], put them in /* Characters above 255 don't fit in sl_map_array[], put them in
* the hash table. Each entry is the char, a NUL the headchar and * the hash table. Each entry is the char, a NUL the headchar and
* a NUL. */ * a NUL. */
@@ -6730,7 +6642,6 @@ set_map_str(slang_T *lp, char_u *map)
} }
} }
else else
#endif
lp->sl_map_array[c] = headc; lp->sl_map_array[c] = headc;
} }
} }

View File

@@ -1103,9 +1103,7 @@ typedef struct
{ {
char_u *vir_line; /* text of the current line */ char_u *vir_line; /* text of the current line */
FILE *vir_fd; /* file descriptor */ FILE *vir_fd; /* file descriptor */
#ifdef FEAT_MBYTE
vimconv_T vir_conv; /* encoding conversion */ vimconv_T vir_conv; /* encoding conversion */
#endif
int vir_version; /* viminfo version detected or -1 */ int vir_version; /* viminfo version detected or -1 */
garray_T vir_barlines; /* lines starting with | */ garray_T vir_barlines; /* lines starting with | */
} vir_T; } vir_T;
@@ -2013,16 +2011,12 @@ typedef struct {
/* for spell checking */ /* for spell checking */
garray_T b_langp; /* list of pointers to slang_T, see spell.c */ garray_T b_langp; /* list of pointers to slang_T, see spell.c */
char_u b_spell_ismw[256];/* flags: is midword char */ char_u b_spell_ismw[256];/* flags: is midword char */
# ifdef FEAT_MBYTE
char_u *b_spell_ismw_mb; /* multi-byte midword chars */ char_u *b_spell_ismw_mb; /* multi-byte midword chars */
# endif
char_u *b_p_spc; /* 'spellcapcheck' */ char_u *b_p_spc; /* 'spellcapcheck' */
regprog_T *b_cap_prog; /* program for 'spellcapcheck' */ regprog_T *b_cap_prog; /* program for 'spellcapcheck' */
char_u *b_p_spf; /* 'spellfile' */ char_u *b_p_spf; /* 'spellfile' */
char_u *b_p_spl; /* 'spelllang' */ char_u *b_p_spl; /* 'spelllang' */
# ifdef FEAT_MBYTE
int b_cjk; /* all CJK letters as OK */ int b_cjk; /* all CJK letters as OK */
# endif
#endif #endif
#if !defined(FEAT_SYN_HL) && !defined(FEAT_SPELL) #if !defined(FEAT_SYN_HL) && !defined(FEAT_SPELL)
int dummy; int dummy;
@@ -2233,9 +2227,7 @@ struct file_buffer
unsigned b_bkc_flags; /* flags for 'backupcopy' */ unsigned b_bkc_flags; /* flags for 'backupcopy' */
int b_p_ci; /* 'copyindent' */ int b_p_ci; /* 'copyindent' */
int b_p_bin; /* 'binary' */ int b_p_bin; /* 'binary' */
#ifdef FEAT_MBYTE
int b_p_bomb; /* 'bomb' */ int b_p_bomb; /* 'bomb' */
#endif
char_u *b_p_bh; /* 'bufhidden' */ char_u *b_p_bh; /* 'bufhidden' */
char_u *b_p_bt; /* 'buftype' */ char_u *b_p_bt; /* 'buftype' */
#ifdef FEAT_QUICKFIX #ifdef FEAT_QUICKFIX
@@ -2270,9 +2262,7 @@ struct file_buffer
int b_p_et; /* 'expandtab' */ int b_p_et; /* 'expandtab' */
int b_p_et_nobin; /* b_p_et saved for binary mode */ int b_p_et_nobin; /* b_p_et saved for binary mode */
int b_p_et_nopaste; /* b_p_et saved for paste mode */ int b_p_et_nopaste; /* b_p_et saved for paste mode */
#ifdef FEAT_MBYTE
char_u *b_p_fenc; /* 'fileencoding' */ char_u *b_p_fenc; /* 'fileencoding' */
#endif
char_u *b_p_ff; /* 'fileformat' */ char_u *b_p_ff; /* 'fileformat' */
char_u *b_p_ft; /* 'filetype' */ char_u *b_p_ft; /* 'filetype' */
char_u *b_p_fo; /* 'formatoptions' */ char_u *b_p_fo; /* 'formatoptions' */
@@ -2304,9 +2294,7 @@ struct file_buffer
#ifdef FEAT_LISP #ifdef FEAT_LISP
int b_p_lisp; /* 'lisp' */ int b_p_lisp; /* 'lisp' */
#endif #endif
#ifdef FEAT_MBYTE
char_u *b_p_menc; /* 'makeencoding' */ char_u *b_p_menc; /* 'makeencoding' */
#endif
char_u *b_p_mps; /* 'matchpairs' */ char_u *b_p_mps; /* 'matchpairs' */
int b_p_ml; /* 'modeline' */ int b_p_ml; /* 'modeline' */
int b_p_ml_nobin; /* b_p_ml saved for binary mode */ int b_p_ml_nobin; /* b_p_ml saved for binary mode */
@@ -2425,11 +2413,9 @@ struct file_buffer
int b_start_eol; /* last line had eol when it was read */ int b_start_eol; /* last line had eol when it was read */
int b_start_ffc; /* first char of 'ff' when edit started */ int b_start_ffc; /* first char of 'ff' when edit started */
#ifdef FEAT_MBYTE
char_u *b_start_fenc; /* 'fileencoding' when edit started or NULL */ char_u *b_start_fenc; /* 'fileencoding' when edit started or NULL */
int b_bad_char; /* "++bad=" argument when edit started or 0 */ int b_bad_char; /* "++bad=" argument when edit started or 0 */
int b_start_bomb; /* 'bomb' when it was read */ int b_start_bomb; /* 'bomb' when it was read */
#endif
#ifdef FEAT_EVAL #ifdef FEAT_EVAL
dictitem_T b_bufvar; /* variable for "b:" Dictionary */ dictitem_T b_bufvar; /* variable for "b:" Dictionary */
@@ -3107,10 +3093,8 @@ typedef struct cmdarg_S
int prechar; /* prefix character (optional, always 'g') */ int prechar; /* prefix character (optional, always 'g') */
int cmdchar; /* command character */ int cmdchar; /* command character */
int nchar; /* next command character (optional) */ int nchar; /* next command character (optional) */
#ifdef FEAT_MBYTE
int ncharC1; /* first composing character (optional) */ int ncharC1; /* first composing character (optional) */
int ncharC2; /* second composing character (optional) */ int ncharC2; /* second composing character (optional) */
#endif
int extra_char; /* yet another character (optional) */ int extra_char; /* yet another character (optional) */
long opcount; /* count before an operator */ long opcount; /* count before an operator */
long count0; /* count before command, default 0 */ long count0; /* count before command, default 0 */

View File

@@ -1974,12 +1974,9 @@ syn_current_attr(
if (vim_iswordp_buf(line + current_col, syn_buf) if (vim_iswordp_buf(line + current_col, syn_buf)
&& (current_col == 0 && (current_col == 0
|| !vim_iswordp_buf(line + current_col - 1 || !vim_iswordp_buf(line + current_col - 1
#ifdef FEAT_MBYTE
- (has_mbyte - (has_mbyte
? (*mb_head_off)(line, line + current_col - 1) ? (*mb_head_off)(line, line + current_col - 1)
: 0) : 0) , syn_buf)))
#endif
, syn_buf)))
{ {
syn_id = check_keyword_id(line, (int)current_col, syn_id = check_keyword_id(line, (int)current_col,
&endcol, &flags, &next_list, cur_si, &endcol, &flags, &next_list, cur_si,
@@ -3355,11 +3352,9 @@ check_keyword_id(
kwlen = 0; kwlen = 0;
do do
{ {
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
kwlen += (*mb_ptr2len)(kwp + kwlen); kwlen += (*mb_ptr2len)(kwp + kwlen);
else else
#endif
++kwlen; ++kwlen;
} }
while (vim_iswordp_buf(kwp + kwlen, syn_buf)); while (vim_iswordp_buf(kwp + kwlen, syn_buf));
@@ -4668,17 +4663,15 @@ get_syn_options(
} }
else if (flagtab[fidx].argtype == 11 && arg[5] == '=') else if (flagtab[fidx].argtype == 11 && arg[5] == '=')
{ {
#ifdef FEAT_MBYTE
/* cchar=? */ /* cchar=? */
if (has_mbyte) if (has_mbyte)
{ {
# ifdef FEAT_CONCEAL #ifdef FEAT_CONCEAL
*conceal_char = mb_ptr2char(arg + 6); *conceal_char = mb_ptr2char(arg + 6);
# endif #endif
arg += mb_ptr2len(arg + 6) - 1; arg += mb_ptr2len(arg + 6) - 1;
} }
else else
#endif
{ {
#ifdef FEAT_CONCEAL #ifdef FEAT_CONCEAL
*conceal_char = arg[6]; *conceal_char = arg[6];
@@ -4948,7 +4941,6 @@ syn_cmd_keyword(exarg_T *eap, int syncing UNUSED)
kw = p + 1; /* skip over the "]" */ kw = p + 1; /* skip over the "]" */
break; break;
} }
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
int l = (*mb_ptr2len)(p + 1); int l = (*mb_ptr2len)(p + 1);
@@ -4957,7 +4949,6 @@ syn_cmd_keyword(exarg_T *eap, int syncing UNUSED)
p += l; p += l;
} }
else else
#endif
{ {
p[0] = p[1]; p[0] = p[1];
++p; ++p;

View File

@@ -1349,9 +1349,7 @@ find_tags(
#endif #endif
pat_T orgpat; /* holds unconverted pattern info */ pat_T orgpat; /* holds unconverted pattern info */
#ifdef FEAT_MBYTE
vimconv_T vimconv; vimconv_T vimconv;
#endif
#ifdef FEAT_TAG_BINS #ifdef FEAT_TAG_BINS
int findall = (mincount == MAXCOL || mincount == TAG_MANY); int findall = (mincount == MAXCOL || mincount == TAG_MANY);
@@ -1387,9 +1385,7 @@ find_tags(
help_save = curbuf->b_help; help_save = curbuf->b_help;
orgpat.pat = pat; orgpat.pat = pat;
#ifdef FEAT_MBYTE
vimconv.vc_type = CONV_NONE; vimconv.vc_type = CONV_NONE;
#endif
/* /*
* Allocate memory for the buffers that are used * Allocate memory for the buffers that are used
@@ -1725,7 +1721,6 @@ find_tags(
} }
line_read_in: line_read_in:
#ifdef FEAT_MBYTE
if (vimconv.vc_type != CONV_NONE) if (vimconv.vc_type != CONV_NONE)
{ {
char_u *conv_line; char_u *conv_line;
@@ -1752,7 +1747,6 @@ line_read_in:
} }
} }
} }
#endif
#ifdef FEAT_EMACS_TAGS #ifdef FEAT_EMACS_TAGS
@@ -1846,7 +1840,6 @@ line_read_in:
if (STRNCMP(lbuf, "!_TAG_FILE_SORTED\t", 18) == 0) if (STRNCMP(lbuf, "!_TAG_FILE_SORTED\t", 18) == 0)
tag_file_sorted = lbuf[18]; tag_file_sorted = lbuf[18];
#endif #endif
#ifdef FEAT_MBYTE
if (STRNCMP(lbuf, "!_TAG_FILE_ENCODING\t", 20) == 0) if (STRNCMP(lbuf, "!_TAG_FILE_ENCODING\t", 20) == 0)
{ {
/* Prepare to convert every line from the specified /* Prepare to convert every line from the specified
@@ -1856,7 +1849,6 @@ line_read_in:
*p = NUL; *p = NUL;
convert_setup(&vimconv, lbuf + 20, p_enc); convert_setup(&vimconv, lbuf + 20, p_enc);
} }
#endif
/* Read the next line. Unrecognized flags are ignored. */ /* Read the next line. Unrecognized flags are ignored. */
continue; continue;
@@ -2472,10 +2464,8 @@ parse_line:
vim_free(incstack[incstack_idx].etag_fname); vim_free(incstack[incstack_idx].etag_fname);
} }
#endif #endif
#ifdef FEAT_MBYTE
if (vimconv.vc_type != CONV_NONE) if (vimconv.vc_type != CONV_NONE)
convert_setup(&vimconv, NULL, NULL); convert_setup(&vimconv, NULL, NULL);
#endif
#ifdef FEAT_TAG_BINS #ifdef FEAT_TAG_BINS
tag_file_sorted = NUL; tag_file_sorted = NUL;

View File

@@ -2585,7 +2585,6 @@ out_flush_cursor(
} }
#if defined(FEAT_MBYTE) || defined(PROTO)
/* /*
* Sometimes a byte out of a multi-byte character is written with out_char(). * Sometimes a byte out of a multi-byte character is written with out_char().
* To avoid flushing half of the character, call this function first. * To avoid flushing half of the character, call this function first.
@@ -2596,7 +2595,6 @@ out_flush_check(void)
if (enc_dbcs != 0 && out_pos >= OUT_SIZE - MB_MAXBYTES) if (enc_dbcs != 0 && out_pos >= OUT_SIZE - MB_MAXBYTES)
out_flush(); out_flush();
} }
#endif
#ifdef FEAT_GUI #ifdef FEAT_GUI
/* /*
@@ -3620,7 +3618,6 @@ may_req_termresponse(void)
} }
} }
# if defined(FEAT_MBYTE) || defined(PROTO)
/* /*
* Check how the terminal treats ambiguous character width (UAX #11). * Check how the terminal treats ambiguous character width (UAX #11).
* First, we move the cursor to (1, 0) and print a test ambiguous character * First, we move the cursor to (1, 0) and print a test ambiguous character
@@ -3666,7 +3663,6 @@ may_req_ambiguous_char_width(void)
(void)vpeekc_nomap(); (void)vpeekc_nomap();
} }
} }
# endif
/* /*
* Similar to requesting the version string: Request the terminal background * Similar to requesting the version string: Request the terminal background
@@ -4606,9 +4602,7 @@ check_termcode(
{ {
int col = 0; int col = 0;
int semicols = 0; int semicols = 0;
#ifdef FEAT_MBYTE
int row_char = NUL; int row_char = NUL;
#endif
extra = 0; extra = 0;
for (i = 2 + (tp[0] != CSI); i < len for (i = 2 + (tp[0] != CSI); i < len
@@ -4617,9 +4611,7 @@ check_termcode(
if (tp[i] == ';' && ++semicols == 1) if (tp[i] == ';' && ++semicols == 1)
{ {
extra = i + 1; extra = i + 1;
#ifdef FEAT_MBYTE
row_char = tp[i - 1]; row_char = tp[i - 1];
#endif
} }
if (i == len) if (i == len)
{ {
@@ -4629,7 +4621,6 @@ check_termcode(
if (extra > 0) if (extra > 0)
col = atoi((char *)tp + extra); col = atoi((char *)tp + extra);
#ifdef FEAT_MBYTE
/* Eat it when it has 2 arguments and ends in 'R'. Also when /* Eat it when it has 2 arguments and ends in 'R'. Also when
* u7_status is not "sent", it may be from a previous Vim that * u7_status is not "sent", it may be from a previous Vim that
* just exited. But not for <S-F3>, it sends something * just exited. But not for <S-F3>, it sends something
@@ -4672,10 +4663,9 @@ check_termcode(
set_vim_var_string(VV_TERMU7RESP, tp, slen); set_vim_var_string(VV_TERMU7RESP, tp, slen);
# endif # endif
} }
else
#endif
/* eat it when at least one digit and ending in 'c' */ /* eat it when at least one digit and ending in 'c' */
if (*T_CRV != NUL && i > 2 + (tp[0] != CSI) && tp[i] == 'c') else if (*T_CRV != NUL && i > 2 + (tp[0] != CSI)
&& tp[i] == 'c')
{ {
int version = col; int version = col;
@@ -5973,11 +5963,9 @@ check_termcode(
if (key_name[0] == KS_KEY) if (key_name[0] == KS_KEY)
{ {
/* from ":set <M-b>=xx" */ /* from ":set <M-b>=xx" */
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
new_slen += (*mb_char2bytes)(key_name[1], string + new_slen); new_slen += (*mb_char2bytes)(key_name[1], string + new_slen);
else else
#endif
string[new_slen++] = key_name[1]; string[new_slen++] = key_name[1];
} }
else if (new_slen == 0 && key_name[0] == KS_EXTRA else if (new_slen == 0 && key_name[0] == KS_EXTRA
@@ -6257,10 +6245,8 @@ replace_termcodes(
} }
} }
#ifdef FEAT_MBYTE
/* skip multibyte char correctly */ /* skip multibyte char correctly */
for (i = (*mb_ptr2len)(src); i > 0; --i) for (i = (*mb_ptr2len)(src); i > 0; --i)
#endif
{ {
/* /*
* If the character is K_SPECIAL, replace it with K_SPECIAL * If the character is K_SPECIAL, replace it with K_SPECIAL

114
src/ui.c
View File

@@ -40,7 +40,7 @@ ui_write(char_u *s, int len)
/* Don't output anything in silent mode ("ex -s") unless 'verbose' set */ /* Don't output anything in silent mode ("ex -s") unless 'verbose' set */
if (!(silent_mode && p_verbose == 0)) if (!(silent_mode && p_verbose == 0))
{ {
#if defined(FEAT_MBYTE) && !defined(WIN3264) #if !defined(WIN3264)
char_u *tofree = NULL; char_u *tofree = NULL;
if (output_conv.vc_type != CONV_NONE) if (output_conv.vc_type != CONV_NONE)
@@ -54,10 +54,10 @@ ui_write(char_u *s, int len)
mch_write(s, len); mch_write(s, len);
#if defined(FEAT_MBYTE) && !defined(WIN3264) # if !defined(WIN3264)
if (output_conv.vc_type != CONV_NONE) if (output_conv.vc_type != CONV_NONE)
vim_free(tofree); vim_free(tofree);
#endif # endif
} }
#endif #endif
} }
@@ -516,10 +516,8 @@ clip_update_selection(VimClipboard *clip)
{ {
start = VIsual; start = VIsual;
end = curwin->w_cursor; end = curwin->w_cursor;
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
end.col += (*mb_ptr2len)(ml_get_cursor()) - 1; end.col += (*mb_ptr2len)(ml_get_cursor()) - 1;
#endif
} }
else else
{ {
@@ -821,9 +819,7 @@ clip_start_selection(int col, int row, int repeated_click)
row = check_row(row); row = check_row(row);
col = check_col(col); col = check_col(col);
#ifdef FEAT_MBYTE
col = mb_fix_col(col, row); col = mb_fix_col(col, row);
#endif
cb->start.lnum = row; cb->start.lnum = row;
cb->start.col = col; cb->start.col = col;
@@ -927,9 +923,7 @@ clip_process_selection(
row = check_row(row); row = check_row(row);
col = check_col(col); col = check_col(col);
#ifdef FEAT_MBYTE
col = mb_fix_col(col, row); col = mb_fix_col(col, row);
#endif
if (col == (int)cb->prev.col && row == cb->prev.lnum && !repeated_click) if (col == (int)cb->prev.col && row == cb->prev.lnum && !repeated_click)
return; return;
@@ -995,21 +989,17 @@ clip_process_selection(
cb->origin_start_col, row, (int)Columns); cb->origin_start_col, row, (int)Columns);
else else
{ {
#ifdef FEAT_MBYTE
if (has_mbyte && mb_lefthalve(row, col)) if (has_mbyte && mb_lefthalve(row, col))
slen = 2; slen = 2;
#endif
clip_update_modeless_selection(cb, cb->origin_row, clip_update_modeless_selection(cb, cb->origin_row,
cb->origin_start_col, row, col + slen); cb->origin_start_col, row, col + slen);
} }
} }
else else
{ {
#ifdef FEAT_MBYTE
if (has_mbyte if (has_mbyte
&& mb_lefthalve(cb->origin_row, cb->origin_start_col)) && mb_lefthalve(cb->origin_row, cb->origin_start_col))
slen = 2; slen = 2;
#endif
if (col >= (int)cb->word_end_col) if (col >= (int)cb->word_end_col)
clip_update_modeless_selection(cb, row, cb->word_end_col, clip_update_modeless_selection(cb, row, cb->word_end_col,
cb->origin_row, cb->origin_start_col + slen); cb->origin_row, cb->origin_start_col + slen);
@@ -1243,9 +1233,7 @@ clip_copy_modeless_selection(int both UNUSED)
int line_end_col; int line_end_col;
int add_newline_flag = FALSE; int add_newline_flag = FALSE;
int len; int len;
#ifdef FEAT_MBYTE
char_u *p; char_u *p;
#endif
int row1 = clip_star.start.lnum; int row1 = clip_star.start.lnum;
int col1 = clip_star.start.col; int col1 = clip_star.start.col;
int row2 = clip_star.end.lnum; int row2 = clip_star.end.lnum;
@@ -1267,23 +1255,19 @@ clip_copy_modeless_selection(int both UNUSED)
{ {
row = col1; col1 = col2; col2 = row; row = col1; col1 = col2; col2 = row;
} }
#ifdef FEAT_MBYTE
/* correct starting point for being on right halve of double-wide char */ /* correct starting point for being on right halve of double-wide char */
p = ScreenLines + LineOffset[row1]; p = ScreenLines + LineOffset[row1];
if (enc_dbcs != 0) if (enc_dbcs != 0)
col1 -= (*mb_head_off)(p, p + col1); col1 -= (*mb_head_off)(p, p + col1);
else if (enc_utf8 && p[col1] == 0) else if (enc_utf8 && p[col1] == 0)
--col1; --col1;
#endif
/* Create a temporary buffer for storing the text */ /* Create a temporary buffer for storing the text */
len = (row2 - row1 + 1) * Columns + 1; len = (row2 - row1 + 1) * Columns + 1;
#ifdef FEAT_MBYTE
if (enc_dbcs != 0) if (enc_dbcs != 0)
len *= 2; /* max. 2 bytes per display cell */ len *= 2; /* max. 2 bytes per display cell */
else if (enc_utf8) else if (enc_utf8)
len *= MB_MAXBYTES; len *= MB_MAXBYTES;
#endif
buffer = lalloc((long_u)len, TRUE); buffer = lalloc((long_u)len, TRUE);
if (buffer == NULL) /* out of memory */ if (buffer == NULL) /* out of memory */
return; return;
@@ -1322,7 +1306,6 @@ clip_copy_modeless_selection(int both UNUSED)
if (row < screen_Rows && end_col <= screen_Columns) if (row < screen_Rows && end_col <= screen_Columns)
{ {
#ifdef FEAT_MBYTE
if (enc_dbcs != 0) if (enc_dbcs != 0)
{ {
int i; int i;
@@ -1373,7 +1356,6 @@ clip_copy_modeless_selection(int both UNUSED)
} }
} }
else else
#endif
{ {
STRNCPY(bufp, ScreenLines + LineOffset[row] + start_col, STRNCPY(bufp, ScreenLines + LineOffset[row] + start_col,
end_col - start_col); end_col - start_col);
@@ -1421,51 +1403,35 @@ clip_get_word_boundaries(VimClipboard *cb, int row, int col)
int start_class; int start_class;
int temp_col; int temp_col;
char_u *p; char_u *p;
#ifdef FEAT_MBYTE
int mboff; int mboff;
#endif
if (row >= screen_Rows || col >= screen_Columns || ScreenLines == NULL) if (row >= screen_Rows || col >= screen_Columns || ScreenLines == NULL)
return; return;
p = ScreenLines + LineOffset[row]; p = ScreenLines + LineOffset[row];
#ifdef FEAT_MBYTE
/* Correct for starting in the right halve of a double-wide char */ /* Correct for starting in the right halve of a double-wide char */
if (enc_dbcs != 0) if (enc_dbcs != 0)
col -= dbcs_screen_head_off(p, p + col); col -= dbcs_screen_head_off(p, p + col);
else if (enc_utf8 && p[col] == 0) else if (enc_utf8 && p[col] == 0)
--col; --col;
#endif
start_class = CHAR_CLASS(p[col]); start_class = CHAR_CLASS(p[col]);
temp_col = col; temp_col = col;
for ( ; temp_col > 0; temp_col--) for ( ; temp_col > 0; temp_col--)
#ifdef FEAT_MBYTE
if (enc_dbcs != 0 if (enc_dbcs != 0
&& (mboff = dbcs_screen_head_off(p, p + temp_col - 1)) > 0) && (mboff = dbcs_screen_head_off(p, p + temp_col - 1)) > 0)
temp_col -= mboff; temp_col -= mboff;
else else if (CHAR_CLASS(p[temp_col - 1]) != start_class
#endif && !(enc_utf8 && p[temp_col - 1] == 0))
if (CHAR_CLASS(p[temp_col - 1]) != start_class
#ifdef FEAT_MBYTE
&& !(enc_utf8 && p[temp_col - 1] == 0)
#endif
)
break; break;
cb->word_start_col = temp_col; cb->word_start_col = temp_col;
temp_col = col; temp_col = col;
for ( ; temp_col < screen_Columns; temp_col++) for ( ; temp_col < screen_Columns; temp_col++)
#ifdef FEAT_MBYTE
if (enc_dbcs != 0 && dbcs_ptr2cells(p + temp_col) == 2) if (enc_dbcs != 0 && dbcs_ptr2cells(p + temp_col) == 2)
++temp_col; ++temp_col;
else else if (CHAR_CLASS(p[temp_col]) != start_class
#endif && !(enc_utf8 && p[temp_col] == 0))
if (CHAR_CLASS(p[temp_col]) != start_class
#ifdef FEAT_MBYTE
&& !(enc_utf8 && p[temp_col] == 0)
#endif
)
break; break;
cb->word_end_col = temp_col; cb->word_end_col = temp_col;
} }
@@ -1820,11 +1786,9 @@ fill_input_buf(int exit_on_error UNUSED)
int len; int len;
int try; int try;
static int did_read_something = FALSE; static int did_read_something = FALSE;
# ifdef FEAT_MBYTE
static char_u *rest = NULL; /* unconverted rest of previous read */ static char_u *rest = NULL; /* unconverted rest of previous read */
static int restlen = 0; static int restlen = 0;
int unconverted; int unconverted;
# endif
#endif #endif
#ifdef FEAT_GUI #ifdef FEAT_GUI
@@ -1860,7 +1824,6 @@ fill_input_buf(int exit_on_error UNUSED)
inbufcount = 0; inbufcount = 0;
# else # else
# ifdef FEAT_MBYTE
if (rest != NULL) if (rest != NULL)
{ {
/* Use remainder of previous call, starts with an invalid character /* Use remainder of previous call, starts with an invalid character
@@ -1881,16 +1844,12 @@ fill_input_buf(int exit_on_error UNUSED)
} }
else else
unconverted = 0; unconverted = 0;
# endif
len = 0; /* to avoid gcc warning */ len = 0; /* to avoid gcc warning */
for (try = 0; try < 100; ++try) for (try = 0; try < 100; ++try)
{ {
size_t readlen = (size_t)((INBUFLEN - inbufcount) size_t readlen = (size_t)((INBUFLEN - inbufcount)
# ifdef FEAT_MBYTE / input_conv.vc_factor);
/ input_conv.vc_factor
# endif
);
# ifdef VMS # ifdef VMS
len = vms_read((char *)inbuf + inbufcount, readlen); len = vms_read((char *)inbuf + inbufcount, readlen);
# else # else
@@ -1936,7 +1895,6 @@ fill_input_buf(int exit_on_error UNUSED)
} }
else else
{ {
# ifdef FEAT_MBYTE
/* /*
* May perform conversion on the input characters. * May perform conversion on the input characters.
* Include the unconverted rest of the previous call. * Include the unconverted rest of the previous call.
@@ -1952,7 +1910,6 @@ fill_input_buf(int exit_on_error UNUSED)
len + unconverted, INBUFLEN - inbufcount, len + unconverted, INBUFLEN - inbufcount,
rest == NULL ? &rest : NULL, &restlen); rest == NULL ? &rest : NULL, &restlen);
} }
# endif
while (len-- > 0) while (len-- > 0)
{ {
/* /*
@@ -2014,8 +1971,6 @@ ui_cursor_shape(void)
} }
#endif #endif
#if defined(FEAT_CLIPBOARD) || defined(FEAT_GUI) || defined(FEAT_RIGHTLEFT) \
|| defined(FEAT_MBYTE) || defined(PROTO)
/* /*
* Check bounds for column number * Check bounds for column number
*/ */
@@ -2041,7 +1996,6 @@ check_row(int row)
return (int)screen_Rows - 1; return (int)screen_Rows - 1;
return row; return row;
} }
#endif
/* /*
* Stuff for the X clipboard. Shared between VMS and Unix. * Stuff for the X clipboard. Shared between VMS and Unix.
@@ -2066,10 +2020,8 @@ open_app_context(void)
} }
static Atom vim_atom; /* Vim's own special selection format */ static Atom vim_atom; /* Vim's own special selection format */
#ifdef FEAT_MBYTE
static Atom vimenc_atom; /* Vim's extended selection format */ static Atom vimenc_atom; /* Vim's extended selection format */
static Atom utf8_atom; static Atom utf8_atom;
#endif
static Atom compound_text_atom; static Atom compound_text_atom;
static Atom text_atom; static Atom text_atom;
static Atom targets_atom; static Atom targets_atom;
@@ -2079,10 +2031,8 @@ static Atom timestamp_atom; /* Used to get a timestamp */
x11_setup_atoms(Display *dpy) x11_setup_atoms(Display *dpy)
{ {
vim_atom = XInternAtom(dpy, VIM_ATOM_NAME, False); vim_atom = XInternAtom(dpy, VIM_ATOM_NAME, False);
#ifdef FEAT_MBYTE
vimenc_atom = XInternAtom(dpy, VIMENC_ATOM_NAME,False); vimenc_atom = XInternAtom(dpy, VIMENC_ATOM_NAME,False);
utf8_atom = XInternAtom(dpy, "UTF8_STRING", False); utf8_atom = XInternAtom(dpy, "UTF8_STRING", False);
#endif
compound_text_atom = XInternAtom(dpy, "COMPOUND_TEXT", False); compound_text_atom = XInternAtom(dpy, "COMPOUND_TEXT", False);
text_atom = XInternAtom(dpy, "TEXT", False); text_atom = XInternAtom(dpy, "TEXT", False);
targets_atom = XInternAtom(dpy, "TARGETS", False); targets_atom = XInternAtom(dpy, "TARGETS", False);
@@ -2170,9 +2120,7 @@ clip_x11_request_selection_cb(
char_u *p; char_u *p;
char **text_list = NULL; char **text_list = NULL;
VimClipboard *cbd; VimClipboard *cbd;
#ifdef FEAT_MBYTE
char_u *tmpbuf = NULL; char_u *tmpbuf = NULL;
#endif
if (*sel_atom == clip_plus.sel_atom) if (*sel_atom == clip_plus.sel_atom)
cbd = &clip_plus; cbd = &clip_plus;
@@ -2193,7 +2141,6 @@ clip_x11_request_selection_cb(
len--; len--;
} }
#ifdef FEAT_MBYTE
else if (*type == vimenc_atom) else if (*type == vimenc_atom)
{ {
char_u *enc; char_u *enc;
@@ -2221,17 +2168,10 @@ clip_x11_request_selection_cb(
convert_setup(&conv, NULL, NULL); convert_setup(&conv, NULL, NULL);
} }
} }
#endif
else if (*type == compound_text_atom else if (*type == compound_text_atom
#ifdef FEAT_MBYTE
|| *type == utf8_atom || *type == utf8_atom
#endif || (enc_dbcs != 0 && *type == text_atom))
|| (
#ifdef FEAT_MBYTE
enc_dbcs != 0 &&
#endif
*type == text_atom))
{ {
XTextProperty text_prop; XTextProperty text_prop;
int n_text = 0; int n_text = 0;
@@ -2241,7 +2181,7 @@ clip_x11_request_selection_cb(
text_prop.encoding = *type; text_prop.encoding = *type;
text_prop.format = *format; text_prop.format = *format;
text_prop.nitems = len; text_prop.nitems = len;
#if defined(FEAT_MBYTE) && defined(X_HAVE_UTF8_STRING) #if defined(X_HAVE_UTF8_STRING)
if (*type == utf8_atom) if (*type == utf8_atom)
status = Xutf8TextPropertyToTextList(X_DISPLAY, &text_prop, status = Xutf8TextPropertyToTextList(X_DISPLAY, &text_prop,
&text_list, &n_text); &text_list, &n_text);
@@ -2261,9 +2201,7 @@ clip_x11_request_selection_cb(
if (text_list != NULL) if (text_list != NULL)
XFreeStringList(text_list); XFreeStringList(text_list);
#ifdef FEAT_MBYTE
vim_free(tmpbuf); vim_free(tmpbuf);
#endif
XtFree((char *)value); XtFree((char *)value);
*(int *)success = TRUE; *(int *)success = TRUE;
} }
@@ -2281,28 +2219,17 @@ clip_x11_request_selection(
time_t start_time; time_t start_time;
int timed_out = FALSE; int timed_out = FALSE;
for (i = for (i = 0; i < 6; i++)
#ifdef FEAT_MBYTE
0
#else
1
#endif
; i < 6; i++)
{ {
switch (i) switch (i)
{ {
#ifdef FEAT_MBYTE
case 0: type = vimenc_atom; break; case 0: type = vimenc_atom; break;
#endif
case 1: type = vim_atom; break; case 1: type = vim_atom; break;
#ifdef FEAT_MBYTE
case 2: type = utf8_atom; break; case 2: type = utf8_atom; break;
#endif
case 3: type = compound_text_atom; break; case 3: type = compound_text_atom; break;
case 4: type = text_atom; break; case 4: type = text_atom; break;
default: type = XA_STRING; default: type = XA_STRING;
} }
#ifdef FEAT_MBYTE
if (type == utf8_atom if (type == utf8_atom
# if defined(X_HAVE_UTF8_STRING) # if defined(X_HAVE_UTF8_STRING)
&& !enc_utf8 && !enc_utf8
@@ -2311,7 +2238,6 @@ clip_x11_request_selection(
/* Only request utf-8 when 'encoding' is utf8 and /* Only request utf-8 when 'encoding' is utf8 and
* Xutf8TextPropertyToTextList is available. */ * Xutf8TextPropertyToTextList is available. */
continue; continue;
#endif
success = MAYBE; success = MAYBE;
XtGetSelectionValue(myShell, cbd->sel_atom, type, XtGetSelectionValue(myShell, cbd->sel_atom, type,
clip_x11_request_selection_cb, (XtPointer)&success, CurrentTime); clip_x11_request_selection_cb, (XtPointer)&success, CurrentTime);
@@ -2406,14 +2332,10 @@ clip_x11_convert_selection_cb(
*value = (XtPointer)array; *value = (XtPointer)array;
i = 0; i = 0;
array[i++] = targets_atom; array[i++] = targets_atom;
#ifdef FEAT_MBYTE
array[i++] = vimenc_atom; array[i++] = vimenc_atom;
#endif
array[i++] = vim_atom; array[i++] = vim_atom;
#ifdef FEAT_MBYTE
if (enc_utf8) if (enc_utf8)
array[i++] = utf8_atom; array[i++] = utf8_atom;
#endif
array[i++] = XA_STRING; array[i++] = XA_STRING;
array[i++] = text_atom; array[i++] = text_atom;
array[i++] = compound_text_atom; array[i++] = compound_text_atom;
@@ -2427,10 +2349,8 @@ clip_x11_convert_selection_cb(
} }
if ( *target != XA_STRING if ( *target != XA_STRING
#ifdef FEAT_MBYTE
&& *target != vimenc_atom && *target != vimenc_atom
&& (*target != utf8_atom || !enc_utf8) && (*target != utf8_atom || !enc_utf8)
#endif
&& *target != vim_atom && *target != vim_atom
&& *target != text_atom && *target != text_atom
&& *target != compound_text_atom) && *target != compound_text_atom)
@@ -2445,11 +2365,9 @@ clip_x11_convert_selection_cb(
if (*target == vim_atom) if (*target == vim_atom)
(*length)++; (*length)++;
#ifdef FEAT_MBYTE
/* Our own format with encoding: motion 'encoding' NUL text */ /* Our own format with encoding: motion 'encoding' NUL text */
if (*target == vimenc_atom) if (*target == vimenc_atom)
*length += STRLEN(p_enc) + 2; *length += STRLEN(p_enc) + 2;
#endif
if (save_length < *length || save_length / 2 >= *length) if (save_length < *length || save_length / 2 >= *length)
*value = XtRealloc((char *)save_result, (Cardinal)*length + 1); *value = XtRealloc((char *)save_result, (Cardinal)*length + 1);
@@ -2463,11 +2381,7 @@ clip_x11_convert_selection_cb(
save_result = (char_u *)*value; save_result = (char_u *)*value;
save_length = *length; save_length = *length;
if (*target == XA_STRING if (*target == XA_STRING || (*target == utf8_atom && enc_utf8))
#ifdef FEAT_MBYTE
|| (*target == utf8_atom && enc_utf8)
#endif
)
{ {
mch_memmove(save_result, string, (size_t)(*length)); mch_memmove(save_result, string, (size_t)(*length));
*type = *target; *type = *target;
@@ -2495,7 +2409,6 @@ clip_x11_convert_selection_cb(
save_result = (char_u *)*value; save_result = (char_u *)*value;
save_length = *length; save_length = *length;
} }
#ifdef FEAT_MBYTE
else if (*target == vimenc_atom) else if (*target == vimenc_atom)
{ {
int l = STRLEN(p_enc); int l = STRLEN(p_enc);
@@ -2505,7 +2418,6 @@ clip_x11_convert_selection_cb(
mch_memmove(save_result + l + 2, string, (size_t)(*length - l - 2)); mch_memmove(save_result + l + 2, string, (size_t)(*length - l - 2));
*type = vimenc_atom; *type = vimenc_atom;
} }
#endif
else else
{ {
save_result[0] = motion_type; save_result[0] = motion_type;
@@ -2599,7 +2511,6 @@ yank_cut_buffer0(Display *dpy, VimClipboard *cbd)
if (nbytes > 0) if (nbytes > 0)
{ {
#ifdef FEAT_MBYTE
int done = FALSE; int done = FALSE;
/* CUT_BUFFER0 is supposed to be always latin1. Convert to 'enc' when /* CUT_BUFFER0 is supposed to be always latin1. Convert to 'enc' when
@@ -2625,7 +2536,6 @@ yank_cut_buffer0(Display *dpy, VimClipboard *cbd)
} }
} }
if (!done) /* use the text without conversion */ if (!done) /* use the text without conversion */
#endif
clip_yank_selection(MCHAR, buffer, (long)nbytes, cbd); clip_yank_selection(MCHAR, buffer, (long)nbytes, cbd);
XFree((void *)buffer); XFree((void *)buffer);
if (p_verbose > 0) if (p_verbose > 0)

View File

@@ -459,11 +459,7 @@ static char *(features[]) =
"+multi_byte_ime", "+multi_byte_ime",
# endif # endif
#else #else
# ifdef FEAT_MBYTE
"+multi_byte", "+multi_byte",
# else
"-multi_byte",
# endif
#endif #endif
#ifdef FEAT_MULTI_LANG #ifdef FEAT_MULTI_LANG
"+multi_lang", "+multi_lang",
@@ -791,6 +787,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
810,
/**/ /**/
809, 809,
/**/ /**/
@@ -3052,14 +3050,12 @@ do_intro_line(
for (l = 0; p[l] != NUL for (l = 0; p[l] != NUL
&& (l == 0 || (p[l] != '<' && p[l - 1] != '>')); ++l) && (l == 0 || (p[l] != '<' && p[l - 1] != '>')); ++l)
{ {
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
clen += ptr2cells(p + l); clen += ptr2cells(p + l);
l += (*mb_ptr2len)(p + l) - 1; l += (*mb_ptr2len)(p + l) - 1;
} }
else else
#endif
clen += byte2cells(p[l]); clen += byte2cells(p[l]);
} }
screen_puts_len(p, l, row, col, *p == '<' ? HL_ATTR(HLF_8) : attr); screen_puts_len(p, l, row, col, *p == '<' ? HL_ATTR(HLF_8) : attr);

View File

@@ -210,7 +210,7 @@
#endif #endif
/* The Mac conversion stuff doesn't work under X11. */ /* The Mac conversion stuff doesn't work under X11. */
#if defined(FEAT_MBYTE) && defined(MACOS_X_DARWIN) #if defined(MACOS_X_DARWIN)
# define MACOS_CONVERT # define MACOS_CONVERT
#endif #endif
@@ -431,16 +431,10 @@ typedef unsigned short sattr_T;
* bits. u8char_T is only used for displaying, it could be 16 bits to save * bits. u8char_T is only used for displaying, it could be 16 bits to save
* memory. * memory.
*/ */
#ifdef FEAT_MBYTE #ifdef UNICODE16
# ifdef UNICODE16
typedef unsigned short u8char_T; /* short should be 16 bits */ typedef unsigned short u8char_T; /* short should be 16 bits */
# else #else
# if VIM_SIZEOF_INT >= 4 typedef unsigned int u8char_T; /* int is 32 bits or more */
typedef unsigned int u8char_T; /* int is 32 bits */
# else
typedef unsigned long u8char_T; /* long should be 32 bits or more */
# endif
# endif
#endif #endif
#ifndef UNIX /* For Unix this is included in os_unix.h */ #ifndef UNIX /* For Unix this is included in os_unix.h */
@@ -1516,14 +1510,9 @@ typedef UINT32_TYPEDEF UINT32_T;
#define DIALOG_MSG_SIZE 1000 /* buffer size for dialog_msg() */ #define DIALOG_MSG_SIZE 1000 /* buffer size for dialog_msg() */
#ifdef FEAT_MBYTE #define MSG_BUF_LEN 480 /* length of buffer for small messages */
# define MSG_BUF_LEN 480 /* length of buffer for small messages */ #define MSG_BUF_CLEN (MSG_BUF_LEN / 6) /* cell length (worst case: utf-8
# define MSG_BUF_CLEN (MSG_BUF_LEN / 6) /* cell length (worst case: utf-8
takes 6 bytes for one cell) */ takes 6 bytes for one cell) */
#else
# define MSG_BUF_LEN 80 /* length of buffer for small messages */
# define MSG_BUF_CLEN MSG_BUF_LEN /* cell length */
#endif
#define FOLD_TEXT_LEN 51 /* buffer size for get_foldtext() */ #define FOLD_TEXT_LEN 51 /* buffer size for get_foldtext() */
@@ -1609,7 +1598,6 @@ typedef UINT32_TYPEDEF UINT32_T;
# endif # endif
#endif #endif
#ifdef FEAT_MBYTE
/* We need to call mb_stricmp() even when we aren't dealing with a multi-byte /* We need to call mb_stricmp() even when we aren't dealing with a multi-byte
* encoding because mb_stricmp() takes care of all ascii and non-ascii * encoding because mb_stricmp() takes care of all ascii and non-ascii
* encodings, including characters with umlauts in latin1, etc., while * encodings, including characters with umlauts in latin1, etc., while
@@ -1618,10 +1606,6 @@ typedef UINT32_TYPEDEF UINT32_T;
# define MB_STRICMP(d, s) mb_strnicmp((char_u *)(d), (char_u *)(s), (int)MAXCOL) # define MB_STRICMP(d, s) mb_strnicmp((char_u *)(d), (char_u *)(s), (int)MAXCOL)
# define MB_STRNICMP(d, s, n) mb_strnicmp((char_u *)(d), (char_u *)(s), (int)(n)) # define MB_STRNICMP(d, s, n) mb_strnicmp((char_u *)(d), (char_u *)(s), (int)(n))
#else
# define MB_STRICMP(d, s) STRICMP((d), (s))
# define MB_STRNICMP(d, s, n) STRNICMP((d), (s), (n))
#endif
#define STRCAT(d, s) strcat((char *)(d), (char *)(s)) #define STRCAT(d, s) strcat((char *)(d), (char *)(s))
#define STRNCAT(d, s, n) strncat((char *)(d), (char *)(s), (size_t)(n)) #define STRNCAT(d, s, n) strncat((char *)(d), (char *)(s), (size_t)(n))
@@ -1766,16 +1750,12 @@ void *vim_memset(void *, int, size_t);
# endif # endif
#endif #endif
#ifdef FEAT_MBYTE #define MAX_MCO 6 /* maximum value for 'maxcombine' */
# define MAX_MCO 6 /* maximum value for 'maxcombine' */
/* Maximum number of bytes in a multi-byte character. It can be one 32-bit /* Maximum number of bytes in a multi-byte character. It can be one 32-bit
* character of up to 6 bytes, or one 16-bit character of up to three bytes * character of up to 6 bytes, or one 16-bit character of up to three bytes
* plus six following composing characters of three bytes each. */ * plus six following composing characters of three bytes each. */
# define MB_MAXBYTES 21 #define MB_MAXBYTES 21
#else
# define MB_MAXBYTES 1
#endif
#if (defined(FEAT_PROFILE) || defined(FEAT_RELTIME)) && !defined(PROTO) #if (defined(FEAT_PROFILE) || defined(FEAT_RELTIME)) && !defined(PROTO)
# ifdef WIN3264 # ifdef WIN3264
@@ -2128,7 +2108,7 @@ typedef enum {
# define USE_MCH_ERRMSG # define USE_MCH_ERRMSG
#endif #endif
# if defined(FEAT_MBYTE) && defined(FEAT_EVAL) \ # if defined(FEAT_EVAL) \
&& (!defined(FEAT_GUI_W32) \ && (!defined(FEAT_GUI_W32) \
|| !(defined(FEAT_MBYTE_IME) || defined(GLOBAL_IME))) \ || !(defined(FEAT_MBYTE_IME) || defined(GLOBAL_IME))) \
&& !(defined(FEAT_GUI_MAC) && defined(MACOS_CONVERT)) && !(defined(FEAT_GUI_MAC) && defined(MACOS_CONVERT))
@@ -2139,20 +2119,15 @@ typedef enum {
# define IME_WITHOUT_XIM # define IME_WITHOUT_XIM
#endif #endif
#if defined(FEAT_MBYTE) && (defined(FEAT_XIM) \ #if defined(FEAT_XIM) \
|| defined(IME_WITHOUT_XIM) \ || defined(IME_WITHOUT_XIM) \
|| (defined(FEAT_GUI_W32) \ || (defined(FEAT_GUI_W32) \
&& (defined(FEAT_MBYTE_IME) || defined(GLOBAL_IME))) \ && (defined(FEAT_MBYTE_IME) || defined(GLOBAL_IME))) \
|| defined(FEAT_GUI_MAC)) || defined(FEAT_GUI_MAC)
/* im_set_active() is available */ /* im_set_active() is available */
# define HAVE_INPUT_METHOD # define HAVE_INPUT_METHOD
#endif #endif
#ifndef FEAT_MBYTE
# define after_pathsep(b, p) vim_ispathsep(*((p) - 1))
# define transchar_byte(c) transchar(c)
#endif
#ifndef FEAT_LINEBREAK #ifndef FEAT_LINEBREAK
/* Without the 'numberwidth' option line numbers are always 7 chars. */ /* Without the 'numberwidth' option line numbers are always 7 chars. */
# define number_width(x) 7 # define number_width(x) 7
@@ -2160,7 +2135,7 @@ typedef enum {
/* This must come after including proto.h. /* This must come after including proto.h.
* For VMS this is defined in macros.h. */ * For VMS this is defined in macros.h. */
#if !(defined(FEAT_MBYTE) && defined(WIN3264)) && !defined(VMS) #if !defined(WIN3264) && !defined(VMS)
# define mch_open(n, m, p) open((n), (m), (p)) # define mch_open(n, m, p) open((n), (m), (p))
# define mch_fopen(n, p) fopen((n), (p)) # define mch_fopen(n, p) fopen((n), (p))
#endif #endif
@@ -2236,37 +2211,32 @@ typedef enum {
# define vim_realloc(ptr, size) realloc((ptr), (size)) # define vim_realloc(ptr, size) realloc((ptr), (size))
#endif #endif
#ifdef FEAT_MBYTE
/* /*
* Return byte length of character that starts with byte "b". * Return byte length of character that starts with byte "b".
* Returns 1 for a single-byte character. * Returns 1 for a single-byte character.
* MB_BYTE2LEN_CHECK() can be used to count a special key as one byte. * MB_BYTE2LEN_CHECK() can be used to count a special key as one byte.
* Don't call MB_BYTE2LEN(b) with b < 0 or b > 255! * Don't call MB_BYTE2LEN(b) with b < 0 or b > 255!
*/ */
# define MB_BYTE2LEN(b) mb_bytelen_tab[b] #define MB_BYTE2LEN(b) mb_bytelen_tab[b]
# define MB_BYTE2LEN_CHECK(b) (((b) < 0 || (b) > 255) ? 1 : mb_bytelen_tab[b]) #define MB_BYTE2LEN_CHECK(b) (((b) < 0 || (b) > 255) ? 1 : mb_bytelen_tab[b])
#endif
#if defined(FEAT_MBYTE) || defined(FEAT_POSTSCRIPT)
/* properties used in enc_canon_table[] (first three mutually exclusive) */ /* properties used in enc_canon_table[] (first three mutually exclusive) */
# define ENC_8BIT 0x01 #define ENC_8BIT 0x01
# define ENC_DBCS 0x02 #define ENC_DBCS 0x02
# define ENC_UNICODE 0x04 #define ENC_UNICODE 0x04
# define ENC_ENDIAN_B 0x10 /* Unicode: Big endian */ #define ENC_ENDIAN_B 0x10 /* Unicode: Big endian */
# define ENC_ENDIAN_L 0x20 /* Unicode: Little endian */ #define ENC_ENDIAN_L 0x20 /* Unicode: Little endian */
# define ENC_2BYTE 0x40 /* Unicode: UCS-2 */ #define ENC_2BYTE 0x40 /* Unicode: UCS-2 */
# define ENC_4BYTE 0x80 /* Unicode: UCS-4 */ #define ENC_4BYTE 0x80 /* Unicode: UCS-4 */
# define ENC_2WORD 0x100 /* Unicode: UTF-16 */ #define ENC_2WORD 0x100 /* Unicode: UTF-16 */
# define ENC_LATIN1 0x200 /* Latin1 */ #define ENC_LATIN1 0x200 /* Latin1 */
# define ENC_LATIN9 0x400 /* Latin9 */ #define ENC_LATIN9 0x400 /* Latin9 */
# define ENC_MACROMAN 0x800 /* Mac Roman (not Macro Man! :-) */ #define ENC_MACROMAN 0x800 /* Mac Roman (not Macro Man! :-) */
#endif
#ifdef FEAT_MBYTE #ifdef USE_ICONV
# ifdef USE_ICONV
# ifndef EILSEQ # ifndef EILSEQ
# define EILSEQ 123 # define EILSEQ 123
# endif # endif
@@ -2282,11 +2252,8 @@ typedef enum {
# define ICONV_EINVAL EINVAL # define ICONV_EINVAL EINVAL
# define ICONV_EILSEQ EILSEQ # define ICONV_EILSEQ EILSEQ
# endif # endif
# endif
#endif #endif
#define SIGN_BYTE 1 /* byte value used where sign is displayed; #define SIGN_BYTE 1 /* byte value used where sign is displayed;
attribute value is sign type */ attribute value is sign type */

View File

@@ -44,7 +44,6 @@ typedef int LPWSTR;
typedef int UINT; typedef int UINT;
#endif #endif
#if defined(FEAT_MBYTE) || defined(PROTO)
/* /*
* Convert an UTF-8 string to UTF-16. * Convert an UTF-8 string to UTF-16.
* "instr[inlen]" is the input. "inlen" is in bytes. * "instr[inlen]" is the input. "inlen" is in bytes.
@@ -179,7 +178,6 @@ WideCharToMultiByte_alloc(UINT cp, DWORD flags,
} }
} }
#endif /* FEAT_MBYTE */
#ifdef FEAT_CLIPBOARD #ifdef FEAT_CLIPBOARD
/* /*
@@ -301,12 +299,10 @@ clip_mch_request_selection(VimClipboard *cbd)
VimClipType_t metadata = { -1, -1, -1, -1 }; VimClipType_t metadata = { -1, -1, -1, -1 };
HGLOBAL hMem = NULL; HGLOBAL hMem = NULL;
char_u *str = NULL; char_u *str = NULL;
#if defined(FEAT_MBYTE) && defined(WIN3264) #if defined(WIN3264)
char_u *to_free = NULL; char_u *to_free = NULL;
#endif #endif
#ifdef FEAT_MBYTE
HGLOBAL rawh = NULL; HGLOBAL rawh = NULL;
#endif
int str_size = 0; int str_size = 0;
int maxlen; int maxlen;
size_t n; size_t n;
@@ -339,7 +335,6 @@ clip_mch_request_selection(VimClipboard *cbd)
} }
} }
#ifdef FEAT_MBYTE
/* Check for Vim's raw clipboard format first. This is used without /* Check for Vim's raw clipboard format first. This is used without
* conversion, but only if 'encoding' matches. */ * conversion, but only if 'encoding' matches. */
if (IsClipboardFormatAvailable(cbd->format_raw) if (IsClipboardFormatAvailable(cbd->format_raw)
@@ -366,9 +361,7 @@ clip_mch_request_selection(VimClipboard *cbd)
} }
if (str == NULL) if (str == NULL)
{ {
#endif #if defined(WIN3264)
#if defined(FEAT_MBYTE) && defined(WIN3264)
/* Try to get the clipboard in Unicode if it's not an empty string. */ /* Try to get the clipboard in Unicode if it's not an empty string. */
if (IsClipboardFormatAvailable(CF_UNICODETEXT) && metadata.ucslen != 0) if (IsClipboardFormatAvailable(CF_UNICODETEXT) && metadata.ucslen != 0)
{ {
@@ -378,8 +371,8 @@ clip_mch_request_selection(VimClipboard *cbd)
{ {
WCHAR *hMemWstr = (WCHAR *)GlobalLock(hMemW); WCHAR *hMemWstr = (WCHAR *)GlobalLock(hMemW);
/* Use the length of our metadata if possible, but limit it to the /* Use the length of our metadata if possible, but limit it to
* GlobalSize() for safety. */ * the GlobalSize() for safety. */
maxlen = (int)(GlobalSize(hMemW) / sizeof(WCHAR)); maxlen = (int)(GlobalSize(hMemW) / sizeof(WCHAR));
if (metadata.ucslen >= 0) if (metadata.ucslen >= 0)
{ {
@@ -424,21 +417,19 @@ clip_mch_request_selection(VimClipboard *cbd)
break; break;
} }
# if defined(FEAT_MBYTE) && defined(WIN3264) #if defined(WIN3264)
/* The text is in the active codepage. Convert to 'encoding', /* The text is in the active codepage. Convert to
* going through UTF-16. */ * 'encoding', going through UTF-16. */
acp_to_enc(str, str_size, &to_free, &maxlen); acp_to_enc(str, str_size, &to_free, &maxlen);
if (to_free != NULL) if (to_free != NULL)
{ {
str_size = maxlen; str_size = maxlen;
str = to_free; str = to_free;
} }
# endif
}
}
#ifdef FEAT_MBYTE
}
#endif #endif
}
}
}
if (str != NULL && *str != NUL) if (str != NULL && *str != NUL)
{ {
@@ -460,12 +451,10 @@ clip_mch_request_selection(VimClipboard *cbd)
/* unlock the global object */ /* unlock the global object */
if (hMem != NULL) if (hMem != NULL)
GlobalUnlock(hMem); GlobalUnlock(hMem);
#ifdef FEAT_MBYTE
if (rawh != NULL) if (rawh != NULL)
GlobalUnlock(rawh); GlobalUnlock(rawh);
#endif
CloseClipboard(); CloseClipboard();
#if defined(FEAT_MBYTE) && defined(WIN3264) #if defined(WIN3264)
vim_free(to_free); vim_free(to_free);
#endif #endif
} }
@@ -482,7 +471,7 @@ clip_mch_set_selection(VimClipboard *cbd)
HGLOBAL hMemRaw = NULL; HGLOBAL hMemRaw = NULL;
HGLOBAL hMem = NULL; HGLOBAL hMem = NULL;
HGLOBAL hMemVim = NULL; HGLOBAL hMemVim = NULL;
# if defined(FEAT_MBYTE) && defined(WIN3264) # if defined(WIN3264)
HGLOBAL hMemW = NULL; HGLOBAL hMemW = NULL;
# endif # endif
@@ -499,7 +488,6 @@ clip_mch_set_selection(VimClipboard *cbd)
metadata.ucslen = 0; metadata.ucslen = 0;
metadata.rawlen = 0; metadata.rawlen = 0;
#ifdef FEAT_MBYTE
/* Always set the raw bytes: 'encoding', NUL and the text. This is used /* Always set the raw bytes: 'encoding', NUL and the text. This is used
* when copy/paste from/to Vim with the same 'encoding', so that illegal * when copy/paste from/to Vim with the same 'encoding', so that illegal
* bytes can also be copied and no conversion is needed. */ * bytes can also be copied and no conversion is needed. */
@@ -519,9 +507,8 @@ clip_mch_set_selection(VimClipboard *cbd)
else else
metadata.rawlen = 0; metadata.rawlen = 0;
} }
#endif
# if defined(FEAT_MBYTE) && defined(WIN3264) # if defined(WIN3264)
{ {
WCHAR *out; WCHAR *out;
int len = metadata.txtlen; int len = metadata.txtlen;
@@ -603,7 +590,7 @@ clip_mch_set_selection(VimClipboard *cbd)
{ {
SetClipboardData(cbd->format, hMemVim); SetClipboardData(cbd->format, hMemVim);
hMemVim = 0; hMemVim = 0;
# if defined(FEAT_MBYTE) && defined(WIN3264) # if defined(WIN3264)
if (hMemW != NULL) if (hMemW != NULL)
{ {
if (SetClipboardData(CF_UNICODETEXT, hMemW) != NULL) if (SetClipboardData(CF_UNICODETEXT, hMemW) != NULL)
@@ -624,7 +611,7 @@ clip_mch_set_selection(VimClipboard *cbd)
GlobalFree(hMemRaw); GlobalFree(hMemRaw);
if (hMem) if (hMem)
GlobalFree(hMem); GlobalFree(hMem);
# if defined(FEAT_MBYTE) && defined(WIN3264) # if defined(WIN3264)
if (hMemW) if (hMemW)
GlobalFree(hMemW); GlobalFree(hMemW);
# endif # endif
@@ -634,7 +621,6 @@ clip_mch_set_selection(VimClipboard *cbd)
#endif /* FEAT_CLIPBOARD */ #endif /* FEAT_CLIPBOARD */
#if defined(FEAT_MBYTE) || defined(PROTO)
/* /*
* Note: the following two functions are only guaranteed to work when using * Note: the following two functions are only guaranteed to work when using
* valid MS-Windows codepages or when iconv() is available. * valid MS-Windows codepages or when iconv() is available.
@@ -759,9 +745,8 @@ utf16_to_enc(short_u *str, int *lenp)
return enc_str; return enc_str;
} }
#endif /* FEAT_MBYTE */
#if (defined(FEAT_MBYTE) && defined(WIN3264)) || defined(PROTO) #if defined(WIN3264) || defined(PROTO)
/* /*
* Convert from the active codepage to 'encoding'. * Convert from the active codepage to 'encoding'.
* Input is "str[str_size]". * Input is "str[str_size]".

View File

@@ -6180,12 +6180,9 @@ file_name_in_line(
*/ */
while (ptr > line) while (ptr > line)
{ {
#ifdef FEAT_MBYTE
if (has_mbyte && (len = (*mb_head_off)(line, ptr - 1)) > 0) if (has_mbyte && (len = (*mb_head_off)(line, ptr - 1)) > 0)
ptr -= len + 1; ptr -= len + 1;
else else if (vim_isfilec(ptr[-1])
#endif
if (vim_isfilec(ptr[-1])
|| ((options & FNAME_HYP) && path_is_url(ptr - 1))) || ((options & FNAME_HYP) && path_is_url(ptr - 1)))
--ptr; --ptr;
else else
@@ -6214,11 +6211,9 @@ file_name_in_line(
if (ptr[len] == '\\') if (ptr[len] == '\\')
/* Skip over the "\" in "\ ". */ /* Skip over the "\" in "\ ". */
++len; ++len;
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
len += (*mb_ptr2len)(ptr + len); len += (*mb_ptr2len)(ptr + len);
else else
#endif
++len; ++len;
} }
@@ -6829,7 +6824,7 @@ match_add(
m->match.regprog = regprog; m->match.regprog = regprog;
m->match.rmm_ic = FALSE; m->match.rmm_ic = FALSE;
m->match.rmm_maxcol = 0; m->match.rmm_maxcol = 0;
# if defined(FEAT_CONCEAL) && defined(FEAT_MBYTE) # if defined(FEAT_CONCEAL)
m->conceal_char = 0; m->conceal_char = 0;
if (conceal_char != NULL) if (conceal_char != NULL)
m->conceal_char = (*mb_ptr2char)(conceal_char); m->conceal_char = (*mb_ptr2char)(conceal_char);