To: vim_dev@googlegroups.com Subject: Patch 8.2.3907 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3907 Problem: Error messages are spread out. Solution: Move error messages to errors.h. Avoid duplicates. Files: src/userfunc.c, src/ex_cmds.c, src/viminfo.c, src/errors.h, src/testdir/test_user_func.vim *** ../vim-8.2.3906/src/userfunc.c 2021-12-26 14:22:55.661931074 +0000 --- src/userfunc.c 2021-12-26 19:56:54.299520638 +0000 *************** *** 29,38 **** // item in it is still being used. static funccall_T *previous_funccal = NULL; - static char *e_funcexts = N_("E122: Function %s already exists, add ! to replace it"); static char *e_funcdict = N_("E717: Dictionary entry already exists"); static char *e_funcref = N_("E718: Funcref required"); - static char *e_nofunc = N_("E130: Unknown function: %s"); static void funccal_unref(funccall_T *fc, ufunc_T *fp, int force); static void func_clear(ufunc_T *fp, int force); --- 29,36 ---- *************** *** 83,89 **** || (p - arg == 8 && STRNCMP(arg, "lastline", 8) == 0)))) { if (!skip) ! semsg(_("E125: Illegal argument: %s"), arg); return arg; } --- 81,87 ---- || (p - arg == 8 && STRNCMP(arg, "lastline", 8) == 0)))) { if (!skip) ! semsg(_(e_illegal_argument_str), arg); return arg; } *************** *** 743,749 **** else if (eap->cmdidx == CMD_def) emsg(_(e_missing_enddef)); else ! emsg(_("E126: Missing :endfunction")); goto theend; } --- 741,747 ---- else if (eap->cmdidx == CMD_def) emsg(_(e_missing_enddef)); else ! emsg(_(e_missing_endfunction)); goto theend; } *************** *** 1785,1791 **** if (argcount == MAX_FUNC_ARGS) emsg_funcname(N_("E740: Too many arguments for function %s"), name); else ! emsg_funcname(N_(e_invalid_arguments_for_function_str), name); } while (--argcount >= 0) --- 1783,1789 ---- if (argcount == MAX_FUNC_ARGS) emsg_funcname(N_("E740: Too many arguments for function %s"), name); else ! emsg_funcname(e_invalid_arguments_for_function_str, name); } while (--argcount >= 0) *************** *** 2341,2347 **** if (fp != NULL) { // TODO: handle ! to overwrite ! semsg(_(e_funcexts), global); return FAIL; } --- 2339,2345 ---- if (fp != NULL) { // TODO: handle ! to overwrite ! semsg(_(e_function_str_already_exists_add_excl_to_replace), global); return FAIL; } *************** *** 2421,2427 **** { if (funcdepth >= p_mfd) { ! emsg(_("E132: Function call depth is higher than 'maxfuncdepth'")); return FAIL; } ++funcdepth; --- 2419,2425 ---- { if (funcdepth >= p_mfd) { ! emsg(_(e_function_call_depth_is_higher_than_macfuncdepth)); return FAIL; } ++funcdepth; *************** *** 3252,3258 **** N_("E276: Cannot use function as a method: %s"), name); break; case FCERR_DELETED: ! emsg_funcname(N_(e_func_deleted), name); break; case FCERR_TOOMANY: emsg_funcname((char *)e_too_many_arguments_for_function_str, --- 3250,3256 ---- N_("E276: Cannot use function as a method: %s"), name); break; case FCERR_DELETED: ! emsg_funcname(e_func_deleted, name); break; case FCERR_TOOMANY: emsg_funcname((char *)e_too_many_arguments_for_function_str, *************** *** 3264,3270 **** break; case FCERR_SCRIPT: emsg_funcname( ! N_(e_using_sid_not_in_script_context_str), name); break; case FCERR_DICT: emsg_funcname( --- 3262,3268 ---- break; case FCERR_SCRIPT: emsg_funcname( ! e_using_sid_not_in_script_context_str, name); break; case FCERR_DICT: emsg_funcname( *************** *** 3627,3633 **** int extra = 0; lval_T lv; int vim9script; - static char *e_function_name = N_("E129: Function name required"); if (fdp != NULL) CLEAR_POINTER(fdp); --- 3625,3630 ---- *************** *** 3655,3661 **** if (end == start) { if (!skip) ! emsg(_(e_function_name)); goto theend; } if (end == NULL || (lv.ll_tv != NULL && (lead > 2 || lv.ll_range))) --- 3652,3658 ---- if (end == start) { if (!skip) ! emsg(_(e_function_name_required)); goto theend; } if (end == NULL || (lv.ll_tv != NULL && (lead > 2 || lv.ll_range))) *************** *** 3775,3781 **** if (len <= 0) { if (!skip) ! emsg(_(e_function_name)); goto theend; } --- 3772,3778 ---- if (len <= 0) { if (!skip) ! emsg(_(e_function_name_required)); goto theend; } *************** *** 3823,3830 **** else if (!(flags & TFN_INT) && (builtin_function(lv.ll_name, len) || (in_vim9script() && *lv.ll_name == '_'))) { ! semsg(_("E128: Function name must start with a capital or \"s:\": %s"), ! start); goto theend; } if (!skip && !(flags & TFN_QUIET) && !(flags & TFN_NO_DEREF)) --- 3820,3826 ---- else if (!(flags & TFN_INT) && (builtin_function(lv.ll_name, len) || (in_vim9script() && *lv.ll_name == '_'))) { ! semsg(_(e_function_name_must_start_with_capital_or_s_str), start); goto theend; } if (!skip && !(flags & TFN_QUIET) && !(flags & TFN_NO_DEREF)) *************** *** 4171,4177 **** } } else ! emsg_funcname(N_("E123: Undefined function: %s"), eap->arg); } goto ret_free; } --- 4167,4173 ---- } } else ! emsg_funcname(e_undefined_function_str, eap->arg); } goto ret_free; } *************** *** 4184,4190 **** { if (!eap->skip) { ! semsg(_("E124: Missing '(': %s"), eap->arg); goto ret_free; } // attempt to continue by skipping some text --- 4180,4186 ---- { if (!eap->skip) { ! semsg(_(e_missing_paren_str), eap->arg); goto ret_free; } // attempt to continue by skipping some text *************** *** 4357,4363 **** if (fudi.fd_dict != NULL && fudi.fd_newkey == NULL) emsg(_(e_funcdict)); else if (name != NULL && find_func(name, is_global, NULL) != NULL) ! emsg_funcname(e_funcexts, name); } if (!eap->skip && did_emsg) --- 4353,4359 ---- if (fudi.fd_dict != NULL && fudi.fd_newkey == NULL) emsg(_(e_funcdict)); else if (name != NULL && find_func(name, is_global, NULL) != NULL) ! emsg_funcname(e_function_str_already_exists_add_excl_to_replace, name); } if (!eap->skip && did_emsg) *************** *** 4415,4428 **** if (vim9script) emsg_funcname(e_name_already_defined_str, name); else ! emsg_funcname(e_funcexts, name); goto erret; } if (fp->uf_calls > 0) { emsg_funcname( ! N_("E127: Cannot redefine function %s: It is in use"), ! name); goto erret; } if (fp->uf_refcount > 1) --- 4411,4423 ---- if (vim9script) emsg_funcname(e_name_already_defined_str, name); else ! emsg_funcname(e_function_str_already_exists_add_excl_to_replace, name); goto erret; } if (fp->uf_calls > 0) { emsg_funcname( ! e_cannot_redefine_function_str_it_is_in_use, name); goto erret; } if (fp->uf_refcount > 1) *************** *** 4900,4911 **** if (fp == NULL) { if (!eap->forceit) ! semsg(_(e_nofunc), eap->arg); return; } if (fp->uf_calls > 0) { ! semsg(_("E131: Cannot delete function %s: It is in use"), eap->arg); return; } if (fp->uf_flags & FC_VIM9) --- 4895,4906 ---- if (fp == NULL) { if (!eap->forceit) ! semsg(_(e_unknown_function_str), eap->arg); return; } if (fp->uf_calls > 0) { ! semsg(_(e_cannot_delete_function_str_it_is_in_use), eap->arg); return; } if (fp->uf_flags & FC_VIM9) *************** *** 5037,5043 **** if (current_funccal == NULL) { ! emsg(_("E133: :return not inside a function")); return; } --- 5032,5038 ---- if (current_funccal == NULL) { ! emsg(_(e_return_not_inside_function)); return; } *** ../vim-8.2.3906/src/ex_cmds.c 2021-12-24 16:46:10.915631989 +0000 --- src/ex_cmds.c 2021-12-26 19:59:18.123348190 +0000 *************** *** 687,693 **** if (dest >= line1 && dest < line2) { ! emsg(_("E134: Cannot move a range of lines into itself")); return FAIL; } --- 687,693 ---- if (dest >= line1 && dest < line2) { ! emsg(_(e_cannot_move_range_of_lines_into_itself)); return FAIL; } *************** *** 1329,1335 **** if (curbuf != old_curbuf) { --no_wait_return; ! emsg(_("E135: *Filter* Autocommands must not change current buffer")); } else if (cmdmod.cmod_flags & CMOD_LOCKMARKS) { --- 1329,1335 ---- if (curbuf != old_curbuf) { --no_wait_return; ! emsg(_(e_filter_autocommands_must_not_change_current_buffer)); } else if (cmdmod.cmod_flags & CMOD_LOCKMARKS) { *** ../vim-8.2.3906/src/viminfo.c 2021-12-13 13:11:00.692262343 +0000 --- src/viminfo.c 2021-12-26 20:05:19.374883774 +0000 *************** *** 1174,1180 **** emsg((char *)IObuff); if (++viminfo_errcnt >= 10) { ! emsg(_("E136: viminfo: Too many errors, skipping rest of file")); return TRUE; } return FALSE; --- 1174,1180 ---- emsg((char *)IObuff); if (++viminfo_errcnt >= 10) { ! emsg(_(e_viminfo_too_many_errors_skipping_rest_of_file)); return TRUE; } return FALSE; *************** *** 3106,3112 **** int tt = msg_didany; // avoid a wait_return for this message, it's annoying ! semsg(_("E137: Viminfo file is not writable: %s"), fname); msg_didany = tt; fclose(fp_in); goto end; --- 3106,3112 ---- int tt = msg_didany; // avoid a wait_return for this message, it's annoying ! semsg(_(e_viminfo_file_is_not_writable_str), fname); msg_didany = tt; fclose(fp_in); goto end; *************** *** 3262,3268 **** // Check if the new viminfo file can be written to. if (fp_out == NULL) { ! semsg(_("E138: Can't write viminfo file %s!"), (fp_in == NULL || tempname == NULL) ? fname : tempname); if (fp_in != NULL) fclose(fp_in); --- 3262,3268 ---- // Check if the new viminfo file can be written to. if (fp_out == NULL) { ! semsg(_(e_cant_write_viminfo_file_str), (fp_in == NULL || tempname == NULL) ? fname : tempname); if (fp_in != NULL) fclose(fp_in); *** ../vim-8.2.3906/src/errors.h 2021-12-25 19:29:18.409881900 +0000 --- src/errors.h 2021-12-26 20:05:14.946889649 +0000 *************** *** 266,273 **** INIT(= N_("E121: Undefined variable: %s")); EXTERN char e_undefined_variable_char_str[] INIT(= N_("E121: Undefined variable: %c:%s")); #endif - EXTERN char e_no_such_user_defined_command_str[] INIT(= N_("E184: No such user-defined command: %s")); --- 266,307 ---- INIT(= N_("E121: Undefined variable: %s")); EXTERN char e_undefined_variable_char_str[] INIT(= N_("E121: Undefined variable: %c:%s")); + EXTERN char e_function_str_already_exists_add_excl_to_replace[] + INIT(= N_("E122: Function %s already exists, add ! to replace it")); + EXTERN char e_undefined_function_str[] + INIT(= N_("E123: Undefined function: %s")); + EXTERN char e_missing_paren_str[] + INIT(= N_("E124: Missing '(': %s")); + EXTERN char e_illegal_argument_str[] + INIT(= N_("E125: Illegal argument: %s")); + EXTERN char e_missing_endfunction[] + INIT(= N_("E126: Missing :endfunction")); + EXTERN char e_cannot_redefine_function_str_it_is_in_use[] + INIT(= N_("E127: Cannot redefine function %s: It is in use")); + EXTERN char e_function_name_must_start_with_capital_or_s_str[] + INIT(= N_("E128: Function name must start with a capital or \"s:\": %s")); + EXTERN char e_function_name_required[] + INIT(= N_("E129: Function name required")); + // E130 unused + EXTERN char e_cannot_delete_function_str_it_is_in_use[] + INIT(= N_("E131: Cannot delete function %s: It is in use")); + EXTERN char e_function_call_depth_is_higher_than_macfuncdepth[] + INIT(= N_("E132: Function call depth is higher than 'maxfuncdepth'")); + EXTERN char e_return_not_inside_function[] + INIT(= N_("E133: :return not inside a function")); + #endif + EXTERN char e_cannot_move_range_of_lines_into_itself[] + INIT(= N_("E134: Cannot move a range of lines into itself")); + EXTERN char e_filter_autocommands_must_not_change_current_buffer[] + INIT(= N_("E135: *Filter* Autocommands must not change current buffer")); + #if defined(FEAT_VIMINFO) + EXTERN char e_viminfo_too_many_errors_skipping_rest_of_file[] + INIT(= N_("E136: viminfo: Too many errors, skipping rest of file")); + EXTERN char e_viminfo_file_is_not_writable_str[] + INIT(= N_("E137: Viminfo file is not writable: %s")); + EXTERN char e_cant_write_viminfo_file_str[] + INIT(= N_("E138: Can't write viminfo file %s!")); #endif EXTERN char e_no_such_user_defined_command_str[] INIT(= N_("E184: No such user-defined command: %s")); *** ../vim-8.2.3906/src/testdir/test_user_func.vim 2021-09-06 19:56:53.296274317 +0100 --- src/testdir/test_user_func.vim 2021-12-26 19:37:47.181036839 +0000 *************** *** 428,434 **** " Test for deleting a function func Test_del_func() ! call assert_fails('delfunction Xabc', 'E130:') let d = {'a' : 10} call assert_fails('delfunc d.a', 'E718:') func d.fn() --- 428,434 ---- " Test for deleting a function func Test_del_func() ! call assert_fails('delfunction Xabc', 'E117:') let d = {'a' : 10} call assert_fails('delfunc d.a', 'E718:') func d.fn() *** ../vim-8.2.3906/src/version.c 2021-12-26 18:08:33.729729382 +0000 --- src/version.c 2021-12-26 20:07:49.318682946 +0000 *************** *** 751,752 **** --- 751,754 ---- { /* Add new patch number below this line */ + /**/ + 3907, /**/ -- hundred-and-one symptoms of being an internet addict: 116. You are living with your boyfriend who networks your respective computers so you can sit in separate rooms and email each other /// 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 ///