From 9e479ea05e00e63ccc985fc8ce4912c709f30111 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Sun, 24 Oct 2021 11:04:28 -0400 Subject: vim-patch:8.2.3561: cscope has a complicated way of giving an error message Problem: Cscope has a complicated way of giving an error message. Solution: Use semsg(). (James McCoy, closes vim/vim#9038) https://github.com/vim/vim/commit/3c5904d2a5d7861c227a4c3cd4ddcbc51014c838 --- src/nvim/if_cscope.c | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) (limited to 'src/nvim/if_cscope.c') diff --git a/src/nvim/if_cscope.c b/src/nvim/if_cscope.c index 24a85e9595..5b5f056164 100644 --- a/src/nvim/if_cscope.c +++ b/src/nvim/if_cscope.c @@ -403,12 +403,8 @@ static int cs_add(exarg_T *eap) static void cs_stat_emsg(char *fname) { - char *stat_emsg = _("E563: stat(%s) error: %d"); - char *buf = xmalloc(strlen(stat_emsg) + MAXPATHL + 10); - - (void)sprintf(buf, stat_emsg, fname, errno); - (void)emsg(buf); - xfree(buf); + int err = errno; + (void)semsg(_("E563: stat(%s) error: %d"), fname, err); } @@ -970,13 +966,7 @@ static int cs_find_common(char *opt, char *pat, int forceit, int verbose, int us qfpos++; // next symbol must be + or - if (strchr(CSQF_FLAGS, *qfpos) == NULL) { - char *nf = _("E469: invalid cscopequickfix flag %c for %c"); - // strlen will be enough because we use chars - char *buf = xmalloc(strlen(nf)); - - sprintf(buf, nf, *qfpos, *(qfpos-1)); - (void)emsg(buf); - xfree(buf); + (void)semsg(_("E469: invalid cscopequickfix flag %c for %c"), *qfpos, *(qfpos - 1));; return FALSE; } @@ -1025,18 +1015,9 @@ static int cs_find_common(char *opt, char *pat, int forceit, int verbose, int us xfree(cmd); if (totmatches == 0) { - char *nf = _("E259: no matches found for cscope query %s of %s"); - char *buf; - - if (!verbose) { - xfree(nummatches); - return FALSE; + if (verbose) { + (void)semsg(_("E259: no matches found for cscope query %s of %s"), opt, pat); } - - buf = xmalloc(strlen(opt) + strlen(pat) + strlen(nf)); - sprintf(buf, nf, opt, pat); - (void)emsg(buf); - xfree(buf); xfree(nummatches); return FALSE; } -- cgit