patch 8.1.0810: too many #ifdefs
Problem: Too many #ifdefs. Solution: Graduate FEAT_MBYTE, part 4.
This commit is contained in:
@ -1789,10 +1789,8 @@ struct exarg
|
||||
int force_bin; /* 0, FORCE_BIN or FORCE_NOBIN */
|
||||
int read_edit; /* ++edit argument */
|
||||
int force_ff; /* ++ff= argument (first char of argument) */
|
||||
#ifdef FEAT_MBYTE
|
||||
int force_enc; /* ++enc= argument (index in cmd[]) */
|
||||
int bad_char; /* BAD_KEEP, BAD_DROP or replacement byte */
|
||||
#endif
|
||||
#ifdef FEAT_USR_CMDS
|
||||
int useridx; /* user command index */
|
||||
#endif
|
||||
|
||||
@ -291,14 +291,11 @@ add_num_buff(buffheader_T *buf, long n)
|
||||
static void
|
||||
add_char_buff(buffheader_T *buf, int c)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
char_u bytes[MB_MAXBYTES + 1];
|
||||
int len;
|
||||
int i;
|
||||
#endif
|
||||
char_u temp[4];
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
if (IS_SPECIAL(c))
|
||||
len = 1;
|
||||
else
|
||||
@ -307,7 +304,6 @@ add_char_buff(buffheader_T *buf, int c)
|
||||
{
|
||||
if (!IS_SPECIAL(c))
|
||||
c = bytes[i];
|
||||
#endif
|
||||
|
||||
if (IS_SPECIAL(c) || c == K_SPECIAL || c == NUL)
|
||||
{
|
||||
@ -333,9 +329,7 @@ add_char_buff(buffheader_T *buf, int c)
|
||||
temp[1] = NUL;
|
||||
}
|
||||
add_buff(buf, temp, -1L);
|
||||
#ifdef FEAT_MBYTE
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* First read ahead buffer. Used for translated commands. */
|
||||
@ -596,12 +590,10 @@ AppendToRedobuffLit(
|
||||
break;
|
||||
|
||||
/* Handle a special or multibyte character. */
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
/* Handle composing chars separately. */
|
||||
c = mb_cptr2char_adv(&s);
|
||||
else
|
||||
#endif
|
||||
c = *s++;
|
||||
if (c < ' ' || c == DEL || (*s == NUL && (c == '0' || c == '^')))
|
||||
add_char_buff(&redobuff, Ctrl_V);
|
||||
@ -686,11 +678,7 @@ stuffReadbuffSpec(char_u *s)
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
c = mb_ptr2char_adv(&s);
|
||||
#else
|
||||
c = *s++;
|
||||
#endif
|
||||
if (c == CAR || c == NL || c == ESC)
|
||||
c = ' ';
|
||||
stuffcharReadbuff(c);
|
||||
@ -732,11 +720,9 @@ read_redo(int init, int old_redo)
|
||||
static buffblock_T *bp;
|
||||
static char_u *p;
|
||||
int c;
|
||||
#ifdef FEAT_MBYTE
|
||||
int n;
|
||||
char_u buf[MB_MAXBYTES + 1];
|
||||
int i;
|
||||
#endif
|
||||
|
||||
if (init)
|
||||
{
|
||||
@ -752,7 +738,6 @@ read_redo(int init, int old_redo)
|
||||
if ((c = *p) != NUL)
|
||||
{
|
||||
/* Reverse the conversion done by add_char_buff() */
|
||||
#ifdef FEAT_MBYTE
|
||||
/* For a multi-byte character get all the bytes and return the
|
||||
* converted character. */
|
||||
if (has_mbyte && (c != K_SPECIAL || p[1] == KS_SPECIAL))
|
||||
@ -760,7 +745,6 @@ read_redo(int init, int old_redo)
|
||||
else
|
||||
n = 1;
|
||||
for (i = 0; ; ++i)
|
||||
#endif
|
||||
{
|
||||
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;
|
||||
p = bp->b_str;
|
||||
}
|
||||
#ifdef FEAT_MBYTE
|
||||
buf[i] = c;
|
||||
if (i == n - 1) /* last byte of a character */
|
||||
{
|
||||
@ -787,7 +770,6 @@ read_redo(int init, int old_redo)
|
||||
c = *p;
|
||||
if (c == NUL) /* cannot happen? */
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -1093,11 +1075,7 @@ ins_typebuf(
|
||||
void
|
||||
ins_char_typebuf(int c)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
char_u buf[MB_MAXBYTES + 1];
|
||||
#else
|
||||
char_u buf[4];
|
||||
#endif
|
||||
if (IS_SPECIAL(c))
|
||||
{
|
||||
buf[0] = K_SPECIAL;
|
||||
@ -1106,14 +1084,7 @@ ins_char_typebuf(int c)
|
||||
buf[3] = NUL;
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
buf[(*mb_char2bytes)(c, buf)] = NUL;
|
||||
#else
|
||||
buf[0] = c;
|
||||
buf[1] = NUL;
|
||||
#endif
|
||||
}
|
||||
(void)ins_typebuf(buf, KeyNoremap, 0, !KeyTyped, cmd_silent);
|
||||
}
|
||||
|
||||
@ -1579,11 +1550,9 @@ updatescript(int c)
|
||||
vgetc(void)
|
||||
{
|
||||
int c, c2;
|
||||
#ifdef FEAT_MBYTE
|
||||
int n;
|
||||
char_u buf[MB_MAXBYTES + 1];
|
||||
int i;
|
||||
#endif
|
||||
|
||||
#ifdef FEAT_EVAL
|
||||
/* Do garbage collection when garbagecollect() was called previously and
|
||||
@ -1763,7 +1732,6 @@ vgetc(void)
|
||||
case K_XRIGHT: c = K_RIGHT; break;
|
||||
}
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
/* For a multi-byte character get all the bytes and return the
|
||||
* converted character.
|
||||
* Note: This will loop until enough bytes are received!
|
||||
@ -1794,7 +1762,6 @@ vgetc(void)
|
||||
--no_mapping;
|
||||
c = (*mb_ptr2char)(buf);
|
||||
}
|
||||
#endif
|
||||
|
||||
break;
|
||||
}
|
||||
@ -2212,7 +2179,6 @@ vgetorpeek(int advance)
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
/* Don't allow mapping the first byte(s) of a
|
||||
* multi-byte char. Happens when mapping
|
||||
* <M-a> and then changing 'encoding'. Beware
|
||||
@ -2225,7 +2191,6 @@ vgetorpeek(int advance)
|
||||
&& MB_BYTE2LEN(c1) > MB_PTR2LEN(p2))
|
||||
mlen = 0;
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
* Check an entry whether it matches.
|
||||
* - Full match: mlen == keylen
|
||||
@ -2685,38 +2650,29 @@ vgetorpeek(int advance)
|
||||
curwin->w_wcol = vcol;
|
||||
vcol += lbr_chartabsize(ptr, ptr + col,
|
||||
(colnr_T)vcol);
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
col += (*mb_ptr2len)(ptr + col);
|
||||
else
|
||||
#endif
|
||||
++col;
|
||||
}
|
||||
curwin->w_wrow = curwin->w_cline_row
|
||||
+ curwin->w_wcol / curwin->w_width;
|
||||
curwin->w_wcol %= curwin->w_width;
|
||||
curwin->w_wcol += curwin_col_off();
|
||||
#ifdef FEAT_MBYTE
|
||||
col = 0; /* no correction needed */
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
--curwin->w_wcol;
|
||||
#ifdef FEAT_MBYTE
|
||||
col = curwin->w_cursor.col - 1;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else if (curwin->w_p_wrap && curwin->w_wrow)
|
||||
{
|
||||
--curwin->w_wrow;
|
||||
curwin->w_wcol = curwin->w_width - 1;
|
||||
#ifdef FEAT_MBYTE
|
||||
col = curwin->w_cursor.col - 1;
|
||||
#endif
|
||||
}
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte && col > 0 && curwin->w_wcol > 0)
|
||||
{
|
||||
/* Correct when the cursor is on the right halve
|
||||
@ -2726,7 +2682,6 @@ vgetorpeek(int advance)
|
||||
if ((*mb_ptr2cells)(ptr + col) > 1)
|
||||
--curwin->w_wcol;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
setcursor();
|
||||
out_flush();
|
||||
@ -3434,7 +3389,6 @@ do_map(
|
||||
* Otherwise we won't be able to find the start of it in a
|
||||
* vi-compatible way.
|
||||
*/
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
int first, last;
|
||||
@ -3458,9 +3412,7 @@ do_map(
|
||||
goto theend;
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (vim_iswordc(keys[len - 1])) /* ends in keyword char */
|
||||
else if (vim_iswordc(keys[len - 1])) // ends in keyword char
|
||||
for (n = 0; n < len - 2; ++n)
|
||||
if (vim_iswordc(keys[n]) != vim_iswordc(keys[len - 2]))
|
||||
{
|
||||
@ -4458,9 +4410,7 @@ check_abbr(
|
||||
#ifdef FEAT_LOCALMAP
|
||||
mapblock_T *mp2;
|
||||
#endif
|
||||
#ifdef FEAT_MBYTE
|
||||
int clen = 0; /* length in characters */
|
||||
#endif
|
||||
int is_id = TRUE;
|
||||
int vim_abbr;
|
||||
|
||||
@ -4480,7 +4430,6 @@ check_abbr(
|
||||
if (col == 0) /* cannot be an abbr. */
|
||||
return FALSE;
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
char_u *p;
|
||||
@ -4508,7 +4457,6 @@ check_abbr(
|
||||
scol = (int)(p - ptr);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if (!vim_iswordc(ptr[col - 1]))
|
||||
vim_abbr = TRUE; /* Vim added abbr. */
|
||||
@ -4601,7 +4549,6 @@ check_abbr(
|
||||
{
|
||||
if (c < ABBR_OFF && (c < ' ' || c > '~'))
|
||||
tb[j++] = Ctrl_V; /* special char needs CTRL-V */
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
/* if ABBR_OFF has been added, remove it here */
|
||||
@ -4610,7 +4557,6 @@ check_abbr(
|
||||
j += (*mb_char2bytes)(c, tb + j);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
tb[j++] = c;
|
||||
}
|
||||
tb[j] = NUL;
|
||||
@ -4637,10 +4583,8 @@ check_abbr(
|
||||
|
||||
tb[0] = Ctrl_H;
|
||||
tb[1] = NUL;
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
len = clen; /* Delete characters instead of bytes */
|
||||
#endif
|
||||
while (len-- > 0) /* delete the from string */
|
||||
(void)ins_typebuf(tb, 1, 0, TRUE, mp->m_silent);
|
||||
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
|
||||
* illegal utf-8 byte:
|
||||
* 0xc0 -> 0xc3 0x80 -> 0xc3 K_SPECIAL KS_SPECIAL KE_FILLER */
|
||||
res = alloc((unsigned)(STRLEN(p) *
|
||||
#ifdef FEAT_MBYTE
|
||||
4
|
||||
#else
|
||||
3
|
||||
#endif
|
||||
) + 1);
|
||||
res = alloc((unsigned)(STRLEN(p) * 4) + 1);
|
||||
if (res != NULL)
|
||||
{
|
||||
d = res;
|
||||
@ -5012,7 +4950,6 @@ put_escstr(FILE *fd, char_u *strstart, int what)
|
||||
|
||||
for ( ; *str != NUL; ++str)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
char_u *p;
|
||||
|
||||
/* Check for a multi-byte character, which may contain escaped
|
||||
@ -5026,7 +4963,6 @@ put_escstr(FILE *fd, char_u *strstart, int what)
|
||||
--str;
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
c = *str;
|
||||
/*
|
||||
|
||||
@ -134,7 +134,7 @@ global_ime_DefWindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
||||
if (pIApp == NULL || pIApp->OnDefWindowProc(hWnd, Msg,
|
||||
wParam, lParam, &lResult) != S_OK)
|
||||
{
|
||||
#if defined(WIN3264) && defined(FEAT_MBYTE)
|
||||
#if defined(WIN3264)
|
||||
if (wide_WindowProc)
|
||||
lResult = DefWindowProcW(hWnd, Msg, wParam, lParam);
|
||||
else
|
||||
|
||||
@ -44,7 +44,6 @@ EXTERN sattr_T *ScreenAttrs INIT(= NULL);
|
||||
EXTERN unsigned *LineOffset INIT(= NULL);
|
||||
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
|
||||
* 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.
|
||||
* These are single-width. */
|
||||
EXTERN schar_T *ScreenLines2 INIT(= NULL);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Indexes for tab page line:
|
||||
@ -798,7 +796,6 @@ EXTERN int vr_lines_changed INIT(= 0); /* #Lines changed by "gR" so far */
|
||||
EXTERN JMP_BUF x_jump_env;
|
||||
#endif
|
||||
|
||||
#if defined(FEAT_MBYTE) || defined(FEAT_POSTSCRIPT)
|
||||
/*
|
||||
* These flags are set based upon 'fileencoding'.
|
||||
* Note that "enc_utf8" is also set for "unicode", because the characters are
|
||||
@ -814,9 +811,7 @@ EXTERN JMP_BUF x_jump_env;
|
||||
#define DBCS_CHTU 9950 /* euc-tw */
|
||||
#define DBCS_2BYTE 1 /* 2byte- */
|
||||
#define DBCS_DEBUG -1
|
||||
#endif
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
EXTERN int enc_dbcs INIT(= 0); /* One of DBCS_xxx values if
|
||||
DBCS encoding */
|
||||
EXTERN int enc_unicode INIT(= 0); /* 2: UCS-2 or UTF-16, 4: UCS-4 */
|
||||
@ -830,7 +825,7 @@ EXTERN int enc_latin9 INIT(= FALSE); /* 'encoding' is latin9 */
|
||||
#endif
|
||||
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() */
|
||||
#endif
|
||||
|
||||
@ -875,7 +870,6 @@ EXTERN int (*iconvctl) (iconv_t cd, int request, void *argument);
|
||||
EXTERN int* (*iconv_errno) (void);
|
||||
# endif
|
||||
|
||||
#endif /* FEAT_MBYTE */
|
||||
|
||||
#ifdef FEAT_XIM
|
||||
# ifdef FEAT_GUI_GTK
|
||||
|
||||
@ -303,14 +303,12 @@ typedef struct Gui
|
||||
GuiFont menu_font; /* menu item font */
|
||||
# endif
|
||||
#endif
|
||||
#ifdef FEAT_MBYTE
|
||||
GuiFont wide_font; /* Normal 'guifontwide' font */
|
||||
#ifndef FEAT_GUI_GTK
|
||||
GuiFont wide_bold_font; /* Bold 'guifontwide' font */
|
||||
GuiFont wide_ital_font; /* Italic 'guifontwide' font */
|
||||
GuiFont wide_boldital_font; /* Bold-Italic 'guifontwide' font */
|
||||
#endif
|
||||
#endif
|
||||
#ifdef FEAT_XFONTSET
|
||||
GuiFontset fontset; /* set of fonts for multi-byte chars */
|
||||
#endif
|
||||
|
||||
@ -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. */
|
||||
#endif
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
#define ENC_OPT ((char *)p_enc)
|
||||
#else
|
||||
# define ENC_OPT "latin1"
|
||||
#endif
|
||||
#define DOPY_FUNC "_vim_pydo"
|
||||
|
||||
static const char *vim_special_path = "_vim_path_";
|
||||
@ -985,11 +981,7 @@ VimStrwidth(PyObject *self UNUSED, PyObject *string)
|
||||
if (!(str = StringToChars(string, &todecref)))
|
||||
return NULL;
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
len = mb_string2cells(str, (int)STRLEN(str));
|
||||
#else
|
||||
len = STRLEN(str);
|
||||
#endif
|
||||
|
||||
Py_XDECREF(todecref);
|
||||
|
||||
|
||||
31
src/macros.h
31
src/macros.h
@ -96,17 +96,10 @@
|
||||
* MB_ISLOWER() and MB_ISUPPER() are to be used on multi-byte characters. But
|
||||
* don't use them for negative values!
|
||||
*/
|
||||
#ifdef FEAT_MBYTE
|
||||
#define MB_ISLOWER(c) vim_islower(c)
|
||||
#define MB_ISUPPER(c) vim_isupper(c)
|
||||
#define MB_TOLOWER(c) vim_tolower(c)
|
||||
#define MB_TOUPPER(c) vim_toupper(c)
|
||||
#else
|
||||
# define MB_ISLOWER(c) islower(c)
|
||||
# define MB_ISUPPER(c) isupper(c)
|
||||
# define MB_TOLOWER(c) TOLOWER_LOC(c)
|
||||
# define MB_TOUPPER(c) TOUPPER_LOC(c)
|
||||
#endif
|
||||
|
||||
/* Use our own isdigit() replacement, because on MS-Windows isdigit() returns
|
||||
* non-zero for superscript 1. Also avoids that isdigit() crashes for numbers
|
||||
@ -139,7 +132,6 @@
|
||||
* a mapping and the langnoremap option was set.
|
||||
* The do-while is just to ignore a ';' after the macro.
|
||||
*/
|
||||
# ifdef FEAT_MBYTE
|
||||
# define LANGMAP_ADJUST(c, condition) \
|
||||
do { \
|
||||
if (*p_langmap \
|
||||
@ -155,17 +147,6 @@
|
||||
} \
|
||||
} while (0)
|
||||
#else
|
||||
# define LANGMAP_ADJUST(c, condition) \
|
||||
do { \
|
||||
if (*p_langmap \
|
||||
&& (condition) \
|
||||
&& (p_lrm || (!p_lrm && KeyTyped)) \
|
||||
&& !KeyStuffed \
|
||||
&& (c) >= 0 && (c) < 256) \
|
||||
c = langmap_mapchar[c]; \
|
||||
} while (0)
|
||||
# endif
|
||||
#else
|
||||
# define LANGMAP_ADJUST(c, condition) /* nop */
|
||||
#endif
|
||||
|
||||
@ -256,7 +237,6 @@
|
||||
* MB_COPY_CHAR(f, t): copy one char from "f" to "t" and advance the pointers.
|
||||
* PTR2CHAR(): get character from pointer.
|
||||
*/
|
||||
#ifdef FEAT_MBYTE
|
||||
/* Get the length of the character p points to, including composing chars */
|
||||
#define MB_PTR2LEN(p) (has_mbyte ? (*mb_ptr2len)(p) : 1)
|
||||
/* Advance multi-byte pointer, skip over composing chars. */
|
||||
@ -272,17 +252,6 @@
|
||||
#define MB_CHARLEN(p) (has_mbyte ? mb_charlen(p) : (int)STRLEN(p))
|
||||
#define MB_CHAR2LEN(c) (has_mbyte ? mb_char2len(c) : 1)
|
||||
#define PTR2CHAR(p) (has_mbyte ? mb_ptr2char(p) : (int)*(p))
|
||||
#else
|
||||
# define MB_PTR2LEN(p) 1
|
||||
# define MB_CPTR2LEN(p) 1
|
||||
# define MB_PTR_ADV(p) ++p
|
||||
# define MB_CPTR_ADV(p) ++p
|
||||
# define MB_PTR_BACK(s, p) --p
|
||||
# define MB_COPY_CHAR(f, t) *t++ = *f++
|
||||
# define MB_CHARLEN(p) STRLEN(p)
|
||||
# define MB_CHAR2LEN(c) 1
|
||||
# define PTR2CHAR(p) ((int)*(p))
|
||||
#endif
|
||||
|
||||
#ifdef FEAT_AUTOCHDIR
|
||||
# define DO_AUTOCHDIR do { if (p_acd) do_autochdir(); } while (0)
|
||||
|
||||
28
src/option.h
28
src/option.h
@ -69,13 +69,11 @@
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
/* Possible values for 'encoding' */
|
||||
#define ENC_UCSBOM "ucs-bom" /* check for BOM at start of file */
|
||||
|
||||
/* default value for 'encoding' */
|
||||
#define ENC_DFLT "latin1"
|
||||
#endif
|
||||
|
||||
/* end-of-line style */
|
||||
#define EOL_UNKNOWN -1 /* not defined yet */
|
||||
@ -315,10 +313,8 @@ EXTERN long p_aleph; /* 'aleph' */
|
||||
#ifdef FEAT_AUTOCHDIR
|
||||
EXTERN int p_acd; /* 'autochdir' */
|
||||
#endif
|
||||
#ifdef FEAT_MBYTE
|
||||
EXTERN char_u *p_ambw; /* 'ambiwidth' */
|
||||
EXTERN char_u *p_emoji; /* 'emoji' */
|
||||
#endif
|
||||
#if defined(FEAT_GUI) && defined(MACOS_X)
|
||||
EXTERN int *p_antialias; /* 'antialias' */
|
||||
#endif
|
||||
@ -395,7 +391,6 @@ EXTERN char_u *p_bsdir; /* 'browsedir' */
|
||||
#ifdef FEAT_LINEBREAK
|
||||
EXTERN char_u *p_breakat; /* 'breakat' */
|
||||
#endif
|
||||
#ifdef FEAT_MBYTE
|
||||
EXTERN char_u *p_cmp; /* 'casemap' */
|
||||
EXTERN unsigned cmp_flags;
|
||||
#ifdef IN_OPTION_C
|
||||
@ -403,14 +398,11 @@ static char *(p_cmp_values[]) = {"internal", "keepascii", NULL};
|
||||
#endif
|
||||
#define CMP_INTERNAL 0x001
|
||||
#define CMP_KEEPASCII 0x002
|
||||
#endif
|
||||
#ifdef FEAT_MBYTE
|
||||
EXTERN char_u *p_enc; /* 'encoding' */
|
||||
EXTERN int p_deco; /* 'delcombine' */
|
||||
#ifdef FEAT_EVAL
|
||||
EXTERN char_u *p_ccv; /* 'charconvert' */
|
||||
#endif
|
||||
#endif
|
||||
#ifdef FEAT_CMDWIN
|
||||
EXTERN char_u *p_cedit; /* 'cedit' */
|
||||
EXTERN long p_cwh; /* 'cmdwinheight' */
|
||||
@ -482,9 +474,7 @@ EXTERN char_u *p_gp; /* 'grepprg' */
|
||||
EXTERN char_u *p_ei; /* 'eventignore' */
|
||||
EXTERN int p_ek; /* 'esckeys' */
|
||||
EXTERN int p_exrc; /* 'exrc' */
|
||||
#ifdef FEAT_MBYTE
|
||||
EXTERN char_u *p_fencs; /* 'fileencodings' */
|
||||
#endif
|
||||
EXTERN char_u *p_ffs; /* 'fileformats' */
|
||||
EXTERN long p_fic; /* 'fileignorecase' */
|
||||
#ifdef FEAT_FOLDING
|
||||
@ -519,11 +509,9 @@ EXTERN char_u *p_pdev; /* 'printdevice' */
|
||||
# ifdef FEAT_POSTSCRIPT
|
||||
EXTERN char_u *p_penc; /* 'printencoding' */
|
||||
EXTERN char_u *p_pexpr; /* 'printexpr' */
|
||||
# ifdef FEAT_MBYTE
|
||||
EXTERN char_u *p_pmfn; /* 'printmbfont' */
|
||||
EXTERN char_u *p_pmcs; /* 'printmbcharset' */
|
||||
# endif
|
||||
# endif
|
||||
EXTERN char_u *p_pfn; /* 'printfont' */
|
||||
EXTERN char_u *p_popt; /* 'printoptions' */
|
||||
EXTERN char_u *p_header; /* 'printheader' */
|
||||
@ -534,9 +522,7 @@ EXTERN char_u *p_guifont; /* 'guifont' */
|
||||
# ifdef FEAT_XFONTSET
|
||||
EXTERN char_u *p_guifontset; /* 'guifontset' */
|
||||
# endif
|
||||
# ifdef FEAT_MBYTE
|
||||
EXTERN char_u *p_guifontwide; /* 'guifontwide' */
|
||||
# endif
|
||||
EXTERN int p_guipty; /* 'guipty' */
|
||||
#endif
|
||||
#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
|
||||
EXTERN long p_imst; /* 'imstyle' */
|
||||
#endif
|
||||
#if defined(FEAT_EVAL) && defined(FEAT_MBYTE)
|
||||
#if defined(FEAT_EVAL)
|
||||
EXTERN char_u *p_imaf; /* 'imactivatefunc' */
|
||||
EXTERN char_u *p_imsf; /* 'imstatusfunc' */
|
||||
#endif
|
||||
#ifdef FEAT_MBYTE
|
||||
EXTERN int p_imcmdline; /* 'imcmdline' */
|
||||
EXTERN int p_imdisable; /* 'imdisable' */
|
||||
#endif
|
||||
EXTERN int p_is; /* 'incsearch' */
|
||||
EXTERN int p_im; /* 'insertmode' */
|
||||
EXTERN char_u *p_isf; /* 'isfname' */
|
||||
@ -629,9 +613,7 @@ EXTERN char_u *p_luadll; /* 'luadll' */
|
||||
EXTERN int p_macatsui; /* 'macatsui' */
|
||||
#endif
|
||||
EXTERN int p_magic; /* 'magic' */
|
||||
#ifdef FEAT_MBYTE
|
||||
EXTERN char_u *p_menc; /* 'makeencoding' */
|
||||
#endif
|
||||
#ifdef FEAT_QUICKFIX
|
||||
EXTERN char_u *p_mef; /* 'makeef' */
|
||||
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 */
|
||||
#endif
|
||||
EXTERN long p_mat; /* 'matchtime' */
|
||||
#ifdef FEAT_MBYTE
|
||||
EXTERN long p_mco; /* 'maxcombine' */
|
||||
#endif
|
||||
#ifdef FEAT_EVAL
|
||||
EXTERN long p_mfd; /* 'maxfuncdepth' */
|
||||
#endif
|
||||
@ -850,9 +830,7 @@ EXTERN char_u *p_tcldll; /* 'tcldll' */
|
||||
#ifdef FEAT_ARABIC
|
||||
EXTERN int p_tbidi; /* 'termbidi' */
|
||||
#endif
|
||||
#ifdef FEAT_MBYTE
|
||||
EXTERN char_u *p_tenc; /* 'termencoding' */
|
||||
#endif
|
||||
#ifdef FEAT_TERMGUICOLORS
|
||||
EXTERN int p_tgc; /* 'termguicolors' */
|
||||
#endif
|
||||
@ -1001,9 +979,7 @@ enum
|
||||
#endif
|
||||
, BV_BIN
|
||||
, BV_BL
|
||||
#ifdef FEAT_MBYTE
|
||||
, BV_BOMB
|
||||
#endif
|
||||
, BV_CI
|
||||
#ifdef FEAT_CINDENT
|
||||
, BV_CIN
|
||||
@ -1068,9 +1044,7 @@ enum
|
||||
, BV_LISP
|
||||
, BV_LW
|
||||
#endif
|
||||
#ifdef FEAT_MBYTE
|
||||
, BV_MENC
|
||||
#endif
|
||||
, BV_MA
|
||||
, BV_ML
|
||||
, BV_MOD
|
||||
|
||||
@ -37,10 +37,8 @@
|
||||
# include <Memory.h>
|
||||
# include <OSUtils.h>
|
||||
# include <Files.h>
|
||||
# ifdef FEAT_MBYTE
|
||||
# include <Script.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Unix interface
|
||||
|
||||
@ -213,14 +213,7 @@ Trace(char *pszFormat, ...);
|
||||
#endif
|
||||
|
||||
/* Enable common dialogs input unicode from IME if possible. */
|
||||
#ifdef FEAT_MBYTE
|
||||
#define pDispatchMessage DispatchMessageW
|
||||
#define pGetMessage GetMessageW
|
||||
#define pIsDialogMessage IsDialogMessageW
|
||||
#define pPeekMessage PeekMessageW
|
||||
#else
|
||||
# define pDispatchMessage DispatchMessage
|
||||
# define pGetMessage GetMessage
|
||||
# define pIsDialogMessage IsDialogMessage
|
||||
# define pPeekMessage PeekMessage
|
||||
#endif
|
||||
|
||||
@ -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 *));
|
||||
#endif
|
||||
# include "move.pro"
|
||||
# if defined(FEAT_MBYTE) || defined(FEAT_XIM) || defined(FEAT_KEYMAP) \
|
||||
|| defined(FEAT_POSTSCRIPT)
|
||||
# include "mbyte.pro"
|
||||
# endif
|
||||
# include "normal.pro"
|
||||
# include "ops.pro"
|
||||
# include "option.pro"
|
||||
|
||||
57
src/search.c
57
src/search.c
@ -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 int lastcdir = FORWARD; /* last direction of character search */
|
||||
static int last_t_cmd = TRUE; /* last search t_cmd */
|
||||
#ifdef FEAT_MBYTE
|
||||
static char_u lastc_bytes[MB_MAXBYTES + 1];
|
||||
static int lastc_bytelen = 1; /* >1 for multi-byte char */
|
||||
#endif
|
||||
|
||||
/* copy of spats[], for keeping the search patterns while executing autocmds */
|
||||
static struct spat saved_spats[2];
|
||||
@ -248,7 +246,6 @@ reverse_text(char_u *s)
|
||||
rev_i = len;
|
||||
for (s_i = 0; s_i < len; ++s_i)
|
||||
{
|
||||
# ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
int mb_len;
|
||||
@ -259,7 +256,6 @@ reverse_text(char_u *s)
|
||||
s_i += mb_len - 1;
|
||||
}
|
||||
else
|
||||
# endif
|
||||
rev[--rev_i] = s[s_i];
|
||||
|
||||
}
|
||||
@ -446,7 +442,6 @@ pat_has_uppercase(char_u *pat)
|
||||
|
||||
while (*p != NUL)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
int l;
|
||||
|
||||
if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1)
|
||||
@ -455,9 +450,7 @@ pat_has_uppercase(char_u *pat)
|
||||
return TRUE;
|
||||
p += l;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (*p == '\\')
|
||||
else if (*p == '\\')
|
||||
{
|
||||
if (p[1] == '_' && p[2] != NUL) /* skip "\_X" */
|
||||
p += 3;
|
||||
@ -480,11 +473,7 @@ pat_has_uppercase(char_u *pat)
|
||||
char_u *
|
||||
last_csearch(void)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
return lastc_bytes;
|
||||
#else
|
||||
return lastc;
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
@ -503,13 +492,11 @@ last_csearch_until(void)
|
||||
set_last_csearch(int c, char_u *s UNUSED, int len UNUSED)
|
||||
{
|
||||
*lastc = c;
|
||||
#ifdef FEAT_MBYTE
|
||||
lastc_bytelen = len;
|
||||
if (len)
|
||||
memcpy(lastc_bytes, s, len);
|
||||
else
|
||||
vim_memset(lastc_bytes, 0, sizeof(lastc_bytes));
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -687,7 +674,6 @@ searchit(
|
||||
* MAXCOL + 1 is zero. */
|
||||
if (pos->col == MAXCOL)
|
||||
start_char_len = 0;
|
||||
#ifdef FEAT_MBYTE
|
||||
/* Watch out for the "col" being MAXCOL - 2, used in a closed fold. */
|
||||
else if (has_mbyte
|
||||
&& pos->lnum >= 1 && pos->lnum <= buf->b_ml.ml_line_count
|
||||
@ -699,7 +685,6 @@ searchit(
|
||||
else
|
||||
start_char_len = (*mb_ptr2len)(ptr + pos->col);
|
||||
}
|
||||
#endif
|
||||
else
|
||||
start_char_len = 1;
|
||||
if (dir == FORWARD)
|
||||
@ -835,12 +820,10 @@ searchit(
|
||||
if (matchcol == matchpos.col
|
||||
&& ptr[matchcol] != NUL)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
matchcol +=
|
||||
(*mb_ptr2len)(ptr + matchcol);
|
||||
else
|
||||
#endif
|
||||
++matchcol;
|
||||
}
|
||||
}
|
||||
@ -849,12 +832,10 @@ searchit(
|
||||
matchcol = matchpos.col;
|
||||
if (ptr[matchcol] != NUL)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
matchcol += (*mb_ptr2len)(ptr
|
||||
+ matchcol);
|
||||
else
|
||||
#endif
|
||||
++matchcol;
|
||||
}
|
||||
}
|
||||
@ -946,12 +927,10 @@ searchit(
|
||||
if (matchcol == matchpos.col
|
||||
&& ptr[matchcol] != NUL)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
matchcol +=
|
||||
(*mb_ptr2len)(ptr + matchcol);
|
||||
else
|
||||
#endif
|
||||
++matchcol;
|
||||
}
|
||||
}
|
||||
@ -963,12 +942,10 @@ searchit(
|
||||
matchcol = matchpos.col;
|
||||
if (ptr[matchcol] != NUL)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
matchcol +=
|
||||
(*mb_ptr2len)(ptr + matchcol);
|
||||
else
|
||||
#endif
|
||||
++matchcol;
|
||||
}
|
||||
}
|
||||
@ -1029,14 +1006,12 @@ searchit(
|
||||
else
|
||||
{
|
||||
--pos->col;
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte
|
||||
&& pos->lnum <= buf->b_ml.ml_line_count)
|
||||
{
|
||||
ptr = ml_get_buf(buf, pos->lnum, FALSE);
|
||||
pos->col -= (*mb_head_off)(ptr, ptr + pos->col);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if (end_pos != NULL)
|
||||
{
|
||||
@ -1410,7 +1385,6 @@ do_search(
|
||||
if (msgbuf != NULL)
|
||||
{
|
||||
msgbuf[0] = dirc;
|
||||
#ifdef FEAT_MBYTE
|
||||
if (enc_utf8 && utf_iscomposing(utf_ptr2char(p)))
|
||||
{
|
||||
/* Use a space to draw the composing char on. */
|
||||
@ -1418,7 +1392,6 @@ do_search(
|
||||
STRCPY(msgbuf + 2, p);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
STRCPY(msgbuf + 1, p);
|
||||
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;
|
||||
set_csearch_direction(dir);
|
||||
set_csearch_until(t_cmd);
|
||||
#ifdef FEAT_MBYTE
|
||||
lastc_bytelen = (*mb_char2bytes)(c, lastc_bytes);
|
||||
if (cap->ncharC1 != 0)
|
||||
{
|
||||
@ -1721,16 +1693,11 @@ searchc(cmdarg_T *cap, int t_cmd)
|
||||
lastc_bytelen += (*mb_char2bytes)(cap->ncharC2,
|
||||
lastc_bytes + lastc_bytelen);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else /* repeat previous search */
|
||||
{
|
||||
if (*lastc == NUL
|
||||
#ifdef FEAT_MBYTE
|
||||
&& lastc_bytelen == 1
|
||||
#endif
|
||||
)
|
||||
if (*lastc == NUL && lastc_bytelen == 1)
|
||||
return FAIL;
|
||||
if (dir) /* repeat in opposite direction */
|
||||
dir = -lastcdir;
|
||||
@ -1758,7 +1725,6 @@ searchc(cmdarg_T *cap, int t_cmd)
|
||||
|
||||
while (count--)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
for (;;)
|
||||
@ -1787,7 +1753,6 @@ searchc(cmdarg_T *cap, int t_cmd)
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
@ -1804,7 +1769,6 @@ searchc(cmdarg_T *cap, int t_cmd)
|
||||
{
|
||||
/* backup to before the character (possibly double-byte) */
|
||||
col -= dir;
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
if (dir < 0)
|
||||
@ -1814,7 +1778,6 @@ searchc(cmdarg_T *cap, int t_cmd)
|
||||
/* To previous char, which may be multi-byte. */
|
||||
col -= (*mb_head_off)(p, p + col);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
curwin->w_cursor.col = col;
|
||||
|
||||
@ -1851,10 +1814,8 @@ check_prevcol(
|
||||
int *prevcol)
|
||||
{
|
||||
--col;
|
||||
#ifdef FEAT_MBYTE
|
||||
if (col > 0 && has_mbyte)
|
||||
col -= (*mb_head_off)(linep, linep + col);
|
||||
#endif
|
||||
if (prevcol)
|
||||
*prevcol = col;
|
||||
return (col >= 0 && linep[col] == ch) ? TRUE : FALSE;
|
||||
@ -2237,10 +2198,8 @@ findmatchlimit(
|
||||
else
|
||||
{
|
||||
--pos.col;
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
pos.col -= (*mb_head_off)(linep, linep + pos.col);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else /* forward search */
|
||||
@ -2278,11 +2237,9 @@ findmatchlimit(
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
pos.col += (*mb_ptr2len)(linep + pos.col);
|
||||
else
|
||||
#endif
|
||||
++pos.col;
|
||||
}
|
||||
}
|
||||
@ -2934,10 +2891,8 @@ findpar(
|
||||
if ((curwin->w_cursor.col = (colnr_T)STRLEN(line)) != 0)
|
||||
{
|
||||
--curwin->w_cursor.col;
|
||||
#ifdef FEAT_MBYTE
|
||||
curwin->w_cursor.col -=
|
||||
(*mb_head_off)(line, line + curwin->w_cursor.col);
|
||||
#endif
|
||||
*pincl = TRUE;
|
||||
}
|
||||
}
|
||||
@ -3029,7 +2984,6 @@ cls(void)
|
||||
#endif
|
||||
if (c == ' ' || c == '\t' || c == NUL)
|
||||
return 0;
|
||||
#ifdef FEAT_MBYTE
|
||||
if (enc_dbcs != 0 && c > 0xFF)
|
||||
{
|
||||
/* If cls_bigword, report multi-byte chars as class 1. */
|
||||
@ -3046,7 +3000,6 @@ cls(void)
|
||||
return 1;
|
||||
return c;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* If cls_bigword is TRUE, report all non-blanks as class 1. */
|
||||
if (cls_bigword)
|
||||
@ -3903,7 +3856,6 @@ in_html_tag(
|
||||
int lc = NUL;
|
||||
pos_T pos;
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
if (enc_dbcs)
|
||||
{
|
||||
char_u *lp = NULL;
|
||||
@ -3924,7 +3876,6 @@ in_html_tag(
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
for (p = line + curwin->w_cursor.col; p > line; )
|
||||
{
|
||||
@ -4371,11 +4322,9 @@ find_next_quote(
|
||||
++col;
|
||||
else if (c == quotechar)
|
||||
break;
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
col += (*mb_ptr2len)(line + col);
|
||||
else
|
||||
#endif
|
||||
++col;
|
||||
}
|
||||
return col;
|
||||
@ -4399,9 +4348,7 @@ find_prev_quote(
|
||||
while (col_start > 0)
|
||||
{
|
||||
--col_start;
|
||||
#ifdef FEAT_MBYTE
|
||||
col_start -= (*mb_head_off)(line, line + col_start);
|
||||
#endif
|
||||
n = 0;
|
||||
if (escape != NULL)
|
||||
while (col_start - n > 0 && vim_strchr(escape,
|
||||
|
||||
@ -820,7 +820,6 @@ sign_define_init_text(sign_T *sp, char_u *text)
|
||||
}
|
||||
|
||||
// Count cells and check for non-printable chars
|
||||
# ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
cells = 0;
|
||||
@ -832,7 +831,6 @@ sign_define_init_text(sign_T *sp, char_u *text)
|
||||
}
|
||||
}
|
||||
else
|
||||
# endif
|
||||
{
|
||||
for (s = text; s < endp; ++s)
|
||||
if (!vim_isprintc(*s))
|
||||
|
||||
177
src/spell.c
177
src/spell.c
@ -224,12 +224,8 @@ typedef struct matchinf_S
|
||||
affixID/condition */
|
||||
int mi_prefcnt; /* number of entries at mi_prefarridx */
|
||||
int mi_prefixlen; /* byte length of prefix */
|
||||
#ifdef FEAT_MBYTE
|
||||
int mi_cprefixlen; /* byte length of prefix in original
|
||||
case */
|
||||
#else
|
||||
# define mi_cprefixlen mi_prefixlen /* it's the same value */
|
||||
#endif
|
||||
|
||||
/* for when checking a compound word */
|
||||
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);
|
||||
#ifdef FEAT_MBYTE
|
||||
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:
|
||||
@ -295,12 +289,10 @@ typedef struct trystate_S
|
||||
char_u ts_prefixdepth; /* stack depth for end of prefix or
|
||||
* PFD_PREFIXTREE or PFD_NOPREFIX */
|
||||
char_u ts_flags; /* TSF_ flags */
|
||||
#ifdef FEAT_MBYTE
|
||||
char_u ts_tcharlen; /* number of bytes in tword character */
|
||||
char_u ts_tcharidx; /* current byte index in tword character */
|
||||
char_u ts_isdiff; /* DIFF_ values */
|
||||
char_u ts_fcharstart; /* index in fword where badword char started */
|
||||
#endif
|
||||
char_u ts_prewordlen; /* length of word in "preword[]" */
|
||||
char_u ts_splitoff; /* index in "tword" after last 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_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);
|
||||
#ifdef FEAT_MBYTE
|
||||
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 score_comp_sal(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 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);
|
||||
#ifdef FEAT_MBYTE
|
||||
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 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);
|
||||
#ifdef FEAT_MBYTE
|
||||
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 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);
|
||||
}
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
return (*mb_ptr2len)(ptr);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
else if (mi.mi_end == ptr)
|
||||
@ -646,9 +630,7 @@ find_word(matchinf_T *mip, int mode)
|
||||
int c;
|
||||
char_u *ptr;
|
||||
idx_T lo, hi, m;
|
||||
#ifdef FEAT_MBYTE
|
||||
char_u *s;
|
||||
#endif
|
||||
char_u *p;
|
||||
int res = SP_BAD;
|
||||
slang_T *slang = mip->mi_lp->lp_slang;
|
||||
@ -794,10 +776,8 @@ find_word(matchinf_T *mip, int mode)
|
||||
arridx = endidx[endidxcnt];
|
||||
wlen = endlen[endidxcnt];
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
if ((*mb_head_off)(ptr, ptr + wlen) > 0)
|
||||
continue; /* not at first byte of character */
|
||||
#endif
|
||||
if (spell_iswordp(ptr + wlen, mip->mi_win))
|
||||
{
|
||||
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. */
|
||||
prefix_found = FALSE;
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
if (mode != FIND_KEEPWORD && has_mbyte)
|
||||
{
|
||||
/* 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);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Check flags and region. For FIND_PREFIX check the condition and
|
||||
* prefix ID.
|
||||
@ -896,7 +874,6 @@ find_word(matchinf_T *mip, int mode)
|
||||
if (((unsigned)flags >> 24) == 0
|
||||
|| wlen - mip->mi_compoff < slang->sl_compminlen)
|
||||
continue;
|
||||
#ifdef FEAT_MBYTE
|
||||
/* For multi-byte chars check character length against
|
||||
* COMPOUNDMIN. */
|
||||
if (has_mbyte
|
||||
@ -904,7 +881,6 @@ find_word(matchinf_T *mip, int mode)
|
||||
&& mb_charlen_len(mip->mi_word + mip->mi_compoff,
|
||||
wlen - mip->mi_compoff) < slang->sl_compminlen)
|
||||
continue;
|
||||
#endif
|
||||
|
||||
/* Limit the number of compound words to COMPOUNDWORDMAX if no
|
||||
* 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
|
||||
* word. */
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte && STRNCMP(ptr, mip->mi_word,
|
||||
mip->mi_compoff) != 0)
|
||||
{
|
||||
@ -948,7 +923,6 @@ find_word(matchinf_T *mip, int mode)
|
||||
MB_PTR_ADV(p);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
p = mip->mi_word + mip->mi_compoff;
|
||||
capflags = captype(p, mip->mi_word + wlen);
|
||||
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. */
|
||||
mip->mi_compoff = endlen[endidxcnt];
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte && mode == FIND_KEEPWORD)
|
||||
{
|
||||
/* 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);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if 0 /* Disabled, see below */
|
||||
c = mip->mi_compoff;
|
||||
#endif
|
||||
@ -1186,15 +1158,12 @@ match_checkcompoundpattern(
|
||||
static int
|
||||
can_compound(slang_T *slang, char_u *word, char_u *flags)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
char_u uflags[MAXWLEN * 2];
|
||||
int i;
|
||||
#endif
|
||||
char_u *p;
|
||||
|
||||
if (slang->sl_compprog == NULL)
|
||||
return FALSE;
|
||||
#ifdef FEAT_MBYTE
|
||||
if (enc_utf8)
|
||||
{
|
||||
/* 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;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
p = flags;
|
||||
if (!vim_regexec_prog(&slang->sl_compprog, FALSE, p, 0))
|
||||
return FALSE;
|
||||
@ -1434,7 +1402,6 @@ find_prefix(matchinf_T *mip, int mode)
|
||||
/* Skip over the previously found word(s). */
|
||||
mip->mi_prefixlen += mip->mi_compoff;
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
/* Case-folded length may differ from original length. */
|
||||
@ -1443,7 +1410,6 @@ find_prefix(matchinf_T *mip, int mode)
|
||||
}
|
||||
else
|
||||
mip->mi_cprefixlen = mip->mi_prefixlen;
|
||||
#endif
|
||||
find_word(mip, FIND_PREFIX);
|
||||
|
||||
|
||||
@ -1912,10 +1878,8 @@ spell_load_lang(char_u *lang)
|
||||
spell_enc(void)
|
||||
{
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
if (STRLEN(p_enc) < 60 && STRCMP(p_enc, "iso-8859-15") != 0)
|
||||
return p_enc;
|
||||
#endif
|
||||
return (char_u *)"latin1";
|
||||
}
|
||||
|
||||
@ -2015,11 +1979,9 @@ slang_clear(slang_T *lp)
|
||||
vim_free(smp->sm_lead);
|
||||
/* Don't free sm_oneof and sm_rules, they point into sm_lead. */
|
||||
vim_free(smp->sm_to);
|
||||
#ifdef FEAT_MBYTE
|
||||
vim_free(smp->sm_lead_w);
|
||||
vim_free(smp->sm_oneof_w);
|
||||
vim_free(smp->sm_to_w);
|
||||
#endif
|
||||
}
|
||||
ga_clear(gap);
|
||||
|
||||
@ -2046,9 +2008,7 @@ slang_clear(slang_T *lp)
|
||||
hash_clear_all(&lp->sl_wordcount, WC_KEY_OFF);
|
||||
hash_init(&lp->sl_wordcount);
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
hash_clear_all(&lp->sl_map_hash, 0);
|
||||
#endif
|
||||
|
||||
/* Clear info from .sug file. */
|
||||
slang_clear_sug(lp);
|
||||
@ -2284,13 +2244,8 @@ count_syllables(slang_T *slang, char_u *word)
|
||||
else
|
||||
{
|
||||
/* No recognized syllable item, at least a syllable char then? */
|
||||
#ifdef FEAT_MBYTE
|
||||
c = mb_ptr2char(p);
|
||||
len = (*mb_ptr2len)(p);
|
||||
#else
|
||||
c = *p;
|
||||
len = 1;
|
||||
#endif
|
||||
if (vim_strchr(slang->sl_syllable, c) == NULL)
|
||||
skip = FALSE; /* No, search for next syllable */
|
||||
else if (!skip)
|
||||
@ -2352,9 +2307,7 @@ did_set_spelllang(win_T *wp)
|
||||
if (spl_copy == NULL)
|
||||
goto theend;
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
wp->w_s->b_cjk = 0;
|
||||
#endif
|
||||
|
||||
/* Loop over comma separated language names. */
|
||||
for (splp = spl_copy; *splp != NUL; )
|
||||
@ -2366,9 +2319,7 @@ did_set_spelllang(win_T *wp)
|
||||
|
||||
if (STRCMP(lang, "cjk") == 0)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
wp->w_s->b_cjk = 1;
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -2633,9 +2584,7 @@ theend:
|
||||
clear_midword(win_T *wp)
|
||||
{
|
||||
vim_memset(wp->w_s->b_spell_ismw, 0, 256);
|
||||
#ifdef FEAT_MBYTE
|
||||
VIM_CLEAR(wp->w_s->b_spell_ismw_mb);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
@ -2651,7 +2600,6 @@ use_midword(slang_T *lp, win_T *wp)
|
||||
return;
|
||||
|
||||
for (p = lp->sl_midword; *p != NUL; )
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
int c, l, n;
|
||||
@ -2679,7 +2627,6 @@ use_midword(slang_T *lp, win_T *wp)
|
||||
p += l;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
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))
|
||||
if (end == NULL ? *p == NUL : p >= end)
|
||||
return 0; /* only non-word characters, illegal word */
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
c = mb_ptr2char_adv(&p);
|
||||
else
|
||||
#endif
|
||||
c = *p++;
|
||||
firstcap = allcap = SPELL_ISUPPER(c);
|
||||
|
||||
@ -2825,7 +2770,6 @@ spell_delete_wordlist(void)
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(FEAT_MBYTE) || defined(EXITFREE) || defined(PROTO)
|
||||
/*
|
||||
* Free all languages.
|
||||
*/
|
||||
@ -2851,9 +2795,7 @@ spell_free_all(void)
|
||||
VIM_CLEAR(repl_to);
|
||||
VIM_CLEAR(repl_from);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(FEAT_MBYTE) || defined(PROTO)
|
||||
/*
|
||||
* Clear all spelling tables and reload them.
|
||||
* Used after 'encoding' is set and when ":mkspell" was used.
|
||||
@ -2884,7 +2826,6 @@ spell_reload(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Opposite of offset2bytes().
|
||||
@ -3016,7 +2957,6 @@ init_spell_chartab(void)
|
||||
|
||||
did_set_spelltab = FALSE;
|
||||
clear_spell_chartab(&spelltab);
|
||||
#ifdef FEAT_MBYTE
|
||||
if (enc_dbcs)
|
||||
{
|
||||
/* DBCS: assume double-wide characters are word characters. */
|
||||
@ -3041,7 +2981,6 @@ init_spell_chartab(void)
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
/* Rough guess: use locale-dependent library functions. */
|
||||
for (i = 128; i < 256; ++i)
|
||||
@ -3073,7 +3012,6 @@ spell_iswordp(
|
||||
char_u *p,
|
||||
win_T *wp) /* buffer used */
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
char_u *s;
|
||||
int l;
|
||||
int c;
|
||||
@ -3102,7 +3040,6 @@ spell_iswordp(
|
||||
return spell_mb_isword_class(mb_get_class(s), wp);
|
||||
return spelltab.st_isw[c];
|
||||
}
|
||||
#endif
|
||||
|
||||
return spelltab.st_isw[wp->w_s->b_spell_ismw[*p] ? p[1] : p[0]];
|
||||
}
|
||||
@ -3114,7 +3051,6 @@ spell_iswordp(
|
||||
int
|
||||
spell_iswordp_nmw(char_u *p, win_T *wp)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
int c;
|
||||
|
||||
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 spelltab.st_isw[c];
|
||||
}
|
||||
#endif
|
||||
return spelltab.st_isw[*p];
|
||||
}
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
/*
|
||||
* Return TRUE if word class indicates a word character.
|
||||
* Only for characters above 255.
|
||||
@ -3171,7 +3105,6 @@ spell_iswordp_w(int *p, win_T *wp)
|
||||
}
|
||||
return spelltab.st_isw[*s];
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Case-fold "str[len]" into "buf[buflen]". The result is NUL terminated.
|
||||
@ -3194,7 +3127,6 @@ spell_casefold(
|
||||
return FAIL; /* result will not fit */
|
||||
}
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
int outi = 0;
|
||||
@ -3215,7 +3147,6 @@ spell_casefold(
|
||||
buf[outi] = NUL;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
/* Be quick for non-multibyte encodings. */
|
||||
for (i = 0; i < len; ++i)
|
||||
@ -4072,21 +4003,17 @@ onecap_copy(
|
||||
int l;
|
||||
|
||||
p = word;
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
c = mb_cptr2char_adv(&p);
|
||||
else
|
||||
#endif
|
||||
c = *p++;
|
||||
if (upper)
|
||||
c = SPELL_TOUPPER(c);
|
||||
else
|
||||
c = SPELL_TOFOLD(c);
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
l = mb_char2bytes(c, wcopy);
|
||||
else
|
||||
#endif
|
||||
{
|
||||
l = 1;
|
||||
wcopy[0] = c;
|
||||
@ -4108,14 +4035,11 @@ allcap_copy(char_u *word, char_u *wcopy)
|
||||
d = wcopy;
|
||||
for (s = word; *s != NUL; )
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
c = mb_cptr2char_adv(&s);
|
||||
else
|
||||
#endif
|
||||
c = *s++;
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
/* We only change 0xdf to SS when we are certain latin1 is used. It
|
||||
* would cause weird errors in other 8-bit encodings. */
|
||||
if (enc_latin1like && c == 0xdf)
|
||||
@ -4126,10 +4050,8 @@ allcap_copy(char_u *word, char_u *wcopy)
|
||||
*d++ = c;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
c = SPELL_TOUPPER(c);
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
if (d - wcopy >= MAXWLEN - MB_MAXBYTES)
|
||||
@ -4137,7 +4059,6 @@ allcap_copy(char_u *word, char_u *wcopy)
|
||||
d += mb_char2bytes(c, d);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if (d - wcopy >= MAXWLEN - 1)
|
||||
break;
|
||||
@ -4434,11 +4355,9 @@ suggest_trie_walk(
|
||||
{
|
||||
/* Set su->su_badflags to the caps type at this position.
|
||||
* Use the caps type until here for the prefix itself. */
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
n = nofold_len(fword, sp->ts_fidx, su->su_badptr);
|
||||
else
|
||||
#endif
|
||||
n = sp->ts_fidx;
|
||||
flags = badword_captype(su->su_badptr, 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
|
||||
< slang->sl_compminlen)
|
||||
break;
|
||||
#ifdef FEAT_MBYTE
|
||||
/* For multi-byte chars check character length against
|
||||
* COMPOUNDMIN. */
|
||||
if (has_mbyte
|
||||
@ -4576,7 +4494,6 @@ suggest_trie_walk(
|
||||
&& mb_charlen(tword + sp->ts_splitoff)
|
||||
< slang->sl_compminlen)
|
||||
break;
|
||||
#endif
|
||||
|
||||
compflags[sp->ts_complen] = ((unsigned)flags >> 24);
|
||||
compflags[sp->ts_complen + 1] = NUL;
|
||||
@ -4625,12 +4542,7 @@ suggest_trie_walk(
|
||||
* allcap and it's only one char long use onecap. */
|
||||
c = su->su_badflags;
|
||||
if ((c & WF_ALLCAP)
|
||||
#ifdef FEAT_MBYTE
|
||||
&& su->su_badlen == (*mb_ptr2len)(su->su_badptr)
|
||||
#else
|
||||
&& su->su_badlen == 1
|
||||
#endif
|
||||
)
|
||||
&& su->su_badlen == (*mb_ptr2len)(su->su_badptr))
|
||||
c = WF_ONECAP;
|
||||
c |= flags;
|
||||
|
||||
@ -4752,11 +4664,8 @@ suggest_trie_walk(
|
||||
* Try word split and/or compounding.
|
||||
*/
|
||||
if ((sp->ts_fidx >= sp->ts_fidxtry || fword_ends)
|
||||
#ifdef FEAT_MBYTE
|
||||
/* Don't split halfway a character. */
|
||||
&& (!has_mbyte || sp->ts_tcharlen == 0)
|
||||
#endif
|
||||
)
|
||||
&& (!has_mbyte || sp->ts_tcharlen == 0))
|
||||
{
|
||||
int try_compound;
|
||||
int try_split;
|
||||
@ -4789,12 +4698,10 @@ suggest_trie_walk(
|
||||
&& ((unsigned)flags >> 24) != 0
|
||||
&& sp->ts_twordlen - sp->ts_splitoff
|
||||
>= slang->sl_compminlen
|
||||
#ifdef FEAT_MBYTE
|
||||
&& (!has_mbyte
|
||||
|| slang->sl_compminlen == 0
|
||||
|| mb_charlen(tword + sp->ts_splitoff)
|
||||
>= slang->sl_compminlen)
|
||||
#endif
|
||||
&& (slang->sl_compsylmax < MAXWLEN
|
||||
|| sp->ts_complen + 1 - sp->ts_compsplit
|
||||
< slang->sl_compmax)
|
||||
@ -4921,11 +4828,9 @@ suggest_trie_walk(
|
||||
|
||||
/* set su->su_badflags to the caps type at this
|
||||
* position */
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
n = nofold_len(fword, sp->ts_fidx, su->su_badptr);
|
||||
else
|
||||
#endif
|
||||
n = sp->ts_fidx;
|
||||
su->su_badflags = badword_captype(su->su_badptr + n,
|
||||
su->su_badptr + su->su_badlen);
|
||||
@ -4963,11 +4868,7 @@ suggest_trie_walk(
|
||||
case STATE_ENDNUL:
|
||||
/* Past the NUL bytes in the node. */
|
||||
su->su_badflags = sp->ts_save_badflags;
|
||||
if (fword[sp->ts_fidx] == NUL
|
||||
#ifdef FEAT_MBYTE
|
||||
&& sp->ts_tcharlen == 0
|
||||
#endif
|
||||
)
|
||||
if (fword[sp->ts_fidx] == NUL && sp->ts_tcharlen == 0)
|
||||
{
|
||||
/* The badword ends, can't use STATE_PLAIN. */
|
||||
PROF_STORE(sp->ts_state)
|
||||
@ -5005,10 +4906,7 @@ suggest_trie_walk(
|
||||
* just deleted this byte, accepting it is always cheaper than
|
||||
* delete + substitute. */
|
||||
if (c == fword[sp->ts_fidx]
|
||||
#ifdef FEAT_MBYTE
|
||||
|| (sp->ts_tcharlen > 0 && sp->ts_isdiff != DIFF_NONE)
|
||||
#endif
|
||||
)
|
||||
|| (sp->ts_tcharlen > 0 && sp->ts_isdiff != DIFF_NONE))
|
||||
newscore = 0;
|
||||
else
|
||||
newscore = SCORE_SUBST;
|
||||
@ -5034,7 +4932,6 @@ suggest_trie_walk(
|
||||
++sp->ts_fidx;
|
||||
tword[sp->ts_twordlen++] = c;
|
||||
sp->ts_arridx = idxs[arridx];
|
||||
#ifdef FEAT_MBYTE
|
||||
if (newscore == SCORE_SUBST)
|
||||
sp->ts_isdiff = DIFF_YES;
|
||||
if (has_mbyte)
|
||||
@ -5122,7 +5019,6 @@ suggest_trie_walk(
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
/* If we found a similar char adjust the score.
|
||||
* We do this after calling go_deeper() because
|
||||
@ -5139,7 +5035,6 @@ suggest_trie_walk(
|
||||
break;
|
||||
|
||||
case STATE_DEL:
|
||||
#ifdef FEAT_MBYTE
|
||||
/* When past the first byte of a multi-byte char don't try
|
||||
* delete/insert/swap a character. */
|
||||
if (has_mbyte && sp->ts_tcharlen > 0)
|
||||
@ -5148,7 +5043,6 @@ suggest_trie_walk(
|
||||
sp->ts_state = STATE_FINAL;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
* 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
|
||||
* a bit illogical for soundfold tree but it does give better
|
||||
* results. */
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
c = mb_ptr2char(fword + sp->ts_fidx);
|
||||
@ -5192,7 +5085,6 @@ suggest_trie_walk(
|
||||
stack[depth].ts_score -= SCORE_DEL - SCORE_DELDUP;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
++stack[depth].ts_fidx;
|
||||
if (fword[sp->ts_fidx] == fword[sp->ts_fidx + 1])
|
||||
@ -5274,7 +5166,6 @@ suggest_trie_walk(
|
||||
sp = &stack[depth];
|
||||
tword[sp->ts_twordlen++] = c;
|
||||
sp->ts_arridx = idxs[n];
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
fl = MB_BYTE2LEN(c);
|
||||
@ -5291,7 +5182,6 @@ suggest_trie_walk(
|
||||
else
|
||||
fl = 1;
|
||||
if (fl == 1)
|
||||
#endif
|
||||
{
|
||||
/* If the previous character was the same, thus doubling a
|
||||
* character, give a bonus to the score. Also for
|
||||
@ -5329,7 +5219,6 @@ suggest_trie_walk(
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
n = MB_CPTR2LEN(p);
|
||||
@ -5342,7 +5231,6 @@ suggest_trie_walk(
|
||||
c2 = mb_ptr2char(p + n);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if (p[1] == NUL)
|
||||
c2 = NUL;
|
||||
@ -5379,7 +5267,6 @@ suggest_trie_walk(
|
||||
PROF_STORE(sp->ts_state)
|
||||
sp->ts_state = STATE_UNSWAP;
|
||||
++depth;
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
fl = mb_char2len(c2);
|
||||
@ -5388,7 +5275,6 @@ suggest_trie_walk(
|
||||
stack[depth].ts_fidxtry = sp->ts_fidx + n + fl;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
p[0] = c2;
|
||||
p[1] = c;
|
||||
@ -5406,7 +5292,6 @@ suggest_trie_walk(
|
||||
case STATE_UNSWAP:
|
||||
/* Undo the STATE_SWAP swap: "21" -> "12". */
|
||||
p = fword + sp->ts_fidx;
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
n = MB_PTR2LEN(p);
|
||||
@ -5415,7 +5300,6 @@ suggest_trie_walk(
|
||||
mb_char2bytes(c, p);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
c = *p;
|
||||
*p = p[1];
|
||||
@ -5427,7 +5311,6 @@ suggest_trie_walk(
|
||||
/* Swap two bytes, skipping one: "123" -> "321". We change
|
||||
* "fword" here, it's changed back afterwards at STATE_UNSWAP3. */
|
||||
p = fword + sp->ts_fidx;
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
n = MB_CPTR2LEN(p);
|
||||
@ -5440,7 +5323,6 @@ suggest_trie_walk(
|
||||
c3 = mb_ptr2char(p + n + fl);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
c = *p;
|
||||
c2 = p[1];
|
||||
@ -5473,7 +5355,6 @@ suggest_trie_walk(
|
||||
PROF_STORE(sp->ts_state)
|
||||
sp->ts_state = STATE_UNSWAP3;
|
||||
++depth;
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
tl = mb_char2len(c3);
|
||||
@ -5483,7 +5364,6 @@ suggest_trie_walk(
|
||||
stack[depth].ts_fidxtry = sp->ts_fidx + n + fl + tl;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
p[0] = p[2];
|
||||
p[2] = c;
|
||||
@ -5500,7 +5380,6 @@ suggest_trie_walk(
|
||||
case STATE_UNSWAP3:
|
||||
/* Undo STATE_SWAP3: "321" -> "123" */
|
||||
p = fword + sp->ts_fidx;
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
n = MB_PTR2LEN(p);
|
||||
@ -5514,7 +5393,6 @@ suggest_trie_walk(
|
||||
p = p + tl;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
c = *p;
|
||||
*p = p[2];
|
||||
@ -5546,7 +5424,6 @@ suggest_trie_walk(
|
||||
sp->ts_state = STATE_UNROT3L;
|
||||
++depth;
|
||||
p = fword + sp->ts_fidx;
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
n = MB_CPTR2LEN(p);
|
||||
@ -5558,7 +5435,6 @@ suggest_trie_walk(
|
||||
stack[depth].ts_fidxtry = sp->ts_fidx + n + fl;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
c = *p;
|
||||
*p = p[1];
|
||||
@ -5577,7 +5453,6 @@ suggest_trie_walk(
|
||||
case STATE_UNROT3L:
|
||||
/* Undo ROT3L: "231" -> "123" */
|
||||
p = fword + sp->ts_fidx;
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
n = MB_PTR2LEN(p);
|
||||
@ -5588,7 +5463,6 @@ suggest_trie_walk(
|
||||
mb_char2bytes(c, p);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
c = p[2];
|
||||
p[2] = p[1];
|
||||
@ -5611,7 +5485,6 @@ suggest_trie_walk(
|
||||
sp->ts_state = STATE_UNROT3R;
|
||||
++depth;
|
||||
p = fword + sp->ts_fidx;
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
n = MB_CPTR2LEN(p);
|
||||
@ -5623,7 +5496,6 @@ suggest_trie_walk(
|
||||
stack[depth].ts_fidxtry = sp->ts_fidx + n + tl;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
c = p[2];
|
||||
p[2] = p[1];
|
||||
@ -5642,7 +5514,6 @@ suggest_trie_walk(
|
||||
case STATE_UNROT3R:
|
||||
/* Undo ROT3R: "312" -> "123" */
|
||||
p = fword + sp->ts_fidx;
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
c = mb_ptr2char(p);
|
||||
@ -5653,7 +5524,6 @@ suggest_trie_walk(
|
||||
mb_char2bytes(c, p + n);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
c = *p;
|
||||
*p = p[1];
|
||||
@ -5738,9 +5608,7 @@ suggest_trie_walk(
|
||||
}
|
||||
mch_memmove(p, ftp->ft_to, tl);
|
||||
stack[depth].ts_fidxtry = sp->ts_fidx + tl;
|
||||
#ifdef FEAT_MBYTE
|
||||
stack[depth].ts_tcharlen = 0;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -5809,7 +5677,6 @@ go_deeper(trystate_T *stack, int depth, int score_add)
|
||||
stack[depth + 1].ts_flags = 0;
|
||||
}
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
/*
|
||||
* 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".
|
||||
@ -5826,7 +5693,6 @@ nofold_len(char_u *fword, int flen, char_u *word)
|
||||
--i;
|
||||
return (int)(p - word);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* "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] == 2: Try using the upper-case character.
|
||||
*/
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
flen = MB_CPTR2LEN(fword + fwordidx[depth]);
|
||||
ulen = MB_CPTR2LEN(uword + uwordidx[depth]);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
ulen = flen = 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)
|
||||
{
|
||||
int m1, m2;
|
||||
#ifdef FEAT_MBYTE
|
||||
char_u buf[MB_MAXBYTES + 1];
|
||||
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);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
m1 = slang->sl_map_array[c1];
|
||||
if (m1 == 0)
|
||||
return FALSE;
|
||||
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
if (c2 >= 256)
|
||||
{
|
||||
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);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
m2 = slang->sl_map_array[c2];
|
||||
|
||||
return m1 == m2;
|
||||
@ -6700,15 +6560,12 @@ add_suggestion(
|
||||
break;
|
||||
MB_PTR_BACK(goodword, pgood);
|
||||
MB_PTR_BACK(su->su_badptr, pbad);
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
if (mb_ptr2char(pgood) != mb_ptr2char(pbad))
|
||||
break;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (*pgood != *pbad)
|
||||
else if (*pgood != *pbad)
|
||||
break;
|
||||
}
|
||||
|
||||
@ -7028,11 +6885,9 @@ spell_soundfold(
|
||||
word = fword;
|
||||
}
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
spell_soundfold_wsal(slang, word, res);
|
||||
else
|
||||
#endif
|
||||
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 c;
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
int prevc = 0;
|
||||
@ -7095,7 +6949,6 @@ spell_soundfold_sofo(slang_T *slang, char_u *inword, char_u *res)
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
/* The sl_sal_first[] table contains the translation. */
|
||||
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;
|
||||
}
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
/*
|
||||
* Turn "inword" into its sound-a-like equivalent in "res[MAXWLEN]".
|
||||
* 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;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Compute a score for two sound-a-like words.
|
||||
@ -7953,7 +7804,6 @@ spell_edit_score(
|
||||
int t;
|
||||
int bc, gc;
|
||||
int pbc, pgc;
|
||||
#ifdef FEAT_MBYTE
|
||||
char_u *p;
|
||||
int wbadword[MAXWLEN];
|
||||
int wgoodword[MAXWLEN];
|
||||
@ -7970,7 +7820,6 @@ spell_edit_score(
|
||||
wgoodword[goodlen++] = 0;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
badlen = (int)STRLEN(badword) + 1;
|
||||
goodlen = (int)STRLEN(goodword) + 1;
|
||||
@ -7992,14 +7841,12 @@ spell_edit_score(
|
||||
CNT(i, 0) = CNT(i - 1, 0) + SCORE_DEL;
|
||||
for (j = 1; j <= goodlen; ++j)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
bc = wbadword[i - 1];
|
||||
gc = wgoodword[j - 1];
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
bc = badword[i - 1];
|
||||
gc = goodword[j - 1];
|
||||
@ -8024,14 +7871,12 @@ spell_edit_score(
|
||||
|
||||
if (i > 1 && j > 1)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
pbc = wbadword[i - 2];
|
||||
pgc = wgoodword[j - 2];
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
pbc = badword[i - 2];
|
||||
pgc = goodword[j - 2];
|
||||
@ -8090,12 +7935,10 @@ spell_edit_score_limit(
|
||||
int minscore;
|
||||
int round;
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
/* Multi-byte characters require a bit more work, use a different function
|
||||
* to avoid testing "has_mbyte" quite often. */
|
||||
if (has_mbyte)
|
||||
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
|
||||
@ -8250,7 +8093,6 @@ pop:
|
||||
return minscore;
|
||||
}
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
/*
|
||||
* Multi-byte version of spell_edit_score_limit().
|
||||
* Keep it in sync with the above!
|
||||
@ -8439,7 +8281,6 @@ pop:
|
||||
return SCORE_MAXMAX;
|
||||
return minscore;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* ":spellinfo"
|
||||
@ -8554,13 +8395,7 @@ spell_dump_compl(
|
||||
n = captype(pat, NULL);
|
||||
if (n == WF_ONECAP)
|
||||
dumpflags |= DUMPFLAG_ONECAP;
|
||||
else if (n == WF_ALLCAP
|
||||
#ifdef FEAT_MBYTE
|
||||
&& (int)STRLEN(pat) > mb_ptr2len(pat)
|
||||
#else
|
||||
&& (int)STRLEN(pat) > 1
|
||||
#endif
|
||||
)
|
||||
else if (n == WF_ALLCAP && (int)STRLEN(pat) > mb_ptr2len(pat))
|
||||
dumpflags |= DUMPFLAG_ALLCAP;
|
||||
}
|
||||
}
|
||||
|
||||
17
src/spell.h
17
src/spell.h
@ -44,11 +44,7 @@ typedef int idx_T;
|
||||
typedef long idx_T;
|
||||
#endif
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
typedef int salfirst_T;
|
||||
#else
|
||||
typedef short salfirst_T;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Structure used to store words and other info for one language, loaded from
|
||||
@ -132,12 +128,8 @@ struct slang_S
|
||||
load */
|
||||
|
||||
int sl_has_map; /* TRUE if there is a MAP line */
|
||||
#ifdef FEAT_MBYTE
|
||||
hashtab_T sl_map_hash; /* MAP for multi-byte 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
|
||||
handled, see add_sound_suggest() */
|
||||
};
|
||||
@ -213,11 +205,9 @@ typedef struct salitem_S
|
||||
char_u *sm_oneof; /* letters from () or NULL */
|
||||
char_u *sm_rules; /* rules like ^, $, priority */
|
||||
char_u *sm_to; /* replacement. */
|
||||
#ifdef FEAT_MBYTE
|
||||
int *sm_lead_w; /* wide character copy of "sm_lead" */
|
||||
int *sm_oneof_w; /* wide character copy of "sm_oneof" */
|
||||
int *sm_to_w; /* wide character copy of "sm_to" */
|
||||
#endif
|
||||
} salitem_T;
|
||||
|
||||
/* Values for SP_*ERROR are negative, positive values are used by
|
||||
@ -260,12 +250,6 @@ typedef struct spelltab_S
|
||||
* differ from what the .spl file uses.
|
||||
* These must not be called with negative number!
|
||||
*/
|
||||
#ifndef FEAT_MBYTE
|
||||
/* 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() */
|
||||
#endif
|
||||
@ -295,7 +279,6 @@ typedef struct spelltab_S
|
||||
# define SPELL_ISUPPER(c) (enc_utf8 && (c) >= 128 ? utf_isupper(c) \
|
||||
: (c) < 256 ? spelltab.st_isu[c] : (FALSE))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef FEAT_SPELL
|
||||
/* First language that is loaded, start of the linked list of loaded
|
||||
|
||||
@ -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 set_sofo(slang_T *lp, char_u *from, char_u *to);
|
||||
static void set_sal_first(slang_T *lp);
|
||||
#ifdef FEAT_MBYTE
|
||||
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 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);
|
||||
@ -1062,7 +1060,6 @@ read_sal_section(FILE *fd, slang_T *slang)
|
||||
return ccnt;
|
||||
}
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
/* convert the multi-byte strings to wide char strings */
|
||||
@ -1088,7 +1085,6 @@ read_sal_section(FILE *fd, slang_T *slang)
|
||||
return SP_OTHERERROR;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (gap->ga_len > 0)
|
||||
@ -1104,7 +1100,6 @@ read_sal_section(FILE *fd, slang_T *slang)
|
||||
smp->sm_oneof = NULL;
|
||||
smp->sm_rules = p;
|
||||
smp->sm_to = NULL;
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
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_to_w = NULL;
|
||||
}
|
||||
#endif
|
||||
++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.
|
||||
* Conversion to utf-8 may double the size. */
|
||||
c = todo * 2 + 7;
|
||||
#ifdef FEAT_MBYTE
|
||||
if (enc_utf8)
|
||||
c += todo * 2;
|
||||
#endif
|
||||
pat = alloc((unsigned)c);
|
||||
if (pat == NULL)
|
||||
return SP_OTHERERROR;
|
||||
@ -1367,11 +1359,9 @@ read_compound(FILE *fd, slang_T *slang, int len)
|
||||
{
|
||||
if (c == '?' || c == '+' || c == '~')
|
||||
*pp++ = '\\'; /* "a?" becomes "a\?", "a+" becomes "a\+" */
|
||||
#ifdef FEAT_MBYTE
|
||||
if (enc_utf8)
|
||||
pp += mb_char2bytes(c, pp);
|
||||
else
|
||||
#endif
|
||||
*pp++ = c;
|
||||
}
|
||||
}
|
||||
@ -1401,7 +1391,6 @@ set_sofo(slang_T *lp, char_u *from, char_u *to)
|
||||
{
|
||||
int i;
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
garray_T *gap;
|
||||
char_u *s;
|
||||
char_u *p;
|
||||
@ -1468,7 +1457,6 @@ set_sofo(slang_T *lp, char_u *from, char_u *to)
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
/* mapping bytes to bytes is done in sl_sal_first[] */
|
||||
if (STRLEN(from) != STRLEN(to))
|
||||
@ -1500,19 +1488,16 @@ set_sal_first(slang_T *lp)
|
||||
smp = (salitem_T *)gap->ga_data;
|
||||
for (i = 0; i < gap->ga_len; ++i)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
/* Use the lowest byte of the first character. For latin1 it's
|
||||
* the character, for other encodings it should differ for most
|
||||
* characters. */
|
||||
c = *smp[i].sm_lead_w & 0xff;
|
||||
else
|
||||
#endif
|
||||
c = *smp[i].sm_lead;
|
||||
if (sfirst[c] == -1)
|
||||
{
|
||||
sfirst[c] = i;
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
int n;
|
||||
@ -1540,12 +1525,10 @@ set_sal_first(slang_T *lp)
|
||||
smp[i] = tsal;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
/*
|
||||
* Turn a multi-byte string into a wide character string.
|
||||
* Return it in allocated memory (NULL for out-of-memory)
|
||||
@ -1566,7 +1549,6 @@ mb_str2wide(char_u *s)
|
||||
}
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Read a tree from the .spl or .sug file.
|
||||
@ -1820,11 +1802,7 @@ struct affentry_S
|
||||
char ae_comppermit; /* COMPOUNDPERMITFLAG found */
|
||||
};
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
#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. */
|
||||
typedef struct affheader_S
|
||||
@ -2271,7 +2249,6 @@ spell_read_aff(spellinfo_T *spin, char_u *fname)
|
||||
|
||||
/* Convert from "SET" to 'encoding' when needed. */
|
||||
vim_free(pc);
|
||||
#ifdef FEAT_MBYTE
|
||||
if (spin->si_conv.vc_type != CONV_NONE)
|
||||
{
|
||||
pc = string_convert(&spin->si_conv, rline, NULL);
|
||||
@ -2284,7 +2261,6 @@ spell_read_aff(spellinfo_T *spin, char_u *fname)
|
||||
line = pc;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
pc = NULL;
|
||||
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)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
/* Setup for conversion from "ENC" to 'encoding'. */
|
||||
aff->af_enc = enc_canonize(items[1]);
|
||||
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"),
|
||||
fname, aff->af_enc, p_enc);
|
||||
spin->si_conv.vc_fail = TRUE;
|
||||
#else
|
||||
smsg(_("Conversion in %s not supported"), fname);
|
||||
#endif
|
||||
}
|
||||
else if (is_aff_rule(items, itemcnt, "FLAG", 2)
|
||||
&& 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. */
|
||||
if (aff_entry->ae_chop != NULL
|
||||
&& aff_entry->ae_add != NULL
|
||||
#ifdef FEAT_MBYTE
|
||||
&& aff_entry->ae_chop[(*mb_ptr2len)(
|
||||
aff_entry->ae_chop)] == NUL
|
||||
#else
|
||||
&& aff_entry->ae_chop[1] == NUL
|
||||
#endif
|
||||
)
|
||||
aff_entry->ae_chop)] == NUL)
|
||||
{
|
||||
int c, c_up;
|
||||
|
||||
@ -2803,7 +2770,7 @@ spell_read_aff(spellinfo_T *spin, char_u *fname)
|
||||
if (aff_entry->ae_cond != NULL)
|
||||
{
|
||||
char_u buf[MAXLINELEN];
|
||||
#ifdef FEAT_MBYTE
|
||||
|
||||
if (has_mbyte)
|
||||
{
|
||||
onecap_copy(items[4], buf, TRUE);
|
||||
@ -2811,7 +2778,6 @@ spell_read_aff(spellinfo_T *spin, char_u *fname)
|
||||
spin, buf);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
*aff_entry->ae_cond = c_up;
|
||||
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. */
|
||||
for (p = items[1]; *p != NUL; )
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
c = mb_ptr2char_adv(&p);
|
||||
#else
|
||||
c = *p++;
|
||||
#endif
|
||||
if ((spin->si_map.ga_len > 0
|
||||
&& vim_strchr(spin->si_map.ga_data, c)
|
||||
!= 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
|
||||
* mb_get_class(), the list of chars in the file will be incomplete.
|
||||
*/
|
||||
if (!spin->si_ascii
|
||||
#ifdef FEAT_MBYTE
|
||||
&& !enc_utf8
|
||||
#endif
|
||||
)
|
||||
if (!spin->si_ascii && !enc_utf8)
|
||||
{
|
||||
if (fol == NULL || low == NULL || upp == NULL)
|
||||
smsg(_("Missing FOL/LOW/UPP line in %s"), fname);
|
||||
@ -3243,21 +3201,13 @@ get_affitem(int flagtype, char_u **pp)
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
res = mb_ptr2char_adv(pp);
|
||||
#else
|
||||
res = *(*pp)++;
|
||||
#endif
|
||||
if (flagtype == AFT_LONG || (flagtype == AFT_CAPLONG
|
||||
&& res >= 'A' && res <= 'Z'))
|
||||
{
|
||||
if (**pp == NUL)
|
||||
return 0;
|
||||
#ifdef FEAT_MBYTE
|
||||
res = mb_ptr2char_adv(pp) + (res << 16);
|
||||
#else
|
||||
res = *(*pp)++ + (res << 16);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
return res;
|
||||
@ -3381,18 +3331,10 @@ flag_in_afflist(int flagtype, char_u *afflist, unsigned flag)
|
||||
case AFT_LONG:
|
||||
for (p = afflist; *p != NUL; )
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
n = mb_ptr2char_adv(&p);
|
||||
#else
|
||||
n = *p++;
|
||||
#endif
|
||||
if ((flagtype == AFT_LONG || (n >= 'A' && n <= 'Z'))
|
||||
&& *p != NUL)
|
||||
#ifdef FEAT_MBYTE
|
||||
n = mb_ptr2char_adv(&p) + (n << 16);
|
||||
#else
|
||||
n = *p++ + (n << 16);
|
||||
#endif
|
||||
if (n == flag)
|
||||
return TRUE;
|
||||
}
|
||||
@ -3589,7 +3531,6 @@ spell_read_dic(spellinfo_T *spin, char_u *fname, afffile_T *affile)
|
||||
continue; /* empty line */
|
||||
line[l] = NUL;
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
/* Convert from "SET" to 'encoding' when needed. */
|
||||
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;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
pc = NULL;
|
||||
w = line;
|
||||
@ -3930,7 +3870,6 @@ store_aff_word(
|
||||
if (ae->ae_chop != NULL)
|
||||
{
|
||||
/* Skip chop string. */
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
i = mb_charlen(ae->ae_chop);
|
||||
@ -3938,7 +3877,6 @@ store_aff_word(
|
||||
MB_PTR_ADV(p);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
p += STRLEN(ae->ae_chop);
|
||||
}
|
||||
STRCAT(newword, p);
|
||||
@ -4162,7 +4100,6 @@ spell_read_wordfile(spellinfo_T *spin, char_u *fname)
|
||||
|
||||
/* Convert from "/encoding={encoding}" to 'encoding' when needed. */
|
||||
vim_free(pc);
|
||||
#ifdef FEAT_MBYTE
|
||||
if (spin->si_conv.vc_type != CONV_NONE)
|
||||
{
|
||||
pc = string_convert(&spin->si_conv, rline, NULL);
|
||||
@ -4175,7 +4112,6 @@ spell_read_wordfile(spellinfo_T *spin, char_u *fname)
|
||||
line = pc;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
pc = NULL;
|
||||
line = rline;
|
||||
@ -4194,7 +4130,6 @@ spell_read_wordfile(spellinfo_T *spin, char_u *fname)
|
||||
fname, lnum, line - 1);
|
||||
else
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
char_u *enc;
|
||||
|
||||
/* Setup for conversion to 'encoding'. */
|
||||
@ -4207,9 +4142,6 @@ spell_read_wordfile(spellinfo_T *spin, char_u *fname)
|
||||
fname, line, p_enc);
|
||||
vim_free(enc);
|
||||
spin->si_conv.vc_fail = TRUE;
|
||||
#else
|
||||
smsg(_("Conversion in %s not supported"), fname);
|
||||
#endif
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@ -4981,11 +4913,9 @@ write_vim_spell(spellinfo_T *spin, char_u *fname)
|
||||
l = 0;
|
||||
for (i = 128; i < 256; ++i)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
l += mb_char2bytes(spelltab.st_fold[i], folchars + l);
|
||||
else
|
||||
#endif
|
||||
folchars[l++] = spelltab.st_fold[i];
|
||||
}
|
||||
put_bytes(fd, (long_u)(1 + 128 + 2 + l), 4); /* <sectionlen> */
|
||||
@ -6112,10 +6042,8 @@ mkspell(
|
||||
error = TRUE;
|
||||
}
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
/* Free any conversion stuff. */
|
||||
convert_setup(&spin.si_conv, NULL, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
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));
|
||||
return FAIL;
|
||||
}
|
||||
#ifdef FEAT_MBYTE
|
||||
f = mb_ptr2char_adv(&pf);
|
||||
l = mb_ptr2char_adv(&pl);
|
||||
u = mb_ptr2char_adv(&pu);
|
||||
#else
|
||||
f = *pf++;
|
||||
l = *pl++;
|
||||
u = *pu++;
|
||||
#endif
|
||||
|
||||
/* Every character that appears is a word character. */
|
||||
if (f < 256)
|
||||
new_st.st_isw[f] = TRUE;
|
||||
@ -6570,11 +6493,7 @@ set_spell_charflags(
|
||||
|
||||
if (*p != NUL)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
c = mb_ptr2char_adv(&p);
|
||||
#else
|
||||
c = *p++;
|
||||
#endif
|
||||
new_st.st_fold[i + 128] = c;
|
||||
if (i + 128 != c && new_st.st_isu[i + 128] && c < 256)
|
||||
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. */
|
||||
for (i = 0; i < 256; ++i)
|
||||
lp->sl_map_array[i] = 0;
|
||||
#ifdef FEAT_MBYTE
|
||||
hash_init(&lp->sl_map_hash);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 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; )
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
c = mb_cptr2char_adv(&p);
|
||||
#else
|
||||
c = *p++;
|
||||
#endif
|
||||
if (c == '/')
|
||||
headc = 0;
|
||||
else
|
||||
@ -6698,7 +6611,6 @@ set_map_str(slang_T *lp, char_u *map)
|
||||
if (headc == 0)
|
||||
headc = c;
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
/* 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
|
||||
* a NUL. */
|
||||
@ -6730,7 +6642,6 @@ set_map_str(slang_T *lp, char_u *map)
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
lp->sl_map_array[c] = headc;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1103,9 +1103,7 @@ typedef struct
|
||||
{
|
||||
char_u *vir_line; /* text of the current line */
|
||||
FILE *vir_fd; /* file descriptor */
|
||||
#ifdef FEAT_MBYTE
|
||||
vimconv_T vir_conv; /* encoding conversion */
|
||||
#endif
|
||||
int vir_version; /* viminfo version detected or -1 */
|
||||
garray_T vir_barlines; /* lines starting with | */
|
||||
} vir_T;
|
||||
@ -2013,17 +2011,13 @@ typedef struct {
|
||||
/* for spell checking */
|
||||
garray_T b_langp; /* list of pointers to slang_T, see spell.c */
|
||||
char_u b_spell_ismw[256];/* flags: is midword char */
|
||||
# ifdef FEAT_MBYTE
|
||||
char_u *b_spell_ismw_mb; /* multi-byte midword chars */
|
||||
# endif
|
||||
char_u *b_p_spc; /* 'spellcapcheck' */
|
||||
regprog_T *b_cap_prog; /* program for 'spellcapcheck' */
|
||||
char_u *b_p_spf; /* 'spellfile' */
|
||||
char_u *b_p_spl; /* 'spelllang' */
|
||||
# ifdef FEAT_MBYTE
|
||||
int b_cjk; /* all CJK letters as OK */
|
||||
#endif
|
||||
#endif
|
||||
#if !defined(FEAT_SYN_HL) && !defined(FEAT_SPELL)
|
||||
int dummy;
|
||||
#endif
|
||||
@ -2233,9 +2227,7 @@ struct file_buffer
|
||||
unsigned b_bkc_flags; /* flags for 'backupcopy' */
|
||||
int b_p_ci; /* 'copyindent' */
|
||||
int b_p_bin; /* 'binary' */
|
||||
#ifdef FEAT_MBYTE
|
||||
int b_p_bomb; /* 'bomb' */
|
||||
#endif
|
||||
char_u *b_p_bh; /* 'bufhidden' */
|
||||
char_u *b_p_bt; /* 'buftype' */
|
||||
#ifdef FEAT_QUICKFIX
|
||||
@ -2270,9 +2262,7 @@ struct file_buffer
|
||||
int b_p_et; /* 'expandtab' */
|
||||
int b_p_et_nobin; /* b_p_et saved for binary mode */
|
||||
int b_p_et_nopaste; /* b_p_et saved for paste mode */
|
||||
#ifdef FEAT_MBYTE
|
||||
char_u *b_p_fenc; /* 'fileencoding' */
|
||||
#endif
|
||||
char_u *b_p_ff; /* 'fileformat' */
|
||||
char_u *b_p_ft; /* 'filetype' */
|
||||
char_u *b_p_fo; /* 'formatoptions' */
|
||||
@ -2304,9 +2294,7 @@ struct file_buffer
|
||||
#ifdef FEAT_LISP
|
||||
int b_p_lisp; /* 'lisp' */
|
||||
#endif
|
||||
#ifdef FEAT_MBYTE
|
||||
char_u *b_p_menc; /* 'makeencoding' */
|
||||
#endif
|
||||
char_u *b_p_mps; /* 'matchpairs' */
|
||||
int b_p_ml; /* 'modeline' */
|
||||
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_ffc; /* first char of 'ff' when edit started */
|
||||
#ifdef FEAT_MBYTE
|
||||
char_u *b_start_fenc; /* 'fileencoding' when edit started or NULL */
|
||||
int b_bad_char; /* "++bad=" argument when edit started or 0 */
|
||||
int b_start_bomb; /* 'bomb' when it was read */
|
||||
#endif
|
||||
|
||||
#ifdef FEAT_EVAL
|
||||
dictitem_T b_bufvar; /* variable for "b:" Dictionary */
|
||||
@ -3107,10 +3093,8 @@ typedef struct cmdarg_S
|
||||
int prechar; /* prefix character (optional, always 'g') */
|
||||
int cmdchar; /* command character */
|
||||
int nchar; /* next command character (optional) */
|
||||
#ifdef FEAT_MBYTE
|
||||
int ncharC1; /* first composing character (optional) */
|
||||
int ncharC2; /* second composing character (optional) */
|
||||
#endif
|
||||
int extra_char; /* yet another character (optional) */
|
||||
long opcount; /* count before an operator */
|
||||
long count0; /* count before command, default 0 */
|
||||
|
||||
11
src/syntax.c
11
src/syntax.c
@ -1974,12 +1974,9 @@ syn_current_attr(
|
||||
if (vim_iswordp_buf(line + current_col, syn_buf)
|
||||
&& (current_col == 0
|
||||
|| !vim_iswordp_buf(line + current_col - 1
|
||||
#ifdef FEAT_MBYTE
|
||||
- (has_mbyte
|
||||
? (*mb_head_off)(line, line + current_col - 1)
|
||||
: 0)
|
||||
#endif
|
||||
, syn_buf)))
|
||||
: 0) , syn_buf)))
|
||||
{
|
||||
syn_id = check_keyword_id(line, (int)current_col,
|
||||
&endcol, &flags, &next_list, cur_si,
|
||||
@ -3355,11 +3352,9 @@ check_keyword_id(
|
||||
kwlen = 0;
|
||||
do
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
kwlen += (*mb_ptr2len)(kwp + kwlen);
|
||||
else
|
||||
#endif
|
||||
++kwlen;
|
||||
}
|
||||
while (vim_iswordp_buf(kwp + kwlen, syn_buf));
|
||||
@ -4668,7 +4663,6 @@ get_syn_options(
|
||||
}
|
||||
else if (flagtab[fidx].argtype == 11 && arg[5] == '=')
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
/* cchar=? */
|
||||
if (has_mbyte)
|
||||
{
|
||||
@ -4678,7 +4672,6 @@ get_syn_options(
|
||||
arg += mb_ptr2len(arg + 6) - 1;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
#ifdef FEAT_CONCEAL
|
||||
*conceal_char = arg[6];
|
||||
@ -4948,7 +4941,6 @@ syn_cmd_keyword(exarg_T *eap, int syncing UNUSED)
|
||||
kw = p + 1; /* skip over the "]" */
|
||||
break;
|
||||
}
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
int l = (*mb_ptr2len)(p + 1);
|
||||
@ -4957,7 +4949,6 @@ syn_cmd_keyword(exarg_T *eap, int syncing UNUSED)
|
||||
p += l;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
p[0] = p[1];
|
||||
++p;
|
||||
|
||||
10
src/tag.c
10
src/tag.c
@ -1349,9 +1349,7 @@ find_tags(
|
||||
#endif
|
||||
|
||||
pat_T orgpat; /* holds unconverted pattern info */
|
||||
#ifdef FEAT_MBYTE
|
||||
vimconv_T vimconv;
|
||||
#endif
|
||||
|
||||
#ifdef FEAT_TAG_BINS
|
||||
int findall = (mincount == MAXCOL || mincount == TAG_MANY);
|
||||
@ -1387,9 +1385,7 @@ find_tags(
|
||||
|
||||
help_save = curbuf->b_help;
|
||||
orgpat.pat = pat;
|
||||
#ifdef FEAT_MBYTE
|
||||
vimconv.vc_type = CONV_NONE;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Allocate memory for the buffers that are used
|
||||
@ -1725,7 +1721,6 @@ find_tags(
|
||||
}
|
||||
line_read_in:
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
if (vimconv.vc_type != CONV_NONE)
|
||||
{
|
||||
char_u *conv_line;
|
||||
@ -1752,7 +1747,6 @@ line_read_in:
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef FEAT_EMACS_TAGS
|
||||
@ -1846,7 +1840,6 @@ line_read_in:
|
||||
if (STRNCMP(lbuf, "!_TAG_FILE_SORTED\t", 18) == 0)
|
||||
tag_file_sorted = lbuf[18];
|
||||
#endif
|
||||
#ifdef FEAT_MBYTE
|
||||
if (STRNCMP(lbuf, "!_TAG_FILE_ENCODING\t", 20) == 0)
|
||||
{
|
||||
/* Prepare to convert every line from the specified
|
||||
@ -1856,7 +1849,6 @@ line_read_in:
|
||||
*p = NUL;
|
||||
convert_setup(&vimconv, lbuf + 20, p_enc);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Read the next line. Unrecognized flags are ignored. */
|
||||
continue;
|
||||
@ -2472,10 +2464,8 @@ parse_line:
|
||||
vim_free(incstack[incstack_idx].etag_fname);
|
||||
}
|
||||
#endif
|
||||
#ifdef FEAT_MBYTE
|
||||
if (vimconv.vc_type != CONV_NONE)
|
||||
convert_setup(&vimconv, NULL, NULL);
|
||||
#endif
|
||||
|
||||
#ifdef FEAT_TAG_BINS
|
||||
tag_file_sorted = NUL;
|
||||
|
||||
18
src/term.c
18
src/term.c
@ -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().
|
||||
* 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)
|
||||
out_flush();
|
||||
}
|
||||
#endif
|
||||
|
||||
#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).
|
||||
* 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();
|
||||
}
|
||||
}
|
||||
# endif
|
||||
|
||||
/*
|
||||
* Similar to requesting the version string: Request the terminal background
|
||||
@ -4606,9 +4602,7 @@ check_termcode(
|
||||
{
|
||||
int col = 0;
|
||||
int semicols = 0;
|
||||
#ifdef FEAT_MBYTE
|
||||
int row_char = NUL;
|
||||
#endif
|
||||
|
||||
extra = 0;
|
||||
for (i = 2 + (tp[0] != CSI); i < len
|
||||
@ -4617,9 +4611,7 @@ check_termcode(
|
||||
if (tp[i] == ';' && ++semicols == 1)
|
||||
{
|
||||
extra = i + 1;
|
||||
#ifdef FEAT_MBYTE
|
||||
row_char = tp[i - 1];
|
||||
#endif
|
||||
}
|
||||
if (i == len)
|
||||
{
|
||||
@ -4629,7 +4621,6 @@ check_termcode(
|
||||
if (extra > 0)
|
||||
col = atoi((char *)tp + extra);
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
/* 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
|
||||
* just exited. But not for <S-F3>, it sends something
|
||||
@ -4672,10 +4663,9 @@ check_termcode(
|
||||
set_vim_var_string(VV_TERMU7RESP, tp, slen);
|
||||
# endif
|
||||
}
|
||||
else
|
||||
#endif
|
||||
/* 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;
|
||||
|
||||
@ -5973,11 +5963,9 @@ check_termcode(
|
||||
if (key_name[0] == KS_KEY)
|
||||
{
|
||||
/* from ":set <M-b>=xx" */
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
new_slen += (*mb_char2bytes)(key_name[1], string + new_slen);
|
||||
else
|
||||
#endif
|
||||
string[new_slen++] = key_name[1];
|
||||
}
|
||||
else if (new_slen == 0 && key_name[0] == KS_EXTRA
|
||||
@ -6257,10 +6245,8 @@ replace_termcodes(
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
/* skip multibyte char correctly */
|
||||
for (i = (*mb_ptr2len)(src); i > 0; --i)
|
||||
#endif
|
||||
{
|
||||
/*
|
||||
* If the character is K_SPECIAL, replace it with K_SPECIAL
|
||||
|
||||
112
src/ui.c
112
src/ui.c
@ -40,7 +40,7 @@ ui_write(char_u *s, int len)
|
||||
/* Don't output anything in silent mode ("ex -s") unless 'verbose' set */
|
||||
if (!(silent_mode && p_verbose == 0))
|
||||
{
|
||||
#if defined(FEAT_MBYTE) && !defined(WIN3264)
|
||||
#if !defined(WIN3264)
|
||||
char_u *tofree = NULL;
|
||||
|
||||
if (output_conv.vc_type != CONV_NONE)
|
||||
@ -54,7 +54,7 @@ ui_write(char_u *s, int len)
|
||||
|
||||
mch_write(s, len);
|
||||
|
||||
#if defined(FEAT_MBYTE) && !defined(WIN3264)
|
||||
# if !defined(WIN3264)
|
||||
if (output_conv.vc_type != CONV_NONE)
|
||||
vim_free(tofree);
|
||||
# endif
|
||||
@ -516,10 +516,8 @@ clip_update_selection(VimClipboard *clip)
|
||||
{
|
||||
start = VIsual;
|
||||
end = curwin->w_cursor;
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
end.col += (*mb_ptr2len)(ml_get_cursor()) - 1;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -821,9 +819,7 @@ clip_start_selection(int col, int row, int repeated_click)
|
||||
|
||||
row = check_row(row);
|
||||
col = check_col(col);
|
||||
#ifdef FEAT_MBYTE
|
||||
col = mb_fix_col(col, row);
|
||||
#endif
|
||||
|
||||
cb->start.lnum = row;
|
||||
cb->start.col = col;
|
||||
@ -927,9 +923,7 @@ clip_process_selection(
|
||||
|
||||
row = check_row(row);
|
||||
col = check_col(col);
|
||||
#ifdef FEAT_MBYTE
|
||||
col = mb_fix_col(col, row);
|
||||
#endif
|
||||
|
||||
if (col == (int)cb->prev.col && row == cb->prev.lnum && !repeated_click)
|
||||
return;
|
||||
@ -995,21 +989,17 @@ clip_process_selection(
|
||||
cb->origin_start_col, row, (int)Columns);
|
||||
else
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte && mb_lefthalve(row, col))
|
||||
slen = 2;
|
||||
#endif
|
||||
clip_update_modeless_selection(cb, cb->origin_row,
|
||||
cb->origin_start_col, row, col + slen);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte
|
||||
&& mb_lefthalve(cb->origin_row, cb->origin_start_col))
|
||||
slen = 2;
|
||||
#endif
|
||||
if (col >= (int)cb->word_end_col)
|
||||
clip_update_modeless_selection(cb, row, cb->word_end_col,
|
||||
cb->origin_row, cb->origin_start_col + slen);
|
||||
@ -1243,9 +1233,7 @@ clip_copy_modeless_selection(int both UNUSED)
|
||||
int line_end_col;
|
||||
int add_newline_flag = FALSE;
|
||||
int len;
|
||||
#ifdef FEAT_MBYTE
|
||||
char_u *p;
|
||||
#endif
|
||||
int row1 = clip_star.start.lnum;
|
||||
int col1 = clip_star.start.col;
|
||||
int row2 = clip_star.end.lnum;
|
||||
@ -1267,23 +1255,19 @@ clip_copy_modeless_selection(int both UNUSED)
|
||||
{
|
||||
row = col1; col1 = col2; col2 = row;
|
||||
}
|
||||
#ifdef FEAT_MBYTE
|
||||
/* correct starting point for being on right halve of double-wide char */
|
||||
p = ScreenLines + LineOffset[row1];
|
||||
if (enc_dbcs != 0)
|
||||
col1 -= (*mb_head_off)(p, p + col1);
|
||||
else if (enc_utf8 && p[col1] == 0)
|
||||
--col1;
|
||||
#endif
|
||||
|
||||
/* Create a temporary buffer for storing the text */
|
||||
len = (row2 - row1 + 1) * Columns + 1;
|
||||
#ifdef FEAT_MBYTE
|
||||
if (enc_dbcs != 0)
|
||||
len *= 2; /* max. 2 bytes per display cell */
|
||||
else if (enc_utf8)
|
||||
len *= MB_MAXBYTES;
|
||||
#endif
|
||||
buffer = lalloc((long_u)len, TRUE);
|
||||
if (buffer == NULL) /* out of memory */
|
||||
return;
|
||||
@ -1322,7 +1306,6 @@ clip_copy_modeless_selection(int both UNUSED)
|
||||
|
||||
if (row < screen_Rows && end_col <= screen_Columns)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
if (enc_dbcs != 0)
|
||||
{
|
||||
int i;
|
||||
@ -1373,7 +1356,6 @@ clip_copy_modeless_selection(int both UNUSED)
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
STRNCPY(bufp, ScreenLines + LineOffset[row] + start_col,
|
||||
end_col - start_col);
|
||||
@ -1421,51 +1403,35 @@ clip_get_word_boundaries(VimClipboard *cb, int row, int col)
|
||||
int start_class;
|
||||
int temp_col;
|
||||
char_u *p;
|
||||
#ifdef FEAT_MBYTE
|
||||
int mboff;
|
||||
#endif
|
||||
|
||||
if (row >= screen_Rows || col >= screen_Columns || ScreenLines == NULL)
|
||||
return;
|
||||
|
||||
p = ScreenLines + LineOffset[row];
|
||||
#ifdef FEAT_MBYTE
|
||||
/* Correct for starting in the right halve of a double-wide char */
|
||||
if (enc_dbcs != 0)
|
||||
col -= dbcs_screen_head_off(p, p + col);
|
||||
else if (enc_utf8 && p[col] == 0)
|
||||
--col;
|
||||
#endif
|
||||
start_class = CHAR_CLASS(p[col]);
|
||||
|
||||
temp_col = col;
|
||||
for ( ; temp_col > 0; temp_col--)
|
||||
#ifdef FEAT_MBYTE
|
||||
if (enc_dbcs != 0
|
||||
&& (mboff = dbcs_screen_head_off(p, p + temp_col - 1)) > 0)
|
||||
temp_col -= mboff;
|
||||
else
|
||||
#endif
|
||||
if (CHAR_CLASS(p[temp_col - 1]) != start_class
|
||||
#ifdef FEAT_MBYTE
|
||||
&& !(enc_utf8 && p[temp_col - 1] == 0)
|
||||
#endif
|
||||
)
|
||||
else if (CHAR_CLASS(p[temp_col - 1]) != start_class
|
||||
&& !(enc_utf8 && p[temp_col - 1] == 0))
|
||||
break;
|
||||
cb->word_start_col = temp_col;
|
||||
|
||||
temp_col = col;
|
||||
for ( ; temp_col < screen_Columns; temp_col++)
|
||||
#ifdef FEAT_MBYTE
|
||||
if (enc_dbcs != 0 && dbcs_ptr2cells(p + temp_col) == 2)
|
||||
++temp_col;
|
||||
else
|
||||
#endif
|
||||
if (CHAR_CLASS(p[temp_col]) != start_class
|
||||
#ifdef FEAT_MBYTE
|
||||
&& !(enc_utf8 && p[temp_col] == 0)
|
||||
#endif
|
||||
)
|
||||
else if (CHAR_CLASS(p[temp_col]) != start_class
|
||||
&& !(enc_utf8 && p[temp_col] == 0))
|
||||
break;
|
||||
cb->word_end_col = temp_col;
|
||||
}
|
||||
@ -1820,12 +1786,10 @@ fill_input_buf(int exit_on_error UNUSED)
|
||||
int len;
|
||||
int try;
|
||||
static int did_read_something = FALSE;
|
||||
# ifdef FEAT_MBYTE
|
||||
static char_u *rest = NULL; /* unconverted rest of previous read */
|
||||
static int restlen = 0;
|
||||
int unconverted;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef FEAT_GUI
|
||||
if (gui.in_use
|
||||
@ -1860,7 +1824,6 @@ fill_input_buf(int exit_on_error UNUSED)
|
||||
inbufcount = 0;
|
||||
# else
|
||||
|
||||
# ifdef FEAT_MBYTE
|
||||
if (rest != NULL)
|
||||
{
|
||||
/* Use remainder of previous call, starts with an invalid character
|
||||
@ -1881,16 +1844,12 @@ fill_input_buf(int exit_on_error UNUSED)
|
||||
}
|
||||
else
|
||||
unconverted = 0;
|
||||
# endif
|
||||
|
||||
len = 0; /* to avoid gcc warning */
|
||||
for (try = 0; try < 100; ++try)
|
||||
{
|
||||
size_t readlen = (size_t)((INBUFLEN - inbufcount)
|
||||
# ifdef FEAT_MBYTE
|
||||
/ input_conv.vc_factor
|
||||
# endif
|
||||
);
|
||||
/ input_conv.vc_factor);
|
||||
# ifdef VMS
|
||||
len = vms_read((char *)inbuf + inbufcount, readlen);
|
||||
# else
|
||||
@ -1936,7 +1895,6 @@ fill_input_buf(int exit_on_error UNUSED)
|
||||
}
|
||||
else
|
||||
{
|
||||
# ifdef FEAT_MBYTE
|
||||
/*
|
||||
* May perform conversion on the input characters.
|
||||
* Include the unconverted rest of the previous call.
|
||||
@ -1952,7 +1910,6 @@ fill_input_buf(int exit_on_error UNUSED)
|
||||
len + unconverted, INBUFLEN - inbufcount,
|
||||
rest == NULL ? &rest : NULL, &restlen);
|
||||
}
|
||||
# endif
|
||||
while (len-- > 0)
|
||||
{
|
||||
/*
|
||||
@ -2014,8 +1971,6 @@ ui_cursor_shape(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(FEAT_CLIPBOARD) || defined(FEAT_GUI) || defined(FEAT_RIGHTLEFT) \
|
||||
|| defined(FEAT_MBYTE) || defined(PROTO)
|
||||
/*
|
||||
* Check bounds for column number
|
||||
*/
|
||||
@ -2041,7 +1996,6 @@ check_row(int row)
|
||||
return (int)screen_Rows - 1;
|
||||
return row;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 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 */
|
||||
#ifdef FEAT_MBYTE
|
||||
static Atom vimenc_atom; /* Vim's extended selection format */
|
||||
static Atom utf8_atom;
|
||||
#endif
|
||||
static Atom compound_text_atom;
|
||||
static Atom text_atom;
|
||||
static Atom targets_atom;
|
||||
@ -2079,10 +2031,8 @@ static Atom timestamp_atom; /* Used to get a timestamp */
|
||||
x11_setup_atoms(Display *dpy)
|
||||
{
|
||||
vim_atom = XInternAtom(dpy, VIM_ATOM_NAME, False);
|
||||
#ifdef FEAT_MBYTE
|
||||
vimenc_atom = XInternAtom(dpy, VIMENC_ATOM_NAME,False);
|
||||
utf8_atom = XInternAtom(dpy, "UTF8_STRING", False);
|
||||
#endif
|
||||
compound_text_atom = XInternAtom(dpy, "COMPOUND_TEXT", False);
|
||||
text_atom = XInternAtom(dpy, "TEXT", False);
|
||||
targets_atom = XInternAtom(dpy, "TARGETS", False);
|
||||
@ -2170,9 +2120,7 @@ clip_x11_request_selection_cb(
|
||||
char_u *p;
|
||||
char **text_list = NULL;
|
||||
VimClipboard *cbd;
|
||||
#ifdef FEAT_MBYTE
|
||||
char_u *tmpbuf = NULL;
|
||||
#endif
|
||||
|
||||
if (*sel_atom == clip_plus.sel_atom)
|
||||
cbd = &clip_plus;
|
||||
@ -2193,7 +2141,6 @@ clip_x11_request_selection_cb(
|
||||
len--;
|
||||
}
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
else if (*type == vimenc_atom)
|
||||
{
|
||||
char_u *enc;
|
||||
@ -2221,17 +2168,10 @@ clip_x11_request_selection_cb(
|
||||
convert_setup(&conv, NULL, NULL);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
else if (*type == compound_text_atom
|
||||
#ifdef FEAT_MBYTE
|
||||
|| *type == utf8_atom
|
||||
#endif
|
||||
|| (
|
||||
#ifdef FEAT_MBYTE
|
||||
enc_dbcs != 0 &&
|
||||
#endif
|
||||
*type == text_atom))
|
||||
|| (enc_dbcs != 0 && *type == text_atom))
|
||||
{
|
||||
XTextProperty text_prop;
|
||||
int n_text = 0;
|
||||
@ -2241,7 +2181,7 @@ clip_x11_request_selection_cb(
|
||||
text_prop.encoding = *type;
|
||||
text_prop.format = *format;
|
||||
text_prop.nitems = len;
|
||||
#if defined(FEAT_MBYTE) && defined(X_HAVE_UTF8_STRING)
|
||||
#if defined(X_HAVE_UTF8_STRING)
|
||||
if (*type == utf8_atom)
|
||||
status = Xutf8TextPropertyToTextList(X_DISPLAY, &text_prop,
|
||||
&text_list, &n_text);
|
||||
@ -2261,9 +2201,7 @@ clip_x11_request_selection_cb(
|
||||
|
||||
if (text_list != NULL)
|
||||
XFreeStringList(text_list);
|
||||
#ifdef FEAT_MBYTE
|
||||
vim_free(tmpbuf);
|
||||
#endif
|
||||
XtFree((char *)value);
|
||||
*(int *)success = TRUE;
|
||||
}
|
||||
@ -2281,28 +2219,17 @@ clip_x11_request_selection(
|
||||
time_t start_time;
|
||||
int timed_out = FALSE;
|
||||
|
||||
for (i =
|
||||
#ifdef FEAT_MBYTE
|
||||
0
|
||||
#else
|
||||
1
|
||||
#endif
|
||||
; i < 6; i++)
|
||||
for (i = 0; i < 6; i++)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
case 0: type = vimenc_atom; break;
|
||||
#endif
|
||||
case 1: type = vim_atom; break;
|
||||
#ifdef FEAT_MBYTE
|
||||
case 2: type = utf8_atom; break;
|
||||
#endif
|
||||
case 3: type = compound_text_atom; break;
|
||||
case 4: type = text_atom; break;
|
||||
default: type = XA_STRING;
|
||||
}
|
||||
#ifdef FEAT_MBYTE
|
||||
if (type == utf8_atom
|
||||
# if defined(X_HAVE_UTF8_STRING)
|
||||
&& !enc_utf8
|
||||
@ -2311,7 +2238,6 @@ clip_x11_request_selection(
|
||||
/* Only request utf-8 when 'encoding' is utf8 and
|
||||
* Xutf8TextPropertyToTextList is available. */
|
||||
continue;
|
||||
#endif
|
||||
success = MAYBE;
|
||||
XtGetSelectionValue(myShell, cbd->sel_atom, type,
|
||||
clip_x11_request_selection_cb, (XtPointer)&success, CurrentTime);
|
||||
@ -2406,14 +2332,10 @@ clip_x11_convert_selection_cb(
|
||||
*value = (XtPointer)array;
|
||||
i = 0;
|
||||
array[i++] = targets_atom;
|
||||
#ifdef FEAT_MBYTE
|
||||
array[i++] = vimenc_atom;
|
||||
#endif
|
||||
array[i++] = vim_atom;
|
||||
#ifdef FEAT_MBYTE
|
||||
if (enc_utf8)
|
||||
array[i++] = utf8_atom;
|
||||
#endif
|
||||
array[i++] = XA_STRING;
|
||||
array[i++] = text_atom;
|
||||
array[i++] = compound_text_atom;
|
||||
@ -2427,10 +2349,8 @@ clip_x11_convert_selection_cb(
|
||||
}
|
||||
|
||||
if ( *target != XA_STRING
|
||||
#ifdef FEAT_MBYTE
|
||||
&& *target != vimenc_atom
|
||||
&& (*target != utf8_atom || !enc_utf8)
|
||||
#endif
|
||||
&& *target != vim_atom
|
||||
&& *target != text_atom
|
||||
&& *target != compound_text_atom)
|
||||
@ -2445,11 +2365,9 @@ clip_x11_convert_selection_cb(
|
||||
if (*target == vim_atom)
|
||||
(*length)++;
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
/* Our own format with encoding: motion 'encoding' NUL text */
|
||||
if (*target == vimenc_atom)
|
||||
*length += STRLEN(p_enc) + 2;
|
||||
#endif
|
||||
|
||||
if (save_length < *length || save_length / 2 >= *length)
|
||||
*value = XtRealloc((char *)save_result, (Cardinal)*length + 1);
|
||||
@ -2463,11 +2381,7 @@ clip_x11_convert_selection_cb(
|
||||
save_result = (char_u *)*value;
|
||||
save_length = *length;
|
||||
|
||||
if (*target == XA_STRING
|
||||
#ifdef FEAT_MBYTE
|
||||
|| (*target == utf8_atom && enc_utf8)
|
||||
#endif
|
||||
)
|
||||
if (*target == XA_STRING || (*target == utf8_atom && enc_utf8))
|
||||
{
|
||||
mch_memmove(save_result, string, (size_t)(*length));
|
||||
*type = *target;
|
||||
@ -2495,7 +2409,6 @@ clip_x11_convert_selection_cb(
|
||||
save_result = (char_u *)*value;
|
||||
save_length = *length;
|
||||
}
|
||||
#ifdef FEAT_MBYTE
|
||||
else if (*target == vimenc_atom)
|
||||
{
|
||||
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));
|
||||
*type = vimenc_atom;
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
save_result[0] = motion_type;
|
||||
@ -2599,7 +2511,6 @@ yank_cut_buffer0(Display *dpy, VimClipboard *cbd)
|
||||
|
||||
if (nbytes > 0)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
int done = FALSE;
|
||||
|
||||
/* 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 */
|
||||
#endif
|
||||
clip_yank_selection(MCHAR, buffer, (long)nbytes, cbd);
|
||||
XFree((void *)buffer);
|
||||
if (p_verbose > 0)
|
||||
|
||||
@ -459,11 +459,7 @@ static char *(features[]) =
|
||||
"+multi_byte_ime",
|
||||
# endif
|
||||
#else
|
||||
# ifdef FEAT_MBYTE
|
||||
"+multi_byte",
|
||||
# else
|
||||
"-multi_byte",
|
||||
# endif
|
||||
#endif
|
||||
#ifdef FEAT_MULTI_LANG
|
||||
"+multi_lang",
|
||||
@ -791,6 +787,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
810,
|
||||
/**/
|
||||
809,
|
||||
/**/
|
||||
@ -3052,14 +3050,12 @@ do_intro_line(
|
||||
for (l = 0; p[l] != NUL
|
||||
&& (l == 0 || (p[l] != '<' && p[l - 1] != '>')); ++l)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
clen += ptr2cells(p + l);
|
||||
l += (*mb_ptr2len)(p + l) - 1;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
clen += byte2cells(p[l]);
|
||||
}
|
||||
screen_puts_len(p, l, row, col, *p == '<' ? HL_ATTR(HLF_8) : attr);
|
||||
|
||||
45
src/vim.h
45
src/vim.h
@ -210,7 +210,7 @@
|
||||
#endif
|
||||
|
||||
/* 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
|
||||
#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
|
||||
* memory.
|
||||
*/
|
||||
#ifdef FEAT_MBYTE
|
||||
#ifdef UNICODE16
|
||||
typedef unsigned short u8char_T; /* short should be 16 bits */
|
||||
#else
|
||||
# if VIM_SIZEOF_INT >= 4
|
||||
typedef unsigned int u8char_T; /* int is 32 bits */
|
||||
# else
|
||||
typedef unsigned long u8char_T; /* long should be 32 bits or more */
|
||||
# endif
|
||||
# endif
|
||||
typedef unsigned int u8char_T; /* int is 32 bits or more */
|
||||
#endif
|
||||
|
||||
#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() */
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
#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
|
||||
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() */
|
||||
|
||||
@ -1609,7 +1598,6 @@ typedef UINT32_TYPEDEF UINT32_T;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
/* 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
|
||||
* 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_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 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
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
#define MAX_MCO 6 /* maximum value for 'maxcombine' */
|
||||
|
||||
/* 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
|
||||
* plus six following composing characters of three bytes each. */
|
||||
#define MB_MAXBYTES 21
|
||||
#else
|
||||
# define MB_MAXBYTES 1
|
||||
#endif
|
||||
|
||||
#if (defined(FEAT_PROFILE) || defined(FEAT_RELTIME)) && !defined(PROTO)
|
||||
# ifdef WIN3264
|
||||
@ -2128,7 +2108,7 @@ typedef enum {
|
||||
# define USE_MCH_ERRMSG
|
||||
#endif
|
||||
|
||||
# if defined(FEAT_MBYTE) && defined(FEAT_EVAL) \
|
||||
# if defined(FEAT_EVAL) \
|
||||
&& (!defined(FEAT_GUI_W32) \
|
||||
|| !(defined(FEAT_MBYTE_IME) || defined(GLOBAL_IME))) \
|
||||
&& !(defined(FEAT_GUI_MAC) && defined(MACOS_CONVERT))
|
||||
@ -2139,20 +2119,15 @@ typedef enum {
|
||||
# define IME_WITHOUT_XIM
|
||||
#endif
|
||||
|
||||
#if defined(FEAT_MBYTE) && (defined(FEAT_XIM) \
|
||||
#if defined(FEAT_XIM) \
|
||||
|| defined(IME_WITHOUT_XIM) \
|
||||
|| (defined(FEAT_GUI_W32) \
|
||||
&& (defined(FEAT_MBYTE_IME) || defined(GLOBAL_IME))) \
|
||||
|| defined(FEAT_GUI_MAC))
|
||||
|| defined(FEAT_GUI_MAC)
|
||||
/* im_set_active() is available */
|
||||
# define HAVE_INPUT_METHOD
|
||||
#endif
|
||||
|
||||
#ifndef FEAT_MBYTE
|
||||
# define after_pathsep(b, p) vim_ispathsep(*((p) - 1))
|
||||
# define transchar_byte(c) transchar(c)
|
||||
#endif
|
||||
|
||||
#ifndef FEAT_LINEBREAK
|
||||
/* Without the 'numberwidth' option line numbers are always 7 chars. */
|
||||
# define number_width(x) 7
|
||||
@ -2160,7 +2135,7 @@ typedef enum {
|
||||
|
||||
/* This must come after including proto.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_fopen(n, p) fopen((n), (p))
|
||||
#endif
|
||||
@ -2236,7 +2211,6 @@ typedef enum {
|
||||
# define vim_realloc(ptr, size) realloc((ptr), (size))
|
||||
#endif
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
/*
|
||||
* Return byte length of character that starts with byte "b".
|
||||
* Returns 1 for a single-byte character.
|
||||
@ -2245,9 +2219,7 @@ typedef enum {
|
||||
*/
|
||||
#define MB_BYTE2LEN(b) 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) */
|
||||
#define ENC_8BIT 0x01
|
||||
#define ENC_DBCS 0x02
|
||||
@ -2263,9 +2235,7 @@ typedef enum {
|
||||
#define ENC_LATIN1 0x200 /* Latin1 */
|
||||
#define ENC_LATIN9 0x400 /* Latin9 */
|
||||
#define ENC_MACROMAN 0x800 /* Mac Roman (not Macro Man! :-) */
|
||||
#endif
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
#ifdef USE_ICONV
|
||||
# ifndef EILSEQ
|
||||
# define EILSEQ 123
|
||||
@ -2284,9 +2254,6 @@ typedef enum {
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#define SIGN_BYTE 1 /* byte value used where sign is displayed;
|
||||
attribute value is sign type */
|
||||
|
||||
|
||||
@ -44,7 +44,6 @@ typedef int LPWSTR;
|
||||
typedef int UINT;
|
||||
#endif
|
||||
|
||||
#if defined(FEAT_MBYTE) || defined(PROTO)
|
||||
/*
|
||||
* Convert an UTF-8 string to UTF-16.
|
||||
* "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
|
||||
/*
|
||||
@ -301,12 +299,10 @@ clip_mch_request_selection(VimClipboard *cbd)
|
||||
VimClipType_t metadata = { -1, -1, -1, -1 };
|
||||
HGLOBAL hMem = NULL;
|
||||
char_u *str = NULL;
|
||||
#if defined(FEAT_MBYTE) && defined(WIN3264)
|
||||
#if defined(WIN3264)
|
||||
char_u *to_free = NULL;
|
||||
#endif
|
||||
#ifdef FEAT_MBYTE
|
||||
HGLOBAL rawh = NULL;
|
||||
#endif
|
||||
int str_size = 0;
|
||||
int maxlen;
|
||||
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
|
||||
* conversion, but only if 'encoding' matches. */
|
||||
if (IsClipboardFormatAvailable(cbd->format_raw)
|
||||
@ -366,9 +361,7 @@ clip_mch_request_selection(VimClipboard *cbd)
|
||||
}
|
||||
if (str == NULL)
|
||||
{
|
||||
#endif
|
||||
|
||||
#if defined(FEAT_MBYTE) && defined(WIN3264)
|
||||
#if defined(WIN3264)
|
||||
/* Try to get the clipboard in Unicode if it's not an empty string. */
|
||||
if (IsClipboardFormatAvailable(CF_UNICODETEXT) && metadata.ucslen != 0)
|
||||
{
|
||||
@ -378,8 +371,8 @@ clip_mch_request_selection(VimClipboard *cbd)
|
||||
{
|
||||
WCHAR *hMemWstr = (WCHAR *)GlobalLock(hMemW);
|
||||
|
||||
/* Use the length of our metadata if possible, but limit it to the
|
||||
* GlobalSize() for safety. */
|
||||
/* Use the length of our metadata if possible, but limit it to
|
||||
* the GlobalSize() for safety. */
|
||||
maxlen = (int)(GlobalSize(hMemW) / sizeof(WCHAR));
|
||||
if (metadata.ucslen >= 0)
|
||||
{
|
||||
@ -424,9 +417,9 @@ clip_mch_request_selection(VimClipboard *cbd)
|
||||
break;
|
||||
}
|
||||
|
||||
# if defined(FEAT_MBYTE) && defined(WIN3264)
|
||||
/* The text is in the active codepage. Convert to 'encoding',
|
||||
* going through UTF-16. */
|
||||
#if defined(WIN3264)
|
||||
/* The text is in the active codepage. Convert to
|
||||
* 'encoding', going through UTF-16. */
|
||||
acp_to_enc(str, str_size, &to_free, &maxlen);
|
||||
if (to_free != NULL)
|
||||
{
|
||||
@ -436,9 +429,7 @@ clip_mch_request_selection(VimClipboard *cbd)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#ifdef FEAT_MBYTE
|
||||
}
|
||||
#endif
|
||||
|
||||
if (str != NULL && *str != NUL)
|
||||
{
|
||||
@ -460,12 +451,10 @@ clip_mch_request_selection(VimClipboard *cbd)
|
||||
/* unlock the global object */
|
||||
if (hMem != NULL)
|
||||
GlobalUnlock(hMem);
|
||||
#ifdef FEAT_MBYTE
|
||||
if (rawh != NULL)
|
||||
GlobalUnlock(rawh);
|
||||
#endif
|
||||
CloseClipboard();
|
||||
#if defined(FEAT_MBYTE) && defined(WIN3264)
|
||||
#if defined(WIN3264)
|
||||
vim_free(to_free);
|
||||
#endif
|
||||
}
|
||||
@ -482,7 +471,7 @@ clip_mch_set_selection(VimClipboard *cbd)
|
||||
HGLOBAL hMemRaw = NULL;
|
||||
HGLOBAL hMem = NULL;
|
||||
HGLOBAL hMemVim = NULL;
|
||||
# if defined(FEAT_MBYTE) && defined(WIN3264)
|
||||
# if defined(WIN3264)
|
||||
HGLOBAL hMemW = NULL;
|
||||
# endif
|
||||
|
||||
@ -499,7 +488,6 @@ clip_mch_set_selection(VimClipboard *cbd)
|
||||
metadata.ucslen = 0;
|
||||
metadata.rawlen = 0;
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
/* 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
|
||||
* bytes can also be copied and no conversion is needed. */
|
||||
@ -519,9 +507,8 @@ clip_mch_set_selection(VimClipboard *cbd)
|
||||
else
|
||||
metadata.rawlen = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
# if defined(FEAT_MBYTE) && defined(WIN3264)
|
||||
# if defined(WIN3264)
|
||||
{
|
||||
WCHAR *out;
|
||||
int len = metadata.txtlen;
|
||||
@ -603,7 +590,7 @@ clip_mch_set_selection(VimClipboard *cbd)
|
||||
{
|
||||
SetClipboardData(cbd->format, hMemVim);
|
||||
hMemVim = 0;
|
||||
# if defined(FEAT_MBYTE) && defined(WIN3264)
|
||||
# if defined(WIN3264)
|
||||
if (hMemW != NULL)
|
||||
{
|
||||
if (SetClipboardData(CF_UNICODETEXT, hMemW) != NULL)
|
||||
@ -624,7 +611,7 @@ clip_mch_set_selection(VimClipboard *cbd)
|
||||
GlobalFree(hMemRaw);
|
||||
if (hMem)
|
||||
GlobalFree(hMem);
|
||||
# if defined(FEAT_MBYTE) && defined(WIN3264)
|
||||
# if defined(WIN3264)
|
||||
if (hMemW)
|
||||
GlobalFree(hMemW);
|
||||
# endif
|
||||
@ -634,7 +621,6 @@ clip_mch_set_selection(VimClipboard *cbd)
|
||||
|
||||
#endif /* FEAT_CLIPBOARD */
|
||||
|
||||
#if defined(FEAT_MBYTE) || defined(PROTO)
|
||||
/*
|
||||
* Note: the following two functions are only guaranteed to work when using
|
||||
* valid MS-Windows codepages or when iconv() is available.
|
||||
@ -759,9 +745,8 @@ utf16_to_enc(short_u *str, int *lenp)
|
||||
|
||||
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'.
|
||||
* Input is "str[str_size]".
|
||||
|
||||
@ -6180,12 +6180,9 @@ file_name_in_line(
|
||||
*/
|
||||
while (ptr > line)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte && (len = (*mb_head_off)(line, ptr - 1)) > 0)
|
||||
ptr -= len + 1;
|
||||
else
|
||||
#endif
|
||||
if (vim_isfilec(ptr[-1])
|
||||
else if (vim_isfilec(ptr[-1])
|
||||
|| ((options & FNAME_HYP) && path_is_url(ptr - 1)))
|
||||
--ptr;
|
||||
else
|
||||
@ -6214,11 +6211,9 @@ file_name_in_line(
|
||||
if (ptr[len] == '\\')
|
||||
/* Skip over the "\" in "\ ". */
|
||||
++len;
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
len += (*mb_ptr2len)(ptr + len);
|
||||
else
|
||||
#endif
|
||||
++len;
|
||||
}
|
||||
|
||||
@ -6829,7 +6824,7 @@ match_add(
|
||||
m->match.regprog = regprog;
|
||||
m->match.rmm_ic = FALSE;
|
||||
m->match.rmm_maxcol = 0;
|
||||
# if defined(FEAT_CONCEAL) && defined(FEAT_MBYTE)
|
||||
# if defined(FEAT_CONCEAL)
|
||||
m->conceal_char = 0;
|
||||
if (conceal_char != NULL)
|
||||
m->conceal_char = (*mb_ptr2char)(conceal_char);
|
||||
|
||||
Reference in New Issue
Block a user