changeset 26436:ef0c07cbf53f v8.2.3749

patch 8.2.3749: error messages are everywhere Commit: https://github.com/vim/vim/commit/12f3c1b77fb39dc338304d5484cdbc99da27389a Author: Bram Moolenaar <Bram@vim.org> Date: Sun Dec 5 21:46:34 2021 +0000 patch 8.2.3749: error messages are everywhere Problem: Error messages are everywhere. Solution: Move more error messages to errors.h and adjust the names.
author Bram Moolenaar <Bram@vim.org>
date Sun, 05 Dec 2021 23:00:06 +0100
parents 8860c02d96a8
children 11441fe9dc13
files src/bufwrite.c src/cmdexpand.c src/errors.h src/getchar.c src/globals.h src/memfile.c src/regexp.c src/regexp_bt.c src/regexp_nfa.c src/tag.c src/version.c
diffstat 11 files changed, 57 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/src/bufwrite.c
+++ b/src/bufwrite.c
@@ -713,7 +713,7 @@ buf_write(
     // Avoid a crash for a long name.
     if (STRLEN(fname) >= MAXPATHL)
     {
-	emsg(_(e_longname));
+	emsg(_(e_name_too_long));
 	return FAIL;
     }
 
--- a/src/cmdexpand.c
+++ b/src/cmdexpand.c
@@ -406,7 +406,7 @@ ExpandOne(
 		    // together. Don't really want to wait for this message
 		    // (and possibly have to hit return to continue!).
 		    if (!(options & WILD_SILENT))
-			emsg(_(e_toomany));
+			emsg(_(e_too_many_file_names));
 		    else if (!(options & WILD_NO_BEEP))
 			beep_flush();
 		}
--- a/src/errors.h
+++ b/src/errors.h
@@ -134,6 +134,40 @@ EXTERN char e_invalid_character_after_st
 	INIT(= N_("E59: invalid character after %s@"));
 EXTERN char e_too_many_complex_str_curly[]
 	INIT(= N_("E60: Too many complex %s{...}s"));
+EXTERN char e_nested_str[]
+	INIT(= N_("E61: Nested %s*"));
+EXTERN char e_nested_str_chr[]
+	INIT(= N_("E62: Nested %s%c"));
+EXTERN char e_invalid_use_of_underscore[]
+	INIT(= N_("E63: invalid use of \\_"));
+EXTERN char e_str_chr_follows_nothing[]
+	INIT(= N_("E64: %s%c follows nothing"));
+EXTERN char e_illegal_back_reference[]
+	INIT(= N_("E65: Illegal back reference"));
+#ifdef FEAT_SYN_HL
+EXTERN char e_z_not_allowed_here[]
+	INIT(= N_("E66: \\z( not allowed here"));
+EXTERN char e_z1_z9_not_allowed_here[]
+	INIT(= N_("E67: \\z1 - \\z9 not allowed here"));
+#endif
+EXTERN char e_missing_sb_after_str[]
+	INIT(= N_("E69: Missing ] after %s%%["));
+EXTERN char e_empty_str_brackets[]
+	INIT(= N_("E70: Empty %s%%[]"));
+EXTERN char e_invalid_character_after_str[]
+	INIT(= N_("E71: Invalid character after %s%%"));
+EXTERN char e_close_error_on_swap_file[]
+	INIT(= N_("E72: Close error on swap file"));
+EXTERN char e_tag_stack_empty[]
+	INIT(= N_("E73: tag stack empty"));
+EXTERN char e_command_too_complex[]
+	INIT(= N_("E74: Command too complex"));
+EXTERN char e_name_too_long[]
+	INIT(= N_("E75: Name too long"));
+EXTERN char e_too_many_brackets[]
+	INIT(= N_("E76: Too many ["));
+EXTERN char e_too_many_file_names[]
+	INIT(= N_("E77: Too many file names"));
 
 #ifdef FEAT_EVAL
 EXTERN char e_undefined_variable_str[]
--- a/src/getchar.c
+++ b/src/getchar.c
@@ -1010,7 +1010,7 @@ ins_typebuf(
 	if (typebuf.tb_len > 2147483647 - extra)
 	{
 	    // string is getting too long for a 32 bit int
-	    emsg(_(e_toocompl));    // also calls flush_buffers
+	    emsg(_(e_command_too_complex));    // also calls flush_buffers
 	    setcursor();
 	    return FAIL;
 	}
--- a/src/globals.h
+++ b/src/globals.h
@@ -1715,12 +1715,6 @@ EXTERN char e_shellempty[]	INIT(= N_("E9
 #if defined(FEAT_SIGN_ICONS) && !defined(FEAT_GUI_GTK)
 EXTERN char e_signdata[]	INIT(= N_("E255: Couldn't read in sign data!"));
 #endif
-EXTERN char e_swapclose[]	INIT(= N_("E72: Close error on swap file"));
-EXTERN char e_tagstack[]	INIT(= N_("E73: tag stack empty"));
-EXTERN char e_toocompl[]	INIT(= N_("E74: Command too complex"));
-EXTERN char e_longname[]	INIT(= N_("E75: Name too long"));
-EXTERN char e_toomsbra[]	INIT(= N_("E76: Too many ["));
-EXTERN char e_toomany[]	INIT(= N_("E77: Too many file names"));
 EXTERN char e_trailing[]	INIT(= N_("E488: Trailing characters"));
 EXTERN char e_trailing_arg[]	INIT(= N_("E488: Trailing characters: %s"));
 EXTERN char e_umark[]		INIT(= N_("E78: Unknown mark"));
--- a/src/memfile.c
+++ b/src/memfile.c
@@ -242,7 +242,7 @@ mf_close(memfile_T *mfp, int del_file)
     if (mfp->mf_fd >= 0)
     {
 	if (close(mfp->mf_fd) < 0)
-	    emsg(_(e_swapclose));
+	    emsg(_(e_close_error_on_swap_file));
     }
     if (del_file && mfp->mf_fname != NULL)
 	mch_remove(mfp->mf_fname);
@@ -288,7 +288,7 @@ mf_close_file(
     }
 
     if (close(mfp->mf_fd) < 0)			// close the file
-	emsg(_(e_swapclose));
+	emsg(_(e_close_error_on_swap_file));
     mfp->mf_fd = -1;
 
     if (mfp->mf_fname != NULL)
--- a/src/regexp.c
+++ b/src/regexp.c
@@ -74,12 +74,6 @@ toggle_Magic(int x)
 static char_u e_missingbracket[] = N_("E769: Missing ] after %s[");
 static char_u e_reverse_range[] = N_("E944: Reverse range in character class");
 static char_u e_large_class[] = N_("E945: Range too large in character class");
-#ifdef FEAT_SYN_HL
-static char_u e_z_not_allowed[] = N_("E66: \\z( not allowed here");
-static char_u e_z1_not_allowed[] = N_("E67: \\z1 - \\z9 not allowed here");
-#endif
-static char_u e_missing_sb[] = N_("E69: Missing ] after %s%%[");
-static char_u e_empty_sb[]  = N_("E70: Empty %s%%[]");
 static char_u e_recursive[]  = N_("E956: Cannot use pattern recursively");
 
 #define NOT_MULTI	0
--- a/src/regexp_bt.c
+++ b/src/regexp_bt.c
@@ -1242,7 +1242,7 @@ seen_endbrace(int refnum)
 		break;
 	if (*p == NUL)
 	{
-	    emsg(_("E65: Illegal back reference"));
+	    emsg(_(e_illegal_back_reference));
 	    rc_did_emsg = TRUE;
 	    return FALSE;
 	}
@@ -1347,7 +1347,7 @@ regatom(int *flagp)
       case Magic('U'):
 	p = vim_strchr(classchars, no_Magic(c));
 	if (p == NULL)
-	    EMSG_RET_NULL(_("E63: invalid use of \\_"));
+	    EMSG_RET_NULL(_(e_invalid_use_of_underscore));
 
 	// When '.' is followed by a composing char ignore the dot, so that
 	// the composing char is matched here.
@@ -1402,7 +1402,7 @@ regatom(int *flagp)
       case Magic('{'):
       case Magic('*'):
 	c = no_Magic(c);
-	EMSG3_RET_NULL(_("E64: %s%c follows nothing"),
+	EMSG3_RET_NULL(_(e_str_chr_follows_nothing),
 		(c == '*' ? reg_magic >= MAGIC_ON : reg_magic == MAGIC_ALL), c);
 	// NOTREACHED
 
@@ -1453,7 +1453,7 @@ regatom(int *flagp)
 	    {
 #ifdef FEAT_SYN_HL
 		case '(': if ((reg_do_extmatch & REX_SET) == 0)
-			      EMSG_RET_NULL(_(e_z_not_allowed));
+			      EMSG_RET_NULL(_(e_z_not_allowed_here));
 			  if (one_exactly)
 			      EMSG_ONE_RET_NULL;
 			  ret = reg(REG_ZPAREN, &flags);
@@ -1472,7 +1472,7 @@ regatom(int *flagp)
 		case '7':
 		case '8':
 		case '9': if ((reg_do_extmatch & REX_USE) == 0)
-			      EMSG_RET_NULL(_(e_z1_not_allowed));
+			      EMSG_RET_NULL(_(e_z1_z9_not_allowed_here));
 			  ret = regnode(ZREF + c - '0');
 			  re_has_z = REX_USE;
 			  break;
@@ -1544,7 +1544,7 @@ regatom(int *flagp)
 			      while ((c = getchr()) != ']')
 			      {
 				  if (c == NUL)
-				      EMSG2_RET_NULL(_(e_missing_sb),
+				      EMSG2_RET_NULL(_(e_missing_sb_after_str),
 						      reg_magic == MAGIC_ALL);
 				  br = regnode(BRANCH);
 				  if (ret == NULL)
@@ -1564,7 +1564,7 @@ regatom(int *flagp)
 				      return NULL;
 			      }
 			      if (ret == NULL)
-				  EMSG2_RET_NULL(_(e_empty_sb),
+				  EMSG2_RET_NULL(_(e_empty_str_brackets),
 						      reg_magic == MAGIC_ALL);
 			      lastbranch = regnode(BRANCH);
 			      br = regnode(NOTHING);
@@ -1712,7 +1712,7 @@ regatom(int *flagp)
 			      }
 			  }
 
-			  EMSG2_RET_NULL(_("E71: Invalid character after %s%%"),
+			  EMSG2_RET_NULL(_(e_invalid_character_after_str),
 						      reg_magic == MAGIC_ALL);
 	    }
 	}
@@ -2001,7 +2001,7 @@ collection:
 		regc(NUL);
 		prevchr_len = 1;	// last char was the ']'
 		if (*regparse != ']')
-		    EMSG_RET_NULL(_(e_toomsbra));	// Cannot happen?
+		    EMSG_RET_NULL(_(e_too_many_brackets));  // Cannot happen?
 		skipchr();	    // let's be friends with the lexer again
 		*flagp |= HASWIDTH | SIMPLE;
 		break;
@@ -2215,8 +2215,8 @@ regpiece(int *flagp)
     {
 	// Can't have a multi follow a multi.
 	if (peekchr() == Magic('*'))
-	    EMSG2_RET_NULL(_("E61: Nested %s*"), reg_magic >= MAGIC_ON);
-	EMSG3_RET_NULL(_("E62: Nested %s%c"), reg_magic == MAGIC_ALL,
+	    EMSG2_RET_NULL(_(e_nested_str), reg_magic >= MAGIC_ON);
+	EMSG3_RET_NULL(_(e_nested_str_chr), reg_magic == MAGIC_ALL,
 							  no_Magic(peekchr()));
     }
 
--- a/src/regexp_nfa.c
+++ b/src/regexp_nfa.c
@@ -1586,7 +1586,7 @@ nfa_regatom(void)
 		case '9':
 		    // \z1...\z9
 		    if ((reg_do_extmatch & REX_USE) == 0)
-			EMSG_RET_FAIL(_(e_z1_not_allowed));
+			EMSG_RET_FAIL(_(e_z1_z9_not_allowed_here));
 		    EMIT(NFA_ZREF1 + (no_Magic(c) - '1'));
 		    // No need to set rex.nfa_has_backref, the sub-matches don't
 		    // change when \z1 .. \z9 matches or not.
@@ -1595,7 +1595,7 @@ nfa_regatom(void)
 		case '(':
 		    // \z(
 		    if ((reg_do_extmatch & REX_SET) == 0)
-			EMSG_RET_FAIL(_(e_z_not_allowed));
+			EMSG_RET_FAIL(_(e_z_not_allowed_here));
 		    if (nfa_reg(REG_ZPAREN) == FAIL)
 			return FAIL;	    // cascaded error
 		    re_has_z = REX_SET;
@@ -1677,7 +1677,7 @@ nfa_regatom(void)
 			for (n = 0; (c = peekchr()) != ']'; ++n)
 			{
 			    if (c == NUL)
-				EMSG2_RET_FAIL(_(e_missing_sb),
+				EMSG2_RET_FAIL(_(e_missing_sb_after_str),
 						      reg_magic == MAGIC_ALL);
 			    // recursive call!
 			    if (nfa_regatom() == FAIL)
@@ -1685,7 +1685,7 @@ nfa_regatom(void)
 			}
 			getchr();  // get the ]
 			if (n == 0)
-			    EMSG2_RET_FAIL(_(e_empty_sb),
+			    EMSG2_RET_FAIL(_(e_empty_str_brackets),
 						      reg_magic == MAGIC_ALL);
 			EMIT(NFA_OPT_CHARS);
 			EMIT(n);
--- a/src/tag.c
+++ b/src/tag.c
@@ -350,7 +350,7 @@ do_tag(
 		    tagstacklen == 0)
 	    {
 		// empty stack
-		emsg(_(e_tagstack));
+		emsg(_(e_tag_stack_empty));
 		goto end_do_tag;
 	    }
 
--- a/src/version.c
+++ b/src/version.c
@@ -754,6 +754,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    3749,
+/**/
     3748,
 /**/
     3747,