comparison src/if_cscope.c @ 26055:109e9272cd5c v8.2.3561

patch 8.2.3561: cscope has a complicated way of giving an error message Commit: https://github.com/vim/vim/commit/3c5904d2a5d7861c227a4c3cd4ddcbc51014c838 Author: James McCoy <jamessan@jamessan.com> Date: Sun Oct 24 14:50:07 2021 +0100 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 https://github.com/vim/vim/issues/9038)
author Bram Moolenaar <Bram@vim.org>
date Sun, 24 Oct 2021 16:00:07 +0200
parents 336e2d9924e6
children 06a137af96f8
comparison
equal deleted inserted replaced
26054:813cc0f2e737 26055:109e9272cd5c
460 } 460 }
461 461
462 static void 462 static void
463 cs_stat_emsg(char *fname) 463 cs_stat_emsg(char *fname)
464 { 464 {
465 char *stat_emsg = _("E563: stat(%s) error: %d"); 465 int err = errno;
466 char *buf = alloc(strlen(stat_emsg) + MAXPATHL + 10); 466 (void)semsg(_("E563: stat(%s) error: %d"), fname, err);
467
468 if (buf != NULL)
469 {
470 (void)sprintf(buf, stat_emsg, fname, errno);
471 (void)emsg(buf);
472 vim_free(buf);
473 }
474 else
475 (void)emsg(_("E563: stat error"));
476 } 467 }
477 468
478 469
479 /* 470 /*
480 * The common routine to add a new cscope connection. Called by 471 * The common routine to add a new cscope connection. Called by
1112 { 1103 {
1113 qfpos++; 1104 qfpos++;
1114 // next symbol must be + or - 1105 // next symbol must be + or -
1115 if (strchr(CSQF_FLAGS, *qfpos) == NULL) 1106 if (strchr(CSQF_FLAGS, *qfpos) == NULL)
1116 { 1107 {
1117 char *nf = _("E469: invalid cscopequickfix flag %c for %c"); 1108 (void)semsg(_("E469: invalid cscopequickfix flag %c for %c"), *qfpos, *(qfpos - 1));
1118 char *buf = alloc(strlen(nf));
1119
1120 // strlen will be enough because we use chars
1121 if (buf != NULL)
1122 {
1123 sprintf(buf, nf, *qfpos, *(qfpos-1));
1124 (void)emsg(buf);
1125 vim_free(buf);
1126 }
1127 return FALSE; 1109 return FALSE;
1128 } 1110 }
1129 1111
1130 if (*qfpos != '0' 1112 if (*qfpos != '0'
1131 && apply_autocmds(EVENT_QUICKFIXCMDPRE, (char_u *)"cscope", 1113 && apply_autocmds(EVENT_QUICKFIXCMDPRE, (char_u *)"cscope",
1175 } 1157 }
1176 vim_free(cmd); 1158 vim_free(cmd);
1177 1159
1178 if (totmatches == 0) 1160 if (totmatches == 0)
1179 { 1161 {
1180 char *nf = _("E259: no matches found for cscope query %s of %s"); 1162 if (verbose)
1181 char *buf; 1163 (void)semsg(_("E259: no matches found for cscope query %s of %s"), opt, pat);
1182
1183 if (!verbose)
1184 {
1185 vim_free(nummatches);
1186 return FALSE;
1187 }
1188
1189 buf = alloc(strlen(opt) + strlen(pat) + strlen(nf));
1190 if (buf == NULL)
1191 (void)emsg(nf);
1192 else
1193 {
1194 sprintf(buf, nf, opt, pat);
1195 (void)emsg(buf);
1196 vim_free(buf);
1197 }
1198 vim_free(nummatches); 1164 vim_free(nummatches);
1199 return FALSE; 1165 return FALSE;
1200 } 1166 }
1201 1167
1202 #ifdef FEAT_QUICKFIX 1168 #ifdef FEAT_QUICKFIX