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.
diff --git a/src/regexp_nfa.c b/src/regexp_nfa.c
index d779fee..15547bb 100644
--- a/src/regexp_nfa.c
+++ b/src/regexp_nfa.c
@@ -1303,11 +1303,11 @@
{
if (extra == NFA_ADD_NL)
{
- EMSGN(_(e_ill_char_class), c);
+ semsg(_(e_ill_char_class), c);
rc_did_emsg = TRUE;
return FAIL;
}
- IEMSGN("INTERNAL: Unknown character class char: %ld", c);
+ siemsg("INTERNAL: Unknown character class char: %ld", c);
return FAIL;
}
#ifdef FEAT_MBYTE
@@ -1349,7 +1349,7 @@
case Magic('|'):
case Magic('&'):
case Magic(')'):
- EMSGN(_(e_misplaced), no_Magic(c));
+ semsg(_(e_misplaced), no_Magic(c));
return FAIL;
case Magic('='):
@@ -1359,7 +1359,7 @@
case Magic('*'):
case Magic('{'):
/* these should follow an atom, not form an atom */
- EMSGN(_(e_misplaced), no_Magic(c));
+ semsg(_(e_misplaced), no_Magic(c));
return FAIL;
case Magic('~'):
@@ -1370,7 +1370,7 @@
* Generated as "\%(pattern\)". */
if (reg_prev_sub == NULL)
{
- EMSG(_(e_nopresub));
+ emsg(_(e_nopresub));
return FAIL;
}
for (lp = reg_prev_sub; *lp != NUL; MB_CPTR_ADV(lp))
@@ -1445,7 +1445,7 @@
break;
#endif
default:
- EMSGN(_("E867: (NFA) Unknown operator '\\z%c'"),
+ semsg(_("E867: (NFA) Unknown operator '\\z%c'"),
no_Magic(c));
return FAIL;
}
@@ -1577,7 +1577,7 @@
#if VIM_SIZEOF_INT < VIM_SIZEOF_LONG
if (n > INT_MAX)
{
- EMSG(_("E951: \\% value too large"));
+ emsg(_("E951: \\% value too large"));
return FAIL;
}
#endif
@@ -1593,7 +1593,7 @@
break;
}
}
- EMSGN(_("E867: (NFA) Unknown operator '\\%%%c'"),
+ semsg(_("E867: (NFA) Unknown operator '\\%%%c'"),
no_Magic(c));
return FAIL;
}
@@ -2071,7 +2071,7 @@
}
if (i == 0)
{
- EMSGN(_("E869: (NFA) Unknown operator '\\@%c'"), op);
+ semsg(_("E869: (NFA) Unknown operator '\\@%c'"), op);
return FAIL;
}
EMIT(i);
@@ -2928,7 +2928,7 @@
fclose(df);
}
#endif
- EMSG(_("E874: (NFA) Could not pop the stack!"));
+ emsg(_("E874: (NFA) Could not pop the stack!"));
}
/*
@@ -4877,7 +4877,7 @@
default:
/* should not be here :P */
- IEMSGN(_(e_ill_char_class), class);
+ siemsg(_(e_ill_char_class), class);
return FAIL;
}
return FAIL;
@@ -5146,7 +5146,7 @@
*listids = (int *)lalloc(sizeof(int) * prog->nstate, TRUE);
if (*listids == NULL)
{
- EMSG(_("E878: (NFA) Could not allocate memory for branch traversal!"));
+ emsg(_("E878: (NFA) Could not allocate memory for branch traversal!"));
return 0;
}
*listids_len = prog->nstate;
@@ -5201,7 +5201,7 @@
}
else
{
- EMSG(_(e_log_open_failed));
+ emsg(_(e_log_open_failed));
log_fd = stderr;
}
#endif
@@ -5521,7 +5521,7 @@
debug = fopen(NFA_REGEXP_DEBUG_LOG, "a");
if (debug == NULL)
{
- EMSG2("(NFA) COULD NOT OPEN %s!", NFA_REGEXP_DEBUG_LOG);
+ semsg("(NFA) COULD NOT OPEN %s!", NFA_REGEXP_DEBUG_LOG);
return FALSE;
}
#endif
@@ -5549,7 +5549,7 @@
}
else
{
- EMSG(_(e_log_open_failed));
+ emsg(_(e_log_open_failed));
log_fd = stderr;
}
#endif
@@ -6670,7 +6670,7 @@
#ifdef DEBUG
if (c < 0)
- IEMSGN("INTERNAL: Negative state char: %ld", c);
+ siemsg("INTERNAL: Negative state char: %ld", c);
#endif
result = (c == curc);
@@ -6961,7 +6961,7 @@
fclose(f);
}
else
- EMSG("Could not open temporary log file for writing");
+ emsg("Could not open temporary log file for writing");
#endif
clear_sub(&subs.norm);
@@ -7094,7 +7094,7 @@
/* Be paranoid... */
if (prog == NULL || line == NULL)
{
- EMSG(_(e_null));
+ emsg(_(e_null));
goto theend;
}
@@ -7212,7 +7212,7 @@
{
/* TODO: only give this error for debugging? */
if (post_ptr >= post_end)
- IEMSGN("Internal error: estimated max number of states insufficient: %ld", post_end - post_start);
+ siemsg("Internal error: estimated max number of states insufficient: %ld", post_end - post_start);
goto fail; /* Cascaded (syntax?) error */
}