To: vim_dev@googlegroups.com Subject: Patch 8.2.4727 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.4727 Problem: Unused code. Solution: Remove code and add #ifdefs. (Dominique Pellé, closes #10136) Files: runtime/doc/editing.txt, runtime/doc/eval.txt, runtime/doc/vim9.txt, src/errors.h, src/option.c, src/search.c, src/proto/search.pro *** ../vim-8.2.4726/runtime/doc/editing.txt 2022-02-11 15:12:06.049929457 +0000 --- runtime/doc/editing.txt 2022-04-10 11:06:17.799370659 +0100 *************** *** 1221,1227 **** If you want to always use ":confirm", set the 'confirm' option. ! *:browse* *:bro* *E338* *E614* *E615* *E616* :bro[wse] {command} Open a file selection dialog for an argument to {command}. At present this works for |:e|, |:w|, |:wall|, |:wq|, |:wqall|, |:x|, |:xall|, |:exit|, --- 1224,1230 ---- If you want to always use ":confirm", set the 'confirm' option. ! *:browse* *:bro* *E338* :bro[wse] {command} Open a file selection dialog for an argument to {command}. At present this works for |:e|, |:w|, |:wall|, |:wq|, |:wqall|, |:x|, |:xall|, |:exit|, *** ../vim-8.2.4726/runtime/doc/eval.txt 2022-02-11 15:12:06.049929457 +0000 --- runtime/doc/eval.txt 2022-04-10 11:06:17.799370659 +0100 *************** *** 180,186 **** 1.2 Function references ~ ! *Funcref* *E695* *E718* A Funcref variable is obtained with the |function()| function, the |funcref()| function or created with the lambda expression |expr-lambda|. It can be used in an expression in the place of a function name, before the parenthesis --- 181,187 ---- 1.2 Function references ~ ! *Funcref* *E695* *E718* *E1192* A Funcref variable is obtained with the |function()| function, the |funcref()| function or created with the lambda expression |expr-lambda|. It can be used in an expression in the place of a function name, before the parenthesis *** ../vim-8.2.4726/runtime/doc/vim9.txt 2022-03-30 21:12:16.447923057 +0100 --- runtime/doc/vim9.txt 2022-04-10 11:06:17.803370647 +0100 *************** *** 362,383 **** Although using a :def function probably works better. Declaring a variable with a type but without an initializer will initialize to false (for bool), empty (for string, list, dict, etc.) or zero (for number, any, etc.). This matters especially when using the "any" type, the value will ! default to the number zero. In Vim9 script `:let` cannot be used. An existing variable is assigned to without any command. The same for global, window, tab, buffer and Vim variables, because they are not really declared. Those can also be deleted with `:unlet`. ! `:lockvar` does not work on local variables. Use `:const` and `:final` instead. The `exists()` and `exists_compiled()` functions do not work on local variables or arguments. ! Variables, functions and function arguments cannot shadow previously defined or imported variables and functions in the same script file. Variables may shadow Ex commands, rename the variable if needed. --- 377,412 ---- Although using a :def function probably works better. + *E1022* *E1103* *E1130* *E1131* *E1133* + *E1134* Declaring a variable with a type but without an initializer will initialize to false (for bool), empty (for string, list, dict, etc.) or zero (for number, any, etc.). This matters especially when using the "any" type, the value will ! default to the number zero. For example, when declaring a list, items can be ! added: > ! var myList: list ! myList->add(7) ! ! Initializing a variable to a null value, e.g. `null_list`, differs from not ! initializing the variable. This throws an error: > ! var myList = null_list ! myList->add(7) # E1130: Cannot add to null list + < *E1016* *E1052* *E1066* In Vim9 script `:let` cannot be used. An existing variable is assigned to without any command. The same for global, window, tab, buffer and Vim variables, because they are not really declared. Those can also be deleted with `:unlet`. ! *E1065* ! You cannot use `:va` to declare a variable, it must be written with the full ! name `:var`. Just to make sure it is easy to read. ! *E1178* `:lockvar` does not work on local variables. Use `:const` and `:final` instead. The `exists()` and `exists_compiled()` functions do not work on local variables or arguments. ! *E1006* *E1041* *E1167* *E1168* *E1213* Variables, functions and function arguments cannot shadow previously defined or imported variables and functions in the same script file. Variables may shadow Ex commands, rename the variable if needed. *** ../vim-8.2.4726/src/errors.h 2022-04-09 21:41:22.262689600 +0100 --- src/errors.h 2022-04-10 11:10:32.186782269 +0100 *************** *** 1152,1159 **** --- 1152,1161 ---- #endif EXTERN char e_ambiguous_use_of_user_defined_command[] INIT(= N_("E464: Ambiguous use of user-defined command")); + #ifdef FEAT_EVAL EXTERN char e_ambiguous_use_of_user_defined_command_str[] INIT(= N_("E464: Ambiguous use of user-defined command: %s")); + #endif EXTERN char e_winsize_requires_two_number_arguments[] INIT(= N_("E465: :winsize requires two number arguments")); EXTERN char e_winpos_requires_two_number_arguments[] *************** *** 1554,1567 **** EXTERN char e_unknown_printer_font_str[] INIT(= N_("E613: Unknown printer font: %s")); #endif ! #ifdef FEAT_BROWSE ! EXTERN char e_vim_selfile_cant_return_to_current_directory[] ! INIT(= N_("E614: vim_SelFile: can't return to current directory")); ! EXTERN char e_vim_selfile_cant_get_current_directory[] ! INIT(= N_("E615: vim_SelFile: can't get current directory")); ! EXTERN char e_vim_selfile_cant_get_font_str[] ! INIT(= N_("E616: vim_SelFile: can't get font %s")); ! #endif #ifdef FEAT_GUI_GTK EXTERN char e_cannot_be_changed_in_gtk_GUI[] INIT(= N_("E617: Cannot be changed in the GTK GUI")); --- 1556,1564 ---- EXTERN char e_unknown_printer_font_str[] INIT(= N_("E613: Unknown printer font: %s")); #endif ! // E614 unused ! // E615 unused ! // E616 unused #ifdef FEAT_GUI_GTK EXTERN char e_cannot_be_changed_in_gtk_GUI[] INIT(= N_("E617: Cannot be changed in the GTK GUI")); *************** *** 2809,2816 **** INIT(= N_("E1084: Cannot delete Vim9 script function %s")); EXTERN char e_not_callable_type_str[] INIT(= N_("E1085: Not a callable type: %s")); ! EXTERN char e_function_reference_invalid[] ! INIT(= N_("E1086: Function reference invalid")); EXTERN char e_cannot_use_index_when_declaring_variable[] INIT(= N_("E1087: Cannot use an index when declaring a variable")); EXTERN char e_script_cannot_import_itself[] --- 2806,2812 ---- INIT(= N_("E1084: Cannot delete Vim9 script function %s")); EXTERN char e_not_callable_type_str[] INIT(= N_("E1085: Not a callable type: %s")); ! // E1086 unused EXTERN char e_cannot_use_index_when_declaring_variable[] INIT(= N_("E1087: Cannot use an index when declaring a variable")); EXTERN char e_script_cannot_import_itself[] *************** *** 3115,3130 **** --- 3111,3130 ---- INIT(= N_("E1216: digraph_setlist() argument must be a list of lists with two items")); #endif #ifdef FEAT_EVAL + # ifdef FEAT_JOB_CHANNEL EXTERN char e_chan_or_job_required_for_argument_nr[] INIT(= N_("E1217: Channel or Job required for argument %d")); EXTERN char e_job_required_for_argument_nr[] INIT(= N_("E1218: Job required for argument %d")); + # endif EXTERN char e_float_or_number_required_for_argument_nr[] INIT(= N_("E1219: Float or Number required for argument %d")); EXTERN char e_string_or_number_required_for_argument_nr[] INIT(= N_("E1220: String or Number required for argument %d")); + # ifdef FEAT_JOB_CHANNEL EXTERN char e_string_or_blob_required_for_argument_nr[] INIT(= N_("E1221: String or Blob required for argument %d")); + # endif EXTERN char e_string_or_list_required_for_argument_nr[] INIT(= N_("E1222: String or List required for argument %d")); EXTERN char e_string_or_dict_required_for_argument_nr[] *************** *** 3157,3164 **** EXTERN char e_legacy_must_be_followed_by_command[] INIT(= N_("E1234: legacy must be followed by a command")); #ifdef FEAT_EVAL ! EXTERN char e_function_reference_is_not_set[] ! INIT(= N_("E1235: Function reference is not set")); EXTERN char e_cannot_use_str_itself_it_is_imported[] INIT(= N_("E1236: Cannot use %s itself, it is imported")); #endif --- 3157,3163 ---- EXTERN char e_legacy_must_be_followed_by_command[] INIT(= N_("E1234: legacy must be followed by a command")); #ifdef FEAT_EVAL ! // E1235 unused EXTERN char e_cannot_use_str_itself_it_is_imported[] INIT(= N_("E1236: Cannot use %s itself, it is imported")); #endif *** ../vim-8.2.4726/src/option.c 2022-04-07 13:26:30.153944670 +0100 --- src/option.c 2022-04-10 11:06:17.803370647 +0100 *************** *** 4463,4468 **** --- 4463,4469 ---- return (char_u *)NULL; } + #if defined(FEAT_QUICKFIX) || defined(PROTO) int is_option_allocated(char *name) { *************** *** 4470,4475 **** --- 4471,4477 ---- return idx >= 0 && (options[idx].flags & P_ALLOCED); } + #endif /* * Translate a string like "t_xx", "" or "" to a key number. *************** *** 7179,7184 **** --- 7181,7187 ---- return buf->b_bkc_flags ? buf->b_bkc_flags : bkc_flags; } + #if defined(FEAT_LINEBREAK) || defined(PROTO) /* * Get the local or global value of 'formatlistpat'. */ *************** *** 7189,7194 **** --- 7192,7198 ---- return p_flp; return buf->b_p_flp; } + #endif /* * Get the local or global value of the 'virtualedit' flags. *** ../vim-8.2.4726/src/search.c 2022-04-04 15:16:50.742014128 +0100 --- src/search.c 2022-04-10 11:06:17.803370647 +0100 *************** *** 1377,1384 **** */ if (*p == '+' || *p == '-' || VIM_ISDIGIT(*p)) spats[0].off.line = TRUE; ! else if ((options & SEARCH_OPT) && ! (*p == 'e' || *p == 's' || *p == 'b')) { if (*p == 'e') // end spats[0].off.end = SEARCH_END; --- 1377,1384 ---- */ if (*p == '+' || *p == '-' || VIM_ISDIGIT(*p)) spats[0].off.line = TRUE; ! else if ((options & SEARCH_OPT) ! && (*p == 'e' || *p == 's' || *p == 'b')) { if (*p == 'e') // end spats[0].off.end = SEARCH_END; *************** *** 1404,1412 **** pat = p; // put pat after search command } ! if ((options & SEARCH_ECHO) && messaging() && ! !msg_silent && ! (!cmd_silent || !shortmess(SHM_SEARCHCOUNT))) { char_u *trunc; char_u off_buf[40]; --- 1404,1412 ---- pat = p; // put pat after search command } ! if ((options & SEARCH_ECHO) && messaging() ! && !msg_silent ! && (!cmd_silent || !shortmess(SHM_SEARCHCOUNT))) { char_u *trunc; char_u off_buf[40]; *************** *** 2450,2457 **** /* * If FM_BLOCKSTOP given, stop at a '{' or '}' in column 0. */ ! if (pos.col == 0 && (flags & FM_BLOCKSTOP) && ! (linep[0] == '{' || linep[0] == '}')) { if (linep[0] == findc && count == 0) // match! return &pos; --- 2450,2457 ---- /* * If FM_BLOCKSTOP given, stop at a '{' or '}' in column 0. */ ! if (pos.col == 0 && (flags & FM_BLOCKSTOP) ! && (linep[0] == '{' || linep[0] == '}')) { if (linep[0] == findc && count == 0) // match! return &pos; *************** *** 2653,2660 **** pos.col -= 2; break; } ! else if (linep[pos.col - 2] == '\\' && ! pos.col > 2 && linep[pos.col - 3] == '\'') { pos.col -= 3; break; --- 2653,2660 ---- pos.col -= 2; break; } ! else if (linep[pos.col - 2] == '\\' ! && pos.col > 2 && linep[pos.col - 3] == '\'') { pos.col -= 3; break; *************** *** 2663,2670 **** } else if (linep[pos.col + 1]) // forward search { ! if (linep[pos.col + 1] == '\\' && ! linep[pos.col + 2] && linep[pos.col + 3] == '\'') { pos.col += 3; break; --- 2663,2670 ---- } else if (linep[pos.col + 1]) // forward search { ! if (linep[pos.col + 1] == '\\' ! && linep[pos.col + 2] && linep[pos.col + 3] == '\'') { pos.col += 3; break; *************** *** 3471,3478 **** if (fullpathcmp(new_fname, files[i].name, TRUE, TRUE) & FPC_SAME) { ! if (type != CHECK_PATH && ! action == ACTION_SHOW_ALL && files[i].matched) { msg_putchar('\n'); // cursor below last one if (!got_int) // don't display if 'q' --- 3471,3479 ---- if (fullpathcmp(new_fname, files[i].name, TRUE, TRUE) & FPC_SAME) { ! if (type != CHECK_PATH ! && action == ACTION_SHOW_ALL ! && files[i].matched) { msg_putchar('\n'); // cursor below last one if (!got_int) // don't display if 'q' *************** *** 4678,4685 **** rettv.v_type = VAR_UNKNOWN; if (li->li_tv.v_type == VAR_STRING) // list of strings itemstr = li->li_tv.vval.v_string; ! else if (li->li_tv.v_type == VAR_DICT && ! (key != NULL || item_cb->cb_name != NULL)) { // For a dict, either use the specified key to lookup the string or // use the specified callback function to get the string. --- 4679,4686 ---- rettv.v_type = VAR_UNKNOWN; if (li->li_tv.v_type == VAR_STRING) // list of strings itemstr = li->li_tv.vval.v_string; ! else if (li->li_tv.v_type == VAR_DICT ! && (key != NULL || item_cb->cb_name != NULL)) { // For a dict, either use the specified key to lookup the string or // use the specified callback function to get the string. *************** *** 4786,4793 **** { if (ptrs[i].score == SCORE_NONE) break; ! if (ptrs[i].lmatchpos != NULL && ! list_append_list(l, ptrs[i].lmatchpos) == FAIL) goto done; } --- 4787,4794 ---- { if (ptrs[i].score == SCORE_NONE) break; ! if (ptrs[i].lmatchpos != NULL ! && list_append_list(l, ptrs[i].lmatchpos) == FAIL) goto done; } *************** *** 5050,5065 **** return OK; } - - /* - * Free a list of fuzzy string matches. - */ - void - fuzmatch_str_free(fuzmatch_str_T *fuzmatch, int count) - { - if (count <= 0 || fuzmatch == NULL) - return; - while (count--) - vim_free(fuzmatch[count].str); - vim_free(fuzmatch); - } --- 5051,5053 ---- *** ../vim-8.2.4726/src/proto/search.pro 2022-02-24 13:28:36.570222354 +0000 --- src/proto/search.pro 2022-04-10 11:06:17.803370647 +0100 *************** *** 42,46 **** void f_matchfuzzypos(typval_T *argvars, typval_T *rettv); int fuzzy_match_str(char_u *str, char_u *pat); int fuzzymatches_to_strmatches(fuzmatch_str_T *fuzmatch, char_u ***matches, int count, int funcsort); - void fuzmatch_str_free(fuzmatch_str_T *fuzmatch, int count); /* vim: set ft=c : */ --- 42,45 ---- *** ../vim-8.2.4726/src/version.c 2022-04-09 21:41:22.266689586 +0100 --- src/version.c 2022-04-10 11:08:49.619017093 +0100 *************** *** 748,749 **** --- 748,751 ---- { /* Add new patch number below this line */ + /**/ + 4727, /**/ -- Why I like vim: > I like VIM because, when I ask a question in this newsgroup, I get a > one-line answer. With xemacs, I get a 1Kb lisp script with bugs in it ;-) /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///