diff src/syntax.c @ 15470:55ccc2d353bd v8.1.0743

patch 8.1.0743: giving error messages is not flexible commit https://github.com/vim/vim/commit/f9e3e09fdc93be9f0d47afbc6c7df1188c2a5a0d Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jan 13 23:38:42 2019 +0100 patch 8.1.0743: giving error messages is not flexible Problem: Giving error messages is not flexible. Solution: Add semsg(). Change argument from "char_u *" to "char *", also for msg() and get rid of most MSG macros. (Ozaki Kiichi, closes #3302) Also make emsg() accept a "char *" argument. Get rid of an enormous number of type casts.
author Bram Moolenaar <Bram@vim.org>
date Sun, 13 Jan 2019 23:45:08 +0100
parents c5ec5ddbe814
children dd725a8ab112
line wrap: on
line diff
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -3444,7 +3444,7 @@ syn_cmd_conceal(exarg_T *eap UNUSED, int
     else if (STRNICMP(arg, "off", 3) == 0 && next - arg == 3)
 	curwin->w_s->b_syn_conceal = FALSE;
     else
-	EMSG2(_("E390: Illegal argument: %s"), arg);
+	semsg(_("E390: Illegal argument: %s"), arg);
 #endif
 }
 
@@ -3474,7 +3474,7 @@ syn_cmd_case(exarg_T *eap, int syncing U
     else if (STRNICMP(arg, "ignore", 6) == 0 && next - arg == 6)
 	curwin->w_s->b_syn_ic = TRUE;
     else
-	EMSG2(_("E390: Illegal argument: %s"), arg);
+	semsg(_("E390: Illegal argument: %s"), arg);
 }
 
 /*
@@ -3508,7 +3508,7 @@ syn_cmd_spell(exarg_T *eap, int syncing 
 	curwin->w_s->b_syn_spell = SYNSPL_DEFAULT;
     else
     {
-	EMSG2(_("E390: Illegal argument: %s"), arg);
+	semsg(_("E390: Illegal argument: %s"), arg);
 	return;
     }
 
@@ -3764,7 +3764,7 @@ syn_cmd_clear(exarg_T *eap, int syncing)
 		id = syn_scl_namen2id(arg + 1, (int)(arg_end - arg - 1));
 		if (id == 0)
 		{
-		    EMSG2(_("E391: No such syntax cluster: %s"), arg);
+		    semsg(_("E391: No such syntax cluster: %s"), arg);
 		    break;
 		}
 		else
@@ -3784,7 +3784,7 @@ syn_cmd_clear(exarg_T *eap, int syncing)
 		id = syn_namen2id(arg, (int)(arg_end - arg));
 		if (id == 0)
 		{
-		    EMSG2(_(e_nogroup), arg);
+		    semsg(_(e_nogroup), arg);
 		    break;
 		}
 		else
@@ -3969,7 +3969,7 @@ syn_cmd_list(
 	    {
 		id = syn_scl_namen2id(arg + 1, (int)(arg_end - arg - 1));
 		if (id == 0)
-		    EMSG2(_("E392: No such syntax cluster: %s"), arg);
+		    semsg(_("E392: No such syntax cluster: %s"), arg);
 		else
 		    syn_list_cluster(id - SYNID_CLUSTER);
 	    }
@@ -3977,7 +3977,7 @@ syn_cmd_list(
 	    {
 		id = syn_namen2id(arg, (int)(arg_end - arg));
 		if (id == 0)
-		    EMSG2(_(e_nogroup), arg);
+		    semsg(_(e_nogroup), arg);
 		else
 		    syn_list_one(id, syncing, TRUE);
 	    }
@@ -4650,7 +4650,7 @@ get_syn_options(
 	{
 	    if (!opt->has_cont_list)
 	    {
-		EMSG(_("E395: contains argument not accepted here"));
+		emsg(_("E395: contains argument not accepted here"));
 		return NULL;
 	    }
 	    if (get_id_list(&arg, 8, &opt->cont_list, skip) == FAIL)
@@ -4689,7 +4689,7 @@ get_syn_options(
 #ifdef FEAT_CONCEAL
 	    if (!vim_isprintc_strict(*conceal_char))
 	    {
-		EMSG(_("E844: invalid cchar value"));
+		emsg(_("E844: invalid cchar value"));
 		return NULL;
 	    }
 #endif
@@ -4705,7 +4705,7 @@ get_syn_options(
 	    {
 		if (opt->sync_idx == NULL)
 		{
-		    EMSG(_("E393: group[t]here not accepted here"));
+		    emsg(_("E393: group[t]here not accepted here"));
 		    return NULL;
 		}
 		gname_start = arg;
@@ -4729,7 +4729,7 @@ get_syn_options(
 			}
 		    if (i < 0)
 		    {
-			EMSG2(_("E394: Didn't find region item for %s"), gname);
+			semsg(_("E394: Didn't find region item for %s"), gname);
 			vim_free(gname);
 			return NULL;
 		    }
@@ -4787,7 +4787,7 @@ syn_cmd_include(exarg_T *eap, int syncin
     int		sgl_id = 1;
     char_u	*group_name_end;
     char_u	*rest;
-    char_u	*errormsg = NULL;
+    char	*errormsg = NULL;
     int		prev_toplvl_grp;
     int		prev_syn_inc_tag;
     int		source = FALSE;
@@ -4802,7 +4802,7 @@ syn_cmd_include(exarg_T *eap, int syncin
 	rest = get_group_name(arg, &group_name_end);
 	if (rest == NULL)
 	{
-	    EMSG((char_u *)_("E397: Filename required"));
+	    emsg(_("E397: Filename required"));
 	    return;
 	}
 	sgl_id = syn_check_cluster(arg, (int)(group_name_end - arg));
@@ -4827,7 +4827,7 @@ syn_cmd_include(exarg_T *eap, int syncin
 	if (expand_filename(eap, syn_cmdlinep, &errormsg) == FAIL)
 	{
 	    if (errormsg != NULL)
-		EMSG(errormsg);
+		emsg(errormsg);
 	    return;
 	}
     }
@@ -4838,7 +4838,7 @@ syn_cmd_include(exarg_T *eap, int syncin
      */
     if (running_syn_inc_tag >= MAX_SYN_INC_TAG)
     {
-	EMSG((char_u *)_("E847: Too many syntax includes"));
+	emsg(_("E847: Too many syntax includes"));
 	return;
     }
     prev_syn_inc_tag = current_syn_inc_tag;
@@ -4847,7 +4847,7 @@ syn_cmd_include(exarg_T *eap, int syncin
     curwin->w_s->b_syn_topgrp = sgl_id;
     if (source ? do_source(eap->arg, FALSE, DOSO_NONE) == FAIL
 				: source_runtime(eap->arg, DIP_ALL) == FAIL)
-	EMSG2(_(e_notopen), eap->arg);
+	semsg(_(e_notopen), eap->arg);
     curwin->w_s->b_syn_topgrp = prev_toplvl_grp;
     current_syn_inc_tag = prev_syn_inc_tag;
 }
@@ -4934,14 +4934,14 @@ syn_cmd_keyword(exarg_T *eap, int syncin
 			    break;
 			if (p[1] == NUL)
 			{
-			    EMSG2(_("E789: Missing ']': %s"), kw);
+			    semsg(_("E789: Missing ']': %s"), kw);
 			    goto error;
 			}
 			if (p[1] == ']')
 			{
 			    if (p[2] != NUL)
 			    {
-				EMSG3(_("E890: trailing char after ']': %s]%s"),
+				semsg(_("E890: trailing char after ']': %s]%s"),
 								kw, &p[2]);
 				goto error;
 			    }
@@ -4975,7 +4975,7 @@ error:
     if (rest != NULL)
 	eap->nextcmd = check_nextcmd(rest);
     else
-	EMSG2(_(e_invarg2), arg);
+	semsg(_(e_invarg2), arg);
 
     redraw_curbuf_later(SOME_VALID);
     syn_stack_free_all(curwin->w_s);		/* Need to recompute all syntax. */
@@ -5083,7 +5083,7 @@ syn_cmd_match(
     vim_free(syn_opt_arg.next_list);
 
     if (rest == NULL)
-	EMSG2(_(e_invarg2), arg);
+	semsg(_(e_invarg2), arg);
 }
 
 /*
@@ -5184,7 +5184,7 @@ syn_cmd_region(
 	if (*rest != '=')
 	{
 	    rest = NULL;
-	    EMSG2(_("E398: Missing '=': %s"), arg);
+	    semsg(_("E398: Missing '=': %s"), arg);
 	    break;
 	}
 	rest = skipwhite(rest + 1);
@@ -5347,9 +5347,9 @@ syn_cmd_region(
 	vim_free(syn_opt_arg.cont_in_list);
 	vim_free(syn_opt_arg.next_list);
 	if (not_enough)
-	    EMSG2(_("E399: Not enough arguments: syntax region %s"), arg);
+	    semsg(_("E399: Not enough arguments: syntax region %s"), arg);
 	else if (illegal || rest == NULL)
-	    EMSG2(_(e_invarg2), arg);
+	    semsg(_(e_invarg2), arg);
     }
 }
 
@@ -5578,7 +5578,7 @@ syn_add_cluster(char_u *name)
     len = curwin->w_s->b_syn_clusters.ga_len;
     if (len >= MAX_CLUSTER_ID)
     {
-	EMSG((char_u *)_("E848: Too many syntax clusters"));
+	emsg(_("E848: Too many syntax clusters"));
 	vim_free(name);
 	return 0;
     }
@@ -5661,7 +5661,7 @@ syn_cmd_cluster(exarg_T *eap, int syncin
 	    clstr_list = NULL;
 	    if (get_id_list(&rest, opt_len, &clstr_list, eap->skip) == FAIL)
 	    {
-		EMSG2(_(e_invarg2), rest);
+		semsg(_(e_invarg2), rest);
 		break;
 	    }
 	    if (scl_id >= 0)
@@ -5680,9 +5680,9 @@ syn_cmd_cluster(exarg_T *eap, int syncin
     }
 
     if (!got_clstr)
-	EMSG(_("E400: No cluster specified"));
+	emsg(_("E400: No cluster specified"));
     if (rest == NULL || !ends_excmd(*rest))
-	EMSG2(_(e_invarg2), arg);
+	semsg(_(e_invarg2), arg);
 }
 
 /*
@@ -5715,7 +5715,7 @@ get_syn_pattern(char_u *arg, synpat_T *c
     end = skip_regexp(arg + 1, *arg, TRUE, NULL);
     if (*end != *arg)			    /* end delimiter not found */
     {
-	EMSG2(_("E401: Pattern delimiter not found: %s"), arg);
+	semsg(_("E401: Pattern delimiter not found: %s"), arg);
 	return NULL;
     }
     /* store the pattern and compiled regexp program */
@@ -5793,7 +5793,7 @@ get_syn_pattern(char_u *arg, synpat_T *c
 
     if (!ends_excmd(*end) && !VIM_ISWHITE(*end))
     {
-	EMSG2(_("E402: Garbage after pattern: %s"), arg);
+	semsg(_("E402: Garbage after pattern: %s"), arg);
 	return NULL;
     }
     return skipwhite(end);
@@ -5885,7 +5885,7 @@ syn_cmd_sync(exarg_T *eap, int syncing U
 	    }
 	    if (curwin->w_s->b_syn_linecont_pat != NULL)
 	    {
-		EMSG(_("E403: syntax sync: line continuations pattern specified twice"));
+		emsg(_("E403: syntax sync: line continuations pattern specified twice"));
 		finished = TRUE;
 		break;
 	    }
@@ -5944,7 +5944,7 @@ syn_cmd_sync(exarg_T *eap, int syncing U
     }
     vim_free(key);
     if (illegal)
-	EMSG2(_("E404: Illegal arguments: %s"), arg_start);
+	semsg(_("E404: Illegal arguments: %s"), arg_start);
     else if (!finished)
     {
 	eap->nextcmd = check_nextcmd(arg_start);
@@ -5995,13 +5995,13 @@ get_id_list(
 	p = skipwhite(*arg + keylen);
 	if (*p != '=')
 	{
-	    EMSG2(_("E405: Missing equal sign: %s"), *arg);
+	    semsg(_("E405: Missing equal sign: %s"), *arg);
 	    break;
 	}
 	p = skipwhite(p + 1);
 	if (ends_excmd(*p))
 	{
-	    EMSG2(_("E406: Empty argument: %s"), *arg);
+	    semsg(_("E406: Empty argument: %s"), *arg);
 	    break;
 	}
 
@@ -6027,14 +6027,14 @@ get_id_list(
 	    {
 		if (TOUPPER_ASC(**arg) != 'C')
 		{
-		    EMSG2(_("E407: %s not allowed here"), name + 1);
+		    semsg(_("E407: %s not allowed here"), name + 1);
 		    failed = TRUE;
 		    vim_free(name);
 		    break;
 		}
 		if (count != 0)
 		{
-		    EMSG2(_("E408: %s must be first in contains list"),
+		    semsg(_("E408: %s must be first in contains list"),
 								     name + 1);
 		    failed = TRUE;
 		    vim_free(name);
@@ -6108,7 +6108,7 @@ get_id_list(
 	    vim_free(name);
 	    if (id == 0)
 	    {
-		EMSG2(_("E409: Unknown group name: %s"), p);
+		semsg(_("E409: Unknown group name: %s"), p);
 		failed = TRUE;
 		break;
 	    }
@@ -6343,7 +6343,7 @@ ex_syntax(exarg_T *eap)
 	{
 	    if (subcommands[i].name == NULL)
 	    {
-		EMSG2(_("E410: Invalid :syntax subcommand: %s"), subcmd_name);
+		semsg(_("E410: Invalid :syntax subcommand: %s"), subcmd_name);
 		break;
 	    }
 	    if (STRCMP(subcmd_name, (char_u *)subcommands[i].name) == 0)
@@ -6648,7 +6648,7 @@ ex_syntime(exarg_T *eap)
     else if (STRCMP(eap->arg, "report") == 0)
 	syntime_report();
     else
-	EMSG2(_(e_invarg2), eap->arg);
+	semsg(_(e_invarg2), eap->arg);
 }
 
     static void
@@ -7158,7 +7158,7 @@ init_highlight(
 	static int	recursive = 0;
 
 	if (recursive >= 5)
-	    EMSG(_("E679: recursive loop loading syncolor.vim"));
+	    emsg(_("E679: recursive loop loading syncolor.vim"));
 	else
 	{
 	    ++recursive;
@@ -7407,7 +7407,7 @@ do_highlight(
     {
 	id = syn_namen2id(line, (int)(name_end - line));
 	if (id == 0)
-	    EMSG2(_("E411: highlight group not found: %s"), line);
+	    semsg(_("E411: highlight group not found: %s"), line);
 	else
 	    highlight_list_one(id);
 	return;
@@ -7431,14 +7431,14 @@ do_highlight(
 
 	if (ends_excmd(*from_start) || ends_excmd(*to_start))
 	{
-	    EMSG2(_("E412: Not enough arguments: \":highlight link %s\""),
+	    semsg(_("E412: Not enough arguments: \":highlight link %s\""),
 								  from_start);
 	    return;
 	}
 
 	if (!ends_excmd(*skipwhite(to_end)))
 	{
-	    EMSG2(_("E413: Too many arguments: \":highlight link %s\""), from_start);
+	    semsg(_("E413: Too many arguments: \":highlight link %s\""), from_start);
 	    return;
 	}
 
@@ -7458,7 +7458,7 @@ do_highlight(
 				   && hl_has_settings(from_id - 1, dodefault))
 	    {
 		if (sourcing_name == NULL && !dodefault)
-		    EMSG(_("E414: group has settings, highlight link ignored"));
+		    emsg(_("E414: group has settings, highlight link ignored"));
 	    }
 	    else if (HL_TABLE()[from_id - 1].sg_link != to_id
 #ifdef FEAT_EVAL
@@ -7605,7 +7605,7 @@ do_highlight(
 	key_start = linep;
 	if (*linep == '=')
 	{
-	    EMSG2(_("E415: unexpected equal sign: %s"), key_start);
+	    semsg(_("E415: unexpected equal sign: %s"), key_start);
 	    error = TRUE;
 	    break;
 	}
@@ -7641,7 +7641,7 @@ do_highlight(
 	 */
 	if (*linep != '=')
 	{
-	    EMSG2(_("E416: missing equal sign: %s"), key_start);
+	    semsg(_("E416: missing equal sign: %s"), key_start);
 	    error = TRUE;
 	    break;
 	}
@@ -7657,7 +7657,7 @@ do_highlight(
 	    linep = vim_strchr(linep, '\'');
 	    if (linep == NULL)
 	    {
-		EMSG2(_(e_invarg2), key_start);
+		semsg(_(e_invarg2), key_start);
 		error = TRUE;
 		break;
 	    }
@@ -7669,7 +7669,7 @@ do_highlight(
 	}
 	if (linep == arg_start)
 	{
-	    EMSG2(_("E417: missing argument: %s"), key_start);
+	    semsg(_("E417: missing argument: %s"), key_start);
 	    error = TRUE;
 	    break;
 	}
@@ -7706,7 +7706,7 @@ do_highlight(
 		}
 		if (i < 0)
 		{
-		    EMSG2(_("E418: Illegal value: %s"), arg);
+		    semsg(_("E418: Illegal value: %s"), arg);
 		    error = TRUE;
 		    break;
 		}
@@ -7831,7 +7831,7 @@ do_highlight(
 		    color = cterm_normal_fg_color - 1;
 		else
 		{
-		    EMSG(_("E419: FG color unknown"));
+		    emsg(_("E419: FG color unknown"));
 		    error = TRUE;
 		    break;
 		}
@@ -7842,7 +7842,7 @@ do_highlight(
 		    color = cterm_normal_bg_color - 1;
 		else
 		{
-		    EMSG(_("E420: BG color unknown"));
+		    emsg(_("E420: BG color unknown"));
 		    error = TRUE;
 		    break;
 		}
@@ -7866,7 +7866,7 @@ do_highlight(
 			break;
 		if (i < 0)
 		{
-		    EMSG2(_("E421: Color name or number not recognized: %s"), key_start);
+		    semsg(_("E421: Color name or number not recognized: %s"), key_start);
 		    error = TRUE;
 		    break;
 		}
@@ -8113,7 +8113,7 @@ do_highlight(
 		    /* Append it to the already found stuff */
 		    if ((int)(STRLEN(buf) + STRLEN(p)) >= 99)
 		    {
-			EMSG2(_("E422: terminal code too long: %s"), arg);
+			semsg(_("E422: terminal code too long: %s"), arg);
 			error = TRUE;
 			break;
 		    }
@@ -8160,7 +8160,7 @@ do_highlight(
 	}
 	else
 	{
-	    EMSG2(_("E423: Illegal argument: %s"), key_start);
+	    semsg(_("E423: Illegal argument: %s"), key_start);
 	    error = TRUE;
 	    break;
 	}
@@ -8827,7 +8827,7 @@ get_attr_entry(garray_T *table, attrentr
 	 */
 	if (recursive)
 	{
-	    EMSG(_("E424: Too many different highlighting attributes in use"));
+	    emsg(_("E424: Too many different highlighting attributes in use"));
 	    return 0;
 	}
 	recursive = TRUE;
@@ -9716,7 +9716,7 @@ syn_add_group(char_u *name)
     {
 	if (!vim_isprintc(*p))
 	{
-	    EMSG(_("E669: Unprintable character in group name"));
+	    emsg(_("E669: Unprintable character in group name"));
 	    vim_free(name);
 	    return 0;
 	}
@@ -9741,7 +9741,7 @@ syn_add_group(char_u *name)
 
     if (highlight_ga.ga_len >= MAX_HL_ID)
     {
-	EMSG(_("E849: Too many highlight and syntax groups"));
+	emsg(_("E849: Too many highlight and syntax groups"));
 	vim_free(name);
 	return 0;
     }