aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/memline.c
diff options
context:
space:
mode:
authorJames McCoy <jamessan@jamessan.com>2021-10-18 09:08:46 -0400
committerJames McCoy <jamessan@jamessan.com>2021-11-01 06:41:28 -0400
commitefa924f66b183d9cf2404ce91c4f009c27e0515a (patch)
treeadc8c74cba88e76c2ae0548cd6e9b01804da9933 /src/nvim/memline.c
parent684640f5518a483cf2bc48efc8f68449379cef69 (diff)
downloadrneovim-efa924f66b183d9cf2404ce91c4f009c27e0515a.tar.gz
rneovim-efa924f66b183d9cf2404ce91c4f009c27e0515a.tar.bz2
rneovim-efa924f66b183d9cf2404ce91c4f009c27e0515a.zip
vim-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 vim/vim#3302) Also make emsg() accept a "char *" argument. Get rid of an enormous number of type casts. https://github.com/vim/vim/commit/f9e3e09fdc93be9f0d47afbc6c7df1188c2a5a0d
Diffstat (limited to 'src/nvim/memline.c')
-rw-r--r--src/nvim/memline.c68
1 files changed, 34 insertions, 34 deletions
diff --git a/src/nvim/memline.c b/src/nvim/memline.c
index 0d3164f578..b8f0cde70e 100644
--- a/src/nvim/memline.c
+++ b/src/nvim/memline.c
@@ -2,7 +2,7 @@
// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
// for debugging
-// #define CHECK(c, s) do { if (c) EMSG(s); } while (0)
+// #define CHECK(c, s) do { if (c) emsg(s); } while (0)
#define CHECK(c, s) do { } while (0)
/*
@@ -296,7 +296,7 @@ int ml_open(buf_T *buf)
*/
hp = mf_new(mfp, false, 1);
if (hp->bh_bnum != 0) {
- IEMSG(_("E298: Didn't get block nr 0?"));
+ iemsg(_("E298: Didn't get block nr 0?"));
goto error;
}
b0p = hp->bh_data;
@@ -340,7 +340,7 @@ int ml_open(buf_T *buf)
goto error;
}
if (hp->bh_bnum != 1) {
- IEMSG(_("E298: Didn't get block nr 1?"));
+ iemsg(_("E298: Didn't get block nr 1?"));
goto error;
}
pp = hp->bh_data;
@@ -356,7 +356,7 @@ int ml_open(buf_T *buf)
*/
hp = ml_new_data(mfp, false, 1);
if (hp->bh_bnum != 2) {
- IEMSG(_("E298: Didn't get block nr 2?"));
+ iemsg(_("E298: Didn't get block nr 2?"));
goto error;
}
@@ -448,13 +448,13 @@ void ml_setname(buf_T *buf)
mfp->mf_fd = os_open((char *)mfp->mf_fname, O_RDWR, 0);
if (mfp->mf_fd < 0) {
// could not (re)open the swap file, what can we do????
- EMSG(_("E301: Oops, lost the swap file!!!"));
+ emsg(_("E301: Oops, lost the swap file!!!"));
return;
}
(void)os_set_cloexec(mfp->mf_fd);
}
if (!success) {
- EMSG(_("E302: Could not rename swap file"));
+ emsg(_("E302: Could not rename swap file"));
}
}
@@ -538,7 +538,7 @@ void ml_open_file(buf_T *buf)
if (*p_dir != NUL && mfp->mf_fname == NULL) {
need_wait_return = true; // call wait_return later
no_wait_return++;
- (void)EMSG2(_("E303: Unable to open swap file for \"%s\", recovery impossible"),
+ (void)semsg(_("E303: Unable to open swap file for \"%s\", recovery impossible"),
buf_spname(buf) != NULL ? buf_spname(buf) : buf->b_fname);
--no_wait_return;
}
@@ -654,7 +654,7 @@ static void ml_upd_block0(buf_T *buf, upd_block0_T what)
}
b0p = hp->bh_data;
if (ml_check_b0_id(b0p) == FAIL) {
- IEMSG(_("E304: ml_upd_block0(): Didn't get block 0??"));
+ iemsg(_("E304: ml_upd_block0(): Didn't get block 0??"));
} else {
if (what == UB_FNAME) {
set_b0_fname(b0p, buf);
@@ -814,7 +814,7 @@ void ml_recover(bool checkext)
// count the number of matching swap files
len = recover_names(fname, FALSE, 0, NULL);
if (len == 0) { // no swap files found
- EMSG2(_("E305: No swap file found for %s"), fname);
+ semsg(_("E305: No swap file found for %s"), fname);
goto theend;
}
if (len == 1) { // one swap file found, use it
@@ -865,7 +865,7 @@ void ml_recover(bool checkext)
mfp = mf_open(fname_used, O_RDONLY);
fname_used = p;
if (mfp == NULL || mfp->mf_fd < 0) {
- EMSG2(_("E306: Cannot open %s"), fname_used);
+ semsg(_("E306: Cannot open %s"), fname_used);
goto theend;
}
buf->b_ml.ml_mfp = mfp;
@@ -901,7 +901,7 @@ void ml_recover(bool checkext)
goto theend;
}
if (ml_check_b0_id(b0p) == FAIL) {
- EMSG2(_("E307: %s does not look like a Vim swap file"), mfp->mf_fname);
+ semsg(_("E307: %s does not look like a Vim swap file"), mfp->mf_fname);
goto theend;
}
if (b0_magic_wrong(b0p)) {
@@ -982,7 +982,7 @@ void ml_recover(bool checkext)
&& org_file_info.stat.st_mtim.tv_sec
> swp_file_info.stat.st_mtim.tv_sec)
|| org_file_info.stat.st_mtim.tv_sec != mtime)) {
- EMSG(_("E308: Warning: Original file may have been changed"));
+ emsg(_("E308: Warning: Original file may have been changed"));
}
ui_flush();
@@ -1052,7 +1052,7 @@ void ml_recover(bool checkext)
*/
if ((hp = mf_get(mfp, bnum, page_count)) == NULL) {
if (bnum == 1) {
- EMSG2(_("E309: Unable to read block 1 from %s"), mfp->mf_fname);
+ semsg(_("E309: Unable to read block 1 from %s"), mfp->mf_fname);
goto theend;
}
++error;
@@ -1121,7 +1121,7 @@ void ml_recover(bool checkext)
dp = hp->bh_data;
if (dp->db_id != DATA_ID) { // block id wrong
if (bnum == 1) {
- EMSG2(_("E310: Block 1 ID wrong (%s not a .swp file?)"),
+ semsg(_("E310: Block 1 ID wrong (%s not a .swp file?)"),
mfp->mf_fname);
goto theend;
}
@@ -1232,11 +1232,11 @@ void ml_recover(bool checkext)
recoverymode = FALSE;
if (got_int) {
- EMSG(_("E311: Recovery Interrupted"));
+ emsg(_("E311: Recovery Interrupted"));
} else if (error) {
++no_wait_return;
MSG(">>>>>>>>>>>>>");
- EMSG(_( "E312: Errors detected while recovering; look for lines starting with ???"));
+ emsg(_( "E312: Errors detected while recovering; look for lines starting with ???"));
--no_wait_return;
MSG(_("See \":help E312\" for more information."));
MSG(">>>>>>>>>>>>>");
@@ -1756,7 +1756,7 @@ void ml_preserve(buf_T *buf, int message, bool do_fsync)
if (mfp == NULL || mfp->mf_fname == NULL) {
if (message) {
- EMSG(_("E313: Cannot preserve, there is no swap file"));
+ emsg(_("E313: Cannot preserve, there is no swap file"));
}
return;
}
@@ -1809,7 +1809,7 @@ theend:
if (status == OK) {
MSG(_("File preserved"));
} else {
- EMSG(_("E314: Preserve failed"));
+ emsg(_("E314: Preserve failed"));
}
}
}
@@ -1857,7 +1857,7 @@ char_u *ml_get_buf(buf_T *buf, linenr_T lnum, bool will_change)
// Avoid giving this message for a recursive call, may happen when
// the GUI redraws part of the text.
recursive++;
- IEMSGN(_("E315: ml_get: invalid lnum: %" PRId64), lnum);
+ siemsg(_("E315: ml_get: invalid lnum: %" PRId64), (int64_t)lnum);
recursive--;
}
errorret:
@@ -1893,8 +1893,8 @@ errorret:
recursive++;
get_trans_bufname(buf);
shorten_dir(NameBuff);
- iemsgf(_("E316: ml_get: cannot find line %" PRId64 " in buffer %d %s"),
- lnum, buf->b_fnum, NameBuff);
+ siemsg(_("E316: ml_get: cannot find line %" PRId64 " in buffer %d %s"),
+ (int64_t)lnum, buf->b_fnum, NameBuff);
recursive--;
}
goto errorret;
@@ -2295,7 +2295,7 @@ static int ml_append_int(buf_T *buf, linenr_T lnum, char_u *line, colnr_T len, b
}
pp = hp->bh_data; // must be pointer block
if (pp->pb_id != PTR_ID) {
- IEMSG(_("E317: pointer block id wrong 3"));
+ iemsg(_("E317: pointer block id wrong 3"));
mf_put(mfp, hp, false, false);
return FAIL;
}
@@ -2437,7 +2437,7 @@ static int ml_append_int(buf_T *buf, linenr_T lnum, char_u *line, colnr_T len, b
* Safety check: fallen out of for loop?
*/
if (stack_idx < 0) {
- IEMSG(_("E318: Updated too many blocks?"));
+ iemsg(_("E318: Updated too many blocks?"));
buf->b_ml.ml_stack_top = 0; // invalidate stack
}
}
@@ -2629,7 +2629,7 @@ static int ml_delete_int(buf_T *buf, linenr_T lnum, bool message)
}
pp = hp->bh_data; // must be pointer block
if (pp->pb_id != PTR_ID) {
- IEMSG(_("E317: pointer block id wrong 4"));
+ iemsg(_("E317: pointer block id wrong 4"));
mf_put(mfp, hp, false, false);
return FAIL;
}
@@ -2845,7 +2845,7 @@ static void ml_flush_line(buf_T *buf)
hp = ml_find_line(buf, lnum, ML_FIND);
if (hp == NULL) {
- IEMSGN(_("E320: Cannot find line %" PRId64), lnum);
+ siemsg(_("E320: Cannot find line %" PRId64), (int64_t)lnum);
} else {
dp = hp->bh_data;
idx = lnum - buf->b_ml.ml_locked_low;
@@ -3060,7 +3060,7 @@ static bhdr_T *ml_find_line(buf_T *buf, linenr_T lnum, int action)
pp = (PTR_BL *)(dp); // must be pointer block
if (pp->pb_id != PTR_ID) {
- IEMSG(_("E317: pointer block id wrong"));
+ iemsg(_("E317: pointer block id wrong"));
goto error_block;
}
@@ -3099,10 +3099,10 @@ static bhdr_T *ml_find_line(buf_T *buf, linenr_T lnum, int action)
}
if (idx >= (int)pp->pb_count) { // past the end: something wrong!
if (lnum > buf->b_ml.ml_line_count) {
- IEMSGN(_("E322: line number out of range: %" PRId64 " past the end"),
- lnum - buf->b_ml.ml_line_count);
+ siemsg(_("E322: line number out of range: %" PRId64 " past the end"),
+ (int64_t)lnum - buf->b_ml.ml_line_count);
} else {
- IEMSGN(_("E323: line count wrong in block %" PRId64), bnum);
+ siemsg(_("E323: line count wrong in block %" PRId64), bnum);
}
goto error_block;
}
@@ -3181,7 +3181,7 @@ static void ml_lineadd(buf_T *buf, int count)
pp = hp->bh_data; // must be pointer block
if (pp->pb_id != PTR_ID) {
mf_put(mfp, hp, false, false);
- IEMSG(_("E317: pointer block id wrong 2"));
+ iemsg(_("E317: pointer block id wrong 2"));
break;
}
pp->pb_pointer[ip->ip_index].pe_line_count += count;
@@ -3214,7 +3214,7 @@ int resolve_symlink(const char_u *fname, char_u *buf)
for (;; ) {
// Limit symlink depth to 100, catch recursive loops.
if (++depth == 100) {
- EMSG2(_("E773: Symlink loop for \"%s\""), fname);
+ semsg(_("E773: Symlink loop for \"%s\""), fname);
return FAIL;
}
@@ -3356,7 +3356,7 @@ static void attention_message(buf_T *buf, char_u *fname)
assert(buf->b_fname != NULL);
++no_wait_return;
- (void)EMSG(_("E325: ATTENTION"));
+ (void)emsg(_("E325: ATTENTION"));
MSG_PUTS(_("\nFound a swap file by the name \""));
msg_home_replace(fname);
MSG_PUTS("\"\n");
@@ -3665,7 +3665,7 @@ static char *findswapname(buf_T *buf, char **dirp, char *old_fname, bool *found_
*/
if (fname[n - 1] == 'a') { // ".s?a"
if (fname[n - 2] == 'a') { // ".saa": tried enough, give up
- EMSG(_("E326: Too many swap files found"));
+ emsg(_("E326: Too many swap files found"));
XFREE_CLEAR(fname);
break;
}
@@ -3681,7 +3681,7 @@ static char *findswapname(buf_T *buf, char **dirp, char *old_fname, bool *found_
int ret;
char *failed_dir;
if ((ret = os_mkdir_recurse(dir_name, 0755, &failed_dir)) != 0) {
- EMSG3(_("E303: Unable to create directory \"%s\" for swap file, "
+ semsg(_("E303: Unable to create directory \"%s\" for swap file, "
"recovery impossible: %s"),
failed_dir, os_strerror(ret));
xfree(failed_dir);