Skip to content

Commit bc4c505

Browse files
committed
patch 8.2.1444: error messages are spread out and names can be confusing
Problem: Error messages are spread out and names can be confusing. Solution: Start moving error messages to a separate file and use clear names.
1 parent cdd70f0 commit bc4c505

18 files changed

Lines changed: 345 additions & 310 deletions

Filelist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ SRC_ALL = \
4545
src/drawline.c \
4646
src/drawscreen.c \
4747
src/edit.c \
48+
src/errors.h \
4849
src/eval.c \
4950
src/evalbuffer.c \
5051
src/evalfunc.c \

src/Make_cyg_ming.mak

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1107,7 +1107,7 @@ cmdidxs: ex_cmds.h
11071107
vim --clean -X --not-a-term -u create_cmdidxs.vim
11081108

11091109
###########################################################################
1110-
INCL = vim.h alloc.h ascii.h ex_cmds.h feature.h globals.h \
1110+
INCL = vim.h alloc.h ascii.h ex_cmds.h feature.h errors.h globals.h \
11111111
keymap.h macros.h option.h os_dos.h os_win32.h proto.h regexp.h \
11121112
spell.h structs.h term.h beval.h $(NBDEBUG_INCL)
11131113
GUI_INCL = gui.h

src/Make_mvc.mak

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ CFLAGS = $(CFLAGS) $(CFLAGS_DEPR)
719719
!include Make_all.mak
720720
!include testdir\Make_all.mak
721721

722-
INCL = vim.h alloc.h ascii.h ex_cmds.h feature.h globals.h \
722+
INCL = vim.h alloc.h ascii.h ex_cmds.h feature.h errors.h globals.h \
723723
keymap.h macros.h option.h os_dos.h os_win32.h proto.h regexp.h \
724724
spell.h structs.h term.h beval.h $(NBDEBUG_INCL)
725725

src/Make_vms.mms

Lines changed: 124 additions & 118 deletions
Large diffs are not rendered by default.

src/Makefile

Lines changed: 140 additions & 140 deletions
Large diffs are not rendered by default.

src/dict.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -847,7 +847,7 @@ eval_dict(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int literal)
847847
if (evaluate)
848848
{
849849
if (*skipwhite(*arg) == ':')
850-
semsg(_(e_no_white_before), ":");
850+
semsg(_(e_no_white_space_allowed_before), ":");
851851
else
852852
semsg(_(e_missing_dict_colon), *arg);
853853
}
@@ -866,7 +866,7 @@ eval_dict(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int literal)
866866
}
867867
if (vim9script && (*arg)[1] != NUL && !VIM_ISWHITE((*arg)[1]))
868868
{
869-
semsg(_(e_white_after), ":");
869+
semsg(_(e_white_space_required_after), ":");
870870
clear_tv(&tvkey);
871871
goto failret;
872872
}
@@ -909,7 +909,7 @@ eval_dict(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int literal)
909909
{
910910
if (vim9script && (*arg)[1] != NUL && !VIM_ISWHITE((*arg)[1]))
911911
{
912-
semsg(_(e_white_after), ",");
912+
semsg(_(e_white_space_required_after), ",");
913913
goto failret;
914914
}
915915
*arg = skipwhite(*arg + 1);
@@ -924,7 +924,7 @@ eval_dict(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int literal)
924924
if (evaluate)
925925
{
926926
if (**arg == ',')
927-
semsg(_(e_no_white_before), ",");
927+
semsg(_(e_no_white_space_allowed_before), ",");
928928
else
929929
semsg(_(e_missing_dict_comma), *arg);
930930
}

src/errors.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/* vi:set ts=8 sts=4 sw=4 noet:
2+
*
3+
* VIM - Vi IMproved by Bram Moolenaar
4+
*
5+
* Do ":help uganda" in Vim to read copying and usage conditions.
6+
* Do ":help credits" in Vim to see a list of people who contributed.
7+
*/
8+
9+
/*
10+
* Definition of error messages, sorted on error number.
11+
*/
12+
13+
#ifdef FEAT_EVAL
14+
EXTERN char e_white_space_required_before_and_after[]
15+
INIT(= N_("E1004: white space required before and after '%s'"));
16+
EXTERN char e_cannot_declare_a_scope_variable[]
17+
INIT(= N_("E1016: Cannot declare a %s variable: %s"));
18+
EXTERN char e_cannot_declare_an_environment_variable[]
19+
INIT(= N_("E1016: Cannot declare an environment variable: %s"));
20+
EXTERN char e_const_requires_a_value[]
21+
INIT(= N_("E1021: const requires a value"));
22+
EXTERN char e_type_or_initialization_required[]
23+
INIT(= N_("E1022: type or initialization required"));
24+
EXTERN char e_colon_required_before_a_range[]
25+
INIT(= N_("E1050: Colon required before a range"));
26+
EXTERN char e_no_white_space_allowed_before[]
27+
INIT(= N_("E1068: No white space allowed before '%s'"));
28+
EXTERN char e_white_space_required_after[]
29+
INIT(= N_("E1069: white space required after '%s'"));
30+
EXTERN char e_name_already_defined[]
31+
INIT(= N_("E1073: name already defined: %s"));
32+
EXTERN char e_list_dict_or_blob_required[]
33+
INIT(= N_("E1090: List, Dict or Blob required"));
34+
EXTERN char e_dictionary_not_set[]
35+
INIT(= N_("E1103: Dictionary not set"));
36+
#endif

src/evalvars.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,7 @@ ex_let(exarg_T *eap)
805805
|| !IS_WHITE_OR_NUL(*expr)))
806806
{
807807
vim_strncpy(op, expr - len, len);
808-
semsg(_(e_white_both), op);
808+
semsg(_(e_white_space_required_before_and_after), op);
809809
i = FAIL;
810810
}
811811

src/ex_docmd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1789,7 +1789,7 @@ do_one_cmd(
17891789
--ea.cmd;
17901790
else if (ea.cmd > cmd)
17911791
{
1792-
emsg(_(e_colon_required));
1792+
emsg(_(e_colon_required_before_a_range));
17931793
goto doend;
17941794
}
17951795
p = find_ex_command(&ea, NULL, lookup_scriptvar, NULL);

src/globals.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1686,7 +1686,6 @@ EXTERN char e_readonlysbx[] INIT(= N_("E794: Cannot set variable in the sandbox:
16861686
EXTERN char e_stringreq[] INIT(= N_("E928: String required"));
16871687
EXTERN char e_emptykey[] INIT(= N_("E713: Cannot use empty key for Dictionary"));
16881688
EXTERN char e_dictreq[] INIT(= N_("E715: Dictionary required"));
1689-
EXTERN char e_dictnull[] INIT(= N_("E1103: Dictionary not set"));
16901689
EXTERN char e_listidx[] INIT(= N_("E684: list index out of range: %ld"));
16911690
EXTERN char e_blobidx[] INIT(= N_("E979: Blob index out of range: %ld"));
16921691
EXTERN char e_invalblob[] INIT(= N_("E978: Invalid operation for Blob"));
@@ -1695,7 +1694,6 @@ EXTERN char e_toofewarg[] INIT(= N_("E119: Not enough arguments for function: %s
16951694
EXTERN char e_func_deleted[] INIT(= N_("E933: Function was deleted: %s"));
16961695
EXTERN char e_dictkey[] INIT(= N_("E716: Key not present in Dictionary: %s"));
16971696
EXTERN char e_listreq[] INIT(= N_("E714: List required"));
1698-
EXTERN char e_listdictblobreq[] INIT(= N_("E1090: List, Dict or Blob required"));
16991697
EXTERN char e_listblobreq[] INIT(= N_("E897: List or Blob required"));
17001698
EXTERN char e_list_end[] INIT(= N_("E697: Missing end of List ']': %s"));
17011699
EXTERN char e_listdictarg[] INIT(= N_("E712: Argument of %s must be a List or Dictionary"));
@@ -1748,7 +1746,6 @@ EXTERN char e_missing_dict_colon[] INIT(= N_("E720: Missing colon in Dictionary:
17481746
EXTERN char e_duplicate_key[] INIT(= N_("E721: Duplicate key in Dictionary: \"%s\""));
17491747
EXTERN char e_missing_dict_comma[] INIT(= N_("E722: Missing comma in Dictionary: %s"));
17501748
EXTERN char e_missing_dict_end[] INIT(= N_("E723: Missing end of Dictionary '}': %s"));
1751-
EXTERN char e_already_defined[] INIT(= N_("E1073: name already defined: %s"));
17521749
#endif
17531750
#ifdef FEAT_CLIENTSERVER
17541751
EXTERN char e_invexprmsg[] INIT(= N_("E449: Invalid expression received"));
@@ -1791,16 +1788,8 @@ EXTERN char e_endif_without_if[] INIT(= N_("E580: :endif without :if"));
17911788
EXTERN char e_continue[] INIT(= N_("E586: :continue without :while or :for"));
17921789
EXTERN char e_break[] INIT(= N_("E587: :break without :while or :for"));
17931790
EXTERN char e_nowhitespace[] INIT(= N_("E274: No white space allowed before parenthesis"));
1794-
EXTERN char e_white_both[] INIT(= N_("E1004: white space required before and after '%s'"));
1795-
EXTERN char e_white_after[] INIT(= N_("E1069: white space required after '%s'"));
1796-
EXTERN char e_no_white_before[] INIT(= N_("E1068: No white space allowed before '%s'"));
17971791

17981792
EXTERN char e_lock_unlock[] INIT(= N_("E940: Cannot lock or unlock variable %s"));
1799-
EXTERN char e_const_req_value[] INIT(= N_("E1021: const requires a value"));
1800-
EXTERN char e_type_req[] INIT(= N_("E1022: type or initialization required"));
1801-
EXTERN char e_declare_var[] INIT(= N_("E1016: Cannot declare a %s variable: %s"));
1802-
EXTERN char e_declare_env_var[] INIT(= N_("E1016: Cannot declare an environment variable: %s"));
1803-
EXTERN char e_colon_required[] INIT(= N_("E1050: Colon required before a range"));
18041793
#endif
18051794
#if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
18061795
EXTERN char e_alloc_color[] INIT(= N_("E254: Cannot allocate color %s"));

0 commit comments

Comments
 (0)