summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-12-26 20:20:34 +0000
committerBram Moolenaar <Bram@vim.org>2021-12-26 20:20:34 +0000
commitc553a21e189aa440515a19c5b25f8b6b50c5d53d (patch)
tree46e5de31c79fe9c8e67b35f6a22d9fa52e3b24ac /src
parent1f318c6eac3d894a3fb9c68c53512cdd75e8f6b4 (diff)
patch 8.2.3907: error messages are spread outv8.2.3907
Problem: Error messages are spread out. Solution: Move error messages to errors.h. Avoid duplicates.
Diffstat (limited to 'src')
-rw-r--r--src/errors.h36
-rw-r--r--src/ex_cmds.c4
-rw-r--r--src/testdir/test_user_func.vim2
-rw-r--r--src/userfunc.c41
-rw-r--r--src/version.c2
-rw-r--r--src/viminfo.c6
6 files changed, 61 insertions, 30 deletions
diff --git a/src/errors.h b/src/errors.h
index e39e4044ad..c629953eb6 100644
--- a/src/errors.h
+++ b/src/errors.h
@@ -266,8 +266,42 @@ EXTERN char e_undefined_variable_str[]
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"));
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
index 14045267da..ff978ad66d 100644
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -687,7 +687,7 @@ do_move(linenr_T line1, linenr_T line2, linenr_T dest)
if (dest >= line1 && dest < line2)
{
- emsg(_("E134: Cannot move a range of lines into itself"));
+ emsg(_(e_cannot_move_range_of_lines_into_itself));
return FAIL;
}
@@ -1329,7 +1329,7 @@ filterend:
if (curbuf != old_curbuf)
{
--no_wait_return;
- emsg(_("E135: *Filter* Autocommands must not change current buffer"));
+ emsg(_(e_filter_autocommands_must_not_change_current_buffer));
}
else if (cmdmod.cmod_flags & CMOD_LOCKMARKS)
{
diff --git a/src/testdir/test_user_func.vim b/src/testdir/test_user_func.vim
index 819a6bba90..6eb8a0f330 100644
--- a/src/testdir/test_user_func.vim
+++ b/src/testdir/test_user_func.vim
@@ -428,7 +428,7 @@ endfunc
" Test for deleting a function
func Test_del_func()
- call assert_fails('delfunction Xabc', 'E130:')
+ call assert_fails('delfunction Xabc', 'E117:')
let d = {'a' : 10}
call assert_fails('delfunc d.a', 'E718:')
func d.fn()
diff --git a/src/userfunc.c b/src/userfunc.c
index 80c64d0deb..8f66291740 100644
--- a/src/userfunc.c
+++ b/src/userfunc.c
@@ -29,10 +29,8 @@ static funccall_T *current_funccal = NULL;
// 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);
@@ -83,7 +81,7 @@ one_function_arg(
|| (p - arg == 8 && STRNCMP(arg, "lastline", 8) == 0))))
{
if (!skip)
- semsg(_("E125: Illegal argument: %s"), arg);
+ semsg(_(e_illegal_argument_str), arg);
return arg;
}
@@ -743,7 +741,7 @@ get_function_body(
else if (eap->cmdidx == CMD_def)
emsg(_(e_missing_enddef));
else
- emsg(_("E126: Missing :endfunction"));
+ emsg(_(e_missing_endfunction));
goto theend;
}
@@ -1785,7 +1783,7 @@ get_func_tv(
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);
+ emsg_funcname(e_invalid_arguments_for_function_str, name);
}
while (--argcount >= 0)
@@ -2341,7 +2339,7 @@ copy_func(char_u *lambda, char_u *global, ectx_T *ectx)
if (fp != NULL)
{
// TODO: handle ! to overwrite
- semsg(_(e_funcexts), global);
+ semsg(_(e_function_str_already_exists_add_excl_to_replace), global);
return FAIL;
}
@@ -2421,7 +2419,7 @@ funcdepth_increment(void)
{
if (funcdepth >= p_mfd)
{
- emsg(_("E132: Function call depth is higher than 'maxfuncdepth'"));
+ emsg(_(e_function_call_depth_is_higher_than_macfuncdepth));
return FAIL;
}
++funcdepth;
@@ -3252,7 +3250,7 @@ user_func_error(int error, char_u *name, funcexe_T *funcexe)
N_("E276: Cannot use function as a method: %s"), name);
break;
case FCERR_DELETED:
- emsg_funcname(N_(e_func_deleted), name);
+ emsg_funcname(e_func_deleted, name);
break;
case FCERR_TOOMANY:
emsg_funcname((char *)e_too_many_arguments_for_function_str,
@@ -3264,7 +3262,7 @@ user_func_error(int error, char_u *name, funcexe_T *funcexe)
break;
case FCERR_SCRIPT:
emsg_funcname(
- N_(e_using_sid_not_in_script_context_str), name);
+ e_using_sid_not_in_script_context_str, name);
break;
case FCERR_DICT:
emsg_funcname(
@@ -3627,7 +3625,6 @@ trans_function_name(
int extra = 0;
lval_T lv;
int vim9script;
- static char *e_function_name = N_("E129: Function name required");
if (fdp != NULL)
CLEAR_POINTER(fdp);
@@ -3655,7 +3652,7 @@ trans_function_name(
if (end == start)
{
if (!skip)
- emsg(_(e_function_name));
+ emsg(_(e_function_name_required));
goto theend;
}
if (end == NULL || (lv.ll_tv != NULL && (lead > 2 || lv.ll_range)))
@@ -3775,7 +3772,7 @@ trans_function_name(
if (len <= 0)
{
if (!skip)
- emsg(_(e_function_name));
+ emsg(_(e_function_name_required));
goto theend;
}
@@ -3823,8 +3820,7 @@ trans_function_name(
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);
+ semsg(_(e_function_name_must_start_with_capital_or_s_str), start);
goto theend;
}
if (!skip && !(flags & TFN_QUIET) && !(flags & TFN_NO_DEREF))
@@ -4171,7 +4167,7 @@ define_function(exarg_T *eap, char_u *name_arg, char_u **line_to_free)
}
}
else
- emsg_funcname(N_("E123: Undefined function: %s"), eap->arg);
+ emsg_funcname(e_undefined_function_str, eap->arg);
}
goto ret_free;
}
@@ -4184,7 +4180,7 @@ define_function(exarg_T *eap, char_u *name_arg, char_u **line_to_free)
{
if (!eap->skip)
{
- semsg(_("E124: Missing '(': %s"), eap->arg);
+ semsg(_(e_missing_paren_str), eap->arg);
goto ret_free;
}
// attempt to continue by skipping some text
@@ -4357,7 +4353,7 @@ define_function(exarg_T *eap, char_u *name_arg, char_u **line_to_free)
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);
+ emsg_funcname(e_function_str_already_exists_add_excl_to_replace, name);
}
if (!eap->skip && did_emsg)
@@ -4415,14 +4411,13 @@ define_function(exarg_T *eap, char_u *name_arg, char_u **line_to_free)
if (vim9script)
emsg_funcname(e_name_already_defined_str, name);
else
- emsg_funcname(e_funcexts, name);
+ emsg_funcname(e_function_str_already_exists_add_excl_to_replace, name);
goto erret;
}
if (fp->uf_calls > 0)
{
emsg_funcname(
- N_("E127: Cannot redefine function %s: It is in use"),
- name);
+ e_cannot_redefine_function_str_it_is_in_use, name);
goto erret;
}
if (fp->uf_refcount > 1)
@@ -4900,12 +4895,12 @@ ex_delfunction(exarg_T *eap)
if (fp == NULL)
{
if (!eap->forceit)
- semsg(_(e_nofunc), eap->arg);
+ semsg(_(e_unknown_function_str), eap->arg);
return;
}
if (fp->uf_calls > 0)
{
- semsg(_("E131: Cannot delete function %s: It is in use"), eap->arg);
+ semsg(_(e_cannot_delete_function_str_it_is_in_use), eap->arg);
return;
}
if (fp->uf_flags & FC_VIM9)
@@ -5037,7 +5032,7 @@ ex_return(exarg_T *eap)
if (current_funccal == NULL)
{
- emsg(_("E133: :return not inside a function"));
+ emsg(_(e_return_not_inside_function));
return;
}
diff --git a/src/version.c b/src/version.c
index 8b9b27ef21..7b8b0a6838 100644
--- a/src/version.c
+++ b/src/version.c
@@ -750,6 +750,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 3907,
+/**/
3906,
/**/
3905,
diff --git a/src/viminfo.c b/src/viminfo.c
index faeb434e9e..b3c0e148e4 100644
--- a/src/viminfo.c
+++ b/src/viminfo.c
@@ -1174,7 +1174,7 @@ viminfo_error(char *errnum, char *message, char_u *line)
emsg((char *)IObuff);
if (++viminfo_errcnt >= 10)
{
- emsg(_("E136: viminfo: Too many errors, skipping rest of file"));
+ emsg(_(e_viminfo_too_many_errors_skipping_rest_of_file));
return TRUE;
}
return FALSE;
@@ -3106,7 +3106,7 @@ write_viminfo(char_u *file, int forceit)
int tt = msg_didany;
// avoid a wait_return for this message, it's annoying
- semsg(_("E137: Viminfo file is not writable: %s"), fname);
+ semsg(_(e_viminfo_file_is_not_writable_str), fname);
msg_didany = tt;
fclose(fp_in);
goto end;
@@ -3262,7 +3262,7 @@ write_viminfo(char_u *file, int forceit)
// Check if the new viminfo file can be written to.
if (fp_out == NULL)
{
- semsg(_("E138: Can't write viminfo file %s!"),
+ semsg(_(e_cant_write_viminfo_file_str),
(fp_in == NULL || tempname == NULL) ? fname : tempname);
if (fp_in != NULL)
fclose(fp_in);