]> granicus.if.org Git - vim/commitdiff
patch 8.2.3907: error messages are spread out v8.2.3907
authorBram Moolenaar <Bram@vim.org>
Sun, 26 Dec 2021 20:20:34 +0000 (20:20 +0000)
committerBram Moolenaar <Bram@vim.org>
Sun, 26 Dec 2021 20:20:34 +0000 (20:20 +0000)
Problem:    Error messages are spread out.
Solution:   Move error messages to errors.h.  Avoid duplicates.

src/errors.h
src/ex_cmds.c
src/testdir/test_user_func.vim
src/userfunc.c
src/version.c
src/viminfo.c

index e39e4044ada868b50a2d3bf74a20742aba441d1e..c629953eb651d16f4a5bb2e5044b23eba8a71c38 100644 (file)
@@ -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"));
index 14045267da0c89c9fdf4280758d9a7e37661d966..ff978ad66d99bbdda148d983440582c072f433a7 100644 (file)
@@ -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)
     {
index 819a6bba90dce2e8ee89e29d70a0a3321d06af31..6eb8a0f3305c985d34c814c14f8ee2b9975adb70 100644 (file)
@@ -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()
index 80c64d0deb9229de956e61ed43780a3d53c3e383..8f662917407530cba84167e8493a5bc441069471 100644 (file)
@@ -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;
     }
 
index 8b9b27ef21a266680816ba292cec9d8486b6404b..7b8b0a68389e6bd7ef1bfcc2ba32cc82e862c09a 100644 (file)
@@ -749,6 +749,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3907,
 /**/
     3906,
 /**/
index faeb434e9edd20a29252bad3b8aa25ed4c13c5ff..b3c0e148e4d798a1c3c0803c11f56eaafae21a5e 100644 (file)
@@ -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);