Problem: Too many #ifdefs.
Solution: Graduate FEAT_MBYTE, part 4.
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
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
{
if (!IS_SPECIAL(c))
c = bytes[i];
-#endif
if (IS_SPECIAL(c) || c == K_SPECIAL || c == NUL)
{
temp[1] = NUL;
}
add_buff(buf, temp, -1L);
-#ifdef FEAT_MBYTE
}
-#endif
}
/* First read ahead buffer. Used for translated commands. */
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);
}
else
{
-#ifdef FEAT_MBYTE
c = mb_ptr2char_adv(&s);
-#else
- c = *s++;
-#endif
if (c == CAR || c == NL || c == ESC)
c = ' ';
stuffcharReadbuff(c);
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)
{
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))
else
n = 1;
for (i = 0; ; ++i)
-#endif
{
if (c == K_SPECIAL) /* special key or escaped K_SPECIAL */
{
bp = bp->b_next;
p = bp->b_str;
}
-#ifdef FEAT_MBYTE
buf[i] = c;
if (i == n - 1) /* last byte of a character */
{
c = *p;
if (c == NUL) /* cannot happen? */
break;
-#endif
}
}
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;
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);
}
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
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!
--no_mapping;
c = (*mb_ptr2char)(buf);
}
-#endif
break;
}
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
&& MB_BYTE2LEN(c1) > MB_PTR2LEN(p2))
mlen = 0;
}
-#endif
/*
* Check an entry whether it matches.
* - Full match: mlen == keylen
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
if ((*mb_ptr2cells)(ptr + col) > 1)
--curwin->w_wcol;
}
-#endif
}
setcursor();
out_flush();
* 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;
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]))
{
#ifdef FEAT_LOCALMAP
mapblock_T *mp2;
#endif
-#ifdef FEAT_MBYTE
int clen = 0; /* length in characters */
-#endif
int is_id = TRUE;
int vim_abbr;
if (col == 0) /* cannot be an abbr. */
return FALSE;
-#ifdef FEAT_MBYTE
if (has_mbyte)
{
char_u *p;
scol = (int)(p - ptr);
}
else
-#endif
{
if (!vim_iswordc(ptr[col - 1]))
vim_abbr = TRUE; /* Vim added 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 */
j += (*mb_char2bytes)(c, tb + j);
}
else
-#endif
tb[j++] = c;
}
tb[j] = NUL;
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;
/* 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;
for ( ; *str != NUL; ++str)
{
-#ifdef FEAT_MBYTE
char_u *p;
/* Check for a multi-byte character, which may contain escaped
--str;
continue;
}
-#endif
c = *str;
/*
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
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
/* 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:
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
* internally stored as UTF-8 (to avoid trouble with NUL bytes).
*/
-# define DBCS_JPN 932 /* japan */
-# define DBCS_JPNU 9932 /* euc-jp */
-# define DBCS_KOR 949 /* korea */
-# define DBCS_KORU 9949 /* euc-kr */
-# define DBCS_CHS 936 /* chinese */
-# define DBCS_CHSU 9936 /* euc-cn */
-# define DBCS_CHT 950 /* taiwan */
-# define DBCS_CHTU 9950 /* euc-tw */
-# define DBCS_2BYTE 1 /* 2byte- */
-# define DBCS_DEBUG -1
-#endif
-
-#ifdef FEAT_MBYTE
+#define DBCS_JPN 932 /* japan */
+#define DBCS_JPNU 9932 /* euc-jp */
+#define DBCS_KOR 949 /* korea */
+#define DBCS_KORU 9949 /* euc-kr */
+#define DBCS_CHS 936 /* chinese */
+#define DBCS_CHSU 9936 /* euc-cn */
+#define DBCS_CHT 950 /* taiwan */
+#define DBCS_CHTU 9950 /* euc-tw */
+#define DBCS_2BYTE 1 /* 2byte- */
+#define DBCS_DEBUG -1
+
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 */
EXTERN int enc_utf8 INIT(= FALSE); /* UTF-8 encoded Unicode */
EXTERN int enc_latin1like INIT(= TRUE); /* 'encoding' is latin1 comp. */
-# if defined(WIN3264) || defined(FEAT_CYGWIN_WIN32_CLIPBOARD)
+#if defined(WIN3264) || defined(FEAT_CYGWIN_WIN32_CLIPBOARD)
/* Codepage nr of 'encoding'. Negative means it's not been set yet, zero
* means 'encoding' is not a valid codepage. */
EXTERN int enc_codepage INIT(= -1);
EXTERN int enc_latin9 INIT(= FALSE); /* 'encoding' is latin9 */
-# endif
+#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
+#endif
/*
* To speed up BYTELEN() we fill a table with the byte lengths whenever
EXTERN int* (*iconv_errno) (void);
# endif
-#endif /* FEAT_MBYTE */
#ifdef FEAT_XIM
# ifdef FEAT_GUI_GTK
GuiFont menu_font; /* menu item font */
# endif
#endif
-#ifdef FEAT_MBYTE
GuiFont wide_font; /* Normal 'guifontwide' font */
-# ifndef FEAT_GUI_GTK
+#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 */
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 ENC_OPT ((char *)p_enc)
#define DOPY_FUNC "_vim_pydo"
static const char *vim_special_path = "_vim_path_";
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);
* MB_ISLOWER() and MB_ISUPPER() are to be used on multi-byte characters. But
* don't use them for negative values!
*/
-#ifdef FEAT_MBYTE
-# define MB_ISLOWER(c) vim_islower(c)
-# define MB_ISUPPER(c) vim_isupper(c)
-# define MB_TOLOWER(c) vim_tolower(c)
-# define MB_TOUPPER(c) vim_toupper(c)
-#else
-# define MB_ISLOWER(c) islower(c)
-# define MB_ISUPPER(c) isupper(c)
-# define MB_TOLOWER(c) TOLOWER_LOC(c)
-# define MB_TOUPPER(c) TOUPPER_LOC(c)
-#endif
+#define MB_ISLOWER(c) vim_islower(c)
+#define MB_ISUPPER(c) vim_isupper(c)
+#define MB_TOLOWER(c) vim_tolower(c)
+#define MB_TOUPPER(c) vim_toupper(c)
/* Use our own isdigit() replacement, because on MS-Windows isdigit() returns
* non-zero for superscript 1. Also avoids that isdigit() crashes for numbers
* a mapping and the langnoremap option was set.
* The do-while is just to ignore a ';' after the macro.
*/
-# ifdef FEAT_MBYTE
-# define LANGMAP_ADJUST(c, condition) \
+# define LANGMAP_ADJUST(c, condition) \
do { \
if (*p_langmap \
&& (condition) \
c = langmap_adjust_mb(c); \
} \
} while (0)
-# else
-# define LANGMAP_ADJUST(c, condition) \
- do { \
- if (*p_langmap \
- && (condition) \
- && (p_lrm || (!p_lrm && KeyTyped)) \
- && !KeyStuffed \
- && (c) >= 0 && (c) < 256) \
- c = langmap_mapchar[c]; \
- } while (0)
-# endif
#else
# define LANGMAP_ADJUST(c, condition) /* nop */
#endif
* MB_COPY_CHAR(f, t): copy one char from "f" to "t" and advance the pointers.
* PTR2CHAR(): get character from pointer.
*/
-#ifdef FEAT_MBYTE
/* Get the length of the character p points to, including composing chars */
-# define MB_PTR2LEN(p) (has_mbyte ? (*mb_ptr2len)(p) : 1)
+#define MB_PTR2LEN(p) (has_mbyte ? (*mb_ptr2len)(p) : 1)
/* Advance multi-byte pointer, skip over composing chars. */
-# define MB_PTR_ADV(p) p += has_mbyte ? (*mb_ptr2len)(p) : 1
+#define MB_PTR_ADV(p) p += has_mbyte ? (*mb_ptr2len)(p) : 1
/* Advance multi-byte pointer, do not skip over composing chars. */
-# define MB_CPTR_ADV(p) p += enc_utf8 ? utf_ptr2len(p) : has_mbyte ? (*mb_ptr2len)(p) : 1
+#define MB_CPTR_ADV(p) p += enc_utf8 ? utf_ptr2len(p) : has_mbyte ? (*mb_ptr2len)(p) : 1
/* Backup multi-byte pointer. Only use with "p" > "s" ! */
-# define MB_PTR_BACK(s, p) p -= has_mbyte ? ((*mb_head_off)(s, p - 1) + 1) : 1
+#define MB_PTR_BACK(s, p) p -= has_mbyte ? ((*mb_head_off)(s, p - 1) + 1) : 1
/* get length of multi-byte char, not including composing chars */
-# define MB_CPTR2LEN(p) (enc_utf8 ? utf_ptr2len(p) : (*mb_ptr2len)(p))
+#define MB_CPTR2LEN(p) (enc_utf8 ? utf_ptr2len(p) : (*mb_ptr2len)(p))
-# define MB_COPY_CHAR(f, t) if (has_mbyte) mb_copy_char(&f, &t); else *t++ = *f++
-# define MB_CHARLEN(p) (has_mbyte ? mb_charlen(p) : (int)STRLEN(p))
-# define MB_CHAR2LEN(c) (has_mbyte ? mb_char2len(c) : 1)
-# define PTR2CHAR(p) (has_mbyte ? mb_ptr2char(p) : (int)*(p))
-#else
-# define MB_PTR2LEN(p) 1
-# define MB_CPTR2LEN(p) 1
-# define MB_PTR_ADV(p) ++p
-# define MB_CPTR_ADV(p) ++p
-# define MB_PTR_BACK(s, p) --p
-# define MB_COPY_CHAR(f, t) *t++ = *f++
-# define MB_CHARLEN(p) STRLEN(p)
-# define MB_CHAR2LEN(c) 1
-# define PTR2CHAR(p) ((int)*(p))
-#endif
+#define MB_COPY_CHAR(f, t) if (has_mbyte) mb_copy_char(&f, &t); else *t++ = *f++
+#define MB_CHARLEN(p) (has_mbyte ? mb_charlen(p) : (int)STRLEN(p))
+#define MB_CHAR2LEN(c) (has_mbyte ? mb_char2len(c) : 1)
+#define PTR2CHAR(p) (has_mbyte ? mb_ptr2char(p) : (int)*(p))
#ifdef FEAT_AUTOCHDIR
# define DO_AUTOCHDIR do { if (p_acd) do_autochdir(); } while (0)
#endif
-#ifdef FEAT_MBYTE
/* Possible values for 'encoding' */
-# define ENC_UCSBOM "ucs-bom" /* check for BOM at start of file */
+#define ENC_UCSBOM "ucs-bom" /* check for BOM at start of file */
/* default value for 'encoding' */
-# define ENC_DFLT "latin1"
-#endif
+#define ENC_DFLT "latin1"
/* end-of-line style */
#define EOL_UNKNOWN -1 /* not defined yet */
#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
#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
+#ifdef IN_OPTION_C
static char *(p_cmp_values[]) = {"internal", "keepascii", NULL};
-# endif
-# define CMP_INTERNAL 0x001
-# define CMP_KEEPASCII 0x002
#endif
-#ifdef FEAT_MBYTE
+#define CMP_INTERNAL 0x001
+#define CMP_KEEPASCII 0x002
EXTERN char_u *p_enc; /* 'encoding' */
EXTERN int p_deco; /* 'delcombine' */
-# ifdef FEAT_EVAL
+#ifdef FEAT_EVAL
EXTERN char_u *p_ccv; /* 'charconvert' */
-# endif
#endif
#ifdef FEAT_CMDWIN
EXTERN char_u *p_cedit; /* 'cedit' */
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
# 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' */
# 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)
#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' */
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' */
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
#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
#endif
, BV_BIN
, BV_BL
-#ifdef FEAT_MBYTE
, BV_BOMB
-#endif
, BV_CI
#ifdef FEAT_CINDENT
, BV_CIN
, BV_LISP
, BV_LW
#endif
-#ifdef FEAT_MBYTE
, BV_MENC
-#endif
, BV_MA
, BV_ML
, BV_MOD
# include <Memory.h>
# include <OSUtils.h>
# include <Files.h>
-# ifdef FEAT_MBYTE
-# include <Script.h>
-# endif
+# include <Script.h>
#endif
/*
#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
+#define pDispatchMessage DispatchMessageW
+#define pGetMessage GetMessageW
+#define pIsDialogMessage IsDialogMessageW
+#define pPeekMessage PeekMessageW
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 "mbyte.pro"
# include "normal.pro"
# include "ops.pro"
# include "option.pro"
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];
rev_i = len;
for (s_i = 0; s_i < len; ++s_i)
{
-# ifdef FEAT_MBYTE
if (has_mbyte)
{
int mb_len;
s_i += mb_len - 1;
}
else
-# endif
rev[--rev_i] = s[s_i];
}
while (*p != NUL)
{
-#ifdef FEAT_MBYTE
int l;
if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1)
return TRUE;
p += l;
}
- else
-#endif
- if (*p == '\\')
+ else if (*p == '\\')
{
if (p[1] == '_' && p[2] != NUL) /* skip "\_X" */
p += 3;
char_u *
last_csearch(void)
{
-#ifdef FEAT_MBYTE
return lastc_bytes;
-#else
- return lastc;
-#endif
}
int
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
* 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
else
start_char_len = (*mb_ptr2len)(ptr + pos->col);
}
-#endif
else
start_char_len = 1;
if (dir == FORWARD)
if (matchcol == matchpos.col
&& ptr[matchcol] != NUL)
{
-#ifdef FEAT_MBYTE
if (has_mbyte)
matchcol +=
(*mb_ptr2len)(ptr + matchcol);
else
-#endif
++matchcol;
}
}
matchcol = matchpos.col;
if (ptr[matchcol] != NUL)
{
-#ifdef FEAT_MBYTE
if (has_mbyte)
matchcol += (*mb_ptr2len)(ptr
+ matchcol);
else
-#endif
++matchcol;
}
}
if (matchcol == matchpos.col
&& ptr[matchcol] != NUL)
{
-#ifdef FEAT_MBYTE
if (has_mbyte)
matchcol +=
(*mb_ptr2len)(ptr + matchcol);
else
-#endif
++matchcol;
}
}
matchcol = matchpos.col;
if (ptr[matchcol] != NUL)
{
-#ifdef FEAT_MBYTE
if (has_mbyte)
matchcol +=
(*mb_ptr2len)(ptr + matchcol);
else
-#endif
++matchcol;
}
}
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)
{
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. */
STRCPY(msgbuf + 2, p);
}
else
-#endif
STRCPY(msgbuf + 1, p);
if (spats[0].off.line || spats[0].off.end || spats[0].off.off)
{
*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)
{
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;
while (count--)
{
-#ifdef FEAT_MBYTE
if (has_mbyte)
{
for (;;)
}
}
else
-#endif
{
for (;;)
{
{
/* backup to before the character (possibly double-byte) */
col -= dir;
-#ifdef FEAT_MBYTE
if (has_mbyte)
{
if (dir < 0)
/* To previous char, which may be multi-byte. */
col -= (*mb_head_off)(p, p + col);
}
-#endif
}
curwin->w_cursor.col = col;
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;
else
{
--pos.col;
-#ifdef FEAT_MBYTE
if (has_mbyte)
pos.col -= (*mb_head_off)(linep, linep + pos.col);
-#endif
}
}
else /* forward search */
}
else
{
-#ifdef FEAT_MBYTE
if (has_mbyte)
pos.col += (*mb_ptr2len)(linep + pos.col);
else
-#endif
++pos.col;
}
}
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;
}
}
#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. */
return 1;
return c;
}
-#endif
/* If cls_bigword is TRUE, report all non-blanks as class 1. */
if (cls_bigword)
int lc = NUL;
pos_T pos;
-#ifdef FEAT_MBYTE
if (enc_dbcs)
{
char_u *lp = NULL;
}
}
else
-#endif
{
for (p = line + curwin->w_cursor.col; p > line; )
{
++col;
else if (c == quotechar)
break;
-#ifdef FEAT_MBYTE
if (has_mbyte)
col += (*mb_ptr2len)(line + col);
else
-#endif
++col;
}
return col;
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,
}
// Count cells and check for non-printable chars
-# ifdef FEAT_MBYTE
if (has_mbyte)
{
cells = 0;
}
}
else
-# endif
{
for (s = text; s < endp; ++s)
if (!vim_isprintc(*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 */
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:
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 */
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);
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);
*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)
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;
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)
* 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
wlen = (int)(p - mip->mi_word);
}
}
-#endif
/* Check flags and region. For FIND_PREFIX check the condition and
* prefix ID.
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
&& 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. */
/* 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)
{
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
/* 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":
mip->mi_compoff = (int)(p - mip->mi_fword);
}
}
-#endif
#if 0 /* Disabled, see below */
c = mip->mi_compoff;
#endif
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. */
p = uflags;
}
else
-#endif
p = flags;
if (!vim_regexec_prog(&slang->sl_compprog, FALSE, p, 0))
return FALSE;
/* 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. */
}
else
mip->mi_cprefixlen = mip->mi_prefixlen;
-#endif
find_word(mip, FIND_PREFIX);
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";
}
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);
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);
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)
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; )
if (STRCMP(lang, "cjk") == 0)
{
-#ifdef FEAT_MBYTE
wp->w_s->b_cjk = 1;
-#endif
continue;
}
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
}
/*
return;
for (p = lp->sl_midword; *p != NUL; )
-#ifdef FEAT_MBYTE
if (has_mbyte)
{
int c, l, n;
p += l;
}
else
-#endif
wp->w_s->b_spell_ismw[*p++] = TRUE;
}
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);
}
}
-#if defined(FEAT_MBYTE) || defined(EXITFREE) || defined(PROTO)
/*
* Free all languages.
*/
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.
}
}
}
-#endif
/*
* Opposite of offset2bytes().
did_set_spelltab = FALSE;
clear_spell_chartab(&spelltab);
-#ifdef FEAT_MBYTE
if (enc_dbcs)
{
/* DBCS: assume double-wide characters are word characters. */
}
}
else
-#endif
{
/* Rough guess: use locale-dependent library functions. */
for (i = 128; i < 256; ++i)
char_u *p,
win_T *wp) /* buffer used */
{
-#ifdef FEAT_MBYTE
char_u *s;
int l;
int c;
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]];
}
int
spell_iswordp_nmw(char_u *p, win_T *wp)
{
-#ifdef FEAT_MBYTE
int c;
if (has_mbyte)
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.
}
return spelltab.st_isw[*s];
}
-#endif
/*
* Case-fold "str[len]" into "buf[buflen]". The result is NUL terminated.
return FAIL; /* result will not fit */
}
-#ifdef FEAT_MBYTE
if (has_mbyte)
{
int outi = 0;
buf[outi] = NUL;
}
else
-#endif
{
/* Be quick for non-multibyte encodings. */
for (i = 0; i < len; ++i)
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;
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)
*d++ = c;
}
else
-#endif
c = SPELL_TOUPPER(c);
-#ifdef FEAT_MBYTE
if (has_mbyte)
{
if (d - wcopy >= MAXWLEN - MB_MAXBYTES)
d += mb_char2bytes(c, d);
}
else
-#endif
{
if (d - wcopy >= MAXWLEN - 1)
break;
{
/* 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,
|| 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
&& mb_charlen(tword + sp->ts_splitoff)
< slang->sl_compminlen)
break;
-#endif
compflags[sp->ts_complen] = ((unsigned)flags >> 24);
compflags[sp->ts_complen + 1] = NUL;
* 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;
* 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;
&& ((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)
/* 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);
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)
* 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;
++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)
}
}
else
-#endif
{
/* If we found a similar char adjust the score.
* We do this after calling go_deeper() because
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)
sp->ts_state = STATE_FINAL;
break;
}
-#endif
/*
* Try skipping one character in the bad word (delete it).
*/
* 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);
stack[depth].ts_score -= SCORE_DEL - SCORE_DELDUP;
}
else
-#endif
{
++stack[depth].ts_fidx;
if (fword[sp->ts_fidx] == fword[sp->ts_fidx + 1])
sp = &stack[depth];
tword[sp->ts_twordlen++] = c;
sp->ts_arridx = idxs[n];
-#ifdef FEAT_MBYTE
if (has_mbyte)
{
fl = MB_BYTE2LEN(c);
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
break;
}
-#ifdef FEAT_MBYTE
if (has_mbyte)
{
n = MB_CPTR2LEN(p);
c2 = mb_ptr2char(p + n);
}
else
-#endif
{
if (p[1] == NUL)
c2 = NUL;
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_UNSWAP;
++depth;
-#ifdef FEAT_MBYTE
if (has_mbyte)
{
fl = mb_char2len(c2);
stack[depth].ts_fidxtry = sp->ts_fidx + n + fl;
}
else
-#endif
{
p[0] = c2;
p[1] = c;
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);
mb_char2bytes(c, p);
}
else
-#endif
{
c = *p;
*p = p[1];
/* 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);
c3 = mb_ptr2char(p + n + fl);
}
else
-#endif
{
c = *p;
c2 = p[1];
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_UNSWAP3;
++depth;
-#ifdef FEAT_MBYTE
if (has_mbyte)
{
tl = mb_char2len(c3);
stack[depth].ts_fidxtry = sp->ts_fidx + n + fl + tl;
}
else
-#endif
{
p[0] = p[2];
p[2] = c;
case STATE_UNSWAP3:
/* Undo STATE_SWAP3: "321" -> "123" */
p = fword + sp->ts_fidx;
-#ifdef FEAT_MBYTE
if (has_mbyte)
{
n = MB_PTR2LEN(p);
p = p + tl;
}
else
-#endif
{
c = *p;
*p = p[2];
sp->ts_state = STATE_UNROT3L;
++depth;
p = fword + sp->ts_fidx;
-#ifdef FEAT_MBYTE
if (has_mbyte)
{
n = MB_CPTR2LEN(p);
stack[depth].ts_fidxtry = sp->ts_fidx + n + fl;
}
else
-#endif
{
c = *p;
*p = p[1];
case STATE_UNROT3L:
/* Undo ROT3L: "231" -> "123" */
p = fword + sp->ts_fidx;
-#ifdef FEAT_MBYTE
if (has_mbyte)
{
n = MB_PTR2LEN(p);
mb_char2bytes(c, p);
}
else
-#endif
{
c = p[2];
p[2] = p[1];
sp->ts_state = STATE_UNROT3R;
++depth;
p = fword + sp->ts_fidx;
-#ifdef FEAT_MBYTE
if (has_mbyte)
{
n = MB_CPTR2LEN(p);
stack[depth].ts_fidxtry = sp->ts_fidx + n + tl;
}
else
-#endif
{
c = p[2];
p[2] = p[1];
case STATE_UNROT3R:
/* Undo ROT3R: "312" -> "123" */
p = fword + sp->ts_fidx;
-#ifdef FEAT_MBYTE
if (has_mbyte)
{
c = mb_ptr2char(p);
mb_char2bytes(c, p + n);
}
else
-#endif
{
c = *p;
*p = p[1];
}
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;
}
}
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".
--i;
return (int)(p - word);
}
-#endif
/*
* "fword" is a good word with case folded. Find the matching keep-case
* 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)
{
similar_chars(slang_T *slang, int c1, int c2)
{
int m1, m2;
-#ifdef FEAT_MBYTE
char_u buf[MB_MAXBYTES + 1];
hashitem_T *hi;
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;
m2 = mb_ptr2char(hi->hi_key + STRLEN(hi->hi_key) + 1);
}
else
-#endif
m2 = slang->sl_map_array[c2];
return m1 == m2;
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;
}
word = fword;
}
-#ifdef FEAT_MBYTE
if (has_mbyte)
spell_soundfold_wsal(slang, word, res);
else
-#endif
spell_soundfold_sal(slang, word, res);
}
}
int ri = 0;
int c;
-#ifdef FEAT_MBYTE
if (has_mbyte)
{
int prevc = 0;
}
}
else
-#endif
{
/* The sl_sal_first[] table contains the translation. */
for (s = inword; (c = *s) != NUL; ++s)
res[reslen] = NUL;
}
-#ifdef FEAT_MBYTE
/*
* Turn "inword" into its sound-a-like equivalent in "res[MAXWLEN]".
* Multi-byte version of spell_soundfold().
}
res[l] = NUL;
}
-#endif
/*
* Compute a score for two sound-a-like words.
int t;
int bc, gc;
int pbc, pgc;
-#ifdef FEAT_MBYTE
char_u *p;
int wbadword[MAXWLEN];
int wgoodword[MAXWLEN];
wgoodword[goodlen++] = 0;
}
else
-#endif
{
badlen = (int)STRLEN(badword) + 1;
goodlen = (int)STRLEN(goodword) + 1;
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];
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];
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
return minscore;
}
-#ifdef FEAT_MBYTE
/*
* Multi-byte version of spell_edit_score_limit().
* Keep it in sync with the above!
return SCORE_MAXMAX;
return minscore;
}
-#endif
/*
* ":spellinfo"
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;
}
}
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
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() */
};
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
* 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
+#if defined(HAVE_WCHAR_H)
+# include <wchar.h> /* for towupper() and towlower() */
+#endif
/* Multi-byte implementation. For Unicode we can call utf_*(), but don't do
* that for ASCII, because we don't want to use 'casemap' here. Otherwise use
* the "w" library function for characters above 255 if available. */
-# ifdef HAVE_TOWLOWER
-# define SPELL_TOFOLD(c) (enc_utf8 && (c) >= 128 ? utf_fold(c) \
+#ifdef HAVE_TOWLOWER
+# define SPELL_TOFOLD(c) (enc_utf8 && (c) >= 128 ? utf_fold(c) \
: (c) < 256 ? (int)spelltab.st_fold[c] : (int)towlower(c))
-# else
-# define SPELL_TOFOLD(c) (enc_utf8 && (c) >= 128 ? utf_fold(c) \
+#else
+# define SPELL_TOFOLD(c) (enc_utf8 && (c) >= 128 ? utf_fold(c) \
: (c) < 256 ? (int)spelltab.st_fold[c] : (c))
-# endif
+#endif
-# ifdef HAVE_TOWUPPER
-# define SPELL_TOUPPER(c) (enc_utf8 && (c) >= 128 ? utf_toupper(c) \
+#ifdef HAVE_TOWUPPER
+# define SPELL_TOUPPER(c) (enc_utf8 && (c) >= 128 ? utf_toupper(c) \
: (c) < 256 ? (int)spelltab.st_upper[c] : (int)towupper(c))
-# else
-# define SPELL_TOUPPER(c) (enc_utf8 && (c) >= 128 ? utf_toupper(c) \
+#else
+# define SPELL_TOUPPER(c) (enc_utf8 && (c) >= 128 ? utf_toupper(c) \
: (c) < 256 ? (int)spelltab.st_upper[c] : (c))
-# endif
+#endif
-# ifdef HAVE_ISWUPPER
-# define SPELL_ISUPPER(c) (enc_utf8 && (c) >= 128 ? utf_isupper(c) \
+#ifdef HAVE_ISWUPPER
+# define SPELL_ISUPPER(c) (enc_utf8 && (c) >= 128 ? utf_isupper(c) \
: (c) < 256 ? spelltab.st_isu[c] : iswupper(c))
-# else
-# define SPELL_ISUPPER(c) (enc_utf8 && (c) >= 128 ? utf_isupper(c) \
+#else
+# define SPELL_ISUPPER(c) (enc_utf8 && (c) >= 128 ? utf_isupper(c) \
: (c) < 256 ? spelltab.st_isu[c] : (FALSE))
-# endif
#endif
#ifdef FEAT_SPELL
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);
return ccnt;
}
-#ifdef FEAT_MBYTE
if (has_mbyte)
{
/* convert the multi-byte strings to wide char strings */
return SP_OTHERERROR;
}
}
-#endif
}
if (gap->ga_len > 0)
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);
smp->sm_oneof_w = NULL;
smp->sm_to_w = NULL;
}
-#endif
++gap->ga_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;
{
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;
}
}
{
int i;
-#ifdef FEAT_MBYTE
garray_T *gap;
char_u *s;
char_u *p;
}
}
else
-#endif
{
/* mapping bytes to bytes is done in sl_sal_first[] */
if (STRLEN(from) != STRLEN(to))
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;
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)
}
return res;
}
-#endif
/*
* Read a tree from the .spl or .sug file.
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
+#define AH_KEY_LEN 17 /* 2 x 8 bytes + NUL */
/* Affix header from ".aff" file. Used for af_pref and af_suff. */
typedef struct affheader_S
/* 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);
line = pc;
}
else
-#endif
{
pc = NULL;
line = rline;
{
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
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)
* 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;
if (aff_entry->ae_cond != NULL)
{
char_u buf[MAXLINELEN];
-#ifdef FEAT_MBYTE
+
if (has_mbyte)
{
onecap_copy(items[4], buf, TRUE);
spin, buf);
}
else
-#endif
*aff_entry->ae_cond = c_up;
if (aff_entry->ae_cond != NULL)
{
/* 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)
* 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);
}
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;
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;
}
continue; /* empty line */
line[l] = NUL;
-#ifdef FEAT_MBYTE
/* Convert from "SET" to 'encoding' when needed. */
if (spin->si_conv.vc_type != CONV_NONE)
{
w = pc;
}
else
-#endif
{
pc = NULL;
w = line;
if (ae->ae_chop != NULL)
{
/* Skip chop string. */
-#ifdef FEAT_MBYTE
if (has_mbyte)
{
i = mb_charlen(ae->ae_chop);
MB_PTR_ADV(p);
}
else
-#endif
p += STRLEN(ae->ae_chop);
}
STRCAT(newword, p);
/* 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);
line = pc;
}
else
-#endif
{
pc = NULL;
line = rline;
fname, lnum, line - 1);
else
{
-#ifdef FEAT_MBYTE
char_u *enc;
/* Setup for conversion to 'encoding'. */
fname, line, p_enc);
vim_free(enc);
spin->si_conv.vc_fail = TRUE;
-#else
- smsg(_("Conversion in %s not supported"), fname);
-#endif
}
continue;
}
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> */
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)
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;
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;
/* 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:
*/
for (p = map; *p != NUL; )
{
-#ifdef FEAT_MBYTE
c = mb_cptr2char_adv(&p);
-#else
- c = *p++;
-#endif
if (c == '/')
headc = 0;
else
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. */
}
}
else
-#endif
lp->sl_map_array[c] = headc;
}
}
{
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;
/* 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;
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
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' */
#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 */
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 */
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 */
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,
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));
}
else if (flagtab[fidx].argtype == 11 && arg[5] == '=')
{
-#ifdef FEAT_MBYTE
/* cchar=? */
if (has_mbyte)
{
-# ifdef FEAT_CONCEAL
+#ifdef FEAT_CONCEAL
*conceal_char = mb_ptr2char(arg + 6);
-# endif
+#endif
arg += mb_ptr2len(arg + 6) - 1;
}
else
-#endif
{
#ifdef FEAT_CONCEAL
*conceal_char = arg[6];
kw = p + 1; /* skip over the "]" */
break;
}
-#ifdef FEAT_MBYTE
if (has_mbyte)
{
int l = (*mb_ptr2len)(p + 1);
p += l;
}
else
-#endif
{
p[0] = p[1];
++p;
#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);
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
}
line_read_in:
-#ifdef FEAT_MBYTE
if (vimconv.vc_type != CONV_NONE)
{
char_u *conv_line;
}
}
}
-#endif
#ifdef FEAT_EMACS_TAGS
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
*p = NUL;
convert_setup(&vimconv, lbuf + 20, p_enc);
}
-#endif
/* Read the next line. Unrecognized flags are ignored. */
continue;
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;
}
-#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.
if (enc_dbcs != 0 && out_pos >= OUT_SIZE - MB_MAXBYTES)
out_flush();
}
-#endif
#ifdef FEAT_GUI
/*
}
}
-# 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
(void)vpeekc_nomap();
}
}
-# endif
/*
* Similar to requesting the version string: Request the terminal background
{
int col = 0;
int semicols = 0;
-#ifdef FEAT_MBYTE
int row_char = NUL;
-#endif
extra = 0;
for (i = 2 + (tp[0] != CSI); i < len
if (tp[i] == ';' && ++semicols == 1)
{
extra = i + 1;
-#ifdef FEAT_MBYTE
row_char = tp[i - 1];
-#endif
}
if (i == len)
{
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
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;
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
}
}
-#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
/* 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)
mch_write(s, len);
-#if defined(FEAT_MBYTE) && !defined(WIN3264)
+# if !defined(WIN3264)
if (output_conv.vc_type != CONV_NONE)
vim_free(tofree);
-#endif
+# endif
}
#endif
}
{
start = VIsual;
end = curwin->w_cursor;
-#ifdef FEAT_MBYTE
if (has_mbyte)
end.col += (*mb_ptr2len)(ml_get_cursor()) - 1;
-#endif
}
else
{
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;
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;
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);
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;
{
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;
if (row < screen_Rows && end_col <= screen_Columns)
{
-#ifdef FEAT_MBYTE
if (enc_dbcs != 0)
{
int i;
}
}
else
-#endif
{
STRNCPY(bufp, ScreenLines + LineOffset[row] + start_col,
end_col - start_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;
}
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
inbufcount = 0;
# else
-# ifdef FEAT_MBYTE
if (rest != NULL)
{
/* Use remainder of previous call, starts with an invalid character
}
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
}
else
{
-# ifdef FEAT_MBYTE
/*
* May perform conversion on the input characters.
* Include the unconverted rest of the previous call.
len + unconverted, INBUFLEN - inbufcount,
rest == NULL ? &rest : NULL, &restlen);
}
-# endif
while (len-- > 0)
{
/*
}
#endif
-#if defined(FEAT_CLIPBOARD) || defined(FEAT_GUI) || defined(FEAT_RIGHTLEFT) \
- || defined(FEAT_MBYTE) || defined(PROTO)
/*
* Check bounds for column number
*/
return (int)screen_Rows - 1;
return row;
}
-#endif
/*
* Stuff for the X clipboard. Shared between VMS and Unix.
}
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;
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);
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;
len--;
}
-#ifdef FEAT_MBYTE
else if (*type == vimenc_atom)
{
char_u *enc;
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;
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);
if (text_list != NULL)
XFreeStringList(text_list);
-#ifdef FEAT_MBYTE
vim_free(tmpbuf);
-#endif
XtFree((char *)value);
*(int *)success = TRUE;
}
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
/* 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);
*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;
}
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)
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);
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;
save_result = (char_u *)*value;
save_length = *length;
}
-#ifdef FEAT_MBYTE
else if (*target == vimenc_atom)
{
int l = STRLEN(p_enc);
mch_memmove(save_result + l + 2, string, (size_t)(*length - l - 2));
*type = vimenc_atom;
}
-#endif
else
{
save_result[0] = motion_type;
if (nbytes > 0)
{
-#ifdef FEAT_MBYTE
int done = FALSE;
/* CUT_BUFFER0 is supposed to be always latin1. Convert to 'enc' when
}
}
if (!done) /* use the text without conversion */
-#endif
clip_yank_selection(MCHAR, buffer, (long)nbytes, cbd);
XFree((void *)buffer);
if (p_verbose > 0)
"+multi_byte_ime",
# endif
#else
-# ifdef FEAT_MBYTE
"+multi_byte",
-# else
- "-multi_byte",
-# endif
#endif
#ifdef FEAT_MULTI_LANG
"+multi_lang",
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 810,
/**/
809,
/**/
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);
#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
* bits. u8char_T is only used for displaying, it could be 16 bits to save
* memory.
*/
-#ifdef FEAT_MBYTE
-# ifdef UNICODE16
+#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
+#else
+typedef unsigned int u8char_T; /* int is 32 bits or more */
#endif
#ifndef UNIX /* For Unix this is included in os_unix.h */
#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
+#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() */
# 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
# 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))
# endif
#endif
-#ifdef FEAT_MBYTE
-# define MAX_MCO 6 /* maximum value for 'maxcombine' */
+#define MAX_MCO 6 /* maximum value for 'maxcombine' */
/* Maximum number of bytes in a multi-byte character. It can be one 32-bit
* 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
+#define MB_MAXBYTES 21
#if (defined(FEAT_PROFILE) || defined(FEAT_RELTIME)) && !defined(PROTO)
# ifdef WIN3264
# 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))
# 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
/* 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
# 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.
* MB_BYTE2LEN_CHECK() can be used to count a special key as one byte.
* Don't call MB_BYTE2LEN(b) with b < 0 or b > 255!
*/
-# define MB_BYTE2LEN(b) mb_bytelen_tab[b]
-# define MB_BYTE2LEN_CHECK(b) (((b) < 0 || (b) > 255) ? 1 : mb_bytelen_tab[b])
-#endif
+#define MB_BYTE2LEN(b) mb_bytelen_tab[b]
+#define MB_BYTE2LEN_CHECK(b) (((b) < 0 || (b) > 255) ? 1 : mb_bytelen_tab[b])
-#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
-# define ENC_UNICODE 0x04
+#define ENC_8BIT 0x01
+#define ENC_DBCS 0x02
+#define ENC_UNICODE 0x04
-# define ENC_ENDIAN_B 0x10 /* Unicode: Big endian */
-# define ENC_ENDIAN_L 0x20 /* Unicode: Little endian */
+#define ENC_ENDIAN_B 0x10 /* Unicode: Big endian */
+#define ENC_ENDIAN_L 0x20 /* Unicode: Little endian */
-# define ENC_2BYTE 0x40 /* Unicode: UCS-2 */
-# define ENC_4BYTE 0x80 /* Unicode: UCS-4 */
-# define ENC_2WORD 0x100 /* Unicode: UTF-16 */
+#define ENC_2BYTE 0x40 /* Unicode: UCS-2 */
+#define ENC_4BYTE 0x80 /* Unicode: UCS-4 */
+#define ENC_2WORD 0x100 /* Unicode: UTF-16 */
-# define ENC_LATIN1 0x200 /* Latin1 */
-# define ENC_LATIN9 0x400 /* Latin9 */
-# define ENC_MACROMAN 0x800 /* Mac Roman (not Macro Man! :-) */
-#endif
+#define ENC_LATIN1 0x200 /* Latin1 */
+#define ENC_LATIN9 0x400 /* Latin9 */
+#define ENC_MACROMAN 0x800 /* Mac Roman (not Macro Man! :-) */
-#ifdef FEAT_MBYTE
-# ifdef USE_ICONV
-# ifndef EILSEQ
-# define EILSEQ 123
-# endif
-# ifdef DYNAMIC_ICONV
+#ifdef USE_ICONV
+# ifndef EILSEQ
+# define EILSEQ 123
+# endif
+# ifdef DYNAMIC_ICONV
/* On Win32 iconv.dll is dynamically loaded. */
-# define ICONV_ERRNO (*iconv_errno())
-# define ICONV_E2BIG 7
-# define ICONV_EINVAL 22
-# define ICONV_EILSEQ 42
-# else
-# define ICONV_ERRNO errno
-# define ICONV_E2BIG E2BIG
-# define ICONV_EINVAL EINVAL
-# define ICONV_EILSEQ EILSEQ
-# endif
+# define ICONV_ERRNO (*iconv_errno())
+# define ICONV_E2BIG 7
+# define ICONV_EINVAL 22
+# define ICONV_EILSEQ 42
+# else
+# define ICONV_ERRNO errno
+# define ICONV_E2BIG E2BIG
+# define ICONV_EINVAL EINVAL
+# define ICONV_EILSEQ EILSEQ
# endif
-
#endif
-
#define SIGN_BYTE 1 /* byte value used where sign is displayed;
attribute value is sign type */
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.
}
}
-#endif /* FEAT_MBYTE */
#ifdef FEAT_CLIPBOARD
/*
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;
}
}
-#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)
}
if (str == NULL)
{
-#endif
-
-#if defined(FEAT_MBYTE) && defined(WIN3264)
- /* Try to get the clipboard in Unicode if it's not an empty string. */
- if (IsClipboardFormatAvailable(CF_UNICODETEXT) && metadata.ucslen != 0)
- {
- HGLOBAL hMemW;
-
- if ((hMemW = GetClipboardData(CF_UNICODETEXT)) != NULL)
+#if defined(WIN3264)
+ /* Try to get the clipboard in Unicode if it's not an empty string. */
+ if (IsClipboardFormatAvailable(CF_UNICODETEXT) && metadata.ucslen != 0)
{
- WCHAR *hMemWstr = (WCHAR *)GlobalLock(hMemW);
+ HGLOBAL hMemW;
- /* 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)
+ if ((hMemW = GetClipboardData(CF_UNICODETEXT)) != NULL)
{
- if (metadata.ucslen > maxlen)
- str_size = maxlen;
+ WCHAR *hMemWstr = (WCHAR *)GlobalLock(hMemW);
+
+ /* 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)
+ {
+ if (metadata.ucslen > maxlen)
+ str_size = maxlen;
+ else
+ str_size = metadata.ucslen;
+ }
else
- str_size = metadata.ucslen;
- }
- else
- {
- for (str_size = 0; str_size < maxlen; ++str_size)
- if (hMemWstr[str_size] == NUL)
- break;
+ {
+ for (str_size = 0; str_size < maxlen; ++str_size)
+ if (hMemWstr[str_size] == NUL)
+ break;
+ }
+ to_free = str = utf16_to_enc((short_u *)hMemWstr, &str_size);
+ GlobalUnlock(hMemW);
}
- to_free = str = utf16_to_enc((short_u *)hMemWstr, &str_size);
- GlobalUnlock(hMemW);
}
- }
- else
+ else
#endif
- /* Get the clipboard in the Active codepage. */
- if (IsClipboardFormatAvailable(CF_TEXT))
- {
- if ((hMem = GetClipboardData(CF_TEXT)) != NULL)
+ /* Get the clipboard in the Active codepage. */
+ if (IsClipboardFormatAvailable(CF_TEXT))
{
- str = (char_u *)GlobalLock(hMem);
-
- /* The length is either what our metadata says or the strlen().
- * But limit it to the GlobalSize() for safety. */
- maxlen = (int)GlobalSize(hMem);
- if (metadata.txtlen >= 0)
+ if ((hMem = GetClipboardData(CF_TEXT)) != NULL)
{
- if (metadata.txtlen > maxlen)
- str_size = maxlen;
+ str = (char_u *)GlobalLock(hMem);
+
+ /* The length is either what our metadata says or the strlen().
+ * But limit it to the GlobalSize() for safety. */
+ maxlen = (int)GlobalSize(hMem);
+ if (metadata.txtlen >= 0)
+ {
+ if (metadata.txtlen > maxlen)
+ str_size = maxlen;
+ else
+ str_size = metadata.txtlen;
+ }
else
- str_size = metadata.txtlen;
- }
- else
- {
- for (str_size = 0; str_size < maxlen; ++str_size)
- if (str[str_size] == NUL)
- break;
- }
-
-# if defined(FEAT_MBYTE) && 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)
- {
- str_size = maxlen;
- str = to_free;
+ {
+ for (str_size = 0; str_size < maxlen; ++str_size)
+ if (str[str_size] == NUL)
+ break;
+ }
+
+#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)
+ {
+ str_size = maxlen;
+ str = to_free;
+ }
+#endif
}
-# endif
}
}
-#ifdef FEAT_MBYTE
- }
-#endif
if (str != NULL && *str != NUL)
{
/* 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
}
HGLOBAL hMemRaw = NULL;
HGLOBAL hMem = NULL;
HGLOBAL hMemVim = NULL;
-# if defined(FEAT_MBYTE) && defined(WIN3264)
+# if defined(WIN3264)
HGLOBAL hMemW = NULL;
# endif
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. */
else
metadata.rawlen = 0;
}
-#endif
-# if defined(FEAT_MBYTE) && defined(WIN3264)
+# if defined(WIN3264)
{
WCHAR *out;
int len = metadata.txtlen;
{
SetClipboardData(cbd->format, hMemVim);
hMemVim = 0;
-# if defined(FEAT_MBYTE) && defined(WIN3264)
+# if defined(WIN3264)
if (hMemW != NULL)
{
if (SetClipboardData(CF_UNICODETEXT, hMemW) != NULL)
GlobalFree(hMemRaw);
if (hMem)
GlobalFree(hMem);
-# if defined(FEAT_MBYTE) && defined(WIN3264)
+# if defined(WIN3264)
if (hMemW)
GlobalFree(hMemW);
# endif
#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.
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]".
*/
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
if (ptr[len] == '\\')
/* Skip over the "\" in "\ ". */
++len;
-#ifdef FEAT_MBYTE
if (has_mbyte)
len += (*mb_ptr2len)(ptr + len);
else
-#endif
++len;
}
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);