mirror of
https://github.com/neovim/neovim.git
synced 2025-10-07 02:16:31 +00:00
vim-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
vim/vim#3302) Also make emsg() accept a "char *" argument. Get rid of
an enormous number of type casts.
f9e3e09fdc
This commit is contained in:
@@ -463,13 +463,13 @@ static int toggle_Magic(int x)
|
||||
|
||||
// Used for an error (down from) vim_regcomp(): give the error message, set
|
||||
// rc_did_emsg and return NULL
|
||||
#define EMSG_RET_NULL(m) return (EMSG(m), rc_did_emsg = true, (void *)NULL)
|
||||
#define IEMSG_RET_NULL(m) return (IEMSG(m), rc_did_emsg = true, (void *)NULL)
|
||||
#define EMSG_RET_FAIL(m) return (EMSG(m), rc_did_emsg = true, FAIL)
|
||||
#define EMSG_RET_NULL(m) return (emsg(m), rc_did_emsg = true, (void *)NULL)
|
||||
#define IEMSG_RET_NULL(m) return (iemsg(m), rc_did_emsg = true, (void *)NULL)
|
||||
#define EMSG_RET_FAIL(m) return (emsg(m), rc_did_emsg = true, FAIL)
|
||||
#define EMSG2_RET_NULL(m, c) \
|
||||
return (EMSG2((m), (c) ? "" : "\\"), rc_did_emsg = true, (void *)NULL)
|
||||
return (semsg((m), (c) ? "" : "\\"), rc_did_emsg = true, (void *)NULL)
|
||||
#define EMSG2_RET_FAIL(m, c) \
|
||||
return (EMSG2((m), (c) ? "" : "\\"), rc_did_emsg = true, FAIL)
|
||||
return (semsg((m), (c) ? "" : "\\"), rc_did_emsg = true, FAIL)
|
||||
#define EMSG_ONE_RET_NULL EMSG2_RET_NULL(_( \
|
||||
"E369: invalid item in %s%%[]"), reg_magic == MAGIC_ALL)
|
||||
|
||||
@@ -1237,7 +1237,7 @@ static int seen_endbrace(int refnum)
|
||||
}
|
||||
|
||||
if (*p == NUL) {
|
||||
EMSG(_("E65: Illegal back reference"));
|
||||
emsg(_("E65: Illegal back reference"));
|
||||
rc_did_emsg = true;
|
||||
return false;
|
||||
}
|
||||
@@ -1767,7 +1767,7 @@ static char_u *regpiece(int *flagp)
|
||||
else
|
||||
sprintf((char *)IObuff, _("E62: Nested %s%c"),
|
||||
reg_magic == MAGIC_ALL ? "" : "\\", no_Magic(peekchr()));
|
||||
EMSG_RET_NULL(IObuff);
|
||||
EMSG_RET_NULL((char *)IObuff);
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -1929,7 +1929,7 @@ static char_u *regatom(int *flagp)
|
||||
sprintf((char *)IObuff, _("E64: %s%c follows nothing"),
|
||||
(c == '*' ? reg_magic >= MAGIC_ON : reg_magic == MAGIC_ALL)
|
||||
? "" : "\\", c);
|
||||
EMSG_RET_NULL(IObuff);
|
||||
EMSG_RET_NULL((char *)IObuff);
|
||||
/* NOTREACHED */
|
||||
|
||||
case Magic('~'): /* previous substitute pattern */
|
||||
@@ -3153,7 +3153,7 @@ static int read_limits(long *minval, long *maxval)
|
||||
if (*regparse != '}') {
|
||||
sprintf((char *)IObuff, _("E554: Syntax error in %s{...}"),
|
||||
reg_magic == MAGIC_ALL ? "" : "\\");
|
||||
EMSG_RET_FAIL(IObuff);
|
||||
EMSG_RET_FAIL((char *)IObuff);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3483,7 +3483,7 @@ static long bt_regexec_both(char_u *line,
|
||||
|
||||
/* Be paranoid... */
|
||||
if (prog == NULL || line == NULL) {
|
||||
IEMSG(_(e_null));
|
||||
iemsg(_(e_null));
|
||||
goto theend;
|
||||
}
|
||||
|
||||
@@ -4730,7 +4730,7 @@ static bool regmatch(
|
||||
* follows. The code is below. Parameters are stored in
|
||||
* a regstar_T on the regstack. */
|
||||
if ((long)((unsigned)regstack.ga_len >> 10) >= p_mmp) {
|
||||
EMSG(_(e_maxmempat));
|
||||
emsg(_(e_maxmempat));
|
||||
status = RA_FAIL;
|
||||
} else {
|
||||
ga_grow(®stack, sizeof(regstar_T));
|
||||
@@ -4768,7 +4768,7 @@ static bool regmatch(
|
||||
case NOBEHIND:
|
||||
/* Need a bit of room to store extra positions. */
|
||||
if ((long)((unsigned)regstack.ga_len >> 10) >= p_mmp) {
|
||||
EMSG(_(e_maxmempat));
|
||||
emsg(_(e_maxmempat));
|
||||
status = RA_FAIL;
|
||||
} else {
|
||||
ga_grow(®stack, sizeof(regbehind_T));
|
||||
@@ -4816,7 +4816,7 @@ static bool regmatch(
|
||||
break;
|
||||
|
||||
default:
|
||||
IEMSG(_(e_re_corr));
|
||||
iemsg(_(e_re_corr));
|
||||
#ifdef REGEXP_DEBUG
|
||||
printf("Illegal op code %d\n", op);
|
||||
#endif
|
||||
@@ -5174,7 +5174,7 @@ static bool regmatch(
|
||||
* We get here only if there's trouble -- normally "case END" is
|
||||
* the terminating point.
|
||||
*/
|
||||
IEMSG(_(e_re_corr));
|
||||
iemsg(_(e_re_corr));
|
||||
#ifdef REGEXP_DEBUG
|
||||
printf("Premature EOL\n");
|
||||
#endif
|
||||
@@ -5196,7 +5196,7 @@ static regitem_T *regstack_push(regstate_T state, char_u *scan)
|
||||
regitem_T *rp;
|
||||
|
||||
if ((long)((unsigned)regstack.ga_len >> 10) >= p_mmp) {
|
||||
EMSG(_(e_maxmempat));
|
||||
emsg(_(e_maxmempat));
|
||||
return NULL;
|
||||
}
|
||||
ga_grow(®stack, sizeof(regitem_T));
|
||||
@@ -5581,7 +5581,7 @@ do_class:
|
||||
break;
|
||||
|
||||
default: // Oh dear. Called inappropriately.
|
||||
IEMSG(_(e_re_corr));
|
||||
iemsg(_(e_re_corr));
|
||||
#ifdef REGEXP_DEBUG
|
||||
printf("Called regrepeat with op code %d\n", OP(p));
|
||||
#endif
|
||||
@@ -5631,7 +5631,7 @@ static int prog_magic_wrong(void)
|
||||
}
|
||||
|
||||
if (UCHARAT(((bt_regprog_T *)prog)->program) != REGMAGIC) {
|
||||
EMSG(_(e_re_corr));
|
||||
emsg(_(e_re_corr));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -6689,7 +6689,7 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest,
|
||||
|
||||
// Be paranoid...
|
||||
if ((source == NULL && expr == NULL) || dest == NULL) {
|
||||
EMSG(_(e_null));
|
||||
emsg(_(e_null));
|
||||
return 0;
|
||||
}
|
||||
if (prog_magic_wrong())
|
||||
@@ -6943,7 +6943,7 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest,
|
||||
}
|
||||
} else if (*s == NUL) { // we hit NUL.
|
||||
if (copy) {
|
||||
IEMSG(_(e_re_damg));
|
||||
iemsg(_(e_re_damg));
|
||||
}
|
||||
goto exit;
|
||||
} else {
|
||||
@@ -7229,7 +7229,7 @@ regprog_T *vim_regcomp(char_u *expr_arg, int re_flags)
|
||||
regname[newengine]);
|
||||
#endif
|
||||
} else {
|
||||
EMSG(_(
|
||||
emsg(_(
|
||||
"E864: \\%#= can only be followed by 0, 1, or 2. The automatic engine will be used "));
|
||||
regexp_engine = AUTOMATIC_ENGINE;
|
||||
}
|
||||
@@ -7263,7 +7263,7 @@ regprog_T *vim_regcomp(char_u *expr_arg, int re_flags)
|
||||
fprintf(f, "Syntax error in \"%s\"\n", expr);
|
||||
fclose(f);
|
||||
} else
|
||||
EMSG2("(NFA) Could not open \"%s\" to write !!!",
|
||||
semsg("(NFA) Could not open \"%s\" to write !!!",
|
||||
BT_REGEXP_DEBUG_LOG_NAME);
|
||||
}
|
||||
#endif
|
||||
@@ -7328,7 +7328,7 @@ static bool vim_regexec_string(regmatch_T *rmp, char_u *line, colnr_T col,
|
||||
|
||||
// Cannot use the same prog recursively, it contains state.
|
||||
if (rmp->regprog->re_in_use) {
|
||||
EMSG(_(e_recursive));
|
||||
emsg(_(e_recursive));
|
||||
return false;
|
||||
}
|
||||
rmp->regprog->re_in_use = true;
|
||||
@@ -7425,7 +7425,7 @@ long vim_regexec_multi(
|
||||
|
||||
// Cannot use the same prog recursively, it contains state.
|
||||
if (rmp->regprog->re_in_use) {
|
||||
EMSG(_(e_recursive));
|
||||
emsg(_(e_recursive));
|
||||
return false;
|
||||
}
|
||||
rmp->regprog->re_in_use = true;
|
||||
|
Reference in New Issue
Block a user