# HG changeset patch # User Bram Moolenaar # Date 1678656605 -3600 # Node ID f3987fde6deab7631085b35a3d36a96c06fc793f # Parent 204cce063401bffad302b860e822eb4f13924592 patch 9.0.1403: unused variables and functions Commit: https://github.com/vim/vim/commit/e764d1b4219e6615a04df1c3a6a5c0210a0a7dac Author: Dominique Pelle Date: Sun Mar 12 21:20:59 2023 +0000 patch 9.0.1403: unused variables and functions Problem: Unused variables and functions. Solution: Delete items and adjust #ifdefs. (Dominique Pell?, closes https://github.com/vim/vim/issues/12145) diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -2994,7 +2994,7 @@ funcref({name} [, {arglist}] [, {dict}]) Can also be used as a |method|: > GetFuncname()->funcref([arg]) < - *function()* *partial* *E700* *E922* *E923* + *function()* *partial* *E700* *E923* function({name} [, {arglist}] [, {dict}]) Return a |Funcref| variable that refers to function {name}. {name} can be the name of a user defined function or an diff --git a/runtime/doc/vim9.txt b/runtime/doc/vim9.txt --- a/runtime/doc/vim9.txt +++ b/runtime/doc/vim9.txt @@ -340,7 +340,7 @@ function, the function does not need to Variable declarations with :var, :final and :const ~ *vim9-declaration* *:var* *E1079* - *E1017* *E1020* *E1054* *E1087* *E1108* *E1124* + *E1017* *E1020* *E1054* *E1087* *E1124* Local variables need to be declared with `:var`. Local constants need to be declared with `:final` or `:const`. We refer to both as "variables" in this section. @@ -1664,8 +1664,8 @@ type, it can not be used in Vim9 script. *E1211* *E1217* *E1218* *E1219* *E1220* *E1221* *E1222* *E1223* *E1224* *E1225* *E1226* *E1227* - *E1228* *E1238* *E1250* *E1251* *E1252* *E1253* - *E1256* *E1297* *E1298* *E1301* + *E1228* *E1238* *E1250* *E1251* *E1252* *E1256* + *E1297* *E1298* *E1301* Types are checked for most builtin functions to make it easier to spot mistakes. diff --git a/src/autocmd.c b/src/autocmd.c --- a/src/autocmd.c +++ b/src/autocmd.c @@ -2519,6 +2519,7 @@ auto_next_pat( } } +#if defined(FEAT_EVAL) || defined(PROTO) /* * Get the script context where autocommand "acp" is defined. */ @@ -2527,6 +2528,7 @@ acp_script_ctx(AutoPatCmd_T *acp) { return &acp->script_ctx; } +#endif /* * Get next autocommand command. diff --git a/src/charset.c b/src/charset.c --- a/src/charset.c +++ b/src/charset.c @@ -907,6 +907,7 @@ vim_isfilec(int c) return (c >= 0x100 || (c > 0 && (g_chartab[c] & CT_FNAME_CHAR))); } +#if defined(FEAT_SPELL) || defined(PROTO) /* * Return TRUE if 'c' is a valid file-name character, including characters left * out of 'isfname' to make "gf" work, such as comma, space, '@', etc. @@ -916,6 +917,7 @@ vim_is_fname_char(int c) { return vim_isfilec(c) || c == ',' || c == ' ' || c == '@'; } +#endif /* * return TRUE if 'c' is a valid file-name character or a wildcard character diff --git a/src/errors.h b/src/errors.h --- a/src/errors.h +++ b/src/errors.h @@ -1182,8 +1182,10 @@ EXTERN char e_invalid_command[] INIT(= N_("E476: Invalid command")); EXTERN char e_invalid_command_str[] INIT(= N_("E476: Invalid command: %s")); +#ifdef FEAT_EVAL EXTERN char e_invalid_command_str_expected_str[] INIT(= N_("E476: Invalid command: %s, expected %s")); +#endif EXTERN char e_no_bang_allowed[] INIT(= N_("E477: No ! allowed")); EXTERN char e_dont_panic[] @@ -1208,8 +1210,10 @@ EXTERN char e_pattern_not_found_str[] INIT(= N_("E486: Pattern not found: %s")); EXTERN char e_argument_must_be_positive[] INIT(= N_("E487: Argument must be positive")); +#ifdef FEAT_PROP_POPUP EXTERN char e_argument_must_be_positive_str[] INIT(= N_("E487: Argument must be positive: %s")); +#endif EXTERN char e_trailing_characters[] INIT(= N_("E488: Trailing characters")); EXTERN char e_trailing_characters_str[] @@ -1370,10 +1374,12 @@ EXTERN char e_illegal_mode[] EXTERN char e_illegal_mouseshape[] INIT(= N_("E547: Illegal mouseshape")); #endif +#ifdef CURSOR_SHAPE EXTERN char e_digit_expected[] INIT(= N_("E548: Digit expected")); EXTERN char e_illegal_percentage[] INIT(= N_("E549: Illegal percentage")); +#endif #ifdef FEAT_PRINTER EXTERN char e_missing_colon_3[] INIT(= N_("E550: Missing colon")); @@ -2039,14 +2045,12 @@ EXTERN char e_id_not_found_nr[] EXTERN char e_cannot_use_percent_with_float[] // xgettext:no-c-format INIT(= N_("E804: Cannot use '%' with Float")); -#endif EXTERN char e_using_float_as_number[] INIT(= N_("E805: Using a Float as a Number")); EXTERN char e_using_float_as_string[] INIT(= N_("E806: Using a Float as a String")); EXTERN char e_expected_float_argument_for_printf[] INIT(= N_("E807: Expected Float argument for printf()")); -#if defined(FEAT_EVAL) EXTERN char e_number_or_float_required[] INIT(= N_("E808: Number or Float required")); #endif @@ -2270,8 +2274,10 @@ EXTERN char e_not_possible_to_change_sig EXTERN char e_cant_rename_viminfo_file_to_str[] INIT(= N_("E886: Can't rename viminfo file to %s!")); #endif +#if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) EXTERN char e_sorry_this_command_is_disabled_python_side_module_could_not_be_loaded[] INIT(= N_("E887: Sorry, this command is disabled, the Python's site module could not be loaded.")); +#endif EXTERN char e_nfa_regexp_cannot_repeat_str[] INIT(= N_("E888: (NFA regexp) cannot repeat %s")); #ifdef FEAT_PROP_POPUP @@ -2282,6 +2288,7 @@ EXTERN char e_number_required[] EXTERN char e_trailing_char_after_rsb_str_str[] INIT(= N_("E890: Trailing char after ']': %s]%s")); #endif +#ifdef FEAT_EVAL EXTERN char e_using_funcref_as_float[] INIT(= N_("E891: Using a Funcref as a Float")); EXTERN char e_using_string_as_float[] @@ -2290,6 +2297,7 @@ EXTERN char e_using_list_as_float[] INIT(= N_("E893: Using a List as a Float")); EXTERN char e_using_dictionary_as_float[] INIT(= N_("E894: Using a Dictionary as a Float")); +#endif #ifdef FEAT_MZSCHEME EXTERN char e_sorry_this_command_is_disabled_the_mzscheme_racket_base_module_could_not_be_loaded[] INIT(= N_("E895: Sorry, this command is disabled, the MzScheme's racket/base module could not be loaded.")); @@ -2330,9 +2338,9 @@ EXTERN char e_received_unknown_command_s EXTERN char e_not_an_open_channel[] INIT(= N_("E906: Not an open channel")); #endif +#ifdef FEAT_EVAL EXTERN char e_using_special_value_as_float[] INIT(= N_("E907: Using a special value as a Float")); -#ifdef FEAT_EVAL EXTERN char e_using_invalid_value_as_string_str[] INIT(= N_("E908: Using an invalid value as a String: %s")); EXTERN char e_cannot_index_special_variable[] @@ -2367,8 +2375,6 @@ EXTERN char e_io_file_requires_name_to_b #ifdef FEAT_EVAL EXTERN char e_invalid_callback_argument[] INIT(= N_("E921: Invalid callback argument")); -EXTERN char e_expected_dict[] - INIT(= N_("E922: Expected a dict")); EXTERN char e_second_argument_of_function_must_be_list_or_dict[] INIT(= N_("E923: Second argument of function() must be a list or a dict")); #endif @@ -2831,8 +2837,6 @@ EXTERN char e_nr_arguments_too_many[] INIT(= N_("E1106: %d arguments too many")); EXTERN char e_string_list_dict_or_blob_required[] INIT(= N_("E1107: String, List, Dict or Blob required")); -EXTERN char e_item_not_found_str[] - INIT(= N_("E1108: Item not found: %s")); EXTERN char e_list_item_nr_is_not_list[] INIT(= N_("E1109: List item %d is not a List")); EXTERN char e_list_item_nr_does_not_contain_3_numbers[] @@ -3186,8 +3190,6 @@ EXTERN char e_list_dict_blob_or_string_r INIT(= N_("E1251: List, Dictionary, Blob or String required for argument %d")); EXTERN char e_string_list_or_blob_required_for_argument_nr[] INIT(= N_("E1252: String, List or Blob required for argument %d")); -EXTERN char e_string_expected_for_argument_nr[] - INIT(= N_("E1253: String expected for argument %d")); EXTERN char e_cannot_use_script_variable_in_for_loop[] INIT(= N_("E1254: Cannot use script variable in for loop")); #endif @@ -3274,6 +3276,7 @@ EXTERN char e_could_not_clear_timeout_st INIT(= N_("E1285: Could not clear timeout: %s")); EXTERN char e_could_not_set_timeout_str[] INIT(= N_("E1286: Could not set timeout: %s")); +#ifndef HAVE_TIMER_CREATE EXTERN char e_could_not_set_handler_for_timeout_str[] INIT(= N_("E1287: Could not set handler for timeout: %s")); EXTERN char e_could_not_reset_handler_for_timeout_str[] @@ -3281,6 +3284,7 @@ EXTERN char e_could_not_reset_handler_fo EXTERN char e_could_not_check_for_pending_sigalrm_str[] INIT(= N_("E1289: Could not check for pending SIGALRM: %s")); #endif +#endif #ifdef FEAT_EVAL EXTERN char e_substitute_nesting_too_deep[] INIT(= N_("E1290: substitute nesting too deep")); diff --git a/src/ex_docmd.c b/src/ex_docmd.c --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -3569,6 +3569,7 @@ one_letter_cmd(char_u *p, cmdidx_T *idx) return FALSE; } +#if defined(FEAT_EVAL) || defined(PROTO) /* * Return TRUE if "cmd" starts with "123->", a number followed by a method * call. @@ -3580,6 +3581,7 @@ number_method(char_u *cmd) return p > cmd && (p = skipwhite(p))[0] == '-' && p[1] == '>'; } +#endif /* * Find an Ex command by its name, either built-in or user. diff --git a/src/move.c b/src/move.c --- a/src/move.c +++ b/src/move.c @@ -662,6 +662,7 @@ changed_window_setting_win(win_T *wp) redraw_win_later(wp, UPD_NOT_VALID); } +#if defined(FEAT_PROP_POPUP) || defined(PROTO) /* * Call changed_window_setting_win() for every window containing "buf". */ @@ -675,6 +676,7 @@ changed_window_setting_buf(buf_T *buf) if (wp->w_buffer == buf) changed_window_setting_win(wp); } +#endif /* * Set wp->w_topline to a certain number. @@ -744,6 +746,7 @@ changed_line_abv_curs_win(win_T *wp) |VALID_CHEIGHT|VALID_TOPLINE); } +#if defined(FEAT_PROP_POPUP) || defined(PROTO) /* * Display of line has changed for "buf", invalidate cursor position and * w_botline. @@ -759,6 +762,7 @@ changed_line_display_buf(buf_T *buf) |VALID_CROW|VALID_CHEIGHT |VALID_TOPLINE|VALID_BOTLINE|VALID_BOTLINE_AP); } +#endif /* * Make sure the value of curwin->w_botline is valid. @@ -3573,7 +3577,6 @@ do_check_cursorbind(void) int set_curswant = curwin->w_set_curswant; win_T *old_curwin = curwin; buf_T *old_curbuf = curbuf; - int restart_edit_save; int old_VIsual_select = VIsual_select; int old_VIsual_active = VIsual_active; @@ -3601,8 +3604,8 @@ do_check_cursorbind(void) // Make sure the cursor is in a valid position. Temporarily set // "restart_edit" to allow the cursor to be beyond the EOL. - restart_edit_save = restart_edit; - restart_edit = TRUE; + int restart_edit_save = restart_edit; + restart_edit = 'a'; check_cursor(); // Avoid a scroll here for the cursor position, 'scrollbind' is diff --git a/src/option.c b/src/option.c --- a/src/option.c +++ b/src/option.c @@ -5246,15 +5246,6 @@ set_option_flag(int opt_idx, long_u flag } /* - * Clear a flag for the option at 'opt_idx'. - */ - void -clear_option_flag(int opt_idx, long_u flag) -{ - options[opt_idx].flags &= ~flag; -} - -/* * Returns TRUE if the option at 'opt_idx' is a global option */ int diff --git a/src/optionstr.c b/src/optionstr.c --- a/src/optionstr.c +++ b/src/optionstr.c @@ -429,6 +429,8 @@ set_string_option_direct( # endif } +#if defined(FEAT_PROP_POPUP) || \ + (defined(FEAT_DIFF) && defined(FEAT_FOLDING)) || defined(PROTO) /* * Like set_string_option_direct(), but for a window-local option in "wp". * Blocks autocommands to avoid the old curwin becoming invalid. @@ -452,6 +454,7 @@ set_string_option_direct_in_win( curbuf = curwin->w_buffer; unblock_autocmds(); } +#endif #if defined(FEAT_PROP_POPUP) || defined(PROTO) /* diff --git a/src/os_unix.c b/src/os_unix.c --- a/src/os_unix.c +++ b/src/os_unix.c @@ -2434,6 +2434,7 @@ vim_is_iris(char_u *name) || STRCMP(name, "builtin_iris-ansi") == 0); } +#if defined(VMS) || defined(PROTO) /* * Return TRUE if "name" is a vt300-like terminal name. */ @@ -2448,6 +2449,7 @@ vim_is_vt300(char_u *name) && vim_strchr((char_u *)"12345", name[2]) != NULL) || STRCMP(name, "builtin_vt320") == 0); } +#endif /* * Insert user name in s[len]. diff --git a/src/proto/option.pro b/src/proto/option.pro --- a/src/proto/option.pro +++ b/src/proto/option.pro @@ -94,7 +94,6 @@ int get_option_value_strict(char_u *name char_u *option_iter_next(void **option, int opt_type); long_u get_option_flags(int opt_idx); void set_option_flag(int opt_idx, long_u flag); -void clear_option_flag(int opt_idx, long_u flag); int is_global_option(int opt_idx); int is_global_local_option(int opt_idx); int is_window_local_option(int opt_idx); diff --git a/src/regexp.c b/src/regexp.c --- a/src/regexp.c +++ b/src/regexp.c @@ -2948,6 +2948,7 @@ vim_regexec_string( return result > 0; } +#if defined(FEAT_SPELL) || defined(FEAT_EVAL) || defined(FEAT_X11) || defined(PROTO) /* * Note: "*prog" may be freed and changed. * Return TRUE if there is a match, FALSE if not. @@ -2968,6 +2969,7 @@ vim_regexec_prog( *prog = regmatch.regprog; return r; } +#endif /* * Note: "rmp->regprog" may be freed and changed. diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -696,6 +696,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1403, +/**/ 1402, /**/ 1401,