# HG changeset patch # User Bram Moolenaar # Date 1548339306 -3600 # Node ID 1ec942f1b64870dda46cdaf6a7bb6649f84c2e99 # Parent 7a8983fe4f97a6c2b9160e089eadb5649a47dd1b patch 8.1.0805: too many #ifdefs commit https://github.com/vim/vim/commit/135059724f140ceac889c9f8136bd1bf5c41d49d Author: Bram Moolenaar Date: Thu Jan 24 15:04:48 2019 +0100 patch 8.1.0805: too many #ifdefs Problem: Too many #ifdefs. Solution: Graduate FEAT_MBYTE, part 1. diff --git a/src/buffer.c b/src/buffer.c --- a/src/buffer.c +++ b/src/buffer.c @@ -704,10 +704,8 @@ buf_clear_file(buf_T *buf) buf->b_shortname = FALSE; buf->b_p_eol = TRUE; buf->b_start_eol = TRUE; -#ifdef FEAT_MBYTE buf->b_p_bomb = FALSE; buf->b_start_bomb = FALSE; -#endif buf->b_ml.ml_mfp = NULL; buf->b_ml.ml_flags = ML_EMPTY; /* empty buffer */ #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, TRUE); /* clear local abbrevs */ #endif -#ifdef FEAT_MBYTE VIM_CLEAR(buf->b_start_fenc); -#endif } /* @@ -2133,9 +2129,7 @@ free_buf_options( { if (free_p_ff) { -#ifdef FEAT_MBYTE clear_string_option(&buf->b_p_fenc); -#endif clear_string_option(&buf->b_p_ff); clear_string_option(&buf->b_p_bh); clear_string_option(&buf->b_p_bt); @@ -2245,9 +2239,7 @@ free_buf_options( clear_string_option(&buf->b_p_lw); #endif clear_string_option(&buf->b_p_bkc); -#ifdef FEAT_MBYTE clear_string_option(&buf->b_p_menc); -#endif } /* @@ -3778,10 +3770,8 @@ maketitle(void) if (len > 100) { len -= 100; -#ifdef FEAT_MBYTE if (has_mbyte) len += (*mb_tail_off)(p, p + len) + 1; -#endif p += len; } STRCPY(icon_str, p); @@ -3939,11 +3929,9 @@ build_stl_str_hl( if (fillchar == 0) fillchar = ' '; -#ifdef FEAT_MBYTE /* Can't handle a multi-byte fill character yet. */ else if (mb_char2len(fillchar) > 1) fillchar = '-'; -#endif // The cursor in windows other than the current one isn't always // up-to-date, esp. because of autocommands and timers. @@ -3973,11 +3961,7 @@ build_stl_str_hl( byteval = 0; } else -#ifdef FEAT_MBYTE byteval = (*mb_ptr2char)(p + wp->w_cursor.col); -#else - byteval = p[wp->w_cursor.col]; -#endif groupdepth = 0; p = out; @@ -4079,7 +4063,6 @@ build_stl_str_hl( if (l > item[groupitem[groupdepth]].maxwid) { /* truncate, remove n bytes of text at the start */ -#ifdef FEAT_MBYTE if (has_mbyte) { /* Find the first character that should be included. */ @@ -4091,17 +4074,15 @@ build_stl_str_hl( } } else -#endif n = (long)(p - t) - item[groupitem[groupdepth]].maxwid + 1; *t = '<'; mch_memmove(t + 1, t + n, (size_t)(p - (t + n))); 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) *p++ = fillchar; -#endif /* correct the start of the items for the truncation */ for (l = groupitem[groupdepth] + 1; l < curitem; l++) @@ -4483,14 +4464,12 @@ build_stl_str_hl( if (l > maxwid) { while (l >= maxwid) -#ifdef FEAT_MBYTE if (has_mbyte) { l -= ptr2cells(t); t += (*mb_ptr2len)(t); } else -#endif l -= byte2cells(*t++); if (p + 1 >= out + outlen) break; @@ -4610,7 +4589,6 @@ build_stl_str_hl( if (width - vim_strsize(s) >= maxwidth) { /* Truncation mark is beyond max length */ -#ifdef FEAT_MBYTE if (has_mbyte) { s = out; @@ -4627,7 +4605,6 @@ build_stl_str_hl( *s++ = fillchar; } else -#endif s = out + maxwidth - 1; for (l = 0; l < itemcnt; l++) if (item[l].start > s) @@ -4638,7 +4615,6 @@ build_stl_str_hl( } else { -#ifdef FEAT_MBYTE if (has_mbyte) { n = 0; @@ -4649,7 +4625,6 @@ build_stl_str_hl( } } else -#endif n = width - maxwidth + 1; p = s + n; STRMOVE(s + 1, p); diff --git a/src/charset.c b/src/charset.c --- a/src/charset.c +++ b/src/charset.c @@ -9,12 +9,10 @@ #include "vim.h" -#ifdef FEAT_MBYTE -# if defined(HAVE_WCHAR_H) -# include /* for towupper() and towlower() */ -# endif +#if defined(HAVE_WCHAR_H) +# include /* for towupper() and towlower() */ +#endif static int win_nolbr_chartabsize(win_T *wp, char_u *s, colnr_T col, int *headp); -#endif static unsigned nr2hex(unsigned c); @@ -109,7 +107,6 @@ buf_init_chartab( #endif while (c < 256) { -#ifdef FEAT_MBYTE /* UTF-8: bytes 0xa0 - 0xff are printable (latin1) */ if (enc_utf8 && c >= 0xa0) g_chartab[c++] = CT_PRINT_CHAR + 1; @@ -120,26 +117,22 @@ buf_init_chartab( else if (enc_dbcs != 0 && MB_BYTE2LEN(c) == 2) g_chartab[c++] = CT_PRINT_CHAR + 2; else -#endif /* the rest is unprintable by default */ g_chartab[c++] = (dy_flags & DY_UHEX) ? 4 : 2; } -#ifdef FEAT_MBYTE /* Assume that every multi-byte char is a filename character. */ for (c = 1; c < 256; ++c) if ((enc_dbcs != 0 && MB_BYTE2LEN(c) > 1) || (enc_dbcs == DBCS_JPNU && c == 0x8e) || (enc_utf8 && c >= 0xa0)) g_chartab[c] |= CT_FNAME_CHAR; -#endif } /* * Init word char flags all to FALSE */ vim_memset(buf->b_chartab, 0, (size_t)32); -#ifdef FEAT_MBYTE if (enc_dbcs != 0) for (c = 0; c < 256; ++c) { @@ -147,7 +140,6 @@ buf_init_chartab( if (MB_BYTE2LEN(c) == 2) SET_CHARTAB(buf, c); } -#endif #ifdef FEAT_LISP /* @@ -184,11 +176,9 @@ buf_init_chartab( if (VIM_ISDIGIT(*p)) c = getdigits(&p); else -#ifdef FEAT_MBYTE if (has_mbyte) c = mb_ptr2char_adv(&p); else -#endif c = *p++; c2 = -1; if (*p == '-' && p[1] != NUL) @@ -197,11 +187,9 @@ buf_init_chartab( if (VIM_ISDIGIT(*p)) c2 = getdigits(&p); else -#ifdef FEAT_MBYTE if (has_mbyte) c2 = mb_ptr2char_adv(&p); else -#endif c2 = *p++; } if (c <= 0 || c >= 256 || (c2 < c && c2 != -1) || c2 >= 256 @@ -253,13 +241,9 @@ buf_init_chartab( || (p_altkeymap && (F_isalpha(c) || F_isdigit(c))) #endif - ) -#ifdef FEAT_MBYTE - /* For double-byte we keep the cell width, so - * that we can detect it from the first byte. */ - && !(enc_dbcs && MB_BYTE2LEN(c) == 2) -#endif - ) + // For double-byte we keep the cell width, so + // that we can detect it from the first byte. + ) && !(enc_dbcs && MB_BYTE2LEN(c) == 2)) { if (tilde) { @@ -322,12 +306,10 @@ trans_characters( room = bufsize - len; while (*buf != 0) { -# ifdef FEAT_MBYTE /* Assume a multi-byte character doesn't need translation. */ if (has_mbyte && (trs_len = (*mb_ptr2len)(buf)) > 1) len -= trs_len; else -# endif { trs = transchar_byte(*buf); trs_len = (int)STRLEN(trs); @@ -356,12 +338,9 @@ transstr(char_u *s) { char_u *res; char_u *p; -#ifdef FEAT_MBYTE int l, len, c; char_u hexbuf[11]; -#endif -#ifdef FEAT_MBYTE if (has_mbyte) { /* Compute the length of the result, taking account of unprintable @@ -394,7 +373,6 @@ transstr(char_u *s) res = alloc((unsigned)(len + 1)); } else -#endif res = alloc((unsigned)(vim_strsize(s) + 1)); if (res != NULL) { @@ -402,7 +380,6 @@ transstr(char_u *s) p = s; while (*p != NUL) { -#ifdef FEAT_MBYTE if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1) { c = (*mb_ptr2char)(p); @@ -413,7 +390,6 @@ transstr(char_u *s) p += l; } else -#endif STRCAT(res, transchar_byte(*p++)); } } @@ -468,7 +444,6 @@ str_foldcase( i = 0; while (STR_CHAR(i) != NUL) { -#ifdef FEAT_MBYTE if (enc_utf8 || (has_mbyte && MB_BYTE2LEN(STR_CHAR(i)) > 1)) { if (enc_utf8) @@ -520,7 +495,6 @@ str_foldcase( i += (*mb_ptr2len)(STR_PTR(i)); } else -#endif { if (buf == NULL) GA_CHAR(i) = TOLOWER_LOC(GA_CHAR(i)); @@ -580,7 +554,6 @@ transchar(int c) return transchar_buf; } -#if defined(FEAT_MBYTE) || defined(PROTO) /* * Like transchar(), but called with a byte instead of a character. Checks * for an illegal UTF-8 byte. @@ -595,7 +568,6 @@ transchar_byte(int c) } return transchar(c); } -#endif /* * 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; } -#ifdef FEAT_MBYTE else if (enc_utf8 && c >= 0x80) { transchar_hex(buf, c); } -#endif #ifndef EBCDIC else if (c >= ' ' + 0x80 && c <= '~' + 0x80) /* 0xa0 - 0xfe */ { @@ -675,13 +645,11 @@ transchar_hex(char_u *buf, int c) int i = 0; buf[0] = '<'; -#ifdef FEAT_MBYTE if (c > 255) { buf[++i] = nr2hex((unsigned)c >> 12); buf[++i] = nr2hex((unsigned)c >> 8); } -#endif buf[++i] = nr2hex((unsigned)c >> 4); buf[++i] = nr2hex((unsigned)c); buf[++i] = '>'; @@ -712,10 +680,8 @@ nr2hex(unsigned c) int byte2cells(int b) { -#ifdef FEAT_MBYTE if (enc_utf8 && b >= 0x80) return 0; -#endif return (g_chartab[b] & CT_CELL_MASK); } @@ -729,7 +695,6 @@ char2cells(int c) { if (IS_SPECIAL(c)) return char2cells(K_SECOND(c)) + 2; -#ifdef FEAT_MBYTE if (c >= 0x80) { /* UTF-8: above 0x80 need to check the value */ @@ -744,7 +709,6 @@ char2cells(int c) return 2; } } -#endif return (g_chartab[c & 0xff] & CT_CELL_MASK); } @@ -755,12 +719,10 @@ char2cells(int c) int ptr2cells(char_u *p) { -#ifdef FEAT_MBYTE /* For UTF-8 we need to look at more bytes if the first byte is >= 0x80. */ if (enc_utf8 && *p >= 0x80) return utf_ptr2cells(p); /* For DBCS we can tell the cell count from the first byte. */ -#endif return (g_chartab[*p] & CT_CELL_MASK); } @@ -784,8 +746,6 @@ vim_strnsize(char_u *s, int len) int size = 0; while (*s != NUL && --len >= 0) - { -#ifdef FEAT_MBYTE if (has_mbyte) { int l = (*mb_ptr2len)(s); @@ -795,9 +755,8 @@ vim_strnsize(char_u *s, int len) len -= l - 1; } else -#endif size += byte2cells(*s++); - } + return size; } @@ -907,12 +866,10 @@ vim_iswordc_buf(int c, buf_T *buf) { if (c >= 0x100) { -#ifdef FEAT_MBYTE if (enc_dbcs != 0) return dbcs_class((unsigned)c >> 8, (unsigned)(c & 0xff)) >= 2; if (enc_utf8) return utf_class_buf(c, buf) >= 2; -#endif return FALSE; } return (c > 0 && GET_CHARTAB(buf, c) != 0); @@ -932,10 +889,8 @@ vim_iswordp_buf(char_u *p, buf_T *buf) { int c = *p; -#ifdef FEAT_MBYTE if (has_mbyte && MB_BYTE2LEN(c) > 1) c = (*mb_ptr2char)(p); -#endif return vim_iswordc_buf(c, buf); } @@ -973,10 +928,8 @@ vim_isfilec_or_wc(int c) int vim_isprintc(int c) { -#ifdef FEAT_MBYTE if (enc_utf8 && c >= 0x100) return utf_printable(c); -#endif return (c >= 0x100 || (c > 0 && (g_chartab[c] & CT_PRINT_CHAR))); } @@ -987,12 +940,10 @@ vim_isprintc(int c) int vim_isprintc_strict(int c) { -#ifdef FEAT_MBYTE if (enc_dbcs != 0 && c < 0x100 && MB_BYTE2LEN(c) > 1) return FALSE; if (enc_utf8 && c >= 0x100) return utf_printable(c); -#endif 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) { #endif -#ifdef FEAT_MBYTE if (curwin->w_p_wrap) return win_nolbr_chartabsize(curwin, s, col, NULL); -#endif RET_WIN_BUF_CHARTABSIZE(curwin, curbuf, s, col) #ifdef FEAT_LINEBREAK } @@ -1058,11 +1007,7 @@ win_lbr_chartabsize( colnr_T col_adj = 0; /* col + screen size of tab */ colnr_T colmax; int added; -# ifdef FEAT_MBYTE int mb_added = 0; -# else -# define mb_added 0 -# endif int numberextra; char_u *ps; int tab_corr = (*s == TAB); @@ -1074,10 +1019,8 @@ win_lbr_chartabsize( if (!wp->w_p_lbr && !wp->w_p_bri && *p_sbr == NUL) #endif { -#ifdef FEAT_MBYTE if (wp->w_p_wrap) return win_nolbr_chartabsize(wp, s, col, headp); -#endif 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 && wp->w_p_wrap && in_win_border(wp, col)) { ++size; /* Count the ">" in the last column. */ mb_added = 1; } -# endif /* * May have to add something for 'breakindent' and/or 'showbreak' @@ -1210,7 +1151,6 @@ win_lbr_chartabsize( #endif } -#if defined(FEAT_MBYTE) || defined(PROTO) /* * 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 @@ -1269,7 +1209,6 @@ in_win_border(win_T *wp, colnr_T vcol) return FALSE; return ((vcol - width1) % width2 == width2 - 1); } -#endif /* FEAT_MBYTE */ /* * Get virtual column number of pos. @@ -1310,11 +1249,9 @@ getvcol( if (*ptr == NUL) pos->col = 0; posptr = ptr + pos->col; -#ifdef FEAT_MBYTE if (has_mbyte) /* always start on the first byte */ posptr -= (*mb_head_off)(line, posptr); -#endif } /* @@ -1329,14 +1266,10 @@ getvcol( #endif ) { -#ifndef FEAT_MBYTE head = 0; -#endif for (;;) { -#ifdef FEAT_MBYTE head = 0; -#endif c = *ptr; /* make sure we don't go past the end of the line */ if (c == NUL) @@ -1353,7 +1286,6 @@ getvcol( #endif else { -#ifdef FEAT_MBYTE if (has_mbyte) { /* For utf-8, if the byte is >= 0x80, need to look at @@ -1374,7 +1306,6 @@ getvcol( } } else -#endif incr = g_chartab[c] & CT_CELL_MASK; } @@ -1460,9 +1391,7 @@ getvvcol( colnr_T col; colnr_T coladd; colnr_T endadd; -# ifdef FEAT_MBYTE char_u *ptr; -# endif if (virtual_active()) { @@ -1471,7 +1400,6 @@ getvvcol( coladd = pos->coladd; endadd = 0; -# ifdef FEAT_MBYTE /* Cannot put the cursor on part of a wide character. */ ptr = ml_get_buf(wp->w_buffer, pos->lnum, FALSE); if (pos->col < (colnr_T)STRLEN(ptr)) @@ -1487,7 +1415,6 @@ getvvcol( coladd = 0; } } -# endif col += coladd; if (start != NULL) *start = col; @@ -1684,7 +1611,6 @@ vim_isbdigit(int c) return (c == '0' || c == '1'); } -#if defined(FEAT_MBYTE) || defined(PROTO) /* * Vim's own character class functions. These exist because many library * 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_LOC(c); } -#endif /* * skiptowhite: skip over text until ' ' or '\t' or NUL. @@ -2077,9 +2002,7 @@ rem_backslash(char_u *str) { #ifdef BACKSLASH_IN_FILENAME return (str[0] == '\\' -# ifdef FEAT_MBYTE && str[1] < 0x80 -# endif && (str[1] == ' ' || (str[1] != NUL && str[1] != '*' diff --git a/src/diff.c b/src/diff.c --- a/src/diff.c +++ b/src/diff.c @@ -741,12 +741,10 @@ diff_write_buffer(buf_T *buf, diffin_T * if (diff_flags & DIFF_ICASE) { int c; - - // xdiff doesn't support ignoring case, fold-case the text. -#ifdef FEAT_MBYTE int orig_len; char_u cbuf[MB_MAXBYTES + 1]; + // xdiff doesn't support ignoring case, fold-case the text. c = PTR2CHAR(s); c = enc_utf8 ? utf_fold(c) : MB_TOLOWER(c); orig_len = MB_PTR2LEN(s); @@ -758,10 +756,6 @@ diff_write_buffer(buf_T *buf, diffin_T * s += orig_len; len += orig_len; -#else - c = *s++; - ptr[len++] = TOLOWER_LOC(c); -#endif } else ptr[len++] = *s++; @@ -1946,7 +1940,6 @@ diff_equal_entry(diff_T *dp, int idx1, i static int diff_equal_char(char_u *p1, char_u *p2, int *len) { -#ifdef FEAT_MBYTE int l = (*mb_ptr2len)(p1); if (l != (*mb_ptr2len)(p2)) @@ -1962,7 +1955,6 @@ diff_equal_char(char_u *p1, char_u *p2, *len = l; } else -#endif { if ((*p1 != *p2) && (!(diff_flags & DIFF_ICASE) @@ -2400,7 +2392,6 @@ diff_find_change( si_new += l; } } -#ifdef FEAT_MBYTE if (has_mbyte) { /* 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_new -= (*mb_head_off)(line_new, line_new + si_new); } -#endif if (*startp > si_org) *startp = si_org; @@ -2438,10 +2428,8 @@ diff_find_change( { p1 = line_org + ei_org; p2 = line_new + ei_new; -#ifdef FEAT_MBYTE p1 -= (*mb_head_off)(line_org, p1); p2 -= (*mb_head_off)(line_new, p2); -#endif if (!diff_equal_char(p1, p2, &l)) break; ei_org -= l; diff --git a/src/digraph.c b/src/digraph.c --- a/src/digraph.c +++ b/src/digraph.c @@ -15,11 +15,7 @@ #if defined(FEAT_DIGRAPHS) || defined(PROTO) -#ifdef FEAT_MBYTE typedef int result_T; -#else -typedef char_u result_T; -#endif typedef struct digraph { @@ -38,8 +34,8 @@ static garray_T user_digraphs = {0, 0, ( * compilers cannot handle them (Amiga SAS/C is the most picky one). */ static digr_T digraphdefault[] = + #ifdef __MINT__ - /* * ATARI digraphs */ @@ -320,137 +316,7 @@ static digr_T digraphdefault[] = }; # else -# if defined(MACOS_X) && !defined(FEAT_MBYTE) - - /* - * 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}, /* */ - {'=', '/', 173}, /* */ - {'A', 'E', 174}, /* */ - {'O', '/', 175}, /* */ - {'0', '0', 176}, /* */ - {'+', '-', 177}, /* */ - {'<', '=', 178}, /* */ - {'>', '=', 179}, /* */ - {'Y', '-', 180}, /* */ - {'j', 'u', 181}, /* */ - {'m', 'u', 181}, /* */ - {'d', 'd', 182}, /* */ - {'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}, /* */ - {'<', '<', 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}, /* */ - {'/', '/', 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 +# ifdef OLD_DIGRAPHS /* * digraphs compatible with Vim 5.x @@ -557,7 +423,7 @@ static digr_T digraphdefault[] = {'y', '"', 255}, /* x XX */ {NUL, NUL, NUL} }; -# else /* OLD_DIGRAPHS */ +# else /* OLD_DIGRAPHS */ /* * digraphs for Unicode from RFC1345 @@ -792,7 +658,6 @@ static digr_T digraphdefault[] = {'y', ':', 0xff}, {'y', '"', 0xff}, // x XX Vim 5.x compatible -# ifdef FEAT_MBYTE # define USE_UNICODE_DIGRAPHS {'A', '-', 0x0100}, @@ -1957,14 +1822,11 @@ static digr_T digraphdefault[] = {'f', 'l', 0xfb02}, {'f', 't', 0xfb05}, {'s', 't', 0xfb06}, -# endif /* FEAT_MBYTE */ {NUL, NUL, NUL} }; -# endif /* OLD_DIGRAPHS */ - -# endif /* Macintosh */ +# endif /* OLD_DIGRAPHS */ # endif /* EBCDIC */ # endif /* !HPUX_DIGRAPHS */ #endif /* !__MINT__ */ @@ -2141,8 +2003,7 @@ getexactdigraph(int char1, int char2, in ++dp; } } -#ifdef FEAT_MBYTE -# ifdef USE_UNICODE_DIGRAPHS +#ifdef USE_UNICODE_DIGRAPHS if (retval != 0 && !enc_utf8) { char_u buf[6], *to; @@ -2166,12 +2027,11 @@ getexactdigraph(int char1, int char2, in (void)convert_setup(&vc, NULL, NULL); } } -# endif +#endif /* Ignore multi-byte characters when not in multi-byte mode. */ if (!has_mbyte && retval > 0xff) retval = 0; -#endif if (retval == 0) /* digraph deleted or not found */ { @@ -2297,10 +2157,7 @@ listdigraphs(int use_headers) #else if (getexactdigraph(dp->char1, dp->char2, FALSE) == dp->result -# ifdef FEAT_MBYTE - && (has_mbyte || dp->result <= 255) -# endif - ) + && (has_mbyte || dp->result <= 255)) printdigraph(dp, use_headers ? &previous : NULL); #endif ++dp; @@ -2364,11 +2221,7 @@ printdigraph(digr_T *dp, result_T *previ int list_width; - if ((dy_flags & DY_UHEX) -#ifdef FEAT_MBYTE - || has_mbyte -#endif - ) + if ((dy_flags & DY_UHEX) || has_mbyte) list_width = 13; else list_width = 11; @@ -2404,7 +2257,6 @@ printdigraph(digr_T *dp, result_T *previ *p = NUL; msg_outtrans(buf); p = buf; -#ifdef FEAT_MBYTE if (has_mbyte) { /* add a space to draw a composing char on */ @@ -2413,7 +2265,6 @@ printdigraph(digr_T *dp, result_T *previ p += (*mb_char2bytes)(dp->result, p); } else -#endif *p++ = (char_u)dp->result; *p = NUL; 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 * which will call ex_loadkeymap() below. */ - buflen = STRLEN(curbuf->b_p_keymap) -# ifdef FEAT_MBYTE - + STRLEN(p_enc) -# endif - + 14; + buflen = STRLEN(curbuf->b_p_keymap) + STRLEN(p_enc) + 14; buf = alloc((unsigned)buflen); if (buf == NULL) return e_outofmem; -# ifdef FEAT_MBYTE /* try finding "keymap/'keymap'_'encoding'.vim" in 'runtimepath' */ vim_snprintf((char *)buf, buflen, "keymap/%s_%s.vim", curbuf->b_p_keymap, p_enc); if (source_runtime(buf, 0) == FAIL) -# endif { /* try finding "keymap/'keymap'.vim" in 'runtimepath' */ vim_snprintf((char *)buf, buflen, "keymap/%s.vim", diff --git a/src/edit.c b/src/edit.c --- a/src/edit.c +++ b/src/edit.c @@ -212,9 +212,7 @@ static int spell_bad_len = 0; /* length static void stop_insert(pos_T *end_insert_pos, int esc, int nomove); static int echeck_abbr(int); static void replace_join(int off); -#ifdef FEAT_MBYTE static void mb_replace_pop_ins(int cc); -#endif static void replace_flush(void); static void replace_do_bs(int limit_col); static int del_char_after_col(int limit_col); @@ -567,14 +565,12 @@ edit( { if (ptr[1] == NUL) ++curwin->w_cursor.col; -#ifdef FEAT_MBYTE else if (has_mbyte) { i = (*mb_ptr2len)(ptr); if (ptr[i] == NUL) curwin->w_cursor.col += i; } -#endif } ins_at_eol = FALSE; } @@ -1580,12 +1576,10 @@ normalchar: * special character. Let CTRL-] expand abbreviations without * inserting it. */ if (vim_iswordc(c) || (!echeck_abbr( -#ifdef FEAT_MBYTE - /* Add ABBR_OFF for characters above 0x100, this is - * what check_abbr() expects. */ - (has_mbyte && c >= 0x100) ? (c + ABBR_OFF) : -#endif - c) && c != Ctrl_RSB)) + // Add ABBR_OFF for characters above 0x100, this is + // what check_abbr() expects. + (has_mbyte && c >= 0x100) ? (c + ABBR_OFF) : c) + && c != Ctrl_RSB)) { insert_special(c, FALSE, FALSE); #ifdef FEAT_RIGHTLEFT @@ -1835,14 +1829,11 @@ edit_putchar(int c, int highlight) attr = 0; pc_row = W_WINROW(curwin) + curwin->w_wrow; pc_col = curwin->w_wincol; -#if defined(FEAT_RIGHTLEFT) || defined(FEAT_MBYTE) pc_status = PC_STATUS_UNSET; -#endif #ifdef FEAT_RIGHTLEFT if (curwin->w_p_rl) { pc_col += curwin->w_width - 1 - curwin->w_wcol; -# ifdef FEAT_MBYTE if (has_mbyte) { 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; } } -# endif } else #endif { pc_col += curwin->w_wcol; -#ifdef FEAT_MBYTE if (mb_lefthalve(pc_row, pc_col)) pc_status = PC_STATUS_LEFT; -#endif } /* save the character to be able to put it back */ -#if defined(FEAT_RIGHTLEFT) || defined(FEAT_MBYTE) if (pc_status == PC_STATUS_UNSET) -#endif { screen_getbytes(pc_row, pc_col, pc_bytes, &pc_attr); pc_status = PC_STATUS_SET; @@ -1953,13 +1939,11 @@ edit_unputchar(void) { if (pc_status != PC_STATUS_UNSET && pc_row >= msg_scrolled) { -#if defined(FEAT_MBYTE) if (pc_status == PC_STATUS_RIGHT) ++curwin->w_wcol; if (pc_status == PC_STATUS_RIGHT || pc_status == PC_STATUS_LEFT) redrawWinline(curwin, curwin->w_cursor.lnum); else -#endif screen_puts(pc_bytes, pc_row - msg_scrolled, pc_col, pc_attr); } } @@ -1979,7 +1963,6 @@ display_dollar(colnr_T col) cursor_off(); save_col = curwin->w_cursor.col; curwin->w_cursor.col = col; -#ifdef FEAT_MBYTE if (has_mbyte) { char_u *p; @@ -1988,7 +1971,6 @@ display_dollar(colnr_T col) p = ml_get_curline(); curwin->w_cursor.col -= (*mb_head_off)(p, p + col); } -#endif curs_columns(FALSE); /* recompute w_wrow and w_wcol */ if (curwin->w_wcol < curwin->w_width) { @@ -2132,11 +2114,9 @@ change_indent( while (vcol <= (int)curwin->w_virtcol) { last_vcol = vcol; -#ifdef FEAT_MBYTE if (has_mbyte && new_cursor_col >= 0) new_cursor_col += (*mb_ptr2len)(ptr + new_cursor_col); else -#endif ++new_cursor_col; vcol += lbr_chartabsize(ptr, ptr + new_cursor_col, (colnr_T)vcol); } @@ -2302,7 +2282,6 @@ backspace_until_column(int col) static int del_char_after_col(int limit_col UNUSED) { -#ifdef FEAT_MBYTE if (enc_utf8 && limit_col >= 0) { 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); } else -#endif (void)del_char(FALSE); return TRUE; } @@ -2529,7 +2507,6 @@ ins_compl_add_infercase( /* Infer case of completed part. */ /* Find actual length of completion. */ -#ifdef FEAT_MBYTE if (has_mbyte) { p = str; @@ -2541,11 +2518,9 @@ ins_compl_add_infercase( } } else -#endif actual_len = len; /* Find actual length of original text. */ -#ifdef FEAT_MBYTE if (has_mbyte) { p = compl_orig_text; @@ -2557,7 +2532,6 @@ ins_compl_add_infercase( } } else -#endif actual_compl_length = compl_length; /* "actual_len" may be smaller than "actual_compl_length" when using @@ -2571,22 +2545,18 @@ ins_compl_add_infercase( { p = str; for (i = 0; i < actual_len; ++i) -#ifdef FEAT_MBYTE if (has_mbyte) wca[i] = mb_ptr2char_adv(&p); else -#endif wca[i] = *(p++); /* Rule 1: Were any chars converted to lower? */ p = compl_orig_text; for (i = 0; i < min_len; ++i) { -#ifdef FEAT_MBYTE if (has_mbyte) c = mb_ptr2char_adv(&p); else -#endif c = *(p++); if (MB_ISLOWER(c)) { @@ -2610,11 +2580,9 @@ ins_compl_add_infercase( p = compl_orig_text; for (i = 0; i < min_len; ++i) { -#ifdef FEAT_MBYTE if (has_mbyte) c = mb_ptr2char_adv(&p); else -#endif c = *(p++); if (was_letter && MB_ISUPPER(c) && MB_ISLOWER(wca[i])) { @@ -2631,11 +2599,9 @@ ins_compl_add_infercase( p = compl_orig_text; for (i = 0; i < min_len; ++i) { -#ifdef FEAT_MBYTE if (has_mbyte) c = mb_ptr2char_adv(&p); else -#endif c = *(p++); if (MB_ISLOWER(c)) wca[i] = MB_TOLOWER(wca[i]); @@ -2652,11 +2618,9 @@ ins_compl_add_infercase( p = IObuff; i = 0; while (i < actual_len && (p - IObuff + 6) < IOSIZE) -#ifdef FEAT_MBYTE if (has_mbyte) p += (*mb_char2bytes)(wca[i++], p); else -#endif *(p++) = wca[i++]; *p = NUL; @@ -2837,14 +2801,12 @@ ins_compl_longest_match(compl_T *match) s = match->cp_str; while (*p != NUL) { -#ifdef FEAT_MBYTE if (has_mbyte) { c1 = mb_ptr2char(p); c2 = mb_ptr2char(s); } else -#endif { c1 = *p; c2 = *s; @@ -2852,14 +2814,12 @@ ins_compl_longest_match(compl_T *match) if (match->cp_icase ? (MB_TOLOWER(c1) != MB_TOLOWER(c2)) : (c1 != c2)) break; -#ifdef FEAT_MBYTE if (has_mbyte) { MB_PTR_ADV(p); MB_PTR_ADV(s); } else -#endif { ++p; ++s; @@ -3426,7 +3386,6 @@ ins_compl_files( wstart = ptr; /* Find end of the word. */ -#ifdef FEAT_MBYTE if (has_mbyte) /* Japanese words may have characters in * different classes, only separate words @@ -3440,7 +3399,6 @@ ins_compl_files( ptr += l; } else -#endif ptr = find_word_end(ptr); /* Add the word. Skip the regexp match. */ @@ -3475,12 +3433,10 @@ ins_compl_files( char_u * find_word_start(char_u *ptr) { -#ifdef FEAT_MBYTE if (has_mbyte) while (*ptr != NUL && *ptr != '\n' && mb_get_class(ptr) <= 1) ptr += (*mb_ptr2len)(ptr); else -#endif while (*ptr != NUL && *ptr != '\n' && !vim_iswordc(*ptr)) ++ptr; return ptr; @@ -3493,7 +3449,6 @@ find_word_start(char_u *ptr) char_u * find_word_end(char_u *ptr) { -#ifdef FEAT_MBYTE int start_class; if (has_mbyte) @@ -3508,7 +3463,6 @@ find_word_end(char_u *ptr) } } else -#endif while (vim_iswordc(*ptr)) ++ptr; return ptr; @@ -3719,13 +3673,10 @@ ins_compl_len(void) static void ins_compl_addleader(int c) { -#ifdef FEAT_MBYTE int cc; -#endif if (stop_arrow() == FAIL) return; -#ifdef FEAT_MBYTE if (has_mbyte && (cc = (*mb_char2len)(c)) > 1) { char_u buf[MB_MAXBYTES + 1]; @@ -3737,7 +3688,6 @@ ins_compl_addleader(int c) AppendToRedobuff(buf); } else -#endif { ins_char(c); if (compl_opt_refresh_always) @@ -4155,10 +4105,8 @@ ins_compl_fixRedoBufForLeader(char_u *pt p = compl_orig_text; for (len = 0; p[len] != NUL && p[len] == ptr[len]; ++len) ; -#ifdef FEAT_MBYTE if (len > 0) len -= (*mb_head_off)(p, p + len); -#endif for (p += len; *p != NUL; MB_PTR_ADV(p)) AppendCharToRedobuff(K_BS); } @@ -5416,25 +5364,14 @@ ins_complete(int c, int enable_pum) return FAIL; if (!vim_iswordp(line + compl_col) || (compl_col > 0 - && ( -#ifdef FEAT_MBYTE - vim_iswordp(mb_prevptr(line, line + compl_col)) -#else - vim_iswordc(line[compl_col - 1]) -#endif - ))) + && (vim_iswordp(mb_prevptr(line, line + compl_col))))) prefix = (char_u *)""; STRCPY((char *)compl_pattern, prefix); (void)quote_meta(compl_pattern + STRLEN(prefix), line + compl_col, compl_length); } - else if (--startcol < 0 || -#ifdef FEAT_MBYTE - !vim_iswordp(mb_prevptr(line, line + startcol + 1)) -#else - !vim_iswordc(line[startcol]) -#endif - ) + else if (--startcol < 0 + || !vim_iswordp(mb_prevptr(line, line + startcol + 1))) { /* Match any word of at least two chars */ compl_pattern = vim_strsave((char_u *)"\\<\\k\\k"); @@ -5445,7 +5382,6 @@ ins_complete(int c, int enable_pum) } else { -#ifdef FEAT_MBYTE /* Search the point of change class of multibyte character * or not a word single byte character backward. */ if (has_mbyte) @@ -5465,7 +5401,6 @@ ins_complete(int c, int enable_pum) } } else -#endif while (--startcol >= 0 && vim_iswordc(line[startcol])) ; compl_col += ++startcol; @@ -5956,7 +5891,6 @@ quote_meta(char_u *dest, char_u *src, in } if (dest != NULL) *dest++ = *src; -# ifdef FEAT_MBYTE /* Copy remaining bytes of a multibyte character. */ if (has_mbyte) { @@ -5972,7 +5906,6 @@ quote_meta(char_u *dest, char_u *src, in *dest++ = *src; } } -# endif } if (dest != NULL) *dest = NUL; @@ -5995,9 +5928,7 @@ get_literal(void) int i; int hex = FALSE; int octal = FALSE; -#ifdef FEAT_MBYTE int unicode = 0; -#endif if (got_int) return Ctrl_C; @@ -6022,28 +5953,18 @@ get_literal(void) { nc = plain_vgetc(); #ifdef FEAT_CMDL_INFO - if (!(State & CMDLINE) -# ifdef FEAT_MBYTE - && MB_BYTE2LEN_CHECK(nc) == 1 -# endif - ) + if (!(State & CMDLINE) && MB_BYTE2LEN_CHECK(nc) == 1) add_to_showcmd(nc); #endif if (nc == 'x' || nc == 'X') hex = TRUE; else if (nc == 'o' || nc == 'O') octal = TRUE; -#ifdef FEAT_MBYTE else if (nc == 'u' || nc == 'U') unicode = nc; -#endif else { - if (hex -#ifdef FEAT_MBYTE - || unicode != 0 -#endif - ) + if (hex || unicode != 0) { if (!vim_isxdigit(nc)) break; @@ -6065,11 +5986,7 @@ get_literal(void) ++i; } - if (cc > 255 -#ifdef FEAT_MBYTE - && unicode == 0 -#endif - ) + if (cc > 255 && unicode == 0) cc = 255; /* limit range to 0-255 */ nc = 0; @@ -6078,13 +5995,11 @@ get_literal(void) if (i >= 2) break; } -#ifdef FEAT_MBYTE else if (unicode) /* Unicode: up to four or eight chars */ { if ((unicode == 'u' && i >= 4) || (unicode == 'U' && i >= 8)) break; } -#endif else if (i >= 3) /* decimal or octal: up to three chars */ break; } @@ -6104,11 +6019,9 @@ get_literal(void) if (cc == 0) /* NUL is stored as NL */ cc = '\n'; -#ifdef FEAT_MBYTE if (enc_dbcs && (cc & 0xff) == 0) cc = '?'; /* don't accept an illegal DBCS char, the NUL in the second byte will cause trouble! */ -#endif --no_mapping; #ifdef FEAT_GUI @@ -6179,11 +6092,7 @@ insert_special( # define ISSPECIAL(c) ((c) < ' ' || (c) >= DEL || (c) == '0' || (c) == '^') #endif -#ifdef FEAT_MBYTE -# define WHITECHAR(cc) (VIM_ISWHITE(cc) && (!enc_utf8 || !utf_iscomposing(utf_ptr2char(ml_get_cursor() + 1)))) -#else -# define WHITECHAR(cc) VIM_ISWHITE(cc) -#endif +#define WHITECHAR(cc) (VIM_ISWHITE(cc) && (!enc_utf8 || !utf_iscomposing(utf_ptr2char(ml_get_cursor() + 1)))) /* * "flags": INSCHAR_FORMAT - force formatting @@ -6340,9 +6249,7 @@ insertchar( #endif if ( !ISSPECIAL(c) -#ifdef FEAT_MBYTE && (!has_mbyte || (*mb_char2len)(c) == 1) -#endif && !has_insertcharpre() && vpeekc() != NUL && !(State & REPLACE_FLAG) @@ -6373,9 +6280,7 @@ insertchar( */ while ( (c = vpeekc()) != NUL && !ISSPECIAL(c) -#ifdef FEAT_MBYTE && (!has_mbyte || MB_BYTE2LEN_CHECK(c) == 1) -#endif && i < INPUT_BUFLEN # ifdef FEAT_FKMAP && !(p_fkmap && KeyTyped) /* Farsi mode mapping moves cursor */ @@ -6412,7 +6317,6 @@ insertchar( } else { -#ifdef FEAT_MBYTE int cc; if (has_mbyte && (cc = (*mb_char2len)(c)) > 1) @@ -6425,7 +6329,6 @@ insertchar( AppendCharToRedobuff(c); } else -#endif { ins_char(c); if (flags & INSCHAR_CTRLV) @@ -6454,9 +6357,7 @@ internal_format( int save_char = NUL; int haveto_redraw = FALSE; int fo_ins_blank = has_format_option(FO_INS_BLANK); -#ifdef FEAT_MBYTE int fo_multibyte = has_format_option(FO_MBYTE_BREAK); -#endif int fo_white_par = has_format_option(FO_WHITE_PAR); int first_line = TRUE; #ifdef FEAT_COMMENTS @@ -6613,7 +6514,6 @@ internal_format( if (curwin->w_cursor.col <= (colnr_T)wantcol) break; } -#ifdef FEAT_MBYTE else if (cc >= 0x100 && fo_multibyte) { /* Break after or before a multi-byte character. */ @@ -6660,7 +6560,6 @@ internal_format( if (curwin->w_cursor.col <= (colnr_T)wantcol) break; } -#endif if (curwin->w_cursor.col == 0) break; dec_cursor(); @@ -7350,7 +7249,6 @@ free_last_insert(void) char_u * add_char2buf(int c, char_u *s) { -#ifdef FEAT_MBYTE char_u temp[MB_MAXBYTES + 1]; int i; int len; @@ -7359,7 +7257,6 @@ add_char2buf(int c, char_u *s) for (i = 0; i < len; ++i) { c = temp[i]; -#endif /* Need to escape K_SPECIAL and CSI like in the typeahead buffer. */ if (c == K_SPECIAL) { @@ -7377,9 +7274,7 @@ add_char2buf(int c, char_u *s) #endif else *s++ = c; -#ifdef FEAT_MBYTE - } -#endif + } return s; } @@ -7435,13 +7330,8 @@ oneright(void) /* Adjust for multi-wide char (excluding TAB) */ ptr = ml_get_cursor(); - coladvance(getviscol() + ((*ptr != TAB && vim_isprintc( -# ifdef FEAT_MBYTE - (*mb_ptr2char)(ptr) -# else - *ptr -# endif - )) + coladvance(getviscol() + ((*ptr != TAB + && vim_isprintc((*mb_ptr2char)(ptr))) ? ptr2cells(ptr) : 1)); curwin->w_set_curswant = TRUE; /* Return OK if the cursor moved, FAIL otherwise (at window edge). */ @@ -7454,11 +7344,9 @@ oneright(void) if (*ptr == NUL) return FAIL; /* already at the very end */ -#ifdef FEAT_MBYTE if (has_mbyte) l = (*mb_ptr2len)(ptr); else -#endif l = 1; /* 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 * characters */ if ((*p_sbr == NUL && !curwin->w_p_bri -# ifdef FEAT_MBYTE - && !has_mbyte -# endif - ) || getviscol() < v) + && !has_mbyte) || getviscol() < v) break; ++width; } @@ -7516,13 +7401,8 @@ oneleft(void) /* Adjust for multi-wide char (not a TAB) */ ptr = ml_get_cursor(); - if (*ptr != TAB && vim_isprintc( -# ifdef FEAT_MBYTE - (*mb_ptr2char)(ptr) -# else - *ptr -# endif - ) && ptr2cells(ptr) > 1) + if (*ptr != TAB && vim_isprintc((*mb_ptr2char)(ptr)) + && ptr2cells(ptr) > 1) curwin->w_cursor.coladd = 0; } @@ -7537,12 +7417,10 @@ oneleft(void) curwin->w_set_curswant = TRUE; --curwin->w_cursor.col; -#ifdef FEAT_MBYTE /* if the character on the left of the current cursor is a multi-byte * character, move to its first byte */ if (has_mbyte) mb_adjust_cursor(); -#endif return OK; } @@ -7829,7 +7707,6 @@ replace_push( ++replace_stack_nr; } -#if defined(FEAT_MBYTE) || defined(PROTO) /* * 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. @@ -7845,7 +7722,6 @@ replace_push_mb(char_u *p) replace_push(p[j]); return l; } -#endif /* * Pop one item from the replace stack. @@ -7893,17 +7769,12 @@ replace_pop_ins(void) State = NORMAL; /* don't want REPLACE here */ while ((cc = replace_pop()) > 0) { -#ifdef FEAT_MBYTE mb_replace_pop_ins(cc); -#else - ins_char(cc); -#endif dec_cursor(); } State = oldState; } -#ifdef FEAT_MBYTE /* * Insert bytes popped from the replace stack. "cc" is the first byte. If it * 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 @@ -8012,7 +7882,6 @@ replace_do_bs(int limit_col) getvcol(curwin, &curwin->w_cursor, NULL, &start_vcol, NULL); orig_vcols = chartabsize(ml_get_cursor(), start_vcol); } -#ifdef FEAT_MBYTE if (has_mbyte) { (void)del_char_after_col(limit_col); @@ -8021,7 +7890,6 @@ replace_do_bs(int limit_col) replace_push(cc); } else -#endif { pchar_cursor(cc); if (State & VREPLACE_FLAG) @@ -8038,9 +7906,7 @@ replace_do_bs(int limit_col) for (i = 0; i < ins_len; ++i) { vcol += chartabsize(p + i, vcol); -#ifdef FEAT_MBYTE i += (*mb_ptr2len)(p) - 1; -#endif } vcol -= start_vcol; @@ -8329,7 +8195,6 @@ in_cinkeys( /* Just completed a word, check if it starts with "look". * search back for the start of a word. */ line = ml_get_curline(); -# ifdef FEAT_MBYTE if (has_mbyte) { char_u *n; @@ -8342,7 +8207,6 @@ in_cinkeys( } } else -# endif for (s = line + curwin->w_cursor.col; s > line; --s) if (!vim_iswordc(s[-1])) break; @@ -8823,11 +8687,9 @@ ins_esc( #endif { --curwin->w_cursor.col; -#ifdef FEAT_MBYTE /* Correct cursor for multi-byte character. */ if (has_mbyte) mb_adjust_cursor(); -#endif } } @@ -9137,9 +8999,7 @@ ins_bs( int did_backspace = FALSE; int in_indent; int oldState; -#ifdef FEAT_MBYTE int cpc[MAX_MCO]; /* composing characters */ -#endif /* * can't delete anything in an empty file @@ -9287,11 +9147,7 @@ ins_bs( while (cc > 0) { save_col = curwin->w_cursor.col; -#ifdef FEAT_MBYTE mb_replace_pop_ins(cc); -#else - ins_char(cc); -#endif curwin->w_cursor.col = save_col; cc = replace_pop(); } @@ -9413,12 +9269,10 @@ ins_bs( */ else { -#ifdef FEAT_MBYTE int cclass = 0, prev_cclass = 0; if (has_mbyte) cclass = mb_get_class(ml_get_cursor()); -#endif do { #ifdef FEAT_RIGHTLEFT @@ -9427,14 +9281,12 @@ ins_bs( dec_cursor(); cc = gchar_cursor(); -#ifdef FEAT_MBYTE /* look multi-byte character class */ if (has_mbyte) { prev_cclass = cclass; cclass = mb_get_class(ml_get_cursor()); } -#endif /* start of word? */ if (mode == BACKSPACE_WORD && !vim_isspace(cc)) @@ -9445,10 +9297,7 @@ ins_bs( /* end of word? */ else if (mode == BACKSPACE_WORD_NOT_SPACE && ((vim_isspace(cc) || vim_iswordc(cc) != temp) -#ifdef FEAT_MBYTE - || prev_cclass != cclass -#endif - )) + || prev_cclass != cclass)) { #ifdef FEAT_RIGHTLEFT if (!revins_on) @@ -9464,12 +9313,9 @@ ins_bs( replace_do_bs(-1); else { -#ifdef FEAT_MBYTE if (enc_utf8 && p_deco) (void)utfc_ptr2char(ml_get_cursor(), cpc); -#endif (void)del_char(FALSE); -#ifdef FEAT_MBYTE /* * If there are combining characters and 'delcombine' is set * 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) inc_cursor(); -#endif #ifdef FEAT_RIGHTLEFT if (revins_chars) { @@ -9713,11 +9558,9 @@ bracketed_paste(paste_mode_T mode, int d // won't get the end sequence. break; -#ifdef FEAT_MBYTE if (has_mbyte) idx += (*mb_char2bytes)(c, buf + idx); else -#endif buf[idx++] = c; buf[idx] = NUL; if (end != NULL && STRNCMP(buf, end, idx) == 0) @@ -9760,11 +9603,9 @@ bracketed_paste(paste_mode_T mode, int d case PASTE_ONE_CHAR: if (ret_char == -1) { -#ifdef FEAT_MBYTE if (has_mbyte) ret_char = (*mb_ptr2char)(buf); else -#endif ret_char = buf[0]; } break; @@ -9972,11 +9813,9 @@ ins_right( else #endif { -#ifdef FEAT_MBYTE if (has_mbyte) curwin->w_cursor.col += (*mb_ptr2len)(ml_get_cursor()); else -#endif ++curwin->w_cursor.col; } @@ -10590,11 +10429,7 @@ ins_copychar(linenr_T lnum) if ((colnr_T)temp > curwin->w_virtcol) ptr = prev_ptr; -#ifdef FEAT_MBYTE c = (*mb_ptr2char)(ptr); -#else - c = *ptr; -#endif if (c == NUL) vim_beep(BO_COPY); return c; @@ -10773,11 +10608,9 @@ do_insert_char_pre(int c) if (!has_insertcharpre()) return NULL; -# ifdef FEAT_MBYTE if (has_mbyte) buf[(*mb_char2bytes)(c, buf)] = NUL; else -# endif { buf[0] = c; buf[1] = NUL; diff --git a/src/eval.c b/src/eval.c --- a/src/eval.c +++ b/src/eval.c @@ -577,7 +577,6 @@ var_redir_stop(void) VIM_CLEAR(redir_varname); } -# if defined(FEAT_MBYTE) || defined(PROTO) int eval_charconvert( char_u *enc_from, @@ -602,7 +601,6 @@ eval_charconvert( return FAIL; return OK; } -# endif # if defined(FEAT_POSTSCRIPT) || defined(PROTO) int @@ -4998,13 +4996,11 @@ get_string_tv(char_u **arg, typval_T *re nr = (nr << 4) + hex2nr(*p); } ++p; -#ifdef FEAT_MBYTE /* For "\u" store the number according to * 'encoding'. */ if (c != 'X') name += (*mb_char2bytes)(nr, name); else -#endif *name++ = nr; } break; @@ -6704,11 +6700,9 @@ set_vim_var_char(int c) { char_u buf[MB_MAXBYTES + 1]; -#ifdef FEAT_MBYTE if (has_mbyte) buf[(*mb_char2bytes)(c, buf)] = NUL; else -#endif { buf[0] = c; buf[1] = NUL; @@ -6885,12 +6879,10 @@ set_cmdarg(exarg_T *eap, char_u *oldarg) if (eap->force_ff != 0) len += 10; /* " ++ff=unix" */ -# ifdef FEAT_MBYTE if (eap->force_enc != 0) len += (unsigned)STRLEN(eap->cmd + eap->force_enc) + 7; if (eap->bad_char != 0) len += 7 + 4; /* " ++bad=" + "keep" or "drop" */ -# endif newval = alloc(len + 1); if (newval == NULL) @@ -6911,7 +6903,6 @@ set_cmdarg(exarg_T *eap, char_u *oldarg) eap->force_ff == 'u' ? "unix" : eap->force_ff == 'd' ? "dos" : "mac"); -#ifdef FEAT_MBYTE if (eap->force_enc != 0) sprintf((char *)newval + STRLEN(newval), " ++enc=%s", eap->cmd + eap->force_enc); @@ -6921,7 +6912,6 @@ set_cmdarg(exarg_T *eap, char_u *oldarg) STRCPY(newval + STRLEN(newval), " ++bad=drop"); else if (eap->bad_char != 0) sprintf((char *)newval + STRLEN(newval), " ++bad=%c", eap->bad_char); -#endif vimvars[VV_CMDARG].vv_str = newval; return oldval; } @@ -8432,7 +8422,6 @@ ex_echo(exarg_T *eap) } else { -#ifdef FEAT_MBYTE if (has_mbyte) { int i = (*mb_ptr2len)(p); @@ -8441,7 +8430,6 @@ ex_echo(exarg_T *eap) p += i - 1; } else -#endif (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. */ for (p = tfname + len - 1; p >= tfname; --p) { -#ifdef FEAT_MBYTE if (has_mbyte) p -= mb_head_off(tfname, p); -#endif if (vim_ispathsep(*p)) { if (sepcount == 0 || (hasTilde && sepcount == 1)) diff --git a/src/evalfunc.c b/src/evalfunc.c --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -2071,9 +2071,7 @@ f_byte2line(typval_T *argvars UNUSED, ty static void byteidx(typval_T *argvars, typval_T *rettv, int comp UNUSED) { -#ifdef FEAT_MBYTE char_u *t; -#endif char_u *str; varnumber_T idx; @@ -2083,7 +2081,6 @@ byteidx(typval_T *argvars, typval_T *ret if (str == NULL || idx < 0) return; -#ifdef FEAT_MBYTE t = str; for ( ; idx > 0; idx--) { @@ -2095,10 +2092,6 @@ byteidx(typval_T *argvars, typval_T *ret t += (*mb_ptr2len)(t); } 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, typ static void f_char2nr(typval_T *argvars, typval_T *rettv) { -#ifdef FEAT_MBYTE if (has_mbyte) { int utf8 = 0; @@ -2464,8 +2456,7 @@ f_char2nr(typval_T *argvars, typval_T *r rettv->vval.v_number = (*mb_ptr2char)(tv_get_string(&argvars[0])); } 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, curwin->w_virtcol - curwin->w_cursor.coladd)) { -# ifdef FEAT_MBYTE int l; if (*p != NUL && p[(l = (*mb_ptr2len)(p))] == NUL) col += l; -# else - if (*p != NUL && p[1] == NUL) - ++col; -# endif } } #endif @@ -2904,11 +2890,9 @@ f_cursor(typval_T *argvars, typval_T *re /* Make sure the cursor is in a valid position. */ check_cursor(); -#ifdef FEAT_MBYTE /* Correct cursor for multi-byte character. */ if (has_mbyte) mb_adjust_cursor(); -#endif curwin->w_set_curswant = set_curswant; rettv->vval.v_number = 0; @@ -4888,10 +4872,8 @@ f_getchar(typval_T *argvars, typval_T *r temp[i++] = K_SECOND(n); temp[i++] = K_THIRD(n); } -#ifdef FEAT_MBYTE else if (has_mbyte) i += (*mb_char2bytes)(n, temp + i); -#endif else temp[i++] = n; temp[i++] = NUL; @@ -5439,7 +5421,7 @@ f_getmatches(typval_T *argvars UNUSED, t dict_add_string(dict, "group", syn_id2name(cur->hlg_id)); dict_add_number(dict, "priority", (long)cur->priority); dict_add_number(dict, "id", (long)cur->id); -# if defined(FEAT_CONCEAL) && defined(FEAT_MBYTE) +# if defined(FEAT_CONCEAL) if (cur->conceal_char) { char_u buf[MB_MAXBYTES + 1]; @@ -6423,9 +6405,7 @@ f_has(typval_T *argvars, typval_T *rettv "mouse_xterm", # endif #endif -#ifdef FEAT_MBYTE "multi_byte", -#endif #ifdef FEAT_MBYTE_IME "multi_byte_ime", #endif @@ -6674,10 +6654,8 @@ f_has(typval_T *argvars, typval_T *rettv n = mch_input_isatty(); else if (STRICMP(name, "ttyout") == 0) n = stdout_isatty; -#ifdef FEAT_MBYTE else if (STRICMP(name, "multi_byte_encoding") == 0) n = has_mbyte; -#endif #if defined(FEAT_BEVAL) && defined(FEAT_GUI_W32) else if (STRICMP(name, "balloon_multiline") == 0) n = multiline_balloon_available(); @@ -6965,17 +6943,14 @@ f_hostname(typval_T *argvars UNUSED, typ static void f_iconv(typval_T *argvars UNUSED, typval_T *rettv) { -#ifdef FEAT_MBYTE char_u buf1[NUMBUFLEN]; char_u buf2[NUMBUFLEN]; char_u *from, *to, *str; vimconv_T vimconv; -#endif rettv->v_type = VAR_STRING; rettv->vval.v_string = NULL; -#ifdef FEAT_MBYTE str = tv_get_string(&argvars[0]); from = enc_canonize(enc_skip(tv_get_string_buf(&argvars[1], buf1))); to = enc_canonize(enc_skip(tv_get_string_buf(&argvars[2], buf2))); @@ -6991,7 +6966,6 @@ f_iconv(typval_T *argvars UNUSED, typval convert_setup(&vimconv, NULL, NULL); vim_free(from); vim_free(to); -#endif } /* @@ -8097,12 +8071,8 @@ find_some_match(typval_T *argvars, typva } else { -#ifdef FEAT_MBYTE startcol = (colnr_T)(regmatch.startp[0] + (*mb_ptr2len)(regmatch.startp[0]) - str); -#else - startcol = (colnr_T)(regmatch.startp[0] + 1 - str); -#endif if (startcol > (colnr_T)len || str + startcol <= regmatch.startp[0]) { @@ -8712,7 +8682,6 @@ f_nr2char(typval_T *argvars, typval_T *r { char_u buf[NUMBUFLEN]; -#ifdef FEAT_MBYTE if (has_mbyte) { int utf8 = 0; @@ -8725,7 +8694,6 @@ f_nr2char(typval_T *argvars, typval_T *r buf[(*mb_char2bytes)((int)tv_get_number(&argvars[0]), buf)] = NUL; } else -#endif { buf[0] = (char_u)tv_get_number(&argvars[0]); buf[1] = NUL; @@ -9175,7 +9143,6 @@ f_readfile(typval_T *argvars, typval_T * } else if (*p == NUL) *p = '\n'; -#ifdef FEAT_MBYTE /* Check for utf8 "bom"; U+FEFF is encoded as EF BB BF. Do this * when finding the BF and check the previous two bytes. */ else if (*p == 0xbf && enc_utf8 && !binary) @@ -9215,7 +9182,6 @@ f_readfile(typval_T *argvars, typval_T * } } } -#endif } /* for */ if (failed || (cnt >= maxline && maxline >= 0) || readlen <= 0) @@ -10386,11 +10352,9 @@ f_screenchar(typval_T *argvars, typval_T else { off = LineOffset[row] + col; -#ifdef FEAT_MBYTE if (enc_utf8 && ScreenLinesUC[off] != 0) c = ScreenLinesUC[off]; else -#endif c = ScreenLines[off]; } rettv->vval.v_number = c; @@ -10910,7 +10874,6 @@ f_setcharsearch(typval_T *argvars, typva csearch = dict_get_string(d, (char_u *)"char", FALSE); if (csearch != NULL) { -#ifdef FEAT_MBYTE if (enc_utf8) { int pcc[MAX_MCO]; @@ -10919,7 +10882,6 @@ f_setcharsearch(typval_T *argvars, typva set_last_csearch(c, csearch, utfc_ptr2len(csearch)); } else -#endif set_last_csearch(PTR2CHAR(csearch), csearch, MB_PTR2LEN(csearch)); } @@ -12511,18 +12473,12 @@ f_split(typval_T *argvars, typval_T *ret } if (!match) break; - /* Advance to just after the match. */ + // Advance to just after the match. if (regmatch.endp[0] > str) col = 0; else - { - /* Don't get stuck at the same match. */ -#ifdef FEAT_MBYTE + // Don't get stuck at the same match. col = (*mb_ptr2len)(regmatch.endp[0]); -#else - col = 1; -#endif - } str = regmatch.endp[0]; } @@ -12632,7 +12588,6 @@ f_strftime(typval_T *argvars, typval_T * rettv->vval.v_string = vim_strsave((char_u *)_("(Invalid)")); else { -# ifdef FEAT_MBYTE vimconv_T conv; char_u *enc; @@ -12641,28 +12596,23 @@ f_strftime(typval_T *argvars, typval_T * convert_setup(&conv, p_enc, enc); if (conv.vc_type != CONV_NONE) p = string_convert(&conv, p, NULL); -# endif if (p != NULL) (void)strftime((char *)result_buf, sizeof(result_buf), (char *)p, curtime); else result_buf[0] = NUL; -# ifdef FEAT_MBYTE if (conv.vc_type != CONV_NONE) vim_free(p); convert_setup(&conv, enc, p_enc); if (conv.vc_type != CONV_NONE) rettv->vval.v_string = string_convert(&conv, result_buf, NULL); else -# endif rettv->vval.v_string = vim_strsave(result_buf); -# ifdef FEAT_MBYTE /* Release conversion descriptors */ convert_setup(&conv, NULL, NULL); vim_free(enc); -# endif } } #endif @@ -12677,6 +12627,7 @@ f_strgetchar(typval_T *argvars, typval_T int len; int error = FALSE; int charidx; + int byteidx = 0; rettv->vval.v_number = -1; str = tv_get_string_chk(&argvars[0]); @@ -12686,25 +12637,17 @@ f_strgetchar(typval_T *argvars, typval_T charidx = (int)tv_get_number_chk(&argvars[1], &error); if (error) return; -#ifdef FEAT_MBYTE - { - int byteidx = 0; - - while (charidx >= 0 && byteidx < len) - { - if (charidx == 0) - { - rettv->vval.v_number = mb_ptr2char(str + byteidx); - break; - } - --charidx; - byteidx += MB_CPTR2LEN(str + byteidx); - } - } -#else - if (charidx < len) - rettv->vval.v_number = str[charidx]; -#endif + + while (charidx >= 0 && byteidx < len) + { + if (charidx == 0) + { + rettv->vval.v_number = mb_ptr2char(str + byteidx); + break; + } + --charidx; + byteidx += MB_CPTR2LEN(str + byteidx); + } } /* @@ -12777,10 +12720,8 @@ f_strchars(typval_T *argvars, typval_T * { char_u *s = tv_get_string(&argvars[0]); int skipcc = 0; -#ifdef FEAT_MBYTE varnumber_T len = 0; int (*func_mb_ptr2char_adv)(char_u **pp); -#endif if (argvars[1].v_type != VAR_UNKNOWN) skipcc = (int)tv_get_number_chk(&argvars[1], NULL); @@ -12788,7 +12729,6 @@ f_strchars(typval_T *argvars, typval_T * emsg(_(e_invarg)); else { -#ifdef FEAT_MBYTE func_mb_ptr2char_adv = skipcc ? mb_ptr2char_adv : mb_cptr2char_adv; while (*s != NUL) { @@ -12796,9 +12736,6 @@ f_strchars(typval_T *argvars, typval_T * ++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 * { char_u *s = tv_get_string(&argvars[0]); - rettv->vval.v_number = (varnumber_T)( -#ifdef FEAT_MBYTE - mb_string2cells(s, -1) -#else - STRLEN(s) -#endif - ); + rettv->vval.v_number = (varnumber_T)(mb_string2cells(s, -1)); } /* @@ -12840,7 +12771,6 @@ f_strwidth(typval_T *argvars, typval_T * static void f_strcharpart(typval_T *argvars, typval_T *rettv) { -#ifdef FEAT_MBYTE char_u *p; int nchar; int nbyte = 0; @@ -12899,9 +12829,6 @@ f_strcharpart(typval_T *argvars, typval_ rettv->v_type = VAR_STRING; 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, cchar = (lcs_conceal == NUL) ? ' ' : lcs_conceal; if (cchar != NUL) { -# ifdef FEAT_MBYTE if (has_mbyte) (*mb_char2bytes)(cchar, str); else -# endif str[0] = cchar; } } @@ -14208,7 +14133,6 @@ f_tr(typval_T *argvars, typval_T *rettv) char_u *fromstr; char_u *tostr; char_u *p; -#ifdef FEAT_MBYTE int inlen; int fromlen; int tolen; @@ -14216,7 +14140,6 @@ f_tr(typval_T *argvars, typval_T *rettv) char_u *cpstr; int cplen; int first = TRUE; -#endif char_u buf[NUMBUFLEN]; char_u buf2[NUMBUFLEN]; garray_T ga; @@ -14232,15 +14155,11 @@ f_tr(typval_T *argvars, typval_T *rettv) return; /* type error; errmsg already given */ ga_init2(&ga, (int)sizeof(char), 80); -#ifdef FEAT_MBYTE if (!has_mbyte) -#endif /* not multi-byte: fromstr and tostr must be the same length */ if (STRLEN(fromstr) != STRLEN(tostr)) { -#ifdef FEAT_MBYTE error: -#endif semsg(_(e_invarg2), fromstr); ga_clear(&ga); return; @@ -14249,7 +14168,6 @@ error: /* fromstr and tostr have to contain the same number of chars */ while (*in_str != NUL) { -#ifdef FEAT_MBYTE if (has_mbyte) { inlen = (*mb_ptr2len)(in_str); @@ -14300,7 +14218,6 @@ error: in_str += inlen; } else -#endif { /* When not using multi-byte chars we can do it faster. */ p = vim_strchr(fromstr, *in_str); diff --git a/src/ex_cmds.c b/src/ex_cmds.c --- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -50,7 +50,6 @@ do_ascii(exarg_T *eap UNUSED) #ifdef FEAT_DIGRAPHS char_u *dig; #endif -#ifdef FEAT_MBYTE int cc[MAX_MCO]; int ci = 0; int len; @@ -58,7 +57,6 @@ do_ascii(exarg_T *eap UNUSED) if (enc_utf8) c = utfc_ptr2char(ml_get_cursor(), cc); else -#endif c = gchar_cursor(); if (c == NUL) { @@ -66,10 +64,8 @@ do_ascii(exarg_T *eap UNUSED) return; } -#ifdef FEAT_MBYTE IObuff[0] = NUL; if (!has_mbyte || (enc_dbcs != 0 && c < 0x100) || c < 0x80) -#endif { if (c == NL) /* NUL is stored as NL */ c = NUL; @@ -106,15 +102,12 @@ do_ascii(exarg_T *eap UNUSED) vim_snprintf((char *)IObuff, IOSIZE, _("<%s>%s%s %d, Hex %02x, Octal %03o"), transchar(c), buf1, buf2, cval, cval, cval); -#ifdef FEAT_MBYTE if (enc_utf8) c = cc[ci++]; else c = 0; -#endif - } - -#ifdef FEAT_MBYTE + } + /* Repeat for combining characters. */ while (has_mbyte && (c >= 0x100 || (enc_utf8 && c >= 0x80))) { @@ -150,7 +143,6 @@ do_ascii(exarg_T *eap UNUSED) else c = 0; } -#endif msg((char *)IObuff); } @@ -823,11 +815,9 @@ ex_retab(exarg_T *eap) if (ptr[col] == NUL) break; vcol += chartabsize(ptr + col, (colnr_T)vcol); -#ifdef FEAT_MBYTE if (has_mbyte) col += (*mb_ptr2len)(ptr + col); else -#endif ++col; } if (new_line == NULL) /* out of memory */ @@ -2282,9 +2272,7 @@ do_viminfo(FILE *fp_in, FILE *fp_out, in if ((vir.vir_line = alloc(LSIZE)) == NULL) return; vir.vir_fd = fp_in; -#ifdef FEAT_MBYTE vir.vir_conv.vc_type = CONV_NONE; -#endif ga_init2(&vir.vir_barlines, (int)sizeof(char_u *), 100); vir.vir_version = -1; @@ -2321,10 +2309,8 @@ do_viminfo(FILE *fp_in, FILE *fp_out, in VIM_VERSION_MEDIUM); fputs(_("# You may edit it if you're careful!\n\n"), fp_out); write_viminfo_version(fp_out); -#ifdef FEAT_MBYTE fputs(_("# Value of 'encoding' when this file was written\n"), fp_out); fprintf(fp_out, "*encoding=%s\n\n", p_enc); -#endif write_viminfo_search_pattern(fp_out); write_viminfo_sub_string(fp_out); #ifdef FEAT_CMDHIST @@ -2353,10 +2339,8 @@ do_viminfo(FILE *fp_in, FILE *fp_out, in } vim_free(vir.vir_line); -#ifdef FEAT_MBYTE if (vir.vir_conv.vc_type != CONV_NONE) convert_setup(&vir.vir_conv, NULL, NULL); -#endif ga_clear_strings(&vir.vir_barlines); } @@ -2484,7 +2468,6 @@ read_viminfo_up_to_marks( static int viminfo_encoding(vir_T *virp) { -#ifdef FEAT_MBYTE char_u *p; int i; @@ -2502,7 +2485,6 @@ viminfo_encoding(vir_T *virp) convert_setup(&virp->vir_conv, p, p_enc); } } -#endif return viminfo_readline(virp); } @@ -2574,7 +2556,6 @@ viminfo_readstring( } *d = NUL; -#ifdef FEAT_MBYTE if (convert && virp->vir_conv.vc_type != CONV_NONE && *retval != NUL) { d = string_convert(&virp->vir_conv, retval, NULL); @@ -2584,7 +2565,6 @@ viminfo_readstring( retval = d; } } -#endif return retval; } @@ -2708,10 +2688,8 @@ barline_parse(vir_T *virp, char_u *text, int i; int allocated = FALSE; int eof; -#ifdef FEAT_MBYTE char_u *sconv; int converted; -#endif while (*p == ',') { @@ -2835,7 +2813,6 @@ barline_parse(vir_T *virp, char_u *text, ++p; s[len] = NUL; -#ifdef FEAT_MBYTE converted = FALSE; if (virp->vir_conv.vc_type != CONV_NONE && *s != NUL) { @@ -2849,7 +2826,7 @@ barline_parse(vir_T *virp, char_u *text, converted = TRUE; } } -#endif + /* Need to copy in allocated memory if the string wasn't allocated * above and we did allocate before, thus vir_line may change. */ if (s != buf && allocated) @@ -2857,11 +2834,7 @@ barline_parse(vir_T *virp, char_u *text, value->bv_string = s; value->bv_type = BVAL_STRING; value->bv_len = len; - value->bv_allocated = allocated -#ifdef FEAT_MBYTE - || converted -#endif - ; + value->bv_allocated = allocated || converted; ++values->ga_len; if (nextp != NULL) { @@ -4094,9 +4067,7 @@ do_ecmd( if (!oldbuf && eap != NULL) { set_file_options(TRUE, eap); -#ifdef FEAT_MBYTE set_forced_fenc(eap); -#endif } } @@ -5317,11 +5288,9 @@ do_sub(exarg_T *eap) else { /* search for a match at next column */ -#ifdef FEAT_MBYTE if (has_mbyte) matchcol += mb_ptr2len(sub_firstline + matchcol); else -#endif ++matchcol; } goto skip; @@ -5759,10 +5728,8 @@ do_sub(exarg_T *eap) p1 = new_start - 1; } } -#ifdef FEAT_MBYTE else if (has_mbyte) p1 += (*mb_ptr2len)(p1) - 1; -#endif } /* @@ -7017,10 +6984,8 @@ fix_help_buffer(void) FILE *fd; char_u *s; int fi; -#ifdef FEAT_MBYTE vimconv_T vc; char_u *cp; -#endif /* Find all "doc/ *.txt" files in this directory. */ add_pathsep(NameBuff); @@ -7086,9 +7051,8 @@ fix_help_buffer(void) && (s = vim_strchr(IObuff + 1, '*')) != NULL) { -#ifdef FEAT_MBYTE int this_utf = MAYBE; -#endif + /* Change tag definition to a * reference and remove /. */ IObuff[0] = '|'; @@ -7097,7 +7061,6 @@ fix_help_buffer(void) { if (*s == '\r' || *s == '\n') *s = NUL; -#ifdef FEAT_MBYTE /* The text is utf-8 when a byte * above 127 is found and no * illegal byte sequence is found. @@ -7112,10 +7075,9 @@ fix_help_buffer(void) this_utf = FALSE; s += l - 1; } -#endif ++s; } -#ifdef FEAT_MBYTE + /* The help file is latin1 or utf-8; * conversion to the current * 'encoding' may be required. */ @@ -7140,10 +7102,6 @@ fix_help_buffer(void) ml_append(lnum, cp, (colnr_T)0, FALSE); if (cp != IObuff) vim_free(cp); -#else - ml_append(lnum, IObuff, (colnr_T)0, - FALSE); -#endif ++lnum; } fclose(fd); @@ -7199,12 +7157,10 @@ helptags_one( int i; char_u *fname; int dirlen; -# ifdef FEAT_MBYTE int utf8 = MAYBE; int this_utf8; int firstline; int mix = FALSE; /* detected mixed encodings */ -# endif /* * Find all *.txt files. @@ -7274,12 +7230,9 @@ helptags_one( } fname = files[fi] + dirlen + 1; -# ifdef FEAT_MBYTE firstline = TRUE; -# endif while (!vim_fgets(IObuff, IOSIZE, fd) && !got_int) { -# ifdef FEAT_MBYTE if (firstline) { /* Detect utf-8 file by a non-ASCII char in the first line. */ @@ -7311,7 +7264,6 @@ helptags_one( } firstline = FALSE; } -# endif p1 = vim_strchr(IObuff, '*'); /* find first '*' */ while (p1 != NULL) { @@ -7398,10 +7350,8 @@ helptags_one( } } -# ifdef FEAT_MBYTE if (utf8 == TRUE) fprintf(fd_tags, "!_TAG_FILE_ENCODING\tutf-8\t//\n"); -# endif /* * Write the tags into the file. @@ -7426,10 +7376,8 @@ helptags_one( } } } -#ifdef FEAT_MBYTE if (mix) got_int = FALSE; /* continue with other languages */ -#endif for (i = 0; i < ga.ga_len; ++i) vim_free(((char_u **)ga.ga_data)[i]); diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c --- a/src/ex_cmds2.c +++ b/src/ex_cmds2.c @@ -1957,7 +1957,7 @@ script_dump_profile(FILE *fd) if (IObuff[IOSIZE - 2] != NUL && IObuff[IOSIZE - 2] != NL) { int n = IOSIZE - 2; -# ifdef FEAT_MBYTE + if (enc_utf8) { /* Move to the first byte of this char. @@ -1968,7 +1968,6 @@ script_dump_profile(FILE *fd) } else if (has_mbyte) n -= mb_head_off(IObuff, IObuff + n); -# endif IObuff[n] = NL; IObuff[n + 1] = NUL; } @@ -4254,9 +4253,7 @@ struct source_cookie int dbg_tick; /* debug_tick when breakpoint was set */ int level; /* top nesting level of sourced file */ #endif -#ifdef FEAT_MBYTE vimconv_T conv; /* type of conversion */ -#endif }; #ifdef FEAT_EVAL @@ -4593,7 +4590,6 @@ do_source( # endif #endif -#ifdef FEAT_MBYTE cookie.conv.vc_type = CONV_NONE; /* no conversion */ /* Read the first line so we can check for a UTF-8 BOM. */ @@ -4612,7 +4608,6 @@ do_source( firstline = p; } } -#endif /* * Call do_cmdline, which will call getsourceline() to get the lines. @@ -4683,9 +4678,7 @@ almosttheend: fclose(cookie.fp); vim_free(cookie.nextline); vim_free(firstline); -#ifdef FEAT_MBYTE convert_setup(&cookie.conv, NULL, NULL); -#endif if (trigger_source_post) apply_autocmds(EVENT_SOURCEPOST, fname_exp, fname_exp, FALSE, curbuf); @@ -4924,7 +4917,6 @@ getsourceline(int c UNUSED, void *cookie } } -#ifdef FEAT_MBYTE if (line != NULL && sp->conv.vc_type != CONV_NONE) { char_u *s; @@ -4937,7 +4929,6 @@ getsourceline(int c UNUSED, void *cookie line = s; } } -#endif #ifdef FEAT_EVAL /* Did we encounter a breakpoint? */ @@ -5194,7 +5185,6 @@ script_line_end(void) void ex_scriptencoding(exarg_T *eap UNUSED) { -#ifdef FEAT_MBYTE struct source_cookie *sp; char_u *name; @@ -5219,7 +5209,6 @@ ex_scriptencoding(exarg_T *eap UNUSED) if (name != eap->arg) vim_free(name); -#endif } #if defined(FEAT_EVAL) || defined(PROTO) diff --git a/src/ex_docmd.c b/src/ex_docmd.c --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -404,8 +404,7 @@ static void ex_folddo(exarg_T *eap); # define ex_foldopen ex_ni # define ex_folddo ex_ni #endif -#if !((defined(HAVE_LOCALE_H) || defined(X_LOCALE)) \ - && (defined(FEAT_GETTEXT) || defined(FEAT_MBYTE))) +#if !(defined(HAVE_LOCALE_H) || defined(X_LOCALE)) # define ex_language ex_ni #endif #ifndef FEAT_SIGNS @@ -1550,7 +1549,6 @@ getline_equal( #endif } -#if defined(FEAT_EVAL) || defined(FEAT_MBYTE) || defined(PROTO) /* * If "fgetline" is get_loop_line(), return the cookie used by the original * getline function. Otherwise return "cookie". @@ -1560,7 +1558,7 @@ getline_cookie( char_u *(*fgetline)(int, void *, int) UNUSED, void *cookie) /* argument for fgetline() */ { -# ifdef FEAT_EVAL +#ifdef FEAT_EVAL char_u *(*gp)(int, void *, int); struct loop_cookie *cp; @@ -1575,11 +1573,10 @@ getline_cookie( cp = cp->cookie; } return cp; -# else +#else return cookie; -# endif -} -#endif +#endif +} /* @@ -3116,17 +3113,9 @@ append_command(char_u *cmd) d = IObuff + STRLEN(IObuff); while (*s != NUL && d - IObuff < IOSIZE - 7) { - if ( -#ifdef FEAT_MBYTE - enc_utf8 ? (s[0] == 0xc2 && s[1] == 0xa0) : -#endif - *s == 0xa0) - { - s += -#ifdef FEAT_MBYTE - enc_utf8 ? 2 : -#endif - 1; + if (enc_utf8 ? (s[0] == 0xc2 && s[1] == 0xa0) : *s == 0xa0) + { + s += enc_utf8 ? 2 : 1; STRCPY(d, ""); d += 4; } @@ -3752,11 +3741,9 @@ set_one_cmd_context( p = xp->xp_pattern; while (*p != NUL) { -#ifdef FEAT_MBYTE if (has_mbyte) c = mb_ptr2char(p); else -#endif c = *p; if (c == '\\' && p[1] != NUL) ++p; @@ -3780,19 +3767,15 @@ set_one_cmd_context( len = 0; /* avoid getting stuck when space is in 'isfname' */ while (*p != NUL) { -#ifdef FEAT_MBYTE if (has_mbyte) c = mb_ptr2char(p); else -#endif c = *p; if (c == '`' || vim_isfilec_or_wc(c)) break; -#ifdef FEAT_MBYTE if (has_mbyte) len = (*mb_ptr2len)(p); else -#endif len = 1; MB_PTR_ADV(p); } @@ -5408,7 +5391,6 @@ skip_cmd_arg( return p; } -#if defined(FEAT_MBYTE) || defined(PROTO) int 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 OK; } -#endif /* * Get "++opt=arg" argument. @@ -5433,10 +5414,8 @@ getargopt(exarg_T *eap) { char_u *arg = eap->arg + 2; int *pp = NULL; -#ifdef FEAT_MBYTE int bad_char_idx; char_u *p; -#endif /* ":edit ++[no]bin[ary] file" */ if (STRNCMP(arg, "bin", 3) == 0 || STRNCMP(arg, "nobin", 5) == 0) @@ -5472,7 +5451,6 @@ getargopt(exarg_T *eap) arg += 10; pp = &eap->force_ff; } -#ifdef FEAT_MBYTE else if (STRNCMP(arg, "enc", 3) == 0) { if (STRNCMP(arg, "encoding", 8) == 0) @@ -5486,7 +5464,6 @@ getargopt(exarg_T *eap) arg += 3; pp = &bad_char_idx; } -#endif if (pp == NULL || *arg != '=') return FAIL; @@ -5497,14 +5474,11 @@ getargopt(exarg_T *eap) eap->arg = skipwhite(arg); *arg = NUL; -#ifdef FEAT_MBYTE if (pp == &eap->force_ff) { -#endif if (check_ff_value(eap->cmd + eap->force_ff) == FAIL) return FAIL; eap->force_ff = eap->cmd[eap->force_ff]; -#ifdef FEAT_MBYTE } 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) return FAIL; } -#endif return OK; } @@ -6507,14 +6480,10 @@ uc_split_args(char_u *arg, size_t *lenp) } else { -#ifdef FEAT_MBYTE int charlen = (*mb_ptr2len)(p); + len += charlen; p += charlen; -#else - ++len; - ++p; -#endif } } @@ -6685,13 +6654,11 @@ uc_check_code( result = STRLEN(eap->arg) + 2; for (p = eap->arg; *p; ++p) { -#ifdef FEAT_MBYTE if (enc_dbcs != 0 && (*mb_ptr2len)(p) == 2) /* DBCS can contain \ in a trail byte, skip the * double-byte character. */ ++p; else -#endif if (*p == '\\' || *p == '"') ++result; } @@ -6701,13 +6668,11 @@ uc_check_code( *buf++ = '"'; for (p = eap->arg; *p; ++p) { -#ifdef FEAT_MBYTE if (enc_dbcs != 0 && (*mb_ptr2len)(p) == 2) /* DBCS can contain \ in a trail byte, copy the * double-byte character to avoid escaping. */ *buf++ = *p++; else -#endif if (*p == '\\' || *p == '"') *buf++ = '\\'; *buf++ = *p; @@ -10328,11 +10293,9 @@ restore_current_state(save_state_T *sst) ex_normal(exarg_T *eap) { save_state_T save_state; -#ifdef FEAT_MBYTE char_u *arg = NULL; int l; char_u *p; -#endif if (ex_normal_lock > 0) { @@ -10345,7 +10308,6 @@ ex_normal(exarg_T *eap) return; } -#ifdef FEAT_MBYTE /* * 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 @@ -10358,15 +10320,15 @@ ex_normal(exarg_T *eap) /* Count the number of characters to be escaped. */ for (p = eap->arg; *p != NUL; ++p) { -# ifdef FEAT_GUI +#ifdef FEAT_GUI if (*p == CSI) /* leadbyte CSI */ len += 2; -# endif +#endif for (l = (*mb_ptr2len)(p) - 1; l > 0; --l) if (*++p == K_SPECIAL /* trailbyte K_SPECIAL or CSI */ -# ifdef FEAT_GUI +#ifdef FEAT_GUI || *p == CSI -# endif +#endif ) len += 2; } @@ -10379,13 +10341,13 @@ ex_normal(exarg_T *eap) for (p = eap->arg; *p != NUL; ++p) { arg[len++] = *p; -# ifdef FEAT_GUI +#ifdef FEAT_GUI if (*p == CSI) { arg[len++] = KS_EXTRA; arg[len++] = (int)KE_CSI; } -# endif +#endif for (l = (*mb_ptr2len)(p) - 1; l > 0; --l) { arg[len++] = *++p; @@ -10394,20 +10356,19 @@ ex_normal(exarg_T *eap) arg[len++] = KS_SPECIAL; arg[len++] = KE_FILLER; } -# ifdef FEAT_GUI +#ifdef FEAT_GUI else if (*p == CSI) { arg[len++] = KS_EXTRA; arg[len++] = (int)KE_CSI; } -# endif +#endif } arg[len] = NUL; } } } } -#endif ++ex_normal_busy; if (save_current_state(&save_state)) @@ -10426,11 +10387,9 @@ ex_normal(exarg_T *eap) check_cursor_moved(curwin); } - exec_normal_cmd( -#ifdef FEAT_MBYTE - arg != NULL ? arg : -#endif - eap->arg, eap->forceit ? REMAP_NONE : REMAP_YES, FALSE); + exec_normal_cmd(arg != NULL + ? arg + : eap->arg, eap->forceit ? REMAP_NONE : REMAP_YES, FALSE); } 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 */ #endif -#ifdef FEAT_MBYTE vim_free(arg); -#endif } /* diff --git a/src/ex_getln.c b/src/ex_getln.c --- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -89,9 +89,7 @@ static char_u *getcmdline_int(int firstc static int cmdline_charsize(int idx); static void set_cmdspos(void); static void set_cmdspos_cursor(void); -#ifdef FEAT_MBYTE static void correct_cmdspos(int idx, int cells); -#endif static void alloc_cmdbuff(int len); static int realloc_cmdbuff(int len); static void draw_cmdline(int start, int len); @@ -769,7 +767,6 @@ may_add_char_to_search(int firstc, int * stuffcharReadbuff(*c); *c = '\\'; } -#ifdef FEAT_MBYTE // add any composing characters if (mb_char2len(*c) != mb_ptr2len(ml_get_cursor())) { @@ -783,7 +780,6 @@ may_add_char_to_search(int firstc, int * } *c = save_c; } -#endif return FAIL; } } @@ -1253,10 +1249,8 @@ getcmdline_int( i = (int)(xpc.xp_pattern - ccline.cmdbuff); while (--j > i) { -#ifdef FEAT_MBYTE if (has_mbyte) j -= (*mb_head_off)(ccline.cmdbuff, ccline.cmdbuff + j); -#endif if (vim_ispathsep(ccline.cmdbuff[j])) { found = TRUE; @@ -1281,10 +1275,8 @@ getcmdline_int( i = (int)(xpc.xp_pattern - ccline.cmdbuff); while (--j > i) { -#ifdef FEAT_MBYTE if (has_mbyte) j -= (*mb_head_off)(ccline.cmdbuff, ccline.cmdbuff + j); -#endif if (vim_ispathsep(ccline.cmdbuff[j]) #ifdef BACKSLASH_IN_FILENAME && vim_strchr((char_u *)" *?[{`$%#", @@ -1616,18 +1608,15 @@ getcmdline_int( */ if (c == K_DEL && ccline.cmdpos != ccline.cmdlen) ++ccline.cmdpos; -#ifdef FEAT_MBYTE if (has_mbyte && c == K_DEL) ccline.cmdpos += mb_off_next(ccline.cmdbuff, ccline.cmdbuff + ccline.cmdpos); -#endif if (ccline.cmdpos > 0) { char_u *p; j = ccline.cmdpos; p = ccline.cmdbuff + j; -#ifdef FEAT_MBYTE if (has_mbyte) { p = mb_prevptr(ccline.cmdbuff, p); @@ -1642,9 +1631,7 @@ getcmdline_int( p += (*mb_ptr2len)(p); } } - else -#endif - if (c == Ctrl_W) + else if (c == Ctrl_W) { while (p > ccline.cmdbuff && vim_isspace(p[-1])) --p; @@ -1893,21 +1880,17 @@ getcmdline_int( if (KeyTyped && ccline.cmdspos + i >= Columns * Rows) break; ccline.cmdspos += i; -#ifdef FEAT_MBYTE if (has_mbyte) ccline.cmdpos += (*mb_ptr2len)(ccline.cmdbuff + ccline.cmdpos); else -#endif ++ccline.cmdpos; } while ((c == K_S_RIGHT || c == K_C_RIGHT || (mod_mask & (MOD_MASK_SHIFT|MOD_MASK_CTRL))) && ccline.cmdbuff[ccline.cmdpos] != ' '); -#ifdef FEAT_MBYTE if (has_mbyte) set_cmdspos_cursor(); -#endif goto cmdline_not_changed; case K_LEFT: @@ -1918,21 +1901,17 @@ getcmdline_int( do { --ccline.cmdpos; -#ifdef FEAT_MBYTE if (has_mbyte) /* move to first byte of char */ ccline.cmdpos -= (*mb_head_off)(ccline.cmdbuff, ccline.cmdbuff + ccline.cmdpos); -#endif ccline.cmdspos -= cmdline_charsize(ccline.cmdpos); } while (ccline.cmdpos > 0 && (c == K_S_LEFT || c == K_C_LEFT || (mod_mask & (MOD_MASK_SHIFT|MOD_MASK_CTRL))) && ccline.cmdbuff[ccline.cmdpos - 1] != ' '); -#ifdef FEAT_MBYTE if (has_mbyte) set_cmdspos_cursor(); -#endif goto cmdline_not_changed; case K_IGNORE: @@ -2030,7 +2009,6 @@ getcmdline_int( if (mouse_row <= cmdline_row + ccline.cmdspos / Columns && mouse_col < ccline.cmdspos % Columns + i) break; -# ifdef FEAT_MBYTE if (has_mbyte) { /* Count ">" for double-wide char that doesn't fit. */ @@ -2038,7 +2016,6 @@ getcmdline_int( ccline.cmdpos += (*mb_ptr2len)(ccline.cmdbuff + ccline.cmdpos) - 1; } -# endif ccline.cmdspos += i; } goto cmdline_not_changed; @@ -2301,7 +2278,6 @@ getcmdline_int( c = get_literal(); /* get next (two) character(s) */ do_abbr = FALSE; /* don't do abbreviation now */ extra_char = NUL; -#ifdef FEAT_MBYTE /* may need to remove ^ when composing char was typed */ if (enc_utf8 && utf_iscomposing(c) && !cmd_silent) { @@ -2309,7 +2285,6 @@ getcmdline_int( msg_putchar(' '); cursorcmd(); } -#endif break; #ifdef FEAT_DIGRAPHS @@ -2374,13 +2349,12 @@ getcmdline_int( * We come here if we have a normal character. */ - if (do_abbr && (IS_SPECIAL(c) || !vim_iswordc(c)) && (ccheck_abbr( -#ifdef FEAT_MBYTE - /* Add ABBR_OFF for characters above 0x100, this is - * what check_abbr() expects. */ - (has_mbyte && c >= 0x100) ? (c + ABBR_OFF) : -#endif - c) || c == Ctrl_RSB)) + if (do_abbr && (IS_SPECIAL(c) || !vim_iswordc(c)) + && (ccheck_abbr( + // Add ABBR_OFF for characters above 0x100, this is + // what check_abbr() expects. + (has_mbyte && c >= 0x100) ? (c + ABBR_OFF) : c) + || c == Ctrl_RSB)) goto cmdline_changed; /* @@ -2390,7 +2364,6 @@ getcmdline_int( put_on_cmdline(get_special_key_name(c, mod_mask), -1, TRUE); else { -#ifdef FEAT_MBYTE if (has_mbyte) { j = (*mb_char2bytes)(c, IObuff); @@ -2398,7 +2371,6 @@ getcmdline_int( put_on_cmdline(IObuff, j, TRUE); } else -#endif { IObuff[0] = c; put_on_cmdline(IObuff, 1, TRUE); @@ -2687,11 +2659,9 @@ set_cmdspos_cursor(void) for (i = 0; i < ccline.cmdlen && i < ccline.cmdpos; ++i) { c = cmdline_charsize(i); -#ifdef FEAT_MBYTE /* Count ">" for double-wide multi-byte char that doesn't fit. */ if (has_mbyte) correct_cmdspos(i, c); -#endif /* If the cmdline doesn't fit, show cursor on last visible char. * Don't move the cursor itself, so we can still append. */ if ((ccline.cmdspos += c) >= m) @@ -2699,14 +2669,11 @@ set_cmdspos_cursor(void) ccline.cmdspos -= c; break; } -#ifdef FEAT_MBYTE if (has_mbyte) 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 * 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++; } -#endif /* * Get an Ex command line for the ":" command. @@ -2849,7 +2815,6 @@ getexmodeline( { if (line_ga.ga_len > 0) { -#ifdef FEAT_MBYTE if (has_mbyte) { p = (char_u *)line_ga.ga_data; @@ -2858,7 +2823,6 @@ getexmodeline( line_ga.ga_len -= len; } else -#endif --line_ga.ga_len; goto redraw; } @@ -2962,12 +2926,10 @@ redraw: if (IS_SPECIAL(c1)) c1 = '?'; -#ifdef FEAT_MBYTE if (has_mbyte) len = (*mb_char2bytes)(c1, (char_u *)line_ga.ga_data + line_ga.ga_len); else -#endif { len = 1; ((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) return MAXCOL; -# ifdef FEAT_MBYTE if (has_mbyte) { colnr_T col; @@ -3082,7 +3043,6 @@ cmdline_getvcol_cursor(void) return col; } else -# endif return ccline.cmdpos; } #endif @@ -3111,7 +3071,6 @@ redrawcmd_preedit(void) old_col = msg_col; cmdspos = ((ccline.cmdfirstc != NUL) ? 1 : 0) + ccline.cmdindent; -# ifdef FEAT_MBYTE if (has_mbyte) { for (col = 0; col < preedit_start_col @@ -3122,7 +3081,6 @@ redrawcmd_preedit(void) } } else -# endif { cmdspos += preedit_start_col; cmdpos += preedit_start_col; @@ -3142,11 +3100,9 @@ redrawcmd_preedit(void) if (char_attr < 0) break; /* end of preedit string */ -# ifdef FEAT_MBYTE if (has_mbyte) char_len = (*mb_ptr2len)(ccline.cmdbuff + cmdpos); else -# endif char_len = 1; 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) { msg_putchar('*'); -# ifdef FEAT_MBYTE if (has_mbyte) i += (*mb_ptr2len)(ccline.cmdbuff + start + i) - 1; -# endif } else #endif @@ -3382,11 +3336,9 @@ unputcmdline(void) msg_no_more = TRUE; if (ccline.cmdlen == ccline.cmdpos) msg_putchar(' '); -#ifdef FEAT_MBYTE else if (has_mbyte) draw_cmdline(ccline.cmdpos, (*mb_ptr2len)(ccline.cmdbuff + ccline.cmdpos)); -#endif else draw_cmdline(ccline.cmdpos, 1); msg_no_more = FALSE; @@ -3429,7 +3381,6 @@ put_on_cmdline(char_u *str, int len, int } else { -#ifdef FEAT_MBYTE if (has_mbyte) { /* Count nr of characters in the new string. */ @@ -3450,15 +3401,12 @@ put_on_cmdline(char_u *str, int len, int else ccline.cmdlen = ccline.cmdpos + len; } - else -#endif - if (ccline.cmdpos + len > ccline.cmdlen) + else if (ccline.cmdpos + len > ccline.cmdlen) ccline.cmdlen = ccline.cmdpos + len; } mch_memmove(ccline.cmdbuff + ccline.cmdpos, str, (size_t)len); ccline.cmdbuff[ccline.cmdlen] = NUL; -#ifdef FEAT_MBYTE if (enc_utf8) { /* When the inserted text starts with a composing character, @@ -3474,7 +3422,7 @@ put_on_cmdline(char_u *str, int len, int len += i; c = utf_ptr2char(ccline.cmdbuff + ccline.cmdpos); } -# ifdef FEAT_ARABIC +#ifdef FEAT_ARABIC if (i == 0 && ccline.cmdpos > 0 && arabic_maycombine(c)) { /* Check the previous character for Arabic combining pair. */ @@ -3489,7 +3437,7 @@ put_on_cmdline(char_u *str, int len, int else i = 0; } -# endif +#endif if (i != 0) { /* Also backup the cursor position. */ @@ -3503,7 +3451,6 @@ put_on_cmdline(char_u *str, int len, int } } } -#endif if (redraw && !cmd_silent) { @@ -3535,17 +3482,15 @@ put_on_cmdline(char_u *str, int len, int for (i = 0; i < len; ++i) { c = cmdline_charsize(ccline.cmdpos); -#ifdef FEAT_MBYTE /* count ">" for a double-wide char that doesn't fit. */ if (has_mbyte) correct_cmdspos(ccline.cmdpos, c); -#endif /* Stop cursor at the end of the screen, but do increment the * insert position, so that entering a very long command * works, even though you can't see it. */ if (ccline.cmdspos + c < m) ccline.cmdspos += c; -#ifdef FEAT_MBYTE + if (has_mbyte) { c = (*mb_ptr2len)(ccline.cmdbuff + ccline.cmdpos) - 1; @@ -3554,7 +3499,6 @@ put_on_cmdline(char_u *str, int len, int ccline.cmdpos += c; i += c; } -#endif ++ccline.cmdpos; } } @@ -3654,7 +3598,6 @@ cmdline_paste( /* Locate start of last word in the cmd buffer. */ for (w = ccline.cmdbuff + ccline.cmdpos; w > ccline.cmdbuff; ) { -#ifdef FEAT_MBYTE if (has_mbyte) { len = (*mb_head_off)(ccline.cmdbuff, w - 1) + 1; @@ -3663,7 +3606,6 @@ cmdline_paste( w -= len; } else -#endif { if (!vim_iswordc(w[-1])) break; @@ -3703,11 +3645,9 @@ cmdline_paste_str(char_u *s, int literal cv = *s; if (cv == Ctrl_V && s[1]) ++s; -#ifdef FEAT_MBYTE if (has_mbyte) c = mb_cptr2char_adv(&s); else -#endif c = *s++; if (cv == Ctrl_V || c == ESC || c == Ctrl_C || c == CAR || c == NL || c == Ctrl_L @@ -4237,22 +4177,18 @@ ExpandOne( for (len = 0; xp->xp_files[0][len]; len += mb_len) { -#ifdef FEAT_MBYTE if (has_mbyte) { mb_len = (*mb_ptr2len)(&xp->xp_files[0][len]); c0 =(* mb_ptr2char)(&xp->xp_files[0][len]); } else -#endif c0 = xp->xp_files[0][len]; for (i = 1; i < xp->xp_numfiles; ++i) { -#ifdef FEAT_MBYTE if (has_mbyte) ci =(* mb_ptr2char)(&xp->xp_files[i][len]); else -#endif ci = xp->xp_files[i][len]; if (p_fic && (xp->xp_context == EXPAND_DIRECTORIES || xp->xp_context == EXPAND_FILES diff --git a/src/fileio.c b/src/fileio.c --- a/src/fileio.c +++ b/src/fileio.c @@ -27,11 +27,9 @@ /* Is there any system that doesn't have access()? */ #define USE_MCH_ACCESS -#ifdef FEAT_MBYTE 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); -# endif #endif #ifdef FEAT_VIMINFO 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 au_find_group(char_u *name); -# define AUGROUP_DEFAULT -1 /* default autocmd group */ -# define AUGROUP_ERROR -2 /* erroneous autocmd group */ -# define AUGROUP_ALL -3 /* all autocmd groups */ - -#if defined(FEAT_CRYPT) || defined(FEAT_MBYTE) -# define HAS_BW_FLAGS -# define FIO_LATIN1 0x01 /* convert Latin1 */ -# define FIO_UTF8 0x02 /* convert UTF-8 */ -# define FIO_UCS2 0x04 /* convert UCS-2 */ -# define FIO_UCS4 0x08 /* convert UCS-4 */ -# define FIO_UTF16 0x10 /* convert UTF-16 */ -# ifdef WIN3264 -# define FIO_CODEPAGE 0x20 /* convert MS-Windows codepage */ -# 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 */ -# 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 +#define AUGROUP_DEFAULT -1 /* default autocmd group */ +#define AUGROUP_ERROR -2 /* erroneous autocmd group */ +#define AUGROUP_ALL -3 /* all autocmd groups */ + +#define HAS_BW_FLAGS +#define FIO_LATIN1 0x01 /* convert Latin1 */ +#define FIO_UTF8 0x02 /* convert UTF-8 */ +#define FIO_UCS2 0x04 /* convert UCS-2 */ +#define FIO_UCS4 0x08 /* convert UCS-4 */ +#define FIO_UTF16 0x10 /* convert UTF-16 */ +#ifdef WIN3264 +# define FIO_CODEPAGE 0x20 /* convert MS-Windows codepage */ +# 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 */ +#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 * for the next call. The value is guessed... */ @@ -95,7 +91,6 @@ struct bw_info #ifdef FEAT_CRYPT buf_T *bw_buffer; /* buffer being written */ #endif -#ifdef FEAT_MBYTE char_u bw_rest[CONV_RESTLEN]; /* not converted bytes */ int bw_restlen; /* nr of bytes in bw_rest[] */ int bw_first; /* first write call */ @@ -104,27 +99,24 @@ struct bw_info int bw_conv_error; /* set for conversion error */ linenr_T bw_conv_error_lnum; /* first line with error or zero */ 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 */ -# endif #endif }; 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 int ucs2bytes(unsigned c, char_u **pp, int flags); static int need_conversion(char_u *fenc); static int get_fio_flags(char_u *ptr); 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); -# ifdef WIN3264 +#ifdef WIN3264 static int get_win_fio_flags(char_u *ptr); -# endif -# ifdef MACOS_CONVERT +#endif +#ifdef MACOS_CONVERT static int get_mac_fio_flags(char_u *ptr); -# endif #endif static char *e_auchangedbuf = N_("E812: Autocommands changed buffer or buffer name"); @@ -265,7 +257,6 @@ readfile( int try_dos; int try_unix; int file_rewind = FALSE; -#ifdef FEAT_MBYTE int can_retry; linenr_T conv_error = 0; /* line nr with conversion error */ 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 */ int advance_fenc = FALSE; long real_size = 0; -# ifdef USE_ICONV +#ifdef USE_ICONV 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 'charconvert' next */ -# endif # endif +#endif int converted = FALSE; /* TRUE if conversion done */ int notconverted = FALSE; /* TRUE if conversion wanted but it wasn't possible */ char_u conv_rest[CONV_RESTLEN]; int conv_restlen = 0; /* nr of bytes in conv_rest[] */ -#endif buf_T *old_curbuf; char_u *old_b_ffname; char_u *old_b_fname; @@ -609,11 +599,9 @@ readfile( * edited before and deleted. Get the old marks. */ check_marks_read(); #endif -#ifdef FEAT_MBYTE /* Set forced 'fileencoding'. */ if (eap != NULL) set_forced_fenc(eap); -#endif apply_autocmds_exarg(EVENT_BUFNEWFILE, sfname, sfname, FALSE, curbuf, eap); /* remember the current fileformat */ @@ -658,10 +646,8 @@ readfile( curbuf->b_p_eol = TRUE; curbuf->b_start_eol = TRUE; } -#ifdef FEAT_MBYTE curbuf->b_p_bomb = FALSE; curbuf->b_start_bomb = FALSE; -#endif } /* 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; -#ifdef FEAT_MBYTE /* "++bad=" argument. */ if (eap != NULL && eap->bad_char != 0) { @@ -926,7 +911,6 @@ readfile( fenc = next_fenc(&fenc_next); fenc_alloced = TRUE; } -#endif /* * Jump back here to retry reading the file in different ways. @@ -966,14 +950,12 @@ retry: while (lnum > from) ml_delete(lnum--, FALSE); file_rewind = FALSE; -#ifdef FEAT_MBYTE if (set_options) { curbuf->b_p_bomb = FALSE; curbuf->b_start_bomb = FALSE; } conv_error = 0; -#endif } /* @@ -997,15 +979,14 @@ retry: fileformat = EOL_UNKNOWN; /* detect from file */ } -#ifdef FEAT_MBYTE -# ifdef USE_ICONV +#ifdef USE_ICONV if (iconv_fd != (iconv_t)-1) { /* aborted conversion with iconv(), close the descriptor */ iconv_close(iconv_fd); iconv_fd = (iconv_t)-1; } -# endif +#endif if (advance_fenc) { @@ -1073,49 +1054,49 @@ retry: else if (enc_utf8 || STRCMP(p_enc, "latin1") == 0) fio_flags = get_fio_flags(fenc); -# ifdef WIN3264 +#ifdef WIN3264 /* * Conversion from an MS-Windows codepage to UTF-8 or another codepage * is handled with MultiByteToWideChar(). */ if (fio_flags == 0) fio_flags = get_win_fio_flags(fenc); -# endif - -# ifdef MACOS_CONVERT +#endif + +#ifdef MACOS_CONVERT /* Conversion from Apple MacRoman to latin1 or UTF-8 */ if (fio_flags == 0) fio_flags = get_mac_fio_flags(fenc); -# endif - -# ifdef USE_ICONV +#endif + +#ifdef USE_ICONV /* * Try using iconv() if we can't convert internally. */ if (fio_flags == 0 -# ifdef FEAT_EVAL +# ifdef FEAT_EVAL && !did_iconv -# endif +# endif ) iconv_fd = (iconv_t)my_iconv_open( enc_utf8 ? (char_u *)"utf-8" : p_enc, fenc); -# endif - -# ifdef FEAT_EVAL +#endif + +#ifdef FEAT_EVAL /* * Use the 'charconvert' expression when conversion is required * and we can't do it internally or with iconv(). */ if (fio_flags == 0 && !read_stdin && !read_buffer && *p_ccv != NUL && !read_fifo -# ifdef USE_ICONV +# ifdef USE_ICONV && iconv_fd == (iconv_t)-1 -# endif +# endif ) { -# ifdef USE_ICONV +# ifdef USE_ICONV did_iconv = FALSE; -# endif +# endif /* Skip conversion when it's already done (retry for wrong * "fileformat"). */ if (tmpname == NULL) @@ -1137,12 +1118,12 @@ retry: } } else -# endif +#endif { if (fio_flags == 0 -# ifdef USE_ICONV +#ifdef USE_ICONV && iconv_fd == (iconv_t)-1 -# endif +#endif ) { /* Conversion wanted but we can't. @@ -1157,7 +1138,6 @@ retry: * another "fenc" value. It's FALSE when no other "fenc" to try, reading * stdin or fixed at a specific encoding. */ can_retry = (*fenc != NUL && !read_stdin && !read_fifo && !keep_dest_enc); -#endif if (!skip_read) { @@ -1165,9 +1145,7 @@ retry: filesize = 0; skip_count = lines_to_skip; read_count = lines_to_read; -#ifdef FEAT_MBYTE conv_restlen = 0; -#endif #ifdef FEAT_PERSISTENT_UNDO read_undo_file = (newfile && (flags & READ_KEEP_UNDO) == 0 && curbuf->b_ffname != NULL @@ -1253,7 +1231,6 @@ retry: ptr = buffer + linerest; line_start = buffer; -#ifdef FEAT_MBYTE /* May need room to translate into. * For iconv() we don't really know the required space, use a * factor ICONV_MULT. @@ -1265,11 +1242,11 @@ retry: * ucs-4 to utf-8: 4 bytes become up to 6 bytes, size must be * multiple of 4 */ real_size = (int)size; -# ifdef USE_ICONV +#ifdef USE_ICONV if (iconv_fd != (iconv_t)-1) size = size / ICONV_MULT; else -# endif +#endif if (fio_flags & FIO_LATIN1) size = size / 2; else if (fio_flags & (FIO_UCS2 | FIO_UTF16)) @@ -1278,17 +1255,15 @@ retry: size = (size * 2 / 3) & ~3; else if (fio_flags == FIO_UCSBOM) size = size / ICONV_MULT; /* worst case */ -# ifdef WIN3264 +#ifdef WIN3264 else if (fio_flags & FIO_CODEPAGE) size = size / ICONV_MULT; /* also worst case */ -# endif -# ifdef MACOS_CONVERT +#endif +#ifdef MACOS_CONVERT else if (fio_flags & FIO_MACROMAN) size = size / ICONV_MULT; /* also worst case */ -# endif -#endif - -#ifdef FEAT_MBYTE +#endif + if (conv_restlen > 0) { /* Insert unconverted bytes from previous line. */ @@ -1296,7 +1271,6 @@ retry: ptr += conv_restlen; size -= conv_restlen; } -#endif if (read_buffer) { @@ -1445,7 +1419,6 @@ retry: { if (size < 0) /* read error */ error = TRUE; -#ifdef FEAT_MBYTE else if (conv_restlen > 0) { /* @@ -1455,9 +1428,9 @@ retry: /* When we did a conversion report an error. */ if (fio_flags != 0 -# ifdef USE_ICONV +#ifdef USE_ICONV || iconv_fd != (iconv_t)-1 -# endif +#endif ) { if (can_retry) @@ -1482,9 +1455,9 @@ retry: * leave the UTF8 checking code to do it, as it * works slightly differently. */ if (bad_char_behavior != BAD_KEEP && (fio_flags != 0 -# ifdef USE_ICONV +#ifdef USE_ICONV || iconv_fd != (iconv_t)-1 -# endif +#endif )) { while (conv_restlen > 0) @@ -1494,21 +1467,19 @@ retry: } } fio_flags = 0; /* don't convert this */ -# ifdef USE_ICONV +#ifdef USE_ICONV if (iconv_fd != (iconv_t)-1) { iconv_close(iconv_fd); iconv_fd = (iconv_t)-1; } -# endif +#endif } } -#endif } } skip_read = FALSE; -#ifdef FEAT_MBYTE /* * At start of file (or after crypt magic number): Check for BOM. * Also check for a BOM for other Unicode encodings, but not after @@ -1516,11 +1487,11 @@ retry: * found. */ if ((filesize == 0 -# ifdef FEAT_CRYPT +#ifdef FEAT_CRYPT || (cryptkey != NULL && filesize == crypt_get_header_len( crypt_get_method_nr(curbuf))) -# endif +#endif ) && (fio_flags == FIO_UCSBOM || (!curbuf->b_p_bomb @@ -1574,16 +1545,14 @@ retry: ptr -= conv_restlen; size += conv_restlen; conv_restlen = 0; -#endif /* * Break here for a read error or end-of-file. */ if (size <= 0) break; -#ifdef FEAT_MBYTE - -# ifdef USE_ICONV + +#ifdef USE_ICONV if (iconv_fd != (iconv_t)-1) { /* @@ -1645,9 +1614,9 @@ retry: mch_memmove(line_start, buffer, (size_t)linerest); size = (long)((char_u *)top - ptr); } -# endif - -# ifdef WIN3264 +#endif + +#ifdef WIN3264 if (fio_flags & FIO_CODEPAGE) { char_u *src, *dst; @@ -1813,8 +1782,8 @@ retry: size = (long)(dst - ptr); } else -# endif -# ifdef MACOS_CONVERT +#endif +#ifdef MACOS_CONVERT if (fio_flags & FIO_MACROMAN) { /* @@ -1825,7 +1794,7 @@ retry: goto rewind_retry; } else -# endif +#endif if (fio_flags != 0) { int u8c; @@ -2089,11 +2058,11 @@ retry: * file is more likely than a conversion error. */ if (can_retry && !incomplete_tail) break; -# ifdef USE_ICONV +#ifdef USE_ICONV /* When we did a conversion report an error. */ if (iconv_fd != (iconv_t)-1 && conv_error == 0) conv_error = readfile_linenr(linecnt, ptr, p); -# endif +#endif /* Remember the first linenr with an illegal byte */ if (conv_error == 0 && illegal_byte == 0) illegal_byte = readfile_linenr(linecnt, ptr, p); @@ -2117,19 +2086,18 @@ retry: /* Detected a UTF-8 error. */ rewind_retry: /* 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) /* iconv() failed, try 'charconvert' */ did_iconv = TRUE; else -# endif +#endif /* use next item from 'fileencodings' */ advance_fenc = TRUE; file_rewind = TRUE; goto retry; } } -#endif /* count the number of characters (after conversion!) */ filesize += size; @@ -2371,7 +2339,6 @@ failed: * encryption was used. */ #endif -#ifdef FEAT_MBYTE /* If editing a new file: set 'fenc' for the current buffer. * Also for ":read ++edit file". */ if (set_options) @@ -2379,13 +2346,12 @@ failed: OPT_FREE|OPT_LOCAL, 0); if (fenc_alloced) vim_free(fenc); -# ifdef USE_ICONV +#ifdef USE_ICONV if (iconv_fd != (iconv_t)-1) { iconv_close(iconv_fd); iconv_fd = (iconv_t)-1; } -# endif #endif if (!read_buffer && !read_stdin) @@ -2409,13 +2375,11 @@ failed: } #endif -#ifdef FEAT_MBYTE if (tmpname != NULL) { mch_remove(tmpname); /* delete converted file */ vim_free(tmpname); } -#endif --no_wait_return; /* may wait for return now */ /* @@ -2528,7 +2492,6 @@ failed: STRCAT(IObuff, _("[long lines split]")); c = TRUE; } -#ifdef FEAT_MBYTE if (notconverted) { STRCAT(IObuff, _("[NOT converted]")); @@ -2539,7 +2502,6 @@ failed: STRCAT(IObuff, _("[converted]")); c = TRUE; } -#endif #ifdef FEAT_CRYPT if (cryptkey != NULL) { @@ -2547,7 +2509,6 @@ failed: c = TRUE; } #endif -#ifdef FEAT_MBYTE if (conv_error != 0) { sprintf((char *)IObuff + STRLEN(IObuff), @@ -2560,9 +2521,7 @@ failed: _("[ILLEGAL BYTE in line %ld]"), (long)illegal_byte); c = TRUE; } - else -#endif - if (error) + else if (error) { STRCAT(IObuff, _("[READ ERRORS]")); c = TRUE; @@ -2601,11 +2560,8 @@ failed: /* with errors writing the file requires ":w!" */ if (newfile && (error -#ifdef FEAT_MBYTE || conv_error != 0 - || (illegal_byte > 0 && bad_char_behavior != BAD_KEEP) -#endif - )) + || (illegal_byte > 0 && bad_char_behavior != BAD_KEEP))) curbuf->b_p_ro = TRUE; u_clearline(); /* cannot use "U" command after adding lines */ @@ -2745,8 +2701,6 @@ is_dev_fd_file(char_u *fname) } #endif -#ifdef FEAT_MBYTE - /* * From the current line count and characters read after that, estimate the * line number where we are now. @@ -2767,7 +2721,6 @@ readfile_linenr( ++lnum; return lnum; } -#endif /* * Fill "*eap" to force the 'fileencoding', 'fileformat' and 'binary to be @@ -2777,21 +2730,13 @@ readfile_linenr( int prep_exarg(exarg_T *eap, buf_T *buf) { - eap->cmd = alloc(15 -#ifdef FEAT_MBYTE - + (unsigned)STRLEN(buf->b_p_fenc) -#endif - ); + eap->cmd = alloc(15 + (unsigned)STRLEN(buf->b_p_fenc)); if (eap->cmd == NULL) return FAIL; -#ifdef FEAT_MBYTE sprintf((char *)eap->cmd, "e ++enc=%s", buf->b_p_fenc); eap->force_enc = 8; eap->bad_char = buf->b_bad_char; -#else - sprintf((char *)eap->cmd, "e"); -#endif eap->force_ff = *buf->b_p_ff; eap->force_bin = buf->b_p_bin ? FORCE_BIN : FORCE_NOBIN; @@ -2825,7 +2770,6 @@ set_file_options(int set_options, exarg_ } } -#if defined(FEAT_MBYTE) || defined(PROTO) /* * Set forced 'fileencoding'. */ @@ -2886,7 +2830,7 @@ next_fenc(char_u **pp) return r; } -# ifdef FEAT_EVAL +#ifdef FEAT_EVAL /* * Convert a file with the 'charconvert' expression. * This closes the file which is to be read, converts it and opens the @@ -2937,9 +2881,8 @@ readfile_charconvert( return tmpname; } -# endif - -#endif +#endif + #ifdef FEAT_VIMINFO /* @@ -3176,12 +3119,10 @@ buf_write( int fileformat; int write_bin; struct bw_info write_info; /* info for buf_write_bytes() */ -#ifdef FEAT_MBYTE int converted = FALSE; int notconverted = FALSE; char_u *fenc; /* effective 'fileencoding' */ char_u *fenc_tofree = NULL; /* allocated "fenc" */ -#endif #ifdef HAS_BW_FLAGS int wb_flags = 0; #endif @@ -3219,15 +3160,13 @@ buf_write( return FAIL; } -#ifdef FEAT_MBYTE /* must init bw_conv_buf and bw_iconv_fd before jumping to "fail" */ write_info.bw_conv_buf = NULL; write_info.bw_conv_error = FALSE; write_info.bw_conv_error_lnum = 0; write_info.bw_restlen = 0; -# ifdef USE_ICONV +#ifdef USE_ICONV write_info.bw_iconv_fd = (iconv_t)-1; -# endif #endif #ifdef FEAT_CRYPT write_info.bw_buffer = buf; @@ -4227,7 +4166,6 @@ buf_write( * multi-byte conversion. */ wfname = fname; -#ifdef FEAT_MBYTE /* Check for forced 'fileencoding' from "++opt=val" argument. */ 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) { /* 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) end = 0; } -# endif - -# ifdef MACOS_CONVERT +#endif + +#ifdef MACOS_CONVERT if (converted && wb_flags == 0 && (wb_flags = get_mac_fio_flags(fenc)) != 0) { write_info.bw_conv_buflen = bufsize * 3; @@ -4286,12 +4224,12 @@ buf_write( if (write_info.bw_conv_buf == NULL) end = 0; } -# endif - -# if defined(FEAT_EVAL) || defined(USE_ICONV) +#endif + +#if defined(FEAT_EVAL) || defined(USE_ICONV) if (converted && wb_flags == 0) { -# ifdef USE_ICONV +# ifdef USE_ICONV /* * Use iconv() conversion when conversion is needed and it's not done * internally. @@ -4308,12 +4246,12 @@ buf_write( end = 0; write_info.bw_first = TRUE; } -# ifdef FEAT_EVAL +# ifdef FEAT_EVAL else -# endif # endif - -# ifdef FEAT_EVAL +# endif + +# ifdef FEAT_EVAL /* * When the file needs to be converted with 'charconvert' after * writing, write to a temp file instead and let the conversion @@ -4328,16 +4266,16 @@ buf_write( goto restore_backup; } } -# endif - } # endif + } +#endif if (converted && wb_flags == 0 -# ifdef USE_ICONV +#ifdef USE_ICONV && write_info.bw_iconv_fd == (iconv_t)-1 -# endif -# ifdef FEAT_EVAL +# endif +# ifdef FEAT_EVAL && wfname == fname -# endif +# endif ) { if (!forceit) @@ -4347,7 +4285,6 @@ buf_write( } notconverted = TRUE; } -#endif /* * 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 * failure. */ -#ifdef FEAT_MBYTE if (!converted || dobackup) -#endif checking_conversion = FALSE; if (checking_conversion) @@ -4477,10 +4412,8 @@ restore_backup: end = 0; } -#ifdef FEAT_MBYTE if (wfname != fname) vim_free(wfname); -#endif goto fail; } write_info.bw_fd = fd; @@ -4563,7 +4496,6 @@ restore_backup: else write_bin = buf->b_p_bin; -#ifdef FEAT_MBYTE /* * The BOM is written just after the encryption magic number. * Skip it when appending and the file already existed, the BOM only @@ -4583,7 +4515,6 @@ restore_backup: } } write_info.bw_start_lnum = start; -#endif #ifdef FEAT_PERSISTENT_UNDO write_undo_file = (buf->b_p_udf @@ -4635,9 +4566,7 @@ restore_backup: nchars += bufsize; s = buffer; len = 0; -#ifdef FEAT_MBYTE write_info.bw_start_lnum = lnum; -#endif } /* write failed or last line has no EOL: stop here */ if (end == 0 @@ -4841,7 +4770,7 @@ restore_backup: } #endif -#if defined(FEAT_MBYTE) && defined(FEAT_EVAL) +#if defined(FEAT_EVAL) if (wfname != fname) { /* @@ -4870,7 +4799,6 @@ restore_backup: */ if (errmsg == NULL) { -#ifdef FEAT_MBYTE if (write_info.bw_conv_error) { if (write_info.bw_conv_error_lnum == 0) @@ -4883,12 +4811,10 @@ restore_backup: (long)write_info.bw_conv_error_lnum); } } + else if (got_int) + errmsg = (char_u *)_(e_interr); else -#endif - if (got_int) - errmsg = (char_u *)_(e_interr); - else - errmsg = (char_u *)_("E514: write error (file system full?)"); + 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 */ c = FALSE; -#ifdef FEAT_MBYTE if (write_info.bw_conv_error) { STRCAT(IObuff, _(" CONVERSION ERROR")); @@ -4972,7 +4897,6 @@ restore_backup: STRCAT(IObuff, _("[converted]")); c = TRUE; } -#endif if (device) { STRCAT(IObuff, _("[Device]")); @@ -5013,11 +4937,8 @@ restore_backup: /* When written everything correctly: reset 'modified'. Unless not * writing to the original file and '+' is not in 'cpoptions'. */ if (reset_changed && whole && !append -#ifdef FEAT_MBYTE && !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); /* b:changedtick is always incremented in unchanged() but that @@ -5113,16 +5034,14 @@ nofail: vim_free(backup); if (buffer != smallbuf) vim_free(buffer); -#ifdef FEAT_MBYTE vim_free(fenc_tofree); vim_free(write_info.bw_conv_buf); -# ifdef USE_ICONV +#ifdef USE_ICONV if (write_info.bw_iconv_fd != (iconv_t)-1) { iconv_close(write_info.bw_iconv_fd); write_info.bw_iconv_fd = (iconv_t)-1; } -# endif #endif #ifdef HAVE_ACL mch_free_acl(acl); @@ -5411,7 +5330,6 @@ buf_write_bytes(struct bw_info *ip) int flags = ip->bw_flags; /* extra flags */ #endif -#ifdef FEAT_MBYTE /* * 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) { /* @@ -5617,7 +5535,7 @@ buf_write_bytes(struct bw_info *ip) fromlen = to - ip->bw_conv_buf; 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) { /* 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); } else -#endif +# endif { /* Convert from UCS-2 to the codepage, using the remainder of * the conversion buffer. If the conversion uses the default @@ -5653,9 +5571,9 @@ buf_write_bytes(struct bw_info *ip) } } } -# endif - -# ifdef MACOS_CONVERT +#endif + +#ifdef MACOS_CONVERT else if (flags & FIO_MACROMAN) { /* @@ -5689,9 +5607,9 @@ buf_write_bytes(struct bw_info *ip) } buf = ip->bw_conv_buf; } -# endif - -# ifdef USE_ICONV +#endif + +#ifdef USE_ICONV if (ip->bw_iconv_fd != (iconv_t)-1) { const char *from; @@ -5759,9 +5677,8 @@ buf_write_bytes(struct bw_info *ip) buf = ip->bw_conv_buf; len = (int)((char_u *)to - ip->bw_conv_buf); } -# endif - } -#endif /* FEAT_MBYTE */ +#endif + } if (ip->bw_fd < 0) /* 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; } -#ifdef FEAT_MBYTE /* * Convert a Unicode character to bytes. * 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); return (int)(p - buf); } -#endif /* * 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)) return; for (p = fname; *p != NUL; ++p) -# ifdef FEAT_MBYTE /* The Big5 encoding can have '\' in the trail byte. */ if (enc_dbcs != 0 && (*mb_ptr2len)(p) > 1) ++p; - else -# endif - if (*p == '\\') + else if (*p == '\\') *p = '/'; } #endif @@ -10340,13 +10252,11 @@ file_pat_to_reg_pat( #endif default: size++; -# ifdef FEAT_MBYTE if (enc_dbcs != 0 && (*mb_ptr2len)(p) > 1) { ++p; ++size; } -# endif break; } } @@ -10479,12 +10389,9 @@ file_pat_to_reg_pat( reg_pat[i++] = ','; break; default: -# ifdef FEAT_MBYTE if (enc_dbcs != 0 && (*mb_ptr2len)(p) > 1) reg_pat[i++] = *p++; - else -# endif - if (allow_dirs != NULL && vim_ispathsep(*p)) + else if (allow_dirs != NULL && vim_ispathsep(*p)) *allow_dirs = TRUE; reg_pat[i++] = *p; break; diff --git a/src/fold.c b/src/fold.c --- a/src/fold.c +++ b/src/fold.c @@ -1057,11 +1057,9 @@ foldAdjustVisual(void) end->col = (colnr_T)STRLEN(ptr); if (end->col > 0 && *p_sel == 'o') --end->col; -#ifdef FEAT_MBYTE /* prevent cursor from moving on the trail byte */ if (has_mbyte) mb_adjust_cursor(); -#endif } } @@ -1946,7 +1944,6 @@ get_foldtext( * replace a TAB with a space. */ for (p = text; *p != NUL; ++p) { -# ifdef FEAT_MBYTE int len; if (has_mbyte && (len = (*mb_ptr2len)(p)) > 1) @@ -1956,7 +1953,6 @@ get_foldtext( p += len - 1; } else -# endif if (*p == TAB) *p = ' '; else if (ptr2cells(p) > 1) diff --git a/src/gui.c b/src/gui.c --- a/src/gui.c +++ b/src/gui.c @@ -13,7 +13,7 @@ /* Structure containing all the GUI information */ gui_T gui; -#if defined(FEAT_MBYTE) && !defined(FEAT_GUI_GTK) +#if !defined(FEAT_GUI_GTK) static void set_guifontwide(char_u *font_name); #endif static void gui_check_pos(void); @@ -397,13 +397,11 @@ gui_init_check(void) gui.fontset = NOFONTSET; # endif #endif -#ifdef FEAT_MBYTE gui.wide_font = NOFONT; -# ifndef FEAT_GUI_GTK +#ifndef FEAT_GUI_GTK gui.wide_bold_font = NOFONT; gui.wide_ital_font = NOFONT; gui.wide_boldital_font = NOFONT; -# endif #endif #ifdef FEAT_MENU @@ -652,10 +650,8 @@ gui_init(void) emsg(_("E665: Cannot start GUI, no valid font found")); goto error2; } -#ifdef FEAT_MBYTE if (gui_get_wide_font() == FAIL) emsg(_("E231: 'guifontwide' invalid")); -#endif gui.num_cols = Columns; gui.num_rows = Rows; @@ -874,7 +870,7 @@ gui_init_font(char_u *font_list, int fon * longer be used! */ 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 * similar double-width font. */ if ((p_guifontwide == NULL || *p_guifontwide == NUL) @@ -916,8 +912,7 @@ gui_init_font(char_u *font_list, int fon 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". */ @@ -964,7 +959,7 @@ set_guifontwide(char_u *name) } } } -# endif /* !FEAT_GUI_GTK */ +#endif /* !FEAT_GUI_GTK */ /* * Get the font for 'guifontwide'. @@ -995,7 +990,7 @@ gui_get_wide_font(void) } gui_mch_free_font(gui.wide_font); -# ifdef FEAT_GUI_GTK +#ifdef FEAT_GUI_GTK /* Avoid unnecessary overhead if 'guifontwide' is equal to 'guifont'. */ if (font != NOFONT && gui.norm_font != NOFONT && pango_font_description_equal(font, gui.norm_font)) @@ -1004,19 +999,18 @@ gui_get_wide_font(void) gui_mch_free_font(font); } else -# endif +#endif gui.wide_font = font; -# ifdef FEAT_GUI_MSWIN +#ifdef FEAT_GUI_MSWIN gui_mch_wide_font_changed(); -# else +#else /* * TODO: setup wide_bold_font, wide_ital_font and wide_boldital_font to * support those fonts for 'guifontwide'. */ -# endif +#endif return OK; } -#endif void gui_set_cursor(int row, int col) @@ -1258,7 +1252,7 @@ gui_update_cursor( } else { -#if defined(FEAT_MBYTE) && defined(FEAT_RIGHTLEFT) +#if defined(FEAT_RIGHTLEFT) int col_off = FALSE; #endif /* @@ -1275,14 +1269,13 @@ gui_update_cursor( cur_height = (gui.char_height * shape->percentage + 99) / 100; cur_width = gui.char_width; } -#ifdef FEAT_MBYTE if (has_mbyte && (*mb_off2cells)(LineOffset[gui.row] + gui.col, LineOffset[gui.row] + screen_Columns) > 1) { /* Double wide character. */ if (shape->shape != SHAPE_VER) cur_width += gui.char_width; -# ifdef FEAT_RIGHTLEFT +#ifdef FEAT_RIGHTLEFT if (CURSOR_BAR_RIGHT) { /* gui.col points to the left halve of the character but @@ -1292,11 +1285,10 @@ gui_update_cursor( col_off = TRUE; ++gui.col; } -# endif +#endif } -#endif gui_mch_draw_part_cursor(cur_width, cur_height, cbg); -#if defined(FEAT_MBYTE) && defined(FEAT_RIGHTLEFT) +#if defined(FEAT_RIGHTLEFT) if (col_off) --gui.col; #endif @@ -2023,9 +2015,7 @@ gui_may_flush(void) gui_outstr(char_u *s, int len) { int this_len; -#ifdef FEAT_MBYTE int cells; -#endif if (len == 0) return; @@ -2035,7 +2025,6 @@ gui_outstr(char_u *s, int len) while (len > 0) { -#ifdef FEAT_MBYTE if (has_mbyte) { /* 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 */ } else -#endif if (gui.col + len > Columns) this_len = Columns - gui.col; else @@ -2061,12 +2049,10 @@ gui_outstr(char_u *s, int len) 0, (guicolor_T)0, (guicolor_T)0, 0); s += this_len; len -= this_len; -#ifdef FEAT_MBYTE /* fill up for a double-width char that doesn't fit. */ if (len > 0 && gui.col < Columns) (void)gui_outstr_nowrap((char_u *)" ", 1, 0, (guicolor_T)0, (guicolor_T)0, 0); -#endif /* The cursor may wrap to the next line. */ if (gui.col >= Columns) { @@ -2089,7 +2075,6 @@ gui_screenchar( guicolor_T bg, /* colors for cursor */ int back) /* backup this many chars when using bold trick */ { -#ifdef FEAT_MBYTE char_u buf[MB_MAXBYTES + 1]; /* 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, enc_dbcs ? (*mb_ptr2len)(ScreenLines + off) : 1, flags, fg, bg, back); -#else - return gui_outstr_nowrap(ScreenLines + off, 1, flags, fg, bg, back); -#endif } #ifdef FEAT_GUI_GTK @@ -2223,9 +2205,7 @@ gui_outstr_nowrap( guicolor_T sp_color; #if !defined(FEAT_GUI_GTK) GuiFont font = NOFONT; -# ifdef FEAT_MBYTE GuiFont wide_font = NOFONT; -# endif # ifdef FEAT_XFONTSET GuiFontset fontset = NOFONTSET; # endif @@ -2316,7 +2296,6 @@ gui_outstr_nowrap( else font = gui.norm_font; -# ifdef FEAT_MBYTE /* * 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 @@ -2330,8 +2309,6 @@ gui_outstr_nowrap( wide_font = gui.wide_ital_font; else if (font == gui.norm_font && gui.wide_font) wide_font = gui.wide_font; -# endif - } # ifdef FEAT_XFONTSET if (fontset != NOFONTSET) @@ -2441,7 +2418,6 @@ gui_outstr_nowrap( /* The value returned is the length in display cells */ len = gui_gtk2_draw_string(gui.row, col, s, len, draw_flags); #else -# ifdef FEAT_MBYTE if (enc_utf8) { int start; /* index of bytes to be drawn */ @@ -2456,11 +2432,11 @@ gui_outstr_nowrap( int curr_wide = FALSE; /* use 'guifontwide' */ int prev_wide = FALSE; int wide_changed; -# ifdef WIN3264 +# ifdef WIN3264 int sep_comp = FALSE; /* Don't separate composing chars. */ -# else +# else int sep_comp = TRUE; /* Separate composing chars. */ -# endif +# endif /* Break the string at a composing character, it has to be drawn on * top of the previous character. */ @@ -2476,9 +2452,9 @@ gui_outstr_nowrap( if (!comping || sep_comp) { if (cn > 1 -# ifdef FEAT_XFONTSET +# ifdef FEAT_XFONTSET && fontset == NOFONTSET -# endif +# endif && wide_font != NOFONT) curr_wide = TRUE; else @@ -2494,15 +2470,15 @@ gui_outstr_nowrap( * a composing character. */ if (i + cl >= len || (comping && sep_comp && i > start) || wide_changed -# if defined(FEAT_GUI_X11) +# if defined(FEAT_GUI_X11) || (cn > 1 -# ifdef FEAT_XFONTSET +# ifdef FEAT_XFONTSET /* No fontset: At least draw char after wide char at * right position. */ && fontset == NOFONTSET -# endif +# endif ) -# endif +# endif ) { if ((comping && sep_comp) || wide_changed) @@ -2529,29 +2505,29 @@ gui_outstr_nowrap( 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 * */ if (cn > 1 && (draw_flags & DRAW_TRANSP) == 0 -# ifdef FEAT_XFONTSET +# ifdef FEAT_XFONTSET && fontset == NOFONTSET -# endif +# endif && !wide_changed) gui_mch_draw_string(gui.row, scol - 1, (char_u *)" ", 1, draw_flags); -# endif +# endif } /* Draw a composing char on top of the previous char. */ 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 */ gui_mch_draw_string(gui.row, scol, s + i, cl, draw_flags | DRAW_TRANSP); -# else +# else gui_mch_draw_string(gui.row, scol - cn, s + i, cl, draw_flags | DRAW_TRANSP); -# endif +# endif start = i + cl; } prev_wide = curr_wide; @@ -2560,17 +2536,14 @@ gui_outstr_nowrap( len = scol - col; } else -# endif { gui_mch_draw_string(gui.row, col, s, len, draw_flags); -# ifdef FEAT_MBYTE if (enc_dbcs == DBCS_JPNU) { /* Get the length in display cells, this can be different from the * number of bytes for "euc-jp". */ len = mb_string2cells(s, len); } -# endif } #endif /* !FEAT_GUI_GTK */ @@ -2697,9 +2670,7 @@ gui_redraw_block( int idx, len; int back, nback; int retval = FALSE; -#ifdef FEAT_MBYTE int orig_col1, orig_col2; -#endif /* Don't try to update when ScreenLines is not valid */ if (!screen_cleared || ScreenLines == NULL) @@ -2716,14 +2687,11 @@ gui_redraw_block( old_row = gui.row; old_col = gui.col; old_hl_mask = gui.highlight_mask; -#ifdef FEAT_MBYTE orig_col1 = col1; orig_col2 = col2; -#endif 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 * the other half. */ col1 = orig_col1; @@ -2753,12 +2721,11 @@ gui_redraw_block( msg((char *)IObuff); } } -# ifdef FEAT_GUI_GTK +#ifdef FEAT_GUI_GTK if (col2 + 1 < Columns && ScreenLines[off + col2 + 1] == 0) ++col2; -# endif +#endif } -#endif gui.col = col1; off = LineOffset[gui.row] + gui.col; len = col2 - col1 + 1; @@ -2778,7 +2745,7 @@ gui_redraw_block( { first_attr = ScreenAttrs[off]; gui.highlight_mask = first_attr; -#if defined(FEAT_MBYTE) && !defined(FEAT_GUI_GTK) +#if !defined(FEAT_GUI_GTK) if (enc_utf8 && ScreenLinesUC[off] != 0) { /* output multi-byte character separately */ @@ -2814,7 +2781,6 @@ gui_redraw_block( for (idx = 0; idx < len && ScreenAttrs[off + idx] == first_attr; idx++) { -# ifdef FEAT_MBYTE /* Stop at a multi-byte Unicode character. */ if (enc_utf8 && ScreenLinesUC[off + idx] != 0) break; @@ -2827,7 +2793,6 @@ gui_redraw_block( + off + idx) == 2) ++idx; /* skip second byte of double-byte char */ } -# endif } nback = gui_outstr_nowrap(ScreenLines + off, idx, flags, (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 row = check_row(Y_2_ROW(y)); -#ifdef FEAT_MBYTE *colp = mb_fix_col(col, row); -#else - *colp = col; -#endif return row; } diff --git a/src/gui_mac.c b/src/gui_mac.c --- a/src/gui_mac.c +++ b/src/gui_mac.c @@ -48,11 +48,7 @@ /* Vim's Scrap flavor. */ #define VIMSCRAPFLAVOR 'VIM!' -#ifdef FEAT_MBYTE -# define SCRAPTEXTFLAVOR kScrapFlavorTypeUnicode -#else -# define SCRAPTEXTFLAVOR kScrapFlavorTypeText -#endif +#define SCRAPTEXTFLAVOR kScrapFlavorTypeUnicode static EventHandlerUPP mouseWheelHandlerUPP = NULL; SInt32 gMacSystemVersion; @@ -169,9 +165,7 @@ static struct # define USE_ATSUI_DRAWING int p_macatsui_last; ATSUStyle gFontStyle; -# ifdef FEAT_MBYTE ATSUStyle gWideFontStyle; -# endif Boolean gIsFontFallbackSet; UInt32 useAntialias_cached = 0x0; #endif @@ -2035,15 +2029,11 @@ gui_mac_handle_window_activate( switch (eventKind) { case kEventWindowActivated: -# if defined(FEAT_MBYTE) im_on_window_switch(TRUE); -# endif return noErr; case kEventWindowDeactivated: -# if defined(FEAT_MBYTE) im_on_window_switch(FALSE); -# endif return noErr; } } @@ -2391,7 +2381,6 @@ gui_mac_doKeyEvent(EventRecord *theEvent } else { -#ifdef FEAT_MBYTE /* Convert characters when needed (e.g., from MacRoman to latin1). * This doesn't work for the NUL byte. */ if (input_conv.vc_type != CONV_NONE && key_char > 0) @@ -2421,7 +2410,6 @@ gui_mac_doKeyEvent(EventRecord *theEvent string[len++] = key_char; } else -#endif string[len++] = key_char; } @@ -3195,12 +3183,6 @@ gui_mch_init(void) } #endif -/* -#ifdef FEAT_MBYTE - set_option_value((char_u *)"encoding", 0L, (char_u *)"utf-8", 0); -#endif -*/ - #ifdef FEAT_GUI_TABLINE /* * Create the tabline @@ -3254,10 +3236,8 @@ gui_mac_dispose_atsui_style(void) { if (p_macatsui && gFontStyle) ATSUDisposeStyle(gFontStyle); -#ifdef FEAT_MBYTE if (p_macatsui && gWideFontStyle) ATSUDisposeStyle(gWideFontStyle); -#endif } #endif @@ -3430,13 +3410,11 @@ gui_mac_create_atsui_style(void) if (ATSUCreateStyle(&gFontStyle) != noErr) gFontStyle = NULL; } -#ifdef FEAT_MBYTE if (p_macatsui && gWideFontStyle == NULL) { if (ATSUCreateStyle(&gWideFontStyle) != noErr) gWideFontStyle = NULL; } -#endif p_macatsui_last = p_macatsui; } @@ -3622,7 +3600,6 @@ gui_mac_set_font_attributes(GuiFont font gFontStyle = NULL; } -#ifdef FEAT_MBYTE if (has_mbyte) { /* FIXME: we should use a more mbyte sensitive way to support @@ -3637,7 +3614,6 @@ gui_mac_set_font_attributes(GuiFont font gWideFontStyle = NULL; } } -#endif } } #endif @@ -3811,7 +3787,6 @@ draw_undercurl(int flags, int row, int c static void draw_string_QD(int row, int col, char_u *s, int len, int flags) { -#ifdef FEAT_MBYTE char_u *tofree = NULL; if (output_conv.vc_type != CONV_NONE) @@ -3820,7 +3795,6 @@ draw_string_QD(int row, int col, char_u if (tofree != NULL) s = tofree; } -#endif /* * On OS X, try using Quartz-style text antialiasing. @@ -3849,7 +3823,6 @@ draw_string_QD(int row, int col, char_u rc.left = FILL_X(col); rc.top = FILL_Y(row); -#ifdef FEAT_MBYTE /* Multibyte computation taken from gui_w32.c */ if (has_mbyte) { @@ -3857,8 +3830,7 @@ draw_string_QD(int row, int col, char_u rc.right = FILL_X(col + mb_string2cells(s, len)); } 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); EraseRect(&rc); } @@ -3918,9 +3890,7 @@ draw_string_QD(int row, int col, char_u if (flags & DRAW_UNDERC) draw_undercurl(flags, row, col, len); -#ifdef FEAT_MBYTE vim_free(tofree); -#endif } #ifdef USE_ATSUI_DRAWING @@ -4007,7 +3977,6 @@ draw_string_ATSUI(int row, int col, char useAntialias_cached = useAntialias; } -#ifdef FEAT_MBYTE if (has_mbyte) { int n, width_in_cell, last_width_in_cell; @@ -4069,7 +4038,6 @@ draw_string_ATSUI(int row, int col, char ATSUDisposeTextLayout(textLayout); } else -#endif { ATSUTextLayout textLayout; @@ -4225,10 +4193,8 @@ gui_mch_draw_hollow_cursor(guicolor_T co rc.left = FILL_X(gui.col); rc.top = FILL_Y(gui.row); rc.right = rc.left + gui.char_width; -#ifdef FEAT_MBYTE if (mb_lefthalve(gui.row, gui.col)) rc.right += gui.char_width; -#endif rc.bottom = rc.top + gui.char_height; gui_mch_set_fg_color(color); @@ -4705,11 +4671,7 @@ gui_mch_add_menu(vimmenu_T *menu, int id */ static long next_avail_id = 128; long menu_after_me = 0; /* Default to the end */ -#if defined(FEAT_MBYTE) CFStringRef name; -#else - char_u *name; -#endif short index; vimmenu_T *parent = menu->parent; vimmenu_T *brother = menu->next; @@ -4750,12 +4712,8 @@ gui_mch_add_menu(vimmenu_T *menu, int id * OSStatus SetMenuTitle(MenuRef, ConstStr255Param title); */ menu->submenu_id = next_avail_id; -#if defined(FEAT_MBYTE) if (CreateNewMenu(menu->submenu_id, 0, (MenuRef *)&menu->submenu_handle) == noErr) SetMenuTitleWithCFString((MenuRef)menu->submenu_handle, name); -#else - menu->submenu_handle = NewMenu(menu->submenu_id, name); -#endif next_avail_id++; } @@ -4784,21 +4742,13 @@ gui_mch_add_menu(vimmenu_T *menu, int id * to avoid special character recognition by InsertMenuItem */ InsertMenuItem(parent->submenu_handle, "\p ", idx); /* afterItem */ -#if defined(FEAT_MBYTE) SetMenuItemTextWithCFString(parent->submenu_handle, idx+1, name); -#else - SetMenuItemText(parent->submenu_handle, idx+1, name); -#endif SetItemCmd(parent->submenu_handle, idx+1, 0x1B); SetItemMark(parent->submenu_handle, idx+1, menu->submenu_id); InsertMenu(menu->submenu_handle, hierMenu); } -#if defined(FEAT_MBYTE) CFRelease(name); -#else - vim_free(name); -#endif #if 0 /* Done by Vim later on */ @@ -4812,11 +4762,7 @@ gui_mch_add_menu(vimmenu_T *menu, int id void gui_mch_add_menu_item(vimmenu_T *menu, int idx) { -#if defined(FEAT_MBYTE) CFStringRef name; -#else - char_u *name; -#endif vimmenu_T *parent = menu->parent; int menu_inserted; @@ -4912,23 +4858,14 @@ gui_mch_add_menu_item(vimmenu_T *menu, i if (!menu_inserted) InsertMenuItem(parent->submenu_handle, "\p ", idx); /* afterItem */ /* Set the menu item name. */ -#if defined(FEAT_MBYTE) SetMenuItemTextWithCFString(parent->submenu_handle, idx+1, name); -#else - SetMenuItemText(parent->submenu_handle, idx+1, name); -#endif #if 0 /* Called by Vim */ DrawMenuBar(); #endif -#if defined(FEAT_MBYTE) CFRelease(name); -#else - /* TODO: Can name be freed? */ - vim_free(name); -#endif } void @@ -6242,7 +6179,7 @@ char_u *FullPathFromFSSpec_save(FSSpec f #endif } -#if (defined(FEAT_MBYTE) && defined(USE_CARBONKEYHANDLER)) || defined(PROTO) +#if defined(USE_CARBONKEYHANDLER) || defined(PROTO) /* * Input Method Control functions. */ @@ -6391,8 +6328,7 @@ im_get_status(void) return im_is_active; } -#endif /* defined(FEAT_MBYTE) || defined(PROTO) */ - +#endif diff --git a/src/gui_photon.c b/src/gui_photon.c --- a/src/gui_photon.c +++ b/src/gui_photon.c @@ -513,13 +513,8 @@ gui_ph_handle_keyboard(PtWidget_t *widge if (special_keys[i].key_sym == 0) { ch = PhTo8859_1(key); - if (ch == -1 -#ifdef FEAT_MBYTE - || (enc_utf8 && ch > 127) -#endif - ) + if (ch == -1 || (enc_utf8 && ch > 127)) { -#ifdef FEAT_MBYTE len = PhKeyToMb(string, key); if (len > 0) { @@ -546,7 +541,6 @@ gui_ph_handle_keyboard(PtWidget_t *widge return Pt_CONSUME; } len = 0; -#endif ch = key->key_cap; if (ch < 0xff) { @@ -1074,7 +1068,6 @@ gui_ph_pane_resize(PtWidget_t *widget, v /****************************************************************************/ -#ifdef FEAT_MBYTE void gui_ph_encoding_changed(int new_encoding) { @@ -1100,7 +1093,6 @@ gui_ph_encoding_changed(int new_encoding charset_translate = PxTranslateSet(charset_translate, charset); } -#endif /****************************************************************************/ /****************************************************************************/ @@ -2141,11 +2133,7 @@ gui_mch_draw_string(int row, int col, ch if (flags & DRAW_UNDERL) PgSetUnderline(gui.norm_pixel, Pg_TRANSPARENT, 0); - if (charset_translate != NULL -#ifdef FEAT_MBYTE - && enc_utf8 == 0 -#endif - ) + if (charset_translate != NULL && enc_utf8 == 0) { int src_taken, dst_made; diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -792,6 +792,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 805, +/**/ 804, /**/ 803,