diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-01-13 23:38:42 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-01-13 23:38:42 +0100 |
commit | f9e3e09fdc93be9f0d47afbc6c7df1188c2a5a0d (patch) | |
tree | a6b07005c19279a4f5d01be14f14861c2657fa95 /src/regexp.c | |
parent | 05500ece6282407f9f7227aaf564e24147326863 (diff) | |
download | vim-git-f9e3e09fdc93be9f0d47afbc6c7df1188c2a5a0d.tar.gz |
patch 8.1.0743: giving error messages is not flexiblev8.1.0743
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.
Diffstat (limited to 'src/regexp.c')
-rw-r--r-- | src/regexp.c | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/src/regexp.c b/src/regexp.c index b7616416c..041928a82 100644 --- a/src/regexp.c +++ b/src/regexp.c @@ -334,11 +334,11 @@ 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 EMSG2_RET_NULL(m, c) return (EMSG2((m), (c) ? "" : "\\"), rc_did_emsg = TRUE, (void *)NULL) -#define EMSG2_RET_FAIL(m, c) return (EMSG2((m), (c) ? "" : "\\"), 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 (semsg((const char *)(m), (c) ? "" : "\\"), rc_did_emsg = TRUE, (void *)NULL) +#define EMSG2_RET_FAIL(m, c) return (semsg((const char *)(m), (c) ? "" : "\\"), rc_did_emsg = TRUE, FAIL) #define EMSG_ONE_RET_NULL EMSG2_RET_NULL(_("E369: invalid item in %s%%[]"), reg_magic == MAGIC_ALL) @@ -1304,7 +1304,7 @@ seen_endbrace(int refnum) break; if (*p == NUL) { - EMSG(_("E65: Illegal back reference")); + emsg(_("E65: Illegal back reference")); rc_did_emsg = TRUE; return FALSE; } @@ -1902,7 +1902,7 @@ 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; @@ -2078,7 +2078,7 @@ 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 */ @@ -3406,7 +3406,7 @@ read_limits(long *minval, long *maxval) { sprintf((char *)IObuff, _("E554: Syntax error in %s{...}"), reg_magic == MAGIC_ALL ? "" : "\\"); - EMSG_RET_FAIL(IObuff); + EMSG_RET_FAIL((char *)IObuff); } /* @@ -3826,7 +3826,7 @@ bt_regexec_both( /* Be paranoid... */ if (prog == NULL || line == NULL) { - EMSG(_(e_null)); + emsg(_(e_null)); goto theend; } @@ -5241,7 +5241,7 @@ regmatch( * 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 if (ga_grow(®stack, sizeof(regstar_T)) == FAIL) @@ -5286,7 +5286,7 @@ regmatch( /* 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 if (ga_grow(®stack, sizeof(regbehind_T)) == FAIL) @@ -5338,7 +5338,7 @@ regmatch( break; default: - EMSG(_(e_re_corr)); + emsg(_(e_re_corr)); #ifdef DEBUG printf("Illegal op code %d\n", op); #endif @@ -5748,7 +5748,7 @@ regmatch( * We get here only if there's trouble -- normally "case END" is * the terminating point. */ - EMSG(_(e_re_corr)); + emsg(_(e_re_corr)); #ifdef DEBUG printf("Premature EOL\n"); #endif @@ -5772,7 +5772,7 @@ regstack_push(regstate_T state, char_u *scan) if ((long)((unsigned)regstack.ga_len >> 10) >= p_mmp) { - EMSG(_(e_maxmempat)); + emsg(_(e_maxmempat)); return NULL; } if (ga_grow(®stack, sizeof(regitem_T)) == FAIL) @@ -6185,7 +6185,7 @@ do_class: break; default: /* Oh dear. Called inappropriately. */ - EMSG(_(e_re_corr)); + emsg(_(e_re_corr)); #ifdef DEBUG printf("Called regrepeat with op code %d\n", OP(p)); #endif @@ -6236,7 +6236,7 @@ prog_magic_wrong(void) if (UCHARAT(((bt_regprog_T *)prog)->program) != REGMAGIC) { - EMSG(_(e_re_corr)); + emsg(_(e_re_corr)); return TRUE; } return FALSE; @@ -7487,7 +7487,7 @@ vim_regsub_both( /* Be paranoid... */ if ((source == NULL && expr == NULL) || dest == NULL) { - EMSG(_(e_null)); + emsg(_(e_null)); return 0; } if (prog_magic_wrong()) @@ -7790,7 +7790,7 @@ vim_regsub_both( else if (*s == NUL) /* we hit NUL. */ { if (copy) - EMSG(_(e_re_damg)); + emsg(_(e_re_damg)); goto exit; } else @@ -8120,13 +8120,13 @@ vim_regcomp(char_u *expr_arg, int re_flags) regexp_engine = expr[4] - '0'; expr += 5; #ifdef DEBUG - smsg((char_u *)"New regexp mode selected (%d): %s", + smsg("New regexp mode selected (%d): %s", regexp_engine, regname[newengine]); #endif } else { - EMSG(_("E864: \\%#= can only be followed by 0, 1, or 2. The automatic engine will be used ")); + emsg(_("E864: \\%#= can only be followed by 0, 1, or 2. The automatic engine will be used ")); regexp_engine = AUTOMATIC_ENGINE; } } @@ -8158,7 +8158,7 @@ vim_regcomp(char_u *expr_arg, int re_flags) 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 @@ -8241,7 +8241,7 @@ vim_regexec_string( // 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; @@ -8365,7 +8365,7 @@ 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; |