mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
*: Make set_vim_var_\* functions have proper argument types
This commit is contained in:
parent
9af400f979
commit
494b1c9bee
@ -658,9 +658,9 @@ void ex_diffupdate(exarg_T *eap)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// We need three temp file names.
|
// We need three temp file names.
|
||||||
char_u *tmp_orig = vim_tempname();
|
char *tmp_orig = (char *) vim_tempname();
|
||||||
char_u *tmp_new = vim_tempname();
|
char *tmp_new = (char *) vim_tempname();
|
||||||
char_u *tmp_diff = vim_tempname();
|
char *tmp_diff = (char *) vim_tempname();
|
||||||
|
|
||||||
if ((tmp_orig == NULL) || (tmp_new == NULL) || (tmp_diff == NULL)) {
|
if ((tmp_orig == NULL) || (tmp_new == NULL) || (tmp_diff == NULL)) {
|
||||||
goto theend;
|
goto theend;
|
||||||
@ -670,11 +670,11 @@ void ex_diffupdate(exarg_T *eap)
|
|||||||
// are no differences. Can't use the return value, it's non-zero when
|
// are no differences. Can't use the return value, it's non-zero when
|
||||||
// there are differences.
|
// there are differences.
|
||||||
// May try twice, first with "-a" and then without.
|
// May try twice, first with "-a" and then without.
|
||||||
int io_error = FALSE;
|
int io_error = false;
|
||||||
int ok = FALSE;
|
bool ok = false;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
ok = FALSE;
|
ok = false;
|
||||||
FILE *fd = mch_fopen((char *)tmp_orig, "w");
|
FILE *fd = mch_fopen(tmp_orig, "w");
|
||||||
|
|
||||||
if (fd == NULL) {
|
if (fd == NULL) {
|
||||||
io_error = TRUE;
|
io_error = TRUE;
|
||||||
@ -683,7 +683,7 @@ void ex_diffupdate(exarg_T *eap)
|
|||||||
io_error = TRUE;
|
io_error = TRUE;
|
||||||
}
|
}
|
||||||
fclose(fd);
|
fclose(fd);
|
||||||
fd = mch_fopen((char *)tmp_new, "w");
|
fd = mch_fopen(tmp_new, "w");
|
||||||
|
|
||||||
if (fd == NULL) {
|
if (fd == NULL) {
|
||||||
io_error = TRUE;
|
io_error = TRUE;
|
||||||
@ -693,7 +693,7 @@ void ex_diffupdate(exarg_T *eap)
|
|||||||
}
|
}
|
||||||
fclose(fd);
|
fclose(fd);
|
||||||
diff_file(tmp_orig, tmp_new, tmp_diff);
|
diff_file(tmp_orig, tmp_new, tmp_diff);
|
||||||
fd = mch_fopen((char *)tmp_diff, "r");
|
fd = mch_fopen(tmp_diff, "r");
|
||||||
|
|
||||||
if (fd == NULL) {
|
if (fd == NULL) {
|
||||||
io_error = TRUE;
|
io_error = TRUE;
|
||||||
@ -712,10 +712,10 @@ void ex_diffupdate(exarg_T *eap)
|
|||||||
}
|
}
|
||||||
fclose(fd);
|
fclose(fd);
|
||||||
}
|
}
|
||||||
os_remove((char *)tmp_diff);
|
os_remove(tmp_diff);
|
||||||
os_remove((char *)tmp_new);
|
os_remove(tmp_new);
|
||||||
}
|
}
|
||||||
os_remove((char *)tmp_orig);
|
os_remove(tmp_orig);
|
||||||
}
|
}
|
||||||
|
|
||||||
// When using 'diffexpr' break here.
|
// When using 'diffexpr' break here.
|
||||||
@ -756,7 +756,7 @@ void ex_diffupdate(exarg_T *eap)
|
|||||||
|
|
||||||
// Write the first buffer to a tempfile.
|
// Write the first buffer to a tempfile.
|
||||||
buf_T *buf = curtab->tp_diffbuf[idx_orig];
|
buf_T *buf = curtab->tp_diffbuf[idx_orig];
|
||||||
if (diff_write(buf, tmp_orig) == FAIL) {
|
if (diff_write(buf, (char_u *) tmp_orig) == FAIL) {
|
||||||
goto theend;
|
goto theend;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -767,17 +767,17 @@ void ex_diffupdate(exarg_T *eap)
|
|||||||
continue; // skip buffer that isn't loaded
|
continue; // skip buffer that isn't loaded
|
||||||
}
|
}
|
||||||
|
|
||||||
if (diff_write(buf, tmp_new) == FAIL) {
|
if (diff_write(buf, (char_u *) tmp_new) == FAIL) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
diff_file(tmp_orig, tmp_new, tmp_diff);
|
diff_file(tmp_orig, tmp_new, tmp_diff);
|
||||||
|
|
||||||
// Read the diff output and add each entry to the diff list.
|
// Read the diff output and add each entry to the diff list.
|
||||||
diff_read(idx_orig, idx_new, tmp_diff);
|
diff_read(idx_orig, idx_new, (char_u *) tmp_diff);
|
||||||
os_remove((char *)tmp_diff);
|
os_remove(tmp_diff);
|
||||||
os_remove((char *)tmp_new);
|
os_remove(tmp_new);
|
||||||
}
|
}
|
||||||
os_remove((char *)tmp_orig);
|
os_remove(tmp_orig);
|
||||||
|
|
||||||
// force updating cursor position on screen
|
// force updating cursor position on screen
|
||||||
curwin->w_valid_cursor.lnum = 0;
|
curwin->w_valid_cursor.lnum = 0;
|
||||||
@ -795,15 +795,16 @@ theend:
|
|||||||
/// @param tmp_orig
|
/// @param tmp_orig
|
||||||
/// @param tmp_new
|
/// @param tmp_new
|
||||||
/// @param tmp_diff
|
/// @param tmp_diff
|
||||||
static void diff_file(char_u *tmp_orig, char_u *tmp_new, char_u *tmp_diff)
|
static void diff_file(const char *const tmp_orig, const char *const tmp_new,
|
||||||
|
const char *const tmp_diff)
|
||||||
{
|
{
|
||||||
if (*p_dex != NUL) {
|
if (*p_dex != NUL) {
|
||||||
// Use 'diffexpr' to generate the diff file.
|
// Use 'diffexpr' to generate the diff file.
|
||||||
eval_diff(tmp_orig, tmp_new, tmp_diff);
|
eval_diff(tmp_orig, tmp_new, tmp_diff);
|
||||||
} else {
|
} else {
|
||||||
size_t len = STRLEN(tmp_orig) + STRLEN(tmp_new) + STRLEN(tmp_diff)
|
const size_t len = (strlen(tmp_orig) + strlen(tmp_new) + strlen(tmp_diff)
|
||||||
+ STRLEN(p_srr) + 27;
|
+ STRLEN(p_srr) + 27);
|
||||||
char_u *cmd = xmalloc(len);
|
char *const cmd = xmalloc(len);
|
||||||
|
|
||||||
/* We don't want $DIFF_OPTIONS to get in the way. */
|
/* We don't want $DIFF_OPTIONS to get in the way. */
|
||||||
if (os_getenv("DIFF_OPTIONS")) {
|
if (os_getenv("DIFF_OPTIONS")) {
|
||||||
@ -813,19 +814,17 @@ static void diff_file(char_u *tmp_orig, char_u *tmp_new, char_u *tmp_diff)
|
|||||||
/* Build the diff command and execute it. Always use -a, binary
|
/* Build the diff command and execute it. Always use -a, binary
|
||||||
* differences are of no use. Ignore errors, diff returns
|
* differences are of no use. Ignore errors, diff returns
|
||||||
* non-zero when differences have been found. */
|
* non-zero when differences have been found. */
|
||||||
vim_snprintf((char *)cmd, len, "diff %s%s%s%s%s %s",
|
vim_snprintf(cmd, len, "diff %s%s%s%s%s %s",
|
||||||
diff_a_works == FALSE ? "" : "-a ",
|
diff_a_works ? "-a " : "",
|
||||||
"",
|
"",
|
||||||
(diff_flags & DIFF_IWHITE) ? "-b " : "",
|
(diff_flags & DIFF_IWHITE) ? "-b " : "",
|
||||||
(diff_flags & DIFF_ICASE) ? "-i " : "",
|
(diff_flags & DIFF_ICASE) ? "-i " : "",
|
||||||
tmp_orig, tmp_new);
|
tmp_orig, tmp_new);
|
||||||
append_redir(cmd, len, p_srr, tmp_diff);
|
append_redir(cmd, len, (char *) p_srr, tmp_diff);
|
||||||
block_autocmds(); // Avoid ShellCmdPost stuff
|
block_autocmds(); // Avoid ShellCmdPost stuff
|
||||||
(void)call_shell(
|
(void)call_shell((char_u *) cmd,
|
||||||
cmd,
|
kShellOptFilter | kShellOptSilent | kShellOptDoOut,
|
||||||
kShellOptFilter | kShellOptSilent | kShellOptDoOut,
|
NULL);
|
||||||
NULL
|
|
||||||
);
|
|
||||||
unblock_autocmds();
|
unblock_autocmds();
|
||||||
xfree(cmd);
|
xfree(cmd);
|
||||||
}
|
}
|
||||||
@ -902,9 +901,11 @@ void ex_diffpatch(exarg_T *eap)
|
|||||||
if (*p_pex != NUL) {
|
if (*p_pex != NUL) {
|
||||||
// Use 'patchexpr' to generate the new file.
|
// Use 'patchexpr' to generate the new file.
|
||||||
#ifdef UNIX
|
#ifdef UNIX
|
||||||
eval_patch(tmp_orig, fullname != NULL ? fullname : eap->arg, tmp_new);
|
eval_patch((char *) tmp_orig,
|
||||||
|
(char *) (fullname != NULL ? fullname : eap->arg),
|
||||||
|
(char *) tmp_new);
|
||||||
#else
|
#else
|
||||||
eval_patch(tmp_orig, eap->arg, tmp_new);
|
eval_patch((char *) tmp_orig, (char *) eap->arg, (char *) tmp_new);
|
||||||
#endif // ifdef UNIX
|
#endif // ifdef UNIX
|
||||||
} else {
|
} else {
|
||||||
// Build the patch command and execute it. Ignore errors. Switch to
|
// Build the patch command and execute it. Ignore errors. Switch to
|
||||||
|
@ -199,7 +199,7 @@ typedef struct insert_state {
|
|||||||
int did_restart_edit; // remember if insert mode was restarted
|
int did_restart_edit; // remember if insert mode was restarted
|
||||||
// after a ctrl+o
|
// after a ctrl+o
|
||||||
bool nomove;
|
bool nomove;
|
||||||
uint8_t *ptr;
|
char_u *ptr;
|
||||||
} InsertState;
|
} InsertState;
|
||||||
|
|
||||||
|
|
||||||
@ -270,8 +270,8 @@ static void insert_enter(InsertState *s)
|
|||||||
s->ptr = (char_u *)"i";
|
s->ptr = (char_u *)"i";
|
||||||
}
|
}
|
||||||
|
|
||||||
set_vim_var_string(VV_INSERTMODE, s->ptr, 1);
|
set_vim_var_string(VV_INSERTMODE, (char *) s->ptr, 1);
|
||||||
set_vim_var_string(VV_CHAR, NULL, -1); /* clear v:char */
|
set_vim_var_string(VV_CHAR, NULL, -1);
|
||||||
apply_autocmds(EVENT_INSERTENTER, NULL, NULL, false, curbuf);
|
apply_autocmds(EVENT_INSERTENTER, NULL, NULL, false, curbuf);
|
||||||
|
|
||||||
// Make sure the cursor didn't move. Do call check_cursor_col() in
|
// Make sure the cursor didn't move. Do call check_cursor_col() in
|
||||||
@ -7239,15 +7239,15 @@ static void ins_insert(int replaceState)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
set_vim_var_string(VV_INSERTMODE,
|
set_vim_var_string(VV_INSERTMODE, ((State & REPLACE_FLAG) ? "i" :
|
||||||
(char_u *)((State & REPLACE_FLAG) ? "i" :
|
replaceState == VREPLACE ? "v" :
|
||||||
replaceState == VREPLACE ? "v" :
|
"r"), 1);
|
||||||
"r"), 1);
|
apply_autocmds(EVENT_INSERTCHANGE, NULL, NULL, false, curbuf);
|
||||||
apply_autocmds(EVENT_INSERTCHANGE, NULL, NULL, FALSE, curbuf);
|
if (State & REPLACE_FLAG) {
|
||||||
if (State & REPLACE_FLAG)
|
|
||||||
State = INSERT | (State & LANGMAP);
|
State = INSERT | (State & LANGMAP);
|
||||||
else
|
} else {
|
||||||
State = replaceState | (State & LANGMAP);
|
State = replaceState | (State & LANGMAP);
|
||||||
|
}
|
||||||
AppendCharToRedobuff(K_INS);
|
AppendCharToRedobuff(K_INS);
|
||||||
showmode();
|
showmode();
|
||||||
ui_cursor_shape(); /* may show different cursor shape */
|
ui_cursor_shape(); /* may show different cursor shape */
|
||||||
@ -8480,22 +8480,22 @@ static colnr_T get_nolist_virtcol(void)
|
|||||||
*/
|
*/
|
||||||
static char_u *do_insert_char_pre(int c)
|
static char_u *do_insert_char_pre(int c)
|
||||||
{
|
{
|
||||||
char_u buf[MB_MAXBYTES + 1];
|
char buf[MB_MAXBYTES + 1];
|
||||||
|
|
||||||
// Return quickly when there is nothing to do.
|
// Return quickly when there is nothing to do.
|
||||||
if (!has_event(EVENT_INSERTCHARPRE)) {
|
if (!has_event(EVENT_INSERTCHARPRE)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (has_mbyte) {
|
if (has_mbyte) {
|
||||||
buf[(*mb_char2bytes)(c, buf)] = NUL;
|
buf[(*mb_char2bytes)(c, (char_u *) buf)] = NUL;
|
||||||
} else {
|
} else {
|
||||||
buf[0] = c;
|
buf[0] = c;
|
||||||
buf[1] = NUL;
|
buf[1] = NUL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Lock the text to avoid weird things from happening. */
|
// Lock the text to avoid weird things from happening.
|
||||||
++textlock;
|
textlock++;
|
||||||
set_vim_var_string(VV_CHAR, buf, -1); /* set v:char */
|
set_vim_var_string(VV_CHAR, buf, -1);
|
||||||
|
|
||||||
char_u *res = NULL;
|
char_u *res = NULL;
|
||||||
if (apply_autocmds(EVENT_INSERTCHARPRE, NULL, NULL, FALSE, curbuf)) {
|
if (apply_autocmds(EVENT_INSERTCHARPRE, NULL, NULL, FALSE, curbuf)) {
|
||||||
@ -8506,8 +8506,8 @@ static char_u *do_insert_char_pre(int c)
|
|||||||
res = vim_strsave(get_vim_var_str(VV_CHAR));
|
res = vim_strsave(get_vim_var_str(VV_CHAR));
|
||||||
}
|
}
|
||||||
|
|
||||||
set_vim_var_string(VV_CHAR, NULL, -1); /* clear v:char */
|
set_vim_var_string(VV_CHAR, NULL, -1);
|
||||||
--textlock;
|
textlock--;
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
165
src/nvim/eval.c
165
src/nvim/eval.c
@ -465,6 +465,8 @@ const list_T *eval_msgpack_type_lists[] = {
|
|||||||
*/
|
*/
|
||||||
void eval_init(void)
|
void eval_init(void)
|
||||||
{
|
{
|
||||||
|
vimvars[VV_VERSION].vv_nr = VIM_VERSION_100;
|
||||||
|
|
||||||
jobs = pmap_new(uint64_t)();
|
jobs = pmap_new(uint64_t)();
|
||||||
struct vimvar *p;
|
struct vimvar *p;
|
||||||
|
|
||||||
@ -768,45 +770,50 @@ void var_redir_stop(void)
|
|||||||
redir_varname = NULL;
|
redir_varname = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int eval_charconvert(char_u *enc_from, char_u *enc_to, char_u *fname_from, char_u *fname_to)
|
int eval_charconvert(const char *const enc_from, const char *const enc_to,
|
||||||
|
const char *const fname_from, const char *const fname_to)
|
||||||
{
|
{
|
||||||
int err = FALSE;
|
int err = false;
|
||||||
|
|
||||||
set_vim_var_string(VV_CC_FROM, enc_from, -1);
|
set_vim_var_string(VV_CC_FROM, enc_from, -1);
|
||||||
set_vim_var_string(VV_CC_TO, enc_to, -1);
|
set_vim_var_string(VV_CC_TO, enc_to, -1);
|
||||||
set_vim_var_string(VV_FNAME_IN, fname_from, -1);
|
set_vim_var_string(VV_FNAME_IN, fname_from, -1);
|
||||||
set_vim_var_string(VV_FNAME_OUT, fname_to, -1);
|
set_vim_var_string(VV_FNAME_OUT, fname_to, -1);
|
||||||
if (eval_to_bool(p_ccv, &err, NULL, FALSE))
|
if (eval_to_bool(p_ccv, &err, NULL, false)) {
|
||||||
err = TRUE;
|
err = true;
|
||||||
|
}
|
||||||
set_vim_var_string(VV_CC_FROM, NULL, -1);
|
set_vim_var_string(VV_CC_FROM, NULL, -1);
|
||||||
set_vim_var_string(VV_CC_TO, NULL, -1);
|
set_vim_var_string(VV_CC_TO, NULL, -1);
|
||||||
set_vim_var_string(VV_FNAME_IN, NULL, -1);
|
set_vim_var_string(VV_FNAME_IN, NULL, -1);
|
||||||
set_vim_var_string(VV_FNAME_OUT, NULL, -1);
|
set_vim_var_string(VV_FNAME_OUT, NULL, -1);
|
||||||
|
|
||||||
if (err)
|
|
||||||
return FAIL;
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
int eval_printexpr(char_u *fname, char_u *args)
|
|
||||||
{
|
|
||||||
int err = FALSE;
|
|
||||||
|
|
||||||
set_vim_var_string(VV_FNAME_IN, fname, -1);
|
|
||||||
set_vim_var_string(VV_CMDARG, args, -1);
|
|
||||||
if (eval_to_bool(p_pexpr, &err, NULL, FALSE))
|
|
||||||
err = TRUE;
|
|
||||||
set_vim_var_string(VV_FNAME_IN, NULL, -1);
|
|
||||||
set_vim_var_string(VV_CMDARG, NULL, -1);
|
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
os_remove((char *)fname);
|
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void eval_diff(char_u *origfile, char_u *newfile, char_u *outfile)
|
int eval_printexpr(const char *const fname, const char *const args)
|
||||||
|
{
|
||||||
|
int err = false;
|
||||||
|
|
||||||
|
set_vim_var_string(VV_FNAME_IN, fname, -1);
|
||||||
|
set_vim_var_string(VV_CMDARG, args, -1);
|
||||||
|
if (eval_to_bool(p_pexpr, &err, NULL, false)) {
|
||||||
|
err = true;
|
||||||
|
}
|
||||||
|
set_vim_var_string(VV_FNAME_IN, NULL, -1);
|
||||||
|
set_vim_var_string(VV_CMDARG, NULL, -1);
|
||||||
|
|
||||||
|
if (err) {
|
||||||
|
os_remove(fname);
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void eval_diff(const char *const origfile, const char *const newfile,
|
||||||
|
const char *const outfile)
|
||||||
{
|
{
|
||||||
int err = FALSE;
|
int err = FALSE;
|
||||||
|
|
||||||
@ -819,7 +826,8 @@ void eval_diff(char_u *origfile, char_u *newfile, char_u *outfile)
|
|||||||
set_vim_var_string(VV_FNAME_OUT, NULL, -1);
|
set_vim_var_string(VV_FNAME_OUT, NULL, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void eval_patch(char_u *origfile, char_u *difffile, char_u *outfile)
|
void eval_patch(const char *const origfile, const char *const difffile,
|
||||||
|
const char *const outfile)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
@ -17083,20 +17091,6 @@ static int eval_isnamec1(int c)
|
|||||||
return ASCII_ISALPHA(c) || c == '_';
|
return ASCII_ISALPHA(c) || c == '_';
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Set number v: variable to "val".
|
|
||||||
*/
|
|
||||||
void set_vim_var_nr(int idx, long val)
|
|
||||||
{
|
|
||||||
vimvars[idx].vv_nr = val;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Set special v: variable to "val"
|
|
||||||
void set_vim_var_special(const int idx, const SpecialVarValue val)
|
|
||||||
{
|
|
||||||
vimvars[idx].vv_special = val;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get number v: variable value.
|
* Get number v: variable value.
|
||||||
*/
|
*/
|
||||||
@ -17134,11 +17128,11 @@ dict_T *get_vim_var_dict(int idx) FUNC_ATTR_PURE
|
|||||||
*/
|
*/
|
||||||
void set_vim_var_char(int c)
|
void set_vim_var_char(int c)
|
||||||
{
|
{
|
||||||
char_u buf[MB_MAXBYTES + 1];
|
char buf[MB_MAXBYTES + 1];
|
||||||
|
|
||||||
if (has_mbyte)
|
if (has_mbyte) {
|
||||||
buf[(*mb_char2bytes)(c, buf)] = NUL;
|
buf[(*mb_char2bytes)(c, (char_u *) buf)] = NUL;
|
||||||
else {
|
} else {
|
||||||
buf[0] = c;
|
buf[0] = c;
|
||||||
buf[1] = NUL;
|
buf[1] = NUL;
|
||||||
}
|
}
|
||||||
@ -17157,47 +17151,68 @@ void set_vcount(long count, long count1, int set_prevcount)
|
|||||||
vimvars[VV_COUNT1].vv_nr = count1;
|
vimvars[VV_COUNT1].vv_nr = count1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/// Set number v: variable to the given value
|
||||||
* Set string v: variable to a copy of "val".
|
///
|
||||||
*/
|
/// @param[in] idx Index of variable to set.
|
||||||
void set_vim_var_string (
|
/// @param[in] val Value to set to.
|
||||||
int idx,
|
void set_vim_var_nr(const VimVarIndex idx, const varnumber_T val)
|
||||||
char_u *val,
|
|
||||||
int len /* length of "val" to use or -1 (whole string) */
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
/* Need to do this (at least) once, since we can't initialize a union.
|
vimvars[idx].vv_nr = val;
|
||||||
* Will always be invoked when "v:progname" is set. */
|
|
||||||
vimvars[VV_VERSION].vv_nr = VIM_VERSION_100;
|
|
||||||
|
|
||||||
xfree(vimvars[idx].vv_str);
|
|
||||||
if (val == NULL)
|
|
||||||
vimvars[idx].vv_str = NULL;
|
|
||||||
else if (len == -1)
|
|
||||||
vimvars[idx].vv_str = vim_strsave(val);
|
|
||||||
else
|
|
||||||
vimvars[idx].vv_str = vim_strnsave(val, len);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/// Set special v: variable to the given value
|
||||||
* Set List v: variable to "val".
|
///
|
||||||
*/
|
/// @param[in] idx Index of variable to set.
|
||||||
void set_vim_var_list(int idx, list_T *val)
|
/// @param[in] val Value to set to.
|
||||||
|
void set_vim_var_special(const VimVarIndex idx, const SpecialVarValue val)
|
||||||
|
{
|
||||||
|
vimvars[idx].vv_special = val;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Set string v: variable to the given string
|
||||||
|
///
|
||||||
|
/// @param[in] idx Index of variable to set.
|
||||||
|
/// @param[in] val Value to set to. Will be copied.
|
||||||
|
/// @param[in] len Legth of that value or -1 in which case strlen() will be
|
||||||
|
/// used.
|
||||||
|
void set_vim_var_string(const VimVarIndex idx, const char *const val,
|
||||||
|
const ptrdiff_t len)
|
||||||
|
{
|
||||||
|
xfree(vimvars[idx].vv_str);
|
||||||
|
if (val == NULL) {
|
||||||
|
vimvars[idx].vv_str = NULL;
|
||||||
|
} else if (len == -1) {
|
||||||
|
vimvars[idx].vv_str = (char_u *) xstrdup(val);
|
||||||
|
} else {
|
||||||
|
vimvars[idx].vv_str = (char_u *) xstrndup(val, (size_t) len);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Set list v: variable to the given list
|
||||||
|
///
|
||||||
|
/// @param[in] idx Index of variable to set.
|
||||||
|
/// @param[in,out] val Value to set to. Reference count will be incremented.
|
||||||
|
void set_vim_var_list(const VimVarIndex idx, list_T *const val)
|
||||||
{
|
{
|
||||||
list_unref(vimvars[idx].vv_list);
|
list_unref(vimvars[idx].vv_list);
|
||||||
vimvars[idx].vv_list = val;
|
vimvars[idx].vv_list = val;
|
||||||
if (val != NULL)
|
if (val != NULL) {
|
||||||
++val->lv_refcount;
|
val->lv_refcount++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set Dictionary v: variable to "val".
|
/// Set Dictionary v: variable to the given dictionary
|
||||||
void set_vim_var_dict(int idx, dict_T *val)
|
///
|
||||||
|
/// @param[in] idx Index of variable to set.
|
||||||
|
/// @param[in,out] val Value to set to. Reference count will be incremented.
|
||||||
|
/// Also keys of the dictionary will be made read-only.
|
||||||
|
void set_vim_var_dict(const VimVarIndex idx, dict_T *const val)
|
||||||
{
|
{
|
||||||
dict_unref(vimvars[idx].vv_dict);
|
dict_unref(vimvars[idx].vv_dict);
|
||||||
vimvars[idx].vv_dict = val;
|
vimvars[idx].vv_dict = val;
|
||||||
|
|
||||||
if (val != NULL) {
|
if (val != NULL) {
|
||||||
++val->dv_refcount;
|
val->dv_refcount++;
|
||||||
// Set readonly
|
// Set readonly
|
||||||
dict_set_keys_readonly(val);
|
dict_set_keys_readonly(val);
|
||||||
}
|
}
|
||||||
@ -17208,15 +17223,17 @@ void set_vim_var_dict(int idx, dict_T *val)
|
|||||||
*/
|
*/
|
||||||
void set_reg_var(int c)
|
void set_reg_var(int c)
|
||||||
{
|
{
|
||||||
char_u regname;
|
char regname;
|
||||||
|
|
||||||
if (c == 0 || c == ' ')
|
if (c == 0 || c == ' ') {
|
||||||
regname = '"';
|
regname = '"';
|
||||||
else
|
} else {
|
||||||
regname = c;
|
regname = c;
|
||||||
/* Avoid free/alloc when the value is already right. */
|
}
|
||||||
if (vimvars[VV_REG].vv_str == NULL || vimvars[VV_REG].vv_str[0] != c)
|
// Avoid free/alloc when the value is already right.
|
||||||
|
if (vimvars[VV_REG].vv_str == NULL || vimvars[VV_REG].vv_str[0] != c) {
|
||||||
set_vim_var_string(VV_REG, ®name, 1);
|
set_vim_var_string(VV_REG, ®name, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -575,8 +575,8 @@ parse_json_number_check:
|
|||||||
tv.vval.v_number = (varnumber_T) nr;
|
tv.vval.v_number = (varnumber_T) nr;
|
||||||
}
|
}
|
||||||
if (json_decoder_pop(OBJ(tv, false, *didcomma, *didcolon),
|
if (json_decoder_pop(OBJ(tv, false, *didcomma, *didcolon),
|
||||||
stack, container_stack,
|
stack, container_stack,
|
||||||
&p, next_map_special, didcomma, didcolon) == FAIL) {
|
&p, next_map_special, didcomma, didcolon) == FAIL) {
|
||||||
goto parse_json_number_fail;
|
goto parse_json_number_fail;
|
||||||
}
|
}
|
||||||
if (*next_map_special) {
|
if (*next_map_special) {
|
||||||
|
@ -1326,15 +1326,17 @@ char_u *make_filter_cmd(char_u *cmd, char_u *itmp, char_u *otmp)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
size_t len = STRLEN(cmd) + 1; // At least enough space for cmd + NULL.
|
size_t len = STRLEN(cmd) + 1; // At least enough space for cmd + NULL.
|
||||||
|
|
||||||
len += is_fish_shell ? sizeof("begin; ""; end") - 1
|
len += is_fish_shell ? sizeof("begin; ""; end") - 1
|
||||||
: sizeof("("")") - 1;
|
: sizeof("("")") - 1;
|
||||||
|
|
||||||
if (itmp != NULL)
|
if (itmp != NULL) {
|
||||||
len += STRLEN(itmp) + sizeof(" { "" < "" } ") - 1;
|
len += STRLEN(itmp) + sizeof(" { "" < "" } ") - 1;
|
||||||
if (otmp != NULL)
|
}
|
||||||
|
if (otmp != NULL) {
|
||||||
len += STRLEN(otmp) + STRLEN(p_srr) + 2; // two extra spaces (" "),
|
len += STRLEN(otmp) + STRLEN(p_srr) + 2; // two extra spaces (" "),
|
||||||
char_u *buf = xmalloc(len);
|
}
|
||||||
|
char *const buf = xmalloc(len);
|
||||||
|
|
||||||
#if defined(UNIX)
|
#if defined(UNIX)
|
||||||
// Put delimiters around the command (for concatenated commands) when
|
// Put delimiters around the command (for concatenated commands) when
|
||||||
@ -1342,19 +1344,19 @@ char_u *make_filter_cmd(char_u *cmd, char_u *itmp, char_u *otmp)
|
|||||||
if (itmp != NULL || otmp != NULL) {
|
if (itmp != NULL || otmp != NULL) {
|
||||||
char *fmt = is_fish_shell ? "begin; %s; end"
|
char *fmt = is_fish_shell ? "begin; %s; end"
|
||||||
: "(%s)";
|
: "(%s)";
|
||||||
vim_snprintf((char *)buf, len, fmt, (char *)cmd);
|
vim_snprintf(buf, len, fmt, (char *)cmd);
|
||||||
} else {
|
} else {
|
||||||
STRCPY(buf, cmd);
|
strncpy(buf, (char *) cmd, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (itmp != NULL) {
|
if (itmp != NULL) {
|
||||||
STRCAT(buf, " < ");
|
strncat(buf, " < ", len);
|
||||||
STRCAT(buf, itmp);
|
strncat(buf, (char *) itmp, len);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
// For shells that don't understand braces around commands, at least allow
|
// For shells that don't understand braces around commands, at least allow
|
||||||
// the use of commands in a pipe.
|
// the use of commands in a pipe.
|
||||||
STRCPY(buf, cmd);
|
strncpy(buf, cmd, len);
|
||||||
if (itmp != NULL) {
|
if (itmp != NULL) {
|
||||||
char_u *p;
|
char_u *p;
|
||||||
|
|
||||||
@ -1362,55 +1364,56 @@ char_u *make_filter_cmd(char_u *cmd, char_u *itmp, char_u *otmp)
|
|||||||
// Don't do this when 'shellquote' is not empty, otherwise the
|
// Don't do this when 'shellquote' is not empty, otherwise the
|
||||||
// redirection would be inside the quotes.
|
// redirection would be inside the quotes.
|
||||||
if (*p_shq == NUL) {
|
if (*p_shq == NUL) {
|
||||||
p = vim_strchr(buf, '|');
|
p = strchr(buf, '|');
|
||||||
if (p != NULL)
|
|
||||||
*p = NUL;
|
|
||||||
}
|
|
||||||
STRCAT(buf, " < ");
|
|
||||||
STRCAT(buf, itmp);
|
|
||||||
if (*p_shq == NUL) {
|
|
||||||
p = vim_strchr(cmd, '|');
|
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
STRCAT(buf, " "); // Insert a space before the '|' for DOS
|
*p = NUL;
|
||||||
STRCAT(buf, p);
|
}
|
||||||
|
}
|
||||||
|
strncat(buf, " < ", len);
|
||||||
|
strncat(buf, (char *) itmp, len);
|
||||||
|
if (*p_shq == NUL) {
|
||||||
|
p = strchr(cmd, '|');
|
||||||
|
if (p != NULL) {
|
||||||
|
strncat(buf, " ", len); // Insert a space before the '|' for DOS
|
||||||
|
strncat(buf, p, len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (otmp != NULL) {
|
if (otmp != NULL) {
|
||||||
append_redir(buf, len, p_srr, otmp);
|
append_redir(buf, len, (char *) p_srr, (char *) otmp);
|
||||||
}
|
}
|
||||||
return buf;
|
return (char_u *) buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/// Append output redirection for the given file to the end of the buffer
|
||||||
* Append output redirection for file "fname" to the end of string buffer
|
///
|
||||||
* "buf[buflen]"
|
/// @param[out] buf Buffer to append to.
|
||||||
* Works with the 'shellredir' and 'shellpipe' options.
|
/// @param[in] buflen Buffer length.
|
||||||
* The caller should make sure that there is enough room:
|
/// @param[in] opt Separator or format string to append: will append
|
||||||
* STRLEN(opt) + STRLEN(fname) + 3
|
/// `printf(' ' . opt, fname)` if `%s` is found in `opt` or
|
||||||
*/
|
/// a space, opt, a space and then fname if `%s` is not found
|
||||||
void append_redir(char_u *buf, size_t buflen, char_u *opt, char_u *fname)
|
/// there.
|
||||||
|
/// @param[in] fname File name to append.
|
||||||
|
void append_redir(char *const buf, const size_t buflen,
|
||||||
|
const char *const opt, const char *const fname)
|
||||||
{
|
{
|
||||||
char_u *p;
|
char *const end = buf + strlen(buf);
|
||||||
char_u *end;
|
// find "%s"
|
||||||
|
const char *p = opt;
|
||||||
end = buf + STRLEN(buf);
|
for (; (p = strchr(p, '%')) != NULL; p++) {
|
||||||
/* find "%s" */
|
if (p[1] == 's') { // found %s
|
||||||
for (p = opt; (p = vim_strchr(p, '%')) != NULL; ++p) {
|
|
||||||
if (p[1] == 's') /* found %s */
|
|
||||||
break;
|
break;
|
||||||
if (p[1] == '%') /* skip %% */
|
} else if (p[1] == '%') { // skip %%
|
||||||
++p;
|
p++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
*end = ' '; /* not really needed? Not with sh, ksh or bash */
|
*end = ' '; // not really needed? Not with sh, ksh or bash
|
||||||
vim_snprintf((char *)end + 1, (size_t)(buflen - (end + 1 - buf)),
|
vim_snprintf(end + 1, (size_t) (buflen - (end + 1 - buf)), opt, fname);
|
||||||
(char *)opt, (char *)fname);
|
} else {
|
||||||
} else
|
vim_snprintf(end, (size_t) (buflen - (end - buf)), " %s %s", opt, fname);
|
||||||
vim_snprintf((char *)end, (size_t)(buflen - (end - buf)),
|
}
|
||||||
" %s %s",
|
|
||||||
(char *)opt, (char *)fname);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_line_no_prefix(linenr_T lnum, int use_number, int list)
|
void print_line_no_prefix(linenr_T lnum, int use_number, int list)
|
||||||
@ -2093,15 +2096,13 @@ do_ecmd (
|
|||||||
|
|
||||||
if ((command != NULL || newlnum > (linenr_T)0)
|
if ((command != NULL || newlnum > (linenr_T)0)
|
||||||
&& *get_vim_var_str(VV_SWAPCOMMAND) == NUL) {
|
&& *get_vim_var_str(VV_SWAPCOMMAND) == NUL) {
|
||||||
char_u *p;
|
// Set v:swapcommand for the SwapExists autocommands.
|
||||||
|
const size_t len = (command != NULL) ? STRLEN(command) + 3 : 30;
|
||||||
/* Set v:swapcommand for the SwapExists autocommands. */
|
char *const p = xmalloc(len);
|
||||||
size_t len = (command != NULL) ? STRLEN(command) + 3 : 30;
|
|
||||||
p = xmalloc(len);
|
|
||||||
if (command != NULL) {
|
if (command != NULL) {
|
||||||
vim_snprintf((char *)p, len, ":%s\r", command);
|
vim_snprintf(p, len, ":%s\r", command);
|
||||||
} else {
|
} else {
|
||||||
vim_snprintf((char *)p, len, "%" PRId64 "G", (int64_t)newlnum);
|
vim_snprintf(p, len, "%" PRId64 "G", (int64_t)newlnum);
|
||||||
}
|
}
|
||||||
set_vim_var_string(VV_SWAPCOMMAND, p, -1);
|
set_vim_var_string(VV_SWAPCOMMAND, p, -1);
|
||||||
did_set_swapcommand = TRUE;
|
did_set_swapcommand = TRUE;
|
||||||
|
@ -3168,27 +3168,27 @@ static char_u *get_mess_env(void)
|
|||||||
*/
|
*/
|
||||||
void set_lang_var(void)
|
void set_lang_var(void)
|
||||||
{
|
{
|
||||||
char_u *loc;
|
const char *loc;
|
||||||
|
|
||||||
# ifdef HAVE_GET_LOCALE_VAL
|
# ifdef HAVE_GET_LOCALE_VAL
|
||||||
loc = (char_u *)get_locale_val(LC_CTYPE);
|
loc = get_locale_val(LC_CTYPE);
|
||||||
# else
|
# else
|
||||||
/* setlocale() not supported: use the default value */
|
// setlocale() not supported: use the default value
|
||||||
loc = (char_u *)"C";
|
loc = "C";
|
||||||
# endif
|
# endif
|
||||||
set_vim_var_string(VV_CTYPE, loc, -1);
|
set_vim_var_string(VV_CTYPE, loc, -1);
|
||||||
|
|
||||||
/* When LC_MESSAGES isn't defined use the value from $LC_MESSAGES, fall
|
/* When LC_MESSAGES isn't defined use the value from $LC_MESSAGES, fall
|
||||||
* back to LC_CTYPE if it's empty. */
|
* back to LC_CTYPE if it's empty. */
|
||||||
# ifdef HAVE_WORKING_LIBINTL
|
# ifdef HAVE_WORKING_LIBINTL
|
||||||
loc = get_mess_env();
|
loc = (char *) get_mess_env();
|
||||||
# else
|
# else
|
||||||
loc = (char_u *)get_locale_val(LC_MESSAGES);
|
loc = get_locale_val(LC_MESSAGES);
|
||||||
# endif
|
# endif
|
||||||
set_vim_var_string(VV_LANG, loc, -1);
|
set_vim_var_string(VV_LANG, loc, -1);
|
||||||
|
|
||||||
# ifdef HAVE_GET_LOCALE_VAL
|
# ifdef HAVE_GET_LOCALE_VAL
|
||||||
loc = (char_u *)get_locale_val(LC_TIME);
|
loc = get_locale_val(LC_TIME);
|
||||||
# endif
|
# endif
|
||||||
set_vim_var_string(VV_LC_TIME, loc, -1);
|
set_vim_var_string(VV_LC_TIME, loc, -1);
|
||||||
}
|
}
|
||||||
|
@ -7421,10 +7421,10 @@ static int mksession_nl = FALSE; /* use NL only in put_eol() */
|
|||||||
static void ex_mkrc(exarg_T *eap)
|
static void ex_mkrc(exarg_T *eap)
|
||||||
{
|
{
|
||||||
FILE *fd;
|
FILE *fd;
|
||||||
int failed = FALSE;
|
int failed = false;
|
||||||
int view_session = FALSE;
|
int view_session = false;
|
||||||
int using_vdir = FALSE; /* using 'viewdir'? */
|
int using_vdir = false; // using 'viewdir'?
|
||||||
char_u *viewFile = NULL;
|
char *viewFile = NULL;
|
||||||
unsigned *flagp;
|
unsigned *flagp;
|
||||||
|
|
||||||
if (eap->cmdidx == CMD_mksession || eap->cmdidx == CMD_mkview) {
|
if (eap->cmdidx == CMD_mksession || eap->cmdidx == CMD_mkview) {
|
||||||
@ -7435,32 +7435,34 @@ static void ex_mkrc(exarg_T *eap)
|
|||||||
* short file name when 'acd' is set, that is checked later. */
|
* short file name when 'acd' is set, that is checked later. */
|
||||||
did_lcd = FALSE;
|
did_lcd = FALSE;
|
||||||
|
|
||||||
char_u *fname;
|
char *fname;
|
||||||
/* ":mkview" or ":mkview 9": generate file name with 'viewdir' */
|
// ":mkview" or ":mkview 9": generate file name with 'viewdir'
|
||||||
if (eap->cmdidx == CMD_mkview
|
if (eap->cmdidx == CMD_mkview
|
||||||
&& (*eap->arg == NUL
|
&& (*eap->arg == NUL
|
||||||
|| (ascii_isdigit(*eap->arg) && eap->arg[1] == NUL))) {
|
|| (ascii_isdigit(*eap->arg) && eap->arg[1] == NUL))) {
|
||||||
eap->forceit = TRUE;
|
eap->forceit = true;
|
||||||
fname = (char_u *)get_view_file(*eap->arg);
|
fname = get_view_file(*eap->arg);
|
||||||
if (fname == NULL)
|
if (fname == NULL) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
viewFile = fname;
|
viewFile = fname;
|
||||||
using_vdir = TRUE;
|
using_vdir = true;
|
||||||
} else if (*eap->arg != NUL)
|
} else if (*eap->arg != NUL) {
|
||||||
fname = eap->arg;
|
fname = (char *) eap->arg;
|
||||||
else if (eap->cmdidx == CMD_mkvimrc)
|
} else if (eap->cmdidx == CMD_mkvimrc) {
|
||||||
fname = (char_u *)VIMRC_FILE;
|
fname = VIMRC_FILE;
|
||||||
else if (eap->cmdidx == CMD_mksession)
|
} else if (eap->cmdidx == CMD_mksession) {
|
||||||
fname = (char_u *)SESSION_FILE;
|
fname = SESSION_FILE;
|
||||||
else
|
} else {
|
||||||
fname = (char_u *)EXRC_FILE;
|
fname = EXRC_FILE;
|
||||||
|
}
|
||||||
|
|
||||||
/* When using 'viewdir' may have to create the directory. */
|
/* When using 'viewdir' may have to create the directory. */
|
||||||
if (using_vdir && !os_isdir(p_vdir)) {
|
if (using_vdir && !os_isdir(p_vdir)) {
|
||||||
vim_mkdir_emsg(p_vdir, 0755);
|
vim_mkdir_emsg(p_vdir, 0755);
|
||||||
}
|
}
|
||||||
|
|
||||||
fd = open_exfile(fname, eap->forceit, WRITEBIN);
|
fd = open_exfile((char_u *) fname, eap->forceit, WRITEBIN);
|
||||||
if (fd != NULL) {
|
if (fd != NULL) {
|
||||||
if (eap->cmdidx == CMD_mkview)
|
if (eap->cmdidx == CMD_mkview)
|
||||||
flagp = &vop_flags;
|
flagp = &vop_flags;
|
||||||
@ -7504,8 +7506,9 @@ static void ex_mkrc(exarg_T *eap)
|
|||||||
|| os_chdir((char *)dirnow) != 0)
|
|| os_chdir((char *)dirnow) != 0)
|
||||||
*dirnow = NUL;
|
*dirnow = NUL;
|
||||||
if (*dirnow != NUL && (ssop_flags & SSOP_SESDIR)) {
|
if (*dirnow != NUL && (ssop_flags & SSOP_SESDIR)) {
|
||||||
if (vim_chdirfile(fname) == OK)
|
if (vim_chdirfile((char_u *) fname) == OK) {
|
||||||
shorten_fnames(TRUE);
|
shorten_fnames(true);
|
||||||
|
}
|
||||||
} else if (*dirnow != NUL
|
} else if (*dirnow != NUL
|
||||||
&& (ssop_flags & SSOP_CURDIR) && globaldir != NULL) {
|
&& (ssop_flags & SSOP_CURDIR) && globaldir != NULL) {
|
||||||
if (os_chdir((char *)globaldir) == 0)
|
if (os_chdir((char *)globaldir) == 0)
|
||||||
@ -7550,15 +7553,14 @@ static void ex_mkrc(exarg_T *eap)
|
|||||||
|
|
||||||
failed |= fclose(fd);
|
failed |= fclose(fd);
|
||||||
|
|
||||||
if (failed)
|
if (failed) {
|
||||||
EMSG(_(e_write));
|
EMSG(_(e_write));
|
||||||
else if (eap->cmdidx == CMD_mksession) {
|
} else if (eap->cmdidx == CMD_mksession) {
|
||||||
/* successful session write - set this_session var */
|
// successful session write - set this_session var
|
||||||
char_u *tbuf;
|
char *const tbuf = xmalloc(MAXPATHL);
|
||||||
|
if (vim_FullName(fname, tbuf, MAXPATHL, false) == OK) {
|
||||||
tbuf = xmalloc(MAXPATHL);
|
|
||||||
if (vim_FullName((char *)fname, (char *)tbuf, MAXPATHL, FALSE) == OK)
|
|
||||||
set_vim_var_string(VV_THIS_SESSION, tbuf, -1);
|
set_vim_var_string(VV_THIS_SESSION, tbuf, -1);
|
||||||
|
}
|
||||||
xfree(tbuf);
|
xfree(tbuf);
|
||||||
}
|
}
|
||||||
#ifdef MKSESSION_NL
|
#ifdef MKSESSION_NL
|
||||||
|
@ -569,17 +569,19 @@ static void catch_exception(except_T *excp)
|
|||||||
{
|
{
|
||||||
excp->caught = caught_stack;
|
excp->caught = caught_stack;
|
||||||
caught_stack = excp;
|
caught_stack = excp;
|
||||||
set_vim_var_string(VV_EXCEPTION, excp->value, -1);
|
set_vim_var_string(VV_EXCEPTION, (char *) excp->value, -1);
|
||||||
if (*excp->throw_name != NUL) {
|
if (*excp->throw_name != NUL) {
|
||||||
if (excp->throw_lnum != 0)
|
if (excp->throw_lnum != 0) {
|
||||||
vim_snprintf((char *)IObuff, IOSIZE, _("%s, line %" PRId64),
|
vim_snprintf((char *)IObuff, IOSIZE, _("%s, line %" PRId64),
|
||||||
excp->throw_name, (int64_t)excp->throw_lnum);
|
excp->throw_name, (int64_t)excp->throw_lnum);
|
||||||
else
|
} else {
|
||||||
vim_snprintf((char *)IObuff, IOSIZE, "%s", excp->throw_name);
|
vim_snprintf((char *)IObuff, IOSIZE, "%s", excp->throw_name);
|
||||||
set_vim_var_string(VV_THROWPOINT, IObuff, -1);
|
}
|
||||||
} else
|
set_vim_var_string(VV_THROWPOINT, (char *) IObuff, -1);
|
||||||
/* throw_name not set on an exception from a command that was typed. */
|
} else {
|
||||||
|
// throw_name not set on an exception from a command that was typed.
|
||||||
set_vim_var_string(VV_THROWPOINT, NULL, -1);
|
set_vim_var_string(VV_THROWPOINT, NULL, -1);
|
||||||
|
}
|
||||||
|
|
||||||
if (p_verbose >= 13 || debug_break_level > 0) {
|
if (p_verbose >= 13 || debug_break_level > 0) {
|
||||||
int save_msg_silent = msg_silent;
|
int save_msg_silent = msg_silent;
|
||||||
@ -614,20 +616,22 @@ static void finish_exception(except_T *excp)
|
|||||||
EMSG(_(e_internal));
|
EMSG(_(e_internal));
|
||||||
caught_stack = caught_stack->caught;
|
caught_stack = caught_stack->caught;
|
||||||
if (caught_stack != NULL) {
|
if (caught_stack != NULL) {
|
||||||
set_vim_var_string(VV_EXCEPTION, caught_stack->value, -1);
|
set_vim_var_string(VV_EXCEPTION, (char *) caught_stack->value, -1);
|
||||||
if (*caught_stack->throw_name != NUL) {
|
if (*caught_stack->throw_name != NUL) {
|
||||||
if (caught_stack->throw_lnum != 0)
|
if (caught_stack->throw_lnum != 0) {
|
||||||
vim_snprintf((char *)IObuff, IOSIZE,
|
vim_snprintf((char *)IObuff, IOSIZE,
|
||||||
_("%s, line %" PRId64), caught_stack->throw_name,
|
_("%s, line %" PRId64), caught_stack->throw_name,
|
||||||
(int64_t)caught_stack->throw_lnum);
|
(int64_t)caught_stack->throw_lnum);
|
||||||
else
|
} else {
|
||||||
vim_snprintf((char *)IObuff, IOSIZE, "%s",
|
vim_snprintf((char *)IObuff, IOSIZE, "%s",
|
||||||
caught_stack->throw_name);
|
caught_stack->throw_name);
|
||||||
set_vim_var_string(VV_THROWPOINT, IObuff, -1);
|
}
|
||||||
} else
|
set_vim_var_string(VV_THROWPOINT, (char *) IObuff, -1);
|
||||||
/* throw_name not set on an exception from a command that was
|
} else {
|
||||||
* typed. */
|
// throw_name not set on an exception from a command that was
|
||||||
|
// typed.
|
||||||
set_vim_var_string(VV_THROWPOINT, NULL, -1);
|
set_vim_var_string(VV_THROWPOINT, NULL, -1);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
set_vim_var_string(VV_EXCEPTION, NULL, -1);
|
set_vim_var_string(VV_EXCEPTION, NULL, -1);
|
||||||
set_vim_var_string(VV_THROWPOINT, NULL, -1);
|
set_vim_var_string(VV_THROWPOINT, NULL, -1);
|
||||||
|
@ -2139,9 +2139,10 @@ readfile_charconvert (
|
|||||||
else {
|
else {
|
||||||
close(*fdp); /* close the input file, ignore errors */
|
close(*fdp); /* close the input file, ignore errors */
|
||||||
*fdp = -1;
|
*fdp = -1;
|
||||||
if (eval_charconvert(fenc, enc_utf8 ? (char_u *)"utf-8" : p_enc,
|
if (eval_charconvert((char *) fenc, enc_utf8 ? "utf-8" : (char *) p_enc,
|
||||||
fname, tmpname) == FAIL)
|
(char *) fname, (char *) tmpname) == FAIL) {
|
||||||
errmsg = (char_u *)_("Conversion with 'charconvert' failed");
|
errmsg = (char_u *)_("Conversion with 'charconvert' failed");
|
||||||
|
}
|
||||||
if (errmsg == NULL && (*fdp = os_open((char *)tmpname, O_RDONLY, 0)) < 0) {
|
if (errmsg == NULL && (*fdp = os_open((char *)tmpname, O_RDONLY, 0)) < 0) {
|
||||||
errmsg = (char_u *)_("can't read output of 'charconvert'");
|
errmsg = (char_u *)_("can't read output of 'charconvert'");
|
||||||
}
|
}
|
||||||
@ -3435,9 +3436,9 @@ restore_backup:
|
|||||||
* with 'charconvert' to (overwrite) the output file.
|
* with 'charconvert' to (overwrite) the output file.
|
||||||
*/
|
*/
|
||||||
if (end != 0) {
|
if (end != 0) {
|
||||||
if (eval_charconvert(enc_utf8 ? (char_u *)"utf-8" : p_enc, fenc,
|
if (eval_charconvert(enc_utf8 ? "utf-8" : (char *) p_enc, (char *) fenc,
|
||||||
wfname, fname) == FAIL) {
|
(char *) wfname, (char *) fname) == FAIL) {
|
||||||
write_info.bw_conv_error = TRUE;
|
write_info.bw_conv_error = true;
|
||||||
end = 0;
|
end = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4740,7 +4741,6 @@ buf_check_timestamp (
|
|||||||
{
|
{
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
char_u *path;
|
char_u *path;
|
||||||
char_u *tbuf;
|
|
||||||
char *mesg = NULL;
|
char *mesg = NULL;
|
||||||
char *mesg2 = "";
|
char *mesg2 = "";
|
||||||
int helpmesg = FALSE;
|
int helpmesg = FALSE;
|
||||||
@ -4810,14 +4810,12 @@ buf_check_timestamp (
|
|||||||
else
|
else
|
||||||
reason = "time";
|
reason = "time";
|
||||||
|
|
||||||
/*
|
// Only give the warning if there are no FileChangedShell
|
||||||
* Only give the warning if there are no FileChangedShell
|
// autocommands.
|
||||||
* autocommands.
|
// Avoid being called recursively by setting "busy".
|
||||||
* Avoid being called recursively by setting "busy".
|
busy = true;
|
||||||
*/
|
set_vim_var_string(VV_FCS_REASON, reason, -1);
|
||||||
busy = TRUE;
|
set_vim_var_string(VV_FCS_CHOICE, "", -1);
|
||||||
set_vim_var_string(VV_FCS_REASON, (char_u *)reason, -1);
|
|
||||||
set_vim_var_string(VV_FCS_CHOICE, (char_u *)"", -1);
|
|
||||||
++allbuf_lock;
|
++allbuf_lock;
|
||||||
n = apply_autocmds(EVENT_FILECHANGEDSHELL,
|
n = apply_autocmds(EVENT_FILECHANGEDSHELL,
|
||||||
buf->b_fname, buf->b_fname, FALSE, buf);
|
buf->b_fname, buf->b_fname, FALSE, buf);
|
||||||
@ -4876,35 +4874,39 @@ buf_check_timestamp (
|
|||||||
|
|
||||||
if (mesg != NULL) {
|
if (mesg != NULL) {
|
||||||
path = home_replace_save(buf, buf->b_fname);
|
path = home_replace_save(buf, buf->b_fname);
|
||||||
if (!helpmesg)
|
if (!helpmesg) {
|
||||||
mesg2 = "";
|
mesg2 = "";
|
||||||
tbuf = xmalloc(STRLEN(path) + STRLEN(mesg) + STRLEN(mesg2) + 2);
|
}
|
||||||
sprintf((char *)tbuf, mesg, path);
|
const size_t tbuf_len = STRLEN(path) + STRLEN(mesg) + STRLEN(mesg2) + 2;
|
||||||
/* Set warningmsg here, before the unimportant and output-specific
|
char *const tbuf = xmalloc(tbuf_len);
|
||||||
* mesg2 has been appended. */
|
snprintf(tbuf, tbuf_len, mesg, path);
|
||||||
|
// Set warningmsg here, before the unimportant and output-specific
|
||||||
|
// mesg2 has been appended.
|
||||||
set_vim_var_string(VV_WARNINGMSG, tbuf, -1);
|
set_vim_var_string(VV_WARNINGMSG, tbuf, -1);
|
||||||
if (can_reload) {
|
if (can_reload) {
|
||||||
if (*mesg2 != NUL) {
|
if (*mesg2 != NUL) {
|
||||||
STRCAT(tbuf, "\n");
|
strncat(tbuf, "\n", tbuf_len);
|
||||||
STRCAT(tbuf, mesg2);
|
strncat(tbuf, mesg2, tbuf_len);
|
||||||
|
}
|
||||||
|
if (do_dialog(VIM_WARNING, (char_u *) _("Warning"), (char_u *) tbuf,
|
||||||
|
(char_u *) _("&OK\n&Load File"), 1, NULL, true) == 2) {
|
||||||
|
reload = true;
|
||||||
}
|
}
|
||||||
if (do_dialog(VIM_WARNING, (char_u *)_("Warning"), tbuf,
|
|
||||||
(char_u *)_("&OK\n&Load File"), 1, NULL, TRUE) == 2)
|
|
||||||
reload = TRUE;
|
|
||||||
} else if (State > NORMAL_BUSY || (State & CMDLINE) || already_warned) {
|
} else if (State > NORMAL_BUSY || (State & CMDLINE) || already_warned) {
|
||||||
if (*mesg2 != NUL) {
|
if (*mesg2 != NUL) {
|
||||||
STRCAT(tbuf, "; ");
|
strncat(tbuf, "; ", tbuf_len);
|
||||||
STRCAT(tbuf, mesg2);
|
strncat(tbuf, mesg2, tbuf_len);
|
||||||
}
|
}
|
||||||
EMSG(tbuf);
|
EMSG(tbuf);
|
||||||
retval = 2;
|
retval = 2;
|
||||||
} else {
|
} else {
|
||||||
if (!autocmd_busy) {
|
if (!autocmd_busy) {
|
||||||
msg_start();
|
msg_start();
|
||||||
msg_puts_attr(tbuf, hl_attr(HLF_E) + MSG_HIST);
|
msg_puts_attr((char_u *) tbuf, hl_attr(HLF_E) + MSG_HIST);
|
||||||
if (*mesg2 != NUL)
|
if (*mesg2 != NUL) {
|
||||||
msg_puts_attr((char_u *)mesg2,
|
msg_puts_attr((char_u *)mesg2,
|
||||||
hl_attr(HLF_W) + MSG_HIST);
|
hl_attr(HLF_W) + MSG_HIST);
|
||||||
|
}
|
||||||
msg_clr_eos();
|
msg_clr_eos();
|
||||||
(void)msg_end();
|
(void)msg_end();
|
||||||
if (emsg_silent == 0) {
|
if (emsg_silent == 0) {
|
||||||
|
@ -1699,14 +1699,14 @@ char_u *get_foldtext(win_T *wp, linenr_T lnum, linenr_T lnume,
|
|||||||
did_emsg = FALSE;
|
did_emsg = FALSE;
|
||||||
|
|
||||||
if (*wp->w_p_fdt != NUL) {
|
if (*wp->w_p_fdt != NUL) {
|
||||||
char_u dashes[MAX_LEVEL + 2];
|
char dashes[MAX_LEVEL + 2];
|
||||||
win_T *save_curwin;
|
win_T *save_curwin;
|
||||||
int level;
|
int level;
|
||||||
char_u *p;
|
char_u *p;
|
||||||
|
|
||||||
/* Set "v:foldstart" and "v:foldend". */
|
// Set "v:foldstart" and "v:foldend".
|
||||||
set_vim_var_nr(VV_FOLDSTART, lnum);
|
set_vim_var_nr(VV_FOLDSTART, (varnumber_T) lnum);
|
||||||
set_vim_var_nr(VV_FOLDEND, lnume);
|
set_vim_var_nr(VV_FOLDEND, (varnumber_T) lnume);
|
||||||
|
|
||||||
/* Set "v:folddashes" to a string of "level" dashes. */
|
/* Set "v:folddashes" to a string of "level" dashes. */
|
||||||
/* Set "v:foldlevel" to "level". */
|
/* Set "v:foldlevel" to "level". */
|
||||||
@ -1716,7 +1716,7 @@ char_u *get_foldtext(win_T *wp, linenr_T lnum, linenr_T lnume,
|
|||||||
memset(dashes, '-', (size_t)level);
|
memset(dashes, '-', (size_t)level);
|
||||||
dashes[level] = NUL;
|
dashes[level] = NUL;
|
||||||
set_vim_var_string(VV_FOLDDASHES, dashes, -1);
|
set_vim_var_string(VV_FOLDDASHES, dashes, -1);
|
||||||
set_vim_var_nr(VV_FOLDLEVEL, (long)level);
|
set_vim_var_nr(VV_FOLDLEVEL, (varnumber_T) level);
|
||||||
|
|
||||||
/* skip evaluating foldtext on errors */
|
/* skip evaluating foldtext on errors */
|
||||||
if (!got_fdt_error) {
|
if (!got_fdt_error) {
|
||||||
@ -2676,7 +2676,7 @@ static void foldlevelExpr(fline_T *flp)
|
|||||||
win = curwin;
|
win = curwin;
|
||||||
curwin = flp->wp;
|
curwin = flp->wp;
|
||||||
curbuf = flp->wp->w_buffer;
|
curbuf = flp->wp->w_buffer;
|
||||||
set_vim_var_nr(VV_LNUM, lnum);
|
set_vim_var_nr(VV_LNUM, (varnumber_T) lnum);
|
||||||
|
|
||||||
flp->start = 0;
|
flp->start = 0;
|
||||||
flp->had_end = flp->end;
|
flp->had_end = flp->end;
|
||||||
|
@ -2780,11 +2780,13 @@ void mch_print_end(prt_settings_T *psettings)
|
|||||||
}
|
}
|
||||||
prt_message((char_u *)_("Sending to printer..."));
|
prt_message((char_u *)_("Sending to printer..."));
|
||||||
|
|
||||||
/* Not printing to a file: use 'printexpr' to print the file. */
|
// Not printing to a file: use 'printexpr' to print the file.
|
||||||
if (eval_printexpr(prt_ps_file_name, psettings->arguments) == FAIL)
|
if (eval_printexpr((char *) prt_ps_file_name, (char *) psettings->arguments)
|
||||||
|
== FAIL) {
|
||||||
EMSG(_("E365: Failed to print PostScript file"));
|
EMSG(_("E365: Failed to print PostScript file"));
|
||||||
else
|
} else {
|
||||||
prt_message((char_u *)_("Print job sent."));
|
prt_message((char_u *)_("Print job sent."));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mch_print_cleanup();
|
mch_print_cleanup();
|
||||||
|
@ -529,7 +529,7 @@ int get_expr_indent(void)
|
|||||||
save_pos = curwin->w_cursor;
|
save_pos = curwin->w_cursor;
|
||||||
save_curswant = curwin->w_curswant;
|
save_curswant = curwin->w_curswant;
|
||||||
save_set_curswant = curwin->w_set_curswant;
|
save_set_curswant = curwin->w_set_curswant;
|
||||||
set_vim_var_nr(VV_LNUM, curwin->w_cursor.lnum);
|
set_vim_var_nr(VV_LNUM, (varnumber_T) curwin->w_cursor.lnum);
|
||||||
|
|
||||||
if (use_sandbox) {
|
if (use_sandbox) {
|
||||||
sandbox++;
|
sandbox++;
|
||||||
|
@ -238,8 +238,8 @@ int main(int argc, char **argv)
|
|||||||
check_and_set_isatty(¶ms);
|
check_and_set_isatty(¶ms);
|
||||||
|
|
||||||
// Get the name with which Nvim was invoked, with and without path.
|
// Get the name with which Nvim was invoked, with and without path.
|
||||||
set_vim_var_string(VV_PROGPATH, (char_u *)argv[0], -1);
|
set_vim_var_string(VV_PROGPATH, argv[0], -1);
|
||||||
set_vim_var_string(VV_PROGNAME, path_tail((char_u *)argv[0]), -1);
|
set_vim_var_string(VV_PROGNAME, (char *) path_tail((char_u *) argv[0]), -1);
|
||||||
|
|
||||||
event_init();
|
event_init();
|
||||||
/*
|
/*
|
||||||
@ -1141,10 +1141,11 @@ scripterror:
|
|||||||
/* If there is a "+123" or "-c" command, set v:swapcommand to the first
|
/* If there is a "+123" or "-c" command, set v:swapcommand to the first
|
||||||
* one. */
|
* one. */
|
||||||
if (parmp->n_commands > 0) {
|
if (parmp->n_commands > 0) {
|
||||||
p = xmalloc(STRLEN(parmp->commands[0]) + 3);
|
const size_t swcmd_len = STRLEN(parmp->commands[0]) + 3;
|
||||||
sprintf((char *)p, ":%s\r", parmp->commands[0]);
|
char *const swcmd = xmalloc(swcmd_len);
|
||||||
set_vim_var_string(VV_SWAPCOMMAND, p, -1);
|
snprintf(swcmd, swcmd_len, ":%s\r", parmp->commands[0]);
|
||||||
xfree(p);
|
set_vim_var_string(VV_SWAPCOMMAND, swcmd, -1);
|
||||||
|
xfree(swcmd);
|
||||||
}
|
}
|
||||||
TIME_MSG("parsing arguments");
|
TIME_MSG("parsing arguments");
|
||||||
}
|
}
|
||||||
|
@ -3194,7 +3194,7 @@ attention_message (
|
|||||||
*/
|
*/
|
||||||
static int do_swapexists(buf_T *buf, char_u *fname)
|
static int do_swapexists(buf_T *buf, char_u *fname)
|
||||||
{
|
{
|
||||||
set_vim_var_string(VV_SWAPNAME, fname, -1);
|
set_vim_var_string(VV_SWAPNAME, (char *) fname, -1);
|
||||||
set_vim_var_string(VV_SWAPCHOICE, NULL, -1);
|
set_vim_var_string(VV_SWAPCHOICE, NULL, -1);
|
||||||
|
|
||||||
/* Trigger SwapExists autocommands with <afile> set to the file being
|
/* Trigger SwapExists autocommands with <afile> set to the file being
|
||||||
|
@ -143,10 +143,11 @@ msg_attr_keep (
|
|||||||
{
|
{
|
||||||
static int entered = 0;
|
static int entered = 0;
|
||||||
int retval;
|
int retval;
|
||||||
char_u *buf = NULL;
|
char_u *buf = NULL;
|
||||||
|
|
||||||
if (attr == 0)
|
if (attr == 0) {
|
||||||
set_vim_var_string(VV_STATUSMSG, s, -1);
|
set_vim_var_string(VV_STATUSMSG, (char *) s, -1);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* It is possible that displaying a messages causes a problem (e.g.,
|
* It is possible that displaying a messages causes a problem (e.g.,
|
||||||
@ -497,8 +498,8 @@ int emsg(char_u *s)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set "v:errmsg", also when using ":silent! cmd" */
|
// set "v:errmsg", also when using ":silent! cmd"
|
||||||
set_vim_var_string(VV_ERRMSG, s, -1);
|
set_vim_var_string(VV_ERRMSG, (char *) s, -1);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* When using ":silent! cmd" ignore error messages.
|
* When using ":silent! cmd" ignore error messages.
|
||||||
@ -1755,25 +1756,24 @@ static void msg_scroll_up(void)
|
|||||||
static void inc_msg_scrolled(void)
|
static void inc_msg_scrolled(void)
|
||||||
{
|
{
|
||||||
if (*get_vim_var_str(VV_SCROLLSTART) == NUL) {
|
if (*get_vim_var_str(VV_SCROLLSTART) == NUL) {
|
||||||
char_u *p = sourcing_name;
|
char *p = (char *) sourcing_name;
|
||||||
char_u *tofree = NULL;
|
char *tofree = NULL;
|
||||||
int len;
|
|
||||||
|
|
||||||
/* v:scrollstart is empty, set it to the script/function name and line
|
// v:scrollstart is empty, set it to the script/function name and line
|
||||||
* number */
|
// number
|
||||||
if (p == NULL)
|
if (p == NULL) {
|
||||||
p = (char_u *)_("Unknown");
|
p = _("Unknown");
|
||||||
else {
|
} else {
|
||||||
len = (int)STRLEN(p) + 40;
|
size_t len = strlen(p) + 40;
|
||||||
tofree = xmalloc(len);
|
tofree = xmalloc(len);
|
||||||
vim_snprintf((char *)tofree, len, _("%s line %" PRId64),
|
vim_snprintf(tofree, len, _("%s line %" PRId64),
|
||||||
p, (int64_t)sourcing_lnum);
|
p, (int64_t) sourcing_lnum);
|
||||||
p = tofree;
|
p = tofree;
|
||||||
}
|
}
|
||||||
set_vim_var_string(VV_SCROLLSTART, p, -1);
|
set_vim_var_string(VV_SCROLLSTART, p, -1);
|
||||||
xfree(tofree);
|
xfree(tofree);
|
||||||
}
|
}
|
||||||
++msg_scrolled;
|
msg_scrolled++;
|
||||||
}
|
}
|
||||||
|
|
||||||
static msgchunk_T *last_msgchunk = NULL; /* last displayed text */
|
static msgchunk_T *last_msgchunk = NULL; /* last displayed text */
|
||||||
@ -2540,7 +2540,7 @@ void give_warning(char_u *message, bool hl) FUNC_ATTR_NONNULL_ARG(1)
|
|||||||
/* Don't want a hit-enter prompt here. */
|
/* Don't want a hit-enter prompt here. */
|
||||||
++no_wait_return;
|
++no_wait_return;
|
||||||
|
|
||||||
set_vim_var_string(VV_WARNINGMSG, message, -1);
|
set_vim_var_string(VV_WARNINGMSG, (char *) message, -1);
|
||||||
xfree(keep_msg);
|
xfree(keep_msg);
|
||||||
keep_msg = NULL;
|
keep_msg = NULL;
|
||||||
if (hl)
|
if (hl)
|
||||||
@ -3054,7 +3054,7 @@ int vim_snprintf_add(char *str, size_t str_m, char *fmt, ...)
|
|||||||
return str_l;
|
return str_l;
|
||||||
}
|
}
|
||||||
|
|
||||||
int vim_snprintf(char *str, size_t str_m, char *fmt, ...)
|
int vim_snprintf(char *str, size_t str_m, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
int str_l;
|
int str_l;
|
||||||
|
@ -2250,7 +2250,7 @@ change_warning (
|
|||||||
msg_col = col;
|
msg_col = col;
|
||||||
msg_source(hl_attr(HLF_W));
|
msg_source(hl_attr(HLF_W));
|
||||||
MSG_PUTS_ATTR(_(w_readonly), hl_attr(HLF_W) | MSG_HIST);
|
MSG_PUTS_ATTR(_(w_readonly), hl_attr(HLF_W) | MSG_HIST);
|
||||||
set_vim_var_string(VV_WARNINGMSG, (char_u *)_(w_readonly), -1);
|
set_vim_var_string(VV_WARNINGMSG, _(w_readonly), -1);
|
||||||
msg_clr_eos();
|
msg_clr_eos();
|
||||||
(void)msg_end();
|
(void)msg_end();
|
||||||
if (msg_silent == 0 && !silent_mode) {
|
if (msg_silent == 0 && !silent_mode) {
|
||||||
|
@ -327,9 +327,10 @@ int call_shell(char_u *cmd, ShellOpts opts, char_u *extra_shell_arg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
set_vim_var_nr(VV_SHELL_ERROR, (long)retval);
|
set_vim_var_nr(VV_SHELL_ERROR, (varnumber_T) retval);
|
||||||
if (do_profiling == PROF_YES)
|
if (do_profiling == PROF_YES) {
|
||||||
prof_child_exit(&wait_time);
|
prof_child_exit(&wait_time);
|
||||||
|
}
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ static void set_vservername(garray_T *srvs)
|
|||||||
char *default_server = (srvs->ga_len > 0)
|
char *default_server = (srvs->ga_len > 0)
|
||||||
? ((SocketWatcher **)srvs->ga_data)[0]->addr
|
? ((SocketWatcher **)srvs->ga_data)[0]->addr
|
||||||
: NULL;
|
: NULL;
|
||||||
set_vim_var_string(VV_SEND_SERVER, (char_u *)default_server, -1);
|
set_vim_var_string(VV_SEND_SERVER, default_server, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Teardown the server module
|
/// Teardown the server module
|
||||||
|
@ -7057,18 +7057,17 @@ static void nv_operator(cmdarg_T *cap)
|
|||||||
*/
|
*/
|
||||||
static void set_op_var(int optype)
|
static void set_op_var(int optype)
|
||||||
{
|
{
|
||||||
char_u opchars[3];
|
if (optype == OP_NOP) {
|
||||||
|
|
||||||
if (optype == OP_NOP)
|
|
||||||
set_vim_var_string(VV_OP, NULL, 0);
|
set_vim_var_string(VV_OP, NULL, 0);
|
||||||
else {
|
} else {
|
||||||
|
char opchars[3];
|
||||||
int opchar0 = get_op_char(optype);
|
int opchar0 = get_op_char(optype);
|
||||||
assert(opchar0 >= 0 && opchar0 <= UCHAR_MAX);
|
assert(opchar0 >= 0 && opchar0 <= UCHAR_MAX);
|
||||||
opchars[0] = (char_u)opchar0;
|
opchars[0] = (char) opchar0;
|
||||||
|
|
||||||
int opchar1 = get_extra_op_char(optype);
|
int opchar1 = get_extra_op_char(optype);
|
||||||
assert(opchar1 >= 0 && opchar1 <= UCHAR_MAX);
|
assert(opchar1 >= 0 && opchar1 <= UCHAR_MAX);
|
||||||
opchars[1] = (char_u)opchar1;
|
opchars[1] = (char) opchar1;
|
||||||
|
|
||||||
opchars[2] = NUL;
|
opchars[2] = NUL;
|
||||||
set_vim_var_string(VV_OP, opchars, -1);
|
set_vim_var_string(VV_OP, opchars, -1);
|
||||||
|
@ -1448,7 +1448,7 @@ do_set (
|
|||||||
char_u *oldval = NULL; // previous value if *varp
|
char_u *oldval = NULL; // previous value if *varp
|
||||||
char_u *newval;
|
char_u *newval;
|
||||||
char_u *origval = NULL;
|
char_u *origval = NULL;
|
||||||
char_u *saved_origval = NULL;
|
char *saved_origval = NULL;
|
||||||
unsigned newlen;
|
unsigned newlen;
|
||||||
int comma;
|
int comma;
|
||||||
int bs;
|
int bs;
|
||||||
@ -1725,7 +1725,7 @@ do_set (
|
|||||||
if (!starting && origval != NULL) {
|
if (!starting && origval != NULL) {
|
||||||
// origval may be freed by
|
// origval may be freed by
|
||||||
// did_set_string_option(), make a copy.
|
// did_set_string_option(), make a copy.
|
||||||
saved_origval = vim_strsave(origval);
|
saved_origval = xstrdup((char *) origval);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Handle side effects, and set the global value for
|
/* Handle side effects, and set the global value for
|
||||||
@ -1740,11 +1740,10 @@ do_set (
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (saved_origval != NULL) {
|
if (saved_origval != NULL) {
|
||||||
char_u buf_type[7];
|
char buf_type[7];
|
||||||
vim_snprintf((char *)buf_type, ARRAY_SIZE(buf_type), "%s",
|
vim_snprintf(buf_type, ARRAY_SIZE(buf_type), "%s",
|
||||||
(opt_flags & OPT_LOCAL) ? "local" : "global");
|
(opt_flags & OPT_LOCAL) ? "local" : "global");
|
||||||
set_vim_var_string(VV_OPTION_NEW,
|
set_vim_var_string(VV_OPTION_NEW, *(char **) varp, -1);
|
||||||
*(char_u **)varp, -1);
|
|
||||||
set_vim_var_string(VV_OPTION_OLD, saved_origval, -1);
|
set_vim_var_string(VV_OPTION_OLD, saved_origval, -1);
|
||||||
set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
|
set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
|
||||||
apply_autocmds(EVENT_OPTIONSET,
|
apply_autocmds(EVENT_OPTIONSET,
|
||||||
@ -2324,7 +2323,7 @@ set_string_option (
|
|||||||
char_u *s;
|
char_u *s;
|
||||||
char_u **varp;
|
char_u **varp;
|
||||||
char_u *oldval;
|
char_u *oldval;
|
||||||
char_u *saved_oldval = NULL;
|
char *saved_oldval = NULL;
|
||||||
char_u *r = NULL;
|
char_u *r = NULL;
|
||||||
|
|
||||||
if (options[opt_idx].var == NULL) /* don't set hidden option */
|
if (options[opt_idx].var == NULL) /* don't set hidden option */
|
||||||
@ -2340,7 +2339,7 @@ set_string_option (
|
|||||||
*varp = s;
|
*varp = s;
|
||||||
|
|
||||||
if (!starting) {
|
if (!starting) {
|
||||||
saved_oldval = vim_strsave(oldval);
|
saved_oldval = xstrdup((char *) oldval);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((r = did_set_string_option(opt_idx, varp, (int)true, oldval, NULL,
|
if ((r = did_set_string_option(opt_idx, varp, (int)true, oldval, NULL,
|
||||||
@ -2349,10 +2348,10 @@ set_string_option (
|
|||||||
|
|
||||||
// call autocommand after handling side effects
|
// call autocommand after handling side effects
|
||||||
if (saved_oldval != NULL) {
|
if (saved_oldval != NULL) {
|
||||||
char_u buf_type[7];
|
char buf_type[7];
|
||||||
vim_snprintf((char *)buf_type, ARRAY_SIZE(buf_type), "%s",
|
vim_snprintf(buf_type, ARRAY_SIZE(buf_type), "%s",
|
||||||
(opt_flags & OPT_LOCAL) ? "local" : "global");
|
(opt_flags & OPT_LOCAL) ? "local" : "global");
|
||||||
set_vim_var_string(VV_OPTION_NEW, *varp, -1);
|
set_vim_var_string(VV_OPTION_NEW, (char *) (*varp), -1);
|
||||||
set_vim_var_string(VV_OPTION_OLD, saved_oldval, -1);
|
set_vim_var_string(VV_OPTION_OLD, saved_oldval, -1);
|
||||||
set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
|
set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
|
||||||
apply_autocmds(EVENT_OPTIONSET,
|
apply_autocmds(EVENT_OPTIONSET,
|
||||||
@ -3800,7 +3799,7 @@ set_bool_option (
|
|||||||
|
|
||||||
msg_source(hl_attr(HLF_W));
|
msg_source(hl_attr(HLF_W));
|
||||||
MSG_ATTR(_(w_arabic), hl_attr(HLF_W));
|
MSG_ATTR(_(w_arabic), hl_attr(HLF_W));
|
||||||
set_vim_var_string(VV_WARNINGMSG, (char_u *)_(w_arabic), -1);
|
set_vim_var_string(VV_WARNINGMSG, _(w_arabic), -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set 'delcombine' */
|
/* set 'delcombine' */
|
||||||
@ -3847,14 +3846,14 @@ set_bool_option (
|
|||||||
options[opt_idx].flags |= P_WAS_SET;
|
options[opt_idx].flags |= P_WAS_SET;
|
||||||
|
|
||||||
if (!starting) {
|
if (!starting) {
|
||||||
char_u buf_old[2];
|
char buf_old[2];
|
||||||
char_u buf_new[2];
|
char buf_new[2];
|
||||||
char_u buf_type[7];
|
char buf_type[7];
|
||||||
vim_snprintf((char *)buf_old, ARRAY_SIZE(buf_old), "%d",
|
vim_snprintf(buf_old, ARRAY_SIZE(buf_old), "%d",
|
||||||
old_value ? true: false);
|
old_value ? true: false);
|
||||||
vim_snprintf((char *)buf_new, ARRAY_SIZE(buf_new), "%d",
|
vim_snprintf(buf_new, ARRAY_SIZE(buf_new), "%d",
|
||||||
value ? true: false);
|
value ? true: false);
|
||||||
vim_snprintf((char *)buf_type, ARRAY_SIZE(buf_type), "%s",
|
vim_snprintf(buf_type, ARRAY_SIZE(buf_type), "%s",
|
||||||
(opt_flags & OPT_LOCAL) ? "local" : "global");
|
(opt_flags & OPT_LOCAL) ? "local" : "global");
|
||||||
set_vim_var_string(VV_OPTION_NEW, buf_new, -1);
|
set_vim_var_string(VV_OPTION_NEW, buf_new, -1);
|
||||||
set_vim_var_string(VV_OPTION_OLD, buf_old, -1);
|
set_vim_var_string(VV_OPTION_OLD, buf_old, -1);
|
||||||
@ -4237,12 +4236,12 @@ set_num_option (
|
|||||||
options[opt_idx].flags |= P_WAS_SET;
|
options[opt_idx].flags |= P_WAS_SET;
|
||||||
|
|
||||||
if (!starting && errmsg == NULL) {
|
if (!starting && errmsg == NULL) {
|
||||||
char_u buf_old[NUMBUFLEN];
|
char buf_old[NUMBUFLEN];
|
||||||
char_u buf_new[NUMBUFLEN];
|
char buf_new[NUMBUFLEN];
|
||||||
char_u buf_type[7];
|
char buf_type[7];
|
||||||
vim_snprintf((char *)buf_old, ARRAY_SIZE(buf_old), "%ld", old_value);
|
vim_snprintf(buf_old, ARRAY_SIZE(buf_old), "%ld", old_value);
|
||||||
vim_snprintf((char *)buf_new, ARRAY_SIZE(buf_new), "%ld", value);
|
vim_snprintf(buf_new, ARRAY_SIZE(buf_new), "%ld", value);
|
||||||
vim_snprintf((char *)buf_type, ARRAY_SIZE(buf_type), "%s",
|
vim_snprintf(buf_type, ARRAY_SIZE(buf_type), "%s",
|
||||||
(opt_flags & OPT_LOCAL) ? "local" : "global");
|
(opt_flags & OPT_LOCAL) ? "local" : "global");
|
||||||
set_vim_var_string(VV_OPTION_NEW, buf_new, -1);
|
set_vim_var_string(VV_OPTION_NEW, buf_new, -1);
|
||||||
set_vim_var_string(VV_OPTION_OLD, buf_old, -1);
|
set_vim_var_string(VV_OPTION_OLD, buf_old, -1);
|
||||||
|
@ -1495,13 +1495,12 @@ void simplify_filename(char_u *filename)
|
|||||||
} while (*p != NUL);
|
} while (*p != NUL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char_u *eval_includeexpr(char_u *ptr, size_t len)
|
static char *eval_includeexpr(const char *const ptr, const size_t len)
|
||||||
{
|
{
|
||||||
assert(len <= INT_MAX);
|
set_vim_var_string(VV_FNAME, ptr, (ptrdiff_t) len);
|
||||||
set_vim_var_string(VV_FNAME, ptr, (int)len);
|
char *res = (char *) eval_to_string_safe(
|
||||||
char_u *res = eval_to_string_safe(curbuf->b_p_inex, NULL,
|
curbuf->b_p_inex, NULL, was_set_insecurely((char_u *)"includeexpr",
|
||||||
was_set_insecurely((char_u *)"includeexpr",
|
OPT_LOCAL));
|
||||||
OPT_LOCAL));
|
|
||||||
set_vim_var_string(VV_FNAME, NULL, 0);
|
set_vim_var_string(VV_FNAME, NULL, 0);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@ -1523,7 +1522,7 @@ find_file_name_in_path (
|
|||||||
char_u *tofree = NULL;
|
char_u *tofree = NULL;
|
||||||
|
|
||||||
if ((options & FNAME_INCL) && *curbuf->b_p_inex != NUL) {
|
if ((options & FNAME_INCL) && *curbuf->b_p_inex != NUL) {
|
||||||
tofree = eval_includeexpr(ptr, len);
|
tofree = (char_u *) eval_includeexpr((char *) ptr, len);
|
||||||
if (tofree != NULL) {
|
if (tofree != NULL) {
|
||||||
ptr = tofree;
|
ptr = tofree;
|
||||||
len = STRLEN(ptr);
|
len = STRLEN(ptr);
|
||||||
@ -1540,7 +1539,7 @@ find_file_name_in_path (
|
|||||||
*/
|
*/
|
||||||
if (file_name == NULL
|
if (file_name == NULL
|
||||||
&& !(options & FNAME_INCL) && *curbuf->b_p_inex != NUL) {
|
&& !(options & FNAME_INCL) && *curbuf->b_p_inex != NUL) {
|
||||||
tofree = eval_includeexpr(ptr, len);
|
tofree = (char_u *) eval_includeexpr((char *) ptr, len);
|
||||||
if (tofree != NULL) {
|
if (tofree != NULL) {
|
||||||
ptr = tofree;
|
ptr = tofree;
|
||||||
len = STRLEN(ptr);
|
len = STRLEN(ptr);
|
||||||
|
@ -2440,8 +2440,6 @@ int grep_internal(cmdidx_T cmdidx)
|
|||||||
void ex_make(exarg_T *eap)
|
void ex_make(exarg_T *eap)
|
||||||
{
|
{
|
||||||
char_u *fname;
|
char_u *fname;
|
||||||
char_u *cmd;
|
|
||||||
size_t len;
|
|
||||||
win_T *wp = NULL;
|
win_T *wp = NULL;
|
||||||
qf_info_T *qi = &ql_info;
|
qf_info_T *qi = &ql_info;
|
||||||
int res;
|
int res;
|
||||||
@ -2479,30 +2477,28 @@ void ex_make(exarg_T *eap)
|
|||||||
return;
|
return;
|
||||||
os_remove((char *)fname); // in case it's not unique
|
os_remove((char *)fname); // in case it's not unique
|
||||||
|
|
||||||
/*
|
// If 'shellpipe' empty: don't redirect to 'errorfile'.
|
||||||
* If 'shellpipe' empty: don't redirect to 'errorfile'.
|
const size_t len = (STRLEN(p_shq) * 2 + STRLEN(eap->arg) + 1
|
||||||
*/
|
+ (*p_sp == NUL
|
||||||
len = STRLEN(p_shq) * 2 + STRLEN(eap->arg) + 1;
|
? 0
|
||||||
|
: STRLEN(p_sp) + STRLEN(fname) + 3));
|
||||||
|
char *const cmd = xmalloc(len);
|
||||||
|
snprintf(cmd, len, "%s%s%s", (char *)p_shq, (char *)eap->arg,
|
||||||
|
(char *)p_shq);
|
||||||
if (*p_sp != NUL) {
|
if (*p_sp != NUL) {
|
||||||
len += STRLEN(p_sp) + STRLEN(fname) + 3;
|
append_redir(cmd, len, (char *) p_sp, (char *) fname);
|
||||||
|
}
|
||||||
|
// Output a newline if there's something else than the :make command that
|
||||||
|
// was typed (in which case the cursor is in column 0).
|
||||||
|
if (msg_col == 0) {
|
||||||
|
msg_didout = false;
|
||||||
}
|
}
|
||||||
cmd = xmalloc(len);
|
|
||||||
sprintf((char *)cmd, "%s%s%s", (char *)p_shq, (char *)eap->arg,
|
|
||||||
(char *)p_shq);
|
|
||||||
if (*p_sp != NUL)
|
|
||||||
append_redir(cmd, len, p_sp, fname);
|
|
||||||
/*
|
|
||||||
* Output a newline if there's something else than the :make command that
|
|
||||||
* was typed (in which case the cursor is in column 0).
|
|
||||||
*/
|
|
||||||
if (msg_col == 0)
|
|
||||||
msg_didout = FALSE;
|
|
||||||
msg_start();
|
msg_start();
|
||||||
MSG_PUTS(":!");
|
MSG_PUTS(":!");
|
||||||
msg_outtrans(cmd); /* show what we are doing */
|
msg_outtrans((char_u *) cmd); // show what we are doing
|
||||||
|
|
||||||
/* let the shell know if we are redirecting output or not */
|
// let the shell know if we are redirecting output or not
|
||||||
do_shell(cmd, *p_sp != NUL ? kShellOptDoOut : 0);
|
do_shell((char_u *) cmd, *p_sp != NUL ? kShellOptDoOut : 0);
|
||||||
|
|
||||||
|
|
||||||
res = qf_init(wp, fname, (eap->cmdidx != CMD_make
|
res = qf_init(wp, fname, (eap->cmdidx != CMD_make
|
||||||
|
@ -872,7 +872,7 @@ do_tag (
|
|||||||
|
|
||||||
/* Let the SwapExists event know what tag we are jumping to. */
|
/* Let the SwapExists event know what tag we are jumping to. */
|
||||||
vim_snprintf((char *)IObuff, IOSIZE, ":ta %s\r", name);
|
vim_snprintf((char *)IObuff, IOSIZE, ":ta %s\r", name);
|
||||||
set_vim_var_string(VV_SWAPCOMMAND, IObuff, -1);
|
set_vim_var_string(VV_SWAPCOMMAND, (char *) IObuff, -1);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Jump to the desired match.
|
* Jump to the desired match.
|
||||||
|
Loading…
Reference in New Issue
Block a user