0
0
mirror of https://github.com/vim/vim.git synced 2025-08-31 20:53:42 -04:00

patch 8.1.0805: too many #ifdefs

Problem:    Too many #ifdefs.
Solution:   Graduate FEAT_MBYTE, part 1.
This commit is contained in:
Bram Moolenaar 2019-01-24 15:04:48 +01:00
parent 4b9e91f0ba
commit 135059724f
17 changed files with 234 additions and 1147 deletions

View File

@ -704,10 +704,8 @@ buf_clear_file(buf_T *buf)
buf->b_shortname = FALSE; buf->b_shortname = FALSE;
buf->b_p_eol = TRUE; buf->b_p_eol = TRUE;
buf->b_start_eol = TRUE; buf->b_start_eol = TRUE;
#ifdef FEAT_MBYTE
buf->b_p_bomb = FALSE; buf->b_p_bomb = FALSE;
buf->b_start_bomb = FALSE; buf->b_start_bomb = FALSE;
#endif
buf->b_ml.ml_mfp = NULL; buf->b_ml.ml_mfp = NULL;
buf->b_ml.ml_flags = ML_EMPTY; /* empty buffer */ buf->b_ml.ml_flags = ML_EMPTY; /* empty buffer */
#ifdef FEAT_NETBEANS_INTG #ifdef FEAT_NETBEANS_INTG
@ -940,9 +938,7 @@ free_buffer_stuff(
map_clear_int(buf, MAP_ALL_MODES, TRUE, FALSE); /* clear local mappings */ map_clear_int(buf, MAP_ALL_MODES, TRUE, FALSE); /* clear local mappings */
map_clear_int(buf, MAP_ALL_MODES, TRUE, TRUE); /* clear local abbrevs */ map_clear_int(buf, MAP_ALL_MODES, TRUE, TRUE); /* clear local abbrevs */
#endif #endif
#ifdef FEAT_MBYTE
VIM_CLEAR(buf->b_start_fenc); VIM_CLEAR(buf->b_start_fenc);
#endif
} }
/* /*
@ -2133,9 +2129,7 @@ free_buf_options(
{ {
if (free_p_ff) if (free_p_ff)
{ {
#ifdef FEAT_MBYTE
clear_string_option(&buf->b_p_fenc); clear_string_option(&buf->b_p_fenc);
#endif
clear_string_option(&buf->b_p_ff); clear_string_option(&buf->b_p_ff);
clear_string_option(&buf->b_p_bh); clear_string_option(&buf->b_p_bh);
clear_string_option(&buf->b_p_bt); clear_string_option(&buf->b_p_bt);
@ -2245,9 +2239,7 @@ free_buf_options(
clear_string_option(&buf->b_p_lw); clear_string_option(&buf->b_p_lw);
#endif #endif
clear_string_option(&buf->b_p_bkc); clear_string_option(&buf->b_p_bkc);
#ifdef FEAT_MBYTE
clear_string_option(&buf->b_p_menc); clear_string_option(&buf->b_p_menc);
#endif
} }
/* /*
@ -3778,10 +3770,8 @@ maketitle(void)
if (len > 100) if (len > 100)
{ {
len -= 100; len -= 100;
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
len += (*mb_tail_off)(p, p + len) + 1; len += (*mb_tail_off)(p, p + len) + 1;
#endif
p += len; p += len;
} }
STRCPY(icon_str, p); STRCPY(icon_str, p);
@ -3939,11 +3929,9 @@ build_stl_str_hl(
if (fillchar == 0) if (fillchar == 0)
fillchar = ' '; fillchar = ' ';
#ifdef FEAT_MBYTE
/* Can't handle a multi-byte fill character yet. */ /* Can't handle a multi-byte fill character yet. */
else if (mb_char2len(fillchar) > 1) else if (mb_char2len(fillchar) > 1)
fillchar = '-'; fillchar = '-';
#endif
// The cursor in windows other than the current one isn't always // The cursor in windows other than the current one isn't always
// up-to-date, esp. because of autocommands and timers. // up-to-date, esp. because of autocommands and timers.
@ -3973,11 +3961,7 @@ build_stl_str_hl(
byteval = 0; byteval = 0;
} }
else else
#ifdef FEAT_MBYTE
byteval = (*mb_ptr2char)(p + wp->w_cursor.col); byteval = (*mb_ptr2char)(p + wp->w_cursor.col);
#else
byteval = p[wp->w_cursor.col];
#endif
groupdepth = 0; groupdepth = 0;
p = out; p = out;
@ -4079,7 +4063,6 @@ build_stl_str_hl(
if (l > item[groupitem[groupdepth]].maxwid) if (l > item[groupitem[groupdepth]].maxwid)
{ {
/* truncate, remove n bytes of text at the start */ /* truncate, remove n bytes of text at the start */
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
/* Find the first character that should be included. */ /* Find the first character that should be included. */
@ -4091,17 +4074,15 @@ build_stl_str_hl(
} }
} }
else else
#endif
n = (long)(p - t) - item[groupitem[groupdepth]].maxwid + 1; n = (long)(p - t) - item[groupitem[groupdepth]].maxwid + 1;
*t = '<'; *t = '<';
mch_memmove(t + 1, t + n, (size_t)(p - (t + n))); mch_memmove(t + 1, t + n, (size_t)(p - (t + n)));
p = p - n + 1; p = p - n + 1;
#ifdef FEAT_MBYTE
/* Fill up space left over by half a double-wide char. */ // Fill up space left over by half a double-wide char.
while (++l < item[groupitem[groupdepth]].minwid) while (++l < item[groupitem[groupdepth]].minwid)
*p++ = fillchar; *p++ = fillchar;
#endif
/* correct the start of the items for the truncation */ /* correct the start of the items for the truncation */
for (l = groupitem[groupdepth] + 1; l < curitem; l++) for (l = groupitem[groupdepth] + 1; l < curitem; l++)
@ -4483,14 +4464,12 @@ build_stl_str_hl(
if (l > maxwid) if (l > maxwid)
{ {
while (l >= maxwid) while (l >= maxwid)
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
l -= ptr2cells(t); l -= ptr2cells(t);
t += (*mb_ptr2len)(t); t += (*mb_ptr2len)(t);
} }
else else
#endif
l -= byte2cells(*t++); l -= byte2cells(*t++);
if (p + 1 >= out + outlen) if (p + 1 >= out + outlen)
break; break;
@ -4610,7 +4589,6 @@ build_stl_str_hl(
if (width - vim_strsize(s) >= maxwidth) if (width - vim_strsize(s) >= maxwidth)
{ {
/* Truncation mark is beyond max length */ /* Truncation mark is beyond max length */
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
s = out; s = out;
@ -4627,7 +4605,6 @@ build_stl_str_hl(
*s++ = fillchar; *s++ = fillchar;
} }
else else
#endif
s = out + maxwidth - 1; s = out + maxwidth - 1;
for (l = 0; l < itemcnt; l++) for (l = 0; l < itemcnt; l++)
if (item[l].start > s) if (item[l].start > s)
@ -4638,7 +4615,6 @@ build_stl_str_hl(
} }
else else
{ {
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
n = 0; n = 0;
@ -4649,7 +4625,6 @@ build_stl_str_hl(
} }
} }
else else
#endif
n = width - maxwidth + 1; n = width - maxwidth + 1;
p = s + n; p = s + n;
STRMOVE(s + 1, p); STRMOVE(s + 1, p);

View File

@ -9,12 +9,10 @@
#include "vim.h" #include "vim.h"
#ifdef FEAT_MBYTE #if defined(HAVE_WCHAR_H)
# if defined(HAVE_WCHAR_H) # include <wchar.h> /* for towupper() and towlower() */
# include <wchar.h> /* for towupper() and towlower() */
# endif
static int win_nolbr_chartabsize(win_T *wp, char_u *s, colnr_T col, int *headp);
#endif #endif
static int win_nolbr_chartabsize(win_T *wp, char_u *s, colnr_T col, int *headp);
static unsigned nr2hex(unsigned c); static unsigned nr2hex(unsigned c);
@ -109,7 +107,6 @@ buf_init_chartab(
#endif #endif
while (c < 256) while (c < 256)
{ {
#ifdef FEAT_MBYTE
/* UTF-8: bytes 0xa0 - 0xff are printable (latin1) */ /* UTF-8: bytes 0xa0 - 0xff are printable (latin1) */
if (enc_utf8 && c >= 0xa0) if (enc_utf8 && c >= 0xa0)
g_chartab[c++] = CT_PRINT_CHAR + 1; g_chartab[c++] = CT_PRINT_CHAR + 1;
@ -120,26 +117,22 @@ buf_init_chartab(
else if (enc_dbcs != 0 && MB_BYTE2LEN(c) == 2) else if (enc_dbcs != 0 && MB_BYTE2LEN(c) == 2)
g_chartab[c++] = CT_PRINT_CHAR + 2; g_chartab[c++] = CT_PRINT_CHAR + 2;
else else
#endif
/* the rest is unprintable by default */ /* the rest is unprintable by default */
g_chartab[c++] = (dy_flags & DY_UHEX) ? 4 : 2; g_chartab[c++] = (dy_flags & DY_UHEX) ? 4 : 2;
} }
#ifdef FEAT_MBYTE
/* Assume that every multi-byte char is a filename character. */ /* Assume that every multi-byte char is a filename character. */
for (c = 1; c < 256; ++c) for (c = 1; c < 256; ++c)
if ((enc_dbcs != 0 && MB_BYTE2LEN(c) > 1) if ((enc_dbcs != 0 && MB_BYTE2LEN(c) > 1)
|| (enc_dbcs == DBCS_JPNU && c == 0x8e) || (enc_dbcs == DBCS_JPNU && c == 0x8e)
|| (enc_utf8 && c >= 0xa0)) || (enc_utf8 && c >= 0xa0))
g_chartab[c] |= CT_FNAME_CHAR; g_chartab[c] |= CT_FNAME_CHAR;
#endif
} }
/* /*
* Init word char flags all to FALSE * Init word char flags all to FALSE
*/ */
vim_memset(buf->b_chartab, 0, (size_t)32); vim_memset(buf->b_chartab, 0, (size_t)32);
#ifdef FEAT_MBYTE
if (enc_dbcs != 0) if (enc_dbcs != 0)
for (c = 0; c < 256; ++c) for (c = 0; c < 256; ++c)
{ {
@ -147,7 +140,6 @@ buf_init_chartab(
if (MB_BYTE2LEN(c) == 2) if (MB_BYTE2LEN(c) == 2)
SET_CHARTAB(buf, c); SET_CHARTAB(buf, c);
} }
#endif
#ifdef FEAT_LISP #ifdef FEAT_LISP
/* /*
@ -184,11 +176,9 @@ buf_init_chartab(
if (VIM_ISDIGIT(*p)) if (VIM_ISDIGIT(*p))
c = getdigits(&p); c = getdigits(&p);
else else
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
c = mb_ptr2char_adv(&p); c = mb_ptr2char_adv(&p);
else else
#endif
c = *p++; c = *p++;
c2 = -1; c2 = -1;
if (*p == '-' && p[1] != NUL) if (*p == '-' && p[1] != NUL)
@ -197,11 +187,9 @@ buf_init_chartab(
if (VIM_ISDIGIT(*p)) if (VIM_ISDIGIT(*p))
c2 = getdigits(&p); c2 = getdigits(&p);
else else
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
c2 = mb_ptr2char_adv(&p); c2 = mb_ptr2char_adv(&p);
else else
#endif
c2 = *p++; c2 = *p++;
} }
if (c <= 0 || c >= 256 || (c2 < c && c2 != -1) || c2 >= 256 if (c <= 0 || c >= 256 || (c2 < c && c2 != -1) || c2 >= 256
@ -253,13 +241,9 @@ buf_init_chartab(
|| (p_altkeymap || (p_altkeymap
&& (F_isalpha(c) || F_isdigit(c))) && (F_isalpha(c) || F_isdigit(c)))
#endif #endif
) // For double-byte we keep the cell width, so
#ifdef FEAT_MBYTE // that we can detect it from the first byte.
/* For double-byte we keep the cell width, so ) && !(enc_dbcs && MB_BYTE2LEN(c) == 2))
* that we can detect it from the first byte. */
&& !(enc_dbcs && MB_BYTE2LEN(c) == 2)
#endif
)
{ {
if (tilde) if (tilde)
{ {
@ -322,12 +306,10 @@ trans_characters(
room = bufsize - len; room = bufsize - len;
while (*buf != 0) while (*buf != 0)
{ {
# ifdef FEAT_MBYTE
/* Assume a multi-byte character doesn't need translation. */ /* Assume a multi-byte character doesn't need translation. */
if (has_mbyte && (trs_len = (*mb_ptr2len)(buf)) > 1) if (has_mbyte && (trs_len = (*mb_ptr2len)(buf)) > 1)
len -= trs_len; len -= trs_len;
else else
# endif
{ {
trs = transchar_byte(*buf); trs = transchar_byte(*buf);
trs_len = (int)STRLEN(trs); trs_len = (int)STRLEN(trs);
@ -356,12 +338,9 @@ transstr(char_u *s)
{ {
char_u *res; char_u *res;
char_u *p; char_u *p;
#ifdef FEAT_MBYTE
int l, len, c; int l, len, c;
char_u hexbuf[11]; char_u hexbuf[11];
#endif
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
/* Compute the length of the result, taking account of unprintable /* Compute the length of the result, taking account of unprintable
@ -394,7 +373,6 @@ transstr(char_u *s)
res = alloc((unsigned)(len + 1)); res = alloc((unsigned)(len + 1));
} }
else else
#endif
res = alloc((unsigned)(vim_strsize(s) + 1)); res = alloc((unsigned)(vim_strsize(s) + 1));
if (res != NULL) if (res != NULL)
{ {
@ -402,7 +380,6 @@ transstr(char_u *s)
p = s; p = s;
while (*p != NUL) while (*p != NUL)
{ {
#ifdef FEAT_MBYTE
if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1) if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1)
{ {
c = (*mb_ptr2char)(p); c = (*mb_ptr2char)(p);
@ -413,7 +390,6 @@ transstr(char_u *s)
p += l; p += l;
} }
else else
#endif
STRCAT(res, transchar_byte(*p++)); STRCAT(res, transchar_byte(*p++));
} }
} }
@ -468,7 +444,6 @@ str_foldcase(
i = 0; i = 0;
while (STR_CHAR(i) != NUL) while (STR_CHAR(i) != NUL)
{ {
#ifdef FEAT_MBYTE
if (enc_utf8 || (has_mbyte && MB_BYTE2LEN(STR_CHAR(i)) > 1)) if (enc_utf8 || (has_mbyte && MB_BYTE2LEN(STR_CHAR(i)) > 1))
{ {
if (enc_utf8) if (enc_utf8)
@ -520,7 +495,6 @@ str_foldcase(
i += (*mb_ptr2len)(STR_PTR(i)); i += (*mb_ptr2len)(STR_PTR(i));
} }
else else
#endif
{ {
if (buf == NULL) if (buf == NULL)
GA_CHAR(i) = TOLOWER_LOC(GA_CHAR(i)); GA_CHAR(i) = TOLOWER_LOC(GA_CHAR(i));
@ -580,7 +554,6 @@ transchar(int c)
return transchar_buf; return transchar_buf;
} }
#if defined(FEAT_MBYTE) || defined(PROTO)
/* /*
* Like transchar(), but called with a byte instead of a character. Checks * Like transchar(), but called with a byte instead of a character. Checks
* for an illegal UTF-8 byte. * for an illegal UTF-8 byte.
@ -595,7 +568,6 @@ transchar_byte(int c)
} }
return transchar(c); return transchar(c);
} }
#endif
/* /*
* Convert non-printable character to two or more printable characters in * Convert non-printable character to two or more printable characters in
@ -632,12 +604,10 @@ transchar_nonprint(char_u *buf, int c)
buf[2] = NUL; buf[2] = NUL;
} }
#ifdef FEAT_MBYTE
else if (enc_utf8 && c >= 0x80) else if (enc_utf8 && c >= 0x80)
{ {
transchar_hex(buf, c); transchar_hex(buf, c);
} }
#endif
#ifndef EBCDIC #ifndef EBCDIC
else if (c >= ' ' + 0x80 && c <= '~' + 0x80) /* 0xa0 - 0xfe */ else if (c >= ' ' + 0x80 && c <= '~' + 0x80) /* 0xa0 - 0xfe */
{ {
@ -675,13 +645,11 @@ transchar_hex(char_u *buf, int c)
int i = 0; int i = 0;
buf[0] = '<'; buf[0] = '<';
#ifdef FEAT_MBYTE
if (c > 255) if (c > 255)
{ {
buf[++i] = nr2hex((unsigned)c >> 12); buf[++i] = nr2hex((unsigned)c >> 12);
buf[++i] = nr2hex((unsigned)c >> 8); buf[++i] = nr2hex((unsigned)c >> 8);
} }
#endif
buf[++i] = nr2hex((unsigned)c >> 4); buf[++i] = nr2hex((unsigned)c >> 4);
buf[++i] = nr2hex((unsigned)c); buf[++i] = nr2hex((unsigned)c);
buf[++i] = '>'; buf[++i] = '>';
@ -712,10 +680,8 @@ nr2hex(unsigned c)
int int
byte2cells(int b) byte2cells(int b)
{ {
#ifdef FEAT_MBYTE
if (enc_utf8 && b >= 0x80) if (enc_utf8 && b >= 0x80)
return 0; return 0;
#endif
return (g_chartab[b] & CT_CELL_MASK); return (g_chartab[b] & CT_CELL_MASK);
} }
@ -729,7 +695,6 @@ char2cells(int c)
{ {
if (IS_SPECIAL(c)) if (IS_SPECIAL(c))
return char2cells(K_SECOND(c)) + 2; return char2cells(K_SECOND(c)) + 2;
#ifdef FEAT_MBYTE
if (c >= 0x80) if (c >= 0x80)
{ {
/* UTF-8: above 0x80 need to check the value */ /* UTF-8: above 0x80 need to check the value */
@ -744,7 +709,6 @@ char2cells(int c)
return 2; return 2;
} }
} }
#endif
return (g_chartab[c & 0xff] & CT_CELL_MASK); return (g_chartab[c & 0xff] & CT_CELL_MASK);
} }
@ -755,12 +719,10 @@ char2cells(int c)
int int
ptr2cells(char_u *p) ptr2cells(char_u *p)
{ {
#ifdef FEAT_MBYTE
/* For UTF-8 we need to look at more bytes if the first byte is >= 0x80. */ /* For UTF-8 we need to look at more bytes if the first byte is >= 0x80. */
if (enc_utf8 && *p >= 0x80) if (enc_utf8 && *p >= 0x80)
return utf_ptr2cells(p); return utf_ptr2cells(p);
/* For DBCS we can tell the cell count from the first byte. */ /* For DBCS we can tell the cell count from the first byte. */
#endif
return (g_chartab[*p] & CT_CELL_MASK); return (g_chartab[*p] & CT_CELL_MASK);
} }
@ -784,8 +746,6 @@ vim_strnsize(char_u *s, int len)
int size = 0; int size = 0;
while (*s != NUL && --len >= 0) while (*s != NUL && --len >= 0)
{
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
int l = (*mb_ptr2len)(s); int l = (*mb_ptr2len)(s);
@ -795,9 +755,8 @@ vim_strnsize(char_u *s, int len)
len -= l - 1; len -= l - 1;
} }
else else
#endif
size += byte2cells(*s++); size += byte2cells(*s++);
}
return size; return size;
} }
@ -907,12 +866,10 @@ vim_iswordc_buf(int c, buf_T *buf)
{ {
if (c >= 0x100) if (c >= 0x100)
{ {
#ifdef FEAT_MBYTE
if (enc_dbcs != 0) if (enc_dbcs != 0)
return dbcs_class((unsigned)c >> 8, (unsigned)(c & 0xff)) >= 2; return dbcs_class((unsigned)c >> 8, (unsigned)(c & 0xff)) >= 2;
if (enc_utf8) if (enc_utf8)
return utf_class_buf(c, buf) >= 2; return utf_class_buf(c, buf) >= 2;
#endif
return FALSE; return FALSE;
} }
return (c > 0 && GET_CHARTAB(buf, c) != 0); return (c > 0 && GET_CHARTAB(buf, c) != 0);
@ -932,10 +889,8 @@ vim_iswordp_buf(char_u *p, buf_T *buf)
{ {
int c = *p; int c = *p;
#ifdef FEAT_MBYTE
if (has_mbyte && MB_BYTE2LEN(c) > 1) if (has_mbyte && MB_BYTE2LEN(c) > 1)
c = (*mb_ptr2char)(p); c = (*mb_ptr2char)(p);
#endif
return vim_iswordc_buf(c, buf); return vim_iswordc_buf(c, buf);
} }
@ -973,10 +928,8 @@ vim_isfilec_or_wc(int c)
int int
vim_isprintc(int c) vim_isprintc(int c)
{ {
#ifdef FEAT_MBYTE
if (enc_utf8 && c >= 0x100) if (enc_utf8 && c >= 0x100)
return utf_printable(c); return utf_printable(c);
#endif
return (c >= 0x100 || (c > 0 && (g_chartab[c] & CT_PRINT_CHAR))); return (c >= 0x100 || (c > 0 && (g_chartab[c] & CT_PRINT_CHAR)));
} }
@ -987,12 +940,10 @@ vim_isprintc(int c)
int int
vim_isprintc_strict(int c) vim_isprintc_strict(int c)
{ {
#ifdef FEAT_MBYTE
if (enc_dbcs != 0 && c < 0x100 && MB_BYTE2LEN(c) > 1) if (enc_dbcs != 0 && c < 0x100 && MB_BYTE2LEN(c) > 1)
return FALSE; return FALSE;
if (enc_utf8 && c >= 0x100) if (enc_utf8 && c >= 0x100)
return utf_printable(c); return utf_printable(c);
#endif
return (c >= 0x100 || (c > 0 && (g_chartab[c] & CT_PRINT_CHAR))); return (c >= 0x100 || (c > 0 && (g_chartab[c] & CT_PRINT_CHAR)));
} }
@ -1009,10 +960,8 @@ lbr_chartabsize(
if (!curwin->w_p_lbr && *p_sbr == NUL && !curwin->w_p_bri) if (!curwin->w_p_lbr && *p_sbr == NUL && !curwin->w_p_bri)
{ {
#endif #endif
#ifdef FEAT_MBYTE
if (curwin->w_p_wrap) if (curwin->w_p_wrap)
return win_nolbr_chartabsize(curwin, s, col, NULL); return win_nolbr_chartabsize(curwin, s, col, NULL);
#endif
RET_WIN_BUF_CHARTABSIZE(curwin, curbuf, s, col) RET_WIN_BUF_CHARTABSIZE(curwin, curbuf, s, col)
#ifdef FEAT_LINEBREAK #ifdef FEAT_LINEBREAK
} }
@ -1058,11 +1007,7 @@ win_lbr_chartabsize(
colnr_T col_adj = 0; /* col + screen size of tab */ colnr_T col_adj = 0; /* col + screen size of tab */
colnr_T colmax; colnr_T colmax;
int added; int added;
# ifdef FEAT_MBYTE
int mb_added = 0; int mb_added = 0;
# else
# define mb_added 0
# endif
int numberextra; int numberextra;
char_u *ps; char_u *ps;
int tab_corr = (*s == TAB); int tab_corr = (*s == TAB);
@ -1074,10 +1019,8 @@ win_lbr_chartabsize(
if (!wp->w_p_lbr && !wp->w_p_bri && *p_sbr == NUL) if (!wp->w_p_lbr && !wp->w_p_bri && *p_sbr == NUL)
#endif #endif
{ {
#ifdef FEAT_MBYTE
if (wp->w_p_wrap) if (wp->w_p_wrap)
return win_nolbr_chartabsize(wp, s, col, headp); return win_nolbr_chartabsize(wp, s, col, headp);
#endif
RET_WIN_BUF_CHARTABSIZE(wp, wp->w_buffer, s, col) RET_WIN_BUF_CHARTABSIZE(wp, wp->w_buffer, s, col)
} }
@ -1135,14 +1078,12 @@ win_lbr_chartabsize(
} }
} }
} }
# ifdef FEAT_MBYTE
else if (has_mbyte && size == 2 && MB_BYTE2LEN(*s) > 1 else if (has_mbyte && size == 2 && MB_BYTE2LEN(*s) > 1
&& wp->w_p_wrap && in_win_border(wp, col)) && wp->w_p_wrap && in_win_border(wp, col))
{ {
++size; /* Count the ">" in the last column. */ ++size; /* Count the ">" in the last column. */
mb_added = 1; mb_added = 1;
} }
# endif
/* /*
* May have to add something for 'breakindent' and/or 'showbreak' * May have to add something for 'breakindent' and/or 'showbreak'
@ -1210,7 +1151,6 @@ win_lbr_chartabsize(
#endif #endif
} }
#if defined(FEAT_MBYTE) || defined(PROTO)
/* /*
* Like win_lbr_chartabsize(), except that we know 'linebreak' is off and * Like win_lbr_chartabsize(), except that we know 'linebreak' is off and
* 'wrap' is on. This means we need to check for a double-byte character that * 'wrap' is on. This means we need to check for a double-byte character that
@ -1269,7 +1209,6 @@ in_win_border(win_T *wp, colnr_T vcol)
return FALSE; return FALSE;
return ((vcol - width1) % width2 == width2 - 1); return ((vcol - width1) % width2 == width2 - 1);
} }
#endif /* FEAT_MBYTE */
/* /*
* Get virtual column number of pos. * Get virtual column number of pos.
@ -1310,11 +1249,9 @@ getvcol(
if (*ptr == NUL) if (*ptr == NUL)
pos->col = 0; pos->col = 0;
posptr = ptr + pos->col; posptr = ptr + pos->col;
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
/* always start on the first byte */ /* always start on the first byte */
posptr -= (*mb_head_off)(line, posptr); posptr -= (*mb_head_off)(line, posptr);
#endif
} }
/* /*
@ -1329,14 +1266,10 @@ getvcol(
#endif #endif
) )
{ {
#ifndef FEAT_MBYTE
head = 0; head = 0;
#endif
for (;;) for (;;)
{ {
#ifdef FEAT_MBYTE
head = 0; head = 0;
#endif
c = *ptr; c = *ptr;
/* make sure we don't go past the end of the line */ /* make sure we don't go past the end of the line */
if (c == NUL) if (c == NUL)
@ -1353,7 +1286,6 @@ getvcol(
#endif #endif
else else
{ {
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
/* For utf-8, if the byte is >= 0x80, need to look at /* For utf-8, if the byte is >= 0x80, need to look at
@ -1374,7 +1306,6 @@ getvcol(
} }
} }
else else
#endif
incr = g_chartab[c] & CT_CELL_MASK; incr = g_chartab[c] & CT_CELL_MASK;
} }
@ -1460,9 +1391,7 @@ getvvcol(
colnr_T col; colnr_T col;
colnr_T coladd; colnr_T coladd;
colnr_T endadd; colnr_T endadd;
# ifdef FEAT_MBYTE
char_u *ptr; char_u *ptr;
# endif
if (virtual_active()) if (virtual_active())
{ {
@ -1471,7 +1400,6 @@ getvvcol(
coladd = pos->coladd; coladd = pos->coladd;
endadd = 0; endadd = 0;
# ifdef FEAT_MBYTE
/* Cannot put the cursor on part of a wide character. */ /* Cannot put the cursor on part of a wide character. */
ptr = ml_get_buf(wp->w_buffer, pos->lnum, FALSE); ptr = ml_get_buf(wp->w_buffer, pos->lnum, FALSE);
if (pos->col < (colnr_T)STRLEN(ptr)) if (pos->col < (colnr_T)STRLEN(ptr))
@ -1487,7 +1415,6 @@ getvvcol(
coladd = 0; coladd = 0;
} }
} }
# endif
col += coladd; col += coladd;
if (start != NULL) if (start != NULL)
*start = col; *start = col;
@ -1684,7 +1611,6 @@ vim_isbdigit(int c)
return (c == '0' || c == '1'); return (c == '0' || c == '1');
} }
#if defined(FEAT_MBYTE) || defined(PROTO)
/* /*
* Vim's own character class functions. These exist because many library * Vim's own character class functions. These exist because many library
* islower()/toupper() etc. do not work properly: they crash when used with * islower()/toupper() etc. do not work properly: they crash when used with
@ -1797,7 +1723,6 @@ vim_tolower(int c)
return TOLOWER_ASC(c); return TOLOWER_ASC(c);
return TOLOWER_LOC(c); return TOLOWER_LOC(c);
} }
#endif
/* /*
* skiptowhite: skip over text until ' ' or '\t' or NUL. * skiptowhite: skip over text until ' ' or '\t' or NUL.
@ -2077,9 +2002,7 @@ rem_backslash(char_u *str)
{ {
#ifdef BACKSLASH_IN_FILENAME #ifdef BACKSLASH_IN_FILENAME
return (str[0] == '\\' return (str[0] == '\\'
# ifdef FEAT_MBYTE
&& str[1] < 0x80 && str[1] < 0x80
# endif
&& (str[1] == ' ' && (str[1] == ' '
|| (str[1] != NUL || (str[1] != NUL
&& str[1] != '*' && str[1] != '*'

View File

@ -741,12 +741,10 @@ diff_write_buffer(buf_T *buf, diffin_T *din)
if (diff_flags & DIFF_ICASE) if (diff_flags & DIFF_ICASE)
{ {
int c; int c;
// xdiff doesn't support ignoring case, fold-case the text.
#ifdef FEAT_MBYTE
int orig_len; int orig_len;
char_u cbuf[MB_MAXBYTES + 1]; char_u cbuf[MB_MAXBYTES + 1];
// xdiff doesn't support ignoring case, fold-case the text.
c = PTR2CHAR(s); c = PTR2CHAR(s);
c = enc_utf8 ? utf_fold(c) : MB_TOLOWER(c); c = enc_utf8 ? utf_fold(c) : MB_TOLOWER(c);
orig_len = MB_PTR2LEN(s); orig_len = MB_PTR2LEN(s);
@ -758,10 +756,6 @@ diff_write_buffer(buf_T *buf, diffin_T *din)
s += orig_len; s += orig_len;
len += orig_len; len += orig_len;
#else
c = *s++;
ptr[len++] = TOLOWER_LOC(c);
#endif
} }
else else
ptr[len++] = *s++; ptr[len++] = *s++;
@ -1946,7 +1940,6 @@ diff_equal_entry(diff_T *dp, int idx1, int idx2)
static int static int
diff_equal_char(char_u *p1, char_u *p2, int *len) diff_equal_char(char_u *p1, char_u *p2, int *len)
{ {
#ifdef FEAT_MBYTE
int l = (*mb_ptr2len)(p1); int l = (*mb_ptr2len)(p1);
if (l != (*mb_ptr2len)(p2)) if (l != (*mb_ptr2len)(p2))
@ -1962,7 +1955,6 @@ diff_equal_char(char_u *p1, char_u *p2, int *len)
*len = l; *len = l;
} }
else else
#endif
{ {
if ((*p1 != *p2) if ((*p1 != *p2)
&& (!(diff_flags & DIFF_ICASE) && (!(diff_flags & DIFF_ICASE)
@ -2400,7 +2392,6 @@ diff_find_change(
si_new += l; si_new += l;
} }
} }
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
/* Move back to first byte of character in both lines (may /* Move back to first byte of character in both lines (may
@ -2408,7 +2399,6 @@ diff_find_change(
si_org -= (*mb_head_off)(line_org, line_org + si_org); si_org -= (*mb_head_off)(line_org, line_org + si_org);
si_new -= (*mb_head_off)(line_new, line_new + si_new); si_new -= (*mb_head_off)(line_new, line_new + si_new);
} }
#endif
if (*startp > si_org) if (*startp > si_org)
*startp = si_org; *startp = si_org;
@ -2438,10 +2428,8 @@ diff_find_change(
{ {
p1 = line_org + ei_org; p1 = line_org + ei_org;
p2 = line_new + ei_new; p2 = line_new + ei_new;
#ifdef FEAT_MBYTE
p1 -= (*mb_head_off)(line_org, p1); p1 -= (*mb_head_off)(line_org, p1);
p2 -= (*mb_head_off)(line_new, p2); p2 -= (*mb_head_off)(line_new, p2);
#endif
if (!diff_equal_char(p1, p2, &l)) if (!diff_equal_char(p1, p2, &l))
break; break;
ei_org -= l; ei_org -= l;

View File

@ -15,11 +15,7 @@
#if defined(FEAT_DIGRAPHS) || defined(PROTO) #if defined(FEAT_DIGRAPHS) || defined(PROTO)
#ifdef FEAT_MBYTE
typedef int result_T; typedef int result_T;
#else
typedef char_u result_T;
#endif
typedef struct digraph typedef struct digraph
{ {
@ -38,8 +34,8 @@ static garray_T user_digraphs = {0, 0, (int)sizeof(digr_T), 10, NULL};
* compilers cannot handle them (Amiga SAS/C is the most picky one). * compilers cannot handle them (Amiga SAS/C is the most picky one).
*/ */
static digr_T digraphdefault[] = static digr_T digraphdefault[] =
#ifdef __MINT__
#ifdef __MINT__
/* /*
* ATARI digraphs * ATARI digraphs
*/ */
@ -320,137 +316,7 @@ static digr_T digraphdefault[] =
}; };
# else # else
# if defined(MACOS_X) && !defined(FEAT_MBYTE) # ifdef OLD_DIGRAPHS
/*
* Macintosh digraphs
*/
{{'a', 't', 64}, /* @ */
{'A', '"', 128}, /* ~@ XX */
{'A', 'o', 129}, /* Å */
{'C', ',', 130}, /* Ç */
{'E', '\'', 131}, /* É */
{'N', '~', 132}, /* Ñ */
{'O', '"', 133}, /* Ö */
{'U', '"', 134}, /* Ü */
{'a', '\'', 135}, /* ~G XX */
{'a', '`', 136}, /* ~H XX */
{'a', '^', 137}, /* â */
{'a', '"', 138}, /* ä */
{'a', '~', 139}, /* ã */
{'a', 'o', 140}, /* å */
{'c', ',', 141}, /* ç */
{'e', '\'', 142}, /* é */
{'e', '`', 143}, /* è */
{'e', '^', 144}, /* ê */
{'e', '"', 145}, /* ë */
{'i', '\'', 146}, /* í */
{'i', '`', 147}, /* ì */
{'i', '^', 148}, /* î */
{'i', '"', 149}, /* ï */
{'n', '~', 150}, /* ñ */
{'o', '\'', 151}, /* ó */
{'o', '`', 152}, /* ò */
{'o', '^', 153}, /* ô */
{'o', '"', 154}, /* ö */
{'o', '~', 155}, /* o */
{'u', '\'', 156}, /* ú */
{'u', '`', 157}, /* ~] XX */
{'u', '^', 158}, /* û */
{'u', '"', 159}, /* ü */
{'+', '_', 160}, /* Ý */
{'~', 'o', 161}, /* ° */
{'c', '|', 162}, /* ¢ */
{'$', '$', 163}, /* £ */
{'p', 'a', 164}, /* § */
{'.', '.', 165}, /* * */
{'P', 'P', 166}, /* ¶ */
{'s', 's', 167}, /* ß */
{'r', 'O', 168}, /* ® */
{'c', 'O', 169}, /* © */
{'T', 'M', 170}, /* <20> */
{'=', '/', 173}, /* */
{'A', 'E', 174}, /* Æ */
{'O', '/', 175}, /* Ø */
{'0', '0', 176}, /* ƒ */
{'+', '-', 177}, /* ± */
{'<', '=', 178}, /* ¾ */
{'>', '=', 179}, /* „ */
{'Y', '-', 180}, /* ¥ */
{'j', 'u', 181}, /* µ */
{'m', 'u', 181}, /* µ */
{'d', 'd', 182}, /* <20> */
{'S', 'S', 183}, /* … */
{'S', 'I', 183}, /* … */
{'P', 'I', 184}, /* ½ */
{'p', 'i', 185}, /* ¼ */
{'I', 'I', 186}, /* † */
{'a', '-', 187}, /* » */
{'o', '-', 188}, /* º */
{'O', 'M', 189}, /* ½ */
{'a', 'e', 190}, /* æ */
{'o', '/', 191}, /* ø */
{'~', '?', 192}, /* ¿ */
{'~', '!', 193}, /* ¡ */
{'-', ',', 194}, /* ¬ */
{'v', '-', 195}, /* ~H XX */
{'f', '-', 196}, /* Ÿ */
{'~', '~', 197}, /* ‰ */
{'D', 'E', 198}, /* <20> */
{'<', '<', 199}, /* « */
{'>', '>', 200}, /* » */
{'.', ':', 201}, /* Š */
{'A', '`', 203}, /* À */
{'A', '~', 204}, /* Ã */
{'O', '~', 205}, /* Õ */
{'O', 'E', 206}, /* */
{'o', 'e', 207}, /* ¦ */
{'-', '.', 208}, /* - */
{'-', '-', 209}, /* - */
{'`', '`', 210}, /* " */
{'\'', '\'', 211}, /* " */
{'`', ' ', 212}, /* ' */
{'\'', ' ', 213}, /* ' */
{'-', ':', 214}, /* ÷ */
{'D', 'I', 215}, /* × */
{'y', ':', 216}, /* ÿ */
{'Y', ':', 217}, /* <20> */
{'/', '/', 218}, /* Ž */
{'E', '=', 219}, /* ¤ Euro System >=8.5 */
{'o', 'x', 219}, /* ¤ Currency System <=8.1*/
{'<', ' ', 220}, /* Ð */
{'>', ' ', 221}, /* ð */
{'f', 'i', 222}, /* Þ */
{'f', 'l', 223}, /* þ */
{'+', '+', 224}, /* ý */
{'~', '.', 225}, /* · */
{',', ' ', 226}, /* */
{',', ',', 227}, /* “ */
{'%', '.', 228}, /* ” */
{'%', '0', 228}, /* ” */
{'A', '^', 229}, /* Â */
{'E', '^', 230}, /* Ê */
{'A', '\'', 231}, /* Á */
{'E', '"', 232}, /* Ë */
{'E', '`', 233}, /* È */
{'I', '\'', 234}, /* Í */
{'I', '^', 235}, /* Î */
{'I', '"', 236}, /* Ï */
{'I', '`', 237}, /* Ì */
{'O', '\'', 238}, /* Ó */
{'O', '^', 239}, /* Ô */
{'A', 'P', 240}, /* • */
{'O', '`', 241}, /* Ò */
{'U', '\'', 242}, /* Ú */
{'U', '^', 243}, /* Û */
{'U', '`', 244}, /* Ù */
{'i', '.', 245}, /* ž */
{NUL, NUL, NUL}
};
# else /* !MACOS_X */
# ifdef OLD_DIGRAPHS
/* /*
* digraphs compatible with Vim 5.x * digraphs compatible with Vim 5.x
@ -557,7 +423,7 @@ static digr_T digraphdefault[] =
{'y', '"', 255}, /* x XX */ {'y', '"', 255}, /* x XX */
{NUL, NUL, NUL} {NUL, NUL, NUL}
}; };
# else /* OLD_DIGRAPHS */ # else /* OLD_DIGRAPHS */
/* /*
* digraphs for Unicode from RFC1345 * digraphs for Unicode from RFC1345
@ -792,7 +658,6 @@ static digr_T digraphdefault[] =
{'y', ':', 0xff}, {'y', ':', 0xff},
{'y', '"', 0xff}, // x XX Vim 5.x compatible {'y', '"', 0xff}, // x XX Vim 5.x compatible
# ifdef FEAT_MBYTE
# define USE_UNICODE_DIGRAPHS # define USE_UNICODE_DIGRAPHS
{'A', '-', 0x0100}, {'A', '-', 0x0100},
@ -1957,14 +1822,11 @@ static digr_T digraphdefault[] =
{'f', 'l', 0xfb02}, {'f', 'l', 0xfb02},
{'f', 't', 0xfb05}, {'f', 't', 0xfb05},
{'s', 't', 0xfb06}, {'s', 't', 0xfb06},
# endif /* FEAT_MBYTE */
{NUL, NUL, NUL} {NUL, NUL, NUL}
}; };
# endif /* OLD_DIGRAPHS */ # endif /* OLD_DIGRAPHS */
# endif /* Macintosh */
# endif /* EBCDIC */ # endif /* EBCDIC */
# endif /* !HPUX_DIGRAPHS */ # endif /* !HPUX_DIGRAPHS */
#endif /* !__MINT__ */ #endif /* !__MINT__ */
@ -2141,8 +2003,7 @@ getexactdigraph(int char1, int char2, int meta_char)
++dp; ++dp;
} }
} }
#ifdef FEAT_MBYTE #ifdef USE_UNICODE_DIGRAPHS
# ifdef USE_UNICODE_DIGRAPHS
if (retval != 0 && !enc_utf8) if (retval != 0 && !enc_utf8)
{ {
char_u buf[6], *to; char_u buf[6], *to;
@ -2166,12 +2027,11 @@ getexactdigraph(int char1, int char2, int meta_char)
(void)convert_setup(&vc, NULL, NULL); (void)convert_setup(&vc, NULL, NULL);
} }
} }
# endif #endif
/* Ignore multi-byte characters when not in multi-byte mode. */ /* Ignore multi-byte characters when not in multi-byte mode. */
if (!has_mbyte && retval > 0xff) if (!has_mbyte && retval > 0xff)
retval = 0; retval = 0;
#endif
if (retval == 0) /* digraph deleted or not found */ if (retval == 0) /* digraph deleted or not found */
{ {
@ -2297,10 +2157,7 @@ listdigraphs(int use_headers)
#else #else
if (getexactdigraph(dp->char1, dp->char2, FALSE) == dp->result if (getexactdigraph(dp->char1, dp->char2, FALSE) == dp->result
# ifdef FEAT_MBYTE && (has_mbyte || dp->result <= 255))
&& (has_mbyte || dp->result <= 255)
# endif
)
printdigraph(dp, use_headers ? &previous : NULL); printdigraph(dp, use_headers ? &previous : NULL);
#endif #endif
++dp; ++dp;
@ -2364,11 +2221,7 @@ printdigraph(digr_T *dp, result_T *previous)
int list_width; int list_width;
if ((dy_flags & DY_UHEX) if ((dy_flags & DY_UHEX) || has_mbyte)
#ifdef FEAT_MBYTE
|| has_mbyte
#endif
)
list_width = 13; list_width = 13;
else else
list_width = 11; list_width = 11;
@ -2404,7 +2257,6 @@ printdigraph(digr_T *dp, result_T *previous)
*p = NUL; *p = NUL;
msg_outtrans(buf); msg_outtrans(buf);
p = buf; p = buf;
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
/* add a space to draw a composing char on */ /* add a space to draw a composing char on */
@ -2413,7 +2265,6 @@ printdigraph(digr_T *dp, result_T *previous)
p += (*mb_char2bytes)(dp->result, p); p += (*mb_char2bytes)(dp->result, p);
} }
else else
#endif
*p++ = (char_u)dp->result; *p++ = (char_u)dp->result;
*p = NUL; *p = NUL;
msg_outtrans_attr(buf, HL_ATTR(HLF_8)); msg_outtrans_attr(buf, HL_ATTR(HLF_8));
@ -2465,21 +2316,15 @@ keymap_init(void)
/* Source the keymap file. It will contain a ":loadkeymap" command /* Source the keymap file. It will contain a ":loadkeymap" command
* which will call ex_loadkeymap() below. */ * which will call ex_loadkeymap() below. */
buflen = STRLEN(curbuf->b_p_keymap) buflen = STRLEN(curbuf->b_p_keymap) + STRLEN(p_enc) + 14;
# ifdef FEAT_MBYTE
+ STRLEN(p_enc)
# endif
+ 14;
buf = alloc((unsigned)buflen); buf = alloc((unsigned)buflen);
if (buf == NULL) if (buf == NULL)
return e_outofmem; return e_outofmem;
# ifdef FEAT_MBYTE
/* try finding "keymap/'keymap'_'encoding'.vim" in 'runtimepath' */ /* try finding "keymap/'keymap'_'encoding'.vim" in 'runtimepath' */
vim_snprintf((char *)buf, buflen, "keymap/%s_%s.vim", vim_snprintf((char *)buf, buflen, "keymap/%s_%s.vim",
curbuf->b_p_keymap, p_enc); curbuf->b_p_keymap, p_enc);
if (source_runtime(buf, 0) == FAIL) if (source_runtime(buf, 0) == FAIL)
# endif
{ {
/* try finding "keymap/'keymap'.vim" in 'runtimepath' */ /* try finding "keymap/'keymap'.vim" in 'runtimepath' */
vim_snprintf((char *)buf, buflen, "keymap/%s.vim", vim_snprintf((char *)buf, buflen, "keymap/%s.vim",

View File

@ -212,9 +212,7 @@ static int spell_bad_len = 0; /* length of located bad word */
static void stop_insert(pos_T *end_insert_pos, int esc, int nomove); static void stop_insert(pos_T *end_insert_pos, int esc, int nomove);
static int echeck_abbr(int); static int echeck_abbr(int);
static void replace_join(int off); static void replace_join(int off);
#ifdef FEAT_MBYTE
static void mb_replace_pop_ins(int cc); static void mb_replace_pop_ins(int cc);
#endif
static void replace_flush(void); static void replace_flush(void);
static void replace_do_bs(int limit_col); static void replace_do_bs(int limit_col);
static int del_char_after_col(int limit_col); static int del_char_after_col(int limit_col);
@ -567,14 +565,12 @@ edit(
{ {
if (ptr[1] == NUL) if (ptr[1] == NUL)
++curwin->w_cursor.col; ++curwin->w_cursor.col;
#ifdef FEAT_MBYTE
else if (has_mbyte) else if (has_mbyte)
{ {
i = (*mb_ptr2len)(ptr); i = (*mb_ptr2len)(ptr);
if (ptr[i] == NUL) if (ptr[i] == NUL)
curwin->w_cursor.col += i; curwin->w_cursor.col += i;
} }
#endif
} }
ins_at_eol = FALSE; ins_at_eol = FALSE;
} }
@ -1580,12 +1576,10 @@ normalchar:
* special character. Let CTRL-] expand abbreviations without * special character. Let CTRL-] expand abbreviations without
* inserting it. */ * inserting it. */
if (vim_iswordc(c) || (!echeck_abbr( if (vim_iswordc(c) || (!echeck_abbr(
#ifdef FEAT_MBYTE // Add ABBR_OFF for characters above 0x100, this is
/* Add ABBR_OFF for characters above 0x100, this is // what check_abbr() expects.
* what check_abbr() expects. */ (has_mbyte && c >= 0x100) ? (c + ABBR_OFF) : c)
(has_mbyte && c >= 0x100) ? (c + ABBR_OFF) : && c != Ctrl_RSB))
#endif
c) && c != Ctrl_RSB))
{ {
insert_special(c, FALSE, FALSE); insert_special(c, FALSE, FALSE);
#ifdef FEAT_RIGHTLEFT #ifdef FEAT_RIGHTLEFT
@ -1835,14 +1829,11 @@ edit_putchar(int c, int highlight)
attr = 0; attr = 0;
pc_row = W_WINROW(curwin) + curwin->w_wrow; pc_row = W_WINROW(curwin) + curwin->w_wrow;
pc_col = curwin->w_wincol; pc_col = curwin->w_wincol;
#if defined(FEAT_RIGHTLEFT) || defined(FEAT_MBYTE)
pc_status = PC_STATUS_UNSET; pc_status = PC_STATUS_UNSET;
#endif
#ifdef FEAT_RIGHTLEFT #ifdef FEAT_RIGHTLEFT
if (curwin->w_p_rl) if (curwin->w_p_rl)
{ {
pc_col += curwin->w_width - 1 - curwin->w_wcol; pc_col += curwin->w_width - 1 - curwin->w_wcol;
# ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
int fix_col = mb_fix_col(pc_col, pc_row); int fix_col = mb_fix_col(pc_col, pc_row);
@ -1854,22 +1845,17 @@ edit_putchar(int c, int highlight)
pc_status = PC_STATUS_RIGHT; pc_status = PC_STATUS_RIGHT;
} }
} }
# endif
} }
else else
#endif #endif
{ {
pc_col += curwin->w_wcol; pc_col += curwin->w_wcol;
#ifdef FEAT_MBYTE
if (mb_lefthalve(pc_row, pc_col)) if (mb_lefthalve(pc_row, pc_col))
pc_status = PC_STATUS_LEFT; pc_status = PC_STATUS_LEFT;
#endif
} }
/* save the character to be able to put it back */ /* save the character to be able to put it back */
#if defined(FEAT_RIGHTLEFT) || defined(FEAT_MBYTE)
if (pc_status == PC_STATUS_UNSET) if (pc_status == PC_STATUS_UNSET)
#endif
{ {
screen_getbytes(pc_row, pc_col, pc_bytes, &pc_attr); screen_getbytes(pc_row, pc_col, pc_bytes, &pc_attr);
pc_status = PC_STATUS_SET; pc_status = PC_STATUS_SET;
@ -1953,13 +1939,11 @@ edit_unputchar(void)
{ {
if (pc_status != PC_STATUS_UNSET && pc_row >= msg_scrolled) if (pc_status != PC_STATUS_UNSET && pc_row >= msg_scrolled)
{ {
#if defined(FEAT_MBYTE)
if (pc_status == PC_STATUS_RIGHT) if (pc_status == PC_STATUS_RIGHT)
++curwin->w_wcol; ++curwin->w_wcol;
if (pc_status == PC_STATUS_RIGHT || pc_status == PC_STATUS_LEFT) if (pc_status == PC_STATUS_RIGHT || pc_status == PC_STATUS_LEFT)
redrawWinline(curwin, curwin->w_cursor.lnum); redrawWinline(curwin, curwin->w_cursor.lnum);
else else
#endif
screen_puts(pc_bytes, pc_row - msg_scrolled, pc_col, pc_attr); screen_puts(pc_bytes, pc_row - msg_scrolled, pc_col, pc_attr);
} }
} }
@ -1979,7 +1963,6 @@ display_dollar(colnr_T col)
cursor_off(); cursor_off();
save_col = curwin->w_cursor.col; save_col = curwin->w_cursor.col;
curwin->w_cursor.col = col; curwin->w_cursor.col = col;
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
char_u *p; char_u *p;
@ -1988,7 +1971,6 @@ display_dollar(colnr_T col)
p = ml_get_curline(); p = ml_get_curline();
curwin->w_cursor.col -= (*mb_head_off)(p, p + col); curwin->w_cursor.col -= (*mb_head_off)(p, p + col);
} }
#endif
curs_columns(FALSE); /* recompute w_wrow and w_wcol */ curs_columns(FALSE); /* recompute w_wrow and w_wcol */
if (curwin->w_wcol < curwin->w_width) if (curwin->w_wcol < curwin->w_width)
{ {
@ -2132,11 +2114,9 @@ change_indent(
while (vcol <= (int)curwin->w_virtcol) while (vcol <= (int)curwin->w_virtcol)
{ {
last_vcol = vcol; last_vcol = vcol;
#ifdef FEAT_MBYTE
if (has_mbyte && new_cursor_col >= 0) if (has_mbyte && new_cursor_col >= 0)
new_cursor_col += (*mb_ptr2len)(ptr + new_cursor_col); new_cursor_col += (*mb_ptr2len)(ptr + new_cursor_col);
else else
#endif
++new_cursor_col; ++new_cursor_col;
vcol += lbr_chartabsize(ptr, ptr + new_cursor_col, (colnr_T)vcol); vcol += lbr_chartabsize(ptr, ptr + new_cursor_col, (colnr_T)vcol);
} }
@ -2302,7 +2282,6 @@ backspace_until_column(int col)
static int static int
del_char_after_col(int limit_col UNUSED) del_char_after_col(int limit_col UNUSED)
{ {
#ifdef FEAT_MBYTE
if (enc_utf8 && limit_col >= 0) if (enc_utf8 && limit_col >= 0)
{ {
colnr_T ecol = curwin->w_cursor.col + 1; colnr_T ecol = curwin->w_cursor.col + 1;
@ -2324,7 +2303,6 @@ del_char_after_col(int limit_col UNUSED)
del_bytes((long)((int)ecol - curwin->w_cursor.col), FALSE, TRUE); del_bytes((long)((int)ecol - curwin->w_cursor.col), FALSE, TRUE);
} }
else else
#endif
(void)del_char(FALSE); (void)del_char(FALSE);
return TRUE; return TRUE;
} }
@ -2529,7 +2507,6 @@ ins_compl_add_infercase(
/* Infer case of completed part. */ /* Infer case of completed part. */
/* Find actual length of completion. */ /* Find actual length of completion. */
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
p = str; p = str;
@ -2541,11 +2518,9 @@ ins_compl_add_infercase(
} }
} }
else else
#endif
actual_len = len; actual_len = len;
/* Find actual length of original text. */ /* Find actual length of original text. */
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
p = compl_orig_text; p = compl_orig_text;
@ -2557,7 +2532,6 @@ ins_compl_add_infercase(
} }
} }
else else
#endif
actual_compl_length = compl_length; actual_compl_length = compl_length;
/* "actual_len" may be smaller than "actual_compl_length" when using /* "actual_len" may be smaller than "actual_compl_length" when using
@ -2571,22 +2545,18 @@ ins_compl_add_infercase(
{ {
p = str; p = str;
for (i = 0; i < actual_len; ++i) for (i = 0; i < actual_len; ++i)
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
wca[i] = mb_ptr2char_adv(&p); wca[i] = mb_ptr2char_adv(&p);
else else
#endif
wca[i] = *(p++); wca[i] = *(p++);
/* Rule 1: Were any chars converted to lower? */ /* Rule 1: Were any chars converted to lower? */
p = compl_orig_text; p = compl_orig_text;
for (i = 0; i < min_len; ++i) for (i = 0; i < min_len; ++i)
{ {
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
c = mb_ptr2char_adv(&p); c = mb_ptr2char_adv(&p);
else else
#endif
c = *(p++); c = *(p++);
if (MB_ISLOWER(c)) if (MB_ISLOWER(c))
{ {
@ -2610,11 +2580,9 @@ ins_compl_add_infercase(
p = compl_orig_text; p = compl_orig_text;
for (i = 0; i < min_len; ++i) for (i = 0; i < min_len; ++i)
{ {
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
c = mb_ptr2char_adv(&p); c = mb_ptr2char_adv(&p);
else else
#endif
c = *(p++); c = *(p++);
if (was_letter && MB_ISUPPER(c) && MB_ISLOWER(wca[i])) if (was_letter && MB_ISUPPER(c) && MB_ISLOWER(wca[i]))
{ {
@ -2631,11 +2599,9 @@ ins_compl_add_infercase(
p = compl_orig_text; p = compl_orig_text;
for (i = 0; i < min_len; ++i) for (i = 0; i < min_len; ++i)
{ {
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
c = mb_ptr2char_adv(&p); c = mb_ptr2char_adv(&p);
else else
#endif
c = *(p++); c = *(p++);
if (MB_ISLOWER(c)) if (MB_ISLOWER(c))
wca[i] = MB_TOLOWER(wca[i]); wca[i] = MB_TOLOWER(wca[i]);
@ -2652,11 +2618,9 @@ ins_compl_add_infercase(
p = IObuff; p = IObuff;
i = 0; i = 0;
while (i < actual_len && (p - IObuff + 6) < IOSIZE) while (i < actual_len && (p - IObuff + 6) < IOSIZE)
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
p += (*mb_char2bytes)(wca[i++], p); p += (*mb_char2bytes)(wca[i++], p);
else else
#endif
*(p++) = wca[i++]; *(p++) = wca[i++];
*p = NUL; *p = NUL;
@ -2837,14 +2801,12 @@ ins_compl_longest_match(compl_T *match)
s = match->cp_str; s = match->cp_str;
while (*p != NUL) while (*p != NUL)
{ {
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
c1 = mb_ptr2char(p); c1 = mb_ptr2char(p);
c2 = mb_ptr2char(s); c2 = mb_ptr2char(s);
} }
else else
#endif
{ {
c1 = *p; c1 = *p;
c2 = *s; c2 = *s;
@ -2852,14 +2814,12 @@ ins_compl_longest_match(compl_T *match)
if (match->cp_icase ? (MB_TOLOWER(c1) != MB_TOLOWER(c2)) if (match->cp_icase ? (MB_TOLOWER(c1) != MB_TOLOWER(c2))
: (c1 != c2)) : (c1 != c2))
break; break;
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
MB_PTR_ADV(p); MB_PTR_ADV(p);
MB_PTR_ADV(s); MB_PTR_ADV(s);
} }
else else
#endif
{ {
++p; ++p;
++s; ++s;
@ -3426,7 +3386,6 @@ ins_compl_files(
wstart = ptr; wstart = ptr;
/* Find end of the word. */ /* Find end of the word. */
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
/* Japanese words may have characters in /* Japanese words may have characters in
* different classes, only separate words * different classes, only separate words
@ -3440,7 +3399,6 @@ ins_compl_files(
ptr += l; ptr += l;
} }
else else
#endif
ptr = find_word_end(ptr); ptr = find_word_end(ptr);
/* Add the word. Skip the regexp match. */ /* Add the word. Skip the regexp match. */
@ -3475,12 +3433,10 @@ ins_compl_files(
char_u * char_u *
find_word_start(char_u *ptr) find_word_start(char_u *ptr)
{ {
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
while (*ptr != NUL && *ptr != '\n' && mb_get_class(ptr) <= 1) while (*ptr != NUL && *ptr != '\n' && mb_get_class(ptr) <= 1)
ptr += (*mb_ptr2len)(ptr); ptr += (*mb_ptr2len)(ptr);
else else
#endif
while (*ptr != NUL && *ptr != '\n' && !vim_iswordc(*ptr)) while (*ptr != NUL && *ptr != '\n' && !vim_iswordc(*ptr))
++ptr; ++ptr;
return ptr; return ptr;
@ -3493,7 +3449,6 @@ find_word_start(char_u *ptr)
char_u * char_u *
find_word_end(char_u *ptr) find_word_end(char_u *ptr)
{ {
#ifdef FEAT_MBYTE
int start_class; int start_class;
if (has_mbyte) if (has_mbyte)
@ -3508,7 +3463,6 @@ find_word_end(char_u *ptr)
} }
} }
else else
#endif
while (vim_iswordc(*ptr)) while (vim_iswordc(*ptr))
++ptr; ++ptr;
return ptr; return ptr;
@ -3719,13 +3673,10 @@ ins_compl_len(void)
static void static void
ins_compl_addleader(int c) ins_compl_addleader(int c)
{ {
#ifdef FEAT_MBYTE
int cc; int cc;
#endif
if (stop_arrow() == FAIL) if (stop_arrow() == FAIL)
return; return;
#ifdef FEAT_MBYTE
if (has_mbyte && (cc = (*mb_char2len)(c)) > 1) if (has_mbyte && (cc = (*mb_char2len)(c)) > 1)
{ {
char_u buf[MB_MAXBYTES + 1]; char_u buf[MB_MAXBYTES + 1];
@ -3737,7 +3688,6 @@ ins_compl_addleader(int c)
AppendToRedobuff(buf); AppendToRedobuff(buf);
} }
else else
#endif
{ {
ins_char(c); ins_char(c);
if (compl_opt_refresh_always) if (compl_opt_refresh_always)
@ -4155,10 +4105,8 @@ ins_compl_fixRedoBufForLeader(char_u *ptr_arg)
p = compl_orig_text; p = compl_orig_text;
for (len = 0; p[len] != NUL && p[len] == ptr[len]; ++len) for (len = 0; p[len] != NUL && p[len] == ptr[len]; ++len)
; ;
#ifdef FEAT_MBYTE
if (len > 0) if (len > 0)
len -= (*mb_head_off)(p, p + len); len -= (*mb_head_off)(p, p + len);
#endif
for (p += len; *p != NUL; MB_PTR_ADV(p)) for (p += len; *p != NUL; MB_PTR_ADV(p))
AppendCharToRedobuff(K_BS); AppendCharToRedobuff(K_BS);
} }
@ -5416,25 +5364,14 @@ ins_complete(int c, int enable_pum)
return FAIL; return FAIL;
if (!vim_iswordp(line + compl_col) if (!vim_iswordp(line + compl_col)
|| (compl_col > 0 || (compl_col > 0
&& ( && (vim_iswordp(mb_prevptr(line, line + compl_col)))))
#ifdef FEAT_MBYTE
vim_iswordp(mb_prevptr(line, line + compl_col))
#else
vim_iswordc(line[compl_col - 1])
#endif
)))
prefix = (char_u *)""; prefix = (char_u *)"";
STRCPY((char *)compl_pattern, prefix); STRCPY((char *)compl_pattern, prefix);
(void)quote_meta(compl_pattern + STRLEN(prefix), (void)quote_meta(compl_pattern + STRLEN(prefix),
line + compl_col, compl_length); line + compl_col, compl_length);
} }
else if (--startcol < 0 || else if (--startcol < 0
#ifdef FEAT_MBYTE || !vim_iswordp(mb_prevptr(line, line + startcol + 1)))
!vim_iswordp(mb_prevptr(line, line + startcol + 1))
#else
!vim_iswordc(line[startcol])
#endif
)
{ {
/* Match any word of at least two chars */ /* Match any word of at least two chars */
compl_pattern = vim_strsave((char_u *)"\\<\\k\\k"); compl_pattern = vim_strsave((char_u *)"\\<\\k\\k");
@ -5445,7 +5382,6 @@ ins_complete(int c, int enable_pum)
} }
else else
{ {
#ifdef FEAT_MBYTE
/* Search the point of change class of multibyte character /* Search the point of change class of multibyte character
* or not a word single byte character backward. */ * or not a word single byte character backward. */
if (has_mbyte) if (has_mbyte)
@ -5465,7 +5401,6 @@ ins_complete(int c, int enable_pum)
} }
} }
else else
#endif
while (--startcol >= 0 && vim_iswordc(line[startcol])) while (--startcol >= 0 && vim_iswordc(line[startcol]))
; ;
compl_col += ++startcol; compl_col += ++startcol;
@ -5956,7 +5891,6 @@ quote_meta(char_u *dest, char_u *src, int len)
} }
if (dest != NULL) if (dest != NULL)
*dest++ = *src; *dest++ = *src;
# ifdef FEAT_MBYTE
/* Copy remaining bytes of a multibyte character. */ /* Copy remaining bytes of a multibyte character. */
if (has_mbyte) if (has_mbyte)
{ {
@ -5972,7 +5906,6 @@ quote_meta(char_u *dest, char_u *src, int len)
*dest++ = *src; *dest++ = *src;
} }
} }
# endif
} }
if (dest != NULL) if (dest != NULL)
*dest = NUL; *dest = NUL;
@ -5995,9 +5928,7 @@ get_literal(void)
int i; int i;
int hex = FALSE; int hex = FALSE;
int octal = FALSE; int octal = FALSE;
#ifdef FEAT_MBYTE
int unicode = 0; int unicode = 0;
#endif
if (got_int) if (got_int)
return Ctrl_C; return Ctrl_C;
@ -6022,28 +5953,18 @@ get_literal(void)
{ {
nc = plain_vgetc(); nc = plain_vgetc();
#ifdef FEAT_CMDL_INFO #ifdef FEAT_CMDL_INFO
if (!(State & CMDLINE) if (!(State & CMDLINE) && MB_BYTE2LEN_CHECK(nc) == 1)
# ifdef FEAT_MBYTE
&& MB_BYTE2LEN_CHECK(nc) == 1
# endif
)
add_to_showcmd(nc); add_to_showcmd(nc);
#endif #endif
if (nc == 'x' || nc == 'X') if (nc == 'x' || nc == 'X')
hex = TRUE; hex = TRUE;
else if (nc == 'o' || nc == 'O') else if (nc == 'o' || nc == 'O')
octal = TRUE; octal = TRUE;
#ifdef FEAT_MBYTE
else if (nc == 'u' || nc == 'U') else if (nc == 'u' || nc == 'U')
unicode = nc; unicode = nc;
#endif
else else
{ {
if (hex if (hex || unicode != 0)
#ifdef FEAT_MBYTE
|| unicode != 0
#endif
)
{ {
if (!vim_isxdigit(nc)) if (!vim_isxdigit(nc))
break; break;
@ -6065,11 +5986,7 @@ get_literal(void)
++i; ++i;
} }
if (cc > 255 if (cc > 255 && unicode == 0)
#ifdef FEAT_MBYTE
&& unicode == 0
#endif
)
cc = 255; /* limit range to 0-255 */ cc = 255; /* limit range to 0-255 */
nc = 0; nc = 0;
@ -6078,13 +5995,11 @@ get_literal(void)
if (i >= 2) if (i >= 2)
break; break;
} }
#ifdef FEAT_MBYTE
else if (unicode) /* Unicode: up to four or eight chars */ else if (unicode) /* Unicode: up to four or eight chars */
{ {
if ((unicode == 'u' && i >= 4) || (unicode == 'U' && i >= 8)) if ((unicode == 'u' && i >= 4) || (unicode == 'U' && i >= 8))
break; break;
} }
#endif
else if (i >= 3) /* decimal or octal: up to three chars */ else if (i >= 3) /* decimal or octal: up to three chars */
break; break;
} }
@ -6104,11 +6019,9 @@ get_literal(void)
if (cc == 0) /* NUL is stored as NL */ if (cc == 0) /* NUL is stored as NL */
cc = '\n'; cc = '\n';
#ifdef FEAT_MBYTE
if (enc_dbcs && (cc & 0xff) == 0) if (enc_dbcs && (cc & 0xff) == 0)
cc = '?'; /* don't accept an illegal DBCS char, the NUL in the cc = '?'; /* don't accept an illegal DBCS char, the NUL in the
second byte will cause trouble! */ second byte will cause trouble! */
#endif
--no_mapping; --no_mapping;
#ifdef FEAT_GUI #ifdef FEAT_GUI
@ -6179,11 +6092,7 @@ insert_special(
# define ISSPECIAL(c) ((c) < ' ' || (c) >= DEL || (c) == '0' || (c) == '^') # define ISSPECIAL(c) ((c) < ' ' || (c) >= DEL || (c) == '0' || (c) == '^')
#endif #endif
#ifdef FEAT_MBYTE #define WHITECHAR(cc) (VIM_ISWHITE(cc) && (!enc_utf8 || !utf_iscomposing(utf_ptr2char(ml_get_cursor() + 1))))
# define WHITECHAR(cc) (VIM_ISWHITE(cc) && (!enc_utf8 || !utf_iscomposing(utf_ptr2char(ml_get_cursor() + 1))))
#else
# define WHITECHAR(cc) VIM_ISWHITE(cc)
#endif
/* /*
* "flags": INSCHAR_FORMAT - force formatting * "flags": INSCHAR_FORMAT - force formatting
@ -6340,9 +6249,7 @@ insertchar(
#endif #endif
if ( !ISSPECIAL(c) if ( !ISSPECIAL(c)
#ifdef FEAT_MBYTE
&& (!has_mbyte || (*mb_char2len)(c) == 1) && (!has_mbyte || (*mb_char2len)(c) == 1)
#endif
&& !has_insertcharpre() && !has_insertcharpre()
&& vpeekc() != NUL && vpeekc() != NUL
&& !(State & REPLACE_FLAG) && !(State & REPLACE_FLAG)
@ -6373,9 +6280,7 @@ insertchar(
*/ */
while ( (c = vpeekc()) != NUL while ( (c = vpeekc()) != NUL
&& !ISSPECIAL(c) && !ISSPECIAL(c)
#ifdef FEAT_MBYTE
&& (!has_mbyte || MB_BYTE2LEN_CHECK(c) == 1) && (!has_mbyte || MB_BYTE2LEN_CHECK(c) == 1)
#endif
&& i < INPUT_BUFLEN && i < INPUT_BUFLEN
# ifdef FEAT_FKMAP # ifdef FEAT_FKMAP
&& !(p_fkmap && KeyTyped) /* Farsi mode mapping moves cursor */ && !(p_fkmap && KeyTyped) /* Farsi mode mapping moves cursor */
@ -6412,7 +6317,6 @@ insertchar(
} }
else else
{ {
#ifdef FEAT_MBYTE
int cc; int cc;
if (has_mbyte && (cc = (*mb_char2len)(c)) > 1) if (has_mbyte && (cc = (*mb_char2len)(c)) > 1)
@ -6425,7 +6329,6 @@ insertchar(
AppendCharToRedobuff(c); AppendCharToRedobuff(c);
} }
else else
#endif
{ {
ins_char(c); ins_char(c);
if (flags & INSCHAR_CTRLV) if (flags & INSCHAR_CTRLV)
@ -6454,9 +6357,7 @@ internal_format(
int save_char = NUL; int save_char = NUL;
int haveto_redraw = FALSE; int haveto_redraw = FALSE;
int fo_ins_blank = has_format_option(FO_INS_BLANK); int fo_ins_blank = has_format_option(FO_INS_BLANK);
#ifdef FEAT_MBYTE
int fo_multibyte = has_format_option(FO_MBYTE_BREAK); int fo_multibyte = has_format_option(FO_MBYTE_BREAK);
#endif
int fo_white_par = has_format_option(FO_WHITE_PAR); int fo_white_par = has_format_option(FO_WHITE_PAR);
int first_line = TRUE; int first_line = TRUE;
#ifdef FEAT_COMMENTS #ifdef FEAT_COMMENTS
@ -6613,7 +6514,6 @@ internal_format(
if (curwin->w_cursor.col <= (colnr_T)wantcol) if (curwin->w_cursor.col <= (colnr_T)wantcol)
break; break;
} }
#ifdef FEAT_MBYTE
else if (cc >= 0x100 && fo_multibyte) else if (cc >= 0x100 && fo_multibyte)
{ {
/* Break after or before a multi-byte character. */ /* Break after or before a multi-byte character. */
@ -6660,7 +6560,6 @@ internal_format(
if (curwin->w_cursor.col <= (colnr_T)wantcol) if (curwin->w_cursor.col <= (colnr_T)wantcol)
break; break;
} }
#endif
if (curwin->w_cursor.col == 0) if (curwin->w_cursor.col == 0)
break; break;
dec_cursor(); dec_cursor();
@ -7350,7 +7249,6 @@ free_last_insert(void)
char_u * char_u *
add_char2buf(int c, char_u *s) add_char2buf(int c, char_u *s)
{ {
#ifdef FEAT_MBYTE
char_u temp[MB_MAXBYTES + 1]; char_u temp[MB_MAXBYTES + 1];
int i; int i;
int len; int len;
@ -7359,7 +7257,6 @@ add_char2buf(int c, char_u *s)
for (i = 0; i < len; ++i) for (i = 0; i < len; ++i)
{ {
c = temp[i]; c = temp[i];
#endif
/* Need to escape K_SPECIAL and CSI like in the typeahead buffer. */ /* Need to escape K_SPECIAL and CSI like in the typeahead buffer. */
if (c == K_SPECIAL) if (c == K_SPECIAL)
{ {
@ -7377,9 +7274,7 @@ add_char2buf(int c, char_u *s)
#endif #endif
else else
*s++ = c; *s++ = c;
#ifdef FEAT_MBYTE
} }
#endif
return s; return s;
} }
@ -7435,13 +7330,8 @@ oneright(void)
/* Adjust for multi-wide char (excluding TAB) */ /* Adjust for multi-wide char (excluding TAB) */
ptr = ml_get_cursor(); ptr = ml_get_cursor();
coladvance(getviscol() + ((*ptr != TAB && vim_isprintc( coladvance(getviscol() + ((*ptr != TAB
# ifdef FEAT_MBYTE && vim_isprintc((*mb_ptr2char)(ptr)))
(*mb_ptr2char)(ptr)
# else
*ptr
# endif
))
? ptr2cells(ptr) : 1)); ? ptr2cells(ptr) : 1));
curwin->w_set_curswant = TRUE; curwin->w_set_curswant = TRUE;
/* Return OK if the cursor moved, FAIL otherwise (at window edge). */ /* Return OK if the cursor moved, FAIL otherwise (at window edge). */
@ -7454,11 +7344,9 @@ oneright(void)
if (*ptr == NUL) if (*ptr == NUL)
return FAIL; /* already at the very end */ return FAIL; /* already at the very end */
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
l = (*mb_ptr2len)(ptr); l = (*mb_ptr2len)(ptr);
else else
#endif
l = 1; l = 1;
/* move "l" bytes right, but don't end up on the NUL, unless 'virtualedit' /* move "l" bytes right, but don't end up on the NUL, unless 'virtualedit'
@ -7499,10 +7387,7 @@ oneleft(void)
* 'breakindent' is not set and there are no multi-byte * 'breakindent' is not set and there are no multi-byte
* characters */ * characters */
if ((*p_sbr == NUL && !curwin->w_p_bri if ((*p_sbr == NUL && !curwin->w_p_bri
# ifdef FEAT_MBYTE && !has_mbyte) || getviscol() < v)
&& !has_mbyte
# endif
) || getviscol() < v)
break; break;
++width; ++width;
} }
@ -7516,13 +7401,8 @@ oneleft(void)
/* Adjust for multi-wide char (not a TAB) */ /* Adjust for multi-wide char (not a TAB) */
ptr = ml_get_cursor(); ptr = ml_get_cursor();
if (*ptr != TAB && vim_isprintc( if (*ptr != TAB && vim_isprintc((*mb_ptr2char)(ptr))
# ifdef FEAT_MBYTE && ptr2cells(ptr) > 1)
(*mb_ptr2char)(ptr)
# else
*ptr
# endif
) && ptr2cells(ptr) > 1)
curwin->w_cursor.coladd = 0; curwin->w_cursor.coladd = 0;
} }
@ -7537,12 +7417,10 @@ oneleft(void)
curwin->w_set_curswant = TRUE; curwin->w_set_curswant = TRUE;
--curwin->w_cursor.col; --curwin->w_cursor.col;
#ifdef FEAT_MBYTE
/* if the character on the left of the current cursor is a multi-byte /* if the character on the left of the current cursor is a multi-byte
* character, move to its first byte */ * character, move to its first byte */
if (has_mbyte) if (has_mbyte)
mb_adjust_cursor(); mb_adjust_cursor();
#endif
return OK; return OK;
} }
@ -7829,7 +7707,6 @@ replace_push(
++replace_stack_nr; ++replace_stack_nr;
} }
#if defined(FEAT_MBYTE) || defined(PROTO)
/* /*
* Push a character onto the replace stack. Handles a multi-byte character in * Push a character onto the replace stack. Handles a multi-byte character in
* reverse byte order, so that the first byte is popped off first. * reverse byte order, so that the first byte is popped off first.
@ -7845,7 +7722,6 @@ replace_push_mb(char_u *p)
replace_push(p[j]); replace_push(p[j]);
return l; return l;
} }
#endif
/* /*
* Pop one item from the replace stack. * Pop one item from the replace stack.
@ -7893,17 +7769,12 @@ replace_pop_ins(void)
State = NORMAL; /* don't want REPLACE here */ State = NORMAL; /* don't want REPLACE here */
while ((cc = replace_pop()) > 0) while ((cc = replace_pop()) > 0)
{ {
#ifdef FEAT_MBYTE
mb_replace_pop_ins(cc); mb_replace_pop_ins(cc);
#else
ins_char(cc);
#endif
dec_cursor(); dec_cursor();
} }
State = oldState; State = oldState;
} }
#ifdef FEAT_MBYTE
/* /*
* Insert bytes popped from the replace stack. "cc" is the first byte. If it * Insert bytes popped from the replace stack. "cc" is the first byte. If it
* indicates a multi-byte char, pop the other bytes too. * indicates a multi-byte char, pop the other bytes too.
@ -7956,7 +7827,6 @@ mb_replace_pop_ins(int cc)
} }
} }
} }
#endif
/* /*
* make the replace stack empty * make the replace stack empty
@ -8012,7 +7882,6 @@ replace_do_bs(int limit_col)
getvcol(curwin, &curwin->w_cursor, NULL, &start_vcol, NULL); getvcol(curwin, &curwin->w_cursor, NULL, &start_vcol, NULL);
orig_vcols = chartabsize(ml_get_cursor(), start_vcol); orig_vcols = chartabsize(ml_get_cursor(), start_vcol);
} }
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
(void)del_char_after_col(limit_col); (void)del_char_after_col(limit_col);
@ -8021,7 +7890,6 @@ replace_do_bs(int limit_col)
replace_push(cc); replace_push(cc);
} }
else else
#endif
{ {
pchar_cursor(cc); pchar_cursor(cc);
if (State & VREPLACE_FLAG) if (State & VREPLACE_FLAG)
@ -8038,9 +7906,7 @@ replace_do_bs(int limit_col)
for (i = 0; i < ins_len; ++i) for (i = 0; i < ins_len; ++i)
{ {
vcol += chartabsize(p + i, vcol); vcol += chartabsize(p + i, vcol);
#ifdef FEAT_MBYTE
i += (*mb_ptr2len)(p) - 1; i += (*mb_ptr2len)(p) - 1;
#endif
} }
vcol -= start_vcol; vcol -= start_vcol;
@ -8329,7 +8195,6 @@ in_cinkeys(
/* Just completed a word, check if it starts with "look". /* Just completed a word, check if it starts with "look".
* search back for the start of a word. */ * search back for the start of a word. */
line = ml_get_curline(); line = ml_get_curline();
# ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
char_u *n; char_u *n;
@ -8342,7 +8207,6 @@ in_cinkeys(
} }
} }
else else
# endif
for (s = line + curwin->w_cursor.col; s > line; --s) for (s = line + curwin->w_cursor.col; s > line; --s)
if (!vim_iswordc(s[-1])) if (!vim_iswordc(s[-1]))
break; break;
@ -8823,11 +8687,9 @@ ins_esc(
#endif #endif
{ {
--curwin->w_cursor.col; --curwin->w_cursor.col;
#ifdef FEAT_MBYTE
/* Correct cursor for multi-byte character. */ /* Correct cursor for multi-byte character. */
if (has_mbyte) if (has_mbyte)
mb_adjust_cursor(); mb_adjust_cursor();
#endif
} }
} }
@ -9137,9 +8999,7 @@ ins_bs(
int did_backspace = FALSE; int did_backspace = FALSE;
int in_indent; int in_indent;
int oldState; int oldState;
#ifdef FEAT_MBYTE
int cpc[MAX_MCO]; /* composing characters */ int cpc[MAX_MCO]; /* composing characters */
#endif
/* /*
* can't delete anything in an empty file * can't delete anything in an empty file
@ -9287,11 +9147,7 @@ ins_bs(
while (cc > 0) while (cc > 0)
{ {
save_col = curwin->w_cursor.col; save_col = curwin->w_cursor.col;
#ifdef FEAT_MBYTE
mb_replace_pop_ins(cc); mb_replace_pop_ins(cc);
#else
ins_char(cc);
#endif
curwin->w_cursor.col = save_col; curwin->w_cursor.col = save_col;
cc = replace_pop(); cc = replace_pop();
} }
@ -9413,12 +9269,10 @@ ins_bs(
*/ */
else else
{ {
#ifdef FEAT_MBYTE
int cclass = 0, prev_cclass = 0; int cclass = 0, prev_cclass = 0;
if (has_mbyte) if (has_mbyte)
cclass = mb_get_class(ml_get_cursor()); cclass = mb_get_class(ml_get_cursor());
#endif
do do
{ {
#ifdef FEAT_RIGHTLEFT #ifdef FEAT_RIGHTLEFT
@ -9427,14 +9281,12 @@ ins_bs(
dec_cursor(); dec_cursor();
cc = gchar_cursor(); cc = gchar_cursor();
#ifdef FEAT_MBYTE
/* look multi-byte character class */ /* look multi-byte character class */
if (has_mbyte) if (has_mbyte)
{ {
prev_cclass = cclass; prev_cclass = cclass;
cclass = mb_get_class(ml_get_cursor()); cclass = mb_get_class(ml_get_cursor());
} }
#endif
/* start of word? */ /* start of word? */
if (mode == BACKSPACE_WORD && !vim_isspace(cc)) if (mode == BACKSPACE_WORD && !vim_isspace(cc))
@ -9445,10 +9297,7 @@ ins_bs(
/* end of word? */ /* end of word? */
else if (mode == BACKSPACE_WORD_NOT_SPACE else if (mode == BACKSPACE_WORD_NOT_SPACE
&& ((vim_isspace(cc) || vim_iswordc(cc) != temp) && ((vim_isspace(cc) || vim_iswordc(cc) != temp)
#ifdef FEAT_MBYTE || prev_cclass != cclass))
|| prev_cclass != cclass
#endif
))
{ {
#ifdef FEAT_RIGHTLEFT #ifdef FEAT_RIGHTLEFT
if (!revins_on) if (!revins_on)
@ -9464,12 +9313,9 @@ ins_bs(
replace_do_bs(-1); replace_do_bs(-1);
else else
{ {
#ifdef FEAT_MBYTE
if (enc_utf8 && p_deco) if (enc_utf8 && p_deco)
(void)utfc_ptr2char(ml_get_cursor(), cpc); (void)utfc_ptr2char(ml_get_cursor(), cpc);
#endif
(void)del_char(FALSE); (void)del_char(FALSE);
#ifdef FEAT_MBYTE
/* /*
* If there are combining characters and 'delcombine' is set * If there are combining characters and 'delcombine' is set
* move the cursor back. Don't back up before the base * move the cursor back. Don't back up before the base
@ -9477,7 +9323,6 @@ ins_bs(
*/ */
if (enc_utf8 && p_deco && cpc[0] != NUL) if (enc_utf8 && p_deco && cpc[0] != NUL)
inc_cursor(); inc_cursor();
#endif
#ifdef FEAT_RIGHTLEFT #ifdef FEAT_RIGHTLEFT
if (revins_chars) if (revins_chars)
{ {
@ -9713,11 +9558,9 @@ bracketed_paste(paste_mode_T mode, int drop, garray_T *gap)
// won't get the end sequence. // won't get the end sequence.
break; break;
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
idx += (*mb_char2bytes)(c, buf + idx); idx += (*mb_char2bytes)(c, buf + idx);
else else
#endif
buf[idx++] = c; buf[idx++] = c;
buf[idx] = NUL; buf[idx] = NUL;
if (end != NULL && STRNCMP(buf, end, idx) == 0) if (end != NULL && STRNCMP(buf, end, idx) == 0)
@ -9760,11 +9603,9 @@ bracketed_paste(paste_mode_T mode, int drop, garray_T *gap)
case PASTE_ONE_CHAR: case PASTE_ONE_CHAR:
if (ret_char == -1) if (ret_char == -1)
{ {
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
ret_char = (*mb_ptr2char)(buf); ret_char = (*mb_ptr2char)(buf);
else else
#endif
ret_char = buf[0]; ret_char = buf[0];
} }
break; break;
@ -9972,11 +9813,9 @@ ins_right(
else else
#endif #endif
{ {
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
curwin->w_cursor.col += (*mb_ptr2len)(ml_get_cursor()); curwin->w_cursor.col += (*mb_ptr2len)(ml_get_cursor());
else else
#endif
++curwin->w_cursor.col; ++curwin->w_cursor.col;
} }
@ -10590,11 +10429,7 @@ ins_copychar(linenr_T lnum)
if ((colnr_T)temp > curwin->w_virtcol) if ((colnr_T)temp > curwin->w_virtcol)
ptr = prev_ptr; ptr = prev_ptr;
#ifdef FEAT_MBYTE
c = (*mb_ptr2char)(ptr); c = (*mb_ptr2char)(ptr);
#else
c = *ptr;
#endif
if (c == NUL) if (c == NUL)
vim_beep(BO_COPY); vim_beep(BO_COPY);
return c; return c;
@ -10773,11 +10608,9 @@ do_insert_char_pre(int c)
if (!has_insertcharpre()) if (!has_insertcharpre())
return NULL; return NULL;
# ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
buf[(*mb_char2bytes)(c, buf)] = NUL; buf[(*mb_char2bytes)(c, buf)] = NUL;
else else
# endif
{ {
buf[0] = c; buf[0] = c;
buf[1] = NUL; buf[1] = NUL;

View File

@ -577,7 +577,6 @@ var_redir_stop(void)
VIM_CLEAR(redir_varname); VIM_CLEAR(redir_varname);
} }
# if defined(FEAT_MBYTE) || defined(PROTO)
int int
eval_charconvert( eval_charconvert(
char_u *enc_from, char_u *enc_from,
@ -602,7 +601,6 @@ eval_charconvert(
return FAIL; return FAIL;
return OK; return OK;
} }
# endif
# if defined(FEAT_POSTSCRIPT) || defined(PROTO) # if defined(FEAT_POSTSCRIPT) || defined(PROTO)
int int
@ -4998,13 +4996,11 @@ get_string_tv(char_u **arg, typval_T *rettv, int evaluate)
nr = (nr << 4) + hex2nr(*p); nr = (nr << 4) + hex2nr(*p);
} }
++p; ++p;
#ifdef FEAT_MBYTE
/* For "\u" store the number according to /* For "\u" store the number according to
* 'encoding'. */ * 'encoding'. */
if (c != 'X') if (c != 'X')
name += (*mb_char2bytes)(nr, name); name += (*mb_char2bytes)(nr, name);
else else
#endif
*name++ = nr; *name++ = nr;
} }
break; break;
@ -6704,11 +6700,9 @@ set_vim_var_char(int c)
{ {
char_u buf[MB_MAXBYTES + 1]; char_u buf[MB_MAXBYTES + 1];
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
buf[(*mb_char2bytes)(c, buf)] = NUL; buf[(*mb_char2bytes)(c, buf)] = NUL;
else else
#endif
{ {
buf[0] = c; buf[0] = c;
buf[1] = NUL; buf[1] = NUL;
@ -6885,12 +6879,10 @@ set_cmdarg(exarg_T *eap, char_u *oldarg)
if (eap->force_ff != 0) if (eap->force_ff != 0)
len += 10; /* " ++ff=unix" */ len += 10; /* " ++ff=unix" */
# ifdef FEAT_MBYTE
if (eap->force_enc != 0) if (eap->force_enc != 0)
len += (unsigned)STRLEN(eap->cmd + eap->force_enc) + 7; len += (unsigned)STRLEN(eap->cmd + eap->force_enc) + 7;
if (eap->bad_char != 0) if (eap->bad_char != 0)
len += 7 + 4; /* " ++bad=" + "keep" or "drop" */ len += 7 + 4; /* " ++bad=" + "keep" or "drop" */
# endif
newval = alloc(len + 1); newval = alloc(len + 1);
if (newval == NULL) if (newval == NULL)
@ -6911,7 +6903,6 @@ set_cmdarg(exarg_T *eap, char_u *oldarg)
eap->force_ff == 'u' ? "unix" eap->force_ff == 'u' ? "unix"
: eap->force_ff == 'd' ? "dos" : eap->force_ff == 'd' ? "dos"
: "mac"); : "mac");
#ifdef FEAT_MBYTE
if (eap->force_enc != 0) if (eap->force_enc != 0)
sprintf((char *)newval + STRLEN(newval), " ++enc=%s", sprintf((char *)newval + STRLEN(newval), " ++enc=%s",
eap->cmd + eap->force_enc); eap->cmd + eap->force_enc);
@ -6921,7 +6912,6 @@ set_cmdarg(exarg_T *eap, char_u *oldarg)
STRCPY(newval + STRLEN(newval), " ++bad=drop"); STRCPY(newval + STRLEN(newval), " ++bad=drop");
else if (eap->bad_char != 0) else if (eap->bad_char != 0)
sprintf((char *)newval + STRLEN(newval), " ++bad=%c", eap->bad_char); sprintf((char *)newval + STRLEN(newval), " ++bad=%c", eap->bad_char);
#endif
vimvars[VV_CMDARG].vv_str = newval; vimvars[VV_CMDARG].vv_str = newval;
return oldval; return oldval;
} }
@ -8432,7 +8422,6 @@ ex_echo(exarg_T *eap)
} }
else else
{ {
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
int i = (*mb_ptr2len)(p); int i = (*mb_ptr2len)(p);
@ -8441,7 +8430,6 @@ ex_echo(exarg_T *eap)
p += i - 1; p += i - 1;
} }
else else
#endif
(void)msg_outtrans_len_attr(p, 1, echo_attr); (void)msg_outtrans_len_attr(p, 1, echo_attr);
} }
} }
@ -10082,10 +10070,8 @@ shortpath_for_partial(
/* Count the paths backward to find the beginning of the desired string. */ /* Count the paths backward to find the beginning of the desired string. */
for (p = tfname + len - 1; p >= tfname; --p) for (p = tfname + len - 1; p >= tfname; --p)
{ {
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
p -= mb_head_off(tfname, p); p -= mb_head_off(tfname, p);
#endif
if (vim_ispathsep(*p)) if (vim_ispathsep(*p))
{ {
if (sepcount == 0 || (hasTilde && sepcount == 1)) if (sepcount == 0 || (hasTilde && sepcount == 1))

View File

@ -2071,9 +2071,7 @@ f_byte2line(typval_T *argvars UNUSED, typval_T *rettv)
static void static void
byteidx(typval_T *argvars, typval_T *rettv, int comp UNUSED) byteidx(typval_T *argvars, typval_T *rettv, int comp UNUSED)
{ {
#ifdef FEAT_MBYTE
char_u *t; char_u *t;
#endif
char_u *str; char_u *str;
varnumber_T idx; varnumber_T idx;
@ -2083,7 +2081,6 @@ byteidx(typval_T *argvars, typval_T *rettv, int comp UNUSED)
if (str == NULL || idx < 0) if (str == NULL || idx < 0)
return; return;
#ifdef FEAT_MBYTE
t = str; t = str;
for ( ; idx > 0; idx--) for ( ; idx > 0; idx--)
{ {
@ -2095,10 +2092,6 @@ byteidx(typval_T *argvars, typval_T *rettv, int comp UNUSED)
t += (*mb_ptr2len)(t); t += (*mb_ptr2len)(t);
} }
rettv->vval.v_number = (varnumber_T)(t - str); rettv->vval.v_number = (varnumber_T)(t - str);
#else
if ((size_t)idx <= STRLEN(str))
rettv->vval.v_number = idx;
#endif
} }
/* /*
@ -2450,7 +2443,6 @@ f_changenr(typval_T *argvars UNUSED, typval_T *rettv)
static void static void
f_char2nr(typval_T *argvars, typval_T *rettv) f_char2nr(typval_T *argvars, typval_T *rettv)
{ {
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
int utf8 = 0; int utf8 = 0;
@ -2464,8 +2456,7 @@ f_char2nr(typval_T *argvars, typval_T *rettv)
rettv->vval.v_number = (*mb_ptr2char)(tv_get_string(&argvars[0])); rettv->vval.v_number = (*mb_ptr2char)(tv_get_string(&argvars[0]));
} }
else else
#endif rettv->vval.v_number = tv_get_string(&argvars[0])[0];
rettv->vval.v_number = tv_get_string(&argvars[0])[0];
} }
/* /*
@ -2536,15 +2527,10 @@ f_col(typval_T *argvars, typval_T *rettv)
if (curwin->w_cursor.coladd >= (colnr_T)chartabsize(p, if (curwin->w_cursor.coladd >= (colnr_T)chartabsize(p,
curwin->w_virtcol - curwin->w_cursor.coladd)) curwin->w_virtcol - curwin->w_cursor.coladd))
{ {
# ifdef FEAT_MBYTE
int l; int l;
if (*p != NUL && p[(l = (*mb_ptr2len)(p))] == NUL) if (*p != NUL && p[(l = (*mb_ptr2len)(p))] == NUL)
col += l; col += l;
# else
if (*p != NUL && p[1] == NUL)
++col;
# endif
} }
} }
#endif #endif
@ -2904,11 +2890,9 @@ f_cursor(typval_T *argvars, typval_T *rettv)
/* Make sure the cursor is in a valid position. */ /* Make sure the cursor is in a valid position. */
check_cursor(); check_cursor();
#ifdef FEAT_MBYTE
/* Correct cursor for multi-byte character. */ /* Correct cursor for multi-byte character. */
if (has_mbyte) if (has_mbyte)
mb_adjust_cursor(); mb_adjust_cursor();
#endif
curwin->w_set_curswant = set_curswant; curwin->w_set_curswant = set_curswant;
rettv->vval.v_number = 0; rettv->vval.v_number = 0;
@ -4888,10 +4872,8 @@ f_getchar(typval_T *argvars, typval_T *rettv)
temp[i++] = K_SECOND(n); temp[i++] = K_SECOND(n);
temp[i++] = K_THIRD(n); temp[i++] = K_THIRD(n);
} }
#ifdef FEAT_MBYTE
else if (has_mbyte) else if (has_mbyte)
i += (*mb_char2bytes)(n, temp + i); i += (*mb_char2bytes)(n, temp + i);
#endif
else else
temp[i++] = n; temp[i++] = n;
temp[i++] = NUL; temp[i++] = NUL;
@ -5439,7 +5421,7 @@ f_getmatches(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
dict_add_string(dict, "group", syn_id2name(cur->hlg_id)); dict_add_string(dict, "group", syn_id2name(cur->hlg_id));
dict_add_number(dict, "priority", (long)cur->priority); dict_add_number(dict, "priority", (long)cur->priority);
dict_add_number(dict, "id", (long)cur->id); dict_add_number(dict, "id", (long)cur->id);
# if defined(FEAT_CONCEAL) && defined(FEAT_MBYTE) # if defined(FEAT_CONCEAL)
if (cur->conceal_char) if (cur->conceal_char)
{ {
char_u buf[MB_MAXBYTES + 1]; char_u buf[MB_MAXBYTES + 1];
@ -6423,9 +6405,7 @@ f_has(typval_T *argvars, typval_T *rettv)
"mouse_xterm", "mouse_xterm",
# endif # endif
#endif #endif
#ifdef FEAT_MBYTE
"multi_byte", "multi_byte",
#endif
#ifdef FEAT_MBYTE_IME #ifdef FEAT_MBYTE_IME
"multi_byte_ime", "multi_byte_ime",
#endif #endif
@ -6674,10 +6654,8 @@ f_has(typval_T *argvars, typval_T *rettv)
n = mch_input_isatty(); n = mch_input_isatty();
else if (STRICMP(name, "ttyout") == 0) else if (STRICMP(name, "ttyout") == 0)
n = stdout_isatty; n = stdout_isatty;
#ifdef FEAT_MBYTE
else if (STRICMP(name, "multi_byte_encoding") == 0) else if (STRICMP(name, "multi_byte_encoding") == 0)
n = has_mbyte; n = has_mbyte;
#endif
#if defined(FEAT_BEVAL) && defined(FEAT_GUI_W32) #if defined(FEAT_BEVAL) && defined(FEAT_GUI_W32)
else if (STRICMP(name, "balloon_multiline") == 0) else if (STRICMP(name, "balloon_multiline") == 0)
n = multiline_balloon_available(); n = multiline_balloon_available();
@ -6965,17 +6943,14 @@ f_hostname(typval_T *argvars UNUSED, typval_T *rettv)
static void static void
f_iconv(typval_T *argvars UNUSED, typval_T *rettv) f_iconv(typval_T *argvars UNUSED, typval_T *rettv)
{ {
#ifdef FEAT_MBYTE
char_u buf1[NUMBUFLEN]; char_u buf1[NUMBUFLEN];
char_u buf2[NUMBUFLEN]; char_u buf2[NUMBUFLEN];
char_u *from, *to, *str; char_u *from, *to, *str;
vimconv_T vimconv; vimconv_T vimconv;
#endif
rettv->v_type = VAR_STRING; rettv->v_type = VAR_STRING;
rettv->vval.v_string = NULL; rettv->vval.v_string = NULL;
#ifdef FEAT_MBYTE
str = tv_get_string(&argvars[0]); str = tv_get_string(&argvars[0]);
from = enc_canonize(enc_skip(tv_get_string_buf(&argvars[1], buf1))); from = enc_canonize(enc_skip(tv_get_string_buf(&argvars[1], buf1)));
to = enc_canonize(enc_skip(tv_get_string_buf(&argvars[2], buf2))); to = enc_canonize(enc_skip(tv_get_string_buf(&argvars[2], buf2)));
@ -6991,7 +6966,6 @@ f_iconv(typval_T *argvars UNUSED, typval_T *rettv)
convert_setup(&vimconv, NULL, NULL); convert_setup(&vimconv, NULL, NULL);
vim_free(from); vim_free(from);
vim_free(to); vim_free(to);
#endif
} }
/* /*
@ -8097,12 +8071,8 @@ find_some_match(typval_T *argvars, typval_T *rettv, matchtype_T type)
} }
else else
{ {
#ifdef FEAT_MBYTE
startcol = (colnr_T)(regmatch.startp[0] startcol = (colnr_T)(regmatch.startp[0]
+ (*mb_ptr2len)(regmatch.startp[0]) - str); + (*mb_ptr2len)(regmatch.startp[0]) - str);
#else
startcol = (colnr_T)(regmatch.startp[0] + 1 - str);
#endif
if (startcol > (colnr_T)len if (startcol > (colnr_T)len
|| str + startcol <= regmatch.startp[0]) || str + startcol <= regmatch.startp[0])
{ {
@ -8712,7 +8682,6 @@ f_nr2char(typval_T *argvars, typval_T *rettv)
{ {
char_u buf[NUMBUFLEN]; char_u buf[NUMBUFLEN];
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
int utf8 = 0; int utf8 = 0;
@ -8725,7 +8694,6 @@ f_nr2char(typval_T *argvars, typval_T *rettv)
buf[(*mb_char2bytes)((int)tv_get_number(&argvars[0]), buf)] = NUL; buf[(*mb_char2bytes)((int)tv_get_number(&argvars[0]), buf)] = NUL;
} }
else else
#endif
{ {
buf[0] = (char_u)tv_get_number(&argvars[0]); buf[0] = (char_u)tv_get_number(&argvars[0]);
buf[1] = NUL; buf[1] = NUL;
@ -9175,7 +9143,6 @@ f_readfile(typval_T *argvars, typval_T *rettv)
} }
else if (*p == NUL) else if (*p == NUL)
*p = '\n'; *p = '\n';
#ifdef FEAT_MBYTE
/* Check for utf8 "bom"; U+FEFF is encoded as EF BB BF. Do this /* Check for utf8 "bom"; U+FEFF is encoded as EF BB BF. Do this
* when finding the BF and check the previous two bytes. */ * when finding the BF and check the previous two bytes. */
else if (*p == 0xbf && enc_utf8 && !binary) else if (*p == 0xbf && enc_utf8 && !binary)
@ -9215,7 +9182,6 @@ f_readfile(typval_T *argvars, typval_T *rettv)
} }
} }
} }
#endif
} /* for */ } /* for */
if (failed || (cnt >= maxline && maxline >= 0) || readlen <= 0) if (failed || (cnt >= maxline && maxline >= 0) || readlen <= 0)
@ -10386,11 +10352,9 @@ f_screenchar(typval_T *argvars, typval_T *rettv)
else else
{ {
off = LineOffset[row] + col; off = LineOffset[row] + col;
#ifdef FEAT_MBYTE
if (enc_utf8 && ScreenLinesUC[off] != 0) if (enc_utf8 && ScreenLinesUC[off] != 0)
c = ScreenLinesUC[off]; c = ScreenLinesUC[off];
else else
#endif
c = ScreenLines[off]; c = ScreenLines[off];
} }
rettv->vval.v_number = c; rettv->vval.v_number = c;
@ -10910,7 +10874,6 @@ f_setcharsearch(typval_T *argvars, typval_T *rettv UNUSED)
csearch = dict_get_string(d, (char_u *)"char", FALSE); csearch = dict_get_string(d, (char_u *)"char", FALSE);
if (csearch != NULL) if (csearch != NULL)
{ {
#ifdef FEAT_MBYTE
if (enc_utf8) if (enc_utf8)
{ {
int pcc[MAX_MCO]; int pcc[MAX_MCO];
@ -10919,7 +10882,6 @@ f_setcharsearch(typval_T *argvars, typval_T *rettv UNUSED)
set_last_csearch(c, csearch, utfc_ptr2len(csearch)); set_last_csearch(c, csearch, utfc_ptr2len(csearch));
} }
else else
#endif
set_last_csearch(PTR2CHAR(csearch), set_last_csearch(PTR2CHAR(csearch),
csearch, MB_PTR2LEN(csearch)); csearch, MB_PTR2LEN(csearch));
} }
@ -12511,18 +12473,12 @@ f_split(typval_T *argvars, typval_T *rettv)
} }
if (!match) if (!match)
break; break;
/* Advance to just after the match. */ // Advance to just after the match.
if (regmatch.endp[0] > str) if (regmatch.endp[0] > str)
col = 0; col = 0;
else else
{ // Don't get stuck at the same match.
/* Don't get stuck at the same match. */
#ifdef FEAT_MBYTE
col = (*mb_ptr2len)(regmatch.endp[0]); col = (*mb_ptr2len)(regmatch.endp[0]);
#else
col = 1;
#endif
}
str = regmatch.endp[0]; str = regmatch.endp[0];
} }
@ -12632,7 +12588,6 @@ f_strftime(typval_T *argvars, typval_T *rettv)
rettv->vval.v_string = vim_strsave((char_u *)_("(Invalid)")); rettv->vval.v_string = vim_strsave((char_u *)_("(Invalid)"));
else else
{ {
# ifdef FEAT_MBYTE
vimconv_T conv; vimconv_T conv;
char_u *enc; char_u *enc;
@ -12641,28 +12596,23 @@ f_strftime(typval_T *argvars, typval_T *rettv)
convert_setup(&conv, p_enc, enc); convert_setup(&conv, p_enc, enc);
if (conv.vc_type != CONV_NONE) if (conv.vc_type != CONV_NONE)
p = string_convert(&conv, p, NULL); p = string_convert(&conv, p, NULL);
# endif
if (p != NULL) if (p != NULL)
(void)strftime((char *)result_buf, sizeof(result_buf), (void)strftime((char *)result_buf, sizeof(result_buf),
(char *)p, curtime); (char *)p, curtime);
else else
result_buf[0] = NUL; result_buf[0] = NUL;
# ifdef FEAT_MBYTE
if (conv.vc_type != CONV_NONE) if (conv.vc_type != CONV_NONE)
vim_free(p); vim_free(p);
convert_setup(&conv, enc, p_enc); convert_setup(&conv, enc, p_enc);
if (conv.vc_type != CONV_NONE) if (conv.vc_type != CONV_NONE)
rettv->vval.v_string = string_convert(&conv, result_buf, NULL); rettv->vval.v_string = string_convert(&conv, result_buf, NULL);
else else
# endif
rettv->vval.v_string = vim_strsave(result_buf); rettv->vval.v_string = vim_strsave(result_buf);
# ifdef FEAT_MBYTE
/* Release conversion descriptors */ /* Release conversion descriptors */
convert_setup(&conv, NULL, NULL); convert_setup(&conv, NULL, NULL);
vim_free(enc); vim_free(enc);
# endif
} }
} }
#endif #endif
@ -12677,6 +12627,7 @@ f_strgetchar(typval_T *argvars, typval_T *rettv)
int len; int len;
int error = FALSE; int error = FALSE;
int charidx; int charidx;
int byteidx = 0;
rettv->vval.v_number = -1; rettv->vval.v_number = -1;
str = tv_get_string_chk(&argvars[0]); str = tv_get_string_chk(&argvars[0]);
@ -12686,25 +12637,17 @@ f_strgetchar(typval_T *argvars, typval_T *rettv)
charidx = (int)tv_get_number_chk(&argvars[1], &error); charidx = (int)tv_get_number_chk(&argvars[1], &error);
if (error) if (error)
return; return;
#ifdef FEAT_MBYTE
{
int byteidx = 0;
while (charidx >= 0 && byteidx < len) while (charidx >= 0 && byteidx < len)
{
if (charidx == 0)
{ {
if (charidx == 0) rettv->vval.v_number = mb_ptr2char(str + byteidx);
{ break;
rettv->vval.v_number = mb_ptr2char(str + byteidx);
break;
}
--charidx;
byteidx += MB_CPTR2LEN(str + byteidx);
} }
--charidx;
byteidx += MB_CPTR2LEN(str + byteidx);
} }
#else
if (charidx < len)
rettv->vval.v_number = str[charidx];
#endif
} }
/* /*
@ -12777,10 +12720,8 @@ f_strchars(typval_T *argvars, typval_T *rettv)
{ {
char_u *s = tv_get_string(&argvars[0]); char_u *s = tv_get_string(&argvars[0]);
int skipcc = 0; int skipcc = 0;
#ifdef FEAT_MBYTE
varnumber_T len = 0; varnumber_T len = 0;
int (*func_mb_ptr2char_adv)(char_u **pp); int (*func_mb_ptr2char_adv)(char_u **pp);
#endif
if (argvars[1].v_type != VAR_UNKNOWN) if (argvars[1].v_type != VAR_UNKNOWN)
skipcc = (int)tv_get_number_chk(&argvars[1], NULL); skipcc = (int)tv_get_number_chk(&argvars[1], NULL);
@ -12788,7 +12729,6 @@ f_strchars(typval_T *argvars, typval_T *rettv)
emsg(_(e_invarg)); emsg(_(e_invarg));
else else
{ {
#ifdef FEAT_MBYTE
func_mb_ptr2char_adv = skipcc ? mb_ptr2char_adv : mb_cptr2char_adv; func_mb_ptr2char_adv = skipcc ? mb_ptr2char_adv : mb_cptr2char_adv;
while (*s != NUL) while (*s != NUL)
{ {
@ -12796,9 +12736,6 @@ f_strchars(typval_T *argvars, typval_T *rettv)
++len; ++len;
} }
rettv->vval.v_number = len; rettv->vval.v_number = len;
#else
rettv->vval.v_number = (varnumber_T)(STRLEN(s));
#endif
} }
} }
@ -12825,13 +12762,7 @@ f_strwidth(typval_T *argvars, typval_T *rettv)
{ {
char_u *s = tv_get_string(&argvars[0]); char_u *s = tv_get_string(&argvars[0]);
rettv->vval.v_number = (varnumber_T)( rettv->vval.v_number = (varnumber_T)(mb_string2cells(s, -1));
#ifdef FEAT_MBYTE
mb_string2cells(s, -1)
#else
STRLEN(s)
#endif
);
} }
/* /*
@ -12840,7 +12771,6 @@ f_strwidth(typval_T *argvars, typval_T *rettv)
static void static void
f_strcharpart(typval_T *argvars, typval_T *rettv) f_strcharpart(typval_T *argvars, typval_T *rettv)
{ {
#ifdef FEAT_MBYTE
char_u *p; char_u *p;
int nchar; int nchar;
int nbyte = 0; int nbyte = 0;
@ -12899,9 +12829,6 @@ f_strcharpart(typval_T *argvars, typval_T *rettv)
rettv->v_type = VAR_STRING; rettv->v_type = VAR_STRING;
rettv->vval.v_string = vim_strnsave(p + nbyte, len); rettv->vval.v_string = vim_strnsave(p + nbyte, len);
#else
f_strpart(argvars, rettv);
#endif
} }
/* /*
@ -13278,11 +13205,9 @@ f_synconcealed(typval_T *argvars UNUSED, typval_T *rettv)
cchar = (lcs_conceal == NUL) ? ' ' : lcs_conceal; cchar = (lcs_conceal == NUL) ? ' ' : lcs_conceal;
if (cchar != NUL) if (cchar != NUL)
{ {
# ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
(*mb_char2bytes)(cchar, str); (*mb_char2bytes)(cchar, str);
else else
# endif
str[0] = cchar; str[0] = cchar;
} }
} }
@ -14208,7 +14133,6 @@ f_tr(typval_T *argvars, typval_T *rettv)
char_u *fromstr; char_u *fromstr;
char_u *tostr; char_u *tostr;
char_u *p; char_u *p;
#ifdef FEAT_MBYTE
int inlen; int inlen;
int fromlen; int fromlen;
int tolen; int tolen;
@ -14216,7 +14140,6 @@ f_tr(typval_T *argvars, typval_T *rettv)
char_u *cpstr; char_u *cpstr;
int cplen; int cplen;
int first = TRUE; int first = TRUE;
#endif
char_u buf[NUMBUFLEN]; char_u buf[NUMBUFLEN];
char_u buf2[NUMBUFLEN]; char_u buf2[NUMBUFLEN];
garray_T ga; garray_T ga;
@ -14232,15 +14155,11 @@ f_tr(typval_T *argvars, typval_T *rettv)
return; /* type error; errmsg already given */ return; /* type error; errmsg already given */
ga_init2(&ga, (int)sizeof(char), 80); ga_init2(&ga, (int)sizeof(char), 80);
#ifdef FEAT_MBYTE
if (!has_mbyte) if (!has_mbyte)
#endif
/* not multi-byte: fromstr and tostr must be the same length */ /* not multi-byte: fromstr and tostr must be the same length */
if (STRLEN(fromstr) != STRLEN(tostr)) if (STRLEN(fromstr) != STRLEN(tostr))
{ {
#ifdef FEAT_MBYTE
error: error:
#endif
semsg(_(e_invarg2), fromstr); semsg(_(e_invarg2), fromstr);
ga_clear(&ga); ga_clear(&ga);
return; return;
@ -14249,7 +14168,6 @@ error:
/* fromstr and tostr have to contain the same number of chars */ /* fromstr and tostr have to contain the same number of chars */
while (*in_str != NUL) while (*in_str != NUL)
{ {
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
inlen = (*mb_ptr2len)(in_str); inlen = (*mb_ptr2len)(in_str);
@ -14300,7 +14218,6 @@ error:
in_str += inlen; in_str += inlen;
} }
else else
#endif
{ {
/* When not using multi-byte chars we can do it faster. */ /* When not using multi-byte chars we can do it faster. */
p = vim_strchr(fromstr, *in_str); p = vim_strchr(fromstr, *in_str);

View File

@ -50,7 +50,6 @@ do_ascii(exarg_T *eap UNUSED)
#ifdef FEAT_DIGRAPHS #ifdef FEAT_DIGRAPHS
char_u *dig; char_u *dig;
#endif #endif
#ifdef FEAT_MBYTE
int cc[MAX_MCO]; int cc[MAX_MCO];
int ci = 0; int ci = 0;
int len; int len;
@ -58,7 +57,6 @@ do_ascii(exarg_T *eap UNUSED)
if (enc_utf8) if (enc_utf8)
c = utfc_ptr2char(ml_get_cursor(), cc); c = utfc_ptr2char(ml_get_cursor(), cc);
else else
#endif
c = gchar_cursor(); c = gchar_cursor();
if (c == NUL) if (c == NUL)
{ {
@ -66,10 +64,8 @@ do_ascii(exarg_T *eap UNUSED)
return; return;
} }
#ifdef FEAT_MBYTE
IObuff[0] = NUL; IObuff[0] = NUL;
if (!has_mbyte || (enc_dbcs != 0 && c < 0x100) || c < 0x80) if (!has_mbyte || (enc_dbcs != 0 && c < 0x100) || c < 0x80)
#endif
{ {
if (c == NL) /* NUL is stored as NL */ if (c == NL) /* NUL is stored as NL */
c = NUL; c = NUL;
@ -106,15 +102,12 @@ do_ascii(exarg_T *eap UNUSED)
vim_snprintf((char *)IObuff, IOSIZE, vim_snprintf((char *)IObuff, IOSIZE,
_("<%s>%s%s %d, Hex %02x, Octal %03o"), _("<%s>%s%s %d, Hex %02x, Octal %03o"),
transchar(c), buf1, buf2, cval, cval, cval); transchar(c), buf1, buf2, cval, cval, cval);
#ifdef FEAT_MBYTE
if (enc_utf8) if (enc_utf8)
c = cc[ci++]; c = cc[ci++];
else else
c = 0; c = 0;
#endif
} }
#ifdef FEAT_MBYTE
/* Repeat for combining characters. */ /* Repeat for combining characters. */
while (has_mbyte && (c >= 0x100 || (enc_utf8 && c >= 0x80))) while (has_mbyte && (c >= 0x100 || (enc_utf8 && c >= 0x80)))
{ {
@ -150,7 +143,6 @@ do_ascii(exarg_T *eap UNUSED)
else else
c = 0; c = 0;
} }
#endif
msg((char *)IObuff); msg((char *)IObuff);
} }
@ -823,11 +815,9 @@ ex_retab(exarg_T *eap)
if (ptr[col] == NUL) if (ptr[col] == NUL)
break; break;
vcol += chartabsize(ptr + col, (colnr_T)vcol); vcol += chartabsize(ptr + col, (colnr_T)vcol);
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
col += (*mb_ptr2len)(ptr + col); col += (*mb_ptr2len)(ptr + col);
else else
#endif
++col; ++col;
} }
if (new_line == NULL) /* out of memory */ if (new_line == NULL) /* out of memory */
@ -2282,9 +2272,7 @@ do_viminfo(FILE *fp_in, FILE *fp_out, int flags)
if ((vir.vir_line = alloc(LSIZE)) == NULL) if ((vir.vir_line = alloc(LSIZE)) == NULL)
return; return;
vir.vir_fd = fp_in; vir.vir_fd = fp_in;
#ifdef FEAT_MBYTE
vir.vir_conv.vc_type = CONV_NONE; vir.vir_conv.vc_type = CONV_NONE;
#endif
ga_init2(&vir.vir_barlines, (int)sizeof(char_u *), 100); ga_init2(&vir.vir_barlines, (int)sizeof(char_u *), 100);
vir.vir_version = -1; vir.vir_version = -1;
@ -2321,10 +2309,8 @@ do_viminfo(FILE *fp_in, FILE *fp_out, int flags)
VIM_VERSION_MEDIUM); VIM_VERSION_MEDIUM);
fputs(_("# You may edit it if you're careful!\n\n"), fp_out); fputs(_("# You may edit it if you're careful!\n\n"), fp_out);
write_viminfo_version(fp_out); write_viminfo_version(fp_out);
#ifdef FEAT_MBYTE
fputs(_("# Value of 'encoding' when this file was written\n"), fp_out); fputs(_("# Value of 'encoding' when this file was written\n"), fp_out);
fprintf(fp_out, "*encoding=%s\n\n", p_enc); fprintf(fp_out, "*encoding=%s\n\n", p_enc);
#endif
write_viminfo_search_pattern(fp_out); write_viminfo_search_pattern(fp_out);
write_viminfo_sub_string(fp_out); write_viminfo_sub_string(fp_out);
#ifdef FEAT_CMDHIST #ifdef FEAT_CMDHIST
@ -2353,10 +2339,8 @@ do_viminfo(FILE *fp_in, FILE *fp_out, int flags)
} }
vim_free(vir.vir_line); vim_free(vir.vir_line);
#ifdef FEAT_MBYTE
if (vir.vir_conv.vc_type != CONV_NONE) if (vir.vir_conv.vc_type != CONV_NONE)
convert_setup(&vir.vir_conv, NULL, NULL); convert_setup(&vir.vir_conv, NULL, NULL);
#endif
ga_clear_strings(&vir.vir_barlines); ga_clear_strings(&vir.vir_barlines);
} }
@ -2484,7 +2468,6 @@ read_viminfo_up_to_marks(
static int static int
viminfo_encoding(vir_T *virp) viminfo_encoding(vir_T *virp)
{ {
#ifdef FEAT_MBYTE
char_u *p; char_u *p;
int i; int i;
@ -2502,7 +2485,6 @@ viminfo_encoding(vir_T *virp)
convert_setup(&virp->vir_conv, p, p_enc); convert_setup(&virp->vir_conv, p, p_enc);
} }
} }
#endif
return viminfo_readline(virp); return viminfo_readline(virp);
} }
@ -2574,7 +2556,6 @@ viminfo_readstring(
} }
*d = NUL; *d = NUL;
#ifdef FEAT_MBYTE
if (convert && virp->vir_conv.vc_type != CONV_NONE && *retval != NUL) if (convert && virp->vir_conv.vc_type != CONV_NONE && *retval != NUL)
{ {
d = string_convert(&virp->vir_conv, retval, NULL); d = string_convert(&virp->vir_conv, retval, NULL);
@ -2584,7 +2565,6 @@ viminfo_readstring(
retval = d; retval = d;
} }
} }
#endif
return retval; return retval;
} }
@ -2708,10 +2688,8 @@ barline_parse(vir_T *virp, char_u *text, garray_T *values)
int i; int i;
int allocated = FALSE; int allocated = FALSE;
int eof; int eof;
#ifdef FEAT_MBYTE
char_u *sconv; char_u *sconv;
int converted; int converted;
#endif
while (*p == ',') while (*p == ',')
{ {
@ -2835,7 +2813,6 @@ barline_parse(vir_T *virp, char_u *text, garray_T *values)
++p; ++p;
s[len] = NUL; s[len] = NUL;
#ifdef FEAT_MBYTE
converted = FALSE; converted = FALSE;
if (virp->vir_conv.vc_type != CONV_NONE && *s != NUL) if (virp->vir_conv.vc_type != CONV_NONE && *s != NUL)
{ {
@ -2849,7 +2826,7 @@ barline_parse(vir_T *virp, char_u *text, garray_T *values)
converted = TRUE; converted = TRUE;
} }
} }
#endif
/* Need to copy in allocated memory if the string wasn't allocated /* Need to copy in allocated memory if the string wasn't allocated
* above and we did allocate before, thus vir_line may change. */ * above and we did allocate before, thus vir_line may change. */
if (s != buf && allocated) if (s != buf && allocated)
@ -2857,11 +2834,7 @@ barline_parse(vir_T *virp, char_u *text, garray_T *values)
value->bv_string = s; value->bv_string = s;
value->bv_type = BVAL_STRING; value->bv_type = BVAL_STRING;
value->bv_len = len; value->bv_len = len;
value->bv_allocated = allocated value->bv_allocated = allocated || converted;
#ifdef FEAT_MBYTE
|| converted
#endif
;
++values->ga_len; ++values->ga_len;
if (nextp != NULL) if (nextp != NULL)
{ {
@ -4094,9 +4067,7 @@ do_ecmd(
if (!oldbuf && eap != NULL) if (!oldbuf && eap != NULL)
{ {
set_file_options(TRUE, eap); set_file_options(TRUE, eap);
#ifdef FEAT_MBYTE
set_forced_fenc(eap); set_forced_fenc(eap);
#endif
} }
} }
@ -5317,11 +5288,9 @@ do_sub(exarg_T *eap)
else else
{ {
/* search for a match at next column */ /* search for a match at next column */
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
matchcol += mb_ptr2len(sub_firstline + matchcol); matchcol += mb_ptr2len(sub_firstline + matchcol);
else else
#endif
++matchcol; ++matchcol;
} }
goto skip; goto skip;
@ -5759,10 +5728,8 @@ do_sub(exarg_T *eap)
p1 = new_start - 1; p1 = new_start - 1;
} }
} }
#ifdef FEAT_MBYTE
else if (has_mbyte) else if (has_mbyte)
p1 += (*mb_ptr2len)(p1) - 1; p1 += (*mb_ptr2len)(p1) - 1;
#endif
} }
/* /*
@ -7017,10 +6984,8 @@ fix_help_buffer(void)
FILE *fd; FILE *fd;
char_u *s; char_u *s;
int fi; int fi;
#ifdef FEAT_MBYTE
vimconv_T vc; vimconv_T vc;
char_u *cp; char_u *cp;
#endif
/* Find all "doc/ *.txt" files in this directory. */ /* Find all "doc/ *.txt" files in this directory. */
add_pathsep(NameBuff); add_pathsep(NameBuff);
@ -7086,9 +7051,8 @@ fix_help_buffer(void)
&& (s = vim_strchr(IObuff + 1, '*')) && (s = vim_strchr(IObuff + 1, '*'))
!= NULL) != NULL)
{ {
#ifdef FEAT_MBYTE
int this_utf = MAYBE; int this_utf = MAYBE;
#endif
/* Change tag definition to a /* Change tag definition to a
* reference and remove <CR>/<NL>. */ * reference and remove <CR>/<NL>. */
IObuff[0] = '|'; IObuff[0] = '|';
@ -7097,7 +7061,6 @@ fix_help_buffer(void)
{ {
if (*s == '\r' || *s == '\n') if (*s == '\r' || *s == '\n')
*s = NUL; *s = NUL;
#ifdef FEAT_MBYTE
/* The text is utf-8 when a byte /* The text is utf-8 when a byte
* above 127 is found and no * above 127 is found and no
* illegal byte sequence is found. * illegal byte sequence is found.
@ -7112,10 +7075,9 @@ fix_help_buffer(void)
this_utf = FALSE; this_utf = FALSE;
s += l - 1; s += l - 1;
} }
#endif
++s; ++s;
} }
#ifdef FEAT_MBYTE
/* The help file is latin1 or utf-8; /* The help file is latin1 or utf-8;
* conversion to the current * conversion to the current
* 'encoding' may be required. */ * 'encoding' may be required. */
@ -7140,10 +7102,6 @@ fix_help_buffer(void)
ml_append(lnum, cp, (colnr_T)0, FALSE); ml_append(lnum, cp, (colnr_T)0, FALSE);
if (cp != IObuff) if (cp != IObuff)
vim_free(cp); vim_free(cp);
#else
ml_append(lnum, IObuff, (colnr_T)0,
FALSE);
#endif
++lnum; ++lnum;
} }
fclose(fd); fclose(fd);
@ -7199,12 +7157,10 @@ helptags_one(
int i; int i;
char_u *fname; char_u *fname;
int dirlen; int dirlen;
# ifdef FEAT_MBYTE
int utf8 = MAYBE; int utf8 = MAYBE;
int this_utf8; int this_utf8;
int firstline; int firstline;
int mix = FALSE; /* detected mixed encodings */ int mix = FALSE; /* detected mixed encodings */
# endif
/* /*
* Find all *.txt files. * Find all *.txt files.
@ -7274,12 +7230,9 @@ helptags_one(
} }
fname = files[fi] + dirlen + 1; fname = files[fi] + dirlen + 1;
# ifdef FEAT_MBYTE
firstline = TRUE; firstline = TRUE;
# endif
while (!vim_fgets(IObuff, IOSIZE, fd) && !got_int) while (!vim_fgets(IObuff, IOSIZE, fd) && !got_int)
{ {
# ifdef FEAT_MBYTE
if (firstline) if (firstline)
{ {
/* Detect utf-8 file by a non-ASCII char in the first line. */ /* Detect utf-8 file by a non-ASCII char in the first line. */
@ -7311,7 +7264,6 @@ helptags_one(
} }
firstline = FALSE; firstline = FALSE;
} }
# endif
p1 = vim_strchr(IObuff, '*'); /* find first '*' */ p1 = vim_strchr(IObuff, '*'); /* find first '*' */
while (p1 != NULL) while (p1 != NULL)
{ {
@ -7398,10 +7350,8 @@ helptags_one(
} }
} }
# ifdef FEAT_MBYTE
if (utf8 == TRUE) if (utf8 == TRUE)
fprintf(fd_tags, "!_TAG_FILE_ENCODING\tutf-8\t//\n"); fprintf(fd_tags, "!_TAG_FILE_ENCODING\tutf-8\t//\n");
# endif
/* /*
* Write the tags into the file. * Write the tags into the file.
@ -7426,10 +7376,8 @@ helptags_one(
} }
} }
} }
#ifdef FEAT_MBYTE
if (mix) if (mix)
got_int = FALSE; /* continue with other languages */ got_int = FALSE; /* continue with other languages */
#endif
for (i = 0; i < ga.ga_len; ++i) for (i = 0; i < ga.ga_len; ++i)
vim_free(((char_u **)ga.ga_data)[i]); vim_free(((char_u **)ga.ga_data)[i]);

View File

@ -1957,7 +1957,7 @@ script_dump_profile(FILE *fd)
if (IObuff[IOSIZE - 2] != NUL && IObuff[IOSIZE - 2] != NL) if (IObuff[IOSIZE - 2] != NUL && IObuff[IOSIZE - 2] != NL)
{ {
int n = IOSIZE - 2; int n = IOSIZE - 2;
# ifdef FEAT_MBYTE
if (enc_utf8) if (enc_utf8)
{ {
/* Move to the first byte of this char. /* Move to the first byte of this char.
@ -1968,7 +1968,6 @@ script_dump_profile(FILE *fd)
} }
else if (has_mbyte) else if (has_mbyte)
n -= mb_head_off(IObuff, IObuff + n); n -= mb_head_off(IObuff, IObuff + n);
# endif
IObuff[n] = NL; IObuff[n] = NL;
IObuff[n + 1] = NUL; IObuff[n + 1] = NUL;
} }
@ -4254,9 +4253,7 @@ struct source_cookie
int dbg_tick; /* debug_tick when breakpoint was set */ int dbg_tick; /* debug_tick when breakpoint was set */
int level; /* top nesting level of sourced file */ int level; /* top nesting level of sourced file */
#endif #endif
#ifdef FEAT_MBYTE
vimconv_T conv; /* type of conversion */ vimconv_T conv; /* type of conversion */
#endif
}; };
#ifdef FEAT_EVAL #ifdef FEAT_EVAL
@ -4593,7 +4590,6 @@ do_source(
# endif # endif
#endif #endif
#ifdef FEAT_MBYTE
cookie.conv.vc_type = CONV_NONE; /* no conversion */ cookie.conv.vc_type = CONV_NONE; /* no conversion */
/* Read the first line so we can check for a UTF-8 BOM. */ /* Read the first line so we can check for a UTF-8 BOM. */
@ -4612,7 +4608,6 @@ do_source(
firstline = p; firstline = p;
} }
} }
#endif
/* /*
* Call do_cmdline, which will call getsourceline() to get the lines. * Call do_cmdline, which will call getsourceline() to get the lines.
@ -4683,9 +4678,7 @@ almosttheend:
fclose(cookie.fp); fclose(cookie.fp);
vim_free(cookie.nextline); vim_free(cookie.nextline);
vim_free(firstline); vim_free(firstline);
#ifdef FEAT_MBYTE
convert_setup(&cookie.conv, NULL, NULL); convert_setup(&cookie.conv, NULL, NULL);
#endif
if (trigger_source_post) if (trigger_source_post)
apply_autocmds(EVENT_SOURCEPOST, fname_exp, fname_exp, FALSE, curbuf); apply_autocmds(EVENT_SOURCEPOST, fname_exp, fname_exp, FALSE, curbuf);
@ -4924,7 +4917,6 @@ getsourceline(int c UNUSED, void *cookie, int indent UNUSED)
} }
} }
#ifdef FEAT_MBYTE
if (line != NULL && sp->conv.vc_type != CONV_NONE) if (line != NULL && sp->conv.vc_type != CONV_NONE)
{ {
char_u *s; char_u *s;
@ -4937,7 +4929,6 @@ getsourceline(int c UNUSED, void *cookie, int indent UNUSED)
line = s; line = s;
} }
} }
#endif
#ifdef FEAT_EVAL #ifdef FEAT_EVAL
/* Did we encounter a breakpoint? */ /* Did we encounter a breakpoint? */
@ -5194,7 +5185,6 @@ script_line_end(void)
void void
ex_scriptencoding(exarg_T *eap UNUSED) ex_scriptencoding(exarg_T *eap UNUSED)
{ {
#ifdef FEAT_MBYTE
struct source_cookie *sp; struct source_cookie *sp;
char_u *name; char_u *name;
@ -5219,7 +5209,6 @@ ex_scriptencoding(exarg_T *eap UNUSED)
if (name != eap->arg) if (name != eap->arg)
vim_free(name); vim_free(name);
#endif
} }
#if defined(FEAT_EVAL) || defined(PROTO) #if defined(FEAT_EVAL) || defined(PROTO)

View File

@ -404,8 +404,7 @@ static void ex_folddo(exarg_T *eap);
# define ex_foldopen ex_ni # define ex_foldopen ex_ni
# define ex_folddo ex_ni # define ex_folddo ex_ni
#endif #endif
#if !((defined(HAVE_LOCALE_H) || defined(X_LOCALE)) \ #if !(defined(HAVE_LOCALE_H) || defined(X_LOCALE))
&& (defined(FEAT_GETTEXT) || defined(FEAT_MBYTE)))
# define ex_language ex_ni # define ex_language ex_ni
#endif #endif
#ifndef FEAT_SIGNS #ifndef FEAT_SIGNS
@ -1550,7 +1549,6 @@ getline_equal(
#endif #endif
} }
#if defined(FEAT_EVAL) || defined(FEAT_MBYTE) || defined(PROTO)
/* /*
* If "fgetline" is get_loop_line(), return the cookie used by the original * If "fgetline" is get_loop_line(), return the cookie used by the original
* getline function. Otherwise return "cookie". * getline function. Otherwise return "cookie".
@ -1560,7 +1558,7 @@ getline_cookie(
char_u *(*fgetline)(int, void *, int) UNUSED, char_u *(*fgetline)(int, void *, int) UNUSED,
void *cookie) /* argument for fgetline() */ void *cookie) /* argument for fgetline() */
{ {
# ifdef FEAT_EVAL #ifdef FEAT_EVAL
char_u *(*gp)(int, void *, int); char_u *(*gp)(int, void *, int);
struct loop_cookie *cp; struct loop_cookie *cp;
@ -1575,11 +1573,10 @@ getline_cookie(
cp = cp->cookie; cp = cp->cookie;
} }
return cp; return cp;
# else #else
return cookie; return cookie;
# endif
}
#endif #endif
}
/* /*
@ -3116,17 +3113,9 @@ append_command(char_u *cmd)
d = IObuff + STRLEN(IObuff); d = IObuff + STRLEN(IObuff);
while (*s != NUL && d - IObuff < IOSIZE - 7) while (*s != NUL && d - IObuff < IOSIZE - 7)
{ {
if ( if (enc_utf8 ? (s[0] == 0xc2 && s[1] == 0xa0) : *s == 0xa0)
#ifdef FEAT_MBYTE
enc_utf8 ? (s[0] == 0xc2 && s[1] == 0xa0) :
#endif
*s == 0xa0)
{ {
s += s += enc_utf8 ? 2 : 1;
#ifdef FEAT_MBYTE
enc_utf8 ? 2 :
#endif
1;
STRCPY(d, "<a0>"); STRCPY(d, "<a0>");
d += 4; d += 4;
} }
@ -3752,11 +3741,9 @@ set_one_cmd_context(
p = xp->xp_pattern; p = xp->xp_pattern;
while (*p != NUL) while (*p != NUL)
{ {
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
c = mb_ptr2char(p); c = mb_ptr2char(p);
else else
#endif
c = *p; c = *p;
if (c == '\\' && p[1] != NUL) if (c == '\\' && p[1] != NUL)
++p; ++p;
@ -3780,19 +3767,15 @@ set_one_cmd_context(
len = 0; /* avoid getting stuck when space is in 'isfname' */ len = 0; /* avoid getting stuck when space is in 'isfname' */
while (*p != NUL) while (*p != NUL)
{ {
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
c = mb_ptr2char(p); c = mb_ptr2char(p);
else else
#endif
c = *p; c = *p;
if (c == '`' || vim_isfilec_or_wc(c)) if (c == '`' || vim_isfilec_or_wc(c))
break; break;
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
len = (*mb_ptr2len)(p); len = (*mb_ptr2len)(p);
else else
#endif
len = 1; len = 1;
MB_PTR_ADV(p); MB_PTR_ADV(p);
} }
@ -5408,7 +5391,6 @@ skip_cmd_arg(
return p; return p;
} }
#if defined(FEAT_MBYTE) || defined(PROTO)
int int
get_bad_opt(char_u *p, exarg_T *eap) get_bad_opt(char_u *p, exarg_T *eap)
{ {
@ -5422,7 +5404,6 @@ get_bad_opt(char_u *p, exarg_T *eap)
return FAIL; return FAIL;
return OK; return OK;
} }
#endif
/* /*
* Get "++opt=arg" argument. * Get "++opt=arg" argument.
@ -5433,10 +5414,8 @@ getargopt(exarg_T *eap)
{ {
char_u *arg = eap->arg + 2; char_u *arg = eap->arg + 2;
int *pp = NULL; int *pp = NULL;
#ifdef FEAT_MBYTE
int bad_char_idx; int bad_char_idx;
char_u *p; char_u *p;
#endif
/* ":edit ++[no]bin[ary] file" */ /* ":edit ++[no]bin[ary] file" */
if (STRNCMP(arg, "bin", 3) == 0 || STRNCMP(arg, "nobin", 5) == 0) if (STRNCMP(arg, "bin", 3) == 0 || STRNCMP(arg, "nobin", 5) == 0)
@ -5472,7 +5451,6 @@ getargopt(exarg_T *eap)
arg += 10; arg += 10;
pp = &eap->force_ff; pp = &eap->force_ff;
} }
#ifdef FEAT_MBYTE
else if (STRNCMP(arg, "enc", 3) == 0) else if (STRNCMP(arg, "enc", 3) == 0)
{ {
if (STRNCMP(arg, "encoding", 8) == 0) if (STRNCMP(arg, "encoding", 8) == 0)
@ -5486,7 +5464,6 @@ getargopt(exarg_T *eap)
arg += 3; arg += 3;
pp = &bad_char_idx; pp = &bad_char_idx;
} }
#endif
if (pp == NULL || *arg != '=') if (pp == NULL || *arg != '=')
return FAIL; return FAIL;
@ -5497,14 +5474,11 @@ getargopt(exarg_T *eap)
eap->arg = skipwhite(arg); eap->arg = skipwhite(arg);
*arg = NUL; *arg = NUL;
#ifdef FEAT_MBYTE
if (pp == &eap->force_ff) if (pp == &eap->force_ff)
{ {
#endif
if (check_ff_value(eap->cmd + eap->force_ff) == FAIL) if (check_ff_value(eap->cmd + eap->force_ff) == FAIL)
return FAIL; return FAIL;
eap->force_ff = eap->cmd[eap->force_ff]; eap->force_ff = eap->cmd[eap->force_ff];
#ifdef FEAT_MBYTE
} }
else if (pp == &eap->force_enc) else if (pp == &eap->force_enc)
{ {
@ -5519,7 +5493,6 @@ getargopt(exarg_T *eap)
if (get_bad_opt(eap->cmd + bad_char_idx, eap) == FAIL) if (get_bad_opt(eap->cmd + bad_char_idx, eap) == FAIL)
return FAIL; return FAIL;
} }
#endif
return OK; return OK;
} }
@ -6507,14 +6480,10 @@ uc_split_args(char_u *arg, size_t *lenp)
} }
else else
{ {
#ifdef FEAT_MBYTE
int charlen = (*mb_ptr2len)(p); int charlen = (*mb_ptr2len)(p);
len += charlen; len += charlen;
p += charlen; p += charlen;
#else
++len;
++p;
#endif
} }
} }
@ -6685,13 +6654,11 @@ uc_check_code(
result = STRLEN(eap->arg) + 2; result = STRLEN(eap->arg) + 2;
for (p = eap->arg; *p; ++p) for (p = eap->arg; *p; ++p)
{ {
#ifdef FEAT_MBYTE
if (enc_dbcs != 0 && (*mb_ptr2len)(p) == 2) if (enc_dbcs != 0 && (*mb_ptr2len)(p) == 2)
/* DBCS can contain \ in a trail byte, skip the /* DBCS can contain \ in a trail byte, skip the
* double-byte character. */ * double-byte character. */
++p; ++p;
else else
#endif
if (*p == '\\' || *p == '"') if (*p == '\\' || *p == '"')
++result; ++result;
} }
@ -6701,13 +6668,11 @@ uc_check_code(
*buf++ = '"'; *buf++ = '"';
for (p = eap->arg; *p; ++p) for (p = eap->arg; *p; ++p)
{ {
#ifdef FEAT_MBYTE
if (enc_dbcs != 0 && (*mb_ptr2len)(p) == 2) if (enc_dbcs != 0 && (*mb_ptr2len)(p) == 2)
/* DBCS can contain \ in a trail byte, copy the /* DBCS can contain \ in a trail byte, copy the
* double-byte character to avoid escaping. */ * double-byte character to avoid escaping. */
*buf++ = *p++; *buf++ = *p++;
else else
#endif
if (*p == '\\' || *p == '"') if (*p == '\\' || *p == '"')
*buf++ = '\\'; *buf++ = '\\';
*buf++ = *p; *buf++ = *p;
@ -10328,11 +10293,9 @@ restore_current_state(save_state_T *sst)
ex_normal(exarg_T *eap) ex_normal(exarg_T *eap)
{ {
save_state_T save_state; save_state_T save_state;
#ifdef FEAT_MBYTE
char_u *arg = NULL; char_u *arg = NULL;
int l; int l;
char_u *p; char_u *p;
#endif
if (ex_normal_lock > 0) if (ex_normal_lock > 0)
{ {
@ -10345,7 +10308,6 @@ ex_normal(exarg_T *eap)
return; return;
} }
#ifdef FEAT_MBYTE
/* /*
* vgetc() expects a CSI and K_SPECIAL to have been escaped. Don't do * vgetc() expects a CSI and K_SPECIAL to have been escaped. Don't do
* this for the K_SPECIAL leading byte, otherwise special keys will not * this for the K_SPECIAL leading byte, otherwise special keys will not
@ -10358,15 +10320,15 @@ ex_normal(exarg_T *eap)
/* Count the number of characters to be escaped. */ /* Count the number of characters to be escaped. */
for (p = eap->arg; *p != NUL; ++p) for (p = eap->arg; *p != NUL; ++p)
{ {
# ifdef FEAT_GUI #ifdef FEAT_GUI
if (*p == CSI) /* leadbyte CSI */ if (*p == CSI) /* leadbyte CSI */
len += 2; len += 2;
# endif #endif
for (l = (*mb_ptr2len)(p) - 1; l > 0; --l) for (l = (*mb_ptr2len)(p) - 1; l > 0; --l)
if (*++p == K_SPECIAL /* trailbyte K_SPECIAL or CSI */ if (*++p == K_SPECIAL /* trailbyte K_SPECIAL or CSI */
# ifdef FEAT_GUI #ifdef FEAT_GUI
|| *p == CSI || *p == CSI
# endif #endif
) )
len += 2; len += 2;
} }
@ -10379,13 +10341,13 @@ ex_normal(exarg_T *eap)
for (p = eap->arg; *p != NUL; ++p) for (p = eap->arg; *p != NUL; ++p)
{ {
arg[len++] = *p; arg[len++] = *p;
# ifdef FEAT_GUI #ifdef FEAT_GUI
if (*p == CSI) if (*p == CSI)
{ {
arg[len++] = KS_EXTRA; arg[len++] = KS_EXTRA;
arg[len++] = (int)KE_CSI; arg[len++] = (int)KE_CSI;
} }
# endif #endif
for (l = (*mb_ptr2len)(p) - 1; l > 0; --l) for (l = (*mb_ptr2len)(p) - 1; l > 0; --l)
{ {
arg[len++] = *++p; arg[len++] = *++p;
@ -10394,20 +10356,19 @@ ex_normal(exarg_T *eap)
arg[len++] = KS_SPECIAL; arg[len++] = KS_SPECIAL;
arg[len++] = KE_FILLER; arg[len++] = KE_FILLER;
} }
# ifdef FEAT_GUI #ifdef FEAT_GUI
else if (*p == CSI) else if (*p == CSI)
{ {
arg[len++] = KS_EXTRA; arg[len++] = KS_EXTRA;
arg[len++] = (int)KE_CSI; arg[len++] = (int)KE_CSI;
} }
# endif #endif
} }
arg[len] = NUL; arg[len] = NUL;
} }
} }
} }
} }
#endif
++ex_normal_busy; ++ex_normal_busy;
if (save_current_state(&save_state)) if (save_current_state(&save_state))
@ -10426,11 +10387,9 @@ ex_normal(exarg_T *eap)
check_cursor_moved(curwin); check_cursor_moved(curwin);
} }
exec_normal_cmd( exec_normal_cmd(arg != NULL
#ifdef FEAT_MBYTE ? arg
arg != NULL ? arg : : eap->arg, eap->forceit ? REMAP_NONE : REMAP_YES, FALSE);
#endif
eap->arg, eap->forceit ? REMAP_NONE : REMAP_YES, FALSE);
} }
while (eap->addr_count > 0 && eap->line1 <= eap->line2 && !got_int); while (eap->addr_count > 0 && eap->line1 <= eap->line2 && !got_int);
} }
@ -10447,9 +10406,7 @@ ex_normal(exarg_T *eap)
ui_cursor_shape(); /* may show different cursor shape */ ui_cursor_shape(); /* may show different cursor shape */
#endif #endif
#ifdef FEAT_MBYTE
vim_free(arg); vim_free(arg);
#endif
} }
/* /*

View File

@ -89,9 +89,7 @@ static char_u *getcmdline_int(int firstc, long count, int indent, int init_cclin
static int cmdline_charsize(int idx); static int cmdline_charsize(int idx);
static void set_cmdspos(void); static void set_cmdspos(void);
static void set_cmdspos_cursor(void); static void set_cmdspos_cursor(void);
#ifdef FEAT_MBYTE
static void correct_cmdspos(int idx, int cells); static void correct_cmdspos(int idx, int cells);
#endif
static void alloc_cmdbuff(int len); static void alloc_cmdbuff(int len);
static int realloc_cmdbuff(int len); static int realloc_cmdbuff(int len);
static void draw_cmdline(int start, int len); static void draw_cmdline(int start, int len);
@ -769,7 +767,6 @@ may_add_char_to_search(int firstc, int *c, incsearch_state_T *is_state)
stuffcharReadbuff(*c); stuffcharReadbuff(*c);
*c = '\\'; *c = '\\';
} }
#ifdef FEAT_MBYTE
// add any composing characters // add any composing characters
if (mb_char2len(*c) != mb_ptr2len(ml_get_cursor())) if (mb_char2len(*c) != mb_ptr2len(ml_get_cursor()))
{ {
@ -783,7 +780,6 @@ may_add_char_to_search(int firstc, int *c, incsearch_state_T *is_state)
} }
*c = save_c; *c = save_c;
} }
#endif
return FAIL; return FAIL;
} }
} }
@ -1253,10 +1249,8 @@ getcmdline_int(
i = (int)(xpc.xp_pattern - ccline.cmdbuff); i = (int)(xpc.xp_pattern - ccline.cmdbuff);
while (--j > i) while (--j > i)
{ {
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
j -= (*mb_head_off)(ccline.cmdbuff, ccline.cmdbuff + j); j -= (*mb_head_off)(ccline.cmdbuff, ccline.cmdbuff + j);
#endif
if (vim_ispathsep(ccline.cmdbuff[j])) if (vim_ispathsep(ccline.cmdbuff[j]))
{ {
found = TRUE; found = TRUE;
@ -1281,10 +1275,8 @@ getcmdline_int(
i = (int)(xpc.xp_pattern - ccline.cmdbuff); i = (int)(xpc.xp_pattern - ccline.cmdbuff);
while (--j > i) while (--j > i)
{ {
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
j -= (*mb_head_off)(ccline.cmdbuff, ccline.cmdbuff + j); j -= (*mb_head_off)(ccline.cmdbuff, ccline.cmdbuff + j);
#endif
if (vim_ispathsep(ccline.cmdbuff[j]) if (vim_ispathsep(ccline.cmdbuff[j])
#ifdef BACKSLASH_IN_FILENAME #ifdef BACKSLASH_IN_FILENAME
&& vim_strchr((char_u *)" *?[{`$%#", && vim_strchr((char_u *)" *?[{`$%#",
@ -1616,18 +1608,15 @@ getcmdline_int(
*/ */
if (c == K_DEL && ccline.cmdpos != ccline.cmdlen) if (c == K_DEL && ccline.cmdpos != ccline.cmdlen)
++ccline.cmdpos; ++ccline.cmdpos;
#ifdef FEAT_MBYTE
if (has_mbyte && c == K_DEL) if (has_mbyte && c == K_DEL)
ccline.cmdpos += mb_off_next(ccline.cmdbuff, ccline.cmdpos += mb_off_next(ccline.cmdbuff,
ccline.cmdbuff + ccline.cmdpos); ccline.cmdbuff + ccline.cmdpos);
#endif
if (ccline.cmdpos > 0) if (ccline.cmdpos > 0)
{ {
char_u *p; char_u *p;
j = ccline.cmdpos; j = ccline.cmdpos;
p = ccline.cmdbuff + j; p = ccline.cmdbuff + j;
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
p = mb_prevptr(ccline.cmdbuff, p); p = mb_prevptr(ccline.cmdbuff, p);
@ -1642,9 +1631,7 @@ getcmdline_int(
p += (*mb_ptr2len)(p); p += (*mb_ptr2len)(p);
} }
} }
else else if (c == Ctrl_W)
#endif
if (c == Ctrl_W)
{ {
while (p > ccline.cmdbuff && vim_isspace(p[-1])) while (p > ccline.cmdbuff && vim_isspace(p[-1]))
--p; --p;
@ -1893,21 +1880,17 @@ getcmdline_int(
if (KeyTyped && ccline.cmdspos + i >= Columns * Rows) if (KeyTyped && ccline.cmdspos + i >= Columns * Rows)
break; break;
ccline.cmdspos += i; ccline.cmdspos += i;
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
ccline.cmdpos += (*mb_ptr2len)(ccline.cmdbuff ccline.cmdpos += (*mb_ptr2len)(ccline.cmdbuff
+ ccline.cmdpos); + ccline.cmdpos);
else else
#endif
++ccline.cmdpos; ++ccline.cmdpos;
} }
while ((c == K_S_RIGHT || c == K_C_RIGHT while ((c == K_S_RIGHT || c == K_C_RIGHT
|| (mod_mask & (MOD_MASK_SHIFT|MOD_MASK_CTRL))) || (mod_mask & (MOD_MASK_SHIFT|MOD_MASK_CTRL)))
&& ccline.cmdbuff[ccline.cmdpos] != ' '); && ccline.cmdbuff[ccline.cmdpos] != ' ');
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
set_cmdspos_cursor(); set_cmdspos_cursor();
#endif
goto cmdline_not_changed; goto cmdline_not_changed;
case K_LEFT: case K_LEFT:
@ -1918,21 +1901,17 @@ getcmdline_int(
do do
{ {
--ccline.cmdpos; --ccline.cmdpos;
#ifdef FEAT_MBYTE
if (has_mbyte) /* move to first byte of char */ if (has_mbyte) /* move to first byte of char */
ccline.cmdpos -= (*mb_head_off)(ccline.cmdbuff, ccline.cmdpos -= (*mb_head_off)(ccline.cmdbuff,
ccline.cmdbuff + ccline.cmdpos); ccline.cmdbuff + ccline.cmdpos);
#endif
ccline.cmdspos -= cmdline_charsize(ccline.cmdpos); ccline.cmdspos -= cmdline_charsize(ccline.cmdpos);
} }
while (ccline.cmdpos > 0 while (ccline.cmdpos > 0
&& (c == K_S_LEFT || c == K_C_LEFT && (c == K_S_LEFT || c == K_C_LEFT
|| (mod_mask & (MOD_MASK_SHIFT|MOD_MASK_CTRL))) || (mod_mask & (MOD_MASK_SHIFT|MOD_MASK_CTRL)))
&& ccline.cmdbuff[ccline.cmdpos - 1] != ' '); && ccline.cmdbuff[ccline.cmdpos - 1] != ' ');
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
set_cmdspos_cursor(); set_cmdspos_cursor();
#endif
goto cmdline_not_changed; goto cmdline_not_changed;
case K_IGNORE: case K_IGNORE:
@ -2030,7 +2009,6 @@ getcmdline_int(
if (mouse_row <= cmdline_row + ccline.cmdspos / Columns if (mouse_row <= cmdline_row + ccline.cmdspos / Columns
&& mouse_col < ccline.cmdspos % Columns + i) && mouse_col < ccline.cmdspos % Columns + i)
break; break;
# ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
/* Count ">" for double-wide char that doesn't fit. */ /* Count ">" for double-wide char that doesn't fit. */
@ -2038,7 +2016,6 @@ getcmdline_int(
ccline.cmdpos += (*mb_ptr2len)(ccline.cmdbuff ccline.cmdpos += (*mb_ptr2len)(ccline.cmdbuff
+ ccline.cmdpos) - 1; + ccline.cmdpos) - 1;
} }
# endif
ccline.cmdspos += i; ccline.cmdspos += i;
} }
goto cmdline_not_changed; goto cmdline_not_changed;
@ -2301,7 +2278,6 @@ getcmdline_int(
c = get_literal(); /* get next (two) character(s) */ c = get_literal(); /* get next (two) character(s) */
do_abbr = FALSE; /* don't do abbreviation now */ do_abbr = FALSE; /* don't do abbreviation now */
extra_char = NUL; extra_char = NUL;
#ifdef FEAT_MBYTE
/* may need to remove ^ when composing char was typed */ /* may need to remove ^ when composing char was typed */
if (enc_utf8 && utf_iscomposing(c) && !cmd_silent) if (enc_utf8 && utf_iscomposing(c) && !cmd_silent)
{ {
@ -2309,7 +2285,6 @@ getcmdline_int(
msg_putchar(' '); msg_putchar(' ');
cursorcmd(); cursorcmd();
} }
#endif
break; break;
#ifdef FEAT_DIGRAPHS #ifdef FEAT_DIGRAPHS
@ -2374,13 +2349,12 @@ getcmdline_int(
* We come here if we have a normal character. * We come here if we have a normal character.
*/ */
if (do_abbr && (IS_SPECIAL(c) || !vim_iswordc(c)) && (ccheck_abbr( if (do_abbr && (IS_SPECIAL(c) || !vim_iswordc(c))
#ifdef FEAT_MBYTE && (ccheck_abbr(
/* Add ABBR_OFF for characters above 0x100, this is // Add ABBR_OFF for characters above 0x100, this is
* what check_abbr() expects. */ // what check_abbr() expects.
(has_mbyte && c >= 0x100) ? (c + ABBR_OFF) : (has_mbyte && c >= 0x100) ? (c + ABBR_OFF) : c)
#endif || c == Ctrl_RSB))
c) || c == Ctrl_RSB))
goto cmdline_changed; goto cmdline_changed;
/* /*
@ -2390,7 +2364,6 @@ getcmdline_int(
put_on_cmdline(get_special_key_name(c, mod_mask), -1, TRUE); put_on_cmdline(get_special_key_name(c, mod_mask), -1, TRUE);
else else
{ {
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
j = (*mb_char2bytes)(c, IObuff); j = (*mb_char2bytes)(c, IObuff);
@ -2398,7 +2371,6 @@ getcmdline_int(
put_on_cmdline(IObuff, j, TRUE); put_on_cmdline(IObuff, j, TRUE);
} }
else else
#endif
{ {
IObuff[0] = c; IObuff[0] = c;
put_on_cmdline(IObuff, 1, TRUE); put_on_cmdline(IObuff, 1, TRUE);
@ -2687,11 +2659,9 @@ set_cmdspos_cursor(void)
for (i = 0; i < ccline.cmdlen && i < ccline.cmdpos; ++i) for (i = 0; i < ccline.cmdlen && i < ccline.cmdpos; ++i)
{ {
c = cmdline_charsize(i); c = cmdline_charsize(i);
#ifdef FEAT_MBYTE
/* Count ">" for double-wide multi-byte char that doesn't fit. */ /* Count ">" for double-wide multi-byte char that doesn't fit. */
if (has_mbyte) if (has_mbyte)
correct_cmdspos(i, c); correct_cmdspos(i, c);
#endif
/* If the cmdline doesn't fit, show cursor on last visible char. /* If the cmdline doesn't fit, show cursor on last visible char.
* Don't move the cursor itself, so we can still append. */ * Don't move the cursor itself, so we can still append. */
if ((ccline.cmdspos += c) >= m) if ((ccline.cmdspos += c) >= m)
@ -2699,14 +2669,11 @@ set_cmdspos_cursor(void)
ccline.cmdspos -= c; ccline.cmdspos -= c;
break; break;
} }
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
i += (*mb_ptr2len)(ccline.cmdbuff + i) - 1; i += (*mb_ptr2len)(ccline.cmdbuff + i) - 1;
#endif
} }
} }
#ifdef FEAT_MBYTE
/* /*
* Check if the character at "idx", which is "cells" wide, is a multi-byte * Check if the character at "idx", which is "cells" wide, is a multi-byte
* character that doesn't fit, so that a ">" must be displayed. * character that doesn't fit, so that a ">" must be displayed.
@ -2719,7 +2686,6 @@ correct_cmdspos(int idx, int cells)
&& ccline.cmdspos % Columns + cells > Columns) && ccline.cmdspos % Columns + cells > Columns)
ccline.cmdspos++; ccline.cmdspos++;
} }
#endif
/* /*
* Get an Ex command line for the ":" command. * Get an Ex command line for the ":" command.
@ -2849,7 +2815,6 @@ getexmodeline(
{ {
if (line_ga.ga_len > 0) if (line_ga.ga_len > 0)
{ {
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
p = (char_u *)line_ga.ga_data; p = (char_u *)line_ga.ga_data;
@ -2858,7 +2823,6 @@ getexmodeline(
line_ga.ga_len -= len; line_ga.ga_len -= len;
} }
else else
#endif
--line_ga.ga_len; --line_ga.ga_len;
goto redraw; goto redraw;
} }
@ -2962,12 +2926,10 @@ redraw:
if (IS_SPECIAL(c1)) if (IS_SPECIAL(c1))
c1 = '?'; c1 = '?';
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
len = (*mb_char2bytes)(c1, len = (*mb_char2bytes)(c1,
(char_u *)line_ga.ga_data + line_ga.ga_len); (char_u *)line_ga.ga_data + line_ga.ga_len);
else else
#endif
{ {
len = 1; len = 1;
((char_u *)line_ga.ga_data)[line_ga.ga_len] = c1; ((char_u *)line_ga.ga_data)[line_ga.ga_len] = c1;
@ -3070,7 +3032,6 @@ cmdline_getvcol_cursor(void)
if (ccline.cmdbuff == NULL || ccline.cmdpos > ccline.cmdlen) if (ccline.cmdbuff == NULL || ccline.cmdpos > ccline.cmdlen)
return MAXCOL; return MAXCOL;
# ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
colnr_T col; colnr_T col;
@ -3082,7 +3043,6 @@ cmdline_getvcol_cursor(void)
return col; return col;
} }
else else
# endif
return ccline.cmdpos; return ccline.cmdpos;
} }
#endif #endif
@ -3111,7 +3071,6 @@ redrawcmd_preedit(void)
old_col = msg_col; old_col = msg_col;
cmdspos = ((ccline.cmdfirstc != NUL) ? 1 : 0) + ccline.cmdindent; cmdspos = ((ccline.cmdfirstc != NUL) ? 1 : 0) + ccline.cmdindent;
# ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
for (col = 0; col < preedit_start_col for (col = 0; col < preedit_start_col
@ -3122,7 +3081,6 @@ redrawcmd_preedit(void)
} }
} }
else else
# endif
{ {
cmdspos += preedit_start_col; cmdspos += preedit_start_col;
cmdpos += preedit_start_col; cmdpos += preedit_start_col;
@ -3142,11 +3100,9 @@ redrawcmd_preedit(void)
if (char_attr < 0) if (char_attr < 0)
break; /* end of preedit string */ break; /* end of preedit string */
# ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
char_len = (*mb_ptr2len)(ccline.cmdbuff + cmdpos); char_len = (*mb_ptr2len)(ccline.cmdbuff + cmdpos);
else else
# endif
char_len = 1; char_len = 1;
msg_outtrans_len_attr(ccline.cmdbuff + cmdpos, char_len, char_attr); msg_outtrans_len_attr(ccline.cmdbuff + cmdpos, char_len, char_attr);
@ -3245,10 +3201,8 @@ draw_cmdline(int start, int len)
for (i = 0; i < len; ++i) for (i = 0; i < len; ++i)
{ {
msg_putchar('*'); msg_putchar('*');
# ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
i += (*mb_ptr2len)(ccline.cmdbuff + start + i) - 1; i += (*mb_ptr2len)(ccline.cmdbuff + start + i) - 1;
# endif
} }
else else
#endif #endif
@ -3382,11 +3336,9 @@ unputcmdline(void)
msg_no_more = TRUE; msg_no_more = TRUE;
if (ccline.cmdlen == ccline.cmdpos) if (ccline.cmdlen == ccline.cmdpos)
msg_putchar(' '); msg_putchar(' ');
#ifdef FEAT_MBYTE
else if (has_mbyte) else if (has_mbyte)
draw_cmdline(ccline.cmdpos, draw_cmdline(ccline.cmdpos,
(*mb_ptr2len)(ccline.cmdbuff + ccline.cmdpos)); (*mb_ptr2len)(ccline.cmdbuff + ccline.cmdpos));
#endif
else else
draw_cmdline(ccline.cmdpos, 1); draw_cmdline(ccline.cmdpos, 1);
msg_no_more = FALSE; msg_no_more = FALSE;
@ -3429,7 +3381,6 @@ put_on_cmdline(char_u *str, int len, int redraw)
} }
else else
{ {
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
/* Count nr of characters in the new string. */ /* Count nr of characters in the new string. */
@ -3450,15 +3401,12 @@ put_on_cmdline(char_u *str, int len, int redraw)
else else
ccline.cmdlen = ccline.cmdpos + len; ccline.cmdlen = ccline.cmdpos + len;
} }
else else if (ccline.cmdpos + len > ccline.cmdlen)
#endif
if (ccline.cmdpos + len > ccline.cmdlen)
ccline.cmdlen = ccline.cmdpos + len; ccline.cmdlen = ccline.cmdpos + len;
} }
mch_memmove(ccline.cmdbuff + ccline.cmdpos, str, (size_t)len); mch_memmove(ccline.cmdbuff + ccline.cmdpos, str, (size_t)len);
ccline.cmdbuff[ccline.cmdlen] = NUL; ccline.cmdbuff[ccline.cmdlen] = NUL;
#ifdef FEAT_MBYTE
if (enc_utf8) if (enc_utf8)
{ {
/* When the inserted text starts with a composing character, /* When the inserted text starts with a composing character,
@ -3474,7 +3422,7 @@ put_on_cmdline(char_u *str, int len, int redraw)
len += i; len += i;
c = utf_ptr2char(ccline.cmdbuff + ccline.cmdpos); c = utf_ptr2char(ccline.cmdbuff + ccline.cmdpos);
} }
# ifdef FEAT_ARABIC #ifdef FEAT_ARABIC
if (i == 0 && ccline.cmdpos > 0 && arabic_maycombine(c)) if (i == 0 && ccline.cmdpos > 0 && arabic_maycombine(c))
{ {
/* Check the previous character for Arabic combining pair. */ /* Check the previous character for Arabic combining pair. */
@ -3489,7 +3437,7 @@ put_on_cmdline(char_u *str, int len, int redraw)
else else
i = 0; i = 0;
} }
# endif #endif
if (i != 0) if (i != 0)
{ {
/* Also backup the cursor position. */ /* Also backup the cursor position. */
@ -3503,7 +3451,6 @@ put_on_cmdline(char_u *str, int len, int redraw)
} }
} }
} }
#endif
if (redraw && !cmd_silent) if (redraw && !cmd_silent)
{ {
@ -3535,17 +3482,15 @@ put_on_cmdline(char_u *str, int len, int redraw)
for (i = 0; i < len; ++i) for (i = 0; i < len; ++i)
{ {
c = cmdline_charsize(ccline.cmdpos); c = cmdline_charsize(ccline.cmdpos);
#ifdef FEAT_MBYTE
/* count ">" for a double-wide char that doesn't fit. */ /* count ">" for a double-wide char that doesn't fit. */
if (has_mbyte) if (has_mbyte)
correct_cmdspos(ccline.cmdpos, c); correct_cmdspos(ccline.cmdpos, c);
#endif
/* Stop cursor at the end of the screen, but do increment the /* Stop cursor at the end of the screen, but do increment the
* insert position, so that entering a very long command * insert position, so that entering a very long command
* works, even though you can't see it. */ * works, even though you can't see it. */
if (ccline.cmdspos + c < m) if (ccline.cmdspos + c < m)
ccline.cmdspos += c; ccline.cmdspos += c;
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
c = (*mb_ptr2len)(ccline.cmdbuff + ccline.cmdpos) - 1; c = (*mb_ptr2len)(ccline.cmdbuff + ccline.cmdpos) - 1;
@ -3554,7 +3499,6 @@ put_on_cmdline(char_u *str, int len, int redraw)
ccline.cmdpos += c; ccline.cmdpos += c;
i += c; i += c;
} }
#endif
++ccline.cmdpos; ++ccline.cmdpos;
} }
} }
@ -3654,7 +3598,6 @@ cmdline_paste(
/* Locate start of last word in the cmd buffer. */ /* Locate start of last word in the cmd buffer. */
for (w = ccline.cmdbuff + ccline.cmdpos; w > ccline.cmdbuff; ) for (w = ccline.cmdbuff + ccline.cmdpos; w > ccline.cmdbuff; )
{ {
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
len = (*mb_head_off)(ccline.cmdbuff, w - 1) + 1; len = (*mb_head_off)(ccline.cmdbuff, w - 1) + 1;
@ -3663,7 +3606,6 @@ cmdline_paste(
w -= len; w -= len;
} }
else else
#endif
{ {
if (!vim_iswordc(w[-1])) if (!vim_iswordc(w[-1]))
break; break;
@ -3703,11 +3645,9 @@ cmdline_paste_str(char_u *s, int literally)
cv = *s; cv = *s;
if (cv == Ctrl_V && s[1]) if (cv == Ctrl_V && s[1])
++s; ++s;
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
c = mb_cptr2char_adv(&s); c = mb_cptr2char_adv(&s);
else else
#endif
c = *s++; c = *s++;
if (cv == Ctrl_V || c == ESC || c == Ctrl_C if (cv == Ctrl_V || c == ESC || c == Ctrl_C
|| c == CAR || c == NL || c == Ctrl_L || c == CAR || c == NL || c == Ctrl_L
@ -4237,22 +4177,18 @@ ExpandOne(
for (len = 0; xp->xp_files[0][len]; len += mb_len) for (len = 0; xp->xp_files[0][len]; len += mb_len)
{ {
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
mb_len = (*mb_ptr2len)(&xp->xp_files[0][len]); mb_len = (*mb_ptr2len)(&xp->xp_files[0][len]);
c0 =(* mb_ptr2char)(&xp->xp_files[0][len]); c0 =(* mb_ptr2char)(&xp->xp_files[0][len]);
} }
else else
#endif
c0 = xp->xp_files[0][len]; c0 = xp->xp_files[0][len];
for (i = 1; i < xp->xp_numfiles; ++i) for (i = 1; i < xp->xp_numfiles; ++i)
{ {
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
ci =(* mb_ptr2char)(&xp->xp_files[i][len]); ci =(* mb_ptr2char)(&xp->xp_files[i][len]);
else else
#endif
ci = xp->xp_files[i][len]; ci = xp->xp_files[i][len];
if (p_fic && (xp->xp_context == EXPAND_DIRECTORIES if (p_fic && (xp->xp_context == EXPAND_DIRECTORIES
|| xp->xp_context == EXPAND_FILES || xp->xp_context == EXPAND_FILES

View File

@ -27,11 +27,9 @@
/* Is there any system that doesn't have access()? */ /* Is there any system that doesn't have access()? */
#define USE_MCH_ACCESS #define USE_MCH_ACCESS
#ifdef FEAT_MBYTE
static char_u *next_fenc(char_u **pp); static char_u *next_fenc(char_u **pp);
# ifdef FEAT_EVAL #ifdef FEAT_EVAL
static char_u *readfile_charconvert(char_u *fname, char_u *fenc, int *fdp); static char_u *readfile_charconvert(char_u *fname, char_u *fenc, int *fdp);
# endif
#endif #endif
#ifdef FEAT_VIMINFO #ifdef FEAT_VIMINFO
static void check_marks_read(void); static void check_marks_read(void);
@ -47,31 +45,29 @@ static int time_differs(long t1, long t2);
static int apply_autocmds_exarg(event_T event, char_u *fname, char_u *fname_io, int force, buf_T *buf, exarg_T *eap); static int apply_autocmds_exarg(event_T event, char_u *fname, char_u *fname_io, int force, buf_T *buf, exarg_T *eap);
static int au_find_group(char_u *name); static int au_find_group(char_u *name);
# define AUGROUP_DEFAULT -1 /* default autocmd group */ #define AUGROUP_DEFAULT -1 /* default autocmd group */
# define AUGROUP_ERROR -2 /* erroneous autocmd group */ #define AUGROUP_ERROR -2 /* erroneous autocmd group */
# define AUGROUP_ALL -3 /* all autocmd groups */ #define AUGROUP_ALL -3 /* all autocmd groups */
#if defined(FEAT_CRYPT) || defined(FEAT_MBYTE) #define HAS_BW_FLAGS
# define HAS_BW_FLAGS #define FIO_LATIN1 0x01 /* convert Latin1 */
# define FIO_LATIN1 0x01 /* convert Latin1 */ #define FIO_UTF8 0x02 /* convert UTF-8 */
# define FIO_UTF8 0x02 /* convert UTF-8 */ #define FIO_UCS2 0x04 /* convert UCS-2 */
# define FIO_UCS2 0x04 /* convert UCS-2 */ #define FIO_UCS4 0x08 /* convert UCS-4 */
# define FIO_UCS4 0x08 /* convert UCS-4 */ #define FIO_UTF16 0x10 /* convert UTF-16 */
# define FIO_UTF16 0x10 /* convert UTF-16 */ #ifdef WIN3264
# ifdef WIN3264 # define FIO_CODEPAGE 0x20 /* convert MS-Windows codepage */
# define FIO_CODEPAGE 0x20 /* convert MS-Windows codepage */ # define FIO_PUT_CP(x) (((x) & 0xffff) << 16) /* put codepage in top word */
# define FIO_PUT_CP(x) (((x) & 0xffff) << 16) /* put codepage in top word */ # define FIO_GET_CP(x) (((x)>>16) & 0xffff) /* get codepage from top word */
# define FIO_GET_CP(x) (((x)>>16) & 0xffff) /* get codepage from top word */
# endif
# ifdef MACOS_CONVERT
# define FIO_MACROMAN 0x20 /* convert MacRoman */
# endif
# define FIO_ENDIAN_L 0x80 /* little endian */
# define FIO_ENCRYPTED 0x1000 /* encrypt written bytes */
# define FIO_NOCONVERT 0x2000 /* skip encoding conversion */
# define FIO_UCSBOM 0x4000 /* check for BOM at start of file */
# define FIO_ALL -1 /* allow all formats */
#endif #endif
#ifdef MACOS_CONVERT
# define FIO_MACROMAN 0x20 /* convert MacRoman */
#endif
#define FIO_ENDIAN_L 0x80 /* little endian */
#define FIO_ENCRYPTED 0x1000 /* encrypt written bytes */
#define FIO_NOCONVERT 0x2000 /* skip encoding conversion */
#define FIO_UCSBOM 0x4000 /* check for BOM at start of file */
#define FIO_ALL -1 /* allow all formats */
/* When converting, a read() or write() may leave some bytes to be converted /* When converting, a read() or write() may leave some bytes to be converted
* for the next call. The value is guessed... */ * for the next call. The value is guessed... */
@ -95,7 +91,6 @@ struct bw_info
#ifdef FEAT_CRYPT #ifdef FEAT_CRYPT
buf_T *bw_buffer; /* buffer being written */ buf_T *bw_buffer; /* buffer being written */
#endif #endif
#ifdef FEAT_MBYTE
char_u bw_rest[CONV_RESTLEN]; /* not converted bytes */ char_u bw_rest[CONV_RESTLEN]; /* not converted bytes */
int bw_restlen; /* nr of bytes in bw_rest[] */ int bw_restlen; /* nr of bytes in bw_rest[] */
int bw_first; /* first write call */ int bw_first; /* first write call */
@ -104,27 +99,24 @@ struct bw_info
int bw_conv_error; /* set for conversion error */ int bw_conv_error; /* set for conversion error */
linenr_T bw_conv_error_lnum; /* first line with error or zero */ linenr_T bw_conv_error_lnum; /* first line with error or zero */
linenr_T bw_start_lnum; /* line number at start of buffer */ linenr_T bw_start_lnum; /* line number at start of buffer */
# ifdef USE_ICONV #ifdef USE_ICONV
iconv_t bw_iconv_fd; /* descriptor for iconv() or -1 */ iconv_t bw_iconv_fd; /* descriptor for iconv() or -1 */
# endif
#endif #endif
}; };
static int buf_write_bytes(struct bw_info *ip); static int buf_write_bytes(struct bw_info *ip);
#ifdef FEAT_MBYTE
static linenr_T readfile_linenr(linenr_T linecnt, char_u *p, char_u *endp); static linenr_T readfile_linenr(linenr_T linecnt, char_u *p, char_u *endp);
static int ucs2bytes(unsigned c, char_u **pp, int flags); static int ucs2bytes(unsigned c, char_u **pp, int flags);
static int need_conversion(char_u *fenc); static int need_conversion(char_u *fenc);
static int get_fio_flags(char_u *ptr); static int get_fio_flags(char_u *ptr);
static char_u *check_for_bom(char_u *p, long size, int *lenp, int flags); static char_u *check_for_bom(char_u *p, long size, int *lenp, int flags);
static int make_bom(char_u *buf, char_u *name); static int make_bom(char_u *buf, char_u *name);
# ifdef WIN3264 #ifdef WIN3264
static int get_win_fio_flags(char_u *ptr); static int get_win_fio_flags(char_u *ptr);
# endif #endif
# ifdef MACOS_CONVERT #ifdef MACOS_CONVERT
static int get_mac_fio_flags(char_u *ptr); static int get_mac_fio_flags(char_u *ptr);
# endif
#endif #endif
static char *e_auchangedbuf = N_("E812: Autocommands changed buffer or buffer name"); static char *e_auchangedbuf = N_("E812: Autocommands changed buffer or buffer name");
@ -265,7 +257,6 @@ readfile(
int try_dos; int try_dos;
int try_unix; int try_unix;
int file_rewind = FALSE; int file_rewind = FALSE;
#ifdef FEAT_MBYTE
int can_retry; int can_retry;
linenr_T conv_error = 0; /* line nr with conversion error */ linenr_T conv_error = 0; /* line nr with conversion error */
linenr_T illegal_byte = 0; /* line nr with illegal byte */ linenr_T illegal_byte = 0; /* line nr with illegal byte */
@ -281,19 +272,18 @@ readfile(
char_u *fenc_next = NULL; /* next item in 'fencs' or NULL */ char_u *fenc_next = NULL; /* next item in 'fencs' or NULL */
int advance_fenc = FALSE; int advance_fenc = FALSE;
long real_size = 0; long real_size = 0;
# ifdef USE_ICONV #ifdef USE_ICONV
iconv_t iconv_fd = (iconv_t)-1; /* descriptor for iconv() or -1 */ iconv_t iconv_fd = (iconv_t)-1; /* descriptor for iconv() or -1 */
# ifdef FEAT_EVAL # ifdef FEAT_EVAL
int did_iconv = FALSE; /* TRUE when iconv() failed and trying int did_iconv = FALSE; /* TRUE when iconv() failed and trying
'charconvert' next */ 'charconvert' next */
# endif
# endif # endif
#endif
int converted = FALSE; /* TRUE if conversion done */ int converted = FALSE; /* TRUE if conversion done */
int notconverted = FALSE; /* TRUE if conversion wanted but it int notconverted = FALSE; /* TRUE if conversion wanted but it
wasn't possible */ wasn't possible */
char_u conv_rest[CONV_RESTLEN]; char_u conv_rest[CONV_RESTLEN];
int conv_restlen = 0; /* nr of bytes in conv_rest[] */ int conv_restlen = 0; /* nr of bytes in conv_rest[] */
#endif
buf_T *old_curbuf; buf_T *old_curbuf;
char_u *old_b_ffname; char_u *old_b_ffname;
char_u *old_b_fname; char_u *old_b_fname;
@ -609,11 +599,9 @@ readfile(
* edited before and deleted. Get the old marks. */ * edited before and deleted. Get the old marks. */
check_marks_read(); check_marks_read();
#endif #endif
#ifdef FEAT_MBYTE
/* Set forced 'fileencoding'. */ /* Set forced 'fileencoding'. */
if (eap != NULL) if (eap != NULL)
set_forced_fenc(eap); set_forced_fenc(eap);
#endif
apply_autocmds_exarg(EVENT_BUFNEWFILE, sfname, sfname, apply_autocmds_exarg(EVENT_BUFNEWFILE, sfname, sfname,
FALSE, curbuf, eap); FALSE, curbuf, eap);
/* remember the current fileformat */ /* remember the current fileformat */
@ -658,10 +646,8 @@ readfile(
curbuf->b_p_eol = TRUE; curbuf->b_p_eol = TRUE;
curbuf->b_start_eol = TRUE; curbuf->b_start_eol = TRUE;
} }
#ifdef FEAT_MBYTE
curbuf->b_p_bomb = FALSE; curbuf->b_p_bomb = FALSE;
curbuf->b_start_bomb = FALSE; curbuf->b_start_bomb = FALSE;
#endif
} }
/* Create a swap file now, so that other Vims are warned that we are /* Create a swap file now, so that other Vims are warned that we are
@ -846,7 +832,6 @@ readfile(
*/ */
linecnt = curbuf->b_ml.ml_line_count; linecnt = curbuf->b_ml.ml_line_count;
#ifdef FEAT_MBYTE
/* "++bad=" argument. */ /* "++bad=" argument. */
if (eap != NULL && eap->bad_char != 0) if (eap != NULL && eap->bad_char != 0)
{ {
@ -926,7 +911,6 @@ readfile(
fenc = next_fenc(&fenc_next); fenc = next_fenc(&fenc_next);
fenc_alloced = TRUE; fenc_alloced = TRUE;
} }
#endif
/* /*
* Jump back here to retry reading the file in different ways. * Jump back here to retry reading the file in different ways.
@ -966,14 +950,12 @@ retry:
while (lnum > from) while (lnum > from)
ml_delete(lnum--, FALSE); ml_delete(lnum--, FALSE);
file_rewind = FALSE; file_rewind = FALSE;
#ifdef FEAT_MBYTE
if (set_options) if (set_options)
{ {
curbuf->b_p_bomb = FALSE; curbuf->b_p_bomb = FALSE;
curbuf->b_start_bomb = FALSE; curbuf->b_start_bomb = FALSE;
} }
conv_error = 0; conv_error = 0;
#endif
} }
/* /*
@ -997,15 +979,14 @@ retry:
fileformat = EOL_UNKNOWN; /* detect from file */ fileformat = EOL_UNKNOWN; /* detect from file */
} }
#ifdef FEAT_MBYTE #ifdef USE_ICONV
# ifdef USE_ICONV
if (iconv_fd != (iconv_t)-1) if (iconv_fd != (iconv_t)-1)
{ {
/* aborted conversion with iconv(), close the descriptor */ /* aborted conversion with iconv(), close the descriptor */
iconv_close(iconv_fd); iconv_close(iconv_fd);
iconv_fd = (iconv_t)-1; iconv_fd = (iconv_t)-1;
} }
# endif #endif
if (advance_fenc) if (advance_fenc)
{ {
@ -1073,49 +1054,49 @@ retry:
else if (enc_utf8 || STRCMP(p_enc, "latin1") == 0) else if (enc_utf8 || STRCMP(p_enc, "latin1") == 0)
fio_flags = get_fio_flags(fenc); fio_flags = get_fio_flags(fenc);
# ifdef WIN3264 #ifdef WIN3264
/* /*
* Conversion from an MS-Windows codepage to UTF-8 or another codepage * Conversion from an MS-Windows codepage to UTF-8 or another codepage
* is handled with MultiByteToWideChar(). * is handled with MultiByteToWideChar().
*/ */
if (fio_flags == 0) if (fio_flags == 0)
fio_flags = get_win_fio_flags(fenc); fio_flags = get_win_fio_flags(fenc);
# endif #endif
# ifdef MACOS_CONVERT #ifdef MACOS_CONVERT
/* Conversion from Apple MacRoman to latin1 or UTF-8 */ /* Conversion from Apple MacRoman to latin1 or UTF-8 */
if (fio_flags == 0) if (fio_flags == 0)
fio_flags = get_mac_fio_flags(fenc); fio_flags = get_mac_fio_flags(fenc);
# endif #endif
# ifdef USE_ICONV #ifdef USE_ICONV
/* /*
* Try using iconv() if we can't convert internally. * Try using iconv() if we can't convert internally.
*/ */
if (fio_flags == 0 if (fio_flags == 0
# ifdef FEAT_EVAL # ifdef FEAT_EVAL
&& !did_iconv && !did_iconv
# endif # endif
) )
iconv_fd = (iconv_t)my_iconv_open( iconv_fd = (iconv_t)my_iconv_open(
enc_utf8 ? (char_u *)"utf-8" : p_enc, fenc); enc_utf8 ? (char_u *)"utf-8" : p_enc, fenc);
# endif #endif
# ifdef FEAT_EVAL #ifdef FEAT_EVAL
/* /*
* Use the 'charconvert' expression when conversion is required * Use the 'charconvert' expression when conversion is required
* and we can't do it internally or with iconv(). * and we can't do it internally or with iconv().
*/ */
if (fio_flags == 0 && !read_stdin && !read_buffer && *p_ccv != NUL if (fio_flags == 0 && !read_stdin && !read_buffer && *p_ccv != NUL
&& !read_fifo && !read_fifo
# ifdef USE_ICONV # ifdef USE_ICONV
&& iconv_fd == (iconv_t)-1 && iconv_fd == (iconv_t)-1
# endif # endif
) )
{ {
# ifdef USE_ICONV # ifdef USE_ICONV
did_iconv = FALSE; did_iconv = FALSE;
# endif # endif
/* Skip conversion when it's already done (retry for wrong /* Skip conversion when it's already done (retry for wrong
* "fileformat"). */ * "fileformat"). */
if (tmpname == NULL) if (tmpname == NULL)
@ -1137,12 +1118,12 @@ retry:
} }
} }
else else
# endif #endif
{ {
if (fio_flags == 0 if (fio_flags == 0
# ifdef USE_ICONV #ifdef USE_ICONV
&& iconv_fd == (iconv_t)-1 && iconv_fd == (iconv_t)-1
# endif #endif
) )
{ {
/* Conversion wanted but we can't. /* Conversion wanted but we can't.
@ -1157,7 +1138,6 @@ retry:
* another "fenc" value. It's FALSE when no other "fenc" to try, reading * another "fenc" value. It's FALSE when no other "fenc" to try, reading
* stdin or fixed at a specific encoding. */ * stdin or fixed at a specific encoding. */
can_retry = (*fenc != NUL && !read_stdin && !read_fifo && !keep_dest_enc); can_retry = (*fenc != NUL && !read_stdin && !read_fifo && !keep_dest_enc);
#endif
if (!skip_read) if (!skip_read)
{ {
@ -1165,9 +1145,7 @@ retry:
filesize = 0; filesize = 0;
skip_count = lines_to_skip; skip_count = lines_to_skip;
read_count = lines_to_read; read_count = lines_to_read;
#ifdef FEAT_MBYTE
conv_restlen = 0; conv_restlen = 0;
#endif
#ifdef FEAT_PERSISTENT_UNDO #ifdef FEAT_PERSISTENT_UNDO
read_undo_file = (newfile && (flags & READ_KEEP_UNDO) == 0 read_undo_file = (newfile && (flags & READ_KEEP_UNDO) == 0
&& curbuf->b_ffname != NULL && curbuf->b_ffname != NULL
@ -1253,7 +1231,6 @@ retry:
ptr = buffer + linerest; ptr = buffer + linerest;
line_start = buffer; line_start = buffer;
#ifdef FEAT_MBYTE
/* May need room to translate into. /* May need room to translate into.
* For iconv() we don't really know the required space, use a * For iconv() we don't really know the required space, use a
* factor ICONV_MULT. * factor ICONV_MULT.
@ -1265,11 +1242,11 @@ retry:
* ucs-4 to utf-8: 4 bytes become up to 6 bytes, size must be * ucs-4 to utf-8: 4 bytes become up to 6 bytes, size must be
* multiple of 4 */ * multiple of 4 */
real_size = (int)size; real_size = (int)size;
# ifdef USE_ICONV #ifdef USE_ICONV
if (iconv_fd != (iconv_t)-1) if (iconv_fd != (iconv_t)-1)
size = size / ICONV_MULT; size = size / ICONV_MULT;
else else
# endif #endif
if (fio_flags & FIO_LATIN1) if (fio_flags & FIO_LATIN1)
size = size / 2; size = size / 2;
else if (fio_flags & (FIO_UCS2 | FIO_UTF16)) else if (fio_flags & (FIO_UCS2 | FIO_UTF16))
@ -1278,17 +1255,15 @@ retry:
size = (size * 2 / 3) & ~3; size = (size * 2 / 3) & ~3;
else if (fio_flags == FIO_UCSBOM) else if (fio_flags == FIO_UCSBOM)
size = size / ICONV_MULT; /* worst case */ size = size / ICONV_MULT; /* worst case */
# ifdef WIN3264 #ifdef WIN3264
else if (fio_flags & FIO_CODEPAGE) else if (fio_flags & FIO_CODEPAGE)
size = size / ICONV_MULT; /* also worst case */ size = size / ICONV_MULT; /* also worst case */
# endif #endif
# ifdef MACOS_CONVERT #ifdef MACOS_CONVERT
else if (fio_flags & FIO_MACROMAN) else if (fio_flags & FIO_MACROMAN)
size = size / ICONV_MULT; /* also worst case */ size = size / ICONV_MULT; /* also worst case */
# endif
#endif #endif
#ifdef FEAT_MBYTE
if (conv_restlen > 0) if (conv_restlen > 0)
{ {
/* Insert unconverted bytes from previous line. */ /* Insert unconverted bytes from previous line. */
@ -1296,7 +1271,6 @@ retry:
ptr += conv_restlen; ptr += conv_restlen;
size -= conv_restlen; size -= conv_restlen;
} }
#endif
if (read_buffer) if (read_buffer)
{ {
@ -1445,7 +1419,6 @@ retry:
{ {
if (size < 0) /* read error */ if (size < 0) /* read error */
error = TRUE; error = TRUE;
#ifdef FEAT_MBYTE
else if (conv_restlen > 0) else if (conv_restlen > 0)
{ {
/* /*
@ -1455,9 +1428,9 @@ retry:
/* When we did a conversion report an error. */ /* When we did a conversion report an error. */
if (fio_flags != 0 if (fio_flags != 0
# ifdef USE_ICONV #ifdef USE_ICONV
|| iconv_fd != (iconv_t)-1 || iconv_fd != (iconv_t)-1
# endif #endif
) )
{ {
if (can_retry) if (can_retry)
@ -1482,9 +1455,9 @@ retry:
* leave the UTF8 checking code to do it, as it * leave the UTF8 checking code to do it, as it
* works slightly differently. */ * works slightly differently. */
if (bad_char_behavior != BAD_KEEP && (fio_flags != 0 if (bad_char_behavior != BAD_KEEP && (fio_flags != 0
# ifdef USE_ICONV #ifdef USE_ICONV
|| iconv_fd != (iconv_t)-1 || iconv_fd != (iconv_t)-1
# endif #endif
)) ))
{ {
while (conv_restlen > 0) while (conv_restlen > 0)
@ -1494,21 +1467,19 @@ retry:
} }
} }
fio_flags = 0; /* don't convert this */ fio_flags = 0; /* don't convert this */
# ifdef USE_ICONV #ifdef USE_ICONV
if (iconv_fd != (iconv_t)-1) if (iconv_fd != (iconv_t)-1)
{ {
iconv_close(iconv_fd); iconv_close(iconv_fd);
iconv_fd = (iconv_t)-1; iconv_fd = (iconv_t)-1;
} }
# endif #endif
} }
} }
#endif
} }
} }
skip_read = FALSE; skip_read = FALSE;
#ifdef FEAT_MBYTE
/* /*
* At start of file (or after crypt magic number): Check for BOM. * At start of file (or after crypt magic number): Check for BOM.
* Also check for a BOM for other Unicode encodings, but not after * Also check for a BOM for other Unicode encodings, but not after
@ -1516,11 +1487,11 @@ retry:
* found. * found.
*/ */
if ((filesize == 0 if ((filesize == 0
# ifdef FEAT_CRYPT #ifdef FEAT_CRYPT
|| (cryptkey != NULL || (cryptkey != NULL
&& filesize == crypt_get_header_len( && filesize == crypt_get_header_len(
crypt_get_method_nr(curbuf))) crypt_get_method_nr(curbuf)))
# endif #endif
) )
&& (fio_flags == FIO_UCSBOM && (fio_flags == FIO_UCSBOM
|| (!curbuf->b_p_bomb || (!curbuf->b_p_bomb
@ -1574,16 +1545,14 @@ retry:
ptr -= conv_restlen; ptr -= conv_restlen;
size += conv_restlen; size += conv_restlen;
conv_restlen = 0; conv_restlen = 0;
#endif
/* /*
* Break here for a read error or end-of-file. * Break here for a read error or end-of-file.
*/ */
if (size <= 0) if (size <= 0)
break; break;
#ifdef FEAT_MBYTE
# ifdef USE_ICONV #ifdef USE_ICONV
if (iconv_fd != (iconv_t)-1) if (iconv_fd != (iconv_t)-1)
{ {
/* /*
@ -1645,9 +1614,9 @@ retry:
mch_memmove(line_start, buffer, (size_t)linerest); mch_memmove(line_start, buffer, (size_t)linerest);
size = (long)((char_u *)top - ptr); size = (long)((char_u *)top - ptr);
} }
# endif #endif
# ifdef WIN3264 #ifdef WIN3264
if (fio_flags & FIO_CODEPAGE) if (fio_flags & FIO_CODEPAGE)
{ {
char_u *src, *dst; char_u *src, *dst;
@ -1813,8 +1782,8 @@ retry:
size = (long)(dst - ptr); size = (long)(dst - ptr);
} }
else else
# endif #endif
# ifdef MACOS_CONVERT #ifdef MACOS_CONVERT
if (fio_flags & FIO_MACROMAN) if (fio_flags & FIO_MACROMAN)
{ {
/* /*
@ -1825,7 +1794,7 @@ retry:
goto rewind_retry; goto rewind_retry;
} }
else else
# endif #endif
if (fio_flags != 0) if (fio_flags != 0)
{ {
int u8c; int u8c;
@ -2089,11 +2058,11 @@ retry:
* file is more likely than a conversion error. */ * file is more likely than a conversion error. */
if (can_retry && !incomplete_tail) if (can_retry && !incomplete_tail)
break; break;
# ifdef USE_ICONV #ifdef USE_ICONV
/* When we did a conversion report an error. */ /* When we did a conversion report an error. */
if (iconv_fd != (iconv_t)-1 && conv_error == 0) if (iconv_fd != (iconv_t)-1 && conv_error == 0)
conv_error = readfile_linenr(linecnt, ptr, p); conv_error = readfile_linenr(linecnt, ptr, p);
# endif #endif
/* Remember the first linenr with an illegal byte */ /* Remember the first linenr with an illegal byte */
if (conv_error == 0 && illegal_byte == 0) if (conv_error == 0 && illegal_byte == 0)
illegal_byte = readfile_linenr(linecnt, ptr, p); illegal_byte = readfile_linenr(linecnt, ptr, p);
@ -2117,19 +2086,18 @@ retry:
/* Detected a UTF-8 error. */ /* Detected a UTF-8 error. */
rewind_retry: rewind_retry:
/* Retry reading with another conversion. */ /* Retry reading with another conversion. */
# if defined(FEAT_EVAL) && defined(USE_ICONV) #if defined(FEAT_EVAL) && defined(USE_ICONV)
if (*p_ccv != NUL && iconv_fd != (iconv_t)-1) if (*p_ccv != NUL && iconv_fd != (iconv_t)-1)
/* iconv() failed, try 'charconvert' */ /* iconv() failed, try 'charconvert' */
did_iconv = TRUE; did_iconv = TRUE;
else else
# endif #endif
/* use next item from 'fileencodings' */ /* use next item from 'fileencodings' */
advance_fenc = TRUE; advance_fenc = TRUE;
file_rewind = TRUE; file_rewind = TRUE;
goto retry; goto retry;
} }
} }
#endif
/* count the number of characters (after conversion!) */ /* count the number of characters (after conversion!) */
filesize += size; filesize += size;
@ -2371,7 +2339,6 @@ failed:
* encryption was used. */ * encryption was used. */
#endif #endif
#ifdef FEAT_MBYTE
/* If editing a new file: set 'fenc' for the current buffer. /* If editing a new file: set 'fenc' for the current buffer.
* Also for ":read ++edit file". */ * Also for ":read ++edit file". */
if (set_options) if (set_options)
@ -2379,13 +2346,12 @@ failed:
OPT_FREE|OPT_LOCAL, 0); OPT_FREE|OPT_LOCAL, 0);
if (fenc_alloced) if (fenc_alloced)
vim_free(fenc); vim_free(fenc);
# ifdef USE_ICONV #ifdef USE_ICONV
if (iconv_fd != (iconv_t)-1) if (iconv_fd != (iconv_t)-1)
{ {
iconv_close(iconv_fd); iconv_close(iconv_fd);
iconv_fd = (iconv_t)-1; iconv_fd = (iconv_t)-1;
} }
# endif
#endif #endif
if (!read_buffer && !read_stdin) if (!read_buffer && !read_stdin)
@ -2409,13 +2375,11 @@ failed:
} }
#endif #endif
#ifdef FEAT_MBYTE
if (tmpname != NULL) if (tmpname != NULL)
{ {
mch_remove(tmpname); /* delete converted file */ mch_remove(tmpname); /* delete converted file */
vim_free(tmpname); vim_free(tmpname);
} }
#endif
--no_wait_return; /* may wait for return now */ --no_wait_return; /* may wait for return now */
/* /*
@ -2528,7 +2492,6 @@ failed:
STRCAT(IObuff, _("[long lines split]")); STRCAT(IObuff, _("[long lines split]"));
c = TRUE; c = TRUE;
} }
#ifdef FEAT_MBYTE
if (notconverted) if (notconverted)
{ {
STRCAT(IObuff, _("[NOT converted]")); STRCAT(IObuff, _("[NOT converted]"));
@ -2539,7 +2502,6 @@ failed:
STRCAT(IObuff, _("[converted]")); STRCAT(IObuff, _("[converted]"));
c = TRUE; c = TRUE;
} }
#endif
#ifdef FEAT_CRYPT #ifdef FEAT_CRYPT
if (cryptkey != NULL) if (cryptkey != NULL)
{ {
@ -2547,7 +2509,6 @@ failed:
c = TRUE; c = TRUE;
} }
#endif #endif
#ifdef FEAT_MBYTE
if (conv_error != 0) if (conv_error != 0)
{ {
sprintf((char *)IObuff + STRLEN(IObuff), sprintf((char *)IObuff + STRLEN(IObuff),
@ -2560,9 +2521,7 @@ failed:
_("[ILLEGAL BYTE in line %ld]"), (long)illegal_byte); _("[ILLEGAL BYTE in line %ld]"), (long)illegal_byte);
c = TRUE; c = TRUE;
} }
else else if (error)
#endif
if (error)
{ {
STRCAT(IObuff, _("[READ ERRORS]")); STRCAT(IObuff, _("[READ ERRORS]"));
c = TRUE; c = TRUE;
@ -2601,11 +2560,8 @@ failed:
/* with errors writing the file requires ":w!" */ /* with errors writing the file requires ":w!" */
if (newfile && (error if (newfile && (error
#ifdef FEAT_MBYTE
|| conv_error != 0 || conv_error != 0
|| (illegal_byte > 0 && bad_char_behavior != BAD_KEEP) || (illegal_byte > 0 && bad_char_behavior != BAD_KEEP)))
#endif
))
curbuf->b_p_ro = TRUE; curbuf->b_p_ro = TRUE;
u_clearline(); /* cannot use "U" command after adding lines */ u_clearline(); /* cannot use "U" command after adding lines */
@ -2745,8 +2701,6 @@ is_dev_fd_file(char_u *fname)
} }
#endif #endif
#ifdef FEAT_MBYTE
/* /*
* From the current line count and characters read after that, estimate the * From the current line count and characters read after that, estimate the
* line number where we are now. * line number where we are now.
@ -2767,7 +2721,6 @@ readfile_linenr(
++lnum; ++lnum;
return lnum; return lnum;
} }
#endif
/* /*
* Fill "*eap" to force the 'fileencoding', 'fileformat' and 'binary to be * Fill "*eap" to force the 'fileencoding', 'fileformat' and 'binary to be
@ -2777,21 +2730,13 @@ readfile_linenr(
int int
prep_exarg(exarg_T *eap, buf_T *buf) prep_exarg(exarg_T *eap, buf_T *buf)
{ {
eap->cmd = alloc(15 eap->cmd = alloc(15 + (unsigned)STRLEN(buf->b_p_fenc));
#ifdef FEAT_MBYTE
+ (unsigned)STRLEN(buf->b_p_fenc)
#endif
);
if (eap->cmd == NULL) if (eap->cmd == NULL)
return FAIL; return FAIL;
#ifdef FEAT_MBYTE
sprintf((char *)eap->cmd, "e ++enc=%s", buf->b_p_fenc); sprintf((char *)eap->cmd, "e ++enc=%s", buf->b_p_fenc);
eap->force_enc = 8; eap->force_enc = 8;
eap->bad_char = buf->b_bad_char; eap->bad_char = buf->b_bad_char;
#else
sprintf((char *)eap->cmd, "e");
#endif
eap->force_ff = *buf->b_p_ff; eap->force_ff = *buf->b_p_ff;
eap->force_bin = buf->b_p_bin ? FORCE_BIN : FORCE_NOBIN; eap->force_bin = buf->b_p_bin ? FORCE_BIN : FORCE_NOBIN;
@ -2825,7 +2770,6 @@ set_file_options(int set_options, exarg_T *eap)
} }
} }
#if defined(FEAT_MBYTE) || defined(PROTO)
/* /*
* Set forced 'fileencoding'. * Set forced 'fileencoding'.
*/ */
@ -2886,7 +2830,7 @@ next_fenc(char_u **pp)
return r; return r;
} }
# ifdef FEAT_EVAL #ifdef FEAT_EVAL
/* /*
* Convert a file with the 'charconvert' expression. * Convert a file with the 'charconvert' expression.
* This closes the file which is to be read, converts it and opens the * This closes the file which is to be read, converts it and opens the
@ -2937,10 +2881,9 @@ readfile_charconvert(
return tmpname; return tmpname;
} }
# endif
#endif #endif
#ifdef FEAT_VIMINFO #ifdef FEAT_VIMINFO
/* /*
* Read marks for the current buffer from the viminfo file, when we support * Read marks for the current buffer from the viminfo file, when we support
@ -3176,12 +3119,10 @@ buf_write(
int fileformat; int fileformat;
int write_bin; int write_bin;
struct bw_info write_info; /* info for buf_write_bytes() */ struct bw_info write_info; /* info for buf_write_bytes() */
#ifdef FEAT_MBYTE
int converted = FALSE; int converted = FALSE;
int notconverted = FALSE; int notconverted = FALSE;
char_u *fenc; /* effective 'fileencoding' */ char_u *fenc; /* effective 'fileencoding' */
char_u *fenc_tofree = NULL; /* allocated "fenc" */ char_u *fenc_tofree = NULL; /* allocated "fenc" */
#endif
#ifdef HAS_BW_FLAGS #ifdef HAS_BW_FLAGS
int wb_flags = 0; int wb_flags = 0;
#endif #endif
@ -3219,15 +3160,13 @@ buf_write(
return FAIL; return FAIL;
} }
#ifdef FEAT_MBYTE
/* must init bw_conv_buf and bw_iconv_fd before jumping to "fail" */ /* must init bw_conv_buf and bw_iconv_fd before jumping to "fail" */
write_info.bw_conv_buf = NULL; write_info.bw_conv_buf = NULL;
write_info.bw_conv_error = FALSE; write_info.bw_conv_error = FALSE;
write_info.bw_conv_error_lnum = 0; write_info.bw_conv_error_lnum = 0;
write_info.bw_restlen = 0; write_info.bw_restlen = 0;
# ifdef USE_ICONV #ifdef USE_ICONV
write_info.bw_iconv_fd = (iconv_t)-1; write_info.bw_iconv_fd = (iconv_t)-1;
# endif
#endif #endif
#ifdef FEAT_CRYPT #ifdef FEAT_CRYPT
write_info.bw_buffer = buf; write_info.bw_buffer = buf;
@ -4227,7 +4166,6 @@ buf_write(
* multi-byte conversion. */ * multi-byte conversion. */
wfname = fname; wfname = fname;
#ifdef FEAT_MBYTE
/* Check for forced 'fileencoding' from "++opt=val" argument. */ /* Check for forced 'fileencoding' from "++opt=val" argument. */
if (eap != NULL && eap->force_enc != 0) if (eap != NULL && eap->force_enc != 0)
{ {
@ -4265,7 +4203,7 @@ buf_write(
} }
} }
# ifdef WIN3264 #ifdef WIN3264
if (converted && wb_flags == 0 && (wb_flags = get_win_fio_flags(fenc)) != 0) if (converted && wb_flags == 0 && (wb_flags = get_win_fio_flags(fenc)) != 0)
{ {
/* Convert UTF-8 -> UCS-2 and UCS-2 -> DBCS. Worst-case * 4: */ /* Convert UTF-8 -> UCS-2 and UCS-2 -> DBCS. Worst-case * 4: */
@ -4275,9 +4213,9 @@ buf_write(
if (write_info.bw_conv_buf == NULL) if (write_info.bw_conv_buf == NULL)
end = 0; end = 0;
} }
# endif #endif
# ifdef MACOS_CONVERT #ifdef MACOS_CONVERT
if (converted && wb_flags == 0 && (wb_flags = get_mac_fio_flags(fenc)) != 0) if (converted && wb_flags == 0 && (wb_flags = get_mac_fio_flags(fenc)) != 0)
{ {
write_info.bw_conv_buflen = bufsize * 3; write_info.bw_conv_buflen = bufsize * 3;
@ -4286,12 +4224,12 @@ buf_write(
if (write_info.bw_conv_buf == NULL) if (write_info.bw_conv_buf == NULL)
end = 0; end = 0;
} }
# endif #endif
# if defined(FEAT_EVAL) || defined(USE_ICONV) #if defined(FEAT_EVAL) || defined(USE_ICONV)
if (converted && wb_flags == 0) if (converted && wb_flags == 0)
{ {
# ifdef USE_ICONV # ifdef USE_ICONV
/* /*
* Use iconv() conversion when conversion is needed and it's not done * Use iconv() conversion when conversion is needed and it's not done
* internally. * internally.
@ -4308,12 +4246,12 @@ buf_write(
end = 0; end = 0;
write_info.bw_first = TRUE; write_info.bw_first = TRUE;
} }
# ifdef FEAT_EVAL
else
# endif
# endif
# ifdef FEAT_EVAL # ifdef FEAT_EVAL
else
# endif
# endif
# ifdef FEAT_EVAL
/* /*
* When the file needs to be converted with 'charconvert' after * When the file needs to be converted with 'charconvert' after
* writing, write to a temp file instead and let the conversion * writing, write to a temp file instead and let the conversion
@ -4328,16 +4266,16 @@ buf_write(
goto restore_backup; goto restore_backup;
} }
} }
# endif
}
# endif # endif
}
#endif
if (converted && wb_flags == 0 if (converted && wb_flags == 0
# ifdef USE_ICONV #ifdef USE_ICONV
&& write_info.bw_iconv_fd == (iconv_t)-1 && write_info.bw_iconv_fd == (iconv_t)-1
# endif # endif
# ifdef FEAT_EVAL # ifdef FEAT_EVAL
&& wfname == fname && wfname == fname
# endif # endif
) )
{ {
if (!forceit) if (!forceit)
@ -4347,7 +4285,6 @@ buf_write(
} }
notconverted = TRUE; notconverted = TRUE;
} }
#endif
/* /*
* If conversion is taking place, we may first pretend to write and check * If conversion is taking place, we may first pretend to write and check
@ -4362,9 +4299,7 @@ buf_write(
* - we make a backup file, that can be restored in case of conversion * - we make a backup file, that can be restored in case of conversion
* failure. * failure.
*/ */
#ifdef FEAT_MBYTE
if (!converted || dobackup) if (!converted || dobackup)
#endif
checking_conversion = FALSE; checking_conversion = FALSE;
if (checking_conversion) if (checking_conversion)
@ -4477,10 +4412,8 @@ restore_backup:
end = 0; end = 0;
} }
#ifdef FEAT_MBYTE
if (wfname != fname) if (wfname != fname)
vim_free(wfname); vim_free(wfname);
#endif
goto fail; goto fail;
} }
write_info.bw_fd = fd; write_info.bw_fd = fd;
@ -4563,7 +4496,6 @@ restore_backup:
else else
write_bin = buf->b_p_bin; write_bin = buf->b_p_bin;
#ifdef FEAT_MBYTE
/* /*
* The BOM is written just after the encryption magic number. * The BOM is written just after the encryption magic number.
* Skip it when appending and the file already existed, the BOM only * Skip it when appending and the file already existed, the BOM only
@ -4583,7 +4515,6 @@ restore_backup:
} }
} }
write_info.bw_start_lnum = start; write_info.bw_start_lnum = start;
#endif
#ifdef FEAT_PERSISTENT_UNDO #ifdef FEAT_PERSISTENT_UNDO
write_undo_file = (buf->b_p_udf write_undo_file = (buf->b_p_udf
@ -4635,9 +4566,7 @@ restore_backup:
nchars += bufsize; nchars += bufsize;
s = buffer; s = buffer;
len = 0; len = 0;
#ifdef FEAT_MBYTE
write_info.bw_start_lnum = lnum; write_info.bw_start_lnum = lnum;
#endif
} }
/* write failed or last line has no EOL: stop here */ /* write failed or last line has no EOL: stop here */
if (end == 0 if (end == 0
@ -4841,7 +4770,7 @@ restore_backup:
} }
#endif #endif
#if defined(FEAT_MBYTE) && defined(FEAT_EVAL) #if defined(FEAT_EVAL)
if (wfname != fname) if (wfname != fname)
{ {
/* /*
@ -4870,7 +4799,6 @@ restore_backup:
*/ */
if (errmsg == NULL) if (errmsg == NULL)
{ {
#ifdef FEAT_MBYTE
if (write_info.bw_conv_error) if (write_info.bw_conv_error)
{ {
if (write_info.bw_conv_error_lnum == 0) if (write_info.bw_conv_error_lnum == 0)
@ -4883,12 +4811,10 @@ restore_backup:
(long)write_info.bw_conv_error_lnum); (long)write_info.bw_conv_error_lnum);
} }
} }
else if (got_int)
errmsg = (char_u *)_(e_interr);
else else
#endif errmsg = (char_u *)_("E514: write error (file system full?)");
if (got_int)
errmsg = (char_u *)_(e_interr);
else
errmsg = (char_u *)_("E514: write error (file system full?)");
} }
/* /*
@ -4953,7 +4879,6 @@ restore_backup:
{ {
msg_add_fname(buf, fname); /* put fname in IObuff with quotes */ msg_add_fname(buf, fname); /* put fname in IObuff with quotes */
c = FALSE; c = FALSE;
#ifdef FEAT_MBYTE
if (write_info.bw_conv_error) if (write_info.bw_conv_error)
{ {
STRCAT(IObuff, _(" CONVERSION ERROR")); STRCAT(IObuff, _(" CONVERSION ERROR"));
@ -4972,7 +4897,6 @@ restore_backup:
STRCAT(IObuff, _("[converted]")); STRCAT(IObuff, _("[converted]"));
c = TRUE; c = TRUE;
} }
#endif
if (device) if (device)
{ {
STRCAT(IObuff, _("[Device]")); STRCAT(IObuff, _("[Device]"));
@ -5013,11 +4937,8 @@ restore_backup:
/* When written everything correctly: reset 'modified'. Unless not /* When written everything correctly: reset 'modified'. Unless not
* writing to the original file and '+' is not in 'cpoptions'. */ * writing to the original file and '+' is not in 'cpoptions'. */
if (reset_changed && whole && !append if (reset_changed && whole && !append
#ifdef FEAT_MBYTE
&& !write_info.bw_conv_error && !write_info.bw_conv_error
#endif && (overwriting || vim_strchr(p_cpo, CPO_PLUS) != NULL))
&& (overwriting || vim_strchr(p_cpo, CPO_PLUS) != NULL)
)
{ {
unchanged(buf, TRUE); unchanged(buf, TRUE);
/* b:changedtick is always incremented in unchanged() but that /* b:changedtick is always incremented in unchanged() but that
@ -5113,16 +5034,14 @@ nofail:
vim_free(backup); vim_free(backup);
if (buffer != smallbuf) if (buffer != smallbuf)
vim_free(buffer); vim_free(buffer);
#ifdef FEAT_MBYTE
vim_free(fenc_tofree); vim_free(fenc_tofree);
vim_free(write_info.bw_conv_buf); vim_free(write_info.bw_conv_buf);
# ifdef USE_ICONV #ifdef USE_ICONV
if (write_info.bw_iconv_fd != (iconv_t)-1) if (write_info.bw_iconv_fd != (iconv_t)-1)
{ {
iconv_close(write_info.bw_iconv_fd); iconv_close(write_info.bw_iconv_fd);
write_info.bw_iconv_fd = (iconv_t)-1; write_info.bw_iconv_fd = (iconv_t)-1;
} }
# endif
#endif #endif
#ifdef HAVE_ACL #ifdef HAVE_ACL
mch_free_acl(acl); mch_free_acl(acl);
@ -5411,7 +5330,6 @@ buf_write_bytes(struct bw_info *ip)
int flags = ip->bw_flags; /* extra flags */ int flags = ip->bw_flags; /* extra flags */
#endif #endif
#ifdef FEAT_MBYTE
/* /*
* Skip conversion when writing the crypt magic number or the BOM. * Skip conversion when writing the crypt magic number or the BOM.
*/ */
@ -5521,7 +5439,7 @@ buf_write_bytes(struct bw_info *ip)
} }
} }
# ifdef WIN3264 #ifdef WIN3264
else if (flags & FIO_CODEPAGE) else if (flags & FIO_CODEPAGE)
{ {
/* /*
@ -5617,7 +5535,7 @@ buf_write_bytes(struct bw_info *ip)
fromlen = to - ip->bw_conv_buf; fromlen = to - ip->bw_conv_buf;
buf = to; buf = to;
# ifdef CP_UTF8 /* VC 4.1 doesn't define CP_UTF8 */ # ifdef CP_UTF8 /* VC 4.1 doesn't define CP_UTF8 */
if (FIO_GET_CP(flags) == CP_UTF8) if (FIO_GET_CP(flags) == CP_UTF8)
{ {
/* Convert from UCS-2 to UTF-8, using the remainder of the /* Convert from UCS-2 to UTF-8, using the remainder of the
@ -5636,7 +5554,7 @@ buf_write_bytes(struct bw_info *ip)
len = (int)(to - buf); len = (int)(to - buf);
} }
else else
#endif # endif
{ {
/* Convert from UCS-2 to the codepage, using the remainder of /* Convert from UCS-2 to the codepage, using the remainder of
* the conversion buffer. If the conversion uses the default * the conversion buffer. If the conversion uses the default
@ -5653,9 +5571,9 @@ buf_write_bytes(struct bw_info *ip)
} }
} }
} }
# endif #endif
# ifdef MACOS_CONVERT #ifdef MACOS_CONVERT
else if (flags & FIO_MACROMAN) else if (flags & FIO_MACROMAN)
{ {
/* /*
@ -5689,9 +5607,9 @@ buf_write_bytes(struct bw_info *ip)
} }
buf = ip->bw_conv_buf; buf = ip->bw_conv_buf;
} }
# endif #endif
# ifdef USE_ICONV #ifdef USE_ICONV
if (ip->bw_iconv_fd != (iconv_t)-1) if (ip->bw_iconv_fd != (iconv_t)-1)
{ {
const char *from; const char *from;
@ -5759,9 +5677,8 @@ buf_write_bytes(struct bw_info *ip)
buf = ip->bw_conv_buf; buf = ip->bw_conv_buf;
len = (int)((char_u *)to - ip->bw_conv_buf); len = (int)((char_u *)to - ip->bw_conv_buf);
} }
# endif #endif
} }
#endif /* FEAT_MBYTE */
if (ip->bw_fd < 0) if (ip->bw_fd < 0)
/* Only checking conversion, which is OK if we get here. */ /* Only checking conversion, which is OK if we get here. */
@ -5798,7 +5715,6 @@ buf_write_bytes(struct bw_info *ip)
return (wlen < len) ? FAIL : OK; return (wlen < len) ? FAIL : OK;
} }
#ifdef FEAT_MBYTE
/* /*
* Convert a Unicode character to bytes. * Convert a Unicode character to bytes.
* Return TRUE for an error, FALSE when it's OK. * Return TRUE for an error, FALSE when it's OK.
@ -6089,7 +6005,6 @@ make_bom(char_u *buf, char_u *name)
(void)ucs2bytes(0xfeff, &p, flags); (void)ucs2bytes(0xfeff, &p, flags);
return (int)(p - buf); return (int)(p - buf);
} }
#endif
/* /*
* Try to find a shortname by comparing the fullname with the current * Try to find a shortname by comparing the fullname with the current
@ -7639,13 +7554,10 @@ forward_slash(char_u *fname)
if (path_with_url(fname)) if (path_with_url(fname))
return; return;
for (p = fname; *p != NUL; ++p) for (p = fname; *p != NUL; ++p)
# ifdef FEAT_MBYTE
/* The Big5 encoding can have '\' in the trail byte. */ /* The Big5 encoding can have '\' in the trail byte. */
if (enc_dbcs != 0 && (*mb_ptr2len)(p) > 1) if (enc_dbcs != 0 && (*mb_ptr2len)(p) > 1)
++p; ++p;
else else if (*p == '\\')
# endif
if (*p == '\\')
*p = '/'; *p = '/';
} }
#endif #endif
@ -10340,13 +10252,11 @@ file_pat_to_reg_pat(
#endif #endif
default: default:
size++; size++;
# ifdef FEAT_MBYTE
if (enc_dbcs != 0 && (*mb_ptr2len)(p) > 1) if (enc_dbcs != 0 && (*mb_ptr2len)(p) > 1)
{ {
++p; ++p;
++size; ++size;
} }
# endif
break; break;
} }
} }
@ -10479,12 +10389,9 @@ file_pat_to_reg_pat(
reg_pat[i++] = ','; reg_pat[i++] = ',';
break; break;
default: default:
# ifdef FEAT_MBYTE
if (enc_dbcs != 0 && (*mb_ptr2len)(p) > 1) if (enc_dbcs != 0 && (*mb_ptr2len)(p) > 1)
reg_pat[i++] = *p++; reg_pat[i++] = *p++;
else else if (allow_dirs != NULL && vim_ispathsep(*p))
# endif
if (allow_dirs != NULL && vim_ispathsep(*p))
*allow_dirs = TRUE; *allow_dirs = TRUE;
reg_pat[i++] = *p; reg_pat[i++] = *p;
break; break;

View File

@ -1057,11 +1057,9 @@ foldAdjustVisual(void)
end->col = (colnr_T)STRLEN(ptr); end->col = (colnr_T)STRLEN(ptr);
if (end->col > 0 && *p_sel == 'o') if (end->col > 0 && *p_sel == 'o')
--end->col; --end->col;
#ifdef FEAT_MBYTE
/* prevent cursor from moving on the trail byte */ /* prevent cursor from moving on the trail byte */
if (has_mbyte) if (has_mbyte)
mb_adjust_cursor(); mb_adjust_cursor();
#endif
} }
} }
@ -1946,7 +1944,6 @@ get_foldtext(
* replace a TAB with a space. */ * replace a TAB with a space. */
for (p = text; *p != NUL; ++p) for (p = text; *p != NUL; ++p)
{ {
# ifdef FEAT_MBYTE
int len; int len;
if (has_mbyte && (len = (*mb_ptr2len)(p)) > 1) if (has_mbyte && (len = (*mb_ptr2len)(p)) > 1)
@ -1956,7 +1953,6 @@ get_foldtext(
p += len - 1; p += len - 1;
} }
else else
# endif
if (*p == TAB) if (*p == TAB)
*p = ' '; *p = ' ';
else if (ptr2cells(p) > 1) else if (ptr2cells(p) > 1)

105
src/gui.c
View File

@ -13,7 +13,7 @@
/* Structure containing all the GUI information */ /* Structure containing all the GUI information */
gui_T gui; gui_T gui;
#if defined(FEAT_MBYTE) && !defined(FEAT_GUI_GTK) #if !defined(FEAT_GUI_GTK)
static void set_guifontwide(char_u *font_name); static void set_guifontwide(char_u *font_name);
#endif #endif
static void gui_check_pos(void); static void gui_check_pos(void);
@ -397,13 +397,11 @@ gui_init_check(void)
gui.fontset = NOFONTSET; gui.fontset = NOFONTSET;
# endif # endif
#endif #endif
#ifdef FEAT_MBYTE
gui.wide_font = NOFONT; gui.wide_font = NOFONT;
# ifndef FEAT_GUI_GTK #ifndef FEAT_GUI_GTK
gui.wide_bold_font = NOFONT; gui.wide_bold_font = NOFONT;
gui.wide_ital_font = NOFONT; gui.wide_ital_font = NOFONT;
gui.wide_boldital_font = NOFONT; gui.wide_boldital_font = NOFONT;
# endif
#endif #endif
#ifdef FEAT_MENU #ifdef FEAT_MENU
@ -652,10 +650,8 @@ gui_init(void)
emsg(_("E665: Cannot start GUI, no valid font found")); emsg(_("E665: Cannot start GUI, no valid font found"));
goto error2; goto error2;
} }
#ifdef FEAT_MBYTE
if (gui_get_wide_font() == FAIL) if (gui_get_wide_font() == FAIL)
emsg(_("E231: 'guifontwide' invalid")); emsg(_("E231: 'guifontwide' invalid"));
#endif
gui.num_cols = Columns; gui.num_cols = Columns;
gui.num_rows = Rows; gui.num_rows = Rows;
@ -874,7 +870,7 @@ gui_init_font(char_u *font_list, int fontset UNUSED)
* longer be used! */ * longer be used! */
if (gui_mch_init_font(font_name, FALSE) == OK) if (gui_mch_init_font(font_name, FALSE) == OK)
{ {
#if defined(FEAT_MBYTE) && !defined(FEAT_GUI_GTK) #if !defined(FEAT_GUI_GTK)
/* If it's a Unicode font, try setting 'guifontwide' to a /* If it's a Unicode font, try setting 'guifontwide' to a
* similar double-width font. */ * similar double-width font. */
if ((p_guifontwide == NULL || *p_guifontwide == NUL) if ((p_guifontwide == NULL || *p_guifontwide == NUL)
@ -916,8 +912,7 @@ gui_init_font(char_u *font_list, int fontset UNUSED)
return ret; return ret;
} }
#if defined(FEAT_MBYTE) || defined(PROTO) #ifndef FEAT_GUI_GTK
# ifndef FEAT_GUI_GTK
/* /*
* Try setting 'guifontwide' to a font twice as wide as "name". * Try setting 'guifontwide' to a font twice as wide as "name".
*/ */
@ -964,7 +959,7 @@ set_guifontwide(char_u *name)
} }
} }
} }
# endif /* !FEAT_GUI_GTK */ #endif /* !FEAT_GUI_GTK */
/* /*
* Get the font for 'guifontwide'. * Get the font for 'guifontwide'.
@ -995,7 +990,7 @@ gui_get_wide_font(void)
} }
gui_mch_free_font(gui.wide_font); gui_mch_free_font(gui.wide_font);
# ifdef FEAT_GUI_GTK #ifdef FEAT_GUI_GTK
/* Avoid unnecessary overhead if 'guifontwide' is equal to 'guifont'. */ /* Avoid unnecessary overhead if 'guifontwide' is equal to 'guifont'. */
if (font != NOFONT && gui.norm_font != NOFONT if (font != NOFONT && gui.norm_font != NOFONT
&& pango_font_description_equal(font, gui.norm_font)) && pango_font_description_equal(font, gui.norm_font))
@ -1004,19 +999,18 @@ gui_get_wide_font(void)
gui_mch_free_font(font); gui_mch_free_font(font);
} }
else else
# endif #endif
gui.wide_font = font; gui.wide_font = font;
# ifdef FEAT_GUI_MSWIN #ifdef FEAT_GUI_MSWIN
gui_mch_wide_font_changed(); gui_mch_wide_font_changed();
# else #else
/* /*
* TODO: setup wide_bold_font, wide_ital_font and wide_boldital_font to * TODO: setup wide_bold_font, wide_ital_font and wide_boldital_font to
* support those fonts for 'guifontwide'. * support those fonts for 'guifontwide'.
*/ */
# endif #endif
return OK; return OK;
} }
#endif
void void
gui_set_cursor(int row, int col) gui_set_cursor(int row, int col)
@ -1258,7 +1252,7 @@ gui_update_cursor(
} }
else else
{ {
#if defined(FEAT_MBYTE) && defined(FEAT_RIGHTLEFT) #if defined(FEAT_RIGHTLEFT)
int col_off = FALSE; int col_off = FALSE;
#endif #endif
/* /*
@ -1275,14 +1269,13 @@ gui_update_cursor(
cur_height = (gui.char_height * shape->percentage + 99) / 100; cur_height = (gui.char_height * shape->percentage + 99) / 100;
cur_width = gui.char_width; cur_width = gui.char_width;
} }
#ifdef FEAT_MBYTE
if (has_mbyte && (*mb_off2cells)(LineOffset[gui.row] + gui.col, if (has_mbyte && (*mb_off2cells)(LineOffset[gui.row] + gui.col,
LineOffset[gui.row] + screen_Columns) > 1) LineOffset[gui.row] + screen_Columns) > 1)
{ {
/* Double wide character. */ /* Double wide character. */
if (shape->shape != SHAPE_VER) if (shape->shape != SHAPE_VER)
cur_width += gui.char_width; cur_width += gui.char_width;
# ifdef FEAT_RIGHTLEFT #ifdef FEAT_RIGHTLEFT
if (CURSOR_BAR_RIGHT) if (CURSOR_BAR_RIGHT)
{ {
/* gui.col points to the left halve of the character but /* gui.col points to the left halve of the character but
@ -1292,11 +1285,10 @@ gui_update_cursor(
col_off = TRUE; col_off = TRUE;
++gui.col; ++gui.col;
} }
# endif
}
#endif #endif
}
gui_mch_draw_part_cursor(cur_width, cur_height, cbg); gui_mch_draw_part_cursor(cur_width, cur_height, cbg);
#if defined(FEAT_MBYTE) && defined(FEAT_RIGHTLEFT) #if defined(FEAT_RIGHTLEFT)
if (col_off) if (col_off)
--gui.col; --gui.col;
#endif #endif
@ -2023,9 +2015,7 @@ gui_may_flush(void)
gui_outstr(char_u *s, int len) gui_outstr(char_u *s, int len)
{ {
int this_len; int this_len;
#ifdef FEAT_MBYTE
int cells; int cells;
#endif
if (len == 0) if (len == 0)
return; return;
@ -2035,7 +2025,6 @@ gui_outstr(char_u *s, int len)
while (len > 0) while (len > 0)
{ {
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
/* Find out how many chars fit in the current line. */ /* Find out how many chars fit in the current line. */
@ -2051,7 +2040,6 @@ gui_outstr(char_u *s, int len)
this_len = len; /* don't include following composing char */ this_len = len; /* don't include following composing char */
} }
else else
#endif
if (gui.col + len > Columns) if (gui.col + len > Columns)
this_len = Columns - gui.col; this_len = Columns - gui.col;
else else
@ -2061,12 +2049,10 @@ gui_outstr(char_u *s, int len)
0, (guicolor_T)0, (guicolor_T)0, 0); 0, (guicolor_T)0, (guicolor_T)0, 0);
s += this_len; s += this_len;
len -= this_len; len -= this_len;
#ifdef FEAT_MBYTE
/* fill up for a double-width char that doesn't fit. */ /* fill up for a double-width char that doesn't fit. */
if (len > 0 && gui.col < Columns) if (len > 0 && gui.col < Columns)
(void)gui_outstr_nowrap((char_u *)" ", 1, (void)gui_outstr_nowrap((char_u *)" ", 1,
0, (guicolor_T)0, (guicolor_T)0, 0); 0, (guicolor_T)0, (guicolor_T)0, 0);
#endif
/* The cursor may wrap to the next line. */ /* The cursor may wrap to the next line. */
if (gui.col >= Columns) if (gui.col >= Columns)
{ {
@ -2089,7 +2075,6 @@ gui_screenchar(
guicolor_T bg, /* colors for cursor */ guicolor_T bg, /* colors for cursor */
int back) /* backup this many chars when using bold trick */ int back) /* backup this many chars when using bold trick */
{ {
#ifdef FEAT_MBYTE
char_u buf[MB_MAXBYTES + 1]; char_u buf[MB_MAXBYTES + 1];
/* Don't draw right halve of a double-width UTF-8 char. "cannot happen" */ /* Don't draw right halve of a double-width UTF-8 char. "cannot happen" */
@ -2112,9 +2097,6 @@ gui_screenchar(
return gui_outstr_nowrap(ScreenLines + off, return gui_outstr_nowrap(ScreenLines + off,
enc_dbcs ? (*mb_ptr2len)(ScreenLines + off) : 1, enc_dbcs ? (*mb_ptr2len)(ScreenLines + off) : 1,
flags, fg, bg, back); flags, fg, bg, back);
#else
return gui_outstr_nowrap(ScreenLines + off, 1, flags, fg, bg, back);
#endif
} }
#ifdef FEAT_GUI_GTK #ifdef FEAT_GUI_GTK
@ -2223,9 +2205,7 @@ gui_outstr_nowrap(
guicolor_T sp_color; guicolor_T sp_color;
#if !defined(FEAT_GUI_GTK) #if !defined(FEAT_GUI_GTK)
GuiFont font = NOFONT; GuiFont font = NOFONT;
# ifdef FEAT_MBYTE
GuiFont wide_font = NOFONT; GuiFont wide_font = NOFONT;
# endif
# ifdef FEAT_XFONTSET # ifdef FEAT_XFONTSET
GuiFontset fontset = NOFONTSET; GuiFontset fontset = NOFONTSET;
# endif # endif
@ -2316,7 +2296,6 @@ gui_outstr_nowrap(
else else
font = gui.norm_font; font = gui.norm_font;
# ifdef FEAT_MBYTE
/* /*
* Choose correct wide_font by font. wide_font should be set with font * Choose correct wide_font by font. wide_font should be set with font
* at same time in above block. But it will make many "ifdef" nasty * at same time in above block. But it will make many "ifdef" nasty
@ -2330,8 +2309,6 @@ gui_outstr_nowrap(
wide_font = gui.wide_ital_font; wide_font = gui.wide_ital_font;
else if (font == gui.norm_font && gui.wide_font) else if (font == gui.norm_font && gui.wide_font)
wide_font = gui.wide_font; wide_font = gui.wide_font;
# endif
} }
# ifdef FEAT_XFONTSET # ifdef FEAT_XFONTSET
if (fontset != NOFONTSET) if (fontset != NOFONTSET)
@ -2441,7 +2418,6 @@ gui_outstr_nowrap(
/* The value returned is the length in display cells */ /* The value returned is the length in display cells */
len = gui_gtk2_draw_string(gui.row, col, s, len, draw_flags); len = gui_gtk2_draw_string(gui.row, col, s, len, draw_flags);
#else #else
# ifdef FEAT_MBYTE
if (enc_utf8) if (enc_utf8)
{ {
int start; /* index of bytes to be drawn */ int start; /* index of bytes to be drawn */
@ -2456,11 +2432,11 @@ gui_outstr_nowrap(
int curr_wide = FALSE; /* use 'guifontwide' */ int curr_wide = FALSE; /* use 'guifontwide' */
int prev_wide = FALSE; int prev_wide = FALSE;
int wide_changed; int wide_changed;
# ifdef WIN3264 # ifdef WIN3264
int sep_comp = FALSE; /* Don't separate composing chars. */ int sep_comp = FALSE; /* Don't separate composing chars. */
# else # else
int sep_comp = TRUE; /* Separate composing chars. */ int sep_comp = TRUE; /* Separate composing chars. */
# endif # endif
/* Break the string at a composing character, it has to be drawn on /* Break the string at a composing character, it has to be drawn on
* top of the previous character. */ * top of the previous character. */
@ -2476,9 +2452,9 @@ gui_outstr_nowrap(
if (!comping || sep_comp) if (!comping || sep_comp)
{ {
if (cn > 1 if (cn > 1
# ifdef FEAT_XFONTSET # ifdef FEAT_XFONTSET
&& fontset == NOFONTSET && fontset == NOFONTSET
# endif # endif
&& wide_font != NOFONT) && wide_font != NOFONT)
curr_wide = TRUE; curr_wide = TRUE;
else else
@ -2494,15 +2470,15 @@ gui_outstr_nowrap(
* a composing character. */ * a composing character. */
if (i + cl >= len || (comping && sep_comp && i > start) if (i + cl >= len || (comping && sep_comp && i > start)
|| wide_changed || wide_changed
# if defined(FEAT_GUI_X11) # if defined(FEAT_GUI_X11)
|| (cn > 1 || (cn > 1
# ifdef FEAT_XFONTSET # ifdef FEAT_XFONTSET
/* No fontset: At least draw char after wide char at /* No fontset: At least draw char after wide char at
* right position. */ * right position. */
&& fontset == NOFONTSET && fontset == NOFONTSET
# endif
)
# endif # endif
)
# endif
) )
{ {
if ((comping && sep_comp) || wide_changed) if ((comping && sep_comp) || wide_changed)
@ -2529,29 +2505,29 @@ gui_outstr_nowrap(
cl = 0; cl = 0;
} }
# if defined(FEAT_GUI_X11) # if defined(FEAT_GUI_X11)
/* No fontset: draw a space to fill the gap after a wide char /* No fontset: draw a space to fill the gap after a wide char
* */ * */
if (cn > 1 && (draw_flags & DRAW_TRANSP) == 0 if (cn > 1 && (draw_flags & DRAW_TRANSP) == 0
# ifdef FEAT_XFONTSET # ifdef FEAT_XFONTSET
&& fontset == NOFONTSET && fontset == NOFONTSET
# endif # endif
&& !wide_changed) && !wide_changed)
gui_mch_draw_string(gui.row, scol - 1, (char_u *)" ", gui_mch_draw_string(gui.row, scol - 1, (char_u *)" ",
1, draw_flags); 1, draw_flags);
# endif # endif
} }
/* Draw a composing char on top of the previous char. */ /* Draw a composing char on top of the previous char. */
if (comping && sep_comp) if (comping && sep_comp)
{ {
# if defined(__APPLE_CC__) && TARGET_API_MAC_CARBON # if defined(__APPLE_CC__) && TARGET_API_MAC_CARBON
/* Carbon ATSUI autodraws composing char over previous char */ /* Carbon ATSUI autodraws composing char over previous char */
gui_mch_draw_string(gui.row, scol, s + i, cl, gui_mch_draw_string(gui.row, scol, s + i, cl,
draw_flags | DRAW_TRANSP); draw_flags | DRAW_TRANSP);
# else # else
gui_mch_draw_string(gui.row, scol - cn, s + i, cl, gui_mch_draw_string(gui.row, scol - cn, s + i, cl,
draw_flags | DRAW_TRANSP); draw_flags | DRAW_TRANSP);
# endif # endif
start = i + cl; start = i + cl;
} }
prev_wide = curr_wide; prev_wide = curr_wide;
@ -2560,17 +2536,14 @@ gui_outstr_nowrap(
len = scol - col; len = scol - col;
} }
else else
# endif
{ {
gui_mch_draw_string(gui.row, col, s, len, draw_flags); gui_mch_draw_string(gui.row, col, s, len, draw_flags);
# ifdef FEAT_MBYTE
if (enc_dbcs == DBCS_JPNU) if (enc_dbcs == DBCS_JPNU)
{ {
/* Get the length in display cells, this can be different from the /* Get the length in display cells, this can be different from the
* number of bytes for "euc-jp". */ * number of bytes for "euc-jp". */
len = mb_string2cells(s, len); len = mb_string2cells(s, len);
} }
# endif
} }
#endif /* !FEAT_GUI_GTK */ #endif /* !FEAT_GUI_GTK */
@ -2697,9 +2670,7 @@ gui_redraw_block(
int idx, len; int idx, len;
int back, nback; int back, nback;
int retval = FALSE; int retval = FALSE;
#ifdef FEAT_MBYTE
int orig_col1, orig_col2; int orig_col1, orig_col2;
#endif
/* Don't try to update when ScreenLines is not valid */ /* Don't try to update when ScreenLines is not valid */
if (!screen_cleared || ScreenLines == NULL) if (!screen_cleared || ScreenLines == NULL)
@ -2716,14 +2687,11 @@ gui_redraw_block(
old_row = gui.row; old_row = gui.row;
old_col = gui.col; old_col = gui.col;
old_hl_mask = gui.highlight_mask; old_hl_mask = gui.highlight_mask;
#ifdef FEAT_MBYTE
orig_col1 = col1; orig_col1 = col1;
orig_col2 = col2; orig_col2 = col2;
#endif
for (gui.row = row1; gui.row <= row2; gui.row++) for (gui.row = row1; gui.row <= row2; gui.row++)
{ {
#ifdef FEAT_MBYTE
/* When only half of a double-wide character is in the block, include /* When only half of a double-wide character is in the block, include
* the other half. */ * the other half. */
col1 = orig_col1; col1 = orig_col1;
@ -2753,12 +2721,11 @@ gui_redraw_block(
msg((char *)IObuff); msg((char *)IObuff);
} }
} }
# ifdef FEAT_GUI_GTK #ifdef FEAT_GUI_GTK
if (col2 + 1 < Columns && ScreenLines[off + col2 + 1] == 0) if (col2 + 1 < Columns && ScreenLines[off + col2 + 1] == 0)
++col2; ++col2;
# endif
}
#endif #endif
}
gui.col = col1; gui.col = col1;
off = LineOffset[gui.row] + gui.col; off = LineOffset[gui.row] + gui.col;
len = col2 - col1 + 1; len = col2 - col1 + 1;
@ -2778,7 +2745,7 @@ gui_redraw_block(
{ {
first_attr = ScreenAttrs[off]; first_attr = ScreenAttrs[off];
gui.highlight_mask = first_attr; gui.highlight_mask = first_attr;
#if defined(FEAT_MBYTE) && !defined(FEAT_GUI_GTK) #if !defined(FEAT_GUI_GTK)
if (enc_utf8 && ScreenLinesUC[off] != 0) if (enc_utf8 && ScreenLinesUC[off] != 0)
{ {
/* output multi-byte character separately */ /* output multi-byte character separately */
@ -2814,7 +2781,6 @@ gui_redraw_block(
for (idx = 0; idx < len && ScreenAttrs[off + idx] == first_attr; for (idx = 0; idx < len && ScreenAttrs[off + idx] == first_attr;
idx++) idx++)
{ {
# ifdef FEAT_MBYTE
/* Stop at a multi-byte Unicode character. */ /* Stop at a multi-byte Unicode character. */
if (enc_utf8 && ScreenLinesUC[off + idx] != 0) if (enc_utf8 && ScreenLinesUC[off + idx] != 0)
break; break;
@ -2827,7 +2793,6 @@ gui_redraw_block(
+ off + idx) == 2) + off + idx) == 2)
++idx; /* skip second byte of double-byte char */ ++idx; /* skip second byte of double-byte char */
} }
# endif
} }
nback = gui_outstr_nowrap(ScreenLines + off, idx, flags, nback = gui_outstr_nowrap(ScreenLines + off, idx, flags,
(guicolor_T)0, (guicolor_T)0, back); (guicolor_T)0, (guicolor_T)0, back);
@ -3390,11 +3355,7 @@ gui_xy2colrow(int x, int y, int *colp)
int col = check_col(X_2_COL(x)); int col = check_col(X_2_COL(x));
int row = check_row(Y_2_ROW(y)); int row = check_row(Y_2_ROW(y));
#ifdef FEAT_MBYTE
*colp = mb_fix_col(col, row); *colp = mb_fix_col(col, row);
#else
*colp = col;
#endif
return row; return row;
} }

View File

@ -48,11 +48,7 @@
/* Vim's Scrap flavor. */ /* Vim's Scrap flavor. */
#define VIMSCRAPFLAVOR 'VIM!' #define VIMSCRAPFLAVOR 'VIM!'
#ifdef FEAT_MBYTE #define SCRAPTEXTFLAVOR kScrapFlavorTypeUnicode
# define SCRAPTEXTFLAVOR kScrapFlavorTypeUnicode
#else
# define SCRAPTEXTFLAVOR kScrapFlavorTypeText
#endif
static EventHandlerUPP mouseWheelHandlerUPP = NULL; static EventHandlerUPP mouseWheelHandlerUPP = NULL;
SInt32 gMacSystemVersion; SInt32 gMacSystemVersion;
@ -169,9 +165,7 @@ static struct
# define USE_ATSUI_DRAWING # define USE_ATSUI_DRAWING
int p_macatsui_last; int p_macatsui_last;
ATSUStyle gFontStyle; ATSUStyle gFontStyle;
# ifdef FEAT_MBYTE
ATSUStyle gWideFontStyle; ATSUStyle gWideFontStyle;
# endif
Boolean gIsFontFallbackSet; Boolean gIsFontFallbackSet;
UInt32 useAntialias_cached = 0x0; UInt32 useAntialias_cached = 0x0;
#endif #endif
@ -2035,15 +2029,11 @@ gui_mac_handle_window_activate(
switch (eventKind) switch (eventKind)
{ {
case kEventWindowActivated: case kEventWindowActivated:
# if defined(FEAT_MBYTE)
im_on_window_switch(TRUE); im_on_window_switch(TRUE);
# endif
return noErr; return noErr;
case kEventWindowDeactivated: case kEventWindowDeactivated:
# if defined(FEAT_MBYTE)
im_on_window_switch(FALSE); im_on_window_switch(FALSE);
# endif
return noErr; return noErr;
} }
} }
@ -2391,7 +2381,6 @@ gui_mac_doKeyEvent(EventRecord *theEvent)
} }
else else
{ {
#ifdef FEAT_MBYTE
/* Convert characters when needed (e.g., from MacRoman to latin1). /* Convert characters when needed (e.g., from MacRoman to latin1).
* This doesn't work for the NUL byte. */ * This doesn't work for the NUL byte. */
if (input_conv.vc_type != CONV_NONE && key_char > 0) if (input_conv.vc_type != CONV_NONE && key_char > 0)
@ -2421,7 +2410,6 @@ gui_mac_doKeyEvent(EventRecord *theEvent)
string[len++] = key_char; string[len++] = key_char;
} }
else else
#endif
string[len++] = key_char; string[len++] = key_char;
} }
@ -3195,12 +3183,6 @@ gui_mch_init(void)
} }
#endif #endif
/*
#ifdef FEAT_MBYTE
set_option_value((char_u *)"encoding", 0L, (char_u *)"utf-8", 0);
#endif
*/
#ifdef FEAT_GUI_TABLINE #ifdef FEAT_GUI_TABLINE
/* /*
* Create the tabline * Create the tabline
@ -3254,10 +3236,8 @@ gui_mac_dispose_atsui_style(void)
{ {
if (p_macatsui && gFontStyle) if (p_macatsui && gFontStyle)
ATSUDisposeStyle(gFontStyle); ATSUDisposeStyle(gFontStyle);
#ifdef FEAT_MBYTE
if (p_macatsui && gWideFontStyle) if (p_macatsui && gWideFontStyle)
ATSUDisposeStyle(gWideFontStyle); ATSUDisposeStyle(gWideFontStyle);
#endif
} }
#endif #endif
@ -3430,13 +3410,11 @@ gui_mac_create_atsui_style(void)
if (ATSUCreateStyle(&gFontStyle) != noErr) if (ATSUCreateStyle(&gFontStyle) != noErr)
gFontStyle = NULL; gFontStyle = NULL;
} }
#ifdef FEAT_MBYTE
if (p_macatsui && gWideFontStyle == NULL) if (p_macatsui && gWideFontStyle == NULL)
{ {
if (ATSUCreateStyle(&gWideFontStyle) != noErr) if (ATSUCreateStyle(&gWideFontStyle) != noErr)
gWideFontStyle = NULL; gWideFontStyle = NULL;
} }
#endif
p_macatsui_last = p_macatsui; p_macatsui_last = p_macatsui;
} }
@ -3622,7 +3600,6 @@ gui_mac_set_font_attributes(GuiFont font)
gFontStyle = NULL; gFontStyle = NULL;
} }
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
/* FIXME: we should use a more mbyte sensitive way to support /* FIXME: we should use a more mbyte sensitive way to support
@ -3637,7 +3614,6 @@ gui_mac_set_font_attributes(GuiFont font)
gWideFontStyle = NULL; gWideFontStyle = NULL;
} }
} }
#endif
} }
} }
#endif #endif
@ -3811,7 +3787,6 @@ draw_undercurl(int flags, int row, int col, int cells)
static void static void
draw_string_QD(int row, int col, char_u *s, int len, int flags) draw_string_QD(int row, int col, char_u *s, int len, int flags)
{ {
#ifdef FEAT_MBYTE
char_u *tofree = NULL; char_u *tofree = NULL;
if (output_conv.vc_type != CONV_NONE) if (output_conv.vc_type != CONV_NONE)
@ -3820,7 +3795,6 @@ draw_string_QD(int row, int col, char_u *s, int len, int flags)
if (tofree != NULL) if (tofree != NULL)
s = tofree; s = tofree;
} }
#endif
/* /*
* On OS X, try using Quartz-style text antialiasing. * On OS X, try using Quartz-style text antialiasing.
@ -3849,7 +3823,6 @@ draw_string_QD(int row, int col, char_u *s, int len, int flags)
rc.left = FILL_X(col); rc.left = FILL_X(col);
rc.top = FILL_Y(row); rc.top = FILL_Y(row);
#ifdef FEAT_MBYTE
/* Multibyte computation taken from gui_w32.c */ /* Multibyte computation taken from gui_w32.c */
if (has_mbyte) if (has_mbyte)
{ {
@ -3857,8 +3830,7 @@ draw_string_QD(int row, int col, char_u *s, int len, int flags)
rc.right = FILL_X(col + mb_string2cells(s, len)); rc.right = FILL_X(col + mb_string2cells(s, len));
} }
else else
#endif rc.right = FILL_X(col + len) + (col + len == Columns);
rc.right = FILL_X(col + len) + (col + len == Columns);
rc.bottom = FILL_Y(row + 1); rc.bottom = FILL_Y(row + 1);
EraseRect(&rc); EraseRect(&rc);
} }
@ -3918,9 +3890,7 @@ draw_string_QD(int row, int col, char_u *s, int len, int flags)
if (flags & DRAW_UNDERC) if (flags & DRAW_UNDERC)
draw_undercurl(flags, row, col, len); draw_undercurl(flags, row, col, len);
#ifdef FEAT_MBYTE
vim_free(tofree); vim_free(tofree);
#endif
} }
#ifdef USE_ATSUI_DRAWING #ifdef USE_ATSUI_DRAWING
@ -4007,7 +3977,6 @@ draw_string_ATSUI(int row, int col, char_u *s, int len, int flags)
useAntialias_cached = useAntialias; useAntialias_cached = useAntialias;
} }
#ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
int n, width_in_cell, last_width_in_cell; int n, width_in_cell, last_width_in_cell;
@ -4069,7 +4038,6 @@ draw_string_ATSUI(int row, int col, char_u *s, int len, int flags)
ATSUDisposeTextLayout(textLayout); ATSUDisposeTextLayout(textLayout);
} }
else else
#endif
{ {
ATSUTextLayout textLayout; ATSUTextLayout textLayout;
@ -4225,10 +4193,8 @@ gui_mch_draw_hollow_cursor(guicolor_T color)
rc.left = FILL_X(gui.col); rc.left = FILL_X(gui.col);
rc.top = FILL_Y(gui.row); rc.top = FILL_Y(gui.row);
rc.right = rc.left + gui.char_width; rc.right = rc.left + gui.char_width;
#ifdef FEAT_MBYTE
if (mb_lefthalve(gui.row, gui.col)) if (mb_lefthalve(gui.row, gui.col))
rc.right += gui.char_width; rc.right += gui.char_width;
#endif
rc.bottom = rc.top + gui.char_height; rc.bottom = rc.top + gui.char_height;
gui_mch_set_fg_color(color); gui_mch_set_fg_color(color);
@ -4705,11 +4671,7 @@ gui_mch_add_menu(vimmenu_T *menu, int idx)
*/ */
static long next_avail_id = 128; static long next_avail_id = 128;
long menu_after_me = 0; /* Default to the end */ long menu_after_me = 0; /* Default to the end */
#if defined(FEAT_MBYTE)
CFStringRef name; CFStringRef name;
#else
char_u *name;
#endif
short index; short index;
vimmenu_T *parent = menu->parent; vimmenu_T *parent = menu->parent;
vimmenu_T *brother = menu->next; vimmenu_T *brother = menu->next;
@ -4750,12 +4712,8 @@ gui_mch_add_menu(vimmenu_T *menu, int idx)
* OSStatus SetMenuTitle(MenuRef, ConstStr255Param title); * OSStatus SetMenuTitle(MenuRef, ConstStr255Param title);
*/ */
menu->submenu_id = next_avail_id; menu->submenu_id = next_avail_id;
#if defined(FEAT_MBYTE)
if (CreateNewMenu(menu->submenu_id, 0, (MenuRef *)&menu->submenu_handle) == noErr) if (CreateNewMenu(menu->submenu_id, 0, (MenuRef *)&menu->submenu_handle) == noErr)
SetMenuTitleWithCFString((MenuRef)menu->submenu_handle, name); SetMenuTitleWithCFString((MenuRef)menu->submenu_handle, name);
#else
menu->submenu_handle = NewMenu(menu->submenu_id, name);
#endif
next_avail_id++; next_avail_id++;
} }
@ -4784,21 +4742,13 @@ gui_mch_add_menu(vimmenu_T *menu, int idx)
* to avoid special character recognition by InsertMenuItem * to avoid special character recognition by InsertMenuItem
*/ */
InsertMenuItem(parent->submenu_handle, "\p ", idx); /* afterItem */ InsertMenuItem(parent->submenu_handle, "\p ", idx); /* afterItem */
#if defined(FEAT_MBYTE)
SetMenuItemTextWithCFString(parent->submenu_handle, idx+1, name); SetMenuItemTextWithCFString(parent->submenu_handle, idx+1, name);
#else
SetMenuItemText(parent->submenu_handle, idx+1, name);
#endif
SetItemCmd(parent->submenu_handle, idx+1, 0x1B); SetItemCmd(parent->submenu_handle, idx+1, 0x1B);
SetItemMark(parent->submenu_handle, idx+1, menu->submenu_id); SetItemMark(parent->submenu_handle, idx+1, menu->submenu_id);
InsertMenu(menu->submenu_handle, hierMenu); InsertMenu(menu->submenu_handle, hierMenu);
} }
#if defined(FEAT_MBYTE)
CFRelease(name); CFRelease(name);
#else
vim_free(name);
#endif
#if 0 #if 0
/* Done by Vim later on */ /* Done by Vim later on */
@ -4812,11 +4762,7 @@ gui_mch_add_menu(vimmenu_T *menu, int idx)
void void
gui_mch_add_menu_item(vimmenu_T *menu, int idx) gui_mch_add_menu_item(vimmenu_T *menu, int idx)
{ {
#if defined(FEAT_MBYTE)
CFStringRef name; CFStringRef name;
#else
char_u *name;
#endif
vimmenu_T *parent = menu->parent; vimmenu_T *parent = menu->parent;
int menu_inserted; int menu_inserted;
@ -4912,23 +4858,14 @@ gui_mch_add_menu_item(vimmenu_T *menu, int idx)
if (!menu_inserted) if (!menu_inserted)
InsertMenuItem(parent->submenu_handle, "\p ", idx); /* afterItem */ InsertMenuItem(parent->submenu_handle, "\p ", idx); /* afterItem */
/* Set the menu item name. */ /* Set the menu item name. */
#if defined(FEAT_MBYTE)
SetMenuItemTextWithCFString(parent->submenu_handle, idx+1, name); SetMenuItemTextWithCFString(parent->submenu_handle, idx+1, name);
#else
SetMenuItemText(parent->submenu_handle, idx+1, name);
#endif
#if 0 #if 0
/* Called by Vim */ /* Called by Vim */
DrawMenuBar(); DrawMenuBar();
#endif #endif
#if defined(FEAT_MBYTE)
CFRelease(name); CFRelease(name);
#else
/* TODO: Can name be freed? */
vim_free(name);
#endif
} }
void void
@ -6242,7 +6179,7 @@ char_u *FullPathFromFSSpec_save(FSSpec file)
#endif #endif
} }
#if (defined(FEAT_MBYTE) && defined(USE_CARBONKEYHANDLER)) || defined(PROTO) #if defined(USE_CARBONKEYHANDLER) || defined(PROTO)
/* /*
* Input Method Control functions. * Input Method Control functions.
*/ */
@ -6391,8 +6328,7 @@ im_get_status(void)
return im_is_active; return im_is_active;
} }
#endif /* defined(FEAT_MBYTE) || defined(PROTO) */ #endif

View File

@ -513,13 +513,8 @@ gui_ph_handle_keyboard(PtWidget_t *widget, void *data, PtCallbackInfo_t *info)
if (special_keys[i].key_sym == 0) if (special_keys[i].key_sym == 0)
{ {
ch = PhTo8859_1(key); ch = PhTo8859_1(key);
if (ch == -1 if (ch == -1 || (enc_utf8 && ch > 127))
#ifdef FEAT_MBYTE
|| (enc_utf8 && ch > 127)
#endif
)
{ {
#ifdef FEAT_MBYTE
len = PhKeyToMb(string, key); len = PhKeyToMb(string, key);
if (len > 0) if (len > 0)
{ {
@ -546,7 +541,6 @@ gui_ph_handle_keyboard(PtWidget_t *widget, void *data, PtCallbackInfo_t *info)
return Pt_CONSUME; return Pt_CONSUME;
} }
len = 0; len = 0;
#endif
ch = key->key_cap; ch = key->key_cap;
if (ch < 0xff) if (ch < 0xff)
{ {
@ -1074,7 +1068,6 @@ gui_ph_pane_resize(PtWidget_t *widget, void *data, PtCallbackInfo_t *info)
/****************************************************************************/ /****************************************************************************/
#ifdef FEAT_MBYTE
void void
gui_ph_encoding_changed(int new_encoding) gui_ph_encoding_changed(int new_encoding)
{ {
@ -1100,7 +1093,6 @@ gui_ph_encoding_changed(int new_encoding)
charset_translate = PxTranslateSet(charset_translate, charset); charset_translate = PxTranslateSet(charset_translate, charset);
} }
#endif
/****************************************************************************/ /****************************************************************************/
/****************************************************************************/ /****************************************************************************/
@ -2141,11 +2133,7 @@ gui_mch_draw_string(int row, int col, char_u *s, int len, int flags)
if (flags & DRAW_UNDERL) if (flags & DRAW_UNDERL)
PgSetUnderline(gui.norm_pixel, Pg_TRANSPARENT, 0); PgSetUnderline(gui.norm_pixel, Pg_TRANSPARENT, 0);
if (charset_translate != NULL if (charset_translate != NULL && enc_utf8 == 0)
#ifdef FEAT_MBYTE
&& enc_utf8 == 0
#endif
)
{ {
int src_taken, dst_made; int src_taken, dst_made;

View File

@ -791,6 +791,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
805,
/**/ /**/
804, 804,
/**/ /**/