1
0
forked from aniani/vim

patch 8.1.1798: warning for unused variable in tiny version

Problem:    Warning for unused variable in tiny version. (Tony Mechelynck)
Solution:   Move inside #ifdef.  Reformat code.
This commit is contained in:
Bram Moolenaar 2019-08-03 14:59:44 +02:00
parent edd680f364
commit eda35f7127
2 changed files with 111 additions and 143 deletions

View File

@ -1910,7 +1910,7 @@ typedef enum {
/* /*
* Handle mappings in the typeahead buffer. * Handle mappings in the typeahead buffer.
* - When something was mapped, return map_result_retry for recursive mappings. * - When something was mapped, return map_result_retry for recursive mappings.
* - When nothing mapped and typeahead has a character return map_result_get. * - When nothing mapped and typeahead has a character: return map_result_get.
* - When there is no match yet, return map_result_nomatch, need to get more * - When there is no match yet, return map_result_nomatch, need to get more
* typeahead. * typeahead.
*/ */
@ -1936,16 +1936,14 @@ handle_mapping(
/* /*
* Check for a mappable key sequence. * Check for a mappable key sequence.
* Walk through one maphash[] list until we find an * Walk through one maphash[] list until we find an entry that matches.
* entry that matches.
* *
* Don't look for mappings if: * Don't look for mappings if:
* - no_mapping set: mapping disabled (e.g. for CTRL-V) * - no_mapping set: mapping disabled (e.g. for CTRL-V)
* - maphash_valid not set: no mappings present. * - maphash_valid not set: no mappings present.
* - typebuf.tb_buf[typebuf.tb_off] should not be remapped * - typebuf.tb_buf[typebuf.tb_off] should not be remapped
* - in insert or cmdline mode and 'paste' option set * - in insert or cmdline mode and 'paste' option set
* - waiting for "hit return to continue" and CR or SPACE * - waiting for "hit return to continue" and CR or SPACE typed
* typed
* - waiting for a char with --more-- * - waiting for a char with --more--
* - in Ctrl-X mode, and we get a valid char for that mode * - in Ctrl-X mode, and we get a valid char for that mode
*/ */
@ -1961,8 +1959,7 @@ handle_mapping(
&& State != ASKMORE && State != ASKMORE
&& State != CONFIRM && State != CONFIRM
#ifdef FEAT_INS_EXPAND #ifdef FEAT_INS_EXPAND
&& !((ctrl_x_mode_not_default() && !((ctrl_x_mode_not_default() && vim_is_ctrl_x_key(tb_c1))
&& vim_is_ctrl_x_key(tb_c1))
|| ((compl_cont_status & CONT_LOCAL) || ((compl_cont_status & CONT_LOCAL)
&& (tb_c1 == Ctrl_N || tb_c1 == Ctrl_P))) && (tb_c1 == Ctrl_N || tb_c1 == Ctrl_P)))
#endif #endif
@ -1973,8 +1970,7 @@ handle_mapping(
nolmaplen = 2; nolmaplen = 2;
else else
{ {
LANGMAP_ADJUST(tb_c1, LANGMAP_ADJUST(tb_c1, (State & (CMDLINE | INSERT)) == 0
(State & (CMDLINE | INSERT)) == 0
&& get_real_state() != SELECTMODE); && get_real_state() != SELECTMODE);
nolmaplen = 0; nolmaplen = 0;
} }
@ -1988,26 +1984,25 @@ handle_mapping(
mp = mp2; mp = mp2;
mp2 = NULL; mp2 = NULL;
} }
/* /*
* Loop until a partly matching mapping is found or * Loop until a partly matching mapping is found or all (local)
* all (local) mappings have been checked. * mappings have been checked.
* The longest full match is remembered in "mp_match". * The longest full match is remembered in "mp_match".
* A full match is only accepted if there is no partly * A full match is only accepted if there is no partly match, so "aa"
* match, so "aa" and "aaa" can both be mapped. * and "aaa" can both be mapped.
*/ */
mp_match = NULL; mp_match = NULL;
mp_match_len = 0; mp_match_len = 0;
for ( ; mp != NULL; for ( ; mp != NULL;
mp->m_next == NULL ? (mp = mp2, mp2 = NULL) mp->m_next == NULL ? (mp = mp2, mp2 = NULL) : (mp = mp->m_next))
: (mp = mp->m_next))
{ {
// Only consider an entry if the first character // Only consider an entry if the first character matches and it is
// matches and it is for the current state. // for the current state.
// Skip ":lmap" mappings if keys were mapped. // Skip ":lmap" mappings if keys were mapped.
if (mp->m_keys[0] == tb_c1 if (mp->m_keys[0] == tb_c1
&& (mp->m_mode & local_State) && (mp->m_mode & local_State)
&& ((mp->m_mode & LANGMAP) == 0 && ((mp->m_mode & LANGMAP) == 0 || typebuf.tb_maplen == 0))
|| typebuf.tb_maplen == 0))
{ {
#ifdef FEAT_LANGMAP #ifdef FEAT_LANGMAP
int nomap = nolmaplen; int nomap = nolmaplen;
@ -2032,10 +2027,9 @@ handle_mapping(
break; break;
} }
// Don't allow mapping the first byte(s) of a // Don't allow mapping the first byte(s) of a multi-byte char.
// multi-byte char. Happens when mapping // Happens when mapping <M-a> and then changing 'encoding'.
// <M-a> and then changing 'encoding'. Beware // Beware that 0x80 is escaped.
// that 0x80 is escaped.
{ {
char_u *p1 = mp->m_keys; char_u *p1 = mp->m_keys;
char_u *p2 = mb_unescape(&p1); char_u *p2 = mb_unescape(&p1);
@ -2049,26 +2043,23 @@ handle_mapping(
// - Full match: mlen == keylen // - Full match: mlen == keylen
// - Partly match: mlen == typebuf.tb_len // - Partly match: mlen == typebuf.tb_len
keylen = mp->m_keylen; keylen = mp->m_keylen;
if (mlen == keylen if (mlen == keylen || (mlen == typebuf.tb_len
|| (mlen == typebuf.tb_len
&& typebuf.tb_len < keylen)) && typebuf.tb_len < keylen))
{ {
char_u *s; char_u *s;
int n; int n;
// If only script-local mappings are // If only script-local mappings are allowed, check if the
// allowed, check if the mapping starts // mapping starts with K_SNR.
// with K_SNR.
s = typebuf.tb_noremap + typebuf.tb_off; s = typebuf.tb_noremap + typebuf.tb_off;
if (*s == RM_SCRIPT if (*s == RM_SCRIPT
&& (mp->m_keys[0] != K_SPECIAL && (mp->m_keys[0] != K_SPECIAL
|| mp->m_keys[1] != KS_EXTRA || mp->m_keys[1] != KS_EXTRA
|| mp->m_keys[2] || mp->m_keys[2] != (int)KE_SNR))
!= (int)KE_SNR))
continue; continue;
// If one of the typed keys cannot be // If one of the typed keys cannot be remapped, skip the
// remapped, skip the entry. // entry.
for (n = mlen; --n >= 0; ) for (n = mlen; --n >= 0; )
if (*s++ & (RM_NONE|RM_ABBR)) if (*s++ & (RM_NONE|RM_ABBR))
break; break;
@ -2093,15 +2084,14 @@ handle_mapping(
} }
} }
else else
// No match; may have to check for // No match; may have to check for termcode at next
// termcode at next character. // character.
if (max_mlen < mlen) if (max_mlen < mlen)
max_mlen = mlen; max_mlen = mlen;
} }
} }
// If no partly match found, use the longest full // If no partly match found, use the longest full match.
// match.
if (keylen != KEYLEN_PART_MAP) if (keylen != KEYLEN_PART_MAP)
{ {
mp = mp_match; mp = mp_match;
@ -2114,22 +2104,18 @@ handle_mapping(
*/ */
if (*p_pt != NUL && mp == NULL && (State & (INSERT|NORMAL))) if (*p_pt != NUL && mp == NULL && (State & (INSERT|NORMAL)))
{ {
for (mlen = 0; mlen < typebuf.tb_len && p_pt[mlen]; for (mlen = 0; mlen < typebuf.tb_len && p_pt[mlen]; ++mlen)
++mlen) if (p_pt[mlen] != typebuf.tb_buf[typebuf.tb_off + mlen])
if (p_pt[mlen] != typebuf.tb_buf[typebuf.tb_off
+ mlen])
break; break;
if (p_pt[mlen] == NUL) // match if (p_pt[mlen] == NUL) // match
{ {
// write chars to script file(s) // write chars to script file(s)
if (mlen > typebuf.tb_maplen) if (mlen > typebuf.tb_maplen)
gotchars(typebuf.tb_buf + typebuf.tb_off gotchars(typebuf.tb_buf + typebuf.tb_off + typebuf.tb_maplen,
+ typebuf.tb_maplen,
mlen - typebuf.tb_maplen); mlen - typebuf.tb_maplen);
del_typebuf(mlen, 0); // remove the chars del_typebuf(mlen, 0); // remove the chars
set_option_value((char_u *)"paste", set_option_value((char_u *)"paste", (long)!p_paste, NULL, 0);
(long)!p_paste, NULL, 0);
if (!(State & INSERT)) if (!(State & INSERT))
{ {
msg_col = 0; msg_col = 0;
@ -2147,26 +2133,22 @@ handle_mapping(
if (mlen == typebuf.tb_len) if (mlen == typebuf.tb_len)
keylen = KEYLEN_PART_KEY; keylen = KEYLEN_PART_KEY;
else if (max_mlen < mlen) else if (max_mlen < mlen)
// no match, may have to check for termcode at // no match, may have to check for termcode at next character
// next character
max_mlen = mlen + 1; max_mlen = mlen + 1;
} }
if ((mp == NULL || max_mlen >= mp_match_len) if ((mp == NULL || max_mlen >= mp_match_len) && keylen != KEYLEN_PART_MAP)
&& keylen != KEYLEN_PART_MAP)
{ {
int save_keylen = keylen; int save_keylen = keylen;
/* /*
* When no matching mapping found or found a * When no matching mapping found or found a non-matching mapping that
* non-matching mapping that matches at least what the * matches at least what the matching mapping matched:
* matching mapping matched:
* Check if we have a terminal code, when: * Check if we have a terminal code, when:
* mapping is allowed, * - mapping is allowed,
* keys have not been mapped, * - keys have not been mapped,
* and not an ESC sequence, not in insert mode or * - and not an ESC sequence, not in insert mode or p_ek is on,
* p_ek is on, * - and when not timed out,
* and when not timed out,
*/ */
if ((no_mapping == 0 || allow_keys != 0) if ((no_mapping == 0 || allow_keys != 0)
&& (typebuf.tb_maplen == 0 && (typebuf.tb_maplen == 0
@ -2177,42 +2159,38 @@ handle_mapping(
keylen = check_termcode(max_mlen + 1, keylen = check_termcode(max_mlen + 1,
NULL, 0, NULL); NULL, 0, NULL);
// If no termcode matched but 'pastetoggle' // If no termcode matched but 'pastetoggle' matched partially it's
// matched partially it's like an incomplete key // like an incomplete key sequence.
// sequence.
if (keylen == 0 && save_keylen == KEYLEN_PART_KEY) if (keylen == 0 && save_keylen == KEYLEN_PART_KEY)
keylen = KEYLEN_PART_KEY; keylen = KEYLEN_PART_KEY;
// When getting a partial match, but the last // When getting a partial match, but the last characters were not
// characters were not typed, don't wait for a // typed, don't wait for a typed character to complete the
// typed character to complete the termcode. // termcode. This helps a lot when a ":normal" command ends in an
// This helps a lot when a ":normal" command ends // ESC.
// in an ESC. if (keylen < 0 && typebuf.tb_len == typebuf.tb_maplen)
if (keylen < 0
&& typebuf.tb_len == typebuf.tb_maplen)
keylen = 0; keylen = 0;
} }
else else
keylen = 0; keylen = 0;
if (keylen == 0) // no matching terminal code if (keylen == 0) // no matching terminal code
{ {
#ifdef AMIGA // check for window bounds report #ifdef AMIGA
// check for window bounds report
if (typebuf.tb_maplen == 0 && (typebuf.tb_buf[ if (typebuf.tb_maplen == 0 && (typebuf.tb_buf[
typebuf.tb_off] & 0xff) == CSI) typebuf.tb_off] & 0xff) == CSI)
{ {
char_u *s; char_u *s;
for (s = typebuf.tb_buf + typebuf.tb_off + 1; for (s = typebuf.tb_buf + typebuf.tb_off + 1;
s < typebuf.tb_buf + typebuf.tb_off s < typebuf.tb_buf + typebuf.tb_off + typebuf.tb_len
+ typebuf.tb_len && (VIM_ISDIGIT(*s) || *s == ';' || *s == ' ');
&& (VIM_ISDIGIT(*s) || *s == ';'
|| *s == ' ');
++s) ++s)
; ;
if (*s == 'r' || *s == '|') // found one if (*s == 'r' || *s == '|') // found one
{ {
del_typebuf((int)(s + 1 - del_typebuf(
(typebuf.tb_buf + typebuf.tb_off)), 0); (int)(s + 1 - (typebuf.tb_buf + typebuf.tb_off)), 0);
// get size and redraw screen // get size and redraw screen
shell_resized(); shell_resized();
*keylenp = keylen; *keylenp = keylen;
@ -2223,10 +2201,9 @@ handle_mapping(
} }
if (keylen >= 0) if (keylen >= 0)
#endif #endif
// When there was a matching mapping and no // When there was a matching mapping and no termcode could be
// termcode could be replaced after another one, // replaced after another one, use that mapping (loop around).
// use that mapping (loop around). If there was // If there was no mapping at all use the character from the
// no mapping at all use the character from the
// typeahead buffer right here. // typeahead buffer right here.
if (mp == NULL) if (mp == NULL)
{ {
@ -2240,22 +2217,20 @@ handle_mapping(
#if defined(FEAT_GUI) && defined(FEAT_MENU) #if defined(FEAT_GUI) && defined(FEAT_MENU)
if (typebuf.tb_len >= 2 if (typebuf.tb_len >= 2
&& typebuf.tb_buf[typebuf.tb_off] == K_SPECIAL && typebuf.tb_buf[typebuf.tb_off] == K_SPECIAL
&& typebuf.tb_buf[typebuf.tb_off + 1] && typebuf.tb_buf[typebuf.tb_off + 1] == KS_MENU)
== KS_MENU)
{ {
int idx; int idx;
// Using a menu may cause a break in undo! // Using a menu may cause a break in undo! It's like using
// It's like using gotchars(), but without // gotchars(), but without recording or writing to a script
// recording or writing to a script file. // file.
may_sync_undo(); may_sync_undo();
del_typebuf(3, 0); del_typebuf(3, 0);
idx = get_menu_index(current_menu, local_State); idx = get_menu_index(current_menu, local_State);
if (idx != MENU_INDEX_INVALID) if (idx != MENU_INDEX_INVALID)
{ {
// In Select mode and a Visual mode menu // In Select mode and a Visual mode menu is used: Switch
// is used: Switch to Visual mode // to Visual mode temporarily. Append K_SELECT to switch
// temporarily. Append K_SELECT to switch
// back to Select mode. // back to Select mode.
if (VIsual_active && VIsual_select if (VIsual_active && VIsual_select
&& (current_menu->modes & VISUAL)) && (current_menu->modes & VISUAL))
@ -2266,8 +2241,7 @@ handle_mapping(
} }
ins_typebuf(current_menu->strings[idx], ins_typebuf(current_menu->strings[idx],
current_menu->noremap[idx], current_menu->noremap[idx],
0, TRUE, 0, TRUE, current_menu->silent[idx]);
current_menu->silent[idx]);
} }
} }
#endif // FEAT_GUI && FEAT_MENU #endif // FEAT_GUI && FEAT_MENU
@ -2275,8 +2249,8 @@ handle_mapping(
return map_result_retry; // try mapping again return map_result_retry; // try mapping again
} }
// Partial match: get some more characters. When a // Partial match: get some more characters. When a matching mapping
// matching mapping was found use that one. // was found use that one.
if (mp == NULL || keylen < 0) if (mp == NULL || keylen < 0)
keylen = KEYLEN_PART_KEY; keylen = KEYLEN_PART_KEY;
else else
@ -2303,8 +2277,7 @@ handle_mapping(
// write chars to script file(s) // write chars to script file(s)
if (keylen > typebuf.tb_maplen) if (keylen > typebuf.tb_maplen)
gotchars(typebuf.tb_buf + typebuf.tb_off gotchars(typebuf.tb_buf + typebuf.tb_off + typebuf.tb_maplen,
+ typebuf.tb_maplen,
keylen - typebuf.tb_maplen); keylen - typebuf.tb_maplen);
cmd_silent = (typebuf.tb_silent > 0); cmd_silent = (typebuf.tb_silent > 0);
@ -2328,23 +2301,19 @@ handle_mapping(
} }
/* /*
* In Select mode and a Visual mode mapping is used: * In Select mode and a Visual mode mapping is used: Switch to Visual
* Switch to Visual mode temporarily. Append K_SELECT * mode temporarily. Append K_SELECT to switch back to Select mode.
* to switch back to Select mode.
*/ */
if (VIsual_active && VIsual_select if (VIsual_active && VIsual_select && (mp->m_mode & VISUAL))
&& (mp->m_mode & VISUAL))
{ {
VIsual_select = FALSE; VIsual_select = FALSE;
(void)ins_typebuf(K_SELECT_STRING, REMAP_NONE, (void)ins_typebuf(K_SELECT_STRING, REMAP_NONE, 0, TRUE, FALSE);
0, TRUE, FALSE);
} }
#ifdef FEAT_EVAL #ifdef FEAT_EVAL
// Copy the values from *mp that are used, because // Copy the values from *mp that are used, because evaluating the
// evaluating the expression may invoke a function // expression may invoke a function that redefines the mapping, thereby
// that redefines the mapping, thereby making *mp // making *mp invalid.
// invalid.
save_m_expr = mp->m_expr; save_m_expr = mp->m_expr;
save_m_noremap = mp->m_noremap; save_m_noremap = mp->m_noremap;
save_m_silent = mp->m_silent; save_m_silent = mp->m_silent;
@ -2352,9 +2321,8 @@ handle_mapping(
save_m_str = NULL; // only saved when needed save_m_str = NULL; // only saved when needed
/* /*
* Handle ":map <expr>": evaluate the {rhs} as an * Handle ":map <expr>": evaluate the {rhs} as an expression. Also
* expression. Also save and restore the command line * save and restore the command line for "normal :".
* for "normal :".
*/ */
if (mp->m_expr) if (mp->m_expr)
{ {
@ -2377,11 +2345,9 @@ handle_mapping(
/* /*
* Insert the 'to' part in the typebuf.tb_buf. * Insert the 'to' part in the typebuf.tb_buf.
* If 'from' field is the same as the start of the * If 'from' field is the same as the start of the 'to' field, don't
* 'to' field, don't remap the first character (but do * remap the first character (but do allow abbreviations).
* allow abbreviations). * If m_noremap is set, don't remap the whole 'to' part.
* If m_noremap is set, don't remap the whole 'to'
* part.
*/ */
if (map_str == NULL) if (map_str == NULL)
i = FAIL; i = FAIL;
@ -2393,8 +2359,7 @@ handle_mapping(
noremap = save_m_noremap; noremap = save_m_noremap;
else if ( else if (
#ifdef FEAT_EVAL #ifdef FEAT_EVAL
STRNCMP(map_str, save_m_keys != NULL STRNCMP(map_str, save_m_keys != NULL ? save_m_keys : mp->m_keys,
? save_m_keys : mp->m_keys,
(size_t)keylen) (size_t)keylen)
#else #else
STRNCMP(map_str, mp->m_keys, (size_t)keylen) STRNCMP(map_str, mp->m_keys, (size_t)keylen)
@ -2470,7 +2435,6 @@ vgetorpeek(int advance)
for mapping to complete */ for mapping to complete */
int mapdepth = 0; /* check for recursive mapping */ int mapdepth = 0; /* check for recursive mapping */
int mode_deleted = FALSE; /* set when mode has been deleted */ int mode_deleted = FALSE; /* set when mode has been deleted */
int i;
#ifdef FEAT_CMDL_INFO #ifdef FEAT_CMDL_INFO
int new_wcol, new_wrow; int new_wcol, new_wrow;
#endif #endif
@ -2541,7 +2505,9 @@ vgetorpeek(int advance)
{ {
long wait_time; long wait_time;
int keylen = 0; int keylen = 0;
#ifdef FEAT_CMDL_INFO
int showcmd_idx;
#endif
/* /*
* ui_breakcheck() is slow, don't use it too often when * ui_breakcheck() is slow, don't use it too often when
* inside a mapping. But call it each time for typed * inside a mapping. But call it each time for typed
@ -2820,7 +2786,7 @@ vgetorpeek(int advance)
* to the user with showcmd. * to the user with showcmd.
*/ */
#ifdef FEAT_CMDL_INFO #ifdef FEAT_CMDL_INFO
i = 0; showcmd_idx = 0;
#endif #endif
c1 = 0; c1 = 0;
if (typebuf.tb_len > 0 && advance && !exmode_active) if (typebuf.tb_len > 0 && advance && !exmode_active)
@ -2846,10 +2812,10 @@ vgetorpeek(int advance)
curwin->w_wrow = new_wrow; curwin->w_wrow = new_wrow;
push_showcmd(); push_showcmd();
if (typebuf.tb_len > SHOWCMD_COLS) if (typebuf.tb_len > SHOWCMD_COLS)
i = typebuf.tb_len - SHOWCMD_COLS; showcmd_idx = typebuf.tb_len - SHOWCMD_COLS;
while (i < typebuf.tb_len) while (showcmd_idx < typebuf.tb_len)
(void)add_to_showcmd(typebuf.tb_buf[typebuf.tb_off (void)add_to_showcmd(
+ i++]); typebuf.tb_buf[typebuf.tb_off + showcmd_idx++]);
curwin->w_wcol = old_wcol; curwin->w_wcol = old_wcol;
curwin->w_wrow = old_wrow; curwin->w_wrow = old_wrow;
#endif #endif
@ -2898,7 +2864,7 @@ vgetorpeek(int advance)
wait_time); wait_time);
#ifdef FEAT_CMDL_INFO #ifdef FEAT_CMDL_INFO
if (i != 0) if (showcmd_idx != 0)
pop_showcmd(); pop_showcmd();
#endif #endif
if (c1 == 1) if (c1 == 1)

View File

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