Mercurial > vim
diff src/misc2.c @ 15597:536dd2bc5ac9 v8.1.0806
patch 8.1.0806: too many #ifdefs
commit https://github.com/vim/vim/commit/fc3abf47fbe1e426f2b676c316c81ee9ff607075
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Jan 24 15:54:21 2019 +0100
patch 8.1.0806: too many #ifdefs
Problem: Too many #ifdefs.
Solution: Graduate FEAT_MBYTE, part 2.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 24 Jan 2019 16:00:08 +0100 |
parents | d89c5b339c2a |
children | 6f1c7e9a6393 |
line wrap: on
line diff
--- a/src/misc2.c +++ b/src/misc2.c @@ -73,7 +73,7 @@ coladvance_force(colnr_T wcol) * Get the screen position of character col with a coladd in the cursor line. */ int -getviscol2(colnr_T col, colnr_T coladd) +getviscol2(colnr_T col, colnr_T coladd UNUSED) { colnr_T x; pos_T pos; @@ -320,11 +320,9 @@ coladvance2( } #endif -#ifdef FEAT_MBYTE /* prevent from moving onto a trail byte */ if (has_mbyte) mb_adjustpos(curbuf, pos); -#endif if (col < wcol) return FAIL; @@ -358,7 +356,6 @@ inc(pos_T *lp) p = ml_get_pos(lp); if (*p != NUL) /* still within line, move to next char (may be NUL) */ { -#ifdef FEAT_MBYTE if (has_mbyte) { int l = (*mb_ptr2len)(p); @@ -366,7 +363,6 @@ inc(pos_T *lp) lp->col += l; return ((p[l] != NUL) ? 0 : 2); } -#endif lp->col++; #ifdef FEAT_VIRTUALEDIT lp->coladd = 0; @@ -424,10 +420,8 @@ dec(pos_T *lp) /* past end of line */ p = ml_get(lp->lnum); lp->col = (colnr_T)STRLEN(p); -#ifdef FEAT_MBYTE if (has_mbyte) lp->col -= (*mb_head_off)(p, p + lp->col); -#endif return 0; } @@ -435,13 +429,11 @@ dec(pos_T *lp) { /* still within line */ lp->col--; -#ifdef FEAT_MBYTE if (has_mbyte) { p = ml_get(lp->lnum); lp->col -= (*mb_head_off)(p, p + lp->col); } -#endif return 0; } @@ -451,10 +443,8 @@ dec(pos_T *lp) lp->lnum--; p = ml_get(lp->lnum); lp->col = (colnr_T)STRLEN(p); -#ifdef FEAT_MBYTE if (has_mbyte) lp->col -= (*mb_head_off)(p, p + lp->col); -#endif return 1; } @@ -608,11 +598,9 @@ check_cursor_col_win(win_T *win) else { win->w_cursor.col = len - 1; -#ifdef FEAT_MBYTE /* Move the cursor to the head byte. */ if (has_mbyte) mb_adjustpos(win->w_buffer, &win->w_cursor); -#endif } } else if (win->w_cursor.col < 0) @@ -1394,9 +1382,7 @@ vim_strsave_escaped_ext( char_u *p2; char_u *escaped_string; unsigned length; -#ifdef FEAT_MBYTE int l; -#endif /* * First count the number of backslashes required. @@ -1405,14 +1391,12 @@ vim_strsave_escaped_ext( length = 1; /* count the trailing NUL */ for (p = string; *p; p++) { -#ifdef FEAT_MBYTE if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1) { length += l; /* count a multibyte char */ p += l - 1; continue; } -#endif if (vim_strchr(esc_chars, *p) != NULL || (bsl && rem_backslash(p))) ++length; /* count a backslash */ ++length; /* count an ordinary char */ @@ -1423,7 +1407,6 @@ vim_strsave_escaped_ext( p2 = escaped_string; for (p = string; *p; p++) { -#ifdef FEAT_MBYTE if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1) { mch_memmove(p2, p, (size_t)l); @@ -1431,7 +1414,6 @@ vim_strsave_escaped_ext( p += l - 1; /* skip multibyte char */ continue; } -#endif if (vim_strchr(esc_chars, *p) != NULL || (bsl && rem_backslash(p))) *p2++ = cc; *p2++ = *p; @@ -1642,7 +1624,6 @@ strup_save(char_u *orig) if (res != NULL) while (*p != NUL) { -# ifdef FEAT_MBYTE int l; if (enc_utf8) @@ -1685,7 +1666,6 @@ strup_save(char_u *orig) else if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1) p += l; /* skip multi-byte character */ else -# endif { *p = TOUPPER_LOC(*p); /* note that toupper() can be a macro */ p++; @@ -1711,7 +1691,6 @@ strlow_save(char_u *orig) if (res != NULL) while (*p != NUL) { -# ifdef FEAT_MBYTE int l; if (enc_utf8) @@ -1754,7 +1733,6 @@ strlow_save(char_u *orig) else if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1) p += l; /* skip multi-byte character */ else -# endif { *p = TOLOWER_LOC(*p); /* note that tolower() can be a macro */ p++; @@ -1943,7 +1921,6 @@ vim_strchr(char_u *string, int c) int b; p = string; -#ifdef FEAT_MBYTE if (enc_utf8 && c >= 0x80) { while (*p != NUL) @@ -1980,7 +1957,6 @@ vim_strchr(char_u *string, int c) } return NULL; } -#endif while ((b = *p) != NUL) { if (b == c) @@ -2713,11 +2689,7 @@ get_special_key_name(int c, int modifier * When not a known special key, and not a printable character, try to * extract modifiers. */ - if (c > 0 -#ifdef FEAT_MBYTE - && (*mb_char2len)(c) == 1 -#endif - ) + if (c > 0 && (*mb_char2len)(c) == 1) { if (table_idx < 0 && (!vim_isprintc(c) || (c & 0x7f) == ' ') @@ -2760,12 +2732,9 @@ get_special_key_name(int c, int modifier /* Not a special key, only modifiers, output directly */ else { -#ifdef FEAT_MBYTE if (has_mbyte && (*mb_char2len)(c) > 1) idx += (*mb_char2bytes)(c, string + idx); - else -#endif - if (vim_isprintc(c)) + else if (vim_isprintc(c)) string[idx++] = c; else { @@ -2825,10 +2794,8 @@ trans_special( dst[dlen++] = KEY2TERMCAP0(key); dst[dlen++] = KEY2TERMCAP1(key); } -#ifdef FEAT_MBYTE else if (has_mbyte && !keycode) dlen += (*mb_char2bytes)(key, dst + dlen); -#endif else if (keycode) dlen = (int)(add_char2buf(key, dst + dlen) - dst); else @@ -2873,11 +2840,9 @@ find_special_key( last_dash = bp; if (bp[1] != NUL) { -#ifdef FEAT_MBYTE if (has_mbyte) l = mb_ptr2len(bp + 1); else -#endif l = 1; /* Anything accepted, like <C-?>. * <C-"> or <M-"> are not special in strings as " is @@ -2935,11 +2900,9 @@ find_special_key( /* Modifier with single letter, or special key name. */ if (in_string && last_dash[1] == '\\' && last_dash[2] == '"') off = 2; -#ifdef FEAT_MBYTE if (has_mbyte) l = mb_ptr2len(last_dash + off); else -#endif l = 1; if (modifiers != 0 && last_dash[l + off] == '>') key = PTR2CHAR(last_dash + off); @@ -3028,10 +2991,7 @@ extract_modifiers(int key, int *modp) if (!(modifiers & MOD_MASK_CMD)) #endif if ((modifiers & MOD_MASK_ALT) && key < 0x80 -#ifdef FEAT_MBYTE - && !enc_dbcs /* avoid creating a lead byte */ -#endif - ) + && !enc_dbcs) // avoid creating a lead byte { key |= 0x80; modifiers &= ~MOD_MASK_ALT; /* remove the META modifier */ @@ -3377,7 +3337,6 @@ get_real_state(void) return State; } -#if defined(FEAT_MBYTE) || defined(PROTO) /* * Return TRUE if "p" points to just after a path separator. * Takes care of multi-byte characters. @@ -3389,7 +3348,6 @@ after_pathsep(char_u *b, char_u *p) return p > b && vim_ispathsep(p[-1]) && (!has_mbyte || (*mb_head_off)(b, p - 1) == 0); } -#endif /* * Return TRUE if file names "f1" and "f2" are in the same directory. @@ -6376,8 +6334,7 @@ time_to_bytes(time_T the_time, char_u *b #endif -#if (defined(FEAT_MBYTE) && defined(FEAT_QUICKFIX)) \ - || defined(FEAT_SPELL) || defined(PROTO) +#if defined(FEAT_QUICKFIX) || defined(FEAT_SPELL) || defined(PROTO) /* * Return TRUE if string "s" contains a non-ASCII character (128 or higher). * When "s" is NULL FALSE is returned.