diff options
Diffstat (limited to 'src/nvim/if_cscope.c')
-rw-r--r-- | src/nvim/if_cscope.c | 91 |
1 files changed, 36 insertions, 55 deletions
diff --git a/src/nvim/if_cscope.c b/src/nvim/if_cscope.c index f3b46eb9e4..5b5f056164 100644 --- a/src/nvim/if_cscope.c +++ b/src/nvim/if_cscope.c @@ -64,7 +64,7 @@ static cscmd_T cs_cmds[] = static void cs_usage_msg(csid_e x) { - (void)EMSG2(_("E560: Usage: cs[cope] %s"), cs_cmds[(int)x].usage); + (void)semsg(_("E560: Usage: cs[cope] %s"), cs_cmds[(int)x].usage); } @@ -184,7 +184,7 @@ static void do_cscope_general(exarg_T *eap, int make_split) if (make_split) { if (!cmdp->cansplit) { - (void)MSG_PUTS(_("This cscope command does not support splitting the window.\n")); + (void)msg_puts(_("This cscope command does not support splitting the window.\n")); return; } postponed_split = -1; @@ -216,7 +216,7 @@ void ex_cstag(exarg_T *eap) int ret = FALSE; if (*eap->arg == NUL) { - (void)EMSG(_("E562: Usage: cstag <ident>")); + (void)emsg(_("E562: Usage: cstag <ident>")); return; } @@ -268,7 +268,7 @@ void ex_cstag(exarg_T *eap) } if (!ret) { - (void)EMSG(_("E257: cstag: tag not found")); + (void)emsg(_("E257: cstag: tag not found")); g_do_tagpreview = 0; } } @@ -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); } @@ -489,7 +485,7 @@ staterr: i = cs_insert_filelist(fname, ppath, flags, &file_info); } else { if (p_csverbose) { - (void)EMSG2(_("E564: %s is not a directory or a valid cscope database"), + (void)semsg(_("E564: %s is not a directory or a valid cscope database"), fname); } goto add_err; @@ -550,7 +546,7 @@ static size_t cs_cnt_connections(void) /// @param idx connection index static void cs_reading_emsg(size_t idx) { - EMSGU(_("E262: error reading cscope connection %" PRIu64), idx); + semsg(_("E262: error reading cscope connection %" PRIu64), (uint64_t)idx); } #define CSREAD_BUFSIZE 2048 @@ -662,7 +658,7 @@ static char *cs_create_cmd(char *csoption, char *pattern) search = 9; break; default: - (void)EMSG(_("E561: unknown cscope search type")); + (void)emsg(_("E561: unknown cscope search type")); cs_usage_msg(Find); return NULL; } @@ -700,7 +696,7 @@ static int cs_create_connection(size_t i) */ to_cs[0] = to_cs[1] = from_cs[0] = from_cs[1] = -1; if (pipe(to_cs) < 0 || pipe(from_cs) < 0) { - (void)EMSG(_("E566: Could not create cscope pipes")); + (void)emsg(_("E566: Could not create cscope pipes")); err_closing: if (to_cs[0] != -1) { (void)close(to_cs[0]); @@ -719,7 +715,7 @@ err_closing: switch (csinfo[i].pid = fork()) { case -1: - (void)EMSG(_("E622: Could not fork for cscope")); + (void)emsg(_("E622: Could not fork for cscope")); goto err_closing; case 0: // child: run cscope. if (dup2(to_cs[0], STDIN_FILENO) == -1) { @@ -752,7 +748,7 @@ err_closing: if (!(pipe_stdin = CreatePipe(&stdin_rd, &stdin_wr, &sa, 0)) || !(pipe_stdout = CreatePipe(&stdout_rd, &stdout_wr, &sa, 0))) { - (void)EMSG(_("E566: Could not create cscope pipes")); + (void)emsg(_("E566: Could not create cscope pipes")); err_closing: if (pipe_stdin) { CloseHandle(stdin_rd); @@ -856,7 +852,7 @@ err_closing: if (!created) { PERROR(_("cs_create_connection exec failed")); - (void)EMSG(_("E623: Could not spawn cscope process")); + (void)emsg(_("E623: Could not spawn cscope process")); goto err_closing; } // else @@ -892,7 +888,7 @@ static int cs_find(exarg_T *eap) char *opt, *pat; if (cs_check_for_connections() == FALSE) { - (void)EMSG(_("E567: no cscope connections")); + (void)emsg(_("E567: no cscope connections")); return FALSE; } @@ -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; } @@ -1050,7 +1031,7 @@ static int cs_find_common(char *opt, char *pat, int forceit, int verbose, int us f = os_fopen((char *)tmp, "w"); if (f == NULL) { - EMSG2(_(e_notopen), tmp); + semsg(_(e_notopen), tmp); } else { cs_file_results(f, nummatches); fclose(f); @@ -1106,7 +1087,7 @@ static int cs_help(exarg_T *eap) { cscmd_T *cmdp = cs_cmds; - (void)MSG_PUTS(_("cscope commands:\n")); + (void)msg_puts(_("cscope commands:\n")); while (cmdp->name != NULL) { char *help = _(cmdp->help); int space_cnt = 30 - vim_strsize((char_u *)help); @@ -1120,7 +1101,7 @@ static int cs_help(exarg_T *eap) help, space_cnt, " ", cmdp->usage); if (strcmp(cmdp->name, "find") == 0) { - MSG_PUTS(_("\n" + msg_puts(_("\n" " a: Find assignments to this symbol\n" " c: Find functions calling this function\n" " d: Find functions called by this function\n" @@ -1161,7 +1142,7 @@ static int cs_insert_filelist(char *fname, char *ppath, char *flags, FileInfo *f if (csinfo[j].fname != NULL && os_fileid_equal_fileinfo(&(csinfo[j].file_id), file_info)) { if (p_csverbose) { - (void)EMSG(_("E568: duplicate cscope database not added")); + (void)emsg(_("E568: duplicate cscope database not added")); } return CSCOPE_FAILURE; } @@ -1267,7 +1248,7 @@ static int cs_kill(exarg_T *eap) i = (size_t)num; } else { // All negative values besides -1 are invalid. if (p_csverbose) { - (void)EMSG2(_("E261: cscope connection %s not found"), stok); + (void)semsg(_("E261: cscope connection %s not found"), stok); } return CSCOPE_FAILURE; } @@ -1283,7 +1264,7 @@ static int cs_kill(exarg_T *eap) if (!killall && (i >= csinfo_size || csinfo[i].fname == NULL)) { if (p_csverbose) { - (void)EMSG2(_("E261: cscope connection %s not found"), stok); + (void)semsg(_("E261: cscope connection %s not found"), stok); } return CSCOPE_FAILURE; } else { @@ -1428,7 +1409,7 @@ static char *cs_manage_matches(char **matches, char **contexts, size_t totmatche cs_print_tags_priv(mp, cp, cnt); break; default: // should not reach here - IEMSG(_("E570: fatal error in cs_manage_matches")); + iemsg(_("E570: fatal error in cs_manage_matches")); return NULL; } @@ -1653,16 +1634,16 @@ static void cs_print_tags_priv(char **matches, char **cntxts, char *buf = xmalloc(newsize); size_t bufsize = newsize; // Track available bufsize (void)snprintf(buf, bufsize, cstag_msg, ptag); - MSG_PUTS_ATTR(buf, HL_ATTR(HLF_T)); + msg_puts_attr(buf, HL_ATTR(HLF_T)); msg_clr_eos(); // restore matches[0] *ptag_end = '\t'; // Column headers for match number, line number and filename. - MSG_PUTS_ATTR(_("\n # line"), HL_ATTR(HLF_T)); + msg_puts_attr(_("\n # line"), HL_ATTR(HLF_T)); msg_advance(msg_col + 2); - MSG_PUTS_ATTR(_("filename / context / line\n"), HL_ATTR(HLF_T)); + msg_puts_attr(_("filename / context / line\n"), HL_ATTR(HLF_T)); for (size_t i = 0; i < num_matches; i++) { assert(strcnt(matches[i], '\t') >= 2); @@ -1689,8 +1670,8 @@ static void cs_print_tags_priv(char **matches, char **cntxts, bufsize = newsize; } (void)snprintf(buf, bufsize, csfmt_str, i + 1, lno); - MSG_PUTS_ATTR(buf, HL_ATTR(HLF_CM)); - MSG_PUTS_LONG_ATTR(cs_pathcomponents(fname), HL_ATTR(HLF_CM)); + msg_puts_attr(buf, HL_ATTR(HLF_CM)); + msg_outtrans_long_attr((char_u *)cs_pathcomponents(fname), HL_ATTR(HLF_CM)); // compute the required space for the context char *context = cntxts[i] ? cntxts[i] : globalcntx; @@ -1712,11 +1693,11 @@ static void cs_print_tags_priv(char **matches, char **cntxts, msg_putchar('\n'); } msg_advance(12); - MSG_PUTS_LONG(buf); + msg_outtrans_long_attr((char_u *)buf, 0); msg_putchar('\n'); if (extra != NULL) { msg_advance(13); - MSG_PUTS_LONG(extra); + msg_outtrans_long_attr((char_u *)extra, 0); } // restore matches[i] @@ -1776,7 +1757,7 @@ static int cs_read_prompt(size_t i) buf[bufpos - epromptlen] = NUL; // print message to user - (void)EMSG2(cs_emsg, buf); + (void)semsg(cs_emsg, buf); // send RETURN to cscope (void)putc('\n', csinfo[i].to_fp); @@ -1799,7 +1780,7 @@ static int cs_read_prompt(size_t i) if (ch == EOF) { PERROR("cs_read_prompt EOF"); if (buf != NULL && buf[0] != NUL) { - (void)EMSG2(cs_emsg, buf); + (void)semsg(cs_emsg, buf); } else if (p_csverbose) { cs_reading_emsg(i); // don't have additional information } @@ -1986,7 +1967,7 @@ static int cs_reset(exarg_T *eap) // connection number in the same line as // "Added cscope database..." snprintf(buf, ARRAY_SIZE(buf), " (#%zu)", i); - MSG_PUTS_ATTR(buf, HL_ATTR(HLF_R)); + msg_puts_attr(buf, HL_ATTR(HLF_R)); } } xfree(dblist[i]); @@ -2059,9 +2040,9 @@ static char *cs_resolve_file(size_t i, char *name) static int cs_show(exarg_T *eap) { if (cs_cnt_connections() == 0) { - MSG_PUTS(_("no cscope connections\n")); + msg_puts(_("no cscope connections\n")); } else { - MSG_PUTS_ATTR(_(" # pid database name prepend path\n"), + msg_puts_attr(_(" # pid database name prepend path\n"), HL_ATTR(HLF_T)); for (size_t i = 0; i < csinfo_size; i++) { if (csinfo[i].fname == NULL) { |